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