unplugin-keywords 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -89,6 +89,8 @@ const _="b";const a={a:_,c:data};
89
89
  Generates deterministic, key-derived hashes (e.g., `"z2pL21k"`). Designed for **public-facing APIs** and structural contracts that must remain consistent across package boundaries (e.g., `package.json` exports).
90
90
  _Convention:_ `import * as PK from '~keywords/public';`
91
91
 
92
+ > **Note:** If you are building libraries for consumers who also use this plugin, see **Library Integration** below for a more optimal approach.
93
+
92
94
  - **`~keywords/raw` (Literal String):**
93
95
  Yields the exact, unobfuscated string literal (e.g., `"function"`, `"click"`). Ideal for standard APIs and repeating language keywords. Ensures a single memory instance of the string across your bundle.
94
96
  _Convention:_ `import * as RK from '~keywords/raw';`
@@ -131,6 +133,21 @@ npx keywords
131
133
  > [!TIP]
132
134
  > During development, the plugin automatically runs a background type generation process while the bundler is running. Manual CLI execution is only necessary for pre-flight type checking (e.g., in CI) before the bundler runs.
133
135
 
136
+ ## Library Integration
137
+
138
+ When publishing libraries intended for consumers who also use `unplugin-keywords`, do not use the plugin during your library's build step. Instead, solely use the `keywords` CLI to generate types for development experience.
139
+
140
+ Publish your `dist` code (.js & .d.ts) with the `import * as K from '~keywords'` statements intact, and add the `"keywordified": true` marker to your `package.json`:
141
+
142
+ ```json
143
+ {
144
+ "name": "my-keywordified-lib",
145
+ "keywordified": true
146
+ }
147
+ ```
148
+
149
+ During the final app build, the consumer's bundler will automatically include your library and process both their app and your library simultaneously. This syncs the lexical dictionary across package boundaries without requiring stable hashes (`~keywords/public`).
150
+
134
151
  ## Example: Class-Based Architectures
135
152
 
136
153
  The namespace import pattern is applicable in class-based architectures where structural symbols are heavily used for internal state and lifecycle methods.
package/dist/api.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as preprocessForExtract, i as extractKeywords, n as createHasher, o as transformCode, r as createRunner, t as createCounter } from "./hash-C5ttE6yV.js";
1
+ import { a as preprocessForExtract, i as extractKeywords, n as createHasher, o as transformCode, r as createRunner, t as createCounter } from "./hash-CCbAtdVs.js";
2
2
  //#region src/api.ts
3
3
  /**
4
4
  * @license
package/dist/bun.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./plugin-DEHtvPIq.js";
1
+ import { t as unpluginFactory } from "./plugin-Bsae1O4R.js";
2
2
  import { createBunPlugin } from "unplugin";
3
3
  //#region src/bun.ts
4
4
  /**
package/dist/esbuild.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./plugin-DEHtvPIq.js";
1
+ import { t as unpluginFactory } from "./plugin-Bsae1O4R.js";
2
2
  import { createEsbuildPlugin } from "unplugin";
3
3
  //#region src/esbuild.ts
4
4
  /**
package/dist/farm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./plugin-DEHtvPIq.js";
1
+ import { t as unpluginFactory } from "./plugin-Bsae1O4R.js";
2
2
  import { createFarmPlugin } from "unplugin";
3
3
  //#region src/farm.ts
4
4
  /**
@@ -1,9 +1,80 @@
1
- import { mkdir, readFile, writeFile } from "node:fs/promises";
1
+ import { createRequire } from "node:module";
2
+ import { mkdir, readFile, readdir, realpath, writeFile } from "node:fs/promises";
2
3
  import * as path from "node:path";
3
- import { globby } from "globby";
4
+ import ignore from "ignore";
4
5
  import pLimit from "p-limit";
5
6
  import { transformSync, types } from "@babel/core";
6
7
  import { createHmac, hkdfSync } from "node:crypto";
8
+ //#region src/internal/discovery.ts
9
+ /**
10
+ * @license
11
+ * SPDX-License-Identifier: MIT
12
+ */
13
+ const require = createRequire(import.meta.url);
14
+ const getPackageRoot = async (pkgName, startDir) => {
15
+ try {
16
+ return path.dirname(require.resolve(`${pkgName}/package.json`, { paths: [startDir] }));
17
+ } catch (err) {
18
+ const code = err?.code;
19
+ if (code === "ERR_PACKAGE_PATH_NOT_EXPORTED" || code === "MODULE_NOT_FOUND") try {
20
+ const mainPath = require.resolve(pkgName, { paths: [startDir] });
21
+ let current = path.dirname(mainPath);
22
+ while (current !== path.dirname(current)) {
23
+ try {
24
+ const pkgContent = await readFile(path.join(current, "package.json"), "utf-8");
25
+ if (JSON.parse(pkgContent).name === pkgName) return current;
26
+ } catch {}
27
+ current = path.dirname(current);
28
+ }
29
+ } catch {
30
+ return null;
31
+ }
32
+ return null;
33
+ }
34
+ };
35
+ const getKeywordifiedPackages = async (root, limit) => {
36
+ const realRoot = await realpath(root).catch(() => root);
37
+ const targetDirs = /* @__PURE__ */ new Set();
38
+ const visited = /* @__PURE__ */ new Set();
39
+ let active = 0;
40
+ return new Promise((resolve, reject) => {
41
+ const enqueue = (dir) => {
42
+ if (visited.has(dir)) return;
43
+ visited.add(dir);
44
+ active++;
45
+ limit(async () => {
46
+ try {
47
+ const resolvedDir = await realpath(dir).catch(() => dir);
48
+ if (dir !== resolvedDir) {
49
+ if (visited.has(resolvedDir)) return;
50
+ visited.add(resolvedDir);
51
+ }
52
+ const pkgContent = await readFile(path.join(resolvedDir, "package.json"), "utf-8");
53
+ const pkg = JSON.parse(pkgContent);
54
+ if (pkg.keywordified === true && resolvedDir !== realRoot) targetDirs.add(resolvedDir);
55
+ const allDeps = {
56
+ ...pkg.dependencies,
57
+ ...pkg.peerDependencies,
58
+ ...pkg.optionalDependencies,
59
+ ...resolvedDir === realRoot ? pkg.devDependencies : {}
60
+ };
61
+ const depRoots = await Promise.all(Object.keys(allDeps).map((dep) => getPackageRoot(dep, resolvedDir)));
62
+ for (const depRoot of depRoots) if (depRoot && !visited.has(depRoot)) enqueue(depRoot);
63
+ } catch {} finally {
64
+ active--;
65
+ if (active === 0) resolve(Array.from(targetDirs));
66
+ }
67
+ });
68
+ };
69
+ try {
70
+ enqueue(realRoot);
71
+ if (active === 0) resolve(Array.from(targetDirs));
72
+ } catch (err) {
73
+ reject(err);
74
+ }
75
+ });
76
+ };
77
+ //#endregion
7
78
  //#region src/internal/constants.ts
8
79
  /**
9
80
  * @license
@@ -322,7 +393,46 @@ const generateTypeDeclaration = (keywords, mode = "local") => {
322
393
  * @license
323
394
  * SPDX-License-Identifier: MIT
324
395
  */
