@terrafirmagreg-team/guide 1.2.7 → 1.2.8
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/guide",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Guide/books section",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@terrafirmagreg-team/data": "^1.2.2",
|
|
26
|
-
"@terrafirmagreg-team/discussions": "^1.2.
|
|
27
|
-
"@terrafirmagreg-team/dump": "^1.2.
|
|
26
|
+
"@terrafirmagreg-team/discussions": "^1.2.6",
|
|
27
|
+
"@terrafirmagreg-team/dump": "^1.2.4",
|
|
28
28
|
"@terrafirmagreg-team/game": "^1.2.4",
|
|
29
|
-
"@terrafirmagreg-team/kit": "^1.2.
|
|
30
|
-
"@terrafirmagreg-team/mdx": "^1.2.
|
|
31
|
-
"@terrafirmagreg-team/preview": "^1.2.
|
|
32
|
-
"@terrafirmagreg-team/search": "^1.2.
|
|
29
|
+
"@terrafirmagreg-team/kit": "^1.2.9",
|
|
30
|
+
"@terrafirmagreg-team/mdx": "^1.2.4",
|
|
31
|
+
"@terrafirmagreg-team/preview": "^1.2.3",
|
|
32
|
+
"@terrafirmagreg-team/search": "^1.2.5",
|
|
33
33
|
"@terrafirmagreg-team/sites": "^1.2.1",
|
|
34
|
-
"@terrafirmagreg-team/translate": "^1.2.
|
|
35
|
-
"@terrafirmagreg-team/ui": "^1.2.
|
|
34
|
+
"@terrafirmagreg-team/translate": "^1.2.6",
|
|
35
|
+
"@terrafirmagreg-team/ui": "^1.2.7",
|
|
36
36
|
"fumadocs-core": "16.17.10",
|
|
37
37
|
"lucide-react": "^1.63.0"
|
|
38
38
|
},
|
|
@@ -6,7 +6,11 @@ import {
|
|
|
6
6
|
useAsyncResult,
|
|
7
7
|
useAsyncValue,
|
|
8
8
|
} from '@terrafirmagreg-team/ui/hooks/use-async-value';
|
|
9
|
+
import { useLastResult } from '@terrafirmagreg-team/ui/hooks/use-last-result';
|
|
9
10
|
import { useVersionedDataset } from '@terrafirmagreg-team/kit/hooks/use-versioned-dataset';
|
|
11
|
+
import { useDumpRetryNonce } from '@terrafirmagreg-team/kit/hooks/use-dump-status';
|
|
12
|
+
import { DumpUnavailable } from '@terrafirmagreg-team/kit/components/views/unavailable';
|
|
13
|
+
import { StaleBadge } from '@terrafirmagreg-team/kit/components/dump-status/stale-badge';
|
|
10
14
|
import { useLangMap } from '@terrafirmagreg-team/game/hooks/use-lang-map';
|
|
11
15
|
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
12
16
|
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
@@ -63,9 +67,13 @@ export function GuideBrowser({
|
|
|
63
67
|
[params],
|
|
64
68
|
);
|
|
65
69
|
const source = getGuideSource();
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
const nonce = useDumpRetryNonce();
|
|
71
|
+
const books = useLastResult(
|
|
72
|
+
useAsyncResult(
|
|
73
|
+
() => source.books(dataset, lang),
|
|
74
|
+
[dataset, lang, nonce],
|
|
75
|
+
),
|
|
76
|
+
dataset.id,
|
|
69
77
|
);
|
|
70
78
|
const langMap = useLangMap(dataset, lang);
|
|
71
79
|
const messages = useMemo<GuideMessages>(
|
|
@@ -107,20 +115,23 @@ export function GuideBrowser({
|
|
|
107
115
|
if (canonical) router.replace(canonical);
|
|
108
116
|
}, [canonical, router]);
|
|
109
117
|
|
|
110
|
-
const payload =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
const payload = useLastResult(
|
|
119
|
+
useAsyncResult(
|
|
120
|
+
langMap && bookId
|
|
121
|
+
? () =>
|
|
122
|
+
source.payload(
|
|
123
|
+
dataset,
|
|
124
|
+
lang,
|
|
125
|
+
bookId,
|
|
126
|
+
entryId,
|
|
127
|
+
categoryId,
|
|
128
|
+
langMap,
|
|
129
|
+
messages,
|
|
130
|
+
)
|
|
131
|
+
: undefined,
|
|
132
|
+
[dataset, lang, bookId, entryId, categoryId, langMap, messages, nonce],
|
|
133
|
+
),
|
|
134
|
+
`${dataset.id}:${bookId ?? ''}`,
|
|
124
135
|
);
|
|
125
136
|
|
|
126
137
|
useEffect(() => {
|
|
@@ -131,11 +142,11 @@ export function GuideBrowser({
|
|
|
131
142
|
|
|
132
143
|
const unavailable = (
|
|
133
144
|
<WorkspaceBody>
|
|
134
|
-
<
|
|
145
|
+
<DumpUnavailable>
|
|
135
146
|
{t('Guide data is temporarily unavailable. Try again later.', {
|
|
136
147
|
note: 'guide.unavailable',
|
|
137
148
|
})}
|
|
138
|
-
</
|
|
149
|
+
</DumpUnavailable>
|
|
139
150
|
</WorkspaceBody>
|
|
140
151
|
);
|
|
141
152
|
|
|
@@ -156,6 +167,11 @@ export function GuideBrowser({
|
|
|
156
167
|
</WorkspaceBody>
|
|
157
168
|
);
|
|
158
169
|
}
|
|
159
|
-
return
|
|
170
|
+
return (
|
|
171
|
+
<div className="relative flex-1">
|
|
172
|
+
{books.stale || payload.stale ? <StaleBadge /> : null}
|
|
173
|
+
<GuidePageView payload={payload.value} langMap={langMap} />
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
160
176
|
}
|
|
161
177
|
|
|
@@ -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 { useGuideTree } from '@terrafirmagreg-team/guide/hooks/use-tree';
|
|
9
10
|
import { guideQueryFromParams } from '@terrafirmagreg-team/guide/lib/nav/query';
|
|
10
11
|
import { parseSectionLocation } from '@terrafirmagreg-team/sites/location';
|
|
@@ -19,10 +20,8 @@ export function useGuideLeftSidebarTree(tree: PageTree.Root): PageTree.Root {
|
|
|
19
20
|
() => (datasetId ? { id: datasetId, version } : undefined),
|
|
20
21
|
[datasetId, version],
|
|
21
22
|
);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
23
|
+
const result = useGuideTree(dataset, lang, bookId);
|
|
24
|
+
const runtime = useLastValue(result.value, dataset?.id ?? '');
|
|
25
|
+
if (!runtime && result.pending) return skeletonTree();
|
|
26
26
|
return runtime ?? tree;
|
|
27
27
|
}
|
|
28
|
-
|
package/src/hooks/use-tree.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
3
3
|
|
|
4
4
|
import type * as PageTree from 'fumadocs-core/page-tree';
|
|
5
|
-
import {
|
|
5
|
+
import { useAsyncResult } from '@terrafirmagreg-team/ui/hooks/use-async-value';
|
|
6
|
+
import { useDumpRetryNonce } from '@terrafirmagreg-team/kit/hooks/use-dump-status';
|
|
6
7
|
import { loadClientGuideBook } from '@terrafirmagreg-team/guide/lib/client/books';
|
|
7
8
|
import { listGuideBooks } from '@terrafirmagreg-team/guide/lib/book/list';
|
|
8
9
|
import { guideTreeChildren } from '@terrafirmagreg-team/guide/components/tree/children';
|
|
@@ -12,8 +13,9 @@ export function useGuideTree(
|
|
|
12
13
|
dataset: DatasetRef | undefined,
|
|
13
14
|
lang: Lang,
|
|
14
15
|
bookId: string | undefined,
|
|
15
|
-
): PageTree.Root | undefined {
|
|
16
|
-
|
|
16
|
+
): { value: PageTree.Root | undefined; pending: boolean; error: unknown } {
|
|
17
|
+
const nonce = useDumpRetryNonce();
|
|
18
|
+
return useAsyncResult(
|
|
17
19
|
dataset
|
|
18
20
|
? async () => {
|
|
19
21
|
const summaries = await listGuideBooks(dataset, lang);
|
|
@@ -29,7 +31,6 @@ export function useGuideTree(
|
|
|
29
31
|
} satisfies PageTree.Root;
|
|
30
32
|
}
|
|
31
33
|
: undefined,
|
|
32
|
-
[dataset, lang, bookId],
|
|
34
|
+
[dataset, lang, bookId, nonce],
|
|
33
35
|
);
|
|
34
36
|
}
|
|
35
|
-
|