@terrafirmagreg-team/recipe 1.2.19 → 1.2.21
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 +8 -8
- package/src/lib/client-index/registry.ts +6 -12
- package/src/lib/og.ts +22 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrafirmagreg-team/recipe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Recipe viewer and calculator",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"./styles.css": "./styles.css"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@terrafirmagreg-team/data": "^1.2.
|
|
27
|
-
"@terrafirmagreg-team/dump": "^1.2.
|
|
28
|
-
"@terrafirmagreg-team/game": "^1.2.
|
|
29
|
-
"@terrafirmagreg-team/kit": "^1.2.
|
|
30
|
-
"@terrafirmagreg-team/mdx": "^1.2.
|
|
31
|
-
"@terrafirmagreg-team/preview": "^1.2.
|
|
26
|
+
"@terrafirmagreg-team/data": "^1.2.10",
|
|
27
|
+
"@terrafirmagreg-team/dump": "^1.2.15",
|
|
28
|
+
"@terrafirmagreg-team/game": "^1.2.9",
|
|
29
|
+
"@terrafirmagreg-team/kit": "^1.2.22",
|
|
30
|
+
"@terrafirmagreg-team/mdx": "^1.2.11",
|
|
31
|
+
"@terrafirmagreg-team/preview": "^1.2.6",
|
|
32
32
|
"@terrafirmagreg-team/sites": "^1.2.3",
|
|
33
33
|
"@terrafirmagreg-team/translate": "^1.2.11",
|
|
34
|
-
"@terrafirmagreg-team/ui": "^1.2.
|
|
34
|
+
"@terrafirmagreg-team/ui": "^1.2.16",
|
|
35
35
|
"@types/pathfinding": "^0.1.0",
|
|
36
36
|
"comlink": "^4.4.2",
|
|
37
37
|
"fflate": "0.8.3",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
2
|
-
import {
|
|
2
|
+
import { clientRegistryNsEntries } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
3
3
|
import { loadClientTagMembers } from '@terrafirmagreg-team/dump/lib/dump/client/tags';
|
|
4
4
|
import {
|
|
5
5
|
asRecord,
|
|
@@ -27,29 +27,23 @@ const registrySliceCache = createDatasetCache(
|
|
|
27
27
|
async (
|
|
28
28
|
dataset: DatasetRef,
|
|
29
29
|
kind: string,
|
|
30
|
+
ns: string,
|
|
30
31
|
): Promise<Record<string, Record<string, unknown>>> => {
|
|
31
32
|
const field = registryField(kind);
|
|
32
|
-
const raw = await
|
|
33
|
+
const raw = await clientRegistryNsEntries(dataset, field, ns, 'high');
|
|
33
34
|
const map = asRecord(raw);
|
|
34
35
|
return map ? resolveEdgeRows(map) : {};
|
|
35
36
|
},
|
|
36
|
-
(dataset, kind) => `${dataset.id}/${dataset.version ?? ''} ${registryField(kind)}`,
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
-
function loadRegistryFile(
|
|
40
|
-
dataset: DatasetRef,
|
|
41
|
-
kind: string,
|
|
42
|
-
): Promise<Record<string, Record<string, unknown>>> {
|
|
43
|
-
return registrySliceCache(dataset, kind);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
39
|
export async function loadRegistryEntrySlice(
|
|
47
40
|
dataset: DatasetRef,
|
|
48
41
|
kind: string,
|
|
49
42
|
id: string,
|
|
50
43
|
): Promise<Record<string, unknown> | undefined> {
|
|
51
44
|
const base = stackIdBase(id);
|
|
52
|
-
const
|
|
45
|
+
const ns = base.includes(':') ? base.split(':', 1)[0] : 'minecraft';
|
|
46
|
+
const map = await registrySliceCache(dataset, kind, ns);
|
|
53
47
|
return map[id] ?? map[base];
|
|
54
48
|
}
|
|
55
49
|
|
|
@@ -60,7 +54,7 @@ const tagSliceCache = createDatasetCache(
|
|
|
60
54
|
ns: string,
|
|
61
55
|
): Promise<Record<string, string[]>> => {
|
|
62
56
|
const prefix = `${ns}:`;
|
|
63
|
-
const map = await
|
|
57
|
+
const map = await registrySliceCache(dataset, kind, ns);
|
|
64
58
|
const out: Record<string, string[]> = {};
|
|
65
59
|
for (const [id, entry] of Object.entries(map)) {
|
|
66
60
|
if (!id.startsWith(prefix)) continue;
|
package/src/lib/og.ts
CHANGED
|
@@ -2,14 +2,13 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
|
2
2
|
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
3
3
|
import { clientDumpLang } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
4
4
|
import { loadClientTagMembers } from '@terrafirmagreg-team/dump/lib/dump/client/tags';
|
|
5
|
-
import type { ReferenceKind } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
6
5
|
import { stripMcFormat } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
7
6
|
import {
|
|
8
7
|
ogLocalized,
|
|
9
|
-
ogRefSprite,
|
|
10
8
|
ogStackName,
|
|
11
9
|
} from '@terrafirmagreg-team/dump/lib/dump/assets/og';
|
|
12
10
|
import {
|
|
11
|
+
ogImageQuery,
|
|
13
12
|
ogName,
|
|
14
13
|
registerOgResolver,
|
|
15
14
|
type OgContext,
|
|
@@ -25,25 +24,23 @@ async function recipeOgContext(
|
|
|
25
24
|
): Promise<OgContext> {
|
|
26
25
|
const tool = search.get('tool');
|
|
27
26
|
if (tool) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
imageQuery: `tool=${encodeURIComponent(tool)}`,
|
|
31
|
-
};
|
|
27
|
+
const entity = { kind: 'tool', name: recipeToolName(tool, lang) };
|
|
28
|
+
return { entity, imageQuery: ogImageQuery(entity, tool) };
|
|
32
29
|
}
|
|
33
30
|
const item = search.get('item');
|
|
34
31
|
const fluid = search.get('fluid');
|
|
35
32
|
if (item || fluid) {
|
|
36
33
|
const kind = fluid ? 'fluid' : 'item';
|
|
37
34
|
const id = (item ?? fluid)!;
|
|
35
|
+
const entity = {
|
|
36
|
+
kind,
|
|
37
|
+
name: await ogStackName(dataset, id, kind, lang),
|
|
38
|
+
id,
|
|
39
|
+
};
|
|
38
40
|
return {
|
|
39
|
-
entity
|
|
40
|
-
kind,
|
|
41
|
-
name: await ogStackName(dataset, id, kind, lang),
|
|
42
|
-
id,
|
|
43
|
-
},
|
|
44
|
-
icon: await ogRefSprite(dataset, { kind, id }),
|
|
41
|
+
entity,
|
|
45
42
|
description: id,
|
|
46
|
-
imageQuery:
|
|
43
|
+
imageQuery: ogImageQuery(entity, id),
|
|
47
44
|
};
|
|
48
45
|
}
|
|
49
46
|
const type = search.get('type');
|
|
@@ -57,21 +54,12 @@ async function recipeOgContext(
|
|
|
57
54
|
const tagId = rest.length ? `${ns}:${tagPath}` : ns;
|
|
58
55
|
const members = await loadClientTagMembers(dataset, tagKind);
|
|
59
56
|
const list = tagId ? members?.[`#${tagId}`] : undefined;
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
id: first,
|
|
67
|
-
})
|
|
68
|
-
: undefined,
|
|
69
|
-
description:
|
|
70
|
-
list != null
|
|
71
|
-
? `${list.length} member${list.length === 1 ? '' : 's'}`
|
|
72
|
-
: `${tagKind} tag`,
|
|
73
|
-
imageQuery: `type=emi:tag&id=${encodeURIComponent(id)}`,
|
|
74
|
-
};
|
|
57
|
+
const entity = { kind: 'tag', name: `#${tagId || id}`, id };
|
|
58
|
+
const description =
|
|
59
|
+
list != null
|
|
60
|
+
? `${list.length} member${list.length === 1 ? '' : 's'}`
|
|
61
|
+
: `${tagKind} tag`;
|
|
62
|
+
return { entity, description, imageQuery: ogImageQuery(entity, description) };
|
|
75
63
|
}
|
|
76
64
|
if (id) {
|
|
77
65
|
const recipe = await loadClientRecipe(dataset, id);
|
|
@@ -95,17 +83,9 @@ async function recipeOgContext(
|
|
|
95
83
|
lang,
|
|
96
84
|
).catch(() => recipe.id)
|
|
97
85
|
: recipe.id;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
? await ogRefSprite(dataset, {
|
|
102
|
-
kind: out.kind === 'tag' ? 'itemTag' : out.kind,
|
|
103
|
-
id: out.id,
|
|
104
|
-
})
|
|
105
|
-
: undefined,
|
|
106
|
-
description: catName ?? recipe.id,
|
|
107
|
-
imageQuery: `id=${encodeURIComponent(id)}`,
|
|
108
|
-
};
|
|
86
|
+
const entity = { kind: 'recipe', name, id: recipe.id };
|
|
87
|
+
const description = catName ?? recipe.id;
|
|
88
|
+
return { entity, description, imageQuery: ogImageQuery(entity, description) };
|
|
109
89
|
}
|
|
110
90
|
if (!type || type === 'all') return {};
|
|
111
91
|
const [categories, map] = await Promise.all([
|
|
@@ -116,11 +96,11 @@ async function recipeOgContext(
|
|
|
116
96
|
if (!category) return {};
|
|
117
97
|
const localized =
|
|
118
98
|
ogLocalized(map, category.display?.name) ?? category.id;
|
|
99
|
+
const entity = { kind: 'category', ...ogName(localized), id: category.id };
|
|
119
100
|
return {
|
|
120
|
-
entity
|
|
121
|
-
icon: await ogRefSprite(dataset, category.icon),
|
|
101
|
+
entity,
|
|
122
102
|
description: category.id,
|
|
123
|
-
imageQuery:
|
|
103
|
+
imageQuery: ogImageQuery(entity, category.id),
|
|
124
104
|
};
|
|
125
105
|
}
|
|
126
106
|
|