@demiurgejs/core 0.2.0-beta.1 → 0.2.0-beta.3

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 (156) hide show
  1. package/README.md +2 -0
  2. package/dist/adapter/testing.d.ts +33 -0
  3. package/dist/adapter/testing.d.ts.map +1 -0
  4. package/dist/adapter/testing.js +251 -0
  5. package/dist/adapter/testing.js.map +1 -0
  6. package/dist/browser/file-router.d.ts.map +1 -1
  7. package/dist/chunks/document-shell-WoM8yZlR.js +35 -0
  8. package/dist/chunks/document-shell-WoM8yZlR.js.map +1 -0
  9. package/dist/chunks/image-codec-Di53WpcH.js +141 -0
  10. package/dist/chunks/image-codec-Di53WpcH.js.map +1 -0
  11. package/dist/chunks/images-Edar3eU1.js +339 -0
  12. package/dist/chunks/images-Edar3eU1.js.map +1 -0
  13. package/dist/chunks/request-metadata-DaIYq4Ea.js +677 -0
  14. package/dist/chunks/request-metadata-DaIYq4Ea.js.map +1 -0
  15. package/dist/chunks/streaming-D0fGAuiO.js +469 -0
  16. package/dist/chunks/streaming-D0fGAuiO.js.map +1 -0
  17. package/dist/chunks/{testing-DBjVCN5v.js → testing-CRflAw4X.js} +1300 -1139
  18. package/dist/chunks/testing-CRflAw4X.js.map +1 -0
  19. package/dist/cli.d.ts.map +1 -1
  20. package/dist/cli.js +63 -54
  21. package/dist/cli.js.map +1 -1
  22. package/dist/data/cache.d.ts +8 -0
  23. package/dist/data/cache.d.ts.map +1 -1
  24. package/dist/data/idempotency.d.ts.map +1 -1
  25. package/dist/data/index.d.ts +3 -1
  26. package/dist/data/index.d.ts.map +1 -1
  27. package/dist/data/testing.d.ts.map +1 -1
  28. package/dist/data/testing.js +94 -72
  29. package/dist/data/testing.js.map +1 -1
  30. package/dist/data/tiered.d.ts +7 -0
  31. package/dist/data/tiered.d.ts.map +1 -0
  32. package/dist/document/deferred-scripts.d.ts +11 -0
  33. package/dist/document/deferred-scripts.d.ts.map +1 -0
  34. package/dist/document/hydration.d.ts.map +1 -1
  35. package/dist/document/index.d.ts +4 -1
  36. package/dist/document/index.d.ts.map +1 -1
  37. package/dist/document/render.d.ts.map +1 -1
  38. package/dist/document/scripts.d.ts +12 -1
  39. package/dist/document/scripts.d.ts.map +1 -1
  40. package/dist/document/trusted-types.d.ts +10 -0
  41. package/dist/document/trusted-types.d.ts.map +1 -0
  42. package/dist/edge/assets.d.ts +14 -0
  43. package/dist/edge/assets.d.ts.map +1 -0
  44. package/dist/edge/index.d.ts +19 -0
  45. package/dist/edge/index.d.ts.map +1 -0
  46. package/dist/edge/index.js +286 -0
  47. package/dist/edge/index.js.map +1 -0
  48. package/dist/edge/stores.d.ts +8 -0
  49. package/dist/edge/stores.d.ts.map +1 -0
  50. package/dist/edge/streaming.d.ts +7 -0
  51. package/dist/edge/streaming.d.ts.map +1 -0
  52. package/dist/index.d.ts +7 -7
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +895 -556
  55. package/dist/index.js.map +1 -1
  56. package/dist/internal/testing.js +6 -6
  57. package/dist/kv/index.d.ts +5 -0
  58. package/dist/kv/index.d.ts.map +1 -0
  59. package/dist/kv/index.js +126 -0
  60. package/dist/kv/index.js.map +1 -0
  61. package/dist/kv/rate-limit-store.d.ts +8 -0
  62. package/dist/kv/rate-limit-store.d.ts.map +1 -0
  63. package/dist/kv/store.d.ts +28 -0
  64. package/dist/kv/store.d.ts.map +1 -0
  65. package/dist/node/font.d.ts +5 -0
  66. package/dist/node/font.d.ts.map +1 -0
  67. package/dist/node/http.d.ts.map +1 -1
  68. package/dist/node/image.d.ts +15 -0
  69. package/dist/node/image.d.ts.map +1 -0
  70. package/dist/node/index.d.ts +4 -0
  71. package/dist/node/index.d.ts.map +1 -1
  72. package/dist/node/index.js +25 -23
  73. package/dist/node/index.js.map +1 -1
  74. package/dist/node/static.d.ts.map +1 -1
  75. package/dist/node/streaming.d.ts.map +1 -1
  76. package/dist/platform/analytics.d.ts +58 -5
  77. package/dist/platform/analytics.d.ts.map +1 -1
  78. package/dist/platform/font-assets.d.ts +19 -0
  79. package/dist/platform/font-assets.d.ts.map +1 -0
  80. package/dist/platform/fonts.d.ts +14 -4
  81. package/dist/platform/fonts.d.ts.map +1 -1
  82. package/dist/platform/image-codec.d.ts +15 -0
  83. package/dist/platform/image-codec.d.ts.map +1 -0
  84. package/dist/platform/image-url.d.ts +17 -0
  85. package/dist/platform/image-url.d.ts.map +1 -0
  86. package/dist/platform/image.d.ts +8 -0
  87. package/dist/platform/image.d.ts.map +1 -0
  88. package/dist/platform/images.d.ts +15 -0
  89. package/dist/platform/images.d.ts.map +1 -1
  90. package/dist/platform/index.d.ts +13 -6
  91. package/dist/platform/index.d.ts.map +1 -1
  92. package/dist/platform/observability.d.ts +2 -1
  93. package/dist/platform/observability.d.ts.map +1 -1
  94. package/dist/platform/web-vitals-client.d.ts +32 -0
  95. package/dist/platform/web-vitals-client.d.ts.map +1 -0
  96. package/dist/platform/web-vitals.d.ts +78 -0
  97. package/dist/platform/web-vitals.d.ts.map +1 -0
  98. package/dist/redis/index.d.ts +5 -0
  99. package/dist/redis/index.d.ts.map +1 -0
  100. package/dist/redis/index.js +209 -0
  101. package/dist/redis/index.js.map +1 -0
  102. package/dist/redis/rate-limit-store.d.ts +8 -0
  103. package/dist/redis/rate-limit-store.d.ts.map +1 -0
  104. package/dist/redis/store.d.ts +8 -0
  105. package/dist/redis/store.d.ts.map +1 -0
  106. package/dist/route/action.d.ts.map +1 -1
  107. package/dist/route/middleware.d.ts.map +1 -1
  108. package/dist/route/response.d.ts.map +1 -1
  109. package/dist/router/index.d.ts +1 -1
  110. package/dist/router/index.d.ts.map +1 -1
  111. package/dist/router/manifest.d.ts +1 -0
  112. package/dist/router/manifest.d.ts.map +1 -1
  113. package/dist/security/cookies.d.ts +26 -0
  114. package/dist/security/cookies.d.ts.map +1 -0
  115. package/dist/security/env.d.ts.map +1 -1
  116. package/dist/security/fetch-metadata.d.ts +29 -0
  117. package/dist/security/fetch-metadata.d.ts.map +1 -0
  118. package/dist/security/index.d.ts +5 -1
  119. package/dist/security/index.d.ts.map +1 -1
  120. package/dist/security/policy.d.ts +2 -27
  121. package/dist/security/policy.d.ts.map +1 -1
  122. package/dist/security/rate-limit.d.ts +6 -3
  123. package/dist/security/rate-limit.d.ts.map +1 -1
  124. package/dist/security/request.d.ts.map +1 -1
  125. package/dist/security/types.d.ts +82 -6
  126. package/dist/security/types.d.ts.map +1 -1
  127. package/dist/security/verification.d.ts.map +1 -1
  128. package/dist/server/document-shell.d.ts +12 -0
  129. package/dist/server/document-shell.d.ts.map +1 -0
  130. package/dist/server/index.d.ts +1 -1
  131. package/dist/server/index.d.ts.map +1 -1
  132. package/dist/server/request-handler.d.ts +6 -2
  133. package/dist/server/request-handler.d.ts.map +1 -1
  134. package/dist/static/images.d.ts +13 -0
  135. package/dist/static/images.d.ts.map +1 -0
  136. package/dist/static/index.d.ts +8 -0
  137. package/dist/static/index.d.ts.map +1 -1
  138. package/dist/static/index.js +421 -313
  139. package/dist/static/index.js.map +1 -1
  140. package/dist/static/vercel.d.ts +3 -0
  141. package/dist/static/vercel.d.ts.map +1 -1
  142. package/dist/vite/index.d.ts +3 -0
  143. package/dist/vite/index.d.ts.map +1 -1
  144. package/dist/vite/index.js +1041 -652
  145. package/dist/vite/index.js.map +1 -1
  146. package/dist/vite/plugin.d.ts +9 -0
  147. package/dist/vite/plugin.d.ts.map +1 -1
  148. package/dist/vite/policy-verification.d.ts.map +1 -1
  149. package/dist/vite/route-audit.d.ts +50 -0
  150. package/dist/vite/route-audit.d.ts.map +1 -0
  151. package/package.json +34 -3
  152. package/dist/chunks/request-metadata-DwEO1EAS.js +0 -477
  153. package/dist/chunks/request-metadata-DwEO1EAS.js.map +0 -1
  154. package/dist/chunks/streaming-Ci6vf3BB.js +0 -353
  155. package/dist/chunks/streaming-Ci6vf3BB.js.map +0 -1
  156. package/dist/chunks/testing-DBjVCN5v.js.map +0 -1
