@noego/forge 0.0.10 → 0.0.12

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 (54) hide show
  1. package/dist/client.cjs +1 -1
  2. package/dist/client.cjs.map +1 -1
  3. package/dist/client.mjs +224 -219
  4. package/dist/client.mjs.map +1 -1
  5. package/dist/options/ServerOptions.cjs +28 -0
  6. package/dist/options/ServerOptions.cjs.map +1 -0
  7. package/dist/options/ServerOptions.d.ts +19 -0
  8. package/dist/options/ServerOptions.mjs +21 -0
  9. package/dist/options/ServerOptions.mjs.map +1 -0
  10. package/dist/options/assets.cjs +42 -0
  11. package/dist/options/assets.cjs.map +1 -0
  12. package/dist/options/assets.d.ts +46 -0
  13. package/dist/options/assets.mjs +38 -0
  14. package/dist/options/assets.mjs.map +1 -0
  15. package/dist/plugins/serverOnlyStub.d.ts +6 -0
  16. package/dist/plugins-cjs/index.plugins.js +9 -0
  17. package/dist/plugins-cjs/index.plugins.js.map +1 -0
  18. package/dist/plugins-cjs/options/ServerOptions.js +28 -0
  19. package/dist/plugins-cjs/options/ServerOptions.js.map +1 -0
  20. package/dist/plugins-cjs/options/assets.js +42 -0
  21. package/dist/plugins-cjs/options/assets.js.map +1 -0
  22. package/dist/plugins-cjs/plugins/serverOnlyStub.js +226 -0
  23. package/dist/plugins-cjs/plugins/serverOnlyStub.js.map +1 -0
  24. package/dist/plugins-cjs/routing/html_render/html_render.js +62 -0
  25. package/dist/plugins-cjs/routing/html_render/html_render.js.map +1 -0
  26. package/dist/plugins-cjs/stubs/server-only.js +10 -0
  27. package/dist/plugins-cjs/stubs/server-only.js.map +1 -0
  28. package/dist/plugins-es/index.plugins.d.ts +2 -0
  29. package/dist/plugins-es/index.plugins.js +2 -0
  30. package/dist/plugins-es/index.plugins.js.map +1 -0
  31. package/dist/plugins-es/options/ServerOptions.d.ts +19 -0
  32. package/dist/plugins-es/options/ServerOptions.js +21 -0
  33. package/dist/plugins-es/options/ServerOptions.js.map +1 -0
  34. package/dist/plugins-es/options/assets.d.ts +46 -0
  35. package/dist/plugins-es/options/assets.js +38 -0
  36. package/dist/plugins-es/options/assets.js.map +1 -0
  37. package/dist/plugins-es/plugins/serverOnlyStub.d.ts +6 -0
  38. package/dist/plugins-es/plugins/serverOnlyStub.js +200 -0
  39. package/dist/plugins-es/plugins/serverOnlyStub.js.map +1 -0
  40. package/dist/plugins-es/routing/html_render/html_render.d.ts +19 -0
  41. package/dist/plugins-es/routing/html_render/html_render.js +53 -0
  42. package/dist/plugins-es/routing/html_render/html_render.js.map +1 -0
  43. package/dist/plugins-es/stubs/server-only.d.ts +3 -0
  44. package/dist/plugins-es/stubs/server-only.js +7 -0
  45. package/dist/plugins-es/stubs/server-only.js.map +1 -0
  46. package/dist/routing/html_render/html_render.d.ts +19 -0
  47. package/dist/routing/html_render/html_render.js +53 -0
  48. package/dist/routing/html_render/html_render.js.map +1 -0
  49. package/dist-ssr/server.cjs +179 -23
  50. package/dist-ssr/server.cjs.map +1 -1
  51. package/dist-ssr/server.js +179 -23
  52. package/dist-ssr/server.js.map +1 -1
  53. package/package.json +11 -4
  54. package/src/components/RecursiveRender.svelte +55 -14
package/dist/client.mjs CHANGED
@@ -1,32 +1,32 @@
1
1
  import { p as G, a as y } from "./page.svelte-Bq1Q01H0.js";
2
2
  import { s as vt } from "./page.svelte-Bq1Q01H0.js";
3
- import * as B from "svelte/internal/client";
3
+ import * as H from "svelte/internal/client";
4
4
  import { hydrate as Y } from "svelte";
5
5
  import J from "../src/components/RecursiveRender.svelte";
6
6
  function K(t) {
7
7
  const i = new G(t);
8
- return (e) => i.match(e) || null;
8
+ return (n) => i.match(n) || null;
9
9
  }
