@terrafirmagreg-team/recipe 1.2.26 → 1.2.28
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 +6 -6
- package/src/components/cards/card/index.tsx +17 -13
- package/src/components/cards/scroll-card/index.tsx +5 -1
- package/src/components/mdx/recipe.tsx +2 -2
- package/src/components/tree.tsx +3 -2
- package/src/components/views/browser/card-grid.tsx +4 -5
- package/src/components/views/browser/index.tsx +0 -17
- package/src/components/views/browser/item-panel/index.tsx +61 -32
- package/src/components/views/browser/item-panel-grid/cell.tsx +9 -3
- package/src/components/views/browser/item-panel-grid/index.tsx +3 -0
- package/src/components/views/landing.tsx +39 -11
- package/src/components/views/layout.tsx +49 -2
- package/src/hooks/use-index.ts +10 -0
- package/src/hooks/use-panel-cells.ts +8 -1
- package/src/hooks/use-panel-page.ts +8 -50
- package/src/hooks/use-session.ts +62 -14
- package/src/lib/client/recipe.ts +2 -2
- package/src/lib/client-index/chrome.ts +4 -4
- package/src/lib/client-index/registry.ts +2 -2
- package/src/lib/client-index/tooltips.ts +2 -2
- package/src/lib/og.ts +39 -7
- package/src/lib/preview.ts +2 -2
- package/src/lib/routes.ts +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrafirmagreg-team/recipe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Recipe viewer and calculator",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@terrafirmagreg-team/data": "^1.2.13",
|
|
27
|
-
"@terrafirmagreg-team/dump": "^1.2.
|
|
28
|
-
"@terrafirmagreg-team/game": "^1.2.
|
|
29
|
-
"@terrafirmagreg-team/kit": "^1.2.
|
|
27
|
+
"@terrafirmagreg-team/dump": "^1.2.21",
|
|
28
|
+
"@terrafirmagreg-team/game": "^1.2.12",
|
|
29
|
+
"@terrafirmagreg-team/kit": "^1.2.29",
|
|
30
30
|
"@terrafirmagreg-team/mdx": "^1.2.12",
|
|
31
31
|
"@terrafirmagreg-team/preview": "^1.2.7",
|
|
32
32
|
"@terrafirmagreg-team/sites": "^1.2.4",
|
|
33
|
-
"@terrafirmagreg-team/translate": "^1.2.
|
|
34
|
-
"@terrafirmagreg-team/ui": "^1.2.
|
|
33
|
+
"@terrafirmagreg-team/translate": "^1.2.13",
|
|
34
|
+
"@terrafirmagreg-team/ui": "^1.2.20",
|
|
35
35
|
"@types/pathfinding": "^0.1.0",
|
|
36
36
|
"comlink": "^4.4.2",
|
|
37
37
|
"fflate": "0.8.3",
|
|
@@ -106,19 +106,23 @@ export function RecipeCard({
|
|
|
106
106
|
ref={rootRef}
|
|
107
107
|
className="relative w-fit overflow-hidden rounded-sm bg-mc-panel"
|
|
108
108
|
>
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
109
|
+
{src ? (
|
|
110
|
+
<>
|
|
111
|
+
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
112
|
+
<img
|
|
113
|
+
src={src}
|
|
114
|
+
alt={title}
|
|
115
|
+
className="block"
|
|
116
|
+
width={naturalW}
|
|
117
|
+
height={naturalH}
|
|
118
|
+
loading="lazy"
|
|
119
|
+
decoding="async"
|
|
120
|
+
draggable={false}
|
|
121
|
+
onError={onFail}
|
|
122
|
+
style={recipeGlareFilter}
|
|
123
|
+
/>
|
|
124
|
+
</>
|
|
125
|
+
) : null}
|
|
122
126
|
{inView && interactive && glbUrl ? (
|
|
123
127
|
<div
|
|
124
128
|
className="absolute"
|
|
@@ -328,7 +328,11 @@ export function ScrollCard(props: Props) {
|
|
|
328
328
|
top: horizontal ? y : shifted,
|
|
329
329
|
fontSize: 8 * scale,
|
|
330
330
|
color: `#${rgb.toString(16).padStart(6, '0')}`,
|
|
331
|
-
|
|
331
|
+
...(shadowRgb !== rgb
|
|
332
|
+
? {
|
|
333
|
+
textShadow: `${scale}px ${scale}px 0 #${shadowRgb.toString(16).padStart(6, '0')}`,
|
|
334
|
+
}
|
|
335
|
+
: {}),
|
|
332
336
|
}}
|
|
333
337
|
>
|
|
334
338
|
<McText text={el.text ?? ''} surface="dark" />
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
resolveRecipeRows,
|
|
20
20
|
} from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
21
21
|
import { loadClientRecipe } from '@terrafirmagreg-team/recipe/lib/client/recipe';
|
|
22
|
-
import {
|
|
22
|
+
import { clientDumpLangRecipe } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
23
23
|
import { recipeTitle } from '@terrafirmagreg-team/recipe/lib/data/parse';
|
|
24
24
|
import { recipeImageUrl } from '@terrafirmagreg-team/dump/lib/dump/assets/urls';
|
|
25
25
|
import { recipeCardImageUrl, recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
@@ -54,7 +54,7 @@ export function Recipe({
|
|
|
54
54
|
const [recipe, chrome, langMap] = await Promise.all([
|
|
55
55
|
loadClientRecipe(dataset, row.id, row.bucket),
|
|
56
56
|
loadRecipeChromeClient(dataset, lang),
|
|
57
|
-
|
|
57
|
+
clientDumpLangRecipe(dataset, lang),
|
|
58
58
|
]);
|
|
59
59
|
const title = recipe
|
|
60
60
|
? recipeTitle(recipe, langMap)
|
package/src/components/tree.tsx
CHANGED
|
@@ -3,7 +3,8 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
|
3
3
|
import { createElement } from 'react';
|
|
4
4
|
import type * as PageTree from 'fumadocs-core/page-tree';
|
|
5
5
|
import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
|
|
6
|
-
import {
|
|
6
|
+
import { creativeTabName } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/load';
|
|
7
|
+
import { clientDumpLangNames } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
7
8
|
import { DUMP_POINTER_TTL } from '@terrafirmagreg-team/dump/lib/dump/json-reader';
|
|
8
9
|
import { createAsyncCache } from '@terrafirmagreg-team/data/lib/async-cache';
|
|
9
10
|
import { getRecipeSource } from '@terrafirmagreg-team/recipe/lib/source';
|
|
@@ -70,7 +71,7 @@ async function buildRecipeTrees(lang: Lang): Promise<SectionTrees> {
|
|
|
70
71
|
for (const { id, title: datasetTitle, languages } of datasets) {
|
|
71
72
|
if (!(languages ?? [defaultLanguage]).includes(lang)) continue;
|
|
72
73
|
const ref = { id };
|
|
73
|
-
const map = await
|
|
74
|
+
const map = await clientDumpLangNames(ref, lang);
|
|
74
75
|
const source = getRecipeSource();
|
|
75
76
|
const categories = await source.categories(ref);
|
|
76
77
|
const types = (await source.manifest(ref))?.indexes.recipes.types;
|
|
@@ -10,7 +10,6 @@ import { CopyIdMenu } from '@terrafirmagreg-team/game/components/entry/copy-id-m
|
|
|
10
10
|
import { EmptyState } from '@terrafirmagreg-team/ui/components/blocks/page/empty-state';
|
|
11
11
|
import { Skeleton } from '@terrafirmagreg-team/ui/components/ui/skeleton';
|
|
12
12
|
import {
|
|
13
|
-
recipeCardImageUrl,
|
|
14
13
|
recipeHref,
|
|
15
14
|
recipeImageUrl,
|
|
16
15
|
} from '@terrafirmagreg-team/recipe/lib/links';
|
|
@@ -86,8 +85,8 @@ function RecipeGridCard({
|
|
|
86
85
|
modId: row.id.split(':', 1)[0],
|
|
87
86
|
image: row.image,
|
|
88
87
|
})
|
|
89
|
-
: undefined)
|
|
90
|
-
|
|
88
|
+
: undefined);
|
|
89
|
+
const expectsImage = recipe?.image !== undefined || row.image !== undefined;
|
|
91
90
|
|
|
92
91
|
const focus = () =>
|
|
93
92
|
pushUrlState(
|
|
@@ -159,7 +158,7 @@ function RecipeGridCard({
|
|
|
159
158
|
style={fit < 1 ? { zoom: fit } : undefined}
|
|
160
159
|
>
|
|
161
160
|
{recipe ? (
|
|
162
|
-
src && !failed ? (
|
|
161
|
+
!expectsImage || (src && !failed) ? (
|
|
163
162
|
<PagedCard
|
|
164
163
|
recipe={recipe}
|
|
165
164
|
dataset={dataset}
|
|
@@ -167,7 +166,7 @@ function RecipeGridCard({
|
|
|
167
166
|
langMap={langMap}
|
|
168
167
|
nav={nav}
|
|
169
168
|
title={title}
|
|
170
|
-
src={src}
|
|
169
|
+
src={src ?? ''}
|
|
171
170
|
naturalW={row.d?.w}
|
|
172
171
|
naturalH={row.d?.h}
|
|
173
172
|
maxH={maxH}
|
|
@@ -13,9 +13,7 @@ import {
|
|
|
13
13
|
import { useRecipeSession } from '@terrafirmagreg-team/recipe/hooks/use-session';
|
|
14
14
|
import { recipeConfig } from '@terrafirmagreg-team/recipe/lib/config';
|
|
15
15
|
import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
16
|
-
import { ItemPanel } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel';
|
|
17
16
|
import { RecipeGlareFilter } from '@terrafirmagreg-team/recipe/components/cards/glare-filter';
|
|
18
|
-
import { RightSidebarPortal } from '@terrafirmagreg-team/ui/components/layouts/right-sidebar';
|
|
19
17
|
import { TypeView } from '@terrafirmagreg-team/recipe/components/views/browser/type-view';
|
|
20
18
|
import { ItemView } from '@terrafirmagreg-team/recipe/components/views/browser/item-view';
|
|
21
19
|
import { Calculator } from '@terrafirmagreg-team/recipe/components/views/calc/calculator';
|
|
@@ -147,21 +145,6 @@ export function RecipeBrowser({
|
|
|
147
145
|
) : null}
|
|
148
146
|
</main>
|
|
149
147
|
</div>
|
|
150
|
-
<RightSidebarPortal>
|
|
151
|
-
<ItemPanel
|
|
152
|
-
dataset={dataset}
|
|
153
|
-
lang={lang}
|
|
154
|
-
index={session.index}
|
|
155
|
-
indexLoading={session.indexLoading}
|
|
156
|
-
names={names}
|
|
157
|
-
tab={session.tab}
|
|
158
|
-
query={session.query}
|
|
159
|
-
setQuery={session.setQuery}
|
|
160
|
-
isCalc={isCalc}
|
|
161
|
-
nav={session.nav}
|
|
162
|
-
className="hidden h-full w-90 lg:flex"
|
|
163
|
-
/>
|
|
164
|
-
</RightSidebarPortal>
|
|
165
148
|
</div>
|
|
166
149
|
</EntryProvider>
|
|
167
150
|
);
|
|
@@ -22,7 +22,10 @@ import { EmptyState } from '@terrafirmagreg-team/ui/components/blocks/page/empty
|
|
|
22
22
|
import { type ItemPanelMode } from '@terrafirmagreg-team/recipe/lib/browser/panel';
|
|
23
23
|
import { recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
24
24
|
import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
favoriteHover,
|
|
27
|
+
type FavoriteHoverTarget,
|
|
28
|
+
} from '@terrafirmagreg-team/recipe/lib/browser/favorite-hover';
|
|
26
29
|
import { IconPager } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
|
|
27
30
|
import { FavoriteButton } from '@terrafirmagreg-team/recipe/components/views/browser/favorite-button';
|
|
28
31
|
import { ItemPanelGrid } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel-grid';
|
|
@@ -92,7 +95,7 @@ export const ItemPanel = memo(function ItemPanel({
|
|
|
92
95
|
const [expandedGroups, setExpandedGroups] = useState<ReadonlySet<string>>(
|
|
93
96
|
new Set(),
|
|
94
97
|
);
|
|
95
|
-
const { cells,
|
|
98
|
+
const { cells, favoriteIds, dIndex, dNames, dLang } =
|
|
96
99
|
usePanelCells({
|
|
97
100
|
dataset,
|
|
98
101
|
index,
|
|
@@ -109,10 +112,7 @@ export const ItemPanel = memo(function ItemPanel({
|
|
|
109
112
|
const { page: panelPage, setPage: setPanelPage } = usePanelPage(dataset);
|
|
110
113
|
const list = usePagedList(cells, panelPage, pageSize);
|
|
111
114
|
|
|
112
|
-
const gridResetKey =
|
|
113
|
-
() => [mode, filtered, favorites.entries],
|
|
114
|
-
[mode, filtered, favorites.entries],
|
|
115
|
-
);
|
|
115
|
+
const gridResetKey = mode;
|
|
116
116
|
const onToggleGroup = useCallback((groupId: string) => {
|
|
117
117
|
setExpandedGroups((prev) => {
|
|
118
118
|
const next = new Set(prev);
|
|
@@ -125,6 +125,27 @@ export const ItemPanel = memo(function ItemPanel({
|
|
|
125
125
|
const resolved = useResolvedLang();
|
|
126
126
|
const onPress = useItemPress({ dataset, nav, isCalc });
|
|
127
127
|
|
|
128
|
+
const {
|
|
129
|
+
tab: navTab,
|
|
130
|
+
search: navSearch,
|
|
131
|
+
tool: navTool,
|
|
132
|
+
unit: navUnit,
|
|
133
|
+
mix: navMix,
|
|
134
|
+
} = nav;
|
|
135
|
+
const cellNav = useMemo<RecipeHrefOpts>(
|
|
136
|
+
() => ({
|
|
137
|
+
tab: navTab,
|
|
138
|
+
search: navSearch,
|
|
139
|
+
tool: navTool,
|
|
140
|
+
unit: navUnit,
|
|
141
|
+
mix: navMix,
|
|
142
|
+
}),
|
|
143
|
+
[navTab, navSearch, navTool, navUnit, navMix],
|
|
144
|
+
);
|
|
145
|
+
const onHover = useCallback((target: FavoriteHoverTarget | undefined) => {
|
|
146
|
+
favoriteHover.base = target;
|
|
147
|
+
}, []);
|
|
148
|
+
|
|
128
149
|
const setTab = (next: string) => {
|
|
129
150
|
setPanelPage(0);
|
|
130
151
|
replaceUrlState(
|
|
@@ -141,20 +162,26 @@ export const ItemPanel = memo(function ItemPanel({
|
|
|
141
162
|
pageRef.current = list.page;
|
|
142
163
|
const [startRaw, setStartRaw] = useState(list.page - (PAGE_WINDOW >> 1));
|
|
143
164
|
const maxStart = Math.max(0, list.pages - PAGE_WINDOW);
|
|
144
|
-
const start = Math.max(
|
|
165
|
+
const start = Math.max(
|
|
166
|
+
0,
|
|
167
|
+
Math.min(
|
|
168
|
+
maxStart,
|
|
169
|
+
Math.max(list.page - (PAGE_WINDOW - 1), Math.min(startRaw, list.page)),
|
|
170
|
+
),
|
|
171
|
+
);
|
|
145
172
|
const windowPages = useMemo(() => {
|
|
146
173
|
const end = Math.min(list.pages, start + PAGE_WINDOW);
|
|
147
174
|
const out: number[] = [];
|
|
148
175
|
for (let i = start; i < end; i++) out.push(i);
|
|
149
176
|
return out;
|
|
150
177
|
}, [start, list.pages]);
|
|
178
|
+
const windowCells = useMemo(
|
|
179
|
+
() =>
|
|
180
|
+
windowPages.map((p) => cells.slice(p * pageSize, (p + 1) * pageSize)),
|
|
181
|
+
[cells, windowPages, pageSize],
|
|
182
|
+
);
|
|
151
183
|
|
|
152
|
-
|
|
153
|
-
if (list.page < start || list.page > start + PAGE_WINDOW - 1) {
|
|
154
|
-
setStartRaw(list.page - (PAGE_WINDOW >> 1));
|
|
155
|
-
}
|
|
156
|
-
}, [list.page, start]);
|
|
157
|
-
|
|
184
|
+
const didInitScroll = useRef(false);
|
|
158
185
|
useLayoutEffect(() => {
|
|
159
186
|
const el = stripRef.current;
|
|
160
187
|
if (!el || w <= 0) return;
|
|
@@ -162,13 +189,18 @@ export const ItemPanel = memo(function ItemPanel({
|
|
|
162
189
|
if (Math.abs(el.scrollLeft - target) > 2) {
|
|
163
190
|
el.scrollTo({
|
|
164
191
|
left: target,
|
|
165
|
-
behavior:
|
|
192
|
+
behavior:
|
|
193
|
+
fromScroll.current || !didInitScroll.current
|
|
194
|
+
? 'instant'
|
|
195
|
+
: 'smooth',
|
|
166
196
|
});
|
|
167
197
|
}
|
|
198
|
+
didInitScroll.current = true;
|
|
168
199
|
fromScroll.current = false;
|
|
169
|
-
}, [list.page,
|
|
200
|
+
}, [list.page, w]);
|
|
170
201
|
|
|
171
202
|
const idle = useRef<number | undefined>(undefined);
|
|
203
|
+
const [scrolling, setScrolling] = useState(false);
|
|
172
204
|
useEffect(() => () => window.clearTimeout(idle.current), []);
|
|
173
205
|
|
|
174
206
|
const onStripScroll = (event: UIEvent<HTMLDivElement>) => {
|
|
@@ -178,15 +210,16 @@ export const ItemPanel = memo(function ItemPanel({
|
|
|
178
210
|
0,
|
|
179
211
|
Math.min(list.pages - 1, Math.round(el.scrollLeft / w)),
|
|
180
212
|
);
|
|
181
|
-
|
|
182
|
-
fromScroll.current = true;
|
|
183
|
-
setPanelPage(next);
|
|
184
|
-
}
|
|
213
|
+
setScrolling(true);
|
|
185
214
|
window.clearTimeout(idle.current);
|
|
186
|
-
idle.current = window.setTimeout(
|
|
187
|
-
()
|
|
188
|
-
|
|
189
|
-
|
|
215
|
+
idle.current = window.setTimeout(() => {
|
|
216
|
+
setScrolling(false);
|
|
217
|
+
if (next !== pageRef.current) {
|
|
218
|
+
fromScroll.current = true;
|
|
219
|
+
setPanelPage(next);
|
|
220
|
+
}
|
|
221
|
+
setStartRaw(pageRef.current - (PAGE_WINDOW >> 1));
|
|
222
|
+
}, 160);
|
|
190
223
|
};
|
|
191
224
|
|
|
192
225
|
const tabOptions = usePanelTabs(dIndex, dNames, dLang);
|
|
@@ -230,30 +263,26 @@ export const ItemPanel = memo(function ItemPanel({
|
|
|
230
263
|
className="h-full shrink-0"
|
|
231
264
|
style={{ width: start * w }}
|
|
232
265
|
/>
|
|
233
|
-
{windowPages.map((pageIndex) => (
|
|
266
|
+
{windowPages.map((pageIndex, i) => (
|
|
234
267
|
<div
|
|
235
268
|
key={pageIndex}
|
|
236
269
|
className="h-full w-full shrink-0 snap-center"
|
|
237
270
|
>
|
|
238
271
|
<ItemPanelGrid
|
|
239
|
-
cells={
|
|
240
|
-
pageIndex * pageSize,
|
|
241
|
-
(pageIndex + 1) * pageSize,
|
|
242
|
-
)}
|
|
272
|
+
cells={windowCells[i]}
|
|
243
273
|
resetKey={gridResetKey}
|
|
244
274
|
dataset={dataset}
|
|
245
275
|
lang={dLang}
|
|
246
276
|
names={dNames}
|
|
247
|
-
nav={
|
|
277
|
+
nav={cellNav}
|
|
248
278
|
cols={cols}
|
|
249
279
|
rows={rows}
|
|
250
280
|
favIds={favIds}
|
|
251
281
|
onPress={onPress}
|
|
252
|
-
onHover={
|
|
253
|
-
favoriteHover.base = target;
|
|
254
|
-
}}
|
|
282
|
+
onHover={onHover}
|
|
255
283
|
onToggleGroup={onToggleGroup}
|
|
256
284
|
draggableStacks={isCalc}
|
|
285
|
+
tooltip={!scrolling}
|
|
257
286
|
/>
|
|
258
287
|
</div>
|
|
259
288
|
))}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
3
3
|
|
|
4
|
-
import type
|
|
4
|
+
import { memo, type ReactNode } from 'react';
|
|
5
5
|
import { Minus, Plus, Star } from 'lucide-react';
|
|
6
6
|
import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
|
|
7
7
|
import { EntryGroup } from '@terrafirmagreg-team/game/components/entry/group';
|
|
@@ -27,6 +27,7 @@ function PanelChip({
|
|
|
27
27
|
names,
|
|
28
28
|
lang,
|
|
29
29
|
favIds,
|
|
30
|
+
tooltip,
|
|
30
31
|
}: {
|
|
31
32
|
id: string;
|
|
32
33
|
size: EntrySize;
|
|
@@ -36,11 +37,13 @@ function PanelChip({
|
|
|
36
37
|
names: Record<string, Record<string, string>>;
|
|
37
38
|
lang: Lang;
|
|
38
39
|
favIds?: ReadonlySet<string>;
|
|
40
|
+
tooltip?: boolean;
|
|
39
41
|
}) {
|
|
40
42
|
return (
|
|
41
43
|
<Entry
|
|
42
44
|
id={id}
|
|
43
45
|
kind={kind}
|
|
46
|
+
tooltip={tooltip === false ? false : undefined}
|
|
44
47
|
name={recipeItemName(names, lang, id)}
|
|
45
48
|
size={size}
|
|
46
49
|
variant="chip"
|
|
@@ -59,7 +62,7 @@ function PanelChip({
|
|
|
59
62
|
);
|
|
60
63
|
}
|
|
61
64
|
|
|
62
|
-
export function PanelCell({
|
|
65
|
+
export const PanelCell = memo(function PanelCell({
|
|
63
66
|
cell,
|
|
64
67
|
dataset,
|
|
65
68
|
lang,
|
|
@@ -68,6 +71,7 @@ export function PanelCell({
|
|
|
68
71
|
favIds,
|
|
69
72
|
expandLabel,
|
|
70
73
|
draggableStacks,
|
|
74
|
+
tooltip,
|
|
71
75
|
onPress,
|
|
72
76
|
onHover,
|
|
73
77
|
onToggleGroup,
|
|
@@ -80,6 +84,7 @@ export function PanelCell({
|
|
|
80
84
|
favIds?: ReadonlySet<string>;
|
|
81
85
|
expandLabel: string;
|
|
82
86
|
draggableStacks?: boolean;
|
|
87
|
+
tooltip?: boolean;
|
|
83
88
|
onPress: (id: string, ref?: 'item' | 'fluid') => void;
|
|
84
89
|
onHover?: (target: FavoriteHoverTarget | undefined) => void;
|
|
85
90
|
onToggleGroup?: (id: string) => void;
|
|
@@ -168,11 +173,12 @@ export function PanelCell({
|
|
|
168
173
|
names={names}
|
|
169
174
|
lang={lang}
|
|
170
175
|
favIds={favIds}
|
|
176
|
+
tooltip={tooltip}
|
|
171
177
|
/>
|
|
172
178
|
</button>
|
|
173
179
|
</CopyIdMenu>
|
|
174
180
|
)}
|
|
175
181
|
</li>
|
|
176
182
|
);
|
|
177
|
-
}
|
|
183
|
+
});
|
|
178
184
|
|
|
@@ -27,6 +27,7 @@ export const ItemPanelGrid = memo(function ItemPanelGrid({
|
|
|
27
27
|
onHover,
|
|
28
28
|
onToggleGroup,
|
|
29
29
|
draggableStacks,
|
|
30
|
+
tooltip,
|
|
30
31
|
}: {
|
|
31
32
|
cells: ItemPanelCell[];
|
|
32
33
|
|
|
@@ -42,6 +43,7 @@ export const ItemPanelGrid = memo(function ItemPanelGrid({
|
|
|
42
43
|
onHover?: (target: FavoriteHoverTarget | undefined) => void;
|
|
43
44
|
onToggleGroup?: (id: string) => void;
|
|
44
45
|
draggableStacks?: boolean;
|
|
46
|
+
tooltip?: boolean;
|
|
45
47
|
}) {
|
|
46
48
|
const t = useTranslations();
|
|
47
49
|
const expandLabel = t('Expand', { note: 'recipe.expand' });
|
|
@@ -75,6 +77,7 @@ export const ItemPanelGrid = memo(function ItemPanelGrid({
|
|
|
75
77
|
favIds={favIds}
|
|
76
78
|
expandLabel={expandLabel}
|
|
77
79
|
draggableStacks={draggableStacks}
|
|
80
|
+
tooltip={tooltip}
|
|
78
81
|
onPress={onPress}
|
|
79
82
|
onHover={onHover}
|
|
80
83
|
onToggleGroup={onToggleGroup}
|
|
@@ -5,27 +5,55 @@ import type {
|
|
|
5
5
|
SectionLandingView,
|
|
6
6
|
} from '@terrafirmagreg-team/kit/components/views/routes';
|
|
7
7
|
import type { RecipeSource } from '@terrafirmagreg-team/recipe/lib/source';
|
|
8
|
+
import { dumpPreloadHrefs } from '@terrafirmagreg-team/dump/lib/dump/preloads';
|
|
8
9
|
import {
|
|
9
10
|
RecipeBrowser,
|
|
10
11
|
RecipeBrowserFallback,
|
|
11
12
|
} from '@terrafirmagreg-team/recipe/components/views/browser';
|
|
12
13
|
|
|
13
|
-
export function recipeLanding({
|
|
14
|
+
export async function recipeLanding({
|
|
14
15
|
page,
|
|
15
16
|
lang,
|
|
16
|
-
}: SectionLandingProps<RecipeSource>): SectionLandingView {
|
|
17
|
+
}: SectionLandingProps<RecipeSource>): Promise<SectionLandingView> {
|
|
18
|
+
const { origin, hrefs } = await dumpPreloadHrefs({ id: page.dataset.id }, [
|
|
19
|
+
'objects.json.gz',
|
|
20
|
+
'manifest.json',
|
|
21
|
+
'registry/items.ndjson',
|
|
22
|
+
'registry/fluids.ndjson',
|
|
23
|
+
'registry/items.icons.ndjson',
|
|
24
|
+
'registry/fluids.icons.ndjson',
|
|
25
|
+
'registry/blocks.icons.ndjson',
|
|
26
|
+
'registry/tabs.ndjson',
|
|
27
|
+
'registry/groups.ndjson',
|
|
28
|
+
'registry/tags.ndjson',
|
|
29
|
+
'registry/recipe_categories.ndjson',
|
|
30
|
+
`lang/${lang}.names.ndjson`,
|
|
31
|
+
`names/${lang}.ndjson`,
|
|
32
|
+
]);
|
|
17
33
|
return {
|
|
18
34
|
node: (
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
<>
|
|
36
|
+
{origin ? <link rel="preconnect" href={origin} /> : null}
|
|
37
|
+
{hrefs.map((href) => (
|
|
38
|
+
<link
|
|
39
|
+
key={href}
|
|
40
|
+
rel="preload"
|
|
41
|
+
href={href}
|
|
42
|
+
as="fetch"
|
|
43
|
+
crossOrigin="anonymous"
|
|
26
44
|
/>
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
))}
|
|
46
|
+
<WorkspaceBody className="viewport-body">
|
|
47
|
+
<Suspense fallback={<RecipeBrowserFallback />}>
|
|
48
|
+
<RecipeBrowser
|
|
49
|
+
dataset={page.dataset.id}
|
|
50
|
+
datasetTitle={page.datasetTitle ?? page.dataset.id}
|
|
51
|
+
lang={lang}
|
|
52
|
+
versions={page.versions}
|
|
53
|
+
/>
|
|
54
|
+
</Suspense>
|
|
55
|
+
</WorkspaceBody>
|
|
56
|
+
</>
|
|
29
57
|
),
|
|
30
58
|
workspace: { full: true, pagination: false },
|
|
31
59
|
};
|
|
@@ -1,10 +1,57 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useEffect } from 'react';
|
|
3
|
-
import type {
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
3
|
+
import type {
|
|
4
|
+
SectionRightPanelProps,
|
|
5
|
+
TreeFeatureProps,
|
|
6
|
+
} from '@terrafirmagreg-team/kit/types';
|
|
7
|
+
import { ItemPanel } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel';
|
|
8
|
+
import { useRecipeSession } from '@terrafirmagreg-team/recipe/hooks/use-session';
|
|
4
9
|
import { useRecipeLeftSidebarTree } from '@terrafirmagreg-team/recipe/hooks/use-left-sidebar-tree';
|
|
10
|
+
import { EntryProvider } from '@terrafirmagreg-team/game/hooks/use-entry-context';
|
|
11
|
+
import type { RecipePageData } from '@terrafirmagreg-team/recipe/types';
|
|
5
12
|
|
|
6
13
|
export function RecipeTreeFeature({ input, dataset, onTree }: TreeFeatureProps) {
|
|
7
14
|
const tree = useRecipeLeftSidebarTree(input, dataset);
|
|
8
15
|
useEffect(() => onTree({ input, tree }), [input, tree, onTree]);
|
|
9
16
|
return null;
|
|
10
17
|
}
|
|
18
|
+
|
|
19
|
+
export function RecipePanelFeature({
|
|
20
|
+
dataset,
|
|
21
|
+
title,
|
|
22
|
+
versions,
|
|
23
|
+
lang,
|
|
24
|
+
}: SectionRightPanelProps) {
|
|
25
|
+
const page = useMemo<RecipePageData>(
|
|
26
|
+
() => ({
|
|
27
|
+
title: title ?? dataset?.id ?? '',
|
|
28
|
+
dataset: dataset ?? { id: '' },
|
|
29
|
+
lang,
|
|
30
|
+
versions,
|
|
31
|
+
}),
|
|
32
|
+
[dataset, title, lang, versions],
|
|
33
|
+
);
|
|
34
|
+
const session = useRecipeSession(page);
|
|
35
|
+
if (!dataset?.id) return null;
|
|
36
|
+
return (
|
|
37
|
+
<EntryProvider
|
|
38
|
+
dataset={session.dataset}
|
|
39
|
+
lang={lang}
|
|
40
|
+
langMap={session.langMap}
|
|
41
|
+
>
|
|
42
|
+
<ItemPanel
|
|
43
|
+
dataset={session.dataset}
|
|
44
|
+
lang={lang}
|
|
45
|
+
index={session.index}
|
|
46
|
+
indexLoading={session.indexLoading}
|
|
47
|
+
names={session.names}
|
|
48
|
+
tab={session.tab}
|
|
49
|
+
query={session.query}
|
|
50
|
+
setQuery={session.setQuery}
|
|
51
|
+
isCalc={session.place?.kind === 'calc'}
|
|
52
|
+
nav={session.nav}
|
|
53
|
+
className="hidden h-full w-90 lg:flex"
|
|
54
|
+
/>
|
|
55
|
+
</EntryProvider>
|
|
56
|
+
);
|
|
57
|
+
}
|
package/src/hooks/use-index.ts
CHANGED
|
@@ -74,6 +74,16 @@ export function useRecipeIndex(dataset: DatasetRef | undefined, lang: string) {
|
|
|
74
74
|
|
|
75
75
|
useAsyncEffect(async (isCancelled) => {
|
|
76
76
|
if (!dataset || warmKey !== key) return;
|
|
77
|
+
const conn = (
|
|
78
|
+
navigator as Navigator & {
|
|
79
|
+
connection?: { effectiveType?: string; saveData?: boolean };
|
|
80
|
+
}
|
|
81
|
+
).connection;
|
|
82
|
+
if (
|
|
83
|
+
conn?.saveData ||
|
|
84
|
+
(conn?.effectiveType && conn.effectiveType !== '4g')
|
|
85
|
+
)
|
|
86
|
+
return;
|
|
77
87
|
for (const entry of locales.filter((item) => item !== lang)) {
|
|
78
88
|
await idle();
|
|
79
89
|
if (isCancelled()) return;
|
|
@@ -20,8 +20,11 @@ import type {
|
|
|
20
20
|
FavoriteEntry,
|
|
21
21
|
ItemPanelCell,
|
|
22
22
|
RecipeCompactIndex,
|
|
23
|
+
UsedItems,
|
|
23
24
|
} from '@terrafirmagreg-team/recipe/types';
|
|
24
25
|
|
|
26
|
+
const UNUSED: UsedItems = { ids: new Set(), bases: new Set() };
|
|
27
|
+
|
|
25
28
|
export function usePanelCells({
|
|
26
29
|
dataset,
|
|
27
30
|
index,
|
|
@@ -62,7 +65,11 @@ export function usePanelCells({
|
|
|
62
65
|
[dIndex, mode, favoriteIds, tab],
|
|
63
66
|
);
|
|
64
67
|
|
|
65
|
-
const used = useMemo(
|
|
68
|
+
const used = useMemo(
|
|
69
|
+
() =>
|
|
70
|
+
mode === 'all' && hideUnused ? recipeUsedItems(dIndex) : UNUSED,
|
|
71
|
+
[dIndex, mode, hideUnused],
|
|
72
|
+
);
|
|
66
73
|
const tooltips = useItemTooltips(dataset, dLang, query.includes('$'));
|
|
67
74
|
const tagMembers = useTagMembers(dataset, query.includes('#'));
|
|
68
75
|
const filtered = useMemo(() => {
|
|
@@ -1,54 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
3
3
|
|
|
4
|
-
import { useCallback } from 'react';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!raw) return {};
|
|
13
|
-
try {
|
|
14
|
-
const parsed: unknown = JSON.parse(raw);
|
|
15
|
-
if (!parsed || typeof parsed !== 'object') return {};
|
|
16
|
-
const out: Record<string, number> = {};
|
|
17
|
-
for (const [key, value] of Object.entries(
|
|
18
|
-
parsed as Record<string, unknown>,
|
|
19
|
-
)) {
|
|
20
|
-
const page = Math.floor(Number(value));
|
|
21
|
-
if (Number.isFinite(page) && page > 0) out[key] = page;
|
|
22
|
-
}
|
|
23
|
-
return out;
|
|
24
|
-
} catch {
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
write: (value) => JSON.stringify(value),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const useStoredPanelPages = createStoredValue(
|
|
32
|
-
'wiki.recipe.panelPage',
|
|
33
|
-
codec,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
export function usePanelPage(dataset: DatasetRef) {
|
|
37
|
-
const [pages, setPages] = useStoredPanelPages();
|
|
38
|
-
const refKey = `${dataset.id}/${dataset.version ?? ''}`;
|
|
39
|
-
const setPage = useCallback(
|
|
40
|
-
(page: number) => {
|
|
41
|
-
setPages((prev) => {
|
|
42
|
-
const next = page > 0 ? page : 0;
|
|
43
|
-
if ((prev[refKey] ?? 0) === next) return prev;
|
|
44
|
-
const copy = { ...prev };
|
|
45
|
-
if (next > 0) copy[refKey] = next;
|
|
46
|
-
else delete copy[refKey];
|
|
47
|
-
return copy;
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
[refKey, setPages],
|
|
51
|
-
);
|
|
52
|
-
return { page: pages[refKey] ?? 0, setPage };
|
|
4
|
+
import { useCallback, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export function usePanelPage(_dataset: DatasetRef) {
|
|
7
|
+
const [page, setPageState] = useState(0);
|
|
8
|
+
const setPage = useCallback((next: number) => {
|
|
9
|
+
setPageState(Math.max(0, Math.floor(next)));
|
|
10
|
+
}, []);
|
|
11
|
+
return { page, setPage };
|
|
53
12
|
}
|
|
54
|
-
|
package/src/hooks/use-session.ts
CHANGED
|
@@ -6,7 +6,10 @@ import { useRecipeIndex } from '@terrafirmagreg-team/recipe/hooks/use-index';
|
|
|
6
6
|
import { useRecipeQuery } from '@terrafirmagreg-team/recipe/hooks/use-query';
|
|
7
7
|
import { useAsyncValue } from '@terrafirmagreg-team/ui/hooks/use-async-value';
|
|
8
8
|
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
clientDumpLangNames,
|
|
11
|
+
clientDumpLangRecipe,
|
|
12
|
+
} from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
10
13
|
import { useRecipeIndexNames } from '@terrafirmagreg-team/recipe/lib/client-index/store';
|
|
11
14
|
import {
|
|
12
15
|
RECIPE_ALL_TYPE,
|
|
@@ -21,6 +24,32 @@ import type {
|
|
|
21
24
|
RecipeSession,
|
|
22
25
|
} from '@terrafirmagreg-team/recipe/types';
|
|
23
26
|
|
|
27
|
+
let langMapMemo:
|
|
28
|
+
| {
|
|
29
|
+
names: Record<string, Record<string, string>>;
|
|
30
|
+
langRaw: Record<string, string> | undefined;
|
|
31
|
+
lang: string;
|
|
32
|
+
map: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
| undefined;
|
|
35
|
+
|
|
36
|
+
function mergeLangMap(
|
|
37
|
+
names: Record<string, Record<string, string>>,
|
|
38
|
+
langRaw: Record<string, string> | undefined,
|
|
39
|
+
lang: string,
|
|
40
|
+
): Record<string, string> {
|
|
41
|
+
if (
|
|
42
|
+
langMapMemo?.names === names &&
|
|
43
|
+
langMapMemo.langRaw === langRaw &&
|
|
44
|
+
langMapMemo.lang === lang
|
|
45
|
+
) {
|
|
46
|
+
return langMapMemo.map;
|
|
47
|
+
}
|
|
48
|
+
const map = { ...names.en_us, ...langRaw, ...names[lang] };
|
|
49
|
+
langMapMemo = { names, langRaw, lang, map };
|
|
50
|
+
return map;
|
|
51
|
+
}
|
|
52
|
+
|
|
24
53
|
export function useRecipeSession(page: RecipePageData): RecipeSession {
|
|
25
54
|
const { dataset: id, lang } = page;
|
|
26
55
|
const dataset =
|
|
@@ -35,24 +64,43 @@ export function useRecipeSession(page: RecipePageData): RecipeSession {
|
|
|
35
64
|
[indexNames, index],
|
|
36
65
|
);
|
|
37
66
|
const langRaw = useAsyncValue(
|
|
38
|
-
() =>
|
|
67
|
+
() =>
|
|
68
|
+
Promise.all([
|
|
69
|
+
clientDumpLangNames(dataset, lang),
|
|
70
|
+
clientDumpLangRecipe(dataset, lang),
|
|
71
|
+
]).then(([names, recipe]) => ({ ...names, ...recipe })),
|
|
39
72
|
[dataset, lang],
|
|
40
73
|
);
|
|
41
74
|
const langMap = useMemo(
|
|
42
|
-
() => (
|
|
75
|
+
() => mergeLangMap(names, langRaw, lang),
|
|
43
76
|
[langRaw, names, lang],
|
|
44
77
|
);
|
|
45
78
|
const used = useMemo(() => recipeUsedItems(index), [index]);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
79
|
+
const { type: navType, tool: navTool } = placeOpts;
|
|
80
|
+
const nav = useMemo<RecipeHrefOpts>(
|
|
81
|
+
() => ({
|
|
82
|
+
...(navType ? { type: navType } : {}),
|
|
83
|
+
...(navTool ? { tool: navTool } : {}),
|
|
84
|
+
tab: query.tab,
|
|
85
|
+
item: query.item,
|
|
86
|
+
fluid: query.fluid,
|
|
87
|
+
id: query.recipeId,
|
|
88
|
+
relation: query.relation,
|
|
89
|
+
search: query.query || undefined,
|
|
90
|
+
rpage: query.rpage + 1,
|
|
91
|
+
}),
|
|
92
|
+
[
|
|
93
|
+
navType,
|
|
94
|
+
navTool,
|
|
95
|
+
query.tab,
|
|
96
|
+
query.item,
|
|
97
|
+
query.fluid,
|
|
98
|
+
query.recipeId,
|
|
99
|
+
query.relation,
|
|
100
|
+
query.query,
|
|
101
|
+
query.rpage,
|
|
102
|
+
],
|
|
103
|
+
);
|
|
56
104
|
|
|
57
105
|
const firstType = useMemo(() => {
|
|
58
106
|
const counts = index?.typeCounts;
|
|
@@ -72,7 +120,7 @@ export function useRecipeSession(page: RecipePageData): RecipeSession {
|
|
|
72
120
|
replaceUrlState(
|
|
73
121
|
recipeHref(dataset, resolved, { ...nav, type: firstType }),
|
|
74
122
|
);
|
|
75
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- nav
|
|
123
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- nav tracks URL state; effect must run only on bare-index transitions
|
|
76
124
|
}, [bareIndex, firstType, dataset, resolved]);
|
|
77
125
|
|
|
78
126
|
return {
|
package/src/lib/client/recipe.ts
CHANGED
|
@@ -15,7 +15,7 @@ const recipeIndex = createDatasetCache(async (dataset: DatasetRef, ns: string) =
|
|
|
15
15
|
const listed = manifest?.namespaces[ns];
|
|
16
16
|
if (!listed || !listed.registry.includes('recipes')) return undefined;
|
|
17
17
|
return asRecord(
|
|
18
|
-
await clientDumpJson(dataset, 'registry/recipes.
|
|
18
|
+
await clientDumpJson(dataset, 'registry/recipes.ndjson', 'high'),
|
|
19
19
|
) as Record<string, string | string[]> | undefined;
|
|
20
20
|
});
|
|
21
21
|
|
|
@@ -43,7 +43,7 @@ export async function clientRecipeFileRels(
|
|
|
43
43
|
: category,
|
|
44
44
|
)
|
|
45
45
|
.filter((path) => !!path)
|
|
46
|
-
.map((path) => `data/${ns}/recipes/${path}.
|
|
46
|
+
.map((path) => `data/${ns}/recipes/${path}.ndjson`);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async function clientRecipeFileRel(
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
RecipeStackGroup,
|
|
6
6
|
} from '@terrafirmagreg-team/recipe/types';
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
clientDumpLangNames,
|
|
9
9
|
clientDumpNames,
|
|
10
10
|
loadClientManifest,
|
|
11
11
|
} from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
@@ -47,7 +47,7 @@ async function clientNamedCategories(
|
|
|
47
47
|
types: string[],
|
|
48
48
|
categories: RecipeCategory[],
|
|
49
49
|
): Promise<Record<string, string>> {
|
|
50
|
-
const map = await
|
|
50
|
+
const map = await clientDumpLangNames(dataset, lang);
|
|
51
51
|
const byId = new Map(categories.map((row) => [row.id, row]));
|
|
52
52
|
const names: Record<string, string> = {};
|
|
53
53
|
for (const id of types) {
|
|
@@ -67,7 +67,7 @@ async function clientRecipeGroups(
|
|
|
67
67
|
): Promise<RecipeStackGroup[]> {
|
|
68
68
|
const rows = await loadClientRegistryGroups(dataset);
|
|
69
69
|
if (!rows.length) return [];
|
|
70
|
-
const map = await
|
|
70
|
+
const map = await clientDumpLangNames(dataset, lang);
|
|
71
71
|
return rows.map((row) => ({
|
|
72
72
|
id: row.id,
|
|
73
73
|
...(row.name ? { name: dumpTextString(map, row.name) } : {}),
|
|
@@ -93,7 +93,7 @@ const loadChrome = createDatasetCache(
|
|
|
93
93
|
clientRecipeGroups(dataset, lang),
|
|
94
94
|
loadClientModNames(dataset, lang),
|
|
95
95
|
clientNamedCategories(dataset, lang, types, categories),
|
|
96
|
-
|
|
96
|
+
clientDumpLangNames(dataset, lang).then((map) => {
|
|
97
97
|
const names: Record<string, string> = {};
|
|
98
98
|
for (const tab of tabs) {
|
|
99
99
|
names[tab.id] = creativeTabName(map, tab.display.name ?? tab.id);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
2
|
-
import {
|
|
2
|
+
import { clientRegistryUsesEntries } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
3
3
|
import { loadClientTagMembers } from '@terrafirmagreg-team/dump/lib/dump/client/tags';
|
|
4
4
|
import {
|
|
5
5
|
asRecord,
|
|
@@ -30,7 +30,7 @@ const registrySliceCache = createDatasetCache(
|
|
|
30
30
|
ns: string,
|
|
31
31
|
): Promise<Record<string, Record<string, unknown>>> => {
|
|
32
32
|
const field = registryField(kind);
|
|
33
|
-
const raw = await
|
|
33
|
+
const raw = await clientRegistryUsesEntries(dataset, field, ns, 'high');
|
|
34
34
|
const map = asRecord(raw);
|
|
35
35
|
return map ? resolveEdgeRows(map) : {};
|
|
36
36
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
2
|
-
import {
|
|
2
|
+
import { clientDumpLangNames } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
3
3
|
import { loadClientKeybinds } from '@terrafirmagreg-team/dump/lib/dump/client/keybinds';
|
|
4
4
|
import {
|
|
5
5
|
loadClientRegistryTooltips,
|
|
@@ -20,7 +20,7 @@ const tooltipsApiCache = createDatasetCache(
|
|
|
20
20
|
}> => {
|
|
21
21
|
const kinds = ['item', 'block', 'fluid', 'entity'] as const;
|
|
22
22
|
const [map, keybinds, shards, modShards] = await Promise.all([
|
|
23
|
-
|
|
23
|
+
clientDumpLangNames(dataset, lang),
|
|
24
24
|
loadClientKeybinds(dataset),
|
|
25
25
|
Promise.all(
|
|
26
26
|
kinds.map((kind) => loadClientRegistryTooltips(dataset, kind)),
|
package/src/lib/og.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
2
2
|
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
3
|
-
import {
|
|
3
|
+
import { clientDumpLangNames } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
4
4
|
import { loadClientTagMembers } from '@terrafirmagreg-team/dump/lib/dump/client/tags';
|
|
5
5
|
import { stripMcFormat } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
6
6
|
import {
|
|
7
|
+
ogIconParam,
|
|
7
8
|
ogLocalized,
|
|
9
|
+
ogStackIcon,
|
|
8
10
|
ogStackName,
|
|
9
11
|
} from '@terrafirmagreg-team/dump/lib/dump/assets/og';
|
|
10
12
|
import {
|
|
11
13
|
ogImageQuery,
|
|
12
14
|
ogName,
|
|
15
|
+
registerOgIconResolver,
|
|
13
16
|
registerOgResolver,
|
|
14
17
|
type OgContext,
|
|
15
18
|
} from '@terrafirmagreg-team/preview/lib';
|
|
@@ -24,7 +27,12 @@ async function recipeOgContext(
|
|
|
24
27
|
): Promise<OgContext> {
|
|
25
28
|
const tool = search.get('tool');
|
|
26
29
|
if (tool) {
|
|
27
|
-
const
|
|
30
|
+
const glyph = TOOL_GLYPH[tool];
|
|
31
|
+
const entity = {
|
|
32
|
+
kind: 'tool',
|
|
33
|
+
name: recipeToolName(tool, lang),
|
|
34
|
+
...(glyph ? { icon: `glyph:${glyph}` } : {}),
|
|
35
|
+
};
|
|
28
36
|
return { entity, imageQuery: ogImageQuery(entity, tool) };
|
|
29
37
|
}
|
|
30
38
|
const item = search.get('item');
|
|
@@ -36,6 +44,7 @@ async function recipeOgContext(
|
|
|
36
44
|
kind,
|
|
37
45
|
name: await ogStackName(dataset, id, kind, lang),
|
|
38
46
|
id,
|
|
47
|
+
icon: `${kind}:${id}`,
|
|
39
48
|
};
|
|
40
49
|
return {
|
|
41
50
|
entity,
|
|
@@ -54,7 +63,12 @@ async function recipeOgContext(
|
|
|
54
63
|
const tagId = rest.length ? `${ns}:${tagPath}` : ns;
|
|
55
64
|
const members = await loadClientTagMembers(dataset, tagKind);
|
|
56
65
|
const list = tagId ? members?.[`#${tagId}`] : undefined;
|
|
57
|
-
const entity = {
|
|
66
|
+
const entity = {
|
|
67
|
+
kind: 'tag',
|
|
68
|
+
name: `#${tagId || id}`,
|
|
69
|
+
id,
|
|
70
|
+
icon: `${tagKind}Tag:#${tagId || id}`,
|
|
71
|
+
};
|
|
58
72
|
const description =
|
|
59
73
|
list != null
|
|
60
74
|
? `${list.length} member${list.length === 1 ? '' : 's'}`
|
|
@@ -67,7 +81,7 @@ async function recipeOgContext(
|
|
|
67
81
|
const out = recipe.outputs[0];
|
|
68
82
|
const [categories, map] = await Promise.all([
|
|
69
83
|
loadDatasetRecipeCategories(dataset),
|
|
70
|
-
|
|
84
|
+
clientDumpLangNames(dataset, lang),
|
|
71
85
|
]);
|
|
72
86
|
const category = categories.find((row) => row.id === recipe.type);
|
|
73
87
|
const catName = category
|
|
@@ -83,20 +97,31 @@ async function recipeOgContext(
|
|
|
83
97
|
lang,
|
|
84
98
|
).catch(() => recipe.id)
|
|
85
99
|
: recipe.id;
|
|
86
|
-
const entity = {
|
|
100
|
+
const entity = {
|
|
101
|
+
kind: 'recipe',
|
|
102
|
+
name,
|
|
103
|
+
id: recipe.id,
|
|
104
|
+
...(out ? { icon: `${out.kind === 'fluid' ? 'fluid' : 'item'}:${out.id}` } : {}),
|
|
105
|
+
};
|
|
87
106
|
const description = catName ?? recipe.id;
|
|
88
107
|
return { entity, description, imageQuery: ogImageQuery(entity, description) };
|
|
89
108
|
}
|
|
90
109
|
if (!type || type === 'all') return {};
|
|
91
110
|
const [categories, map] = await Promise.all([
|
|
92
111
|
loadDatasetRecipeCategories(dataset),
|
|
93
|
-
|
|
112
|
+
clientDumpLangNames(dataset, lang),
|
|
94
113
|
]);
|
|
95
114
|
const category = categories.find((row) => row.id === type);
|
|
96
115
|
if (!category) return {};
|
|
97
116
|
const localized =
|
|
98
117
|
ogLocalized(map, category.display?.name) ?? category.id;
|
|
99
|
-
const
|
|
118
|
+
const icon = ogIconParam(category.icon);
|
|
119
|
+
const entity = {
|
|
120
|
+
kind: 'category',
|
|
121
|
+
...ogName(localized),
|
|
122
|
+
id: category.id,
|
|
123
|
+
...(icon ? { icon } : {}),
|
|
124
|
+
};
|
|
100
125
|
return {
|
|
101
126
|
entity,
|
|
102
127
|
description: category.id,
|
|
@@ -104,4 +129,11 @@ async function recipeOgContext(
|
|
|
104
129
|
};
|
|
105
130
|
}
|
|
106
131
|
|
|
132
|
+
const TOOL_GLYPH: Record<string, string> = {
|
|
133
|
+
calc: 'calculator',
|
|
134
|
+
forge: 'anvil',
|
|
135
|
+
alloy: 'flask',
|
|
136
|
+
};
|
|
137
|
+
|
|
107
138
|
registerOgResolver('recipe', recipeOgContext);
|
|
139
|
+
registerOgIconResolver(ogStackIcon);
|
package/src/lib/preview.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { registerPreviewResolver } from '@terrafirmagreg-team/preview/lib';
|
|
2
|
-
import {
|
|
2
|
+
import { clientDumpLangNames } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
3
3
|
import { loadDatasetRecipeCategories } from '@terrafirmagreg-team/recipe/lib/data/category/load';
|
|
4
4
|
import { langString } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
5
5
|
import { entryPreviewIcon } from '@terrafirmagreg-team/game/lib/preview';
|
|
@@ -28,5 +28,5 @@ export async function recipeLinkPreview({
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
registerPreviewResolver('recipe', recipeLinkPreview, { langMap:
|
|
31
|
+
registerPreviewResolver('recipe', recipeLinkPreview, { langMap: clientDumpLangNames });
|
|
32
32
|
|
package/src/lib/routes.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { createSectionRoutes } from '@terrafirmagreg-team/kit/components/views/routes';
|
|
2
2
|
import { ogDeepLink } from '@terrafirmagreg-team/preview/server';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
RecipePanelFeature,
|
|
5
|
+
RecipeTreeFeature,
|
|
6
|
+
} from '@terrafirmagreg-team/recipe/components/views/layout';
|
|
4
7
|
import { RecipeAxisSwitcher } from '@terrafirmagreg-team/recipe/components/views/browser/axis-switcher';
|
|
5
8
|
import { recipeLanding } from '@terrafirmagreg-team/recipe/components/views/landing';
|
|
6
9
|
import { recipeTrees } from '@terrafirmagreg-team/recipe/components/tree';
|
|
@@ -15,6 +18,7 @@ export function recipeRoutes() {
|
|
|
15
18
|
layout: {
|
|
16
19
|
treeFeature: RecipeTreeFeature,
|
|
17
20
|
sidebar: { feature: RecipeAxisSwitcher },
|
|
21
|
+
rightPanel: RecipePanelFeature,
|
|
18
22
|
},
|
|
19
23
|
landing: recipeLanding,
|
|
20
24
|
deepLink: ogDeepLink('recipe'),
|