@tanstack/start-plugin-core 1.166.11 → 1.166.13

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.
Files changed (87) hide show
  1. package/dist/esm/build-sitemap.js +94 -123
  2. package/dist/esm/build-sitemap.js.map +1 -1
  3. package/dist/esm/constants.js +15 -20
  4. package/dist/esm/constants.js.map +1 -1
  5. package/dist/esm/dev-server-plugin/dev-styles.js +137 -150
  6. package/dist/esm/dev-server-plugin/dev-styles.js.map +1 -1
  7. package/dist/esm/dev-server-plugin/extract-html-scripts.js +16 -15
  8. package/dist/esm/dev-server-plugin/extract-html-scripts.js.map +1 -1
  9. package/dist/esm/dev-server-plugin/plugin.js +125 -195
  10. package/dist/esm/dev-server-plugin/plugin.js.map +1 -1
  11. package/dist/esm/import-protection-plugin/ast.js +6 -5
  12. package/dist/esm/import-protection-plugin/ast.js.map +1 -1
  13. package/dist/esm/import-protection-plugin/constants.js +20 -22
  14. package/dist/esm/import-protection-plugin/constants.js.map +1 -1
  15. package/dist/esm/import-protection-plugin/defaults.js +35 -25
  16. package/dist/esm/import-protection-plugin/defaults.js.map +1 -1
  17. package/dist/esm/import-protection-plugin/extensionlessAbsoluteIdResolver.js +93 -92
  18. package/dist/esm/import-protection-plugin/extensionlessAbsoluteIdResolver.js.map +1 -1
  19. package/dist/esm/import-protection-plugin/matchers.js +23 -24
  20. package/dist/esm/import-protection-plugin/matchers.js.map +1 -1
  21. package/dist/esm/import-protection-plugin/plugin.js +1045 -1361
  22. package/dist/esm/import-protection-plugin/plugin.js.map +1 -1
  23. package/dist/esm/import-protection-plugin/postCompileUsage.js +58 -55
  24. package/dist/esm/import-protection-plugin/postCompileUsage.js.map +1 -1
  25. package/dist/esm/import-protection-plugin/rewriteDeniedImports.js +187 -259
  26. package/dist/esm/import-protection-plugin/rewriteDeniedImports.js.map +1 -1
  27. package/dist/esm/import-protection-plugin/sourceLocation.js +238 -248
  28. package/dist/esm/import-protection-plugin/sourceLocation.js.map +1 -1
  29. package/dist/esm/import-protection-plugin/trace.js +173 -184
  30. package/dist/esm/import-protection-plugin/trace.js.map +1 -1
  31. package/dist/esm/import-protection-plugin/utils.js +132 -111
  32. package/dist/esm/import-protection-plugin/utils.js.map +1 -1
  33. package/dist/esm/import-protection-plugin/virtualModules.js +214 -194
  34. package/dist/esm/import-protection-plugin/virtualModules.js.map +1 -1
  35. package/dist/esm/index.js +2 -7
  36. package/dist/esm/load-env-plugin/plugin.js +12 -11
  37. package/dist/esm/load-env-plugin/plugin.js.map +1 -1
  38. package/dist/esm/output-directory.js +10 -10
  39. package/dist/esm/output-directory.js.map +1 -1
  40. package/dist/esm/plugin.js +275 -355
  41. package/dist/esm/plugin.js.map +1 -1
  42. package/dist/esm/post-server-build.js +39 -53
  43. package/dist/esm/post-server-build.js.map +1 -1
  44. package/dist/esm/prerender.js +177 -239
  45. package/dist/esm/prerender.js.map +1 -1
  46. package/dist/esm/preview-server-plugin/plugin.js +41 -44
  47. package/dist/esm/preview-server-plugin/plugin.js.map +1 -1
  48. package/dist/esm/queue.js +115 -126
  49. package/dist/esm/queue.js.map +1 -1
  50. package/dist/esm/resolve-entries.js +31 -32
  51. package/dist/esm/resolve-entries.js.map +1 -1
  52. package/dist/esm/schema.js +156 -179
  53. package/dist/esm/schema.js.map +1 -1
  54. package/dist/esm/start-compiler-plugin/compiler.js +655 -812
  55. package/dist/esm/start-compiler-plugin/compiler.js.map +1 -1
  56. package/dist/esm/start-compiler-plugin/handleClientOnlyJSX.js +25 -8
  57. package/dist/esm/start-compiler-plugin/handleClientOnlyJSX.js.map +1 -1
  58. package/dist/esm/start-compiler-plugin/handleCreateIsomorphicFn.js +22 -19
  59. package/dist/esm/start-compiler-plugin/handleCreateIsomorphicFn.js.map +1 -1
  60. package/dist/esm/start-compiler-plugin/handleCreateMiddleware.js +20 -22
  61. package/dist/esm/start-compiler-plugin/handleCreateMiddleware.js.map +1 -1
  62. package/dist/esm/start-compiler-plugin/handleCreateServerFn.js +187 -255
  63. package/dist/esm/start-compiler-plugin/handleCreateServerFn.js.map +1 -1
  64. package/dist/esm/start-compiler-plugin/handleEnvOnly.js +23 -33
  65. package/dist/esm/start-compiler-plugin/handleEnvOnly.js.map +1 -1
  66. package/dist/esm/start-compiler-plugin/plugin.js +247 -291
  67. package/dist/esm/start-compiler-plugin/plugin.js.map +1 -1
  68. package/dist/esm/start-compiler-plugin/utils.js +27 -27
  69. package/dist/esm/start-compiler-plugin/utils.js.map +1 -1
  70. package/dist/esm/start-manifest-plugin/manifestBuilder.js +272 -378
  71. package/dist/esm/start-manifest-plugin/manifestBuilder.js.map +1 -1
  72. package/dist/esm/start-manifest-plugin/plugin.js +35 -44
  73. package/dist/esm/start-manifest-plugin/plugin.js.map +1 -1
  74. package/dist/esm/start-router-plugin/constants.js +6 -5
  75. package/dist/esm/start-router-plugin/constants.js.map +1 -1
  76. package/dist/esm/start-router-plugin/generator-plugins/prerender-routes-plugin.js +24 -19
  77. package/dist/esm/start-router-plugin/generator-plugins/prerender-routes-plugin.js.map +1 -1
  78. package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js +28 -29
  79. package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js.map +1 -1
  80. package/dist/esm/start-router-plugin/plugin.js +146 -199
  81. package/dist/esm/start-router-plugin/plugin.js.map +1 -1
  82. package/dist/esm/start-router-plugin/pruneServerOnlySubtrees.js +32 -31
  83. package/dist/esm/start-router-plugin/pruneServerOnlySubtrees.js.map +1 -1
  84. package/dist/esm/utils.js +14 -14
  85. package/dist/esm/utils.js.map +1 -1
  86. package/package.json +7 -7
  87. package/dist/esm/index.js.map +0 -1