10
10
  function Q(t) {
11
11
  return t.map((i) => {
12
- const e = i.path, o = K(e);
13
- return { pattern: e, parser: o };
12
+ const n = i.path, o = K(n);
13
+ return { pattern: n, parser: o };
14
14
  });
15
15
  }
16
- function A() {
17
- return A = Object.assign ? Object.assign.bind() : function(t) {
16
+ function q() {
17
+ return q = Object.assign ? Object.assign.bind() : function(t) {
18
18
  for (var i = 1; i < arguments.length; i++) {
19
- var e = arguments[i];
20
- for (var o in e) ({}).hasOwnProperty.call(e, o) && (t[o] = e[o]);
19
+ var n = arguments[i];
20
+ for (var o in n) ({}).hasOwnProperty.call(n, o) && (t[o] = n[o]);
21
21
  }
22
22
  return t;
23
- }, A.apply(null, arguments);
23
+ }, q.apply(null, arguments);
24
24
  }
25
- var S;
25
+ var O;
26
26
  (function(t) {
27
27
  t.Pop = "POP", t.Push = "PUSH", t.Replace = "REPLACE";
28
- })(S || (S = {}));
29
- var I = process.env.NODE_ENV !== "production" ? function(t) {
28
+ })(O || (O = {}));
29
+ var D = process.env.NODE_ENV !== "production" ? function(t) {
30
30
  return Object.freeze(t);
31
31
  } : function(t) {
32
32
  return t;
@@ -40,36 +40,36 @@ function X(t, i) {
40
40
  }
41
41
  }
42
42
  }
