@terrafirmagreg-team/recipe 1.2.34 → 1.2.36

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.34",
3
+ "version": "1.2.36",
4
4
  "type": "module",
5
5
  "description": "Recipe viewer and calculator",
6
6
  "license": "LGPL-3.0-only",
@@ -26,12 +26,12 @@
26
26
  "@terrafirmagreg-team/data": "^1.2.14",
27
27
  "@terrafirmagreg-team/dump": "^1.2.25",
28
28
  "@terrafirmagreg-team/game": "^1.2.15",
29
- "@terrafirmagreg-team/kit": "^1.2.33",
29
+ "@terrafirmagreg-team/kit": "^1.2.35",
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
33
  "@terrafirmagreg-team/translate": "^1.2.14",
34
- "@terrafirmagreg-team/ui": "^1.2.25",
34
+ "@terrafirmagreg-team/ui": "^1.2.27",
35
35
  "@types/pathfinding": "^0.1.0",
36
36
  "comlink": "^4.4.2",
37
37
  "fflate": "0.8.3",
@@ -26,7 +26,8 @@ export function CardText({
26
26
  : widget.text;
27
27
  if (!content) return null;
28
28
  const wrap = widget.type === 'paragraph';
29
- const rgb = 0x000000;
29
+ const rgb = (widget.color ?? 0xffffff) & 0xffffff;
30
+ const shadowRgb = ((rgb & 0xfcfcfc) >> 2) & 0xffffff;
30
31
  return (
31
32
  <span
32
33
  className={`font-mc pointer-events-none absolute leading-none ${wrap ? 'whitespace-pre-wrap' : 'whitespace-pre'}`}
@@ -45,6 +46,11 @@ export function CardText({
45
46
  }),
46
47
  fontSize: size ?? 8 * scale,
47
48
  color: `#${rgb.toString(16).padStart(6, '0')}`,
49
+ ...(widget.shadow === true
50
+ ? {
51
+ textShadow: `${scale}px ${scale}px 0 #${shadowRgb.toString(16).padStart(6, '0')}`,
52
+ }
53
+ : {}),
48
54
  }}
49
55
  >
50
56
  <McText text={content} surface="light" />
@@ -79,6 +79,7 @@ export function RecipeFrame({
79
79
  {list ? (
80
80
  onPageChange ? (
81
81
  <Pager
82
+ layout="center"
82
83
  page={list.page}
83
84
  pages={list.pages}
84
85
  to={list.to}
@@ -96,7 +96,7 @@ export const ItemPanel = memo(function ItemPanel({
96
96
  const [expandedGroups, setExpandedGroups] = useState<ReadonlySet<string>>(
97
97
  new Set(),
98
98
  );
99
- const { cells, favoriteIds, dIndex, dNames, dLang } =
99
+ const { cells, favoriteIds, dIndex, dNames, dLang, used } =
100
100
  usePanelCells({
101
101
  dataset,
102
102
  index,
@@ -254,7 +254,7 @@ export const ItemPanel = memo(function ItemPanel({
254
254
  );
255
255
  };
256
256
 
257
- const tabOptions = usePanelTabs(dIndex, dNames, dLang);
257
+ const tabOptions = usePanelTabs(dIndex, dNames, dLang, used);
258
258
 
259
259
  const failed = isDatasetFailed(useFailedDatasets(), dataset);
260
260
 
@@ -66,7 +66,6 @@ export const PanelCell = memo(function PanelCell({
66
66
  names,
67
67
  nav,
68
68
  favIds,
69
- expandLabel,
70
69
  draggableStacks,
71
70
  onPress,
72
71
  onHover,
@@ -78,7 +77,6 @@ export const PanelCell = memo(function PanelCell({
78
77
  names: Record<string, Record<string, string>>;
79
78
  nav: RecipeHrefOpts;
80
79
  favIds?: ReadonlySet<string>;
81
- expandLabel: string;
82
80
  draggableStacks?: boolean;
83
81
  onPress: (id: string, ref?: 'item' | 'fluid') => void;
84
82
  onHover?: (target: FavoriteHoverTarget | undefined) => void;
@@ -117,7 +115,7 @@ export const PanelCell = memo(function PanelCell({
117
115
  fav={cell.fav}
118
116
  />
119
117
  ) : cell.kind === 'group' ? (
120
- <Hint label={cell.expanded ? undefined : expandLabel}>
118
+ <Hint label={cell.label}>
121
119
  <button
122
120
  type="button"
123
121
  aria-label={cell.label}
@@ -126,7 +124,11 @@ export const PanelCell = memo(function PanelCell({
126
124
  className="block rounded-sm"
127
125
  >
128
126
  <span className="relative flex size-9 items-center justify-center">
129
- <EntryGroup members={cell.members} size="lg" />
127
+ <EntryGroup
128
+ members={cell.members}
129
+ kind={cell.ref === 'fluid' ? 'fluid' : 'item'}
130
+ size="lg"
131
+ />
130
132
  <Badge className="absolute -right-0.5 -bottom-0.5 z-10 h-auto rounded-sm px-0.5 py-0 leading-tight">
131
133
  {cell.expanded ? (
132
134
  <Minus className="size-3" />
@@ -2,7 +2,6 @@
2
2
  import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
3
3
 
4
4
  import { memo } from 'react';
5
- import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
6
5
  import { PanelCell } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel-grid/cell';
7
6
  import { useMountLimit } from '@terrafirmagreg-team/recipe/hooks/use-mount-limit';
8
7
  import { useGroupOutlines } from '@terrafirmagreg-team/recipe/hooks/use-group-outlines';
@@ -47,8 +46,6 @@ export const ItemPanelGrid = memo(function ItemPanelGrid({
47
46
  eager?: boolean;
48
47
  frozen?: boolean;
49
48
  }) {
50
- const t = useTranslations();
51
- const expandLabel = t('Expand', { note: 'recipe.expand' });
52
49
  const limit = useMountLimit(cells.length, resetKey, eager);
53
50
  const shown = frozen
54
51
  ? []
@@ -81,7 +78,6 @@ export const ItemPanelGrid = memo(function ItemPanelGrid({
81
78
  names={names}
82
79
  nav={nav}
83
80
  favIds={favIds}
84
- expandLabel={expandLabel}
85
81
  draggableStacks={draggableStacks}
86
82
  onPress={onPress}
87
83
  onHover={onHover}
@@ -82,6 +82,7 @@ export function QueryPager({
82
82
  const resolved = useResolvedLang();
83
83
  return (
84
84
  <Pager
85
+ layout="center"
85
86
  page={list.page}
86
87
  pages={list.pages}
87
88
  to={list.to}
@@ -61,6 +61,8 @@ export function RecipeTypeTabs({
61
61
  help: category?.display?.name
62
62
  ? creativeTabName(langMap ?? {}, category.display.name)
63
63
  : recipeItemName(names, lang, id),
64
+ helpMod:
65
+ index?.mods?.[id.split(':', 2)[0] ?? ''] ?? id.split(':', 2)[0],
64
66
  };
65
67
  });
66
68
  }, [index, ids, lang, names, dataset, langMap]);
@@ -84,7 +84,6 @@ export function Calculator({ session }: { session: RecipeSession }) {
84
84
  nodes: deferredNodes,
85
85
  tagMembers,
86
86
  ensureMaterial,
87
- fluids: session.index?.fluids,
88
87
  });
89
88
 
90
89
  const iconItems = useMemo(
@@ -50,7 +50,6 @@ export function useCalcActions({
50
50
  nodes,
51
51
  tagMembers,
52
52
  ensureMaterial,
53
- fluids,
54
53
  }: {
55
54
  dataset: DatasetRef;
56
55
  lang: Lang;
@@ -68,9 +67,7 @@ export function useCalcActions({
68
67
  nodes: CalcNode[];
69
68
  tagMembers?: (tagId: string) => TagResolution | undefined;
70
69
  ensureMaterial?: (materialId: string) => void;
71
- fluids?: readonly string[];
72
70
  }) {
73
- const fluidIds = useMemo(() => new Set(fluids ?? []), [fluids]);
74
71
  const { checked: shared, onClick: onShare } = useCopyButton(async () => {
75
72
  const tree = encodeShare();
76
73
  const { id: datasetId, version } = dataset;
@@ -133,13 +130,6 @@ export function useCalcActions({
133
130
 
134
131
  const onAddCard = useCallback(
135
132
  (materialId: string, kind: CalcKind, pos?: { x: number; y: number }) => {
136
- if (kind === 'item' && materialId.endsWith('_bucket')) {
137
- const fluidId = materialId.slice(0, -'_bucket'.length);
138
- if (fluidIds.has(fluidId)) {
139
- materialId = fluidId;
140
- kind = 'fluid';
141
- }
142
- }
143
133
  const id = newCardId();
144
134
  persist({
145
135
  cards: [
@@ -152,7 +142,7 @@ export function useCalcActions({
152
142
  setFocusNodeId(id);
153
143
  return id;
154
144
  },
155
- [flushAmounts, persist, wires, tagSelections, setFocusNodeId, fluidIds],
145
+ [flushAmounts, persist, wires, tagSelections, setFocusNodeId],
156
146
  );
157
147
 
158
148
  const onSupplyInput = useCallback(
@@ -2,7 +2,7 @@ import { boolCodec, createStoredValue } from '@terrafirmagreg-team/ui/lib/utils/
2
2
 
3
3
  const useStoredHideUnused = createStoredValue(
4
4
  'wiki.recipe.hideUnused',
5
- boolCodec(false),
5
+ boolCodec(true),
6
6
  );
7
7
 
8
8
  export function useHideUnused() {
@@ -118,9 +118,18 @@ export function usePanelCells({
118
118
  dIndex?.groups,
119
119
  expandedGroups,
120
120
  fluidIds,
121
+ dNames[dLang] ?? dNames.en_us,
121
122
  );
122
- }, [deferredFiltered, dIndex, mode, expandedGroups, favorites.entries]);
123
+ }, [deferredFiltered, dIndex, mode, expandedGroups, favorites.entries, dNames, dLang]);
123
124
 
124
- return { cells, filtered: deferredFiltered, favoriteIds, dIndex, dNames, dLang };
125
+ return {
126
+ cells,
127
+ filtered: deferredFiltered,
128
+ favoriteIds,
129
+ dIndex,
130
+ dNames,
131
+ dLang,
132
+ used,
133
+ };
125
134
  }
126
135
 
@@ -5,12 +5,16 @@ import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
5
5
  import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
6
6
  import { panelTabRows } from '@terrafirmagreg-team/recipe/lib/browser/panel';
7
7
  import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
8
- import type { RecipeCompactIndex } from '@terrafirmagreg-team/recipe/types';
8
+ import type {
9
+ RecipeCompactIndex,
10
+ UsedItems,
11
+ } from '@terrafirmagreg-team/recipe/types';
9
12
 
10
13
  export function usePanelTabs(
11
14
  index: RecipeCompactIndex | null,
12
15
  names: Record<string, Record<string, string>>,
13
16
  lang: Lang,
17
+ used?: UsedItems,
14
18
  ) {
15
19
  const t = useTranslations();
16
20
  return useMemo(
@@ -22,10 +26,11 @@ export function usePanelTabs(
22
26
  kind: 'item',
23
27
  size: 'lg',
24
28
  href: false,
29
+ tooltip: false,
25
30
  }),
26
31
  help: t('All items', { note: 'recipe.all_items' }),
27
32
  },
28
- ...panelTabRows(index, names, lang).map((row) => ({
33
+ ...panelTabRows(index, names, lang, used).map((row) => ({
29
34
  id: row.id,
30
35
  icon: createElement(Entry, {
31
36
  ...(row.iconRef
@@ -33,11 +38,13 @@ export function usePanelTabs(
33
38
  : { id: row.icon, kind: 'item' as const }),
34
39
  size: 'lg',
35
40
  href: false,
41
+ tooltip: false,
36
42
  }),
37
43
  help: row.help,
44
+ helpMod: row.helpMod,
38
45
  })),
39
46
  ],
40
- [index, lang, names, t],
47
+ [index, lang, names, t, used],
41
48
  );
42
49
  }
43
50
 
@@ -3,13 +3,23 @@ import {
3
3
  type TaggedReference,
4
4
  } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
5
5
  import { registryId } from '@terrafirmagreg-team/dump/lib/dump/paths';
6
- import { creativeTabName } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
6
+ import {
7
+ creativeTabName,
8
+ humanizeKey,
9
+ langString,
10
+ stripMcFormat,
11
+ } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
7
12
  import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
13
+ import {
14
+ filterUsedIds,
15
+ hasRecipeUsage,
16
+ } from '@terrafirmagreg-team/recipe/lib/browser/used-items';
8
17
  import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
9
18
  import type {
10
19
  ItemPanelCell,
11
20
  RecipeCompactIndex,
12
21
  RecipeStackGroup,
22
+ UsedItems,
13
23
  } from '@terrafirmagreg-team/recipe/types';
14
24
 
15
25
  function catalogPool(index: RecipeCompactIndex, tab?: string): string[] {
@@ -24,8 +34,22 @@ type ItemPanelTabRow = {
24
34
  icon: string;
25
35
  iconRef?: TaggedReference;
26
36
  help: string;
37
+ helpMod?: string;
27
38
  };
28
39
 
40
+ function stackGroupLabel(
41
+ map: Record<string, string>,
42
+ id: string,
43
+ ): string {
44
+ const [ns, path] = id.split(':', 2);
45
+ const flat = path?.replaceAll('/', '.') ?? id;
46
+ for (const candidate of [ns, 'c', 'forge']) {
47
+ const value = langString(map, `tag.item.${candidate}.${flat}`);
48
+ if (value !== undefined) return stripMcFormat(value);
49
+ }
50
+ return humanizeKey(id);
51
+ }
52
+
29
53
  export function panelPool(
30
54
  mode: ItemPanelMode,
31
55
  favoriteIds: string[],
@@ -41,6 +65,7 @@ export function buildPanelCells(
41
65
  groups: RecipeStackGroup[] | undefined,
42
66
  expandedGroups: ReadonlySet<string>,
43
67
  fluidIds?: ReadonlySet<string>,
68
+ langMap?: Record<string, string>,
44
69
  ): ItemPanelCell[] {
45
70
  const cell = (id: string): ItemPanelCell =>
46
71
  fluidIds?.has(registryId(id))
@@ -74,12 +99,19 @@ export function buildPanelCells(
74
99
  continue;
75
100
  }
76
101
  const expanded = expandedGroups.has(group.id);
102
+ const fluid = members.every((member) =>
103
+ fluidIds?.has(registryId(member)),
104
+ );
77
105
  out.push({
78
106
  kind: 'group',
79
107
  id: group.id,
80
- label: group.name ?? group.id,
108
+ label:
109
+ group.name && group.name !== group.id
110
+ ? group.name
111
+ : stackGroupLabel(langMap ?? {}, group.id),
81
112
  members,
82
113
  expanded,
114
+ ...(fluid ? { ref: 'fluid' as const } : {}),
83
115
  });
84
116
  if (expanded)
85
117
  for (const member of members)
@@ -97,9 +129,17 @@ export function panelTabRows(
97
129
  index: RecipeCompactIndex | null,
98
130
  names: Record<string, Record<string, string>>,
99
131
  lang: Lang,
132
+ used?: UsedItems,
100
133
  ): ItemPanelTabRow[] {
134
+ const hideEmpty = used !== undefined && hasRecipeUsage(used);
101
135
  const rows: ItemPanelTabRow[] = [];
102
136
  for (const row of index?.tabs ?? []) {
137
+ if (
138
+ hideEmpty &&
139
+ filterUsedIds(index?.tabItems?.[row.id] ?? [], used).length === 0
140
+ ) {
141
+ continue;
142
+ }
103
143
  const icon =
104
144
  (row.icon ? stackIdFromRef(row.icon) : undefined) ??
105
145
  index?.tabItems?.[row.id]?.[0];
@@ -111,6 +151,9 @@ export function panelTabRows(
111
151
  help: row.display?.name
112
152
  ? creativeTabName(names[lang] ?? names.en_us ?? {}, row.display.name)
113
153
  : recipeItemName(names, lang, row.id),
154
+ helpMod:
155
+ index?.mods?.[row.id.split(':', 2)[0] ?? ''] ??
156
+ row.id.split(':', 2)[0],
114
157
  });
115
158
  }
116
159
  return rows;
@@ -53,6 +53,7 @@ export type ItemPanelCell =
53
53
  label: string;
54
54
  members: string[];
55
55
  expanded: boolean;
56
+ ref?: 'item' | 'fluid';
56
57
  }
57
58
  | { kind: 'recipe'; fav: RecipeFavorite };
58
59