@tanstack/start-plugin-core 1.166.12 → 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.
- package/dist/esm/build-sitemap.js +94 -123
- package/dist/esm/build-sitemap.js.map +1 -1
- package/dist/esm/constants.js +15 -20
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/dev-server-plugin/dev-styles.js +137 -150
- package/dist/esm/dev-server-plugin/dev-styles.js.map +1 -1
- package/dist/esm/dev-server-plugin/extract-html-scripts.js +16 -15
- package/dist/esm/dev-server-plugin/extract-html-scripts.js.map +1 -1
- package/dist/esm/dev-server-plugin/plugin.js +125 -195
- package/dist/esm/dev-server-plugin/plugin.js.map +1 -1
- package/dist/esm/import-protection-plugin/ast.js +6 -5
- package/dist/esm/import-protection-plugin/ast.js.map +1 -1
- package/dist/esm/import-protection-plugin/constants.js +20 -22
- package/dist/esm/import-protection-plugin/constants.js.map +1 -1
- package/dist/esm/import-protection-plugin/defaults.js +35 -25
- package/dist/esm/import-protection-plugin/defaults.js.map +1 -1
- package/dist/esm/import-protection-plugin/extensionlessAbsoluteIdResolver.js +93 -92
- package/dist/esm/import-protection-plugin/extensionlessAbsoluteIdResolver.js.map +1 -1
- package/dist/esm/import-protection-plugin/matchers.js +23 -24
- package/dist/esm/import-protection-plugin/matchers.js.map +1 -1
- package/dist/esm/import-protection-plugin/plugin.js +1045 -1361
- package/dist/esm/import-protection-plugin/plugin.js.map +1 -1
- package/dist/esm/import-protection-plugin/postCompileUsage.js +58 -55
- package/dist/esm/import-protection-plugin/postCompileUsage.js.map +1 -1
- package/dist/esm/import-protection-plugin/rewriteDeniedImports.js +187 -259
- package/dist/esm/import-protection-plugin/rewriteDeniedImports.js.map +1 -1
- package/dist/esm/import-protection-plugin/sourceLocation.js +238 -248
- package/dist/esm/import-protection-plugin/sourceLocation.js.map +1 -1
- package/dist/esm/import-protection-plugin/trace.js +173 -184
- package/dist/esm/import-protection-plugin/trace.js.map +1 -1
- package/dist/esm/import-protection-plugin/utils.js +132 -111
- package/dist/esm/import-protection-plugin/utils.js.map +1 -1
- package/dist/esm/import-protection-plugin/virtualModules.js +216 -196
- package/dist/esm/import-protection-plugin/virtualModules.js.map +1 -1
- package/dist/esm/index.js +2 -7
- package/dist/esm/load-env-plugin/plugin.js +12 -11
- package/dist/esm/load-env-plugin/plugin.js.map +1 -1
- package/dist/esm/output-directory.js +10 -10
- package/dist/esm/output-directory.js.map +1 -1
- package/dist/esm/plugin.js +275 -355
- package/dist/esm/plugin.js.map +1 -1
- package/dist/esm/post-server-build.js +39 -53
- package/dist/esm/post-server-build.js.map +1 -1
- package/dist/esm/prerender.js +177 -239
- package/dist/esm/prerender.js.map +1 -1
- package/dist/esm/preview-server-plugin/plugin.js +41 -44
- package/dist/esm/preview-server-plugin/plugin.js.map +1 -1
- package/dist/esm/queue.js +115 -126
- package/dist/esm/queue.js.map +1 -1
- package/dist/esm/resolve-entries.js +31 -32
- package/dist/esm/resolve-entries.js.map +1 -1
- package/dist/esm/schema.js +156 -179
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/start-compiler-plugin/compiler.js +655 -812
- package/dist/esm/start-compiler-plugin/compiler.js.map +1 -1
- package/dist/esm/start-compiler-plugin/handleClientOnlyJSX.js +25 -8
- package/dist/esm/start-compiler-plugin/handleClientOnlyJSX.js.map +1 -1
- package/dist/esm/start-compiler-plugin/handleCreateIsomorphicFn.js +22 -19
- package/dist/esm/start-compiler-plugin/handleCreateIsomorphicFn.js.map +1 -1
- package/dist/esm/start-compiler-plugin/handleCreateMiddleware.js +20 -22
- package/dist/esm/start-compiler-plugin/handleCreateMiddleware.js.map +1 -1
- package/dist/esm/start-compiler-plugin/handleCreateServerFn.js +187 -255
- package/dist/esm/start-compiler-plugin/handleCreateServerFn.js.map +1 -1
- package/dist/esm/start-compiler-plugin/handleEnvOnly.js +23 -33
- package/dist/esm/start-compiler-plugin/handleEnvOnly.js.map +1 -1
- package/dist/esm/start-compiler-plugin/plugin.js +247 -291
- package/dist/esm/start-compiler-plugin/plugin.js.map +1 -1
- package/dist/esm/start-compiler-plugin/utils.js +27 -27
- package/dist/esm/start-compiler-plugin/utils.js.map +1 -1
- package/dist/esm/start-manifest-plugin/manifestBuilder.js +272 -378
- package/dist/esm/start-manifest-plugin/manifestBuilder.js.map +1 -1
- package/dist/esm/start-manifest-plugin/plugin.js +35 -44
- package/dist/esm/start-manifest-plugin/plugin.js.map +1 -1
- package/dist/esm/start-router-plugin/constants.js +6 -5
- package/dist/esm/start-router-plugin/constants.js.map +1 -1
- package/dist/esm/start-router-plugin/generator-plugins/prerender-routes-plugin.js +24 -19
- package/dist/esm/start-router-plugin/generator-plugins/prerender-routes-plugin.js.map +1 -1
- package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js +28 -29
- package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js.map +1 -1
- package/dist/esm/start-router-plugin/plugin.js +146 -199
- package/dist/esm/start-router-plugin/plugin.js.map +1 -1
- package/dist/esm/start-router-plugin/pruneServerOnlySubtrees.js +32 -31
- package/dist/esm/start-router-plugin/pruneServerOnlySubtrees.js.map +1 -1
- package/dist/esm/utils.js +14 -14
- package/dist/esm/utils.js.map +1 -1
- package/package.json +7 -7
- 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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
//#
|
|
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"],"
|
|
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;EACjC,MAAM,SAAS,KAAK,QAAQ,IAAI,IAAI;AACpC,MAAI,OAAQ,QAAO,OAAO;EAE1B,IAAI,SAAS;EACb,IAAI;AAEJ,MAAI,WAAW,IAAI,EAAE;GACnB,MAAM,MAAM,QAAQ,IAAI;AACxB,OAAI,CAAC,2BAA2B,SAAS,IAAI,EAAE;IAC7C,MAAM,WAAW,kBAAkB,KAAK,SAAS,IAAI,IAAI;KACvD,MAAM,QAAQ,IAAI;KAClB,YAAY;KACZ,KAAK;KACN,CAAC;AACF,QAAI,UAAU;AACZ,wBAAmB;AACnB,cAAS,kBAAkB,SAAS;;;;EAK1C,MAAM,eAAe,mBACjB,kBAAkB,iBAAiB,GACnC,KAAA;EAEJ,MAAM,OAAO,KAAK,gBAAgB,KAAK,aAAa;AACpD,OAAK,QAAQ,IAAI,KAAK;GAAE,OAAO;GAAQ;GAAM,CAAC;AAC9C,OAAK,UAAU,KAAK,KAAK;AACzB,SAAO;;CAGT,cAAsB,KAAmB;EACvC,MAAM,OAAO,KAAK,UAAU,IAAI,IAAI;AACpC,MAAI,CAAC,KAAM;AAGX,OAAK,MAAM,OAAO,MAAM,KAAK,KAAK,CAChC,MAAK,UAAU,IAAI;;CAIvB,gBAAwB,KAAa,cAAkC;EACrE,MAAM,uBAAO,IAAI,KAAa;AAC9B,OAAK,IAAI,QAAQ,MAAM;AAEvB,MAAI,WAAW,IAAI,CACjB,MAAK,IAAI,OAAO,QAAQ,IAAI,GAAG;AAEjC,MAAI,aACF,MAAK,IAAI,QAAQ,eAAe;AAGlC,SAAO;;CAGT,UAAkB,KAAa,MAAyB;AACtD,OAAK,MAAM,OAAO,MAAM;GACtB,IAAI,OAAO,KAAK,UAAU,IAAI,IAAI;AAClC,OAAI,CAAC,MAAM;AACT,2BAAO,IAAI,KAAa;AACxB,SAAK,UAAU,IAAI,KAAK,KAAK;;AAE/B,QAAK,IAAI,IAAI;;;CAIjB,UAAkB,KAAmB;EACnC,MAAM,QAAQ,KAAK,QAAQ,IAAI,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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
22
|
+
return patterns.map(compileMatcher);
|
|
17
23
|
}
|
|
18
24
|
function matchesAny(value, matchers) {
|
|
19
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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"],"
|
|
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"}
|