@terrafirmagreg-team/recipe 1.2.39 → 1.2.41

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terrafirmagreg-team/recipe",
3
- "version": "1.2.39",
3
+ "version": "1.2.41",
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.16",
29
- "@terrafirmagreg-team/kit": "^1.2.36",
28
+ "@terrafirmagreg-team/game": "^1.2.17",
29
+ "@terrafirmagreg-team/kit": "^1.2.37",
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
- "@terrafirmagreg-team/translate": "^1.2.14",
34
- "@terrafirmagreg-team/ui": "^1.2.29",
33
+ "@terrafirmagreg-team/translate": "^1.2.16",
34
+ "@terrafirmagreg-team/ui": "^1.2.31",
35
35
  "@types/pathfinding": "^0.1.0",
36
36
  "comlink": "^4.4.2",
37
37
  "fflate": "0.8.3",
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { useMemo, useRef } from 'react';
4
4
  import { SlotHitbox } from '@terrafirmagreg-team/recipe/components/cards/slot-hitbox';
5
- import { recipeGlareFilter } from '@terrafirmagreg-team/recipe/components/cards/glare-filter';
6
5
  import {
7
6
  cardStripGeo,
8
7
  countCoveredText,
@@ -120,7 +119,6 @@ export function RecipeCard({
120
119
  decoding="async"
121
120
  draggable={false}
122
121
  onError={onFail}
123
- style={recipeGlareFilter}
124
122
  />
125
123
  </>
126
124
  ) : null}
@@ -167,7 +165,7 @@ export function RecipeCard({
167
165
  />
168
166
  ))
169
167
  : null}
