@aethervtt/shard-ui 0.0.1
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/components.d.ts +144 -0
- package/dist/components.js +355 -0
- package/dist/flex.d.ts +107 -0
- package/dist/flex.js +751 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +133 -0
- package/dist/interaction.d.ts +44 -0
- package/dist/interaction.js +416 -0
- package/dist/length.d.ts +17 -0
- package/dist/length.js +92 -0
- package/dist/methods.d.ts +52 -0
- package/dist/methods.js +187 -0
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +40 -0
- package/dist/render.d.ts +76 -0
- package/dist/render.js +715 -0
- package/dist/shaders.d.ts +2 -0
- package/dist/shaders.js +124 -0
- package/dist/style.d.ts +45 -0
- package/dist/style.js +111 -0
- package/dist/testing.d.ts +20 -0
- package/dist/testing.js +68 -0
- package/dist/theme.d.ts +30 -0
- package/dist/theme.js +172 -0
- package/dist/tree.d.ts +172 -0
- package/dist/tree.js +1109 -0
- package/package.json +42 -0
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { type Entity, type Table, type World } from '@aethervtt/shard-core';
|
|
2
|
+
import { type Font, TextLayout } from '@aethervtt/shard-text';
|
|
3
|
+
import { FlexTree } from './flex.js';
|
|
4
|
+
import { ResolvedStyle, type StyleColumns } from './style.js';
|
|
5
|
+
import { type UiThemeAsset } from './theme.js';
|
|
6
|
+
/** Interactive node kinds. */
|
|
7
|
+
export declare const Kind: {
|
|
8
|
+
readonly None: 0;
|
|
9
|
+
readonly Button: 1;
|
|
10
|
+
readonly Toggle: 2;
|
|
11
|
+
readonly Slider: 3;
|
|
12
|
+
readonly TextInput: 4;
|
|
13
|
+
};
|
|
14
|
+
export declare const AnchorState: {
|
|
15
|
+
readonly None: 0;
|
|
16
|
+
readonly OnScreen: 1;
|
|
17
|
+
readonly Clamped: 2;
|
|
18
|
+
readonly Hidden: 3;
|
|
19
|
+
};
|
|
20
|
+
export declare const Overflow: {
|
|
21
|
+
readonly Visible: 0;
|
|
22
|
+
readonly Clip: 1;
|
|
23
|
+
readonly Scroll: 2;
|
|
24
|
+
};
|
|
25
|
+
/** Text a node measures and draws, and what it was last measured with. */
|
|
26
|
+
export interface TextNode {
|
|
27
|
+
entity: Entity;
|
|
28
|
+
value: string;
|
|
29
|
+
font: Font | undefined;
|
|
30
|
+
fontVersion: number;
|
|
31
|
+
size: number;
|
|
32
|
+
lineHeight: number;
|
|
33
|
+
wrap: boolean;
|
|
34
|
+
/** Two cached measurements: max width → (width, height). */
|
|
35
|
+
cacheW: Float32Array;
|
|
36
|
+
cacheOut: Float32Array;
|
|
37
|
+
cacheN: number;
|
|
38
|
+
/** The drawn layout (at the final width), and what it was laid out with. */
|
|
39
|
+
layout: TextLayout;
|
|
40
|
+
laidWidth: number;
|
|
41
|
+
laidVersion: number;
|
|
42
|
+
}
|
|
43
|
+
/** One UI tree: its nodes in preorder (children in `order`), and everything computed for them. */
|
|
44
|
+
export declare class UiRootState {
|
|
45
|
+
readonly entity: Entity;
|
|
46
|
+
readonly tree: FlexTree;
|
|
47
|
+
/** Node index → entity. Node 0 is the root. */
|
|
48
|
+
entities: Entity[];
|
|
49
|
+
parent: Int32Array<ArrayBuffer>;
|
|
50
|
+
/** Index past the node's subtree. */
|
|
51
|
+
end: Int32Array<ArrayBuffer>;
|
|
52
|
+
/** Node indices in paint order (siblings by zIndex, stable). */
|
|
53
|
+
paint: Int32Array<ArrayBuffer>;
|
|
54
|
+
/** Computed rect (root pixels), after scroll and anchor scale. */
|
|
55
|
+
x: Float32Array<ArrayBuffer>;
|
|
56
|
+
y: Float32Array<ArrayBuffer>;
|
|
57
|
+
w: Float32Array<ArrayBuffer>;
|
|
58
|
+
h: Float32Array<ArrayBuffer>;
|
|
59
|
+
/** Clip applied to the node (x0, y0, x1, y1), and what it passes to its children. */
|
|
60
|
+
clip: Float32Array<ArrayBuffer>;
|
|
61
|
+
childClip: Float32Array<ArrayBuffer>;
|
|
62
|
+
visible: Uint8Array<ArrayBuffer>;
|
|
63
|
+
scale: Float32Array<ArrayBuffer>;
|
|
64
|
+
angle: Float32Array<ArrayBuffer>;
|
|
65
|
+
anchorState: Uint8Array<ArrayBuffer>;
|
|
66
|
+
distance: Float32Array<ArrayBuffer>;
|
|
67
|
+
contentW: Float32Array<ArrayBuffer>;
|
|
68
|
+
contentH: Float32Array<ArrayBuffer>;
|
|
69
|
+
overflow: Uint8Array<ArrayBuffer>;
|
|
70
|
+
scrollX: Float32Array<ArrayBuffer>;
|
|
71
|
+
scrollY: Float32Array<ArrayBuffer>;
|
|
72
|
+
/** 1: has UiAnchor; 2: UiAnchorArrow. */
|
|
73
|
+
anchorKind: Uint8Array<ArrayBuffer>;
|
|
74
|
+
/** Widget kind (Kind), disabled, and whether the node takes the pointer. */
|
|
75
|
+
kind: Uint8Array<ArrayBuffer>;
|
|
76
|
+
disabled: Uint8Array<ArrayBuffer>;
|
|
77
|
+
solid: Uint8Array<ArrayBuffer>;
|
|
78
|
+
/** This frame: its flex tree is refilled and laid out; its UiLayout rows are written. */
|
|
79
|
+
filling: boolean;
|
|
80
|
+
writing: boolean;
|
|
81
|
+
/** Widgets, styles, or images changed: refresh kind, disabled, and solid. */
|
|
82
|
+
flagsDirty: boolean;
|
|
83
|
+
/** order and zIndex per node when the tree was built. */
|
|
84
|
+
sortKeys: Int16Array<ArrayBuffer>;
|
|
85
|
+
/** Distance scale of each anchor (1 for other nodes). */
|
|
86
|
+
anchorScale: Float32Array<ArrayBuffer>;
|
|
87
|
+
/** Nodes that measure text, by node index. */
|
|
88
|
+
texts: (TextNode | undefined)[];
|
|
89
|
+
/** Image intrinsic size (0 until the texture loads). */
|
|
90
|
+
imageW: Float32Array<ArrayBuffer>;
|
|
91
|
+
imageH: Float32Array<ArrayBuffer>;
|
|
92
|
+
count: number;
|
|
93
|
+
hasAnchors: boolean;
|
|
94
|
+
/** Root pixels → screen pixels. */
|
|
95
|
+
factor: number;
|
|
96
|
+
width: number;
|
|
97
|
+
height: number;
|
|
98
|
+
viewportW: number;
|
|
99
|
+
viewportH: number;
|
|
100
|
+
camera: Entity | null;
|
|
101
|
+
theme: UiThemeAsset | undefined;
|
|
102
|
+
themeVersion: number;
|
|
103
|
+
order: number;
|
|
104
|
+
dirty: boolean;
|
|
105
|
+
/** Frame counter of the last layout, for describe. */
|
|
106
|
+
laidOutAt: number;
|
|
107
|
+
/** Something visual changed since the renderer last built this root. */
|
|
108
|
+
visualVersion: number;
|
|
109
|
+
constructor(entity: Entity);
|
|
110
|
+
reserve(n: number): void;
|
|
111
|
+
}
|
|
112
|
+
/** Every UI tree, which root each node is in, and this frame's work counts. */
|
|
113
|
+
export declare class UiStore {
|
|
114
|
+
roots: UiRootState[];
|
|
115
|
+
readonly rootOf: Map<number, UiRootState>;
|
|
116
|
+
readonly indexOf: Map<number, number>;
|
|
117
|
+
/** UiNode entities outside any UiRoot (ui/no-root), reported once each. */
|
|
118
|
+
readonly orphans: Set<number>;
|
|
119
|
+
readonly reportedOrphans: Set<number>;
|
|
120
|
+
/** Styles nodes name that their root's theme lacks (ui/unknown-style), reported once each. */
|
|
121
|
+
readonly reportedStyles: Set<string>;
|
|
122
|
+
structureDirty: boolean;
|
|
123
|
+
frame: number;
|
|
124
|
+
/** This frame: roots laid out, nodes they had, anchor-only repositions, layout calls. */
|
|
125
|
+
layouts: number;
|
|
126
|
+
nodesLaidOut: number;
|
|
127
|
+
repositions: number;
|
|
128
|
+
flexCalls: number;
|
|
129
|
+
totalLayouts: number;
|
|
130
|
+
root(entity: Entity): UiRootState | undefined;
|
|
131
|
+
}
|
|
132
|
+
export declare const UiState: import("@aethervtt/shard-core").ResourceDef<UiStore>;
|
|
133
|
+
/** Marks trees for a rebuild when nodes appear, disappear, or move to another parent. */
|
|
134
|
+
export declare function observeUiStructure(world: World): void;
|
|
135
|
+
/** Lays out a text node's string at a width: block width, and lines × line height. */
|
|
136
|
+
export declare function measureTextNode(t: TextNode, maxWidth: number, out: Float32Array, into?: TextLayout): TextLayout;
|
|
137
|
+
/**
|
|
138
|
+
* Recomputes which nodes are widgets and which take the pointer (a visible background or border,
|
|
139
|
+
* an image, or a widget), after anything visual changed.
|
|
140
|
+
*/
|
|
141
|
+
export declare function refreshFlags(world: World, r: UiRootState): void;
|
|
142
|
+
interface LayoutState {
|
|
143
|
+
roots: ReturnType<World['query']>;
|
|
144
|
+
nodes: ReturnType<World['query']>;
|
|
145
|
+
texts: ReturnType<World['query']>;
|
|
146
|
+
images: ReturnType<World['query']>;
|
|
147
|
+
anchors: ReturnType<World['query']>;
|
|
148
|
+
cameras: ReturnType<World['query']>;
|
|
149
|
+
inputs: ReturnType<World['query']>;
|
|
150
|
+
styles: ReturnType<World['query']>;
|
|
151
|
+
widgets: ReturnType<World['query']>[];
|
|
152
|
+
interactions: ReturnType<World['query']>;
|
|
153
|
+
measure: (node: number, maxWidth: number, out: Float32Array) => void;
|
|
154
|
+
current: UiRootState | undefined;
|
|
155
|
+
style: ResolvedStyle;
|
|
156
|
+
lastTick: number;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Lays out UI after transform propagation (anchors need world positions). Only roots with a
|
|
160
|
+
* changed node, text, image, root, viewport, font, or theme lay out; anchors that only moved
|
|
161
|
+
* reposition their subtree without a layout.
|
|
162
|
+
*/
|
|
163
|
+
export declare const layoutUi: import("@aethervtt/shard-core").SystemDef<LayoutState>;
|
|
164
|
+
/** UiStyle and UiText columns of a table (either may be missing). Cached per table. */
|
|
165
|
+
export declare function textColumns(table: Table): StyleColumns;
|
|
166
|
+
/**
|
|
167
|
+
* Absolute rects from the flex tree: parents' positions, scroll offsets, anchor points and
|
|
168
|
+
* scales; clips from ancestors that clip or scroll; visibility (display none, hidden anchors,
|
|
169
|
+
* arrows of anchors that aren't clamped); content size for scrolling.
|
|
170
|
+
*/
|
|
171
|
+
export declare function derive(r: UiRootState): void;
|
|
172
|
+
export {};
|