@@ -0,0 +1,677 @@
1
+ import { renderToString as q } from "react-dom/server";
2
+ import { createContext as J, useContext as j, useEffect as G, createElement as f } from "react";
3
+ const W = {
4
+ backgroundLifetime: !1,
5
+ crossOriginIsolationHeaders: !1,
6
+ nonceInjection: !1,
7
+ sharedCache: !1,
8
+ staticOutput: !1,
9
+ streaming: !1,
10
+ webSocket: !1,
11
+ webTransport: !1
12
+ };
13
+ function Ue(e) {
14
+ return {
15
+ capabilities: {
16
+ ...W,
17
+ ...e.capabilities
18
+ },
19
+ name: e.name
20
+ };
21
+ }
22
+ function H(e, t) {
23
+ const r = [...new Set(t)], n = r.filter(
24
+ (o) => !e.capabilities[o]
25
+ );
26
+ return {
27
+ adapter: e.name,
28
+ missing: n,
29
+ ok: n.length === 0,
30
+ required: r
31
+ };
32
+ }
33
+ function Me(e, t) {
34
+ const r = H(e, t);
35
+ if (!r.ok)
36
+ throw new Error(
37
+ `Adapter "${e.name}" does not support required capabilities: ${r.missing.join(", ")}.`
38
+ );
39
+ return r;
40
+ }
41
+ const x = "__demiurge_data", Y = "data-demiurge-hydrate", K = "data-demiurge-fallback";
42
+ function z(e, t = {}) {
43
+ return V(
44
+ JSON.stringify({ data: e, hasData: !0, ...t })
45
+ );
46
+ }
47
+ function Be(e) {
48
+ const t = e.getElementById(x), r = t?.tagName === "TEMPLATE" ? t.content.textContent : t?.textContent;
49
+ if (r)
50
+ try {
51
+ return JSON.parse(r);
52
+ } catch (n) {
53
+ throw new Error(
54
+ "Demiurge could not parse the initial route data payload.",
55
+ { cause: n }
56
+ );
57
+ }
58
+ }
59
+ function V(e) {
60
+ return e.replace(/&/g, "\\u0026").replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
61
+ }
62
+ const E = "demiurge", k = /* @__PURE__ */ new WeakMap();
63
+ function T(e, t) {
64
+ return Q(e)?.createScriptURL(t) ?? t;
65
+ }
66
+ function Q(e) {
67
+ if (!e)
68
+ return null;
69
+ const t = k.get(e);
70
+ if (t !== void 0)
71
+ return t;
72
+ const r = X(e);
73
+ return k.set(e, r), r;
74
+ }
75
+ function X(e) {
76
+ const t = e.trustedTypes;
77
+ if (!t || typeof t.createPolicy != "function")
78
+ return null;
79
+ try {
80
+ return t.createPolicy(E, {
81
+ // The framework passes only a URL that the server rendered into its own
82
+ // placeholder attribute. `script-src` and `worker-src` still govern that
83
+ // URL, so this policy adds a type without widening the source rules.
84
+ createScriptURL: (r) => r
85
+ });
86
+ } catch (r) {
87
+ return console.error(
88
+ `Demiurge could not create the ${JSON.stringify(E)} Trusted Types policy. Add ${JSON.stringify(E)} to the document trusted-types directive.`,
89
+ r
90
+ ), null;
91
+ }
92
+ }
93
+ const U = "text/demiurge-script", p = "data-demiurge-script", y = "data-demiurge-script-src", h = "data-demiurge-script-type", D = "data-demiurge-script-started", Z = 2e3, ee = [
94
+ "data-api",
95
+ "data-demiurge-script-placement",
96
+ "data-domain",
97
+ "id",
98
+ "integrity",
99
+ "referrerpolicy"
100
+ ], M = /* @__PURE__ */ new Map();
101
+ function R(e) {
102
+ return e === "idle" || e === "worker";
103
+ }
104
+ function te(e) {
105
+ const t = e ?? (typeof document > "u" ? void 0 : document);
106
+ if (!t)
107
+ return;
108
+ const r = t.querySelectorAll(
109
+ `script[${p}]:not([${D}])`
110
+ );
111
+ for (const n of [...r]) {
112
+ const o = n.getAttribute(p);
113
+ if (!(o !== "idle" && o !== "worker")) {
114
+ if (n.setAttribute(D, ""), o === "worker") {
115
+ oe(n);
116
+ continue;
117
+ }
118
+ re(n, () => ne(n));
119
+ }
120
+ }
121
+ }
122
+ function Fe(e) {
123
+ return M.get(e);
124
+ }
125
+ function re(e, t) {
126
+ const r = e.ownerDocument.defaultView;
127
+ if (r && typeof r.requestIdleCallback == "function") {
128
+ r.requestIdleCallback(() => t(), { timeout: Z });
129
+ return;
130
+ }
131
+ (r ?? globalThis).setTimeout(t, 1);
132
+ }
133
+ function ne(e) {
134
+ const t = e.ownerDocument, r = e.getAttribute(y);
135
+ if (!r)
136
+ return;
137
+ const n = t.createElement("script"), o = e.getAttribute(h);
138
+ for (const s of ee) {
139
+ const c = e.getAttribute(s);
140
+ c !== null && n.setAttribute(s, c);
141
+ }
142
+ e.removeAttribute("id"), o && (n.type = o), n.async = !0, n.nonce = e.nonce, n.src = T(t.defaultView, r), t.head.appendChild(n);
143
+ }
144
+ function oe(e) {
145
+ const t = e.getAttribute(y), r = e.ownerDocument.defaultView;
146
+ if (!t)
147
+ return;
148
+ if (!r || typeof r.Worker != "function") {
149
+ console.error(
150
+ `Demiurge could not start the worker script ${JSON.stringify(t)}. This runtime has no Worker constructor.`
151
+ );
152
+ return;
153
+ }
154
+ const n = e.getAttribute(h);
155
+ try {
156
+ M.set(
157
+ t,
158
+ new r.Worker(T(r, t), {
159
+ type: n === "module" ? "module" : "classic"
160
+ })
161
+ );
162
+ } catch (o) {
163
+ console.error(
164
+ `Demiurge could not start the worker script ${JSON.stringify(t)}.`,
165
+ o
166
+ );
167
+ }
168
+ }
169
+ const ie = /* @__PURE__ */ new Set([
170
+ "afterInteractive",
171
+ "beforeInteractive",
172
+ "idle",
173
+ "module",
174
+ "worker"
175
+ ]), a = Symbol("demiurge.scriptPlacement"), B = J(
176
+ void 0
177
+ );
178
+ function ce(e = {}) {
179
+ let t = !1;
180
+ const r = [...e.scripts ?? []], n = new Set(r.map((c) => c.src)), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
181
+ return {
182
+ get dev() {
183
+ return e.dev ?? !1;
184
+ },
185
+ get headFlushed() {
186
+ return t;
187
+ },
188
+ flushHead() {
189
+ t = !0;
190
+ },
191
+ nonce: e.nonce,
192
+ register(c) {
193
+ if (n.has(c.src) || o.has(c.src))
194
+ return "skip";
195
+ if (o.add(c.src), !t)
196
+ return s.set(c.src, {
197
+ ...c,
198
+ [a]: "hoisted"
199
+ }), "hoist";
200
+ if (c.strategy === "beforeInteractive" && (e.dev ?? !1))
201
+ throw new Error(
202
+ `A render-discovered beforeInteractive script ${JSON.stringify(c.src)} was found after the document head flushed. Declare it in export const scripts.`
203
+ );
204
+ return "render";
205
+ },
206
+ scripts() {
207
+ return F([...r, ...s.values()]);
208
+ }
209
+ };
210
+ }
211
+ function Le(e) {
212
+ const t = j(B), r = ae(e);
213
+ if (G(() => {
214
+ R(r.strategy) && te();
215
+ }), !t) {
216
+ if (typeof document > "u")
217
+ throw new Error(
218
+ `The script ${JSON.stringify(r.src)} rendered outside a Demiurge document render context. A server render must wrap its component tree with the script render context.`
219
+ );
220
+ return se(r.src) ? null : v({
221
+ ...r,
222
+ [a]: "in-place"
223
+ }, ue());
224
+ }
225
+ return t.register(r) !== "render" ? null : v({
226
+ ...r,
227
+ [a]: "in-place"
228
+ }, t.nonce);
229
+ }
230
+ function v(e, t) {
231
+ return R(e.strategy) ? f("script", {
232
+ "data-api": e.dataApi,
233
+ [p]: e.strategy,
234
+ "data-demiurge-script-placement": e[a],
235
+ [y]: e.src,
236
+ [h]: e.type,
237
+ "data-domain": e.dataDomain,
238
+ id: e.id,
239
+ integrity: e.integrity,
240
+ nonce: e.nonce ?? t,
241
+ referrerPolicy: e.referrerPolicy,
242
+ type: U
243
+ }) : f("script", {
244
+ async: e.async,
245
+ crossOrigin: e.crossOrigin,
246
+ "data-api": e.dataApi,
247
+ "data-domain": e.dataDomain,
248
+ "data-demiurge-script-placement": e[a],
249
+ defer: e.defer,
250
+ id: e.id,
251
+ integrity: e.integrity,
252
+ nonce: e.nonce ?? t,
253
+ referrerPolicy: e.referrerPolicy,
254
+ src: e.src,
255
+ type: e.type ?? pe(e.strategy)
256
+ });
257
+ }
258
+ function se(e) {
259
+ if (typeof document > "u")
260
+ return !1;
261
+ const t = new URL(e, document.baseURI).href;
262
+ return [...document.scripts].some(
263
+ (r) => r.src === t && r.dataset.demiurgeScriptPlacement !== "in-place"
264
+ );
265
+ }
266
+ function ue() {
267
+ if (!(typeof document > "u"))
268
+ return [...document.scripts].reverse().find((e) => e.nonce)?.nonce;
269
+ }
270
+ function Ne(e) {
271
+ return e;
272
+ }
273
+ function ae(e) {
274
+ const t = e.strategy ?? "afterInteractive";
275
+ if (!ie.has(t))
276
+ throw new Error(
277
+ `Unsupported script strategy ${JSON.stringify(t)}. Demiurge supports "beforeInteractive", "module", "afterInteractive", "idle", and "worker".`
278
+ );
279
+ if (t === "module" && e.type && e.type !== "module")
280
+ throw new Error(
281
+ 'The "module" script strategy cannot be combined with type="text/javascript".'
282
+ );
283
+ if (t === "worker" && (e.async || e.defer))
284
+ throw new Error(
285
+ 'The "worker" script strategy runs off the main thread, so it cannot be combined with async or defer.'
286
+ );
287
+ return {
288
+ ...e,
289
+ kind: "script",
290
+ strategy: t
291
+ };
292
+ }
293
+ function de(e, t) {
294
+ return f(B.Provider, { value: e, children: t });
295
+ }
296
+ async function qe(e, t) {
297
+ const r = [];
298
+ for (const n of e) {
299
+ if (!n)
300
+ continue;
301
+ const o = typeof n == "function" ? await n(t) : n;
302
+ r.push(...o);
303
+ }
304
+ return F(le(r));
305
+ }
306
+ function le(e) {
307
+ const t = /* @__PURE__ */ new Map();
308
+ for (const r of e)
309
+ t.set(I(r), {
310
+ ...t.get(I(r)),
311
+ ...r
312
+ });
313
+ return [...t.values()];
314
+ }
315
+ function I(e) {
316
+ return [
317
+ e.src,
318
+ e.type ?? "",
319
+ e.integrity ?? "",
320
+ e.strategy
321
+ ].join("\0");
322
+ }
323
+ function fe(e, t) {
324
+ return C(e.strategy) - C(t.strategy) || e.src.localeCompare(t.src);
325
+ }
326
+ function F(e) {
327
+ return e.sort(fe);
328
+ }
329
+ function pe(e) {
330
+ return e === "module" ? "module" : void 0;
331
+ }
332
+ function C(e) {
333
+ return e === "beforeInteractive" ? 0 : e === "module" ? 1 : e === "afterInteractive" ? 2 : e === "idle" ? 3 : 4;
334
+ }
335
+ const me = "data-demiurge-structured-data";
336
+ function ye(e) {
337
+ if (e.body) {
338
+ const { html: t, ...r } = e.body, { prefix: n, suffix: o } = he({ ...e, body: r });
339
+ return `${n}${t}${o}`;
340
+ }
341
+ return $e(e);
342
+ }
343
+ function he({
344
+ body: e,
345
+ entrySrc: t,
346
+ lang: r = "en",
347
+ links: n = [],
348
+ metadata: o,
349
+ nonce: s,
350
+ scripts: c = [],
351
+ styles: $ = [],
352
+ title: S = "Demiurge App"
353
+ }) {
354
+ const w = o?.title ?? S, l = [
355
+ ...c.filter((g) => g[a] !== "hoisted").map((g) => ` ${b(g, s)}`),
356
+ ge(e.data, e.navigation),
357
+ ...t ? [L(t, s)] : []
358
+ ].join(`
359
+ `);
360
+ return {
361
+ prefix: `<!doctype html>
362
+ <html lang="${u(r)}">
363
+ <head>
364
+ ${N({ links: n, metadata: o, nonce: s, scripts: c, styles: $, title: w })}
365
+ </head>
366
+ <body>
367
+ ${we(e)}`,
368
+ suffix: `</div>
369
+ ${l}
370
+ </body>
371
+ </html>
372
+ `
373
+ };
374
+ }
375
+ function $e({
376
+ entrySrc: e,
377
+ lang: t = "en",
378
+ links: r = [],
379
+ metadata: n,
380
+ nonce: o,
381
+ scripts: s = [],
382
+ styles: c = [],
383
+ title: $ = "Demiurge App"
384
+ }) {
385
+ const S = n?.title ?? $, w = [
386
+ Se(),
387
+ ...s.filter((l) => l[a] !== "hoisted").map((l) => ` ${b(l, o)}`),
388
+ ...e ? [L(e, o)] : []
389
+ ].join(`
390
+ `);
391
+ return `<!doctype html>
392
+ <html lang="${u(t)}">
393
+ <head>
394
+ ${N({ links: r, metadata: n, nonce: o, scripts: s, styles: c, title: S })}
395
+ </head>
396
+ <body>
397
+ ${w}
398
+ </body>
399
+ </html>
400
+ `;
401
+ }
402
+ function Se(e) {
403
+ return ' <div id="root"></div>';
404
+ }
405
+ function we(e) {
406
+ const t = e.fallback ? ` ${K}="${u(e.fallback)}"` : "";
407
+ return ` <div id="root" ${Y}=""${t}>`;
408
+ }
409
+ function ge(e, t) {
410
+ return ` <template id="${x}">${z(e, { navigation: t })}</template>`;
411
+ }
412
+ function L(e, t) {
413
+ return ` <script type="module" src="${u(e)}"${i("nonce", t)}><\/script>`;
414
+ }
415
+ function N({
416
+ links: e,
417
+ metadata: t,
418
+ nonce: r,
419
+ scripts: n,
420
+ styles: o,
421
+ title: s
422
+ }) {
423
+ return [
424
+ d({
425
+ content: t?.charset ?? "UTF-8",
426
+ name: "charset"
427
+ }),
428
+ d({
429
+ content: t?.viewport ?? "width=device-width, initial-scale=1.0",
430
+ name: "viewport"
431
+ }),
432
+ ` <title>${u(s)}</title>`,
433
+ ...t?.description ? [
434
+ d({
435
+ content: t.description,
436
+ name: "description"
437
+ })
438
+ ] : [],
439
+ ...t?.canonical ? [
440
+ A({
441
+ href: t.canonical,
442
+ rel: "canonical"
443
+ })
444
+ ] : [],
445
+ ...Ee(t),
446
+ ...Ae(t),
447
+ ...(t?.custom ?? []).map(Re),
448
+ ...(t?.structuredData ?? []).map(
449
+ (c) => be(c, r)
450
+ ),
451
+ ...o.map(
452
+ (c) => ` <link rel="stylesheet" href="${u(c)}" />`
453
+ ),
454
+ ...e.map(A),
455
+ ...n.filter((c) => c[a] === "hoisted").map((c) => ` ${b(c, r)}`)
456
+ ].join(`
457
+ `);
458
+ }
459
+ function Ee(e) {
460
+ if (!e?.robots)
461
+ return [];
462
+ const t = [
463
+ e.robots.index === !1 ? "noindex" : "index",
464
+ e.robots.follow === !1 ? "nofollow" : "follow"
465
+ ];
466
+ return [
467
+ d({
468
+ content: t.join(", "),
469
+ name: "robots"
470
+ })
471
+ ];
472
+ }
473
+ function Ae(e) {
474
+ return e?.openGraph ? [
475
+ e.openGraph.title ? d({
476
+ content: e.openGraph.title,
477
+ property: "og:title"
478
+ }) : null,
479
+ e.openGraph.description ? d({
480
+ content: e.openGraph.description,
481
+ property: "og:description"
482
+ }) : null,
483
+ e.openGraph.image ? d({
484
+ content: e.openGraph.image,
485
+ property: "og:image"
486
+ }) : null
487
+ ].filter((t) => !!t) : [];
488
+ }
489
+ function Re(e) {
490
+ return e.kind === "link" ? A(e) : d(e);
491
+ }
492
+ function be(e, t) {
493
+ return ` <script type="application/ld+json"${t ? "" : ` ${me}`}${i("nonce", t)}>${ve(JSON.stringify(e.value))}<\/script>`;
494
+ }
495
+ function d(e) {
496
+ if (e.name === "charset")
497
+ return ` <meta charset="${u(e.content)}" />`;
498
+ const t = e.name ? ` name="${u(e.name)}"` : "", r = e.property ? ` property="${u(e.property)}"` : "";
499
+ return ` <meta${t}${r} content="${u(e.content)}" />`;
500
+ }
501
+ function A(e) {
502
+ return ` <link${i("rel", e.rel)}${i("href", e.href)}${i("as", e.as)}${i("type", e.type)}${i("crossorigin", e.crossOrigin)}${i("hreflang", e.hrefLang)} />`;
503
+ }
504
+ function b(e, t) {
505
+ return R(e.strategy) ? ke(e, t) : `<script${i("id", e.id)}${i("src", e.src)}${i("type", e.type ?? De(e.strategy))}${i("nonce", e.nonce ?? t)}${i("integrity", e.integrity)}${i("crossorigin", e.crossOrigin)}${i("referrerpolicy", e.referrerPolicy)}${i("data-api", e.dataApi)}${i("data-domain", e.dataDomain)}${i("data-demiurge-script-placement", e[a])}${P("async", e.async)}${P("defer", e.defer)}><\/script>`;
506
+ }
507
+ function ke(e, t) {
508
+ return `<script${i("id", e.id)}${i("type", U)}${i("nonce", e.nonce ?? t)}${i("integrity", e.integrity)}${i("crossorigin", e.crossOrigin)}${i("referrerpolicy", e.referrerPolicy)}${i("data-api", e.dataApi)}${i("data-domain", e.dataDomain)}${i(p, e.strategy)}${i(y, e.src)}${i(h, e.type)}${i("data-demiurge-script-placement", e[a])}><\/script>`;
509
+ }
510
+ function De(e) {
511
+ return e === "module" ? "module" : void 0;
512
+ }
513
+ function i(e, t) {
514
+ return t ? ` ${e}="${u(t)}"` : "";
515
+ }
516
+ function P(e, t) {
517
+ return t ? ` ${e}` : "";
518
+ }
519
+ function u(e) {
520
+ return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
521
+ }
522
+ function ve(e) {
523
+ return e.replaceAll("<", "\\u003c").replaceAll(">", "\\u003e").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029");
524
+ }
525
+ function Je(e) {
526
+ return e;
527
+ }
528
+ function je(e, t = {}) {
529
+ return {
530
+ ...t,
531
+ href: e,
532
+ kind: "link",
533
+ rel: "preconnect"
534
+ };
535
+ }
536
+ function Ge(e, t) {
537
+ return {
538
+ ...t,
539
+ href: e,
540
+ kind: "link",
541
+ rel: "preload"
542
+ };
543
+ }
544
+ function We(e) {
545
+ return {
546
+ href: e,
547
+ kind: "link",
548
+ rel: "modulepreload"
549
+ };
550
+ }
551
+ async function He(e, t) {
552
+ const r = [];
553
+ for (const n of e) {
554
+ if (!n)
555
+ continue;
556
+ const o = typeof n == "function" ? await n(t) : n;
557
+ r.push(...o);
558
+ }
559
+ return Ie(r).sort(Ce);
560
+ }
561
+ function Ie(e) {
562
+ const t = /* @__PURE__ */ new Map();
563
+ for (const r of e)
564
+ t.set(_(r), {
565
+ ...t.get(_(r)),
566
+ ...r
567
+ });
568
+ return [...t.values()];
569
+ }
570
+ function _(e) {
571
+ return [
572
+ e.rel,
573
+ e.href,
574
+ e.as ?? "",
575
+ e.type ?? "",
576
+ e.crossOrigin ?? ""
577
+ ].join("\0");
578
+ }
579
+ function Ce(e, t) {
580
+ return O(e.rel) - O(t.rel) || e.href.localeCompare(t.href);
581
+ }
582
+ function O(e) {
583
+ return e === "preconnect" ? 0 : e === "preload" ? 1 : e === "modulepreload" ? 2 : 3;
584
+ }
585
+ function Pe(e, t) {
586
+ const r = f(e.page, {
587
+ data: e.data,
588
+ path: e.path,
589
+ pathname: e.pathname
590
+ }), n = e.layouts.reduceRight(
591
+ (o, s) => f(s, {
592
+ children: o,
593
+ path: e.path,
594
+ pathname: e.pathname
595
+ }),
596
+ r
597
+ );
598
+ return t ? de(t, n) : n;
599
+ }
600
+ function _e(e, t = {}) {
601
+ return ce({
602
+ dev: t.dev,
603
+ nonce: t.nonce,
604
+ scripts: e.scripts
605
+ });
606
+ }
607
+ function Oe(e, t = {}) {
608
+ const r = _e(e, t), n = q(Pe(e, r));
609
+ return ye({
610
+ body: {
611
+ data: e.data,
612
+ html: n,
613
+ navigation: e.render.mode === "static" ? "document" : t.navigation
614
+ },
615
+ entrySrc: t.clientEntry,
616
+ lang: t.lang,
617
+ links: e.links,
618
+ metadata: e.metadata,
619
+ nonce: t.nonce,
620
+ scripts: r.scripts(),
621
+ styles: t.styles,
622
+ title: t.title
623
+ });
624
+ }
625
+ function Ye(e, t = {}) {
626
+ const r = Oe(e, t);
627
+ return new Response(r, {
628
+ headers: {
629
+ "content-type": "text/html; charset=utf-8"
630
+ }
631
+ });
632
+ }
633
+ const m = /* @__PURE__ */ new WeakMap();
634
+ function Ke(e) {
635
+ return m.get(e);
636
+ }
637
+ function ze(e, t) {
638
+ m.set(e, t);
639
+ }
640
+ function Ve(e, t) {
641
+ const r = m.get(e);
642
+ r && m.set(t, r);
643
+ }
644
+ export {
645
+ Ke as A,
646
+ Ve as B,
647
+ E as F,
648
+ Y as H,
649
+ me as S,
650
+ Ye as a,
651
+ Pe as b,
652
+ _e as c,
653
+ Ue as d,
654
+ ye as e,
655
+ Oe as f,
656
+ Be as g,
657
+ te as h,
658
+ K as i,
659
+ ae as j,
660
+ Le as k,
661
+ Me as l,
662
+ H as m,
663
+ T as n,
664
+ Je as o,
665
+ Ge as p,
666
+ Ne as q,
667
+ he as r,
668
+ ze as s,
669
+ Fe as t,
670
+ We as u,
671
+ je as v,
672
+ He as w,
673
+ qe as x,
674
+ ce as y,
675
+ de as z
676
+ };
677
+ //# sourceMappingURL=request-metadata-DaIYq4Ea.js.map