170
- {inView && interactive ? (
168
+ {inView ? (
171
169
  <CardWidgetTips
172
170
  widgets={recipe.widgets}
173
171
  entities={entities}
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { McText } from '@terrafirmagreg-team/game/components/entry/mc-text';
4
4
  import { dumpTextString } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
5
+ import { widgetTextColor } from '@terrafirmagreg-team/recipe/lib/cards/model';
5
6
  import type { RecipeTextWidget } from '@terrafirmagreg-team/recipe/lib/data/dto';
6
7
 
7
8
  export function CardText({
@@ -26,7 +27,7 @@ export function CardText({
26
27
  : widget.text;
27
28
  if (!content) return null;
28
29
  const wrap = widget.type === 'paragraph';
29
- const rgb = (widget.color ?? 0xffffff) & 0xffffff;
30
+ const rgb = widgetTextColor(widget.color, widget.shadow === true);
30
31
  const shadowRgb = ((rgb & 0xfcfcfc) >> 2) & 0xffffff;
31
32
  return (
32
33
  <span
@@ -5,7 +5,6 @@ import { RecipeCard } from './card';
5
5
  import { SlotHitbox } from './slot-hitbox';
6
6
  import { StripCard } from './strip-card';
7
7
  import { ScrollCard } from './scroll-card';
8
- import { recipeGlareFilter } from './glare-filter';
9
8
  import { recipeGrid } from '@terrafirmagreg-team/recipe/lib/data/grid';
10
9
  import { recipeScroll } from '@terrafirmagreg-team/recipe/lib/data/scroll';
11
10
  import { recipeSlots } from '@terrafirmagreg-team/recipe/lib/browser/recipe-slots';
@@ -134,7 +133,6 @@ export function PagedCard({
134
133
  loading="lazy"
135
134
  decoding="async"
136
135
  onError={onFail}
137
- style={recipeGlareFilter}
138
136
  />
139
137
  {inView && !props.frameOnly
140
138
  ? slots
@@ -174,7 +172,6 @@ export function PagedCard({
174
172
  height={natural}
175
173
  style={{
176
174
  transform: `translateY(${-(natural - capH)}px)`,
177
- ...recipeGlareFilter,
178
175
  }}
179
176
  loading="lazy"
180
177
  decoding="async"
@@ -16,11 +16,16 @@ import {
16
16
  type ScrollElement,
17
17
  type ScrollFrame,
18
18
  } from '@terrafirmagreg-team/recipe/lib/data/scroll';
19
+ import { widgetTextColor } from '@terrafirmagreg-team/recipe/lib/cards/model';
19
20
  import { texturePublicUrl } from '@terrafirmagreg-team/dump/lib/dump/assets/urls';
20
21
  import { dumpRelPublicUrl } from '@terrafirmagreg-team/dump/lib/dump/paths';
21
22
  import { useInView } from '@terrafirmagreg-team/ui/hooks/use-in-view';
22
23
  import { useSwipe } from '@terrafirmagreg-team/ui/hooks/use-swipe';
23
24
  import { McText } from '@terrafirmagreg-team/game/components/entry/mc-text';
25
+ import {
26
+ dumpTextLines,
27
+ dumpTextString,
28
+ } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
24
29
  import { stackIdFromRef } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
25
30
 
26
31
  const FALLBACK_PITCH = 18;
@@ -321,7 +326,7 @@ export function ScrollCard(props: Props) {
321
326
  : undefined;
322
327
 
323
328
  const renderText = (el: ScrollElement, index: number, moving: boolean) => {
324
- const rgb = (el.color ?? 0xffffff) & 0xffffff;
329
+ const rgb = widgetTextColor(el.color, true);
325
330
  const shadowRgb = ((rgb & 0xfcfcfc) >> 2) & 0xffffff;
326
331
  const x = (el.x - viewport.x) * scale;
327
332
  const y = (el.y - viewport.y) * scale;
@@ -339,7 +344,16 @@ export function ScrollCard(props: Props) {
339
344
  textShadow: `${scale / 2}px ${scale / 2}px 0 #${shadowRgb.toString(16).padStart(6, '0')}`,
340
345
  }}
341
346
  >
342
- <McText text={el.text ?? ''} surface="dark" />
347
+ <McText
348
+ text={
349
+ (el.component
350
+ ? dumpTextString(props.langMap ?? {}, el.component)
351
+ : undefined) ||
352
+ el.text ||
353
+ ''
354
+ }
355
+ surface="dark"
356
+ />
343
357
  </span>
344
358
  );
345
359
  };
@@ -414,7 +428,11 @@ export function ScrollCard(props: Props) {
414
428
  x={0}
415
429
  y={0}
416
430
  pitch={el.w * scale}
417
- tooltipLines={el.tooltip}
431
+ tooltipLines={
432
+ el.tooltipComponents?.length
433
+ ? dumpTextLines(props.langMap ?? {}, el.tooltipComponents)
434
+ : el.tooltip
435
+ }
418
436
  interactive={interactive}
419
437
  tooltipLevel={slotTooltip}
420
438
  />
@@ -471,7 +489,11 @@ export function ScrollCard(props: Props) {
471
489
  y={0}
472
490
  pitch={cell}
473
491
  hideIcon
474
- tooltipLines={el.tooltip}
492
+ tooltipLines={
493
+ el.tooltipComponents?.length
494
+ ? dumpTextLines(props.langMap ?? {}, el.tooltipComponents)
495
+ : el.tooltip
496
+ }
475
497
  interactive={interactive}
476
498
  tooltipLevel={slotTooltip}
477
499
  />
@@ -3,7 +3,6 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
3
3
 
4
4
  import { Fragment, useRef, useState } from 'react';
5
5
  import { SlotHitbox } from '@terrafirmagreg-team/recipe/components/cards/slot-hitbox';
6
- import { recipeGlareFilter } from '@terrafirmagreg-team/recipe/components/cards/glare-filter';
7
6
  import { StripCardSprite } from '@terrafirmagreg-team/recipe/components/cards/strip-card/sprite';
8
7
  import {
9
8
  StripCardTagCopy,
@@ -101,7 +100,7 @@ export function StripCard({
101
100
  setMeasured({ src, h: event.currentTarget.naturalHeight })
102
101
  }
103
102
  />
104
- <div className="absolute inset-0" style={recipeGlareFilter}>
103
+ <div className="absolute inset-0">
105
104
  <Hint label={title}>
106
105
  <StripCardSprite
107
106
  src={src}
@@ -62,6 +62,8 @@ export function RecipeFrame({
62
62
  }),
63
63
  );
64
64
  };
65
+ const onPagerWheel = (event: { deltaY: number }) =>
66
+ goPage(event.deltaY > 0 ? 1 : -1);
65
67
  return (
66
68
  <div className="flex h-full min-h-0 flex-1 flex-col">
67
69
  {strip ? (
@@ -71,9 +73,9 @@ export function RecipeFrame({
71
73
  ) : null}
72
74
  <div
73
75
  className={cn(
74
- 'grid items-center gap-x-3 border-b border-border pb-2 pt-2',
76
+ 'relative grid items-center gap-x-3 border-b border-border pb-2 pt-2 max-sm:pe-11',
75
77
  navPrev || navNext
76
- ? 'grid-cols-[minmax(0,1fr)_minmax(0,360px)_minmax(0,1fr)]'
78
+ ? 'grid-cols-[auto_minmax(0,1fr)_auto] sm:grid-cols-[minmax(0,1fr)_minmax(0,360px)_minmax(0,1fr)]'
77
79
  : 'grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]',
78
80
  )}
79
81
  >
@@ -103,15 +105,12 @@ export function RecipeFrame({
103
105
  ) : (
104
106
  <div className="min-w-0 max-w-full">{header}</div>
105
107
  )}
106
- <div className="flex min-w-0 items-center justify-self-end">
108
+ <div className="flex min-w-0 items-center justify-self-end max-sm:absolute max-sm:end-1.5 max-sm:top-1/2 max-sm:-translate-y-1/2">
107
109
  <RecipeToolbar session={session} />
108
110
  </div>
109
111
  </div>
110
112
  {list ? (
111
- <div
112
- onWheel={(event) => goPage(event.deltaY > 0 ? 1 : -1)}
113
- className="mx-auto w-full max-w-90"
114
- >
113
+ <div onWheel={onPagerWheel} className="mx-auto w-full sm:max-w-90">
115
114
  {onPageChange ? (
116
115
  <Pager
117
116
  layout="spread"
@@ -137,7 +136,7 @@ export function RecipeFrame({
137
136
  ) : null}
138
137
  <div className="relative flex min-h-0 flex-1 overflow-hidden pt-2">
139
138
  {rail ? (
140
- <div className="absolute start-0 top-2 bottom-0 z-10 flex flex-col">
139
+ <div className="z-10 flex flex-col sm:absolute sm:start-0 sm:top-2 sm:bottom-0">
141
140
  {rail}
142
141
  </div>
143
142
  ) : null}
@@ -13,7 +13,6 @@ 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 { RecipeGlareFilter } from '@terrafirmagreg-team/recipe/components/cards/glare-filter';
17
16
  import { TypeView } from '@terrafirmagreg-team/recipe/components/views/browser/type-view';
18
17
  import { ItemView } from '@terrafirmagreg-team/recipe/components/views/browser/item-view';
19
18
  import { Calculator } from '@terrafirmagreg-team/recipe/components/views/calc/calculator';
@@ -138,7 +137,6 @@ function RecipeBrowserContent({
138
137
 
139
138
  return (
140
139
  <EntryProvider dataset={dataset} lang={lang} langMap={session.langMap}>
141
- <RecipeGlareFilter />
142
140
  <div
143
141
  className={cn(
144
142
  'viewport-shell recipe-viewport not-prose flex w-full flex-col gap-3',
@@ -3,7 +3,7 @@
3
3
  import { useState } from 'react';
4
4
  import { LayoutGrid } from 'lucide-react';
5
5
  import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
6
- import { Button } from '@terrafirmagreg-team/ui/components/ui/button';
6
+ import { IconButton } from '@terrafirmagreg-team/ui/components/blocks/button/icon-button';
7
7
  import {
8
8
  Sheet,
9
9
  SheetContent,
@@ -26,15 +26,15 @@ export function RecipeToolbar({ session }: { session: RecipeSession }) {
26
26
 
27
27
  return (
28
28
  <div className="flex items-center gap-2">
29
- <Button
30
- variant="outline"
31
- size="sm"
29
+ <IconButton
30
+ variant="secondary"
31
+ size="icon-lg"
32
32
  className="lg:hidden"
33
+ label={t('Items', { note: 'recipe.items' })}
33
34
  onClick={() => setItemsOpen(true)}
34
35
  >
35
- <LayoutGrid className="size-3.5" />
36
- {t('Items', { note: 'recipe.items' })}
37
- </Button>
36
+ <LayoutGrid className="size-[58%]" />
37
+ </IconButton>
38
38
  <Sheet open={itemsOpen} onOpenChange={setItemsOpen}>
39
39
  <SheetContent side="right" className="w-full gap-3 sm:max-w-md">
40
40
  <SheetHeader>
@@ -189,6 +189,7 @@ export function TypeView({ session }: { session: RecipeSession }) {
189
189
  dir={-1}
190
190
  label={t('Previous category', { note: 'recipe.axis.prev' })}
191
191
  disabled={nonEmptyIds.length < 2}
192
+ className="max-sm:hidden"
192
193
  onClick={() => goCategory(-1)}
193
194
  />
194
195
  }
@@ -197,6 +198,7 @@ export function TypeView({ session }: { session: RecipeSession }) {
197
198
  dir={1}
198
199
  label={t('Next category', { note: 'recipe.axis.next' })}
199
200
  disabled={nonEmptyIds.length < 2}
201
+ className="max-sm:hidden"
200
202
  onClick={() => goCategory(1)}
201
203
  />
202
204
  }
@@ -0,0 +1,21 @@
1
+ import assert from 'node:assert/strict';
2
+ import { test } from 'node:test';
3
+ import { widgetTextColor } from '@terrafirmagreg-team/recipe/lib/cards/model';
4
+
5
+ test('widgetTextColor defaults uncolored shadowed text to white', () => {
6
+ assert.equal(widgetTextColor(undefined, true), 0xffffff);
7
+ });
8
+
9
+ test('widgetTextColor defaults uncolored unshadowed text to black', () => {
10
+ assert.equal(widgetTextColor(undefined, false), 0x000000);
11
+ });
12
+
13
+ test('widgetTextColor keeps explicit colors', () => {
14
+ assert.equal(widgetTextColor(0xffffff, false), 0xffffff);
15
+ assert.equal(widgetTextColor(0xff0000, true), 0xff0000);
16
+ assert.equal(widgetTextColor(0, false), 0);
17
+ });
18
+
19
+ test('widgetTextColor masks color to 24 bits', () => {
20
+ assert.equal(widgetTextColor(0x1ff0000, true), 0xff0000);
21
+ });
@@ -3,6 +3,13 @@ import type {
3
3
  RecipeTextWidget,
4
4
  } from '@terrafirmagreg-team/recipe/lib/data/dto';
5
5
 
6
+ export function widgetTextColor(
7
+ color: number | undefined,
8
+ shadow: boolean,
9
+ ): number {
10
+ return (color ?? (shadow ? 0xffffff : 0)) & 0xffffff;
11
+ }
12
+
6
13
  export type CardStripGeo = {
7
14
  slots: RecipeSlotWidget[];
8
15
  top: number;
@@ -0,0 +1,51 @@
1
+ import assert from 'node:assert/strict';
2
+ import { test } from 'node:test';
3
+ import { dumpTextLines } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
4
+ import { parseDecorWidgets } from '@terrafirmagreg-team/recipe/lib/data/parse/widgets';
5
+
6
+ const LANG = {
7
+ 'tfg.emi.fluid_veins.biomes': 'Биомы:',
8
+ 'tfg.emi.fluid_veins.yield_range': 'Выход: %s-%s',
9
+ };
10
+
11
+ test('parseDecorWidgets keeps tooltipComponents next to plain tooltip', () => {
12
+ const [widget] = parseDecorWidgets([
13
+ {
14
+ type: 'text',
15
+ x: 8,
16
+ y: 126,
17
+ w: 22,
18
+ h: 9,
19
+ text: '··· +8',
20
+ tooltip: ['Coastal Dunes, Shore'],
21
+ tooltipComponents: [
22
+ { translate: 'tfg.emi.fluid_veins.biomes' },
23
+ { text: '§7Coastal Dunes' },
24
+ ],
25
+ },
26
+ ]);
27
+ assert.equal(widget?.type, 'text');
28
+ if (widget?.type !== 'text') return;
29
+ assert.equal(widget.tooltip?.[0], 'Coastal Dunes, Shore');
30
+ assert.equal(widget?.tooltipComponents?.length, 2);
31
+ assert.equal(
32
+ widget?.tooltipComponents?.[0]?.translate,
33
+ 'tfg.emi.fluid_veins.biomes',
34
+ );
35
+ });
36
+
37
+ test('dumpTextLines resolves translate keys from lang map', () => {
38
+ const lines = dumpTextLines(LANG, [
39
+ { translate: 'tfg.emi.fluid_veins.biomes' },
40
+ {
41
+ translate: 'tfg.emi.fluid_veins.yield_range',
42
+ with: [{ text: '100' }, { text: '200' }],
43
+ },
44
+ { text: '§7plain' },
45
+ ]);
46
+ assert.deepEqual(lines, ['Биомы:', 'Выход: 100-200', '§7plain']);
47
+ });
48
+
49
+ test('dumpTextLines leaves untranslated keys empty like the card fallback', () => {
50
+ assert.deepEqual(dumpTextLines({}, [{ translate: 'missing.key' }]), ['']);
51
+ });
@@ -8,6 +8,11 @@ import {
8
8
  asTaggedReference,
9
9
  type TaggedReference,
10
10
  } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
11
+ import {
12
+ asDumpText,
13
+ asDumpTextList,
14
+ type DumpText,
15
+ } from '@terrafirmagreg-team/dump/lib/dump/contract/text';
11
16
 
12
17
  export type ScrollRect = { x: number; y: number; w: number; h: number };
13
18
 
@@ -42,8 +47,10 @@ export type ScrollElement = {
42
47
  base?: TaggedReference;
43
48
  mark?: boolean;
44
49
  tooltip?: string[];
50
+ tooltipComponents?: DumpText[];
45
51
  label?: string;
46
52
  text?: string;
53
+ component?: DumpText;
47
54
  color?: number;
48
55
  pin?: boolean;
49
56
  u?: number;
@@ -140,8 +147,10 @@ function scrollElement(value: unknown): ScrollElement | undefined {
140
147
  .map(asString)
141
148
  .filter((line): line is string => line !== undefined && line.length > 0)
142
149
  : undefined,
150
+ tooltipComponents: asDumpTextList(raw.tooltipComponents),
143
151
  label: asString(raw.label),
144
152
  text: asString(raw.text),
153
+ component: asDumpText(raw.component),
145
154
  color: asNumber(raw.color),
146
155
  pin: asBool(raw.pin) === true || undefined,
147
156
  u: asNumber(raw.u),
@@ -1,29 +0,0 @@
1
- import type { CSSProperties } from 'react';
2
-
3
- export const RECIPE_GLARE_FILTER_ID = 'recipe-glare-cut';
4
-
5
- export const recipeGlareFilter: CSSProperties = {
6
- filter: `url(#${RECIPE_GLARE_FILTER_ID})`,
7
- };
8
-
9
- export function RecipeGlareFilter() {
10
- return (
11
- <svg aria-hidden className="absolute size-0 overflow-hidden">
12
- <defs>
13
- <filter
14
- id={RECIPE_GLARE_FILTER_ID}
15
- colorInterpolationFilters="sRGB"
16
- >
17
- <feColorMatrix
18
- type="matrix"
19
- values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 -2.946 -9.912 -1.001 13.44 0"
20
- />
21
- <feComponentTransfer>
22
- <feFuncA type="table" tableValues="0.03 1" />
23
- </feComponentTransfer>
24
- </filter>
25
- </defs>
26
- </svg>
27
- );
28
- }
29
-