@terrafirmagreg-team/recipe 1.2.37 → 1.2.39
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.
- package/package.json +3 -3
- package/src/components/cards/card/text.tsx +3 -2
- package/src/components/cards/scroll-card/index.tsx +16 -3
- package/src/components/cards/slot-hitbox.tsx +7 -4
- package/src/components/cards/strip-card/member-cell.tsx +4 -2
- package/src/components/views/browser/card-grid.tsx +2 -1
- package/src/components/views/browser/frame.tsx +73 -33
- package/src/components/views/browser/item-view/index.tsx +12 -9
- package/src/components/views/browser/item-view/tags.tsx +3 -3
- package/src/components/views/browser/query-controls.tsx +1 -1
- package/src/components/views/browser/type-view.tsx +40 -1
- package/src/components/views/calc/calculator/actions.tsx +34 -5
- package/src/components/views/calc/calculator/index.tsx +22 -8
- package/src/components/views/calc/edge.tsx +11 -4
- package/src/components/views/calc/node-card/badges.tsx +17 -3
- package/src/components/views/calc/node-card/full.tsx +117 -37
- package/src/components/views/calc/node-card/menu.tsx +12 -1
- package/src/components/views/calc/node-card/port-cells.tsx +13 -8
- package/src/components/views/calc/node-card/ports.tsx +39 -13
- package/src/components/views/calc/recipe-picker/body.tsx +34 -1
- package/src/components/views/calc/sidebar.tsx +8 -2
- package/src/components/views/calc/trees/label.tsx +9 -5
- package/src/hooks/calc/use-actions.ts +26 -3
- package/src/hooks/calc/use-amounts.ts +32 -5
- package/src/hooks/calc/use-data.ts +2 -1
- package/src/hooks/calc/use-share.ts +15 -8
- package/src/hooks/calc/use-storage.ts +2 -1
- package/src/lib/calc/flow.ts +6 -1
|
@@ -24,7 +24,7 @@ export function useCalcData(session: RecipeSession) {
|
|
|
24
24
|
const { dataset } = session;
|
|
25
25
|
const catalog = session.index;
|
|
26
26
|
const storageKey = calcStorageKey('recipe', dataset);
|
|
27
|
-
const sharePending = useCalcShare({
|
|
27
|
+
const { pending: sharePending, failed: shareFailed } = useCalcShare({
|
|
28
28
|
storageKey,
|
|
29
29
|
dataset,
|
|
30
30
|
incoming: session.tree ?? '',
|
|
@@ -196,6 +196,7 @@ export function useCalcData(session: RecipeSession) {
|
|
|
196
196
|
encodeShare,
|
|
197
197
|
recipeBody,
|
|
198
198
|
settled,
|
|
199
|
+
shareFailed,
|
|
199
200
|
bodiesLoaded: maps.bodyMap.size,
|
|
200
201
|
workerSettled: worker.settled,
|
|
201
202
|
};
|
|
@@ -22,9 +22,10 @@ export function useCalcShare({
|
|
|
22
22
|
dataset: DatasetRef;
|
|
23
23
|
incoming: string;
|
|
24
24
|
version?: string;
|
|
25
|
-
}): boolean {
|
|
25
|
+
}): { pending: boolean; failed: boolean } {
|
|
26
26
|
const isShareId = incoming.startsWith('s');
|
|
27
27
|
const [sharedTree, setSharedTree] = useState<string | null>(null);
|
|
28
|
+
const [fetchFailed, setFetchFailed] = useState(false);
|
|
28
29
|
useEffect(() => {
|
|
29
30
|
if (!isShareId) return;
|
|
30
31
|
let cancelled = false;
|
|
@@ -34,11 +35,12 @@ export function useCalcShare({
|
|
|
34
35
|
)
|
|
35
36
|
.then((res) => (res.ok ? res.json() : null))
|
|
36
37
|
.then((body: { tree?: unknown } | null) => {
|
|
37
|
-
if (
|
|
38
|
-
|
|
38
|
+
if (cancelled) return;
|
|
39
|
+
if (typeof body?.tree === 'string') setSharedTree(body.tree);
|
|
40
|
+
else setFetchFailed(true);
|
|
39
41
|
})
|
|
40
42
|
.catch(() => {
|
|
41
|
-
if (!cancelled)
|
|
43
|
+
if (!cancelled) setFetchFailed(true);
|
|
42
44
|
});
|
|
43
45
|
return () => {
|
|
44
46
|
cancelled = true;
|
|
@@ -58,9 +60,14 @@ export function useCalcShare({
|
|
|
58
60
|
entry.id,
|
|
59
61
|
);
|
|
60
62
|
}
|
|
61
|
-
if (incoming
|
|
62
|
-
|
|
63
|
+
if (incoming && (decoded || !isShareId))
|
|
64
|
+
replaceUrlState(recipeCalcHref(dataset, resolved, undefined, version));
|
|
65
|
+
}, [transport, storageKey, dataset, resolved, incoming, version, isShareId]);
|
|
63
66
|
|
|
64
|
-
return
|
|
67
|
+
return {
|
|
68
|
+
pending: isShareId && sharedTree === null && !fetchFailed,
|
|
69
|
+
failed:
|
|
70
|
+
fetchFailed ||
|
|
71
|
+
(transport !== null && !decodeCalcState(transport)),
|
|
72
|
+
};
|
|
65
73
|
}
|
|
66
|
-
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
type CalcTreeEntry,
|
|
19
19
|
} from '@terrafirmagreg-team/recipe/lib/calc/storage';
|
|
20
20
|
import type { CalculatorState } from '@terrafirmagreg-team/recipe/types/calc';
|
|
21
|
+
import { stripMcFormat } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
21
22
|
|
|
22
23
|
const EMPTY_TABS: CalcTreeEntry[] = [];
|
|
23
24
|
const EMPTY_CALC: CalculatorState = {
|
|
@@ -97,7 +98,7 @@ export function useCalcStorage(storageKey: string) {
|
|
|
97
98
|
(id: string, name: string) => {
|
|
98
99
|
updateCalcTab(storageKey, id, (tab) => ({
|
|
99
100
|
...tab,
|
|
100
|
-
name: name.trim() || undefined,
|
|
101
|
+
name: stripMcFormat(name).trim() || undefined,
|
|
101
102
|
}));
|
|
102
103
|
},
|
|
103
104
|
[storageKey],
|
package/src/lib/calc/flow.ts
CHANGED
|
@@ -67,7 +67,11 @@ export type CalcFlowData = {
|
|
|
67
67
|
) => void;
|
|
68
68
|
onRemoveCard: (cardId: string) => void;
|
|
69
69
|
onMoveCard: (cardId: string, pos: { x: number; y: number }) => void;
|
|
70
|
-
onCrafts: (
|
|
70
|
+
onCrafts: (
|
|
71
|
+
cardId: string,
|
|
72
|
+
crafts: number | ((current: number) => number),
|
|
73
|
+
) => void;
|
|
74
|
+
pendingCrafts?: Map<string, number> | null;
|
|
71
75
|
onWire: (from: string, to: string, input: number, out?: number) => void;
|
|
72
76
|
onUnwire: (
|
|
73
77
|
from: string,
|
|
@@ -237,6 +241,7 @@ function sameFlowData(a: CalcFlowData, b: CalcFlowData): boolean {
|
|
|
237
241
|
a.onRemoveCard === b.onRemoveCard &&
|
|
238
242
|
a.onMoveCard === b.onMoveCard &&
|
|
239
243
|
a.onCrafts === b.onCrafts &&
|
|
244
|
+
a.pendingCrafts === b.pendingCrafts &&
|
|
240
245
|
a.onWire === b.onWire &&
|
|
241
246
|
a.onUnwire === b.onUnwire &&
|
|
242
247
|
a.onRewire === b.onRewire &&
|