@terrafirmagreg-team/game 1.2.1 → 1.2.3

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/game",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "type": "module",
5
5
  "description": "Game-data components and catalogs",
6
6
  "license": "LGPL-3.0-only",
@@ -22,17 +22,16 @@
22
22
  "./src/types/*.ts",
23
23
  "./src/types/*/index.ts"
24
24
  ],
25
- "./styles.css": "./styles.css",
26
- "./locales": "./src/locales.ts"
25
+ "./styles.css": "./styles.css"
27
26
  },
28
27
  "dependencies": {
29
28
  "@terrafirmagreg-team/data": "1.2.1",
30
29
  "@terrafirmagreg-team/dump": "1.2.1",
31
- "@terrafirmagreg-team/kit": "1.2.1",
32
- "@terrafirmagreg-team/search": "1.2.1",
30
+ "@terrafirmagreg-team/kit": "1.2.3",
31
+ "@terrafirmagreg-team/search": "1.2.2",
33
32
  "@terrafirmagreg-team/sites": "1.2.1",
34
- "@terrafirmagreg-team/translate": "1.2.1",
35
- "@terrafirmagreg-team/ui": "1.2.1",
33
+ "@terrafirmagreg-team/translate": "1.2.3",
34
+ "@terrafirmagreg-team/ui": "1.2.2",
36
35
  "fumadocs-core": "16.17.8",
37
36
  "lucide-react": "^0.577.0",
38
37
  "server-only": "^0.0.1"
@@ -2,6 +2,7 @@
2
2
  import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
3
3
 
4
4
  import { useState, type ReactElement, type ReactNode } from 'react';
5
+ import type { ReferenceKind } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
5
6
  import { useModifierKeys } from '@terrafirmagreg-team/ui/hooks/use-modifier-keys';
6
7
  import { LazyTooltip } from '@terrafirmagreg-team/ui/components/blocks/tooltip/lazy';
7
8
  import { stackTooltip } from '@terrafirmagreg-team/game/lib/entry/tooltip';
@@ -50,7 +51,7 @@ export function EntryTooltip({
50
51
  dataset: DatasetRef;
51
52
  id: string;
52
53
  name: string;
53
- kind?: 'item' | 'fluid' | 'entity';
54
+ kind?: ReferenceKind;
54
55
 
55
56
  lang?: string;
56
57
  langMap?: Record<string, string>;
@@ -1,6 +1,9 @@
1
1
  import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
2
2
  import { entryHref } from '@terrafirmagreg-team/game/lib/entry/href';
3
- import { tagKindOf } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
3
+ import {
4
+ isTagKind,
5
+ tagKindOf,
6
+ } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
4
7
  import type { ReferenceKind } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
5
8
  import type { EntryProps } from '@terrafirmagreg-team/game/types/entry';
6
9
 
@@ -20,7 +23,8 @@ export function usesStackTooltip(kind: ReferenceKind | undefined): boolean {
20
23
 
21
24
  export function tooltipLoadKind(
22
25
  kind: ReferenceKind | undefined,
23
- ): 'item' | 'fluid' | 'entity' | undefined {
26
+ ): ReferenceKind | undefined {
27
+ if (isTagKind(kind)) return kind;
24
28
  const member = tagKindOf(kind) ?? kind;
25
29
  if (member === 'fluid') return 'fluid';
26
30
  if (member === 'entity') return 'entity';
@@ -1,14 +1,22 @@
1
1
  import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
2
2
  import { displayOf } from '@terrafirmagreg-team/dump/lib/dump/data/registry/parse';
3
- import { parseStackId } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
3
+ import {
4
+ parseStackId,
5
+ tagKindOf,
6
+ type ReferenceKind,
7
+ } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
4
8
  import { clientDumpLang } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
5
9
  import {
6
10
  clientRegistryKindFor,
7
11
  loadClientRegistry,
8
12
  } from '@terrafirmagreg-team/dump/lib/dump/client/registry';
9
13
  import type { DumpDisplay } from '@terrafirmagreg-team/dump/lib/dump/contract/text';
10
- import { dumpTextLines } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
14
+ import {
15
+ dumpTextLines,
16
+ stackDisplayName,
17
+ } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
11
18
  import { createDatasetCache } from '@terrafirmagreg-team/dump/lib/dump/reader';
19
+ import { fetchTagMembers } from '@terrafirmagreg-team/game/lib/entry/icon-load';
12
20
 
13
21
  export const loadStackDisplay = createDatasetCache(
14
22
  async (
@@ -43,11 +51,28 @@ export async function stackTooltip(
43
51
  id: string,
44
52
  lang: string | undefined,
45
53
  langMap: Record<string, string> | undefined,
46
- kind: 'item' | 'fluid' | 'entity' | undefined,
54
+ kind: ReferenceKind | undefined,
47
55
  ): Promise<StackTooltip> {
48
- const display = await loadStackDisplay(dataset, id, kind);
49
56
  const map =
50
57
  langMap ?? (lang ? await clientDumpLang(dataset, lang) : undefined);
58
+ if (id.startsWith('#')) {
59
+ if (!map) return { lines: [], mods: {} };
60
+ const members = await fetchTagMembers(
61
+ dataset,
62
+ id.slice(1),
63
+ tagKindOf(kind) ?? 'item',
64
+ );
65
+ return {
66
+ lines: members.map((member) => stackDisplayName(map, member)),
67
+ mods: {},
68
+ };
69
+ }
70
+ const memberKind = tagKindOf(kind) ?? kind;
71
+ const loadKind =
72
+ memberKind === 'fluid' || memberKind === 'entity'
73
+ ? memberKind
74
+ : 'item';
75
+ const display = await loadStackDisplay(dataset, id, loadKind);
51
76
  if (!display || !map) return { lines: [], mods: {} };
52
77
  const mods: Record<string, string[]> = {};
53
78
  for (const [mod, raw] of Object.entries(display.tooltipMods ?? {})) {
@@ -1,5 +0,0 @@
1
- {
2
- "Copy NBT(ui.entry.copy_nbt)": "Copy NBT",
3
- "Copy id(ui.entry.copy)": "Copy id",
4
- "Copy stack id(ui.entry.copy_stack)": "Copy stack id"
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "Copy NBT(ui.entry.copy_nbt)": "Копировать NBT",
3
- "Copy id(ui.entry.copy)": "Копировать id",
4
- "Copy stack id(ui.entry.copy_stack)": "Копировать id стака"
5
- }
package/src/locales.ts DELETED
@@ -1,6 +0,0 @@
1
- import { createLocaleCatalog } from '@terrafirmagreg-team/translate/lib/locales';
2
-
3
- export const locales = createLocaleCatalog(
4
- import.meta.glob('./locales/*.json', { eager: true, import: 'default' }),
5
- );
6
-