vinext 0.0.53 → 0.0.54

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 (188) hide show
  1. package/dist/build/inline-css.d.ts +7 -0
  2. package/dist/build/inline-css.js +50 -0
  3. package/dist/build/inline-css.js.map +1 -0
  4. package/dist/build/prerender.js +2 -1
  5. package/dist/build/prerender.js.map +1 -1
  6. package/dist/check.js +4 -0
  7. package/dist/check.js.map +1 -1
  8. package/dist/client/navigation-runtime.d.ts +2 -1
  9. package/dist/client/navigation-runtime.js.map +1 -1
  10. package/dist/client/window-next.d.ts +7 -0
  11. package/dist/client/window-next.js.map +1 -1
  12. package/dist/config/next-config.d.ts +83 -1
  13. package/dist/config/next-config.js +131 -2
  14. package/dist/config/next-config.js.map +1 -1
  15. package/dist/deploy.js +13 -0
  16. package/dist/deploy.js.map +1 -1
  17. package/dist/entries/app-browser-entry.d.ts +11 -1
  18. package/dist/entries/app-browser-entry.js +16 -6
  19. package/dist/entries/app-browser-entry.js.map +1 -1
  20. package/dist/entries/app-rsc-entry.d.ts +8 -1
  21. package/dist/entries/app-rsc-entry.js +18 -5
  22. package/dist/entries/app-rsc-entry.js.map +1 -1
  23. package/dist/entries/app-rsc-manifest.d.ts +21 -1
  24. package/dist/entries/app-rsc-manifest.js +6 -4
  25. package/dist/entries/app-rsc-manifest.js.map +1 -1
  26. package/dist/entries/pages-client-entry.d.ts +4 -1
  27. package/dist/entries/pages-client-entry.js +18 -2
  28. package/dist/entries/pages-client-entry.js.map +1 -1
  29. package/dist/entries/pages-server-entry.js +82 -4
  30. package/dist/entries/pages-server-entry.js.map +1 -1
  31. package/dist/entries/runtime-entry-module.d.ts +1 -10
  32. package/dist/entries/runtime-entry-module.js +2 -12
  33. package/dist/entries/runtime-entry-module.js.map +1 -1
  34. package/dist/index.js +63 -5
  35. package/dist/index.js.map +1 -1
  36. package/dist/plugins/remove-console.d.ts +16 -0
  37. package/dist/plugins/remove-console.js +176 -0
  38. package/dist/plugins/remove-console.js.map +1 -0
  39. package/dist/routing/app-route-graph.d.ts +24 -1
  40. package/dist/routing/app-route-graph.js +52 -4
  41. package/dist/routing/app-route-graph.js.map +1 -1
  42. package/dist/routing/app-router.d.ts +2 -2
  43. package/dist/routing/app-router.js +2 -2
  44. package/dist/routing/app-router.js.map +1 -1
  45. package/dist/routing/file-matcher.d.ts +21 -1
  46. package/dist/routing/file-matcher.js +39 -1
  47. package/dist/routing/file-matcher.js.map +1 -1
  48. package/dist/routing/pages-router.d.ts +1 -1
  49. package/dist/routing/pages-router.js +10 -3
  50. package/dist/routing/pages-router.js.map +1 -1
  51. package/dist/server/api-handler.js +1 -1
  52. package/dist/server/app-browser-entry.js +25 -16
  53. package/dist/server/app-browser-entry.js.map +1 -1
  54. package/dist/server/app-browser-navigation-controller.d.ts +2 -0
  55. package/dist/server/app-browser-navigation-controller.js +4 -0
  56. package/dist/server/app-browser-navigation-controller.js.map +1 -1
  57. package/dist/server/app-elements-wire.d.ts +13 -4
  58. package/dist/server/app-elements-wire.js +10 -1
  59. package/dist/server/app-elements-wire.js.map +1 -1
  60. package/dist/server/app-elements.d.ts +2 -2
  61. package/dist/server/app-elements.js +2 -2
  62. package/dist/server/app-elements.js.map +1 -1
  63. package/dist/server/app-fallback-renderer.d.ts +15 -5
  64. package/dist/server/app-fallback-renderer.js +10 -4
  65. package/dist/server/app-fallback-renderer.js.map +1 -1
  66. package/dist/server/app-inline-css-client.d.ts +7 -0
  67. package/dist/server/app-inline-css-client.js +37 -0
  68. package/dist/server/app-inline-css-client.js.map +1 -0
  69. package/dist/server/app-page-boundary.d.ts +21 -1
  70. package/dist/server/app-page-boundary.js +28 -3
  71. package/dist/server/app-page-boundary.js.map +1 -1
  72. package/dist/server/app-page-cache.d.ts +7 -3
  73. package/dist/server/app-page-cache.js +7 -7
  74. package/dist/server/app-page-cache.js.map +1 -1
  75. package/dist/server/app-page-dispatch.d.ts +10 -1
  76. package/dist/server/app-page-dispatch.js +126 -79
  77. package/dist/server/app-page-dispatch.js.map +1 -1
  78. package/dist/server/app-page-element-builder.js +12 -28
  79. package/dist/server/app-page-element-builder.js.map +1 -1
  80. package/dist/server/app-page-render-identity.d.ts +22 -0
  81. package/dist/server/app-page-render-identity.js +42 -0
  82. package/dist/server/app-page-render-identity.js.map +1 -0
  83. package/dist/server/app-page-render.d.ts +8 -1
  84. package/dist/server/app-page-render.js +4 -1
  85. package/dist/server/app-page-render.js.map +1 -1
  86. package/dist/server/app-page-request.d.ts +6 -3
  87. package/dist/server/app-page-request.js +5 -2
  88. package/dist/server/app-page-request.js.map +1 -1
  89. package/dist/server/app-page-response.js +2 -2
  90. package/dist/server/app-page-response.js.map +1 -1
  91. package/dist/server/app-page-route-wiring.d.ts +15 -0
  92. package/dist/server/app-page-route-wiring.js +7 -5
  93. package/dist/server/app-page-route-wiring.js.map +1 -1
  94. package/dist/server/app-page-stream.d.ts +11 -0
  95. package/dist/server/app-page-stream.js +1 -0
  96. package/dist/server/app-page-stream.js.map +1 -1
  97. package/dist/server/app-route-handler-response.js +37 -5
  98. package/dist/server/app-route-handler-response.js.map +1 -1
  99. package/dist/server/app-rsc-handler.d.ts +14 -3
  100. package/dist/server/app-rsc-handler.js +45 -5
  101. package/dist/server/app-rsc-handler.js.map +1 -1
  102. package/dist/server/app-rsc-request-normalization.d.ts +2 -1
  103. package/dist/server/app-rsc-request-normalization.js +3 -2
  104. package/dist/server/app-rsc-request-normalization.js.map +1 -1
  105. package/dist/server/app-server-action-execution.d.ts +21 -3
  106. package/dist/server/app-server-action-execution.js +42 -7
  107. package/dist/server/app-server-action-execution.js.map +1 -1
  108. package/dist/server/app-ssr-entry.d.ts +6 -0
  109. package/dist/server/app-ssr-entry.js +22 -7
  110. package/dist/server/app-ssr-entry.js.map +1 -1
  111. package/dist/server/app-ssr-error-meta.js +3 -3
  112. package/dist/server/app-ssr-error-meta.js.map +1 -1
  113. package/dist/server/app-ssr-stream.d.ts +2 -1
  114. package/dist/server/app-ssr-stream.js +176 -31
  115. package/dist/server/app-ssr-stream.js.map +1 -1
  116. package/dist/server/client-trace-metadata.d.ts +31 -0
  117. package/dist/server/client-trace-metadata.js +83 -0
  118. package/dist/server/client-trace-metadata.js.map +1 -0
  119. package/dist/server/cookie-utils.d.ts +13 -0
  120. package/dist/server/cookie-utils.js +20 -0
  121. package/dist/server/cookie-utils.js.map +1 -0
  122. package/dist/server/dev-server.d.ts +8 -1
  123. package/dist/server/dev-server.js +34 -5
  124. package/dist/server/dev-server.js.map +1 -1
  125. package/dist/server/html.d.ts +2 -1
  126. package/dist/server/html.js +6 -1
  127. package/dist/server/html.js.map +1 -1
  128. package/dist/server/isr-cache.d.ts +7 -5
  129. package/dist/server/isr-cache.js +17 -6
  130. package/dist/server/isr-cache.js.map +1 -1
  131. package/dist/server/middleware-runtime.js +1 -2
  132. package/dist/server/middleware-runtime.js.map +1 -1
  133. package/dist/server/pages-document-initial-props.d.ts +7 -0
  134. package/dist/server/pages-document-initial-props.js +14 -0
  135. package/dist/server/pages-document-initial-props.js.map +1 -0
  136. package/dist/server/pages-page-data.js +3 -0
  137. package/dist/server/pages-page-data.js.map +1 -1
  138. package/dist/server/pages-page-method.d.ts +48 -0
  139. package/dist/server/pages-page-method.js +19 -0
  140. package/dist/server/pages-page-method.js.map +1 -0
  141. package/dist/server/pages-page-response.d.ts +6 -0
  142. package/dist/server/pages-page-response.js +10 -3
  143. package/dist/server/pages-page-response.js.map +1 -1
  144. package/dist/server/pages-serializable-props.d.ts +25 -0
  145. package/dist/server/pages-serializable-props.js +69 -0
  146. package/dist/server/pages-serializable-props.js.map +1 -0
  147. package/dist/server/prod-server.js +3 -0
  148. package/dist/server/prod-server.js.map +1 -1
  149. package/dist/server/server-action-not-found.js +3 -2
  150. package/dist/server/server-action-not-found.js.map +1 -1
  151. package/dist/server/static-file-cache.js +2 -1
  152. package/dist/server/static-file-cache.js.map +1 -1
  153. package/dist/shims/app-router-scroll-state.d.ts +4 -2
  154. package/dist/shims/app-router-scroll-state.js +16 -3
  155. package/dist/shims/app-router-scroll-state.js.map +1 -1
  156. package/dist/shims/app-router-scroll.d.ts +16 -2
  157. package/dist/shims/app-router-scroll.js +18 -3
  158. package/dist/shims/app-router-scroll.js.map +1 -1
  159. package/dist/shims/cache.d.ts +6 -0
  160. package/dist/shims/cache.js +7 -0
  161. package/dist/shims/cache.js.map +1 -1
  162. package/dist/shims/error.js +3 -0
  163. package/dist/shims/error.js.map +1 -1
  164. package/dist/shims/headers.d.ts +7 -0
  165. package/dist/shims/headers.js +9 -1
  166. package/dist/shims/headers.js.map +1 -1
  167. package/dist/shims/internal/app-route-detection.d.ts +37 -0
  168. package/dist/shims/internal/app-route-detection.js +69 -0
  169. package/dist/shims/internal/app-route-detection.js.map +1 -0
  170. package/dist/shims/link.d.ts +18 -2
  171. package/dist/shims/link.js +70 -6
  172. package/dist/shims/link.js.map +1 -1
  173. package/dist/shims/metadata.d.ts +7 -6
  174. package/dist/shims/metadata.js +9 -5
  175. package/dist/shims/metadata.js.map +1 -1
  176. package/dist/shims/navigation.d.ts +1 -2
  177. package/dist/shims/navigation.js +63 -12
  178. package/dist/shims/navigation.js.map +1 -1
  179. package/dist/shims/router.d.ts +5 -0
  180. package/dist/shims/router.js +14 -4
  181. package/dist/shims/router.js.map +1 -1
  182. package/dist/shims/script.d.ts +11 -1
  183. package/dist/shims/script.js +75 -6
  184. package/dist/shims/script.js.map +1 -1
  185. package/dist/utils/path.d.ts +13 -0
  186. package/dist/utils/path.js +16 -0
  187. package/dist/utils/path.js.map +1 -0
  188. package/package.json +1 -1
