@terrafirmagreg-team/recipe 1.2.22 → 1.2.23

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.
@@ -11,6 +11,7 @@ import { useCycleIndex } from '@terrafirmagreg-team/ui/hooks/use-cycle-index';
11
11
  import { stackDisplayName } from '@terrafirmagreg-team/game/lib/entry/display';
12
12
  import { entryHref } from '@terrafirmagreg-team/game/lib/entry/href';
13
13
  import { loadStackDisplay } from '@terrafirmagreg-team/game/lib/entry/tooltip';
14
+ import { texturePublicUrl } from '@terrafirmagreg-team/dump/lib/dump/assets/urls';
14
15
  import { favoriteHover } from '@terrafirmagreg-team/recipe/lib/browser/favorite-hover';
15
16
  import { useAsyncResult } from '@terrafirmagreg-team/ui/hooks/use-async-value';
16
17
  import type { ReferenceKind } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
@@ -114,6 +115,11 @@ export function SlotHitbox({
114
115
  ? widget.tagKind
115
116
  : undefined
116
117
  : widgetRefKind(widget);
118
+ const chanceUrl =
119
+ dataset && (alternatives?.length ?? 0) > 1
120
+ ? texturePublicUrl(dataset, 'emi:textures/gui/widgets.png')
121
+ : undefined;
122
+ const chance = widget.w >= 26 ? { u: 19, v: 27 } : { u: 1, v: 19 };
117
123
  const icon = (
118
124
  <span className="pointer-events-none flex size-full items-center justify-center">
119
125
  {alternatives && alternatives.length > 1 ? (
@@ -121,7 +127,19 @@ export function SlotHitbox({
121
127
  aria-hidden
122
128
  className="absolute bg-mc-inset"
123
129
  style={{ inset: scale }}
124
- />
130
+ >
131
+ {chanceUrl ? (
132
+ <span
133
+ className="absolute inset-0 block"
134
+ style={{
135
+ backgroundImage: `url(${chanceUrl})`,
136
+ backgroundSize: `${256 * scale}px ${256 * scale}px`,
137
+ backgroundPosition: `-${chance.u * scale}px -${chance.v * scale}px`,
138
+ imageRendering: 'pixelated',
139
+ }}
140
+ />
141
+ ) : null}
142
+ </span>
125
143
  ) : null}
126
144
  <EntryIcon
127
145
  id={iconId}
@@ -4,71 +4,23 @@ import { useState } from 'react';
4
4
  import { Check, Copy } from 'lucide-react';
5
5
  import { useCopyButton } from '@terrafirmagreg-team/ui/hooks/use-copy-button';
6
6
  import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
7
+ import { CardPager } from '@terrafirmagreg-team/recipe/components/cards/controls/card-pager';
8
+ import { texturePublicUrl } from '@terrafirmagreg-team/dump/lib/dump/assets/urls';
9
+ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
7
10
 
8
- export function StripCardTagPager({
9
- left,
10
- top,
11
- dir,
12
- scale,
13
- disabled,
14
- onClick,
15
- }: {
11
+ const BUTTONS_TEX = 'emi:textures/gui/buttons.png';
12
+
13
+ export function StripCardTagPager(props: {
16
14
  left: number;
17
15
  top: number;
18
16
  dir: -1 | 1;
19
17
  scale: number;
20
18
  disabled: boolean;
21
19
  onClick: () => void;
20
+ dataset: DatasetRef;
22
21
  }) {
23
- const t = useTranslations();
24
- const [hover, setHover] = useState(false);
25
- const arrow = `${3.5 * scale}px solid ${disabled ? 'var(--color-mc-inset)' : hover ? 'var(--color-mc-arrow-dark)' : 'var(--color-mc-arrow)'}`;
26
- return (
27
- <button
28
- type="button"
29
- aria-label={
30
- dir < 0
31
- ? t('Previous Page', { note: 'ui.prev_page' })
32
- : t('Next Page', { note: 'ui.next_page' })
33
- }
34
- disabled={disabled}
35
- onClick={onClick}
36
- onMouseEnter={() => setHover(true)}
37
- onMouseLeave={() => setHover(false)}
38
- onFocus={() => setHover(true)}
39
- onBlur={() => setHover(false)}
40
- className="absolute flex cursor-pointer items-center justify-center border-0 bg-transparent p-0 outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-default"
41
- style={{
42
- left: left - 4 * scale,
43
- top: top - 4 * scale,
44
- width: 20 * scale,
45
- height: 20 * scale,
46
- }}
47
- >
48
- <span
49
- aria-hidden
50
- className="flex items-center justify-center"
51
- style={{
52
- width: 12 * scale,
53
- height: 12 * scale,
54
- background: disabled ? 'var(--color-mc-dim)' : hover ? 'var(--color-mc-bright)' : 'var(--color-mc-panel)',
55
- boxShadow: `inset ${scale}px ${scale}px 0 rgba(255,255,255,0.65), inset -${scale}px -${scale}px 0 rgba(0,0,0,0.45)`,
56
- }}
57
- >
58
- <span
59
- aria-hidden
60
- className="block"
61
- style={{
62
- width: 0,
63
- height: 0,
64
- borderTop: `${2.5 * scale}px solid transparent`,
65
- borderBottom: `${2.5 * scale}px solid transparent`,
66
- ...(dir < 0 ? { borderRight: arrow } : { borderLeft: arrow }),
67
- }}
68
- />
69
- </span>
70
- </button>
71
- );
22
+ const { dataset, ...rest } = props;
23
+ return <CardPager {...rest} tex={texturePublicUrl(dataset, BUTTONS_TEX)} />;
72
24
  }
73
25
 
74
26
  export function StripCardTagCopy({
@@ -189,6 +189,7 @@ export function StripCard({
189
189
  scale={scale}
190
190
  disabled={clamped <= 0}
191
191
  onClick={() => setPage(clamped - 1)}
192
+ dataset={dataset}
192
193
  />
193
194
  <StripCardTagPager
194
195
  left={(margin + guiW - 14) * scale}
@@ -197,6 +198,7 @@ export function StripCard({
197
198
  scale={scale}
198
199
  disabled={clamped + 1 >= pages}
199
200
  onClick={() => setPage(clamped + 1)}
201
+ dataset={dataset}
200
202
  />
201
203
  </>
202
204
  )}
@@ -3,6 +3,7 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
3
3
 
4
4
  import Link from 'next/link';
5
5
  import { EntryIcon } from '@terrafirmagreg-team/game/components/entry/icon';
6
+ import { McText } from '@terrafirmagreg-team/game/components/entry/mc-text';
6
7
  import {
7
8
  EntryTooltip,
8
9
  type EntryTooltipLevel,
@@ -31,6 +32,8 @@ export function StripCardMember({
31
32
  x,
32
33
  y,
33
34
  pitch,
35
+ hideIcon,
36
+ tooltipLines,
34
37
  interactive = true,
35
38
  tooltipLevel,
36
39
  }: {
@@ -42,12 +45,17 @@ export function StripCardMember({
42
45
  x: number;
43
46
  y: number;
44
47
  pitch: number;
48
+ hideIcon?: boolean;
49
+ tooltipLines?: string[];
45
50
  interactive?: boolean;
46
51
  tooltipLevel?: EntryTooltipLevel;
47
52
  }) {
48
53
  const kind = MEMBER_KIND[member.kind ?? 'item'] ?? 'item';
49
54
  const name = stackDisplayName(langMap, member.id);
50
- const checkKind = kind === 'item' || kind === 'fluid' ? kind : undefined;
55
+ const checkKind =
56
+ kind === 'item' || kind === 'fluid' || kind === 'block' || kind === 'entity'
57
+ ? kind
58
+ : undefined;
51
59
  const stackPeek =
52
60
  dataset && checkKind
53
61
  ? loadStackDisplay.peek(dataset, member.id, checkKind)
@@ -77,15 +85,20 @@ export function StripCardMember({
77
85
  }
78
86
  const inner = (
79
87
  <>
80
- <span className="pointer-events-none flex size-full items-center justify-center">
81
- <EntryIcon
82
- id={member.id}
83
- kind={kind}
84
- dataset={dataset}
85
- size={Math.max(8, pitch - 4)}
86
- missing="placeholder"
87
- />
88
- </span>
88
+ {hideIcon ? null : (
89
+ <span
90
+ className="pointer-events-none absolute flex justify-center"
91
+ style={{ inset: 0, alignItems: 'center' }}
92
+ >
93
+ <EntryIcon
94
+ id={member.id}
95
+ kind={kind}
96
+ dataset={dataset}
97
+ size={Math.max(8, pitch - 4)}
98
+ missing="placeholder"
99
+ />
100
+ </span>
101
+ )}
89
102
  {badges.length > 0 && (
90
103
  <span
91
104
  className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-white [text-shadow:1px_1px_0_var(--color-mc-arrow)]"
@@ -96,6 +109,15 @@ export function StripCardMember({
96
109
  )}
97
110
  </>
98
111
  );
112
+ const footer = tooltipLines?.length ? (
113
+ <>
114
+ {tooltipLines.map((line, index) => (
115
+ <p key={`${index}:${line}`} className="text-muted-foreground">
116
+ <McText text={line} surface="inverted" />
117
+ </p>
118
+ ))}
119
+ </>
120
+ ) : undefined;
99
121
  const faceStyle = { left: x, top: y, width: pitch, height: pitch };
100
122
  const hover = {
101
123
  onMouseEnter: () => {
@@ -118,10 +140,11 @@ export function StripCardMember({
118
140
  dataset={dataset}
119
141
  id={member.id}
120
142
  name={name}
121
- kind={kind === 'fluid' ? 'fluid' : kind === 'entity' ? 'entity' : 'item'}
143
+ kind={kind}
122
144
  lang={lang}
123
145
  langMap={langMap}
124
146
  level={tooltipLevel}
147
+ footer={footer}
125
148
  >
126
149
  <span
127
150
  {...hover}
@@ -139,10 +162,11 @@ export function StripCardMember({
139
162
  dataset={dataset}
140
163
  id={member.id}
141
164
  name={name}
142
- kind={kind === 'fluid' ? 'fluid' : kind === 'entity' ? 'entity' : 'item'}
165
+ kind={kind}
143
166
  lang={lang}
144
167
  langMap={langMap}
145
168
  level={tooltipLevel}
169
+ footer={footer}
146
170
  >
147
171
  <span
148
172
  {...hover}
@@ -30,6 +30,7 @@ export function useRecipeIndex(dataset: DatasetRef | undefined, lang: string) {
30
30
  const [loaded, setLoaded] = useState<LoadedIndex | null>(null);
31
31
  const [complete, setComplete] = useState<string | null>(null);
32
32
  const [lastFull, setLastFull] = useState<RecipeCompactIndex | null>(null);
33
+ const [warmKey, setWarmKey] = useState<string | null>(null);
33
34
  const nonce = useDumpRetryNonce();
34
35
  const { locales: items } = useLang();
35
36
  const locales = useMemo(
@@ -62,20 +63,19 @@ export function useRecipeIndex(dataset: DatasetRef | undefined, lang: string) {
62
63
  [lang]: { ...entityNames, ...index.names[lang] },
63
64
  },
64
65
  });
65
- }, [dataset, lang, nonce]);
66
+ setWarmKey(key);
67
+ }, [dataset, lang, nonce, key]);
66
68
 
67
69
  useAsyncEffect(async (isCancelled) => {
68
- if (!dataset) return;
69
- const others = locales.filter((entry) => entry !== lang);
70
- for (const entry of others) {
71
- if (isCancelled()) return;
70
+ if (!dataset || warmKey !== key) return;
71
+ for (const entry of locales.filter((item) => item !== lang)) {
72
72
  await idle();
73
73
  if (isCancelled()) return;
74
- const chrome = await loadRecipeChromeClient(dataset, entry);
74
+ const other = await loadRecipeChromeClient(dataset, entry);
75
75
  if (isCancelled()) return;
76
- await loadRecipeCompactIndex(dataset, chrome);
76
+ await loadRecipeCompactIndex(dataset, other);
77
77
  }
78
- }, [dataset, lang, locales]);
78
+ }, [dataset, lang, locales, warmKey, key]);
79
79
 
80
80
  const active = loaded?.key === key ? loaded.index : null;
81
81
  const index = active?.items.length ? active : (lastFull ?? active);
@@ -1,34 +1,24 @@
1
1
  'use client';
2
- import { usePathname } from 'next/navigation';
3
- import { useMemo } from 'react';
4
2
  import type * as PageTree from 'fumadocs-core/page-tree';
5
- import { useLocationSearchParams } from '@terrafirmagreg-team/ui/hooks/page/use-location-search';
3
+ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
6
4
  import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
7
5
  import { useLastValue } from '@terrafirmagreg-team/ui/hooks/use-last-value';
8
6
  import { skeletonTree } from '@terrafirmagreg-team/ui/lib/tree';
9
7
  import { useRecipeModNames } from '@terrafirmagreg-team/recipe/hooks/use-mod-names';
10
8
  import { useSidebarGroup } from '@terrafirmagreg-team/recipe/hooks/use-sidebar-group';
11
9
  import { groupRecipeSidebarByMod } from '@terrafirmagreg-team/recipe/lib/browser/sidebar';
12
- import { parseSectionLocation } from '@terrafirmagreg-team/sites/location';
13
- import { useVersionPreference } from '@terrafirmagreg-team/kit/hooks/use-version-pref';
14
10
 
15
- export function useRecipeLeftSidebarTree(tree: PageTree.Root): PageTree.Root {
16
- const { dataset: datasetId } = parseSectionLocation(usePathname());
11
+ export function useRecipeLeftSidebarTree(
12
+ tree: PageTree.Root,
13
+ dataset?: DatasetRef,
14
+ ): PageTree.Root {
17
15
  const lang = useResolvedLang();
18
16
  const { sidebarGroup } = useSidebarGroup();
19
- const scopeKey = datasetId ?? '';
20
- const versionParam = useLocationSearchParams().get('version') ?? undefined;
21
- const preferred = useVersionPreference(datasetId);
22
- const version = versionParam ?? preferred;
23
- const dataset = useMemo(
24
- () => (datasetId ? { id: datasetId, version } : undefined),
25
- [datasetId, version],
26
- );
27
17
  const result = useRecipeModNames(
28
18
  sidebarGroup === 'mod' ? dataset : undefined,
29
19
  lang,
30
20
  );
31
- const modNames = useLastValue(result.value, scopeKey);
21
+ const modNames = useLastValue(result.value, dataset?.id ?? '');
32
22
  if (sidebarGroup === 'mod' && !modNames && result.pending)
33
23
  return skeletonTree('recipe:skeleton');
34
24
  return sidebarGroup === 'mod' && modNames
@@ -4,26 +4,22 @@ import type {
4
4
  RecipeChrome,
5
5
  RecipeStackGroup,
6
6
  } from '@terrafirmagreg-team/recipe/types';
7
- import { clientDumpLang, loadClientManifest } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
7
+ import {
8
+ clientDumpLang,
9
+ clientDumpNames,
10
+ loadClientManifest,
11
+ } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
8
12
  import {
9
13
  creativeTabName,
10
14
  dumpTextString,
11
15
  } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
12
- import { stackDisplayName } from '@terrafirmagreg-team/game/lib/entry/display';
13
- import {
14
- loadClientRegistry,
15
- loadClientRegistryOrder,
16
- resolveClientStackDisplay,
17
- } from '@terrafirmagreg-team/dump/lib/dump/client/registry';
16
+ import { loadClientRegistryOrder } from '@terrafirmagreg-team/dump/lib/dump/client/registry';
18
17
  import { loadClientTagMembers } from '@terrafirmagreg-team/dump/lib/dump/client/tags';
19
18
  import { loadClientTabs } from '@terrafirmagreg-team/dump/lib/dump/client/tabs';
20
19
  import { loadDatasetRecipeCategories } from '@terrafirmagreg-team/recipe/lib/data/category/load';
21
20
  import { loadClientRegistryGroups } from '@terrafirmagreg-team/dump/lib/dump/client/groups';
22
21
  import { loadClientModNames } from '@terrafirmagreg-team/dump/lib/dump/client/mods';
23
- import { loadClientModAtlases } from '@terrafirmagreg-team/dump/lib/dump/client/atlases';
24
- import { lookupSpriteInBundle } from '@terrafirmagreg-team/dump/lib/dump/assets/atlas/lookup';
25
- import { stackIdBase, stackIdFromRef } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
26
- import type { AtlasBundle } from '@terrafirmagreg-team/dump/lib/dump/assets/atlas/dto';
22
+ import { stackIdFromRef } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
27
23
  import { createDatasetCache } from '@terrafirmagreg-team/dump/lib/dump/reader';
28
24
 
29
25
  async function clientEntityNames(
@@ -31,49 +27,15 @@ async function clientEntityNames(
31
27
  lang: string,
32
28
  ids: Iterable<string>,
33
29
  ): Promise<Record<string, string>> {
34
- const [map, items, fluids] = await Promise.all([
35
- clientDumpLang(dataset, lang),
36
- loadClientRegistry(dataset, 'items'),
37
- loadClientRegistry(dataset, 'fluids'),
38
- ]);
39
- const all = [...new Set([...items.keys(), ...fluids.keys(), ...ids])];
40
- const info = new Map<string, { baseId: string; langKey?: string }>();
41
- const mods = new Set<string>();
42
- for (const id of all) {
43
- const baseId = stackIdBase(id);
44
- const langKey = resolveClientStackDisplay(id, items, fluids)?.name;
45
- info.set(id, { baseId, ...(langKey ? { langKey } : {}) });
46
- if (!langKey && baseId.includes(':') && !baseId.startsWith('#')) {
47
- const mod = baseId.split(':', 2)[0];
48
- if (mod) mods.add(mod);
30
+ const table = await clientDumpNames(dataset, lang);
31
+ for (const id of ids) {
32
+ if (table[id] === undefined) {
33
+ throw new Error(
34
+ `dump names missing id "${id}" for ${dataset.id} lang=${lang}`,
35
+ );
49
36
  }
50
37
  }
51
- const atlases = new Map<string, AtlasBundle>();
52
- await Promise.all(
53
- [...mods].map(async (mod) => {
54
- atlases.set(mod, await loadClientModAtlases(dataset, mod));
55
- }),
56
- );
57
- const names: Record<string, string> = { ...map };
58
- let processed = 0;
59
- for (const [id, entry] of info) {
60
- if (++processed % 2000 === 0) {
61
- await new Promise((resolve) => setTimeout(resolve));
62
- }
63
- const langKey =
64
- entry.langKey ??
65
- lookupSpriteInBundle(
66
- atlases.get(entry.baseId.split(':', 2)[0] ?? ''),
67
- entry.baseId,
68
- )?.sprite.langKey;
69
- const kind = entry.baseId.startsWith('#')
70
- ? undefined
71
- : fluids.has(entry.baseId)
72
- ? 'fluid'
73
- : 'item';
74
- names[id] = stackDisplayName(map, id, kind, langKey);
75
- }
76
- return names;
38
+ return { ...table };
77
39
  }
78
40
 
79
41
  async function clientNamedCategories(
@@ -56,12 +56,13 @@ const typeRowsCache = createDatasetCache(
56
56
  });
57
57
  }),
58
58
  );
59
- return buckets
59
+ const rows = buckets
60
60
  .flat()
61
61
  .sort(
62
62
  (a, b) =>
63
63
  (a.o ?? Number.MAX_SAFE_INTEGER) - (b.o ?? Number.MAX_SAFE_INTEGER),
64
64
  );
65
+ return rows;
65
66
  },
66
67
  (dataset, _index, typeId) => `${dataset.id}/${dataset.version ?? ''} ${typeId}`,
67
68
  );
@@ -1,8 +1,54 @@
1
1
  import {
2
+ asBool,
2
3
  asNumber,
3
4
  asRecord,
4
5
  asString,
5
6
  } from '@terrafirmagreg-team/dump/lib/dump/contract/read';
7
+ import {
8
+ asTaggedReference,
9
+ type TaggedReference,
10
+ } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
11
+
12
+ export type ScrollRect = { x: number; y: number; w: number; h: number };
13
+
14
+ export type ScrollBarSkinPiece = {
15
+ u: number;
16
+ v: number;
17
+ w: number;
18
+ h: number;
19
+ s: number | number[];
20
+ };
21
+
22
+ export type ScrollBarSkin = {
23
+ track: ScrollBarSkinPiece;
24
+ thumb: ScrollBarSkinPiece;
25
+ };
26
+
27
+ export type ScrollFrame = {
28
+ tex: string;
29
+ u: number;
30
+ v: number;
31
+ s: number;
32
+ t: number;
33
+ };
34
+
35
+ export type ScrollElement = {
36
+ x: number;
37
+ y: number;
38
+ w: number;
39
+ h: number;
40
+ kind: 'slot' | 'text' | 'block' | 'entity';
41
+ ref?: TaggedReference;
42
+ base?: TaggedReference;
43
+ mark?: boolean;
44
+ tooltip?: string[];
45
+ label?: string;
46
+ text?: string;
47
+ color?: number;
48
+ pin?: boolean;
49
+ u?: number;
50
+ v?: number;
51
+ };
6
52
 
7
53
  export type RecipeScroll = {
8
54
  x: number;
@@ -12,8 +58,97 @@ export type RecipeScroll = {
12
58
  axis: 'vertical' | 'horizontal';
13
59
  contentH: number;
14
60
  contentW: number;
61
+ bar?: ScrollRect;
62
+ viewport?: ScrollRect;
63
+ clipTop?: number;
64
+ guiTex?: string;
65
+ barSkin?: ScrollBarSkin;
66
+ frame?: ScrollFrame;
67
+ slotTex?: string;
68
+ overlay?: string;
69
+ overlayW?: number;
70
+ overlayH?: number;
71
+ decomposed?: boolean;
72
+ elements?: ScrollElement[];
15
73
  };
16
74
 
75
+ function scrollRect(value: unknown): ScrollRect | undefined {
76
+ const raw = asRecord(value);
77
+ if (!raw) return undefined;
78
+ const x = asNumber(raw.x);
79
+ const y = asNumber(raw.y);
80
+ const w = asNumber(raw.w);
81
+ const h = asNumber(raw.h);
82
+ if (x === undefined || y === undefined || !w || !h) return undefined;
83
+ return { x, y, w, h };
84
+ }
85
+
86
+ function skinPiece(value: unknown): ScrollBarSkinPiece | undefined {
87
+ const raw = asRecord(value);
88
+ if (!raw) return undefined;
89
+ const u = asNumber(raw.u);
90
+ const v = asNumber(raw.v);
91
+ const w = asNumber(raw.w);
92
+ const h = asNumber(raw.h);
93
+ if (u === undefined || v === undefined || !w || !h) return undefined;
94
+ const s = raw.s;
95
+ const slices = Array.isArray(s)
96
+ ? s.map(asNumber).filter((n): n is number => n !== undefined)
97
+ : (asNumber(s) ?? 0);
98
+ return { u, v, w, h, s: slices };
99
+ }
100
+
101
+ function scrollFrame(value: unknown): ScrollFrame | undefined {
102
+ const raw = asRecord(value);
103
+ if (!raw) return undefined;
104
+ const tex = asString(raw.tex);
105
+ const u = asNumber(raw.u);
106
+ const v = asNumber(raw.v);
107
+ const s = asNumber(raw.s);
108
+ const t = asNumber(raw.t);
109
+ if (!tex || u === undefined || v === undefined || !s || !t) return undefined;
110
+ return { tex, u, v, s, t };
111
+ }
112
+
113
+ function scrollElement(value: unknown): ScrollElement | undefined {
114
+ const raw = asRecord(value);
115
+ if (!raw) return undefined;
116
+ const x = asNumber(raw.x);
117
+ const y = asNumber(raw.y);
118
+ if (x === undefined || y === undefined) return undefined;
119
+ const kind = asString(raw.kind);
120
+ if (
121
+ kind !== 'slot' &&
122
+ kind !== 'text' &&
123
+ kind !== 'block' &&
124
+ kind !== 'entity'
125
+ )
126
+ return undefined;
127
+ const w = asNumber(raw.w);
128
+ const h = asNumber(raw.h);
129
+ return {
130
+ x,
131
+ y,
132
+ w: w ?? 18,
133
+ h: h ?? 18,
134
+ kind,
135
+ ref: asTaggedReference(raw.ref),
136
+ base: asTaggedReference(raw.base),
137
+ mark: asBool(raw.mark) === true || undefined,
138
+ tooltip: Array.isArray(raw.tooltip)
139
+ ? raw.tooltip
140
+ .map(asString)
141
+ .filter((line): line is string => line !== undefined && line.length > 0)
142
+ : undefined,
143
+ label: asString(raw.label),
144
+ text: asString(raw.text),
145
+ color: asNumber(raw.color),
146
+ pin: asBool(raw.pin) === true || undefined,
147
+ u: asNumber(raw.u),
148
+ v: asNumber(raw.v),
149
+ };
150
+ }
151
+
17
152
  export function recipeScroll(
18
153
  properties: Record<string, unknown> | undefined,
19
154
  ): RecipeScroll | undefined {
@@ -26,7 +161,42 @@ export function recipeScroll(
26
161
  const contentH = asNumber(raw.contentH) ?? 0;
27
162
  const contentW = asNumber(raw.contentW) ?? 0;
28
163
  if (x === undefined || y === undefined || !w || !h) return undefined;
29
- if (contentH <= h && contentW <= w) return undefined;
30
164
  const axis = asString(raw.axis) === 'horizontal' ? 'horizontal' : 'vertical';
31
- return { x, y, w, h, axis, contentH, contentW };
165
+ const rawSkin = asRecord(raw.barSkin);
166
+ const barSkin =
167
+ rawSkin !== undefined
168
+ ? {
169
+ track: skinPiece(rawSkin.track),
170
+ thumb: skinPiece(rawSkin.thumb),
171
+ }
172
+ : undefined;
173
+ const elements = Array.isArray(raw.elements)
174
+ ? raw.elements
175
+ .map(scrollElement)
176
+ .filter((el): el is ScrollElement => el !== undefined)
177
+ : undefined;
178
+ return {
179
+ x,
180
+ y,
181
+ w,
182
+ h,
183
+ axis,
184
+ contentH,
185
+ contentW,
186
+ bar: scrollRect(raw.bar),
187
+ viewport: scrollRect(raw.viewport),
188
+ clipTop: asNumber(raw.clipTop) || undefined,
189
+ guiTex: asString(raw.guiTex),
190
+ barSkin:
191
+ barSkin?.track !== undefined && barSkin.thumb !== undefined
192
+ ? { track: barSkin.track, thumb: barSkin.thumb }
193
+ : undefined,
194
+ frame: scrollFrame(raw.frame),
195
+ slotTex: asString(raw.slotTex),
196
+ overlay: asString(raw.overlay),
197
+ overlayW: asNumber(raw.overlayW),
198
+ overlayH: asNumber(raw.overlayH),
199
+ decomposed: asBool(raw.decomposed) === true || undefined,
200
+ elements: elements && elements.length > 0 ? elements : undefined,
201
+ };
32
202
  }