@noego/forge 0.0.3 → 0.0.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.
package/dist/client.mjs CHANGED
@@ -1,605 +1,185 @@
1
- import { p as X, a as E } from "./page.svelte-C4chAYK2.js";
2
- import { s as Pt } from "./page.svelte-C4chAYK2.js";
3
- import * as t from "svelte/internal/client";
4
- import { hydrate as Z } from "svelte";
5
- import "svelte/internal/disclose-version";
6
- import "svelte/internal/flags/legacy";
7
- function $(e) {
8
- const a = new X(e);
9
- return (o) => a.match(o) || null;
10
- }
11
- function tt(e) {
12
- return e.map((a) => {
13
- const o = a.path, r = $(o);
14
- return { pattern: o, parser: r };
1
+ import { p as S } from "./index-DFgPI13E.js";
2
+ import { updateRoute as m, loadRoute as L } from "../src/client/navigation.svelte";
3
+ import { loadRoute as W, updateRoute as z } from "../src/client/navigation.svelte";
4
+ import { MANIFEST_STORE as g, updateManifestStore as R } from "../src/routing/manifest/store.svelte";
5
+ import { MANIFEST_STORE as B, updateManifestStore as Y } from "../src/routing/manifest/store.svelte";
6
+ import { page as h } from "../src/client/page.svelte";
7
+ import { page as J, shadowUrl as K } from "../src/client/page.svelte";
8
+ function U(c) {
9
+ const l = new S(c);
10
+ return (i) => l.match(i) || null;
11
+ }
12
+ function q(c) {
13
+ return c.map((l) => {
14
+ const i = l.path, r = U(i);
15
+ return { pattern: i, parser: r };
15
16
  });
16
17
  }
17
- function Y(e, a) {
18
- t.push(a, !1);
19
- const o = t.mutable_source(), r = t.mutable_source(), s = t.mutable_source(), c = t.mutable_source(), l = t.mutable_source(), i = t.mutable_source();
20
- let n = t.prop(a, "layouts", 24, () => []), f = t.prop(a, "view", 8, null), p = t.prop(a, "data", 24, () => ({})), g = t.prop(a, "params", 24, () => ({})), d = t.prop(a, "urlParams", 24, () => ({})), h = t.prop(a, "query", 24, () => ({})), m = t.prop(a, "page", 8, null);
21
- console.log("[page]", m()), t.legacy_pre_effect(
22
- () => (t.get(o), t.get(r), t.deep_read_state(n())),
23
- () => {
24
- ((b) => (t.set(o, b[0]), t.set(r, b.slice(1))))(n());
25
- }
26
- ), t.legacy_pre_effect(
27
- () => (t.get(s), t.get(c), t.deep_read_state(p())),
28
- () => {
29
- ((b) => (t.set(s, b[0]), t.set(c, b.slice(1))))(p().layout || []);
30
- }
31
- ), t.legacy_pre_effect(() => t.deep_read_state(p()), () => {
32
- t.set(l, p().view);
33
- }), t.legacy_pre_effect(
34
- () => (t.get(c), t.deep_read_state(p())),
35
- () => {
36
- t.set(i, {
37
- layout: t.get(c),
38
- view: p().view
39
- });
40
- }
41
- ), t.legacy_pre_effect_reset(), t.init();
42
- var S = t.comment(), j = t.first_child(S);
43
- {
44
- var U = (b) => {
45
- var R = t.comment(), O = t.first_child(R);
46
- t.component(O, () => t.get(o), (A, u) => {
47
- u(A, t.spread_props(() => t.get(s) || {}, {
48
- get params() {
49
- return g();
50
- },
51
- get urlParams() {
52
- return d();
53
- },
54
- get query() {
55
- return h();
56
- },
57
- get page() {
58
- return m();
59
- },
60
- children: (w, v) => {
61
- var P = t.comment(), _ = t.first_child(P);
62
- Y(_, {
63
- get layouts() {
64
- return t.get(r);
65
- },
66
- get view() {
67
- return f();
68
- },
69
- get data() {
70
- return t.get(i);
71
- },
72
- get params() {
73
- return g();
74
- },
75
- get urlParams() {
76
- return d();
77
- },
78
- get query() {
79
- return h();
80
- },
81
- get page() {
82
- return m();
83
- }
84
- }), t.append(w, P);
85
- },
86
- $$slots: { default: !0 }
87
- }));
88
- }), t.append(b, R);
89
- }, L = (b, R) => {
90
- {
91
- var O = (u) => {
92
- var w = t.comment(), v = t.first_child(w);
93
- t.component(v, () => t.get(o), (P, _) => {
94
- _(P, t.spread_props(() => t.get(s) || {}, {
95
- get params() {
96
- return g();
97
- },
98
- get urlParams() {
99
- return d();
100
- },
101
- get query() {
102
- return h();
103
- },
104
- get page() {
105
- return m();
106
- },
107
- children: (k, x) => {
108
- var q = t.comment(), W = t.first_child(q);
109
- t.component(W, f, (K, Q) => {
110
- Q(K, t.spread_props(() => t.get(l) || {}, {
111
- get params() {
112
- return g();
113
- },
114
- get urlParams() {
115
- return d();
116
- },
117
- get query() {
118
- return h();
119
- },
120
- get page() {
121
- return m();
122
- }
123
- }));
124
- }), t.append(k, q);
125
- },
126
- $$slots: { default: !0 }
127
- }));
128
- }), t.append(u, w);
129
- }, A = (u) => {
130
- var w = t.comment(), v = t.first_child(w);
131
- t.component(v, f, (P, _) => {
132
- _(P, t.spread_props(() => t.get(l) || {}, {
133
- get params() {
134
- return g();
135
- },
136
- get urlParams() {
137
- return d();
138
- },
139
- get query() {
140
- return h();
141
- },
142
- get page() {
143
- return m();
144
- }
145
- }));
146
- }), t.append(u, w);
147
- };
148
- t.if(
149
- b,
150
- (u) => {
151
- t.get(o) ? u(O) : u(A, !1);
152
- },
153
- R
154
- );
155
- }
156
- };
157
- t.if(j, (b) => {
158
- t.get(r).length > 0 ? b(U) : b(L, !1);
159
- });
160
- }
161
- t.append(e, S), t.pop();
162
- }
163
- function D() {
164
- return D = Object.assign ? Object.assign.bind() : function(e) {
165
- for (var a = 1; a < arguments.length; a++) {
166
- var o = arguments[a];
167
- for (var r in o) ({}).hasOwnProperty.call(o, r) && (e[r] = o[r]);
168
- }
169
- return e;
170
- }, D.apply(null, arguments);
171
- }
172
- var N;
173
- (function(e) {
174
- e.Pop = "POP", e.Push = "PUSH", e.Replace = "REPLACE";
175
- })(N || (N = {}));
176
- var B = process.env.NODE_ENV !== "production" ? function(e) {
177
- return Object.freeze(e);
178
- } : function(e) {
179
- return e;
180
- };
181
- function et(e, a) {
182
- {
183
- typeof console < "u" && console.warn(a);
184
- try {
185
- throw new Error(a);
186
- } catch {
187
- }
188
- }
189
- }
190
- var V = "beforeunload", nt = "popstate";
191
- function rt(e) {
192
- e === void 0 && (e = {});
193
- var a = e, o = a.window, r = o === void 0 ? document.defaultView : o, s = r.history;
194
- function c() {
195
- var u = r.location, w = u.pathname, v = u.search, P = u.hash, _ = s.state || {};
196
- return [_.idx, B({
197
- pathname: w,
198
- search: v,
199
- hash: P,
200
- state: _.usr || null,
201
- key: _.key || "default"
202
- })];
203
- }
204
- var l = null;
205
- function i() {
206
- if (l)
207
- h.call(l), l = null;
208
- else {
209
- var u = N.Pop, w = c(), v = w[0], P = w[1];
210
- if (h.length)
211
- if (v != null) {
212
- var _ = p - v;
213
- _ && (l = {
214
- action: u,
215
- location: P,
216
- retry: function() {
217
- O(_ * -1);
218
- }
219
- }, O(_));
220
- } else
221
- process.env.NODE_ENV !== "production" && et(
222
- !1,
223
- // TODO: Write up a doc that explains our blocking strategy in
224
- // detail and link to it here so people can understand better what
225
- // is going on and how to avoid it.
226
- "You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation."
227
- );
228
- else
229
- L(u);
230
- }
231
- }
232
- r.addEventListener(nt, i);
233
- var n = N.Pop, f = c(), p = f[0], g = f[1], d = G(), h = G();
234
- p == null && (p = 0, s.replaceState(D({}, s.state, {
235
- idx: p
236
- }), ""));
237
- function m(u) {
238
- return typeof u == "string" ? u : ot(u);
239
- }
240
- function S(u, w) {
241
- return w === void 0 && (w = null), B(D({
242
- pathname: g.pathname,
243
- hash: "",
244
- search: ""
245
- }, typeof u == "string" ? it(u) : u, {
246
- state: w,
247
- key: at()
248
- }));
249
- }
250
- function j(u, w) {
251
- return [{
252
- usr: u.state,
253
- key: u.key,
254
- idx: w
255
- }, m(u)];
256
- }
257
- function U(u, w, v) {
258
- return !h.length || (h.call({
259
- action: u,
260
- location: w,
261
- retry: v
262
- }), !1);
263
- }
264
- function L(u) {
265
- n = u;
266
- var w = c();
267
- p = w[0], g = w[1], d.call({
268
- action: n,
269
- location: g
270
- });
271
- }
272
- function b(u, w) {
273
- var v = N.Push, P = S(u, w);
274
- function _() {
275
- b(u, w);
276
- }
277
- if (U(v, P, _)) {
278
- var k = j(P, p + 1), x = k[0], q = k[1];
279
- try {
280
- s.pushState(x, "", q);
281
- } catch {
282
- r.location.assign(q);
283
- }
284
- L(v);
285
- }
286
- }
287
- function R(u, w) {
288
- var v = N.Replace, P = S(u, w);
289
- function _() {
290
- R(u, w);
291
- }
292
- if (U(v, P, _)) {
293
- var k = j(P, p), x = k[0], q = k[1];
294
- s.replaceState(x, "", q), L(v);
295
- }
296
- }
297
- function O(u) {
298
- s.go(u);
299
- }
300
- var A = {
301
- get action() {
302
- return n;
303
- },
304
- get location() {
305
- return g;
306
- },
307
- createHref: m,
308
- push: b,
309
- replace: R,
310
- go: O,
311
- back: function() {
312
- O(-1);
313
- },
314
- forward: function() {
315
- O(1);
316
- },
317
- listen: function(w) {
318
- return d.push(w);
319
- },
320
- block: function(w) {
321
- var v = h.push(w);
322
- return h.length === 1 && r.addEventListener(V, z), function() {
323
- v(), h.length || r.removeEventListener(V, z);
324
- };
325
- }
326
- };
327
- return A;
328
- }
329
- function z(e) {
330
- e.preventDefault(), e.returnValue = "";
331
- }
332
- function G() {
333
- var e = [];
334
- return {
335
- get length() {
336
- return e.length;
337
- },
338
- push: function(o) {
339
- return e.push(o), function() {
340
- e = e.filter(function(r) {
341
- return r !== o;
342
- });
343
- };
344
- },
345
- call: function(o) {
346
- e.forEach(function(r) {
347
- return r && r(o);
348
- });
349
- }
350
- };
351
- }
352
- function at() {
353
- return Math.random().toString(36).substr(2, 8);
354
- }
355
- function ot(e) {
356
- var a = e.pathname, o = a === void 0 ? "/" : a, r = e.search, s = r === void 0 ? "" : r, c = e.hash, l = c === void 0 ? "" : c;
357
- return s && s !== "?" && (o += s.charAt(0) === "?" ? s : "?" + s), l && l !== "#" && (o += l.charAt(0) === "#" ? l : "#" + l), o;
358
- }
359
- function it(e) {
360
- var a = {};
361
- if (e) {
362
- var o = e.indexOf("#");
363
- o >= 0 && (a.hash = e.substr(o), e = e.substr(0, o));
364
- var r = e.indexOf("?");
365
- r >= 0 && (a.search = e.substr(r), e = e.substr(0, r)), e && (a.pathname = e);
366
- }
367
- return a;
368
- }
369
- const st = rt(), y = t.proxy({
370
- layouts: [],
371
- view: null,
372
- data: null,
373
- params: null,
374
- urlParams: null,
375
- query: null,
376
- page: E
377
- });
378
- function F(...e) {
379
- let a = e.map((o, r) => r === 0 ? o.replace(/\/+$/, "") : o.replace(/^\/+|\/+$/g, "")).join("/");
380
- return a.startsWith("/") || (a = "/" + a), a.split("?")[0];
381
- }
382
- async function ct(e, a, o, r, s, c) {
383
- try {
384
- const l = (o.layout || []).map((p) => F(a, p).toString());
385
- let i = F(a, o.view).toString();
386
- console.log({ layouts_paths: l, view_path: i });
387
- const n = await Promise.all(l.map((p) => import(
388
- /* @vite-ignore */
389
- p
390
- ).then((g) => g.default)));
391
- i.startsWith("/") || (i = "/" + i);
392
- const f = await import(
393
- /* @vite-ignore */
394
- i
395
- ).then((p) => p.default);
396
- y.layouts = n, y.view = f, y.params = r, y.data = window.__INITIAL_DATA__, y.urlParams = s, y.query = c, Z(Y, { target: e, props: y });
397
- } catch (l) {
398
- console.log("Client-side route loading failed - falling back to SSR navigation"), console.error("Route loading error:", l);
399
- const i = window.location.pathname || "/";
400
- window.location.href = i;
401
- }
402
- }
403
- async function C(e, a, o, r, s, c, l = !1, i = !0) {
404
- try {
405
- const n = (o.layout || []).map((d) => F(a, d).toString()), f = F(a, o.view).toString(), p = await Promise.all(n.map((d) => import(
406
- /* @vite-ignore */
407
- d
408
- ).then((h) => h.default))), g = await import(
409
- /* @vite-ignore */
410
- f
411
- ).then((d) => d.default);
412
- if (l) {
413
- const d = {
414
- method: o.method,
415
- headers: {
416
- "Content-Type": "application/json",
417
- Accept: "application/json"
418
- }
419
- };
420
- d[J] = !0, await fetch(e, d).then((h) => {
421
- if (h.ok)
422
- return h.json();
423
- throw new Error("Network response was not ok");
424
- }).then((h) => {
425
- console.log("Server data", h), y.data = h, y.params = r, y.layouts = p, y.view = g, y.urlParams = s, y.query = c;
426
- });
427
- } else
428
- y.data = { layout: [], view: {} }, y.params = r, y.layouts = p, y.view = g, y.urlParams = s, y.query = c;
429
- window && window.scroll(0, 0), i && st.push(e);
430
- } catch (n) {
431
- console.log("Client-side navigation failed for URL:", e, "- falling back to SSR navigation"), console.error("Navigation error:", n), window.location.href = e;
432
- }
433
- }
434
- const T = t.proxy({});
435
- async function lt() {
436
- Object.assign(T, window.__MANIFEST__);
437
- }
438
- function ut(e, a, o) {
18
+ function j(c, l, i) {
439
19
  if (!document) {
440
20
  console.error("Document not found");
441
21
  return;
442
22
  }
443
23
  document.addEventListener("click", (r) => {
444
- var l, i;
445
- const s = window.location.pathname, c = ((l = r.target) == null ? void 0 : l.tagName) === "A" ? r.target : (i = r.target) == null ? void 0 : i.closest("A");
446
- if (c) {
447
- let n = c.getAttribute("href");
448
- if (s === n) {
24
+ var s, e;
25
+ const a = window.location.pathname, n = ((s = r.target) == null ? void 0 : s.tagName) === "A" ? r.target : (e = r.target) == null ? void 0 : e.closest("A");
26
+ if (n) {
27
+ let t = n.getAttribute("href");
28
+ if (a === t) {
449
29
  r.preventDefault();
450
30
  return;
451
31
  }
452
- if (n && n.startsWith("/") || n.startsWith(".")) {
453
- const f = n.split("?")[0], p = c.getAttribute("method") || "get", g = a.find((d) => d.method.toLowerCase() === p && o.find((h) => h.parser(f) && h.pattern === d.path));
454
- if (g) {
32
+ if (t && t.startsWith("/") || t.startsWith(".")) {
33
+ const o = t.split("?")[0], p = n.getAttribute("method") || "get", u = l.find((d) => d.method.toLowerCase() === p && i.find((f) => f.parser(o) && f.pattern === d.path));
34
+ if (u) {
455
35
  r.preventDefault();
456
- const d = o.find((L) => L.parser(f) && L.pattern === g.path), h = (d == null ? void 0 : d.parser(f)) || {}, m = new URLSearchParams(n.split("?")[1] || ""), S = Object.fromEntries(m.entries()) || {}, j = { ...h, ...S }, U = T[d == null ? void 0 : d.pattern];
457
- C(n, e, g, j, h, S, U);
36
+ const d = i.find((_) => _.parser(o) && _.pattern === u.path), f = (d == null ? void 0 : d.parser(o)) || {}, w = new URLSearchParams(t.split("?")[1] || ""), E = Object.fromEntries(w.entries()) || {}, v = { ...f, ...E }, O = g[d == null ? void 0 : d.pattern];
37
+ m(t, c, u, v, f, E, O);
458
38
  } else
459
- console.log("No matching route found for URL:", n, "- using fallback navigation");
39
+ console.log("No matching route found for URL:", t, "- using fallback navigation");
460
40
  }
461
41
  }
462
42
  }), window.addEventListener("popstate", (r) => {
463
- const s = window.location.pathname, c = window.location.pathname + window.location.search;
464
- E.url = c, E.pathname = window.location.pathname;
465
- const l = "get", i = a.find((n) => n.method.toLowerCase() === l && o.find((f) => f.parser(s) && f.pattern === n.path));
466
- if (i) {
467
- const n = o.find((m) => m.parser(s) && m.pattern === i.path), f = (n == null ? void 0 : n.parser(s)) || {}, p = new URLSearchParams(window.location.search), g = Object.fromEntries(p.entries()) || {};
468
- Object.assign(E.params, f), Object.assign(E.query, g);
469
- const d = { ...f, ...g }, h = T[n == null ? void 0 : n.pattern];
470
- C(c, e, i, d, f, g, h, !1);
43
+ const a = window.location.pathname, n = window.location.pathname + window.location.search;
44
+ h.url = n, h.pathname = window.location.pathname;
45
+ const s = "get", e = l.find((t) => t.method.toLowerCase() === s && i.find((o) => o.parser(a) && o.pattern === t.path));
46
+ if (e) {
47
+ const t = i.find((w) => w.parser(a) && w.pattern === e.path), o = (t == null ? void 0 : t.parser(a)) || {}, p = new URLSearchParams(window.location.search), u = Object.fromEntries(p.entries()) || {};
48
+ Object.assign(h.params, o), Object.assign(h.query, u);
49
+ const d = { ...o, ...u }, f = g[t == null ? void 0 : t.pattern];
50
+ m(n, c, e, d, o, u, f, !1);
471
51
  } else
472
- console.log("No matching route found for popstate navigation to:", s, "- using fallback navigation"), window.location.href = s;
52
+ console.log("No matching route found for popstate navigation to:", a, "- using fallback navigation"), window.location.href = a;
473
53
  }), function() {
474
- const r = history.pushState, s = history.replaceState;
475
- history.pushState = function(...c) {
476
- const l = r.apply(this, c), i = new Event("pushstate");
477
- return i.state = c[0], i.url = c[2], window.dispatchEvent(i), l;
478
- }, history.replaceState = function(...c) {
479
- const l = s.apply(this, c), i = c[2], n = window.location.pathname;
480
- if ((i ? new URL(i, window.location.origin).pathname : n) !== n) {
54
+ const r = history.pushState, a = history.replaceState;
55
+ history.pushState = function(...n) {
56
+ const s = r.apply(this, n), e = new Event("pushstate");
57
+ return e.state = n[0], e.url = n[2], window.dispatchEvent(e), s;
58
+ }, history.replaceState = function(...n) {
59
+ const s = a.apply(this, n), e = n[2], t = window.location.pathname;
60
+ if ((e ? new URL(e, window.location.origin).pathname : t) !== t) {
481
61
  const p = new Event("replacestate");
482
- p.state = c[0], p.url = c[2], window.dispatchEvent(p);
62
+ p.state = n[0], p.url = n[2], window.dispatchEvent(p);
483
63
  }
484
- return l;
64
+ return s;
485
65
  };
486
66
  }(), window.addEventListener("pushstate", (r) => {
487
- const s = r.url || window.location.pathname + window.location.search, c = s.split("?")[0], l = "get", i = a.find((n) => n.method.toLowerCase() === l && o.find((f) => f.parser(c) && f.pattern === n.path));
488
- if (i) {
489
- const n = o.find((m) => m.parser(c) && m.pattern === i.path), f = n == null ? void 0 : n.parser(c), p = new URLSearchParams(s.split("?")[1] || ""), g = Object.fromEntries(p.entries());
490
- E.url = s, E.pathname = window.location.pathname, Object.assign(E.params, f), Object.assign(E.query, g);
491
- const d = { ...f, ...g }, h = T[n == null ? void 0 : n.pattern];
492
- C(s, e, i, d, f, g, h, !1);
67
+ const a = r.url || window.location.pathname + window.location.search, n = a.split("?")[0], s = "get", e = l.find((t) => t.method.toLowerCase() === s && i.find((o) => o.parser(n) && o.pattern === t.path));
68
+ if (e) {
69
+ const t = i.find((w) => w.parser(n) && w.pattern === e.path), o = t == null ? void 0 : t.parser(n), p = new URLSearchParams(a.split("?")[1] || ""), u = Object.fromEntries(p.entries());
70
+ h.url = a, h.pathname = window.location.pathname, Object.assign(h.params, o), Object.assign(h.query, u);
71
+ const d = { ...o, ...u }, f = g[t == null ? void 0 : t.pattern];
72
+ m(a, c, e, d, o, u, f, !1);
493
73
  } else
494
- console.log("No matching route found for pushstate to:", c, "- using fallback navigation"), window.location.href = c;
74
+ console.log("No matching route found for pushstate to:", n, "- using fallback navigation"), window.location.href = n;
495
75
  }), window.addEventListener("replacestate", (r) => {
496
- const s = r.url || window.location.pathname + window.location.search, c = s.split("?")[0];
497
- E.url = s, E.pathname = window.location.pathname, E.query = Object.fromEntries(new URLSearchParams(s.split("?")[1] || ""));
498
- const l = "get", i = a.find((n) => n.method.toLowerCase() === l && o.find((f) => f.parser(c) && f.pattern === n.path));
499
- if (i) {
500
- const n = o.find((m) => m.parser(c) && m.pattern === i.path), f = (n == null ? void 0 : n.parser(c)) || {}, p = new URLSearchParams(s.split("?")[1] || ""), g = Object.fromEntries(p.entries()) || {}, d = { ...f, ...g }, h = T[n == null ? void 0 : n.pattern];
501
- C(s, e, i, d, f, g, h, !1);
76
+ const a = r.url || window.location.pathname + window.location.search, n = a.split("?")[0];
77
+ h.url = a, h.pathname = window.location.pathname, h.query = Object.fromEntries(new URLSearchParams(a.split("?")[1] || ""));
78
+ const s = "get", e = l.find((t) => t.method.toLowerCase() === s && i.find((o) => o.parser(n) && o.pattern === t.path));
79
+ if (e) {
80
+ const t = i.find((w) => w.parser(n) && w.pattern === e.path), o = (t == null ? void 0 : t.parser(n)) || {}, p = new URLSearchParams(a.split("?")[1] || ""), u = Object.fromEntries(p.entries()) || {}, d = { ...o, ...u }, f = g[t == null ? void 0 : t.pattern];
81
+ m(a, c, e, d, o, u, f, !1);
502
82
  } else
503
- console.log("No matching route found for replacestate to:", c, "- using fallback navigation"), window.location.href = c;
83
+ console.log("No matching route found for replacestate to:", n, "- using fallback navigation"), window.location.href = n;
504
84
  });
505
85
  }
506
- const J = Symbol("forge-load-function");
507
- let H = [], I = null;
508
- function pt(e) {
86
+ const N = Symbol("forge-load-function");
87
+ let P = [], b = null;
88
+ function A(c) {
509
89
  try {
510
- const a = new URL(e, window.location.origin);
511
- return a.origin === window.location.origin && !a.pathname.startsWith("/api/");
90
+ const l = new URL(c, window.location.origin);
91
+ return l.origin === window.location.origin && !l.pathname.startsWith("/api/");
512
92
  } catch {
513
- return !e.startsWith("/api/");
93
+ return !c.startsWith("/api/");
514
94
  }
515
95
  }
516
- function ft() {
517
- typeof window < "u" && !I && (I = window.fetch, window.fetch = async function(e, a = {}) {
518
- console.log("🔵 Enhanced fetch called for:", e), console.log("🔵 Initial headers:", a.headers);
519
- const o = new Headers(a.headers), r = Object.fromEntries(o.entries());
96
+ function k() {
97
+ typeof window < "u" && !b && (b = window.fetch, window.fetch = async function(c, l = {}) {
98
+ console.log("🔵 Enhanced fetch called for:", c), console.log("🔵 Initial headers:", l.headers);
99
+ const i = new Headers(l.headers), r = Object.fromEntries(i.entries());
520
100
  console.log("🟡 Headers before middleware:", r);
521
- for (const i of H)
522
- i.length === 2 ? await new Promise((n, f) => {
101
+ for (const e of P)
102
+ e.length === 2 ? await new Promise((t, o) => {
523
103
  try {
524
- i(r, (p) => {
525
- p ? f(p) : n();
104
+ e(r, (p) => {
105
+ p ? o(p) : t();
526
106
  });
527
107
  } catch (p) {
528
- f(p);
108
+ o(p);
529
109
  }
530
- }) : await i(r);
110
+ }) : await e(r);
531
111
  console.log("🟢 Headers after middleware:", r);
532
- const s = new Headers();
533
- Object.entries(r).forEach(([i, n]) => {
534
- n !== void 0 && s.set(i, n);
112
+ const a = new Headers();
113
+ Object.entries(r).forEach(([e, t]) => {
114
+ t !== void 0 && a.set(e, t);
535
115
  });
536
- const c = {
537
- ...a,
538
- headers: s
116
+ const n = {
117
+ ...l,
118
+ headers: a
539
119
  };
540
- console.log("🔴 Final requestInit:", c), console.log("🔴 Headers entries:", Array.from(s.entries()));
541
- const l = await I(e, c);
542
- if (l.status >= 300 && l.status < 400 && a[J]) {
543
- const i = l.headers.get("location");
544
- if (i && pt(i))
545
- return window.location.href = i, l;
120
+ console.log("🔴 Final requestInit:", n), console.log("🔴 Headers entries:", Array.from(a.entries()));
121
+ const s = await b(c, n);
122
+ if (s.status >= 300 && s.status < 400 && l[N]) {
123
+ const e = s.headers.get("location");
124
+ if (e && A(e))
125
+ return window.location.href = e, s;
546
126
  }
547
- return l;
127
+ return s;
548
128
  });
549
129
  }
550
- ft();
551
- const mt = {
130
+ k();
131
+ const H = {
552
132
  /**
553
133
  * Add middleware to the fetch pipeline
554
134
  */
555
- configUpdate(e) {
556
- if (typeof e != "function")
135
+ configUpdate(c) {
136
+ if (typeof c != "function")
557
137
  throw new Error("Middleware must be a function");
558
- H.push(e);
138
+ P.push(c);
559
139
  },
560
140
  /**
561
141
  * Reset all middleware
562
142
  */
563
143
  reset() {
564
- H.length = 0;
144
+ P.length = 0;
565
145
  },
566
146
  /**
567
147
  * Get current middleware count (for debugging)
568
148
  */
569
149
  getMiddlewareCount() {
570
- return H.length;
150
+ return P.length;
571
151
  }
572
152
  };
573
- let M;
574
- async function vt(e, a) {
575
- let o = a.component_dir;
576
- if (!o && typeof o != "string")
153
+ let y;
154
+ async function x(c, l) {
155
+ let i = l.component_dir;
156
+ if (!i && typeof i != "string")
577
157
  throw new Error("No component directory provided");
578
158
  let r = window.__ROUTING__;
579
- if (M = tt(r), window && window.location) {
580
- const s = (window.location.pathname || "/").split("?")[0];
581
- console.log(`Current pathname: ${s}`);
582
- const c = M.find((i) => i.parser(s));
583
- let l = c ? r.find((i) => i.path === c.pattern) : null;
584
- if (c && l) {
585
- console.log("Found route:", l);
586
- const i = c.parser(s) || {}, n = new URLSearchParams(window.location.search), f = Object.fromEntries(n.entries()) || {}, p = { ...i, ...f };
587
- lt(), ct(e, o, l, p, i, f), ut(o, r, M);
159
+ if (y = q(r), window && window.location) {
160
+ const a = (window.location.pathname || "/").split("?")[0];
161
+ console.log(`Current pathname: ${a}`);
162
+ const n = y.find((e) => e.parser(a));
163
+ let s = n ? r.find((e) => e.path === n.pattern) : null;
164
+ if (n && s) {
165
+ console.log("Found route:", s);
166
+ const e = n.parser(a) || {}, t = new URLSearchParams(window.location.search), o = Object.fromEntries(t.entries()) || {}, p = { ...e, ...o };
167
+ R(), L(c, i, s, p, e, o), j(i, r, y);
588
168
  } else {
589
- console.log("No matching route found, using fallback navigation"), window.location.href = s;
169
+ console.log("No matching route found, using fallback navigation"), window.location.href = a;
590
170
  return;
591
171
  }
592
172
  }
593
173
  }
594
174
  export {
595
- T as MANIFEST_STORE,
596
- ut as bootstrap_events,
597
- vt as createApp,
598
- mt as fetch,
599
- ct as loadRoute,
600
- E as page,
601
- Pt as shadowUrl,
602
- lt as updateManifestStore,
603
- C as updateRoute
175
+ B as MANIFEST_STORE,
176
+ j as bootstrap_events,
177
+ x as createApp,
178
+ H as fetch,
179
+ W as loadRoute,
180
+ J as page,
181
+ K as shadowUrl,
182
+ Y as updateManifestStore,
183
+ z as updateRoute
604
184
  };
605
185
  //# sourceMappingURL=client.mjs.map