@terrafirmagreg-team/recipe 1.2.7 → 1.2.9

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.7",
3
+ "version": "1.2.9",
4
4
  "type": "module",
5
5
  "description": "Recipe viewer and calculator",
6
6
  "license": "LGPL-3.0-only",
@@ -23,21 +23,22 @@
23
23
  "./styles.css": "./styles.css"
24
24
  },
25
25
  "dependencies": {
26
- "@terrafirmagreg-team/data": "^1.2.2",
27
- "@terrafirmagreg-team/dump": "^1.2.3",
28
- "@terrafirmagreg-team/game": "^1.2.4",
29
- "@terrafirmagreg-team/kit": "^1.2.8",
30
- "@terrafirmagreg-team/mdx": "^1.2.3",
31
- "@terrafirmagreg-team/preview": "^1.2.2",
32
- "@terrafirmagreg-team/sites": "^1.2.1",
33
- "@terrafirmagreg-team/translate": "^1.2.5",
34
- "@terrafirmagreg-team/ui": "^1.2.6",
26
+ "@terrafirmagreg-team/data": "^1.2.3",
27
+ "@terrafirmagreg-team/dump": "^1.2.5",
28
+ "@terrafirmagreg-team/game": "^1.2.5",
29
+ "@terrafirmagreg-team/kit": "^1.2.10",
30
+ "@terrafirmagreg-team/mdx": "^1.2.5",
31
+ "@terrafirmagreg-team/preview": "^1.2.3",
32
+ "@terrafirmagreg-team/sites": "^1.2.2",
33
+ "@terrafirmagreg-team/translate": "^1.2.7",
34
+ "@terrafirmagreg-team/ui": "^1.2.8",
35
+ "@types/pathfinding": "^0.1.0",
35
36
  "comlink": "^4.4.2",
36
37
  "fflate": "0.8.3",
37
38
  "fumadocs-core": "16.17.10",
38
39
  "lucide-react": "^1.63.0",
39
40
  "pathfinding": "0.4.18",
40
- "@types/pathfinding": "^0.1.0"
41
+ "server-only": "^0.0.1"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "next": ">=15",
@@ -9,6 +9,7 @@ import { recipePlaceFromParams } from '@terrafirmagreg-team/recipe/lib/links';
9
9
  import { recipeCalcHref, recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
10
10
  import { parseSectionLocation } from '@terrafirmagreg-team/sites/location';
11
11
  import { Switcher } from '@terrafirmagreg-team/ui/components/blocks/nav/switcher';
12
+ import { useFailedDatasets } from '@terrafirmagreg-team/kit/hooks/use-dump-status';
12
13
 
13
14
  export function RecipeAxisSwitcher() {
14
15
  const t = useTranslations();
@@ -16,8 +17,9 @@ export function RecipeAxisSwitcher() {
16
17
  const lang = useResolvedLang();
17
18
  const params = useLocationSearchParams();
18
19
  const axis = recipePlaceFromParams(params).kind;
20
+ const failed = useFailedDatasets();
19
21
  const dataset = { id: datasetId ?? '', version: params.get('version') ?? undefined };
20
- if (!datasetId) return null;
22
+ if (!datasetId || failed.includes(datasetId)) return null;
21
23
  return (
22
24
  <Switcher
23
25
  options={[
@@ -1,6 +1,12 @@
1
1
  'use client';
2
2
 
3
3
  import { useDocumentTitle } from '@terrafirmagreg-team/ui/hooks/use-document-title';
4
+ import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
5
+ import { useFailedDatasets } from '@terrafirmagreg-team/kit/hooks/use-dump-status';
6
+ import {
7
+ DumpUnavailable,
8
+ DumpUnavailableOverlay,
9
+ } from '@terrafirmagreg-team/kit/components/views/unavailable';
4
10
  import { useRecipeSession } from '@terrafirmagreg-team/recipe/hooks/use-session';
5
11
  import { recipeConfig } from '@terrafirmagreg-team/recipe/lib/config';
6
12
  import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
@@ -13,8 +19,10 @@ import { Calculator } from '@terrafirmagreg-team/recipe/components/views/calc/ca
13
19
  import { ForgeCalculator } from '@terrafirmagreg-team/recipe/components/views/forge';
14
20
  import { AlloyCalculator } from '@terrafirmagreg-team/recipe/components/views/alloy';
15
21
  import { RecipeFrame } from '@terrafirmagreg-team/recipe/components/views/browser/frame';
16
- import { RecipeTypeTabs } from '@terrafirmagreg-team/recipe/components/views/browser/type-tabs';
17
- import { ItemRow } from '@terrafirmagreg-team/ui/components/blocks/list/row';
22
+ import {
23
+ RecipeHeaderSkeleton,
24
+ RecipeTabsSkeleton,
25
+ } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel/skeleton';
18
26
  import { Skeleton } from '@terrafirmagreg-team/ui/components/ui/skeleton';
19
27
  import { EntryProvider } from '@terrafirmagreg-team/game/hooks/use-entry-context';
20
28
  import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
@@ -26,7 +34,10 @@ export function RecipeBrowserFallback() {
26
34
  <div className="viewport-shell recipe-viewport not-prose flex w-full flex-col gap-3">
27
35
  <div className="flex min-h-0 flex-1 gap-4">
28
36
  <main className="flex min-w-0 flex-1 flex-col">
29
- <Skeleton className="mb-3 h-9 w-full rounded-md" />
37
+ <RecipeTabsSkeleton />
38
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border pb-2 pt-2">
39
+ <RecipeHeaderSkeleton />
40
+ </div>
30
41
  <div className="flex min-h-0 flex-1 flex-col items-center justify-start gap-2 pt-2">
31
42
  {Array.from({ length: 6 }, (_, i) => (
32
43
  <Skeleton
@@ -59,9 +70,12 @@ export function RecipeBrowser({
59
70
  lang,
60
71
  versions: versions as string[] | undefined,
61
72
  };
73
+ const t = useTranslations();
62
74
  const session = useRecipeSession(page);
63
75
  const { dataset, item, fluid, names } = session;
64
76
  const focusId = item ?? fluid;
77
+ const failed =
78
+ useFailedDatasets().includes(id) && !session.index?.items.length;
65
79
 
66
80
  const focusTitle = focusId
67
81
  ? recipeItemName(names, lang, focusId)
@@ -70,8 +84,28 @@ export function RecipeBrowser({
70
84
 
71
85
  const isCalc = session.place?.kind === 'calc';
72
86
 
87
+ const frameSkeleton = (
88
+ <RecipeFrame
89
+ session={session}
90
+ strip={<RecipeTabsSkeleton />}
91
+ header={<RecipeHeaderSkeleton />}
92
+ >
93
+ <div className="flex min-h-0 flex-1 flex-col items-center justify-start gap-2 pt-2">
94
+ {Array.from({ length: 6 }, (_, i) => (
95
+ <Skeleton
96
+ key={i}
97
+ className="h-24 rounded-md"
98
+ style={{ width: 240 + (i % 3) * 70 }}
99
+ />
100
+ ))}
101
+ </div>
102
+ </RecipeFrame>
103
+ );
104
+
73
105
  let main;
74
- if (focusId) {
106
+ if (failed) {
107
+ main = frameSkeleton;
108
+ } else if (focusId) {
75
109
  main = <ItemView session={session} />;
76
110
  } else if (isCalc) {
77
111
  main = <Calculator session={session} />;
@@ -82,23 +116,7 @@ export function RecipeBrowser({
82
116
  } else if (session.place?.kind === 'type') {
83
117
  main = <TypeView session={session} />;
84
118
  } else {
85
- main = (
86
- <RecipeFrame
87
- session={session}
88
- strip={<RecipeTypeTabs session={session} ids={[]} />}
89
- header={<ItemRow layout="header" title={page.title} />}
90
- >
91
- <div className="flex min-h-0 flex-1 flex-col items-center justify-start gap-2 pt-2">
92
- {Array.from({ length: 6 }, (_, i) => (
93
- <Skeleton
94
- key={i}
95
- className="h-24 rounded-md"
96
- style={{ width: 240 + (i % 3) * 70 }}
97
- />
98
- ))}
99
- </div>
100
- </RecipeFrame>
101
- );
119
+ main = frameSkeleton;
102
120
  }
103
121
 
104
122
  return (
@@ -111,7 +129,19 @@ export function RecipeBrowser({
111
129
  )}
112
130
  >
113
131
  <div className="flex min-h-0 flex-1 gap-4">
114
- <main className="flex min-w-0 flex-1 flex-col">{main}</main>
132
+ <main className="relative flex min-w-0 flex-1 flex-col">
133
+ {main}
134
+ {failed ? (
135
+ <DumpUnavailableOverlay>
136
+ <DumpUnavailable>
137
+ {t(
138
+ 'Recipe data is temporarily unavailable. Try again later.',
139
+ { note: 'recipe.unavailable' },
140
+ )}
141
+ </DumpUnavailable>
142
+ </DumpUnavailableOverlay>
143
+ ) : null}
144
+ </main>
115
145
  </div>
116
146
  <RightSidebarPortal>
117
147
  <ItemPanel
@@ -31,7 +31,11 @@ import { usePanelPage } from '@terrafirmagreg-team/recipe/hooks/use-panel-page';
31
31
  import { useItemPress } from '@terrafirmagreg-team/recipe/hooks/use-item-press';
32
32
  import { usePanelCells } from '@terrafirmagreg-team/recipe/hooks/use-panel-cells';
33
33
  import { usePanelTabs } from '@terrafirmagreg-team/recipe/hooks/use-panel-tabs';
34
- import { PanelSkeleton } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel/skeleton';
34
+ import {
35
+ RecipePanelSkeleton,
36
+ RecipeTabsSkeleton,
37
+ } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel/skeleton';
38
+ import { useFailedDatasets } from '@terrafirmagreg-team/kit/hooks/use-dump-status';
35
39
  import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
36
40
  import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
37
41
  import type {
@@ -133,12 +137,14 @@ export const ItemPanel = memo(function ItemPanel({
133
137
 
134
138
  const tabOptions = usePanelTabs(dIndex, dNames, dLang);
135
139
 
140
+ const failed = useFailedDatasets().includes(dataset.id);
141
+
136
142
  let body;
137
143
  const indexEmpty = !index?.items.length;
138
- if (!measured || (indexLoading && indexEmpty)) {
144
+ if (!measured || ((indexLoading || failed) && indexEmpty)) {
139
145
  body =
140
- indexLoading && indexEmpty ? (
141
- <PanelSkeleton cols={cols} rows={rows} />
146
+ (indexLoading || failed) && indexEmpty ? (
147
+ <RecipePanelSkeleton cols={cols} rows={rows} />
142
148
  ) : null;
143
149
  } else if (!list.shown.length) {
144
150
  body = (
@@ -174,14 +180,18 @@ export const ItemPanel = memo(function ItemPanel({
174
180
 
175
181
  return (
176
182
  <div className={cn('not-prose flex min-h-0 flex-col gap-2', className)}>
177
- <IconPager
178
- value={mode === 'fav' ? 'fav' : (tab ?? '')}
179
- options={tabOptions}
180
- onChange={(id) => {
181
- setMode('all');
182
- setTab(id);
183
- }}
184
- />
183
+ {(indexLoading || failed) && indexEmpty ? (
184
+ <RecipeTabsSkeleton />
185
+ ) : (
186
+ <IconPager
187
+ value={mode === 'fav' ? 'fav' : (tab ?? '')}
188
+ options={tabOptions}
189
+ onChange={(id) => {
190
+ setMode('all');
191
+ setTab(id);
192
+ }}
193
+ />
194
+ )}
185
195
  <Pager
186
196
  page={list.page}
187
197
  pages={list.pages}
@@ -1,8 +1,51 @@
1
1
  'use client';
2
2
 
3
+ import { PagerArrow } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
3
4
  import { Skeleton } from '@terrafirmagreg-team/ui/components/ui/skeleton';
5
+ import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
4
6
 
5
- export function PanelSkeleton({ cols, rows }: { cols: number; rows: number }) {
7
+ export function RecipeTabsSkeleton({
8
+ count = 9,
9
+ className,
10
+ }: {
11
+ count?: number;
12
+ className?: string;
13
+ }) {
14
+ return (
15
+ <div
16
+ aria-hidden
17
+ className={cn('flex min-h-9 items-center gap-1', className)}
18
+ >
19
+ <PagerArrow dir={-1} disabled onClick={() => {}} />
20
+ <div className="flex min-w-0 flex-1 items-center justify-center gap-1">
21
+ {Array.from({ length: count }, (_, i) => (
22
+ <Skeleton key={i} className="size-9 shrink-0 rounded-sm" />
23
+ ))}
24
+ </div>
25
+ <PagerArrow dir={1} disabled onClick={() => {}} />
26
+ </div>
27
+ );
28
+ }
29
+
30
+ export function RecipeHeaderSkeleton() {
31
+ return (
32
+ <div aria-hidden className="flex items-start gap-3">
33
+ <Skeleton className="size-8 shrink-0 rounded-md" />
34
+ <div className="flex min-w-0 flex-1 flex-col gap-1">
35
+ <Skeleton className="h-3 w-20 rounded-sm" />
36
+ <Skeleton className="h-4 w-40 rounded-sm" />
37
+ </div>
38
+ </div>
39
+ );
40
+ }
41
+
42
+ export function RecipePanelSkeleton({
43
+ cols,
44
+ rows,
45
+ }: {
46
+ cols: number;
47
+ rows: number;
48
+ }) {
6
49
  return (
7
50
  <ul
8
51
  aria-hidden
@@ -11,11 +11,15 @@ import {
11
11
  SheetTitle,
12
12
  } from '@terrafirmagreg-team/ui/components/ui/sheet';
13
13
  import { ItemPanel } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel';
14
+ import { useFailedDatasets } from '@terrafirmagreg-team/kit/hooks/use-dump-status';
14
15
  import type { RecipeSession } from '@terrafirmagreg-team/recipe/types';
15
16
 
16
17
  export function RecipeToolbar({ session }: { session: RecipeSession }) {
17
18
  const t = useTranslations();
18
19
  const [itemsOpen, setItemsOpen] = useState(false);
20
+ const failed = useFailedDatasets().includes(session.dataset.id);
21
+ if ((session.indexLoading || failed) && !session.index?.items.length)
22
+ return null;
19
23
 
20
24
  return (
21
25
  <div className="flex items-center gap-2">
@@ -4,6 +4,7 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
4
4
  import { startTransition, useMemo, useState } from 'react';
5
5
  import { useLang } from '@terrafirmagreg-team/translate/provider';
6
6
  import { useAsyncEffect } from '@terrafirmagreg-team/ui/hooks/use-async-value';
7
+ import { useDumpRetryNonce } from '@terrafirmagreg-team/kit/hooks/use-dump-status';
7
8
  import {
8
9
  loadRecipeChromeClient,
9
10
  loadRecipeCompactIndex,
@@ -28,6 +29,7 @@ export function useRecipeIndex(dataset: DatasetRef | undefined, lang: string) {
28
29
  const [loaded, setLoaded] = useState<LoadedIndex | null>(null);
29
30
  const [complete, setComplete] = useState<string | null>(null);
30
31
  const [lastFull, setLastFull] = useState<RecipeCompactIndex | null>(null);
32
+ const nonce = useDumpRetryNonce();
31
33
  const { locales: items } = useLang();
32
34
  const locales = useMemo(
33
35
  () => items?.map((item) => item.locale) ?? [lang],
@@ -50,7 +52,7 @@ export function useRecipeIndex(dataset: DatasetRef | undefined, lang: string) {
50
52
  setLastFull(index);
51
53
  });
52
54
  publishRecipeIndex(dataset, lang, index);
53
- }, [dataset, lang]);
55
+ }, [dataset, lang, nonce]);
54
56
 
55
57
  useAsyncEffect(async (isCancelled) => {
56
58
  if (!dataset) return;
@@ -5,6 +5,7 @@ import type * as PageTree from 'fumadocs-core/page-tree';
5
5
  import { useLocationSearchParams } from '@terrafirmagreg-team/ui/hooks/page/use-location-search';
6
6
  import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
7
7
  import { useLastValue } from '@terrafirmagreg-team/ui/hooks/use-last-value';
8
+ import { skeletonTree } from '@terrafirmagreg-team/ui/lib/tree';
8
9
  import { useRecipeModNames } from '@terrafirmagreg-team/recipe/hooks/use-mod-names';
9
10
  import { useSidebarGroup } from '@terrafirmagreg-team/recipe/hooks/use-sidebar-group';
10
11
  import { groupRecipeSidebarByMod } from '@terrafirmagreg-team/recipe/lib/browser/sidebar';
@@ -20,15 +21,14 @@ export function useRecipeLeftSidebarTree(tree: PageTree.Root): PageTree.Root {
20
21
  () => (datasetId ? { id: datasetId, version } : undefined),
21
22
  [datasetId, version],
22
23
  );
23
- const modNames = useLastValue(
24
- useRecipeModNames(
25
- sidebarGroup === 'mod' ? dataset : undefined,
26
- lang,
27
- ),
28
- scopeKey,
24
+ const result = useRecipeModNames(
25
+ sidebarGroup === 'mod' ? dataset : undefined,
26
+ lang,
29
27
  );
28
+ const modNames = useLastValue(result.value, scopeKey);
29
+ if (sidebarGroup === 'mod' && !modNames && result.pending)
30
+ return skeletonTree('recipe:skeleton');
30
31
  return sidebarGroup === 'mod' && modNames
31
32
  ? groupRecipeSidebarByMod(tree, modNames)
32
33
  : tree;
33
34
  }
34
-
@@ -1,17 +1,18 @@
1
1
  'use client';
2
2
  import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
3
3
 
4
- import { useAsyncValue } from '@terrafirmagreg-team/ui/hooks/use-async-value';
4
+ import { useAsyncResult } from '@terrafirmagreg-team/ui/hooks/use-async-value';
5
+ import { useDumpRetryNonce } from '@terrafirmagreg-team/kit/hooks/use-dump-status';
5
6
  import { loadClientModNames } from '@terrafirmagreg-team/dump/lib/dump/client/mods';
6
7
  import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
7
8
 
8
9
  export function useRecipeModNames(
9
10
  dataset: DatasetRef | undefined,
10
11
  lang: Lang,
11
- ): Record<string, string> | undefined {
12
- return useAsyncValue(
12
+ ): { value: Record<string, string> | undefined; pending: boolean } {
13
+ const nonce = useDumpRetryNonce();
14
+ return useAsyncResult(
13
15
  dataset ? () => loadClientModNames(dataset, lang) : undefined,
14
- [dataset, lang],
16
+ [dataset, lang, nonce],
15
17
  );
16
18
  }
17
-