@terrafirmagreg-team/recipe 1.2.43 → 1.2.44

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/package.json +4 -3
  2. package/src/components/cards/calc-add-item.tsx +2 -1
  3. package/src/components/views/browser/frame.tsx +36 -9
  4. package/src/components/views/browser/query-controls.tsx +6 -1
  5. package/src/components/views/browser/type-view.tsx +21 -2
  6. package/src/components/views/calc/calculator/help.tsx +6 -6
  7. package/src/components/views/calc/calculator/index.tsx +29 -6
  8. package/src/components/views/calc/edge.tsx +197 -113
  9. package/src/components/views/calc/flow/index.tsx +120 -39
  10. package/src/components/views/calc/flow/notes.tsx +282 -0
  11. package/src/components/views/calc/flow/toolbar.tsx +46 -1
  12. package/src/components/views/calc/flow/view-menu.tsx +11 -0
  13. package/src/components/views/calc/material-picker.tsx +112 -0
  14. package/src/components/views/calc/node-card/badges.tsx +2 -2
  15. package/src/components/views/calc/node-card/full.tsx +13 -2
  16. package/src/components/views/calc/node-card/menu.tsx +0 -17
  17. package/src/components/views/calc/node-card/port-cells.tsx +4 -4
  18. package/src/components/views/calc/node-card/ports.tsx +6 -1
  19. package/src/components/views/calc/recipe-picker/body.tsx +21 -5
  20. package/src/components/views/calc/recipe-picker/footer.tsx +1 -28
  21. package/src/hooks/calc/flow/use-handlers.ts +21 -14
  22. package/src/hooks/calc/flow/use-layout.ts +7 -7
  23. package/src/hooks/calc/flow/use-shift-held.ts +25 -0
  24. package/src/hooks/calc/use-actions.ts +126 -61
  25. package/src/hooks/calc/use-amounts.ts +8 -5
  26. package/src/hooks/calc/use-data.ts +11 -8
  27. package/src/hooks/calc/use-history.ts +98 -0
  28. package/src/hooks/calc/use-pipe-edit.ts +21 -0
  29. package/src/hooks/calc/use-snap.ts +17 -0
  30. package/src/hooks/calc/use-storage.ts +2 -1
  31. package/src/hooks/use-add-to-calc.ts +2 -1
  32. package/src/hooks/use-item-press.ts +4 -2
  33. package/src/hooks/use-query.ts +22 -1
  34. package/src/hooks/use-session.ts +2 -0
  35. package/src/lib/browser/row-search.test.ts +55 -0
  36. package/src/lib/browser/row-search.ts +24 -0
  37. package/src/lib/calc/flow.ts +31 -26
  38. package/src/lib/calc/member.test.ts +5 -5
  39. package/src/lib/calc/pack.ts +6 -6
  40. package/src/lib/calc/{wire.test.ts → pipe.test.ts} +5 -5
  41. package/src/lib/calc/{wire.ts → pipe.ts} +9 -9
  42. package/src/lib/calc/route/index.ts +1 -0
  43. package/src/lib/calc/scheme.test.ts +7 -7
  44. package/src/lib/calc/scheme.ts +16 -15
  45. package/src/lib/calc/storage/entry.test.ts +66 -0
  46. package/src/lib/calc/storage/entry.ts +29 -7
  47. package/src/lib/calc/storage/store.ts +3 -1
  48. package/src/lib/calc/tree/share.test.ts +102 -0
  49. package/src/lib/calc/tree/share.ts +43 -13
  50. package/src/lib/links.ts +3 -0
  51. package/src/types/calc-flow-props.ts +13 -2
  52. package/src/types/calc.ts +23 -3
  53. package/src/types/index.ts +3 -0
  54. package/styles/calc.css +65 -39
