resuxjs 0.4.0-beta.7 → 0.4.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 (185) hide show
  1. package/README.md +4 -2
  2. package/dist/_virtual/_rolldown/runtime.js +4 -0
  3. package/dist/build/index.d.ts +1 -2
  4. package/dist/cli.d.ts +3 -3
  5. package/dist/cli.js +125 -31
  6. package/dist/cli.js.map +1 -1
  7. package/dist/compiler/adapter.d.ts +2 -3
  8. package/dist/compiler/adapter.js +2 -2
  9. package/dist/compiler/dev-warnings.d.ts +1 -2
  10. package/dist/compiler/directives.d.ts +1 -2
  11. package/dist/compiler/directives.js +7 -3
  12. package/dist/compiler/directives.js.map +1 -1
  13. package/dist/compiler/implementation.d.ts +4 -2
  14. package/dist/compiler/implementation.js +101 -43
  15. package/dist/compiler/index.d.ts +2 -3
  16. package/dist/compiler/index.js +2 -2
  17. package/dist/compiler/index.js.map +1 -1
  18. package/dist/core/config.d.ts +1 -2
  19. package/dist/core/hooks.d.ts +10 -2
  20. package/dist/core/hooks.js.map +1 -1
  21. package/dist/core/index.d.ts +2 -2
  22. package/dist/core/module-container.d.ts +1 -2
  23. package/dist/core/module-container.js +2 -1
  24. package/dist/core/module-container.js.map +1 -1
  25. package/dist/core/resux.d.ts +1 -2
  26. package/dist/create.d.ts +1 -2
  27. package/dist/create.js +110 -33
  28. package/dist/create.js.map +1 -1
  29. package/dist/deploy/cloudflare.d.ts +1 -2
  30. package/dist/deploy/common.d.ts +1 -2
  31. package/dist/deploy/common.js +19 -3
  32. package/dist/deploy/common.js.map +1 -1
  33. package/dist/deploy/framework-runtime.d.ts +1 -2
  34. package/dist/deploy/index.d.ts +1 -2
  35. package/dist/deploy/netlify.d.ts +1 -2
  36. package/dist/deploy/node.d.ts +1 -2
  37. package/dist/deploy/production-report.d.ts +1 -2
  38. package/dist/deploy/runtime-dependencies.d.ts +1 -2
  39. package/dist/deploy/static.d.ts +1 -2
  40. package/dist/deploy/types.d.ts +1 -2
  41. package/dist/deploy/vercel.d.ts +1 -2
  42. package/dist/deploy/vercel.js +3 -3
  43. package/dist/deploy/vercel.js.map +1 -1
  44. package/dist/fonts/index.d.ts +1 -2
  45. package/dist/fonts/index.js.map +1 -1
  46. package/dist/globals.d.ts +1 -2
  47. package/dist/halal-core/ai/classifyProject.d.ts +1 -2
  48. package/dist/halal-core/ai/classifyRuntimeContent.d.ts +1 -2
  49. package/dist/halal-core/ai/createProjectSummary.d.ts +1 -2
  50. package/dist/halal-core/ai/halalClassifierPrompt.d.ts +1 -2
  51. package/dist/halal-core/ai/redactSensitiveData.d.ts +1 -2
  52. package/dist/halal-core/ai/validateAiResponse.d.ts +1 -2
  53. package/dist/halal-core/cli/check.d.ts +1 -2
  54. package/dist/halal-core/cli/explain.d.ts +1 -2
  55. package/dist/halal-core/cli/report.d.ts +1 -2
  56. package/dist/halal-core/cli/submitReview.d.ts +1 -2
  57. package/dist/halal-core/cli/verifyReview.d.ts +1 -2
  58. package/dist/halal-core/config.d.ts +2 -2
  59. package/dist/halal-core/config.js.map +1 -1
  60. package/dist/halal-core/crypto/integrity.d.ts +1 -2
  61. package/dist/halal-core/crypto/integrity.js +1 -1
  62. package/dist/halal-core/crypto/integrity.js.map +1 -1
  63. package/dist/halal-core/enforce.d.ts +4 -3
  64. package/dist/halal-core/enforce.js +31 -4
  65. package/dist/halal-core/enforce.js.map +1 -1
  66. package/dist/halal-core/lifecycle.d.ts +1 -2
  67. package/dist/halal-core/policy.d.ts +1 -2
  68. package/dist/halal-core/report/formatBrowserOverlay.d.ts +1 -2
  69. package/dist/halal-core/report/formatTerminalReport.d.ts +1 -2
  70. package/dist/halal-core/report/generateHalalReport.d.ts +1 -2
  71. package/dist/halal-core/report/signReport.d.ts +1 -2
  72. package/dist/halal-core/report/verifyReport.d.ts +1 -2
  73. package/dist/halal-core/review/createReviewRequest.d.ts +1 -2
  74. package/dist/halal-core/review/reviewPolicy.d.ts +1 -2
  75. package/dist/halal-core/review/signedReviewFile.d.ts +1 -2
  76. package/dist/halal-core/review/verifyReviewApproval.d.ts +1 -2
  77. package/dist/halal-core/rules/adultContentRules.d.ts +1 -2
  78. package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +1 -2
  79. package/dist/halal-core/rules/childSafetyRules.d.ts +1 -2
  80. package/dist/halal-core/rules/coreCategories.d.ts +1 -2
  81. package/dist/halal-core/rules/cyberAbuseRules.d.ts +1 -2
  82. package/dist/halal-core/rules/defaultBlockedRules.d.ts +1 -2
  83. package/dist/halal-core/rules/dependencyRules.d.ts +1 -2
  84. package/dist/halal-core/rules/endpointRules.d.ts +1 -2
  85. package/dist/halal-core/rules/environmentalHarmRules.d.ts +1 -2
  86. package/dist/halal-core/rules/financeRibaRules.d.ts +1 -2
  87. package/dist/halal-core/rules/gamblingRules.d.ts +1 -2
  88. package/dist/halal-core/rules/generalHarmRules.d.ts +1 -2
  89. package/dist/halal-core/rules/healthHarmRules.d.ts +1 -2
  90. package/dist/halal-core/rules/keywordRules.d.ts +1 -2
  91. package/dist/halal-core/rules/privacyAbuseRules.d.ts +1 -2
  92. package/dist/halal-core/rules/scamFraudRules.d.ts +1 -2
  93. package/dist/halal-core/rules/selfHarmRules.d.ts +1 -2
  94. package/dist/halal-core/rules/violenceExtremismRules.d.ts +1 -2
  95. package/dist/halal-core/runtime/guard.d.ts +1 -2
  96. package/dist/halal-core/runtime/guard.js.map +1 -1
  97. package/dist/halal-core/runtime/reviewedMemory.d.ts +1 -2
  98. package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +1 -2
  99. package/dist/halal-core/runtime/types.d.ts +1 -2
  100. package/dist/halal-core/scanner/scanApiRoutes.d.ts +1 -2
  101. package/dist/halal-core/scanner/scanComponents.d.ts +1 -2
  102. package/dist/halal-core/scanner/scanContent.d.ts +1 -2
  103. package/dist/halal-core/scanner/scanDependencies.d.ts +1 -2
  104. package/dist/halal-core/scanner/scanDomains.d.ts +1 -2
  105. package/dist/halal-core/scanner/scanEnvNames.d.ts +1 -2
  106. package/dist/halal-core/scanner/scanMetadata.d.ts +1 -2
  107. package/dist/halal-core/scanner/scanPages.d.ts +1 -2
  108. package/dist/halal-core/scanner/scanProject.d.ts +1 -2
  109. package/dist/halal-core/scanner/scanRoutes.d.ts +1 -2
  110. package/dist/halal-core/scanner/scanTranslations.d.ts +1 -2
  111. package/dist/halal-core/status.d.ts +1 -2
  112. package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +1 -2
  113. package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +1 -2
  114. package/dist/halal-core/tamper/verifyReportSignature.d.ts +1 -2
  115. package/dist/head/utils.d.ts +15 -0
  116. package/dist/head/utils.js +52 -0
  117. package/dist/head/utils.js.map +1 -0
  118. package/dist/i18n/index.d.ts +1 -2
  119. package/dist/i18n/index.js.map +1 -1
  120. package/dist/i18n/shared.d.ts +1 -2
  121. package/dist/icons/api-fetcher.d.ts +1 -2
  122. package/dist/icons/cache.d.ts +1 -2
  123. package/dist/icons/cache.js.map +1 -1
  124. package/dist/icons/component.d.ts +7 -8
  125. package/dist/icons/constants.d.ts +1 -2
  126. package/dist/icons/css-mode.d.ts +1 -2
  127. package/dist/icons/index.d.ts +1 -2
  128. package/dist/icons/index.js.map +1 -1
  129. package/dist/icons/local-svg.d.ts +1 -2
  130. package/dist/icons/normalize.d.ts +1 -2
  131. package/dist/icons/offline-loader.d.ts +1 -2
  132. package/dist/icons/parser.d.ts +1 -2
  133. package/dist/icons/registry.d.ts +1 -2
  134. package/dist/icons/resolver.d.ts +1 -2
  135. package/dist/icons/svg-mode.d.ts +1 -2
  136. package/dist/icons/transform.d.ts +1 -2
  137. package/dist/icons/types.d.ts +1 -2
  138. package/dist/index.d.ts +2 -2
  139. package/dist/index.js +2 -2
  140. package/dist/kit/index.d.ts +1 -2
  141. package/dist/nitro-server/index.d.ts +1 -2
  142. package/dist/node.d.ts +1 -2
  143. package/dist/reactivity/computed.d.ts +1 -2
  144. package/dist/reactivity/computed.js.map +1 -1
  145. package/dist/reactivity/effect.d.ts +3 -3
  146. package/dist/reactivity/effect.js +8 -3
  147. package/dist/reactivity/effect.js.map +1 -1
  148. package/dist/reactivity/reactive.d.ts +1 -2
  149. package/dist/reactivity/reactive.js +221 -11
  150. package/dist/reactivity/reactive.js.map +1 -1
  151. package/dist/reactivity/ref.d.ts +1 -2
  152. package/dist/reactivity/ref.js.map +1 -1
  153. package/dist/reactivity/scheduler.d.ts +1 -2
  154. package/dist/reactivity/scheduler.js +2 -0
  155. package/dist/reactivity/scheduler.js.map +1 -1
  156. package/dist/reactivity/types.d.ts +1 -2
  157. package/dist/reactivity/utils.d.ts +1 -2
  158. package/dist/reactivity/watch.d.ts +1 -2
  159. package/dist/reactivity/watch.js.map +1 -1
  160. package/dist/runtime/core.d.ts +1 -2
  161. package/dist/runtime/core.js.map +1 -1
  162. package/dist/runtime/index.d.ts +19 -2
  163. package/dist/runtime/index.js +921 -170
  164. package/dist/runtime/index.js.map +1 -1
  165. package/dist/runtime/resume.d.ts +1 -2
  166. package/dist/runtime/resume.js.map +1 -1
  167. package/dist/runtime/router.d.ts +1 -2
  168. package/dist/runtime/router.js.map +1 -1
  169. package/dist/runtime/streaming.d.ts +1 -2
  170. package/dist/runtime/streaming.js.map +1 -1
  171. package/dist/runtime/view-transitions/detect.d.ts +1 -2
  172. package/dist/runtime/view-transitions/transition.d.ts +1 -2
  173. package/dist/runtime/view-transitions/types.d.ts +1 -2
  174. package/dist/security/media-fetch.d.ts +1 -2
  175. package/dist/security/media-fetch.js.map +1 -1
  176. package/dist/security/path-boundary.d.ts +1 -2
  177. package/dist/security/path-boundary.js +10 -4
  178. package/dist/security/path-boundary.js.map +1 -1
  179. package/dist/ui/index.d.ts +41 -42
  180. package/dist/ui/verification-code.d.ts +9 -10
  181. package/dist/ui/verification-code.js.map +1 -1
  182. package/dist/vite-builder/index.d.ts +1 -2
  183. package/package.json +2 -2
  184. package/templates/default/.env.example +3 -0
  185. package/templates/default/nitro.config.ts +16 -4
