@tanstack/start-plugin-core 1.167.35 → 1.169.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.
Files changed (187) hide show
  1. package/dist/esm/import-protection/adapterUtils.d.ts +27 -0
  2. package/dist/esm/import-protection/adapterUtils.js +31 -0
  3. package/dist/esm/import-protection/adapterUtils.js.map +1 -0
  4. package/dist/esm/import-protection/analysis.d.ts +36 -0
  5. package/dist/esm/import-protection/analysis.js +407 -0
  6. package/dist/esm/import-protection/analysis.js.map +1 -0
  7. package/dist/esm/{import-protection-plugin → import-protection}/ast.js +1 -1
  8. package/dist/esm/import-protection/ast.js.map +1 -0
  9. package/dist/esm/import-protection/constants.d.ts +11 -0
  10. package/dist/esm/{import-protection-plugin → import-protection}/constants.js +7 -2
  11. package/dist/esm/import-protection/constants.js.map +1 -0
  12. package/dist/esm/{import-protection-plugin → import-protection}/defaults.js +1 -1
  13. package/dist/esm/import-protection/defaults.js.map +1 -0
  14. package/dist/esm/{import-protection-plugin → import-protection}/extensionlessAbsoluteIdResolver.js +2 -2
  15. package/dist/esm/import-protection/extensionlessAbsoluteIdResolver.js.map +1 -0
  16. package/dist/esm/{import-protection-plugin → import-protection}/matchers.js +1 -1
  17. package/dist/esm/import-protection/matchers.js.map +1 -0
  18. package/dist/esm/{import-protection-plugin/rewriteDeniedImports.d.ts → import-protection/rewrite.d.ts} +0 -4
  19. package/dist/esm/import-protection/rewrite.js +121 -0
  20. package/dist/esm/import-protection/rewrite.js.map +1 -0
  21. package/dist/esm/{import-protection-plugin → import-protection}/sourceLocation.d.ts +32 -3
  22. package/dist/esm/{import-protection-plugin → import-protection}/sourceLocation.js +65 -10
  23. package/dist/esm/import-protection/sourceLocation.js.map +1 -0
  24. package/dist/esm/{import-protection-plugin → import-protection}/trace.d.ts +0 -1
  25. package/dist/esm/{import-protection-plugin → import-protection}/trace.js +1 -1
  26. package/dist/esm/import-protection/trace.js.map +1 -0
  27. package/dist/esm/{import-protection-plugin → import-protection}/utils.d.ts +18 -1
  28. package/dist/esm/{import-protection-plugin → import-protection}/utils.js +13 -20
  29. package/dist/esm/import-protection/utils.js.map +1 -0
  30. package/dist/esm/import-protection/virtualModules.d.ts +25 -0
  31. package/dist/esm/{import-protection-plugin → import-protection}/virtualModules.js +5 -117
  32. package/dist/esm/import-protection/virtualModules.js.map +1 -0
  33. package/dist/esm/index.d.ts +1 -5
  34. package/dist/esm/index.js +2 -4
  35. package/dist/esm/post-build.d.ts +9 -0
  36. package/dist/esm/post-build.js +37 -0
  37. package/dist/esm/post-build.js.map +1 -0
  38. package/dist/esm/prerender.d.ts +11 -0
  39. package/dist/esm/prerender.js +159 -0
  40. package/dist/esm/prerender.js.map +1 -0
  41. package/dist/esm/rsbuild/dev-server.d.ts +21 -0
  42. package/dist/esm/rsbuild/dev-server.js +76 -0
  43. package/dist/esm/rsbuild/dev-server.js.map +1 -0
  44. package/dist/esm/rsbuild/import-protection.d.ts +10 -0
  45. package/dist/esm/rsbuild/import-protection.js +775 -0
  46. package/dist/esm/rsbuild/import-protection.js.map +1 -0
  47. package/dist/esm/rsbuild/index.d.ts +4 -0
  48. package/dist/esm/rsbuild/index.js +3 -0
  49. package/dist/esm/rsbuild/normalized-client-build.d.ts +18 -0
  50. package/dist/esm/rsbuild/normalized-client-build.js +207 -0
  51. package/dist/esm/rsbuild/normalized-client-build.js.map +1 -0
  52. package/dist/esm/rsbuild/planning.d.ts +52 -0
  53. package/dist/esm/rsbuild/planning.js +108 -0
  54. package/dist/esm/rsbuild/planning.js.map +1 -0
  55. package/dist/esm/rsbuild/plugin.d.ts +4 -0
  56. package/dist/esm/rsbuild/plugin.js +344 -0
  57. package/dist/esm/rsbuild/plugin.js.map +1 -0
  58. package/dist/esm/rsbuild/post-build.d.ts +6 -0
  59. package/dist/esm/rsbuild/post-build.js +57 -0
  60. package/dist/esm/rsbuild/post-build.js.map +1 -0
  61. package/dist/esm/rsbuild/schema.d.ts +3372 -0
  62. package/dist/esm/rsbuild/schema.js +12 -0
  63. package/dist/esm/rsbuild/schema.js.map +1 -0
  64. package/dist/esm/rsbuild/start-compiler-host.d.ts +20 -0
  65. package/dist/esm/rsbuild/start-compiler-host.js +150 -0
  66. package/dist/esm/rsbuild/start-compiler-host.js.map +1 -0
  67. package/dist/esm/rsbuild/start-router-plugin.d.ts +18 -0
  68. package/dist/esm/rsbuild/start-router-plugin.js +63 -0
  69. package/dist/esm/rsbuild/start-router-plugin.js.map +1 -0
  70. package/dist/esm/rsbuild/swc-rsc.d.ts +14 -0
  71. package/dist/esm/rsbuild/swc-rsc.js +93 -0
  72. package/dist/esm/rsbuild/swc-rsc.js.map +1 -0
  73. package/dist/esm/rsbuild/types.d.ts +17 -0
  74. package/dist/esm/rsbuild/types.js +0 -0
  75. package/dist/esm/rsbuild/virtual-modules.d.ts +53 -0
  76. package/dist/esm/rsbuild/virtual-modules.js +287 -0
  77. package/dist/esm/rsbuild/virtual-modules.js.map +1 -0
  78. package/dist/esm/schema.d.ts +43 -43
  79. package/dist/esm/start-compiler/compiler.d.ts +1 -1
  80. package/dist/esm/start-compiler/compiler.js +80 -9
  81. package/dist/esm/start-compiler/compiler.js.map +1 -1
  82. package/dist/esm/start-compiler/handleCreateServerFn.js +9 -0
  83. package/dist/esm/start-compiler/handleCreateServerFn.js.map +1 -1
  84. package/dist/esm/start-compiler/host.js +5 -1
  85. package/dist/esm/start-compiler/host.js.map +1 -1
  86. package/dist/esm/start-compiler/types.d.ts +1 -0
  87. package/dist/esm/utils.d.ts +1 -0
  88. package/dist/esm/utils.js +10 -1
  89. package/dist/esm/utils.js.map +1 -1
  90. package/dist/esm/{import-protection-plugin → vite/import-protection-plugin}/plugin.js +41 -92
  91. package/dist/esm/vite/import-protection-plugin/plugin.js.map +1 -0
  92. package/dist/esm/{import-protection-plugin → vite/import-protection-plugin}/types.d.ts +5 -5
  93. package/dist/esm/vite/import-protection-plugin/virtualModules.d.ts +8 -0
  94. package/dist/esm/vite/import-protection-plugin/virtualModules.js +49 -0
  95. package/dist/esm/vite/import-protection-plugin/virtualModules.js.map +1 -0
  96. package/dist/esm/vite/index.d.ts +5 -0
  97. package/dist/esm/vite/index.js +4 -0
  98. package/dist/esm/vite/plugin.js +1 -1
  99. package/dist/esm/vite/plugin.js.map +1 -1
  100. package/dist/esm/vite/post-server-build.js +14 -32
  101. package/dist/esm/vite/post-server-build.js.map +1 -1
  102. package/dist/esm/vite/prerender.d.ts +2 -2
  103. package/dist/esm/vite/prerender.js +17 -147
  104. package/dist/esm/vite/prerender.js.map +1 -1
  105. package/dist/esm/vite/schema.d.ts +23 -23
  106. package/dist/esm/vite/start-compiler-plugin/hot-update.d.ts +2 -0
  107. package/dist/esm/vite/start-compiler-plugin/hot-update.js +16 -0
  108. package/dist/esm/vite/start-compiler-plugin/hot-update.js.map +1 -0
  109. package/dist/esm/vite/start-compiler-plugin/module-specifier.js +9 -4
  110. package/dist/esm/vite/start-compiler-plugin/module-specifier.js.map +1 -1
  111. package/dist/esm/vite/start-compiler-plugin/plugin.js +86 -13
  112. package/dist/esm/vite/start-compiler-plugin/plugin.js.map +1 -1
  113. package/package.json +32 -4
  114. package/src/import-protection/INTERNALS.md +266 -0
  115. package/src/import-protection/adapterUtils.ts +94 -0
  116. package/src/import-protection/analysis.ts +853 -0
  117. package/src/{import-protection-plugin → import-protection}/constants.ts +7 -0
  118. package/src/import-protection/rewrite.ts +229 -0
  119. package/src/{import-protection-plugin → import-protection}/sourceLocation.ts +125 -9
  120. package/src/{import-protection-plugin → import-protection}/trace.ts +0 -1
  121. package/src/{import-protection-plugin → import-protection}/utils.ts +36 -21
  122. package/src/{import-protection-plugin → import-protection}/virtualModules.ts +30 -177
  123. package/src/index.ts +1 -8
  124. package/src/post-build.ts +64 -0
  125. package/src/prerender.ts +292 -0
  126. package/src/rsbuild/INTERNALS-import-protection.md +169 -0
  127. package/src/rsbuild/dev-server.ts +129 -0
  128. package/src/rsbuild/import-protection.ts +1599 -0
  129. package/src/rsbuild/index.ts +4 -0
  130. package/src/rsbuild/normalized-client-build.ts +346 -0
  131. package/src/rsbuild/planning.ts +234 -0
  132. package/src/rsbuild/plugin.ts +754 -0
  133. package/src/rsbuild/post-build.ts +96 -0
  134. package/src/rsbuild/schema.ts +31 -0
  135. package/src/rsbuild/start-compiler-host.ts +250 -0
  136. package/src/rsbuild/start-router-plugin.ts +86 -0
  137. package/src/rsbuild/swc-rsc.ts +166 -0
  138. package/src/rsbuild/types.ts +20 -0
  139. package/src/rsbuild/virtual-modules.ts +565 -0
  140. package/src/start-compiler/compiler.ts +153 -19
  141. package/src/start-compiler/handleCreateServerFn.ts +18 -0
  142. package/src/start-compiler/types.ts +1 -0
  143. package/src/utils.ts +14 -0
  144. package/src/vite/import-protection-plugin/INTERNALS.md +187 -0
  145. package/src/{import-protection-plugin → vite/import-protection-plugin}/plugin.ts +73 -158
  146. package/src/{import-protection-plugin → vite/import-protection-plugin}/types.ts +5 -5
  147. package/src/vite/import-protection-plugin/virtualModules.ts +122 -0
  148. package/src/vite/index.ts +8 -0
  149. package/src/vite/plugin.ts +1 -1
  150. package/src/vite/post-server-build.ts +14 -57
  151. package/src/vite/prerender.ts +19 -260
  152. package/src/vite/start-compiler-plugin/hot-update.ts +24 -0
  153. package/src/vite/start-compiler-plugin/module-specifier.ts +15 -5
  154. package/src/vite/start-compiler-plugin/plugin.ts +193 -18
  155. package/dist/esm/import-protection-plugin/ast.js.map +0 -1
  156. package/dist/esm/import-protection-plugin/constants.d.ts +0 -6
  157. package/dist/esm/import-protection-plugin/constants.js.map +0 -1
  158. package/dist/esm/import-protection-plugin/defaults.js.map +0 -1
  159. package/dist/esm/import-protection-plugin/extensionlessAbsoluteIdResolver.js.map +0 -1
  160. package/dist/esm/import-protection-plugin/matchers.js.map +0 -1
  161. package/dist/esm/import-protection-plugin/plugin.js.map +0 -1
  162. package/dist/esm/import-protection-plugin/postCompileUsage.d.ts +0 -13
  163. package/dist/esm/import-protection-plugin/postCompileUsage.js +0 -63
  164. package/dist/esm/import-protection-plugin/postCompileUsage.js.map +0 -1
  165. package/dist/esm/import-protection-plugin/rewriteDeniedImports.js +0 -205
  166. package/dist/esm/import-protection-plugin/rewriteDeniedImports.js.map +0 -1
  167. package/dist/esm/import-protection-plugin/sourceLocation.js.map +0 -1
  168. package/dist/esm/import-protection-plugin/trace.js.map +0 -1
  169. package/dist/esm/import-protection-plugin/utils.js.map +0 -1
  170. package/dist/esm/import-protection-plugin/virtualModules.d.ts +0 -78
  171. package/dist/esm/import-protection-plugin/virtualModules.js.map +0 -1
  172. package/dist/esm/start-compiler/load-module.d.ts +0 -14
  173. package/dist/esm/start-compiler/load-module.js +0 -18
  174. package/dist/esm/start-compiler/load-module.js.map +0 -1
  175. package/src/import-protection-plugin/INTERNALS.md +0 -700
  176. package/src/import-protection-plugin/postCompileUsage.ts +0 -100
  177. package/src/import-protection-plugin/rewriteDeniedImports.ts +0 -379
  178. package/src/start-compiler/load-module.ts +0 -31
  179. /package/dist/esm/{import-protection-plugin → import-protection}/ast.d.ts +0 -0
  180. /package/dist/esm/{import-protection-plugin → import-protection}/defaults.d.ts +0 -0
  181. /package/dist/esm/{import-protection-plugin → import-protection}/extensionlessAbsoluteIdResolver.d.ts +0 -0
  182. /package/dist/esm/{import-protection-plugin → import-protection}/matchers.d.ts +0 -0
  183. /package/dist/esm/{import-protection-plugin → vite/import-protection-plugin}/plugin.d.ts +0 -0
  184. /package/src/{import-protection-plugin → import-protection}/ast.ts +0 -0
  185. /package/src/{import-protection-plugin → import-protection}/defaults.ts +0 -0
  186. /package/src/{import-protection-plugin → import-protection}/extensionlessAbsoluteIdResolver.ts +0 -0
  187. /package/src/{import-protection-plugin → import-protection}/matchers.ts +0 -0