@@ -1,95 +1,96 @@
1
- import { isAbsolute, dirname, extname, basename } from "node:path";
2
- import { resolveModulePath } from "exsolve";
3
1
  import { KNOWN_SOURCE_EXTENSIONS } from "./constants.js";
4
2
  import { normalizeFilePath } from "./utils.js";
5
- const FILE_RESOLUTION_EXTENSIONS = [...KNOWN_SOURCE_EXTENSIONS];
6
- class ExtensionlessAbsoluteIdResolver {
7
- entries = /* @__PURE__ */ new Map();
8
- keysByDep = /* @__PURE__ */ new Map();
9
- clear() {
10
- this.entries.clear();
11
- this.keysByDep.clear();
12
- }
13
- /**
14
- * Invalidate any cached entries that might be affected by changes to `id`.
15
- * We invalidate both the file and its containing directory.
16
- */
17
- invalidateByFile(id) {
18
- const file = normalizeFilePath(id);
19
- this.invalidateDep(`file:${file}`);
20
- if (isAbsolute(file)) {
21
- this.invalidateDep(`dir:${dirname(file)}`);
22
- }
23
- }
24
- resolve(id) {
25
- const key = normalizeFilePath(id);
26
- const cached = this.entries.get(key);
27
- if (cached) return cached.value;
28
- let result = key;
29
- let resolvedPhysical;
30
- if (isAbsolute(key)) {
31
- const ext = extname(key);
32
- if (!FILE_RESOLUTION_EXTENSIONS.includes(ext)) {
33
- const resolved = resolveModulePath(`./${basename(key)}`, {
34
- from: dirname(key),
35
- extensions: FILE_RESOLUTION_EXTENSIONS,
36
- try: true
37
- });
38
- if (resolved) {
39
- resolvedPhysical = resolved;
40
- result = normalizeFilePath(resolved);
41
- }
42
- }
43
- }
44
- const resolvedFile = resolvedPhysical ? normalizeFilePath(resolvedPhysical) : void 0;
45
- const deps = this.buildDepsForKey(key, resolvedFile);
46
- this.entries.set(key, { value: result, deps });
47
- this.indexDeps(key, deps);
48
- return result;
49
- }
50
- invalidateDep(dep) {
51
- const keys = this.keysByDep.get(dep);
52
- if (!keys) return;
53
- for (const key of Array.from(keys)) {
54
- this.deleteKey(key);
55
- }
56
- }
57
- buildDepsForKey(key, resolvedFile) {
58
- const deps = /* @__PURE__ */ new Set();
59
- deps.add(`file:${key}`);
60
- if (isAbsolute(key)) {
61
- deps.add(`dir:${dirname(key)}`);
62
- }
63
- if (resolvedFile) {
64
- deps.add(`file:${resolvedFile}`);
65
- }
66
- return deps;
67
- }
68
- indexDeps(key, deps) {
69
- for (const dep of deps) {
70
- let keys = this.keysByDep.get(dep);
71
- if (!keys) {
72
- keys = /* @__PURE__ */ new Set();
73
- this.keysByDep.set(dep, keys);
74
- }
75
- keys.add(key);
76
- }
77
- }
78
- deleteKey(key) {
79
- const entry = this.entries.get(key);
80
- this.entries.delete(key);
81
- if (!entry) return;
82
- for (const dep of entry.deps) {
83
- const keys = this.keysByDep.get(dep);
84
- if (!keys) continue;
85
- keys.delete(key);
86
- if (keys.size === 0) {
87
- this.keysByDep.delete(dep);
88
- }
89
- }
90
- }
91
- }
92
- export {
93
- ExtensionlessAbsoluteIdResolver
3
+ import { basename, dirname, extname, isAbsolute } from "node:path";
4
+ import { resolveModulePath } from "exsolve";
5
+ //#region src/import-protection-plugin/extensionlessAbsoluteIdResolver.ts
6
+ var FILE_RESOLUTION_EXTENSIONS = [...KNOWN_SOURCE_EXTENSIONS];
7
+ /**
8
+ * Canonicalize extensionless absolute IDs like `/src/foo.server` to the
9
+ * physical file when possible.
10
+ *
11
+ * Keeps a small cache plus a reverse index so we can invalidate on HMR
12
+ * updates without clearing the whole map.
13
+ */
14
+ var ExtensionlessAbsoluteIdResolver = class {
15
+ entries = /* @__PURE__ */ new Map();
16
+ keysByDep = /* @__PURE__ */ new Map();
17
+ clear() {
18
+ this.entries.clear();
19
+ this.keysByDep.clear();
20
+ }
21
+ /**
22
+ * Invalidate any cached entries that might be affected by changes to `id`.
23
+ * We invalidate both the file and its containing directory.
24
+ */
25
+ invalidateByFile(id) {
26
+ const file = normalizeFilePath(id);
27
+ this.invalidateDep(`file:${file}`);
28
+ if (isAbsolute(file)) this.invalidateDep(`dir:${dirname(file)}`);
29
+ }
30
+ resolve(id) {
31
+ const key = normalizeFilePath(id);
32
+ const cached = this.entries.get(key);
33
+ if (cached) return cached.value;
34
+ let result = key;
35
+ let resolvedPhysical;
36
+ if (isAbsolute(key)) {
37
+ const ext = extname(key);
38
+ if (!FILE_RESOLUTION_EXTENSIONS.includes(ext)) {
39
+ const resolved = resolveModulePath(`./${basename(key)}`, {
40
+ from: dirname(key),
41
+ extensions: FILE_RESOLUTION_EXTENSIONS,
42
+ try: true
43
+ });
44
+ if (resolved) {
45
+ resolvedPhysical = resolved;
46
+ result = normalizeFilePath(resolved);
47
+ }
48
+ }
49
+ }
50
+ const resolvedFile = resolvedPhysical ? normalizeFilePath(resolvedPhysical) : void 0;
51
+ const deps = this.buildDepsForKey(key, resolvedFile);
52
+ this.entries.set(key, {
53
+ value: result,
54
+ deps
55
+ });
56
+ this.indexDeps(key, deps);
57
+ return result;
58
+ }
59
+ invalidateDep(dep) {
60
+ const keys = this.keysByDep.get(dep);
61
+ if (!keys) return;
62
+ for (const key of Array.from(keys)) this.deleteKey(key);
63
+ }
64
+ buildDepsForKey(key, resolvedFile) {
65
+ const deps = /* @__PURE__ */ new Set();
66
+ deps.add(`file:${key}`);
67
+ if (isAbsolute(key)) deps.add(`dir:${dirname(key)}`);
68
+ if (resolvedFile) deps.add(`file:${resolvedFile}`);
69
+ return deps;
70
+ }
71
+ indexDeps(key, deps) {
72
+ for (const dep of deps) {
73
+ let keys = this.keysByDep.get(dep);
74
+ if (!keys) {
75
+ keys = /* @__PURE__ */ new Set();
76
+ this.keysByDep.set(dep, keys);
77
+ }
78
+ keys.add(key);
79
+ }
80
+ }
81
+ deleteKey(key) {
82
+ const entry = this.entries.get(key);
83
+ this.entries.delete(key);
84
+ if (!entry) return;
85
+ for (const dep of entry.deps) {
86
+ const keys = this.keysByDep.get(dep);
87
+ if (!keys) continue;
88
+ keys.delete(key);
89
+ if (keys.size === 0) this.keysByDep.delete(dep);
90
+ }
91
+ }
94
92
  };
95
- //# sourceMappingURL=extensionlessAbsoluteIdResolver.js.map
93
+ //#endregion
94
+ export { ExtensionlessAbsoluteIdResolver };
95
+
96
+ //# sourceMappingURL=extensionlessAbsoluteIdResolver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensionlessAbsoluteIdResolver.js","sources":["../../../src/import-protection-plugin/extensionlessAbsoluteIdResolver.ts"],"sourcesContent":["import { basename, dirname, extname, isAbsolute } from 'node:path'\nimport { resolveModulePath } from 'exsolve'\n\nimport { KNOWN_SOURCE_EXTENSIONS } from './constants'\nimport { normalizeFilePath } from './utils'\n\nconst FILE_RESOLUTION_EXTENSIONS = [...KNOWN_SOURCE_EXTENSIONS]\n\ntype DepKey = `file:${string}` | `dir:${string}`\n\n/**\n * Canonicalize extensionless absolute IDs like `/src/foo.server` to the\n * physical file when possible.\n *\n * Keeps a small cache plus a reverse index so we can invalidate on HMR\n * updates without clearing the whole map.\n */\nexport class ExtensionlessAbsoluteIdResolver {\n private entries = new Map<string, { value: string; deps: Set<DepKey> }>()\n private keysByDep = new Map<DepKey, Set<string>>()\n\n clear(): void {\n this.entries.clear()\n this.keysByDep.clear()\n }\n\n /**\n * Invalidate any cached entries that might be affected by changes to `id`.\n * We invalidate both the file and its containing directory.\n */\n invalidateByFile(id: string): void {\n const file = normalizeFilePath(id)\n this.invalidateDep(`file:${file}`)\n if (isAbsolute(file)) {\n this.invalidateDep(`dir:${dirname(file)}`)\n }\n }\n\n resolve(id: string): string {\n const key = normalizeFilePath(id)\n const cached = this.entries.get(key)\n if (cached) return cached.value\n\n let result = key\n let resolvedPhysical: string | undefined\n\n if (isAbsolute(key)) {\n const ext = extname(key)\n if (!FILE_RESOLUTION_EXTENSIONS.includes(ext)) {\n const resolved = resolveModulePath(`./${basename(key)}`, {\n from: dirname(key),\n extensions: FILE_RESOLUTION_EXTENSIONS,\n try: true,\n })\n if (resolved) {\n resolvedPhysical = resolved\n result = normalizeFilePath(resolved)\n }\n }\n }\n\n const resolvedFile = resolvedPhysical\n ? normalizeFilePath(resolvedPhysical)\n : undefined\n\n const deps = this.buildDepsForKey(key, resolvedFile)\n this.entries.set(key, { value: result, deps })\n this.indexDeps(key, deps)\n return result\n }\n\n private invalidateDep(dep: DepKey): void {\n const keys = this.keysByDep.get(dep)\n if (!keys) return\n\n // Copy because deleting keys mutates indexes.\n for (const key of Array.from(keys)) {\n this.deleteKey(key)\n }\n }\n\n private buildDepsForKey(key: string, resolvedFile: string | undefined) {\n const deps = new Set<DepKey>()\n deps.add(`file:${key}`)\n\n if (isAbsolute(key)) {\n deps.add(`dir:${dirname(key)}`)\n }\n if (resolvedFile) {\n deps.add(`file:${resolvedFile}`)\n }\n\n return deps\n }\n\n private indexDeps(key: string, deps: Set<DepKey>): void {\n for (const dep of deps) {\n let keys = this.keysByDep.get(dep)\n if (!keys) {\n keys = new Set<string>()\n this.keysByDep.set(dep, keys)\n }\n keys.add(key)\n }\n }\n\n private deleteKey(key: string): void {\n const entry = this.entries.get(key)\n this.entries.delete(key)\n if (!entry) return\n\n for (const dep of entry.deps) {\n const keys = this.keysByDep.get(dep)\n if (!keys) continue\n keys.delete(key)\n if (keys.size === 0) {\n this.keysByDep.delete(dep)\n }\n }\n }\n}\n"],"names":[],"mappings":";;;;AAMA,MAAM,6BAA6B,CAAC,GAAG,uBAAuB;AAWvD,MAAM,gCAAgC;AAAA,EACnC,8BAAc,IAAA;AAAA,EACd,gCAAgB,IAAA;AAAA,EAExB,QAAc;AACZ,SAAK,QAAQ,MAAA;AACb,SAAK,UAAU,MAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,iBAAiB,IAAkB;AACjC,UAAM,OAAO,kBAAkB,EAAE;AACjC,SAAK,cAAc,QAAQ,IAAI,EAAE;AACjC,QAAI,WAAW,IAAI,GAAG;AACpB,WAAK,cAAc,OAAO,QAAQ,IAAI,CAAC,EAAE;AAAA,IAC3C;AAAA,EACF;AAAA,EAEA,QAAQ,IAAoB;AAC1B,UAAM,MAAM,kBAAkB,EAAE;AAChC,UAAM,SAAS,KAAK,QAAQ,IAAI,GAAG;AACnC,QAAI,eAAe,OAAO;AAE1B,QAAI,SAAS;AACb,QAAI;AAEJ,QAAI,WAAW,GAAG,GAAG;AACnB,YAAM,MAAM,QAAQ,GAAG;AACvB,UAAI,CAAC,2BAA2B,SAAS,GAAG,GAAG;AAC7C,cAAM,WAAW,kBAAkB,KAAK,SAAS,GAAG,CAAC,IAAI;AA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AAC5B,YAAM,OAAO,KAAK,UAAU,IAAI,GAAG;AACnC,UAAI,CAAC,KAAM;AACX,WAAK,OAAO,GAAG;AACf,UAAI,KAAK,SAAS,GAAG;AACnB,aAAK,UAAU,OAAO,GAAG;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"extensionlessAbsoluteIdResolver.js","names":[],"sources":["../../../src/import-protection-plugin/extensionlessAbsoluteIdResolver.ts"],"sourcesContent":["import { basename, dirname, extname, isAbsolute } from 'node:path'\nimport { resolveModulePath } from 'exsolve'\n\nimport { KNOWN_SOURCE_EXTENSIONS } from './constants'\nimport { normalizeFilePath } from './utils'\n\nconst FILE_RESOLUTION_EXTENSIONS = [...KNOWN_SOURCE_EXTENSIONS]\n\ntype DepKey = `file:${string}` | `dir:${string}`\n\n/**\n * Canonicalize extensionless absolute IDs like `/src/foo.server` to the\n * physical file when possible.\n *\n * Keeps a small cache plus a reverse index so we can invalidate on HMR\n * updates without clearing the whole map.\n */\nexport class ExtensionlessAbsoluteIdResolver {\n private entries = new Map<string, { value: string; deps: Set<DepKey> }>()\n private keysByDep = new Map<DepKey, Set<string>>()\n\n clear(): void {\n this.entries.clear()\n this.keysByDep.clear()\n }\n\n /**\n * Invalidate any cached entries that might be affected by changes to `id`.\n * We invalidate both the file and its containing directory.\n */\n invalidateByFile(id: string): void {\n const file = normalizeFilePath(id)\n this.invalidateDep(`file:${file}`)\n if (isAbsolute(file)) {\n this.invalidateDep(`dir:${dirname(file)}`)\n }\n }\n\n resolve(id: string): string {\n const key = normalizeFilePath(id)\n const cached = this.entries.get(key)\n if (cached) return cached.value\n\n let result = key\n let resolvedPhysical: string | undefined\n\n if (isAbsolute(key)) {\n const ext = extname(key)\n if (!FILE_RESOLUTION_EXTENSIONS.includes(ext)) {\n const resolved = resolveModulePath(`./${basename(key)}`, {\n from: dirname(key),\n extensions: FILE_RESOLUTION_EXTENSIONS,\n try: true,\n })\n if (resolved) {\n resolvedPhysical = resolved\n result = normalizeFilePath(resolved)\n }\n }\n }\n\n const resolvedFile = resolvedPhysical\n ? normalizeFilePath(resolvedPhysical)\n : undefined\n\n const deps = this.buildDepsForKey(key, resolvedFile)\n this.entries.set(key, { value: result, deps })\n this.indexDeps(key, deps)\n return result\n }\n\n private invalidateDep(dep: DepKey): void {\n const keys = this.keysByDep.get(dep)\n if (!keys) return\n\n // Copy because deleting keys mutates indexes.\n for (const key of Array.from(keys)) {\n this.deleteKey(key)\n }\n }\n\n private buildDepsForKey(key: string, resolvedFile: string | undefined) {\n const deps = new Set<DepKey>()\n deps.add(`file:${key}`)\n\n if (isAbsolute(key)) {\n deps.add(`dir:${dirname(key)}`)\n }\n if (resolvedFile) {\n deps.add(`file:${resolvedFile}`)\n }\n\n return deps\n }\n\n private indexDeps(key: string, deps: Set<DepKey>): void {\n for (const dep of deps) {\n let keys = this.keysByDep.get(dep)\n if (!keys) {\n keys = new Set<string>()\n this.keysByDep.set(dep, keys)\n }\n keys.add(key)\n }\n }\n\n private deleteKey(key: string): void {\n const entry = this.entries.get(key)\n this.entries.delete(key)\n if (!entry) return\n\n for (const dep of entry.deps) {\n const keys = this.keysByDep.get(dep)\n if (!keys) continue\n keys.delete(key)\n if (keys.size === 0) {\n this.keysByDep.delete(dep)\n }\n }\n }\n}\n"],"mappings":";;;;;AAMA,IAAM,6BAA6B,CAAC,GAAG,wBAAwB;;;;;;;;AAW/D,IAAa,kCAAb,MAA6C;CAC3C,0BAAkB,IAAI,KAAmD;CACzE,4BAAoB,IAAI,KAA0B;CAElD,QAAc;AACZ,OAAK,QAAQ,OAAO;AACpB,OAAK,UAAU,OAAO;;;;;;CAOxB,iBAAiB,IAAkB;EACjC,MAAM,OAAO,kBAAkB,GAAG;AAClC,OAAK,cAAc,QAAQ,OAAO;AAClC,MAAI,WAAW,KAAK,CAClB,MAAK,cAAc,OAAO,QAAQ,KAAK,GAAG;;CAI9C,QAAQ,IAAoB;EAC1B,MAAM,MAAM,kBAAkB,GAAG;EACj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I,IAAI;AACnC,OAAK,QAAQ,OAAO,IAAI;AACxB,MAAI,CAAC,MAAO;AAEZ,OAAK,MAAM,OAAO,MAAM,MAAM;GAC5B,MAAM,OAAO,KAAK,UAAU,IAAI,IAAI;AACpC,OAAI,CAAC,KAAM;AACX,QAAK,OAAO,IAAI;AAChB,OAAI,KAAK,SAAS,EAChB,MAAK,UAAU,OAAO,IAAI"}
@@ -1,31 +1,30 @@
1
1
  import picomatch from "picomatch";
2
+ //#region src/import-protection-plugin/matchers.ts
3
+ /**
4
+ * Compile a Pattern (string glob or RegExp) into a fast test function.
5
+ * String patterns use picomatch for full glob support (**, *, ?, braces, etc.).
6
+ * RegExp patterns are used as-is.
7
+ */
2
8
  function compileMatcher(pattern) {
3
- if (pattern instanceof RegExp) {
4
- return {
5
- pattern,
6
- test: (value) => {
7
- pattern.lastIndex = 0;
8
- return pattern.test(value);
9
- }
10
- };
11
- }
12
- const isMatch = picomatch(pattern, { dot: true });
13
- return { pattern, test: isMatch };
9
+ if (pattern instanceof RegExp) return {
10
+ pattern,
11
+ test: (value) => {
12
+ pattern.lastIndex = 0;
13
+ return pattern.test(value);
14
+ }
15
+ };
16
+ return {
17
+ pattern,
18
+ test: picomatch(pattern, { dot: true })
19
+ };
14
20
  }
15
21
  function compileMatchers(patterns) {
16
- return patterns.map(compileMatcher);
22
+ return patterns.map(compileMatcher);
17
23
  }
18
24
  function matchesAny(value, matchers) {
19
- for (const matcher of matchers) {
20
- if (matcher.test(value)) {
21
- return matcher;
22
- }
23
- }
24
- return void 0;
25
+ for (const matcher of matchers) if (matcher.test(value)) return matcher;
25
26
  }
26
- export {
27
- compileMatcher,
28
- compileMatchers,
29
- matchesAny
30
- };
31
- //# sourceMappingURL=matchers.js.map
27
+ //#endregion
28
+ export { compileMatchers, matchesAny };
29
+
30
+ //# sourceMappingURL=matchers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"matchers.js","sources":["../../../src/import-protection-plugin/matchers.ts"],"sourcesContent":["import picomatch from 'picomatch'\n\nimport type { Pattern } from './utils'\n\nexport interface CompiledMatcher {\n pattern: Pattern\n test: (value: string) => boolean\n}\n\n/**\n * Compile a Pattern (string glob or RegExp) into a fast test function.\n * String patterns use picomatch for full glob support (**, *, ?, braces, etc.).\n * RegExp patterns are used as-is.\n */\nexport function compileMatcher(pattern: Pattern): CompiledMatcher {\n if (pattern instanceof RegExp) {\n // RegExp with `g` or `y` flags are stateful because `.test()` mutates\n // `lastIndex`. Reset it to keep matcher evaluation deterministic.\n return {\n pattern,\n test: (value: string) => {\n pattern.lastIndex = 0\n return pattern.test(value)\n },\n }\n }\n\n const isMatch = picomatch(pattern, { dot: true })\n return { pattern, test: isMatch }\n}\n\nexport function compileMatchers(\n patterns: Array<Pattern>,\n): Array<CompiledMatcher> {\n return patterns.map(compileMatcher)\n}\n\nexport function matchesAny(\n value: string,\n matchers: Array<CompiledMatcher>,\n): CompiledMatcher | undefined {\n for (const matcher of matchers) {\n if (matcher.test(value)) {\n return matcher\n }\n }\n return undefined\n}\n"],"names":[],"mappings":";AAcO,SAAS,eAAe,SAAmC;AAChE,MAAI,mBAAmB,QAAQ;AAG7B,WAAO;AAAA,MACL;AAAA,MACA,MAAM,CAAC,UAAkB;AACvB,gBAAQ,YAAY;AACpB,eAAO,QAAQ,KAAK,KAAK;AAAA,MAC3B;AAAA,IAAA;AAAA,EAEJ;AAEA,QAAM,UAAU,UAAU,SAAS,EAAE,KAAK,MAAM;AAChD,SAAO,EAAE,SAAS,MAAM,QAAA;AAC1B;AAEO,SAAS,gBACd,UACwB;AACxB,SAAO,SAAS,IAAI,cAAc;AACpC;AAEO,SAAS,WACd,OACA,UAC6B;AAC7B,aAAW,WAAW,UAAU;AAC9B,QAAI,QAAQ,KAAK,KAAK,GAAG;AACvB,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;"}
1
+ {"version":3,"file":"matchers.js","names":[],"sources":["../../../src/import-protection-plugin/matchers.ts"],"sourcesContent":["import picomatch from 'picomatch'\n\nimport type { Pattern } from './utils'\n\nexport interface CompiledMatcher {\n pattern: Pattern\n test: (value: string) => boolean\n}\n\n/**\n * Compile a Pattern (string glob or RegExp) into a fast test function.\n * String patterns use picomatch for full glob support (**, *, ?, braces, etc.).\n * RegExp patterns are used as-is.\n */\nexport function compileMatcher(pattern: Pattern): CompiledMatcher {\n if (pattern instanceof RegExp) {\n // RegExp with `g` or `y` flags are stateful because `.test()` mutates\n // `lastIndex`. Reset it to keep matcher evaluation deterministic.\n return {\n pattern,\n test: (value: string) => {\n pattern.lastIndex = 0\n return pattern.test(value)\n },\n }\n }\n\n const isMatch = picomatch(pattern, { dot: true })\n return { pattern, test: isMatch }\n}\n\nexport function compileMatchers(\n patterns: Array<Pattern>,\n): Array<CompiledMatcher> {\n return patterns.map(compileMatcher)\n}\n\nexport function matchesAny(\n value: string,\n matchers: Array<CompiledMatcher>,\n): CompiledMatcher | undefined {\n for (const matcher of matchers) {\n if (matcher.test(value)) {\n return matcher\n }\n }\n return undefined\n}\n"],"mappings":";;;;;;;AAcA,SAAgB,eAAe,SAAmC;AAChE,KAAI,mBAAmB,OAGrB,QAAO;EACL;EACA,OAAO,UAAkB;AACvB,WAAQ,YAAY;AACpB,UAAO,QAAQ,KAAK,MAAM;;EAE7B;AAIH,QAAO;EAAE;EAAS,MADF,UAAU,SAAS,EAAE,KAAK,MAAM,CAAC;EAChB;;AAGnC,SAAgB,gBACd,UACwB;AACxB,QAAO,SAAS,IAAI,eAAe;;AAGrC,SAAgB,WACd,OACA,UAC6B;AAC7B,MAAK,MAAM,WAAW,SACpB,KAAI,QAAQ,KAAK,MAAM,CACrB,QAAO"}