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

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 (191) hide show
  1. package/README.md +13 -11
  2. package/bin/demiurge.mjs +30 -12
  3. package/dist/browser/file-router.d.ts +388 -5
  4. package/dist/browser/file-router.d.ts.map +1 -1
  5. package/dist/browser/focus.d.ts +20 -0
  6. package/dist/browser/focus.d.ts.map +1 -0
  7. package/dist/browser/index.d.ts +7 -1
  8. package/dist/browser/index.d.ts.map +1 -1
  9. package/dist/browser/mutation-action.d.ts +81 -0
  10. package/dist/browser/mutation-action.d.ts.map +1 -0
  11. package/dist/chunks/document-shell-CpJnFtSC.js +36 -0
  12. package/dist/chunks/document-shell-CpJnFtSC.js.map +1 -0
  13. package/dist/chunks/env-startup-DOBYWlZD.js +257 -0
  14. package/dist/chunks/env-startup-DOBYWlZD.js.map +1 -0
  15. package/dist/chunks/{image-codec-Di53WpcH.js → image-codec-BmzWnH6W.js} +2 -2
  16. package/dist/chunks/{image-codec-Di53WpcH.js.map → image-codec-BmzWnH6W.js.map} +1 -1
  17. package/dist/chunks/{images-Edar3eU1.js → images-BQ80950B.js} +99 -91
  18. package/dist/chunks/images-BQ80950B.js.map +1 -0
  19. package/dist/chunks/index-BVk9zWbe.js +832 -0
  20. package/dist/chunks/index-BVk9zWbe.js.map +1 -0
  21. package/dist/chunks/manifest-vO6c0G0W.js +19 -0
  22. package/dist/chunks/manifest-vO6c0G0W.js.map +1 -0
  23. package/dist/chunks/plugin-BQgMiHxa.js +1827 -0
  24. package/dist/chunks/plugin-BQgMiHxa.js.map +1 -0
  25. package/dist/chunks/session-store-ChModVcq.js +92 -0
  26. package/dist/chunks/session-store-ChModVcq.js.map +1 -0
  27. package/dist/chunks/static-files-ehaD1kE7.js +51 -0
  28. package/dist/chunks/static-files-ehaD1kE7.js.map +1 -0
  29. package/dist/chunks/{streaming-D0fGAuiO.js → streaming-BEbPN7Uk.js} +163 -163
  30. package/dist/chunks/streaming-BEbPN7Uk.js.map +1 -0
  31. package/dist/chunks/testing-DueXbMo4.js +4167 -0
  32. package/dist/chunks/testing-DueXbMo4.js.map +1 -0
  33. package/dist/chunks/vite-DO70kZA6.js +259 -0
  34. package/dist/chunks/vite-DO70kZA6.js.map +1 -0
  35. package/dist/cli.d.ts +17 -25
  36. package/dist/cli.d.ts.map +1 -1
  37. package/dist/cli.js +159 -124
  38. package/dist/cli.js.map +1 -1
  39. package/dist/config/define.d.ts +3 -0
  40. package/dist/config/define.d.ts.map +1 -0
  41. package/dist/config/index.d.ts +7 -0
  42. package/dist/config/index.d.ts.map +1 -0
  43. package/dist/config/index.js +78 -0
  44. package/dist/config/index.js.map +1 -0
  45. package/dist/config/load.d.ts +12 -0
  46. package/dist/config/load.d.ts.map +1 -0
  47. package/dist/config/types.d.ts +64 -0
  48. package/dist/config/types.d.ts.map +1 -0
  49. package/dist/config/validate.d.ts +9 -0
  50. package/dist/config/validate.d.ts.map +1 -0
  51. package/dist/config/vite.d.ts +12 -0
  52. package/dist/config/vite.d.ts.map +1 -0
  53. package/dist/data/cache.d.ts +2 -0
  54. package/dist/data/cache.d.ts.map +1 -1
  55. package/dist/data/idempotency.d.ts.map +1 -1
  56. package/dist/deployment/testing.d.ts +25 -0
  57. package/dist/deployment/testing.d.ts.map +1 -0
  58. package/dist/deployment/testing.js +171 -0
  59. package/dist/deployment/testing.js.map +1 -0
  60. package/dist/document/hydration.d.ts +9 -0
  61. package/dist/document/hydration.d.ts.map +1 -1
  62. package/dist/document/index.d.ts +4 -2
  63. package/dist/document/index.d.ts.map +1 -1
  64. package/dist/document/metadata.d.ts +8 -0
  65. package/dist/document/metadata.d.ts.map +1 -1
  66. package/dist/document/navigation.d.ts +28 -0
  67. package/dist/document/navigation.d.ts.map +1 -0
  68. package/dist/document/render.d.ts +3 -1
  69. package/dist/document/render.d.ts.map +1 -1
  70. package/dist/document/seo.d.ts.map +1 -1
  71. package/dist/edge/assets.d.ts.map +1 -1
  72. package/dist/edge/index.js +55 -73
  73. package/dist/edge/index.js.map +1 -1
  74. package/dist/index.d.ts +12 -10
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +1860 -691
  77. package/dist/index.js.map +1 -1
  78. package/dist/internal/testing.js +12 -12
  79. package/dist/kv/index.d.ts +2 -0
  80. package/dist/kv/index.d.ts.map +1 -1
  81. package/dist/kv/index.js +170 -73
  82. package/dist/kv/index.js.map +1 -1
  83. package/dist/kv/session-store.d.ts +20 -0
  84. package/dist/kv/session-store.d.ts.map +1 -0
  85. package/dist/manifest.d.ts +10 -0
  86. package/dist/manifest.d.ts.map +1 -0
  87. package/dist/node/image.d.ts.map +1 -1
  88. package/dist/node/index.d.ts +3 -0
  89. package/dist/node/index.d.ts.map +1 -1
  90. package/dist/node/index.js +251 -178
  91. package/dist/node/index.js.map +1 -1
  92. package/dist/node/serve.d.ts +47 -0
  93. package/dist/node/serve.d.ts.map +1 -0
  94. package/dist/node/static.d.ts.map +1 -1
  95. package/dist/platform/fonts.d.ts.map +1 -1
  96. package/dist/platform/image-url.d.ts.map +1 -1
  97. package/dist/platform/url.d.ts +19 -0
  98. package/dist/platform/url.d.ts.map +1 -0
  99. package/dist/platform/web-vitals.d.ts.map +1 -1
  100. package/dist/redis/index.d.ts +2 -0
  101. package/dist/redis/index.d.ts.map +1 -1
  102. package/dist/redis/index.js +186 -69
  103. package/dist/redis/index.js.map +1 -1
  104. package/dist/redis/session-store.d.ts +9 -0
  105. package/dist/redis/session-store.d.ts.map +1 -0
  106. package/dist/route/index.d.ts +2 -2
  107. package/dist/route/index.d.ts.map +1 -1
  108. package/dist/route/mutation.d.ts +97 -0
  109. package/dist/route/mutation.d.ts.map +1 -0
  110. package/dist/route/types.d.ts +6 -1
  111. package/dist/route/types.d.ts.map +1 -1
  112. package/dist/router/manifest.d.ts +8 -0
  113. package/dist/router/manifest.d.ts.map +1 -1
  114. package/dist/router/navigation-data.d.ts +9 -1
  115. package/dist/router/navigation-data.d.ts.map +1 -1
  116. package/dist/routing/generate.d.ts +3 -0
  117. package/dist/routing/generate.d.ts.map +1 -1
  118. package/dist/routing/index.d.ts +3 -1
  119. package/dist/routing/index.d.ts.map +1 -1
  120. package/dist/routing/locale.d.ts +43 -0
  121. package/dist/routing/locale.d.ts.map +1 -0
  122. package/dist/routing/types.d.ts +12 -0
  123. package/dist/routing/types.d.ts.map +1 -1
  124. package/dist/security/cookie-session.d.ts +43 -0
  125. package/dist/security/cookie-session.d.ts.map +1 -0
  126. package/dist/security/csrf.d.ts +1 -1
  127. package/dist/security/csrf.d.ts.map +1 -1
  128. package/dist/security/env-startup.d.ts +15 -0
  129. package/dist/security/env-startup.d.ts.map +1 -0
  130. package/dist/security/env.d.ts +25 -6
  131. package/dist/security/env.d.ts.map +1 -1
  132. package/dist/security/index.d.ts +9 -1
  133. package/dist/security/index.d.ts.map +1 -1
  134. package/dist/security/report.d.ts.map +1 -1
  135. package/dist/security/session-manager.d.ts +32 -0
  136. package/dist/security/session-manager.d.ts.map +1 -0
  137. package/dist/security/session-store.d.ts +51 -0
  138. package/dist/security/session-store.d.ts.map +1 -0
  139. package/dist/security/testing.d.ts +10 -0
  140. package/dist/security/testing.d.ts.map +1 -0
  141. package/dist/security/testing.js +145 -0
  142. package/dist/security/testing.js.map +1 -0
  143. package/dist/security/types.d.ts +1 -0
  144. package/dist/security/types.d.ts.map +1 -1
  145. package/dist/server/document-shell.d.ts.map +1 -1
  146. package/dist/server/errors.d.ts +1 -0
  147. package/dist/server/errors.d.ts.map +1 -1
  148. package/dist/server/index.d.ts +1 -0
  149. package/dist/server/index.d.ts.map +1 -1
  150. package/dist/server/not-found.d.ts +1 -0
  151. package/dist/server/not-found.d.ts.map +1 -1
  152. package/dist/server/render-tree.d.ts.map +1 -1
  153. package/dist/server/request-handler.d.ts +4 -0
  154. package/dist/server/request-handler.d.ts.map +1 -1
  155. package/dist/server/request-metadata.d.ts +1 -0
  156. package/dist/server/request-metadata.d.ts.map +1 -1
  157. package/dist/server/ssr.d.ts +2 -0
  158. package/dist/server/ssr.d.ts.map +1 -1
  159. package/dist/static/index.d.ts +2 -0
  160. package/dist/static/index.d.ts.map +1 -1
  161. package/dist/static/index.js +380 -363
  162. package/dist/static/index.js.map +1 -1
  163. package/dist/static/preview.d.ts.map +1 -1
  164. package/dist/static/vercel.d.ts +11 -2
  165. package/dist/static/vercel.d.ts.map +1 -1
  166. package/dist/static-files.d.ts +12 -0
  167. package/dist/static-files.d.ts.map +1 -1
  168. package/dist/type-guards.d.ts +19 -0
  169. package/dist/type-guards.d.ts.map +1 -0
  170. package/dist/vite/env-boundary.d.ts +14 -0
  171. package/dist/vite/env-boundary.d.ts.map +1 -0
  172. package/dist/vite/index.d.ts +5 -3
  173. package/dist/vite/index.d.ts.map +1 -1
  174. package/dist/vite/index.js +22 -1560
  175. package/dist/vite/index.js.map +1 -1
  176. package/dist/vite/plugin.d.ts +6 -1
  177. package/dist/vite/plugin.d.ts.map +1 -1
  178. package/dist/vite/policy-verification.d.ts.map +1 -1
  179. package/package.json +19 -6
  180. package/dist/chunks/document-shell-WoM8yZlR.js +0 -35
  181. package/dist/chunks/document-shell-WoM8yZlR.js.map +0 -1
  182. package/dist/chunks/images-Edar3eU1.js.map +0 -1
  183. package/dist/chunks/request-metadata-DaIYq4Ea.js +0 -677
  184. package/dist/chunks/request-metadata-DaIYq4Ea.js.map +0 -1
  185. package/dist/chunks/static-files-DUjHw-4H.js +0 -11
  186. package/dist/chunks/static-files-DUjHw-4H.js.map +0 -1
  187. package/dist/chunks/streaming-D0fGAuiO.js.map +0 -1
  188. package/dist/chunks/testing-CRflAw4X.js +0 -3475
  189. package/dist/chunks/testing-CRflAw4X.js.map +0 -1
  190. package/dist/route/action.d.ts +0 -33
  191. package/dist/route/action.d.ts.map +0 -1
@@ -1,677 +0,0 @@
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