resuxjs 0.4.0-beta.7 → 0.4.0-beta.8

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 (180) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +4 -0
  2. package/dist/build/index.d.ts +1 -2
  3. package/dist/cli.d.ts +3 -3
  4. package/dist/cli.js +125 -31
  5. package/dist/cli.js.map +1 -1
  6. package/dist/compiler/adapter.d.ts +2 -3
  7. package/dist/compiler/adapter.js +2 -2
  8. package/dist/compiler/dev-warnings.d.ts +1 -2
  9. package/dist/compiler/directives.d.ts +1 -2
  10. package/dist/compiler/implementation.d.ts +4 -2
  11. package/dist/compiler/implementation.js +68 -30
  12. package/dist/compiler/index.d.ts +2 -3
  13. package/dist/compiler/index.js +2 -2
  14. package/dist/compiler/index.js.map +1 -1
  15. package/dist/core/config.d.ts +1 -2
  16. package/dist/core/hooks.d.ts +10 -2
  17. package/dist/core/hooks.js.map +1 -1
  18. package/dist/core/index.d.ts +2 -2
  19. package/dist/core/module-container.d.ts +1 -2
  20. package/dist/core/module-container.js +2 -1
  21. package/dist/core/module-container.js.map +1 -1
  22. package/dist/core/resux.d.ts +1 -2
  23. package/dist/create.d.ts +1 -2
  24. package/dist/create.js +104 -33
  25. package/dist/create.js.map +1 -1
  26. package/dist/deploy/cloudflare.d.ts +1 -2
  27. package/dist/deploy/common.d.ts +1 -2
  28. package/dist/deploy/framework-runtime.d.ts +1 -2
  29. package/dist/deploy/index.d.ts +1 -2
  30. package/dist/deploy/netlify.d.ts +1 -2
  31. package/dist/deploy/node.d.ts +1 -2
  32. package/dist/deploy/production-report.d.ts +1 -2
  33. package/dist/deploy/runtime-dependencies.d.ts +1 -2
  34. package/dist/deploy/static.d.ts +1 -2
  35. package/dist/deploy/types.d.ts +1 -2
  36. package/dist/deploy/vercel.d.ts +1 -2
  37. package/dist/deploy/vercel.js +3 -3
  38. package/dist/deploy/vercel.js.map +1 -1
  39. package/dist/fonts/index.d.ts +1 -2
  40. package/dist/fonts/index.js.map +1 -1
  41. package/dist/globals.d.ts +1 -2
  42. package/dist/halal-core/ai/classifyProject.d.ts +1 -2
  43. package/dist/halal-core/ai/classifyRuntimeContent.d.ts +1 -2
  44. package/dist/halal-core/ai/createProjectSummary.d.ts +1 -2
  45. package/dist/halal-core/ai/halalClassifierPrompt.d.ts +1 -2
  46. package/dist/halal-core/ai/redactSensitiveData.d.ts +1 -2
  47. package/dist/halal-core/ai/validateAiResponse.d.ts +1 -2
  48. package/dist/halal-core/cli/check.d.ts +1 -2
  49. package/dist/halal-core/cli/explain.d.ts +1 -2
  50. package/dist/halal-core/cli/report.d.ts +1 -2
  51. package/dist/halal-core/cli/submitReview.d.ts +1 -2
  52. package/dist/halal-core/cli/verifyReview.d.ts +1 -2
  53. package/dist/halal-core/config.d.ts +2 -2
  54. package/dist/halal-core/config.js.map +1 -1
  55. package/dist/halal-core/crypto/integrity.d.ts +1 -2
  56. package/dist/halal-core/crypto/integrity.js +1 -1
  57. package/dist/halal-core/crypto/integrity.js.map +1 -1
  58. package/dist/halal-core/enforce.d.ts +4 -3
  59. package/dist/halal-core/enforce.js +31 -4
  60. package/dist/halal-core/enforce.js.map +1 -1
  61. package/dist/halal-core/lifecycle.d.ts +1 -2
  62. package/dist/halal-core/policy.d.ts +1 -2
  63. package/dist/halal-core/report/formatBrowserOverlay.d.ts +1 -2
  64. package/dist/halal-core/report/formatTerminalReport.d.ts +1 -2
  65. package/dist/halal-core/report/generateHalalReport.d.ts +1 -2
  66. package/dist/halal-core/report/signReport.d.ts +1 -2
  67. package/dist/halal-core/report/verifyReport.d.ts +1 -2
  68. package/dist/halal-core/review/createReviewRequest.d.ts +1 -2
  69. package/dist/halal-core/review/reviewPolicy.d.ts +1 -2
  70. package/dist/halal-core/review/signedReviewFile.d.ts +1 -2
  71. package/dist/halal-core/review/verifyReviewApproval.d.ts +1 -2
  72. package/dist/halal-core/rules/adultContentRules.d.ts +1 -2
  73. package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +1 -2
  74. package/dist/halal-core/rules/childSafetyRules.d.ts +1 -2
  75. package/dist/halal-core/rules/coreCategories.d.ts +1 -2
  76. package/dist/halal-core/rules/cyberAbuseRules.d.ts +1 -2
  77. package/dist/halal-core/rules/defaultBlockedRules.d.ts +1 -2
  78. package/dist/halal-core/rules/dependencyRules.d.ts +1 -2
  79. package/dist/halal-core/rules/endpointRules.d.ts +1 -2
  80. package/dist/halal-core/rules/environmentalHarmRules.d.ts +1 -2
  81. package/dist/halal-core/rules/financeRibaRules.d.ts +1 -2
  82. package/dist/halal-core/rules/gamblingRules.d.ts +1 -2
  83. package/dist/halal-core/rules/generalHarmRules.d.ts +1 -2
  84. package/dist/halal-core/rules/healthHarmRules.d.ts +1 -2
  85. package/dist/halal-core/rules/keywordRules.d.ts +1 -2
  86. package/dist/halal-core/rules/privacyAbuseRules.d.ts +1 -2
  87. package/dist/halal-core/rules/scamFraudRules.d.ts +1 -2
  88. package/dist/halal-core/rules/selfHarmRules.d.ts +1 -2
  89. package/dist/halal-core/rules/violenceExtremismRules.d.ts +1 -2
  90. package/dist/halal-core/runtime/guard.d.ts +1 -2
  91. package/dist/halal-core/runtime/guard.js.map +1 -1
  92. package/dist/halal-core/runtime/reviewedMemory.d.ts +1 -2
  93. package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +1 -2
  94. package/dist/halal-core/runtime/types.d.ts +1 -2
  95. package/dist/halal-core/scanner/scanApiRoutes.d.ts +1 -2
  96. package/dist/halal-core/scanner/scanComponents.d.ts +1 -2
  97. package/dist/halal-core/scanner/scanContent.d.ts +1 -2
  98. package/dist/halal-core/scanner/scanDependencies.d.ts +1 -2
  99. package/dist/halal-core/scanner/scanDomains.d.ts +1 -2
  100. package/dist/halal-core/scanner/scanEnvNames.d.ts +1 -2
  101. package/dist/halal-core/scanner/scanMetadata.d.ts +1 -2
  102. package/dist/halal-core/scanner/scanPages.d.ts +1 -2
  103. package/dist/halal-core/scanner/scanProject.d.ts +1 -2
  104. package/dist/halal-core/scanner/scanRoutes.d.ts +1 -2
  105. package/dist/halal-core/scanner/scanTranslations.d.ts +1 -2
  106. package/dist/halal-core/status.d.ts +1 -2
  107. package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +1 -2
  108. package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +1 -2
  109. package/dist/halal-core/tamper/verifyReportSignature.d.ts +1 -2
  110. package/dist/head/utils.d.ts +15 -0
  111. package/dist/head/utils.js +52 -0
  112. package/dist/head/utils.js.map +1 -0
  113. package/dist/i18n/index.d.ts +1 -2
  114. package/dist/i18n/index.js.map +1 -1
  115. package/dist/i18n/shared.d.ts +1 -2
  116. package/dist/icons/api-fetcher.d.ts +1 -2
  117. package/dist/icons/cache.d.ts +1 -2
  118. package/dist/icons/cache.js.map +1 -1
  119. package/dist/icons/component.d.ts +9 -10
  120. package/dist/icons/constants.d.ts +1 -2
  121. package/dist/icons/css-mode.d.ts +1 -2
  122. package/dist/icons/index.d.ts +1 -2
  123. package/dist/icons/index.js.map +1 -1
  124. package/dist/icons/local-svg.d.ts +1 -2
  125. package/dist/icons/normalize.d.ts +1 -2
  126. package/dist/icons/offline-loader.d.ts +1 -2
  127. package/dist/icons/parser.d.ts +1 -2
  128. package/dist/icons/registry.d.ts +1 -2
  129. package/dist/icons/resolver.d.ts +1 -2
  130. package/dist/icons/svg-mode.d.ts +1 -2
  131. package/dist/icons/transform.d.ts +1 -2
  132. package/dist/icons/types.d.ts +1 -2
  133. package/dist/index.d.ts +2 -2
  134. package/dist/index.js +2 -2
  135. package/dist/kit/index.d.ts +1 -2
  136. package/dist/nitro-server/index.d.ts +1 -2
  137. package/dist/node.d.ts +1 -2
  138. package/dist/reactivity/computed.d.ts +1 -2
  139. package/dist/reactivity/computed.js.map +1 -1
  140. package/dist/reactivity/effect.d.ts +3 -3
  141. package/dist/reactivity/effect.js +8 -3
  142. package/dist/reactivity/effect.js.map +1 -1
  143. package/dist/reactivity/reactive.d.ts +1 -2
  144. package/dist/reactivity/reactive.js +221 -11
  145. package/dist/reactivity/reactive.js.map +1 -1
  146. package/dist/reactivity/ref.d.ts +1 -2
  147. package/dist/reactivity/ref.js.map +1 -1
  148. package/dist/reactivity/scheduler.d.ts +1 -2
  149. package/dist/reactivity/scheduler.js +2 -0
  150. package/dist/reactivity/scheduler.js.map +1 -1
  151. package/dist/reactivity/types.d.ts +1 -2
  152. package/dist/reactivity/utils.d.ts +1 -2
  153. package/dist/reactivity/watch.d.ts +1 -2
  154. package/dist/reactivity/watch.js.map +1 -1
  155. package/dist/runtime/core.d.ts +1 -2
  156. package/dist/runtime/core.js.map +1 -1
  157. package/dist/runtime/index.d.ts +19 -2
  158. package/dist/runtime/index.js +480 -79
  159. package/dist/runtime/index.js.map +1 -1
  160. package/dist/runtime/resume.d.ts +1 -2
  161. package/dist/runtime/resume.js.map +1 -1
  162. package/dist/runtime/router.d.ts +1 -2
  163. package/dist/runtime/router.js.map +1 -1
  164. package/dist/runtime/streaming.d.ts +1 -2
  165. package/dist/runtime/streaming.js.map +1 -1
  166. package/dist/runtime/view-transitions/detect.d.ts +1 -2
  167. package/dist/runtime/view-transitions/transition.d.ts +1 -2
  168. package/dist/runtime/view-transitions/types.d.ts +1 -2
  169. package/dist/security/media-fetch.d.ts +1 -2
  170. package/dist/security/media-fetch.js.map +1 -1
  171. package/dist/security/path-boundary.d.ts +1 -2
  172. package/dist/security/path-boundary.js +10 -4
  173. package/dist/security/path-boundary.js.map +1 -1
  174. package/dist/ui/index.d.ts +47 -48
  175. package/dist/ui/verification-code.d.ts +3 -4
  176. package/dist/ui/verification-code.js.map +1 -1
  177. package/dist/vite-builder/index.d.ts +1 -2
  178. package/package.json +2 -2
  179. package/templates/default/.env.example +3 -0
  180. 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;
