@terrafirmagreg-team/recipe 1.2.30 → 1.2.32
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 +5 -5
- package/src/components/cards/card/index.tsx +3 -1
- package/src/components/cards/card/scene.tsx +1 -3
- package/src/components/cards/card/text.tsx +3 -1
- package/src/components/cards/card/tips.tsx +14 -3
- package/src/components/cards/slot-hitbox.tsx +1 -1
- package/src/components/views/browser/item-view/index.tsx +0 -2
- package/src/components/views/browser/item-view/tags.tsx +1 -7
- package/src/lib/client/recipe-categories.ts +6 -4
- package/src/lib/data/category/dto.ts +1 -0
- package/src/lib/data/dto.ts +6 -1
- package/src/lib/data/parse/layout.ts +13 -1
- package/src/lib/data/parse/widgets.ts +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrafirmagreg-team/recipe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Recipe viewer and calculator",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@terrafirmagreg-team/data": "^1.2.14",
|
|
27
|
-
"@terrafirmagreg-team/dump": "^1.2.
|
|
27
|
+
"@terrafirmagreg-team/dump": "^1.2.25",
|
|
28
28
|
"@terrafirmagreg-team/game": "^1.2.14",
|
|
29
|
-
"@terrafirmagreg-team/kit": "^1.2.
|
|
30
|
-
"@terrafirmagreg-team/mdx": "^1.2.
|
|
31
|
-
"@terrafirmagreg-team/preview": "^1.2.
|
|
29
|
+
"@terrafirmagreg-team/kit": "^1.2.31",
|
|
30
|
+
"@terrafirmagreg-team/mdx": "^1.2.14",
|
|
31
|
+
"@terrafirmagreg-team/preview": "^1.2.12",
|
|
32
32
|
"@terrafirmagreg-team/sites": "^1.2.5",
|
|
33
33
|
"@terrafirmagreg-team/translate": "^1.2.14",
|
|
34
34
|
"@terrafirmagreg-team/ui": "^1.2.23",
|
|
@@ -84,7 +84,8 @@ export function RecipeCard({
|
|
|
84
84
|
: slots;
|
|
85
85
|
const entities = recipeSceneEntities(recipe.properties);
|
|
86
86
|
const textWidgets = recipe.widgets.filter(
|
|
87
|
-
(widget): widget is RecipeTextWidget =>
|
|
87
|
+
(widget): widget is RecipeTextWidget =>
|
|
88
|
+
widget.type === 'text' || widget.type === 'paragraph',
|
|
88
89
|
);
|
|
89
90
|
const stripTexts = textWidgets.filter(
|
|
90
91
|
(widget) => textInStrip(widget, strip) && !countCoveredText(widget, strip.slots),
|
|
@@ -172,6 +173,7 @@ export function RecipeCard({
|
|
|
172
173
|
entities={entities}
|
|
173
174
|
margin={margin}
|
|
174
175
|
scale={scale}
|
|
176
|
+
langMap={langMap}
|
|
175
177
|
/>
|
|
176
178
|
) : null}
|
|
177
179
|
{inView && strip.overflow && !frameOnly ? (
|
|
@@ -9,11 +9,9 @@ import type {
|
|
|
9
9
|
RecipeSceneEntity,
|
|
10
10
|
RecipeSceneRect,
|
|
11
11
|
} from '@terrafirmagreg-team/recipe/lib/data/scene';
|
|
12
|
-
import type { RecipeDecorWidget } from '@terrafirmagreg-team/recipe/lib/data/dto';
|
|
13
|
-
|
|
14
12
|
export function sceneEntityHit(
|
|
15
13
|
entities: RecipeSceneEntity[],
|
|
16
|
-
widget:
|
|
14
|
+
widget: { x: number; y: number; w: number; h: number },
|
|
17
15
|
): boolean {
|
|
18
16
|
return entities.some((entity) => {
|
|
19
17
|
const region: RecipeSceneRect = entity.clip ?? entity;
|
|
@@ -25,12 +25,13 @@ export function CardText({
|
|
|
25
25
|
? dumpTextString(langMap ?? {}, widget.component) || widget.text
|
|
26
26
|
: widget.text;
|
|
27
27
|
if (!content) return null;
|
|
28
|
+
const wrap = widget.type === 'paragraph';
|
|
28
29
|
const rgb = widget.color === undefined ? 0xffffff : widget.color & 0xffffff;
|
|
29
30
|
const shadowRgb = ((rgb & 0xfcfcfc) >> 2) & 0xffffff;
|
|
30
31
|
const shadowed = widget.shadow === true;
|
|
31
32
|
return (
|
|
32
33
|
<span
|
|
33
|
-
className=
|
|
34
|
+
className={`font-mc pointer-events-none absolute leading-none ${wrap ? 'whitespace-pre-wrap' : 'whitespace-pre'}`}
|
|
34
35
|
style={{
|
|
35
36
|
...(anchor
|
|
36
37
|
? {
|
|
@@ -42,6 +43,7 @@ export function CardText({
|
|
|
42
43
|
: {
|
|
43
44
|
left: (widget.x + offX) * scale,
|
|
44
45
|
top: (widget.y + offY) * scale,
|
|
46
|
+
...(wrap ? { width: widget.w * scale } : {}),
|
|
45
47
|
}),
|
|
46
48
|
fontSize: size ?? 8 * scale,
|
|
47
49
|
color: `#${rgb.toString(16).padStart(6, '0')}`,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { McText } from '@terrafirmagreg-team/game/components/entry/mc-text';
|
|
4
|
+
import { dumpTextLines } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
4
5
|
import { sceneEntityHit } from '@terrafirmagreg-team/recipe/components/cards/card/scene';
|
|
5
6
|
import {
|
|
6
7
|
Tooltip,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
} from '@terrafirmagreg-team/ui/components/ui/tooltip';
|
|
10
11
|
import type {
|
|
11
12
|
RecipeDecorWidget,
|
|
13
|
+
RecipeTextWidget,
|
|
12
14
|
RecipeWidget,
|
|
13
15
|
} from '@terrafirmagreg-team/recipe/lib/data/dto';
|
|
14
16
|
import type { RecipeSceneEntity } from '@terrafirmagreg-team/recipe/lib/data/scene';
|
|
@@ -18,16 +20,22 @@ export function CardWidgetTips({
|
|
|
18
20
|
entities,
|
|
19
21
|
margin,
|
|
20
22
|
scale,
|
|
23
|
+
langMap,
|
|
21
24
|
}: {
|
|
22
25
|
widgets: RecipeWidget[];
|
|
23
26
|
entities: RecipeSceneEntity[];
|
|
24
27
|
margin: number;
|
|
25
28
|
scale: number;
|
|
29
|
+
langMap?: Record<string, string>;
|
|
26
30
|
}) {
|
|
27
31
|
return widgets
|
|
28
32
|
.filter(
|
|
29
|
-
(widget): widget is RecipeDecorWidget =>
|
|
30
|
-
widget.type === 'widget'
|
|
33
|
+
(widget): widget is RecipeDecorWidget | RecipeTextWidget =>
|
|
34
|
+
(widget.type === 'widget' ||
|
|
35
|
+
widget.type === 'text' ||
|
|
36
|
+
widget.type === 'paragraph') &&
|
|
37
|
+
((widget.tooltip?.length ?? 0) > 0 ||
|
|
38
|
+
(widget.tooltipComponents?.length ?? 0) > 0),
|
|
31
39
|
)
|
|
32
40
|
.map((widget, index) => {
|
|
33
41
|
const panel = sceneEntityHit(entities, widget);
|
|
@@ -50,7 +58,10 @@ export function CardWidgetTips({
|
|
|
50
58
|
render={<span className="absolute block" style={hit} />}
|
|
51
59
|
/>
|
|
52
60
|
<TooltipContent className="flex-col items-start gap-0.5 p-3 text-sm whitespace-pre-wrap">
|
|
53
|
-
{(widget.
|
|
61
|
+
{(widget.tooltipComponents?.length
|
|
62
|
+
? dumpTextLines(langMap ?? {}, widget.tooltipComponents)
|
|
63
|
+
: (widget.tooltip ?? [])
|
|
64
|
+
).map((line, lineIndex) => (
|
|
54
65
|
<p key={lineIndex}>
|
|
55
66
|
<McText text={line} surface="dark" />
|
|
56
67
|
</p>
|
|
@@ -123,7 +123,7 @@ export function SlotHitbox({
|
|
|
123
123
|
? widget.tagKind
|
|
124
124
|
: undefined
|
|
125
125
|
: widgetRefKind(widget);
|
|
126
|
-
const icon = (
|
|
126
|
+
const icon = widget.iconless ? null : (
|
|
127
127
|
<span className="pointer-events-none flex size-full items-center justify-center">
|
|
128
128
|
{alternatives && alternatives.length > 1 ? (
|
|
129
129
|
<span
|
|
@@ -5,25 +5,19 @@ import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-transl
|
|
|
5
5
|
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
6
6
|
import { EmptyState } from '@terrafirmagreg-team/ui/components/blocks/page/empty-state';
|
|
7
7
|
import { LinkPreview } from '@terrafirmagreg-team/ui/components/blocks/link/link-preview';
|
|
8
|
-
import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
9
8
|
import { tagPseudoId } from '@terrafirmagreg-team/dump/lib/dump/paths';
|
|
10
9
|
import { recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
11
10
|
import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
12
|
-
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
13
11
|
import type { RecipeHrefOpts } from '@terrafirmagreg-team/recipe/types';
|
|
14
12
|
|
|
15
13
|
export function ItemTagGroups({
|
|
16
14
|
groups,
|
|
17
15
|
dataset,
|
|
18
|
-
lang,
|
|
19
|
-
names,
|
|
20
16
|
query,
|
|
21
17
|
nav,
|
|
22
18
|
}: {
|
|
23
19
|
groups: [string, string[]][];
|
|
24
20
|
dataset: DatasetRef;
|
|
25
|
-
lang: Lang;
|
|
26
|
-
names: Record<string, Record<string, string>>;
|
|
27
21
|
query: string;
|
|
28
22
|
nav: RecipeHrefOpts;
|
|
29
23
|
}) {
|
|
@@ -76,7 +70,7 @@ export function ItemTagGroups({
|
|
|
76
70
|
);
|
|
77
71
|
}}
|
|
78
72
|
>
|
|
79
|
-
{
|
|
73
|
+
{`#${bare}`}
|
|
80
74
|
</LinkPreview>
|
|
81
75
|
);
|
|
82
76
|
})}
|
|
@@ -6,9 +6,11 @@ export function clientRecipeLayout(
|
|
|
6
6
|
dataset: DatasetRef,
|
|
7
7
|
categoryId: string,
|
|
8
8
|
): Promise<DumpRecipeLayout | undefined> {
|
|
9
|
-
return loadDatasetRecipeCategories(dataset).then(
|
|
10
|
-
(
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
return loadDatasetRecipeCategories(dataset).then((categories) => {
|
|
10
|
+
const cat = categories.find((item) => item.id === categoryId);
|
|
11
|
+
return cat?.layout
|
|
12
|
+
? { ...cat.layout, workstations: cat.workstations }
|
|
13
|
+
: undefined;
|
|
14
|
+
});
|
|
13
15
|
}
|
|
14
16
|
|
package/src/lib/data/dto.ts
CHANGED
|
@@ -53,10 +53,12 @@ export type RecipeSlotWidget = {
|
|
|
53
53
|
chance?: number;
|
|
54
54
|
|
|
55
55
|
alternatives?: string[];
|
|
56
|
+
|
|
57
|
+
iconless?: boolean;
|
|
56
58
|
};
|
|
57
59
|
|
|
58
60
|
export type RecipeTextWidget = {
|
|
59
|
-
type: 'text';
|
|
61
|
+
type: 'text' | 'paragraph';
|
|
60
62
|
x: number;
|
|
61
63
|
y: number;
|
|
62
64
|
w: number;
|
|
@@ -69,6 +71,7 @@ export type RecipeTextWidget = {
|
|
|
69
71
|
|
|
70
72
|
shadow?: boolean;
|
|
71
73
|
tooltip?: string[];
|
|
74
|
+
tooltipComponents?: DumpText[];
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
export type RecipeGrid = {
|
|
@@ -108,6 +111,7 @@ export type RecipeTextureWidget = {
|
|
|
108
111
|
textureW?: number;
|
|
109
112
|
textureH?: number;
|
|
110
113
|
tooltip?: string[];
|
|
114
|
+
tooltipComponents?: DumpText[];
|
|
111
115
|
};
|
|
112
116
|
|
|
113
117
|
export type RecipeDecorWidget = {
|
|
@@ -117,6 +121,7 @@ export type RecipeDecorWidget = {
|
|
|
117
121
|
w: number;
|
|
118
122
|
h: number;
|
|
119
123
|
tooltip?: string[];
|
|
124
|
+
tooltipComponents?: DumpText[];
|
|
120
125
|
};
|
|
121
126
|
|
|
122
127
|
export type RecipeWidget =
|
|
@@ -48,6 +48,7 @@ function recipeIo(
|
|
|
48
48
|
function positionedWidgets(
|
|
49
49
|
recipe: Pick<Recipe, 'slots'>,
|
|
50
50
|
covered: Set<string>,
|
|
51
|
+
workstationIds: Set<string>,
|
|
51
52
|
): RecipeWidget[] {
|
|
52
53
|
const out: RecipeWidget[] = [];
|
|
53
54
|
for (const [slotId, fill] of Object.entries(recipe.slots)) {
|
|
@@ -71,6 +72,9 @@ function positionedWidgets(
|
|
|
71
72
|
...(fill.alternatives?.length
|
|
72
73
|
? { alternatives: fill.alternatives.map(stackIdFromRef) }
|
|
73
74
|
: {}),
|
|
75
|
+
...(fill.type === 'catalyst' && workstationIds.has(fill.id)
|
|
76
|
+
? { iconless: true }
|
|
77
|
+
: {}),
|
|
74
78
|
});
|
|
75
79
|
}
|
|
76
80
|
return out;
|
|
@@ -79,6 +83,7 @@ function positionedWidgets(
|
|
|
79
83
|
function widgetsFromLayout(
|
|
80
84
|
recipe: Pick<Recipe, 'slots'>,
|
|
81
85
|
layout: DumpRecipeLayout,
|
|
86
|
+
workstationIds: Set<string>,
|
|
82
87
|
): RecipeWidget[] {
|
|
83
88
|
const out: RecipeWidget[] = [];
|
|
84
89
|
for (const slot of layout.slots) {
|
|
@@ -103,6 +108,9 @@ function widgetsFromLayout(
|
|
|
103
108
|
...(fill.alternatives?.length
|
|
104
109
|
? { alternatives: fill.alternatives.map(stackIdFromRef) }
|
|
105
110
|
: {}),
|
|
111
|
+
...(fill.type === 'catalyst' && workstationIds.has(fill.id)
|
|
112
|
+
? { iconless: true }
|
|
113
|
+
: {}),
|
|
106
114
|
});
|
|
107
115
|
}
|
|
108
116
|
return out;
|
|
@@ -110,16 +118,20 @@ function widgetsFromLayout(
|
|
|
110
118
|
|
|
111
119
|
export function hydrateRecipe(recipe: Recipe, layout?: DumpRecipeLayout): Recipe {
|
|
112
120
|
const io = recipeIo(recipe, layout);
|
|
121
|
+
const workstationIds = new Set(
|
|
122
|
+
(layout?.workstations ?? []).map((ref) => ref.id),
|
|
123
|
+
);
|
|
113
124
|
return {
|
|
114
125
|
...recipe,
|
|
115
126
|
type: recipe.category,
|
|
116
127
|
inputs: io.inputs,
|
|
117
128
|
outputs: io.outputs,
|
|
118
129
|
widgets: [
|
|
119
|
-
...(layout ? widgetsFromLayout(recipe, layout) : []),
|
|
130
|
+
...(layout ? widgetsFromLayout(recipe, layout, workstationIds) : []),
|
|
120
131
|
...positionedWidgets(
|
|
121
132
|
recipe,
|
|
122
133
|
new Set((layout?.slots ?? []).map((slot) => slot.id)),
|
|
134
|
+
workstationIds,
|
|
123
135
|
),
|
|
124
136
|
...(recipe.widgets as RecipeWidget[]).filter(
|
|
125
137
|
(widget) => widget.type !== 'slot',
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { asNumber, asRecord, asString } from '@terrafirmagreg-team/dump/lib/dump/contract/read';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
asDumpText,
|
|
4
|
+
asDumpTextList,
|
|
5
|
+
} from '@terrafirmagreg-team/dump/lib/dump/contract/text';
|
|
3
6
|
import type { RecipeWidget } from '@terrafirmagreg-team/recipe/lib/data/dto';
|
|
4
7
|
|
|
5
8
|
function parseDecorWidget(value: unknown): RecipeWidget | undefined {
|
|
@@ -17,9 +20,13 @@ function parseDecorWidget(value: unknown): RecipeWidget | undefined {
|
|
|
17
20
|
return text ? [text] : [];
|
|
18
21
|
})
|
|
19
22
|
: undefined;
|
|
23
|
+
const tooltipComponents = asDumpTextList(row.tooltipComponents);
|
|
20
24
|
const box = { x, y, w: w ?? 0, h: h ?? 0 };
|
|
21
|
-
const tip =
|
|
22
|
-
|
|
25
|
+
const tip = {
|
|
26
|
+
...(tooltip?.length ? { tooltip } : {}),
|
|
27
|
+
...(tooltipComponents?.length ? { tooltipComponents } : {}),
|
|
28
|
+
};
|
|
29
|
+
if (type === 'text' || type === 'paragraph') {
|
|
23
30
|
const component = asDumpText(row.component);
|
|
24
31
|
const text = asString(row.text) ?? (component ? '' : undefined);
|
|
25
32
|
if (text === undefined) return undefined;
|