@@ -0,0 +1,27 @@
1
+ import { CompiledMatcher } from './matchers.js';
2
+ export type ImportProtectionEnvType = 'client' | 'server';
3
+ export interface ImportProtectionEnvRules {
4
+ specifiers: Array<CompiledMatcher>;
5
+ files: Array<CompiledMatcher>;
6
+ excludeFiles: Array<CompiledMatcher>;
7
+ }
8
+ /**
9
+ * Shared subset of adapter config used to decide which environment rules apply
10
+ * and whether an importer should be checked at all.
11
+ */
12
+ export interface ImportProtectionAdapterConfig {
13
+ root: string;
14
+ srcDirectory: string;
15
+ compiledRules: {
16
+ client: ImportProtectionEnvRules;
17
+ server: ImportProtectionEnvRules;
18
+ };
19
+ includeMatchers: Array<CompiledMatcher>;
20
+ excludeMatchers: Array<CompiledMatcher>;
21
+ ignoreImporterMatchers: Array<CompiledMatcher>;
22
+ envTypeMap: Map<string, ImportProtectionEnvType>;
23
+ }
24
+ export declare function getImportProtectionRelativePath(root: string, absolutePath: string): string;
25
+ export declare function getImportProtectionEnvType(config: Pick<ImportProtectionAdapterConfig, 'envTypeMap'>, envName: string): ImportProtectionEnvType;
26
+ export declare function getImportProtectionRulesForEnvironment(config: Pick<ImportProtectionAdapterConfig, 'compiledRules' | 'envTypeMap'>, envName: string): ImportProtectionEnvRules;
27
+ export declare function shouldCheckImportProtectionImporter(config: Pick<ImportProtectionAdapterConfig, 'root' | 'srcDirectory' | 'includeMatchers' | 'excludeMatchers' | 'ignoreImporterMatchers'>, importer: string, cache?: Map<string, boolean>): boolean;
@@ -0,0 +1,31 @@
1
+ import { isInsideDirectory, normalizeFilePath, relativizePath } from "./utils.js";
2
+ import { matchesAny } from "./matchers.js";
3
+ //#region src/import-protection/adapterUtils.ts
4
+ function getImportProtectionRelativePath(root, absolutePath) {
5
+ return relativizePath(normalizeFilePath(absolutePath), root);
6
+ }
7
+ function getImportProtectionEnvType(config, envName) {
8
+ return config.envTypeMap.get(envName) ?? "server";
9
+ }
10
+ function getImportProtectionRulesForEnvironment(config, envName) {
11
+ return getImportProtectionEnvType(config, envName) === "client" ? config.compiledRules.client : config.compiledRules.server;
12
+ }
13
+ function shouldCheckImportProtectionImporter(config, importer, cache) {
14
+ const normalizedImporter = normalizeFilePath(importer);
15
+ if (cache) {
16
+ const cached = cache.get(normalizedImporter);
17
+ if (cached !== void 0) return cached;
18
+ }
19
+ const relativePath = relativizePath(normalizedImporter, config.root);
20
+ let result;
21
+ if (config.excludeMatchers.length > 0 && matchesAny(relativePath, config.excludeMatchers) || config.ignoreImporterMatchers.length > 0 && matchesAny(relativePath, config.ignoreImporterMatchers)) result = false;
22
+ else if (config.includeMatchers.length > 0) result = !!matchesAny(relativePath, config.includeMatchers);
23
+ else if (config.srcDirectory) result = isInsideDirectory(normalizedImporter, config.srcDirectory);
24
+ else result = true;
25
+ cache?.set(normalizedImporter, result);
26
+ return result;
27
+ }
28
+ //#endregion
29
+ export { getImportProtectionEnvType, getImportProtectionRelativePath, getImportProtectionRulesForEnvironment, shouldCheckImportProtectionImporter };
30
+
31
+ //# sourceMappingURL=adapterUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapterUtils.js","names":[],"sources":["../../../src/import-protection/adapterUtils.ts"],"sourcesContent":["import { matchesAny } from './matchers'\nimport { isInsideDirectory, normalizeFilePath, relativizePath } from './utils'\nimport type { CompiledMatcher } from './matchers'\n\nexport type ImportProtectionEnvType = 'client' | 'server'\n\nexport interface ImportProtectionEnvRules {\n specifiers: Array<CompiledMatcher>\n files: Array<CompiledMatcher>\n excludeFiles: Array<CompiledMatcher>\n}\n\n/**\n * Shared subset of adapter config used to decide which environment rules apply\n * and whether an importer should be checked at all.\n */\nexport interface ImportProtectionAdapterConfig {\n root: string\n srcDirectory: string\n compiledRules: {\n client: ImportProtectionEnvRules\n server: ImportProtectionEnvRules\n }\n includeMatchers: Array<CompiledMatcher>\n excludeMatchers: Array<CompiledMatcher>\n ignoreImporterMatchers: Array<CompiledMatcher>\n envTypeMap: Map<string, ImportProtectionEnvType>\n}\n\nexport function getImportProtectionRelativePath(\n root: string,\n absolutePath: string,\n): string {\n return relativizePath(normalizeFilePath(absolutePath), root)\n}\n\nexport function getImportProtectionEnvType(\n config: Pick<ImportProtectionAdapterConfig, 'envTypeMap'>,\n envName: string,\n): ImportProtectionEnvType {\n return config.envTypeMap.get(envName) ?? 'server'\n}\n\nexport function getImportProtectionRulesForEnvironment(\n config: Pick<ImportProtectionAdapterConfig, 'compiledRules' | 'envTypeMap'>,\n envName: string,\n): ImportProtectionEnvRules {\n return getImportProtectionEnvType(config, envName) === 'client'\n ? config.compiledRules.client\n : config.compiledRules.server\n}\n\nexport function shouldCheckImportProtectionImporter(\n config: Pick<\n ImportProtectionAdapterConfig,\n | 'root'\n | 'srcDirectory'\n | 'includeMatchers'\n | 'excludeMatchers'\n | 'ignoreImporterMatchers'\n >,\n importer: string,\n cache?: Map<string, boolean>,\n): boolean {\n const normalizedImporter = normalizeFilePath(importer)\n\n if (cache) {\n const cached = cache.get(normalizedImporter)\n if (cached !== undefined) {\n return cached\n }\n }\n\n const relativePath = relativizePath(normalizedImporter, config.root)\n\n let result: boolean\n if (\n (config.excludeMatchers.length > 0 &&\n matchesAny(relativePath, config.excludeMatchers)) ||\n (config.ignoreImporterMatchers.length > 0 &&\n matchesAny(relativePath, config.ignoreImporterMatchers))\n ) {\n result = false\n } else if (config.includeMatchers.length > 0) {\n result = !!matchesAny(relativePath, config.includeMatchers)\n } else if (config.srcDirectory) {\n result = isInsideDirectory(normalizedImporter, config.srcDirectory)\n } else {\n result = true\n }\n\n cache?.set(normalizedImporter, result)\n return result\n}\n"],"mappings":";;;AA6BA,SAAgB,gCACd,MACA,cACQ;AACR,QAAO,eAAe,kBAAkB,aAAa,EAAE,KAAK;;AAG9D,SAAgB,2BACd,QACA,SACyB;AACzB,QAAO,OAAO,WAAW,IAAI,QAAQ,IAAI;;AAG3C,SAAgB,uCACd,QACA,SAC0B;AAC1B,QAAO,2BAA2B,QAAQ,QAAQ,KAAK,WACnD,OAAO,cAAc,SACrB,OAAO,cAAc;;AAG3B,SAAgB,oCACd,QAQA,UACA,OACS;CACT,MAAM,qBAAqB,kBAAkB,SAAS;AAEtD,KAAI,OAAO;EACT,MAAM,SAAS,MAAM,IAAI,mBAAmB;AAC5C,MAAI,WAAW,KAAA,EACb,QAAO;;CAIX,MAAM,eAAe,eAAe,oBAAoB,OAAO,KAAK;CAEpE,IAAI;AACJ,KACG,OAAO,gBAAgB,SAAS,KAC/B,WAAW,cAAc,OAAO,gBAAgB,IACjD,OAAO,uBAAuB,SAAS,KACtC,WAAW,cAAc,OAAO,uBAAuB,CAEzD,UAAS;UACA,OAAO,gBAAgB,SAAS,EACzC,UAAS,CAAC,CAAC,WAAW,cAAc,OAAO,gBAAgB;UAClD,OAAO,aAChB,UAAS,kBAAkB,oBAAoB,OAAO,aAAa;KAEnE,UAAS;AAGX,QAAO,IAAI,oBAAoB,OAAO;AACtC,QAAO"}
@@ -0,0 +1,36 @@
1
+ import { LineIndex, TransformResult } from './sourceLocation.js';
2
+ import { ParsedAst } from './ast.js';
3
+ export type UsagePos = {
4
+ line: number;
5
+ column0: number;
6
+ };
7
+ type BoundaryEnv = 'client' | 'server';
8
+ type ImportBindingInfo = {
9
+ importedLocalNames: Set<string>;
10
+ memberBindingToSource: Map<string, string>;
11
+ };
12
+ type UsageCacheKey = `${BoundaryEnv | 'post'}::${string}`;
13
+ export type ImportAnalysis = {
14
+ ast: ParsedAst;
15
+ lineIndex: LineIndex;
16
+ importSourcesInOrder: Array<string>;
17
+ importSpecifierLocationIndex: Map<string, number>;
18
+ importBindingsBySource: Map<string, ImportBindingInfo>;
19
+ mockExportNamesBySource: Map<string, Array<string>>;
20
+ namedExports: Array<string>;
21
+ usageByKey: Map<UsageCacheKey, UsagePos | null>;
22
+ };
23
+ export declare function isValidExportName(name: string): boolean;
24
+ export declare function getOrCreateImportAnalysis(result: TransformResult): ImportAnalysis;
25
+ export declare function getImportSourcesFromResult(result: TransformResult): Array<string>;
26
+ export declare function getImportSources(code: string): Array<string>;
27
+ export declare function getImportSpecifierLocationFromResult(result: TransformResult, source: string): number;
28
+ export declare function getMockExportNamesBySourceFromResult(result: TransformResult): Map<string, Array<string>>;
29
+ export declare function getMockExportNamesBySource(code: string): Map<string, Array<string>>;
30
+ export declare function getNamedExportsFromResult(result: TransformResult): Array<string>;
31
+ export declare function getNamedExports(code: string): Array<string>;
32
+ export declare function findPostCompileUsagePosFromResult(result: TransformResult, source: string): UsagePos | undefined;
33
+ export declare function findPostCompileUsagePos(code: string, source: string): UsagePos | undefined;
34
+ export declare function findOriginalUnsafeUsagePosFromResult(result: TransformResult, source: string, envType: BoundaryEnv): UsagePos | undefined;
35
+ export declare function findOriginalUnsafeUsagePos(code: string, source: string, envType: BoundaryEnv): UsagePos | undefined;
36
+ export {};
@@ -0,0 +1,407 @@
1
+ import { getOrCreate } from "./utils.js";
2
+ import { parseImportProtectionAst } from "./ast.js";
3
+ import { buildLineIndex } from "./sourceLocation.js";
4
+ import * as t from "@babel/types";
5
+ //#region src/import-protection/analysis.ts
6
+ function makeTransientResult(code) {
7
+ return {
8
+ code,
9
+ map: void 0,
10
+ originalCode: void 0
11
+ };
12
+ }
13
+ function getModuleExportName(node) {
14
+ return t.isIdentifier(node) ? node.name : node.value;
15
+ }
16
+ function getStringLiteralValueStart(node) {
17
+ if (node.start == null) return -1;
18
+ const raw = node.extra?.raw;
19
+ if (typeof raw === "string" && (raw.startsWith("'") || raw.startsWith("\""))) return node.start + 1;
20
+ return node.start;
21
+ }
22
+ function collectIdentifiersFromPattern(pattern, add) {
23
+ if (t.isIdentifier(pattern)) add(pattern.name);
24
+ else if (t.isObjectPattern(pattern)) for (const prop of pattern.properties) if (t.isRestElement(prop)) collectIdentifiersFromPattern(prop.argument, add);
25
+ else collectIdentifiersFromPattern(prop.value, add);
26
+ else if (t.isArrayPattern(pattern)) {
27
+ for (const elem of pattern.elements) if (elem) collectIdentifiersFromPattern(elem, add);
28
+ } else if (t.isAssignmentPattern(pattern)) collectIdentifiersFromPattern(pattern.left, add);
29
+ else if (t.isRestElement(pattern)) collectIdentifiersFromPattern(pattern.argument, add);
30
+ }
31
+ function isValidExportName(name) {
32
+ if (name === "default" || name.length === 0) return false;
33
+ const first = name.charCodeAt(0);
34
+ if (!(first >= 65 && first <= 90 || first >= 97 && first <= 122 || first === 95 || first === 36)) return false;
35
+ for (let i = 1; i < name.length; i++) {
36
+ const ch = name.charCodeAt(i);
37
+ if (!(ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 48 && ch <= 57 || ch === 95 || ch === 36)) return false;
38
+ }
39
+ return true;
40
+ }
41
+ function buildImportAnalysis(result) {
42
+ const ast = result.parsedAst ?? parseImportProtectionAst(result.code);
43
+ result.parsedAst = ast;
44
+ const importSourcesInOrder = [];
45
+ const importSpecifierLocationIndex = /* @__PURE__ */ new Map();
46
+ const importBindingsBySource = /* @__PURE__ */ new Map();
47
+ const mockNamesBySource = /* @__PURE__ */ new Map();
48
+ const namedExports = /* @__PURE__ */ new Set();
49
+ const getBindingInfo = (source) => getOrCreate(importBindingsBySource, source, () => ({
50
+ importedLocalNames: /* @__PURE__ */ new Set(),
51
+ memberBindingToSource: /* @__PURE__ */ new Map()
52
+ }));
53
+ const addSpecifierLocation = (node) => {
54
+ importSourcesInOrder.push(node.value);
55
+ const index = getStringLiteralValueStart(node);
56
+ if (index === -1) return;
57
+ const prev = importSpecifierLocationIndex.get(node.value);
58
+ if (prev == null || index < prev) importSpecifierLocationIndex.set(node.value, index);
59
+ };
60
+ const addMockName = (source, name) => {
61
+ if (name === "default" || name.length === 0) return;
62
+ getOrCreate(mockNamesBySource, source, () => /* @__PURE__ */ new Set()).add(name);
63
+ };
64
+ const addNamedExport = (name) => {
65
+ if (name !== "default" && name.length > 0) namedExports.add(name);
66
+ };
67
+ const visit = (node) => {
68
+ if (t.isImportDeclaration(node)) {
69
+ addSpecifierLocation(node.source);
70
+ if (node.importKind !== "type") {
71
+ const source = node.source.value;
72
+ const bindingInfo = getBindingInfo(source);
73
+ for (const specifier of node.specifiers) {
74
+ if (t.isImportNamespaceSpecifier(specifier)) {
75
+ bindingInfo.importedLocalNames.add(specifier.local.name);
76
+ bindingInfo.memberBindingToSource.set(specifier.local.name, source);
77
+ continue;
78
+ }
79
+ if (t.isImportDefaultSpecifier(specifier)) {
80
+ bindingInfo.importedLocalNames.add(specifier.local.name);
81
+ bindingInfo.memberBindingToSource.set(specifier.local.name, source);
82
+ continue;
83
+ }
84
+ if (!t.isImportSpecifier(specifier)) continue;
85
+ if (specifier.importKind === "type") continue;
86
+ bindingInfo.importedLocalNames.add(specifier.local.name);
87
+ const importedName = getModuleExportName(specifier.imported);
88
+ if (importedName !== "default") addMockName(source, importedName);
89
+ }
90
+ }
91
+ } else if (t.isExportNamedDeclaration(node)) {
92
+ if (node.source && t.isStringLiteral(node.source)) addSpecifierLocation(node.source);
93
+ if (node.exportKind !== "type" && node.source?.value) {
94
+ const source = node.source.value;
95
+ for (const specifier of node.specifiers) {
96
+ if (!t.isExportSpecifier(specifier)) continue;
97
+ if (specifier.exportKind === "type") continue;
98
+ addMockName(source, getModuleExportName(specifier.local));
99
+ }
100
+ }
101
+ if (node.exportKind !== "type") {
102
+ if (node.declaration) {
103
+ const decl = node.declaration;
104
+ if (t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) {
105
+ if (decl.id?.name) addNamedExport(decl.id.name);
106
+ } else if (t.isVariableDeclaration(decl)) for (const d of decl.declarations) collectIdentifiersFromPattern(d.id, addNamedExport);
107
+ }
108
+ for (const specifier of node.specifiers) {
109
+ if (!t.isExportSpecifier(specifier)) continue;
110
+ if (specifier.exportKind === "type") continue;
111
+ addNamedExport(getModuleExportName(specifier.exported));
112
+ }
113
+ }
114
+ } else if (t.isExportAllDeclaration(node)) addSpecifierLocation(node.source);
115
+ else if (t.isImportExpression(node)) {
116
+ if (t.isStringLiteral(node.source)) addSpecifierLocation(node.source);
117
+ } else if (t.isCallExpression(node) && t.isImport(node.callee)) {
118
+ const sourceNode = node.arguments[0];
119
+ if (t.isStringLiteral(sourceNode)) addSpecifierLocation(sourceNode);
120
+ } else if (t.isMemberExpression(node) || t.isOptionalMemberExpression(node)) {
121
+ const object = node.object;
122
+ if (t.isIdentifier(object)) for (const [source, bindingInfo] of importBindingsBySource) {
123
+ if (!bindingInfo.memberBindingToSource.has(object.name)) continue;
124
+ const property = node.property;
125
+ if (!node.computed && t.isIdentifier(property)) addMockName(source, property.name);
126
+ else if (node.computed && t.isStringLiteral(property)) addMockName(source, property.value);
127
+ }
128
+ }
129
+ const keys = t.VISITOR_KEYS[node.type];
130
+ if (!keys) return;
131
+ for (const key of keys) {
132
+ const child = node[key];
133
+ if (Array.isArray(child)) {
134
+ for (const item of child) if (item && typeof item === "object" && "type" in item) visit(item);
135
+ } else if (child && typeof child === "object" && "type" in child) visit(child);
136
+ }
137
+ };
138
+ visit(ast.program);
139
+ const mockExportNamesBySource = /* @__PURE__ */ new Map();
140
+ for (const [source, names] of mockNamesBySource) mockExportNamesBySource.set(source, Array.from(names).sort());
141
+ const lineIndex = result.lineIndex ?? buildLineIndex(result.code);
142
+ result.lineIndex = lineIndex;
143
+ return {
144
+ ast,
145
+ lineIndex,
146
+ importSourcesInOrder,
147
+ importSpecifierLocationIndex,
148
+ importBindingsBySource,
149
+ mockExportNamesBySource,
150
+ namedExports: Array.from(namedExports).sort(),
151
+ usageByKey: /* @__PURE__ */ new Map()
152
+ };
153
+ }
154
+ function getOrCreateImportAnalysis(result) {
155
+ if (!result.analysis) result.analysis = buildImportAnalysis(result);
156
+ return result.analysis;
157
+ }
158
+ function getImportSourcesFromResult(result) {
159
+ return getOrCreateImportAnalysis(result).importSourcesInOrder;
160
+ }
161
+ function getImportSources(code) {
162
+ return getImportSourcesFromResult(makeTransientResult(code));
163
+ }
164
+ function getImportSpecifierLocationFromResult(result, source) {
165
+ return getOrCreateImportAnalysis(result).importSpecifierLocationIndex.get(source) ?? -1;
166
+ }
167
+ function getMockExportNamesBySourceFromResult(result) {
168
+ return getOrCreateImportAnalysis(result).mockExportNamesBySource;
169
+ }
170
+ function getMockExportNamesBySource(code) {
171
+ return getMockExportNamesBySourceFromResult(makeTransientResult(code));
172
+ }
173
+ function getNamedExportsFromResult(result) {
174
+ return getOrCreateImportAnalysis(result).namedExports;
175
+ }
176
+ function getNamedExports(code) {
177
+ return getNamedExportsFromResult(makeTransientResult(code));
178
+ }
179
+ function isCompilerSafeBoundaryCall(call, fnNode, envType) {
180
+ if (!call.arguments.some((arg) => arg === fnNode)) return false;
181
+ const callee = call.callee;
182
+ if (t.isIdentifier(callee)) return envType === "client" ? callee.name === "createServerOnlyFn" : callee.name === "createClientOnlyFn";
183
+ if (!t.isMemberExpression(callee) || callee.computed) return false;
184
+ if (!t.isIdentifier(callee.property)) return false;
185
+ const prop = callee.property.name;
186
+ const rootName = getCalleeRootName(callee.object);
187
+ if (envType === "client") {
188
+ if (prop === "handler") return rootName === "createServerFn" || /ServerFn$/.test(rootName ?? "");
189
+ if (prop === "server") return rootName === "createMiddleware" || rootName === "createIsomorphicFn" || /Middleware$/.test(rootName ?? "");
190
+ return false;
191
+ }
192
+ if (prop === "client") return rootName === "createIsomorphicFn";
193
+ return false;
194
+ }
195
+ function getCalleeRootName(node) {
196
+ if (t.isIdentifier(node)) return node.name;
197
+ if (t.isCallExpression(node)) return getCalleeRootName(node.callee);
198
+ if (t.isMemberExpression(node)) return getCalleeRootName(node.object);
199
+ }
200
+ function getBoundNamesFromPattern(pattern, out) {
201
+ if (t.isIdentifier(pattern)) out.add(pattern.name);
202
+ else if (t.isObjectPattern(pattern)) for (const prop of pattern.properties) if (t.isRestElement(prop)) getBoundNamesFromPattern(prop.argument, out);
203
+ else getBoundNamesFromPattern(prop.value, out);
204
+ else if (t.isArrayPattern(pattern)) {
205
+ for (const elem of pattern.elements) if (elem) getBoundNamesFromPattern(elem, out);
206
+ } else if (t.isAssignmentPattern(pattern)) getBoundNamesFromPattern(pattern.left, out);
207
+ else if (t.isRestElement(pattern)) getBoundNamesFromPattern(pattern.argument, out);
208
+ }
209
+ function addPatternBindingsIfTracked(pattern, tracked, out) {
210
+ const names = /* @__PURE__ */ new Set();
211
+ getBoundNamesFromPattern(pattern, names);
212
+ for (const name of names) if (tracked.has(name)) out.add(name);
213
+ }
214
+ function collectHoistedVarBindings(node, tracked, out, isRoot = true) {
215
+ if (!isRoot && t.isFunction(node)) return;
216
+ if (t.isVariableDeclaration(node) && node.kind === "var") for (const decl of node.declarations) addPatternBindingsIfTracked(decl.id, tracked, out);
217
+ const keys = t.VISITOR_KEYS[node.type];
218
+ if (!keys) return;
219
+ for (const key of keys) {
220
+ const child = node[key];
221
+ if (Array.isArray(child)) {
222
+ for (const item of child) if (item && typeof item === "object" && "type" in item) collectHoistedVarBindings(item, tracked, out, false);
223
+ } else if (child && typeof child === "object" && "type" in child) collectHoistedVarBindings(child, tracked, out, false);
224
+ }
225
+ }
226
+ function collectProgramBindings(program, tracked) {
227
+ const bindings = /* @__PURE__ */ new Set();
228
+ for (const node of program.body) {
229
+ if (t.isVariableDeclaration(node)) {
230
+ for (const decl of node.declarations) addPatternBindingsIfTracked(decl.id, tracked, bindings);
231
+ continue;
232
+ }
233
+ if (t.isFunctionDeclaration(node) || t.isClassDeclaration(node)) {
234
+ if (node.id && tracked.has(node.id.name)) bindings.add(node.id.name);
235
+ }
236
+ }
237
+ return bindings;
238
+ }
239
+ function collectBlockBindings(block, tracked) {
240
+ const bindings = /* @__PURE__ */ new Set();
241
+ for (const node of block.body) {
242
+ if (t.isVariableDeclaration(node) && node.kind !== "var") {
243
+ for (const decl of node.declarations) addPatternBindingsIfTracked(decl.id, tracked, bindings);
244
+ continue;
245
+ }
246
+ if (t.isFunctionDeclaration(node) || t.isClassDeclaration(node)) {
247
+ if (node.id && tracked.has(node.id.name)) bindings.add(node.id.name);
248
+ }
249
+ }
250
+ return bindings;
251
+ }
252
+ function collectFunctionBindings(fn, tracked) {
253
+ const bindings = /* @__PURE__ */ new Set();
254
+ if ((t.isFunctionDeclaration(fn) || t.isFunctionExpression(fn)) && fn.id && tracked.has(fn.id.name)) bindings.add(fn.id.name);
255
+ for (const param of fn.params) addPatternBindingsIfTracked(param, tracked, bindings);
256
+ if (t.isBlockStatement(fn.body)) collectHoistedVarBindings(fn.body, tracked, bindings);
257
+ return bindings;
258
+ }
259
+ function isShadowedByScope(name, scopeStack) {
260
+ for (let i = scopeStack.length - 1; i >= 0; i--) if (scopeStack[i]?.has(name)) return true;
261
+ return false;
262
+ }
263
+ function isBindingIdentifierInParent(node, parent) {
264
+ if (!parent) return false;
265
+ if (t.isImportSpecifier(parent) || t.isImportDefaultSpecifier(parent)) return parent.local === node;
266
+ if (t.isImportNamespaceSpecifier(parent)) return parent.local === node;
267
+ if (t.isFunctionDeclaration(parent) || t.isFunctionExpression(parent)) return parent.id === node || parent.params.includes(node);
268
+ if (t.isArrowFunctionExpression(parent)) return parent.params.includes(node);
269
+ if (t.isClassDeclaration(parent) || t.isClassExpression(parent)) return parent.id === node;
270
+ if (t.isVariableDeclarator(parent)) return parent.id === node;
271
+ if (t.isCatchClause(parent)) return parent.param === node;
272
+ return false;
273
+ }
274
+ function isInsideCompilerSafeBoundaryNodes(parents, envType) {
275
+ for (let i = parents.length - 1; i >= 0; i--) {
276
+ const node = parents[i];
277
+ if (!t.isFunction(node)) continue;
278
+ const call = parents[i - 1];
279
+ if (call && t.isCallExpression(call) && isCompilerSafeBoundaryCall(call, node, envType)) return true;
280
+ }
281
+ return false;
282
+ }
283
+ function findUsagePosInAnalysis(result, source, envType) {
284
+ const analysis = getOrCreateImportAnalysis(result);
285
+ const cacheKey = `${envType ?? "post"}::${source}`;
286
+ if (analysis.usageByKey.has(cacheKey)) return analysis.usageByKey.get(cacheKey) ?? void 0;
287
+ const imported = analysis.importBindingsBySource.get(source)?.importedLocalNames;
288
+ if (!imported || imported.size === 0) {
289
+ analysis.usageByKey.set(cacheKey, null);
290
+ return;
291
+ }
292
+ let preferred;
293
+ let anyUsage;
294
+ const visit = (node, ctx) => {
295
+ if (preferred && anyUsage) return;
296
+ if (t.isProgram(node)) {
297
+ const nextCtx = {
298
+ parents: [...ctx.parents, node],
299
+ scopeStack: [...ctx.scopeStack, collectProgramBindings(node, imported)]
300
+ };
301
+ for (const child of node.body) visit(child, nextCtx);
302
+ return;
303
+ }
304
+ if (t.isFunction(node)) {
305
+ const functionCtx = {
306
+ parents: [...ctx.parents, node],
307
+ scopeStack: [...ctx.scopeStack, collectFunctionBindings(node, imported)]
308
+ };
309
+ visit(node.body, functionCtx);
310
+ return;
311
+ }
312
+ if (t.isBlockStatement(node)) {
313
+ const nextCtx = {
314
+ parents: [...ctx.parents, node],
315
+ scopeStack: [...ctx.scopeStack, collectBlockBindings(node, imported)]
316
+ };
317
+ for (const child of node.body) visit(child, nextCtx);
318
+ return;
319
+ }
320
+ if (t.isCatchClause(node)) {
321
+ const bindings = /* @__PURE__ */ new Set();
322
+ if (node.param) addPatternBindingsIfTracked(node.param, imported, bindings);
323
+ const nextCtx = {
324
+ parents: [...ctx.parents, node],
325
+ scopeStack: bindings.size ? [...ctx.scopeStack, bindings] : ctx.scopeStack
326
+ };
327
+ visit(node.body, nextCtx);
328
+ return;
329
+ }
330
+ if (t.isForStatement(node) && t.isVariableDeclaration(node.init) && node.init.kind !== "var") {
331
+ const bindings = /* @__PURE__ */ new Set();
332
+ for (const decl of node.init.declarations) addPatternBindingsIfTracked(decl.id, imported, bindings);
333
+ const nextCtx = {
334
+ parents: [...ctx.parents, node],
335
+ scopeStack: bindings.size ? [...ctx.scopeStack, bindings] : ctx.scopeStack
336
+ };
337
+ visit(node.init, nextCtx);
338
+ if (node.test) visit(node.test, nextCtx);
339
+ if (node.update) visit(node.update, nextCtx);
340
+ visit(node.body, nextCtx);
341
+ return;
342
+ }
343
+ if ((t.isForInStatement(node) || t.isForOfStatement(node)) && t.isVariableDeclaration(node.left) && node.left.kind !== "var") {
344
+ const bindings = /* @__PURE__ */ new Set();
345
+ for (const decl of node.left.declarations) addPatternBindingsIfTracked(decl.id, imported, bindings);
346
+ const nextCtx = {
347
+ parents: [...ctx.parents, node],
348
+ scopeStack: bindings.size ? [...ctx.scopeStack, bindings] : ctx.scopeStack
349
+ };
350
+ visit(node.left, nextCtx);
351
+ visit(node.right, nextCtx);
352
+ visit(node.body, nextCtx);
353
+ return;
354
+ }
355
+ const nextParents = [...ctx.parents, node];
356
+ if (t.isIdentifier(node)) {
357
+ const parent = ctx.parents[ctx.parents.length - 1];
358
+ if (imported.has(node.name)) {
359
+ if (!isBindingIdentifierInParent(node, parent)) {
360
+ if (!(t.isObjectProperty(parent) && parent.key === node && !parent.computed && !parent.shorthand) && !(t.isObjectMethod(parent) && parent.key === node && !parent.computed) && !(t.isExportSpecifier(parent) && parent.exported === node) && !isShadowedByScope(node.name, ctx.scopeStack) && !(envType && isInsideCompilerSafeBoundaryNodes(ctx.parents, envType))) {
361
+ const loc = node.loc?.start;
362
+ if (loc) {
363
+ const pos = {
364
+ line: loc.line,
365
+ column0: loc.column
366
+ };
367
+ if (t.isCallExpression(parent) && parent.callee === node || t.isNewExpression(parent) && parent.callee === node || (t.isMemberExpression(parent) || t.isOptionalMemberExpression(parent)) && parent.object === node) preferred ||= pos;
368
+ else anyUsage ||= pos;
369
+ }
370
+ }
371
+ }
372
+ }
373
+ }
374
+ if (t.isImportDeclaration(node)) return;
375
+ const keys = t.VISITOR_KEYS[node.type];
376
+ if (!keys) return;
377
+ for (const key of keys) {
378
+ const child = node[key];
379
+ if (Array.isArray(child)) {
380
+ for (const item of child) if (item && typeof item === "object" && "type" in item) visit(item, {
381
+ parents: nextParents,
382
+ scopeStack: ctx.scopeStack
383
+ });
384
+ } else if (child && typeof child === "object" && "type" in child) visit(child, {
385
+ parents: nextParents,
386
+ scopeStack: ctx.scopeStack
387
+ });
388
+ }
389
+ };
390
+ visit(analysis.ast.program, {
391
+ parents: [],
392
+ scopeStack: []
393
+ });
394
+ const pos = preferred ?? anyUsage ?? null;
395
+ analysis.usageByKey.set(cacheKey, pos);
396
+ return pos ?? void 0;
397
+ }
398
+ function findPostCompileUsagePosFromResult(result, source) {
399
+ return findUsagePosInAnalysis(result, source);
400
+ }
401
+ function findOriginalUnsafeUsagePosFromResult(result, source, envType) {
402
+ return findUsagePosInAnalysis(result, source, envType);
403
+ }
404
+ //#endregion
405
+ export { findOriginalUnsafeUsagePosFromResult, findPostCompileUsagePosFromResult, getImportSources, getImportSpecifierLocationFromResult, getMockExportNamesBySource, getNamedExports, isValidExportName };
406
+
407
+ //# sourceMappingURL=analysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis.js","names":[],"sources":["../../../src/import-protection/analysis.ts"],"sourcesContent":["import * as t from '@babel/types'\n\nimport { parseImportProtectionAst } from './ast'\nimport { buildLineIndex } from './sourceLocation'\nimport { getOrCreate } from './utils'\nimport type { LineIndex, TransformResult } from './sourceLocation'\nimport type { ParsedAst } from './ast'\n\nexport type UsagePos = { line: number; column0: number }\n\ntype BoundaryEnv = 'client' | 'server'\n\ntype ImportBindingInfo = {\n importedLocalNames: Set<string>\n memberBindingToSource: Map<string, string>\n}\n\ntype UsageCacheKey = `${BoundaryEnv | 'post'}::${string}`\n\nexport type ImportAnalysis = {\n ast: ParsedAst\n lineIndex: LineIndex\n importSourcesInOrder: Array<string>\n importSpecifierLocationIndex: Map<string, number>\n importBindingsBySource: Map<string, ImportBindingInfo>\n mockExportNamesBySource: Map<string, Array<string>>\n namedExports: Array<string>\n usageByKey: Map<UsageCacheKey, UsagePos | null>\n}\n\nfunction makeTransientResult(code: string): TransformResult {\n return {\n code,\n map: undefined,\n originalCode: undefined,\n }\n}\n\nfunction getModuleExportName(node: t.Identifier | t.StringLiteral): string {\n return t.isIdentifier(node) ? node.name : node.value\n}\n\nfunction getStringLiteralValueStart(node: t.StringLiteral): number {\n if (node.start == null) {\n return -1\n }\n\n const raw = node.extra?.raw\n if (typeof raw === 'string' && (raw.startsWith(\"'\") || raw.startsWith('\"'))) {\n return node.start + 1\n }\n\n return node.start\n}\n\nfunction collectIdentifiersFromPattern(\n pattern: t.LVal,\n add: (name: string) => void,\n): void {\n if (t.isIdentifier(pattern)) {\n add(pattern.name)\n } else if (t.isObjectPattern(pattern)) {\n for (const prop of pattern.properties) {\n if (t.isRestElement(prop)) {\n collectIdentifiersFromPattern(prop.argument as t.LVal, add)\n } else {\n collectIdentifiersFromPattern(prop.value as t.LVal, add)\n }\n }\n } else if (t.isArrayPattern(pattern)) {\n for (const elem of pattern.elements) {\n if (elem) collectIdentifiersFromPattern(elem as t.LVal, add)\n }\n } else if (t.isAssignmentPattern(pattern)) {\n collectIdentifiersFromPattern(pattern.left, add)\n } else if (t.isRestElement(pattern)) {\n collectIdentifiersFromPattern(pattern.argument as t.LVal, add)\n }\n}\n\nexport function isValidExportName(name: string): boolean {\n if (name === 'default' || name.length === 0) return false\n const first = name.charCodeAt(0)\n if (\n !(\n (first >= 65 && first <= 90) ||\n (first >= 97 && first <= 122) ||\n first === 95 ||\n first === 36\n )\n )\n return false\n for (let i = 1; i < name.length; i++) {\n const ch = name.charCodeAt(i)\n if (\n !(\n (ch >= 65 && ch <= 90) ||\n (ch >= 97 && ch <= 122) ||\n (ch >= 48 && ch <= 57) ||\n ch === 95 ||\n ch === 36\n )\n )\n return false\n }\n return true\n}\n\nfunction buildImportAnalysis(result: TransformResult): ImportAnalysis {\n const ast = result.parsedAst ?? parseImportProtectionAst(result.code)\n result.parsedAst = ast\n\n const importSourcesInOrder: Array<string> = []\n const importSpecifierLocationIndex = new Map<string, number>()\n const importBindingsBySource = new Map<string, ImportBindingInfo>()\n const mockNamesBySource = new Map<string, Set<string>>()\n const namedExports = new Set<string>()\n\n const getBindingInfo = (source: string): ImportBindingInfo =>\n getOrCreate(importBindingsBySource, source, () => ({\n importedLocalNames: new Set<string>(),\n memberBindingToSource: new Map<string, string>(),\n }))\n\n const addSpecifierLocation = (node: t.StringLiteral) => {\n importSourcesInOrder.push(node.value)\n\n const index = getStringLiteralValueStart(node)\n if (index === -1) {\n return\n }\n\n const prev = importSpecifierLocationIndex.get(node.value)\n if (prev == null || index < prev) {\n importSpecifierLocationIndex.set(node.value, index)\n }\n }\n\n const addMockName = (source: string, name: string) => {\n if (name === 'default' || name.length === 0) return\n getOrCreate(mockNamesBySource, source, () => new Set<string>()).add(name)\n }\n\n const addNamedExport = (name: string) => {\n if (name !== 'default' && name.length > 0) {\n namedExports.add(name)\n }\n }\n\n const visit = (node: t.Node): void => {\n if (t.isImportDeclaration(node)) {\n addSpecifierLocation(node.source)\n if (node.importKind !== 'type') {\n const source = node.source.value\n const bindingInfo = getBindingInfo(source)\n for (const specifier of node.specifiers) {\n if (t.isImportNamespaceSpecifier(specifier)) {\n bindingInfo.importedLocalNames.add(specifier.local.name)\n bindingInfo.memberBindingToSource.set(specifier.local.name, source)\n continue\n }\n\n if (t.isImportDefaultSpecifier(specifier)) {\n bindingInfo.importedLocalNames.add(specifier.local.name)\n bindingInfo.memberBindingToSource.set(specifier.local.name, source)\n continue\n }\n\n if (!t.isImportSpecifier(specifier)) continue\n if (specifier.importKind === 'type') continue\n\n bindingInfo.importedLocalNames.add(specifier.local.name)\n const importedName = getModuleExportName(specifier.imported)\n if (importedName !== 'default') {\n addMockName(source, importedName)\n }\n }\n }\n } else if (t.isExportNamedDeclaration(node)) {\n if (node.source && t.isStringLiteral(node.source)) {\n addSpecifierLocation(node.source)\n }\n\n if (node.exportKind !== 'type' && node.source?.value) {\n const source = node.source.value\n for (const specifier of node.specifiers) {\n if (!t.isExportSpecifier(specifier)) continue\n if (specifier.exportKind === 'type') continue\n addMockName(source, getModuleExportName(specifier.local))\n }\n }\n\n if (node.exportKind !== 'type') {\n if (node.declaration) {\n const decl = node.declaration\n if (t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) {\n if (decl.id?.name) addNamedExport(decl.id.name)\n } else if (t.isVariableDeclaration(decl)) {\n for (const d of decl.declarations) {\n collectIdentifiersFromPattern(d.id as t.LVal, addNamedExport)\n }\n }\n }\n\n for (const specifier of node.specifiers) {\n if (!t.isExportSpecifier(specifier)) continue\n if (specifier.exportKind === 'type') continue\n const exportedName = getModuleExportName(specifier.exported)\n addNamedExport(exportedName)\n }\n }\n } else if (t.isExportAllDeclaration(node)) {\n addSpecifierLocation(node.source)\n } else if (t.isImportExpression(node)) {\n if (t.isStringLiteral(node.source)) {\n addSpecifierLocation(node.source)\n }\n } else if (t.isCallExpression(node) && t.isImport(node.callee)) {\n const sourceNode = node.arguments[0]\n if (t.isStringLiteral(sourceNode)) {\n addSpecifierLocation(sourceNode)\n }\n } else if (\n t.isMemberExpression(node) ||\n t.isOptionalMemberExpression(node)\n ) {\n const object = node.object\n if (t.isIdentifier(object)) {\n for (const [source, bindingInfo] of importBindingsBySource) {\n if (!bindingInfo.memberBindingToSource.has(object.name)) {\n continue\n }\n\n const property = node.property\n if (!node.computed && t.isIdentifier(property)) {\n addMockName(source, property.name)\n } else if (node.computed && t.isStringLiteral(property)) {\n addMockName(source, property.value)\n }\n }\n }\n }\n\n const keys = t.VISITOR_KEYS[node.type]\n if (!keys) return\n for (const key of keys) {\n const child = (node as unknown as Record<string, unknown>)[key]\n if (Array.isArray(child)) {\n for (const item of child) {\n if (item && typeof item === 'object' && 'type' in item) {\n visit(item as t.Node)\n }\n }\n } else if (child && typeof child === 'object' && 'type' in child) {\n visit(child as t.Node)\n }\n }\n }\n\n visit(ast.program)\n\n const mockExportNamesBySource = new Map<string, Array<string>>()\n for (const [source, names] of mockNamesBySource) {\n mockExportNamesBySource.set(source, Array.from(names).sort())\n }\n\n const lineIndex = result.lineIndex ?? buildLineIndex(result.code)\n result.lineIndex = lineIndex\n\n const analysis = {\n ast,\n lineIndex,\n importSourcesInOrder,\n importSpecifierLocationIndex,\n importBindingsBySource,\n mockExportNamesBySource,\n namedExports: Array.from(namedExports).sort(),\n usageByKey: new Map(),\n }\n\n return analysis\n}\n\nexport function getOrCreateImportAnalysis(\n result: TransformResult,\n): ImportAnalysis {\n if (!result.analysis) {\n result.analysis = buildImportAnalysis(result)\n }\n\n return result.analysis\n}\n\nexport function getImportSourcesFromResult(\n result: TransformResult,\n): Array<string> {\n return getOrCreateImportAnalysis(result).importSourcesInOrder\n}\n\nexport function getImportSources(code: string): Array<string> {\n return getImportSourcesFromResult(makeTransientResult(code))\n}\n\nexport function getImportSpecifierLocationFromResult(\n result: TransformResult,\n source: string,\n): number {\n return (\n getOrCreateImportAnalysis(result).importSpecifierLocationIndex.get(\n source,\n ) ?? -1\n )\n}\n\nexport function getMockExportNamesBySourceFromResult(\n result: TransformResult,\n): Map<string, Array<string>> {\n return getOrCreateImportAnalysis(result).mockExportNamesBySource\n}\n\nexport function getMockExportNamesBySource(\n code: string,\n): Map<string, Array<string>> {\n return getMockExportNamesBySourceFromResult(makeTransientResult(code))\n}\n\nexport function getNamedExportsFromResult(\n result: TransformResult,\n): Array<string> {\n return getOrCreateImportAnalysis(result).namedExports\n}\n\nexport function getNamedExports(code: string): Array<string> {\n return getNamedExportsFromResult(makeTransientResult(code))\n}\n\nfunction isCompilerSafeBoundaryCall(\n call: t.CallExpression,\n fnNode: t.Function,\n envType: BoundaryEnv,\n): boolean {\n const directArgument = call.arguments.some((arg) => arg === fnNode)\n if (!directArgument) {\n return false\n }\n\n const callee = call.callee\n\n if (t.isIdentifier(callee)) {\n return envType === 'client'\n ? callee.name === 'createServerOnlyFn'\n : callee.name === 'createClientOnlyFn'\n }\n\n if (!t.isMemberExpression(callee) || callee.computed) {\n return false\n }\n\n if (!t.isIdentifier(callee.property)) {\n return false\n }\n\n const prop = callee.property.name\n const rootName = getCalleeRootName(callee.object)\n\n if (envType === 'client') {\n if (prop === 'handler') {\n return rootName === 'createServerFn' || /ServerFn$/.test(rootName ?? '')\n }\n\n if (prop === 'server') {\n return (\n rootName === 'createMiddleware' ||\n rootName === 'createIsomorphicFn' ||\n /Middleware$/.test(rootName ?? '')\n )\n }\n\n return false\n }\n\n if (prop === 'client') {\n return rootName === 'createIsomorphicFn'\n }\n\n return false\n}\n\nfunction getCalleeRootName(\n node: t.Expression | t.Super | t.V8IntrinsicIdentifier,\n): string | undefined {\n if (t.isIdentifier(node)) {\n return node.name\n }\n\n if (t.isCallExpression(node)) {\n return getCalleeRootName(node.callee)\n }\n\n if (t.isMemberExpression(node)) {\n return getCalleeRootName(node.object)\n }\n\n return undefined\n}\n\nfunction getBoundNamesFromPattern(pattern: t.LVal, out: Set<string>): void {\n if (t.isIdentifier(pattern)) {\n out.add(pattern.name)\n } else if (t.isObjectPattern(pattern)) {\n for (const prop of pattern.properties) {\n if (t.isRestElement(prop)) {\n getBoundNamesFromPattern(prop.argument as t.LVal, out)\n } else {\n getBoundNamesFromPattern(prop.value as t.LVal, out)\n }\n }\n } else if (t.isArrayPattern(pattern)) {\n for (const elem of pattern.elements) {\n if (elem) getBoundNamesFromPattern(elem as t.LVal, out)\n }\n } else if (t.isAssignmentPattern(pattern)) {\n getBoundNamesFromPattern(pattern.left, out)\n } else if (t.isRestElement(pattern)) {\n getBoundNamesFromPattern(pattern.argument as t.LVal, out)\n }\n}\n\nfunction addPatternBindingsIfTracked(\n pattern: t.LVal,\n tracked: Set<string>,\n out: Set<string>,\n): void {\n const names = new Set<string>()\n getBoundNamesFromPattern(pattern, names)\n for (const name of names) {\n if (tracked.has(name)) {\n out.add(name)\n }\n }\n}\n\nfunction collectHoistedVarBindings(\n node: t.Node,\n tracked: Set<string>,\n out: Set<string>,\n isRoot = true,\n): void {\n if (!isRoot && t.isFunction(node)) {\n return\n }\n\n if (t.isVariableDeclaration(node) && node.kind === 'var') {\n for (const decl of node.declarations) {\n addPatternBindingsIfTracked(decl.id as t.LVal, tracked, out)\n }\n }\n\n const keys = t.VISITOR_KEYS[node.type]\n if (!keys) return\n for (const key of keys) {\n const child = (node as unknown as Record<string, unknown>)[key]\n if (Array.isArray(child)) {\n for (const item of child) {\n if (item && typeof item === 'object' && 'type' in item) {\n collectHoistedVarBindings(item as t.Node, tracked, out, false)\n }\n }\n } else if (child && typeof child === 'object' && 'type' in child) {\n collectHoistedVarBindings(child as t.Node, tracked, out, false)\n }\n }\n}\n\nfunction collectProgramBindings(\n program: t.Program,\n tracked: Set<string>,\n): Set<string> {\n const bindings = new Set<string>()\n\n for (const node of program.body) {\n if (t.isVariableDeclaration(node)) {\n for (const decl of node.declarations) {\n addPatternBindingsIfTracked(decl.id as t.LVal, tracked, bindings)\n }\n continue\n }\n\n if (t.isFunctionDeclaration(node) || t.isClassDeclaration(node)) {\n if (node.id && tracked.has(node.id.name)) {\n bindings.add(node.id.name)\n }\n }\n }\n\n return bindings\n}\n\nfunction collectBlockBindings(\n block: t.BlockStatement,\n tracked: Set<string>,\n): Set<string> {\n const bindings = new Set<string>()\n\n for (const node of block.body) {\n if (t.isVariableDeclaration(node) && node.kind !== 'var') {\n for (const decl of node.declarations) {\n addPatternBindingsIfTracked(decl.id as t.LVal, tracked, bindings)\n }\n continue\n }\n\n if (t.isFunctionDeclaration(node) || t.isClassDeclaration(node)) {\n if (node.id && tracked.has(node.id.name)) {\n bindings.add(node.id.name)\n }\n }\n }\n\n return bindings\n}\n\nfunction collectFunctionBindings(\n fn: t.Function,\n tracked: Set<string>,\n): Set<string> {\n const bindings = new Set<string>()\n\n if (\n (t.isFunctionDeclaration(fn) || t.isFunctionExpression(fn)) &&\n fn.id &&\n tracked.has(fn.id.name)\n ) {\n bindings.add(fn.id.name)\n }\n\n for (const param of fn.params) {\n addPatternBindingsIfTracked(param as t.LVal, tracked, bindings)\n }\n\n if (t.isBlockStatement(fn.body)) {\n collectHoistedVarBindings(fn.body, tracked, bindings)\n }\n\n return bindings\n}\n\ntype UsageWalkContext = {\n parents: Array<t.Node>\n scopeStack: Array<Set<string>>\n}\n\nfunction isShadowedByScope(\n name: string,\n scopeStack: Array<Set<string>>,\n): boolean {\n for (let i = scopeStack.length - 1; i >= 0; i--) {\n if (scopeStack[i]?.has(name)) {\n return true\n }\n }\n return false\n}\n\nfunction isBindingIdentifierInParent(\n node: t.Identifier,\n parent: t.Node | undefined,\n): boolean {\n if (!parent) return false\n\n if (t.isImportSpecifier(parent) || t.isImportDefaultSpecifier(parent)) {\n return parent.local === node\n }\n if (t.isImportNamespaceSpecifier(parent)) {\n return parent.local === node\n }\n if (t.isFunctionDeclaration(parent) || t.isFunctionExpression(parent)) {\n return (\n parent.id === node || parent.params.includes(node as unknown as t.Pattern)\n )\n }\n if (t.isArrowFunctionExpression(parent)) {\n return parent.params.includes(node as unknown as t.Pattern)\n }\n if (t.isClassDeclaration(parent) || t.isClassExpression(parent)) {\n return parent.id === node\n }\n if (t.isVariableDeclarator(parent)) {\n return parent.id === node\n }\n if (t.isCatchClause(parent)) {\n return parent.param === node\n }\n\n return false\n}\n\nfunction isInsideCompilerSafeBoundaryNodes(\n parents: Array<t.Node>,\n envType: BoundaryEnv,\n): boolean {\n for (let i = parents.length - 1; i >= 0; i--) {\n const node = parents[i]!\n if (!t.isFunction(node)) {\n continue\n }\n\n const call = parents[i - 1]\n if (\n call &&\n t.isCallExpression(call) &&\n isCompilerSafeBoundaryCall(call, node, envType)\n ) {\n return true\n }\n }\n\n return false\n}\n\nfunction findUsagePosInAnalysis(\n result: TransformResult,\n source: string,\n envType?: BoundaryEnv,\n): UsagePos | undefined {\n const analysis = getOrCreateImportAnalysis(result)\n const cacheKey: UsageCacheKey = `${envType ?? 'post'}::${source}`\n if (analysis.usageByKey.has(cacheKey)) {\n return analysis.usageByKey.get(cacheKey) ?? undefined\n }\n\n const imported =\n analysis.importBindingsBySource.get(source)?.importedLocalNames\n if (!imported || imported.size === 0) {\n analysis.usageByKey.set(cacheKey, null)\n return undefined\n }\n\n let preferred: UsagePos | undefined\n let anyUsage: UsagePos | undefined\n\n const visit = (node: t.Node, ctx: UsageWalkContext): void => {\n if (preferred && anyUsage) {\n return\n }\n\n if (t.isProgram(node)) {\n const nextCtx = {\n parents: [...ctx.parents, node],\n scopeStack: [...ctx.scopeStack, collectProgramBindings(node, imported)],\n }\n for (const child of node.body) {\n visit(child, nextCtx)\n }\n return\n }\n\n if (t.isFunction(node)) {\n const functionCtx = {\n parents: [...ctx.parents, node],\n scopeStack: [\n ...ctx.scopeStack,\n collectFunctionBindings(node, imported),\n ],\n }\n\n visit(node.body, functionCtx)\n return\n }\n\n if (t.isBlockStatement(node)) {\n const nextCtx = {\n parents: [...ctx.parents, node],\n scopeStack: [...ctx.scopeStack, collectBlockBindings(node, imported)],\n }\n for (const child of node.body) {\n visit(child, nextCtx)\n }\n return\n }\n\n if (t.isCatchClause(node)) {\n const bindings = new Set<string>()\n if (node.param) {\n addPatternBindingsIfTracked(node.param as t.LVal, imported, bindings)\n }\n const nextCtx = {\n parents: [...ctx.parents, node],\n scopeStack: bindings.size\n ? [...ctx.scopeStack, bindings]\n : ctx.scopeStack,\n }\n visit(node.body, nextCtx)\n return\n }\n\n if (\n t.isForStatement(node) &&\n t.isVariableDeclaration(node.init) &&\n node.init.kind !== 'var'\n ) {\n const bindings = new Set<string>()\n for (const decl of node.init.declarations) {\n addPatternBindingsIfTracked(decl.id as t.LVal, imported, bindings)\n }\n const nextCtx = {\n parents: [...ctx.parents, node],\n scopeStack: bindings.size\n ? [...ctx.scopeStack, bindings]\n : ctx.scopeStack,\n }\n visit(node.init, nextCtx)\n if (node.test) visit(node.test, nextCtx)\n if (node.update) visit(node.update, nextCtx)\n visit(node.body, nextCtx)\n return\n }\n\n if (\n (t.isForInStatement(node) || t.isForOfStatement(node)) &&\n t.isVariableDeclaration(node.left) &&\n node.left.kind !== 'var'\n ) {\n const bindings = new Set<string>()\n for (const decl of node.left.declarations) {\n addPatternBindingsIfTracked(decl.id as t.LVal, imported, bindings)\n }\n const nextCtx = {\n parents: [...ctx.parents, node],\n scopeStack: bindings.size\n ? [...ctx.scopeStack, bindings]\n : ctx.scopeStack,\n }\n visit(node.left, nextCtx)\n visit(node.right, nextCtx)\n visit(node.body, nextCtx)\n return\n }\n\n const nextParents = [...ctx.parents, node]\n\n if (t.isIdentifier(node)) {\n const parent = ctx.parents[ctx.parents.length - 1]\n if (imported.has(node.name)) {\n if (!isBindingIdentifierInParent(node, parent)) {\n if (\n !(\n t.isObjectProperty(parent) &&\n parent.key === node &&\n !parent.computed &&\n !parent.shorthand\n ) &&\n !(\n t.isObjectMethod(parent) &&\n parent.key === node &&\n !parent.computed\n ) &&\n !(t.isExportSpecifier(parent) && parent.exported === node) &&\n !isShadowedByScope(node.name, ctx.scopeStack) &&\n !(\n envType && isInsideCompilerSafeBoundaryNodes(ctx.parents, envType)\n )\n ) {\n const loc = node.loc?.start\n if (loc) {\n const pos: UsagePos = { line: loc.line, column0: loc.column }\n const isPreferred =\n (t.isCallExpression(parent) && parent.callee === node) ||\n (t.isNewExpression(parent) && parent.callee === node) ||\n ((t.isMemberExpression(parent) ||\n t.isOptionalMemberExpression(parent)) &&\n parent.object === node)\n\n if (isPreferred) {\n preferred ||= pos\n } else {\n anyUsage ||= pos\n }\n }\n }\n }\n }\n }\n\n if (t.isImportDeclaration(node)) {\n return\n }\n\n const keys = t.VISITOR_KEYS[node.type]\n if (!keys) return\n for (const key of keys) {\n const child = (node as unknown as Record<string, unknown>)[key]\n if (Array.isArray(child)) {\n for (const item of child) {\n if (item && typeof item === 'object' && 'type' in item) {\n visit(item as t.Node, {\n parents: nextParents,\n scopeStack: ctx.scopeStack,\n })\n }\n }\n } else if (child && typeof child === 'object' && 'type' in child) {\n visit(child as t.Node, {\n parents: nextParents,\n scopeStack: ctx.scopeStack,\n })\n }\n }\n }\n\n visit(analysis.ast.program, {\n parents: [],\n scopeStack: [],\n })\n\n const pos = preferred ?? anyUsage ?? null\n analysis.usageByKey.set(cacheKey, pos)\n return pos ?? undefined\n}\n\nexport function findPostCompileUsagePosFromResult(\n result: TransformResult,\n source: string,\n): UsagePos | undefined {\n return findUsagePosInAnalysis(result, source)\n}\n\nexport function findPostCompileUsagePos(\n code: string,\n source: string,\n): UsagePos | undefined {\n return findPostCompileUsagePosFromResult(makeTransientResult(code), source)\n}\n\nexport function findOriginalUnsafeUsagePosFromResult(\n result: TransformResult,\n source: string,\n envType: BoundaryEnv,\n): UsagePos | undefined {\n return findUsagePosInAnalysis(result, source, envType)\n}\n\nexport function findOriginalUnsafeUsagePos(\n code: string,\n source: string,\n envType: BoundaryEnv,\n): UsagePos | undefined {\n return findOriginalUnsafeUsagePosFromResult(\n makeTransientResult(code),\n source,\n envType,\n )\n}\n"],"mappings":";;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B;AACtB,QAAO,uBAAuB,QAAQ,QAAQ,QAAQ"}
@@ -1,5 +1,5 @@
1
1
  import { parseAst } from "@tanstack/router-utils";
