@terrafirmagreg-team/recipe 1.2.33 → 1.2.34
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 +4 -4
- package/src/components/cards/card/strip.tsx +1 -0
- package/src/components/cards/card/text.tsx +2 -2
- package/src/components/cards/scroll-card/index.tsx +2 -1
- package/src/components/cards/slot-hitbox.tsx +2 -2
- package/src/components/cards/strip-card/member-cell.tsx +1 -1
- package/src/components/views/calc/calculator/index.tsx +2 -2
- package/src/hooks/calc/use-far-mode.ts +2 -2
- package/src/hooks/calc/use-view-mode.ts +1 -1
- package/src/hooks/use-panel-cells.ts +2 -0
- package/src/lib/browser/lookup.ts +22 -4
- package/src/lib/browser/panel.ts +19 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrafirmagreg-team/recipe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.34",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Recipe viewer and calculator",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@terrafirmagreg-team/data": "^1.2.14",
|
|
27
27
|
"@terrafirmagreg-team/dump": "^1.2.25",
|
|
28
|
-
"@terrafirmagreg-team/game": "^1.2.
|
|
29
|
-
"@terrafirmagreg-team/kit": "^1.2.
|
|
28
|
+
"@terrafirmagreg-team/game": "^1.2.15",
|
|
29
|
+
"@terrafirmagreg-team/kit": "^1.2.33",
|
|
30
30
|
"@terrafirmagreg-team/mdx": "^1.2.14",
|
|
31
31
|
"@terrafirmagreg-team/preview": "^1.2.12",
|
|
32
32
|
"@terrafirmagreg-team/sites": "^1.2.5",
|
|
33
33
|
"@terrafirmagreg-team/translate": "^1.2.14",
|
|
34
|
-
"@terrafirmagreg-team/ui": "^1.2.
|
|
34
|
+
"@terrafirmagreg-team/ui": "^1.2.25",
|
|
35
35
|
"@types/pathfinding": "^0.1.0",
|
|
36
36
|
"comlink": "^4.4.2",
|
|
37
37
|
"fflate": "0.8.3",
|
|
@@ -111,6 +111,7 @@ export function CardStrip({
|
|
|
111
111
|
top: widget.y * scale,
|
|
112
112
|
width: widget.w * scale,
|
|
113
113
|
height: widget.h * scale,
|
|
114
|
+
backgroundColor: 'var(--color-mc-inset)',
|
|
114
115
|
backgroundImage: `url(${widgetsUrl})`,
|
|
115
116
|
backgroundSize: `${256 * scale}px ${256 * scale}px`,
|
|
116
117
|
backgroundPosition: '0px 0px',
|
|
@@ -26,7 +26,7 @@ export function CardText({
|
|
|
26
26
|
: widget.text;
|
|
27
27
|
if (!content) return null;
|
|
28
28
|
const wrap = widget.type === 'paragraph';
|
|
29
|
-
const rgb =
|
|
29
|
+
const rgb = 0x000000;
|
|
30
30
|
return (
|
|
31
31
|
<span
|
|
32
32
|
className={`font-mc pointer-events-none absolute leading-none ${wrap ? 'whitespace-pre-wrap' : 'whitespace-pre'}`}
|
|
@@ -47,7 +47,7 @@ export function CardText({
|
|
|
47
47
|
color: `#${rgb.toString(16).padStart(6, '0')}`,
|
|
48
48
|
}}
|
|
49
49
|
>
|
|
50
|
-
<McText text={content} surface="
|
|
50
|
+
<McText text={content} surface="light" />
|
|
51
51
|
</span>
|
|
52
52
|
);
|
|
53
53
|
}
|
|
@@ -363,6 +363,7 @@ export function ScrollCard(props: Props) {
|
|
|
363
363
|
aria-hidden
|
|
364
364
|
className="absolute inset-0 block"
|
|
365
365
|
style={{
|
|
366
|
+
backgroundColor: 'var(--color-mc-inset)',
|
|
366
367
|
backgroundImage: `url(${slotTexUrl})`,
|
|
367
368
|
backgroundSize: `${ATLAS * scale}px ${ATLAS * scale}px`,
|
|
368
369
|
backgroundPosition: `-${(el.u ?? 0) * scale}px -${(el.v ?? 0) * scale}px`,
|
|
@@ -411,7 +412,7 @@ export function ScrollCard(props: Props) {
|
|
|
411
412
|
) : null}
|
|
412
413
|
{el.label ? (
|
|
413
414
|
<span
|
|
414
|
-
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-
|
|
415
|
+
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-black"
|
|
415
416
|
style={{ fontSize: (el.w / 16) * 7 * scale }}
|
|
416
417
|
>
|
|
417
418
|
{el.label}
|
|
@@ -142,7 +142,7 @@ export function SlotHitbox({
|
|
|
142
142
|
{widget.kind === 'tag' ? (
|
|
143
143
|
<span
|
|
144
144
|
aria-hidden
|
|
145
|
-
className="font-mc pointer-events-none absolute top-0 left-0 leading-none text-
|
|
145
|
+
className="font-mc pointer-events-none absolute top-0 left-0 leading-none text-black"
|
|
146
146
|
style={{
|
|
147
147
|
paddingLeft: scale / 2,
|
|
148
148
|
fontSize: (Math.min(widget.w, widget.h) / 16) * 7 * scale,
|
|
@@ -163,7 +163,7 @@ export function SlotHitbox({
|
|
|
163
163
|
widget.count !== undefined && widget.count > 1 ? (
|
|
164
164
|
<span
|
|
165
165
|
aria-hidden
|
|
166
|
-
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-
|
|
166
|
+
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-black"
|
|
167
167
|
style={{
|
|
168
168
|
paddingRight: scale,
|
|
169
169
|
paddingBottom: scale,
|
|
@@ -109,7 +109,7 @@ export function StripCardMember({
|
|
|
109
109
|
)}
|
|
110
110
|
{badges.length > 0 && (
|
|
111
111
|
<span
|
|
112
|
-
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-
|
|
112
|
+
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-black"
|
|
113
113
|
style={{ fontSize: (pitch / 16) * (kind === 'fluid' ? 4 : 7) }}
|
|
114
114
|
>
|
|
115
115
|
{badges.join(' ')}
|
|
@@ -158,8 +158,8 @@ export function Calculator({ session }: { session: RecipeSession }) {
|
|
|
158
158
|
focusNodeId={focusNodeId}
|
|
159
159
|
onFocusedNode={() => setFocusNodeId(null)}
|
|
160
160
|
empty={
|
|
161
|
-
<div className="absolute inset-0 z-10 grid place-items-center overflow-auto p-4">
|
|
162
|
-
<div className="flex flex-col items-center gap-4">
|
|
161
|
+
<div className="pointer-events-none absolute inset-0 z-10 grid place-items-center overflow-auto p-4">
|
|
162
|
+
<div className="pointer-events-auto flex flex-col items-center gap-4">
|
|
163
163
|
<EmptyState variant="empty">
|
|
164
164
|
{t('Click an item in the catalog to add a card.', { note: 'recipe.calc.empty' })}
|
|
165
165
|
</EmptyState>
|
|
@@ -15,10 +15,10 @@ import type { CalcFarMode } from '@terrafirmagreg-team/recipe/lib/calc/flow';
|
|
|
15
15
|
const FAR_MODES: CalcFarMode[] = ['full', 'preview', 'hidden'];
|
|
16
16
|
const useStoredMode = createStoredValue(
|
|
17
17
|
'calc:far',
|
|
18
|
-
literalCodec(FAR_MODES, '
|
|
18
|
+
literalCodec(FAR_MODES, 'full'),
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
-
const CalcFarContext = createContext<CalcFarMode>('
|
|
21
|
+
const CalcFarContext = createContext<CalcFarMode>('full');
|
|
22
22
|
|
|
23
23
|
export const CalcFarProvider = CalcFarContext.Provider;
|
|
24
24
|
|
|
@@ -10,7 +10,7 @@ import type { CalcViewMode } from '@terrafirmagreg-team/recipe/lib/calc/flow';
|
|
|
10
10
|
const MODES: CalcViewMode[] = ['mini', 'normal', 'detailed'];
|
|
11
11
|
const useStoredMode = createStoredValue(
|
|
12
12
|
'calc:view',
|
|
13
|
-
literalCodec(MODES, '
|
|
13
|
+
literalCodec(MODES, 'detailed'),
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
export function useCalcViewMode() {
|
|
@@ -112,10 +112,12 @@ export function usePanelCells({
|
|
|
112
112
|
: [],
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
|
+
const fluidIds = new Set(dIndex?.fluids ?? []);
|
|
115
116
|
return buildPanelCells(
|
|
116
117
|
deferredFiltered,
|
|
117
118
|
dIndex?.groups,
|
|
118
119
|
expandedGroups,
|
|
120
|
+
fluidIds,
|
|
119
121
|
);
|
|
120
122
|
}, [deferredFiltered, dIndex, mode, expandedGroups, favorites.entries]);
|
|
121
123
|
|
|
@@ -56,7 +56,13 @@ export async function recipesForOutput(
|
|
|
56
56
|
]);
|
|
57
57
|
const extra = io?.outputs.get(base) ?? [];
|
|
58
58
|
const ids = extra.length ? [...new Set([...refs, ...extra])] : refs;
|
|
59
|
-
|
|
59
|
+
const keepTagRows = opts?.includeTagRows ?? false;
|
|
60
|
+
return (await resolveRecipeRows(dataset, index, ids, opts)).filter(
|
|
61
|
+
(row) =>
|
|
62
|
+
row.out.includes(base) ||
|
|
63
|
+
(keepTagRows &&
|
|
64
|
+
(row.cat ?? index.types[row.type]) === 'emi:tag'),
|
|
65
|
+
);
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
export async function usesForInput(
|
|
@@ -88,10 +94,12 @@ export async function usesForInput(
|
|
|
88
94
|
...tagKinds.map((tagKind) => loadTagSlice(dataset, tagKind, ns)),
|
|
89
95
|
]);
|
|
90
96
|
const tagKeys: string[] = [];
|
|
97
|
+
const acceptedTags = new Set<string>();
|
|
91
98
|
for (const [i, slice] of tagSlices.entries()) {
|
|
92
99
|
const registry = `${tagKinds[i]}s`;
|
|
93
100
|
for (const tag of slice[base] ?? slice[item] ?? []) {
|
|
94
101
|
const raw = tag.startsWith('#') ? tag.slice(1) : tag;
|
|
102
|
+
acceptedTags.add(`#${raw}`);
|
|
95
103
|
const parts = splitDumpId(raw);
|
|
96
104
|
if (parts) tagKeys.push(`${parts.ns}:${registry}/${parts.path}`);
|
|
97
105
|
}
|
|
@@ -111,11 +119,21 @@ export async function usesForInput(
|
|
|
111
119
|
const allRefs = ioRefs.length
|
|
112
120
|
? [...new Set([...refs, ...ioRefs])]
|
|
113
121
|
: refs;
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
const [refRows, tagRows] = await Promise.all([
|
|
123
|
+
resolveRecipeRows(dataset, index, allRefs, {
|
|
124
|
+
includeTagRows: false,
|
|
125
|
+
...opts,
|
|
126
|
+
}),
|
|
127
|
+
resolveRecipeRows(dataset, index, tagRefs, {
|
|
116
128
|
includeTagRows: false,
|
|
117
129
|
...opts,
|
|
118
|
-
})
|
|
130
|
+
}),
|
|
131
|
+
]);
|
|
132
|
+
return uniqueRows([
|
|
133
|
+
...refRows.filter((row) => row.in.includes(base)),
|
|
134
|
+
...tagRows.filter((row) =>
|
|
135
|
+
row.in.some((id) => acceptedTags.has(id)),
|
|
136
|
+
),
|
|
119
137
|
...stationRows.flat(),
|
|
120
138
|
]);
|
|
121
139
|
}
|
package/src/lib/browser/panel.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type TaggedReference,
|
|
4
4
|
} from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
5
5
|
import { registryId } from '@terrafirmagreg-team/dump/lib/dump/paths';
|
|
6
|
+
import { creativeTabName } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
6
7
|
import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
7
8
|
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
8
9
|
import type {
|
|
@@ -12,7 +13,7 @@ import type {
|
|
|
12
13
|
} from '@terrafirmagreg-team/recipe/types';
|
|
13
14
|
|
|
14
15
|
function catalogPool(index: RecipeCompactIndex, tab?: string): string[] {
|
|
15
|
-
if (!tab) return index.items;
|
|
16
|
+
if (!tab) return [...index.items, ...(index.fluids ?? [])];
|
|
16
17
|
return index.tabItems?.[tab] ?? [];
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -39,8 +40,13 @@ export function buildPanelCells(
|
|
|
39
40
|
ids: readonly string[],
|
|
40
41
|
groups: RecipeStackGroup[] | undefined,
|
|
41
42
|
expandedGroups: ReadonlySet<string>,
|
|
43
|
+
fluidIds?: ReadonlySet<string>,
|
|
42
44
|
): ItemPanelCell[] {
|
|
43
|
-
|
|
45
|
+
const cell = (id: string): ItemPanelCell =>
|
|
46
|
+
fluidIds?.has(registryId(id))
|
|
47
|
+
? { kind: 'stack', id, ref: 'fluid' }
|
|
48
|
+
: { kind: 'stack', id };
|
|
49
|
+
if (!groups?.length) return ids.map(cell);
|
|
44
50
|
const byMember = new Map<string, RecipeStackGroup>();
|
|
45
51
|
for (const group of groups)
|
|
46
52
|
for (const member of group.members) {
|
|
@@ -56,7 +62,7 @@ export function buildPanelCells(
|
|
|
56
62
|
seen.add(base);
|
|
57
63
|
const group = byMember.get(base);
|
|
58
64
|
if (!group) {
|
|
59
|
-
out.push(
|
|
65
|
+
out.push(cell(id));
|
|
60
66
|
continue;
|
|
61
67
|
}
|
|
62
68
|
const members = group.members.filter((member) =>
|
|
@@ -64,7 +70,7 @@ export function buildPanelCells(
|
|
|
64
70
|
);
|
|
65
71
|
for (const member of members) seen.add(registryId(member));
|
|
66
72
|
if (members.length <= 1) {
|
|
67
|
-
out.push(
|
|
73
|
+
out.push(cell(members[0] ?? id));
|
|
68
74
|
continue;
|
|
69
75
|
}
|
|
70
76
|
const expanded = expandedGroups.has(group.id);
|
|
@@ -77,7 +83,12 @@ export function buildPanelCells(
|
|
|
77
83
|
});
|
|
78
84
|
if (expanded)
|
|
79
85
|
for (const member of members)
|
|
80
|
-
out.push({
|
|
86
|
+
out.push({
|
|
87
|
+
kind: 'stack',
|
|
88
|
+
id: member,
|
|
89
|
+
groupId: group.id,
|
|
90
|
+
...(fluidIds?.has(registryId(member)) ? { ref: 'fluid' as const } : {}),
|
|
91
|
+
});
|
|
81
92
|
}
|
|
82
93
|
return out;
|
|
83
94
|
}
|
|
@@ -97,7 +108,9 @@ export function panelTabRows(
|
|
|
97
108
|
id: row.id,
|
|
98
109
|
icon,
|
|
99
110
|
iconRef: row.icon,
|
|
100
|
-
help:
|
|
111
|
+
help: row.display?.name
|
|
112
|
+
? creativeTabName(names[lang] ?? names.en_us ?? {}, row.display.name)
|
|
113
|
+
: recipeItemName(names, lang, row.id),
|
|
101
114
|
});
|
|
102
115
|
}
|
|
103
116
|
return rows;
|