@terrafirmagreg-team/game 0.1.0 → 1.2.0
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 +15 -14
- package/src/components/entry/atlas-sprite.tsx +22 -35
- package/src/components/entry/copy-id-menu.tsx +22 -29
- package/src/components/entry/entry.tsx +99 -20
- package/src/components/entry/group.tsx +27 -46
- package/src/components/entry/icon.tsx +21 -27
- package/src/components/entry/list.tsx +15 -18
- package/src/components/entry/mc-text.tsx +3 -89
- package/src/components/entry/stack-count.tsx +12 -8
- package/src/components/entry/tooltip.tsx +52 -44
- package/src/components/mdx/item-icon.tsx +23 -15
- package/src/components/preview-icon.tsx +2 -1
- package/src/hooks/use-dump-location.ts +4 -2
- package/src/hooks/use-entry-context.ts +3 -1
- package/src/hooks/use-icon-source.ts +22 -13
- package/src/hooks/use-lang-map.ts +4 -2
- package/src/lib/entry/display.ts +2 -1
- package/src/lib/entry/entry.ts +5 -3
- package/src/lib/entry/formula.ts +1 -0
- package/src/lib/entry/href.ts +20 -12
- package/src/lib/entry/icon-load.ts +67 -31
- package/src/lib/entry/icon.ts +3 -2
- package/src/lib/entry/tooltip.ts +12 -10
- package/src/lib/preview.ts +4 -2
- package/src/lib/search.ts +18 -19
- package/src/locales/en_us.json +3 -7
- package/src/locales/ru_ru.json +3 -7
- package/src/locales.ts +1 -0
- package/src/types/entry.ts +41 -2
- package/styles/fonts.css +18 -2
- package/src/components/entry/frame.tsx +0 -32
- package/src/components/entry/icon/tabs.tsx +0 -118
- package/src/lib/dump/assets/atlas/dto.ts +0 -49
- package/src/lib/dump/assets/atlas/lookup.ts +0 -206
- package/src/lib/dump/assets/atlas/sprites.ts +0 -130
- package/src/lib/dump/assets/lang/load.ts +0 -17
- package/src/lib/dump/assets/lang/names.ts +0 -244
- package/src/lib/dump/assets/urls.ts +0 -143
- package/src/lib/dump/client/atlases.ts +0 -83
- package/src/lib/dump/client/dump.ts +0 -188
- package/src/lib/dump/client/groups.ts +0 -31
- package/src/lib/dump/client/keybinds.ts +0 -11
- package/src/lib/dump/client/mods.ts +0 -16
- package/src/lib/dump/client/registry.ts +0 -125
- package/src/lib/dump/client/tabs.ts +0 -27
- package/src/lib/dump/client/tags.ts +0 -64
- package/src/lib/dump/contract/kind.ts +0 -61
- package/src/lib/dump/contract/read.ts +0 -77
- package/src/lib/dump/contract/ref.ts +0 -262
- package/src/lib/dump/contract/text.ts +0 -86
- package/src/lib/dump/data/registry/dto.ts +0 -56
- package/src/lib/dump/data/registry/parse.ts +0 -291
- package/src/lib/dump/data/tab/dto.ts +0 -13
- package/src/lib/dump/data/tab/parse.ts +0 -26
- package/src/lib/dump/data/tag/dto.ts +0 -7
- package/src/lib/dump/data/tag/parse.ts +0 -57
- package/src/lib/dump/gen/data/guides/book.ts +0 -56
- package/src/lib/dump/gen/data/guides/category.ts +0 -30
- package/src/lib/dump/gen/data/guides/entry.ts +0 -48
- package/src/lib/dump/gen/data/models/model.ts +0 -3
- package/src/lib/dump/gen/data/quests/chapter.ts +0 -126
- package/src/lib/dump/gen/data/quests/chapter_groups.ts +0 -11
- package/src/lib/dump/gen/data/quests/data.ts +0 -40
- package/src/lib/dump/gen/data/recipes/recipe.ts +0 -78
- package/src/lib/dump/gen/index.ts +0 -20
- package/src/lib/dump/gen/keybinds.ts +0 -3
- package/src/lib/dump/gen/lang.ts +0 -3
- package/src/lib/dump/gen/manifest.ts +0 -59
- package/src/lib/dump/gen/registry/blocks.ts +0 -60
- package/src/lib/dump/gen/registry/entities.ts +0 -49
- package/src/lib/dump/gen/registry/fluids.ts +0 -48
- package/src/lib/dump/gen/registry/groups.ts +0 -14
- package/src/lib/dump/gen/registry/items.ts +0 -51
- package/src/lib/dump/gen/registry/recipe_categories.ts +0 -64
- package/src/lib/dump/gen/registry/recipes.ts +0 -3
- package/src/lib/dump/gen/registry/tabs.ts +0 -46
- package/src/lib/dump/gen/registry/tags.ts +0 -11
- package/src/lib/dump/json-reader.ts +0 -231
- package/src/lib/dump/manifest/dto.ts +0 -11
- package/src/lib/dump/manifest/parse.ts +0 -167
- package/src/lib/dump/mods/dto.ts +0 -40
- package/src/lib/dump/mods/index.ts +0 -81
- package/src/lib/dump/mods/load.ts +0 -61
- package/src/lib/dump/paths.ts +0 -171
- package/src/lib/dump/reader.ts +0 -15
- package/src/lib/snbt.ts +0 -246
package/src/lib/entry/href.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type DatasetRef,
|
|
3
|
+
sectionUrl,
|
|
4
|
+
} from '@terrafirmagreg-team/sites/location';
|
|
2
5
|
import { encodeQuery, withLang } from '@terrafirmagreg-team/translate/lib/url';
|
|
3
|
-
import { tagPseudoId } from '@terrafirmagreg-team/
|
|
4
|
-
import { refId, tagKindOf } from '@terrafirmagreg-team/
|
|
5
|
-
import type { TaggedReference } from '@terrafirmagreg-team/
|
|
6
|
+
import { tagPseudoId } from '@terrafirmagreg-team/dump/lib/dump/paths';
|
|
7
|
+
import { refId, tagKindOf } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
8
|
+
import type { TaggedReference } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
6
9
|
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
7
10
|
import type { EntryHrefOpts } from '@terrafirmagreg-team/game/types/entry';
|
|
8
11
|
|
|
@@ -11,7 +14,7 @@ export type { EntryHrefOpts } from '@terrafirmagreg-team/game/types/entry';
|
|
|
11
14
|
const query = encodeQuery;
|
|
12
15
|
|
|
13
16
|
function recipeHref(
|
|
14
|
-
dataset:
|
|
17
|
+
dataset: DatasetRef,
|
|
15
18
|
lang: Lang | undefined,
|
|
16
19
|
opts?: {
|
|
17
20
|
type?: string;
|
|
@@ -31,14 +34,15 @@ function recipeHref(
|
|
|
31
34
|
['tab', opts?.tab],
|
|
32
35
|
['search', opts?.search],
|
|
33
36
|
['rpage', opts?.rpage && opts.rpage > 1 ? Math.floor(opts.rpage) : undefined],
|
|
37
|
+
['version', dataset.version],
|
|
34
38
|
]);
|
|
35
|
-
const base = sectionUrl('recipe', dataset);
|
|
39
|
+
const base = sectionUrl('recipe', dataset.id);
|
|
36
40
|
const href = q ? `${base}?${q}` : base;
|
|
37
41
|
return lang ? withLang(href, lang) : href;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
function recipeStackHref(
|
|
41
|
-
dataset:
|
|
45
|
+
dataset: DatasetRef,
|
|
42
46
|
lang: Lang | undefined,
|
|
43
47
|
id: string,
|
|
44
48
|
opts?: Pick<EntryHrefOpts, 'tab' | 'search'> & {
|
|
@@ -61,7 +65,7 @@ function recipeStackHref(
|
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
function questHref(
|
|
64
|
-
dataset:
|
|
68
|
+
dataset: DatasetRef,
|
|
65
69
|
lang: Lang | undefined,
|
|
66
70
|
opts?: { category?: string; id?: string; item?: string },
|
|
67
71
|
): string {
|
|
@@ -69,32 +73,35 @@ function questHref(
|
|
|
69
73
|
['category', opts?.category],
|
|
70
74
|
['id', opts?.id],
|
|
71
75
|
['item', opts?.item],
|
|
76
|
+
['version', dataset.version],
|
|
72
77
|
]);
|
|
73
|
-
const base = sectionUrl('quest', dataset);
|
|
78
|
+
const base = sectionUrl('quest', dataset.id);
|
|
74
79
|
const href = q ? `${base}?${q}` : base;
|
|
75
80
|
return lang ? withLang(href, lang) : href;
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
export function guideHref(
|
|
79
|
-
dataset:
|
|
84
|
+
dataset: DatasetRef,
|
|
80
85
|
lang: Lang | undefined,
|
|
81
86
|
bookId?: string,
|
|
82
87
|
entryId?: string,
|
|
83
88
|
hash?: string,
|
|
84
89
|
categoryId?: string,
|
|
85
90
|
): string {
|
|
91
|
+
const { id, version } = dataset;
|
|
86
92
|
const q = query([
|
|
87
93
|
['book', bookId],
|
|
88
94
|
['entry', entryId],
|
|
89
95
|
['cat', entryId ? undefined : categoryId],
|
|
96
|
+
['version', version],
|
|
90
97
|
]);
|
|
91
|
-
const base = `${sectionUrl('guide',
|
|
98
|
+
const base = `${sectionUrl('guide', id)}${q ? `?${q}` : ''}`;
|
|
92
99
|
const href = hash ? `${base}#${hash}` : base;
|
|
93
100
|
return lang ? withLang(href, lang) : href;
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
export function entryHref(
|
|
97
|
-
dataset:
|
|
104
|
+
dataset: DatasetRef,
|
|
98
105
|
lang: Lang | undefined,
|
|
99
106
|
reference: TaggedReference,
|
|
100
107
|
opts?: EntryHrefOpts,
|
|
@@ -146,3 +153,4 @@ export function entryHref(
|
|
|
146
153
|
}
|
|
147
154
|
}
|
|
148
155
|
}
|
|
156
|
+
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
2
|
+
import type { AtlasBundle } from '@terrafirmagreg-team/dump/lib/dump/assets/atlas/dto';
|
|
2
3
|
import {
|
|
3
4
|
clientDumpJson,
|
|
4
5
|
clientRegistryDataFileRel,
|
|
5
6
|
clientTagFileRel,
|
|
6
|
-
} from '@terrafirmagreg-team/
|
|
7
|
-
import { loadClientModAtlases } from '@terrafirmagreg-team/
|
|
8
|
-
import { dumpRelPublicUrl, matchTagIndexKey } from '@terrafirmagreg-team/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import type {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
} from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
8
|
+
import { loadClientModAtlases } from '@terrafirmagreg-team/dump/lib/dump/client/atlases';
|
|
9
|
+
import { dumpRelPublicUrl, matchTagIndexKey } from '@terrafirmagreg-team/dump/lib/dump/paths';
|
|
10
|
+
import { modelPublicUrl } from '@terrafirmagreg-team/dump/lib/dump/assets/urls';
|
|
11
|
+
import { lookupSpriteInBundle } from '@terrafirmagreg-team/dump/lib/dump/assets/atlas/lookup';
|
|
12
|
+
import { asIdTable, asRecord, asString } from '@terrafirmagreg-team/dump/lib/dump/contract/read';
|
|
13
|
+
import { asTaggedReference } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
14
|
+
import { asEntry, matchVariant } from '@terrafirmagreg-team/dump/lib/dump/data/registry/parse';
|
|
15
|
+
import type { DumpEntityEntry } from '@terrafirmagreg-team/dump/lib/dump/data/registry/dto';
|
|
16
|
+
import { asTag, firstTagItem } from '@terrafirmagreg-team/dump/lib/dump/data/tag/parse';
|
|
17
|
+
import type { DumpNbt } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
18
|
+
import type { DumpTag } from '@terrafirmagreg-team/dump/lib/dump/data/tag/dto';
|
|
19
|
+
import { createDatasetCache } from '@terrafirmagreg-team/dump/lib/dump/reader';
|
|
20
|
+
|
|
21
|
+
export type { AtlasBundle } from '@terrafirmagreg-team/dump/lib/dump/assets/atlas/dto';
|
|
20
22
|
|
|
21
23
|
type TagMemberKind = 'item' | 'block' | 'fluid' | 'entity';
|
|
22
24
|
|
|
@@ -28,7 +30,7 @@ const TAG_MEMBER_REGISTRY: Record<TagMemberKind, string> = {
|
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
export function fetchAtlases(
|
|
31
|
-
dataset:
|
|
33
|
+
dataset: DatasetRef,
|
|
32
34
|
modId: string,
|
|
33
35
|
): Promise<AtlasBundle | null> {
|
|
34
36
|
return loadClientModAtlases(dataset, modId).then((bundle) =>
|
|
@@ -36,8 +38,8 @@ export function fetchAtlases(
|
|
|
36
38
|
);
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
const fetchTagRecord =
|
|
40
|
-
async (dataset:
|
|
41
|
+
const fetchTagRecord = createDatasetCache(
|
|
42
|
+
async (dataset: DatasetRef, tagId: string, memberKind: TagMemberKind) => {
|
|
41
43
|
const rel = await clientTagFileRel(dataset, tagId);
|
|
42
44
|
const entries = asRecord(await clientDumpJson(dataset, rel, 'high'));
|
|
43
45
|
if (!entries) return undefined;
|
|
@@ -53,7 +55,7 @@ const fetchTagRecord = createAsyncCache(
|
|
|
53
55
|
);
|
|
54
56
|
|
|
55
57
|
export function fetchTagItem(
|
|
56
|
-
dataset:
|
|
58
|
+
dataset: DatasetRef,
|
|
57
59
|
tagId: string,
|
|
58
60
|
memberKind: TagMemberKind,
|
|
59
61
|
): Promise<string | null> {
|
|
@@ -71,9 +73,9 @@ const TAG_ICON_SPRITE_KIND: Record<TagMemberKind, 'item' | 'fluid'> = {
|
|
|
71
73
|
entity: 'item',
|
|
72
74
|
};
|
|
73
75
|
|
|
74
|
-
const fetchTagMembersList =
|
|
76
|
+
const fetchTagMembersList = createDatasetCache(
|
|
75
77
|
async (
|
|
76
|
-
dataset:
|
|
78
|
+
dataset: DatasetRef,
|
|
77
79
|
tagId: string,
|
|
78
80
|
memberKind: TagMemberKind,
|
|
79
81
|
): Promise<string[]> => {
|
|
@@ -103,15 +105,15 @@ const fetchTagMembersList = createAsyncCache(
|
|
|
103
105
|
);
|
|
104
106
|
|
|
105
107
|
export function fetchTagMembers(
|
|
106
|
-
dataset:
|
|
108
|
+
dataset: DatasetRef,
|
|
107
109
|
tagId: string,
|
|
108
110
|
memberKind: TagMemberKind,
|
|
109
111
|
): Promise<string[]> {
|
|
110
112
|
return fetchTagMembersList(dataset, tagId, memberKind);
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
const fetchBlockItem =
|
|
114
|
-
async (dataset:
|
|
115
|
+
const fetchBlockItem = createDatasetCache(
|
|
116
|
+
async (dataset: DatasetRef, blockId: string): Promise<string> => {
|
|
115
117
|
const ns = blockId.split(':', 1)[0];
|
|
116
118
|
const rel = ns
|
|
117
119
|
? await clientRegistryDataFileRel(dataset, ns, 'blocks')
|
|
@@ -126,13 +128,13 @@ const fetchBlockItem = createAsyncCache(
|
|
|
126
128
|
);
|
|
127
129
|
|
|
128
130
|
export function blockItemId(
|
|
129
|
-
dataset:
|
|
131
|
+
dataset: DatasetRef,
|
|
130
132
|
blockId: string,
|
|
131
133
|
): Promise<string> {
|
|
132
134
|
return fetchBlockItem(dataset, blockId);
|
|
133
135
|
}
|
|
134
136
|
|
|
135
|
-
const fetchEntity =
|
|
137
|
+
const fetchEntity = createDatasetCache(async (dataset: DatasetRef, id: string) => {
|
|
136
138
|
const ns = id.split(':', 1)[0];
|
|
137
139
|
const rel = ns
|
|
138
140
|
? await clientRegistryDataFileRel(dataset, ns, 'entities')
|
|
@@ -147,7 +149,7 @@ const fetchEntity = createAsyncCache(async (dataset: string, id: string) => {
|
|
|
147
149
|
});
|
|
148
150
|
|
|
149
151
|
export async function fetchEntityTexture(
|
|
150
|
-
dataset:
|
|
152
|
+
dataset: DatasetRef,
|
|
151
153
|
id: string,
|
|
152
154
|
nbt?: DumpNbt,
|
|
153
155
|
): Promise<string | null> {
|
|
@@ -156,7 +158,7 @@ export async function fetchEntityTexture(
|
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
export function peekEntityTexture(
|
|
159
|
-
dataset:
|
|
161
|
+
dataset: DatasetRef,
|
|
160
162
|
id: string,
|
|
161
163
|
nbt?: DumpNbt,
|
|
162
164
|
): string | null | undefined {
|
|
@@ -166,8 +168,41 @@ export function peekEntityTexture(
|
|
|
166
168
|
: entityTextureUrl(dataset, entity, id, nbt);
|
|
167
169
|
}
|
|
168
170
|
|
|
171
|
+
export async function fetchEntityModel(
|
|
172
|
+
dataset: DatasetRef,
|
|
173
|
+
id: string,
|
|
174
|
+
nbt?: DumpNbt,
|
|
175
|
+
): Promise<string | null> {
|
|
176
|
+
const entity = await fetchEntity(dataset, id);
|
|
177
|
+
return entityModelUrl(dataset, entity, id, nbt);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function peekEntityModel(
|
|
181
|
+
dataset: DatasetRef,
|
|
182
|
+
id: string,
|
|
183
|
+
nbt?: DumpNbt,
|
|
184
|
+
): string | null | undefined {
|
|
185
|
+
const entity = fetchEntity.peek(dataset, id);
|
|
186
|
+
return entity === undefined
|
|
187
|
+
? undefined
|
|
188
|
+
: entityModelUrl(dataset, entity, id, nbt);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function entityModelUrl(
|
|
192
|
+
dataset: DatasetRef,
|
|
193
|
+
entity: DumpEntityEntry | undefined,
|
|
194
|
+
id: string,
|
|
195
|
+
nbt?: DumpNbt,
|
|
196
|
+
): string | null {
|
|
197
|
+
if (!entity) return null;
|
|
198
|
+
const model = matchVariant(entity.variants, nbt)?.model ?? entity.model;
|
|
199
|
+
if (!model) return null;
|
|
200
|
+
const ns = id.split(':', 1)[0];
|
|
201
|
+
return modelPublicUrl(dataset, ns, model) ?? null;
|
|
202
|
+
}
|
|
203
|
+
|
|
169
204
|
export function peekTagMembers(
|
|
170
|
-
dataset:
|
|
205
|
+
dataset: DatasetRef,
|
|
171
206
|
tagId: string,
|
|
172
207
|
memberKind: TagMemberKind,
|
|
173
208
|
): string[] | undefined {
|
|
@@ -175,14 +210,14 @@ export function peekTagMembers(
|
|
|
175
210
|
}
|
|
176
211
|
|
|
177
212
|
export function peekBlockItem(
|
|
178
|
-
dataset:
|
|
213
|
+
dataset: DatasetRef,
|
|
179
214
|
blockId: string,
|
|
180
215
|
): string | undefined {
|
|
181
216
|
return fetchBlockItem.peek(dataset, blockId);
|
|
182
217
|
}
|
|
183
218
|
|
|
184
219
|
function entityTextureUrl(
|
|
185
|
-
dataset:
|
|
220
|
+
dataset: DatasetRef,
|
|
186
221
|
entity: DumpEntityEntry | undefined,
|
|
187
222
|
id: string,
|
|
188
223
|
nbt?: DumpNbt,
|
|
@@ -193,3 +228,4 @@ function entityTextureUrl(
|
|
|
193
228
|
const ns = id.split(':', 1)[0];
|
|
194
229
|
return dumpRelPublicUrl(dataset, `assets/${ns}/${texture}`) ?? null;
|
|
195
230
|
}
|
|
231
|
+
|
package/src/lib/entry/icon.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { tagKindOf } from '@terrafirmagreg-team/
|
|
2
|
-
import type { ReferenceKind } from '@terrafirmagreg-team/
|
|
1
|
+
import { tagKindOf } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
2
|
+
import type { ReferenceKind } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
3
3
|
|
|
4
4
|
export function stackKindOf(
|
|
5
5
|
kind: ReferenceKind | undefined,
|
|
@@ -8,3 +8,4 @@ export function stackKindOf(
|
|
|
8
8
|
const member = tagKindOf(kind);
|
|
9
9
|
return member === 'entity' ? undefined : member;
|
|
10
10
|
}
|
|
11
|
+
|
package/src/lib/entry/tooltip.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
2
|
+
import { displayOf } from '@terrafirmagreg-team/dump/lib/dump/data/registry/parse';
|
|
3
|
+
import { parseStackId } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
4
|
+
import { clientDumpLang } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
4
5
|
import {
|
|
5
6
|
clientRegistryKindFor,
|
|
6
7
|
loadClientRegistry,
|
|
7
|
-
} from '@terrafirmagreg-team/
|
|
8
|
-
import type { DumpDisplay } from '@terrafirmagreg-team/
|
|
9
|
-
import { dumpTextLines } from '@terrafirmagreg-team/
|
|
10
|
-
import {
|
|
8
|
+
} from '@terrafirmagreg-team/dump/lib/dump/client/registry';
|
|
9
|
+
import type { DumpDisplay } from '@terrafirmagreg-team/dump/lib/dump/contract/text';
|
|
10
|
+
import { dumpTextLines } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
11
|
+
import { createDatasetCache } from '@terrafirmagreg-team/dump/lib/dump/reader';
|
|
11
12
|
|
|
12
|
-
export const loadStackDisplay =
|
|
13
|
+
export const loadStackDisplay = createDatasetCache(
|
|
13
14
|
async (
|
|
14
|
-
dataset:
|
|
15
|
+
dataset: DatasetRef,
|
|
15
16
|
compactId: string,
|
|
16
17
|
kind?: 'item' | 'fluid' | 'entity',
|
|
17
18
|
): Promise<DumpDisplay | undefined> => {
|
|
@@ -38,7 +39,7 @@ type StackTooltip = {
|
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
export async function stackTooltip(
|
|
41
|
-
dataset:
|
|
42
|
+
dataset: DatasetRef,
|
|
42
43
|
id: string,
|
|
43
44
|
lang: string | undefined,
|
|
44
45
|
langMap: Record<string, string> | undefined,
|
|
@@ -58,3 +59,4 @@ export async function stackTooltip(
|
|
|
58
59
|
mods,
|
|
59
60
|
};
|
|
60
61
|
}
|
|
62
|
+
|
package/src/lib/preview.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
1
2
|
import {
|
|
2
3
|
stackIdFromRef,
|
|
3
4
|
type TaggedReference,
|
|
4
|
-
} from '@terrafirmagreg-team/
|
|
5
|
+
} from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
5
6
|
import type { PreviewIcon } from '@terrafirmagreg-team/ui/types/preview';
|
|
6
7
|
|
|
7
8
|
export function entryPreviewIcon(
|
|
8
9
|
ref: TaggedReference | undefined,
|
|
9
|
-
dataset:
|
|
10
|
+
dataset: DatasetRef,
|
|
10
11
|
): PreviewIcon | undefined {
|
|
11
12
|
if (!ref) return undefined;
|
|
12
13
|
return {
|
|
@@ -16,3 +17,4 @@ export function entryPreviewIcon(
|
|
|
16
17
|
dataset,
|
|
17
18
|
};
|
|
18
19
|
}
|
|
20
|
+
|
package/src/lib/search.ts
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import { staticClient } from 'fumadocs-core/search/client/orama-static';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { dumpStorageUrl } from './dump/paths';
|
|
2
|
+
import type { SearchClientSourceCtx } from '@terrafirmagreg-team/search/lib/sources';
|
|
3
|
+
import { loadClientVersions } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
4
|
+
import { dumpStorageUrl } from '@terrafirmagreg-team/dump/lib/dump/paths';
|
|
6
5
|
|
|
7
6
|
export function dumpSearchClientSource({ refs, locale, tag }: SearchClientSourceCtx) {
|
|
8
7
|
return {
|
|
9
|
-
deps: [refs.
|
|
8
|
+
deps: [JSON.stringify(refs.map(({ id, version }) => [id, version])), locale, String(tag)],
|
|
10
9
|
async search(query: string) {
|
|
11
|
-
const
|
|
12
|
-
refs.map(async (
|
|
13
|
-
const { id, version } = parseDatasetRef(ref);
|
|
10
|
+
const lists = await Promise.all(
|
|
11
|
+
refs.map(async ({ id, version }) => {
|
|
14
12
|
const ver = version ?? (await loadClientVersions(id))?.latest;
|
|
15
|
-
if (!ver) return
|
|
16
|
-
|
|
17
|
-
locale,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
if (!ver) return [];
|
|
14
|
+
const run = async (from: string) =>
|
|
15
|
+
staticClient({ locale, tag, from }).search(query);
|
|
16
|
+
return run(dumpStorageUrl(`${id}/${ver}/search/${locale}.json`))
|
|
17
|
+
.catch(() =>
|
|
18
|
+
run(
|
|
19
|
+
`/api/search/dump?id=${encodeURIComponent(id)}&ver=${encodeURIComponent(ver)}&lang=${encodeURIComponent(locale)}`,
|
|
20
|
+
),
|
|
21
|
+
)
|
|
22
|
+
.catch(() => run(dumpStorageUrl(`${id}/${ver}/search.json`)))
|
|
23
|
+
.catch(() => []);
|
|
21
24
|
}),
|
|
22
25
|
);
|
|
23
|
-
const lists = await Promise.all(
|
|
24
|
-
clients.flatMap((client) =>
|
|
25
|
-
client ? [Promise.resolve(client.search(query)).catch(() => [])] : [],
|
|
26
|
-
),
|
|
27
|
-
);
|
|
28
26
|
return lists.flat();
|
|
29
27
|
},
|
|
30
28
|
};
|
|
31
29
|
}
|
|
30
|
+
|
package/src/locales/en_us.json
CHANGED
package/src/locales/ru_ru.json
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ui":
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"copy_stack": "Копировать id стака",
|
|
6
|
-
"copy_nbt": "Копировать NBT"
|
|
7
|
-
}
|
|
8
|
-
}
|
|
2
|
+
"Copy NBT(ui.entry.copy_nbt)": "Копировать NBT",
|
|
3
|
+
"Copy id(ui.entry.copy)": "Копировать id",
|
|
4
|
+
"Copy stack id(ui.entry.copy_stack)": "Копировать id стака"
|
|
9
5
|
}
|
package/src/locales.ts
CHANGED
package/src/types/entry.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
1
2
|
import type { ReactNode } from 'react';
|
|
2
3
|
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
3
|
-
import type { DumpNbt, ReferenceKind, TaggedReference } from '@terrafirmagreg-team/
|
|
4
|
+
import type { DumpNbt, ReferenceKind, TaggedReference } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
4
5
|
|
|
5
6
|
export type EntrySize = 'sm' | 'md' | 'lg' | 'xl' | number;
|
|
6
7
|
|
|
@@ -21,7 +22,7 @@ export type EntryProps = {
|
|
|
21
22
|
reference?: TaggedReference;
|
|
22
23
|
kind?: ReferenceKind;
|
|
23
24
|
id?: string;
|
|
24
|
-
dataset?:
|
|
25
|
+
dataset?: DatasetRef;
|
|
25
26
|
|
|
26
27
|
name?: string;
|
|
27
28
|
|
|
@@ -47,6 +48,44 @@ export type EntryProps = {
|
|
|
47
48
|
|
|
48
49
|
tooltip?: boolean | 'compact' | 'extended' | 'full' | 'adaptive';
|
|
49
50
|
children?: ReactNode;
|
|
51
|
+
|
|
52
|
+
icon?: TaggedReference;
|
|
53
|
+
|
|
54
|
+
entityView?: 'auto' | 'texture' | 'egg';
|
|
50
55
|
} & Omit<EntryHrefOpts, 'tab'>;
|
|
51
56
|
|
|
52
57
|
export type KindEntryProps = Omit<EntryProps, 'kind'>;
|
|
58
|
+
|
|
59
|
+
export type EntryDirectiveProps = Pick<
|
|
60
|
+
KindEntryProps,
|
|
61
|
+
| 'id'
|
|
62
|
+
| 'dataset'
|
|
63
|
+
| 'name'
|
|
64
|
+
| 'size'
|
|
65
|
+
| 'variant'
|
|
66
|
+
| 'labeled'
|
|
67
|
+
| 'label'
|
|
68
|
+
| 'copy'
|
|
69
|
+
| 'className'
|
|
70
|
+
| 'missing'
|
|
71
|
+
| 'tooltip'
|
|
72
|
+
>;
|
|
73
|
+
|
|
74
|
+
export type BlockDirectiveProps = EntryDirectiveProps &
|
|
75
|
+
Pick<KindEntryProps, 'href' | 'tab' | 'search'>;
|
|
76
|
+
|
|
77
|
+
export type ItemDirectiveProps = BlockDirectiveProps;
|
|
78
|
+
export type FluidDirectiveProps = BlockDirectiveProps;
|
|
79
|
+
export type TagDirectiveProps = BlockDirectiveProps;
|
|
80
|
+
export type RecipeDirectiveProps = BlockDirectiveProps;
|
|
81
|
+
|
|
82
|
+
export type EntityDirectiveProps = EntryDirectiveProps & {
|
|
83
|
+
view?: 'auto' | 'texture' | 'egg' | 'model';
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type QuestDirectiveProps = EntryDirectiveProps &
|
|
87
|
+
Pick<KindEntryProps, 'href' | 'filename'>;
|
|
88
|
+
|
|
89
|
+
export type GuideDirectiveProps = EntryDirectiveProps &
|
|
90
|
+
Pick<KindEntryProps, 'href' | 'modId' | 'bookPath' | 'entry' | 'hash'>;
|
|
91
|
+
|
package/styles/fonts.css
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: 'Minecraft';
|
|
3
|
-
src:
|
|
3
|
+
src:
|
|
4
|
+
url('https://cdn.jsdelivr.net/gh/IdreesInc/Minecraft-Font@master/Minecraft.otf')
|
|
5
|
+
format('opentype'),
|
|
6
|
+
url('https://cdn.jsdelivr.net/npm/@south-paw/typeface-minecraft@1.0.0/files/minecraft.woff2')
|
|
7
|
+
format('woff2'),
|
|
8
|
+
url('https://pub-491e074ddb0942ee9dfa8204a68f07a3.r2.dev/fonts/minecraft.otf')
|
|
9
|
+
format('opentype');
|
|
4
10
|
font-display: swap;
|
|
5
11
|
}
|
|
6
12
|
|
|
7
13
|
@font-face {
|
|
8
14
|
font-family: 'Unifont';
|
|
9
|
-
src: url('/
|
|
15
|
+
src: url('https://edent.gitlab.io/unifont/unifont-12.0.01.woff2')
|
|
16
|
+
format('woff2');
|
|
10
17
|
font-display: swap;
|
|
18
|
+
unicode-range: U+0000-FFFF;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@font-face {
|
|
22
|
+
font-family: 'Unifont';
|
|
23
|
+
src: url('https://edent.gitlab.io/unifont/unifont_upper-12.0.01.woff2')
|
|
24
|
+
format('woff2');
|
|
25
|
+
font-display: swap;
|
|
26
|
+
unicode-range: U+10000-10FFFF;
|
|
11
27
|
}
|
|
12
28
|
|
|
13
29
|
.font-mc {
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
3
|
-
|
|
4
|
-
export const ENTRY_CHIP_CLASS =
|
|
5
|
-
'inline-flex shrink-0 items-center justify-center rounded-sm border border-border bg-secondary p-0.5 hover:bg-accent';
|
|
6
|
-
|
|
7
|
-
export function EntryFrame({
|
|
8
|
-
size,
|
|
9
|
-
chip = false,
|
|
10
|
-
className,
|
|
11
|
-
style,
|
|
12
|
-
children,
|
|
13
|
-
}: {
|
|
14
|
-
size?: number;
|
|
15
|
-
chip?: boolean;
|
|
16
|
-
className?: string;
|
|
17
|
-
style?: React.CSSProperties;
|
|
18
|
-
children?: ReactNode;
|
|
19
|
-
}) {
|
|
20
|
-
return (
|
|
21
|
-
<span
|
|
22
|
-
className={cn(
|
|
23
|
-
'inline-flex shrink-0 items-center justify-center',
|
|
24
|
-
chip && ENTRY_CHIP_CLASS,
|
|
25
|
-
className,
|
|
26
|
-
)}
|
|
27
|
-
style={{ ...(size ? { width: size, height: size } : undefined), ...style }}
|
|
28
|
-
>
|
|
29
|
-
{children}
|
|
30
|
-
</span>
|
|
31
|
-
);
|
|
32
|
-
}
|