2
- //#region src/import-protection-plugin/ast.ts
2
+ //#region src/import-protection/ast.ts
3
3
  function parseImportProtectionAst(code) {
4
4
  return parseAst({ code });
5
5
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.js","names":[],"sources":["../../../src/import-protection/ast.ts"],"sourcesContent":["import { parseAst } from '@tanstack/router-utils'\n\nexport type ParsedAst = ReturnType<typeof parseAst>\n\nexport function parseImportProtectionAst(code: string): ParsedAst {\n return parseAst({ code })\n}\n"],"mappings":";;AAIA,SAAgB,yBAAyB,MAAyB;AAChE,QAAO,SAAS,EAAE,MAAM,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const SERVER_FN_LOOKUP_QUERY = "?server-fn-module-lookup";
2
+ export declare const MOCK_MODULE_ID = "tanstack-start-import-protection:mock";
3
+ export declare const MOCK_BUILD_PREFIX = "tanstack-start-import-protection:mock:build:";
4
+ export declare const MOCK_EDGE_PREFIX = "tanstack-start-import-protection:mock-edge:";
5
+ export declare const MOCK_RUNTIME_PREFIX = "tanstack-start-import-protection:mock-runtime:";
6
+ export declare const MARKER_PREFIX = "tanstack-start-import-protection:marker:";
7
+ export declare const IMPORT_PROTECTION_DEBUG: boolean;
8
+ export declare const IMPORT_PROTECTION_DEBUG_FILTER: string | undefined;
9
+ export declare const KNOWN_SOURCE_EXTENSIONS: Set<string>;
10
+ /** Vite's browser-visible prefix for virtual modules (replaces `\0`). */
11
+ export declare const VITE_BROWSER_VIRTUAL_PREFIX = "/@id/__x00__";
@@ -1,6 +1,11 @@
1
1
  import { SERVER_FN_LOOKUP } from "../constants.js";
2
- //#region src/import-protection-plugin/constants.ts
2
+ //#region src/import-protection/constants.ts
3
3
  var SERVER_FN_LOOKUP_QUERY = `?${SERVER_FN_LOOKUP}`;
4
+ var MOCK_MODULE_ID = "tanstack-start-import-protection:mock";
5
+ var MOCK_BUILD_PREFIX = "tanstack-start-import-protection:mock:build:";
6
+ var MOCK_EDGE_PREFIX = "tanstack-start-import-protection:mock-edge:";
7
+ var MOCK_RUNTIME_PREFIX = "tanstack-start-import-protection:mock-runtime:";
8
+ var MARKER_PREFIX = "tanstack-start-import-protection:marker:";
4
9
  var IMPORT_PROTECTION_DEBUG = process.env.TSR_IMPORT_PROTECTION_DEBUG === "1" || process.env.TSR_IMPORT_PROTECTION_DEBUG === "true";
5
10
  var IMPORT_PROTECTION_DEBUG_FILTER = process.env.TSR_IMPORT_PROTECTION_DEBUG_FILTER;
6
11
  var KNOWN_SOURCE_EXTENSIONS = new Set([
@@ -17,6 +22,6 @@ var KNOWN_SOURCE_EXTENSIONS = new Set([
17
22
  /** Vite's browser-visible prefix for virtual modules (replaces `\0`). */
18
23
  var VITE_BROWSER_VIRTUAL_PREFIX = "/@id/__x00__";
19
24
  //#endregion
20
- export { IMPORT_PROTECTION_DEBUG, IMPORT_PROTECTION_DEBUG_FILTER, KNOWN_SOURCE_EXTENSIONS, SERVER_FN_LOOKUP_QUERY, VITE_BROWSER_VIRTUAL_PREFIX };
25
+ export { IMPORT_PROTECTION_DEBUG, IMPORT_PROTECTION_DEBUG_FILTER, KNOWN_SOURCE_EXTENSIONS, MARKER_PREFIX, MOCK_BUILD_PREFIX, MOCK_EDGE_PREFIX, MOCK_MODULE_ID, MOCK_RUNTIME_PREFIX, SERVER_FN_LOOKUP_QUERY, VITE_BROWSER_VIRTUAL_PREFIX };
21
26
 
22
27
  //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../../../src/import-protection/constants.ts"],"sourcesContent":["import { SERVER_FN_LOOKUP } from '../constants'\n\nexport const SERVER_FN_LOOKUP_QUERY = `?${SERVER_FN_LOOKUP}`\n\nexport const MOCK_MODULE_ID = 'tanstack-start-import-protection:mock'\nexport const MOCK_BUILD_PREFIX = 'tanstack-start-import-protection:mock:build:'\nexport const MOCK_EDGE_PREFIX = 'tanstack-start-import-protection:mock-edge:'\nexport const MOCK_RUNTIME_PREFIX =\n 'tanstack-start-import-protection:mock-runtime:'\nexport const MARKER_PREFIX = 'tanstack-start-import-protection:marker:'\n\nexport const IMPORT_PROTECTION_DEBUG =\n process.env.TSR_IMPORT_PROTECTION_DEBUG === '1' ||\n process.env.TSR_IMPORT_PROTECTION_DEBUG === 'true'\n\nexport const IMPORT_PROTECTION_DEBUG_FILTER =\n process.env.TSR_IMPORT_PROTECTION_DEBUG_FILTER\n\nexport const KNOWN_SOURCE_EXTENSIONS = new Set([\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n '.json',\n])\n\n/** Vite's browser-visible prefix for virtual modules (replaces `\\0`). */\nexport const VITE_BROWSER_VIRTUAL_PREFIX = '/@id/__x00__'\n"],"mappings":";;AAEA,IAAa,yBAAyB,IAAI;AAE1C,IAAa,iBAAiB;AAC9B,IAAa,oBAAoB;AACjC,IAAa,mBAAmB;AAChC,IAAa,sBACX;AACF,IAAa,gBAAgB;AAE7B,IAAa,0BACX,QAAQ,IAAI,gCAAgC,OAC5C,QAAQ,IAAI,gCAAgC;AAE9C,IAAa,iCACX,QAAQ,IAAI;AAEd,IAAa,0BAA0B,IAAI,IAAI;CAC7C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;AAGF,IAAa,8BAA8B"}