diff --git a/package.json b/package.json index 5f6c4ff..8a5efa6 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ ], "dependencies": { "@antv/g6": "^4.8.24", - "@gkd-kit/selector": "0.0.22", + "@gkd-kit/selector": "0.0.23", + "@gkd-kit/wasm_matches": "0.0.1", "@rushstack/eslint-patch": "^1.7.2", "@tsconfig/node20": "^20.1.2", "@types/file-saver": "^2.0.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0aa2e77..a8fa4bc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,11 @@ dependencies: specifier: ^4.8.24 version: 4.8.24 '@gkd-kit/selector': - specifier: 0.0.22 - version: 0.0.22 + specifier: 0.0.23 + version: 0.0.23 + '@gkd-kit/wasm_matches': + specifier: 0.0.1 + version: 0.0.1 '@rushstack/eslint-patch': specifier: ^1.7.2 version: 1.7.2 @@ -2290,8 +2293,12 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: false - /@gkd-kit/selector@0.0.22: - resolution: {integrity: sha512-ru+QzuraI3ITzeUH9INp8/oNVcyK+WQhlanSu+unspMCeMnXc0cF1uEQtm7utIKNSCOUTfuWlHDxR4rROZKnLw==} + /@gkd-kit/selector@0.0.23: + resolution: {integrity: sha512-C6y0Um4F26oeebcN4hl0ACzw0nHZQYU0tw5fURY6DK+yZZSGfQ6JyCDY+lRR/koX+mhoK/HM0TV9pZniSBWTHA==} + dev: false + + /@gkd-kit/wasm_matches@0.0.1: + resolution: {integrity: sha512-PUYa98MXyumiIVuYHozbYThhPnYwrdvEwyL+tBmneonIq1Vm2CmeUfk3FbJXxaMQE2/3JBa7utfk0HAu/03xDQ==} dev: false /@humanwhocodes/config-array@0.11.14: diff --git a/src/utils/selector.ts b/src/utils/selector.ts index a356159..464d3e0 100644 --- a/src/utils/selector.ts +++ b/src/utils/selector.ts @@ -1,8 +1,26 @@ import { MultiplatformSelector, MultiplatformTransform, + updateWasmToMatches, } from '@gkd-kit/selector'; import type { RawNode } from './types'; +import matchesInstantiate from '@gkd-kit/wasm_matches'; +import matchesWasmUrl from '@gkd-kit/wasm_matches/dist/mod.wasm?url'; + +matchesInstantiate(fetch(matchesWasmUrl)) + .then((mod) => { + const toMatches = mod.exports.toMatches; + updateWasmToMatches(toMatches as any); + if (import.meta.env.PROD) { + console.log('use wasm matches'); + } + }) + .catch((e) => { + console.error(e); + if (import.meta.env.PROD) { + console.log('use js matches'); + } + }); const transform = new MultiplatformTransform( (node, name) => { diff --git a/vite.config.ts b/vite.config.ts index c991de2..140166c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -27,6 +27,10 @@ export default defineConfig(() => { host: '127.0.0.1', port: 8444, }, + preview: { + host: '127.0.0.1', + port: 8444, + }, build: { target: `chrome70`, sourcemap: true,