@demiurgejs/core 0.1.0 → 0.1.1

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.
@@ -1,4 +1,4 @@
1
- import { g as mt, h as ht, b as Le, r as pt } from "./ssr-O3d7Q73U.js";
1
+ import { g as mt, h as ht, b as Le, r as pt } from "./ssr-BJejKlkZ.js";
2
2
  import { createElement as ee } from "react";
3
3
  import { renderToString as He } from "react-dom/server";
4
4
  import { jsxs as N, jsx as $ } from "react/jsx-runtime";
@@ -557,14 +557,14 @@ function qt(e, t) {
557
557
  });
558
558
  }
559
559
  function Wt(e) {
560
- return e.map(Bt).join(", ");
560
+ return e.map(Gt).join(", ");
561
561
  }
562
562
  function S(e) {
563
563
  if (e)
564
564
  return Array.isArray(e) ? e : [e];
565
565
  }
566
- function Bt(e) {
567
- if (!Gt(e.name))
566
+ function Gt(e) {
567
+ if (!Bt(e.name))
568
568
  throw new Error(
569
569
  `Server-Timing metric name "${e.name}" is not a valid token.`
570
570
  );
@@ -576,7 +576,7 @@ function Bt(e) {
576
576
  }
577
577
  return e.description !== void 0 && t.push(`desc="${Vt(e.description)}"`), t.join(";");
578
578
  }
579
- function Gt(e) {
579
+ function Bt(e) {
580
580
  return /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(e);
581
581
  }
582
582
  function _t(e) {
@@ -1242,7 +1242,7 @@ async function qe(e, t, r = new Request(`http://demiurge.local${t}`), n, s = ae(
1242
1242
  status: "not-found"
1243
1243
  };
1244
1244
  const c = e.layouts.filter(
1245
- (f) => B(f.fileSegments, a.route.fileSegments)
1245
+ (f) => G(f.fileSegments, a.route.fileSegments)
1246
1246
  ), u = await a.route.load();
1247
1247
  if (!u.GET || u.GET.kind !== "page")
1248
1248
  return {
@@ -1297,42 +1297,42 @@ async function qe(e, t, r = new Request(`http://demiurge.local${t}`), n, s = ae(
1297
1297
  }
1298
1298
  };
1299
1299
  }
1300
- async function $s(e) {
1301
- const t = ae(), r = [];
1302
- for (const n of e.routes) {
1303
- const s = await n.load();
1304
- if (!s.GET || s.GET.kind !== "page")
1300
+ async function $s(e, t = {}) {
1301
+ const r = ae(), n = [];
1302
+ for (const s of e.routes) {
1303
+ const o = await s.load();
1304
+ if (!o.GET || o.GET.kind !== "page" && !t.includeResources)
1305
1305
  continue;
1306
- if (s.GET.render.mode !== "static")
1306
+ if (o.GET.kind === "page" && o.GET.render.mode !== "static")
1307
1307
  throw new Error(
1308
- `Page route "${n.file}" uses render mode "${s.GET.render.mode}" and cannot be emitted as static output. Set render: { mode: "static" } or deploy a runtime adapter.`
1308
+ `Page route "${s.file}" uses render mode "${o.GET.render.mode}" and cannot be emitted as static output. Set render: { mode: "static" } or deploy a runtime adapter.`
1309
1309
  );
1310
- const o = Er(n.segments);
1311
- if (br(n.segments).length === 0) {
1312
- r.push({
1313
- file: n.file,
1310
+ const i = Er(s.segments);
1311
+ if (br(s.segments).length === 0) {
1312
+ n.push({
1313
+ file: s.file,
1314
1314
  path: {},
1315
- pattern: o,
1316
- pathname: o
1315
+ pattern: i,
1316
+ pathname: i
1317
1317
  });
1318
1318
  continue;
1319
1319
  }
1320
- if (!s.paths)
1320
+ if (!o.paths)
1321
1321
  throw new Error(
1322
- `Dynamic static route "${n.file}" must export paths for "${o}".`
1322
+ `Dynamic static route "${s.file}" must export paths for "${i}".`
1323
1323
  );
1324
- const a = await s.paths({ cache: t });
1325
- for (const c of a) {
1326
- const u = Tr(n, o, c);
1327
- r.push({
1328
- file: n.file,
1329
- path: u,
1330
- pattern: o,
1331
- pathname: xr(n.segments, u)
1324
+ const c = await o.paths({ cache: r });
1325
+ for (const u of c) {
1326
+ const l = Tr(s, i, u);
1327
+ n.push({
1328
+ file: s.file,
1329
+ path: l,
1330
+ pattern: i,
1331
+ pathname: xr(s.segments, l)
1332
1332
  });
1333
1333
  }
1334
1334
  }
1335
- return r;
1335
+ return n;
1336
1336
  }
1337
1337
  async function Is(e, t) {
1338
1338
  const r = L(e.routes, t);
@@ -1362,11 +1362,11 @@ async function We(e, t) {
1362
1362
  }
1363
1363
  async function pr(e, t) {
1364
1364
  return await le(
1365
- Be(e.fallbacks.error, t)
1365
+ Ge(e.fallbacks.error, t)
1366
1366
  );
1367
1367
  }
1368
1368
  async function ne(e, t, r = {}) {
1369
- const s = await (r.fallback ?? Be(e.fallbacks.notFound, t))?.load(), o = s?.default, i = r.documentContributions ?? !0;
1369
+ const s = await (r.fallback ?? Ge(e.fallbacks.notFound, t))?.load(), o = s?.default, i = r.documentContributions ?? !0;
1370
1370
  if (s?.layout === !1)
1371
1371
  return {
1372
1372
  layouts: [],
@@ -1402,27 +1402,27 @@ async function ne(e, t, r = {}) {
1402
1402
  function gr(e, t) {
1403
1403
  const r = _(t);
1404
1404
  return e.layouts.filter(
1405
- (n) => !n.fileSegments.some(G) && ue(n.segments, r)
1405
+ (n) => !n.fileSegments.some(B) && ue(n.segments, r)
1406
1406
  );
1407
1407
  }
1408
1408
  function wr(e, t) {
1409
1409
  const r = _(t);
1410
1410
  return e.policies.filter(
1411
- (n) => !n.fileSegments.some(G) && ue(n.segments, r)
1411
+ (n) => !n.fileSegments.some(B) && ue(n.segments, r)
1412
1412
  );
1413
1413
  }
1414
1414
  function ce(e, t) {
1415
1415
  for (let r = e.length - 1; r >= 0; r -= 1) {
1416
1416
  const n = e[r];
1417
- if (B(n.fileSegments, t.fileSegments))
1417
+ if (G(n.fileSegments, t.fileSegments))
1418
1418
  return n;
1419
1419
  }
1420
1420
  }
1421
- function Be(e, t) {
1421
+ function Ge(e, t) {
1422
1422
  const r = _(t);
1423
1423
  for (let n = e.length - 1; n >= 0; n -= 1) {
1424
1424
  const s = e[n];
1425
- if (!s.fileSegments.some(G) && ue(s.segments, r))
1425
+ if (!s.fileSegments.some(B) && ue(s.segments, r))
1426
1426
  return s;
1427
1427
  }
1428
1428
  }
@@ -1467,15 +1467,15 @@ function Hs(e, t) {
1467
1467
  (r, n) => t[n] === r
1468
1468
  );
1469
1469
  }
1470
- function B(e, t) {
1470
+ function G(e, t) {
1471
1471
  return e.every(
1472
1472
  (r, n) => t[n] === r
1473
1473
  );
1474
1474
  }
1475
1475
  function R(e) {
1476
- return e.flatMap((t) => G(t) ? [] : t === "index" ? [] : t.startsWith("[...") && t.endsWith("]") ? [`*${t.slice(4, -1)}`] : t.startsWith("[") && t.endsWith("]") ? [`:${t.slice(1, -1)}`] : [t]);
1476
+ return e.flatMap((t) => B(t) ? [] : t === "index" ? [] : t.startsWith("[...") && t.endsWith("]") ? [`*${t.slice(4, -1)}`] : t.startsWith("[") && t.endsWith("]") ? [`:${t.slice(1, -1)}`] : [t]);
1477
1477
  }
1478
- function G(e) {
1478
+ function B(e) {
1479
1479
  return e.startsWith("(") && e.endsWith(")");
1480
1480
  }
1481
1481
  function Er(e) {
@@ -1533,7 +1533,7 @@ class fe extends URIError {
1533
1533
  }
1534
1534
  }
1535
1535
  const x = "x-demiurge-navigation", Pr = "data", Cr = "data", Z = "error", xe = "not-found";
1536
- function Ge(e) {
1536
+ function Be(e) {
1537
1537
  return e.headers.get(x) === Pr;
1538
1538
  }
1539
1539
  function Ar(e) {
@@ -1695,7 +1695,7 @@ async function js(e, t = "sha256") {
1695
1695
  return `'${t}-${Yr(new Uint8Array(r))}'`;
1696
1696
  }
1697
1697
  function Je(e, t = {}) {
1698
- Gr(e);
1698
+ Br(e);
1699
1699
  const r = new Headers(), n = e.csp !== !1 && e.csp ? qr(e.csp, t) : void 0, s = Fr(e.trustedTypes), o = e.trustedTypes ? e.trustedTypes.mode === "report-only" : !1;
1700
1700
  return y(
1701
1701
  r,
@@ -1809,12 +1809,12 @@ function Xe(e) {
1809
1809
  }
1810
1810
  function Wr(e) {
1811
1811
  if (e)
1812
- return Object.entries(e).sort(([t], [r]) => t.localeCompare(r)).map(([t, r]) => `${t}="${Br(r)}"`).join(", ");
1812
+ return Object.entries(e).sort(([t], [r]) => t.localeCompare(r)).map(([t, r]) => `${t}="${Gr(r)}"`).join(", ");
1813
1813
  }
1814
- function Br(e) {
1814
+ function Gr(e) {
1815
1815
  return e.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
1816
1816
  }
1817
- function Gr(e) {
1817
+ function Br(e) {
1818
1818
  const t = e.headers?.reportingEndpoints;
1819
1819
  if (t) {
1820
1820
  const n = Object.entries(t);
@@ -2385,7 +2385,7 @@ async function Wn(e, t, r) {
2385
2385
  return Pe;
2386
2386
  }
2387
2387
  }
2388
- function Bn(e) {
2388
+ function Gn(e) {
2389
2389
  return W({
2390
2390
  instance: `${e.pathname}${e.search}`,
2391
2391
  status: 404,
@@ -2395,10 +2395,10 @@ function Bn(e) {
2395
2395
  async function se(e, t, r = {}) {
2396
2396
  const n = new URL(t.url);
2397
2397
  if (!it(t))
2398
- return Bn(n);
2398
+ return Gn(n);
2399
2399
  const s = await ne(e, n.pathname, {
2400
2400
  onLayoutError: (u) => r.onError?.(u, "page")
2401
- }), o = await Gn(e, n.pathname), i = r.nonce ?? (Ye(o) ? Ze() : void 0), a = _n(s, { ...r, nonce: i }), c = Je(o ?? {}, {
2401
+ }), o = await Bn(e, n.pathname), i = r.nonce ?? (Ye(o) ? Ze() : void 0), a = _n(s, { ...r, nonce: i }), c = Je(o ?? {}, {
2402
2402
  nonce: i,
2403
2403
  request: t
2404
2404
  });
@@ -2410,7 +2410,7 @@ async function se(e, t, r = {}) {
2410
2410
  }
2411
2411
  );
2412
2412
  }
2413
- async function Gn(e, t) {
2413
+ async function Bn(e, t) {
2414
2414
  const r = await Promise.all(
2415
2415
  wr(e, t).map((n) => n.load())
2416
2416
  );
@@ -2478,7 +2478,7 @@ function zs(e) {
2478
2478
  async function Vn(e, t, r = {
2479
2479
  rateLimitStore: lt
2480
2480
  }) {
2481
- const n = new URL(t.url), s = Yn(n, r), o = Ge(t);
2481
+ const n = new URL(t.url), s = Yn(n, r), o = Be(t);
2482
2482
  let i;
2483
2483
  try {
2484
2484
  i = L(e.routes, n.pathname);
@@ -2600,7 +2600,7 @@ async function Kn(e, t, r, n, s, o) {
2600
2600
  ...o,
2601
2601
  nonce: v
2602
2602
  });
2603
- if (Ge(t))
2603
+ if (Be(t))
2604
2604
  return Ar(p.match.data);
2605
2605
  if (p.match.render.mode === "streaming" && !s.renderPage)
2606
2606
  throw new Error(
@@ -2715,7 +2715,7 @@ function Zn(e, t) {
2715
2715
  async function Qn(e, t, r, n) {
2716
2716
  const s = await Promise.all(
2717
2717
  e.policies.filter(
2718
- (o) => B(o.fileSegments, t.fileSegments)
2718
+ (o) => G(o.fileSegments, t.fileSegments)
2719
2719
  ).map((o) => o.load())
2720
2720
  );
2721
2721
  return Ke(
@@ -2729,7 +2729,7 @@ async function Qn(e, t, r, n) {
2729
2729
  async function $e(e, t) {
2730
2730
  return (await Promise.all(
2731
2731
  e.middlewares.filter(
2732
- (n) => B(n.fileSegments, t.fileSegments)
2732
+ (n) => G(n.fileSegments, t.fileSegments)
2733
2733
  ).map((n) => n.load())
2734
2734
  )).flatMap(
2735
2735
  (n) => n.middleware ? [n.middleware] : []
@@ -2780,92 +2780,93 @@ function rs(e) {
2780
2780
  return e.GET && !t.includes("HEAD") && t.push("HEAD"), t;
2781
2781
  }
2782
2782
  export {
2783
- ms as $,
2784
- Ue as A,
2783
+ ys as $,
2784
+ ot as A,
2785
2785
  ke as B,
2786
- Me as C,
2787
- et as D,
2788
- cn as E,
2789
- an as F,
2790
- Ns as G,
2786
+ Ue as C,
2787
+ Me as D,
2788
+ et as E,
2789
+ cn as F,
2790
+ an as G,
2791
2791
  Kt as H,
2792
- ae as I,
2793
- tr as J,
2794
- zs as K,
2795
- as as L,
2796
- fs as M,
2792
+ Ns as I,
2793
+ ae as J,
2794
+ tr as K,
2795
+ zs as L,
2796
+ as as M,
2797
2797
  x as N,
2798
- Ms as O,
2799
- ps as P,
2800
- Us as Q,
2798
+ fs as O,
2799
+ Ms as P,
2800
+ ps as Q,
2801
2801
  D as R,
2802
- Ds as S,
2803
- Cn as T,
2804
- un as U,
2805
- Sn as V,
2806
- kn as W,
2807
- Es as X,
2808
- Fs as Y,
2809
- ws as Z,
2810
- ys as _,
2802
+ Us as S,
2803
+ Ds as T,
2804
+ Cn as U,
2805
+ un as V,
2806
+ Sn as W,
2807
+ kn as X,
2808
+ Es as Y,
2809
+ Fs as Z,
2810
+ ws as _,
2811
2811
  $s as a,
2812
- Ke as a0,
2813
- Or as a1,
2814
- Ir as a2,
2815
- ds as a3,
2816
- ls as a4,
2817
- bs as a5,
2818
- ln as a6,
2819
- st as a7,
2820
- cs as a8,
2821
- us as a9,
2822
- Cs as aa,
2823
- Rs as ab,
2824
- gt as ac,
2825
- b as ad,
2826
- vt as ae,
2827
- P as af,
2828
- je as ag,
2829
- te as ah,
2830
- ks as ai,
2831
- xs as aj,
2832
- vs as ak,
2833
- hs as al,
2834
- As as am,
2835
- Ss as an,
2836
- En as ao,
2837
- Ls as ap,
2838
- B as aq,
2839
- Hs as ar,
2840
- Os as as,
2841
- Sr as at,
2842
- kr as au,
2843
- _ as av,
2844
- R as aw,
2812
+ ms as a0,
2813
+ Ke as a1,
2814
+ Or as a2,
2815
+ Ir as a3,
2816
+ ds as a4,
2817
+ ls as a5,
2818
+ bs as a6,
2819
+ ln as a7,
2820
+ st as a8,
2821
+ cs as a9,
2822
+ us as aa,
2823
+ Cs as ab,
2824
+ Rs as ac,
2825
+ gt as ad,
2826
+ b as ae,
2827
+ vt as af,
2828
+ P as ag,
2829
+ je as ah,
2830
+ te as ai,
2831
+ ks as aj,
2832
+ xs as ak,
2833
+ vs as al,
2834
+ hs as am,
2835
+ As as an,
2836
+ Ss as ao,
2837
+ En as ap,
2838
+ Ls as aq,
2839
+ G as ar,
2840
+ Hs as as,
2841
+ Os as at,
2842
+ Sr as au,
2843
+ kr as av,
2844
+ _ as aw,
2845
+ R as ax,
2845
2846
  nt as b,
2846
2847
  ur as c,
2847
2848
  js as d,
2848
- Ts as e,
2849
+ Ze as e,
2849
2850
  L as f,
2850
- Pt as g,
2851
+ Ts as g,
2851
2852
  Vn as h,
2852
- qe as i,
2853
- hr as j,
2854
- Pr as k,
2853
+ Pt as i,
2854
+ qe as j,
2855
+ hr as k,
2855
2856
  Is as l,
2856
- Cr as m,
2857
- xe as n,
2858
- Z as o,
2857
+ Pr as m,
2858
+ Cr as n,
2859
+ xe as o,
2859
2860
  I as p,
2860
- Ps as q,
2861
+ Z as q,
2861
2862
  se as r,
2862
2863
  Re as s,
2863
2864
  $t as t,
2864
- ie as u,
2865
- gs as v,
2866
- Je as w,
2867
- Qr as x,
2868
- Pn as y,
2869
- ot as z
2865
+ Ps as u,
2866
+ ie as v,
2867
+ gs as w,
2868
+ Je as x,
2869
+ Qr as y,
2870
+ Pn as z
2870
2871
  };
2871
- //# sourceMappingURL=testing-BBnJ5WUR.js.map
2872
+ //# sourceMappingURL=testing-DR3eQAvY.js.map