@terrafirmagreg-team/recipe 1.2.27 → 1.2.29
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/cards/slot-hitbox.tsx +22 -4
- package/src/components/mdx/recipe.tsx +2 -2
- package/src/components/tree.tsx +7 -6
- package/src/components/views/alloy/list.tsx +1 -0
- package/src/components/views/browser/axis-switcher.tsx +6 -7
- package/src/components/views/browser/card-grid.tsx +14 -7
- package/src/components/views/browser/index.tsx +23 -9
- package/src/components/views/browser/item-panel/index.tsx +125 -70
- package/src/components/views/browser/item-panel-grid/index.tsx +10 -2
- package/src/components/views/browser/item-view/tags.tsx +2 -0
- package/src/components/views/browser/type-view.tsx +5 -4
- package/src/components/views/calc/calculator/index.tsx +2 -0
- package/src/components/views/calc/sidebar.tsx +4 -1
- package/src/components/views/forge/list.tsx +1 -0
- package/src/components/views/landing.tsx +39 -11
- package/src/hooks/alloy/use-fluid-colors.ts +2 -3
- package/src/hooks/alloy/use-mix-state.ts +2 -0
- package/src/hooks/calc/use-actions.ts +6 -4
- package/src/hooks/calc/use-data.ts +1 -0
- package/src/hooks/calc/use-share.ts +6 -4
- package/src/hooks/use-add-to-calc.ts +2 -1
- package/src/hooks/use-index.ts +29 -8
- package/src/hooks/use-mount-limit.ts +9 -3
- package/src/hooks/use-panel-page.ts +8 -50
- package/src/hooks/use-panel-warmup.ts +129 -0
- package/src/hooks/use-query.ts +8 -2
- package/src/hooks/use-session.ts +47 -7
- package/src/lib/browser/fluid-outputs.ts +2 -3
- package/src/lib/cards/model.ts +5 -1
- package/src/lib/client/recipe.ts +24 -30
- package/src/lib/client-index/catalog.ts +2 -3
- package/src/lib/client-index/chrome.test.ts +87 -0
- package/src/lib/client-index/chrome.ts +27 -134
- package/src/lib/client-index/prepared-catalog.ts +80 -0
- package/src/lib/client-index/registry.ts +3 -4
- package/src/lib/client-index/rows.test.ts +127 -0
- package/src/lib/client-index/rows.ts +51 -194
- package/src/lib/client-index/store.ts +2 -3
- package/src/lib/client-index/tooltips.ts +4 -5
- package/src/lib/links.ts +10 -3
- package/src/lib/og.ts +39 -7
- package/src/lib/preview.ts +2 -2
- package/src/types/catalog.ts +18 -0
- package/src/types/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrafirmagreg-team/recipe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.29",
|
|
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.22",
|
|
28
|
+
"@terrafirmagreg-team/game": "^1.2.13",
|
|
29
|
+
"@terrafirmagreg-team/kit": "^1.2.29",
|
|
30
30
|
"@terrafirmagreg-team/mdx": "^1.2.12",
|
|
31
|
-
"@terrafirmagreg-team/preview": "^1.2.
|
|
31
|
+
"@terrafirmagreg-team/preview": "^1.2.8",
|
|
32
32
|
"@terrafirmagreg-team/sites": "^1.2.4",
|
|
33
33
|
"@terrafirmagreg-team/translate": "^1.2.13",
|
|
34
|
-
"@terrafirmagreg-team/ui": "^1.2.
|
|
34
|
+
"@terrafirmagreg-team/ui": "^1.2.21",
|
|
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" />
|
|
@@ -79,7 +79,10 @@ export function SlotHitbox({
|
|
|
79
79
|
|
|
80
80
|
tooltipLevel?: EntryTooltipLevel;
|
|
81
81
|
}) {
|
|
82
|
-
const name =
|
|
82
|
+
const name =
|
|
83
|
+
widget.kind === 'tag'
|
|
84
|
+
? `#${widget.id.replace(/^#+/, '')}`
|
|
85
|
+
: stackDisplayName(langMap, widget.id);
|
|
83
86
|
const kind =
|
|
84
87
|
widget.kind === 'fluid' || widget.kind === 'tag' ? widget.kind : 'item';
|
|
85
88
|
const checkKind = kind === 'tag' || !interactive ? undefined : kind;
|
|
@@ -114,9 +117,11 @@ export function SlotHitbox({
|
|
|
114
117
|
? (alternatives[altIndex] ?? alternatives[0]!)
|
|
115
118
|
: widget.id;
|
|
116
119
|
const iconKind = alternatives?.length
|
|
117
|
-
? widget.
|
|
118
|
-
?
|
|
119
|
-
:
|
|
120
|
+
? widget.kind === 'fluid'
|
|
121
|
+
? 'fluid'
|
|
122
|
+
: widget.tagKind === 'fluid' || widget.tagKind === 'block'
|
|
123
|
+
? widget.tagKind
|
|
124
|
+
: undefined
|
|
120
125
|
: widgetRefKind(widget);
|
|
121
126
|
const icon = (
|
|
122
127
|
<span className="pointer-events-none flex size-full items-center justify-center">
|
|
@@ -134,6 +139,19 @@ export function SlotHitbox({
|
|
|
134
139
|
size={iconSize}
|
|
135
140
|
missing="placeholder"
|
|
136
141
|
/>
|
|
142
|
+
{widget.kind === 'tag' ? (
|
|
143
|
+
<span
|
|
144
|
+
aria-hidden
|
|
145
|
+
className="font-mc pointer-events-none absolute top-0 left-0 leading-none text-amber-300"
|
|
146
|
+
style={{
|
|
147
|
+
paddingLeft: scale / 2,
|
|
148
|
+
fontSize: (Math.min(widget.w, widget.h) / 16) * 7 * scale,
|
|
149
|
+
textShadow: `${scale}px ${scale}px 0 var(--color-mc-arrow)`,
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
#
|
|
153
|
+
</span>
|
|
154
|
+
) : null}
|
|
137
155
|
</span>
|
|
138
156
|
);
|
|
139
157
|
const pos = {
|
|
@@ -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
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import 'server-only';
|
|
2
|
-
import type
|
|
2
|
+
import { datasetCacheKey, type DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
3
|
+
import { resolveDatasetSnapshot } from '@terrafirmagreg-team/dump/lib/dump/snapshot';
|
|
3
4
|
import { createElement } from 'react';
|
|
4
5
|
import type * as PageTree from 'fumadocs-core/page-tree';
|
|
5
6
|
import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
|
|
6
|
-
import {
|
|
7
|
+
import { creativeTabName } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/load';
|
|
8
|
+
import { clientDumpLangNames } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
7
9
|
import { DUMP_POINTER_TTL } from '@terrafirmagreg-team/dump/lib/dump/json-reader';
|
|
8
10
|
import { createAsyncCache } from '@terrafirmagreg-team/data/lib/async-cache';
|
|
9
11
|
import { getRecipeSource } from '@terrafirmagreg-team/recipe/lib/source';
|
|
@@ -49,7 +51,7 @@ function categoryLeaf(
|
|
|
49
51
|
name: creativeTabName(map, category.display?.name),
|
|
50
52
|
url: `${recipeBasePath(dataset)}?type=${encodeQueryValue(category.id)}`,
|
|
51
53
|
icon: categoryIcon(dataset, category),
|
|
52
|
-
$id:
|
|
54
|
+
$id: datasetCacheKey(dataset, 'type', category.id),
|
|
53
55
|
}) as PageTree.Item;
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -69,8 +71,8 @@ async function buildRecipeTrees(lang: Lang): Promise<SectionTrees> {
|
|
|
69
71
|
const trees: SectionTrees = {};
|
|
70
72
|
for (const { id, title: datasetTitle, languages } of datasets) {
|
|
71
73
|
if (!(languages ?? [defaultLanguage]).includes(lang)) continue;
|
|
72
|
-
const ref = { id };
|
|
73
|
-
const map = await
|
|
74
|
+
const ref = await resolveDatasetSnapshot({ id });
|
|
75
|
+
const map = await clientDumpLangNames(ref, lang);
|
|
74
76
|
const source = getRecipeSource();
|
|
75
77
|
const categories = await source.categories(ref);
|
|
76
78
|
const types = (await source.manifest(ref))?.indexes.recipes.types;
|
|
@@ -96,4 +98,3 @@ async function buildRecipeTrees(lang: Lang): Promise<SectionTrees> {
|
|
|
96
98
|
}
|
|
97
99
|
return trees;
|
|
98
100
|
}
|
|
99
|
-
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
isDatasetFailed,
|
|
14
14
|
useFailedDatasets,
|
|
15
15
|
} from '@terrafirmagreg-team/kit/hooks/use-dump-status';
|
|
16
|
-
import {
|
|
16
|
+
import { useVersionedDataset } from '@terrafirmagreg-team/kit/hooks/use-versioned-dataset';
|
|
17
|
+
import { useSectionCatalog } from '@terrafirmagreg-team/kit/hooks/use-catalog';
|
|
17
18
|
|
|
18
19
|
export function RecipeAxisSwitcher() {
|
|
19
20
|
const t = useTranslations();
|
|
@@ -22,12 +23,10 @@ export function RecipeAxisSwitcher() {
|
|
|
22
23
|
const params = useLocationSearchParams();
|
|
23
24
|
const axis = recipePlaceFromParams(params).kind;
|
|
24
25
|
const failed = useFailedDatasets();
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
if (!datasetId || isDatasetFailed(failed, dataset)) return null;
|
|
26
|
+
const catalog = useSectionCatalog();
|
|
27
|
+
const meta = catalog.recipe?.find(({ id }) => id === datasetId);
|
|
28
|
+
const dataset = useVersionedDataset(datasetId, meta);
|
|
29
|
+
if (!datasetId || !dataset || isDatasetFailed(failed, dataset)) return null;
|
|
31
30
|
return (
|
|
32
31
|
<Switcher
|
|
33
32
|
options={[
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useEffect, useState, type ReactNode, type RefObject } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAsyncResult } from '@terrafirmagreg-team/ui/hooks/use-async-value';
|
|
5
5
|
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
6
6
|
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
7
7
|
import { PagedCard } from '@terrafirmagreg-team/recipe/components/cards/paged-card';
|
|
@@ -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';
|
|
@@ -18,6 +17,7 @@ import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
|
18
17
|
import { loadClientRecipe } from '@terrafirmagreg-team/recipe/lib/client/recipe';
|
|
19
18
|
import { pushUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
20
19
|
import { useSwipe } from '@terrafirmagreg-team/ui/hooks/use-swipe';
|
|
20
|
+
import { dismissOpenTooltips } from '@terrafirmagreg-team/ui/lib/dismiss-tooltips';
|
|
21
21
|
import { favoriteHover } from '@terrafirmagreg-team/recipe/lib/browser/favorite-hover';
|
|
22
22
|
import { recipeTitle } from '@terrafirmagreg-team/recipe/lib/data/parse';
|
|
23
23
|
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
@@ -70,10 +70,12 @@ function RecipeGridCard({
|
|
|
70
70
|
const t = useTranslations();
|
|
71
71
|
const resolved = useResolvedLang();
|
|
72
72
|
const { dataset, lang, langMap, names, nav, index } = session;
|
|
73
|
-
const
|
|
73
|
+
const recipeRes = useAsyncResult(
|
|
74
74
|
() => loadClientRecipe(dataset, row.id, row.bucket),
|
|
75
75
|
[dataset, row.id, row.bucket],
|
|
76
76
|
);
|
|
77
|
+
const recipe = recipeRes.value;
|
|
78
|
+
const recipeMissing = !recipeRes.pending && !recipe;
|
|
77
79
|
const [failed, setFailed] = useState(false);
|
|
78
80
|
|
|
79
81
|
const title = recipe
|
|
@@ -86,8 +88,8 @@ function RecipeGridCard({
|
|
|
86
88
|
modId: row.id.split(':', 1)[0],
|
|
87
89
|
image: row.image,
|
|
88
90
|
})
|
|
89
|
-
: undefined)
|
|
90
|
-
|
|
91
|
+
: undefined);
|
|
92
|
+
const expectsImage = recipe?.image !== undefined || row.image !== undefined;
|
|
91
93
|
|
|
92
94
|
const focus = () =>
|
|
93
95
|
pushUrlState(
|
|
@@ -159,7 +161,7 @@ function RecipeGridCard({
|
|
|
159
161
|
style={fit < 1 ? { zoom: fit } : undefined}
|
|
160
162
|
>
|
|
161
163
|
{recipe ? (
|
|
162
|
-
src && !failed ? (
|
|
164
|
+
!expectsImage || (src && !failed) ? (
|
|
163
165
|
<PagedCard
|
|
164
166
|
recipe={recipe}
|
|
165
167
|
dataset={dataset}
|
|
@@ -167,7 +169,7 @@ function RecipeGridCard({
|
|
|
167
169
|
langMap={langMap}
|
|
168
170
|
nav={nav}
|
|
169
171
|
title={title}
|
|
170
|
-
src={src}
|
|
172
|
+
src={src ?? ''}
|
|
171
173
|
naturalW={row.d?.w}
|
|
172
174
|
naturalH={row.d?.h}
|
|
173
175
|
maxH={maxH}
|
|
@@ -189,6 +191,10 @@ function RecipeGridCard({
|
|
|
189
191
|
onError={() => setFailed(true)}
|
|
190
192
|
className="block rounded-sm"
|
|
191
193
|
/>
|
|
194
|
+
) : recipeMissing ? (
|
|
195
|
+
<EmptyState variant="empty">
|
|
196
|
+
{t('No recipe image in dump.', { note: 'recipe.no_image' })}
|
|
197
|
+
</EmptyState>
|
|
192
198
|
) : (
|
|
193
199
|
<Skeleton
|
|
194
200
|
className="rounded-sm"
|
|
@@ -268,6 +274,7 @@ export function RecipeCardGrid({
|
|
|
268
274
|
<div
|
|
269
275
|
ref={boxRef}
|
|
270
276
|
{...swipe}
|
|
277
|
+
onScroll={dismissOpenTooltips}
|
|
271
278
|
className="flex min-h-0 flex-1 flex-col items-center justify-start gap-2 overflow-x-auto overflow-y-clip"
|
|
272
279
|
>
|
|
273
280
|
{body}
|
|
@@ -29,6 +29,9 @@ import { EntryProvider } from '@terrafirmagreg-team/game/hooks/use-entry-context
|
|
|
29
29
|
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
30
30
|
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
31
31
|
import type { RecipePageData } from '@terrafirmagreg-team/recipe/types';
|
|
32
|
+
import type { DatasetSnapshot } from '@terrafirmagreg-team/sites/location';
|
|
33
|
+
import { useVersionedDataset } from '@terrafirmagreg-team/kit/hooks/use-versioned-dataset';
|
|
34
|
+
import { SnapshotBoundary } from '@terrafirmagreg-team/kit/components/dump-status/snapshot-boundary';
|
|
32
35
|
|
|
33
36
|
export function RecipeBrowserFallback() {
|
|
34
37
|
return (
|
|
@@ -54,20 +57,32 @@ export function RecipeBrowserFallback() {
|
|
|
54
57
|
);
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
dataset: id,
|
|
59
|
-
datasetTitle,
|
|
60
|
-
lang,
|
|
61
|
-
versions,
|
|
62
|
-
}: {
|
|
60
|
+
type RecipeBrowserProps = {
|
|
63
61
|
dataset: string;
|
|
64
62
|
datasetTitle: string;
|
|
65
63
|
lang: Lang;
|
|
66
64
|
versions?: readonly string[];
|
|
67
|
-
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export function RecipeBrowser(props: RecipeBrowserProps) {
|
|
68
|
+
const selection = useVersionedDataset(props.dataset, { versions: props.versions }) ??
|
|
69
|
+
{ id: props.dataset };
|
|
70
|
+
return (
|
|
71
|
+
<SnapshotBoundary selection={selection} fallback={<RecipeBrowserFallback />}>
|
|
72
|
+
{(dataset) => <RecipeBrowserContent {...props} dataset={dataset} />}
|
|
73
|
+
</SnapshotBoundary>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function RecipeBrowserContent({
|
|
78
|
+
dataset: pinnedDataset,
|
|
79
|
+
datasetTitle,
|
|
80
|
+
lang,
|
|
81
|
+
versions,
|
|
82
|
+
}: Omit<RecipeBrowserProps, 'dataset'> & { dataset: DatasetSnapshot }) {
|
|
68
83
|
const page: RecipePageData = {
|
|
69
84
|
title: datasetTitle,
|
|
70
|
-
dataset:
|
|
85
|
+
dataset: pinnedDataset,
|
|
71
86
|
lang,
|
|
72
87
|
versions: versions as string[] | undefined,
|
|
73
88
|
};
|
|
@@ -149,4 +164,3 @@ export function RecipeBrowser({
|
|
|
149
164
|
</EntryProvider>
|
|
150
165
|
);
|
|
151
166
|
}
|
|
152
|
-
|