@@ -33,6 +33,46 @@ function resolveScriptNonce(explicitNonce, contextualNonce) {
33
33
  if (typeof window === "undefined") return;
34
34
  return getClientAutoNonce();
35
35
  }
36
+ /**
37
+ * Insert `<link rel="stylesheet">` tags into `document.head` for each entry
38
+ * in `stylesheets`. Used by the imperative client-side load path
39
+ * (`handleClientScriptLoad`) when `ReactDOM.preinit` is not available
40
+ * (e.g. pre-Float React or hosts that strip it). Mirrors Next.js's
41
+ * `insertStylesheets` Pages-Router fallback at
42
+ * `.nextjs-ref/packages/next/src/client/script.tsx:48-59`.
43
+ *
44
+ * The `ReactDOM.preinit` path is preferred where available — it dedupes
45
+ * across mounts and respects React Float's hoisting order. This DOM
46
+ * fallback is best-effort: no dedupe, no ordering guarantee.
47
+ */
48
+ function insertClientStylesheets(stylesheets) {
49
+ if (!stylesheets || stylesheets.length === 0) return;
50
+ if (typeof document === "undefined") return;
51
+ if (typeof ReactDOM.preinit === "function") {
52
+ for (const href of stylesheets) ReactDOM.preinit(href, { as: "style" });
53
+ return;
54
+ }
55
+ const head = document.head;
56
+ if (!head) return;
57
+ for (const href of stylesheets) {
58
+ const link = document.createElement("link");
59
+ link.rel = "stylesheet";
60
+ link.type = "text/css";
61
+ link.href = href;
62
+ head.appendChild(link);
63
+ }
64
+ }
65
+ /**
66
+ * Emit `<link rel="stylesheet">` tags during SSR for each entry in
67
+ * `stylesheets` via `ReactDOM.preinit`. React Float hoists these into
68
+ * `<head>` in the streamed HTML. Mirrors the App-Router branch of
69
+ * Next.js's Script component at `.nextjs-ref/packages/next/src/client/script.tsx:309-313`.
70
+ */
71
+ function preinitStylesheetsForSSR(stylesheets) {
72
+ if (!stylesheets || stylesheets.length === 0) return;
73
+ if (typeof ReactDOM.preinit !== "function") return;
74
+ for (const href of stylesheets) ReactDOM.preinit(href, { as: "style" });
75
+ }
36
76
  function buildBeforeInteractiveScriptProps(options) {
37
77
  const scriptProps = { ...options.rest };
38
78
  if (options.src) scriptProps.src = options.src;
@@ -62,11 +102,30 @@ function extractBeforeInteractiveInlineContent(children, dangerouslySetInnerHTML
62
102
  return null;
63
103
  }
64
104
  /**
105
+ * Map of React DOM prop names to their HTML attribute equivalents. Mirrors
106
+ * Next.js's `set-attributes-from-props.ts`:
107
+ * .nextjs-ref/packages/next/src/client/set-attributes-from-props.ts
108
+ * HTML parses attribute names case-insensitively, so without this translation
109
+ * `className="foo"` round-trips as `classname="foo"` and CSS selectors on
110
+ * `.foo` never match. Same hazard for `htmlFor`/`for`, `httpEquiv`/`http-equiv`,
111
+ * `acceptCharset`/`accept-charset`.
112
+ */
113
+ const REACT_TO_HTML_ATTR = {
114
+ acceptCharset: "accept-charset",
115
+ className: "class",
116
+ htmlFor: "for",
117
+ httpEquiv: "http-equiv"
118
+ };
119
+ /**
65
120
  * Convert the residual `<Script>` props into a plain string-attributes record
66
121
  * for emission inside a hoisted `<script>` tag. Drops React-only props
67
122
  * (event handlers, children, etc.) and reserved keys already handled by the
68
123
  * pre-head-injection emitter (id, nonce). Skips `undefined`/`null` so they
69
124
  * round-trip as "attribute absent" rather than `attr="undefined"`.
125
+ *
126
+ * React DOM prop names (className, htmlFor, etc.) are translated to their
127
+ * HTML attribute names so the output parses correctly — see comment on
128
+ * `REACT_TO_HTML_ATTR`.
70
129
  */
71
130
  function collectBeforeInteractiveAttributes(rest) {
72
131
  const RESERVED = new Set([
@@ -78,18 +137,20 @@ function collectBeforeInteractiveAttributes(rest) {
78
137
  "dangerouslySetInnerHTML",
79
138
  "onLoad",
80
139
  "onReady",
81
- "onError"
140
+ "onError",
141
+ "stylesheets"
82
142
  ]);
83
143
  const out = {};
84
144
  for (const [key, value] of Object.entries(rest)) {
85
145
  if (RESERVED.has(key)) continue;
86
146
  if (value === void 0 || value === null || value === false) continue;
147
+ const attrName = REACT_TO_HTML_ATTR[key] ?? key;
87
148
  if (typeof value === "boolean") {
88
- out[key] = true;
149
+ out[attrName] = true;
89
150
  continue;
90
151
  }
91
152
  if (typeof value === "string" || typeof value === "number") {
92
- out[key] = String(value);
153
+ out[attrName] = String(value);
93
154
  continue;
94
155
  }
95
156
  }
@@ -127,8 +188,9 @@ function setScriptAttributes(el, rest) {
127
188
  }
128
189
  }
129
190
  function loadClientScript(props, options) {
130
- const { src, id, onLoad, onReady, onError, strategy = "afterInteractive", children, dangerouslySetInnerHTML, ...rest } = props;
191
+ const { src, id, onLoad, onReady, onError, strategy = "afterInteractive", children, dangerouslySetInnerHTML, stylesheets, ...rest } = props;
131
192
  if (typeof window === "undefined") return;
193
+ insertClientStylesheets(stylesheets);
132
194
  const key = id ?? src ?? "";
133
195
  if (key && loadedScripts.has(key)) {
134
196
  if (options.fireReadyWhenAlreadyLoaded) onReady?.();
@@ -195,7 +257,7 @@ function initScriptLoader(scripts) {
195
257
  for (const script of scripts) handleClientScriptLoad(script);
196
258
  }
197
259
  function Script(props) {
198
- const { src, id, strategy = "afterInteractive", onLoad, onReady, onError, children, dangerouslySetInnerHTML, ...rest } = props;
260
+ const { src, id, strategy = "afterInteractive", onLoad, onReady, onError, children, dangerouslySetInnerHTML, stylesheets, ...rest } = props;
199
261
  const hasMounted = useRef(false);
200
262
  const key = id ?? src ?? "";
201
263
  const contextualNonce = useScriptNonce();
@@ -204,8 +266,12 @@ function Script(props) {
204
266
  useEffect(() => {
205
267
  if (hasMounted.current) return;
206
268
  hasMounted.current = true;
207
- if (strategy === "beforeInteractive") return;
269
+ if (strategy === "beforeInteractive") {
270
+ insertClientStylesheets(stylesheets);
271
+ return;
272
+ }
208
273
  if (key && loadedScripts.has(key)) {
274
+ insertClientStylesheets(stylesheets);
209
275
  onReady?.();
210
276
  return;
211
277
  }
@@ -223,6 +289,7 @@ function Script(props) {
223
289
  onError,
224
290
  children,
225
291
  dangerouslySetInnerHTML,
292
+ stylesheets,
226
293
  ...rest
227
294
  }, {
228
295
  resolvedNonce,
@@ -245,11 +312,13 @@ function Script(props) {
245
312
  onError,
246
313
  children,
247
314
  dangerouslySetInnerHTML,
315
+ stylesheets,
248
316
  key,
249
317
  resolvedNonce,
250
318
  rest
251
319
  ]);
252
320
  if (typeof window === "undefined") {
321
+ preinitStylesheetsForSSR(stylesheets);
253
322
  if (src && typeof ReactDOM.preload === "function" && (strategy === "afterInteractive" || strategy === "beforeInteractive")) {
254
323
  const integrity = typeof rest.integrity === "string" ? rest.integrity : void 0;
255
324
  const preloadOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"script.js","names":[],"sources":["../../src/shims/script.tsx"],"sourcesContent":["\"use client\";\n\n/**\n * next/script shim\n *\n * Provides the <Script> component for loading third-party scripts with\n * configurable loading strategies.\n *\n * Strategies:\n * - \"beforeInteractive\": rendered as a <script> tag in SSR output\n * - \"afterInteractive\" (default): loaded client-side after hydration\n * - \"lazyOnload\": deferred until window.load + requestIdleCallback\n * - \"worker\": sets type=\"text/partytown\" (requires Partytown setup)\n */\nimport React, { useEffect, useRef } from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { hasAppNavigationRuntimeBootstrap } from \"../client/navigation-runtime.js\";\nimport { escapeInlineContent } from \"./head.js\";\nimport { useScriptNonce } from \"./script-nonce-context.js\";\nimport {\n useBeforeInteractiveRegister,\n type BeforeInteractiveInlineScript,\n} from \"./before-interactive-context.js\";\n\nexport type ScriptProps = {\n /** Script source URL */\n src?: string;\n /** Loading strategy. Default: \"afterInteractive\" */\n strategy?: \"beforeInteractive\" | \"afterInteractive\" | \"lazyOnload\" | \"worker\";\n /** Unique identifier for the script */\n id?: string;\n /** Called when the script has loaded */\n onLoad?: (e: Event) => void;\n /** Called when the script is ready (after load, and on every re-render if already loaded) */\n onReady?: () => void;\n /** Called on script load error */\n onError?: (e: Event) => void;\n /** Inline script content */\n children?: React.ReactNode;\n /** Dangerous inner HTML */\n dangerouslySetInnerHTML?: { __html: string };\n /** Script type attribute */\n type?: string;\n /** Async attribute */\n async?: boolean;\n /** Defer attribute */\n defer?: boolean;\n /** Crossorigin attribute */\n crossOrigin?: string;\n /** Nonce for CSP */\n nonce?: string;\n /** Integrity hash */\n integrity?: string;\n /** Additional attributes */\n [key: string]: unknown;\n};\n\n// Track scripts that have already been loaded, plus remote scripts currently\n// loading, to avoid duplicate DOM insertion when same-src components mount\n// before the first load event fires.\nconst loadedScripts = new Set<string>();\nconst loadingScripts = new Map<string, Promise<Event>>();\n\nfunction getClientAutoNonce(): string | undefined {\n if (typeof document === \"undefined\") return undefined;\n\n const existingNonceElement = document.querySelector(\"[nonce]\");\n if (!existingNonceElement) return undefined;\n\n // `HTMLElement` is not defined in some SSR/edge runtimes that polyfill\n // `document` but stop short of the full DOM surface. Guarding the\n // constructor before `instanceof` keeps SSR from crashing in those hosts;\n // when the constructor *is* present we still prefer the typed `.nonce`\n // property because browsers strip the `nonce` attribute from serialised\n // HTML for CSP reasons.\n if (typeof HTMLElement !== \"undefined\" && existingNonceElement instanceof HTMLElement) {\n return existingNonceElement.nonce || existingNonceElement.getAttribute(\"nonce\") || undefined;\n }\n\n return existingNonceElement.getAttribute(\"nonce\") || undefined;\n}\n\nfunction resolveScriptNonce(explicitNonce: unknown, contextualNonce?: string): string | undefined {\n if (typeof explicitNonce === \"string\" && explicitNonce.length > 0) {\n return explicitNonce;\n }\n\n if (typeof contextualNonce === \"string\" && contextualNonce.length > 0) {\n return contextualNonce;\n }\n\n if (typeof window === \"undefined\") {\n return undefined;\n }\n\n return getClientAutoNonce();\n}\n\nfunction buildBeforeInteractiveScriptProps(options: {\n src?: string;\n id?: string;\n rest: Record<string, unknown>;\n resolvedNonce?: string;\n dangerouslySetInnerHTML?: { __html: string };\n}): Record<string, unknown> {\n const scriptProps: Record<string, unknown> = { ...options.rest };\n if (options.src) scriptProps.src = options.src;\n if (options.id) scriptProps.id = options.id;\n if (options.resolvedNonce) {\n scriptProps.nonce = options.resolvedNonce;\n }\n if (options.dangerouslySetInnerHTML) {\n scriptProps.dangerouslySetInnerHTML = {\n __html: escapeInlineContent(options.dangerouslySetInnerHTML.__html, \"script\"),\n };\n }\n return scriptProps;\n}\n\n/**\n * Extract the inline script content for a `beforeInteractive` Script element\n * with no `src`. Returns `null` when the element has neither a string-shaped\n * `children` value nor a valid `dangerouslySetInnerHTML.__html` payload — in\n * that case the caller should fall through to React's regular rendering path.\n *\n * The returned string is the raw author-supplied JavaScript content. Callers\n * are responsible for passing it through `escapeInlineContent(..., \"script\")`\n * before emitting it inside a `<script>` tag (we keep that escape adjacent\n * to the emit point so the rule is obvious at the boundary).\n */\nfunction extractBeforeInteractiveInlineContent(\n children: React.ReactNode,\n dangerouslySetInnerHTML?: { __html: string },\n): string | null {\n if (\n dangerouslySetInnerHTML &&\n typeof dangerouslySetInnerHTML.__html === \"string\" &&\n dangerouslySetInnerHTML.__html.length > 0\n ) {\n return dangerouslySetInnerHTML.__html;\n }\n if (typeof children === \"string\" && children.length > 0) {\n return children;\n }\n if (Array.isArray(children) && children.every((c) => typeof c === \"string\")) {\n const joined = (children as string[]).join(\"\");\n return joined.length > 0 ? joined : null;\n }\n return null;\n}\n\n/**\n * Convert the residual `<Script>` props into a plain string-attributes record\n * for emission inside a hoisted `<script>` tag. Drops React-only props\n * (event handlers, children, etc.) and reserved keys already handled by the\n * pre-head-injection emitter (id, nonce). Skips `undefined`/`null` so they\n * round-trip as \"attribute absent\" rather than `attr=\"undefined\"`.\n */\nfunction collectBeforeInteractiveAttributes(\n rest: Record<string, unknown>,\n): Record<string, string | boolean> {\n const RESERVED = new Set([\n \"id\",\n \"nonce\",\n \"src\",\n \"children\",\n \"strategy\",\n \"dangerouslySetInnerHTML\",\n \"onLoad\",\n \"onReady\",\n \"onError\",\n ]);\n const out: Record<string, string | boolean> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (RESERVED.has(key)) continue;\n if (value === undefined || value === null || value === false) continue;\n if (typeof value === \"boolean\") {\n out[key] = true;\n continue;\n }\n if (typeof value === \"string\" || typeof value === \"number\") {\n out[key] = String(value);\n continue;\n }\n // Skip anything else (functions, objects) — they cannot serialise into an\n // HTML attribute and only the developer-controlled string/boolean shape\n // is expected for native `<script>` attributes here.\n }\n return out;\n}\n\nfunction setBooleanScriptAttribute(el: HTMLScriptElement, attr: string, value: unknown): boolean {\n const enabled = value !== false && value !== \"false\" && Boolean(value);\n\n switch (attr) {\n case \"async\":\n el.async = enabled;\n break;\n case \"defer\":\n el.defer = enabled;\n break;\n case \"noModule\":\n case \"nomodule\":\n el.noModule = enabled;\n break;\n default:\n return false;\n }\n\n if (!enabled) {\n // Dynamic script elements start in the browser's force-async state.\n // Setting and removing the attribute mirrors Next.js and clears that state.\n el.setAttribute(attr, \"\");\n el.removeAttribute(attr);\n }\n\n return true;\n}\n\nfunction setScriptAttributes(el: HTMLScriptElement, rest: Record<string, unknown>): void {\n for (const [attr, value] of Object.entries(rest)) {\n if (attr === \"dangerouslySetInnerHTML\") continue;\n if (value === undefined) continue;\n if (setBooleanScriptAttribute(el, attr, value)) continue;\n if (attr === \"className\" && typeof value === \"string\") {\n el.setAttribute(\"class\", value);\n } else if (typeof value === \"string\") {\n el.setAttribute(attr, value);\n } else if (typeof value === \"boolean\" && value) {\n el.setAttribute(attr, \"\");\n }\n }\n}\n\nfunction loadClientScript(\n props: ScriptProps,\n options: {\n resolvedNonce?: string;\n fireReadyWhenAlreadyLoaded: boolean;\n },\n): void {\n const {\n src,\n id,\n onLoad,\n onReady,\n onError,\n strategy = \"afterInteractive\",\n children,\n dangerouslySetInnerHTML,\n ...rest\n } = props;\n if (typeof window === \"undefined\") return;\n\n const key = id ?? src ?? \"\";\n if (key && loadedScripts.has(key)) {\n if (options.fireReadyWhenAlreadyLoaded) {\n onReady?.();\n }\n return;\n }\n\n if (src) {\n const existingLoad = loadingScripts.get(src);\n if (existingLoad) {\n void existingLoad.then(\n (event) => {\n if (key) loadedScripts.add(key);\n onLoad?.(event);\n onReady?.();\n },\n (event) => onError?.(event),\n );\n return;\n }\n }\n\n const el = document.createElement(\"script\");\n if (src) el.src = src;\n if (id) el.id = id;\n\n setScriptAttributes(el, rest);\n if (options.resolvedNonce && !el.getAttribute(\"nonce\")) {\n el.setAttribute(\"nonce\", options.resolvedNonce);\n }\n\n if (strategy === \"worker\") {\n el.setAttribute(\"type\", \"text/partytown\");\n }\n\n const markLoaded = () => {\n if (key) loadedScripts.add(key);\n onReady?.();\n };\n\n if (dangerouslySetInnerHTML?.__html) {\n // Intentional: mirrors the Next.js <Script> API where dangerouslySetInnerHTML\n // is developer-supplied inline script content (not user input). The prop name\n // itself signals developer awareness of the XSS risk, consistent with React's\n // design. User-supplied data must never flow into this prop.\n el.innerHTML = dangerouslySetInnerHTML.__html;\n markLoaded();\n } else if (children && typeof children === \"string\") {\n el.textContent = children;\n markLoaded();\n } else if (src) {\n const loadPromise = new Promise<Event>((resolve, reject) => {\n el.addEventListener(\"load\", (event) => {\n resolve(event);\n if (key) loadedScripts.add(key);\n onLoad?.(event);\n onReady?.();\n });\n el.addEventListener(\"error\", (event) => {\n reject(event);\n onError?.(event);\n });\n });\n loadPromise.catch(() => undefined).finally(() => loadingScripts.delete(src));\n loadingScripts.set(src, loadPromise);\n }\n\n document.body.appendChild(el);\n}\n\n/**\n * Load a script imperatively (outside of React).\n */\nexport function handleClientScriptLoad(props: ScriptProps): void {\n loadClientScript(props, {\n resolvedNonce: resolveScriptNonce(props.nonce),\n fireReadyWhenAlreadyLoaded: false,\n });\n}\n\n/**\n * Initialize multiple scripts at once (called during app bootstrap).\n */\nexport function initScriptLoader(scripts: ScriptProps[]): void {\n for (const script of scripts) {\n handleClientScriptLoad(script);\n }\n}\n\nfunction Script(props: ScriptProps): React.ReactElement | null {\n const {\n src,\n id,\n strategy = \"afterInteractive\",\n onLoad,\n onReady,\n onError,\n children,\n dangerouslySetInnerHTML,\n ...rest\n } = props;\n\n const hasMounted = useRef(false);\n const key = id ?? src ?? \"\";\n const contextualNonce = useScriptNonce();\n const resolvedNonce = resolveScriptNonce(rest.nonce, contextualNonce);\n // Available only during SSR — the provider lives in app-ssr-entry.ts. When\n // missing (Pages Router SSR, raw renderToString, client render) we keep the\n // inline `<script>` element in source order.\n const registerBeforeInteractive = useBeforeInteractiveRegister();\n\n // Client path: load scripts via useEffect based on strategy.\n // useEffect never runs during SSR, so it's safe to call unconditionally.\n useEffect(() => {\n if (hasMounted.current) return;\n hasMounted.current = true;\n\n if (strategy === \"beforeInteractive\") {\n return;\n }\n\n // Already loaded — just fire onReady\n if (key && loadedScripts.has(key)) {\n onReady?.();\n return;\n }\n\n const load = () => {\n if (key && loadedScripts.has(key)) {\n onReady?.();\n return;\n }\n\n loadClientScript(\n {\n src,\n id,\n strategy,\n onLoad,\n onReady,\n onError,\n children,\n dangerouslySetInnerHTML,\n ...rest,\n },\n { resolvedNonce, fireReadyWhenAlreadyLoaded: true },\n );\n };\n\n if (strategy === \"lazyOnload\") {\n // Wait for window load, then use idle callback\n if (document.readyState === \"complete\") {\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(load);\n } else {\n setTimeout(load, 1);\n }\n } else {\n window.addEventListener(\"load\", () => {\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(load);\n } else {\n setTimeout(load, 1);\n }\n });\n }\n } else {\n // \"afterInteractive\" (default), \"beforeInteractive\" (client re-mount), \"worker\"\n load();\n }\n }, [\n src,\n id,\n strategy,\n onLoad,\n onReady,\n onError,\n children,\n dangerouslySetInnerHTML,\n key,\n resolvedNonce,\n rest,\n ]);\n\n // SSR path: only \"beforeInteractive\" renders a <script> tag server-side\n if (typeof window === \"undefined\") {\n // React Float preload — emits <link rel=\"preload\" as=\"script\" /> in <head>\n // so the script is fetched while HTML streams. Mirrors Next.js's App Router\n // behavior at .nextjs-ref/packages/next/src/client/script.tsx:298-376:\n // - afterInteractive with src: preload only (no <script> tag in SSR)\n // - beforeInteractive with src: preload + <script> tag\n // - inline scripts (no src): no preload\n // Calling ReactDOM.preload during SSR is safe in both routers; React only\n // hoists the link when it has a real <head> to hoist into.\n if (\n src &&\n typeof ReactDOM.preload === \"function\" &&\n (strategy === \"afterInteractive\" || strategy === \"beforeInteractive\")\n ) {\n const integrity = typeof rest.integrity === \"string\" ? rest.integrity : undefined;\n const crossOrigin =\n rest.crossOrigin === \"anonymous\" || rest.crossOrigin === \"use-credentials\"\n ? rest.crossOrigin\n : undefined;\n const preloadOptions: ReactDOM.PreloadOptions = {\n as: \"script\",\n crossOrigin,\n };\n if (resolvedNonce !== undefined) {\n preloadOptions.nonce = resolvedNonce;\n }\n if (integrity !== undefined) {\n preloadOptions.integrity = integrity;\n }\n ReactDOM.preload(src, preloadOptions);\n }\n\n if (strategy === \"beforeInteractive\") {\n // Inline beforeInteractive scripts (no src) need to run BEFORE any\n // stylesheets, modulepreload links, or other resource hints React Float\n // hoists into <head>. React Fizz emits user-rendered head children\n // AFTER the hoisted resources, so leaving the script in source order\n // breaks the no-flash dark-mode pattern. We instead capture the inline\n // content through BeforeInteractiveContext and the SSR pipeline emits\n // it immediately after `<head>` opens — guaranteeing it precedes every\n // React-emitted hint in the streamed HTML.\n const inlineContent = src\n ? null\n : extractBeforeInteractiveInlineContent(children, dangerouslySetInnerHTML);\n if (inlineContent !== null && registerBeforeInteractive) {\n const inline: BeforeInteractiveInlineScript = {\n id,\n // Escape `</script>` sequences exactly as the inline render path does\n // (see buildBeforeInteractiveScriptProps); keep the escape colocated\n // with the emit boundary so it never gets accidentally skipped.\n innerHTML: escapeInlineContent(inlineContent, \"script\"),\n nonce: resolvedNonce,\n attributes: collectBeforeInteractiveAttributes(rest),\n };\n registerBeforeInteractive(inline);\n return null;\n }\n\n return React.createElement(\n \"script\",\n buildBeforeInteractiveScriptProps({\n src,\n id,\n rest,\n resolvedNonce,\n dangerouslySetInnerHTML,\n }),\n children,\n );\n }\n // Other strategies don't render during SSR\n return null;\n }\n\n if (strategy === \"beforeInteractive\") {\n // On the client, only suppress the `<script>` render for inline\n // beforeInteractive Scripts in App Router pages. The pre-head splice\n // in app-ssr-entry/app-ssr-stream already put the tag in the DOM, so\n // rendering it again would either duplicate the script (for Scripts\n // outside `<head>`) or cause a hydration mismatch (positions differ).\n //\n // For Pages Router and any other SSR path that didn't run through\n // app-ssr-entry, the server rendered the `<script>` inline in source\n // order, so the client must match. We detect \"App Router\" via the\n // navigation runtime that the App Router bootstrap installs before\n // calling hydrateRoot — it is the most reliable runtime signal we\n // can read from inside a `\"use client\"` shim.\n //\n // External-`src` beforeInteractive scripts always keep rendering\n // inline. They are not captured by the pre-head splice and must mount\n // through React so their `src` attribute is fetched on the client.\n const inlineContent = src\n ? null\n : extractBeforeInteractiveInlineContent(children, dangerouslySetInnerHTML);\n if (inlineContent !== null && hasAppNavigationRuntimeBootstrap()) {\n return null;\n }\n\n return React.createElement(\n \"script\",\n buildBeforeInteractiveScriptProps({\n src,\n id,\n rest,\n resolvedNonce,\n dangerouslySetInnerHTML,\n }),\n children,\n );\n }\n\n // The component itself renders nothing — scripts are injected imperatively\n return null;\n}\n\nexport default Script;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,gCAAgB,IAAI,KAAa;AACvC,MAAM,iCAAiB,IAAI,KAA6B;AAExD,SAAS,qBAAyC;CAChD,IAAI,OAAO,aAAa,aAAa,OAAO,KAAA;CAE5C,MAAM,uBAAuB,SAAS,cAAc,UAAU;CAC9D,IAAI,CAAC,sBAAsB,OAAO,KAAA;CAQlC,IAAI,OAAO,gBAAgB,eAAe,gCAAgC,aACxE,OAAO,qBAAqB,SAAS,qBAAqB,aAAa,QAAQ,IAAI,KAAA;CAGrF,OAAO,qBAAqB,aAAa,QAAQ,IAAI,KAAA;;AAGvD,SAAS,mBAAmB,eAAwB,iBAA8C;CAChG,IAAI,OAAO,kBAAkB,YAAY,cAAc,SAAS,GAC9D,OAAO;CAGT,IAAI,OAAO,oBAAoB,YAAY,gBAAgB,SAAS,GAClE,OAAO;CAGT,IAAI,OAAO,WAAW,aACpB;CAGF,OAAO,oBAAoB;;AAG7B,SAAS,kCAAkC,SAMf;CAC1B,MAAM,cAAuC,EAAE,GAAG,QAAQ,MAAM;CAChE,IAAI,QAAQ,KAAK,YAAY,MAAM,QAAQ;CAC3C,IAAI,QAAQ,IAAI,YAAY,KAAK,QAAQ;CACzC,IAAI,QAAQ,eACV,YAAY,QAAQ,QAAQ;CAE9B,IAAI,QAAQ,yBACV,YAAY,0BAA0B,EACpC,QAAQ,oBAAoB,QAAQ,wBAAwB,QAAQ,SAAS,EAC9E;CAEH,OAAO;;;;;;;;;;;;;AAcT,SAAS,sCACP,UACA,yBACe;CACf,IACE,2BACA,OAAO,wBAA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AO,iBAAiB,cAAc;GACpC,IAAI,OAAO,wBAAwB,YACjC,oBAAoB,KAAK;QAEzB,WAAW,MAAM,EAAE;IAErB;OAIJ,MAAM;IAEP;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAGF,IAAI,OAAO,WAAW,aAAa;EASjC,IACE,OACA,OAAO,SAAS,YAAY,eAC3B,aAAa,sBAAsB,aAAa,sBACjD;GACA,MAAM,YAAY,OAAO,KAAK,cAAc,WAAW,KAAK,YAAY,KAAA;GAKxE,MAAM,iBAA0C;IAC9C,IAAI;IACJ,aALA,KAAK,gBAAgB,eAAe,KAAK,gBAAgB,oBACrD,KAAK,cACL,KAAA;IAIL;GACD,IAAI,kBAAkB,KAAA,GACpB,eAAe,QAAQ;GAEzB,IAAI,cAAc,KAAA,GAChB,eAAe,YAAY;GAE7B,SAAS,QAAQ,KAAK,eAAe;;EAGvC,IAAI,aAAa,qBAAqB;GASpC,MAAM,gBAAgB,MAClB,OACA,sCAAsC,UAAU,wBAAwB;GAC5E,IAAI,kBAAkB,QAAQ,2BAA2B;IAUvD,0BAA0B;KARxB;KAIA,WAAW,oBAAoB,eAAe,SAAS;KACvD,OAAO;KACP,YAAY,mCAAmC,KAAK;KAEtB,CAAC;IACjC,OAAO;;GAGT,OAAO,MAAM,cACX,UACA,kCAAkC;IAChC;IACA;IACA;IACA;IACA;IACD,CAAC,EACF,SACD;;EAGH,OAAO;;CAGT,IAAI,aAAa,qBAAqB;EAoBpC,KAHsB,MAClB,OACA,sCAAsC,UAAU,wBAAwB,MACtD,QAAQ,kCAAkC,EAC9D,OAAO;EAGT,OAAO,MAAM,cACX,UACA,kCAAkC;GAChC;GACA;GACA;GACA;GACA;GACD,CAAC,EACF,SACD;;CAIH,OAAO"}
1
+ {"version":3,"file":"script.js","names":[],"sources":["../../src/shims/script.tsx"],"sourcesContent":["\"use client\";\n\n/**\n * next/script shim\n *\n * Provides the <Script> component for loading third-party scripts with\n * configurable loading strategies.\n *\n * Strategies:\n * - \"beforeInteractive\": rendered as a <script> tag in SSR output\n * - \"afterInteractive\" (default): loaded client-side after hydration\n * - \"lazyOnload\": deferred until window.load + requestIdleCallback\n * - \"worker\": sets type=\"text/partytown\" (requires Partytown setup)\n */\nimport React, { useEffect, useRef } from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { hasAppNavigationRuntimeBootstrap } from \"../client/navigation-runtime.js\";\nimport { escapeInlineContent } from \"./head.js\";\nimport { useScriptNonce } from \"./script-nonce-context.js\";\nimport {\n useBeforeInteractiveRegister,\n type BeforeInteractiveInlineScript,\n} from \"./before-interactive-context.js\";\n\nexport type ScriptProps = {\n /** Script source URL */\n src?: string;\n /** Loading strategy. Default: \"afterInteractive\" */\n strategy?: \"beforeInteractive\" | \"afterInteractive\" | \"lazyOnload\" | \"worker\";\n /** Unique identifier for the script */\n id?: string;\n /** Called when the script has loaded */\n onLoad?: (e: Event) => void;\n /** Called when the script is ready (after load, and on every re-render if already loaded) */\n onReady?: () => void;\n /** Called on script load error */\n onError?: (e: Event) => void;\n /** Inline script content */\n children?: React.ReactNode;\n /** Dangerous inner HTML */\n dangerouslySetInnerHTML?: { __html: string };\n /** Script type attribute */\n type?: string;\n /** Async attribute */\n async?: boolean;\n /** Defer attribute */\n defer?: boolean;\n /** Crossorigin attribute */\n crossOrigin?: string;\n /** Nonce for CSP */\n nonce?: string;\n /** Integrity hash */\n integrity?: string;\n /**\n * Associated stylesheets to load alongside the script. Emitted as\n * `<link rel=\"stylesheet\" href=\"...\">` on SSR (via `ReactDOM.preinit`)\n * and inserted into `<head>` on the client load path.\n *\n * Mirrors Next.js App Router behaviour at\n * `.nextjs-ref/packages/next/src/client/script.tsx` (`insertStylesheets`\n * and the `appDir` block).\n */\n stylesheets?: string[];\n /** Additional attributes */\n [key: string]: unknown;\n};\n\n// Track scripts that have already been loaded, plus remote scripts currently\n// loading, to avoid duplicate DOM insertion when same-src components mount\n// before the first load event fires.\nconst loadedScripts = new Set<string>();\nconst loadingScripts = new Map<string, Promise<Event>>();\n\nfunction getClientAutoNonce(): string | undefined {\n if (typeof document === \"undefined\") return undefined;\n\n const existingNonceElement = document.querySelector(\"[nonce]\");\n if (!existingNonceElement) return undefined;\n\n // `HTMLElement` is not defined in some SSR/edge runtimes that polyfill\n // `document` but stop short of the full DOM surface. Guarding the\n // constructor before `instanceof` keeps SSR from crashing in those hosts;\n // when the constructor *is* present we still prefer the typed `.nonce`\n // property because browsers strip the `nonce` attribute from serialised\n // HTML for CSP reasons.\n if (typeof HTMLElement !== \"undefined\" && existingNonceElement instanceof HTMLElement) {\n return existingNonceElement.nonce || existingNonceElement.getAttribute(\"nonce\") || undefined;\n }\n\n return existingNonceElement.getAttribute(\"nonce\") || undefined;\n}\n\nfunction resolveScriptNonce(explicitNonce: unknown, contextualNonce?: string): string | undefined {\n if (typeof explicitNonce === \"string\" && explicitNonce.length > 0) {\n return explicitNonce;\n }\n\n if (typeof contextualNonce === \"string\" && contextualNonce.length > 0) {\n return contextualNonce;\n }\n\n if (typeof window === \"undefined\") {\n return undefined;\n }\n\n return getClientAutoNonce();\n}\n\n/**\n * Insert `<link rel=\"stylesheet\">` tags into `document.head` for each entry\n * in `stylesheets`. Used by the imperative client-side load path\n * (`handleClientScriptLoad`) when `ReactDOM.preinit` is not available\n * (e.g. pre-Float React or hosts that strip it). Mirrors Next.js's\n * `insertStylesheets` Pages-Router fallback at\n * `.nextjs-ref/packages/next/src/client/script.tsx:48-59`.\n *\n * The `ReactDOM.preinit` path is preferred where available — it dedupes\n * across mounts and respects React Float's hoisting order. This DOM\n * fallback is best-effort: no dedupe, no ordering guarantee.\n */\nfunction insertClientStylesheets(stylesheets: string[] | undefined): void {\n if (!stylesheets || stylesheets.length === 0) return;\n if (typeof document === \"undefined\") return;\n\n // Prefer ReactDOM.preinit when available — it dedupes via React Float\n // and matches Next.js's app-router behaviour.\n if (typeof ReactDOM.preinit === \"function\") {\n for (const href of stylesheets) {\n ReactDOM.preinit(href, { as: \"style\" });\n }\n return;\n }\n\n const head = document.head;\n if (!head) return;\n for (const href of stylesheets) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.type = \"text/css\";\n link.href = href;\n head.appendChild(link);\n }\n}\n\n/**\n * Emit `<link rel=\"stylesheet\">` tags during SSR for each entry in\n * `stylesheets` via `ReactDOM.preinit`. React Float hoists these into\n * `<head>` in the streamed HTML. Mirrors the App-Router branch of\n * Next.js's Script component at `.nextjs-ref/packages/next/src/client/script.tsx:309-313`.\n */\nfunction preinitStylesheetsForSSR(stylesheets: string[] | undefined): void {\n if (!stylesheets || stylesheets.length === 0) return;\n if (typeof ReactDOM.preinit !== \"function\") return;\n for (const href of stylesheets) {\n ReactDOM.preinit(href, { as: \"style\" });\n }\n}\n\nfunction buildBeforeInteractiveScriptProps(options: {\n src?: string;\n id?: string;\n rest: Record<string, unknown>;\n resolvedNonce?: string;\n dangerouslySetInnerHTML?: { __html: string };\n}): Record<string, unknown> {\n const scriptProps: Record<string, unknown> = { ...options.rest };\n if (options.src) scriptProps.src = options.src;\n if (options.id) scriptProps.id = options.id;\n if (options.resolvedNonce) {\n scriptProps.nonce = options.resolvedNonce;\n }\n if (options.dangerouslySetInnerHTML) {\n scriptProps.dangerouslySetInnerHTML = {\n __html: escapeInlineContent(options.dangerouslySetInnerHTML.__html, \"script\"),\n };\n }\n return scriptProps;\n}\n\n/**\n * Extract the inline script content for a `beforeInteractive` Script element\n * with no `src`. Returns `null` when the element has neither a string-shaped\n * `children` value nor a valid `dangerouslySetInnerHTML.__html` payload — in\n * that case the caller should fall through to React's regular rendering path.\n *\n * The returned string is the raw author-supplied JavaScript content. Callers\n * are responsible for passing it through `escapeInlineContent(..., \"script\")`\n * before emitting it inside a `<script>` tag (we keep that escape adjacent\n * to the emit point so the rule is obvious at the boundary).\n */\nfunction extractBeforeInteractiveInlineContent(\n children: React.ReactNode,\n dangerouslySetInnerHTML?: { __html: string },\n): string | null {\n if (\n dangerouslySetInnerHTML &&\n typeof dangerouslySetInnerHTML.__html === \"string\" &&\n dangerouslySetInnerHTML.__html.length > 0\n ) {\n return dangerouslySetInnerHTML.__html;\n }\n if (typeof children === \"string\" && children.length > 0) {\n return children;\n }\n if (Array.isArray(children) && children.every((c) => typeof c === \"string\")) {\n const joined = (children as string[]).join(\"\");\n return joined.length > 0 ? joined : null;\n }\n return null;\n}\n\n/**\n * Map of React DOM prop names to their HTML attribute equivalents. Mirrors\n * Next.js's `set-attributes-from-props.ts`:\n * .nextjs-ref/packages/next/src/client/set-attributes-from-props.ts\n * HTML parses attribute names case-insensitively, so without this translation\n * `className=\"foo\"` round-trips as `classname=\"foo\"` and CSS selectors on\n * `.foo` never match. Same hazard for `htmlFor`/`for`, `httpEquiv`/`http-equiv`,\n * `acceptCharset`/`accept-charset`.\n */\nconst REACT_TO_HTML_ATTR: Record<string, string> = {\n acceptCharset: \"accept-charset\",\n className: \"class\",\n htmlFor: \"for\",\n httpEquiv: \"http-equiv\",\n};\n\n/**\n * Convert the residual `<Script>` props into a plain string-attributes record\n * for emission inside a hoisted `<script>` tag. Drops React-only props\n * (event handlers, children, etc.) and reserved keys already handled by the\n * pre-head-injection emitter (id, nonce). Skips `undefined`/`null` so they\n * round-trip as \"attribute absent\" rather than `attr=\"undefined\"`.\n *\n * React DOM prop names (className, htmlFor, etc.) are translated to their\n * HTML attribute names so the output parses correctly — see comment on\n * `REACT_TO_HTML_ATTR`.\n */\nfunction collectBeforeInteractiveAttributes(\n rest: Record<string, unknown>,\n): Record<string, string | boolean> {\n const RESERVED = new Set([\n \"id\",\n \"nonce\",\n \"src\",\n \"children\",\n \"strategy\",\n \"dangerouslySetInnerHTML\",\n \"onLoad\",\n \"onReady\",\n \"onError\",\n \"stylesheets\",\n ]);\n const out: Record<string, string | boolean> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (RESERVED.has(key)) continue;\n if (value === undefined || value === null || value === false) continue;\n const attrName = REACT_TO_HTML_ATTR[key] ?? key;\n if (typeof value === \"boolean\") {\n out[attrName] = true;\n continue;\n }\n if (typeof value === \"string\" || typeof value === \"number\") {\n out[attrName] = String(value);\n continue;\n }\n // Skip anything else (functions, objects) — they cannot serialise into an\n // HTML attribute and only the developer-controlled string/boolean shape\n // is expected for native `<script>` attributes here.\n }\n return out;\n}\n\nfunction setBooleanScriptAttribute(el: HTMLScriptElement, attr: string, value: unknown): boolean {\n const enabled = value !== false && value !== \"false\" && Boolean(value);\n\n switch (attr) {\n case \"async\":\n el.async = enabled;\n break;\n case \"defer\":\n el.defer = enabled;\n break;\n case \"noModule\":\n case \"nomodule\":\n el.noModule = enabled;\n break;\n default:\n return false;\n }\n\n if (!enabled) {\n // Dynamic script elements start in the browser's force-async state.\n // Setting and removing the attribute mirrors Next.js and clears that state.\n el.setAttribute(attr, \"\");\n el.removeAttribute(attr);\n }\n\n return true;\n}\n\nfunction setScriptAttributes(el: HTMLScriptElement, rest: Record<string, unknown>): void {\n for (const [attr, value] of Object.entries(rest)) {\n if (attr === \"dangerouslySetInnerHTML\") continue;\n if (value === undefined) continue;\n if (setBooleanScriptAttribute(el, attr, value)) continue;\n if (attr === \"className\" && typeof value === \"string\") {\n el.setAttribute(\"class\", value);\n } else if (typeof value === \"string\") {\n el.setAttribute(attr, value);\n } else if (typeof value === \"boolean\" && value) {\n el.setAttribute(attr, \"\");\n }\n }\n}\n\nfunction loadClientScript(\n props: ScriptProps,\n options: {\n resolvedNonce?: string;\n fireReadyWhenAlreadyLoaded: boolean;\n },\n): void {\n const {\n src,\n id,\n onLoad,\n onReady,\n onError,\n strategy = \"afterInteractive\",\n children,\n dangerouslySetInnerHTML,\n stylesheets,\n ...rest\n } = props;\n if (typeof window === \"undefined\") return;\n\n // Insert associated stylesheets into <head> regardless of whether the\n // script was already loaded — the script's onReady handlers may already\n // assume the stylesheet is present. `insertClientStylesheets` dedupes\n // via ReactDOM.preinit where available.\n insertClientStylesheets(stylesheets);\n\n const key = id ?? src ?? \"\";\n if (key && loadedScripts.has(key)) {\n if (options.fireReadyWhenAlreadyLoaded) {\n onReady?.();\n }\n return;\n }\n\n if (src) {\n const existingLoad = loadingScripts.get(src);\n if (existingLoad) {\n void existingLoad.then(\n (event) => {\n if (key) loadedScripts.add(key);\n onLoad?.(event);\n onReady?.();\n },\n (event) => onError?.(event),\n );\n return;\n }\n }\n\n const el = document.createElement(\"script\");\n if (src) el.src = src;\n if (id) el.id = id;\n\n setScriptAttributes(el, rest);\n if (options.resolvedNonce && !el.getAttribute(\"nonce\")) {\n el.setAttribute(\"nonce\", options.resolvedNonce);\n }\n\n if (strategy === \"worker\") {\n el.setAttribute(\"type\", \"text/partytown\");\n }\n\n const markLoaded = () => {\n if (key) loadedScripts.add(key);\n onReady?.();\n };\n\n if (dangerouslySetInnerHTML?.__html) {\n // Intentional: mirrors the Next.js <Script> API where dangerouslySetInnerHTML\n // is developer-supplied inline script content (not user input). The prop name\n // itself signals developer awareness of the XSS risk, consistent with React's\n // design. User-supplied data must never flow into this prop.\n el.innerHTML = dangerouslySetInnerHTML.__html;\n markLoaded();\n } else if (children && typeof children === \"string\") {\n el.textContent = children;\n markLoaded();\n } else if (src) {\n const loadPromise = new Promise<Event>((resolve, reject) => {\n el.addEventListener(\"load\", (event) => {\n resolve(event);\n if (key) loadedScripts.add(key);\n onLoad?.(event);\n onReady?.();\n });\n el.addEventListener(\"error\", (event) => {\n reject(event);\n onError?.(event);\n });\n });\n loadPromise.catch(() => undefined).finally(() => loadingScripts.delete(src));\n loadingScripts.set(src, loadPromise);\n }\n\n document.body.appendChild(el);\n}\n\n/**\n * Load a script imperatively (outside of React).\n */\nexport function handleClientScriptLoad(props: ScriptProps): void {\n loadClientScript(props, {\n resolvedNonce: resolveScriptNonce(props.nonce),\n fireReadyWhenAlreadyLoaded: false,\n });\n}\n\n/**\n * Initialize multiple scripts at once (called during app bootstrap).\n */\nexport function initScriptLoader(scripts: ScriptProps[]): void {\n for (const script of scripts) {\n handleClientScriptLoad(script);\n }\n}\n\nfunction Script(props: ScriptProps): React.ReactElement | null {\n const {\n src,\n id,\n strategy = \"afterInteractive\",\n onLoad,\n onReady,\n onError,\n children,\n dangerouslySetInnerHTML,\n stylesheets,\n ...rest\n } = props;\n\n const hasMounted = useRef(false);\n const key = id ?? src ?? \"\";\n const contextualNonce = useScriptNonce();\n const resolvedNonce = resolveScriptNonce(rest.nonce, contextualNonce);\n // Available only during SSR — the provider lives in app-ssr-entry.ts. When\n // missing (Pages Router SSR, raw renderToString, client render) we keep the\n // inline `<script>` element in source order.\n const registerBeforeInteractive = useBeforeInteractiveRegister();\n\n // Client path: load scripts via useEffect based on strategy.\n // useEffect never runs during SSR, so it's safe to call unconditionally.\n useEffect(() => {\n if (hasMounted.current) return;\n hasMounted.current = true;\n\n if (strategy === \"beforeInteractive\") {\n // The script itself is loaded by Next.js's bootstrap before hydration,\n // but the associated stylesheets still need to land in <head> on the\n // client. ReactDOM.preinit (called inside insertClientStylesheets)\n // dedupes against any SSR-emitted <link rel=\"stylesheet\">, so this is\n // safe even when the server already hoisted them via React Float.\n insertClientStylesheets(stylesheets);\n return;\n }\n\n // Already loaded — just fire onReady\n if (key && loadedScripts.has(key)) {\n // Stylesheets must still be inserted on subsequent mounts of the same\n // script. loadClientScript handles this for the fresh-load path; the\n // already-loaded shortcut needs it explicitly.\n insertClientStylesheets(stylesheets);\n onReady?.();\n return;\n }\n\n const load = () => {\n if (key && loadedScripts.has(key)) {\n onReady?.();\n return;\n }\n\n loadClientScript(\n {\n src,\n id,\n strategy,\n onLoad,\n onReady,\n onError,\n children,\n dangerouslySetInnerHTML,\n stylesheets,\n ...rest,\n },\n { resolvedNonce, fireReadyWhenAlreadyLoaded: true },\n );\n };\n\n if (strategy === \"lazyOnload\") {\n // Wait for window load, then use idle callback\n if (document.readyState === \"complete\") {\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(load);\n } else {\n setTimeout(load, 1);\n }\n } else {\n window.addEventListener(\"load\", () => {\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(load);\n } else {\n setTimeout(load, 1);\n }\n });\n }\n } else {\n // \"afterInteractive\" (default), \"beforeInteractive\" (client re-mount), \"worker\"\n load();\n }\n }, [\n src,\n id,\n strategy,\n onLoad,\n onReady,\n onError,\n children,\n dangerouslySetInnerHTML,\n stylesheets,\n key,\n resolvedNonce,\n rest,\n ]);\n\n // SSR path: only \"beforeInteractive\" renders a <script> tag server-side\n if (typeof window === \"undefined\") {\n // Emit associated stylesheets as <link rel=\"stylesheet\"> via React Float.\n // ReactDOM.preinit dedupes across mounts and hoists the link into <head>\n // regardless of strategy — matches Next.js's app-router branch at\n // `.nextjs-ref/packages/next/src/client/script.tsx:309-313`.\n preinitStylesheetsForSSR(stylesheets);\n\n // React Float preload — emits <link rel=\"preload\" as=\"script\" /> in <head>\n // so the script is fetched while HTML streams. Mirrors Next.js's App Router\n // behavior at .nextjs-ref/packages/next/src/client/script.tsx:298-376:\n // - afterInteractive with src: preload only (no <script> tag in SSR)\n // - beforeInteractive with src: preload + <script> tag\n // - inline scripts (no src): no preload\n // Calling ReactDOM.preload during SSR is safe in both routers; React only\n // hoists the link when it has a real <head> to hoist into.\n if (\n src &&\n typeof ReactDOM.preload === \"function\" &&\n (strategy === \"afterInteractive\" || strategy === \"beforeInteractive\")\n ) {\n const integrity = typeof rest.integrity === \"string\" ? rest.integrity : undefined;\n const crossOrigin =\n rest.crossOrigin === \"anonymous\" || rest.crossOrigin === \"use-credentials\"\n ? rest.crossOrigin\n : undefined;\n const preloadOptions: ReactDOM.PreloadOptions = {\n as: \"script\",\n crossOrigin,\n };\n if (resolvedNonce !== undefined) {\n preloadOptions.nonce = resolvedNonce;\n }\n if (integrity !== undefined) {\n preloadOptions.integrity = integrity;\n }\n ReactDOM.preload(src, preloadOptions);\n }\n\n if (strategy === \"beforeInteractive\") {\n // Inline beforeInteractive scripts (no src) need to run BEFORE any\n // stylesheets, modulepreload links, or other resource hints React Float\n // hoists into <head>. React Fizz emits user-rendered head children\n // AFTER the hoisted resources, so leaving the script in source order\n // breaks the no-flash dark-mode pattern. We instead capture the inline\n // content through BeforeInteractiveContext and the SSR pipeline emits\n // it immediately after `<head>` opens — guaranteeing it precedes every\n // React-emitted hint in the streamed HTML.\n const inlineContent = src\n ? null\n : extractBeforeInteractiveInlineContent(children, dangerouslySetInnerHTML);\n if (inlineContent !== null && registerBeforeInteractive) {\n const inline: BeforeInteractiveInlineScript = {\n id,\n // Escape `</script>` sequences exactly as the inline render path does\n // (see buildBeforeInteractiveScriptProps); keep the escape colocated\n // with the emit boundary so it never gets accidentally skipped.\n innerHTML: escapeInlineContent(inlineContent, \"script\"),\n nonce: resolvedNonce,\n attributes: collectBeforeInteractiveAttributes(rest),\n };\n registerBeforeInteractive(inline);\n return null;\n }\n\n return React.createElement(\n \"script\",\n buildBeforeInteractiveScriptProps({\n src,\n id,\n rest,\n resolvedNonce,\n dangerouslySetInnerHTML,\n }),\n children,\n );\n }\n // Other strategies don't render during SSR\n return null;\n }\n\n if (strategy === \"beforeInteractive\") {\n // On the client, only suppress the `<script>` render for inline\n // beforeInteractive Scripts in App Router pages. The pre-head splice\n // in app-ssr-entry/app-ssr-stream already put the tag in the DOM, so\n // rendering it again would either duplicate the script (for Scripts\n // outside `<head>`) or cause a hydration mismatch (positions differ).\n //\n // For Pages Router and any other SSR path that didn't run through\n // app-ssr-entry, the server rendered the `<script>` inline in source\n // order, so the client must match. We detect \"App Router\" via the\n // navigation runtime that the App Router bootstrap installs before\n // calling hydrateRoot — it is the most reliable runtime signal we\n // can read from inside a `\"use client\"` shim.\n //\n // External-`src` beforeInteractive scripts always keep rendering\n // inline. They are not captured by the pre-head splice and must mount\n // through React so their `src` attribute is fetched on the client.\n const inlineContent = src\n ? null\n : extractBeforeInteractiveInlineContent(children, dangerouslySetInnerHTML);\n if (inlineContent !== null && hasAppNavigationRuntimeBootstrap()) {\n return null;\n }\n\n return React.createElement(\n \"script\",\n buildBeforeInteractiveScriptProps({\n src,\n id,\n rest,\n resolvedNonce,\n dangerouslySetInnerHTML,\n }),\n children,\n );\n }\n\n // The component itself renders nothing — scripts are injected imperatively\n return null;\n}\n\nexport default Script;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsEA,MAAM,gCAAgB,IAAI,KAAa;AACvC,MAAM,iCAAiB,IAAI,KAA6B;AAExD,SAAS,qBAAyC;CAChD,IAAI,OAAO,aAAa,aAAa,OAAO,KAAA;CAE5C,MAAM,uBAAuB,SAAS,cAAc,UAAU;CAC9D,IAAI,CAAC,sBAAsB,OAAO,KAAA;CAQlC,IAAI,OAAO,gBAAgB,eAAe,gCAAgC,aACxE,OAAO,qBAAqB,SAAS,qBAAqB,aAAa,QAAQ,IAAI,KAAA;CAGrF,OAAO,qBAAqB,aAAa,QAAQ,IAAI,KAAA;;AAGvD,SAAS,mBAAmB,eAAwB,iBAA8C;CAChG,IAAI,OAAO,kBAAkB,YAAY,cAAc,SAAS,GAC9D,OAAO;CAGT,IAAI,OAAO,oBAAoB,YAAY,gBAAgB,SAAS,GAClE,OAAO;CAGT,IAAI,OAAO,WAAW,aACpB;CAGF,OAAO,oBAAoB;;;;;;;;;;;;;;AAe7B,SAAS,wBAAwB,aAAyC;CACxE,IAAI,CAAC,eAAe,YAAY,WAAW,GAAG;CAC9C,IAAI,OAAO,aAAa,aAAa;CAIrC,IAAI,OAAO,SAAS,YAAY,YAAY;EAC1C,KAAK,MAAM,QAAQ,aACjB,SAAS,QAAQ,MAAM,EAAE,IAAI,SAAS,CAAC;EAEzC;;CAGF,MAAM,OAAO,SAAS;CACtB,IAAI,CAAC,MAAM;CACX,KAAK,MAAM,QAAQ,aAAa;EAC9B,MAAM,OAAO,SAAS,cAAc,OAAO;EAC3C,KAAK,MAAM;EACX,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,YAAY,KAAK;;;;;;;;;AAU1B,SAAS,yBAAyB,aAAyC;CACzE,IAAI,CAAC,eAAe,YAAY,WAAW,GAAG;CAC9C,IAAI,OAAO,SAAS,YAAY,YAAY;CAC5C,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,YAAY;GAE7B,SAAS,QAAQ,KAAK,eAAe;;EAGvC,IAAI,aAAa,qBAAqB;GASpC,MAAM,gBAAgB,MAClB,OACA,sCAAsC,UAAU,wBAAwB;GAC5E,IAAI,kBAAkB,QAAQ,2BAA2B;IAUvD,0BAA0B;KARxB;KAIA,WAAW,oBAAoB,eAAe,SAAS;KACvD,OAAO;KACP,YAAY,mCAAmC,KAAK;KAEtB,CAAC;IACjC,OAAO;;GAGT,OAAO,MAAM,cACX,UACA,kCAAkC;IAChC;IACA;IACA;IACA;IACA;IACD,CAAC,EACF,SACD;;EAGH,OAAO;;CAGT,IAAI,aAAa,qBAAqB;EAoBpC,KAHsB,MAClB,OACA,sCAAsC,UAAU,wBAAwB,MACtD,QAAQ,kCAAkC,EAC9D,OAAO;EAGT,OAAO,MAAM,cACX,UACA,kCAAkC;GAChC;GACA;GACA;GACA;GACA;GACD,CAAC,EACF,SACD;;CAIH,OAAO"}
@@ -0,0 +1,13 @@
1
+ //#region src/utils/path.d.ts
2
+ /**
3
+ * Convert Windows-style backslash path separators to forward slashes.
4
+ *
5
+ * Generated entry modules embed absolute filesystem paths inside `import`
6
+ * statements. On Windows the OS-native paths use `\` which is invalid in JS
7
+ * module specifiers, so every entry generator normalizes paths through this
8
+ * helper before stringifying them into the emitted code.
9
+ */
10
+ declare function normalizePathSeparators(p: string): string;
11
+ //#endregion
12
+ export { normalizePathSeparators };
13
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1,16 @@
1
+ //#region src/utils/path.ts
2
+ /**
3
+ * Convert Windows-style backslash path separators to forward slashes.
4
+ *
5
+ * Generated entry modules embed absolute filesystem paths inside `import`
6
+ * statements. On Windows the OS-native paths use `\` which is invalid in JS
7
+ * module specifiers, so every entry generator normalizes paths through this
8
+ * helper before stringifying them into the emitted code.
9
+ */
10
+ function normalizePathSeparators(p) {
11
+ return p.replace(/\\/g, "/");
12
+ }
13
+ //#endregion
14
+ export { normalizePathSeparators };
15
+
16
+ //# sourceMappingURL=path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.js","names":[],"sources":["../../src/utils/path.ts"],"sourcesContent":["/**\n * Convert Windows-style backslash path separators to forward slashes.\n *\n * Generated entry modules embed absolute filesystem paths inside `import`\n * statements. On Windows the OS-native paths use `\\` which is invalid in JS\n * module specifiers, so every entry generator normalizes paths through this\n * helper before stringifying them into the emitted code.\n */\nexport function normalizePathSeparators(p: string): string {\n return p.replace(/\\\\/g, \"/\");\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,wBAAwB,GAAmB;CACzD,OAAO,EAAE,QAAQ,OAAO,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vinext",
3
- "version": "0.0.53",
3
+ "version": "0.0.54",
4
4
  "description": "Run Next.js apps on Vite. Drop-in replacement for the next CLI.",
5
5
  "license": "MIT",
6
6
  "repository": {