@@ -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,
@@ -1827,7 +1871,7 @@ function validateTemplateHandlers(events, analysis, file, fullSource, templateLo
1827
1871
  if (!handlerNode) continue;
1828
1872
  const locals = analysis.inlineHandlerLocals.get(event.handler) ?? [];
1829
1873
  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));
1874
+ 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
1875
  }
1832
1876
  }
1833
1877
  function findUnsupportedCapture(node, handlerName, analysis, templateLocals = []) {
@@ -1967,6 +2011,8 @@ function createComponentModuleSource(options) {
1967
2011
  `file: ${JSON.stringify(normalizePath(options.file))},`,
1968
2012
  `script: __rx_setup,`,
1969
2013
  `template: __template,`,
2014
+ `templateRefs: ${JSON.stringify(options.templateRefs ?? [])},`,
2015
+ `templateForRefs: ${JSON.stringify(options.templateForRefs ?? [])}`,
1970
2016
  `handlers: ${JSON.stringify([...options.analysis.handlerNames])},`,
1971
2017
  `styles: ${JSON.stringify(options.styles)},`,
1972
2018
  `styleScopeId: ${JSON.stringify(options.styleScopeId)},`,
@@ -2213,20 +2259,6 @@ function readSecurityContentSecurityPolicy(config, head) {
2213
2259
  }
2214
2260
  return "";
2215
2261
  }
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
2262
  function allowsInlineStyleForCsp(csp) {
2231
2263
  const sources = cspDirectiveSources(csp, [
2232
2264
  "style-src-elem",
@@ -2274,10 +2306,16 @@ function readInlinePublicCss(appRoot, href, maxBytes) {
2274
2306
  if (!pathname.toLowerCase().endsWith(".css")) return null;
2275
2307
  const publicRoot = path.resolve(appRoot, "public");
2276
2308
  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;
2309
+ const relativePath = pathname.replace(/^[/\\]+/, "");
2310
+ const candidates = [{
2311
+ root: publicRoot,
2312
+ candidate: path.resolve(publicRoot, relativePath)
2313
+ }, {
2314
+ root: staticRoot,
2315
+ candidate: path.resolve(staticRoot, relativePath)
2316
+ }];
2317
+ for (const { root, candidate } of candidates) {
2318
+ if (!isPathWithinBoundary(root, candidate) || !existsSync(candidate)) continue;
2281
2319
  const css = ts.sys.readFile(candidate);
2282
2320
  if (typeof css !== "string" || Buffer.byteLength(css, "utf8") > maxBytes || hasRelativeCssReferences(css)) continue;
2283
2321
  return css;
@@ -2633,13 +2671,13 @@ function createModuleOptions(module, options) {
2633
2671
  }
2634
2672
  function resolveBuiltinModule(specifier) {
2635
2673
  const normalized = specifier.startsWith("resux:") ? specifier.slice(6) : specifier;
2636
- return builtinModules$1[normalized] ?? null;
2674
+ return builtinModules[normalized] ?? null;
2637
2675
  }
2638
2676
  const i18nBuiltinModule = { async setup(options, resux) {
2639
2677
  const imported = await import("../i18n/index.js");
2640
2678
  await getModuleSetup(imported.default ?? imported)(options, resux);
2641
2679
  } };
2642
- const builtinModules$1 = {
2680
+ const builtinModules = {
2643
2681
  i18n: i18nBuiltinModule,
2644
2682
  "resuxjs/i18n": i18nBuiltinModule,
2645
2683
  "@resuxjs/i18n": i18nBuiltinModule,
@@ -2706,7 +2744,7 @@ function resolveModuleSpecifier(specifier, root) {
2706
2744
  const resolved = specifier.startsWith("file:") ? new URL(specifier) : path.resolve(root, specifier);
2707
2745
  return resolveLocalModuleFile(resolved instanceof URL ? fileURLToPath(resolved) : resolved);
2708
2746
  }
2709
- return require.resolve(specifier, { paths: [root] });
2747
+ return __require.resolve(specifier, { paths: [root] });
2710
2748
  }
2711
2749
  function resolveLocalModuleFile(file) {
2712
2750
  const found = [
@@ -3232,7 +3270,7 @@ function normalizeConfiguredPackageCssMap(config) {
3232
3270
  }
3233
3271
  function canResolvePackageSpecifier(appRoot, specifier) {
3234
3272
  try {
3235
- require.resolve(specifier, { paths: [appRoot] });
3273
+ __require.resolve(specifier, { paths: [appRoot] });
3236
3274
  return true;
3237
3275
  } catch {
3238
3276
  return false;
@@ -3363,7 +3401,7 @@ async function analyzePackageUsage(appRoot, sources, runtimeConfig) {
3363
3401
  for (const [name, usage] of map.entries()) {
3364
3402
  let missing = false;
3365
3403
  try {
3366
- require.resolve(name, { paths: [appRoot] });
3404
+ __require.resolve(name, { paths: [appRoot] });
3367
3405
  } catch {
3368
3406
  missing = true;
3369
3407
  usage.warnings.add(`Package "${name}" is imported but not installed.`);
@@ -3546,6 +3584,6 @@ function resolveFileExtension(filePath) {
3546
3584
  function fileUrl(file) {
3547
3585
  return pathToFileURL(file).href;
3548
3586
  }
3549
- export { ResuxCompileError, buildProject, compileVueFile, compileVueSource, createRouteManifest, fileUrl, resolveFileExtension };
3587
+ export { RESUMABLE_HANDLER_ALLOWED_GLOBALS, ResuxCompileError, buildProject, compileVueFile, compileVueSource, createRouteManifest, fileUrl, resolveFileExtension };
3550
3588
 
3551
3589
  //# 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