@scrolled/nav-graph 0.1.1-dev.7c21e18 → 0.1.1-dev.df34916

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 (43) hide show
  1. package/README.md +12 -7
  2. package/dist/compile/compileGraph.d.ts.map +1 -1
  3. package/dist/compile/compileGraph.js +23 -0
  4. package/dist/compile/compileGraph.js.map +1 -1
  5. package/dist/dsl/builder.d.ts +41 -8
  6. package/dist/dsl/builder.d.ts.map +1 -1
  7. package/dist/dsl/builder.js +26 -4
  8. package/dist/dsl/builder.js.map +1 -1
  9. package/dist/dsl/index.d.ts +1 -1
  10. package/dist/dsl/index.d.ts.map +1 -1
  11. package/dist/dsl/index.js.map +1 -1
  12. package/dist/dsl/requirements.d.ts +2 -1
  13. package/dist/dsl/requirements.d.ts.map +1 -1
  14. package/dist/dsl/requirements.js +10 -2
  15. package/dist/dsl/requirements.js.map +1 -1
  16. package/dist/graphs/starter/index.d.ts.map +1 -1
  17. package/dist/graphs/starter/index.js +16 -7
  18. package/dist/graphs/starter/index.js.map +1 -1
  19. package/dist/index.d.ts +5 -4
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +3 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/ir/schema.d.ts +115 -31
  24. package/dist/ir/schema.d.ts.map +1 -1
  25. package/dist/ir/schema.js +20 -3
  26. package/dist/ir/schema.js.map +1 -1
  27. package/dist/ir/types.d.ts +29 -3
  28. package/dist/ir/types.d.ts.map +1 -1
  29. package/dist/ir/types.js +10 -1
  30. package/dist/ir/types.js.map +1 -1
  31. package/dist/path/findPath.d.ts +33 -0
  32. package/dist/path/findPath.d.ts.map +1 -1
  33. package/dist/path/findPath.js +135 -27
  34. package/dist/path/findPath.js.map +1 -1
  35. package/dist/path/index.d.ts +4 -2
  36. package/dist/path/index.d.ts.map +1 -1
  37. package/dist/path/index.js +2 -1
  38. package/dist/path/index.js.map +1 -1
  39. package/dist/path/unlockables.d.ts +36 -0
  40. package/dist/path/unlockables.d.ts.map +1 -0
  41. package/dist/path/unlockables.js +62 -0
  42. package/dist/path/unlockables.js.map +1 -0
  43. package/package.json +26 -35
@@ -1,37 +1,79 @@
1
- // MVP pathfinding: fewest-hops BFS over the compiled adjacency.
1
+ // Weighted pathfinding: least-time Dijkstra over the compiled adjacency.
2
+ //
3
+ // Two methods cost time — `walk` and `transport` (boats/trains/carpets). Each
4
+ // costs its declared `seconds`, or its method default when untimed, so a graph
5
+ // with no times set still routes sensibly. Every other method (portal, npc,
6
+ // item, skill) is a teleport-like transition, treated as instant.
7
+ //
8
+ // `transport` time is *conditional*: with fast travel enabled (the player holds
9
+ // a fast-travel ticket), every transport hop is instant, so routes prefer boats
10
+ // over long walks; without it, transports cost their ride time and the router
11
+ // may route around them.
12
+ //
13
+ // `scroll` edges (return-to-nearest-town) are *availability*-conditional: they
14
+ // are traversable only when `nearestTownScroll` is set (the player carries
15
+ // return scrolls). They are instant like other teleports when enabled.
2
16
  //
3
17
  // When an eligibility predicate is supplied:
4
- // 1. Run BFS with the predicate pruning candidate edges.
18
+ // 1. Run Dijkstra with the predicate pruning candidate edges.
5
19
  // 2. If the destination is reachable that way, return `status: 'found'`.