@@ -1,4 +1,4 @@
1
- import { BuildOptions, BuildResult, ClientEnhancementManifestEntry, CompileErrorLocation, CompiledComponent, CompiledMiddleware, CompiledPlugin, CompiledServerMiddleware, ResuxCompileError, RouteManifestRecord, RouteRuleConfig, ServerHandlerRecord, VueIslandRecord, createRouteManifest, fileUrl, resolveFileExtension } from "./index.js";
1
+ import { BuildOptions, BuildResult, ClientEnhancementManifestEntry, CompileErrorLocation, CompiledComponent, CompiledMiddleware, CompiledPlugin, CompiledServerMiddleware, RESUMABLE_HANDLER_ALLOWED_GLOBALS, ResuxCompileError, RouteManifestRecord, RouteRuleConfig, ServerHandlerRecord, VueIslandRecord, createRouteManifest, fileUrl, resolveFileExtension } from "./index.js";
2
2
  import { normalizeResuxDirectiveSyntax, normalizeResuxSfcSource } from "./directives.js";
3
3
  export interface ResuxCompileVueSourceOptions {
4
4
  file: string;
@@ -14,5 +14,4 @@ export declare function compileVueFile(file: string, options: {
14
14
  dev?: boolean;
15
15
  }): Promise<CompiledComponent>;
16
16
  export declare function buildProject(appRoot: string, outDir?: string, options?: BuildOptions): Promise<BuildResult>;
17
- export { BuildOptions, BuildResult, ClientEnhancementManifestEntry, CompileErrorLocation, CompiledComponent, CompiledMiddleware, CompiledPlugin, CompiledServerMiddleware, ResuxCompileError, RouteManifestRecord, RouteRuleConfig, ServerHandlerRecord, VueIslandRecord, createRouteManifest, fileUrl, normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, resolveFileExtension };
18
- //# sourceMappingURL=adapter.d.ts.map
17
+ export { BuildOptions, BuildResult, ClientEnhancementManifestEntry, CompileErrorLocation, CompiledComponent, CompiledMiddleware, CompiledPlugin, CompiledServerMiddleware, RESUMABLE_HANDLER_ALLOWED_GLOBALS, ResuxCompileError, RouteManifestRecord, RouteRuleConfig, ServerHandlerRecord, VueIslandRecord, createRouteManifest, fileUrl, normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, resolveFileExtension };
@@ -1,4 +1,4 @@
1
- import { ResuxCompileError, buildProject as buildProject$1, compileVueSource as compileVueSource$1, createRouteManifest, fileUrl, resolveFileExtension } from "./index.js";
1
+ import { RESUMABLE_HANDLER_ALLOWED_GLOBALS, ResuxCompileError, buildProject as buildProject$1, compileVueSource as compileVueSource$1, createRouteManifest, fileUrl, resolveFileExtension } from "./index.js";
2
2
  import { normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, rethrowWithResuxDirectiveBrand } from "./directives.js";
3
3
  import { emitResuxDevWarnings } from "./dev-warnings.js";
4
4
  import { syncBuiltinESMExports } from "node:module";
@@ -75,6 +75,6 @@ async function withResuxDirectiveFileReads(task, emittedDevWarnings) {
75
75
  function pascalCase(value) {
76
76
  return value.replace(/\[[^\]]+\]/g, (match) => match.slice(1, -1)).split(/[^A-Za-z0-9]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
77
77
  }
78
- export { ResuxCompileError, buildProject, compileVueFile, compileVueSource, createRouteManifest, fileUrl, normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, resolveFileExtension };
78
+ export { RESUMABLE_HANDLER_ALLOWED_GLOBALS, ResuxCompileError, buildProject, compileVueFile, compileVueSource, createRouteManifest, fileUrl, normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, resolveFileExtension };
79
79
 
80
80
  //# sourceMappingURL=adapter.js.map
@@ -8,5 +8,4 @@ export interface ResuxDevWarning {
8
8
  }
9
9
  export declare function collectResuxDevWarnings(source: string, file?: string): ResuxDevWarning[];
10
10
  export declare function emitResuxDevWarnings(source: string, file: string, emitted?: Set<string>): void;
11
- export declare function formatResuxDevWarning(warning: ResuxDevWarning): string;
12
- //# sourceMappingURL=dev-warnings.d.ts.map
11
+ export declare function formatResuxDevWarning(warning: ResuxDevWarning): string;
@@ -10,5 +10,4 @@ export declare function normalizeResuxDirectiveSyntax(template: string): string;
10
10
  */
11
11
  export declare function normalizeResuxSfcSource(source: string, filename?: string): string;
12
12
  /** Rewords compiler diagnostics so the public API always speaks Resux syntax. */
13
- export declare function rethrowWithResuxDirectiveBrand(error: unknown): never;
14
- //# sourceMappingURL=directives.d.ts.map
13
+ export declare function rethrowWithResuxDirectiveBrand(error: unknown): never;
@@ -77,15 +77,19 @@ function resolveTemplateContentBounds(source, content, reportedOffset) {
77
77
  end: fallbackStart + content.length
78
78
  };
79
79
  }
80
+ function previousNonSpaceChar(source, index) {
81
+ for (let cursor = index - 1; cursor >= 0; cursor--) if (!/\s/.test(source[cursor])) return source[cursor];
82
+ return "";
83
+ }
80
84
  function findTagEnd(source, start) {
81
85
  let quote = null;
82
86
  for (let index = start; index < source.length; index++) {
83
87
  const char = source[index];
84
88
  if (quote) {
85
- if (char === quote && source[index - 1] !== "\\") quote = null;
89
+ if (char === quote) quote = null;
86
90
  continue;
87
91
  }
88
- if (char === "\"" || char === "'") {
92
+ if ((char === "\"" || char === "'") && previousNonSpaceChar(source, index) === "=") {
89
93
  quote = char;
90
94
  continue;
91
95
  }
@@ -106,7 +110,7 @@ function normalizeOpeningTag(tag) {
106
110
  const valueStart = cursor;
107
111
  cursor++;
108
112
  while (cursor < tag.length) {
109
- if (tag[cursor] === quote && tag[cursor - 1] !== "\\") {
113
+ if (tag[cursor] === quote) {
110
114
  cursor++;
111
115
  break;
112
116
  }
@@ -1 +1 @@
1
- {"version":3,"file":"directives.js","names":["parseSfc"],"sources":["../../src/compiler/directives.ts"],"sourcesContent":["import { parse as parseSfc } from \"@vue/compiler-sfc\";\n\nconst RX_DIRECTIVE_PREFIX = \"rx-\";\nconst VUE_DIRECTIVE_PREFIX = \"v-\";\n\n/**\n * Converts Resux-branded directive attributes (`rx-*`) to the directive names\n * understood by Vue's template parser. Only attribute names inside opening\n * template tags are changed; text, comments and attribute values are preserved.\n */\nexport function normalizeResuxDirectiveSyntax(template: string): string {\n let output = \"\";\n let cursor = 0;\n\n while (cursor < template.length) {\n const tagStart = template.indexOf(\"<\", cursor);\n if (tagStart === -1) {\n output += template.slice(cursor);\n break;\n }\n\n output += template.slice(cursor, tagStart);\n\n if (template.startsWith(\"<!--\", tagStart)) {\n const commentEnd = template.indexOf(\"-->\", tagStart + 4);\n if (commentEnd === -1) {\n output += template.slice(tagStart);\n break;\n }\n output += template.slice(tagStart, commentEnd + 3);\n cursor = commentEnd + 3;\n continue;\n }\n\n const tagEnd = findTagEnd(template, tagStart + 1);\n if (tagEnd === -1) {\n output += template.slice(tagStart);\n break;\n }\n\n output += normalizeOpeningTag(template.slice(tagStart, tagEnd + 1));\n cursor = tagEnd + 1;\n }\n\n return output;\n}\n\n/**\n * Normalizes only the `<template>` block of a Vue SFC. Script and style blocks\n * are intentionally untouched, so strings such as `\"rx-if\"` keep their value.\n */\nexport function normalizeResuxSfcSource(source: string, filename = \"component.vue\"): string {\n if (!source.includes(RX_DIRECTIVE_PREFIX)) {\n return source;\n }\n\n const parsed = parseSfc(source, { filename });\n const template = parsed.descriptor.template;\n if (!template || !template.content.includes(RX_DIRECTIVE_PREFIX)) {\n return source;\n }\n\n const normalizedTemplate = normalizeResuxDirectiveSyntax(template.content);\n if (normalizedTemplate === template.content) {\n return source;\n }\n\n const bounds = resolveTemplateContentBounds(source, template.content, template.loc.start.offset);\n if (!bounds) {\n return source;\n }\n\n return `${source.slice(0, bounds.start)}${normalizedTemplate}${source.slice(bounds.end)}`;\n}\n\n/** Rewords compiler diagnostics so the public API always speaks Resux syntax. */\nexport function rethrowWithResuxDirectiveBrand(error: unknown): never {\n if (error instanceof Error) {\n error.message = brandDirectiveText(error.message);\n if (error.stack) {\n error.stack = brandDirectiveText(error.stack);\n }\n }\n throw error;\n}\n\nfunction brandDirectiveText(value: string): string {\n return value.replace(/\\bv-(?=[a-z][\\w-]*)/gi, RX_DIRECTIVE_PREFIX);\n}\n\nfunction resolveTemplateContentBounds(\n source: string,\n content: string,\n reportedOffset: number,\n): { start: number; end: number } | null {\n if (source.slice(reportedOffset, reportedOffset + content.length) === content) {\n return { start: reportedOffset, end: reportedOffset + content.length };\n }\n\n const templateOpen = /<template(?:\\s[^>]*)?>/i.exec(source);\n if (!templateOpen || templateOpen.index === undefined) {\n return null;\n }\n\n const openingEnd = templateOpen.index + templateOpen[0].length;\n const fallbackStart = source.indexOf(content, openingEnd);\n if (fallbackStart === -1) {\n return null;\n }\n\n return { start: fallbackStart, end: fallbackStart + content.length };\n}\n\nfunction findTagEnd(source: string, start: number): number {\n let quote: '\"' | \"'\" | null = null;\n\n for (let index = start; index < source.length; index++) {\n const char = source[index];\n if (quote) {\n if (char === quote && source[index - 1] !== \"\\\\\") {\n quote = null;\n }\n continue;\n }\n\n if (char === '\"' || char === \"'\") {\n quote = char;\n continue;\n }\n\n if (char === \">\") {\n return index;\n }\n }\n\n return -1;\n}\n\nfunction normalizeOpeningTag(tag: string): string {\n if (/^<\\s*(?:\\/|!|\\?)/.test(tag)) {\n return tag;\n }\n\n let output = \"\";\n let cursor = 0;\n let expectsUnquotedValue = false;\n\n // Copy the opening bracket, whitespace and element name unchanged.\n while (cursor < tag.length && !/\\s/.test(tag[cursor]) && tag[cursor] !== \">\") {\n output += tag[cursor++];\n }\n\n while (cursor < tag.length) {\n const char = tag[cursor];\n\n if (char === '\"' || char === \"'\") {\n const quote = char;\n const valueStart = cursor;\n cursor++;\n while (cursor < tag.length) {\n if (tag[cursor] === quote && tag[cursor - 1] !== \"\\\\\") {\n cursor++;\n break;\n }\n cursor++;\n }\n output += tag.slice(valueStart, cursor);\n expectsUnquotedValue = false;\n continue;\n }\n\n if (/\\s/.test(char) || char === \"/\" || char === \">\") {\n output += char;\n cursor++;\n continue;\n }\n\n if (char === \"=\") {\n output += char;\n cursor++;\n expectsUnquotedValue = true;\n continue;\n }\n\n const tokenStart = cursor;\n while (\n cursor < tag.length\n && !/\\s/.test(tag[cursor])\n && tag[cursor] !== \"=\"\n && tag[cursor] !== \"/\"\n && tag[cursor] !== \">\"\n ) {\n cursor++;\n }\n\n const token = tag.slice(tokenStart, cursor);\n output += !expectsUnquotedValue\n && token.startsWith(RX_DIRECTIVE_PREFIX)\n && token.length >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AG,GAC7B,OAAO;CAGT,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI,uBAAuB;CAG3B,OAAO,SAAS,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,OAAO,KAAK,IAAI,YAAY,KACvE,UAAU,IAAI;CAGhB,OAAO,SAAS,IAAI,QAAQ;EAC1B,MAAM,OAAO,IAAI;EAEjB,IAAI,SAAS,QAAO,SAAS,KAAK;GAChC,MAAM,QAAQ;GACd,MAAM,aAAa;GACnB;GACA,OAAO,SAAS,IAAI,QAAQ;IAC1B,IAAI,IAAI,YAAY,SAAS,IAAI,SAAS,OAAO,MAAM;KACrD;KACA;IACF;IACA;GACF;GACA,UAAU,IAAI,MAAM,YAAY,MAAM;GACtC,uBAAuB;GACvB;EACF;EAEA,IAAI,KAAK,KAAK,IAAI,KAAK,SAAS,OAAO,SAAS,KAAK;GACnD,UAAU;GACV;GACA;EACF;EAEA,IAAI,SAAS,KAAK;GAChB,UAAU;GACV;GACA,uBAAuB;GACvB;EACF;EAEA,MAAM,aAAa;EACnB,OACE,SAAS,IAAI,UACV,CAAC,KAAK,KAAK,IAAI,OAAO,KACtB,IAAI,YAAY,OAChB,IAAI,YAAY,OAChB,IAAI,YAAY,KAEnB;EAGF,MAAM,QAAQ,IAAI,MAAM,YAAY,MAAM;EAC1C,UAAU,CAAC,wBACN,MAAM,WAAW,mBAAmB,KACpC,MAAM,SAAS,IACd,GAAG,uBAAuB,MAAM,MAAM,CAA0B,MAChE;EACN,uBAAuB;CACzB;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"directives.js","names":["parseSfc"],"sources":["../../src/compiler/directives.ts"],"sourcesContent":["import { parse as parseSfc } from \"@vue/compiler-sfc\";\n\nconst RX_DIRECTIVE_PREFIX = \"rx-\";\nconst VUE_DIRECTIVE_PREFIX = \"v-\";\n\n/**\n * Converts Resux-branded directive attributes (`rx-*`) to the directive names\n * understood by Vue's template parser. Only attribute names inside opening\n * template tags are changed; text, comments and attribute values are preserved.\n */\nexport function normalizeResuxDirectiveSyntax(template: string): string {\n let output = \"\";\n let cursor = 0;\n\n while (cursor < template.length) {\n const tagStart = template.indexOf(\"<\", cursor);\n if (tagStart === -1) {\n output += template.slice(cursor);\n break;\n }\n\n output += template.slice(cursor, tagStart);\n\n if (template.startsWith(\"<!--\", tagStart)) {\n const commentEnd = template.indexOf(\"-->\", tagStart + 4);\n if (commentEnd === -1) {\n output += template.slice(tagStart);\n break;\n }\n output += template.slice(tagStart, commentEnd + 3);\n cursor = commentEnd + 3;\n continue;\n }\n\n const tagEnd = findTagEnd(template, tagStart + 1);\n if (tagEnd === -1) {\n output += template.slice(tagStart);\n break;\n }\n\n output += normalizeOpeningTag(template.slice(tagStart, tagEnd + 1));\n cursor = tagEnd + 1;\n }\n\n return output;\n}\n\n/**\n * Normalizes only the `<template>` block of a Vue SFC. Script and style blocks\n * are intentionally untouched, so strings such as `\"rx-if\"` keep their value.\n */\nexport function normalizeResuxSfcSource(source: string, filename = \"component.vue\"): string {\n if (!source.includes(RX_DIRECTIVE_PREFIX)) {\n return source;\n }\n\n const parsed = parseSfc(source, { filename });\n const template = parsed.descriptor.template;\n if (!template || !template.content.includes(RX_DIRECTIVE_PREFIX)) {\n return source;\n }\n\n const normalizedTemplate = normalizeResuxDirectiveSyntax(template.content);\n if (normalizedTemplate === template.content) {\n return source;\n }\n\n const bounds = resolveTemplateContentBounds(source, template.content, template.loc.start.offset);\n if (!bounds) {\n return source;\n }\n\n return `${source.slice(0, bounds.start)}${normalizedTemplate}${source.slice(bounds.end)}`;\n}\n\n/** Rewords compiler diagnostics so the public API always speaks Resux syntax. */\nexport function rethrowWithResuxDirectiveBrand(error: unknown): never {\n if (error instanceof Error) {\n error.message = brandDirectiveText(error.message);\n if (error.stack) {\n error.stack = brandDirectiveText(error.stack);\n }\n }\n throw error;\n}\n\nfunction brandDirectiveText(value: string): string {\n return value.replace(/\\bv-(?=[a-z][\\w-]*)/gi, RX_DIRECTIVE_PREFIX);\n}\n\nfunction resolveTemplateContentBounds(\n source: string,\n content: string,\n reportedOffset: number,\n): { start: number; end: number } | null {\n if (source.slice(reportedOffset, reportedOffset + content.length) === content) {\n return { start: reportedOffset, end: reportedOffset + content.length };\n }\n\n const templateOpen = /<template(?:\\s[^>]*)?>/i.exec(source);\n if (!templateOpen || templateOpen.index === undefined) {\n return null;\n }\n\n const openingEnd = templateOpen.index + templateOpen[0].length;\n const fallbackStart = source.indexOf(content, openingEnd);\n if (fallbackStart === -1) {\n return null;\n }\n\n return { start: fallbackStart, end: fallbackStart + content.length };\n}\n\nfunction previousNonSpaceChar(source: string, index: number): string {\n for (let cursor = index - 1; cursor >= 0; cursor--) {\n if (!/\\s/.test(source[cursor])) {\n return source[cursor];\n }\n }\n return \"\";\n}\n\nfunction findTagEnd(source: string, start: number): number {\n let quote: '\"' | \"'\" | null = null;\n\n for (let index = start; index < source.length; index++) {\n const char = source[index];\n if (quote) {\n // HTML attribute values have no backslash escapes, so a value such as\n // title=\"C:\\\" ends at its closing quote.\n if (char === quote) {\n quote = null;\n }\n continue;\n }\n\n // Only a quote that starts an attribute value (right after `=`) opens a\n // quoted region. Quotes inside dynamic argument names such as\n // `:['a\\'b']` are part of an expression, not an attribute value.\n if ((char === '\"' || char === \"'\") && previousNonSpaceChar(source, index) === \"=\") {\n quote = char;\n continue;\n }\n\n if (char === \">\") {\n return index;\n }\n }\n\n return -1;\n}\n\nfunction normalizeOpeningTag(tag: string): string {\n if (/^<\\s*(?:\\/|!|\\?)/.test(tag)) {\n return tag;\n }\n\n let output = \"\";\n let cursor = 0;\n let expectsUnquotedValue = false;\n\n // Copy the opening bracket, whitespace and element name unchanged.\n while (cursor < tag.length && !/\\s/.test(tag[cursor]) && tag[cursor] !== \">\") {\n output += tag[cursor++];\n }\n\n while (cursor < tag.length) {\n const char = tag[cursor];\n\n if (char === '\"' || char === \"'\") {\n const quote = char;\n const valueStart = cursor;\n cursor++;\n while (cursor < tag.length) {\n if (tag[cursor] === quote) {\n cursor++;\n break;\n }\n cursor++;\n }\n output += tag.slice(valueStart, cursor);\n expectsUnquotedValue = false;\n continue;\n }\n\n if (/\\s/.test(char) || char === \"/\" || char === \">\") {\n output += char;\n cursor++;\n continue;\n }\n\n if (char === \"=\") {\n output += char;\n cursor++;\n expectsUnquotedValue = true;\n continue;\n }\n\n const tokenStart = cursor;\n while (\n cursor < tag.length\n && !/\\s/.test(tag[cursor])\n && tag[cursor] !== \"=\"\n && tag[cursor] !== \"/\"\n && tag[cursor] !== \">\"\n ) {\n cursor++;\n }\n\n const token = tag.slice(tokenStart, cursor);\n output += !expectsUnquotedValue\n && token.startsWith(RX_DIRECTIVE_PREFIX)\n && token.length > RX_DIRECTIVE_PREFIX.length\n ? `${VUE_DIRECTIVE_PREFIX}${token.slice(RX_DIRECTIVE_PREFIX.length)}`\n : token;\n expectsUnquotedValue = false;\n }\n\n return output;\n}\n"],"mappings":";;AAEA,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;;;;;;AAO7B,SAAgB,8BAA8B,UAA0B;CACtE,IAAI,SAAS;CACb,IAAI,SAAS;CAEb,OAAO,SAAS,SAAS,QAAQ;EAC/B,MAAM,WAAW,SAAS,QAAQ,KAAK,MAAM;EAC7C,IAAI,aAAa,IAAI;GACnB,UAAU,SAAS,MAAM,MAAM;GAC/B;EACF;EAEA,UAAU,SAAS,MAAM,QAAQ,QAAQ;EAEzC,IAAI,SAAS,WAAW,QAAQ,QAAQ,GAAG;GACzC,MAAM,aAAa,SAAS,QAAQ,OAAO,WAAW,CAAC;GACvD,IAAI,eAAe,IAAI;IACrB,UAAU,SAAS,MAAM,QAAQ;IACjC;GACF;GACA,UAAU,SAAS,MAAM,UAAU,aAAa,CAAC;GACjD,SAAS,aAAa;GACtB;EACF;EAEA,MAAM,SAAS,WAAW,UAAU,WAAW,CAAC;EAChD,IAAI,WAAW,IAAI;GACjB,UAAU,SAAS,MAAM,QAAQ;GACjC;EACF;EAEA,UAAU,oBAAoB,SAAS,MAAM,UAAU,SAAS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UACV,CAAC,KAAK,KAAK,IAAI,OAAO,KACtB,IAAI,YAAY,OAChB,IAAI,YAAY,OAChB,IAAI,YAAY,KAEnB;EAGF,MAAM,QAAQ,IAAI,MAAM,YAAY,MAAM;EAC1C,UAAU,CAAC,wBACN,MAAM,WAAW,mBAAmB,KACpC,MAAM,SAAS,IACd,GAAG,uBAAuB,MAAM,MAAM,CAA0B,MAChE;EACN,uBAAuB;CACzB;CAEA,OAAO;AACT"}
@@ -17,6 +17,8 @@ export interface CompiledComponent {
17
17
  serverSource: string;
18
18
  clientSource: string;
19
19
  template: TemplateNode[];
20
+ templateRefs?: string[];
21
+ templateForRefs?: string[];
20
22
  handlers: string[];
21
23
  styles: ComponentStyle[];
22
24
  styleScopeId?: string;
@@ -116,6 +118,7 @@ export interface BuildOptions {
116
118
  changedPath?: string;
117
119
  traceBuild?: boolean;
118
120
  }
121
+ export declare const RESUMABLE_HANDLER_ALLOWED_GLOBALS: Set<string>;
119
122
  export declare function buildProject(appRoot: string, outDir?: string, options?: BuildOptions): Promise<BuildResult>;
120
123
  export declare function compileVueFile(file: string, options: {
121
124
  id: string;
@@ -130,5 +133,4 @@ export declare function compileVueSource(source: string, options: {
130
133
  }): CompiledComponent;
131
134
  export declare function createRouteManifest(root: string, files: string[], idByFile?: Map<string, string>, compiledByFile?: Map<string, CompiledComponent>): RouteManifestRecord[];
132
135
  export declare function resolveFileExtension(filePath: string): string;
133
- export declare function fileUrl(file: string): string;
134
- //# sourceMappingURL=index.d.ts.map
136
+ export declare function fileUrl(file: string): string;
@@ -1,9 +1,11 @@
1
+ import { __require } from "../_virtual/_rolldown/runtime.js";
1
2
  import { createResux } from "../core/resux.js";
3
+ import { cspDirectiveSources } from "../head/utils.js";
2
4
  import { ResuxModuleContainer } from "../core/module-container.js";
3
5
  import { buildLocalePath, normalizeI18nRuntimeConfig } from "../i18n/shared.js";
4
6
  import { withResuxKitContext } from "../kit/index.js";
7
+ import { isPathWithinBoundary } from "../security/path-boundary.js";
5
8
  import { getClientRuntimeSource } from "../runtime/index.js";
6
- import { createRequire } from "node:module";
7
9
  import { existsSync, mkdirSync, statSync, writeFileSync } from "node:fs";
8
10
  import { mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
9
11
  import path from "node:path";
@@ -15,7 +17,6 @@ import { compileStyle, parse as parse$1 } from "@vue/compiler-sfc";
15
17
  import vuePlugin from "@vitejs/plugin-vue";
16
18
  import { build } from "vite";
17
19
  // src/compiler/index.ts
18
- const require = createRequire(import.meta.url);
19
20
  var ResuxCompileError = class extends Error {
20
21
  location;
21
22
  constructor(message, location) {
@@ -38,6 +39,14 @@ const RESUMABLE_HANDLER_ALLOWED_GLOBALS = /* @__PURE__ */ new Set([
38
39
  "console",
39
40
  "undefined",
40
41
  "globalThis",
42
+ "window",
43
+ "document",
44
+ "navigator",
45
+ "localStorage",
46
+ "sessionStorage",
47
+ "location",
48
+ "history",
49
+ "alert",
41
50
  "performance",
42
51
  "fetch",
43
52
  "Headers",
@@ -702,7 +711,7 @@ async function buildClientAssets(root, outDir, components, plugins, middleware,
702
711
  logLevel: "warn",
703
712
  plugins: [vuePlugin(), ...contributions?.vitePlugins ?? []],
704
713
  resolve: { alias: {
705
- vue: require.resolve("vue"),
714
+ vue: __require.resolve("vue"),
706
715
  "@": normalizePath(root),
707
716
  "~": normalizePath(root)
708
717
  } },
@@ -788,6 +797,8 @@ function compileVueSource(source, options) {
788
797
  name: options.name,
789
798
  file: options.file,
790
799
  template: template.nodes,
800
+ templateRefs: template.templateRefs,
801
+ templateForRefs: template.templateForRefs,
791
802
  analysis,
792
803
  styles: compiledStyles.styles,
793
804
  styleScopeId: compiledStyles.styleScopeId,
@@ -800,6 +811,8 @@ function compileVueSource(source, options) {
800
811
  name: options.name,
801
812
  file: options.file,
802
813
  template: template.nodes,
814
+ templateRefs: template.templateRefs,
815
+ templateForRefs: template.templateForRefs,
803
816
  analysis,
804
817
  styles: compiledStyles.styles,
805
818
  styleScopeId: compiledStyles.styleScopeId,
@@ -814,6 +827,8 @@ function compileVueSource(source, options) {
814
827
  serverSource,
815
828
  clientSource,
816
829
  template: template.nodes,
830
+ templateRefs: template.templateRefs,
831
+ templateForRefs: template.templateForRefs,
817
832
  handlers: [...new Set(template.handlers.map((event) => event.handler))],
818
833
  styles: compiledStyles.styles,
819
834
  styleScopeId: compiledStyles.styleScopeId,
@@ -931,11 +946,21 @@ function readRuntimeI18nConfig(runtimeConfig) {
931
946
  const i18n = publicConfig.i18n;
932
947
  return normalizeI18nRuntimeConfig(i18n);
933
948
  }
949
+ function collectTemplateForRefs(nodes, insideFor = false, out = /* @__PURE__ */ new Set()) {
950
+ for (const node of nodes) {
951
+ if (!node || node.type !== "element") continue;
952
+ const nowInsideFor = insideFor || Boolean(node.for);
953
+ if (nowInsideFor && node.ref) out.add(node.ref);
954
+ if (Array.isArray(node.children)) collectTemplateForRefs(node.children, nowInsideFor, out);
955
+ }
956
+ return out;
957
+ }
934
958
  function compileTemplate(template, file, templateRefBindings = /* @__PURE__ */ new Set()) {
935
959
  const ast = parse(template, { comments: false });
936
960
  const state = {
937
961
  file,
938
962
  templateRefBindings,
963
+ templateRefs: /* @__PURE__ */ new Set(),
939
964
  bindingIndex: 0,
940
965
  inlineHandlerIndex: 0,
941
966
  handlers: [],
@@ -944,12 +969,15 @@ function compileTemplate(template, file, templateRefBindings = /* @__PURE__ */ n
944
969
  activeLocals: [],
945
970
  allLocals: /* @__PURE__ */ new Set()
946
971
  };
972
+ const nodes = compileTemplateChildren(ast.children, state);
947
973
  return {
948
- nodes: compileTemplateChildren(ast.children, state),
974
+ nodes,
949
975
  handlers: state.handlers,
950
976
  inlineHandlers: state.inlineHandlers,
951
977
  expressions: state.expressions,
952
- allLocals: Array.from(state.allLocals)
978
+ allLocals: Array.from(state.allLocals),
979
+ templateRefs: Array.from(state.templateRefs),
980
+ templateForRefs: Array.from(collectTemplateForRefs(nodes))
953
981
  };
954
982
  }
955
983
  function compileTemplateChildren(children, state) {
@@ -1066,6 +1094,13 @@ function compileTemplateNode(node, state, options = {}) {
1066
1094
  };
1067
1095
  for (const prop of node.props) {
1068
1096
  if (prop.type === NodeTypes.ATTRIBUTE) {
1097
+ if (prop.name === "ref" && prop.value?.content) {
1098
+ const refName = prop.value.content.trim();
1099
+ if (refName) {
1100
+ state.templateRefs.add(refName);
1101
+ element.ref = refName;
1102
+ }
1103
+ }
1069
1104
  attrs.push({
1070
1105
  kind: "static",
1071
1106
  name: prop.name,
@@ -1078,6 +1113,15 @@ function compileTemplateNode(node, state, options = {}) {
1078
1113
  const arg = expressionContent(prop.arg);
1079
1114
  const expression = expressionContent(prop.exp);
1080
1115
  if (!arg || !expression) throw new ResuxCompileError("Dynamic bindings need an argument and expression.", locationFromVueNode(state.file, prop));
1116
+ if (arg === "ref") {
1117
+ const trimmed = expression.trim();
1118
+ const quotedMatch = /^(['"`])([\s\S]*)\1$/.exec(trimmed);
1119
+ const staticRefName = quotedMatch ? quotedMatch[2].trim() : /^[A-Za-z_$][\w$]*$/.test(trimmed) ? trimmed : "";
1120
+ if (staticRefName) {
1121
+ state.templateRefs.add(staticRefName);
1122
+ element.ref = staticRefName;
1123
+ }
1124
+ }
1081
1125
  attrs.push({
1082
1126
  kind: "dynamic",
1083
1127
  name: arg,
@@ -1283,7 +1327,7 @@ function transformTemplateExpressionCode(expression, templateRefBindings, file,
1283
1327
  const identifiers = /* @__PURE__ */ new Set();
1284
1328
  const visit = (current) => {
1285
1329
  if (ts.isIdentifier(current)) {
1286
- if (shouldAutoUnwrapTemplateIdentifier(current)) {
1330
+ if (shouldAutoUnwrapTemplateIdentifier(current) && !isShadowedByFunctionParameter(current)) {
1287
1331
  if (templateRefBindings.has(current.text)) {
1288
1332
  const position = current.end - 1;
1289
1333
  if (position >= 0 && position <= expression.length) insertions.push(position);
@@ -1316,6 +1360,13 @@ function transformTemplateExpressionCode(expression, templateRefBindings, file,
1316
1360
  identifiers: [...identifiers]
1317
1361
  };
1318
1362
  }
1363
+ function isShadowedByFunctionParameter(node) {
1364
+ for (let current = node; current; current = current.parent) {
1365
+ if (!ts.isArrowFunction(current) && !ts.isFunctionExpression(current)) continue;
1366
+ for (const parameter of current.parameters) if (collectBindingNames(parameter.name).includes(node.text)) return true;
1367
+ }
1368
+ return false;
1369
+ }
1319
1370
  function shouldAutoUnwrapTemplateIdentifier(node) {
1320
1371
  const parent = node.parent;
1321
1372
  if (!parent) return true;
@@ -1827,7 +1878,7 @@ function validateTemplateHandlers(events, analysis, file, fullSource, templateLo
1827
1878
  if (!handlerNode) continue;
1828
1879
  const locals = analysis.inlineHandlerLocals.get(event.handler) ?? [];
1829
1880
  const unsupportedCapture = findUnsupportedCapture(handlerNode, event.handler, analysis, locals);
1830
- if (unsupportedCapture) throw new ResuxCompileError(`Handler "${event.handler}" captures "${unsupportedCapture}", which is not resumable in Resux.`, locationFromTsNode(file, analysis.sourceFile, handlerNode));
1881
+ if (unsupportedCapture) throw new ResuxCompileError(`Handler "${event.handler}" captures "${unsupportedCapture}", which is not resumable in Resux. If this is a client or browser API, access it via "globalThis.${unsupportedCapture}" or move client-only logic into onMounted() or useClientEnhancement(). See https://resux.dev/guide/resumability-handlers for allowed globals and resumability rules.`, locationFromTsNode(file, analysis.sourceFile, handlerNode));
1831
1882
  }
1832
1883
  }
1833
1884
  function findUnsupportedCapture(node, handlerName, analysis, templateLocals = []) {
@@ -1967,6 +2018,8 @@ function createComponentModuleSource(options) {
1967
2018
  `file: ${JSON.stringify(normalizePath(options.file))},`,
1968
2019
  `script: __rx_setup,`,
1969
2020
  `template: __template,`,
2021
+ `templateRefs: ${JSON.stringify(options.templateRefs ?? [])},`,
2022
+ `templateForRefs: ${JSON.stringify(options.templateForRefs ?? [])}`,
1970
2023
  `handlers: ${JSON.stringify([...options.analysis.handlerNames])},`,
1971
2024
  `styles: ${JSON.stringify(options.styles)},`,
1972
2025
  `styleScopeId: ${JSON.stringify(options.styleScopeId)},`,
@@ -2213,20 +2266,6 @@ function readSecurityContentSecurityPolicy(config, head) {
2213
2266
  }
2214
2267
  return "";
2215
2268
  }
2216
- function cspDirectiveSources(csp, names) {
2217
- if (!csp.trim()) return null;
2218
- const directives = /* @__PURE__ */ new Map();
2219
- for (const rawDirective of csp.split(";")) {
2220
- const tokens = rawDirective.trim().split(/\s+/).filter(Boolean);
2221
- if (!tokens.length) continue;
2222
- directives.set(tokens[0].toLowerCase(), tokens.slice(1));
2223
- }
2224
- for (const name of names) {
2225
- const sources = directives.get(name);
2226
- if (sources) return sources;
2227
- }
2228
- return null;
2229
- }
2230
2269
  function allowsInlineStyleForCsp(csp) {
2231
2270
  const sources = cspDirectiveSources(csp, [
2232
2271
  "style-src-elem",
@@ -2274,10 +2313,16 @@ function readInlinePublicCss(appRoot, href, maxBytes) {
2274
2313
  if (!pathname.toLowerCase().endsWith(".css")) return null;
2275
2314
  const publicRoot = path.resolve(appRoot, "public");
2276
2315
  const staticRoot = path.resolve(appRoot, "static");
2277
- const relativePath = pathname.replace(/^\/+/, "");
2278
- const candidates = [path.resolve(publicRoot, relativePath), path.resolve(staticRoot, relativePath)];
2279
- for (const candidate of candidates) {
2280
- if (!(candidate.startsWith(publicRoot + path.sep) ? publicRoot : candidate.startsWith(staticRoot + path.sep) ? staticRoot : null) || !existsSync(candidate)) continue;
2316
+ const relativePath = pathname.replace(/^[/\\]+/, "");
2317
+ const candidates = [{
2318
+ root: publicRoot,
2319
+ candidate: path.resolve(publicRoot, relativePath)
2320
+ }, {
2321
+ root: staticRoot,
2322
+ candidate: path.resolve(staticRoot, relativePath)
2323
+ }];
2324
+ for (const { root, candidate } of candidates) {
2325
+ if (!isPathWithinBoundary(root, candidate) || !existsSync(candidate)) continue;
2281
2326
  const css = ts.sys.readFile(candidate);
2282
2327
  if (typeof css !== "string" || Buffer.byteLength(css, "utf8") > maxBytes || hasRelativeCssReferences(css)) continue;
2283
2328
  return css;
@@ -2313,21 +2358,31 @@ function scanRuntimeConfigForSecrets(config, halalConfig) {
2313
2358
  /amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}/i,
2314
2359
  /https?:\/\/[^/]+:[^/]+@/
2315
2360
  ];
2316
- for (const [key, value] of Object.entries(publicConfig)) {
2317
- const upperKey = key.toUpperCase();
2318
- if (unsafeKeys.some((unsafe) => upperKey.includes(unsafe))) {
2319
- const msg = `[resux-safety] Unsafe key name "${key}" found in public runtimeConfig. Do not expose secrets to the client.`;
2320
- if (isStrict) throw new Error(msg);
2321
- else console.warn(`\x1b[33m${msg}\x1b[0m`);
2361
+ const report = (msg) => {
2362
+ if (isStrict) throw new Error(msg);
2363
+ console.warn(`\x1b[33m${msg}\x1b[0m`);
2364
+ };
2365
+ const seen = /* @__PURE__ */ new WeakSet();
2366
+ const scan = (value, pathLabel, keyName) => {
2367
+ if (keyName !== null) {
2368
+ const upperKey = keyName.toUpperCase();
2369
+ if (unsafeKeys.some((unsafe) => upperKey.includes(unsafe))) report(`[resux-safety] Unsafe key name "${pathLabel}" found in public runtimeConfig. Do not expose secrets to the client.`);
2322
2370
  }
2323
2371
  if (typeof value === "string") {
2324
- if (secretValuePatterns.some((pattern) => pattern.test(value))) {
2325
- const msg = `[resux-safety] Value of public runtimeConfig key "${key}" looks like a private credential or API secret. Do not expose secrets to the client.`;
2326
- if (isStrict) throw new Error(msg);
2327
- else console.warn(`\x1b[33m${msg}\x1b[0m`);
2372
+ if (secretValuePatterns.some((pattern) => pattern.test(value))) report(`[resux-safety] Value of public runtimeConfig key "${pathLabel}" looks like a private credential or API secret. Do not expose secrets to the client.`);
2373
+ return;
2374
+ }
2375
+ if (value && typeof value === "object") {
2376
+ if (seen.has(value)) return;
2377
+ seen.add(value);
2378
+ if (Array.isArray(value)) {
2379
+ value.forEach((item, index) => scan(item, `${pathLabel}[${index}]`, null));
2380
+ return;
2328
2381
  }
2382
+ for (const [childKey, childValue] of Object.entries(value)) scan(childValue, `${pathLabel}.${childKey}`, childKey);
2329
2383
  }
2330
- }
2384
+ };
2385
+ for (const [key, value] of Object.entries(publicConfig)) scan(value, key, key);
2331
2386
  }
2332
2387
  function createRuntimeConfig(config) {
2333
2388
  const runtimeConfig = config.runtimeConfig;
@@ -2345,7 +2400,10 @@ function createRuntimeConfig(config) {
2345
2400
  }
2346
2401
  };
2347
2402
  const halalConfig = config.halalAI;
2348
- scanRuntimeConfigForSecrets(appRuntimeConfig, halalConfig);
2403
+ scanRuntimeConfigForSecrets({
2404
+ ...appRuntimeConfig,
2405
+ public: publicConfig
2406
+ }, halalConfig);
2349
2407
  return appRuntimeConfig;
2350
2408
  }
2351
2409
  function createRouteRules(config) {
@@ -2633,13 +2691,13 @@ function createModuleOptions(module, options) {
2633
2691
  }
2634
2692
  function resolveBuiltinModule(specifier) {
2635
2693
  const normalized = specifier.startsWith("resux:") ? specifier.slice(6) : specifier;
2636
- return builtinModules$1[normalized] ?? null;
2694
+ return builtinModules[normalized] ?? null;
2637
2695
  }
2638
2696
  const i18nBuiltinModule = { async setup(options, resux) {
2639
2697
  const imported = await import("../i18n/index.js");
2640
2698
  await getModuleSetup(imported.default ?? imported)(options, resux);
2641
2699
  } };
2642
- const builtinModules$1 = {
2700
+ const builtinModules = {
2643
2701
  i18n: i18nBuiltinModule,
2644
2702
  "resuxjs/i18n": i18nBuiltinModule,
2645
2703
  "@resuxjs/i18n": i18nBuiltinModule,
@@ -2706,7 +2764,7 @@ function resolveModuleSpecifier(specifier, root) {
2706
2764
  const resolved = specifier.startsWith("file:") ? new URL(specifier) : path.resolve(root, specifier);
2707
2765
  return resolveLocalModuleFile(resolved instanceof URL ? fileURLToPath(resolved) : resolved);
2708
2766
  }
2709
- return require.resolve(specifier, { paths: [root] });
2767
+ return __require.resolve(specifier, { paths: [root] });
2710
2768
  }
2711
2769
  function resolveLocalModuleFile(file) {
2712
2770
  const found = [
@@ -3232,7 +3290,7 @@ function normalizeConfiguredPackageCssMap(config) {
3232
3290
  }
3233
3291
  function canResolvePackageSpecifier(appRoot, specifier) {
3234
3292
  try {
3235
- require.resolve(specifier, { paths: [appRoot] });
3293
+ __require.resolve(specifier, { paths: [appRoot] });
3236
3294
  return true;
3237
3295
  } catch {
3238
3296
  return false;
@@ -3363,7 +3421,7 @@ async function analyzePackageUsage(appRoot, sources, runtimeConfig) {
3363
3421
  for (const [name, usage] of map.entries()) {
3364
3422
  let missing = false;
3365
3423
  try {
3366
- require.resolve(name, { paths: [appRoot] });
3424
+ __require.resolve(name, { paths: [appRoot] });
3367
3425
  } catch {
3368
3426
  missing = true;
3369
3427
  usage.warnings.add(`Package "${name}" is imported but not installed.`);
@@ -3546,6 +3604,6 @@ function resolveFileExtension(filePath) {
3546
3604
  function fileUrl(file) {
3547
3605
  return pathToFileURL(file).href;
3548
3606
  }
3549
- export { ResuxCompileError, buildProject, compileVueFile, compileVueSource, createRouteManifest, fileUrl, resolveFileExtension };
3607
+ export { RESUMABLE_HANDLER_ALLOWED_GLOBALS, ResuxCompileError, buildProject, compileVueFile, compileVueSource, createRouteManifest, fileUrl, resolveFileExtension };
3550
3608
 
3551
3609
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { BuildOptions, BuildResult, ClientEnhancementManifestEntry, CompileErrorLocation, CompiledComponent, CompiledMiddleware, CompiledPlugin, CompiledServerMiddleware, ResuxCompileError, RouteManifestRecord, RouteRuleConfig, ServerHandlerRecord, VueIslandRecord, createRouteManifest, fileUrl, resolveFileExtension } from "./implementation.js";
1
+ import { BuildOptions, BuildResult, ClientEnhancementManifestEntry, CompileErrorLocation, CompiledComponent, CompiledMiddleware, CompiledPlugin, CompiledServerMiddleware, RESUMABLE_HANDLER_ALLOWED_GLOBALS, ResuxCompileError, RouteManifestRecord, RouteRuleConfig, ServerHandlerRecord, VueIslandRecord, createRouteManifest, fileUrl, resolveFileExtension } from "./implementation.js";
2
2
  import { normalizeResuxDirectiveSyntax, normalizeResuxSfcSource } from "./directives.js";
3
3
  export interface ResuxCompileVueSourceOptions {
4
4
  file: string;
@@ -14,5 +14,4 @@ export declare function compileVueFile(file: string, options: {
14
14
  dev?: boolean;
15
15
  }): Promise<CompiledComponent>;
16
16
  export declare function buildProject(appRoot: string, outDir?: string, options?: BuildOptions): Promise<BuildResult>;
17
- export { BuildOptions, BuildResult, ClientEnhancementManifestEntry, CompileErrorLocation, CompiledComponent, CompiledMiddleware, CompiledPlugin, CompiledServerMiddleware, ResuxCompileError, RouteManifestRecord, RouteRuleConfig, ServerHandlerRecord, VueIslandRecord, createRouteManifest, fileUrl, normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, resolveFileExtension };
18
- //# sourceMappingURL=adapter.d.ts.map
17
+ export { BuildOptions, BuildResult, ClientEnhancementManifestEntry, CompileErrorLocation, CompiledComponent, CompiledMiddleware, CompiledPlugin, CompiledServerMiddleware, RESUMABLE_HANDLER_ALLOWED_GLOBALS, ResuxCompileError, RouteManifestRecord, RouteRuleConfig, ServerHandlerRecord, VueIslandRecord, createRouteManifest, fileUrl, normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, resolveFileExtension };
@@ -1,4 +1,4 @@
1
- import { ResuxCompileError, buildProject as buildProject$1, compileVueSource as compileVueSource$1, createRouteManifest, fileUrl, resolveFileExtension } from "./implementation.js";
1
+ import { RESUMABLE_HANDLER_ALLOWED_GLOBALS, ResuxCompileError, buildProject as buildProject$1, compileVueSource as compileVueSource$1, createRouteManifest, fileUrl, resolveFileExtension } from "./implementation.js";
2
2
  import { normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, rethrowWithResuxDirectiveBrand } from "./directives.js";
3
3
  import { emitResuxDevWarnings } from "./dev-warnings.js";
4
4
  import { syncBuiltinESMExports } from "node:module";
@@ -75,6 +75,6 @@ async function withResuxDirectiveFileReads(task, emittedDevWarnings) {
75
75
  function pascalCase(value) {
76
76
  return value.replace(/\[[^\]]+\]/g, (match) => match.slice(1, -1)).split(/[^A-Za-z0-9]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
77
77
  }
78
- export { ResuxCompileError, buildProject, compileVueFile, compileVueSource, createRouteManifest, fileUrl, normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, resolveFileExtension };
78
+ export { RESUMABLE_HANDLER_ALLOWED_GLOBALS, ResuxCompileError, buildProject, compileVueFile, compileVueSource, createRouteManifest, fileUrl, normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, resolveFileExtension };
79
79
 
80
80
  //# sourceMappingURL=adapter.js.map