@noego/forge 0.0.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.
Files changed (145) hide show
  1. package/README.md +620 -0
  2. package/dist/client/client.d.ts +8 -0
  3. package/dist/client/client.d.ts.map +1 -0
  4. package/dist/client/events.d.ts +4 -0
  5. package/dist/client/events.d.ts.map +1 -0
  6. package/dist/client/index.d.ts +6 -0
  7. package/dist/client/index.d.ts.map +1 -0
  8. package/dist/client/navigation.svelte.d.ts +4 -0
  9. package/dist/client/navigation.svelte.d.ts.map +1 -0
  10. package/dist/client/page.svelte.d.ts +4 -0
  11. package/dist/client/page.svelte.d.ts.map +1 -0
  12. package/dist/client.cjs +2 -0
  13. package/dist/client.cjs.map +1 -0
  14. package/dist/client.d.ts +2 -0
  15. package/dist/client.mjs +605 -0
  16. package/dist/client.mjs.map +1 -0
  17. package/dist/index.d.ts +3 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/options/ServerOptions.d.ts +16 -0
  20. package/dist/options/ServerOptions.d.ts.map +1 -0
  21. package/dist/page.cjs +2 -0
  22. package/dist/page.cjs.map +1 -0
  23. package/dist/page.d.ts +2 -0
  24. package/dist/page.mjs +7 -0
  25. package/dist/page.mjs.map +1 -0
  26. package/dist/page.svelte-C4chAYK2.js +137 -0
  27. package/dist/page.svelte-C4chAYK2.js.map +1 -0
  28. package/dist/page.svelte-Dvj7306U.cjs +2 -0
  29. package/dist/page.svelte-Dvj7306U.cjs.map +1 -0
  30. package/dist/parser/IRoute.d.ts +31 -0
  31. package/dist/parser/IRoute.d.ts.map +1 -0
  32. package/dist/parser/openapi.d.ts +9 -0
  33. package/dist/parser/openapi.d.ts.map +1 -0
  34. package/dist/parser/path.d.ts +9 -0
  35. package/dist/parser/path.d.ts.map +1 -0
  36. package/dist/routing/base.d.ts +10 -0
  37. package/dist/routing/base.d.ts.map +1 -0
  38. package/dist/routing/component_loader/component_loader.d.ts +27 -0
  39. package/dist/routing/component_loader/component_loader.d.ts.map +1 -0
  40. package/dist/routing/component_loader/component_manager.d.ts +12 -0
  41. package/dist/routing/component_loader/component_manager.d.ts.map +1 -0
  42. package/dist/routing/html_render/html_render.d.ts +20 -0
  43. package/dist/routing/html_render/html_render.d.ts.map +1 -0
  44. package/dist/routing/manifest/base.d.ts +11 -0
  45. package/dist/routing/manifest/base.d.ts.map +1 -0
  46. package/dist/routing/manifest/store.svelte.d.ts +3 -0
  47. package/dist/routing/manifest/store.svelte.d.ts.map +1 -0
  48. package/dist/routing/page.d.ts +7 -0
  49. package/dist/routing/page.d.ts.map +1 -0
  50. package/dist/routing/server_adapter/api_adapter.d.ts +23 -0
  51. package/dist/routing/server_adapter/api_adapter.d.ts.map +1 -0
  52. package/dist/routing/server_adapter/express_server_adapter.d.ts +20 -0
  53. package/dist/routing/server_adapter/express_server_adapter.d.ts.map +1 -0
  54. package/dist/routing/server_adapter/middleware_adapter.d.ts +12 -0
  55. package/dist/routing/server_adapter/middleware_adapter.d.ts.map +1 -0
  56. package/dist/routing/server_adapter/server_adapter.d.ts +5 -0
  57. package/dist/routing/server_adapter/server_adapter.d.ts.map +1 -0
  58. package/dist/routing/shadow/shadow_route.d.ts +2 -0
  59. package/dist/routing/shadow/shadow_route.d.ts.map +1 -0
  60. package/dist/routing/url_parser.d.ts +12 -0
  61. package/dist/routing/url_parser.d.ts.map +1 -0
  62. package/dist/server/server.d.ts +5 -0
  63. package/dist/server/server.d.ts.map +1 -0
  64. package/dist/shared.cjs +2 -0
  65. package/dist/shared.cjs.map +1 -0
  66. package/dist/shared.d.ts +2 -0
  67. package/dist/shared.d.ts.map +1 -0
  68. package/dist/shared.mjs +5 -0
  69. package/dist/shared.mjs.map +1 -0
  70. package/dist/types/Callback.d.ts +2 -0
  71. package/dist/types/Callback.d.ts.map +1 -0
  72. package/dist/types/FetchMiddleware.d.ts +21 -0
  73. package/dist/types/FetchMiddleware.d.ts.map +1 -0
  74. package/dist/vite-env.d.ts +19 -0
  75. package/dist-ssr/client/client.d.ts +8 -0
  76. package/dist-ssr/client/client.d.ts.map +1 -0
  77. package/dist-ssr/client/events.d.ts +4 -0
  78. package/dist-ssr/client/events.d.ts.map +1 -0
  79. package/dist-ssr/client/index.d.ts +6 -0
  80. package/dist-ssr/client/index.d.ts.map +1 -0
  81. package/dist-ssr/client/navigation.svelte.d.ts +4 -0
  82. package/dist-ssr/client/navigation.svelte.d.ts.map +1 -0
  83. package/dist-ssr/client/page.svelte.d.ts +4 -0
  84. package/dist-ssr/client/page.svelte.d.ts.map +1 -0
  85. package/dist-ssr/index.d.ts +3 -0
  86. package/dist-ssr/index.d.ts.map +1 -0
  87. package/dist-ssr/options/ServerOptions.d.ts +16 -0
  88. package/dist-ssr/options/ServerOptions.d.ts.map +1 -0
  89. package/dist-ssr/parser/IRoute.d.ts +31 -0
  90. package/dist-ssr/parser/IRoute.d.ts.map +1 -0
  91. package/dist-ssr/parser/openapi.d.ts +9 -0
  92. package/dist-ssr/parser/openapi.d.ts.map +1 -0
  93. package/dist-ssr/parser/path.d.ts +9 -0
  94. package/dist-ssr/parser/path.d.ts.map +1 -0
  95. package/dist-ssr/path-CyGuWUeq.cjs +68 -0
  96. package/dist-ssr/path-CyGuWUeq.cjs.map +1 -0
  97. package/dist-ssr/path-ODk1FhWY.js +69 -0
  98. package/dist-ssr/path-ODk1FhWY.js.map +1 -0
  99. package/dist-ssr/routing/base.d.ts +10 -0
  100. package/dist-ssr/routing/base.d.ts.map +1 -0
  101. package/dist-ssr/routing/component_loader/component_loader.d.ts +27 -0
  102. package/dist-ssr/routing/component_loader/component_loader.d.ts.map +1 -0
  103. package/dist-ssr/routing/component_loader/component_manager.d.ts +12 -0
  104. package/dist-ssr/routing/component_loader/component_manager.d.ts.map +1 -0
  105. package/dist-ssr/routing/html_render/html_render.d.ts +20 -0
  106. package/dist-ssr/routing/html_render/html_render.d.ts.map +1 -0
  107. package/dist-ssr/routing/manifest/base.d.ts +11 -0
  108. package/dist-ssr/routing/manifest/base.d.ts.map +1 -0
  109. package/dist-ssr/routing/manifest/store.svelte.d.ts +3 -0
  110. package/dist-ssr/routing/manifest/store.svelte.d.ts.map +1 -0
  111. package/dist-ssr/routing/page.d.ts +7 -0
  112. package/dist-ssr/routing/page.d.ts.map +1 -0
  113. package/dist-ssr/routing/server_adapter/api_adapter.d.ts +23 -0
  114. package/dist-ssr/routing/server_adapter/api_adapter.d.ts.map +1 -0
  115. package/dist-ssr/routing/server_adapter/express_server_adapter.d.ts +20 -0
  116. package/dist-ssr/routing/server_adapter/express_server_adapter.d.ts.map +1 -0
  117. package/dist-ssr/routing/server_adapter/middleware_adapter.d.ts +12 -0
  118. package/dist-ssr/routing/server_adapter/middleware_adapter.d.ts.map +1 -0
  119. package/dist-ssr/routing/server_adapter/server_adapter.d.ts +5 -0
  120. package/dist-ssr/routing/server_adapter/server_adapter.d.ts.map +1 -0
  121. package/dist-ssr/routing/shadow/shadow_route.d.ts +2 -0
  122. package/dist-ssr/routing/shadow/shadow_route.d.ts.map +1 -0
  123. package/dist-ssr/routing/url_parser.d.ts +12 -0
  124. package/dist-ssr/routing/url_parser.d.ts.map +1 -0
  125. package/dist-ssr/server/server.d.ts +5 -0
  126. package/dist-ssr/server/server.d.ts.map +1 -0
  127. package/dist-ssr/server.cjs +876 -0
  128. package/dist-ssr/server.cjs.map +1 -0
  129. package/dist-ssr/server.d.ts +2 -0
  130. package/dist-ssr/server.js +838 -0
  131. package/dist-ssr/server.js.map +1 -0
  132. package/dist-ssr/shared.cjs +31 -0
  133. package/dist-ssr/shared.cjs.map +1 -0
  134. package/dist-ssr/shared.d.ts +2 -0
  135. package/dist-ssr/shared.d.ts.map +1 -0
  136. package/dist-ssr/shared.js +31 -0
  137. package/dist-ssr/shared.js.map +1 -0
  138. package/dist-ssr/types/Callback.d.ts +2 -0
  139. package/dist-ssr/types/Callback.d.ts.map +1 -0
  140. package/dist-ssr/types/FetchMiddleware.d.ts +21 -0
  141. package/dist-ssr/types/FetchMiddleware.d.ts.map +1 -0
  142. package/dist-ssr/vite-env.d.ts +19 -0
  143. package/loaders/loader.mjs +20 -0
  144. package/package.json +121 -0
  145. package/schema.json +333 -0
