@overmvp/kumi 0.4.0 → 0.5.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/builder/module-declarations.mjs +2 -2
- package/builder/module-declarations.test.mjs +4 -2
- package/package.json +1 -1
- package/router/router-view.ts +5 -3
- package/scripts/addon-build.mjs +2 -0
- package/scripts/kumi-cli.mjs +0 -0
- package/src/elements.ts +11 -1
- package/src/module-ui.ts +4 -0
- package/src/module.ts +14 -4
- package/templates/addon/src/app/app.module.ts +3 -5
- package/templates/addon/src/modules/greeting/greeting.module.ts +2 -2
- package/templates/addon/src/modules/playtime/playtime.module.ts +3 -5
- package/utils/format.ts +13 -0
- package/utils/index.ts +1 -1
- package/wow/animation.ts +16 -4
- package/wow/app-ui.ts +132 -22
- package/wow/aura-container.ts +132 -38
- package/wow/aura-countdown.ts +19 -3
- package/wow/aura-follower.ts +32 -0
- package/wow/aura-view.ts +49 -0
- package/wow/css-box.ts +7 -4
- package/wow/css-surfaces.ts +10 -4
- package/wow/frames.ts +2 -0
- package/wow/hooks.ts +17 -0
- package/wow/hotkeys.ts +221 -0
- package/wow/index.ts +9 -5
- package/wow/initial-view.ts +99 -0
- package/wow/layout-view.ts +1 -1
- package/wow/native.ts +1 -0
- package/wow/pixel.ts +25 -0
- package/wow/scroll-view.ts +5 -4
- package/wow/status-bar.ts +65 -0
- package/wow/unit-button.ts +25 -4
- package/wow/view-nodes.ts +11 -4
- package/wow/view.ts +113 -116
package/wow/view.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Anchor, Binding, CooldownValue, Element, Job, NativeStyle, ReadonlyRef, Runtime, RuntimeScope,
|
|
1
|
+
import type { Anchor, Binding, CooldownValue, Element, Job, NativeStyle, ReadonlyRef, Runtime, RuntimeScope, StyleClass, TransitionOptions, UIElement } from "../src";
|
|
2
2
|
import { bindValue } from "../src/bindings";
|
|
3
3
|
import type { CssTokenRecipe } from "../src/css-v1";
|
|
4
4
|
import { bindImageSize, imageSize, positiveImageDimension } from "../src/images";
|
|
@@ -13,6 +13,7 @@ import { extendStyleEnvironment, resolveStyleValue, styleValue, type StyleEnviro
|
|
|
13
13
|
import { createFrame, type FontString, type FrameMap, type FrameParent, type StatusBar, type Texture } from "./frames";
|
|
14
14
|
import { canAccessRegion } from "./frame-access";
|
|
15
15
|
import { bindAbsolutePosition, type NativeEndTarget, type NativeStartTarget, type NativeTextEndTarget } from "./absolute-position";
|
|
16
|
+
import { createAuraFollowerFrame } from "./aura-follower";
|
|
16
17
|
import { bindBorrowedSlot, type BorrowedSlot } from "./borrowed-slot";
|
|
17
18
|
import { prepareCssStyle, type ReadCssStyle } from "./css-style";
|
|
18
19
|
import { readCssColor } from "./css-color";
|
|
@@ -27,6 +28,8 @@ import { mountImageLayers } from "./image-layers";
|
|
|
27
28
|
import { mountScrollView, type CreateScrollArea, type ScrollArea } from "./scroll-view";
|
|
28
29
|
import { bindButtonDrag } from "./button-drag";
|
|
29
30
|
import { bindActionVisibility, bindButtonMove, bindSecureAction, bindSecureMacro, listenForDrop, unlockedActionSlot } from "./action-button";
|
|
31
|
+
import { bindSecureUnit } from "./unit-button";
|
|
32
|
+
import { bindStatusBar } from "./status-bar";
|
|
30
33
|
import { bindElementEvents, hasElementInput, type NativeElementEventHost } from "./element-events";
|
|
31
34
|
import { api, isSecret, reveal } from "./native";
|
|
32
35
|
import { hookScript, hookSecureMethod } from "./native-hooks";
|
|
@@ -34,9 +37,10 @@ import { rawField } from "./lua-table";
|
|
|
34
37
|
import { observeContainer, type NativeMediaOptions } from "./media-query";
|
|
35
38
|
import { mountRangeArt } from "./range-art";
|
|
36
39
|
import { protect } from "./protect";
|
|
40
|
+
import { initialLayoutQueue, stageInitialView, type InitialViewStages } from "./initial-view";
|
|
37
41
|
import { animateVisibility } from "./transition";
|
|
38
42
|
import { attachLayoutItem, isAbsoluteFill, mountLayoutRoot, NativeLayoutItem, readLayoutValue, type NativeLayoutDiagnostics, type NativeLayoutGroup, type StageInitialLayout } from "./layout-view";
|
|
39
|
-
import { finishViewNode, mountLogicalGroup, mountViewNode, orderLogicalRows, type LogicalGroup, type LogicalNode } from "./view-nodes";
|
|
43
|
+
import { attachViewRef, finishViewNode, mountLogicalGroup, mountViewNode, orderLogicalRows, type LogicalGroup, type LogicalNode } from "./view-nodes";
|
|
40
44
|
import { bindStatePaint, createNativePaintState, type ButtonPaintTiming, type NativeButtonPaintMotion, type NativePaintState,
|
|
41
45
|
type NativeStateColor, type TextColorStateChange } from "./state-paint";
|
|
42
46
|
import { isIntrinsicWidth, type FlexNode } from "../src/flex-layout";
|
|
@@ -52,7 +56,6 @@ type Layout = Pick<Element<"frame">["props"], "width" | "height" | "fullWidth" |
|
|
|
52
56
|
unanchored?: boolean;
|
|
53
57
|
};
|
|
54
58
|
type StatusBarProps = Element<"statusbar">["props"];
|
|
55
|
-
type NativeStatusBarValue = Parameters<StatusBar["SetValue"]>[0];
|
|
56
59
|
type NativeChildren = OwnedArray<UIElement>;
|
|
57
60
|
const headingSizes = [24, 20, 18, 16, 14, 12] as const;
|
|
58
61
|
|
|
@@ -75,10 +78,7 @@ declare module "../src/elements" {
|
|
|
75
78
|
|
|
76
79
|
/** Pass the mounted handle to the element's ref and clear it when the mount is released. */
|
|
77
80
|
function attachRef<Handle>(scope: RuntimeScope, ref: ((this: void, handle?: Handle) => void) | undefined, handle: Handle): Failure | undefined {
|
|
78
|
-
if (
|
|
79
|
-
const attached = scope.protect(() => ref(handle));
|
|
80
|
-
if (!attached.ok) return attached;
|
|
81
|
-
scope.onDispose(() => ref(undefined));
|
|
81
|
+
if (ref !== undefined) return attachViewRef(scope, ref, () => handle);
|
|
82
82
|
}
|
|
83
83
|
export interface NativeRootLayer {
|
|
84
84
|
readonly strata: FrameStrata;
|
|
@@ -129,8 +129,10 @@ export interface NativeViewOptions extends NativeTextHost {
|
|
|
129
129
|
layoutDiagnostics?: NativeLayoutDiagnostics;
|
|
130
130
|
/** Complete the newly mounted tree's first CSS layout before returning. Later updates use the frame budget. */
|
|
131
131
|
initialLayout?: "sync";
|
|
132
|
-
/**
|
|
133
|
-
|
|
132
|
+
/** @internal Notify the hidden window host after native children and first layout finish. */
|
|
133
|
+
completeStagedMount?(this: void, failure?: Failure): void | Failure;
|
|
134
|
+
/** Mount only text and textures on a borrowed frame. Native-owned regions stay with their parent on disposal. */
|
|
135
|
+
regionsOnly?: boolean | "native-owned";
|
|
134
136
|
/**
|
|
135
137
|
* Apply a strata and optional absolute frame level to the native root at mount time.
|
|
136
138
|
* An explicit level takes precedence over the root's `style.zIndex`.
|
|
@@ -208,6 +210,7 @@ type MountOptions = NativeViewOptions & {
|
|
|
208
210
|
manualControl?(this: void, owner: RuntimeScope, nested: boolean): ManualControlBindings | undefined;
|
|
209
211
|
mediaContainer?: Frame;
|
|
210
212
|
stageInitialLayout?: StageInitialLayout;
|
|
213
|
+
initialStages?: InitialViewStages;
|
|
211
214
|
};
|
|
212
215
|
|
|
213
216
|
interface ManualControlBindings {
|
|
@@ -478,47 +481,6 @@ function mountBackground(frame: Frame, color: string | undefined, scope: Runtime
|
|
|
478
481
|
});
|
|
479
482
|
}
|
|
480
483
|
|
|
481
|
-
/** Box a WoW number so application refs can publish it without comparing the number. */
|
|
482
|
-
export function statusBarValue(this: void, value: NativeStatusBarValue): StatusBarValue {
|
|
483
|
-
return { nativeValue: value } as StatusBarValue;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
function readStatusBarBinding(binding: Binding<StatusBarValue>): Result<StatusBarValue> {
|
|
487
|
-
if (typeof binding === "number" || "nativeValue" in binding) return ok(binding);
|
|
488
|
-
const value = binding.value;
|
|
489
|
-
return typeof value === "object" && "ok" in value ? value : ok(value);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
function unwrapStatusBarValue(value: StatusBarValue): NativeStatusBarValue {
|
|
493
|
-
return typeof value === "number" ? value : value.nativeValue as NativeStatusBarValue;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
function bindStatusBar(scope: RuntimeScope, bar: StatusBar, { min, max, value, smooth }: StatusBarProps): Failure | undefined {
|
|
497
|
-
const interpolation = smooth ? api.Enum?.StatusBarInterpolation?.ExponentialEaseOut : undefined;
|
|
498
|
-
let previousMin: StatusBarValue | undefined;
|
|
499
|
-
let previousMax: StatusBarValue | undefined;
|
|
500
|
-
let previousValue: StatusBarValue | undefined;
|
|
501
|
-
const subscription = scope.watchEffect(() => {
|
|
502
|
-
const nextMin = readStatusBarBinding(min);
|
|
503
|
-
const nextMax = readStatusBarBinding(max);
|
|
504
|
-
const nextValue = readStatusBarBinding(value);
|
|
505
|
-
if (!nextMin.ok) return nextMin;
|
|
506
|
-
if (!nextMax.ok) return nextMax;
|
|
507
|
-
if (!nextValue.ok) return nextValue;
|
|
508
|
-
|
|
509
|
-
// Compare plain numbers and wrapper identities only. The payload reaches native setters directly.
|
|
510
|
-
const boundsChanged = previousMin !== nextMin.value || previousMax !== nextMax.value;
|
|
511
|
-
if (boundsChanged) bar.SetMinMaxValues(unwrapStatusBarValue(nextMin.value), unwrapStatusBarValue(nextMax.value));
|
|
512
|
-
if (boundsChanged || previousValue !== nextValue.value) {
|
|
513
|
-
bar.SetValue(unwrapStatusBarValue(nextValue.value), interpolation);
|
|
514
|
-
}
|
|
515
|
-
previousMin = nextMin.value;
|
|
516
|
-
previousMax = nextMax.value;
|
|
517
|
-
previousValue = nextValue.value;
|
|
518
|
-
});
|
|
519
|
-
return subscription.ok ? undefined : subscription;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
484
|
function onlyChild(node: Element<"transition">) {
|
|
523
485
|
const children = node.children as NativeChildren;
|
|
524
486
|
return children.length === 1 ? children[0] : undefined;
|
|
@@ -552,7 +514,7 @@ function mountPortal(parent: Frame, node: Element<"portal">, scope: RuntimeScope
|
|
|
552
514
|
function bindRegionEvents(parent: Frame, region: Region, props: Element<"text" | "image" | "texture">["props"],
|
|
553
515
|
scope: RuntimeScope, options: MountOptions, logical: LogicalNode, paint?: NativePaintState) {
|
|
554
516
|
if (!hasElementInput(props) && paint?.needs("hover") !== true && paint?.needs("active") !== true) return;
|
|
555
|
-
if (options.regionsOnly
|
|
517
|
+
if (options.regionsOnly) return fail("Native region mounts do not create input frames");
|
|
556
518
|
const input = createFrame("Frame", undefined, parent);
|
|
557
519
|
input.SetAllPoints(region);
|
|
558
520
|
logical.hitTarget = input;
|
|
@@ -613,7 +575,7 @@ function bindControlPaint(frame: Frame, style: Layout["style"], paint: NativePai
|
|
|
613
575
|
|
|
614
576
|
function bindRegionPaint(parent: Frame, region: Region, style: Layout["style"], paint: NativePaintState | undefined, scope: RuntimeScope,
|
|
615
577
|
options: MountOptions, motion?: TransitionOptions, environment?: StyleEnvironment, liveStyle?: ReadCssStyle, color?: NativeStateColor) {
|
|
616
|
-
if (options.regionsOnly
|
|
578
|
+
if (options.regionsOnly && (style?.border !== undefined || style?.backgroundColor !== undefined
|
|
617
579
|
|| style?.backgroundImage !== undefined || paint?.usesBackgroundColor === true || paint?.usesBackgroundImage === true)) {
|
|
618
580
|
return fail("Native region mounts use region tint for paint, without a separate CSS surface");
|
|
619
581
|
}
|
|
@@ -760,6 +722,37 @@ function bindSkinCaption(caption: FontString, label: string, style: StyleClass,
|
|
|
760
722
|
|
|
761
723
|
const protectedCombatView = fail("Combat-updating views require owned, unprotected JSX");
|
|
762
724
|
|
|
725
|
+
function mountViewChildren(children: NativeChildren, scope: RuntimeScope, stages: InitialViewStages | undefined,
|
|
726
|
+
mount: (this: void, child: UIElement) => Failure | undefined, finish?: Job): Failure | undefined {
|
|
727
|
+
if (stages?.accepts() === true && children.length > 0) {
|
|
728
|
+
if (finish !== undefined) stages.push(scope, finish);
|
|
729
|
+
for (let index = children.length - 1; index >= 0; index--) {
|
|
730
|
+
const child = children[index];
|
|
731
|
+
stages.push(scope, () => mount(child));
|
|
732
|
+
}
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
for (const child of children) {
|
|
736
|
+
const failure = mount(child);
|
|
737
|
+
if (failure !== undefined) return failure;
|
|
738
|
+
}
|
|
739
|
+
return finish?.() ?? undefined;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function atomicMount(options: MountOptions): MountOptions {
|
|
743
|
+
return options.initialStages === undefined ? options : { ...options as OwnedRecord<MountOptions>, initialStages: undefined };
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function keyedRowMount(node: Element<"keyedList">, options: MountOptions) {
|
|
747
|
+
const atomic = atomicMount(options);
|
|
748
|
+
let stageFirst = node.props.stageFirstRow === true;
|
|
749
|
+
return () => {
|
|
750
|
+
const selected = stageFirst ? options : atomic;
|
|
751
|
+
stageFirst = false;
|
|
752
|
+
return selected;
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
|
|
763
756
|
function mountFrame(frame: Frame, parent: FrameParent, node: Element<"frame">, scope: RuntimeScope,
|
|
764
757
|
options: MountOptions, group: LogicalGroup, motion?: TransitionOptions, environment?: StyleEnvironment, skipStyleLevel = false,
|
|
765
758
|
flow?: NativeLayoutGroup, typography?: NativeTextStyle, liveStyle?: ReadCssStyle, unanchored = false): Failure | undefined {
|
|
@@ -799,13 +792,11 @@ function mountFrame(frame: Frame, parent: FrameParent, node: Element<"frame">, s
|
|
|
799
792
|
if (layers !== undefined) return layers;
|
|
800
793
|
}
|
|
801
794
|
const childOptions = container && options.media !== undefined ? { ...options as OwnedRecord<MountOptions>, mediaContainer: frame } : options;
|
|
802
|
-
|
|
803
|
-
const failure = mountChild(childParent, child, scope, childOptions, logical, undefined, environment, childrenLayout, appearance);
|
|
804
|
-
if (failure) return failure;
|
|
805
|
-
}
|
|
806
|
-
return attachRef(scope, node.props.ref, frame)
|
|
795
|
+
const finish = () => attachRef(scope, node.props.ref, frame)
|
|
807
796
|
?? bindElementEvents(frame, node.props, scope, options.newEventScope, options.elementEvents, undefined, false, logical, paint)
|
|
808
797
|
?? finishViewNode(scope, logical, node.props.nodeRef);
|
|
798
|
+
return mountViewChildren(node.children as NativeChildren, scope, options.initialStages,
|
|
799
|
+
child => mountChild(childParent, child, scope, childOptions, logical, undefined, environment, childrenLayout, appearance), finish);
|
|
809
800
|
}
|
|
810
801
|
|
|
811
802
|
function imageFillsAxis(length: NativeStyle["width"], start: NativeStyle["left"], end: NativeStyle["right"]): boolean {
|
|
@@ -978,8 +969,9 @@ function mountButtonContent(button: FrameMap["Button"], node: Element<"button">,
|
|
|
978
969
|
buttonTiming: ButtonPaintTiming | undefined, flow?: NativeLayoutGroup): Failure | undefined {
|
|
979
970
|
const appearance = inheritTextStyle(typography, node.props.style, environment, paint, undefined, liveStyle,
|
|
980
971
|
options.inheritedTextColorDuration, buttonTiming);
|
|
972
|
+
const childOptions = atomicMount(options);
|
|
981
973
|
for (const child of node.children as NativeChildren) {
|
|
982
|
-
const failure = mountChild(button, child, scope,
|
|
974
|
+
const failure = mountChild(button, child, scope, childOptions, group, undefined, environment, flow, appearance);
|
|
983
975
|
if (failure) return failure;
|
|
984
976
|
}
|
|
985
977
|
const label = paint?.usesColor === true ? button.GetFontString() : undefined;
|
|
@@ -993,9 +985,12 @@ function mountButton(parent: Frame, node: Element<"button">, scope: RuntimeScope
|
|
|
993
985
|
typography: NativeTextStyle | undefined, rootControl: { unanchored?: boolean; attach(this: void, frame: Frame): void } | undefined,
|
|
994
986
|
liveStyle: ReadCssStyle | undefined, manualControl: ManualControlBindings | undefined): Failure | undefined {
|
|
995
987
|
const { value, unstyled, disabled, checked } = node.props;
|
|
996
|
-
const { secureAction, secureMacro, onReceiveDrag } = node.props;
|
|
997
|
-
if (secureAction !== undefined && secureMacro !== undefined
|
|
998
|
-
|
|
988
|
+
const { secureAction, secureMacro, secureUnit, secureUnitMenu, onReceiveDrag } = node.props;
|
|
989
|
+
if (secureAction !== undefined && (secureMacro !== undefined || secureUnit !== undefined)
|
|
990
|
+
|| secureMacro !== undefined && secureUnit !== undefined) return fail("A button can have only one secure action");
|
|
991
|
+
if (secureUnit !== undefined && node.props.shown !== undefined) return fail("A secure unit button owns its visibility");
|
|
992
|
+
if (secureUnitMenu === true && secureUnit === undefined) return fail("A secure unit menu needs secureUnit");
|
|
993
|
+
const secure = secureAction !== undefined || secureMacro !== undefined || secureUnit !== undefined;
|
|
999
994
|
if (secure && !unlockedActionSlot()) return fail("Secure action buttons must mount outside combat");
|
|
1000
995
|
const plain = unstyled === true || secure;
|
|
1001
996
|
const factory = plain ? undefined : options?.createButton;
|
|
@@ -1058,7 +1053,7 @@ function mountButton(parent: Frame, node: Element<"button">, scope: RuntimeScope
|
|
|
1058
1053
|
const logical = mountViewNode(scope, group, "button", button, node.props);
|
|
1059
1054
|
const action = secureAction !== undefined ? bindSecureAction(button, scope, secureAction, onReceiveDrag)
|
|
1060
1055
|
: secureMacro !== undefined ? bindSecureMacro(button, scope, secureMacro) ?? listenForDrop(button, scope, onReceiveDrag)
|
|
1061
|
-
: listenForDrop(button, scope, onReceiveDrag);
|
|
1056
|
+
: secureUnit !== undefined ? bindSecureUnit(button, scope, secureUnit, secureUnitMenu === true) : listenForDrop(button, scope, onReceiveDrag);
|
|
1062
1057
|
if (action !== undefined) return action;
|
|
1063
1058
|
const move = bindButtonMove(button, scope, node.props);
|
|
1064
1059
|
if (move !== undefined) return move;
|
|
@@ -1206,7 +1201,7 @@ function mountEditBox(parent: Frame, node: Element<"editbox">, scope: RuntimeSco
|
|
|
1206
1201
|
edit.ClearFocus();
|
|
1207
1202
|
});
|
|
1208
1203
|
if (ref) {
|
|
1209
|
-
ref({
|
|
1204
|
+
const attached = attachViewRef(scope, ref, () => ({
|
|
1210
1205
|
focus: () => {
|
|
1211
1206
|
if (!scope.isActive() || !enabled || reveal(edit.IsVisible()) !== true) return false;
|
|
1212
1207
|
edit.SetFocus();
|
|
@@ -1215,8 +1210,8 @@ function mountEditBox(parent: Frame, node: Element<"editbox">, scope: RuntimeSco
|
|
|
1215
1210
|
blur: () => {
|
|
1216
1211
|
if (scope.isActive()) edit.ClearFocus();
|
|
1217
1212
|
},
|
|
1218
|
-
});
|
|
1219
|
-
|
|
1213
|
+
}));
|
|
1214
|
+
if (attached !== undefined) return attached;
|
|
1220
1215
|
}
|
|
1221
1216
|
if (node.props.nativeImageLayers !== undefined) {
|
|
1222
1217
|
const layers = mountImageLayers(edit, scope, node.props.nativeImageLayers);
|
|
@@ -1261,7 +1256,7 @@ function mountEditBox(parent: Frame, node: Element<"editbox">, scope: RuntimeSco
|
|
|
1261
1256
|
function rejectProtectedElement(node: UIElement, options: NativeViewOptions | undefined): Failure | undefined {
|
|
1262
1257
|
if (options?.unprotectedOnly !== true) return;
|
|
1263
1258
|
if (node.kind === "slot" || node.kind === "portal" || node.kind === "frame" && node.props.secureStateHandler === true
|
|
1264
|
-
|| node.kind === "button" && (node.props.secureAction !== undefined || node.props.secureMacro !== undefined
|
|
1259
|
+
|| node.kind === "button" && (node.props.secureAction !== undefined || node.props.secureMacro !== undefined || node.props.secureUnit !== undefined
|
|
1265
1260
|
|| options.createButton !== undefined && node.props.unstyled !== true)
|
|
1266
1261
|
|| node.kind === "scrollview" && options.scrollArea !== undefined) {
|
|
1267
1262
|
return protectedCombatView;
|
|
@@ -1329,15 +1324,13 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1329
1324
|
}
|
|
1330
1325
|
switch (node.kind) {
|
|
1331
1326
|
case "fragment": {
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
if (failure) return failure;
|
|
1335
|
-
}
|
|
1336
|
-
return;
|
|
1327
|
+
return mountViewChildren(node.children as NativeChildren, scope, options.initialStages,
|
|
1328
|
+
child => mountChild(parent, child, scope, options, group, motion, environment, flow, typography));
|
|
1337
1329
|
}
|
|
1338
1330
|
case "keyedList": {
|
|
1339
1331
|
const list = mountLogicalGroup(scope, group);
|
|
1340
1332
|
if (flow !== undefined) return mountLayoutRows(parent, node, scope, flow, options, list, motion, environment, typography);
|
|
1333
|
+
const rowOptions = keyedRowMount(node, options);
|
|
1341
1334
|
return node.props.mount(scope, {
|
|
1342
1335
|
mount: (tree, rowScope) => {
|
|
1343
1336
|
const row = createFrame("Frame", undefined, parent);
|
|
@@ -1345,7 +1338,7 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1345
1338
|
row.Hide();
|
|
1346
1339
|
rowScope.onDispose(() => row.Hide());
|
|
1347
1340
|
row.SetAllPoints(parent);
|
|
1348
|
-
const failure = mountChild(row, tree, rowScope,
|
|
1341
|
+
const failure = mountChild(row, tree, rowScope, rowOptions(), rowGroup, motion, environment, undefined, typography);
|
|
1349
1342
|
return failure ?? ok({ frame: row, logical: rowGroup });
|
|
1350
1343
|
},
|
|
1351
1344
|
order: rows => {
|
|
@@ -1362,7 +1355,9 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1362
1355
|
case "portal":
|
|
1363
1356
|
return mountPortal(parent, node, scope, options, group, environment, typography);
|
|
1364
1357
|
case "frame": {
|
|
1365
|
-
|
|
1358
|
+
if (node.props.nativeAuraFollower === true && node.props.secureStateHandler === true) return fail("Aura followers are render-only frames");
|
|
1359
|
+
const frame = node.props.nativeAuraFollower === true ? createAuraFollowerFrame(parent)
|
|
1360
|
+
: createFrame("Frame", undefined, parent, node.props.secureStateHandler === true ? "SecureHandlerStateTemplate" : undefined);
|
|
1366
1361
|
rootControl?.attach(frame);
|
|
1367
1362
|
return bindFrameScale(frame, scope, node.props.nativeScale)
|
|
1368
1363
|
?? mountFrame(frame, parent, node, scope, options, group, motion, environment, false, flow, typography, liveStyle);
|
|
@@ -1375,7 +1370,8 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1375
1370
|
if (failure) return failure;
|
|
1376
1371
|
const logical = mountViewNode(scope, group, "scrollview", scroll.frame, node.props);
|
|
1377
1372
|
const appearance = inheritTextStyle(typography, node.props.style, environment, paint, undefined, liveStyle);
|
|
1378
|
-
const
|
|
1373
|
+
const atomic = atomicMount(options);
|
|
1374
|
+
const childOptions = atomic.media === undefined ? atomic : { ...atomic as OwnedRecord<MountOptions>, mediaContainer: scroll.frame };
|
|
1379
1375
|
for (const child of node.children as NativeChildren) {
|
|
1380
1376
|
const failed = mountChild(scroll.content, child, scope, childOptions, logical, undefined, environment, undefined, appearance);
|
|
1381
1377
|
if (failed) return failed;
|
|
@@ -1413,7 +1409,7 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1413
1409
|
if (placed) return placed;
|
|
1414
1410
|
const logical = mountViewNode(scope, group, "statusbar", bar, node.props);
|
|
1415
1411
|
options?.statusbar?.(bar, node.props, scope);
|
|
1416
|
-
return bindStatusBar(scope, bar, node.props)
|
|
1412
|
+
return bindStatusBar(scope, bar, node.props, options.reduceMotion)
|
|
1417
1413
|
?? bindNativeTint(scope, style, paint, options, (r, g, b, a) => bar.SetStatusBarColor(r, g, b, a),
|
|
1418
1414
|
() => captureStatusBarTint(bar), motion, environment, liveStyle)
|
|
1419
1415
|
?? bindFramePaint(bar, style, paint, scope, options, motion, environment, liveStyle)
|
|
@@ -1497,7 +1493,7 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1497
1493
|
?? finishViewNode(scope, logical, node.props.nodeRef);
|
|
1498
1494
|
}
|
|
1499
1495
|
case "range": {
|
|
1500
|
-
const { value, disabled, label, hideLabel, min, max, step = 1, onChange, onCommit } = node.props;
|
|
1496
|
+
const { value, disabled, label, hideLabel, min, max, step = 1, onChange, onCommit, onCancel } = node.props;
|
|
1501
1497
|
if (!Number.isFinite(min) || !Number.isFinite(max) || !Number.isFinite(step) || max <= min || step <= 0) {
|
|
1502
1498
|
return fail("Invalid slider range");
|
|
1503
1499
|
}
|
|
@@ -1512,6 +1508,12 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1512
1508
|
caption.SetText(label);
|
|
1513
1509
|
}
|
|
1514
1510
|
let current = min;
|
|
1511
|
+
let changedByPointer = false;
|
|
1512
|
+
function cancelAdjustment(this: void) {
|
|
1513
|
+
if (!changedByPointer) return;
|
|
1514
|
+
changedByPointer = false;
|
|
1515
|
+
onCancel?.();
|
|
1516
|
+
}
|
|
1515
1517
|
const paint = createNativePaintState(node.props.style, environment);
|
|
1516
1518
|
const failure = placeFrame(slider, parent, node.props, scope, motion, false, flow, paint) ?? bind(scope, value, next => {
|
|
1517
1519
|
if (isSecret(next) || !Number.isFinite(next)) return;
|
|
@@ -1521,15 +1523,19 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1521
1523
|
if (isSecret(next)) return;
|
|
1522
1524
|
const enabled = !next && onChange !== undefined;
|
|
1523
1525
|
slider.SetEnabled(enabled);
|
|
1526
|
+
if (!enabled) cancelAdjustment();
|
|
1524
1527
|
paint?.set("disabled", !enabled);
|
|
1525
1528
|
});
|
|
1526
1529
|
if (failure) return failure;
|
|
1527
1530
|
if (rangeSkin !== undefined) hideStockControlArt(slider, caption);
|
|
1528
1531
|
if (caption !== undefined) options.range?.(slider, caption, node.props, scope);
|
|
1529
|
-
|
|
1532
|
+
if (onCommit !== undefined || onCancel !== undefined) {
|
|
1533
|
+
const hidden = hookScript(slider, "OnHide", cancelAdjustment, scope);
|
|
1534
|
+
if (!hidden.ok) return hidden;
|
|
1535
|
+
}
|
|
1530
1536
|
if (onCommit !== undefined) {
|
|
1531
|
-
const complete = hookScript(slider, "OnMouseUp", () => {
|
|
1532
|
-
if (!changedByPointer) return;
|
|
1537
|
+
const complete = hookScript(slider, "OnMouseUp", (_slider, button) => {
|
|
1538
|
+
if (reveal(button) !== "LeftButton" || !changedByPointer) return;
|
|
1533
1539
|
changedByPointer = false;
|
|
1534
1540
|
onCommit();
|
|
1535
1541
|
}, scope);
|
|
@@ -1537,11 +1543,11 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1537
1543
|
}
|
|
1538
1544
|
if (onChange !== undefined) {
|
|
1539
1545
|
slider.SetScript("OnValueChanged", (_, raw, userInput) => {
|
|
1540
|
-
if (!userInput || !scope.isActive()) return;
|
|
1546
|
+
if (!userInput || !scope.isActive() || reveal(slider.IsEnabled()) !== true) return;
|
|
1541
1547
|
const next = reveal(raw);
|
|
1542
1548
|
if (next === undefined || next === current) return;
|
|
1543
1549
|
slider.SetValue(current, false);
|
|
1544
|
-
changedByPointer = onCommit !== undefined;
|
|
1550
|
+
changedByPointer = onCommit !== undefined || onCancel !== undefined;
|
|
1545
1551
|
onChange(next);
|
|
1546
1552
|
});
|
|
1547
1553
|
scope.onDispose(() => slider.SetScript("OnValueChanged", undefined));
|
|
@@ -1633,24 +1639,27 @@ function mountLayoutRows(parent: Frame, node: Element<"keyedList">, scope: Runti
|
|
|
1633
1639
|
if (index >= 0) flow.children.splice(index, 1);
|
|
1634
1640
|
flow.enqueue();
|
|
1635
1641
|
});
|
|
1642
|
+
const rowOptions = keyedRowMount(node, options);
|
|
1636
1643
|
return node.props.mount(scope, {
|
|
1637
1644
|
mount: (tree, rowScope): Result<{ item?: NativeLayoutItem; logical: LogicalGroup }> => {
|
|
1638
1645
|
const row = mountLogicalGroup(rowScope, logical, false);
|
|
1646
|
+
const rowMount = rowOptions();
|
|
1639
1647
|
if (tree.kind === "frame" && motion === undefined && isAbsoluteFill(tree.props) && flowContainer(tree.props.style?.display)
|
|
1640
1648
|
&& tree.props.style?.mediaStyles === undefined && tree.props.style?.styleTokens === undefined) {
|
|
1641
|
-
const failure = mountChild(parent, tree, rowScope,
|
|
1649
|
+
const failure = mountChild(parent, tree, rowScope, rowMount, row, motion, environment, undefined, typography, {
|
|
1642
1650
|
attach: frame => { rowScope.onDispose(() => frame.Hide()); },
|
|
1643
1651
|
});
|
|
1644
1652
|
return failure ?? ok({ logical: row });
|
|
1645
1653
|
}
|
|
1646
|
-
if ((tree.kind === "frame" || tree.kind === "button" && tree.props.secureAction === undefined
|
|
1654
|
+
if ((tree.kind === "frame" || tree.kind === "button" && tree.props.secureAction === undefined
|
|
1655
|
+
&& tree.props.secureMacro === undefined && tree.props.secureUnit === undefined)
|
|
1647
1656
|
&& tree.props.directKeyedLayout === true && tree.props.anchor === undefined && tree.props.style?.position !== "absolute"
|
|
1648
1657
|
&& tree.props.style?.mediaStyles === undefined && tree.props.style?.styleTokens === undefined) {
|
|
1649
1658
|
// Keep the item detached until the keyed reconciler publishes its order.
|
|
1650
1659
|
const detached: NativeLayoutGroup = {
|
|
1651
1660
|
children: ownedArray(), enqueue: flow.enqueue, visibility: flow.visibility, textMeasure: flow.textMeasure,
|
|
1652
1661
|
};
|
|
1653
|
-
const failure = mountChild(parent, tree, rowScope,
|
|
1662
|
+
const failure = mountChild(parent, tree, rowScope, rowMount, row, motion, environment, detached, typography);
|
|
1654
1663
|
if (failure !== undefined) return failure;
|
|
1655
1664
|
const item = detached.children[0];
|
|
1656
1665
|
return item instanceof NativeLayoutItem ? ok({ item, logical: row }) : fail("Direct keyed row did not attach to its layout");
|
|
@@ -1660,14 +1669,14 @@ function mountLayoutRows(parent: Frame, node: Element<"keyedList">, scope: Runti
|
|
|
1660
1669
|
if (style && "position" in style && style.position === "absolute") {
|
|
1661
1670
|
frame.SetAllPoints(parent);
|
|
1662
1671
|
rowScope.onDispose(() => frame.Hide());
|
|
1663
|
-
const failure = mountChild(frame, tree, rowScope,
|
|
1672
|
+
const failure = mountChild(frame, tree, rowScope, rowMount, row, motion, environment, undefined, typography);
|
|
1664
1673
|
return failure ?? ok({ logical: row });
|
|
1665
1674
|
}
|
|
1666
1675
|
const gridColumn = style && "gridColumn" in style ? style.gridColumn : undefined;
|
|
1667
1676
|
const item = attachLayoutItem(flow, frame, parent, { style: { display: "flex", flexDirection: "column", gridColumn } },
|
|
1668
1677
|
rowScope, true, undefined, true);
|
|
1669
1678
|
if (!item.ok) return item;
|
|
1670
|
-
const failure = mountChild(frame, tree, rowScope,
|
|
1679
|
+
const failure = mountChild(frame, tree, rowScope, rowMount, row, motion, environment, item.value.group, typography);
|
|
1671
1680
|
return failure ?? ok({ item: item.value, logical: row });
|
|
1672
1681
|
},
|
|
1673
1682
|
order: rows => {
|
|
@@ -1836,49 +1845,36 @@ function isNativeRegionTree(tree: UIElement): boolean {
|
|
|
1836
1845
|
return (tree.kind === "text" || tree.kind === "image" || tree.kind === "texture") && children.length === 0;
|
|
1837
1846
|
}
|
|
1838
1847
|
|
|
1839
|
-
function initialLayoutQueue
|
|
1840
|
-
const
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
};
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
for (let pass = 0; jobs.size > 0; pass++) {
|
|
1849
|
-
if (pass === 16) return fail("Initial native layout did not settle");
|
|
1850
|
-
const pending = [...jobs];
|
|
1851
|
-
for (const job of pending) {
|
|
1852
|
-
// A parent can invalidate a child that has yet to run in this pass.
|
|
1853
|
-
jobs.delete(job);
|
|
1854
|
-
const failure = job();
|
|
1855
|
-
if (failure !== undefined) return failure;
|
|
1856
|
-
}
|
|
1857
|
-
}
|
|
1858
|
-
});
|
|
1859
|
-
staging = false;
|
|
1860
|
-
jobs.clear();
|
|
1861
|
-
return result.ok ? result.value : result;
|
|
1862
|
-
}
|
|
1863
|
-
return { stage, commit };
|
|
1848
|
+
function commitInitialLayout(initial: ReturnType<typeof initialLayoutQueue>) {
|
|
1849
|
+
const result = protect(() => {
|
|
1850
|
+
for (;;) {
|
|
1851
|
+
const step = initial.step();
|
|
1852
|
+
if (step !== true) return step;
|
|
1853
|
+
}
|
|
1854
|
+
});
|
|
1855
|
+
initial.stop();
|
|
1856
|
+
return result.ok ? result.value : result;
|
|
1864
1857
|
}
|
|
1865
1858
|
|
|
1866
1859
|
/** Mount a WoW frame tree, an unstyled control, or scoped regions on a borrowed frame. */
|
|
1867
1860
|
export function mountNative(parent: FrameParent, runtime: Runtime, render: (this: void, scope: RuntimeScope) => UIElement,
|
|
1868
1861
|
options?: NativeViewOptions) {
|
|
1869
|
-
if (options?.unprotectedOnly === true && options.regionsOnly
|
|
1862
|
+
if (options?.unprotectedOnly === true && options.regionsOnly) return fail("Combat-updating views require an owned root");
|
|
1870
1863
|
const requestedLayer = options?.rootLayer;
|
|
1871
1864
|
const checkedLayer = requestedLayer === undefined ? undefined : readRootLayer(requestedLayer);
|
|
1872
1865
|
if (checkedLayer?.ok === false) return checkedLayer;
|
|
1873
1866
|
const layer = checkedLayer?.value;
|
|
1874
1867
|
const scope = runtime.scope();
|
|
1875
1868
|
const manual = options?.bindings === "manual" ? manualBindings(scope) : undefined;
|
|
1876
|
-
const
|
|
1869
|
+
const complete = options?.completeStagedMount;
|
|
1870
|
+
const initial = complete !== undefined || options?.initialLayout === "sync" ? initialLayoutQueue() : undefined;
|
|
1871
|
+
const initialStages = complete === undefined || initial === undefined ? undefined : stageInitialView(scope, initial, complete);
|
|
1877
1872
|
let mountedTree = false;
|
|
1878
1873
|
const result = withReactiveScope(scope, () => {
|
|
1879
1874
|
const mark = markMediaReads();
|
|
1880
1875
|
let tree = attachMediaReads(render(scope), mark);
|
|
1881
|
-
const mountedOptions: MountOptions = { ...options as OwnedRecord<NativeViewOptions> | undefined,
|
|
1876
|
+
const mountedOptions: MountOptions = { ...options as OwnedRecord<NativeViewOptions> | undefined,
|
|
1877
|
+
newEventScope: () => runtime.scope(), stageInitialLayout: initial?.stage, initialStages };
|
|
1882
1878
|
if (manual !== undefined) mountedOptions.manualControl = (owner, nested) => {
|
|
1883
1879
|
const control = manual.control(owner, nested);
|
|
1884
1880
|
if (control === undefined) return;
|
|
@@ -1889,7 +1885,7 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1889
1885
|
} };
|
|
1890
1886
|
};
|
|
1891
1887
|
const owner = manual?.scope ?? scope;
|
|
1892
|
-
if (options?.regionsOnly
|
|
1888
|
+
if (options?.regionsOnly) {
|
|
1893
1889
|
if (layer !== undefined || options.rootScale !== undefined || options.rootBackdrop !== undefined) {
|
|
1894
1890
|
return fail("Native root layer, scale and backdrop require a frame root");
|
|
1895
1891
|
}
|
|
@@ -1970,7 +1966,8 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1970
1966
|
return ok({ frame, dispose: scope.dispose, flushBindings: manual?.flush });
|
|
1971
1967
|
});
|
|
1972
1968
|
let mounted = result.ok ? result.value : result;
|
|
1973
|
-
if (mounted.ok &&
|
|
1969
|
+
if (mounted.ok && initialStages !== undefined) initialStages.start();
|
|
1970
|
+
else if (mounted.ok && initial !== undefined) mounted = commitInitialLayout(initial) ?? mounted;
|
|
1974
1971
|
if (!mounted.ok) protect(scope.dispose);
|
|
1975
1972
|
return mounted;
|
|
1976
1973
|
}
|