@@ -46,6 +46,8 @@ export function useRecipeQuery(dataset: DatasetRef, version?: string) {
46
46
  isAlloy && params.get('unit') === 'ingot' ? ('ingot' as const) : undefined;
47
47
  const alloyMix = isAlloy ? (params.get('mix') ?? undefined) : undefined;
48
48
  const searchParam = isTool ? '' : (params.get('search') ?? '');
49
+ const rsearchParam =
50
+ isTool && !isCalc ? '' : (params.get('rsearch') ?? '');
49
51
  const rpageValue = isTool ? 0 : urlPage(params, 'rpage');
50
52
 
51
53
  const [query, setQuery] = useState(searchParam);
@@ -54,6 +56,12 @@ export function useRecipeQuery(dataset: DatasetRef, version?: string) {
54
56
  setLastSearch(searchParam);
55
57
  setQuery(searchParam);
56
58
  }
59
+ const [rquery, setRquery] = useState(rsearchParam);
60
+ const [lastRsearch, setLastRsearch] = useState(rsearchParam);
61
+ if (lastRsearch !== rsearchParam) {
62
+ setLastRsearch(rsearchParam);
63
+ setRquery(rsearchParam);
64
+ }
57
65
 
58
66
  useEffect(() => {
59
67
  if (!isTool) return;
@@ -73,6 +81,7 @@ export function useRecipeQuery(dataset: DatasetRef, version?: string) {
73
81
  params.get('fluid') ||
74
82
  params.get('relation') ||
75
83
  params.get('search') ||
84
+ params.get('rsearch') ||
76
85
  params.get('rpage') ||
77
86
  params.get('solo') ||
78
87
  params.get('tree') ||
@@ -80,7 +89,13 @@ export function useRecipeQuery(dataset: DatasetRef, version?: string) {
80
89
  if (!stray) return;
81
90
  replaceUrlState(
82
91
  isCalc
83
- ? recipeCalcHref(dataset, resolved, tree || undefined, version)
92
+ ? recipeCalcHref(
93
+ dataset,
94
+ resolved,
95
+ tree || undefined,
96
+ version,
97
+ params.get('rsearch') || undefined,
98
+ )
84
99
  : recipeHref(dataset, resolved, {
85
100
  tool: place.kind,
86
101
  id: recipeId,
@@ -118,6 +133,7 @@ export function useRecipeQuery(dataset: DatasetRef, version?: string) {
118
133
  relation,
119
134
  tab,
120
135
  search: searchParam || undefined,
136
+ rsearch: rsearchParam || undefined,
121
137
  rpage: rpageValue + 1,
122
138
  version,
123
139
  }),
@@ -136,6 +152,7 @@ export function useRecipeQuery(dataset: DatasetRef, version?: string) {
136
152
  relation,
137
153
  tab,
138
154
  searchParam,
155
+ rsearchParam,
139
156
  rpageValue,
140
157
  ]);
141
158
 
@@ -154,6 +171,7 @@ export function useRecipeQuery(dataset: DatasetRef, version?: string) {
154
171
  relation,
155
172
  tab,
156
173
  search: searchParam || undefined,
174
+ rsearch: rsearchParam || undefined,
157
175
  rpage: rpageValue + 1,
158
176
  version,
159
177
  }),
@@ -171,6 +189,7 @@ export function useRecipeQuery(dataset: DatasetRef, version?: string) {
171
189
  relation,
172
190
  tab,
173
191
  searchParam,
192
+ rsearchParam,
174
193
  rpageValue,
175
194
  ]);
176
195
 
@@ -187,6 +206,8 @@ export function useRecipeQuery(dataset: DatasetRef, version?: string) {
187
206
  tree,
188
207
  query,
189
208
  setQuery,
209
+ rquery,
210
+ setRquery,
190
211
  rpage: rpageValue,
191
212
  };
192
213
  }
@@ -93,6 +93,7 @@ export function useRecipeSession(page: RecipePageData): RecipeSession {
93
93
  id: query.recipeId,
94
94
  relation: query.relation,
95
95
  search: query.query || undefined,
96
+ rsearch: query.rquery || undefined,
96
97
  rpage: query.rpage + 1,
97
98
  version: selection?.version,
98
99
  }),
@@ -105,6 +106,7 @@ export function useRecipeSession(page: RecipePageData): RecipeSession {
105
106
  query.recipeId,
106
107
  query.relation,
107
108
  query.query,
109
+ query.rquery,
108
110
  query.rpage,
109
111
  selection?.version,
110
112
  ],
@@ -0,0 +1,55 @@
1
+ import assert from 'node:assert/strict';
2
+ import { test } from 'node:test';
3
+ import { rowMatchesTerms, rowSearchTerms } from './row-search';
4
+ import type { RecipeCompactRow } from '@terrafirmagreg-team/recipe/types';
5
+
6
+ const ROW: RecipeCompactRow = {
7
+ id: 'gtceu:lathe/lathe_amethyst_to_rod',
8
+ type: 0,
9
+ in: ['gtceu:amethyst_gem'],
10
+ out: ['gtceu:amethyst_rod'],
11
+ };
12
+
13
+ const NAMES: Record<string, string> = {
14
+ 'gtceu:amethyst_gem': 'Amethyst Gem',
15
+ 'gtceu:amethyst_rod': 'Amethyst Rod',
16
+ };
17
+ const nameOf = (id: string) => NAMES[id];
18
+
19
+ test('rowSearchTerms splits on |, trims, lowercases, drops empties', () => {
20
+ assert.deepEqual(rowSearchTerms(''), []);
21
+ assert.deepEqual(rowSearchTerms('rod'), ['rod']);
22
+ assert.deepEqual(rowSearchTerms('Rod | RUBY '), ['rod', 'ruby']);
23
+ assert.deepEqual(rowSearchTerms('a||b'), ['a', 'b']);
24
+ assert.deepEqual(rowSearchTerms('|'), []);
25
+ });
26
+
27
+ test('rowMatchesTerms passes everything without terms', () => {
28
+ assert.equal(rowMatchesTerms(ROW, [], nameOf), true);
29
+ });
30
+
31
+ test('rowMatchesTerms matches input and output ids', () => {
32
+ assert.equal(rowMatchesTerms(ROW, ['amethyst_gem'], nameOf), true);
33
+ assert.equal(rowMatchesTerms(ROW, ['rod'], nameOf), true);
34
+ assert.equal(rowMatchesTerms(ROW, ['ingot'], nameOf), false);
35
+ });
36
+
37
+ test('rowMatchesTerms matches localized names via nameOf', () => {
38
+ assert.equal(rowMatchesTerms(ROW, ['amethyst rod'], nameOf), true);
39
+ assert.equal(rowMatchesTerms(ROW, ['gem'], nameOf), true);
40
+ });
41
+
42
+ test('rowMatchesTerms ORs terms across inputs and outputs', () => {
43
+ assert.equal(rowMatchesTerms(ROW, rowSearchTerms('copper|gem'), nameOf), true);
44
+ assert.equal(
45
+ rowMatchesTerms(ROW, rowSearchTerms('copper|iron'), nameOf),
46
+ false,
47
+ );
48
+ });
49
+
50
+ test('rowMatchesTerms tolerates names missing from the map', () => {
51
+ const noName = () => undefined;
52
+ assert.equal(rowMatchesTerms(ROW, ['rod'], noName), true);
53
+ assert.equal(rowMatchesTerms(ROW, ['amethyst rod'], noName), false);
54
+ assert.equal(rowMatchesTerms(ROW, ['amethyst rod'], nameOf), true);
55
+ });
@@ -0,0 +1,24 @@
1
+ import type { RecipeCompactRow } from '@terrafirmagreg-team/recipe/types';
2
+
3
+ export function rowSearchTerms(query: string): string[] {
4
+ return query
5
+ .split('|')
6
+ .map((term) => term.trim().toLowerCase())
7
+ .filter(Boolean);
8
+ }
9
+
10
+ export function rowMatchesTerms(
11
+ row: RecipeCompactRow,
12
+ terms: string[],
13
+ nameOf: (id: string) => string | undefined,
14
+ ): boolean {
15
+ if (!terms.length) return true;
16
+ const ids = [...row.in, ...row.out];
17
+ return terms.some((term) =>
18
+ ids.some(
19
+ (id) =>
20
+ id.toLowerCase().includes(term) ||
21
+ (nameOf(id)?.toLowerCase().includes(term) ?? false),
22
+ ),
23
+ );
24
+ }
@@ -2,12 +2,13 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
2
2
  import type { Edge, Node } from '@terrafirmagreg-team/ui/lib/canvas/xyflow';
3
3
  import type { Recipe } from '@terrafirmagreg-team/recipe/lib/data/dto';
4
4
  import { PORT_IN } from '@terrafirmagreg-team/recipe/lib/calc/ports';
5
- import { resolveWireEnds } from '@terrafirmagreg-team/recipe/lib/calc/wire';
5
+ import { resolvePipeEnds } from '@terrafirmagreg-team/recipe/lib/calc/pipe';
6
6
  import type {
7
7
  CalcKind,
8
8
  CalcNode,
9
+ CalcNote,
9
10
  CalcRecipeSummary,
10
- CalcWire,
11
+ CalcPipe,
11
12
  } from '@terrafirmagreg-team/recipe/types/calc';
12
13
  import type { RecipeRelation } from '@terrafirmagreg-team/recipe/types';
13
14
  import type { FlowPoint } from '@terrafirmagreg-team/ui/types/canvas';
@@ -73,25 +74,27 @@ export type CalcFlowData = {
73
74
  crafts: number | ((current: number) => number),
74
75
  ) => void;
75
76
  pendingCrafts?: Map<string, number> | null;
76
- onWire: (from: string, to: string, input: number, out?: number) => void;
77
- onUnwire: (
77
+ onConnect: (from: string, to: string, input: number, out?: number) => void;
78
+ onDisconnect: (
78
79
  from: string,
79
80
  to: string,
80
81
  input: number,
81
82
  out?: number,
82
83
  ) => void;
83
- onRewire: (
84
+ onReroute: (
84
85
  from: string,
85
86
  to: string,
86
87
  input: number,
87
88
  next: { from: string; to: string; input: number; out?: number },
88
89
  ) => void;
89
- onWireAmount: (
90
+ onPipeLimit: (
90
91
  from: string,
91
92
  to: string,
92
93
  input: number,
93
94
  amount: number | null,
94
95
  ) => void;
96
+ onEditNote: (id: string, text: string) => void;
97
+ onNoteColor: (id: string, color: CalcNote['color']) => void;
95
98
  recipeDefaults: Record<string, string>;
96
99
  onSetRecipeDefault: (materialId: string, recipeId: string | null) => void;
97
100
  };
@@ -120,7 +123,7 @@ export function nodeSize(
120
123
 
121
124
  export function cardsToFlow(
122
125
  nodes: CalcNode[],
123
- wires: readonly CalcWire[],
126
+ pipes: readonly CalcPipe[],
124
127
  data: Omit<CalcFlowData, 'node'>,
125
128
  flows?: readonly (number | undefined)[],
126
129
  ): { nodes: AnyCalcFlowNode[]; edges: Edge[] } {
@@ -139,34 +142,34 @@ export function cardsToFlow(
139
142
  };
140
143
  });
141
144
  const byId = new Map(nodes.map((node) => [node.id, node]));
142
- const edges: Edge[] = wires.flatMap((wire, index) => {
143
- const src = byId.get(wire.from);
144
- const dst = byId.get(wire.to);
145
+ const edges: Edge[] = pipes.flatMap((pipe, index) => {
146
+ const src = byId.get(pipe.from);
147
+ const dst = byId.get(pipe.to);
145
148
  if (!src || !dst) return [];
146
- const ends = resolveWireEnds(src, dst, wire);
149
+ const ends = resolvePipeEnds(src, dst, pipe);
147
150
  if (!ends) return [];
148
151
  const input = dst.inputs[ends.inputIndex];
149
- if (!input?.wired) return [];
152
+ if (!input?.connected) return [];
150
153
  const outIndex = ends.outIndex;
151
154
  const mat = src.outputs[outIndex];
152
155
  return [
153
156
  {
154
- id: `wire:${wire.from}->${wire.to}:${wire.input}:${index}`,
155
- source: wire.from,
157
+ id: `pipe:${pipe.from}->${pipe.to}:${pipe.input}:${index}`,
158
+ source: pipe.from,
156
159
  sourceHandle: outIndex > 0 ? `out-${outIndex}` : 'out',
157
- target: wire.to,
160
+ target: pipe.to,
158
161
  targetHandle: `in-${ends.inputIndex}`,
159
162
  type: 'calcEdge',
160
- className: 'calc-edge--wire',
163
+ className: 'calc-edge--pipe',
161
164
  deletable: true,
162
165
  data: {
163
- wire,
166
+ pipe,
164
167
  flow: flows?.[index],
165
168
  matId: mat?.id ?? input.id,
166
169
  matKind: mat?.kind ?? input.kind,
167
170
  dataset: data.dataset,
168
- onWireAmount: data.onWireAmount,
169
- onUnwire: data.onUnwire,
171
+ onPipeLimit: data.onPipeLimit,
172
+ onDisconnect: data.onDisconnect,
170
173
  },
171
174
  },
172
175
  ];
@@ -205,7 +208,7 @@ function sameCalcNode(a: CalcNode, b: CalcNode): boolean {
205
208
  inp.id === b.inputs[index]?.id &&
206
209
  inp.amount === b.inputs[index]?.amount &&
207
210
  inp.covered === b.inputs[index]?.covered &&
208
- inp.wired === b.inputs[index]?.wired &&
211
+ inp.connected === b.inputs[index]?.connected &&
209
212
  inp.catalyst === b.inputs[index]?.catalyst &&
210
213
  (inp.members?.join() ?? '') ===
211
214
  (b.inputs[index]?.members?.join() ?? ''),
@@ -244,10 +247,12 @@ function sameFlowData(a: CalcFlowData, b: CalcFlowData): boolean {
244
247
  a.onMoveCard === b.onMoveCard &&
245
248
  a.onCrafts === b.onCrafts &&
246
249
  a.pendingCrafts === b.pendingCrafts &&
247
- a.onWire === b.onWire &&
248
- a.onUnwire === b.onUnwire &&
249
- a.onRewire === b.onRewire &&
250
- a.onWireAmount === b.onWireAmount &&
250
+ a.onConnect === b.onConnect &&
251
+ a.onDisconnect === b.onDisconnect &&
252
+ a.onReroute === b.onReroute &&
253
+ a.onPipeLimit === b.onPipeLimit &&
254
+ a.onEditNote === b.onEditNote &&
255
+ a.onNoteColor === b.onNoteColor &&
251
256
  a.recipeDefaults === b.recipeDefaults &&
252
257
  a.onSetRecipeDefault === b.onSetRecipeDefault
253
258
  );
@@ -318,8 +323,8 @@ export function reconcileCalcEdges(
318
323
  kept.targetHandle === edge.targetHandle &&
319
324
  kept.className === edge.className &&
320
325
  kept.data?.flow === edge.data?.flow &&
321
- (kept.data?.wire as CalcWire | undefined)?.amount ===
322
- (edge.data?.wire as CalcWire | undefined)?.amount &&
326
+ (kept.data?.pipe as CalcPipe | undefined)?.amount ===
327
+ (edge.data?.pipe as CalcPipe | undefined)?.amount &&
323
328
  ((kept.data?.points as FlowPoint[] | undefined)?.length ?? 0) ===
324
329
  ((edge.data?.points as FlowPoint[] | undefined)?.length ?? 0) &&
325
330
  (kept.data?.points as FlowPoint[] | undefined)?.every(
@@ -63,7 +63,7 @@ test('pinnedRecipe pins a tag slot to the selected member', () => {
63
63
  catalyst: false,
64
64
  tagId: 'forge:rods/amethyst',
65
65
  members: ['minecraft:amethyst_shard', 'gtceu:amethyst_rod'],
66
- wired: false,
66
+ connected: false,
67
67
  covered: 0,
68
68
  },
69
69
  ]);
@@ -83,7 +83,7 @@ test('pinnedRecipe matches hash-prefixed selections and widget ids', () => {
83
83
  amount: 1,
84
84
  catalyst: false,
85
85
  tagId: '#forge:rods/amethyst',
86
- wired: false,
86
+ connected: false,
87
87
  covered: 0,
88
88
  },
89
89
  ]);
@@ -104,7 +104,7 @@ test('pinnedRecipe keeps cycling when no selection exists', () => {
104
104
  catalyst: false,
105
105
  tagId: 'forge:rods/amethyst',
106
106
  members: ['minecraft:amethyst_shard', 'gtceu:amethyst_rod'],
107
- wired: false,
107
+ connected: false,
108
108
  covered: 0,
109
109
  },
110
110
  ]);
@@ -129,7 +129,7 @@ test('pinnedRecipe matches members by base id against NBT alternatives', () => {
129
129
  amount: 1,
130
130
  catalyst: false,
131
131
  tagId: '#forge:tools/hammers',
132
- wired: false,
132
+ connected: false,
133
133
  covered: 0,
134
134
  },
135
135
  ]);
@@ -163,7 +163,7 @@ test('pinnedRecipe pins the picked member outside alternatives and skips non-tag
163
163
  amount: 1,
164
164
  catalyst: false,
165
165
  tagId: 'forge:rods/amethyst',
166
- wired: false,
166
+ connected: false,
167
167
  covered: 0,
168
168
  },
169
169
  ]);
@@ -1,7 +1,7 @@
1
1
  import type { Recipe } from '@terrafirmagreg-team/recipe/lib/data/dto';
2
2
  import type {
3
3
  CalcNode,
4
- CalcWire,
4
+ CalcPipe,
5
5
  } from '@terrafirmagreg-team/recipe/types/calc';
6
6
  import {
7
7
  nodeSize,
@@ -16,7 +16,7 @@ export type CalcPackOptions = {
16
16
 
17
17
  export function layoutCards(
18
18
  nodes: CalcNode[],
19
- wires: readonly CalcWire[],
19
+ pipes: readonly CalcPipe[],
20
20
  options: CalcPackOptions,
21
21
  ): Map<string, { x: number; y: number }> {
22
22
  const { gaps } = options;
@@ -28,10 +28,10 @@ export function layoutCards(
28
28
  const byId = new Map(nodes.map((node) => [node.id, node]));
29
29
  const consumers = new Map<string, string[]>();
30
30
  const suppliers = new Map<string, string[]>();
31
- for (const wire of wires) {
32
- if (!byId.has(wire.from) || !byId.has(wire.to)) continue;
33
- consumers.set(wire.from, [...(consumers.get(wire.from) ?? []), wire.to]);
34
- suppliers.set(wire.to, [...(suppliers.get(wire.to) ?? []), wire.from]);
31
+ for (const pipe of pipes) {
32
+ if (!byId.has(pipe.from) || !byId.has(pipe.to)) continue;
33
+ consumers.set(pipe.from, [...(consumers.get(pipe.from) ?? []), pipe.to]);
34
+ suppliers.set(pipe.to, [...(suppliers.get(pipe.to) ?? []), pipe.from]);
35
35
  }
36
36
 
37
37
  const depth = new Map<string, number>();
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import { test } from 'node:test';
3
- import { wireEndMatches } from './wire';
3
+ import { pipeEndMatches } from './pipe';
4
4
  import type { CalcNodeInput } from '@terrafirmagreg-team/recipe/types/calc';
5
5
 
6
6
  const NBT = '{"Damage":0,"GT.Tool":{}}';
@@ -13,7 +13,7 @@ test('NBT input id matches a base output id', () => {
13
13
  catalyst: false,
14
14
  } as CalcNodeInput;
15
15
  assert.equal(
16
- wireEndMatches(input, {
16
+ pipeEndMatches(input, {
17
17
  id: 'gtceu:duranium_hammer',
18
18
  kind: 'item',
19
19
  amount: 1,
@@ -35,7 +35,7 @@ test('tag members carrying NBT match a base output id', () => {
35
35
  ],
36
36
  } as CalcNodeInput;
37
37
  assert.equal(
38
- wireEndMatches(input, {
38
+ pipeEndMatches(input, {
39
39
  id: 'gtceu:duranium_hammer',
40
40
  kind: 'item',
41
41
  amount: 1,
@@ -52,7 +52,7 @@ test('kind mismatch and unrelated ids still fail', () => {
52
52
  catalyst: false,
53
53
  } as CalcNodeInput;
54
54
  assert.equal(
55
- wireEndMatches(input, {
55
+ pipeEndMatches(input, {
56
56
  id: 'gtceu:duranium_hammer',
57
57
  kind: 'fluid',
58
58
  amount: 1,
@@ -60,7 +60,7 @@ test('kind mismatch and unrelated ids still fail', () => {
60
60
  false,
61
61
  );
62
62
  assert.equal(
63
- wireEndMatches(input, {
63
+ pipeEndMatches(input, {
64
64
  id: 'gtceu:copper_hammer',
65
65
  kind: 'item',
66
66
  amount: 1,
@@ -3,10 +3,10 @@ import type {
3
3
  CalcMaterial,
4
4
  CalcNode,
5
5
  CalcNodeInput,
6
- CalcWire,
6
+ CalcPipe,
7
7
  } from '@terrafirmagreg-team/recipe/types/calc';
8
8
 
9
- export function wireEndMatches(
9
+ export function pipeEndMatches(
10
10
  input: CalcNodeInput,
11
11
  out: CalcMaterial,
12
12
  ): boolean {
@@ -18,24 +18,24 @@ export function wireEndMatches(
18
18
  );
19
19
  }
20
20
 
21
- export function resolveWireEnds(
21
+ export function resolvePipeEnds(
22
22
  src: CalcNode,
23
23
  dst: CalcNode,
24
- wire: CalcWire,
24
+ pipe: CalcPipe,
25
25
  ): { inputIndex: number; outIndex: number } | null {
26
- const hinted = dst.inputs[wire.input];
26
+ const hinted = dst.inputs[pipe.input];
27
27
  if (hinted?.id) {
28
28
  const outIndex = src.outputs.findIndex((out) =>
29
- wireEndMatches(hinted, out),
29
+ pipeEndMatches(hinted, out),
30
30
  );
31
- if (outIndex >= 0) return { inputIndex: wire.input, outIndex };
31
+ if (outIndex >= 0) return { inputIndex: pipe.input, outIndex };
32
32
  }
33
33
  for (let i = 0; i < dst.inputs.length; i += 1) {
34
- if (i === wire.input) continue;
34
+ if (i === pipe.input) continue;
35
35
  const input = dst.inputs[i];
36
36
  if (!input?.id) continue;
37
37
  const outIndex = src.outputs.findIndex((out) =>
38
- wireEndMatches(input, out),
38
+ pipeEndMatches(input, out),
39
39
  );
40
40
  if (outIndex >= 0) return { inputIndex: i, outIndex };
41
41
  }
@@ -1,3 +1,4 @@
1
1
  export type { RouteNode } from './geometry';
2
+ export { orthoPoints } from './polyline';
2
3
  export { createCircuitRouter } from './router';
3
4
 
@@ -50,7 +50,7 @@ function ctx(tagSelections: Record<string, string>): SchemeContext {
50
50
  }
51
51
 
52
52
  function tagInput(tagSelections: Record<string, string>) {
53
- const { nodes } = buildScheme({ cards: [CARD], wires: [], ctx: ctx(tagSelections) });
53
+ const { nodes } = buildScheme({ cards: [CARD], pipes: [], ctx: ctx(tagSelections) });
54
54
  const node = nodes[0];
55
55
  return node?.inputs[1];
56
56
  }
@@ -96,7 +96,7 @@ function nbtCtx(tagSelections: Record<string, string>): SchemeContext {
96
96
  function nbtTagInput(tagSelections: Record<string, string>) {
97
97
  const { nodes } = buildScheme({
98
98
  cards: [CARD],
99
- wires: [],
99
+ pipes: [],
100
100
  ctx: nbtCtx(tagSelections),
101
101
  });
102
102
  return nodes[0]?.inputs[1];
@@ -115,7 +115,7 @@ test('tag input normalizes an NBT selection to its base id', () => {
115
115
  test('memberTarget marks the picked member on a tag card', () => {
116
116
  const { nodes } = buildScheme({
117
117
  cards: [{ ...CARD, id: 't1', materialId: `#${TAG}`, recipeId: null }],
118
- wires: [],
118
+ pipes: [],
119
119
  ctx: ctx({}),
120
120
  });
121
121
  const target = memberTarget(
@@ -128,7 +128,7 @@ test('memberTarget marks the picked member on a tag card', () => {
128
128
  test('memberTarget resolves node-level tag cards', () => {
129
129
  const { nodes } = buildScheme({
130
130
  cards: [{ ...CARD, id: 't1', materialId: `#${TAG}`, recipeId: null }],
131
- wires: [],
131
+ pipes: [],
132
132
  ctx: ctx({}),
133
133
  });
134
134
  const target = memberTarget({ node: nodes[0]! });
@@ -139,7 +139,7 @@ test('memberTarget resolves node-level tag cards', () => {
139
139
  });
140
140
 
141
141
  test('memberTarget resolves a tag input on a recipe node', () => {
142
- const { nodes } = buildScheme({ cards: [CARD], wires: [], ctx: ctx({}) });
142
+ const { nodes } = buildScheme({ cards: [CARD], pipes: [], ctx: ctx({}) });
143
143
  const target = memberTarget({ node: nodes[0]!, input: 1 });
144
144
  assert.equal(target?.tagId, TAG);
145
145
  assert.deepEqual(target?.members, RODS);
@@ -148,7 +148,7 @@ test('memberTarget resolves a tag input on a recipe node', () => {
148
148
  });
149
149
 
150
150
  test('memberTarget is empty for plain inputs and missing slots', () => {
151
- const { nodes } = buildScheme({ cards: [CARD], wires: [], ctx: ctx({}) });
151
+ const { nodes } = buildScheme({ cards: [CARD], pipes: [], ctx: ctx({}) });
152
152
  assert.equal(memberTarget({ node: nodes[0]!, input: 0 }), undefined);
153
153
  assert.equal(memberTarget({ node: nodes[0]!, input: 9 }), undefined);
154
154
  });
@@ -198,7 +198,7 @@ test('fluid-only recipe produces its fluid output and feeds a consumer', () => {
198
198
  crafts: 1,
199
199
  },
200
200
  ],
201
- wires: [{ from: 'src', to: 'dst', input: 0 }],
201
+ pipes: [{ from: 'src', to: 'dst', input: 0 }],
202
202
  ctx: fluidCtx([FLUID_RECIPE, CONSUME_RECIPE]),
203
203
  });
204
204
  const [src, dst] = nodes;
@@ -7,12 +7,12 @@ import type {
7
7
  CalcOutput,
8
8
  CalcRecipe,
9
9
  CalcRecipeSummary,
10
- CalcWire,
10
+ CalcPipe,
11
11
  TagResolution,
12
12
  } from '@terrafirmagreg-team/recipe/types/calc';
13
13
  import { stackIdBase } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
14
14
  import { mergeAmounts } from './tree/materials';
15
- import { resolveWireEnds } from './wire';
15
+ import { resolvePipeEnds } from './pipe';
16
16
 
17
17
  export type SchemeContext = {
18
18
  recipeMap: Map<string, CalcRecipe>;
@@ -56,11 +56,11 @@ function inputMember(
56
56
 
57
57
  export function buildScheme({
58
58
  cards,
59
- wires,
59
+ pipes,
60
60
  ctx,
61
61
  }: {
62
62
  cards: readonly CalcCard[];
63
- wires: readonly CalcWire[];
63
+ pipes: readonly CalcPipe[];
64
64
  ctx: SchemeContext;
65
65
  }): { nodes: CalcNode[]; flows: (number | undefined)[] } {
66
66
  const byId = new Map<string, CalcNode>();
@@ -128,9 +128,10 @@ export function buildScheme({
128
128
  ? entry.amount
129
129
  : entry.amount * card.crafts,
130
130
  catalyst: entry.catalyst,
131
+ ...(entry.chance !== undefined ? { chance: entry.chance } : {}),
131
132
  tagId: entry.tagId,
132
133
  ...(member.members ? { members: member.members } : {}),
133
- wired: false,
134
+ connected: false,
134
135
  covered: 0,
135
136
  } satisfies CalcNodeInput;
136
137
  }),
@@ -151,23 +152,23 @@ export function buildScheme({
151
152
  return node;
152
153
  });
153
154
 
154
- const flows: (number | undefined)[] = new Array(wires.length);
155
+ const flows: (number | undefined)[] = new Array(pipes.length);
155
156
  const deg = new Map<string, number>();
156
157
  const adj = new Map<string, string[]>();
157
- wires.forEach((wire, wireIndex) => {
158
- const src = byId.get(wire.from);
159
- const dst = byId.get(wire.to);
158
+ pipes.forEach((pipe, pipeIndex) => {
159
+ const src = byId.get(pipe.from);
160
+ const dst = byId.get(pipe.to);
160
161
  if (!src || !dst || src === dst) return;
161
- const ends = resolveWireEnds(src, dst, wire);
162
+ const ends = resolvePipeEnds(src, dst, pipe);
162
163
  if (!ends) return;
163
164
  const input = dst.inputs[ends.inputIndex];
164
165
  const srcOut = src.outputs[ends.outIndex];
165
166
  if (!input?.id || !srcOut) return;
166
- input.wired = true;
167
+ input.connected = true;
167
168
  const covered = Math.min(
168
169
  Math.max(srcOut.remaining, 0),
169
170
  input.amount - input.covered,
170
- wire.amount ?? Infinity,
171
+ pipe.amount ?? Infinity,
171
172
  );
172
173
  input.covered += covered;
173
174
  srcOut.allocated += covered;
@@ -176,9 +177,9 @@ export function buildScheme({
176
177
  src.allocated += covered;
177
178
  src.remaining -= covered;
178
179
  }
179
- flows[wireIndex] = covered;
180
- adj.set(wire.from, [...(adj.get(wire.from) ?? []), wire.to]);
181
- deg.set(wire.to, (deg.get(wire.to) ?? 0) + 1);
180
+ flows[pipeIndex] = covered;
181
+ adj.set(pipe.from, [...(adj.get(pipe.from) ?? []), pipe.to]);
182
+ deg.set(pipe.to, (deg.get(pipe.to) ?? 0) + 1);
182
183
  });
183
184
 
184
185
  const cyclic = (start: string): boolean => {