6
- // 3. Otherwise run BFS again *without* the filter. If a path exists, return
7
- // `status: 'unreachable-when-filtered'` with the unfiltered path as
20
+ // 3. Otherwise run Dijkstra again *without* the filter. If a path exists,
21
+ // return `status: 'unreachable-when-filtered'` with the unfiltered path as
8
22
  // `fallback` and the step indices the filter blocked. This is FR7 — the
9
23
  // app never has to surface a blank "no path" state when the graph itself
10
24
  // is connected.
11
- // 4. If the unfiltered BFS also fails, return `status: 'unreachable'`.
25
+ // 4. If the unfiltered search also fails, return `status: 'unreachable'`.
26
+ /** Assumed travel time, in seconds, for a walk edge that declares no `seconds`. */
27
+ export const DEFAULT_WALK_SECONDS = 60;
28
+ /**
29
+ * Assumed ride time, in seconds, for a transport edge that declares no
30
+ * `seconds`. Longer than a walk hop: boarding a boat/train means waiting for it.
31
+ */
32
+ export const DEFAULT_TRANSPORT_SECONDS = 300;
33
+ /**
34
+ * Travel time an edge contributes to a route. `walk` always costs time;
35
+ * `transport` costs its ride time unless `fastTravel` waives it; portal / npc /
36
+ * item / skill transitions teleport the player instantly.
37
+ */
38
+ export function edgeSeconds(edge, opts = {}) {
39
+ switch (edge.method) {
40
+ case 'walk':
41
+ return edge.seconds ?? DEFAULT_WALK_SECONDS;
42
+ case 'transport':
43
+ return opts.fastTravel ? 0 : (edge.seconds ?? DEFAULT_TRANSPORT_SECONDS);
44
+ default:
45
+ return 0;
46
+ }
47
+ }
12
48
  export function findPath(graph, from, to, opts = {}) {
13
49
  assertNodeKnown(graph, from, 'from');
14
50
  assertNodeKnown(graph, to, 'to');
15
51
  if (from === to)
16
- return { status: 'found', steps: [] };
17
- const filtered = opts.eligible ? bfs(graph, from, to, opts.eligible) : null;
18
- if (filtered)
19
- return { status: 'found', steps: filtered };
20
- const unfiltered = bfs(graph, from, to);
52
+ return { status: 'found', steps: [], totalSeconds: 0 };
53
+ const cost = { fastTravel: opts.fastTravel };
54
+ const allowScroll = opts.nearestTownScroll ?? false;
55
+ const filtered = opts.eligible
56
+ ? dijkstra(graph, from, to, cost, allowScroll, opts.eligible)
57
+ : null;
58
+ if (filtered) {
59
+ return { status: 'found', steps: filtered.steps, totalSeconds: filtered.totalSeconds };
60
+ }
61
+ const unfiltered = dijkstra(graph, from, to, cost, allowScroll);
21
62
  if (!unfiltered)
22
- return { status: 'unreachable', steps: [] };
63
+ return { status: 'unreachable', steps: [], totalSeconds: 0 };
23
64
  if (!opts.eligible) {
24
- return { status: 'found', steps: unfiltered };
65
+ return { status: 'found', steps: unfiltered.steps, totalSeconds: unfiltered.totalSeconds };
25
66
  }
26
67
  const blocked = [];
27
- unfiltered.forEach((edge, i) => {
68
+ unfiltered.steps.forEach((edge, i) => {
28
69
  if (!opts.eligible(edge))
29
70
  blocked.push(i);
30
71
  });
31
72
  return {
32
73
  status: 'unreachable-when-filtered',
33
74
  steps: [],
34
- fallback: { steps: unfiltered, blocked },
75
+ totalSeconds: 0,
76
+ fallback: { steps: unfiltered.steps, totalSeconds: unfiltered.totalSeconds, blocked },
35
77
  };
36
78
  }
37
79
  function assertNodeKnown(graph, id, label) {
@@ -39,23 +81,33 @@ function assertNodeKnown(graph, id, label) {
39
81
  throw new Error(`findPath ${label} references undeclared node "${id}".`);
40
82
  }
41
83
  }
42
- function bfs(graph, from, to, eligible) {
84
+ function dijkstra(graph, from, to, cost, allowScroll, eligible) {
85
+ const dist = new Map([[from, 0]]);
43
86
  const cameFrom = new Map();
44
- const visited = new Set([from]);
45
- const queue = [from];
46
- while (queue.length > 0) {
47
- const node = queue.shift();
87
+ const settled = new Set();
88
+ const frontier = new MinHeap();
89
+ frontier.push(from, 0);
90
+ while (!frontier.isEmpty()) {
91
+ const node = frontier.pop();
92
+ if (settled.has(node))
93
+ continue; // stale heap entry — already finalized
48
94
  if (node === to)
49
- return reconstruct(cameFrom, from, to);
50
- const out = graph.adjacency.get(node) ?? [];
51
- for (const edge of out) {
95
+ return { steps: reconstruct(cameFrom, from, to), totalSeconds: dist.get(to) };
96
+ settled.add(node);
97
+ const base = dist.get(node);
98
+ for (const edge of graph.adjacency.get(node) ?? []) {
99
+ if (edge.method === 'scroll' && !allowScroll)
100
+ continue;
52
101
  if (eligible && !eligible(edge))
53
102
  continue;
54
- if (visited.has(edge.to))
103
+ if (settled.has(edge.to))
55
104
  continue;
56
- visited.add(edge.to);
57
- cameFrom.set(edge.to, edge);
58
- queue.push(edge.to);
105
+ const next = base + edgeSeconds(edge, cost);
106
+ if (next < (dist.get(edge.to) ?? Infinity)) {
107
+ dist.set(edge.to, next);
108
+ cameFrom.set(edge.to, edge);
109
+ frontier.push(edge.to, next);
110
+ }
59
111
  }
60
112
  }
61
113
  return null;
@@ -66,7 +118,7 @@ function reconstruct(cameFrom, from, to) {
66
118
  while (cursor !== from) {
67
119
  const edge = cameFrom.get(cursor);
68
120
  if (!edge) {
69
- // Defensive: BFS only stores cameFrom for reachable nodes, so this
121
+ // Defensive: Dijkstra only stores cameFrom for reachable nodes, so this
70
122
  // branch is unreachable in practice — but typing the lookup demands it.
71
123
  throw new Error(`Path reconstruction broke at "${cursor}".`);
72
124
  }
@@ -75,4 +127,60 @@ function reconstruct(cameFrom, from, to) {
75
127
  }
76
128
  return steps.reverse();
77
129
  }
130
+ // Binary min-heap keyed by tentative distance. Uses lazy deletion — a node can
131
+ // appear more than once and settled entries are skipped on pop.
132
+ class MinHeap {
133
+ nodes = [];
134
+ keys = [];
135
+ isEmpty() {
136
+ return this.nodes.length === 0;
137
+ }
138
+ push(node, key) {
139
+ this.nodes.push(node);
140
+ this.keys.push(key);
141
+ this.bubbleUp(this.nodes.length - 1);
142
+ }
143
+ pop() {
144
+ if (this.nodes.length === 0)
145
+ return undefined;
146
+ const top = this.nodes[0];
147
+ const lastNode = this.nodes.pop();
148
+ const lastKey = this.keys.pop();
149
+ if (this.nodes.length > 0) {
150
+ this.nodes[0] = lastNode;
151
+ this.keys[0] = lastKey;
152
+ this.bubbleDown(0);
153
+ }
154
+ return top;
155
+ }
156
+ bubbleUp(i) {
157
+ while (i > 0) {
158
+ const parent = (i - 1) >> 1;
159
+ if (this.keys[parent] <= this.keys[i])
160
+ break;
161
+ this.swap(i, parent);
162
+ i = parent;
163
+ }
164
+ }
165
+ bubbleDown(i) {
166
+ const n = this.nodes.length;
167
+ for (;;) {
168
+ const left = 2 * i + 1;
169
+ const right = left + 1;
170
+ let smallest = i;
171
+ if (left < n && this.keys[left] < this.keys[smallest])
172
+ smallest = left;
173
+ if (right < n && this.keys[right] < this.keys[smallest])
174
+ smallest = right;
175
+ if (smallest === i)
176
+ break;
177
+ this.swap(i, smallest);
178
+ i = smallest;
179
+ }
180
+ }
181
+ swap(a, b) {
182
+ [this.nodes[a], this.nodes[b]] = [this.nodes[b], this.nodes[a]];
183
+ [this.keys[a], this.keys[b]] = [this.keys[b], this.keys[a]];
184
+ }
185
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,CAAC,GAAG,CAAC,CAAC;YACvB,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC;YACvB,IAAI,QAAQ,GAAG,CAAC,CAAC;YACjB,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAAE,QAAQ,GAAG,IAAI,CAAC;YACvE,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAAE,QAAQ,GAAG,KAAK,CAAC;YAC1E,IAAI,QAAQ,KAAK,CAAC;gBAAE,MAAM;YAC1B,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;YACvB,CAAC,GAAG,QAAQ,CAAC;QACf,CAAC;IACH,CAAC;IAEO,IAAI,CAAC,CAAS,EAAE,CAAS;QAC/B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAChE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF"}
@@ -1,5 +1,7 @@
1
1
  export { eligibilityFilter } from './eligibility';
2
2
  export type { UserCapability } from './eligibility';
3
- export { findPath } from './findPath';
4
- export type { FindPathOptions, PathResult } from './findPath';
3
+ export { collectUnlockables, isUnlockable, lockedRequirementsFilter, requirementEntityId, requirementKey, } from './unlockables';
4
+ export type { UnlockableEntry, UnlockableKind, UnlockableRequirement } from './unlockables';
5
+ export { DEFAULT_TRANSPORT_SECONDS, DEFAULT_WALK_SECONDS, edgeSeconds, findPath } from './findPath';
6
+ export type { EdgeCostOptions, FindPathOptions, PathResult } from './findPath';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/path/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/path/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACpG,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { eligibilityFilter } from './eligibility';
2
- export { findPath } from './findPath';
2
+ export { collectUnlockables, isUnlockable, lockedRequirementsFilter, requirementEntityId, requirementKey, } from './unlockables';
3
+ export { DEFAULT_TRANSPORT_SECONDS, DEFAULT_WALK_SECONDS, edgeSeconds, findPath } from './findPath';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/path/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/path/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { NavGraphSource, Requirement, TravelEdge } from '../ir/types';
2
+ export type UnlockableKind = 'item' | 'quest';
3
+ export type UnlockableRequirement = Extract<Requirement, {
4
+ kind: UnlockableKind;
5
+ }>;
6
+ export declare function isUnlockable(req: Requirement): req is UnlockableRequirement;
7
+ /** The opaque entity id a requirement gates on. */
8
+ export declare function requirementEntityId(req: UnlockableRequirement): number;
9
+ /**
10
+ * Stable `${kind}:${id}` key identifying a requirement's unlockable subject.
11
+ * Two edges that require the same item (or quest) share a key, so one toggle
12
+ * governs both.
13
+ */
14
+ export declare function requirementKey(req: UnlockableRequirement): string;
15
+ /** One distinct unlockable subject referenced somewhere in the graph. */
16
+ export interface UnlockableEntry {
17
+ key: string;
18
+ kind: UnlockableKind;
19
+ id: number;
20
+ /** Author-supplied display name, when any edge naming this subject provides one. */
21
+ name?: string;
22
+ }
23
+ /**
24
+ * Every distinct item/quest requirement referenced by the graph's edges, one
25
+ * entry per `${kind}:${id}` in first-seen order. A named occurrence wins over
26
+ * an anonymous one, so a subject named on any edge surfaces its name.
27
+ */
28
+ export declare function collectUnlockables(source: NavGraphSource): UnlockableEntry[];
29
+ /**
30
+ * An eligibility predicate for `findPath` that blocks any edge requiring a
31
+ * *locked* item or quest — a subject whose `${kind}:${id}` key is in `locked`.
32
+ * Non-unlockable requirements (meso, level) never block. An empty set passes
33
+ * every edge, matching "all requirements unlocked by default".
34
+ */
35
+ export declare function lockedRequirementsFilter(locked: ReadonlySet<string>): (edge: TravelEdge) => boolean;
36
+ //# sourceMappingURL=unlockables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unlockables.d.ts","sourceRoot":"","sources":["../../src/path/unlockables.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE3E,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC,CAAC;AAEnF,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,IAAI,qBAAqB,CAE3E;AAED,mDAAmD;AACnD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,qBAAqB,GAAG,MAAM,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,qBAAqB,GAAG,MAAM,CAEjE;AAED,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,cAAc,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,eAAe,EAAE,CAoB5E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,GAC1B,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAM/B"}
@@ -0,0 +1,62 @@
1
+ // The "requirements you've unlocked" model.
2
+ //
3
+ // Two requirement kinds gate on an opaque game entity id — `item` and `quest`.
4
+ // Those are things a traveller either has unlocked or hasn't, so the navigator
5
+ // lets them declare which ones they hold and routes around the rest. `meso` and
6
+ // `level` are scalar thresholds rather than opaque ids, so they're never gated
7
+ // here and always pass.
8
+ export function isUnlockable(req) {
9
+ return req.kind === 'item' || req.kind === 'quest';
10
+ }
11
+ /** The opaque entity id a requirement gates on. */
12
+ export function requirementEntityId(req) {
13
+ return req.kind === 'item' ? req.itemId : req.questId;
14
+ }
15
+ /**
16
+ * Stable `${kind}:${id}` key identifying a requirement's unlockable subject.
17
+ * Two edges that require the same item (or quest) share a key, so one toggle
18
+ * governs both.
19
+ */
20
+ export function requirementKey(req) {
21
+ return `${req.kind}:${requirementEntityId(req)}`;
22
+ }
23
+ /**
24
+ * Every distinct item/quest requirement referenced by the graph's edges, one
25
+ * entry per `${kind}:${id}` in first-seen order. A named occurrence wins over
26
+ * an anonymous one, so a subject named on any edge surfaces its name.
27
+ */
28
+ export function collectUnlockables(source) {
29
+ const byKey = new Map();
30
+ for (const edge of source.edges) {
31
+ for (const req of edge.requirements ?? []) {
32
+ if (!isUnlockable(req))
33
+ continue;
34
+ const key = requirementKey(req);
35
+ const existing = byKey.get(key);
36
+ if (!existing) {
37
+ byKey.set(key, {
38
+ key,
39
+ kind: req.kind,
40
+ id: requirementEntityId(req),
41
+ ...(req.name ? { name: req.name } : {}),
42
+ });
43
+ }
44
+ else if (!existing.name && req.name) {
45
+ existing.name = req.name;
46
+ }
47
+ }
48
+ }
49
+ return [...byKey.values()];
50
+ }
51
+ /**
52
+ * An eligibility predicate for `findPath` that blocks any edge requiring a
53
+ * *locked* item or quest — a subject whose `${kind}:${id}` key is in `locked`.
54
+ * Non-unlockable requirements (meso, level) never block. An empty set passes
55
+ * every edge, matching "all requirements unlocked by default".
56
+ */
57
+ export function lockedRequirementsFilter(locked) {
58
+ if (locked.size === 0)
59
+ return () => true;
60
+ return (edge) => (edge.requirements ?? []).every((req) => !isUnlockable(req) || !locked.has(requirementKey(req)));
61
+ }
62
+ //# sourceMappingURL=unlockables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unlockables.js","sourceRoot":"","sources":["../../src/path/unlockables.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,wBAAwB;AAQxB,MAAM,UAAU,YAAY,CAAC,GAAgB;IAC3C,OAAO,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,CAAC;AACrD,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,mBAAmB,CAAC,GAA0B;IAC5D,OAAO,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAA0B;IACvD,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC;AACnD,CAAC;AAWD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAsB;IACvD,MAAM,KAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,YAAY,IAAI,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;gBAAE,SAAS;YACjC,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;YAChC,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;oBACb,GAAG;oBACH,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,EAAE,EAAE,mBAAmB,CAAC,GAAG,CAAC;oBAC5B,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACxC,CAAC,CAAC;YACL,CAAC;iBAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;gBACtC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAA2B;IAE3B,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;IACzC,OAAO,CAAC,IAAI,EAAE,EAAE,CACd,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,KAAK,CAC7B,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAChE,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrolled/nav-graph",
3
- "version": "0.1.1-dev.7c21e18",
3
+ "version": "0.1.1-dev.df34916",
4
4
  "type": "module",
5
5
  "description": "Framework-agnostic graph core: IR types + Zod schema, an authoring DSL, a compiler (IR → runtime adjacency), and pathfinding (BFS + eligibility). The engine behind Scrolled Navigator; usable standalone in Node and the browser.",
6
6
  "license": "Apache-2.0",
@@ -29,42 +29,25 @@
29
29
  "README.md",
30
30
  "LICENSE"
31
31
  ],
32
- "main": "./src/index.ts",
33
- "module": "./src/index.ts",
34
- "types": "./src/index.ts",
32
+ "main": "./dist/index.js",
33
+ "module": "./dist/index.js",
34
+ "types": "./dist/index.d.ts",
35
35
  "exports": {
36
- ".": "./src/index.ts",
37
- "./ir": "./src/ir/index.ts",
38
- "./dsl": "./src/dsl/index.ts"
39
- },
40
- "publishConfig": {
41
- "access": "public",
42
- "main": "./dist/index.js",
43
- "module": "./dist/index.js",
44
- "types": "./dist/index.d.ts",
45
- "exports": {
46
- ".": {
47
- "types": "./dist/index.d.ts",
48
- "import": "./dist/index.js"
49
- },
50
- "./ir": {
51
- "types": "./dist/ir/index.d.ts",
52
- "import": "./dist/ir/index.js"
53
- },
54
- "./dsl": {
55
- "types": "./dist/dsl/index.d.ts",
56
- "import": "./dist/dsl/index.js"
57
- }
36
+ ".": {
37
+ "types": "./dist/index.d.ts",
38
+ "import": "./dist/index.js"
39
+ },
40
+ "./ir": {
41
+ "types": "./dist/ir/index.d.ts",
42
+ "import": "./dist/ir/index.js"
43
+ },
44
+ "./dsl": {
45
+ "types": "./dist/dsl/index.d.ts",
46
+ "import": "./dist/dsl/index.js"
58
47
  }
59
48
  },
60
- "scripts": {
61
- "build": "tsc -p tsconfig.build.json",
62
- "clean": "rm -rf dist LICENSE",
63
- "export": "vite-node src/cli/export.ts",
64
- "test": "vitest run --passWithNoTests",
65
- "typecheck": "tsc --noEmit",
66
- "lint": "eslint .",
67
- "prepublishOnly": "pnpm run typecheck && pnpm run test && pnpm run clean && pnpm run build && cp ../../LICENSE LICENSE"
49
+ "publishConfig": {
50
+ "access": "public"
68
51
  },
69
52
  "dependencies": {
70
53
  "zod": "^3.23.8"
@@ -74,5 +57,13 @@
74
57
  "vite": "^5.4.8",
75
58
  "vite-node": "^2.1.2",
76
59
  "vitest": "^2.1.2"
60
+ },
61
+ "scripts": {
62
+ "build": "tsc -p tsconfig.build.json",
63
+ "clean": "rm -rf dist LICENSE",
64
+ "export": "vite-node src/cli/export.ts",
65
+ "test": "vitest run --passWithNoTests",
66
+ "typecheck": "tsc --noEmit",
67
+ "lint": "eslint ."
77
68
  }
78
- }
69
+ }