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