diff --git a/__tests__/integration/gallery.spec.ts b/__tests__/integration/gallery.spec.ts index 3a8a594fb4..cc5e44ebd1 100644 --- a/__tests__/integration/gallery.spec.ts +++ b/__tests__/integration/gallery.spec.ts @@ -13,5 +13,5 @@ const TEST_CASES = [ ]; describe('Gallery Snapshot', () => { - generateCanvasTestCases('Gallery', TEST_CASES); + generateCanvasTestCases('gallery', TEST_CASES); }); diff --git a/__tests__/integration/heatmap.spec.ts b/__tests__/integration/heatmap.spec.ts index d45d075662..96c5ceb0c3 100644 --- a/__tests__/integration/heatmap.spec.ts +++ b/__tests__/integration/heatmap.spec.ts @@ -15,5 +15,5 @@ const TEST_CASES = [ ]; describe('Heatmap Snapshot', () => { - generateCanvasTestCases('Heatmap', TEST_CASES); + generateCanvasTestCases('heatmap', TEST_CASES); }); diff --git a/__tests__/integration/line.spec.ts b/__tests__/integration/line.spec.ts index 2d0817f1cd..d457d2b4a2 100644 --- a/__tests__/integration/line.spec.ts +++ b/__tests__/integration/line.spec.ts @@ -35,5 +35,5 @@ const TEST_CASES = [ ]; describe('Line Snapshot', () => { - generateCanvasTestCases('Line', TEST_CASES); + generateCanvasTestCases('line', TEST_CASES); }); diff --git a/__tests__/integration/mask.spec.ts b/__tests__/integration/mask.spec.ts index 5fc9456cf5..ad52db2ec3 100644 --- a/__tests__/integration/mask.spec.ts +++ b/__tests__/integration/mask.spec.ts @@ -11,5 +11,5 @@ const TEST_CASES = [ ]; describe('Mask Snapshot', () => { - generateCanvasTestCases('Mask', TEST_CASES); + generateCanvasTestCases('mask', TEST_CASES); }); diff --git a/__tests__/integration/point.spec.ts b/__tests__/integration/point.spec.ts index ae4c51dfd0..c5d54f76aa 100644 --- a/__tests__/integration/point.spec.ts +++ b/__tests__/integration/point.spec.ts @@ -16,7 +16,6 @@ const TEST_CASES = [ }, { name: 'fill_image', - sleepTime: 1000, }, { name: 'image', @@ -28,5 +27,5 @@ const TEST_CASES = [ ]; describe('Point Snapshot', () => { - generateCanvasTestCases('Point', TEST_CASES); + generateCanvasTestCases('point', TEST_CASES); }); diff --git a/__tests__/integration/polygon.spec.ts b/__tests__/integration/polygon.spec.ts index 4f166f1411..078576364b 100644 --- a/__tests__/integration/polygon.spec.ts +++ b/__tests__/integration/polygon.spec.ts @@ -27,5 +27,5 @@ const TEST_CASES = [ ]; describe('Polygon Snapshot', () => { - generateCanvasTestCases('Polygon', TEST_CASES); + generateCanvasTestCases('polygon', TEST_CASES); }); diff --git a/__tests__/integration/utils/generator.ts b/__tests__/integration/utils/generator.ts index 66eeea5b3d..eec536c9ab 100644 --- a/__tests__/integration/utils/generator.ts +++ b/__tests__/integration/utils/generator.ts @@ -1,14 +1,14 @@ -import type { Browser, BrowserContext, Page } from 'playwright'; +import type { Browser, BrowserContext } from 'playwright'; import { chromium, devices } from 'playwright'; import { sleep } from './sleep'; import './useSnapshotMatchers'; export function generateCanvasTestCases( namespace: string, - tests: { name: string; sleepTime?: number; snapshots?: boolean }[], + tests: { name: string; sleepTime?: number; snapshot?: boolean }[], ) { const port = (globalThis as any).PORT; - let browser: Browser, context: BrowserContext, page: Page; + let browser: Browser, context: BrowserContext; beforeAll(async () => { // Setup @@ -16,8 +16,6 @@ export function generateCanvasTestCases( args: ['--headless', '--no-sandbox'], }); context = await browser.newContext(devices['Desktop Chrome']); - page = await context.newPage(); - await context.exposeFunction('screenshot', () => {}); }); afterAll(async () => { @@ -26,15 +24,29 @@ export function generateCanvasTestCases( }); tests - .filter((test) => test.snapshots !== false) + .filter((test) => test.snapshot !== false) .map((test) => { const { name, sleepTime = 200 } = test; const key = `${namespace}_${name}`; it(key, async () => { + const page = await context.newPage(); + + let resolveReady: () => void; + const readyPromise = new Promise((resolve) => { + resolveReady = () => { + resolve(); + }; + }); + + await page.exposeFunction('screenshot', async () => { + resolveReady(); + }); + // Go to test page served by vite devServer. const url = `http://localhost:${port}/?namespace=${namespace}&name=${name}&snapshot=true`; await page.goto(url); + await readyPromise; await sleep(sleepTime); // Chart already rendered, capture into buffer. @@ -45,7 +57,7 @@ export function generateCanvasTestCases( try { expect(buffer).toMatchCanvasSnapshot(dir, key, { maxError }); } finally { - // + page.close(); } }); }); diff --git a/examples/demos_next/basemap/amap-data.ts b/examples/demos/basemap/amap-data.ts similarity index 100% rename from examples/demos_next/basemap/amap-data.ts rename to examples/demos/basemap/amap-data.ts diff --git a/examples/demos_next/basemap/index.ts b/examples/demos/basemap/index.ts similarity index 100% rename from examples/demos_next/basemap/index.ts rename to examples/demos/basemap/index.ts diff --git a/examples/demos_next/basemap/wgs84-data.ts b/examples/demos/basemap/wgs84-data.ts similarity index 100% rename from examples/demos_next/basemap/wgs84-data.ts rename to examples/demos/basemap/wgs84-data.ts diff --git a/examples/demos_next/bugfix/data-shake.ts b/examples/demos/bugfix/data-shake.ts similarity index 100% rename from examples/demos_next/bugfix/data-shake.ts rename to examples/demos/bugfix/data-shake.ts diff --git a/examples/demos_next/bugfix/index.ts b/examples/demos/bugfix/index.ts similarity index 100% rename from examples/demos_next/bugfix/index.ts rename to examples/demos/bugfix/index.ts diff --git a/examples/demos_next/bugfix/legend-event.ts b/examples/demos/bugfix/legend-event.ts similarity index 100% rename from examples/demos_next/bugfix/legend-event.ts rename to examples/demos/bugfix/legend-event.ts diff --git a/examples/demos_next/bugfix/muti-polygon.ts b/examples/demos/bugfix/muti-polygon.ts similarity index 100% rename from examples/demos_next/bugfix/muti-polygon.ts rename to examples/demos/bugfix/muti-polygon.ts diff --git a/examples/demos_next/bugfix/remove-muti-layer.ts b/examples/demos/bugfix/remove-muti-layer.ts similarity index 100% rename from examples/demos_next/bugfix/remove-muti-layer.ts rename to examples/demos/bugfix/remove-muti-layer.ts diff --git a/examples/demos_next/bugfix/set-color.ts b/examples/demos/bugfix/set-color.ts similarity index 100% rename from examples/demos_next/bugfix/set-color.ts rename to examples/demos/bugfix/set-color.ts diff --git a/examples/demos_next/bugfix/set-data.ts b/examples/demos/bugfix/set-data.ts similarity index 100% rename from examples/demos_next/bugfix/set-data.ts rename to examples/demos/bugfix/set-data.ts diff --git a/examples/demos_next/bugfix/set-size.ts b/examples/demos/bugfix/set-size.ts similarity index 100% rename from examples/demos_next/bugfix/set-size.ts rename to examples/demos/bugfix/set-size.ts diff --git a/examples/demos_next/bugfix/text-offsets.ts b/examples/demos/bugfix/text-offsets.ts similarity index 100% rename from examples/demos_next/bugfix/text-offsets.ts rename to examples/demos/bugfix/text-offsets.ts diff --git a/examples/demos_next/bugfix/tile-update.ts b/examples/demos/bugfix/tile-update.ts similarity index 100% rename from examples/demos_next/bugfix/tile-update.ts rename to examples/demos/bugfix/tile-update.ts diff --git a/examples/demos_next/bugfix/touch-event.ts b/examples/demos/bugfix/touch-event.ts similarity index 100% rename from examples/demos_next/bugfix/touch-event.ts rename to examples/demos/bugfix/touch-event.ts diff --git a/examples/demos_next/canvas/event.ts b/examples/demos/canvas/event.ts similarity index 100% rename from examples/demos_next/canvas/event.ts rename to examples/demos/canvas/event.ts diff --git a/examples/demos_next/canvas/index.ts b/examples/demos/canvas/index.ts similarity index 100% rename from examples/demos_next/canvas/index.ts rename to examples/demos/canvas/index.ts diff --git a/examples/demos_next/canvas/layer.ts b/examples/demos/canvas/layer.ts similarity index 100% rename from examples/demos_next/canvas/layer.ts rename to examples/demos/canvas/layer.ts diff --git a/examples/demos_next/components/index.ts b/examples/demos/components/index.ts similarity index 100% rename from examples/demos_next/components/index.ts rename to examples/demos/components/index.ts diff --git a/examples/demos_next/components/layer-popup.ts b/examples/demos/components/layer-popup.ts similarity index 100% rename from examples/demos_next/components/layer-popup.ts rename to examples/demos/components/layer-popup.ts diff --git a/examples/demos_next/components/marker.ts b/examples/demos/components/marker.ts similarity index 100% rename from examples/demos_next/components/marker.ts rename to examples/demos/components/marker.ts diff --git a/examples/demos_next/components/popup.ts b/examples/demos/components/popup.ts similarity index 100% rename from examples/demos_next/components/popup.ts rename to examples/demos/components/popup.ts diff --git a/examples/demos_next/components/swipe.ts b/examples/demos/components/swipe.ts similarity index 100% rename from examples/demos_next/components/swipe.ts rename to examples/demos/components/swipe.ts diff --git a/examples/demos_next/components/zoom.ts b/examples/demos/components/zoom.ts similarity index 100% rename from examples/demos_next/components/zoom.ts rename to examples/demos/components/zoom.ts diff --git a/examples/demos_next/extend/index.ts b/examples/demos/extend/index.ts similarity index 100% rename from examples/demos_next/extend/index.ts rename to examples/demos/extend/index.ts diff --git a/examples/demos_next/extend/three-geometry.ts b/examples/demos/extend/three-geometry.ts similarity index 100% rename from examples/demos_next/extend/three-geometry.ts rename to examples/demos/extend/three-geometry.ts diff --git a/examples/demos_next/gallery/fujian.ts b/examples/demos/gallery/fujian.ts similarity index 100% rename from examples/demos_next/gallery/fujian.ts rename to examples/demos/gallery/fujian.ts diff --git a/examples/demos_next/gallery/index.ts b/examples/demos/gallery/index.ts similarity index 100% rename from examples/demos_next/gallery/index.ts rename to examples/demos/gallery/index.ts diff --git a/examples/demos_next/gallery/vari-flight.ts b/examples/demos/gallery/vari-flight.ts similarity index 100% rename from examples/demos_next/gallery/vari-flight.ts rename to examples/demos/gallery/vari-flight.ts diff --git a/examples/demos_next/heatmap/grid.ts b/examples/demos/heatmap/grid.ts similarity index 100% rename from examples/demos_next/heatmap/grid.ts rename to examples/demos/heatmap/grid.ts diff --git a/examples/demos_next/heatmap/hexagon.ts b/examples/demos/heatmap/hexagon.ts similarity index 95% rename from examples/demos_next/heatmap/hexagon.ts rename to examples/demos/heatmap/hexagon.ts index c87da856d9..3357c3034e 100644 --- a/examples/demos_next/heatmap/hexagon.ts +++ b/examples/demos/heatmap/hexagon.ts @@ -45,9 +45,9 @@ export const hexagon: TestCase = async (options) => { ].reverse(), ); - scene.startAnimate(); + // scene.startAnimate(); scene.addLayer(layer); - scene.render(); + // scene.render(); return scene; }; diff --git a/examples/demos_next/heatmap/index.ts b/examples/demos/heatmap/index.ts similarity index 100% rename from examples/demos_next/heatmap/index.ts rename to examples/demos/heatmap/index.ts diff --git a/examples/demos_next/heatmap/normal-3d.ts b/examples/demos/heatmap/normal-3d.ts similarity index 100% rename from examples/demos_next/heatmap/normal-3d.ts rename to examples/demos/heatmap/normal-3d.ts diff --git a/examples/demos_next/heatmap/normal.ts b/examples/demos/heatmap/normal.ts similarity index 100% rename from examples/demos_next/heatmap/normal.ts rename to examples/demos/heatmap/normal.ts diff --git a/examples/demos_next/index.ts b/examples/demos/index.ts similarity index 77% rename from examples/demos_next/index.ts rename to examples/demos/index.ts index b823ae25a2..7615b566f6 100644 --- a/examples/demos_next/index.ts +++ b/examples/demos/index.ts @@ -14,8 +14,6 @@ import * as RasterTestCases from './raster'; import * as TileTestCases from './tile'; import * as WebgpuTestCases from './webgpu'; -export { BasemapTestCases, CanvasTestCases, PointTestCases }; - export const TestCases = new Map([ ['bugfix', Object.entries(BugfixTestCases)], ['point', Object.entries(PointTestCases)], @@ -32,3 +30,16 @@ export const TestCases = new Map([ ['webgpu', Object.entries(WebgpuTestCases)], ['extend', Object.entries(ExtendTestCases)], ]); + +export function geSnapshotTestsFromNamespace(namespace: string) { + const testcases = TestCases.get(namespace); + if (!testcases) return []; + const demo = testcases + .filter(([, demo]) => Boolean(demo.snapshot)) + .map(([name, demo]) => ({ + name, + snapshot: Boolean(demo.snapshot), + sleepTime: typeof demo?.snapshot === 'object' ? demo.snapshot?.sleepTime : undefined, + })); + return demo; +} diff --git a/examples/demos_next/line/arc-3d.ts b/examples/demos/line/arc-3d.ts similarity index 100% rename from examples/demos_next/line/arc-3d.ts rename to examples/demos/line/arc-3d.ts diff --git a/examples/demos_next/line/arc.ts b/examples/demos/line/arc.ts similarity index 100% rename from examples/demos_next/line/arc.ts rename to examples/demos/line/arc.ts diff --git a/examples/demos_next/line/dash.ts b/examples/demos/line/dash.ts similarity index 100% rename from examples/demos_next/line/dash.ts rename to examples/demos/line/dash.ts diff --git a/examples/demos_next/line/flow.ts b/examples/demos/line/flow.ts similarity index 100% rename from examples/demos_next/line/flow.ts rename to examples/demos/line/flow.ts diff --git a/examples/demos_next/line/greatcircle.ts b/examples/demos/line/greatcircle.ts similarity index 100% rename from examples/demos_next/line/greatcircle.ts rename to examples/demos/line/greatcircle.ts diff --git a/examples/demos_next/line/index.ts b/examples/demos/line/index.ts similarity index 100% rename from examples/demos_next/line/index.ts rename to examples/demos/line/index.ts diff --git a/examples/demos_next/line/normal.ts b/examples/demos/line/normal.ts similarity index 100% rename from examples/demos_next/line/normal.ts rename to examples/demos/line/normal.ts diff --git a/examples/demos_next/line/simple.ts b/examples/demos/line/simple.ts similarity index 100% rename from examples/demos_next/line/simple.ts rename to examples/demos/line/simple.ts diff --git a/examples/demos_next/line/wall.ts b/examples/demos/line/wall.ts similarity index 100% rename from examples/demos_next/line/wall.ts rename to examples/demos/line/wall.ts diff --git a/examples/demos_next/mask/index.ts b/examples/demos/mask/index.ts similarity index 100% rename from examples/demos_next/mask/index.ts rename to examples/demos/mask/index.ts diff --git a/examples/demos_next/mask/multi.ts b/examples/demos/mask/multi.ts similarity index 100% rename from examples/demos_next/mask/multi.ts rename to examples/demos/mask/multi.ts diff --git a/examples/demos_next/mask/raster-tile.ts b/examples/demos/mask/raster-tile.ts similarity index 100% rename from examples/demos_next/mask/raster-tile.ts rename to examples/demos/mask/raster-tile.ts diff --git a/examples/demos_next/mask/single.ts b/examples/demos/mask/single.ts similarity index 100% rename from examples/demos_next/mask/single.ts rename to examples/demos/mask/single.ts diff --git a/examples/demos_next/point/billboard.ts b/examples/demos/point/billboard.ts similarity index 100% rename from examples/demos_next/point/billboard.ts rename to examples/demos/point/billboard.ts diff --git a/examples/demos_next/point/column.ts b/examples/demos/point/column.ts similarity index 100% rename from examples/demos_next/point/column.ts rename to examples/demos/point/column.ts diff --git a/examples/demos_next/point/dot.ts b/examples/demos/point/dot.ts similarity index 100% rename from examples/demos_next/point/dot.ts rename to examples/demos/point/dot.ts diff --git a/examples/demos_next/point/fill-image.ts b/examples/demos/point/fill-image.ts similarity index 100% rename from examples/demos_next/point/fill-image.ts rename to examples/demos/point/fill-image.ts diff --git a/examples/demos_next/point/fill.ts b/examples/demos/point/fill.ts similarity index 100% rename from examples/demos_next/point/fill.ts rename to examples/demos/point/fill.ts diff --git a/examples/demos_next/point/image.ts b/examples/demos/point/image.ts similarity index 100% rename from examples/demos_next/point/image.ts rename to examples/demos/point/image.ts diff --git a/examples/demos_next/point/index.ts b/examples/demos/point/index.ts similarity index 100% rename from examples/demos_next/point/index.ts rename to examples/demos/point/index.ts diff --git a/examples/demos_next/point/radar.ts b/examples/demos/point/radar.ts similarity index 100% rename from examples/demos_next/point/radar.ts rename to examples/demos/point/radar.ts diff --git a/examples/demos_next/point/text.ts b/examples/demos/point/text.ts similarity index 100% rename from examples/demos_next/point/text.ts rename to examples/demos/point/text.ts diff --git a/examples/demos_next/polygon/extrude-city.ts b/examples/demos/polygon/extrude-city.ts similarity index 100% rename from examples/demos_next/polygon/extrude-city.ts rename to examples/demos/polygon/extrude-city.ts diff --git a/examples/demos_next/polygon/extrude.ts b/examples/demos/polygon/extrude.ts similarity index 100% rename from examples/demos_next/polygon/extrude.ts rename to examples/demos/polygon/extrude.ts diff --git a/examples/demos_next/polygon/extrusion.ts b/examples/demos/polygon/extrusion.ts similarity index 100% rename from examples/demos_next/polygon/extrusion.ts rename to examples/demos/polygon/extrusion.ts diff --git a/examples/demos_next/polygon/fill-linear.ts b/examples/demos/polygon/fill-linear.ts similarity index 100% rename from examples/demos_next/polygon/fill-linear.ts rename to examples/demos/polygon/fill-linear.ts diff --git a/examples/demos_next/polygon/fill.ts b/examples/demos/polygon/fill.ts similarity index 100% rename from examples/demos_next/polygon/fill.ts rename to examples/demos/polygon/fill.ts diff --git a/examples/demos_next/polygon/index.ts b/examples/demos/polygon/index.ts similarity index 100% rename from examples/demos_next/polygon/index.ts rename to examples/demos/polygon/index.ts diff --git a/examples/demos_next/polygon/ocean.ts b/examples/demos/polygon/ocean.ts similarity index 100% rename from examples/demos_next/polygon/ocean.ts rename to examples/demos/polygon/ocean.ts diff --git a/examples/demos_next/polygon/texture.ts b/examples/demos/polygon/texture.ts similarity index 100% rename from examples/demos_next/polygon/texture.ts rename to examples/demos/polygon/texture.ts diff --git a/examples/demos_next/polygon/water.ts b/examples/demos/polygon/water.ts similarity index 100% rename from examples/demos_next/polygon/water.ts rename to examples/demos/polygon/water.ts diff --git a/examples/demos_next/raster/dem.ts b/examples/demos/raster/dem.ts similarity index 100% rename from examples/demos_next/raster/dem.ts rename to examples/demos/raster/dem.ts diff --git a/examples/demos_next/raster/image.ts b/examples/demos/raster/image.ts similarity index 100% rename from examples/demos_next/raster/image.ts rename to examples/demos/raster/image.ts diff --git a/examples/demos_next/raster/imageBox.ts b/examples/demos/raster/imageBox.ts similarity index 100% rename from examples/demos_next/raster/imageBox.ts rename to examples/demos/raster/imageBox.ts diff --git a/examples/demos_next/raster/index.ts b/examples/demos/raster/index.ts similarity index 100% rename from examples/demos_next/raster/index.ts rename to examples/demos/raster/index.ts diff --git a/examples/demos_next/raster/multiband.ts b/examples/demos/raster/multiband.ts similarity index 100% rename from examples/demos_next/raster/multiband.ts rename to examples/demos/raster/multiband.ts diff --git a/examples/demos_next/raster/ndvi.ts b/examples/demos/raster/ndvi.ts similarity index 100% rename from examples/demos_next/raster/ndvi.ts rename to examples/demos/raster/ndvi.ts diff --git a/examples/demos_next/raster/tiff.ts b/examples/demos/raster/tiff.ts similarity index 100% rename from examples/demos_next/raster/tiff.ts rename to examples/demos/raster/tiff.ts diff --git a/examples/demos_next/tile/index.ts b/examples/demos/tile/index.ts similarity index 100% rename from examples/demos_next/tile/index.ts rename to examples/demos/tile/index.ts diff --git a/examples/demos_next/tile/raster-tile.ts b/examples/demos/tile/raster-tile.ts similarity index 100% rename from examples/demos_next/tile/raster-tile.ts rename to examples/demos/tile/raster-tile.ts diff --git a/examples/demos_next/tile/terrain-rgb.ts b/examples/demos/tile/terrain-rgb.ts similarity index 100% rename from examples/demos_next/tile/terrain-rgb.ts rename to examples/demos/tile/terrain-rgb.ts diff --git a/examples/demos_next/tile/vector-city.ts b/examples/demos/tile/vector-city.ts similarity index 100% rename from examples/demos_next/tile/vector-city.ts rename to examples/demos/tile/vector-city.ts diff --git a/examples/demos_next/tile/vector-line.ts b/examples/demos/tile/vector-line.ts similarity index 100% rename from examples/demos_next/tile/vector-line.ts rename to examples/demos/tile/vector-line.ts diff --git a/examples/demos_next/tile/vector-perf.ts b/examples/demos/tile/vector-perf.ts similarity index 100% rename from examples/demos_next/tile/vector-perf.ts rename to examples/demos/tile/vector-perf.ts diff --git a/examples/demos_next/tile/vector-usa.ts b/examples/demos/tile/vector-usa.ts similarity index 100% rename from examples/demos_next/tile/vector-usa.ts rename to examples/demos/tile/vector-usa.ts diff --git a/examples/demos_next/webgpu/boids.ts b/examples/demos/webgpu/boids.ts similarity index 100% rename from examples/demos_next/webgpu/boids.ts rename to examples/demos/webgpu/boids.ts diff --git a/examples/demos_next/webgpu/compute-texture.ts b/examples/demos/webgpu/compute-texture.ts similarity index 100% rename from examples/demos_next/webgpu/compute-texture.ts rename to examples/demos/webgpu/compute-texture.ts diff --git a/examples/demos_next/webgpu/idw.ts b/examples/demos/webgpu/idw.ts similarity index 100% rename from examples/demos_next/webgpu/idw.ts rename to examples/demos/webgpu/idw.ts diff --git a/examples/demos_next/webgpu/index.ts b/examples/demos/webgpu/index.ts similarity index 100% rename from examples/demos_next/webgpu/index.ts rename to examples/demos/webgpu/index.ts diff --git a/examples/demos_next/webgpu/perf.ts b/examples/demos/webgpu/perf.ts similarity index 100% rename from examples/demos_next/webgpu/perf.ts rename to examples/demos/webgpu/perf.ts diff --git a/examples/demos_next/webgpu/template.ts b/examples/demos/webgpu/template.ts similarity index 100% rename from examples/demos_next/webgpu/template.ts rename to examples/demos/webgpu/template.ts diff --git a/examples/demos_next/webgpu/utils/common.ts b/examples/demos/webgpu/utils/common.ts similarity index 100% rename from examples/demos_next/webgpu/utils/common.ts rename to examples/demos/webgpu/utils/common.ts diff --git a/examples/main.tsx b/examples/main.tsx index 0bcdc81c94..5c701da518 100644 --- a/examples/main.tsx +++ b/examples/main.tsx @@ -1,11 +1,11 @@ import type { Scene } from '@antv/l7-scene'; -import { Cascader } from 'antd'; +import { Cascader, ConfigProvider } from 'antd'; import 'antd/dist/reset.css'; import type { Controller } from 'lil-gui'; import GUI from 'lil-gui'; import React, { useEffect, useRef, useState } from 'react'; import { DEFAULT_GUI_OPTIONS, MAP_TYPES, SEARCH_PARAMS_KEYS } from './constants'; -import { TestCases } from './demos_next'; +import { TestCases } from './demos'; import type { GUIOptions } from './types'; const DEMO_LIST = Array.from(TestCases).map(([namespace, cases]) => { @@ -66,6 +66,12 @@ export const Main = () => { if (TestCase.extendGUI) { extendGUI = TestCase.extendGUI?.(guiRef.current!); } + + // @ts-ignore + if (isSnapshotMode && window.screenshot) { + // @ts-ignore + await window.screenshot(); + } }; asyncFun(); @@ -74,6 +80,9 @@ export const Main = () => { return () => { scene?.destroy(); extendGUI.forEach((d) => d.destroy()); + while (mapContainer.current?.firstChild) { + mapContainer.current.removeChild(mapContainer.current.lastChild!); + } }; }, [viewDemo, guiOptions]); @@ -84,14 +93,15 @@ export const Main = () => { return ( <> {!isSnapshotMode && ( -
+ -
+ )}