@@ -0,0 +1,605 @@
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 };
15
+ });
16
+ }
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) {
439
+ if (!document) {
440
+ console.error("Document not found");
441
+ return;
442
+ }
443
+ 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) {
449
+ r.preventDefault();
450
+ return;
451
+ }
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) {
455
+ 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);
458
+ } else
459
+ console.log("No matching route found for URL:", n, "- using fallback navigation");
460
+ }
461
+ }
462
+ }), 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);
471
+ } else
472
+ console.log("No matching route found for popstate navigation to:", s, "- using fallback navigation"), window.location.href = s;
473
+ }), 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) {
481
+ const p = new Event("replacestate");
482
+ p.state = c[0], p.url = c[2], window.dispatchEvent(p);
483
+ }
484
+ return l;
485
+ };
486
+ }(), 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);
493
+ } else
494
+ console.log("No matching route found for pushstate to:", c, "- using fallback navigation"), window.location.href = c;
495
+ }), 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);
502
+ } else
503
+ console.log("No matching route found for replacestate to:", c, "- using fallback navigation"), window.location.href = c;
504
+ });
505
+ }
506
+ const J = Symbol("forge-load-function");
507
+ let H = [], I = null;
508
+ function pt(e) {
509
+ try {
510
+ const a = new URL(e, window.location.origin);
511
+ return a.origin === window.location.origin && !a.pathname.startsWith("/api/");
512
+ } catch {
513
+ return !e.startsWith("/api/");
514
+ }
515
+ }
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());
520
+ console.log("🟡 Headers before middleware:", r);
521
+ for (const i of H)
522
+ i.length === 2 ? await new Promise((n, f) => {
523
+ try {
524
+ i(r, (p) => {
525
+ p ? f(p) : n();
526
+ });
527
+ } catch (p) {
528
+ f(p);
529
+ }
530
+ }) : await i(r);
531
+ 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);
535
+ });
536
+ const c = {
537
+ ...a,
538
+ headers: s
539
+ };
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;
546
+ }
547
+ return l;
548
+ });
549
+ }
550
+ ft();
551
+ const mt = {
552
+ /**
553
+ * Add middleware to the fetch pipeline
554
+ */
555
+ configUpdate(e) {
556
+ if (typeof e != "function")
557
+ throw new Error("Middleware must be a function");
558
+ H.push(e);
559
+ },
560
+ /**
561
+ * Reset all middleware
562
+ */
563
+ reset() {
564
+ H.length = 0;
565
+ },
566
+ /**
567
+ * Get current middleware count (for debugging)
568
+ */
569
+ getMiddlewareCount() {
570
+ return H.length;
571
+ }
572
+ };
573
+ let M;
574
+ async function vt(e, a) {
575
+ let o = a.component_dir;
576
+ if (!o && typeof o != "string")
577
+ throw new Error("No component directory provided");
578
+ 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);
588
+ } else {
589
+ console.log("No matching route found, using fallback navigation"), window.location.href = s;
590
+ return;
591
+ }
592
+ }
593
+ }
594
+ 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
604
+ };
605
+ //# sourceMappingURL=client.mjs.map