diff --git a/.changeset/oxc-yuku.md b/.changeset/oxc-yuku.md new file mode 100644 index 00000000..c64021aa --- /dev/null +++ b/.changeset/oxc-yuku.md @@ -0,0 +1,5 @@ +--- +'@node-core/doc-kit': patch +--- + +Swap `oxc-parser` for `@yuku-parser/wasm` diff --git a/package-lock.json b/package-lock.json index eff2cd84..86627858 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@node-core/doc-kit", - "version": "1.4.2", + "version": "1.4.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@node-core/doc-kit", - "version": "1.4.2", + "version": "1.4.3", "dependencies": { "@actions/core": "^3.0.0", "@heroicons/react": "^2.2.0", @@ -17,6 +17,7 @@ "@orama/ui": "^1.5.4", "@rollup/plugin-virtual": "^3.0.2", "@swc/html-wasm": "^1.15.43", + "@yuku-parser/wasm": "^0.7.0", "acorn": "^8.17.0", "commander": "^15.0.0", "dedent": "^1.7.2", @@ -28,7 +29,6 @@ "hastscript": "^9.0.1", "lightningcss-wasm": "^1.32.0", "mdast-util-slice-markdown": "^2.0.1", - "oxc-parser": "^0.139.0", "piscina": "^5.2.0", "preact": "^10.29.2", "preact-render-to-string": "^6.7.0", @@ -53,7 +53,8 @@ "unist-util-remove": "^4.0.0", "unist-util-select": "^5.1.0", "unist-util-visit": "^5.1.0", - "yaml": "^2.9.0" + "yaml": "^2.9.0", + "yuku-ast": "^0.7.0" }, "bin": { "doc-kit": "bin/cli.mjs" @@ -1600,352 +1601,6 @@ "@orama/core": "^1.2.13" } }, - "node_modules/@oxc-parser/binding-android-arm-eabi": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-android-arm-eabi/-/binding-android-arm-eabi-0.139.0.tgz", - "integrity": "sha512-22EsXTA3Vc7OvrF4bfT48PFln2UbxkVgrp/Tm32qLw76Dv7SmcInfClJe6yPYamnli6HiqasnESZ5ezN+X4ybg==", - "cpu": [ - "arm" - ], - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-android-arm64": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-android-arm64/-/binding-android-arm64-0.139.0.tgz", - "integrity": "sha512-uASQkZV+CUQ6xXvoMzDQyfhd8OMusdv2FyCPfAi5ZDYptesapJlw7erhpGi1Lc+U8QjQV2JUrIh7d/3su2LzmQ==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-darwin-arm64": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-darwin-arm64/-/binding-darwin-arm64-0.139.0.tgz", - "integrity": "sha512-vuQOv2WF5pZCkdSPEExul98o853M3MCR24DpWsGrUoPJu5KcnGE34kLXY2yFwBwZwT+eN1x40Tt4q6ZzlEdNUA==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-darwin-x64": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-darwin-x64/-/binding-darwin-x64-0.139.0.tgz", - "integrity": "sha512-zxZB8ChS+7XactZhcyxQ292P/DNiiBaPPKYiVUlb3RC0V/hme5bokNubjcmEmbW9uTfmqLTpveAdkbe66H3pGg==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-freebsd-x64": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-freebsd-x64/-/binding-freebsd-x64-0.139.0.tgz", - "integrity": "sha512-iw2MsoCPBQwdJqywRAGsF1jEAcGoZ+DeG2LVzt5pdUvRHqajsMF46BH0rHiWoWtMwcMSia+oQYga7fHo7u7Bcw==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-linux-arm-gnueabihf": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-0.139.0.tgz", - "integrity": "sha512-SwjD/k3Y5bwGJWOH313VyaDrAuaYg1Pe+4AAXCgUKvSO5IHkj+mZ0oFcOWmB5nTuOM3uwdT+leL8h4OnFlI5hw==", - "cpu": [ - "arm" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-linux-arm-musleabihf": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-0.139.0.tgz", - "integrity": "sha512-qbeygDkcvailKFhphb2YGMMXsaZIynHlPtoOrcx4NZB/tRbUKraCCMbw8dPeFtEKasfS2qWh1VnReY+Lcys1zA==", - "cpu": [ - "arm" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-linux-arm64-gnu": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-0.139.0.tgz", - "integrity": "sha512-SrlL02KeImKlvx/9rCeopOLH7qKI3rqKKEguK6KBwVwEGLhV/A47dW4DNigf6/LFhrwoovaiayEQryjYAI86dQ==", - "cpu": [ - "arm64" - ], - "libc": [ - "glibc" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-linux-arm64-musl": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm64-musl/-/binding-linux-arm64-musl-0.139.0.tgz", - "integrity": "sha512-u9e884ChAVRmIZ1jr/m46S96FoDQnruFjISLi4Y0i6Wu/JUUmIiw7+umLyXILJsPfUuqnN5BJLe23t07+Y6+IA==", - "cpu": [ - "arm64" - ], - "libc": [ - "musl" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-linux-ppc64-gnu": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-0.139.0.tgz", - "integrity": "sha512-Z9tU2b3GJfAXOdirQmz4gZQkQkVjy53i77gf91l0733MQKa/qtk73KQQE2GzDtMqim+HyjpzvemmqzBtH2IJUA==", - "cpu": [ - "ppc64" - ], - "libc": [ - "glibc" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-linux-riscv64-gnu": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-0.139.0.tgz", - "integrity": "sha512-RyUbr7hzPK84YDWKs77PRYk9VBwWbsbuYsQzQWiSmLnARXTg2zntLPGfCH/1wpfUYdmGkp/6SsqTXSsYdw9Jgw==", - "cpu": [ - "riscv64" - ], - "libc": [ - "glibc" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-linux-riscv64-musl": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-0.139.0.tgz", - "integrity": "sha512-dcQhjtcDvtR8BgkUpt03Yz5SzxdzYvTigenIJOEsiSX6G2t6yybEMxGWjp0dOuYGror0BaqcZfTyXR58amCEig==", - "cpu": [ - "riscv64" - ], - "libc": [ - "musl" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-linux-s390x-gnu": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-0.139.0.tgz", - "integrity": "sha512-iuGrxysV4rGUymdKpn7bgZQ6Vix8Bi/6D/rp71HYIzphq6NKrsBhsGOYsSZte+uBFL43tXh7Xr7TM72sGliJNA==", - "cpu": [ - "s390x" - ], - "libc": [ - "glibc" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-linux-x64-gnu": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-x64-gnu/-/binding-linux-x64-gnu-0.139.0.tgz", - "integrity": "sha512-NxJdZZyaa2JLLvNfH/iJQXfCNfKcPMylwY4ObMpBVmW4Nq+RyUpVVQXrMMelcQ6rwx3nuhF1Iga8n+eoAKGCIA==", - "cpu": [ - "x64" - ], - "libc": [ - "glibc" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-linux-x64-musl": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-x64-musl/-/binding-linux-x64-musl-0.139.0.tgz", - "integrity": "sha512-ePxBvvtzISmSsJ0RIj8FNikSCn58i1jtccj7XR4U9Li4iSzhkFyYlnJ51cQTUwkairz8WMTD4SpKoot8RyTnQA==", - "cpu": [ - "x64" - ], - "libc": [ - "musl" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-openharmony-arm64": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-openharmony-arm64/-/binding-openharmony-arm64-0.139.0.tgz", - "integrity": "sha512-b/c2+mPXMOxG5x16n8yf9cjor/ntQQScmYnSmLEWIWJ4rfXd5dokMxx0kliSLA+YAGq6DD3K9BWi+aFXHiiV1w==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "openharmony" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-wasm32-wasi": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-wasm32-wasi/-/binding-wasm32-wasi-0.139.0.tgz", - "integrity": "sha512-rNU0pO+/CVPC2qZ+xtX5R2cOje9Q75q3UkfgwUCPlplqxMv6Iffd5tMPGVMCLGnPINxPlmi0WPsW94HltbYvfQ==", - "cpu": [ - "wasm32" - ], - "license": "MIT", - "optional": true, - "dependencies": { - "@emnapi/core": "1.11.1", - "@emnapi/runtime": "1.11.1", - "@napi-rs/wasm-runtime": "^1.1.6" - }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-win32-arm64-msvc": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-0.139.0.tgz", - "integrity": "sha512-JPEmfncZfqAFiGsAN6UZSMIBqnG8wn8buywRacFOWjP+9dZwcs03SsBp4tmyjM/4l/VoH/IuThrW1Jof3OyQUw==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-win32-ia32-msvc": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-0.139.0.tgz", - "integrity": "sha512-c06dWBwEnFHof5JN7T9/ts23uATXS9czPEBO60d4xnjH2Am29Bo7OGKdVHRmcWQnw0OBxlTg9fIEXAvtcwOBfw==", - "cpu": [ - "ia32" - ], - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-parser/binding-win32-x64-msvc": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-x64-msvc/-/binding-win32-x64-msvc-0.139.0.tgz", - "integrity": "sha512-bI3/44urQjW/D495JPXe+c9d+4Q+ONi3DvDNnzwRZYTWHZ3hAlFdmirYK4mzhTfCZiAly02EbMYir7QGU+9O2Q==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, "node_modules/@oxc-project/types": { "version": "0.137.0", "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.137.0.tgz", @@ -3874,6 +3529,22 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/@yuku-parser/wasm": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@yuku-parser/wasm/-/wasm-0.7.0.tgz", + "integrity": "sha512-yNm7YgGt2P7UvN0kG7yDn80+N7tpyG65X+CQOHCYDbLOZLtl/sLgkpnMW5blwBCpWH5PFke0vkUISwxmbWM54w==", + "license": "MIT", + "dependencies": { + "@yuku-toolchain/types": "0.7.0", + "yuku-ast": "0.7.0" + } + }, + "node_modules/@yuku-toolchain/types": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@yuku-toolchain/types/-/types-0.7.0.tgz", + "integrity": "sha512-kKleXJmXcZnJ5LUDTeYvK350SB+BXdpoHUwT78GGyOXOhCZ0tWf+seDPAvVnCrjoJhf+FhqtR5HRUfWW+yILQw==", + "license": "MIT" + }, "node_modules/acorn": { "version": "8.17.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.17.0.tgz", @@ -8685,52 +8356,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/oxc-parser": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/oxc-parser/-/oxc-parser-0.139.0.tgz", - "integrity": "sha512-cf1TKZN+zc0lwqigeyXKzKVk5+vNRe99Or2+wVJsXLdlhJgC+gsIniYDfj/ZEBzCJ8Xm21ZG6YtMbR262CcS2w==", - "license": "MIT", - "dependencies": { - "@oxc-project/types": "^0.139.0" - }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - }, - "funding": { - "url": "https://github.com/sponsors/Boshen" - }, - "optionalDependencies": { - "@oxc-parser/binding-android-arm-eabi": "0.139.0", - "@oxc-parser/binding-android-arm64": "0.139.0", - "@oxc-parser/binding-darwin-arm64": "0.139.0", - "@oxc-parser/binding-darwin-x64": "0.139.0", - "@oxc-parser/binding-freebsd-x64": "0.139.0", - "@oxc-parser/binding-linux-arm-gnueabihf": "0.139.0", - "@oxc-parser/binding-linux-arm-musleabihf": "0.139.0", - "@oxc-parser/binding-linux-arm64-gnu": "0.139.0", - "@oxc-parser/binding-linux-arm64-musl": "0.139.0", - "@oxc-parser/binding-linux-ppc64-gnu": "0.139.0", - "@oxc-parser/binding-linux-riscv64-gnu": "0.139.0", - "@oxc-parser/binding-linux-riscv64-musl": "0.139.0", - "@oxc-parser/binding-linux-s390x-gnu": "0.139.0", - "@oxc-parser/binding-linux-x64-gnu": "0.139.0", - "@oxc-parser/binding-linux-x64-musl": "0.139.0", - "@oxc-parser/binding-openharmony-arm64": "0.139.0", - "@oxc-parser/binding-wasm32-wasi": "0.139.0", - "@oxc-parser/binding-win32-arm64-msvc": "0.139.0", - "@oxc-parser/binding-win32-ia32-msvc": "0.139.0", - "@oxc-parser/binding-win32-x64-msvc": "0.139.0" - } - }, - "node_modules/oxc-parser/node_modules/@oxc-project/types": { - "version": "0.139.0", - "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.139.0.tgz", - "integrity": "sha512-r9gHphtCs+1M7J0pw6Sn/hh/Wpa/iQrOOkrNAlVLF/gHq+/CJmHIWKKUUhdWjcD6CIa8idarspCsASiXCXvFUw==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/Boshen" - } - }, "node_modules/p-filter": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/p-filter/-/p-filter-2.1.0.tgz", @@ -11191,6 +10816,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/yuku-ast": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/yuku-ast/-/yuku-ast-0.7.0.tgz", + "integrity": "sha512-W5UzqYg/Xuyz41cAyxwo/TIPpDX221OuC9U5f44+NulDAHDwtzvGE3M3Xz3mdcLEutWOmTc/WP/y7NO6ANA2gw==", + "license": "MIT", + "dependencies": { + "@yuku-toolchain/types": "0.7.0" + } + }, "node_modules/zod": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz", diff --git a/package.json b/package.json index 715add8a..19370758 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "@orama/ui": "^1.5.4", "@rollup/plugin-virtual": "^3.0.2", "@swc/html-wasm": "^1.15.43", + "@yuku-parser/wasm": "^0.7.0", "acorn": "^8.17.0", "commander": "^15.0.0", "dedent": "^1.7.2", @@ -81,7 +82,6 @@ "hastscript": "^9.0.1", "lightningcss-wasm": "^1.32.0", "mdast-util-slice-markdown": "^2.0.1", - "oxc-parser": "^0.139.0", "piscina": "^5.2.0", "preact": "^10.29.2", "preact-render-to-string": "^6.7.0", @@ -106,6 +106,7 @@ "unist-util-remove": "^4.0.0", "unist-util-select": "^5.1.0", "unist-util-visit": "^5.1.0", - "yaml": "^2.9.0" + "yaml": "^2.9.0", + "yuku-ast": "^0.7.0" } } diff --git a/src/generators/metadata/utils/resolveTypes.mjs b/src/generators/metadata/utils/resolveTypes.mjs index 86cf0d3c..c3cfcb72 100644 --- a/src/generators/metadata/utils/resolveTypes.mjs +++ b/src/generators/metadata/utils/resolveTypes.mjs @@ -1,5 +1,6 @@ -import { parseSync, Visitor } from 'oxc-parser'; +import { parse } from '@yuku-parser/wasm'; import { visit } from 'unist-util-visit'; +import { walk } from 'yuku-ast'; import { lookupTypeName, resolveTypeReference } from './transformers.mjs'; import logger from '../../../logger/index.mjs'; @@ -12,6 +13,7 @@ const KEYWORDS = [ 'TSUnknownKeyword', 'TSNeverKeyword', 'TSVoidKeyword', + 'TSNullKeyword', 'TSUndefinedKeyword', 'TSObjectKeyword', 'TSBigIntKeyword', @@ -36,9 +38,9 @@ const parseAliases = values => { }) .join(''); - const result = parseSync('types.ts', source); + const result = parse(source, { lang: 'ts' }); - if (result.errors.length > 0) { + if (result.diagnostics.length > 0) { return undefined; } @@ -66,7 +68,7 @@ const parseAliases = values => { }); }; - const visitor = new Visitor({ + walk(result.program, { /** * */ @@ -79,15 +81,9 @@ const parseAliases = values => { * */ TSImportType: node => node.qualifier && record(node.qualifier), // import('fs').Stats - /** - * - */ - TSLiteralType: node => node.literal.type === 'NullLiteral' && record(node), ...Object.fromEntries(KEYWORDS.map(kind => [kind, record])), }); - visitor.visit(result.program); - return identifiersPerAlias.map(identifiers => ({ identifiers })); };