@terrafirmagreg-team/recipe 1.2.22 → 1.2.24
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/components/cards/card/strip.tsx +18 -0
- package/src/components/cards/controls/card-pager.tsx +101 -0
- package/src/components/cards/controls/card-scrollbar.tsx +370 -0
- package/src/components/cards/paged-card.tsx +1 -1
- package/src/components/cards/scroll-card/index.tsx +605 -131
- package/src/components/cards/slot-hitbox.tsx +19 -1
- package/src/components/cards/strip-card/buttons.tsx +9 -57
- package/src/components/cards/strip-card/index.tsx +2 -0
- package/src/components/cards/strip-card/member-cell.tsx +36 -12
- package/src/components/views/browser/card-grid.tsx +1 -1
- package/src/components/views/layout.tsx +7 -11
- package/src/hooks/use-index.ts +25 -16
- package/src/hooks/use-left-sidebar-tree.ts +6 -16
- package/src/lib/client-index/chrome.ts +17 -52
- package/src/lib/client-index/rows.ts +2 -1
- package/src/lib/data/scroll.ts +172 -2
- package/src/lib/routes.ts +22 -0
package/src/lib/data/scroll.ts
CHANGED
|
@@ -1,8 +1,54 @@
|
|
|
1
1
|
import {
|
|
2
|
+
asBool,
|
|
2
3
|
asNumber,
|
|
3
4
|
asRecord,
|
|
4
5
|
asString,
|
|
5
6
|
} from '@terrafirmagreg-team/dump/lib/dump/contract/read';
|
|
7
|
+
import {
|
|
8
|
+
asTaggedReference,
|
|
9
|
+
type TaggedReference,
|
|
10
|
+
} from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
11
|
+
|
|
12
|
+
export type ScrollRect = { x: number; y: number; w: number; h: number };
|
|
13
|
+
|
|
14
|
+
export type ScrollBarSkinPiece = {
|
|
15
|
+
u: number;
|
|
16
|
+
v: number;
|
|
17
|
+
w: number;
|
|
18
|
+
h: number;
|
|
19
|
+
s: number | number[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type ScrollBarSkin = {
|
|
23
|
+
track: ScrollBarSkinPiece;
|
|
24
|
+
thumb: ScrollBarSkinPiece;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type ScrollFrame = {
|
|
28
|
+
tex: string;
|
|
29
|
+
u: number;
|
|
30
|
+
v: number;
|
|
31
|
+
s: number;
|
|
32
|
+
t: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type ScrollElement = {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
w: number;
|
|
39
|
+
h: number;
|
|
40
|
+
kind: 'slot' | 'text' | 'block' | 'entity';
|
|
41
|
+
ref?: TaggedReference;
|
|
42
|
+
base?: TaggedReference;
|
|
43
|
+
mark?: boolean;
|
|
44
|
+
tooltip?: string[];
|
|
45
|
+
label?: string;
|
|
46
|
+
text?: string;
|
|
47
|
+
color?: number;
|
|
48
|
+
pin?: boolean;
|
|
49
|
+
u?: number;
|
|
50
|
+
v?: number;
|
|
51
|
+
};
|
|
6
52
|
|
|
7
53
|
export type RecipeScroll = {
|
|
8
54
|
x: number;
|
|
@@ -12,8 +58,97 @@ export type RecipeScroll = {
|
|
|
12
58
|
axis: 'vertical' | 'horizontal';
|
|
13
59
|
contentH: number;
|
|
14
60
|
contentW: number;
|
|
61
|
+
bar?: ScrollRect;
|
|
62
|
+
viewport?: ScrollRect;
|
|
63
|
+
clipTop?: number;
|
|
64
|
+
guiTex?: string;
|
|
65
|
+
barSkin?: ScrollBarSkin;
|
|
66
|
+
frame?: ScrollFrame;
|
|
67
|
+
slotTex?: string;
|
|
68
|
+
overlay?: string;
|
|
69
|
+
overlayW?: number;
|
|
70
|
+
overlayH?: number;
|
|
71
|
+
decomposed?: boolean;
|
|
72
|
+
elements?: ScrollElement[];
|
|
15
73
|
};
|
|
16
74
|
|
|
75
|
+
function scrollRect(value: unknown): ScrollRect | undefined {
|
|
76
|
+
const raw = asRecord(value);
|
|
77
|
+
if (!raw) return undefined;
|
|
78
|
+
const x = asNumber(raw.x);
|
|
79
|
+
const y = asNumber(raw.y);
|
|
80
|
+
const w = asNumber(raw.w);
|
|
81
|
+
const h = asNumber(raw.h);
|
|
82
|
+
if (x === undefined || y === undefined || !w || !h) return undefined;
|
|
83
|
+
return { x, y, w, h };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function skinPiece(value: unknown): ScrollBarSkinPiece | undefined {
|
|
87
|
+
const raw = asRecord(value);
|
|
88
|
+
if (!raw) return undefined;
|
|
89
|
+
const u = asNumber(raw.u);
|
|
90
|
+
const v = asNumber(raw.v);
|
|
91
|
+
const w = asNumber(raw.w);
|
|
92
|
+
const h = asNumber(raw.h);
|
|
93
|
+
if (u === undefined || v === undefined || !w || !h) return undefined;
|
|
94
|
+
const s = raw.s;
|
|
95
|
+
const slices = Array.isArray(s)
|
|
96
|
+
? s.map(asNumber).filter((n): n is number => n !== undefined)
|
|
97
|
+
: (asNumber(s) ?? 0);
|
|
98
|
+
return { u, v, w, h, s: slices };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function scrollFrame(value: unknown): ScrollFrame | undefined {
|
|
102
|
+
const raw = asRecord(value);
|
|
103
|
+
if (!raw) return undefined;
|
|
104
|
+
const tex = asString(raw.tex);
|
|
105
|
+
const u = asNumber(raw.u);
|
|
106
|
+
const v = asNumber(raw.v);
|
|
107
|
+
const s = asNumber(raw.s);
|
|
108
|
+
const t = asNumber(raw.t);
|
|
109
|
+
if (!tex || u === undefined || v === undefined || !s || !t) return undefined;
|
|
110
|
+
return { tex, u, v, s, t };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function scrollElement(value: unknown): ScrollElement | undefined {
|
|
114
|
+
const raw = asRecord(value);
|
|
115
|
+
if (!raw) return undefined;
|
|
116
|
+
const x = asNumber(raw.x);
|
|
117
|
+
const y = asNumber(raw.y);
|
|
118
|
+
if (x === undefined || y === undefined) return undefined;
|
|
119
|
+
const kind = asString(raw.kind);
|
|
120
|
+
if (
|
|
121
|
+
kind !== 'slot' &&
|
|
122
|
+
kind !== 'text' &&
|
|
123
|
+
kind !== 'block' &&
|
|
124
|
+
kind !== 'entity'
|
|
125
|
+
)
|
|
126
|
+
return undefined;
|
|
127
|
+
const w = asNumber(raw.w);
|
|
128
|
+
const h = asNumber(raw.h);
|
|
129
|
+
return {
|
|
130
|
+
x,
|
|
131
|
+
y,
|
|
132
|
+
w: w ?? 18,
|
|
133
|
+
h: h ?? 18,
|
|
134
|
+
kind,
|
|
135
|
+
ref: asTaggedReference(raw.ref),
|
|
136
|
+
base: asTaggedReference(raw.base),
|
|
137
|
+
mark: asBool(raw.mark) === true || undefined,
|
|
138
|
+
tooltip: Array.isArray(raw.tooltip)
|
|
139
|
+
? raw.tooltip
|
|
140
|
+
.map(asString)
|
|
141
|
+
.filter((line): line is string => line !== undefined && line.length > 0)
|
|
142
|
+
: undefined,
|
|
143
|
+
label: asString(raw.label),
|
|
144
|
+
text: asString(raw.text),
|
|
145
|
+
color: asNumber(raw.color),
|
|
146
|
+
pin: asBool(raw.pin) === true || undefined,
|
|
147
|
+
u: asNumber(raw.u),
|
|
148
|
+
v: asNumber(raw.v),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
17
152
|
export function recipeScroll(
|
|
18
153
|
properties: Record<string, unknown> | undefined,
|
|
19
154
|
): RecipeScroll | undefined {
|
|
@@ -26,7 +161,42 @@ export function recipeScroll(
|
|
|
26
161
|
const contentH = asNumber(raw.contentH) ?? 0;
|
|
27
162
|
const contentW = asNumber(raw.contentW) ?? 0;
|
|
28
163
|
if (x === undefined || y === undefined || !w || !h) return undefined;
|
|
29
|
-
if (contentH <= h && contentW <= w) return undefined;
|
|
30
164
|
const axis = asString(raw.axis) === 'horizontal' ? 'horizontal' : 'vertical';
|
|
31
|
-
|
|
165
|
+
const rawSkin = asRecord(raw.barSkin);
|
|
166
|
+
const barSkin =
|
|
167
|
+
rawSkin !== undefined
|
|
168
|
+
? {
|
|
169
|
+
track: skinPiece(rawSkin.track),
|
|
170
|
+
thumb: skinPiece(rawSkin.thumb),
|
|
171
|
+
}
|
|
172
|
+
: undefined;
|
|
173
|
+
const elements = Array.isArray(raw.elements)
|
|
174
|
+
? raw.elements
|
|
175
|
+
.map(scrollElement)
|
|
176
|
+
.filter((el): el is ScrollElement => el !== undefined)
|
|
177
|
+
: undefined;
|
|
178
|
+
return {
|
|
179
|
+
x,
|
|
180
|
+
y,
|
|
181
|
+
w,
|
|
182
|
+
h,
|
|
183
|
+
axis,
|
|
184
|
+
contentH,
|
|
185
|
+
contentW,
|
|
186
|
+
bar: scrollRect(raw.bar),
|
|
187
|
+
viewport: scrollRect(raw.viewport),
|
|
188
|
+
clipTop: asNumber(raw.clipTop) || undefined,
|
|
189
|
+
guiTex: asString(raw.guiTex),
|
|
190
|
+
barSkin:
|
|
191
|
+
barSkin?.track !== undefined && barSkin.thumb !== undefined
|
|
192
|
+
? { track: barSkin.track, thumb: barSkin.thumb }
|
|
193
|
+
: undefined,
|
|
194
|
+
frame: scrollFrame(raw.frame),
|
|
195
|
+
slotTex: asString(raw.slotTex),
|
|
196
|
+
overlay: asString(raw.overlay),
|
|
197
|
+
overlayW: asNumber(raw.overlayW),
|
|
198
|
+
overlayH: asNumber(raw.overlayH),
|
|
199
|
+
decomposed: asBool(raw.decomposed) === true || undefined,
|
|
200
|
+
elements: elements && elements.length > 0 ? elements : undefined,
|
|
201
|
+
};
|
|
32
202
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createSectionRoutes } from '@terrafirmagreg-team/kit/components/views/routes';
|
|
2
|
+
import { ogDeepLink } from '@terrafirmagreg-team/preview/server';
|
|
3
|
+
import { RecipeTreeFeature } from '@terrafirmagreg-team/recipe/components/views/layout';
|
|
4
|
+
import { RecipeAxisSwitcher } from '@terrafirmagreg-team/recipe/components/views/browser/axis-switcher';
|
|
5
|
+
import { recipeLanding } from '@terrafirmagreg-team/recipe/components/views/landing';
|
|
6
|
+
import { recipeTrees } from '@terrafirmagreg-team/recipe/components/tree';
|
|
7
|
+
import { getRecipeSource } from '@terrafirmagreg-team/recipe/lib/source';
|
|
8
|
+
import '@terrafirmagreg-team/recipe/lib/og';
|
|
9
|
+
|
|
10
|
+
export function recipeRoutes() {
|
|
11
|
+
return createSectionRoutes({
|
|
12
|
+
section: 'recipe',
|
|
13
|
+
trees: recipeTrees,
|
|
14
|
+
source: { getSource: getRecipeSource },
|
|
15
|
+
layout: {
|
|
16
|
+
treeFeature: RecipeTreeFeature,
|
|
17
|
+
sidebar: { feature: RecipeAxisSwitcher },
|
|
18
|
+
},
|
|
19
|
+
landing: recipeLanding,
|
|
20
|
+
deepLink: ogDeepLink('recipe'),
|
|
21
|
+
});
|
|
22
|
+
}
|