@overmvp/kumi 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +67 -2
- package/animation/color-transition.ts +196 -0
- package/animation/cycle.ts +151 -0
- package/animation/ease.ts +29 -0
- package/animation/index.ts +13 -0
- package/animation/package.json +12 -0
- package/animation/presets.ts +376 -0
- package/animation/spec.ts +197 -0
- package/builder/Cargo.lock +192 -0
- package/builder/Cargo.toml +7 -0
- package/builder/css-v1.mjs +387 -0
- package/builder/css-v1.test.mjs +361 -0
- package/builder/generated-output.mjs +61 -0
- package/builder/generated-output.test.mjs +132 -0
- package/builder/jsx-form.mjs +93 -0
- package/builder/jsx-form.test.mjs +48 -0
- package/builder/jsx-lists.mjs +209 -0
- package/builder/link-addon-package.mjs +127 -0
- package/builder/lua-assets.mjs +74 -0
- package/builder/lua-builtin-values.mjs +57 -0
- package/builder/lua-builtin-values.test.mjs +155 -0
- package/builder/lua-loop-closures.mjs +183 -0
- package/builder/lua-loop-closures.test.mjs +89 -0
- package/builder/lua-truthiness.mjs +61 -0
- package/builder/lua-truthiness.test.mjs +113 -0
- package/builder/module-declarations.mjs +594 -0
- package/builder/module-declarations.test.mjs +435 -0
- package/builder/native-kernels.mjs +60 -0
- package/builder/native-lua.d.ts +57 -0
- package/builder/native-routes.mjs +51 -0
- package/builder/no-static-ref-read.mjs +93 -0
- package/builder/no-static-ref-read.test.mjs +181 -0
- package/builder/secure-snippet.mjs +317 -0
- package/builder/secure-snippet.test.mjs +101 -0
- package/builder/shared-lua-runtime.mjs +150 -0
- package/builder/src/addon-link.lua +29 -0
- package/builder/src/arrays.lua +260 -0
- package/builder/src/assets.rs +177 -0
- package/builder/src/classes.lua +75 -0
- package/builder/src/collections.lua +190 -0
- package/builder/src/compiler.rs +2336 -0
- package/builder/src/config.rs +42 -0
- package/builder/src/entries.rs +166 -0
- package/builder/src/errors.lua +15 -0
- package/builder/src/lua_data.rs +231 -0
- package/builder/src/main.rs +381 -0
- package/builder/src/native_ir.rs +65 -0
- package/builder/src/native_signal.rs +83 -0
- package/builder/src/numbers.lua +76 -0
- package/builder/src/project-front.mjs +3682 -0
- package/builder/src/records.lua +75 -0
- package/builder/src/routes.rs +124 -0
- package/builder/src/setup-store.lua +18 -0
- package/builder/src/signal-kernel.fingerprint +1 -0
- package/builder/src/strings.lua +103 -0
- package/builder/src/ts-lower.mjs +68 -0
- package/builder/src/wow-reads.lua +22 -0
- package/builder/src/wow_client.rs +253 -0
- package/builder/src/wow_types.rs +564 -0
- package/builder/style-modules.mjs +93 -0
- package/builder/style-states.mjs +100 -0
- package/builder/style-states.test.mjs +103 -0
- package/builder/vite-assets.mjs +53 -0
- package/builder/vite-project.mjs +10 -0
- package/config.ts +59 -0
- package/eslint.mjs +74 -0
- package/form/index.ts +526 -0
- package/form/package.json +13 -0
- package/motion/index.ts +2 -0
- package/motion/package.json +10 -0
- package/package.json +26 -4
- package/router/index.ts +50 -0
- package/router/navigation.ts +22 -0
- package/router/package.json +12 -0
- package/router/router-view.ts +134 -0
- package/router/routes.ts +64 -0
- package/scripts/addon-build.mjs +364 -0
- package/scripts/addon-project.mjs +78 -0
- package/scripts/kumi-cli.mjs +105 -0
- package/scripts/link-addons.mjs +61 -0
- package/src/bindings.ts +35 -0
- package/src/context.ts +15 -0
- package/src/css-tokens.ts +239 -0
- package/src/css-v1.ts +68 -0
- package/src/cvars.ts +91 -0
- package/src/element-node.ts +32 -0
- package/src/elements.ts +505 -0
- package/src/feature-scope.ts +82 -0
- package/src/flex-layout.ts +807 -0
- package/src/frame-scheduler.ts +336 -0
- package/src/grid-tracks.ts +165 -0
- package/src/image-imports.d.ts +24 -0
- package/src/images.ts +79 -0
- package/src/index.ts +29 -0
- package/src/jsx-dev-runtime.ts +2 -0
- package/src/jsx-runtime.ts +29 -0
- package/src/jsx.d.ts +12 -0
- package/src/keyed-list.ts +366 -0
- package/src/media-query.ts +144 -0
- package/src/module-ui.ts +147 -0
- package/src/module.ts +311 -0
- package/src/node-selectors.ts +114 -0
- package/src/owned-collections.ts +52 -0
- package/src/providers.ts +241 -0
- package/src/reactive-scope.ts +34 -0
- package/src/reactivity.ts +275 -0
- package/src/result.ts +64 -0
- package/src/runtime.ts +52 -0
- package/src/scheduler.ts +185 -0
- package/src/signal-kernel.ts +63 -0
- package/src/style-classes.ts +51 -0
- package/src/style-states.ts +134 -0
- package/src/style-variables.ts +53 -0
- package/src/text-children.ts +42 -0
- package/src/theme.ts +50 -0
- package/src/transition.ts +18 -0
- package/state/index.ts +9 -0
- package/state/package.json +12 -0
- package/state/setup-store-persistence.ts +206 -0
- package/state/setup-store-view.ts +10 -0
- package/state/setup-store.ts +342 -0
- package/state/store-bindings.ts +25 -0
- package/state/store.ts +84 -0
- package/styles/_layers.scss +14 -0
- package/templates/addon/.agents/skills/kumi-build-debug/SKILL.md +36 -0
- package/templates/addon/.agents/skills/kumi-feature/SKILL.md +50 -0
- package/templates/addon/.agents/skills/kumi-plugin/SKILL.md +36 -0
- package/templates/addon/.agents/skills/kumi-store/SKILL.md +47 -0
- package/templates/addon/.agents/skills/kumi-ui/SKILL.md +73 -0
- package/templates/addon/.agents/skills/kumi-wow-api/SKILL.md +30 -0
- package/templates/addon/.claude/skills/kumi-build-debug/SKILL.md +36 -0
- package/templates/addon/.claude/skills/kumi-feature/SKILL.md +50 -0
- package/templates/addon/.claude/skills/kumi-plugin/SKILL.md +36 -0
- package/templates/addon/.claude/skills/kumi-store/SKILL.md +47 -0
- package/templates/addon/.claude/skills/kumi-ui/SKILL.md +73 -0
- package/templates/addon/.claude/skills/kumi-wow-api/SKILL.md +30 -0
- package/templates/addon/AGENTS.md +34 -0
- package/templates/addon/Assets/Art/Corner10.tga +0 -0
- package/templates/addon/Assets/Art/Corner11.tga +0 -0
- package/templates/addon/Assets/Art/Corner12.tga +0 -0
- package/templates/addon/Assets/Art/Corner13.tga +0 -0
- package/templates/addon/Assets/Art/Corner14.tga +0 -0
- package/templates/addon/Assets/Art/Corner15.tga +0 -0
- package/templates/addon/Assets/Art/Corner16.tga +0 -0
- package/templates/addon/Assets/Art/Corner2.tga +0 -0
- package/templates/addon/Assets/Art/Corner3.tga +0 -0
- package/templates/addon/Assets/Art/Corner4.tga +0 -0
- package/templates/addon/Assets/Art/Corner5.tga +0 -0
- package/templates/addon/Assets/Art/Corner6.tga +0 -0
- package/templates/addon/Assets/Art/Corner7.tga +0 -0
- package/templates/addon/Assets/Art/Corner8.tga +0 -0
- package/templates/addon/Assets/Art/Corner9.tga +0 -0
- package/templates/addon/Assets/Art/Dot.tga +0 -0
- package/templates/addon/Assets/Art/Gear.tga +0 -0
- package/templates/addon/Assets/Art/Grip.tga +0 -0
- package/templates/addon/Assets/Art/Outline10.tga +0 -0
- package/templates/addon/Assets/Art/Outline12.tga +0 -0
- package/templates/addon/Assets/Art/Outline13.tga +0 -0
- package/templates/addon/Assets/Art/Outline14.tga +0 -0
- package/templates/addon/Assets/Art/Outline15.tga +0 -0
- package/templates/addon/Assets/Art/Outline2.tga +0 -0
- package/templates/addon/Assets/Art/Outline3.tga +0 -0
- package/templates/addon/Assets/Art/Outline5.tga +0 -0
- package/templates/addon/Assets/Art/Outline7.tga +0 -0
- package/templates/addon/Assets/Art/Outline9.tga +0 -0
- package/templates/addon/Assets/Art/Round11.tga +0 -0
- package/templates/addon/Assets/Art/Round11Border.tga +0 -0
- package/templates/addon/Assets/Art/Round4.tga +0 -0
- package/templates/addon/Assets/Art/Round4Border.tga +0 -0
- package/templates/addon/Assets/Art/Round6.tga +0 -0
- package/templates/addon/Assets/Art/Round6Border.tga +0 -0
- package/templates/addon/Assets/Art/Round8.tga +0 -0
- package/templates/addon/Assets/Art/Round8Border.tga +0 -0
- package/templates/addon/Assets/Art/Search.tga +0 -0
- package/templates/addon/CLAUDE.md +1 -0
- package/templates/addon/README.md +49 -0
- package/templates/addon/eslint.config.mjs +6 -0
- package/templates/addon/gitignore +9 -0
- package/templates/addon/kumi.config.ts +17 -0
- package/templates/addon/package.json +20 -0
- package/templates/addon/src/app/app.module.ts +18 -0
- package/templates/addon/src/app/commands.store.ts +11 -0
- package/templates/addon/src/app/layout/AppWindow.module.scss +92 -0
- package/templates/addon/src/app/layout/AppWindow.tsx +32 -0
- package/templates/addon/src/app/main.ts +5 -0
- package/templates/addon/src/app/routes/(window)/home/page.tsx +8 -0
- package/templates/addon/src/app/routes/(window)/plugins/page.tsx +38 -0
- package/templates/addon/src/app/routes/(window)/settings/page.tsx +8 -0
- package/templates/addon/src/app/theme.ts +6 -0
- package/templates/addon/src/modules/greeting/api/player.api.ts +29 -0
- package/templates/addon/src/modules/greeting/greeting.module.ts +18 -0
- package/templates/addon/src/modules/greeting/model/greeting.store.ts +81 -0
- package/templates/addon/src/modules/greeting/services/greeting.service.ts +38 -0
- package/templates/addon/src/modules/greeting/ui/Greeting.module.scss +105 -0
- package/templates/addon/src/modules/greeting/ui/GreetingCard.tsx +29 -0
- package/templates/addon/src/modules/greeting/widgets/GreetingHud.tsx +54 -0
- package/templates/addon/src/modules/greeting/widgets/GreetingOverview.tsx +18 -0
- package/templates/addon/src/modules/greeting/widgets/GreetingSettings.tsx +56 -0
- package/templates/addon/src/modules/playtime/api/clock.api.ts +6 -0
- package/templates/addon/src/modules/playtime/model/playtime.store.ts +19 -0
- package/templates/addon/src/modules/playtime/playtime.module.ts +18 -0
- package/templates/addon/src/modules/playtime/services/playtime.service.ts +18 -0
- package/templates/addon/src/modules/playtime/ui/Playtime.module.scss +25 -0
- package/templates/addon/src/modules/playtime/ui/PlaytimeBadge.tsx +10 -0
- package/templates/addon/src/modules/playtime/widgets/PlaytimePage.tsx +16 -0
- package/templates/addon/src/shared/api/native-art.ts +28 -0
- package/templates/addon/src/shared/assets/close.png +0 -0
- package/templates/addon/src/shared/lib/format.ts +20 -0
- package/templates/addon/src/shared/styles/_tokens.scss +12 -0
- package/templates/addon/src/shared/ui/Button.tsx +29 -0
- package/templates/addon/src/shared/ui/Choice.tsx +34 -0
- package/templates/addon/src/shared/ui/Controls.module.scss +93 -0
- package/templates/addon/src/shared/ui/Glyph.tsx +18 -0
- package/templates/addon/src/shared/ui/Slider.tsx +25 -0
- package/templates/addon/src/shared/ui/Toggle.tsx +29 -0
- package/templates/addon/src/shared/ui/focus-ref.ts +7 -0
- package/templates/addon/src/shared/ui/range-skin.tsx +15 -0
- package/templates/addon/tsconfig.json +63 -0
- package/translate/index.ts +14 -0
- package/translate/package.json +9 -0
- package/utils/colors.ts +76 -0
- package/utils/format.ts +37 -0
- package/utils/index.ts +4 -0
- package/utils/number.ts +17 -0
- package/utils/package.json +7 -0
- package/utils/text.ts +6 -0
- package/validate/index.ts +119 -0
- package/validate/package.json +9 -0
- package/wow/absolute-position.ts +142 -0
- package/wow/action-bar-layout.ts +108 -0
- package/wow/action-button.ts +219 -0
- package/wow/action-catalog.ts +98 -0
- package/wow/addon-manifest.ts +36 -0
- package/wow/animation.ts +428 -0
- package/wow/app-ui.ts +221 -0
- package/wow/aura-button.ts +76 -0
- package/wow/aura-container.ts +591 -0
- package/wow/aura-countdown.ts +201 -0
- package/wow/aura-slot.ts +153 -0
- package/wow/bar-shade.ts +93 -0
- package/wow/borrowed-slot.ts +216 -0
- package/wow/button-drag.ts +48 -0
- package/wow/cast-clock.ts +153 -0
- package/wow/cast-text.ts +83 -0
- package/wow/class-colors.ts +126 -0
- package/wow/clock.ts +7 -0
- package/wow/color-picker.ts +128 -0
- package/wow/commands.ts +17 -0
- package/wow/contained-frame.ts +128 -0
- package/wow/contract.ts +42 -0
- package/wow/cooldown-timing.ts +24 -0
- package/wow/css-box.ts +144 -0
- package/wow/css-color.ts +12 -0
- package/wow/css-style.ts +109 -0
- package/wow/css-surfaces.ts +603 -0
- package/wow/css-text.ts +399 -0
- package/wow/cursor.ts +45 -0
- package/wow/cvar-schema.ts +32 -0
- package/wow/cvars.ts +98 -0
- package/wow/dropdown-art.ts +39 -0
- package/wow/element-click.ts +20 -0
- package/wow/element-event-coordinator.ts +219 -0
- package/wow/element-events.ts +317 -0
- package/wow/event-dispatcher.ts +151 -0
- package/wow/events.ts +50 -0
- package/wow/font-cache.ts +92 -0
- package/wow/frame-access.ts +53 -0
- package/wow/frame-layer.ts +5 -0
- package/wow/frame-timing.ts +13 -0
- package/wow/frames.ts +236 -0
- package/wow/heal-prediction.ts +305 -0
- package/wow/hooks.ts +133 -0
- package/wow/image-layers.ts +55 -0
- package/wow/index.ts +111 -0
- package/wow/layout-view.ts +663 -0
- package/wow/locale-font.ts +15 -0
- package/wow/lua-string.ts +18 -0
- package/wow/lua-table.ts +18 -0
- package/wow/macro-book.ts +84 -0
- package/wow/map-position.ts +27 -0
- package/wow/media-query.ts +65 -0
- package/wow/module-events.ts +11 -0
- package/wow/native-hooks.ts +168 -0
- package/wow/native-placement.ts +88 -0
- package/wow/native.ts +153 -0
- package/wow/number-format.ts +8 -0
- package/wow/number-input.ts +10 -0
- package/wow/panel-host.ts +97 -0
- package/wow/pixel.ts +35 -0
- package/wow/plugins.ts +246 -0
- package/wow/protect.ts +48 -0
- package/wow/protected-layout.ts +133 -0
- package/wow/protected-view.ts +103 -0
- package/wow/range-art.ts +81 -0
- package/wow/readable-api.ts +120 -0
- package/wow/reparent-frame.ts +99 -0
- package/wow/rounded-texture.ts +183 -0
- package/wow/saved-variables.ts +109 -0
- package/wow/scroll-view.ts +64 -0
- package/wow/secret-ref.ts +14 -0
- package/wow/secure-bindings.ts +89 -0
- package/wow/secure-clicks.ts +432 -0
- package/wow/secure-snippet.ts +235 -0
- package/wow/secure-state.ts +130 -0
- package/wow/secure-target-visibility.ts +89 -0
- package/wow/secure-transaction.ts +331 -0
- package/wow/special-window.ts +269 -0
- package/wow/spell-cooldown.ts +36 -0
- package/wow/start-addon.ts +122 -0
- package/wow/state-paint.ts +256 -0
- package/wow/transition.ts +86 -0
- package/wow/unit-button.ts +39 -0
- package/wow/unit-cast.ts +92 -0
- package/wow/unit-health-text.ts +47 -0
- package/wow/view-nodes.ts +304 -0
- package/wow/view.ts +1864 -0
- package/wow/visible-frame-job.ts +34 -0
- package/wow/width-reserve.ts +108 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import type { KumiNode, MountedElementKind, NodeRect } from "../src/element-node";
|
|
2
|
+
import type { NativeHandle } from "../src/elements";
|
|
3
|
+
import { compileNodeSelector, type NodeQuery } from "../src/node-selectors";
|
|
4
|
+
import { ownedArray, type OwnedArray, type OwnedReadonlyArray } from "../src/owned-collections";
|
|
5
|
+
import { ok, type Failure } from "../src/result";
|
|
6
|
+
import type { RuntimeScope } from "../src/runtime";
|
|
7
|
+
import type { Frame, FrameParent } from "./frames";
|
|
8
|
+
import { api, reveal } from "./native";
|
|
9
|
+
import { protect } from "./protect";
|
|
10
|
+
|
|
11
|
+
type NodeVisitor = (this: void, node: LogicalNode) => boolean;
|
|
12
|
+
type NodeRegion = FrameParent & Partial<Pick<Frame, "IsVisible" | "IsShown" | "IsMouseOver" | "IsForbidden"
|
|
13
|
+
| "GetRect" | "IsAnchoringSecret">> & {
|
|
14
|
+
SetFocus?(this: object): void;
|
|
15
|
+
HasFocus?(this: object): boolean;
|
|
16
|
+
IsEnabled?(this: object): boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
interface Metadata {
|
|
20
|
+
id?: string;
|
|
21
|
+
part?: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
data?: Readonly<Record<string, string>>;
|
|
24
|
+
[attribute: `data-${string}`]: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface LogicalGroup {
|
|
28
|
+
readonly scope: RuntimeScope;
|
|
29
|
+
readonly parent?: LogicalNode;
|
|
30
|
+
entries?: OwnedArray<LogicalGroup>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface LogicalNode<Kind extends MountedElementKind = MountedElementKind> extends LogicalGroup {
|
|
34
|
+
readonly kind: Kind;
|
|
35
|
+
readonly region: NodeRegion;
|
|
36
|
+
readonly metadata: Metadata;
|
|
37
|
+
hitTarget?: Frame;
|
|
38
|
+
view?: NativeViewNode<Kind>;
|
|
39
|
+
snapshot?: OwnedReadonlyArray<NativeViewNode>;
|
|
40
|
+
siblingIndex?: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isNode(group: LogicalGroup): group is LogicalNode {
|
|
44
|
+
return "kind" in group;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function logicalParent(group: LogicalGroup) {
|
|
48
|
+
return isNode(group) ? group : group.parent;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function append(group: LogicalGroup, child: LogicalGroup) {
|
|
52
|
+
if (group.entries === undefined) group.entries = ownedArray<LogicalGroup>();
|
|
53
|
+
group.entries.push(child);
|
|
54
|
+
const parent = logicalParent(group);
|
|
55
|
+
if (parent !== undefined) parent.snapshot = undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function mountLogicalGroup(this: void, scope: RuntimeScope, group: LogicalGroup, attached = true): LogicalGroup {
|
|
59
|
+
const parent = logicalParent(group);
|
|
60
|
+
const branch: LogicalGroup = { scope, parent };
|
|
61
|
+
if (attached) append(group, branch);
|
|
62
|
+
if (scope !== group.scope) {
|
|
63
|
+
scope.onDispose(() => clearLogicalGroup(branch));
|
|
64
|
+
}
|
|
65
|
+
return branch;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function clearLogicalGroup(this: void, group: LogicalGroup) {
|
|
69
|
+
group.entries = undefined;
|
|
70
|
+
const parent = logicalParent(group);
|
|
71
|
+
if (parent !== undefined) parent.snapshot = undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function orderLogicalRows(this: void, group: LogicalGroup, rows: readonly { logical: LogicalGroup }[]) {
|
|
75
|
+
const entries = ownedArray<LogicalGroup>();
|
|
76
|
+
for (const row of rows as OwnedReadonlyArray<{ logical: LogicalGroup }>) entries.push(row.logical);
|
|
77
|
+
group.entries = entries;
|
|
78
|
+
if (group.parent !== undefined) group.parent.snapshot = undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function walk(group: LogicalGroup, visit: NodeVisitor, deep: boolean): boolean {
|
|
82
|
+
if (group.entries === undefined || !group.scope.isActive()) return false;
|
|
83
|
+
for (const entry of group.entries) {
|
|
84
|
+
if (!isNode(entry)) {
|
|
85
|
+
if (walk(entry, visit, deep)) return true;
|
|
86
|
+
} else if (entry.scope.isActive() && (visit(entry) || (deep && walk(entry, visit, true)))) return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function readable(region: NodeRegion) {
|
|
92
|
+
return typeof region.IsForbidden !== "function" || reveal(region.IsForbidden()) === false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
class NativeViewNode<Kind extends MountedElementKind = MountedElementKind> implements KumiNode<Kind> {
|
|
96
|
+
private dataSnapshot?: Readonly<Record<string, string>>;
|
|
97
|
+
|
|
98
|
+
constructor(private mounted?: LogicalNode<Kind>) {}
|
|
99
|
+
|
|
100
|
+
private current() {
|
|
101
|
+
return this.mounted?.scope.isActive() === true ? this.mounted : undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get kind() { return this.current()?.kind; }
|
|
105
|
+
get parent(): NativeViewNode | undefined {
|
|
106
|
+
const parent = this.current()?.parent;
|
|
107
|
+
return parent === undefined ? undefined : expose(parent);
|
|
108
|
+
}
|
|
109
|
+
get native() { return this.current()?.region as NativeHandle<Kind> | undefined; }
|
|
110
|
+
get id() { return reveal(this.current()?.metadata.id); }
|
|
111
|
+
get part() { return reveal(this.current()?.metadata.part); }
|
|
112
|
+
get className() { return reveal(this.current()?.metadata.className); }
|
|
113
|
+
|
|
114
|
+
get data() {
|
|
115
|
+
const state = this.current();
|
|
116
|
+
if (state === undefined) return;
|
|
117
|
+
if (this.dataSnapshot === undefined) {
|
|
118
|
+
const data: Record<string, string> = {};
|
|
119
|
+
for (const [name, raw] of Object.entries(reveal(state.metadata.data) ?? {})) {
|
|
120
|
+
const value = reveal(raw);
|
|
121
|
+
if (typeof value === "string") data[name] = value;
|
|
122
|
+
}
|
|
123
|
+
for (const [name, raw] of Object.entries(state.metadata)) {
|
|
124
|
+
const value = reveal(raw);
|
|
125
|
+
if (name.startsWith("data-") && typeof value === "string") data[name.slice(5)] = value;
|
|
126
|
+
}
|
|
127
|
+
this.dataSnapshot = data;
|
|
128
|
+
}
|
|
129
|
+
return this.dataSnapshot;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
get children(): OwnedReadonlyArray<NativeViewNode> | undefined {
|
|
133
|
+
const state = this.current();
|
|
134
|
+
if (state === undefined) return;
|
|
135
|
+
if (state.snapshot === undefined) {
|
|
136
|
+
const result = ownedArray<NativeViewNode>();
|
|
137
|
+
walk(state, node => {
|
|
138
|
+
node.siblingIndex = result.length;
|
|
139
|
+
result.push(expose(node));
|
|
140
|
+
return false;
|
|
141
|
+
}, false);
|
|
142
|
+
state.snapshot = result;
|
|
143
|
+
}
|
|
144
|
+
return state.snapshot;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
get firstChild(): NativeViewNode | undefined {
|
|
148
|
+
const children = this.children;
|
|
149
|
+
return children === undefined ? undefined : children[0];
|
|
150
|
+
}
|
|
151
|
+
get lastChild(): NativeViewNode | undefined {
|
|
152
|
+
const children = this.children;
|
|
153
|
+
return children === undefined ? undefined : children[children.length - 1];
|
|
154
|
+
}
|
|
155
|
+
get previousSibling(): NativeViewNode | undefined { return this.sibling(-1); }
|
|
156
|
+
get nextSibling(): NativeViewNode | undefined { return this.sibling(1); }
|
|
157
|
+
|
|
158
|
+
private sibling(offset: number): NativeViewNode | undefined {
|
|
159
|
+
const state = this.current();
|
|
160
|
+
const siblings = this.parent?.children;
|
|
161
|
+
const index = state?.siblingIndex;
|
|
162
|
+
if (siblings === undefined || index === undefined || siblings[index] !== this) return;
|
|
163
|
+
return siblings[index + offset];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
release() {
|
|
167
|
+
this.mounted = undefined;
|
|
168
|
+
this.dataSnapshot = undefined;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
closest(selector: string): NodeQuery<KumiNode | undefined> | undefined {
|
|
172
|
+
if (this.current() === undefined) return;
|
|
173
|
+
const predicate = compileNodeSelector(selector);
|
|
174
|
+
if (!predicate.ok) return predicate;
|
|
175
|
+
for (let current: KumiNode | undefined = this; current !== undefined; current = current.parent) {
|
|
176
|
+
if (predicate.value(current)) return ok(current);
|
|
177
|
+
}
|
|
178
|
+
return ok(undefined);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
querySelector(selector: string): NodeQuery<KumiNode | undefined> | undefined {
|
|
182
|
+
const state = this.current();
|
|
183
|
+
if (state === undefined) return;
|
|
184
|
+
const predicate = compileNodeSelector(selector);
|
|
185
|
+
if (!predicate.ok) return predicate;
|
|
186
|
+
let found: KumiNode | undefined;
|
|
187
|
+
walk(state, entry => {
|
|
188
|
+
const node = expose(entry);
|
|
189
|
+
if (!predicate.value(node)) return false;
|
|
190
|
+
found = node;
|
|
191
|
+
return true;
|
|
192
|
+
}, true);
|
|
193
|
+
return ok(found);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
querySelectorAll(selector: string): NodeQuery<readonly KumiNode[]> | undefined {
|
|
197
|
+
const state = this.current();
|
|
198
|
+
if (state === undefined) return;
|
|
199
|
+
const predicate = compileNodeSelector(selector);
|
|
200
|
+
if (!predicate.ok) return predicate;
|
|
201
|
+
const matches: KumiNode[] = [];
|
|
202
|
+
walk(state, entry => {
|
|
203
|
+
const node = expose(entry);
|
|
204
|
+
if (predicate.value(node)) matches.push(node);
|
|
205
|
+
return false;
|
|
206
|
+
}, true);
|
|
207
|
+
return ok(matches);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
contains(node: KumiNode) {
|
|
211
|
+
if (this.current() === undefined) return;
|
|
212
|
+
for (let current: KumiNode | undefined = node; current !== undefined; current = current.parent) {
|
|
213
|
+
if (current === this) return true;
|
|
214
|
+
}
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
rect(): NodeRect | undefined {
|
|
219
|
+
const region = this.current()?.region;
|
|
220
|
+
if (region?.GetRect === undefined) return;
|
|
221
|
+
const measured = protect(() => {
|
|
222
|
+
if (!readable(region) || (region.IsAnchoringSecret !== undefined && reveal(region.IsAnchoringSecret()) !== false)) return;
|
|
223
|
+
const [rawLeft, rawBottom, rawWidth, rawHeight] = region.GetRect!();
|
|
224
|
+
const left = reveal(rawLeft), bottom = reveal(rawBottom), width = reveal(rawWidth), height = reveal(rawHeight);
|
|
225
|
+
if (left === undefined || bottom === undefined || width === undefined || height === undefined
|
|
226
|
+
|| !Number.isFinite(left) || !Number.isFinite(bottom) || !Number.isFinite(width) || !Number.isFinite(height)) return;
|
|
227
|
+
return { left, bottom, width, height };
|
|
228
|
+
});
|
|
229
|
+
return measured.ok ? measured.value : undefined;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
isShown() {
|
|
233
|
+
const region = this.current()?.region;
|
|
234
|
+
if (region === undefined) return;
|
|
235
|
+
const result = protect(() => {
|
|
236
|
+
if (!readable(region)) return;
|
|
237
|
+
return region.IsVisible === undefined ? reveal(region.IsShown?.()) : reveal(region.IsVisible());
|
|
238
|
+
});
|
|
239
|
+
return result.ok ? result.value : undefined;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
focus() {
|
|
243
|
+
const region = this.current()?.region;
|
|
244
|
+
if (region === undefined) return;
|
|
245
|
+
if (region.SetFocus === undefined || reveal(api.InCombatLockdown()) !== false || this.isShown() !== true) return false;
|
|
246
|
+
const focused = protect(() => {
|
|
247
|
+
if (!readable(region) || (region.IsEnabled !== undefined && reveal(region.IsEnabled()) !== true)) return false;
|
|
248
|
+
region.SetFocus!();
|
|
249
|
+
return region.HasFocus === undefined || reveal(region.HasFocus()) === true;
|
|
250
|
+
});
|
|
251
|
+
return focused.ok && focused.value;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
mouseHit(): boolean | undefined {
|
|
255
|
+
const state = this.current();
|
|
256
|
+
return state === undefined ? false : hitViewNode(state);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function hitSelf(node: LogicalNode): boolean | undefined {
|
|
261
|
+
const target = node.hitTarget ?? node.region;
|
|
262
|
+
const mouse = target.IsMouseOver;
|
|
263
|
+
if (mouse === undefined) return false;
|
|
264
|
+
if (!readable(target)) return;
|
|
265
|
+
const visible = reveal(target.IsVisible?.());
|
|
266
|
+
return visible === true ? reveal(mouse.call(target)) : visible;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function hitViewNode(this: void, node: LogicalNode): boolean | undefined {
|
|
270
|
+
if (!node.scope.isActive()) return false;
|
|
271
|
+
const first = hitSelf(node);
|
|
272
|
+
if (first === true) return true;
|
|
273
|
+
let known = first === false;
|
|
274
|
+
const hit = walk(node, child => {
|
|
275
|
+
const result = hitSelf(child);
|
|
276
|
+
if (result === undefined) known = false;
|
|
277
|
+
return result === true;
|
|
278
|
+
}, true);
|
|
279
|
+
return hit ? true : known ? false : undefined;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function expose<Kind extends MountedElementKind>(node: LogicalNode<Kind>): NativeViewNode<Kind> {
|
|
283
|
+
if (node.view !== undefined) return node.view;
|
|
284
|
+
const view = new NativeViewNode(node);
|
|
285
|
+
node.view = view;
|
|
286
|
+
const cleanup = node.scope.onDispose(() => view.release());
|
|
287
|
+
if (!cleanup.ok) view.release();
|
|
288
|
+
return view;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function mountViewNode<Kind extends MountedElementKind>(this: void, scope: RuntimeScope, group: LogicalGroup,
|
|
292
|
+
kind: Kind, region: FrameParent, metadata: Metadata): LogicalNode<Kind> {
|
|
293
|
+
const node: LogicalNode<Kind> = { scope, parent: logicalParent(group), kind, region, metadata };
|
|
294
|
+
append(group, node);
|
|
295
|
+
return node;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export function finishViewNode<Kind extends MountedElementKind>(this: void, scope: RuntimeScope, node: LogicalNode<Kind>,
|
|
299
|
+
ref?: (this: void, value?: KumiNode<Kind>) => void): Failure | undefined {
|
|
300
|
+
if (ref === undefined) return;
|
|
301
|
+
const exposed = scope.protect(() => ref(expose(node)));
|
|
302
|
+
if (!exposed.ok) return exposed;
|
|
303
|
+
scope.onDispose(() => ref(undefined));
|
|
304
|
+
}
|