@vielzeug/wayfinder 2.1.0 → 3.0.0

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 (60) hide show
  1. package/README.md +3 -41
  2. package/dist/compile.cjs +1 -1
  3. package/dist/compile.cjs.map +1 -1
  4. package/dist/compile.d.ts +4 -4
  5. package/dist/compile.d.ts.map +1 -1
  6. package/dist/compile.js +2 -5
  7. package/dist/compile.js.map +1 -1
  8. package/dist/context.cjs +1 -1
  9. package/dist/context.cjs.map +1 -1
  10. package/dist/context.d.ts +6 -7
  11. package/dist/context.d.ts.map +1 -1
  12. package/dist/context.js +19 -18
  13. package/dist/context.js.map +1 -1
  14. package/dist/guards.cjs +1 -1
  15. package/dist/guards.cjs.map +1 -1
  16. package/dist/guards.js +1 -1
  17. package/dist/guards.js.map +1 -1
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +3 -3
  22. package/dist/path.cjs +1 -1
  23. package/dist/path.cjs.map +1 -1
  24. package/dist/path.d.ts +4 -5
  25. package/dist/path.d.ts.map +1 -1
  26. package/dist/path.js +1 -10
  27. package/dist/path.js.map +1 -1
  28. package/dist/router.cjs +1 -1
  29. package/dist/router.cjs.map +1 -1
  30. package/dist/router.d.ts +14 -22
  31. package/dist/router.d.ts.map +1 -1
  32. package/dist/router.js +179 -227
  33. package/dist/router.js.map +1 -1
  34. package/dist/types.d.ts +27 -39
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/wayfinder.cjs +1 -1
  37. package/dist/wayfinder.cjs.map +1 -1
  38. package/dist/wayfinder.iife.js +1 -1
  39. package/dist/wayfinder.iife.js.map +1 -1
  40. package/dist/wayfinder.js +1 -1
  41. package/dist/wayfinder.js.map +1 -1
  42. package/package.json +7 -18
  43. package/dist/devtools.cjs +0 -2
  44. package/dist/devtools.cjs.map +0 -1
  45. package/dist/devtools.d.ts +0 -47
  46. package/dist/devtools.d.ts.map +0 -1
  47. package/dist/devtools.js +0 -13
  48. package/dist/devtools.js.map +0 -1
  49. package/dist/hydration.cjs +0 -2
  50. package/dist/hydration.cjs.map +0 -1
  51. package/dist/hydration.d.ts +0 -7
  52. package/dist/hydration.d.ts.map +0 -1
  53. package/dist/hydration.js +0 -55
  54. package/dist/hydration.js.map +0 -1
  55. package/dist/preload.cjs +0 -2
  56. package/dist/preload.cjs.map +0 -1
  57. package/dist/preload.d.ts +0 -18
  58. package/dist/preload.d.ts.map +0 -1
  59. package/dist/preload.js +0 -30
  60. package/dist/preload.js.map +0 -1