43
- var F = "beforeunload", Z = "popstate";
43
+ var I = "beforeunload", Z = "popstate";
44
44
  function tt(t) {
45
45
  t === void 0 && (t = {});
46
- var i = t, e = i.window, o = e === void 0 ? document.defaultView : e, a = o.history;
46
+ var i = t, n = i.window, o = n === void 0 ? document.defaultView : n, a = o.history;
47
47
  function r() {
48
- var u = o.location, w = u.pathname, m = u.search, P = u.hash, b = a.state || {};
49
- return [b.idx, I({
50
- pathname: w,
51
- search: m,
52
- hash: P,
53
- state: b.usr || null,
54
- key: b.key || "default"
48
+ var d = o.location, m = d.pathname, v = d.search, b = d.hash, P = a.state || {};
49
+ return [P.idx, D({
50
+ pathname: m,
51
+ search: v,
52
+ hash: b,
53
+ state: P.usr || null,
54
+ key: P.key || "default"
55
55
  })];
56
56
  }
57
- var l = null;
58
- function s() {
59
- if (l)
60
- p.call(l), l = null;
57
+ var c = null;
58
+ function l() {
59
+ if (c)
60
+ w.call(c), c = null;
61
61
  else {
62
- var u = S.Pop, w = r(), m = w[0], P = w[1];
63
- if (p.length)
64
- if (m != null) {
65
- var b = f - m;
66
- b && (l = {
67
- action: u,
68
- location: P,
62
+ var d = O.Pop, m = r(), v = m[0], b = m[1];
63
+ if (w.length)
64
+ if (v != null) {
65
+ var P = u - v;
66
+ P && (c = {
67
+ action: d,
68
+ location: b,
69
69
  retry: function() {
70
- L(b * -1);
70
+ S(P * -1);
71
71
  }
72
- }, L(b));
72
+ }, S(P));
73
73
  } else
74
74
  process.env.NODE_ENV !== "production" && X(
75
75
  !1,
@@ -79,125 +79,125 @@ function tt(t) {
79
79
  "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."
80
80
  );
81
81
  else
82
- E(u);
82
+ E(d);
83
83
  }
84
84
  }
85
- o.addEventListener(Z, s);
86
- var n = S.Pop, c = r(), f = c[0], h = c[1], d = W(), p = W();
87
- f == null && (f = 0, a.replaceState(A({}, a.state, {
88
- idx: f
85
+ o.addEventListener(Z, l);
86
+ var e = O.Pop, s = r(), u = s[0], p = s[1], f = F(), w = F();
87
+ u == null && (u = 0, a.replaceState(q({}, a.state, {
88
+ idx: u
89
89
  }), ""));
90
- function v(u) {
91
- return typeof u == "string" ? u : nt(u);
90
+ function h(d) {
91
+ return typeof d == "string" ? d : nt(d);
92
92
  }
93
- function O(u, w) {
94
- return w === void 0 && (w = null), I(A({
95
- pathname: h.pathname,
93
+ function L(d, m) {
94
+ return m === void 0 && (m = null), D(q({
95
+ pathname: p.pathname,
96
96
  hash: "",
97
97
  search: ""
98
- }, typeof u == "string" ? ot(u) : u, {
99
- state: w,
98
+ }, typeof d == "string" ? ot(d) : d, {
99
+ state: m,
100
100
  key: et()
101
101
  }));
102
102
  }
103
- function k(u, w) {
103
+ function R(d, m) {
104
104
  return [{
105
- usr: u.state,
106
- key: u.key,
107
- idx: w
108
- }, v(u)];
105
+ usr: d.state,
106
+ key: d.key,
107
+ idx: m
108
+ }, h(d)];
109
109
  }
110
- function j(u, w, m) {
111
- return !p.length || (p.call({
112
- action: u,
113
- location: w,
114
- retry: m
110
+ function k(d, m, v) {
111
+ return !w.length || (w.call({
112
+ action: d,
113
+ location: m,
114
+ retry: v
115
115
  }), !1);
116
116
  }
117
- function E(u) {
118
- n = u;
119
- var w = r();
120
- f = w[0], h = w[1], d.call({
121
- action: n,
122
- location: h
117
+ function E(d) {
118
+ e = d;
119
+ var m = r();
120
+ u = m[0], p = m[1], f.call({
121
+ action: e,
122
+ location: p
123
123
  });
124
124
  }
125
- function M(u, w) {
126
- var m = S.Push, P = O(u, w);
127
- function b() {
128
- M(u, w);
125
+ function M(d, m) {
126
+ var v = O.Push, b = L(d, m);
127
+ function P() {
128
+ M(d, m);
129
129
  }
130
- if (j(m, P, b)) {
131
- var _ = k(P, f + 1), x = _[0], U = _[1];
130
+ if (k(v, b, P)) {
131
+ var _ = R(b, u + 1), x = _[0], N = _[1];
132
132
  try {
133
- a.pushState(x, "", U);
133
+ a.pushState(x, "", N);
134
134
  } catch {
135
- o.location.assign(U);
135
+ o.location.assign(N);
136
136
  }
137
- E(m);
137
+ E(v);
138
138
  }
139
139
  }
140
- function D(u, w) {
141
- var m = S.Replace, P = O(u, w);
142
- function b() {
143
- D(u, w);
140
+ function W(d, m) {
141
+ var v = O.Replace, b = L(d, m);
142
+ function P() {
143
+ W(d, m);
144
144
  }
145
- if (j(m, P, b)) {
146
- var _ = k(P, f), x = _[0], U = _[1];
147
- a.replaceState(x, "", U), E(m);
145
+ if (k(v, b, P)) {
146
+ var _ = R(b, u), x = _[0], N = _[1];
147
+ a.replaceState(x, "", N), E(v);
148
148
  }
149
149
  }
150
- function L(u) {
151
- a.go(u);
150
+ function S(d) {
151
+ a.go(d);
152
152
  }
153
- var z = {
153
+ var V = {
154
154
  get action() {
155
- return n;
155
+ return e;
156
156
  },
157
157
  get location() {
158
- return h;
158
+ return p;
159
159
  },
160
- createHref: v,
160
+ createHref: h,
161
161
  push: M,
162
- replace: D,
163
- go: L,
162
+ replace: W,
163
+ go: S,
164
164
  back: function() {
165
- L(-1);
165
+ S(-1);
166
166
  },
167
167
  forward: function() {
168
- L(1);
168
+ S(1);
169
169
  },
170
- listen: function(w) {
171
- return d.push(w);
170
+ listen: function(m) {
171
+ return f.push(m);
172
172
  },
173
- block: function(w) {
174
- var m = p.push(w);
175
- return p.length === 1 && o.addEventListener(F, H), function() {
176
- m(), p.length || o.removeEventListener(F, H);
173
+ block: function(m) {
174
+ var v = w.push(m);
175
+ return w.length === 1 && o.addEventListener(I, z), function() {
176
+ v(), w.length || o.removeEventListener(I, z);
177
177
  };
178
178
  }
179
179
  };
180
- return z;
180
+ return V;
181
181
  }
182
- function H(t) {
182
+ function z(t) {
183
183
  t.preventDefault(), t.returnValue = "";
184
184
  }
185
- function W() {
185
+ function F() {
186
186
  var t = [];
187
187
  return {
188
188
  get length() {
189
189
  return t.length;
190
190
  },
191
- push: function(e) {
192
- return t.push(e), function() {
191
+ push: function(n) {
192
+ return t.push(n), function() {
193
193
  t = t.filter(function(o) {
194
- return o !== e;
194
+ return o !== n;
195
195
  });
196
196
  };
197
197
  },
198
- call: function(e) {
198
+ call: function(n) {
199
199
  t.forEach(function(o) {
200
- return o && o(e);
200
+ return o && o(n);
201
201
  });
202
202
  }
203
203
  };
@@ -206,20 +206,20 @@ function et() {
206
206
  return Math.random().toString(36).substr(2, 8);
207
207
  }
208
208
  function nt(t) {
209
- var i = t.pathname, e = i === void 0 ? "/" : i, o = t.search, a = o === void 0 ? "" : o, r = t.hash, l = r === void 0 ? "" : r;
210
- return a && a !== "?" && (e += a.charAt(0) === "?" ? a : "?" + a), l && l !== "#" && (e += l.charAt(0) === "#" ? l : "#" + l), e;
209
+ var i = t.pathname, n = i === void 0 ? "/" : i, o = t.search, a = o === void 0 ? "" : o, r = t.hash, c = r === void 0 ? "" : r;
210
+ return a && a !== "?" && (n += a.charAt(0) === "?" ? a : "?" + a), c && c !== "#" && (n += c.charAt(0) === "#" ? c : "#" + c), n;
211
211
  }
212
212
  function ot(t) {
213
213
  var i = {};
214
214
  if (t) {
215
- var e = t.indexOf("#");
216
- e >= 0 && (i.hash = t.substr(e), t = t.substr(0, e));
215
+ var n = t.indexOf("#");
216
+ n >= 0 && (i.hash = t.substr(n), t = t.substr(0, n));
217
217
  var o = t.indexOf("?");
218
218
  o >= 0 && (i.search = t.substr(o), t = t.substr(0, o)), t && (i.pathname = t);
219
219
  }
220
220
  return i;
221
221
  }
222
- const rt = tt(), g = B.proxy({
222
+ const rt = tt(), g = H.proxy({
223
223
  layouts: [],
224
224
  view: null,
225
225
  data: null,
@@ -228,136 +228,143 @@ const rt = tt(), g = B.proxy({
228
228
  query: null,
229
229
  page: y
230
230
  });
231
- function T(...t) {
232
- let i = t.map((e, o) => o === 0 ? e.replace(/\/+$/, "") : e.replace(/^\/+|\/+$/g, "")).join("/");
231
+ function A(...t) {
232
+ let i = t.map((n, o) => o === 0 ? n.replace(/\/+$/, "") : n.replace(/^\/+|\/+$/g, "")).join("/");
233
233
  return i.startsWith("/") || (i = "/" + i), i.split("?")[0];
234
234
  }
235
- async function at(t, i, e, o, a, r) {
235
+ async function at(t, i, n, o, a, r) {
236
236
  try {
237
- const l = (e.layout || []).map((f) => T(i, f).toString());
238
- let s = T(i, e.view).toString();
239
- console.log({ layouts_paths: l, view_path: s });
240
- const n = await Promise.all(l.map((f) => import(
237
+ const c = typeof i == "string" && i.indexOf("assets") !== -1, l = (n.layout || []).map((p) => {
238
+ let f = A(i, p).toString();
239
+ return c && (f = f.endsWith(".svelte") ? f.replace(/\.svelte$/, ".js") : /[.][a-z]+$/.test(f) ? f : f + ".js"), f;
240
+ });
241
+ let e = A(i, n.view).toString();
242
+ c && (e = e.endsWith(".svelte") ? e.replace(/\.svelte$/, ".js") : /[.][a-z]+$/.test(e) ? e : e + ".js"), console.log({ layouts_paths: l, view_path: e });
243
+ const s = await Promise.all(l.map((p) => import(
241
244
  /* @vite-ignore */
242
- f
243
- ).then((h) => h.default)));
244
- s.startsWith("/") || (s = "/" + s);
245
- const c = await import(
245
+ p
246
+ ).then((f) => f.default)));
247
+ e.startsWith("/") || (e = "/" + e);
248
+ const u = await import(
246
249
  /* @vite-ignore */
247
- s
248
- ).then((f) => f.default);
249
- g.layouts = n, g.view = c, g.params = o, g.data = window.__INITIAL_DATA__, g.urlParams = a, g.query = r, Y(J, { target: t, props: g });
250
- } catch (l) {
251
- console.log("Client-side route loading failed - falling back to SSR navigation"), console.error("Route loading error:", l);
252
- const s = window.location.pathname || "/";
253
- window.location.href = s;
250
+ e
251
+ ).then((p) => p.default);
252
+ g.layouts = s, g.view = u, g.params = o, g.data = window.__INITIAL_DATA__, g.urlParams = a, g.query = r, Y(J, { target: t, props: g });
253
+ } catch (c) {
254
+ console.error("Client-side route loading failed:", c);
254
255
  }
255
256
  }
256
- async function N(t, i, e, o, a, r, l = !1, s = !0) {
257
+ async function U(t, i, n, o, a, r, c = !1, l = !0) {
257
258
  try {
258
- const n = (e.layout || []).map((d) => T(i, d).toString()), c = T(i, e.view).toString(), f = await Promise.all(n.map((d) => import(
259
+ const e = typeof i == "string" && i.indexOf("assets") !== -1, s = (n.layout || []).map((w) => {
260
+ let h = A(i, w).toString();
261
+ return e && (h = h.endsWith(".svelte") ? h.replace(/\.svelte$/, ".js") : /[.][a-z]+$/.test(h) ? h : h + ".js"), h;
262
+ });
263
+ let u = A(i, n.view).toString();
264
+ e && (u = u.endsWith(".svelte") ? u.replace(/\.svelte$/, ".js") : /[.][a-z]+$/.test(u) ? u : u + ".js");
265
+ const p = await Promise.all(s.map((w) => import(
259
266
  /* @vite-ignore */
260
- d
261
- ).then((p) => p.default))), h = await import(
267
+ w
268
+ ).then((h) => h.default))), f = await import(
262
269
  /* @vite-ignore */
263
- c
264
- ).then((d) => d.default);
265
- if (l) {
266
- const d = {
267
- method: e.method,
270
+ u
271
+ ).then((w) => w.default);
272
+ if (c) {
273
+ const w = {
274
+ method: n.method,
268
275
  headers: {
269
276
  "Content-Type": "application/json",
270
277
  Accept: "application/json"
271
278
  }
272
279
  };
273
- d[V] = !0, await fetch(t, d).then((p) => {
274
- if (p.ok)
275
- return p.json();
280
+ w[B] = !0, await fetch(t, w).then((h) => {
281
+ if (h.ok)
282
+ return h.json();
276
283
  throw new Error("Network response was not ok");
277
- }).then((p) => {
278
- console.log("Server data", p), g.data = p, g.params = o, g.layouts = f, g.view = h, g.urlParams = a, g.query = r;
284
+ }).then((h) => {
285
+ console.log("Server data", h), g.data = h, g.params = o, g.layouts = p, g.view = f, g.urlParams = a, g.query = r;
279
286
  });
280
287
  } else
281
- g.data = { layout: [], view: {} }, g.params = o, g.layouts = f, g.view = h, g.urlParams = a, g.query = r;
282
- window && window.scroll(0, 0), s && rt.push(t);
283
- } catch (n) {
284
- console.log("Client-side navigation failed for URL:", t, "- falling back to SSR navigation"), console.error("Navigation error:", n), window.location.href = t;
288
+ g.data = { layout: [], view: {} }, g.params = o, g.layouts = p, g.view = f, g.urlParams = a, g.query = r;
289
+ window && window.scroll(0, 0), l && rt.push(t);
290
+ } catch (e) {
291
+ console.error("Client-side navigation failed for URL:", t, e);
285
292
  }
286
293
  }
287
- const R = B.proxy({});
294
+ const j = H.proxy({});
288
295
  async function it() {
289
- Object.assign(R, window.__MANIFEST__);
296
+ Object.assign(j, window.__MANIFEST__);
290
297
  }
291
- function st(t, i, e) {
298
+ function st(t, i, n) {
292
299
  if (!document) {
293
300
  console.error("Document not found");
294
301
  return;
295
302
  }
296
303
  document.addEventListener("click", (o) => {
297
- var l, s;
298
- const a = window.location.pathname, r = ((l = o.target) == null ? void 0 : l.tagName) === "A" ? o.target : (s = o.target) == null ? void 0 : s.closest("A");
304
+ var c, l;
305
+ const a = window.location.pathname, r = ((c = o.target) == null ? void 0 : c.tagName) === "A" ? o.target : (l = o.target) == null ? void 0 : l.closest("A");
299
306
  if (r) {
300
- let n = r.getAttribute("href");
301
- if (a === n) {
307
+ let e = r.getAttribute("href");
308
+ if (a === e) {
302
309
  o.preventDefault();
303
310
  return;
304
311
  }
305
- if (n && n.startsWith("/") || n.startsWith(".")) {
306
- const c = n.split("?")[0], f = r.getAttribute("method") || "get", h = i.find((d) => d.method.toLowerCase() === f && e.find((p) => p.parser(c) && p.pattern === d.path));
307
- if (h) {
312
+ if (e && e.startsWith("/") || e.startsWith(".")) {
313
+ const s = e.split("?")[0], u = r.getAttribute("method") || "get", p = i.find((f) => f.method.toLowerCase() === u && n.find((w) => w.parser(s) && w.pattern === f.path));
314
+ if (p) {
308
315
  o.preventDefault();
309
- const d = e.find((E) => E.parser(c) && E.pattern === h.path), p = (d == null ? void 0 : d.parser(c)) || {}, v = new URLSearchParams(n.split("?")[1] || ""), O = Object.fromEntries(v.entries()) || {}, k = { ...p, ...O }, j = R[d == null ? void 0 : d.pattern];
310
- N(n, t, h, k, p, O, j);
316
+ const f = n.find((E) => E.parser(s) && E.pattern === p.path), w = (f == null ? void 0 : f.parser(s)) || {}, h = new URLSearchParams(e.split("?")[1] || ""), L = Object.fromEntries(h.entries()) || {}, R = { ...w, ...L }, k = j[f == null ? void 0 : f.pattern];
317
+ U(e, t, p, R, w, L, k);
311
318
  } else
312
- console.log("No matching route found for URL:", n, "- using fallback navigation");
319
+ console.log("No matching route found for URL:", e, "- using fallback navigation");
313
320
  }
314
321
  }
315
322
  }), window.addEventListener("popstate", (o) => {
316
323
  const a = window.location.pathname, r = window.location.pathname + window.location.search;
317
324
  y.url = r, y.pathname = window.location.pathname;
318
- const l = "get", s = i.find((n) => n.method.toLowerCase() === l && e.find((c) => c.parser(a) && c.pattern === n.path));
319
- if (s) {
320
- const n = e.find((v) => v.parser(a) && v.pattern === s.path), c = (n == null ? void 0 : n.parser(a)) || {}, f = new URLSearchParams(window.location.search), h = Object.fromEntries(f.entries()) || {};
321
- y.params = c, y.query = h;
322
- const d = { ...c, ...h }, p = R[n == null ? void 0 : n.pattern];
323
- N(r, t, s, d, c, h, p, !1);
325
+ const c = "get", l = i.find((e) => e.method.toLowerCase() === c && n.find((s) => s.parser(a) && s.pattern === e.path));
326
+ if (l) {
327
+ const e = n.find((h) => h.parser(a) && h.pattern === l.path), s = (e == null ? void 0 : e.parser(a)) || {}, u = new URLSearchParams(window.location.search), p = Object.fromEntries(u.entries()) || {};
328
+ y.params = s, y.query = p;
329
+ const f = { ...s, ...p }, w = j[e == null ? void 0 : e.pattern];
330
+ U(r, t, l, f, s, p, w, !1);
324
331
  } else
325
332
  console.log("No matching route found for popstate navigation to:", a, "- using fallback navigation"), window.location.href = a;
326
333
  }), function() {
327
334
  const o = history.pushState, a = history.replaceState;
328
335
  history.pushState = function(...r) {
329
- const l = o.apply(this, r), s = new Event("pushstate");
330
- return s.state = r[0], s.url = r[2], window.dispatchEvent(s), l;
336
+ const c = o.apply(this, r), l = new Event("pushstate");
337
+ return l.state = r[0], l.url = r[2], window.dispatchEvent(l), c;
331
338
  }, history.replaceState = function(...r) {
332
- const l = a.apply(this, r), s = r[2], n = window.location.pathname;
333
- if ((s ? new URL(s, window.location.origin).pathname : n) !== n) {
334
- const f = new Event("replacestate");
335
- f.state = r[0], f.url = r[2], window.dispatchEvent(f);
339
+ const c = a.apply(this, r), l = r[2], e = window.location.pathname;
340
+ if ((l ? new URL(l, window.location.origin).pathname : e) !== e) {
341
+ const u = new Event("replacestate");
342
+ u.state = r[0], u.url = r[2], window.dispatchEvent(u);
336
343
  }
337
- return l;
344
+ return c;
338
345
  };
339
346
  }(), window.addEventListener("pushstate", (o) => {
340
- const a = o.url || window.location.pathname + window.location.search, r = a.split("?")[0], l = "get", s = i.find((n) => n.method.toLowerCase() === l && e.find((c) => c.parser(r) && c.pattern === n.path));
341
- if (s) {
342
- const n = e.find((v) => v.parser(r) && v.pattern === s.path), c = n == null ? void 0 : n.parser(r), f = new URLSearchParams(a.split("?")[1] || ""), h = Object.fromEntries(f.entries());
343
- y.url = a, y.pathname = window.location.pathname, Object.assign(y.params, c), Object.assign(y.query, h);
344
- const d = { ...c, ...h }, p = R[n == null ? void 0 : n.pattern];
345
- N(a, t, s, d, c, h, p, !1);
347
+ const a = o.url || window.location.pathname + window.location.search, r = a.split("?")[0], c = "get", l = i.find((e) => e.method.toLowerCase() === c && n.find((s) => s.parser(r) && s.pattern === e.path));
348
+ if (l) {
349
+ const e = n.find((h) => h.parser(r) && h.pattern === l.path), s = e == null ? void 0 : e.parser(r), u = new URLSearchParams(a.split("?")[1] || ""), p = Object.fromEntries(u.entries());
350
+ y.url = a, y.pathname = window.location.pathname, Object.assign(y.params, s), Object.assign(y.query, p);
351
+ const f = { ...s, ...p }, w = j[e == null ? void 0 : e.pattern];
352
+ U(a, t, l, f, s, p, w, !1);
346
353
  } else
347
354
  console.log("No matching route found for pushstate to:", r, "- using fallback navigation"), window.location.href = r;
348
355
  }), window.addEventListener("replacestate", (o) => {
349
356
  const a = o.url || window.location.pathname + window.location.search, r = a.split("?")[0];
350
357
  y.url = a, y.pathname = window.location.pathname, y.query = Object.fromEntries(new URLSearchParams(a.split("?")[1] || ""));
351
- const l = "get", s = i.find((n) => n.method.toLowerCase() === l && e.find((c) => c.parser(r) && c.pattern === n.path));
352
- if (s) {
353
- const n = e.find((v) => v.parser(r) && v.pattern === s.path), c = (n == null ? void 0 : n.parser(r)) || {}, f = new URLSearchParams(a.split("?")[1] || ""), h = Object.fromEntries(f.entries()) || {}, d = { ...c, ...h }, p = R[n == null ? void 0 : n.pattern];
354
- N(a, t, s, d, c, h, p, !1);
358
+ const c = "get", l = i.find((e) => e.method.toLowerCase() === c && n.find((s) => s.parser(r) && s.pattern === e.path));
359
+ if (l) {
360
+ const e = n.find((h) => h.parser(r) && h.pattern === l.path), s = (e == null ? void 0 : e.parser(r)) || {}, u = new URLSearchParams(a.split("?")[1] || ""), p = Object.fromEntries(u.entries()) || {}, f = { ...s, ...p }, w = j[e == null ? void 0 : e.pattern];
361
+ U(a, t, l, f, s, p, w, !1);
355
362
  } else
356
363
  console.log("No matching route found for replacestate to:", r, "- using fallback navigation"), window.location.href = r;
357
364
  });
358
365
  }
359
- const V = Symbol("forge-load-function");
360
- let q = [], $ = null;
366
+ const B = Symbol("forge-load-function");
367
+ let $ = [], C = null;
361
368
  function ct(t) {
362
369
  try {
363
370
  const i = new URL(t, window.location.origin);
@@ -367,40 +374,40 @@ function ct(t) {
367
374
  }
368
375
  }
369
376
  function lt() {
370
- typeof window < "u" && !$ && ($ = window.fetch, window.fetch = async function(t, i = {}) {
377
+ typeof window < "u" && !C && (C = window.fetch, window.fetch = async function(t, i = {}) {
371
378
  console.log("🔵 Enhanced fetch called for:", t), console.log("🔵 Initial init:", i);
372
- let e = { ...i };
373
- for (const a of q)
379
+ let n = { ...i };
380
+ for (const a of $)
374
381
  try {
375
382
  if (a.length === 2) {
376
- const r = new Headers(e.headers), l = Object.fromEntries(r.entries());
377
- console.log("🟡 Running callback-style middleware (length=2)"), await new Promise((s, n) => {
383
+ const r = new Headers(n.headers), c = Object.fromEntries(r.entries());
384
+ console.log("🟡 Running callback-style middleware (length=2)"), await new Promise((l, e) => {
378
385
  try {
379
- a(l, (c) => {
380
- if (c)
381
- n(c);
386
+ a(c, (s) => {
387
+ if (s)
388
+ e(s);
382
389
  else {
383
- const f = new Headers();
384
- Object.entries(l).forEach(([h, d]) => {
385
- d !== void 0 && f.set(h, d);
386
- }), e.headers = f, s();
390
+ const u = new Headers();
391
+ Object.entries(c).forEach(([p, f]) => {
392
+ f !== void 0 && u.set(p, f);
393
+ }), n.headers = u, l();
387
394
  }
388
395
  });
389
- } catch (c) {
390
- n(c);
396
+ } catch (s) {
397
+ e(s);
391
398
  }
392
399
  });
393
400
  } else {
394
401
  console.log("🟡 Running new-style RequestInit middleware (length=" + a.length + ")");
395
- const r = await a(e, t);
396
- r && typeof r == "object" ? (console.log("🟢 Middleware returned RequestInit:", r), e = r) : console.log("🟢 Middleware returned:", r);
402
+ const r = await a(n, t);
403
+ r && typeof r == "object" ? (console.log("🟢 Middleware returned RequestInit:", r), n = r) : console.log("🟢 Middleware returned:", r);
397
404
  }
398
405
  } catch (r) {
399
406
  throw console.error("🔴 Middleware error:", r), r;
400
407
  }
401
- console.log("🟢 Final init after middleware:", e);
402
- const o = await $(t, e);
403
- if (o.status >= 300 && o.status < 400 && i[V]) {
408
+ console.log("🟢 Final init after middleware:", n);
409
+ const o = await C(t, n);
410
+ if (o.status >= 300 && o.status < 400 && i[B]) {
404
411
  const a = o.headers.get("location");
405
412
  if (a && ct(a))
406
413
  return window.location.href = a, o;
@@ -416,44 +423,42 @@ const ht = {
416
423
  configUpdate(t) {
417
424
  if (typeof t != "function")
418
425
  throw new Error("Middleware must be a function");
419
- q.push(t);
426
+ $.push(t);
420
427
  },
421
428
  /**
422
429
  * Reset all middleware
423
430
  */
424
431
  reset() {
425
- q.length = 0;
432
+ $.length = 0;
426
433
  },
427
434
  /**
428
435
  * Get current middleware count (for debugging)
429
436
  */
430
437
  getMiddlewareCount() {
431
- return q.length;
438
+ return $.length;
432
439
  }
433
440
  };
434
- let C;
441
+ let T;
435
442
  async function wt(t, i) {
436
- let e = i.component_dir;
437
- if (!e && typeof e != "string")
443
+ let n = window.__COMPONENT_DIR__ || i.component_dir;
444
+ if (!n && typeof n != "string")
438
445
  throw new Error("No component directory provided");
439
446
  let o = window.__ROUTING__;
440
- if (C = Q(o), window && window.location) {
447
+ if (T = Q(o), window && window.location) {
441
448
  const a = (window.location.pathname || "/").split("?")[0];
442
449
  console.log(`Current pathname: ${a}`);
443
- const r = C.find((s) => s.parser(a));
444
- let l = r ? o.find((s) => s.path === r.pattern) : null;
445
- if (r && l) {
446
- console.log("Found route:", l);
447
- const s = r.parser(a) || {}, n = new URLSearchParams(window.location.search), c = Object.fromEntries(n.entries()) || {}, f = { ...s, ...c };
448
- it(), at(t, e, l, f, s, c), st(e, o, C);
449
- } else {
450
- console.log("No matching route found, using fallback navigation"), window.location.href = a;
451
- return;
452
- }
450
+ const r = T.find((l) => l.parser(a));
451
+ let c = r ? o.find((l) => l.path === r.pattern) : null;
452
+ if (r && c) {
453
+ console.log("Found route:", c);
454
+ const l = r.parser(a) || {}, e = new URLSearchParams(window.location.search), s = Object.fromEntries(e.entries()) || {}, u = { ...l, ...s };
455
+ it(), at(t, n, c, u, l, s), st(n, o, T);
456
+ } else
457
+ console.warn("No matching route found for:", a);
453
458
  }
454
459
  }
455
460
  export {
456
- R as MANIFEST_STORE,
461
+ j as MANIFEST_STORE,
457
462
  st as bootstrap_events,
458
463
  wt as createApp,
459
464
  ht as fetch,
@@ -461,6 +466,6 @@ export {
461
466
  y as page,
462
467
  vt as shadowUrl,
463
468
  it as updateManifestStore,
464
- N as updateRoute
469
+ U as updateRoute
465
470
  };
466
471
  //# sourceMappingURL=client.mjs.map