325
- const collectKeywordsFromRoot = async (root, silent, ignoredDirs = [], concurrency = 100) => {
396
+ const EXTENSIONS = /\.(?:m?[jt]sx?|svelte)$/;
397
+ const getIgnorer = async (dir, defaultIgnores = []) => {
398
+ const ig = ignore().add(defaultIgnores);
399
+ try {
400
+ const content = await readFile(path.join(dir, ".gitignore"), "utf-8");
401
+ ig.add(content);
402
+ } catch {}
403
+ return ig;
404
+ };
405
+ const walkDir = async (startDir, baseDir, ig, files, limit) => {
406
+ let active = 0;
407
+ return new Promise((resolve, reject) => {
408
+ const enqueue = (dir) => {
409
+ active++;
410
+ limit(async () => {
411
+ try {
412
+ const entries = await readdir(dir, { withFileTypes: true });
413
+ for (const entry of entries) {
414
+ if (entry.name === ".git" || entry.name === "node_modules") continue;
415
+ const fullPath = path.join(dir, entry.name);
416
+ const relPath = path.relative(baseDir, fullPath).replace(/\\/g, "/");
417
+ if (ig.ignores(relPath)) continue;
418
+ if (entry.isDirectory()) enqueue(fullPath);
419
+ else if (entry.isFile() && EXTENSIONS.test(entry.name)) files.push(fullPath);
420
+ }
421
+ } catch {} finally {
422
+ active--;
423
+ if (active === 0) resolve();
424
+ }
425
+ });
426
+ };
427
+ try {
428
+ enqueue(startDir);
429
+ if (active === 0) resolve();
430
+ } catch (err) {
431
+ reject(err);
432
+ }
433
+ });
434
+ };
435
+ const collectKeywordsFromRoot = async (root, silent, ignorePatterns = [], concurrency = 100) => {
326
436
  const collectedKeywords = {
327
437
  local: /* @__PURE__ */ new Set(),
328
438
  public: /* @__PURE__ */ new Set(),
@@ -330,14 +440,14 @@ const collectKeywordsFromRoot = async (root, silent, ignoredDirs = [], concurren
330
440
  };
331
441
  const start = performance.now();
332
442
  if (!silent) console.error("Scanning project files for keywords...");
333
- const files = await globby("**/*.{js,ts,mjs,mts,jsx,tsx,mjsx,mtsx,svelte}", {
334
- cwd: root,
335
- absolute: false,
336
- ignore: ["**/node_modules/**", ...ignoredDirs.map((dir) => `${dir}/**`)],
337
- gitignore: true
338
- });
443
+ const limit = pLimit({ concurrency });
444
+ const targetDirs = [root, ...await getKeywordifiedPackages(root, limit)];
445
+ const allFiles = [];
446
+ await Promise.all(targetDirs.map(async (dir) => {
447
+ await walkDir(dir, dir, await getIgnorer(dir, dir === root ? ignorePatterns : []), allFiles, limit);
448
+ }));
339
449
  let processed = 0;
340
- await pLimit({ concurrency }).map(files, async (file) => {
450
+ await limit.map(allFiles, async (file) => {
341
451
  let code;
342
452
  try {
343
453
  code = await readFile(file, "utf-8");
@@ -354,7 +464,7 @@ const collectKeywordsFromRoot = async (root, silent, ignoredDirs = [], concurren
354
464
  processed++;
355
465
  });
356
466
  const elapsed = performance.now() - start;
357
- if (!silent) console.error(`Scan complete: ${processed}/${files.length} files, ${collectedKeywords.local.size} local, ${collectedKeywords.public.size} public, ${collectedKeywords.raw.size} raw keywords (${elapsed.toFixed(2)}ms).`);
467
+ if (!silent) console.error(`Scan complete: ${processed}/${allFiles.length} files, ${collectedKeywords.local.size} local, ${collectedKeywords.public.size} public, ${collectedKeywords.raw.size} raw keywords (${elapsed.toFixed(2)}ms).`);
358
468
  return collectedKeywords;
359
469
  };
360
470
  const pkgJson = {
@@ -2788,4 +2898,4 @@ const createCounter = (secret) => {
2788
2898
  //#endregion
2789
2899
  export { preprocessForExtract as a, PLUGIN_NAME as c, VIRTUAL_INTERNAL_RAW_MODULE_ID as d, VIRTUAL_MODULE_ID as f, extractKeywords as i, VIRTUAL_INTERNAL_MODULE_ID as l, VIRTUAL_RAW_MODULE_ID as m, createHasher as n, transformCode as o, VIRTUAL_PUBLIC_MODULE_ID as p, createRunner as r, encodeIdentifier as s, createCounter as t, VIRTUAL_INTERNAL_PUBLIC_MODULE_ID as u };
2790
2900
 
2791
- //# sourceMappingURL=hash-C5ttE6yV.js.map
2901
+ //# sourceMappingURL=hash-CCbAtdVs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash-CCbAtdVs.js","names":["t","blacklist","info"],"sources":["../src/internal/discovery.ts","../src/internal/constants.ts","../src/internal/encode.ts","../src/internal/transform.ts","../src/internal/typegen.ts","../src/internal/cli.ts","../src/internal/hash.ts"],"sourcesContent":["/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nimport { readFile, realpath } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport * as path from 'node:path';\nimport type { LimitFunction } from 'p-limit';\n\nconst require = createRequire(import.meta.url);\n\nconst getPackageRoot = async (\n pkgName: string,\n startDir: string,\n): Promise<string | null> => {\n try {\n return path.dirname(\n require.resolve(`${pkgName}/package.json`, { paths: [startDir] }),\n );\n } catch (err: unknown) {\n const code = (err as { code?: string })?.code;\n if (\n code === 'ERR_PACKAGE_PATH_NOT_EXPORTED' ||\n code === 'MODULE_NOT_FOUND'\n ) {\n try {\n const mainPath = require.resolve(pkgName, { paths: [startDir] });\n let current = path.dirname(mainPath);\n while (current !== path.dirname(current)) {\n try {\n const pkgPath = path.join(current, 'package.json');\n const pkgContent = await readFile(pkgPath, 'utf-8');\n const pkg = JSON.parse(pkgContent);\n if (pkg.name === pkgName) {\n return current;\n }\n } catch {}\n current = path.dirname(current);\n }\n } catch {\n return null;\n }\n }\n return null;\n }\n};\n\nexport const getKeywordifiedPackages = async (\n root: string,\n limit: LimitFunction,\n): Promise<string[]> => {\n const realRoot = await realpath(root).catch(() => root);\n const targetDirs = new Set<string>();\n const visited = new Set<string>();\n\n let active = 0;\n return new Promise((resolve, reject) => {\n const enqueue = (dir: string) => {\n if (visited.has(dir)) {\n return;\n }\n visited.add(dir);\n active++;\n\n limit(async () => {\n try {\n const resolvedDir = await realpath(dir).catch(() => dir);\n if (dir !== resolvedDir) {\n if (visited.has(resolvedDir)) {\n return;\n }\n visited.add(resolvedDir);\n }\n\n const pkgPath = path.join(resolvedDir, 'package.json');\n const pkgContent = await readFile(pkgPath, 'utf-8');\n const pkg = JSON.parse(pkgContent);\n if (pkg.keywordified === true && resolvedDir !== realRoot) {\n targetDirs.add(resolvedDir);\n }\n\n const allDeps = {\n ...pkg.dependencies,\n ...pkg.peerDependencies,\n ...pkg.optionalDependencies,\n ...(resolvedDir === realRoot ? pkg.devDependencies : {}),\n };\n const depRoots = await Promise.all(\n Object.keys(allDeps).map((dep) => getPackageRoot(dep, resolvedDir)),\n );\n for (const depRoot of depRoots) {\n if (depRoot && !visited.has(depRoot)) {\n enqueue(depRoot);\n }\n }\n } catch {\n } finally {\n active--;\n if (active === 0) {\n resolve(Array.from(targetDirs));\n }\n }\n });\n };\n\n try {\n enqueue(realRoot);\n if (active === 0) {\n resolve(Array.from(targetDirs));\n }\n } catch (err) {\n reject(err);\n }\n });\n};\n","/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nexport const VIRTUAL_MODULE_ID = '~keywords';\nexport const VIRTUAL_PUBLIC_MODULE_ID = '~keywords/public';\nexport const VIRTUAL_RAW_MODULE_ID = '~keywords/raw';\n\nexport const VIRTUAL_INTERNAL_MODULE_ID = '~keywords-internal';\nexport const VIRTUAL_INTERNAL_PUBLIC_MODULE_ID = '~keywords-internal/public';\nexport const VIRTUAL_INTERNAL_RAW_MODULE_ID = '~keywords-internal/raw';\n\nexport const PLUGIN_NAME = 'unplugin-keywords';\n\nexport const HASH_LENGTH = 7;\n\nexport const KEYWORD_ROUTE = '_';\n\n// URL-safe so that K.abc can be used in URL\nexport const DEBUG_SEPARATOR = '.';\n","/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\ndeclare const __encoded__: unique symbol;\ntype Encoded = string & { [__encoded__]: never };\n\nexport const encodeIdentifier = (identifier: string): Encoded => {\n let encoded = '';\n for (let i = 0; i < identifier.length; i++) {\n const c = identifier[i] as string;\n if (/[a-zA-Z0-9_]/.test(c)) {\n encoded += c;\n } else if (c === '$') {\n encoded += '$$';\n } else {\n encoded += `$${c.charCodeAt(0).toString(16).padStart(4, '0')}`;\n }\n }\n return encoded as Encoded;\n};\n\nexport const toSafeVarName = (encoded: Encoded): string => `_$${encoded}`;\n","/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n type FileResult,\n type NodePath,\n type PluginItem,\n type PluginObject,\n type PluginPass,\n types as t,\n transformSync,\n} from '@babel/core';\nimport {\n KEYWORD_ROUTE,\n PLUGIN_NAME,\n VIRTUAL_INTERNAL_MODULE_ID,\n VIRTUAL_INTERNAL_PUBLIC_MODULE_ID,\n VIRTUAL_INTERNAL_RAW_MODULE_ID,\n VIRTUAL_MODULE_ID,\n VIRTUAL_PUBLIC_MODULE_ID,\n VIRTUAL_RAW_MODULE_ID,\n} from './constants.js';\nimport { encodeIdentifier, toSafeVarName } from './encode.js';\n\nexport interface KeywordSet {\n local: Set<string>;\n public: Set<string>;\n raw: Set<string>;\n}\n\nconst isPureTypeSpace = (path: NodePath): boolean => {\n let current: NodePath | null = path;\n while (current) {\n const parent = current.parentPath;\n if (!parent) {\n break;\n }\n // 1. Value crossings via `typeof`\n if (parent.isTSTypeQuery()) {\n return false;\n }\n // 2. Computed keys (e.g., interface I { [Abc]: string })\n if ('computed' in parent.node && parent.node.computed) {\n if (current.key === 'key' || current.key === 'property') {\n return false;\n }\n }\n // 3-A. Definitive Type Contexts\n if (\n parent.isTSType() ||\n parent.isTSTypeParameterDeclaration() ||\n parent.isTSTypeParameterInstantiation() ||\n parent.isTSClassImplements() ||\n parent.isTSInterfaceHeritage()\n ) {\n return true;\n }\n // 3-B. Type Declaration Identifiers (e.g., interface Abc {}, type Abc = {})\n if (\n parent.isTSInterfaceDeclaration() ||\n parent.isTSTypeAliasDeclaration() ||\n parent.isTSEnumDeclaration() ||\n parent.isTSModuleDeclaration()\n ) {\n if (current.key === 'id') {\n return true;\n }\n }\n // 4. Continue up structural TS nodes (A.B.C)\n if (parent.isTSQualifiedName() || parent.isTSEntityName()) {\n current = current.parentPath;\n continue;\n }\n // 5. If we reach standard JS statements/expressions, it implies Value Space.\n if (parent.isExpression() || parent.isStatement()) {\n break;\n }\n current = current.parentPath;\n }\n return false;\n};\n\ninterface TransformState extends PluginPass {\n keywords: KeywordSet;\n keywordUids: {\n local: Map<string, t.Identifier>;\n public: Map<string, t.Identifier>;\n raw: Map<string, t.Identifier>;\n };\n}\n\ninterface TransformMetadata {\n keywords?: { local: string[]; public: string[]; raw: string[] };\n}\n\nconst transformPlugin = (mode: 'extract' | 'transform'): PluginItem => {\n const plugin: PluginObject<TransformState> = {\n name: `${PLUGIN_NAME}:${mode}`,\n\n visitor: {\n Program: {\n enter(_, state) {\n state.keywords = {\n local: new Set(),\n public: new Set(),\n raw: new Set(),\n };\n state.keywordUids = {\n local: new Map(),\n public: new Map(),\n raw: new Map(),\n };\n },\n\n exit(path, state) {\n const metadata = state.file.metadata as TransformMetadata;\n metadata.keywords = {\n local: Array.from(state.keywords.local),\n public: Array.from(state.keywords.public),\n raw: Array.from(state.keywords.raw),\n };\n\n if (mode === 'transform') {\n const newImports = [];\n for (const [keyword, safeId] of state.keywordUids.local.entries()) {\n const encoded = encodeIdentifier(keyword);\n newImports.push(\n t.importDeclaration(\n [t.importDefaultSpecifier(safeId)],\n t.stringLiteral(\n `${VIRTUAL_INTERNAL_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n ),\n ),\n );\n }\n for (const [\n keyword,\n safeId,\n ] of state.keywordUids.public.entries()) {\n const encoded = encodeIdentifier(keyword);\n newImports.push(\n t.importDeclaration(\n [t.importDefaultSpecifier(safeId)],\n t.stringLiteral(\n `${VIRTUAL_INTERNAL_PUBLIC_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n ),\n ),\n );\n }\n for (const [keyword, safeId] of state.keywordUids.raw.entries()) {\n const encoded = encodeIdentifier(keyword);\n newImports.push(\n t.importDeclaration(\n [t.importDefaultSpecifier(safeId)],\n t.stringLiteral(\n `${VIRTUAL_INTERNAL_RAW_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n ),\n ),\n );\n }\n if (newImports.length > 0) {\n path.unshiftContainer('body', newImports);\n }\n }\n },\n },\n\n ImportDeclaration(path, state) {\n const sourceValue = path.node.source.value;\n if (\n sourceValue !== VIRTUAL_MODULE_ID &&\n sourceValue !== VIRTUAL_PUBLIC_MODULE_ID &&\n sourceValue !== VIRTUAL_RAW_MODULE_ID\n ) {\n return;\n }\n const isPublic = sourceValue === VIRTUAL_PUBLIC_MODULE_ID;\n const isRaw = sourceValue === VIRTUAL_RAW_MODULE_ID;\n const targetSet = isRaw\n ? state.keywords.raw\n : isPublic\n ? state.keywords.public\n : state.keywords.local;\n const targetMap = isRaw\n ? state.keywordUids.raw\n : isPublic\n ? state.keywordUids.public\n : state.keywordUids.local;\n\n const programScope = path.scope.getProgramParent();\n const processKeyword = (keyword: string): t.Identifier | null => {\n targetSet.add(keyword);\n if (mode === 'extract') {\n return null;\n }\n if (targetMap.has(keyword)) {\n return targetMap.get(keyword) as t.Identifier;\n }\n const encoded = encodeIdentifier(keyword);\n const safeName = toSafeVarName(encoded);\n const uid = programScope.generateUidIdentifier(safeName);\n targetMap.set(keyword, uid);\n return uid;\n };\n\n for (const specifierPath of path.get('specifiers')) {\n const localName = specifierPath.node.local.name;\n const binding = path.scope.getBinding(localName);\n if (!binding) {\n continue;\n }\n\n // Case A: Default & Named Imports\n if (\n specifierPath.isImportDefaultSpecifier() ||\n specifierPath.isImportSpecifier()\n ) {\n let keyword: string;\n if (specifierPath.isImportDefaultSpecifier()) {\n keyword = 'default';\n } else {\n const imported = specifierPath.node.imported;\n keyword = t.isIdentifier(imported)\n ? imported.name\n : imported.value;\n }\n const uidNode = processKeyword(keyword);\n if (!uidNode) {\n continue;\n }\n\n // 1) Fast Path: Values & JSX\n for (const refPath of binding.referencePaths) {\n if (isPureTypeSpace(refPath)) {\n continue;\n }\n if (refPath.isJSXIdentifier()) {\n refPath.replaceWith(t.jsxIdentifier(uidNode.name));\n } else {\n refPath.replaceWith(t.cloneNode(uidNode));\n }\n }\n\n // 2) Slow Path: TS Types\n // NOTE: Can be skipped due to type erasure, but for consistency\n path.parentPath.traverse({\n // e.g., type T = typeof abc;\n TSTypeQuery(tsPath) {\n if (\n t.isIdentifier(tsPath.node.exprName) &&\n tsPath.node.exprName.name === localName &&\n tsPath.scope.getBinding(localName) === binding\n ) {\n tsPath.get('exprName').replaceWith(t.cloneNode(uidNode));\n }\n },\n });\n }\n\n // Case B: Namespace Imports\n else if (specifierPath.isImportNamespaceSpecifier()) {\n // 1) Fast Path: JS Values & JSX accesses\n for (const refPath of binding.referencePaths) {\n if (isPureTypeSpace(refPath)) {\n continue;\n }\n const parentPath = refPath.parentPath;\n if (!parentPath) {\n continue;\n }\n if (\n parentPath.isMemberExpression() &&\n parentPath.node.object === refPath.node\n ) {\n const propNode = parentPath.node.property;\n let keyword: string | undefined;\n if (!parentPath.node.computed && t.isIdentifier(propNode)) {\n keyword = propNode.name;\n } else if (parentPath.node.computed) {\n const propPath = parentPath.get('property');\n const evalResult = Array.isArray(propPath)\n ? { confident: false, value: null }\n : propPath.evaluate();\n if (\n evalResult.confident &&\n typeof evalResult.value === 'string'\n ) {\n keyword = evalResult.value;\n }\n }\n if (keyword) {\n const uidNode = processKeyword(keyword);\n if (uidNode) {\n parentPath.replaceWith(t.cloneNode(uidNode));\n }\n }\n } else if (\n parentPath.isJSXMemberExpression() &&\n parentPath.node.object === refPath.node\n ) {\n const keyword = parentPath.node.property.name;\n const uidNode = processKeyword(keyword);\n if (uidNode) {\n parentPath.replaceWith(t.jsxIdentifier(uidNode.name));\n }\n }\n }\n\n // 2) Slow Path: TS Namespace Types\n path.parentPath.traverse({\n // e.g., type T = typeof A.abc;\n TSTypeQuery(tsPath) {\n const expr = tsPath.node.exprName;\n if (\n t.isTSQualifiedName(expr) &&\n t.isIdentifier(expr.left) &&\n expr.left.name === localName &&\n tsPath.scope.getBinding(localName) === binding\n ) {\n const keyword = expr.right.name;\n const uidNode = processKeyword(keyword);\n if (uidNode) {\n tsPath.get('exprName').replaceWith(t.cloneNode(uidNode));\n }\n }\n },\n\n // e.g., type T = ((typeof A))['prop'];\n TSIndexedAccessType(tsPath) {\n const objPath = tsPath.get('objectType') as NodePath;\n if (\n objPath.isTSTypeQuery() &&\n t.isIdentifier(objPath.node.exprName) &&\n objPath.node.exprName.name === localName &&\n tsPath.scope.getBinding(localName) === binding\n ) {\n const indexNode = tsPath.node.indexType;\n let keyword: string | undefined;\n if (t.isTSLiteralType(indexNode)) {\n if (t.isStringLiteral(indexNode.literal)) {\n keyword = indexNode.literal.value;\n } else if (\n t.isTemplateLiteral(indexNode.literal) &&\n indexNode.literal.quasis.length === 1 &&\n indexNode.literal.quasis[0]?.value?.cooked\n ) {\n keyword = indexNode.literal.quasis[0].value.cooked;\n }\n }\n if (keyword) {\n const uidNode = processKeyword(keyword);\n if (uidNode) {\n tsPath.replaceWith(t.tsTypeQuery(t.cloneNode(uidNode)));\n }\n }\n }\n },\n });\n }\n }\n\n if (mode === 'transform') {\n path.remove();\n }\n },\n\n ExportNamedDeclaration(path, state) {\n const sourceValue = path.node.source?.value;\n if (\n sourceValue !== VIRTUAL_MODULE_ID &&\n sourceValue !== VIRTUAL_PUBLIC_MODULE_ID &&\n sourceValue !== VIRTUAL_RAW_MODULE_ID\n ) {\n return;\n }\n const isPublic = sourceValue === VIRTUAL_PUBLIC_MODULE_ID;\n const isRaw = sourceValue === VIRTUAL_RAW_MODULE_ID;\n const targetSet = isRaw\n ? state.keywords.raw\n : isPublic\n ? state.keywords.public\n : state.keywords.local;\n\n if (mode === 'extract') {\n for (const specifierPath of path.get('specifiers')) {\n if (specifierPath.isExportSpecifier()) {\n const local = specifierPath.node.local as\n | t.Identifier\n | t.StringLiteral; // local can be a StringLiteral in ES2022\n const keyword = t.isIdentifier(local) ? local.name : local.value;\n targetSet.add(keyword);\n }\n }\n return;\n }\n\n const newExports = path\n .get('specifiers')\n .map((specifierPath) => {\n if (specifierPath.isExportSpecifier()) {\n const local = specifierPath.node.local as\n | t.Identifier\n | t.StringLiteral; // local can be a StringLiteral in ES2022\n const keyword = t.isIdentifier(local) ? local.name : local.value;\n targetSet.add(keyword);\n const encoded = encodeIdentifier(keyword);\n const targetModuleId = isRaw\n ? VIRTUAL_INTERNAL_RAW_MODULE_ID\n : isPublic\n ? VIRTUAL_INTERNAL_PUBLIC_MODULE_ID\n : VIRTUAL_INTERNAL_MODULE_ID;\n return t.exportNamedDeclaration(\n null,\n [\n t.exportSpecifier(\n t.identifier('default'),\n specifierPath.node.exported,\n ),\n ],\n t.stringLiteral(\n `${targetModuleId}/${KEYWORD_ROUTE}/${encoded}`,\n ),\n );\n }\n return null;\n })\n .filter((node): node is t.ExportNamedDeclaration => node !== null);\n\n if (newExports.length > 0) {\n path.replaceWithMultiple(newExports);\n } else {\n path.remove();\n }\n },\n },\n };\n\n return () => plugin as PluginObject;\n};\n\nconst isJsx = (id: string): boolean => /\\.m?[jt]sx$/.test(id);\n\nexport const transformCode = (\n code: string,\n id: string,\n): {\n code: string;\n map: NonNullable<FileResult['map']> | null;\n keywords: KeywordSet;\n} | null => {\n if (\n !code.includes(VIRTUAL_MODULE_ID) &&\n !code.includes(VIRTUAL_PUBLIC_MODULE_ID) &&\n !code.includes(VIRTUAL_RAW_MODULE_ID)\n ) {\n return null;\n }\n const result = transformSync(code, {\n babelrc: false,\n configFile: false,\n filename: id,\n sourceMaps: true,\n ast: false,\n plugins: [transformPlugin('transform')],\n parserOpts: {\n plugins: ['typescript', ...(isJsx(id) ? (['jsx'] as const) : [])],\n },\n });\n if (!result) {\n return null;\n }\n const metadata = result.metadata as TransformMetadata | undefined;\n const keywords: KeywordSet = {\n local: new Set(metadata?.keywords?.local ?? []),\n public: new Set(metadata?.keywords?.public ?? []),\n raw: new Set(metadata?.keywords?.raw ?? []),\n };\n return {\n code: result.code ?? '',\n map: result.map ?? null,\n keywords,\n };\n};\n\nexport const extractKeywords = (\n code: string,\n id: string,\n): KeywordSet | null => {\n if (\n !code.includes(VIRTUAL_MODULE_ID) &&\n !code.includes(VIRTUAL_PUBLIC_MODULE_ID) &&\n !code.includes(VIRTUAL_RAW_MODULE_ID)\n ) {\n return null;\n }\n let result: FileResult | null;\n try {\n result = transformSync(code, {\n babelrc: false,\n configFile: false,\n sourceMaps: false,\n ast: false,\n code: false,\n plugins: [transformPlugin('extract')],\n parserOpts: {\n plugins: ['typescript', ...(isJsx(id) ? (['jsx'] as const) : [])],\n errorRecovery: true,\n },\n });\n } catch {\n return null;\n }\n if (!result) {\n return null;\n }\n const metadata = result.metadata as TransformMetadata | undefined;\n return {\n local: new Set(metadata?.keywords?.local ?? []),\n public: new Set(metadata?.keywords?.public ?? []),\n raw: new Set(metadata?.keywords?.raw ?? []),\n };\n};\n\nexport const preprocessForExtract = async (\n code: string,\n id: string,\n): Promise<string | null> => {\n let finalCode = code;\n if (\n !code.includes(VIRTUAL_MODULE_ID) &&\n !code.includes(VIRTUAL_PUBLIC_MODULE_ID) &&\n !code.includes(VIRTUAL_RAW_MODULE_ID)\n ) {\n return null;\n }\n if (/\\.svelte$/.test(id)) {\n try {\n const compiler = await import('svelte/compiler');\n const result = compiler.compile(finalCode, { filename: id });\n finalCode = result.js.code;\n } catch {\n return null;\n }\n }\n return finalCode;\n};\n","/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nimport { DEBUG_SEPARATOR, HASH_LENGTH } from './constants.js';\nimport { encodeIdentifier, toSafeVarName } from './encode.js';\n\nexport const generateTypeDeclaration = (\n keywords: Set<string>,\n mode: 'local' | 'public' | 'raw' = 'local',\n): string => {\n const sortedKeywords = Array.from(keywords).sort();\n const content = [];\n\n for (const keyword of sortedKeywords) {\n const encoded = encodeIdentifier(keyword);\n const safeName = toSafeVarName(encoded);\n const hash = mode === 'public' ? '*'.repeat(HASH_LENGTH) : '==';\n const value =\n mode === 'raw' ? keyword : `${hash}${DEBUG_SEPARATOR}${keyword}`;\n content.push(`declare const ${safeName}: ${JSON.stringify(value)};`);\n }\n content.push('');\n\n content.push('export {');\n for (const keyword of sortedKeywords) {\n const encoded = encodeIdentifier(keyword);\n const safeName = toSafeVarName(encoded);\n content.push(` ${safeName} as ${JSON.stringify(keyword)},`);\n }\n content.push('};');\n content.push('');\n\n return content.join('\\n');\n};\n","/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nimport { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';\nimport * as path from 'node:path';\nimport ignore, { type Ignore } from 'ignore';\nimport pLimit, { type LimitFunction } from 'p-limit';\nimport { getKeywordifiedPackages } from './discovery.js';\nimport {\n extractKeywords,\n type KeywordSet,\n preprocessForExtract,\n} from './transform.js';\nimport { generateTypeDeclaration } from './typegen.js';\n\nconst EXTENSIONS = /\\.(?:m?[jt]sx?|svelte)$/;\n\nconst getIgnorer = async (\n dir: string,\n defaultIgnores: string[] = [],\n): Promise<Ignore> => {\n const ig = ignore().add(defaultIgnores);\n try {\n const gitignorePath = path.join(dir, '.gitignore');\n const content = await readFile(gitignorePath, 'utf-8');\n ig.add(content);\n } catch {}\n return ig;\n};\n\nconst walkDir = async (\n startDir: string,\n baseDir: string,\n ig: Ignore,\n files: string[],\n limit: LimitFunction,\n): Promise<void> => {\n let active = 0;\n return new Promise((resolve, reject) => {\n const enqueue = (dir: string) => {\n active++;\n limit(async () => {\n try {\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.name === '.git' || entry.name === 'node_modules') {\n continue;\n }\n const fullPath = path.join(dir, entry.name);\n const relPath = path\n .relative(baseDir, fullPath)\n .replace(/\\\\/g, '/');\n if (ig.ignores(relPath)) {\n continue;\n }\n if (entry.isDirectory()) {\n enqueue(fullPath);\n } else if (entry.isFile() && EXTENSIONS.test(entry.name)) {\n files.push(fullPath);\n }\n }\n } catch {\n } finally {\n active--;\n if (active === 0) {\n resolve();\n }\n }\n });\n };\n try {\n enqueue(startDir);\n if (active === 0) {\n resolve();\n }\n } catch (err) {\n reject(err);\n }\n });\n};\n\nconst collectKeywordsFromRoot = async (\n root: string,\n silent: boolean,\n ignorePatterns: string[] = [],\n concurrency: number = 100,\n): Promise<KeywordSet> => {\n const collectedKeywords: KeywordSet = {\n local: new Set(),\n public: new Set(),\n raw: new Set(),\n };\n\n const start = performance.now();\n if (!silent) {\n console.error('Scanning project files for keywords...');\n }\n\n const limit = pLimit({ concurrency });\n const keywordifiedDirs = await getKeywordifiedPackages(root, limit);\n const targetDirs = [root, ...keywordifiedDirs];\n\n const allFiles: string[] = [];\n await Promise.all(\n targetDirs.map(async (dir) => {\n const ig = await getIgnorer(dir, dir === root ? ignorePatterns : []);\n await walkDir(dir, dir, ig, allFiles, limit);\n }),\n );\n\n let processed = 0;\n await limit.map(allFiles, async (file) => {\n let code: string | null;\n try {\n code = await readFile(file, 'utf-8');\n } catch {\n return;\n }\n code = await preprocessForExtract(code, file);\n if (!code) {\n return;\n }\n const keywords = extractKeywords(code, file);\n if (!keywords) {\n return;\n }\n for (const keyword of keywords.local) {\n collectedKeywords.local.add(keyword);\n }\n for (const keyword of keywords.public) {\n collectedKeywords.public.add(keyword);\n }\n for (const keyword of keywords.raw) {\n collectedKeywords.raw.add(keyword);\n }\n processed++;\n });\n\n const elapsed = performance.now() - start;\n if (!silent) {\n console.error(\n `Scan complete: ${processed}/${allFiles.length} files, ` +\n `${collectedKeywords.local.size} local, ` +\n `${collectedKeywords.public.size} public, ` +\n `${collectedKeywords.raw.size} raw keywords ` +\n `(${elapsed.toFixed(2)}ms).`,\n );\n }\n\n return collectedKeywords;\n};\n\nconst pkgJson = {\n private: true,\n type: 'module',\n sideEffects: false,\n exports: {\n '.': {\n types: './index.d.ts',\n },\n './public': {\n types: './public.d.ts',\n },\n './raw': {\n types: './raw.d.ts',\n },\n },\n};\n\ninterface RunnerOptions {\n root: string;\n silent: boolean;\n outDir: string;\n}\n\nexport const createRunner = (options?: Partial<RunnerOptions>) => {\n const {\n root = process.cwd(),\n silent = false,\n outDir = path.join('node_modules', '~keywords'),\n } = options ?? {};\n return {\n async collect(): Promise<KeywordSet> {\n return collectKeywordsFromRoot(root, silent);\n },\n\n async save(keywords: KeywordSet): Promise<void> {\n const content = generateTypeDeclaration(keywords.local);\n const publicContent = generateTypeDeclaration(keywords.public, 'public');\n const rawContent = generateTypeDeclaration(keywords.raw, 'raw');\n const outPath = path.join(root, outDir);\n await mkdir(outPath, { recursive: true });\n await writeFile(path.join(outPath, 'index.d.ts'), `${content.trim()}\\n`);\n await writeFile(\n path.join(outPath, 'public.d.ts'),\n `${publicContent.trim()}\\n`,\n );\n await writeFile(path.join(outPath, 'raw.d.ts'), `${rawContent.trim()}\\n`);\n await writeFile(\n path.join(outPath, 'package.json'),\n `${JSON.stringify(pkgJson, null, 2)}\\n`,\n );\n },\n\n async run(): Promise<void> {\n const keywords = await this.collect();\n await this.save(keywords);\n },\n };\n};\n","/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nimport { createHmac, hkdfSync } from 'node:crypto';\nimport blacklist from 'virtual:blacklist';\nimport {\n HASH_LENGTH,\n VIRTUAL_MODULE_ID,\n VIRTUAL_PUBLIC_MODULE_ID,\n} from './constants.js';\n\nconst ALPHA_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst BASE62_CHARS = `${ALPHA_CHARS}0123456789`;\n\nconst ALPHA_LEN = BigInt(ALPHA_CHARS.length); // 52n\nconst BASE62_LEN = BigInt(BASE62_CHARS.length); // 62n\n\nexport type Hasher = (input: string) => string;\n\n// Format: [1 Alpha] + [N Base62]\nexport const createHasher = (secret: string): Hasher => {\n const base62TailLength = HASH_LENGTH - 1;\n\n const cache = new Map<string, string>();\n return (input) => {\n if (cache.has(input)) {\n return cache.get(input) as string;\n }\n\n const info = VIRTUAL_PUBLIC_MODULE_ID;\n let retry = 0;\n let result: string;\n\n do {\n const r = retry.toString();\n retry++;\n const payload = `${info.length}:${info}|${input.length}:${input}|${r.length}:${r}`;\n const hasher = createHmac('sha256', secret);\n const buffer = hasher.update(payload).digest('hex');\n\n let entropy = BigInt(`0x${buffer}`);\n result = '';\n\n result += ALPHA_CHARS[Number(entropy % ALPHA_LEN)];\n entropy /= ALPHA_LEN;\n for (let i = 0; i < base62TailLength; i++) {\n result += BASE62_CHARS[Number(entropy % BASE62_LEN)];\n entropy /= BASE62_LEN;\n }\n } while (blacklist.has(result));\n\n cache.set(input, result);\n return result;\n };\n};\n\n// Fisher-Yates based deterministic shuffle\nconst shuffle = (str: string, secret: string, salt: string): string => {\n const arr = Array.from(str);\n const requiredBytes = (arr.length - 1) * 4;\n\n const info = VIRTUAL_MODULE_ID;\n const keyingMaterial = hkdfSync('sha256', secret, salt, info, requiredBytes);\n const prngBuffer = Buffer.from(keyingMaterial);\n\n let byteOffset = 0;\n for (let i = arr.length - 1; i > 0; i--) {\n const random32 = prngBuffer.readUInt32BE(byteOffset);\n byteOffset += 4;\n const j = random32 % (i + 1);\n const temp = arr[i] as string;\n arr[i] = arr[j] as string;\n arr[j] = temp;\n }\n\n return arr.join('');\n};\n\nexport const createCounter = (secret: string): Hasher => {\n const shuffledAlpha = shuffle(ALPHA_CHARS, secret, 'alpha');\n const shuffledBase62 = shuffle(BASE62_CHARS, secret, 'base62');\n\n let index = 0;\n const cache = new Map<string, string>();\n return (input) => {\n if (cache.has(input)) {\n return cache.get(input) as string;\n }\n\n let result: string;\n do {\n result = '';\n let current = index;\n index++;\n\n result += shuffledAlpha[current % shuffledAlpha.length];\n current = Math.floor(current / shuffledAlpha.length);\n while (current > 0) {\n current--;\n result += shuffledBase62[current % shuffledBase62.length];\n current = Math.floor(current / shuffledBase62.length);\n }\n } while (blacklist.has(result));\n\n cache.set(input, result);\n return result;\n };\n};\n"],"mappings":";;;;;;;;;;;;AAUA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,MAAM,iBAAiB,OACrB,SACA,aAC2B;CAC3B,IAAI;EACF,OAAO,KAAK,QACV,QAAQ,QAAQ,GAAG,QAAQ,gBAAgB,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAClE;UACM,KAAc;EACrB,MAAM,OAAQ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G;IAClB;IACA,UAAU,eAAe,UAAU,eAAe;IAClD,UAAU,KAAK,MAAM,UAAU,eAAe,OAAO;;WAEhDD,2BAAU,IAAI,OAAO;EAE9B,MAAM,IAAI,OAAO,OAAO;EACxB,OAAO"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./plugin-DEHtvPIq.js";
1
+ import { t as unpluginFactory } from "./plugin-Bsae1O4R.js";
2
2
  import { createUnplugin } from "unplugin";
3
3
  //#region src/index.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { a as preprocessForExtract, c as PLUGIN_NAME, d as VIRTUAL_INTERNAL_RAW_MODULE_ID, f as VIRTUAL_MODULE_ID, i as extractKeywords, l as VIRTUAL_INTERNAL_MODULE_ID, m as VIRTUAL_RAW_MODULE_ID, n as createHasher, o as transformCode, p as VIRTUAL_PUBLIC_MODULE_ID, r as createRunner, s as encodeIdentifier, t as createCounter, u as VIRTUAL_INTERNAL_PUBLIC_MODULE_ID } from "./hash-C5ttE6yV.js";
1
+ import { a as preprocessForExtract, c as PLUGIN_NAME, d as VIRTUAL_INTERNAL_RAW_MODULE_ID, f as VIRTUAL_MODULE_ID, i as extractKeywords, l as VIRTUAL_INTERNAL_MODULE_ID, m as VIRTUAL_RAW_MODULE_ID, n as createHasher, o as transformCode, p as VIRTUAL_PUBLIC_MODULE_ID, r as createRunner, s as encodeIdentifier, t as createCounter, u as VIRTUAL_INTERNAL_PUBLIC_MODULE_ID } from "./hash-CCbAtdVs.js";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import pLimit from "p-limit";
4
4
  //#region src/internal/plugin.ts
@@ -14,7 +14,6 @@ const splitQuery = (id) => {
14
14
  };
15
15
  const toIncludes = (id) => [new RegExp(`^${id}/`)];
16
16
  const SUFFIX_REGEX = /\.(?:m?[jt]sx?|svelte)(?:$|\?)/;
17
- const COMMON_EXCLUDES = [/\/node_modules\//];
18
17
  const unpluginFactory = ({ isDev, secret }) => {
19
18
  const runner = createRunner({ silent: true });
20
19
  const runnerLimit = pLimit({ concurrency: 1 });
@@ -51,27 +50,21 @@ const unpluginFactory = ({ isDev, secret }) => {
51
50
  await runnerLimit(() => Promise.resolve());
52
51
  },
53
52
  resolveId: {
54
- filter: { id: {
55
- include: [
56
- ...toIncludes(VIRTUAL_INTERNAL_MODULE_ID),
57
- ...toIncludes(VIRTUAL_INTERNAL_PUBLIC_MODULE_ID),
58
- ...toIncludes(VIRTUAL_INTERNAL_RAW_MODULE_ID)
59
- ],
60
- exclude: COMMON_EXCLUDES
61
- } },
53
+ filter: { id: { include: [
54
+ ...toIncludes(VIRTUAL_INTERNAL_MODULE_ID),
55
+ ...toIncludes(VIRTUAL_INTERNAL_PUBLIC_MODULE_ID),
56
+ ...toIncludes(VIRTUAL_INTERNAL_RAW_MODULE_ID)
57
+ ] } },
62
58
  handler(id) {
63
59
  return resolveId(id);
64
60
  }
65
61
  },
66
62
  load: {
67
- filter: { id: {
68
- include: [
69
- ...toIncludes(resolveId(VIRTUAL_INTERNAL_MODULE_ID)),
70
- ...toIncludes(resolveId(VIRTUAL_INTERNAL_PUBLIC_MODULE_ID)),
71
- ...toIncludes(resolveId(VIRTUAL_INTERNAL_RAW_MODULE_ID))
72
- ],
73
- exclude: COMMON_EXCLUDES
74
- } },
63
+ filter: { id: { include: [
64
+ ...toIncludes(resolveId(VIRTUAL_INTERNAL_MODULE_ID)),
65
+ ...toIncludes(resolveId(VIRTUAL_INTERNAL_PUBLIC_MODULE_ID)),
66
+ ...toIncludes(resolveId(VIRTUAL_INTERNAL_RAW_MODULE_ID))
67
+ ] } },
75
68
  handler(id) {
76
69
  const [validId] = splitQuery(id);
77
70
  if (resolvedMap.has(validId)) return resolvedMap.get(validId);
@@ -80,10 +73,7 @@ const unpluginFactory = ({ isDev, secret }) => {
80
73
  },
81
74
  transform: {
82
75
  filter: {
83
- id: {
84
- include: [SUFFIX_REGEX],
85
- exclude: COMMON_EXCLUDES
86
- },
76
+ id: { include: [SUFFIX_REGEX] },
87
77
  code: { include: [
88
78
  VIRTUAL_MODULE_ID,
89
79
  VIRTUAL_PUBLIC_MODULE_ID,
@@ -121,7 +111,7 @@ const unpluginFactory = ({ isDev, secret }) => {
121
111
  }
122
112
  },
123
113
  async watchChange(id, { event }) {
124
- if (!SUFFIX_REGEX.test(id) || COMMON_EXCLUDES.some((regex) => regex.test(id)) || event === "delete") return;
114
+ if (!SUFFIX_REGEX.test(id) || event === "delete") return;
125
115
  const [validId] = splitQuery(id);
126
116
  let code;
127
117
  try {
@@ -158,4 +148,4 @@ const unpluginFactory = ({ isDev, secret }) => {
158
148
  //#endregion
159
149
  export { unpluginFactory as t };
160
150
 
161
- //# sourceMappingURL=plugin-DEHtvPIq.js.map
151
+ //# sourceMappingURL=plugin-Bsae1O4R.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-Bsae1O4R.js","names":[],"sources":["../src/internal/plugin.ts"],"sourcesContent":["/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nimport { readFile } from 'node:fs/promises';\nimport pLimit from 'p-limit';\nimport type { UnpluginFactory } from 'unplugin';\nimport { createRunner } from './cli.js';\nimport {\n DEBUG_SEPARATOR,\n KEYWORD_ROUTE,\n PLUGIN_NAME,\n VIRTUAL_INTERNAL_MODULE_ID,\n VIRTUAL_INTERNAL_PUBLIC_MODULE_ID,\n VIRTUAL_INTERNAL_RAW_MODULE_ID,\n VIRTUAL_MODULE_ID,\n VIRTUAL_PUBLIC_MODULE_ID,\n VIRTUAL_RAW_MODULE_ID,\n} from './constants.js';\nimport { encodeIdentifier } from './encode.js';\nimport { createCounter, createHasher, type Hasher } from './hash.js';\nimport {\n extractKeywords,\n type KeywordSet,\n preprocessForExtract,\n transformCode,\n} from './transform.js';\n\nconst resolveId = (id: string): string => `\\0${id}`;\n\nconst splitQuery = (id: string): [string, string | undefined] => {\n const index = id.indexOf('?');\n if (index === -1) {\n return [id, undefined];\n }\n return [id.slice(0, index), id.slice(index + 1)];\n};\n\nconst toIncludes = (id: string): RegExp[] => [new RegExp(`^${id}/`)];\n\nconst SUFFIX_REGEX = /\\.(?:m?[jt]sx?|svelte)(?:$|\\?)/;\n\nexport interface Options {\n /**\n * If true, preserves the original keyword as a suffix in the generated\n * identifier for easier debugging (e.g., `\"zXpL21k.SET_USER\"`).\n */\n isDev: boolean;\n /**\n * The cryptographic key used to initialize the deterministic HMAC algorithm.\n * Modifying this value will globally rotate all generated hashes.\n * To ensure cross-boundary consistency between independent builds,\n * they must share the same secret key.\n */\n secret: string;\n}\n\nexport const unpluginFactory: UnpluginFactory<Options> = ({\n isDev,\n secret,\n}) => {\n const runner = createRunner({ silent: true });\n const runnerLimit = pLimit({ concurrency: 1 });\n const typegenKeywords: KeywordSet = {\n local: new Set(),\n public: new Set(),\n raw: new Set(),\n };\n\n let isInitialized = false;\n const runInit = async () => {\n try {\n const keywords = await runner.collect();\n for (const keyword of keywords.local) {\n typegenKeywords.local.add(keyword);\n }\n for (const keyword of keywords.public) {\n typegenKeywords.public.add(keyword);\n }\n for (const keyword of keywords.raw) {\n typegenKeywords.raw.add(keyword);\n }\n await runner.save(typegenKeywords);\n isInitialized = true;\n } catch {}\n };\n\n let hasherPublic: Hasher;\n let hasherLocal: Hasher;\n let resolvedMap: Map<string, string>;\n\n return {\n name: PLUGIN_NAME,\n\n buildStart() {\n hasherPublic = createHasher(secret);\n hasherLocal = createCounter(secret);\n resolvedMap = new Map();\n if (!isInitialized) {\n runnerLimit(async () => {\n if (!isInitialized) {\n await runInit();\n }\n });\n }\n },\n\n async buildEnd() {\n // Flush the background queue\n await runnerLimit(() => Promise.resolve());\n },\n\n resolveId: {\n filter: {\n id: {\n include: [\n ...toIncludes(VIRTUAL_INTERNAL_MODULE_ID),\n ...toIncludes(VIRTUAL_INTERNAL_PUBLIC_MODULE_ID),\n ...toIncludes(VIRTUAL_INTERNAL_RAW_MODULE_ID),\n ],\n },\n },\n handler(id) {\n return resolveId(id);\n },\n },\n\n load: {\n filter: {\n id: {\n include: [\n ...toIncludes(resolveId(VIRTUAL_INTERNAL_MODULE_ID)),\n ...toIncludes(resolveId(VIRTUAL_INTERNAL_PUBLIC_MODULE_ID)),\n ...toIncludes(resolveId(VIRTUAL_INTERNAL_RAW_MODULE_ID)),\n ],\n },\n },\n handler(id) {\n const [validId] = splitQuery(id);\n if (resolvedMap.has(validId)) {\n return resolvedMap.get(validId);\n }\n return null;\n },\n },\n\n transform: {\n filter: {\n id: {\n include: [SUFFIX_REGEX],\n },\n code: {\n include: [\n VIRTUAL_MODULE_ID,\n VIRTUAL_PUBLIC_MODULE_ID,\n VIRTUAL_RAW_MODULE_ID,\n ],\n },\n },\n handler(code, id) {\n const [validId] = splitQuery(id);\n const result = transformCode(code, validId);\n if (!result) {\n return null;\n }\n const { code: transformed, map, keywords } = result;\n for (const keyword of keywords.local) {\n const encoded = encodeIdentifier(keyword);\n const resolvedId = resolveId(\n `${VIRTUAL_INTERNAL_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n );\n if (resolvedMap.has(resolvedId)) {\n continue;\n }\n const hash = hasherLocal(keyword);\n const value = isDev ? `${hash}${DEBUG_SEPARATOR}${keyword}` : hash;\n resolvedMap.set(\n resolvedId,\n `export default ${JSON.stringify(value)};\\n`,\n );\n }\n for (const keyword of keywords.public) {\n const encoded = encodeIdentifier(keyword);\n const resolvedId = resolveId(\n `${VIRTUAL_INTERNAL_PUBLIC_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n );\n if (resolvedMap.has(resolvedId)) {\n continue;\n }\n const hash = hasherPublic(keyword);\n const value = isDev ? `${hash}${DEBUG_SEPARATOR}${keyword}` : hash;\n resolvedMap.set(\n resolvedId,\n `export default ${JSON.stringify(value)};\\n`,\n );\n }\n for (const keyword of keywords.raw) {\n const encoded = encodeIdentifier(keyword);\n const resolvedId = resolveId(\n `${VIRTUAL_INTERNAL_RAW_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n );\n if (resolvedMap.has(resolvedId)) {\n continue;\n }\n resolvedMap.set(\n resolvedId,\n `export default ${JSON.stringify(keyword)};\\n`,\n );\n }\n return { code: transformed, map };\n },\n },\n\n async watchChange(id, { event }) {\n if (!SUFFIX_REGEX.test(id) || event === 'delete') {\n return;\n }\n const [validId] = splitQuery(id);\n let code: string | null;\n try {\n code = await readFile(validId, 'utf-8');\n } catch {\n return;\n }\n code = await preprocessForExtract(code, validId);\n if (!code) {\n return;\n }\n const keywords = extractKeywords(code, validId);\n if (!keywords) {\n return;\n }\n let isAdded = false;\n for (const keyword of keywords.local) {\n if (!typegenKeywords.local.has(keyword)) {\n typegenKeywords.local.add(keyword);\n isAdded = true;\n }\n }\n for (const keyword of keywords.public) {\n if (!typegenKeywords.public.has(keyword)) {\n typegenKeywords.public.add(keyword);\n isAdded = true;\n }\n }\n for (const keyword of keywords.raw) {\n if (!typegenKeywords.raw.has(keyword)) {\n typegenKeywords.raw.add(keyword);\n isAdded = true;\n }\n }\n if (!isInitialized || isAdded) {\n runnerLimit(async () => {\n if (!isInitialized) {\n await runInit();\n } else if (isAdded) {\n try {\n await runner.save(typegenKeywords);\n } catch {}\n }\n });\n }\n },\n };\n};\n"],"mappings":";;;;;;;;AA6BA,MAAM,aAAa,OAAuB,KAAK;AAE/C,MAAM,cAAc,OAA6C;CAC/D,MAAM,QAAQ,GAAG,QAAQ,IAAI;CAC7B,IAAI,UAAU,IACZ,OAAO,CAAC,IAAI,KAAA,EAAU;CAExB,OAAO,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,QAAQ,EAAE,CAAC;;AAGlD,MAAM,cAAc,OAAyB,CAAC,IAAI,OAAO,IAAI,GAAG,GAAG,CAAC;AAEpE,MAAM,eAAe;AAiBrB,MAAa,mBAA6C,EACxD,OACA,aACI;CACJ,MAAM,SAAS,aAAa,EAAE,QAAQ,MAAM,CAAC;CAC7C,MAAM,cAAc,OAAO,EAAE,aAAa,GAAG,CAAC;CAC9C,MAAM,kBAA8B;EAClC,uBAAO,I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AAS,QAAQ;WACjC;IACN;;GAEF,OAAO,MAAM,qBAAqB,MAAM,QAAQ;GAChD,IAAI,CAAC,MACH;GAEF,MAAM,WAAW,gBAAgB,MAAM,QAAQ;GAC/C,IAAI,CAAC,UACH;GAEF,IAAI,UAAU;GACd,KAAK,MAAM,WAAW,SAAS,OAC7B,IAAI,CAAC,gBAAgB,MAAM,IAAI,QAAQ,EAAE;IACvC,gBAAgB,MAAM,IAAI,QAAQ;IAClC,UAAU;;GAGd,KAAK,MAAM,WAAW,SAAS,QAC7B,IAAI,CAAC,gBAAgB,OAAO,IAAI,QAAQ,EAAE;IACxC,gBAAgB,OAAO,IAAI,QAAQ;IACnC,UAAU;;GAGd,KAAK,MAAM,WAAW,SAAS,KAC7B,IAAI,CAAC,gBAAgB,IAAI,IAAI,QAAQ,EAAE;IACrC,gBAAgB,IAAI,IAAI,QAAQ;IAChC,UAAU;;GAGd,IAAI,CAAC,iBAAiB,SACpB,YAAY,YAAY;IACtB,IAAI,CAAC,eACH,MAAM,SAAS;SACV,IAAI,SACT,IAAI;KACF,MAAM,OAAO,KAAK,gBAAgB;YAC5B;KAEV;;EAGP"}
package/dist/rolldown.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./plugin-DEHtvPIq.js";
1
+ import { t as unpluginFactory } from "./plugin-Bsae1O4R.js";
2
2
  import { createRolldownPlugin } from "unplugin";
3
3
  //#region src/rolldown.ts
4
4
  /**
package/dist/rollup.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./plugin-DEHtvPIq.js";
1
+ import { t as unpluginFactory } from "./plugin-Bsae1O4R.js";
2
2
  import { createRollupPlugin } from "unplugin";
3
3
  //#region src/rollup.ts
4
4
  /**
package/dist/rspack.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./plugin-DEHtvPIq.js";
1
+ import { t as unpluginFactory } from "./plugin-Bsae1O4R.js";
2
2
  import { createRspackPlugin } from "unplugin";
3
3
  //#region src/rspack.ts
4
4
  /**
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./plugin-DEHtvPIq.js";
1
+ import { t as unpluginFactory } from "./plugin-Bsae1O4R.js";
2
2
  import { createVitePlugin } from "unplugin";
3
3
  //#region src/vite.ts
4
4
  /**
package/dist/webpack.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./plugin-DEHtvPIq.js";
1
+ import { t as unpluginFactory } from "./plugin-Bsae1O4R.js";
2
2
  import { createWebpackPlugin } from "unplugin";
3
3
  //#region src/webpack.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-keywords",
3
- "version": "2.15.0",
3
+ "version": "2.16.0",
4
4
  "description": "A build plugin for structural string literal minification and obfuscation.",
5
5
  "keywords": [
6
6
  "unplugin",
@@ -70,7 +70,7 @@
70
70
  ],
71
71
  "dependencies": {
72
72
  "@babel/core": "^8.0.0-rc.5",
73
- "globby": "^16.2.0",
73
+ "ignore": "^7.0.5",
74
74
  "p-limit": "^7.3.0",
75
75
  "unplugin": "^3.0.0"
76
76
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash-C5ttE6yV.js","names":["t","blacklist","info"],"sources":["../src/internal/constants.ts","../src/internal/encode.ts","../src/internal/transform.ts","../src/internal/typegen.ts","../src/internal/cli.ts","../src/internal/hash.ts"],"sourcesContent":["/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nexport const VIRTUAL_MODULE_ID = '~keywords';\nexport const VIRTUAL_PUBLIC_MODULE_ID = '~keywords/public';\nexport const VIRTUAL_RAW_MODULE_ID = '~keywords/raw';\n\nexport const VIRTUAL_INTERNAL_MODULE_ID = '~keywords-internal';\nexport const VIRTUAL_INTERNAL_PUBLIC_MODULE_ID = '~keywords-internal/public';\nexport const VIRTUAL_INTERNAL_RAW_MODULE_ID = '~keywords-internal/raw';\n\nexport const PLUGIN_NAME = 'unplugin-keywords';\n\nexport const HASH_LENGTH = 7;\n\nexport const KEYWORD_ROUTE = '_';\n\n// URL-safe so that K.abc can be used in URL\nexport const DEBUG_SEPARATOR = '.';\n","/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\ndeclare const __encoded__: unique symbol;\ntype Encoded = string & { [__encoded__]: never };\n\nexport const encodeIdentifier = (identifier: string): Encoded => {\n let encoded = '';\n for (let i = 0; i < identifier.length; i++) {\n const c = identifier[i] as string;\n if (/[a-zA-Z0-9_]/.test(c)) {\n encoded += c;\n } else if (c === '$') {\n encoded += '$$';\n } else {\n encoded += `$${c.charCodeAt(0).toString(16).padStart(4, '0')}`;\n }\n }\n return encoded as Encoded;\n};\n\nexport const toSafeVarName = (encoded: Encoded): string => `_$${encoded}`;\n","/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n type FileResult,\n type NodePath,\n type PluginItem,\n type PluginObject,\n type PluginPass,\n types as t,\n transformSync,\n} from '@babel/core';\nimport {\n KEYWORD_ROUTE,\n PLUGIN_NAME,\n VIRTUAL_INTERNAL_MODULE_ID,\n VIRTUAL_INTERNAL_PUBLIC_MODULE_ID,\n VIRTUAL_INTERNAL_RAW_MODULE_ID,\n VIRTUAL_MODULE_ID,\n VIRTUAL_PUBLIC_MODULE_ID,\n VIRTUAL_RAW_MODULE_ID,\n} from './constants.js';\nimport { encodeIdentifier, toSafeVarName } from './encode.js';\n\nexport interface KeywordSet {\n local: Set<string>;\n public: Set<string>;\n raw: Set<string>;\n}\n\nconst isPureTypeSpace = (path: NodePath): boolean => {\n let current: NodePath | null = path;\n while (current) {\n const parent = current.parentPath;\n if (!parent) {\n break;\n }\n // 1. Value crossings via `typeof`\n if (parent.isTSTypeQuery()) {\n return false;\n }\n // 2. Computed keys (e.g., interface I { [Abc]: string })\n if ('computed' in parent.node && parent.node.computed) {\n if (current.key === 'key' || current.key === 'property') {\n return false;\n }\n }\n // 3-A. Definitive Type Contexts\n if (\n parent.isTSType() ||\n parent.isTSTypeParameterDeclaration() ||\n parent.isTSTypeParameterInstantiation() ||\n parent.isTSClassImplements() ||\n parent.isTSInterfaceHeritage()\n ) {\n return true;\n }\n // 3-B. Type Declaration Identifiers (e.g., interface Abc {}, type Abc = {})\n if (\n parent.isTSInterfaceDeclaration() ||\n parent.isTSTypeAliasDeclaration() ||\n parent.isTSEnumDeclaration() ||\n parent.isTSModuleDeclaration()\n ) {\n if (current.key === 'id') {\n return true;\n }\n }\n // 4. Continue up structural TS nodes (A.B.C)\n if (parent.isTSQualifiedName() || parent.isTSEntityName()) {\n current = current.parentPath;\n continue;\n }\n // 5. If we reach standard JS statements/expressions, it implies Value Space.\n if (parent.isExpression() || parent.isStatement()) {\n break;\n }\n current = current.parentPath;\n }\n return false;\n};\n\ninterface TransformState extends PluginPass {\n keywords: KeywordSet;\n keywordUids: {\n local: Map<string, t.Identifier>;\n public: Map<string, t.Identifier>;\n raw: Map<string, t.Identifier>;\n };\n}\n\ninterface TransformMetadata {\n keywords?: { local: string[]; public: string[]; raw: string[] };\n}\n\nconst transformPlugin = (mode: 'extract' | 'transform'): PluginItem => {\n const plugin: PluginObject<TransformState> = {\n name: `${PLUGIN_NAME}:${mode}`,\n\n visitor: {\n Program: {\n enter(_, state) {\n state.keywords = {\n local: new Set(),\n public: new Set(),\n raw: new Set(),\n };\n state.keywordUids = {\n local: new Map(),\n public: new Map(),\n raw: new Map(),\n };\n },\n\n exit(path, state) {\n const metadata = state.file.metadata as TransformMetadata;\n metadata.keywords = {\n local: Array.from(state.keywords.local),\n public: Array.from(state.keywords.public),\n raw: Array.from(state.keywords.raw),\n };\n\n if (mode === 'transform') {\n const newImports = [];\n for (const [keyword, safeId] of state.keywordUids.local.entries()) {\n const encoded = encodeIdentifier(keyword);\n newImports.push(\n t.importDeclaration(\n [t.importDefaultSpecifier(safeId)],\n t.stringLiteral(\n `${VIRTUAL_INTERNAL_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n ),\n ),\n );\n }\n for (const [\n keyword,\n safeId,\n ] of state.keywordUids.public.entries()) {\n const encoded = encodeIdentifier(keyword);\n newImports.push(\n t.importDeclaration(\n [t.importDefaultSpecifier(safeId)],\n t.stringLiteral(\n `${VIRTUAL_INTERNAL_PUBLIC_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n ),\n ),\n );\n }\n for (const [keyword, safeId] of state.keywordUids.raw.entries()) {\n const encoded = encodeIdentifier(keyword);\n newImports.push(\n t.importDeclaration(\n [t.importDefaultSpecifier(safeId)],\n t.stringLiteral(\n `${VIRTUAL_INTERNAL_RAW_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n ),\n ),\n );\n }\n if (newImports.length > 0) {\n path.unshiftContainer('body', newImports);\n }\n }\n },\n },\n\n ImportDeclaration(path, state) {\n const sourceValue = path.node.source.value;\n if (\n sourceValue !== VIRTUAL_MODULE_ID &&\n sourceValue !== VIRTUAL_PUBLIC_MODULE_ID &&\n sourceValue !== VIRTUAL_RAW_MODULE_ID\n ) {\n return;\n }\n const isPublic = sourceValue === VIRTUAL_PUBLIC_MODULE_ID;\n const isRaw = sourceValue === VIRTUAL_RAW_MODULE_ID;\n const targetSet = isRaw\n ? state.keywords.raw\n : isPublic\n ? state.keywords.public\n : state.keywords.local;\n const targetMap = isRaw\n ? state.keywordUids.raw\n : isPublic\n ? state.keywordUids.public\n : state.keywordUids.local;\n\n const programScope = path.scope.getProgramParent();\n const processKeyword = (keyword: string): t.Identifier | null => {\n targetSet.add(keyword);\n if (mode === 'extract') {\n return null;\n }\n if (targetMap.has(keyword)) {\n return targetMap.get(keyword) as t.Identifier;\n }\n const encoded = encodeIdentifier(keyword);\n const safeName = toSafeVarName(encoded);\n const uid = programScope.generateUidIdentifier(safeName);\n targetMap.set(keyword, uid);\n return uid;\n };\n\n for (const specifierPath of path.get('specifiers')) {\n const localName = specifierPath.node.local.name;\n const binding = path.scope.getBinding(localName);\n if (!binding) {\n continue;\n }\n\n // Case A: Default & Named Imports\n if (\n specifierPath.isImportDefaultSpecifier() ||\n specifierPath.isImportSpecifier()\n ) {\n let keyword: string;\n if (specifierPath.isImportDefaultSpecifier()) {\n keyword = 'default';\n } else {\n const imported = specifierPath.node.imported;\n keyword = t.isIdentifier(imported)\n ? imported.name\n : imported.value;\n }\n const uidNode = processKeyword(keyword);\n if (!uidNode) {\n continue;\n }\n\n // 1) Fast Path: Values & JSX\n for (const refPath of binding.referencePaths) {\n if (isPureTypeSpace(refPath)) {\n continue;\n }\n if (refPath.isJSXIdentifier()) {\n refPath.replaceWith(t.jsxIdentifier(uidNode.name));\n } else {\n refPath.replaceWith(t.cloneNode(uidNode));\n }\n }\n\n // 2) Slow Path: TS Types\n // NOTE: Can be skipped due to type erasure, but for consistency\n path.parentPath.traverse({\n // e.g., type T = typeof abc;\n TSTypeQuery(tsPath) {\n if (\n t.isIdentifier(tsPath.node.exprName) &&\n tsPath.node.exprName.name === localName &&\n tsPath.scope.getBinding(localName) === binding\n ) {\n tsPath.get('exprName').replaceWith(t.cloneNode(uidNode));\n }\n },\n });\n }\n\n // Case B: Namespace Imports\n else if (specifierPath.isImportNamespaceSpecifier()) {\n // 1) Fast Path: JS Values & JSX accesses\n for (const refPath of binding.referencePaths) {\n if (isPureTypeSpace(refPath)) {\n continue;\n }\n const parentPath = refPath.parentPath;\n if (!parentPath) {\n continue;\n }\n if (\n parentPath.isMemberExpression() &&\n parentPath.node.object === refPath.node\n ) {\n const propNode = parentPath.node.property;\n let keyword: string | undefined;\n if (!parentPath.node.computed && t.isIdentifier(propNode)) {\n keyword = propNode.name;\n } else if (parentPath.node.computed) {\n const propPath = parentPath.get('property');\n const evalResult = Array.isArray(propPath)\n ? { confident: false, value: null }\n : propPath.evaluate();\n if (\n evalResult.confident &&\n typeof evalResult.value === 'string'\n ) {\n keyword = evalResult.value;\n }\n }\n if (keyword) {\n const uidNode = processKeyword(keyword);\n if (uidNode) {\n parentPath.replaceWith(t.cloneNode(uidNode));\n }\n }\n } else if (\n parentPath.isJSXMemberExpression() &&\n parentPath.node.object === refPath.node\n ) {\n const keyword = parentPath.node.property.name;\n const uidNode = processKeyword(keyword);\n if (uidNode) {\n parentPath.replaceWith(t.jsxIdentifier(uidNode.name));\n }\n }\n }\n\n // 2) Slow Path: TS Namespace Types\n path.parentPath.traverse({\n // e.g., type T = typeof A.abc;\n TSTypeQuery(tsPath) {\n const expr = tsPath.node.exprName;\n if (\n t.isTSQualifiedName(expr) &&\n t.isIdentifier(expr.left) &&\n expr.left.name === localName &&\n tsPath.scope.getBinding(localName) === binding\n ) {\n const keyword = expr.right.name;\n const uidNode = processKeyword(keyword);\n if (uidNode) {\n tsPath.get('exprName').replaceWith(t.cloneNode(uidNode));\n }\n }\n },\n\n // e.g., type T = ((typeof A))['prop'];\n TSIndexedAccessType(tsPath) {\n const objPath = tsPath.get('objectType') as NodePath;\n if (\n objPath.isTSTypeQuery() &&\n t.isIdentifier(objPath.node.exprName) &&\n objPath.node.exprName.name === localName &&\n tsPath.scope.getBinding(localName) === binding\n ) {\n const indexNode = tsPath.node.indexType;\n let keyword: string | undefined;\n if (t.isTSLiteralType(indexNode)) {\n if (t.isStringLiteral(indexNode.literal)) {\n keyword = indexNode.literal.value;\n } else if (\n t.isTemplateLiteral(indexNode.literal) &&\n indexNode.literal.quasis.length === 1 &&\n indexNode.literal.quasis[0]?.value?.cooked\n ) {\n keyword = indexNode.literal.quasis[0].value.cooked;\n }\n }\n if (keyword) {\n const uidNode = processKeyword(keyword);\n if (uidNode) {\n tsPath.replaceWith(t.tsTypeQuery(t.cloneNode(uidNode)));\n }\n }\n }\n },\n });\n }\n }\n\n if (mode === 'transform') {\n path.remove();\n }\n },\n\n ExportNamedDeclaration(path, state) {\n const sourceValue = path.node.source?.value;\n if (\n sourceValue !== VIRTUAL_MODULE_ID &&\n sourceValue !== VIRTUAL_PUBLIC_MODULE_ID &&\n sourceValue !== VIRTUAL_RAW_MODULE_ID\n ) {\n return;\n }\n const isPublic = sourceValue === VIRTUAL_PUBLIC_MODULE_ID;\n const isRaw = sourceValue === VIRTUAL_RAW_MODULE_ID;\n const targetSet = isRaw\n ? state.keywords.raw\n : isPublic\n ? state.keywords.public\n : state.keywords.local;\n\n if (mode === 'extract') {\n for (const specifierPath of path.get('specifiers')) {\n if (specifierPath.isExportSpecifier()) {\n const local = specifierPath.node.local as\n | t.Identifier\n | t.StringLiteral; // local can be a StringLiteral in ES2022\n const keyword = t.isIdentifier(local) ? local.name : local.value;\n targetSet.add(keyword);\n }\n }\n return;\n }\n\n const newExports = path\n .get('specifiers')\n .map((specifierPath) => {\n if (specifierPath.isExportSpecifier()) {\n const local = specifierPath.node.local as\n | t.Identifier\n | t.StringLiteral; // local can be a StringLiteral in ES2022\n const keyword = t.isIdentifier(local) ? local.name : local.value;\n targetSet.add(keyword);\n const encoded = encodeIdentifier(keyword);\n const targetModuleId = isRaw\n ? VIRTUAL_INTERNAL_RAW_MODULE_ID\n : isPublic\n ? VIRTUAL_INTERNAL_PUBLIC_MODULE_ID\n : VIRTUAL_INTERNAL_MODULE_ID;\n return t.exportNamedDeclaration(\n null,\n [\n t.exportSpecifier(\n t.identifier('default'),\n specifierPath.node.exported,\n ),\n ],\n t.stringLiteral(\n `${targetModuleId}/${KEYWORD_ROUTE}/${encoded}`,\n ),\n );\n }\n return null;\n })\n .filter((node): node is t.ExportNamedDeclaration => node !== null);\n\n if (newExports.length > 0) {\n path.replaceWithMultiple(newExports);\n } else {\n path.remove();\n }\n },\n },\n };\n\n return () => plugin as PluginObject;\n};\n\nconst isJsx = (id: string): boolean => /\\.m?[jt]sx$/.test(id);\n\nexport const transformCode = (\n code: string,\n id: string,\n): {\n code: string;\n map: NonNullable<FileResult['map']> | null;\n keywords: KeywordSet;\n} | null => {\n if (\n !code.includes(VIRTUAL_MODULE_ID) &&\n !code.includes(VIRTUAL_PUBLIC_MODULE_ID) &&\n !code.includes(VIRTUAL_RAW_MODULE_ID)\n ) {\n return null;\n }\n const result = transformSync(code, {\n babelrc: false,\n configFile: false,\n filename: id,\n sourceMaps: true,\n ast: false,\n plugins: [transformPlugin('transform')],\n parserOpts: {\n plugins: ['typescript', ...(isJsx(id) ? (['jsx'] as const) : [])],\n },\n });\n if (!result) {\n return null;\n }\n const metadata = result.metadata as TransformMetadata | undefined;\n const keywords: KeywordSet = {\n local: new Set(metadata?.keywords?.local ?? []),\n public: new Set(metadata?.keywords?.public ?? []),\n raw: new Set(metadata?.keywords?.raw ?? []),\n };\n return {\n code: result.code ?? '',\n map: result.map ?? null,\n keywords,\n };\n};\n\nexport const extractKeywords = (\n code: string,\n id: string,\n): KeywordSet | null => {\n if (\n !code.includes(VIRTUAL_MODULE_ID) &&\n !code.includes(VIRTUAL_PUBLIC_MODULE_ID) &&\n !code.includes(VIRTUAL_RAW_MODULE_ID)\n ) {\n return null;\n }\n let result: FileResult | null;\n try {\n result = transformSync(code, {\n babelrc: false,\n configFile: false,\n sourceMaps: false,\n ast: false,\n code: false,\n plugins: [transformPlugin('extract')],\n parserOpts: {\n plugins: ['typescript', ...(isJsx(id) ? (['jsx'] as const) : [])],\n errorRecovery: true,\n },\n });\n } catch {\n return null;\n }\n if (!result) {\n return null;\n }\n const metadata = result.metadata as TransformMetadata | undefined;\n return {\n local: new Set(metadata?.keywords?.local ?? []),\n public: new Set(metadata?.keywords?.public ?? []),\n raw: new Set(metadata?.keywords?.raw ?? []),\n };\n};\n\nexport const preprocessForExtract = async (\n code: string,\n id: string,\n): Promise<string | null> => {\n let finalCode = code;\n if (\n !code.includes(VIRTUAL_MODULE_ID) &&\n !code.includes(VIRTUAL_PUBLIC_MODULE_ID) &&\n !code.includes(VIRTUAL_RAW_MODULE_ID)\n ) {\n return null;\n }\n if (/\\.svelte$/.test(id)) {\n try {\n const compiler = await import('svelte/compiler');\n const result = compiler.compile(finalCode, { filename: id });\n finalCode = result.js.code;\n } catch {\n return null;\n }\n }\n return finalCode;\n};\n","/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nimport { DEBUG_SEPARATOR, HASH_LENGTH } from './constants.js';\nimport { encodeIdentifier, toSafeVarName } from './encode.js';\n\nexport const generateTypeDeclaration = (\n keywords: Set<string>,\n mode: 'local' | 'public' | 'raw' = 'local',\n): string => {\n const sortedKeywords = Array.from(keywords).sort();\n const content = [];\n\n for (const keyword of sortedKeywords) {\n const encoded = encodeIdentifier(keyword);\n const safeName = toSafeVarName(encoded);\n const hash = mode === 'public' ? '*'.repeat(HASH_LENGTH) : '==';\n const value =\n mode === 'raw' ? keyword : `${hash}${DEBUG_SEPARATOR}${keyword}`;\n content.push(`declare const ${safeName}: ${JSON.stringify(value)};`);\n }\n content.push('');\n\n content.push('export {');\n for (const keyword of sortedKeywords) {\n const encoded = encodeIdentifier(keyword);\n const safeName = toSafeVarName(encoded);\n content.push(` ${safeName} as ${JSON.stringify(keyword)},`);\n }\n content.push('};');\n content.push('');\n\n return content.join('\\n');\n};\n","/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { globby } from 'globby';\nimport pLimit from 'p-limit';\nimport {\n extractKeywords,\n type KeywordSet,\n preprocessForExtract,\n} from './transform.js';\nimport { generateTypeDeclaration } from './typegen.js';\n\nconst collectKeywordsFromRoot = async (\n root: string,\n silent: boolean,\n ignoredDirs: string[] = [],\n concurrency: number = 100,\n): Promise<KeywordSet> => {\n const collectedKeywords: KeywordSet = {\n local: new Set(),\n public: new Set(),\n raw: new Set(),\n };\n\n const start = performance.now();\n if (!silent) {\n console.error('Scanning project files for keywords...');\n }\n\n const files = await globby('**/*.{js,ts,mjs,mts,jsx,tsx,mjsx,mtsx,svelte}', {\n cwd: root,\n absolute: false,\n ignore: ['**/node_modules/**', ...ignoredDirs.map((dir) => `${dir}/**`)],\n gitignore: true,\n });\n\n let processed = 0;\n const limit = pLimit({ concurrency });\n await limit.map(files, async (file) => {\n let code: string | null;\n try {\n code = await readFile(file, 'utf-8');\n } catch {\n return;\n }\n code = await preprocessForExtract(code, file);\n if (!code) {\n return;\n }\n const keywords = extractKeywords(code, file);\n if (!keywords) {\n return;\n }\n for (const keyword of keywords.local) {\n collectedKeywords.local.add(keyword);\n }\n for (const keyword of keywords.public) {\n collectedKeywords.public.add(keyword);\n }\n for (const keyword of keywords.raw) {\n collectedKeywords.raw.add(keyword);\n }\n processed++;\n });\n\n const elapsed = performance.now() - start;\n if (!silent) {\n console.error(\n `Scan complete: ${processed}/${files.length} files, ` +\n `${collectedKeywords.local.size} local, ` +\n `${collectedKeywords.public.size} public, ` +\n `${collectedKeywords.raw.size} raw keywords ` +\n `(${elapsed.toFixed(2)}ms).`,\n );\n }\n\n return collectedKeywords;\n};\n\nconst pkgJson = {\n private: true,\n type: 'module',\n sideEffects: false,\n exports: {\n '.': {\n types: './index.d.ts',\n },\n './public': {\n types: './public.d.ts',\n },\n './raw': {\n types: './raw.d.ts',\n },\n },\n};\n\ninterface RunnerOptions {\n root: string;\n silent: boolean;\n outDir: string;\n}\n\nexport const createRunner = (options?: Partial<RunnerOptions>) => {\n const {\n root = process.cwd(),\n silent = false,\n outDir = path.join('node_modules', '~keywords'),\n } = options ?? {};\n return {\n async collect(): Promise<KeywordSet> {\n return collectKeywordsFromRoot(root, silent);\n },\n\n async save(keywords: KeywordSet): Promise<void> {\n const content = generateTypeDeclaration(keywords.local);\n const publicContent = generateTypeDeclaration(keywords.public, 'public');\n const rawContent = generateTypeDeclaration(keywords.raw, 'raw');\n const outPath = path.join(root, outDir);\n await mkdir(outPath, { recursive: true });\n await writeFile(path.join(outPath, 'index.d.ts'), `${content.trim()}\\n`);\n await writeFile(\n path.join(outPath, 'public.d.ts'),\n `${publicContent.trim()}\\n`,\n );\n await writeFile(path.join(outPath, 'raw.d.ts'), `${rawContent.trim()}\\n`);\n await writeFile(\n path.join(outPath, 'package.json'),\n `${JSON.stringify(pkgJson, null, 2)}\\n`,\n );\n },\n\n async run(): Promise<void> {\n const keywords = await this.collect();\n await this.save(keywords);\n },\n };\n};\n","/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nimport { createHmac, hkdfSync } from 'node:crypto';\nimport blacklist from 'virtual:blacklist';\nimport {\n HASH_LENGTH,\n VIRTUAL_MODULE_ID,\n VIRTUAL_PUBLIC_MODULE_ID,\n} from './constants.js';\n\nconst ALPHA_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst BASE62_CHARS = `${ALPHA_CHARS}0123456789`;\n\nconst ALPHA_LEN = BigInt(ALPHA_CHARS.length); // 52n\nconst BASE62_LEN = BigInt(BASE62_CHARS.length); // 62n\n\nexport type Hasher = (input: string) => string;\n\n// Format: [1 Alpha] + [N Base62]\nexport const createHasher = (secret: string): Hasher => {\n const base62TailLength = HASH_LENGTH - 1;\n\n const cache = new Map<string, string>();\n return (input) => {\n if (cache.has(input)) {\n return cache.get(input) as string;\n }\n\n const info = VIRTUAL_PUBLIC_MODULE_ID;\n let retry = 0;\n let result: string;\n\n do {\n const r = retry.toString();\n retry++;\n const payload = `${info.length}:${info}|${input.length}:${input}|${r.length}:${r}`;\n const hasher = createHmac('sha256', secret);\n const buffer = hasher.update(payload).digest('hex');\n\n let entropy = BigInt(`0x${buffer}`);\n result = '';\n\n result += ALPHA_CHARS[Number(entropy % ALPHA_LEN)];\n entropy /= ALPHA_LEN;\n for (let i = 0; i < base62TailLength; i++) {\n result += BASE62_CHARS[Number(entropy % BASE62_LEN)];\n entropy /= BASE62_LEN;\n }\n } while (blacklist.has(result));\n\n cache.set(input, result);\n return result;\n };\n};\n\n// Fisher-Yates based deterministic shuffle\nconst shuffle = (str: string, secret: string, salt: string): string => {\n const arr = Array.from(str);\n const requiredBytes = (arr.length - 1) * 4;\n\n const info = VIRTUAL_MODULE_ID;\n const keyingMaterial = hkdfSync('sha256', secret, salt, info, requiredBytes);\n const prngBuffer = Buffer.from(keyingMaterial);\n\n let byteOffset = 0;\n for (let i = arr.length - 1; i > 0; i--) {\n const random32 = prngBuffer.readUInt32BE(byteOffset);\n byteOffset += 4;\n const j = random32 % (i + 1);\n const temp = arr[i] as string;\n arr[i] = arr[j] as string;\n arr[j] = temp;\n }\n\n return arr.join('');\n};\n\nexport const createCounter = (secret: string): Hasher => {\n const shuffledAlpha = shuffle(ALPHA_CHARS, secret, 'alpha');\n const shuffledBase62 = shuffle(BASE62_CHARS, secret, 'base62');\n\n let index = 0;\n const cache = new Map<string, string>();\n return (input) => {\n if (cache.has(input)) {\n return cache.get(input) as string;\n }\n\n let result: string;\n do {\n result = '';\n let current = index;\n index++;\n\n result += shuffledAlpha[current % shuffledAlpha.length];\n current = Math.floor(current / shuffledAlpha.length);\n while (current > 0) {\n current--;\n result += shuffledBase62[current % shuffledBase62.length];\n current = Math.floor(current / shuffledBase62.length);\n }\n } while (blacklist.has(result));\n\n cache.set(input, result);\n return result;\n };\n};\n"],"mappings":";;;;;;;;;;;AAKA,MAAa,oBAAoB;AACjC,MAAa,2BAA2B;AACxC,MAAa,wBAAwB;AAErC,MAAa,6BAA6B;AAC1C,MAAa,oCAAoC;AACjD,MAAa,iCAAiC;AAE9C,MAAa,cAAc;;;;;;;ACL3B,MAAa,oBAAoB,eAAgC;CAC/D,IAAI,UAAU;CACd,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;EAC1C,MAAM,IAAI,WAAW;EACrB,IAAI,eAAe,KAAK,EAAE,EACxB,WAAW;OACN,IAAI,MAAM,KACf,WAAW;OAEX,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI;;CAGhE,OAAO;;AAGT,MAAa,iBAAiB,YAA6B,KAAK;;;;;;;ACShE,MAAM,mBAAmB,SAA4B;CACnD,IAAI,UAA2B;CAC/B,OAAO,SAAS;EACd,MAAM,SAAS,QAAQ;EACvB,IAAI,CAAC,QACH;EAGF,IAAI,OAAO,eAAe,EACxB,OAAO;EAGT,IAAI,cAAc,OAAO,QAAQ,OAAO,KAAK;OACvC,QAAQ,QAAQ,SAAS,QAAQ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AM,iBAAiB,QAAQ,cAAc,QAAQ,SAAS;CAE9D,IAAI,QAAQ;CACZ,MAAM,wBAAQ,IAAI,KAAqB;CACvC,QAAQ,UAAU;EAChB,IAAI,MAAM,IAAI,MAAM,EAClB,OAAO,MAAM,IAAI,MAAM;EAGzB,IAAI;EACJ,GAAG;GACD,SAAS;GACT,IAAI,UAAU;GACd;GAEA,UAAU,cAAc,UAAU,cAAc;GAChD,UAAU,KAAK,MAAM,UAAU,cAAc,OAAO;GACpD,OAAO,UAAU,GAAG;IAClB;IACA,UAAU,eAAe,UAAU,eAAe;IAClD,UAAU,KAAK,MAAM,UAAU,eAAe,OAAO;;WAEhDD,2BAAU,IAAI,OAAO;EAE9B,MAAM,IAAI,OAAO,OAAO;EACxB,OAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-DEHtvPIq.js","names":[],"sources":["../src/internal/plugin.ts"],"sourcesContent":["/**\n * @license\n * SPDX-License-Identifier: MIT\n */\n\nimport { readFile } from 'node:fs/promises';\nimport pLimit from 'p-limit';\nimport type { UnpluginFactory } from 'unplugin';\nimport { createRunner } from './cli.js';\nimport {\n DEBUG_SEPARATOR,\n KEYWORD_ROUTE,\n PLUGIN_NAME,\n VIRTUAL_INTERNAL_MODULE_ID,\n VIRTUAL_INTERNAL_PUBLIC_MODULE_ID,\n VIRTUAL_INTERNAL_RAW_MODULE_ID,\n VIRTUAL_MODULE_ID,\n VIRTUAL_PUBLIC_MODULE_ID,\n VIRTUAL_RAW_MODULE_ID,\n} from './constants.js';\nimport { encodeIdentifier } from './encode.js';\nimport { createCounter, createHasher, type Hasher } from './hash.js';\nimport {\n extractKeywords,\n type KeywordSet,\n preprocessForExtract,\n transformCode,\n} from './transform.js';\n\nconst resolveId = (id: string): string => `\\0${id}`;\n\nconst splitQuery = (id: string): [string, string | undefined] => {\n const index = id.indexOf('?');\n if (index === -1) {\n return [id, undefined];\n }\n return [id.slice(0, index), id.slice(index + 1)];\n};\n\nconst toIncludes = (id: string): RegExp[] => [new RegExp(`^${id}/`)];\n\nconst SUFFIX_REGEX = /\\.(?:m?[jt]sx?|svelte)(?:$|\\?)/;\nconst COMMON_EXCLUDES = [/\\/node_modules\\//];\n\nexport interface Options {\n /**\n * If true, preserves the original keyword as a suffix in the generated\n * identifier for easier debugging (e.g., `\"zXpL21k.SET_USER\"`).\n */\n isDev: boolean;\n /**\n * The cryptographic key used to initialize the deterministic HMAC algorithm.\n * Modifying this value will globally rotate all generated hashes.\n * To ensure cross-boundary consistency between independent builds,\n * they must share the same secret key.\n */\n secret: string;\n}\n\nexport const unpluginFactory: UnpluginFactory<Options> = ({\n isDev,\n secret,\n}) => {\n const runner = createRunner({ silent: true });\n const runnerLimit = pLimit({ concurrency: 1 });\n const typegenKeywords: KeywordSet = {\n local: new Set(),\n public: new Set(),\n raw: new Set(),\n };\n\n let isInitialized = false;\n const runInit = async () => {\n try {\n const keywords = await runner.collect();\n for (const keyword of keywords.local) {\n typegenKeywords.local.add(keyword);\n }\n for (const keyword of keywords.public) {\n typegenKeywords.public.add(keyword);\n }\n for (const keyword of keywords.raw) {\n typegenKeywords.raw.add(keyword);\n }\n await runner.save(typegenKeywords);\n isInitialized = true;\n } catch {}\n };\n\n let hasherPublic: Hasher;\n let hasherLocal: Hasher;\n let resolvedMap: Map<string, string>;\n\n return {\n name: PLUGIN_NAME,\n\n buildStart() {\n hasherPublic = createHasher(secret);\n hasherLocal = createCounter(secret);\n resolvedMap = new Map();\n if (!isInitialized) {\n runnerLimit(async () => {\n if (!isInitialized) {\n await runInit();\n }\n });\n }\n },\n\n async buildEnd() {\n // Flush the background queue\n await runnerLimit(() => Promise.resolve());\n },\n\n resolveId: {\n filter: {\n id: {\n include: [\n ...toIncludes(VIRTUAL_INTERNAL_MODULE_ID),\n ...toIncludes(VIRTUAL_INTERNAL_PUBLIC_MODULE_ID),\n ...toIncludes(VIRTUAL_INTERNAL_RAW_MODULE_ID),\n ],\n exclude: COMMON_EXCLUDES,\n },\n },\n handler(id) {\n return resolveId(id);\n },\n },\n\n load: {\n filter: {\n id: {\n include: [\n ...toIncludes(resolveId(VIRTUAL_INTERNAL_MODULE_ID)),\n ...toIncludes(resolveId(VIRTUAL_INTERNAL_PUBLIC_MODULE_ID)),\n ...toIncludes(resolveId(VIRTUAL_INTERNAL_RAW_MODULE_ID)),\n ],\n exclude: COMMON_EXCLUDES,\n },\n },\n handler(id) {\n const [validId] = splitQuery(id);\n if (resolvedMap.has(validId)) {\n return resolvedMap.get(validId);\n }\n return null;\n },\n },\n\n transform: {\n filter: {\n id: {\n include: [SUFFIX_REGEX],\n exclude: COMMON_EXCLUDES,\n },\n code: {\n include: [\n VIRTUAL_MODULE_ID,\n VIRTUAL_PUBLIC_MODULE_ID,\n VIRTUAL_RAW_MODULE_ID,\n ],\n },\n },\n handler(code, id) {\n const [validId] = splitQuery(id);\n const result = transformCode(code, validId);\n if (!result) {\n return null;\n }\n const { code: transformed, map, keywords } = result;\n for (const keyword of keywords.local) {\n const encoded = encodeIdentifier(keyword);\n const resolvedId = resolveId(\n `${VIRTUAL_INTERNAL_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n );\n if (resolvedMap.has(resolvedId)) {\n continue;\n }\n const hash = hasherLocal(keyword);\n const value = isDev ? `${hash}${DEBUG_SEPARATOR}${keyword}` : hash;\n resolvedMap.set(\n resolvedId,\n `export default ${JSON.stringify(value)};\\n`,\n );\n }\n for (const keyword of keywords.public) {\n const encoded = encodeIdentifier(keyword);\n const resolvedId = resolveId(\n `${VIRTUAL_INTERNAL_PUBLIC_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n );\n if (resolvedMap.has(resolvedId)) {\n continue;\n }\n const hash = hasherPublic(keyword);\n const value = isDev ? `${hash}${DEBUG_SEPARATOR}${keyword}` : hash;\n resolvedMap.set(\n resolvedId,\n `export default ${JSON.stringify(value)};\\n`,\n );\n }\n for (const keyword of keywords.raw) {\n const encoded = encodeIdentifier(keyword);\n const resolvedId = resolveId(\n `${VIRTUAL_INTERNAL_RAW_MODULE_ID}/${KEYWORD_ROUTE}/${encoded}`,\n );\n if (resolvedMap.has(resolvedId)) {\n continue;\n }\n resolvedMap.set(\n resolvedId,\n `export default ${JSON.stringify(keyword)};\\n`,\n );\n }\n return { code: transformed, map };\n },\n },\n\n async watchChange(id, { event }) {\n if (\n !SUFFIX_REGEX.test(id) ||\n COMMON_EXCLUDES.some((regex) => regex.test(id)) ||\n event === 'delete'\n ) {\n return;\n }\n const [validId] = splitQuery(id);\n let code: string | null;\n try {\n code = await readFile(validId, 'utf-8');\n } catch {\n return;\n }\n code = await preprocessForExtract(code, validId);\n if (!code) {\n return;\n }\n const keywords = extractKeywords(code, validId);\n if (!keywords) {\n return;\n }\n let isAdded = false;\n for (const keyword of keywords.local) {\n if (!typegenKeywords.local.has(keyword)) {\n typegenKeywords.local.add(keyword);\n isAdded = true;\n }\n }\n for (const keyword of keywords.public) {\n if (!typegenKeywords.public.has(keyword)) {\n typegenKeywords.public.add(keyword);\n isAdded = true;\n }\n }\n for (const keyword of keywords.raw) {\n if (!typegenKeywords.raw.has(keyword)) {\n typegenKeywords.raw.add(keyword);\n isAdded = true;\n }\n }\n if (!isInitialized || isAdded) {\n runnerLimit(async () => {\n if (!isInitialized) {\n await runInit();\n } else if (isAdded) {\n try {\n await runner.save(typegenKeywords);\n } catch {}\n }\n });\n }\n },\n };\n};\n"],"mappings":";;;;;;;;AA6BA,MAAM,aAAa,OAAuB,KAAK;AAE/C,MAAM,cAAc,OAA6C;CAC/D,MAAM,QAAQ,GAAG,QAAQ,IAAI;CAC7B,IAAI,UAAU,IACZ,OAAO,CAAC,IAAI,KAAA,EAAU;CAExB,OAAO,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,QAAQ,EAAE,CAAC;;AAGlD,MAAM,cAAc,OAAyB,CAAC,IAAI,OAAO,IAAI,GAAG,GAAG,CAAC;AAEpE,MAAM,eAAe;AACrB,MAAM,kBAAkB,CAAC,mBAAmB;AA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