@@ -1,7 +0,0 @@
1
- import type { RouteBranchDef, RouteRecord } from './types';
2
- export type HydrationManager<TMeta = unknown, TComponent = unknown> = ReturnType<typeof createHydrationManager<TMeta, TComponent>>;
3
- export declare function createHydrationManager<TMeta = unknown, TComponent = unknown>(): {
4
- effectiveDefs: (record: RouteRecord<TMeta, TComponent>) => readonly RouteBranchDef<TMeta, TComponent>[];
5
- hydrate: (record: RouteRecord<TMeta, TComponent>) => Promise<void>;
6
- };
7
- //# sourceMappingURL=hydration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hydration.d.ts","sourceRoot":"","sources":["../src/hydration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAkB3D,MAAM,MAAM,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,UAAU,GAAG,OAAO,IAAI,UAAU,CAC9E,OAAO,sBAAsB,CAAC,KAAK,EAAE,UAAU,CAAC,CACjD,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,KAAK,GAAG,OAAO,EAAE,UAAU,GAAG,OAAO;4BAO3C,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,KAAG,SAAS,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE;sBAkB7E,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC;EA0D9E"}
package/dist/hydration.js DELETED
@@ -1,55 +0,0 @@
1
- //#region src/hydration.ts
2
- function e() {
3
- let e = /* @__PURE__ */ new Map();
4
- function t(t) {
5
- let n = e.get(t);
6
- return n?.overrides.size ? t.branchDefs.map((e, t) => {
7
- let r = n.overrides.get(t);
8
- return r ? {
9
- ...e,
10
- ...r
11
- } : e;
12
- }) : t.branchDefs;
13
- }
14
- async function n(t) {
15
- if (!t.branchDefs.some((e) => e.lazy != null)) return;
16
- let n = e.get(t);
17
- if (n?.done) return;
18
- if (n?.work) {
19
- await n.work;
20
- return;
21
- }
22
- n = {
23
- done: !1,
24
- overrides: /* @__PURE__ */ new Map()
25
- }, e.set(t, n);
26
- let r = n, i = (async () => {
27
- let e = t.branchDefs.map((e, t) => ({
28
- def: e,
29
- i: t
30
- })).filter(({ def: e }) => e.lazy != null), n = await Promise.all(e.map(async ({ def: e, i: t }) => ({
31
- index: t,
32
- mod: await e.lazy()
33
- })));
34
- for (let { index: e, mod: t } of n) {
35
- let n = {};
36
- t.data !== void 0 && (n.dataFn = t.data), t.component !== void 0 && (n.component = t.component), t.meta !== void 0 && (n.meta = t.meta), r.overrides.set(e, n);
37
- }
38
- r.done = !0, r.work = void 0;
39
- })();
40
- n.work = i;
41
- try {
42
- await i;
43
- } catch (n) {
44
- throw e.delete(t), n;
45
- }
46
- }
47
- return {
48
- effectiveDefs: t,
49
- hydrate: n
50
- };
51
- }
52
- //#endregion
53
- export { e as createHydrationManager };
54
-
55
- //# sourceMappingURL=hydration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hydration.js","names":[],"sources":["../src/hydration.ts"],"sourcesContent":["import type { RouteBranchDef, RouteRecord } from './types';\n\n/**\n * HydrationOverride — lazy-resolved values for a single branch node.\n * Stored separately from the compiled RouteRecord so the record is never mutated.\n */\ntype HydrationOverride<TMeta, TComponent> = {\n component?: TComponent;\n dataFn?: RouteBranchDef['dataFn'];\n meta?: TMeta;\n};\n\ntype HydrationState<TMeta, TComponent> = {\n done: boolean;\n overrides: Map<number, HydrationOverride<TMeta, TComponent>>;\n work?: Promise<void>;\n};\n\nexport type HydrationManager<TMeta = unknown, TComponent = unknown> = ReturnType<\n typeof createHydrationManager<TMeta, TComponent>\n>;\n\nexport function createHydrationManager<TMeta = unknown, TComponent = unknown>() {\n const cache = new Map<RouteRecord, HydrationState<TMeta, TComponent>>();\n\n /**\n * Returns branchDefs merged with any lazy-resolved overrides.\n * Falls back to the original compiled defs when no overrides exist.\n */\n function effectiveDefs(record: RouteRecord<TMeta, TComponent>): readonly RouteBranchDef<TMeta, TComponent>[] {\n const state = cache.get(record);\n\n if (!state?.overrides.size) return record.branchDefs as readonly RouteBranchDef<TMeta, TComponent>[];\n\n return (record.branchDefs as readonly RouteBranchDef<TMeta, TComponent>[]).map((def, i) => {\n const override = state.overrides.get(i);\n\n return override ? { ...def, ...override } : def;\n });\n }\n\n /**\n * Resolves all lazy imports for the record.\n * All-or-nothing: overrides are committed only after every import succeeds.\n * On failure the cache entry is removed so the next navigation can retry.\n * Concurrent calls for the same record share the in-flight promise.\n */\n async function hydrate(record: RouteRecord<TMeta, TComponent>): Promise<void> {\n const hasLazy = record.branchDefs.some((d) => d.lazy != null);\n\n if (!hasLazy) return;\n\n let state = cache.get(record);\n\n if (state?.done) return;\n\n if (state?.work) {\n await state.work;\n\n return;\n }\n\n state = { done: false, overrides: new Map() };\n cache.set(record, state);\n\n const capturedState = state;\n\n type LazyMod = Awaited<ReturnType<NonNullable<RouteBranchDef<TMeta, TComponent>['lazy']>>>;\n\n const work = (async (): Promise<void> => {\n const lazyEntries = (record.branchDefs as readonly RouteBranchDef<TMeta, TComponent>[])\n .map((def, i) => ({ def, i }))\n .filter(({ def }) => def.lazy != null);\n\n const resolved: Array<{ index: number; mod: LazyMod }> = await Promise.all(\n lazyEntries.map(async ({ def, i }) => ({ index: i, mod: await def.lazy!() })),\n );\n\n for (const { index, mod } of resolved) {\n const override: HydrationOverride<TMeta, TComponent> = {};\n\n if (mod.data !== undefined) override.dataFn = mod.data;\n\n if (mod.component !== undefined) override.component = mod.component as TComponent;\n\n if (mod.meta !== undefined) override.meta = mod.meta as TMeta;\n\n capturedState.overrides.set(index, override);\n }\n\n capturedState.done = true;\n capturedState.work = undefined;\n })();\n\n state.work = work;\n\n try {\n await work;\n } catch (err) {\n cache.delete(record);\n throw err;\n }\n }\n\n return { effectiveDefs, hydrate };\n}\n"],"mappings":";AAsBA,SAAgB,IAAgE;CAC9E,IAAM,oBAAQ,IAAI,IAAoD;CAMtE,SAAS,EAAc,GAAsF;EAC3G,IAAM,IAAQ,EAAM,IAAI,CAAM;EAI9B,OAFK,GAAO,UAAU,OAEd,EAAO,WAA4D,KAAK,GAAK,MAAM;GACzF,IAAM,IAAW,EAAM,UAAU,IAAI,CAAC;GAEtC,OAAO,IAAW;IAAE,GAAG;IAAK,GAAG;GAAS,IAAI;EAC9C,CAAC,IANkC,EAAO;CAO5C;CAQA,eAAe,EAAQ,GAAuD;EAG5E,IAAI,CAFY,EAAO,WAAW,MAAM,MAAM,EAAE,QAAQ,IAEnD,GAAS;EAEd,IAAI,IAAQ,EAAM,IAAI,CAAM;EAE5B,IAAI,GAAO,MAAM;EAEjB,IAAI,GAAO,MAAM;GACf,MAAM,EAAM;GAEZ;EACF;EAGA,AADA,IAAQ;GAAE,MAAM;GAAO,2BAAW,IAAI,IAAI;EAAE,GAC5C,EAAM,IAAI,GAAQ,CAAK;EAEvB,IAAM,IAAgB,GAIhB,KAAQ,YAA2B;GACvC,IAAM,IAAe,EAAO,WACzB,KAAK,GAAK,OAAO;IAAE;IAAK;GAAE,EAAE,CAAC,CAC7B,QAAQ,EAAE,aAAU,EAAI,QAAQ,IAAI,GAEjC,IAAmD,MAAM,QAAQ,IACrE,EAAY,IAAI,OAAO,EAAE,QAAK,YAAS;IAAE,OAAO;IAAG,KAAK,MAAM,EAAI,KAAM;GAAE,EAAE,CAC9E;GAEA,KAAK,IAAM,EAAE,UAAO,YAAS,GAAU;IACrC,IAAM,IAAiD,CAAC;IAQxD,AANI,EAAI,SAAS,KAAA,MAAW,EAAS,SAAS,EAAI,OAE9C,EAAI,cAAc,KAAA,MAAW,EAAS,YAAY,EAAI,YAEtD,EAAI,SAAS,KAAA,MAAW,EAAS,OAAO,EAAI,OAEhD,EAAc,UAAU,IAAI,GAAO,CAAQ;GAC7C;GAGA,AADA,EAAc,OAAO,IACrB,EAAc,OAAO,KAAA;EACvB,EAAA,CAAG;EAEH,EAAM,OAAO;EAEb,IAAI;GACF,MAAM;EACR,SAAS,GAAK;GAEZ,MADA,EAAM,OAAO,CAAM,GACb;EACR;CACF;CAEA,OAAO;EAAE;EAAe;CAAQ;AAClC"}
package/dist/preload.cjs DELETED
@@ -1,2 +0,0 @@
1
- function e(e=20){let t=new Map,n=new Map;return{consume(e){let n=t.get(e);return n!==void 0&&t.delete(e),n},getInflight(e){return n.get(e)},set(n,r){if(t.size>=e){let e=t.keys().next().value;t.delete(e)}t.set(n,r)},track(e,t){n.set(e,t)},untrack(e){n.delete(e)}}}exports.createPreloadManager=e;
2
- //# sourceMappingURL=preload.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preload.cjs","names":[],"sources":["../src/preload.ts"],"sourcesContent":["/**\n * PreloadManager — FIFO cache for preloaded data loader results with concurrent-call deduplication.\n * Eviction removes the oldest inserted entry (insertion-order FIFO, not access-order LRU).\n *\n * - `set(key, results)` — store results; evicts the oldest entry when the cache is full.\n * - `consume(key)` — retrieve and delete results (consume-once semantics).\n * - `track(key, work)` / `untrack(key)` — deduplicate concurrent `preload()` calls for the same route.\n * - `getInflight(key)` — return the in-flight promise if one exists.\n */\nexport type PreloadManager = ReturnType<typeof createPreloadManager>;\n\nexport function createPreloadManager(max = 20) {\n const results = new Map<string, unknown[]>();\n const inflight = new Map<string, Promise<void>>();\n\n return {\n consume(key: string): unknown[] | undefined {\n const cached = results.get(key);\n\n if (cached !== undefined) results.delete(key);\n\n return cached;\n },\n\n getInflight(key: string): Promise<void> | undefined {\n return inflight.get(key);\n },\n\n set(key: string, data: unknown[]): void {\n if (results.size >= max) {\n const oldest = results.keys().next().value as string;\n\n results.delete(oldest);\n }\n\n results.set(key, data);\n },\n\n track(key: string, work: Promise<void>): void {\n inflight.set(key, work);\n },\n\n untrack(key: string): void {\n inflight.delete(key);\n },\n };\n}\n"],"mappings":"AAWA,SAAgB,EAAqB,EAAM,GAAI,CAC7C,IAAM,EAAU,IAAI,IACd,EAAW,IAAI,IAErB,MAAO,CACL,QAAQ,EAAoC,CAC1C,IAAM,EAAS,EAAQ,IAAI,CAAG,EAI9B,OAFI,IAAW,IAAA,IAAW,EAAQ,OAAO,CAAG,EAErC,CACT,EAEA,YAAY,EAAwC,CAClD,OAAO,EAAS,IAAI,CAAG,CACzB,EAEA,IAAI,EAAa,EAAuB,CACtC,GAAI,EAAQ,MAAQ,EAAK,CACvB,IAAM,EAAS,EAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,MAErC,EAAQ,OAAO,CAAM,CACvB,CAEA,EAAQ,IAAI,EAAK,CAAI,CACvB,EAEA,MAAM,EAAa,EAA2B,CAC5C,EAAS,IAAI,EAAK,CAAI,CACxB,EAEA,QAAQ,EAAmB,CACzB,EAAS,OAAO,CAAG,CACrB,CACF,CACF"}
package/dist/preload.d.ts DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * PreloadManager — FIFO cache for preloaded data loader results with concurrent-call deduplication.
3
- * Eviction removes the oldest inserted entry (insertion-order FIFO, not access-order LRU).
4
- *
5
- * - `set(key, results)` — store results; evicts the oldest entry when the cache is full.
6
- * - `consume(key)` — retrieve and delete results (consume-once semantics).
7
- * - `track(key, work)` / `untrack(key)` — deduplicate concurrent `preload()` calls for the same route.
8
- * - `getInflight(key)` — return the in-flight promise if one exists.
9
- */
10
- export type PreloadManager = ReturnType<typeof createPreloadManager>;
11
- export declare function createPreloadManager(max?: number): {
12
- consume(key: string): unknown[] | undefined;
13
- getInflight(key: string): Promise<void> | undefined;
14
- set(key: string, data: unknown[]): void;
15
- track(key: string, work: Promise<void>): void;
16
- untrack(key: string): void;
17
- };
18
- //# sourceMappingURL=preload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preload.d.ts","sourceRoot":"","sources":["../src/preload.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAErE,wBAAgB,oBAAoB,CAAC,GAAG,SAAK;iBAK5B,MAAM,GAAG,OAAO,EAAE,GAAG,SAAS;qBAQ1B,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS;aAI1C,MAAM,QAAQ,OAAO,EAAE,GAAG,IAAI;eAU5B,MAAM,QAAQ,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;iBAIhC,MAAM,GAAG,IAAI;EAI7B"}
package/dist/preload.js DELETED
@@ -1,30 +0,0 @@
1
- //#region src/preload.ts
2
- function e(e = 20) {
3
- let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
4
- return {
5
- consume(e) {
6
- let n = t.get(e);
7
- return n !== void 0 && t.delete(e), n;
8
- },
9
- getInflight(e) {
10
- return n.get(e);
11
- },
12
- set(n, r) {
13
- if (t.size >= e) {
14
- let e = t.keys().next().value;
15
- t.delete(e);
16
- }
17
- t.set(n, r);
18
- },
19
- track(e, t) {
20
- n.set(e, t);
21
- },
22
- untrack(e) {
23
- n.delete(e);
24
- }
25
- };
26
- }
27
- //#endregion
28
- export { e as createPreloadManager };
29
-
30
- //# sourceMappingURL=preload.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preload.js","names":[],"sources":["../src/preload.ts"],"sourcesContent":["/**\n * PreloadManager — FIFO cache for preloaded data loader results with concurrent-call deduplication.\n * Eviction removes the oldest inserted entry (insertion-order FIFO, not access-order LRU).\n *\n * - `set(key, results)` — store results; evicts the oldest entry when the cache is full.\n * - `consume(key)` — retrieve and delete results (consume-once semantics).\n * - `track(key, work)` / `untrack(key)` — deduplicate concurrent `preload()` calls for the same route.\n * - `getInflight(key)` — return the in-flight promise if one exists.\n */\nexport type PreloadManager = ReturnType<typeof createPreloadManager>;\n\nexport function createPreloadManager(max = 20) {\n const results = new Map<string, unknown[]>();\n const inflight = new Map<string, Promise<void>>();\n\n return {\n consume(key: string): unknown[] | undefined {\n const cached = results.get(key);\n\n if (cached !== undefined) results.delete(key);\n\n return cached;\n },\n\n getInflight(key: string): Promise<void> | undefined {\n return inflight.get(key);\n },\n\n set(key: string, data: unknown[]): void {\n if (results.size >= max) {\n const oldest = results.keys().next().value as string;\n\n results.delete(oldest);\n }\n\n results.set(key, data);\n },\n\n track(key: string, work: Promise<void>): void {\n inflight.set(key, work);\n },\n\n untrack(key: string): void {\n inflight.delete(key);\n },\n };\n}\n"],"mappings":";AAWA,SAAgB,EAAqB,IAAM,IAAI;CAC7C,IAAM,oBAAU,IAAI,IAAuB,GACrC,oBAAW,IAAI,IAA2B;CAEhD,OAAO;EACL,QAAQ,GAAoC;GAC1C,IAAM,IAAS,EAAQ,IAAI,CAAG;GAI9B,OAFI,MAAW,KAAA,KAAW,EAAQ,OAAO,CAAG,GAErC;EACT;EAEA,YAAY,GAAwC;GAClD,OAAO,EAAS,IAAI,CAAG;EACzB;EAEA,IAAI,GAAa,GAAuB;GACtC,IAAI,EAAQ,QAAQ,GAAK;IACvB,IAAM,IAAS,EAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;IAErC,EAAQ,OAAO,CAAM;GACvB;GAEA,EAAQ,IAAI,GAAK,CAAI;EACvB;EAEA,MAAM,GAAa,GAA2B;GAC5C,EAAS,IAAI,GAAK,CAAI;EACxB;EAEA,QAAQ,GAAmB;GACzB,EAAS,OAAO,CAAG;EACrB;CACF;AACF"}