@overmvp/kumi 0.3.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/animation/index.ts +4 -0
- package/animation/motion-policy.ts +20 -0
- package/animation/slide.ts +61 -0
- package/animation/spring.ts +75 -0
- package/animation/staggered-reveal.ts +34 -0
- package/builder/css-gradients.mjs +74 -0
- package/builder/css-mask-assets.mjs +52 -0
- package/builder/css-mask-assets.test.mjs +31 -0
- package/builder/css-v1.mjs +73 -22
- package/builder/css-v1.test.mjs +42 -2
- package/builder/module-declarations.mjs +2 -2
- package/builder/module-declarations.test.mjs +4 -2
- package/builder/src/compiler.rs +25 -0
- package/builder/src/lua_upvalues.rs +641 -0
- package/builder/src/main.rs +1 -0
- package/builder/style-modules.mjs +21 -3
- package/builder/style-modules.test.mjs +24 -0
- package/builder/style-states.mjs +6 -4
- package/package.json +1 -1
- package/router/index.ts +1 -0
- package/router/link.tsx +32 -0
- package/router/router-view.ts +5 -3
- package/scripts/addon-build.mjs +17 -2
- package/scripts/addon-project.mjs +22 -11
- package/scripts/kumi-cli.mjs +0 -0
- package/src/bindings.ts +10 -4
- package/src/context.ts +31 -7
- package/src/css-tokens.ts +11 -2
- package/src/css-v1.ts +3 -0
- package/src/elements.ts +20 -1
- package/src/flex-layout.ts +26 -5
- package/src/frame-scheduler.ts +3 -1
- package/src/index.ts +2 -2
- package/src/keyed-list.ts +9 -6
- package/src/module-ui.ts +22 -2
- package/src/module.ts +26 -7
- package/src/reactivity.ts +14 -1
- package/src/style-classes.ts +22 -1
- package/src/style-states.ts +13 -6
- package/state/setup-store.ts +3 -3
- package/templates/addon/.agents/skills/kumi-ui/SKILL.md +1 -1
- package/templates/addon/.claude/skills/kumi-ui/SKILL.md +1 -1
- package/templates/addon/AGENTS.md +1 -1
- package/templates/addon/kumi.config.ts +17 -17
- package/templates/addon/src/app/app.module.ts +3 -5
- package/templates/addon/src/app/layout/{AppWindow.module.scss → AppWindow.module.css} +10 -12
- package/templates/addon/src/modules/greeting/greeting.module.ts +2 -2
- package/templates/addon/src/modules/greeting/ui/{Greeting.module.scss → Greeting.module.css} +9 -11
- package/templates/addon/src/modules/playtime/playtime.module.ts +3 -5
- package/templates/addon/src/modules/playtime/ui/{Playtime.module.scss → Playtime.module.css} +3 -5
- package/templates/addon/src/shared/styles/tokens.css +13 -0
- package/templates/addon/src/shared/ui/{Controls.module.scss → Controls.module.css} +18 -20
- package/utils/format.ts +13 -0
- package/utils/index.ts +1 -1
- package/wow/action-button.ts +26 -1
- package/wow/addon-manifest.ts +2 -0
- package/wow/animation.ts +19 -18
- package/wow/app-ui.ts +150 -31
- 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-background-image.ts +75 -0
- package/wow/css-box.ts +14 -9
- package/wow/css-image-mask.ts +32 -0
- package/wow/css-surfaces.ts +88 -35
- package/wow/element-events.ts +33 -13
- package/wow/frames.ts +2 -0
- package/wow/heal-prediction.ts +2 -4
- package/wow/hooks.ts +17 -0
- package/wow/hotkeys.ts +221 -0
- package/wow/index.ts +11 -6
- package/wow/initial-view.ts +99 -0
- package/wow/layout-view.ts +19 -10
- package/wow/module-replacements.ts +103 -0
- package/wow/native.ts +1 -0
- package/wow/pixel.ts +25 -0
- package/wow/pointer-click.ts +35 -0
- package/wow/protected-view.ts +49 -13
- package/wow/rounded-texture.ts +9 -4
- package/wow/scroll-view.ts +5 -4
- package/wow/state-paint.ts +5 -14
- package/wow/status-bar.ts +65 -0
- package/wow/texture-fill.ts +10 -0
- package/wow/unit-button.ts +25 -4
- package/wow/unit-cast.ts +6 -4
- package/wow/view-nodes.ts +11 -4
- package/wow/view.ts +387 -278
- package/templates/addon/src/shared/styles/_tokens.scss +0 -12
package/wow/view.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Anchor, Binding, 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,18 +13,23 @@ 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";
|
|
20
|
+
import { mountImageMask } from "./css-image-mask";
|
|
19
21
|
import { bindEditTextAlign, bindTextColor, bindTextTypography, createTextContent, inheritTextStyle, type NativeTextHost, type NativeTextStyle } from "./css-text";
|
|
20
22
|
import { hasCssSurface, includeCssBorderPadding, mountCssContent, mountCssSurface } from "./css-box";
|
|
21
23
|
import type { CssSurfaceOptions } from "./css-surfaces";
|
|
22
24
|
import { prepareDropdownArt } from "./dropdown-art";
|
|
23
25
|
import { frameStrata, maximumFrameLevel, type FrameStrata } from "./frame-layer";
|
|
26
|
+
import { addonManifest } from "./addon-manifest";
|
|
24
27
|
import { mountImageLayers } from "./image-layers";
|
|
25
28
|
import { mountScrollView, type CreateScrollArea, type ScrollArea } from "./scroll-view";
|
|
26
29
|
import { bindButtonDrag } from "./button-drag";
|
|
27
|
-
import { bindActionVisibility, bindButtonMove, bindSecureAction, listenForDrop, unlockedActionSlot } from "./action-button";
|
|
30
|
+
import { bindActionVisibility, bindButtonMove, bindSecureAction, bindSecureMacro, listenForDrop, unlockedActionSlot } from "./action-button";
|
|
31
|
+
import { bindSecureUnit } from "./unit-button";
|
|
32
|
+
import { bindStatusBar } from "./status-bar";
|
|
28
33
|
import { bindElementEvents, hasElementInput, type NativeElementEventHost } from "./element-events";
|
|
29
34
|
import { api, isSecret, reveal } from "./native";
|
|
30
35
|
import { hookScript, hookSecureMethod } from "./native-hooks";
|
|
@@ -32,12 +37,13 @@ import { rawField } from "./lua-table";
|
|
|
32
37
|
import { observeContainer, type NativeMediaOptions } from "./media-query";
|
|
33
38
|
import { mountRangeArt } from "./range-art";
|
|
34
39
|
import { protect } from "./protect";
|
|
40
|
+
import { initialLayoutQueue, stageInitialView, type InitialViewStages } from "./initial-view";
|
|
35
41
|
import { animateVisibility } from "./transition";
|
|
36
42
|
import { attachLayoutItem, isAbsoluteFill, mountLayoutRoot, NativeLayoutItem, readLayoutValue, type NativeLayoutDiagnostics, type NativeLayoutGroup, type StageInitialLayout } from "./layout-view";
|
|
37
|
-
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";
|
|
38
44
|
import { bindStatePaint, createNativePaintState, type ButtonPaintTiming, type NativeButtonPaintMotion, type NativePaintState,
|
|
39
45
|
type NativeStateColor, type TextColorStateChange } from "./state-paint";
|
|
40
|
-
import type
|
|
46
|
+
import { isIntrinsicWidth, type FlexNode } from "../src/flex-layout";
|
|
41
47
|
|
|
42
48
|
type Frame = FrameMap["Frame"];
|
|
43
49
|
declare const GameFontNormal: Parameters<FrameMap["EditBox"]["SetFontObject"]>[0];
|
|
@@ -50,7 +56,6 @@ type Layout = Pick<Element<"frame">["props"], "width" | "height" | "fullWidth" |
|
|
|
50
56
|
unanchored?: boolean;
|
|
51
57
|
};
|
|
52
58
|
type StatusBarProps = Element<"statusbar">["props"];
|
|
53
|
-
type NativeStatusBarValue = Parameters<StatusBar["SetValue"]>[0];
|
|
54
59
|
type NativeChildren = OwnedArray<UIElement>;
|
|
55
60
|
const headingSizes = [24, 20, 18, 16, 14, 12] as const;
|
|
56
61
|
|
|
@@ -73,10 +78,7 @@ declare module "../src/elements" {
|
|
|
73
78
|
|
|
74
79
|
/** Pass the mounted handle to the element's ref and clear it when the mount is released. */
|
|
75
80
|
function attachRef<Handle>(scope: RuntimeScope, ref: ((this: void, handle?: Handle) => void) | undefined, handle: Handle): Failure | undefined {
|
|
76
|
-
if (
|
|
77
|
-
const attached = scope.protect(() => ref(handle));
|
|
78
|
-
if (!attached.ok) return attached;
|
|
79
|
-
scope.onDispose(() => ref(undefined));
|
|
81
|
+
if (ref !== undefined) return attachViewRef(scope, ref, () => handle);
|
|
80
82
|
}
|
|
81
83
|
export interface NativeRootLayer {
|
|
82
84
|
readonly strata: FrameStrata;
|
|
@@ -116,6 +118,8 @@ export interface NativeListboxSkin extends NativeControlSkinStyle {
|
|
|
116
118
|
|
|
117
119
|
export interface NativeViewOptions extends NativeTextHost {
|
|
118
120
|
bindings?: "manual";
|
|
121
|
+
/** @internal Keep combat-updating views within their owned, unprotected subtree. */
|
|
122
|
+
unprotectedOnly?: true;
|
|
119
123
|
/** Capture the manual bindings of matching text regions for a targeted flush. Full view flushes still include them. */
|
|
120
124
|
manualTextBindings?: {
|
|
121
125
|
readonly part: string;
|
|
@@ -125,8 +129,10 @@ export interface NativeViewOptions extends NativeTextHost {
|
|
|
125
129
|
layoutDiagnostics?: NativeLayoutDiagnostics;
|
|
126
130
|
/** Complete the newly mounted tree's first CSS layout before returning. Later updates use the frame budget. */
|
|
127
131
|
initialLayout?: "sync";
|
|
128
|
-
/**
|
|
129
|
-
|
|
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";
|
|
130
136
|
/**
|
|
131
137
|
* Apply a strata and optional absolute frame level to the native root at mount time.
|
|
132
138
|
* An explicit level takes precedence over the root's `style.zIndex`.
|
|
@@ -204,6 +210,7 @@ type MountOptions = NativeViewOptions & {
|
|
|
204
210
|
manualControl?(this: void, owner: RuntimeScope, nested: boolean): ManualControlBindings | undefined;
|
|
205
211
|
mediaContainer?: Frame;
|
|
206
212
|
stageInitialLayout?: StageInitialLayout;
|
|
213
|
+
initialStages?: InitialViewStages;
|
|
207
214
|
};
|
|
208
215
|
|
|
209
216
|
interface ManualControlBindings {
|
|
@@ -297,7 +304,20 @@ function placeFrame(frame: Region & Pick<Frame, "SetFrameLevel">, parent: FrameP
|
|
|
297
304
|
return place(frame, parent, props, scope, motion, flex, undefined, undefined, paint, undefined, startAfter, endBefore);
|
|
298
305
|
}
|
|
299
306
|
|
|
300
|
-
function
|
|
307
|
+
function boundSize(scope: RuntimeScope, size: NativeStyle["width"], min: NativeStyle["minWidth"], max: NativeStyle["maxWidth"]): NativeStyle["width"] {
|
|
308
|
+
if (size === undefined || min === undefined && max === undefined) return size;
|
|
309
|
+
return scope.computedResult(() => {
|
|
310
|
+
const requested = readLayoutValue(size);
|
|
311
|
+
if (!requested.ok || typeof requested.value !== "number") return requested.ok ? ok(requested.value ?? "auto") : requested;
|
|
312
|
+
const minimum = readLayoutValue(min);
|
|
313
|
+
if (!minimum.ok) return minimum;
|
|
314
|
+
const maximum = readLayoutValue(max);
|
|
315
|
+
if (!maximum.ok) return maximum;
|
|
316
|
+
return ok(Math.max(minimum.value ?? 0, Math.min(maximum.value ?? Infinity, requested.value)));
|
|
317
|
+
}, "CSS size limits");
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function bindNativeSize(region: Region, scope: RuntimeScope, width: NativeStyle["width"], height: NativeStyle["width"],
|
|
301
321
|
combine: boolean, afterWidth?: (this: void, width: number) => void): Failure | undefined {
|
|
302
322
|
if (combine && afterWidth === undefined && typeof region.SetSize === "function") {
|
|
303
323
|
if (typeof width === "number" && typeof height === "number" && !isSecret(width) && !isSecret(height)
|
|
@@ -342,8 +362,8 @@ function place(region: Region, parent: FrameParent, props: Layout, scope: Runtim
|
|
|
342
362
|
let x = 0, y = 0, motionOffset = 0;
|
|
343
363
|
let opacity = 1, motionAlpha = 1;
|
|
344
364
|
let stateOpacity: number | undefined, lastAlpha: number | undefined;
|
|
345
|
-
const width = props.width ?? props.style?.width;
|
|
346
|
-
const height = props.height ?? props.style?.height;
|
|
365
|
+
const width = boundSize(scope, props.width ?? props.style?.width, props.style?.minWidth, props.style?.maxWidth);
|
|
366
|
+
const height = boundSize(scope, props.height ?? props.style?.height, props.style?.minHeight, props.style?.maxHeight);
|
|
347
367
|
const absoluteOffset = absolute && motion !== undefined ? ref(0) : undefined;
|
|
348
368
|
const baseOpacity = props.opacity ?? props.style?.opacity;
|
|
349
369
|
const drawAlpha = paint?.usesOpacity === true ? (force = false) => {
|
|
@@ -461,47 +481,6 @@ function mountBackground(frame: Frame, color: string | undefined, scope: Runtime
|
|
|
461
481
|
});
|
|
462
482
|
}
|
|
463
483
|
|
|
464
|
-
/** Box a WoW number so application refs can publish it without comparing the number. */
|
|
465
|
-
export function statusBarValue(this: void, value: NativeStatusBarValue): StatusBarValue {
|
|
466
|
-
return { nativeValue: value } as StatusBarValue;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
function readStatusBarBinding(binding: Binding<StatusBarValue>): Result<StatusBarValue> {
|
|
470
|
-
if (typeof binding === "number" || "nativeValue" in binding) return ok(binding);
|
|
471
|
-
const value = binding.value;
|
|
472
|
-
return typeof value === "object" && "ok" in value ? value : ok(value);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
function unwrapStatusBarValue(value: StatusBarValue): NativeStatusBarValue {
|
|
476
|
-
return typeof value === "number" ? value : value.nativeValue as NativeStatusBarValue;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
function bindStatusBar(scope: RuntimeScope, bar: StatusBar, { min, max, value, smooth }: StatusBarProps): Failure | undefined {
|
|
480
|
-
const interpolation = smooth ? api.Enum?.StatusBarInterpolation?.ExponentialEaseOut : undefined;
|
|
481
|
-
let previousMin: StatusBarValue | undefined;
|
|
482
|
-
let previousMax: StatusBarValue | undefined;
|
|
483
|
-
let previousValue: StatusBarValue | undefined;
|
|
484
|
-
const subscription = scope.watchEffect(() => {
|
|
485
|
-
const nextMin = readStatusBarBinding(min);
|
|
486
|
-
const nextMax = readStatusBarBinding(max);
|
|
487
|
-
const nextValue = readStatusBarBinding(value);
|
|
488
|
-
if (!nextMin.ok) return nextMin;
|
|
489
|
-
if (!nextMax.ok) return nextMax;
|
|
490
|
-
if (!nextValue.ok) return nextValue;
|
|
491
|
-
|
|
492
|
-
// Compare plain numbers and wrapper identities only. The payload reaches native setters directly.
|
|
493
|
-
const boundsChanged = previousMin !== nextMin.value || previousMax !== nextMax.value;
|
|
494
|
-
if (boundsChanged) bar.SetMinMaxValues(unwrapStatusBarValue(nextMin.value), unwrapStatusBarValue(nextMax.value));
|
|
495
|
-
if (boundsChanged || previousValue !== nextValue.value) {
|
|
496
|
-
bar.SetValue(unwrapStatusBarValue(nextValue.value), interpolation);
|
|
497
|
-
}
|
|
498
|
-
previousMin = nextMin.value;
|
|
499
|
-
previousMax = nextMax.value;
|
|
500
|
-
previousValue = nextValue.value;
|
|
501
|
-
});
|
|
502
|
-
return subscription.ok ? undefined : subscription;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
484
|
function onlyChild(node: Element<"transition">) {
|
|
506
485
|
const children = node.children as NativeChildren;
|
|
507
486
|
return children.length === 1 ? children[0] : undefined;
|
|
@@ -535,7 +514,7 @@ function mountPortal(parent: Frame, node: Element<"portal">, scope: RuntimeScope
|
|
|
535
514
|
function bindRegionEvents(parent: Frame, region: Region, props: Element<"text" | "image" | "texture">["props"],
|
|
536
515
|
scope: RuntimeScope, options: MountOptions, logical: LogicalNode, paint?: NativePaintState) {
|
|
537
516
|
if (!hasElementInput(props) && paint?.needs("hover") !== true && paint?.needs("active") !== true) return;
|
|
538
|
-
if (options.regionsOnly
|
|
517
|
+
if (options.regionsOnly) return fail("Native region mounts do not create input frames");
|
|
539
518
|
const input = createFrame("Frame", undefined, parent);
|
|
540
519
|
input.SetAllPoints(region);
|
|
541
520
|
logical.hitTarget = input;
|
|
@@ -596,7 +575,7 @@ function bindControlPaint(frame: Frame, style: Layout["style"], paint: NativePai
|
|
|
596
575
|
|
|
597
576
|
function bindRegionPaint(parent: Frame, region: Region, style: Layout["style"], paint: NativePaintState | undefined, scope: RuntimeScope,
|
|
598
577
|
options: MountOptions, motion?: TransitionOptions, environment?: StyleEnvironment, liveStyle?: ReadCssStyle, color?: NativeStateColor) {
|
|
599
|
-
if (options.regionsOnly
|
|
578
|
+
if (options.regionsOnly && (style?.border !== undefined || style?.backgroundColor !== undefined
|
|
600
579
|
|| style?.backgroundImage !== undefined || paint?.usesBackgroundColor === true || paint?.usesBackgroundImage === true)) {
|
|
601
580
|
return fail("Native region mounts use region tint for paint, without a separate CSS surface");
|
|
602
581
|
}
|
|
@@ -741,10 +720,44 @@ function bindSkinCaption(caption: FontString, label: string, style: StyleClass,
|
|
|
741
720
|
?? bindTextColor(caption, scope, appearance?.color, position?.onTextPaint);
|
|
742
721
|
}
|
|
743
722
|
|
|
723
|
+
const protectedCombatView = fail("Combat-updating views require owned, unprotected JSX");
|
|
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
|
+
|
|
744
756
|
function mountFrame(frame: Frame, parent: FrameParent, node: Element<"frame">, scope: RuntimeScope,
|
|
745
757
|
options: MountOptions, group: LogicalGroup, motion?: TransitionOptions, environment?: StyleEnvironment, skipStyleLevel = false,
|
|
746
758
|
flow?: NativeLayoutGroup, typography?: NativeTextStyle, liveStyle?: ReadCssStyle, unanchored = false): Failure | undefined {
|
|
747
759
|
const { style } = node.props;
|
|
760
|
+
if (options.unprotectedOnly === true && options.scrollArea !== undefined && style?.overflow === "scroll") return protectedCombatView;
|
|
748
761
|
const display = style?.display;
|
|
749
762
|
const container = flowContainer(display) && style?.overflow !== "scroll";
|
|
750
763
|
const decorativeBorder = node.props.nativeRoundedArt === true;
|
|
@@ -779,13 +792,11 @@ function mountFrame(frame: Frame, parent: FrameParent, node: Element<"frame">, s
|
|
|
779
792
|
if (layers !== undefined) return layers;
|
|
780
793
|
}
|
|
781
794
|
const childOptions = container && options.media !== undefined ? { ...options as OwnedRecord<MountOptions>, mediaContainer: frame } : options;
|
|
782
|
-
|
|
783
|
-
const failure = mountChild(childParent, child, scope, childOptions, logical, undefined, environment, childrenLayout, appearance);
|
|
784
|
-
if (failure) return failure;
|
|
785
|
-
}
|
|
786
|
-
return attachRef(scope, node.props.ref, frame)
|
|
795
|
+
const finish = () => attachRef(scope, node.props.ref, frame)
|
|
787
796
|
?? bindElementEvents(frame, node.props, scope, options.newEventScope, options.elementEvents, undefined, false, logical, paint)
|
|
788
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);
|
|
789
800
|
}
|
|
790
801
|
|
|
791
802
|
function imageFillsAxis(length: NativeStyle["width"], start: NativeStyle["left"], end: NativeStyle["right"]): boolean {
|
|
@@ -912,6 +923,10 @@ function mountImage(parent: Frame, node: Element<"image"> | Element<"texture">,
|
|
|
912
923
|
} : undefined, undefined, paint);
|
|
913
924
|
if (placed) return placed;
|
|
914
925
|
const logical = mountViewNode(scope, group, "image", texture, node.props);
|
|
926
|
+
if (style?.maskImage !== undefined) {
|
|
927
|
+
const applied = mountImageMask(scope, parent, texture, style.maskImage);
|
|
928
|
+
if (!applied.ok) return applied;
|
|
929
|
+
}
|
|
915
930
|
if (nativeDesaturated !== undefined) {
|
|
916
931
|
const desaturated = bind(scope, nativeDesaturated, value => texture.SetDesaturated(value));
|
|
917
932
|
if (desaturated !== undefined) return desaturated;
|
|
@@ -951,11 +966,12 @@ function hasInteractivePaint(style: NativeStyle | undefined, kind: UIElement["ki
|
|
|
951
966
|
function mountButtonContent(button: FrameMap["Button"], node: Element<"button">, scope: RuntimeScope, options: MountOptions,
|
|
952
967
|
group: LogicalGroup, paint: NativePaintState | undefined, motion: TransitionOptions | undefined,
|
|
953
968
|
environment: StyleEnvironment | undefined, typography: NativeTextStyle | undefined, liveStyle: ReadCssStyle | undefined,
|
|
954
|
-
buttonTiming: ButtonPaintTiming | undefined): Failure | undefined {
|
|
969
|
+
buttonTiming: ButtonPaintTiming | undefined, flow?: NativeLayoutGroup): Failure | undefined {
|
|
955
970
|
const appearance = inheritTextStyle(typography, node.props.style, environment, paint, undefined, liveStyle,
|
|
956
971
|
options.inheritedTextColorDuration, buttonTiming);
|
|
972
|
+
const childOptions = atomicMount(options);
|
|
957
973
|
for (const child of node.children as NativeChildren) {
|
|
958
|
-
const failure = mountChild(button, child, scope,
|
|
974
|
+
const failure = mountChild(button, child, scope, childOptions, group, undefined, environment, flow, appearance);
|
|
959
975
|
if (failure) return failure;
|
|
960
976
|
}
|
|
961
977
|
const label = paint?.usesColor === true ? button.GetFontString() : undefined;
|
|
@@ -969,8 +985,12 @@ function mountButton(parent: Frame, node: Element<"button">, scope: RuntimeScope
|
|
|
969
985
|
typography: NativeTextStyle | undefined, rootControl: { unanchored?: boolean; attach(this: void, frame: Frame): void } | undefined,
|
|
970
986
|
liveStyle: ReadCssStyle | undefined, manualControl: ManualControlBindings | undefined): Failure | undefined {
|
|
971
987
|
const { value, unstyled, disabled, checked } = node.props;
|
|
972
|
-
const { secureAction, onReceiveDrag } = node.props;
|
|
973
|
-
|
|
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;
|
|
974
994
|
if (secure && !unlockedActionSlot()) return fail("Secure action buttons must mount outside combat");
|
|
975
995
|
const plain = unstyled === true || secure;
|
|
976
996
|
const factory = plain ? undefined : options?.createButton;
|
|
@@ -989,9 +1009,27 @@ function mountButton(parent: Frame, node: Element<"button">, scope: RuntimeScope
|
|
|
989
1009
|
const deferred = secure && node.props.deferContentUntilShown === true && node.props.anchor !== undefined
|
|
990
1010
|
&& options.bindings !== "manual" && motion === undefined && node.props.style?.display !== "none" ? node.props.shown : undefined;
|
|
991
1011
|
const unanchored = rootControl?.unanchored === true;
|
|
992
|
-
const
|
|
993
|
-
|
|
994
|
-
|
|
1012
|
+
const width = !secure && node.props.width === undefined ? readLayoutValue(node.props.style?.width) : undefined;
|
|
1013
|
+
if (width?.ok === false) return width;
|
|
1014
|
+
const intrinsic = isIntrinsicWidth(width?.value);
|
|
1015
|
+
const display = node.props.style?.display;
|
|
1016
|
+
const contentFlow = !secure && (node.children as NativeChildren).length > 0 && (intrinsic || flowContainer(display));
|
|
1017
|
+
let geometry: Layout = node.props;
|
|
1018
|
+
if (unanchored || deferred !== undefined) geometry = { ...geometry as OwnedRecord<Layout>, unanchored, shown: deferred === undefined ? node.props.shown : undefined };
|
|
1019
|
+
if (contentFlow && !flowContainer(display)) {
|
|
1020
|
+
geometry = { ...geometry as OwnedRecord<Layout>, style: { ...geometry.style as OwnedRecord<NativeStyle>, display: "flex" } };
|
|
1021
|
+
}
|
|
1022
|
+
if (intrinsic || contentFlow) geometry = includeCssBorderPadding(scope, geometry, liveStyle, node.props.nativeRoundedArt);
|
|
1023
|
+
const measure = intrinsic && !contentFlow ? () => {
|
|
1024
|
+
const label = button.GetFontString();
|
|
1025
|
+
return { width: reveal(label?.GetUnboundedStringWidth()) ?? 0, height: reveal(label?.GetStringHeight()) ?? 0 };
|
|
1026
|
+
} : undefined;
|
|
1027
|
+
const layout = !intrinsic && !contentFlow ? undefined
|
|
1028
|
+
: flow !== undefined && geometry.anchor === undefined && geometry.style?.position !== "absolute"
|
|
1029
|
+
? attachLayoutItem(flow, button, parent, geometry, scope, contentFlow, measure)
|
|
1030
|
+
: mountLayoutRoot(button, parent, geometry, scope, options.layoutDiagnostics, options.stageInitialLayout, measure);
|
|
1031
|
+
if (layout?.ok === false) return layout;
|
|
1032
|
+
const item = layout?.value;
|
|
995
1033
|
const bindFlags = () => (disabled === undefined ? undefined : bind(scope, disabled, next => {
|
|
996
1034
|
if (isSecret(next)) return;
|
|
997
1035
|
button.SetEnabled(!next);
|
|
@@ -1003,21 +1041,26 @@ function mountButton(parent: Frame, node: Element<"button">, scope: RuntimeScope
|
|
|
1003
1041
|
// In a manual paint batch the authored flags must refresh before opacity and color consume them.
|
|
1004
1042
|
const flagsFirst = options.bindings === "manual" || buttonTiming !== undefined;
|
|
1005
1043
|
const failure = (flagsFirst ? bindFlags() : undefined)
|
|
1006
|
-
?? placeFrame(button, parent, geometry, scope, motion, false, flow, paint,
|
|
1044
|
+
?? placeFrame(button, parent, geometry, scope, motion, false, item ?? flow, paint,
|
|
1007
1045
|
startAfter === undefined ? undefined : { kind: "button", target: startAfter })
|
|
1008
|
-
?? (plain ? undefined : bind(scope, value, next =>
|
|
1046
|
+
?? (plain ? undefined : bind(scope, value, next => {
|
|
1047
|
+
button.SetText(next);
|
|
1048
|
+
if (measure !== undefined) item?.group.enqueue();
|
|
1049
|
+
}))
|
|
1009
1050
|
?? (flagsFirst ? undefined : bindFlags());
|
|
1010
1051
|
if (failure) return failure;
|
|
1011
1052
|
if (disabled === undefined && paint?.needs("disabled") === true) paint.set("disabled", reveal(button.IsEnabled()) === false);
|
|
1012
1053
|
const logical = mountViewNode(scope, group, "button", button, node.props);
|
|
1013
|
-
const action = secureAction
|
|
1014
|
-
:
|
|
1054
|
+
const action = secureAction !== undefined ? bindSecureAction(button, scope, secureAction, onReceiveDrag)
|
|
1055
|
+
: secureMacro !== undefined ? bindSecureMacro(button, scope, secureMacro) ?? listenForDrop(button, scope, onReceiveDrag)
|
|
1056
|
+
: secureUnit !== undefined ? bindSecureUnit(button, scope, secureUnit, secureUnitMenu === true) : listenForDrop(button, scope, onReceiveDrag);
|
|
1015
1057
|
if (action !== undefined) return action;
|
|
1016
1058
|
const move = bindButtonMove(button, scope, node.props);
|
|
1017
1059
|
if (move !== undefined) return move;
|
|
1018
1060
|
bindButtonDrag(button, scope, node.props);
|
|
1019
1061
|
const content = deferred === undefined
|
|
1020
|
-
? mountButtonContent(button, node, scope, options, logical, paint, motion, environment, typography, liveStyle, buttonTiming
|
|
1062
|
+
? mountButtonContent(button, node, scope, options, logical, paint, motion, environment, typography, liveStyle, buttonTiming,
|
|
1063
|
+
contentFlow ? item?.group : undefined)
|
|
1021
1064
|
: bindActionVisibility(button, scope, deferred, owner => mountButtonContent(button, node, owner, options,
|
|
1022
1065
|
mountLogicalGroup(owner, logical), paint, motion, environment, typography, liveStyle, buttonTiming));
|
|
1023
1066
|
if (content !== undefined) return content;
|
|
@@ -1033,9 +1076,198 @@ function mountButton(parent: Frame, node: Element<"button">, scope: RuntimeScope
|
|
|
1033
1076
|
?? finishViewNode(scope, logical, node.props.nodeRef);
|
|
1034
1077
|
}
|
|
1035
1078
|
|
|
1079
|
+
function usableCooldown(value: CooldownValue | undefined): value is CooldownValue {
|
|
1080
|
+
if (isSecret(value) || typeof value !== "object" || value === null) return false;
|
|
1081
|
+
const start = reveal(value.start);
|
|
1082
|
+
const duration = reveal(value.duration);
|
|
1083
|
+
const rate = reveal(value.rate);
|
|
1084
|
+
return typeof start === "number" && Number.isFinite(start) && start >= 0
|
|
1085
|
+
&& typeof duration === "number" && Number.isFinite(duration) && duration > 0
|
|
1086
|
+
&& typeof rate === "number" && Number.isFinite(rate) && rate > 0;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
function sameCooldown(previous: CooldownValue | undefined, next: CooldownValue | undefined): boolean {
|
|
1090
|
+
if (!usableCooldown(previous)) return !usableCooldown(next);
|
|
1091
|
+
return usableCooldown(next) && previous.start === next.start && previous.duration === next.duration && previous.rate === next.rate;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
function mountCooldown(parent: Frame, node: Element<"cooldown">, scope: RuntimeScope, motion?: TransitionOptions,
|
|
1095
|
+
environment?: StyleEnvironment, flow?: NativeLayoutGroup): Failure | undefined {
|
|
1096
|
+
const cooldown = createFrame("Cooldown", undefined, parent, "CooldownFrameTemplate");
|
|
1097
|
+
scope.onDispose(() => cooldown.Hide());
|
|
1098
|
+
cooldown.EnableMouse(false);
|
|
1099
|
+
if (node.props.reverse !== undefined) cooldown.SetReverse(node.props.reverse);
|
|
1100
|
+
if (node.props.swipeTexture !== undefined) {
|
|
1101
|
+
cooldown.SetSwipeTexture(node.props.swipeTexture, 1, 1, 1, 1);
|
|
1102
|
+
cooldown.SetDrawEdge(false);
|
|
1103
|
+
cooldown.SetDrawBling(false);
|
|
1104
|
+
cooldown.SetHideCountdownNumbers(true);
|
|
1105
|
+
const color = node.props.style?.color;
|
|
1106
|
+
const tinted = color === undefined ? undefined : bindColor(scope, color, environment, literal => {
|
|
1107
|
+
const rgba = readCssColor(literal);
|
|
1108
|
+
if (rgba !== undefined) cooldown.SetSwipeColor(...rgba);
|
|
1109
|
+
});
|
|
1110
|
+
if (tinted !== undefined) return tinted;
|
|
1111
|
+
}
|
|
1112
|
+
const placed = placeFrame(cooldown, parent, node.props, scope, motion, false, flow);
|
|
1113
|
+
if (placed !== undefined) return placed;
|
|
1114
|
+
return bindValue(scope, node.props.value, timing => {
|
|
1115
|
+
if (usableCooldown(timing)) cooldown.SetCooldown(timing.start, timing.duration, timing.rate);
|
|
1116
|
+
else cooldown.Clear();
|
|
1117
|
+
}, sameCooldown);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
function mountEditBox(parent: Frame, node: Element<"editbox">, scope: RuntimeScope, options: MountOptions, group: LogicalGroup,
|
|
1121
|
+
inputSkin: NativeViewOptions["inputSkin"], styledInput: NativeViewOptions["inputSkin"], skinnedHint: boolean,
|
|
1122
|
+
motion?: TransitionOptions, environment?: StyleEnvironment, flow?: NativeLayoutGroup, liveStyle?: ReadCssStyle,
|
|
1123
|
+
rootControl?: { unanchored?: boolean; attach(this: void, frame: Frame): void }, manualControl?: ManualControlBindings): Failure | undefined {
|
|
1124
|
+
const { style } = node.props;
|
|
1125
|
+
const { value, type, placeholder, unstyled, maxLetters, disabled, onChange, onFocus, onBlur, onEnter, onEscape, ref } = node.props;
|
|
1126
|
+
const edit = createFrame("EditBox", undefined, parent, unstyled ? undefined : "InputBoxTemplate");
|
|
1127
|
+
rootControl?.attach(edit);
|
|
1128
|
+
if (styledInput !== undefined) {
|
|
1129
|
+
for (const raw of [...edit.GetRegions()]) {
|
|
1130
|
+
const region = reveal(raw) as Texture | undefined;
|
|
1131
|
+
if (region !== undefined && reveal(region.GetObjectType()) === "Texture") region.Hide();
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
if (unstyled) edit.SetFontObject(GameFontNormal);
|
|
1135
|
+
const paint = createNativePaintState(node.props.style, environment);
|
|
1136
|
+
const eventPaint = interactiveControlPaint(paint, manualControl?.flush);
|
|
1137
|
+
const geometry = rootControl?.unanchored === true ? { ...node.props as OwnedRecord<typeof node.props>, unanchored: true } : node.props;
|
|
1138
|
+
const placed = placeFrame(edit, parent, geometry, scope, motion, false, flow, paint);
|
|
1139
|
+
if (placed) return placed;
|
|
1140
|
+
edit.SetAutoFocus(false);
|
|
1141
|
+
if (type === "password") edit.SetPassword(true);
|
|
1142
|
+
if (maxLetters !== undefined) edit.SetMaxLetters(maxLetters);
|
|
1143
|
+
const hint = placeholder !== undefined || skinnedHint ? edit.CreateFontString(undefined, "OVERLAY", "GameFontDisableSmall") : undefined;
|
|
1144
|
+
if (hint !== undefined) {
|
|
1145
|
+
if (styledInput?.unstyled !== true || styledInput.caption.position !== "absolute") {
|
|
1146
|
+
hint.SetPoint("LEFT", edit, "LEFT", 5, 0);
|
|
1147
|
+
hint.SetPoint("RIGHT", edit, "RIGHT", -5, 0);
|
|
1148
|
+
hint.SetJustifyH("LEFT");
|
|
1149
|
+
}
|
|
1150
|
+
hint.SetText(placeholder ?? "");
|
|
1151
|
+
}
|
|
1152
|
+
let enabled = true;
|
|
1153
|
+
const bound = bind(scope, value, next => {
|
|
1154
|
+
if (isSecret(next)) return;
|
|
1155
|
+
if (reveal(edit.GetText()) !== next) edit.SetText(next);
|
|
1156
|
+
hint?.SetShown(next === "");
|
|
1157
|
+
}) ?? (disabled === undefined ? undefined : bind(scope, disabled, next => {
|
|
1158
|
+
if (isSecret(next)) return;
|
|
1159
|
+
enabled = !next;
|
|
1160
|
+
edit.SetEnabled(enabled);
|
|
1161
|
+
paint?.set("disabled", next);
|
|
1162
|
+
}));
|
|
1163
|
+
if (bound) return bound;
|
|
1164
|
+
if (onChange !== undefined || hint !== undefined) {
|
|
1165
|
+
edit.SetScript("OnTextChanged", (_, userInput) => {
|
|
1166
|
+
if (!scope.isActive()) return;
|
|
1167
|
+
if (userInput ? !enabled : !skinnedHint) return;
|
|
1168
|
+
const text = reveal(edit.GetText());
|
|
1169
|
+
if (text === undefined) return;
|
|
1170
|
+
hint?.SetShown(text === "");
|
|
1171
|
+
if (userInput) onChange?.(text);
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
const focusPaint = paint?.needs("focus") === true;
|
|
1175
|
+
const nativeFocus = styledInput === undefined ? undefined : edit.GetScript("OnEditFocusGained");
|
|
1176
|
+
const nativeBlur = styledInput === undefined ? undefined : edit.GetScript("OnEditFocusLost");
|
|
1177
|
+
if (onFocus || focusPaint) edit.SetScript("OnEditFocusGained", frame => {
|
|
1178
|
+
nativeFocus?.(frame);
|
|
1179
|
+
if (!enabled || !scope.isActive()) return;
|
|
1180
|
+
if (focusPaint) eventPaint?.set("focus", true);
|
|
1181
|
+
onFocus?.();
|
|
1182
|
+
});
|
|
1183
|
+
if (onBlur || focusPaint) edit.SetScript("OnEditFocusLost", frame => {
|
|
1184
|
+
nativeBlur?.(frame);
|
|
1185
|
+
if (!scope.isActive()) return;
|
|
1186
|
+
if (focusPaint) eventPaint?.set("focus", false);
|
|
1187
|
+
onBlur?.();
|
|
1188
|
+
});
|
|
1189
|
+
if (onEnter) edit.SetScript("OnEnterPressed", () => {
|
|
1190
|
+
if (!enabled || !scope.isActive()) return;
|
|
1191
|
+
const text = reveal(edit.GetText());
|
|
1192
|
+
if (text !== undefined) onEnter(text);
|
|
1193
|
+
});
|
|
1194
|
+
if (onEscape) edit.SetScript("OnEscapePressed", () => { if (enabled && scope.isActive()) onEscape(); });
|
|
1195
|
+
scope.onDispose(() => {
|
|
1196
|
+
edit.SetScript("OnTextChanged", undefined);
|
|
1197
|
+
if (onFocus || focusPaint) edit.SetScript("OnEditFocusGained", nativeFocus);
|
|
1198
|
+
edit.SetScript("OnEditFocusLost", nativeBlur);
|
|
1199
|
+
if (onEnter) edit.SetScript("OnEnterPressed", undefined);
|
|
1200
|
+
if (onEscape) edit.SetScript("OnEscapePressed", undefined);
|
|
1201
|
+
edit.ClearFocus();
|
|
1202
|
+
});
|
|
1203
|
+
if (ref) {
|
|
1204
|
+
const attached = attachViewRef(scope, ref, () => ({
|
|
1205
|
+
focus: () => {
|
|
1206
|
+
if (!scope.isActive() || !enabled || reveal(edit.IsVisible()) !== true) return false;
|
|
1207
|
+
edit.SetFocus();
|
|
1208
|
+
return true;
|
|
1209
|
+
},
|
|
1210
|
+
blur: () => {
|
|
1211
|
+
if (scope.isActive()) edit.ClearFocus();
|
|
1212
|
+
},
|
|
1213
|
+
}));
|
|
1214
|
+
if (attached !== undefined) return attached;
|
|
1215
|
+
}
|
|
1216
|
+
if (node.props.nativeImageLayers !== undefined) {
|
|
1217
|
+
const layers = mountImageLayers(edit, scope, node.props.nativeImageLayers);
|
|
1218
|
+
if (layers !== undefined) return layers;
|
|
1219
|
+
}
|
|
1220
|
+
options?.input?.(edit, node.props, scope, hint);
|
|
1221
|
+
if (styledInput !== undefined) {
|
|
1222
|
+
function syncEnabled() {
|
|
1223
|
+
const actual = reveal(edit.IsEnabled());
|
|
1224
|
+
if (actual === undefined) return;
|
|
1225
|
+
enabled = actual;
|
|
1226
|
+
eventPaint?.set("disabled", !actual);
|
|
1227
|
+
}
|
|
1228
|
+
syncEnabled();
|
|
1229
|
+
const hooked = hookSecureMethod(edit, "SetEnabled", syncEnabled, scope);
|
|
1230
|
+
if (!hooked.ok) return hooked;
|
|
1231
|
+
}
|
|
1232
|
+
if (hint !== undefined && placeholder !== undefined && inputSkin !== undefined) {
|
|
1233
|
+
const styled = bindSkinCaption(hint, placeholder, inputSkin.caption, scope, options, environment,
|
|
1234
|
+
styledInput === undefined ? undefined : { parent: edit });
|
|
1235
|
+
if (styled !== undefined) return styled;
|
|
1236
|
+
}
|
|
1237
|
+
const insets = unstyled || styledInput !== undefined ? bindEditInsets(edit, style?.padding, scope) : undefined;
|
|
1238
|
+
if (insets !== undefined) return insets;
|
|
1239
|
+
const alignment = bindEditTextAlign(edit, scope, style, liveStyle);
|
|
1240
|
+
if (alignment !== undefined) return alignment;
|
|
1241
|
+
const authoredColor = (unstyled || styledInput !== undefined) && (style?.color !== undefined || mediaPaint(style, "color"));
|
|
1242
|
+
const text = paint?.usesColor === true || authoredColor
|
|
1243
|
+
? bindStatePaint(scope, paint, { environment, motion, reduceMotion: options.reduceMotion, liveStyle }, undefined, {
|
|
1244
|
+
fallback: () => ok((liveStyle?.() ?? style)?.color),
|
|
1245
|
+
read: () => edit.GetTextColor(),
|
|
1246
|
+
write: (r, g, b, a) => edit.SetTextColor(r, g, b, a),
|
|
1247
|
+
}) : undefined;
|
|
1248
|
+
return text ?? bindFramePaint(edit, node.props.style, paint, scope, options, motion, environment, liveStyle, undefined,
|
|
1249
|
+
node.props.nativeRoundedArt)
|
|
1250
|
+
?? (eventPaint === undefined ? undefined
|
|
1251
|
+
: bindElementEvents(edit, {}, scope, options.newEventScope, options.elementEvents, undefined, true, undefined,
|
|
1252
|
+
eventPaint, styledInput !== undefined))
|
|
1253
|
+
?? finishViewNode(scope, mountViewNode(scope, group, "editbox", edit, node.props), node.props.nodeRef);
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
function rejectProtectedElement(node: UIElement, options: NativeViewOptions | undefined): Failure | undefined {
|
|
1257
|
+
if (options?.unprotectedOnly !== true) return;
|
|
1258
|
+
if (node.kind === "slot" || node.kind === "portal" || node.kind === "frame" && node.props.secureStateHandler === true
|
|
1259
|
+
|| node.kind === "button" && (node.props.secureAction !== undefined || node.props.secureMacro !== undefined || node.props.secureUnit !== undefined
|
|
1260
|
+
|| options.createButton !== undefined && node.props.unstyled !== true)
|
|
1261
|
+
|| node.kind === "scrollview" && options.scrollArea !== undefined) {
|
|
1262
|
+
return protectedCombatView;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1036
1266
|
function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options: MountOptions, group: LogicalGroup,
|
|
1037
1267
|
motion?: TransitionOptions, inherited?: StyleEnvironment, flow?: NativeLayoutGroup, typography?: NativeTextStyle,
|
|
1038
1268
|
rootControl?: { unanchored?: boolean; attach(this: void, frame: Frame): void }): Failure | undefined {
|
|
1269
|
+
const denied = rejectProtectedElement(node, options);
|
|
1270
|
+
if (denied !== undefined) return denied;
|
|
1039
1271
|
const checkboxSkin = node.kind === "checkbox" ? options.checkboxSkin : undefined;
|
|
1040
1272
|
const rangeSkin = node.kind === "range" ? options.rangeSkin : undefined;
|
|
1041
1273
|
const listboxSkin = node.kind === "listbox" ? options.listboxSkin : undefined;
|
|
@@ -1084,23 +1316,21 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1084
1316
|
node = { ...node as OwnedRecord<typeof node>, props: { ...node.props as OwnedRecord<typeof node.props>, anchor: { point: "TOPLEFT" } } };
|
|
1085
1317
|
}
|
|
1086
1318
|
}
|
|
1087
|
-
if (node.kind !== "frame" && (style?.display === "flex" || style?.display === "grid" || style?.display === "block")) {
|
|
1088
|
-
return fail("Layout containers require a native frame");
|
|
1319
|
+
if (node.kind !== "frame" && node.kind !== "button" && (style?.display === "flex" || style?.display === "grid" || style?.display === "block")) {
|
|
1320
|
+
return fail("Layout containers require a native frame or button");
|
|
1089
1321
|
}
|
|
1090
1322
|
if (node.kind !== "frame" && style?.overflow === "scroll") {
|
|
1091
1323
|
return fail("CSS overflow scroll requires a native frame");
|
|
1092
1324
|
}
|
|
1093
1325
|
switch (node.kind) {
|
|
1094
1326
|
case "fragment": {
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
if (failure) return failure;
|
|
1098
|
-
}
|
|
1099
|
-
return;
|
|
1327
|
+
return mountViewChildren(node.children as NativeChildren, scope, options.initialStages,
|
|
1328
|
+
child => mountChild(parent, child, scope, options, group, motion, environment, flow, typography));
|
|
1100
1329
|
}
|
|
1101
1330
|
case "keyedList": {
|
|
1102
1331
|
const list = mountLogicalGroup(scope, group);
|
|
1103
1332
|
if (flow !== undefined) return mountLayoutRows(parent, node, scope, flow, options, list, motion, environment, typography);
|
|
1333
|
+
const rowOptions = keyedRowMount(node, options);
|
|
1104
1334
|
return node.props.mount(scope, {
|
|
1105
1335
|
mount: (tree, rowScope) => {
|
|
1106
1336
|
const row = createFrame("Frame", undefined, parent);
|
|
@@ -1108,7 +1338,7 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1108
1338
|
row.Hide();
|
|
1109
1339
|
rowScope.onDispose(() => row.Hide());
|
|
1110
1340
|
row.SetAllPoints(parent);
|
|
1111
|
-
const failure = mountChild(row, tree, rowScope,
|
|
1341
|
+
const failure = mountChild(row, tree, rowScope, rowOptions(), rowGroup, motion, environment, undefined, typography);
|
|
1112
1342
|
return failure ?? ok({ frame: row, logical: rowGroup });
|
|
1113
1343
|
},
|
|
1114
1344
|
order: rows => {
|
|
@@ -1125,7 +1355,9 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1125
1355
|
case "portal":
|
|
1126
1356
|
return mountPortal(parent, node, scope, options, group, environment, typography);
|
|
1127
1357
|
case "frame": {
|
|
1128
|
-
|
|
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);
|
|
1129
1361
|
rootControl?.attach(frame);
|
|
1130
1362
|
return bindFrameScale(frame, scope, node.props.nativeScale)
|
|
1131
1363
|
?? mountFrame(frame, parent, node, scope, options, group, motion, environment, false, flow, typography, liveStyle);
|
|
@@ -1138,7 +1370,8 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1138
1370
|
if (failure) return failure;
|
|
1139
1371
|
const logical = mountViewNode(scope, group, "scrollview", scroll.frame, node.props);
|
|
1140
1372
|
const appearance = inheritTextStyle(typography, node.props.style, environment, paint, undefined, liveStyle);
|
|
1141
|
-
const
|
|
1373
|
+
const atomic = atomicMount(options);
|
|
1374
|
+
const childOptions = atomic.media === undefined ? atomic : { ...atomic as OwnedRecord<MountOptions>, mediaContainer: scroll.frame };
|
|
1142
1375
|
for (const child of node.children as NativeChildren) {
|
|
1143
1376
|
const failed = mountChild(scroll.content, child, scope, childOptions, logical, undefined, environment, undefined, appearance);
|
|
1144
1377
|
if (failed) return failed;
|
|
@@ -1165,17 +1398,8 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1165
1398
|
case "image":
|
|
1166
1399
|
case "texture":
|
|
1167
1400
|
return mountImage(parent, node, scope, options, group, motion, environment, flow, typography, liveStyle);
|
|
1168
|
-
case "cooldown":
|
|
1169
|
-
|
|
1170
|
-
scope.onDispose(() => cooldown.Hide());
|
|
1171
|
-
cooldown.EnableMouse(false);
|
|
1172
|
-
const placed = placeFrame(cooldown, parent, node.props, scope, motion, false, flow);
|
|
1173
|
-
if (placed !== undefined) return placed;
|
|
1174
|
-
return bindValue(scope, node.props.value, timing => {
|
|
1175
|
-
if (timing === undefined) cooldown.Clear();
|
|
1176
|
-
else cooldown.SetCooldown(timing.start, timing.duration, timing.rate);
|
|
1177
|
-
}, (before, next) => before?.start === next?.start && before?.duration === next?.duration && before?.rate === next?.rate);
|
|
1178
|
-
}
|
|
1401
|
+
case "cooldown":
|
|
1402
|
+
return mountCooldown(parent, node, scope, motion, environment, flow);
|
|
1179
1403
|
case "statusbar": {
|
|
1180
1404
|
const bar = createFrame("StatusBar", undefined, parent);
|
|
1181
1405
|
scope.onDispose(() => bar.Hide());
|
|
@@ -1185,7 +1409,7 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1185
1409
|
if (placed) return placed;
|
|
1186
1410
|
const logical = mountViewNode(scope, group, "statusbar", bar, node.props);
|
|
1187
1411
|
options?.statusbar?.(bar, node.props, scope);
|
|
1188
|
-
return bindStatusBar(scope, bar, node.props)
|
|
1412
|
+
return bindStatusBar(scope, bar, node.props, options.reduceMotion)
|
|
1189
1413
|
?? bindNativeTint(scope, style, paint, options, (r, g, b, a) => bar.SetStatusBarColor(r, g, b, a),
|
|
1190
1414
|
() => captureStatusBarTint(bar), motion, environment, liveStyle)
|
|
1191
1415
|
?? bindFramePaint(bar, style, paint, scope, options, motion, environment, liveStyle)
|
|
@@ -1195,137 +1419,9 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1195
1419
|
}
|
|
1196
1420
|
case "button":
|
|
1197
1421
|
return mountButton(parent, node, scope, options, group, motion, environment, flow, typography, rootControl, liveStyle, manualControl);
|
|
1198
|
-
case "editbox":
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
rootControl?.attach(edit);
|
|
1202
|
-
if (styledInput !== undefined) {
|
|
1203
|
-
for (const raw of [...edit.GetRegions()]) {
|
|
1204
|
-
const region = reveal(raw) as Texture | undefined;
|
|
1205
|
-
if (region !== undefined && reveal(region.GetObjectType()) === "Texture") region.Hide();
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
if (unstyled) edit.SetFontObject(GameFontNormal);
|
|
1209
|
-
const paint = createNativePaintState(node.props.style, environment);
|
|
1210
|
-
const eventPaint = interactiveControlPaint(paint, manualControl?.flush);
|
|
1211
|
-
const geometry = rootControl?.unanchored === true ? { ...node.props as OwnedRecord<typeof node.props>, unanchored: true } : node.props;
|
|
1212
|
-
const placed = placeFrame(edit, parent, geometry, scope, motion, false, flow, paint);
|
|
1213
|
-
if (placed) return placed;
|
|
1214
|
-
edit.SetAutoFocus(false);
|
|
1215
|
-
if (type === "password") edit.SetPassword(true);
|
|
1216
|
-
if (maxLetters !== undefined) edit.SetMaxLetters(maxLetters);
|
|
1217
|
-
const hint = placeholder !== undefined || skinnedHint ? edit.CreateFontString(undefined, "OVERLAY", "GameFontDisableSmall") : undefined;
|
|
1218
|
-
if (hint !== undefined) {
|
|
1219
|
-
if (styledInput?.unstyled !== true || styledInput.caption.position !== "absolute") {
|
|
1220
|
-
hint.SetPoint("LEFT", edit, "LEFT", 5, 0);
|
|
1221
|
-
hint.SetPoint("RIGHT", edit, "RIGHT", -5, 0);
|
|
1222
|
-
hint.SetJustifyH("LEFT");
|
|
1223
|
-
}
|
|
1224
|
-
hint.SetText(placeholder ?? "");
|
|
1225
|
-
}
|
|
1226
|
-
let enabled = true;
|
|
1227
|
-
const bound = bind(scope, value, next => {
|
|
1228
|
-
if (isSecret(next)) return;
|
|
1229
|
-
if (reveal(edit.GetText()) !== next) edit.SetText(next);
|
|
1230
|
-
hint?.SetShown(next === "");
|
|
1231
|
-
}) ?? (disabled === undefined ? undefined : bind(scope, disabled, next => {
|
|
1232
|
-
if (isSecret(next)) return;
|
|
1233
|
-
enabled = !next;
|
|
1234
|
-
edit.SetEnabled(enabled);
|
|
1235
|
-
paint?.set("disabled", next);
|
|
1236
|
-
}));
|
|
1237
|
-
if (bound) return bound;
|
|
1238
|
-
if (onChange !== undefined || hint !== undefined) {
|
|
1239
|
-
edit.SetScript("OnTextChanged", (_, userInput) => {
|
|
1240
|
-
if (!scope.isActive()) return;
|
|
1241
|
-
if (userInput ? !enabled : !skinnedHint) return;
|
|
1242
|
-
const text = reveal(edit.GetText());
|
|
1243
|
-
if (text === undefined) return;
|
|
1244
|
-
hint?.SetShown(text === "");
|
|
1245
|
-
if (userInput) onChange?.(text);
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
const focusPaint = paint?.needs("focus") === true;
|
|
1249
|
-
const nativeFocus = styledInput === undefined ? undefined : edit.GetScript("OnEditFocusGained");
|
|
1250
|
-
const nativeBlur = styledInput === undefined ? undefined : edit.GetScript("OnEditFocusLost");
|
|
1251
|
-
if (onFocus || focusPaint) edit.SetScript("OnEditFocusGained", frame => {
|
|
1252
|
-
nativeFocus?.(frame);
|
|
1253
|
-
if (!enabled || !scope.isActive()) return;
|
|
1254
|
-
if (focusPaint) eventPaint?.set("focus", true);
|
|
1255
|
-
onFocus?.();
|
|
1256
|
-
});
|
|
1257
|
-
if (onBlur || focusPaint) edit.SetScript("OnEditFocusLost", frame => {
|
|
1258
|
-
nativeBlur?.(frame);
|
|
1259
|
-
if (!scope.isActive()) return;
|
|
1260
|
-
if (focusPaint) eventPaint?.set("focus", false);
|
|
1261
|
-
onBlur?.();
|
|
1262
|
-
});
|
|
1263
|
-
if (onEnter) edit.SetScript("OnEnterPressed", () => {
|
|
1264
|
-
if (!enabled || !scope.isActive()) return;
|
|
1265
|
-
const text = reveal(edit.GetText());
|
|
1266
|
-
if (text !== undefined) onEnter(text);
|
|
1267
|
-
});
|
|
1268
|
-
if (onEscape) edit.SetScript("OnEscapePressed", () => { if (enabled && scope.isActive()) onEscape(); });
|
|
1269
|
-
scope.onDispose(() => {
|
|
1270
|
-
edit.SetScript("OnTextChanged", undefined);
|
|
1271
|
-
if (onFocus || focusPaint) edit.SetScript("OnEditFocusGained", nativeFocus);
|
|
1272
|
-
edit.SetScript("OnEditFocusLost", nativeBlur);
|
|
1273
|
-
if (onEnter) edit.SetScript("OnEnterPressed", undefined);
|
|
1274
|
-
if (onEscape) edit.SetScript("OnEscapePressed", undefined);
|
|
1275
|
-
edit.ClearFocus();
|
|
1276
|
-
});
|
|
1277
|
-
if (ref) {
|
|
1278
|
-
ref({
|
|
1279
|
-
focus: () => {
|
|
1280
|
-
if (!scope.isActive() || !enabled || reveal(edit.IsVisible()) !== true) return false;
|
|
1281
|
-
edit.SetFocus();
|
|
1282
|
-
return true;
|
|
1283
|
-
},
|
|
1284
|
-
blur: () => {
|
|
1285
|
-
if (scope.isActive()) edit.ClearFocus();
|
|
1286
|
-
},
|
|
1287
|
-
});
|
|
1288
|
-
scope.onDispose(() => ref(undefined));
|
|
1289
|
-
}
|
|
1290
|
-
if (node.props.nativeImageLayers !== undefined) {
|
|
1291
|
-
const layers = mountImageLayers(edit, scope, node.props.nativeImageLayers);
|
|
1292
|
-
if (layers !== undefined) return layers;
|
|
1293
|
-
}
|
|
1294
|
-
options?.input?.(edit, node.props, scope, hint);
|
|
1295
|
-
if (styledInput !== undefined) {
|
|
1296
|
-
function syncEnabled() {
|
|
1297
|
-
const actual = reveal(edit.IsEnabled());
|
|
1298
|
-
if (actual === undefined) return;
|
|
1299
|
-
enabled = actual;
|
|
1300
|
-
eventPaint?.set("disabled", !actual);
|
|
1301
|
-
}
|
|
1302
|
-
syncEnabled();
|
|
1303
|
-
const hooked = hookSecureMethod(edit, "SetEnabled", syncEnabled, scope);
|
|
1304
|
-
if (!hooked.ok) return hooked;
|
|
1305
|
-
}
|
|
1306
|
-
if (hint !== undefined && placeholder !== undefined && inputSkin !== undefined) {
|
|
1307
|
-
const styled = bindSkinCaption(hint, placeholder, inputSkin.caption, scope, options, environment,
|
|
1308
|
-
styledInput === undefined ? undefined : { parent: edit });
|
|
1309
|
-
if (styled !== undefined) return styled;
|
|
1310
|
-
}
|
|
1311
|
-
const insets = unstyled || styledInput !== undefined ? bindEditInsets(edit, style?.padding, scope) : undefined;
|
|
1312
|
-
if (insets !== undefined) return insets;
|
|
1313
|
-
const alignment = bindEditTextAlign(edit, scope, style, liveStyle);
|
|
1314
|
-
if (alignment !== undefined) return alignment;
|
|
1315
|
-
const authoredColor = (unstyled || styledInput !== undefined) && (style?.color !== undefined || mediaPaint(style, "color"));
|
|
1316
|
-
const text = paint?.usesColor === true || authoredColor
|
|
1317
|
-
? bindStatePaint(scope, paint, { environment, motion, reduceMotion: options.reduceMotion, liveStyle }, undefined, {
|
|
1318
|
-
fallback: () => ok((liveStyle?.() ?? style)?.color),
|
|
1319
|
-
read: () => edit.GetTextColor(),
|
|
1320
|
-
write: (r, g, b, a) => edit.SetTextColor(r, g, b, a),
|
|
1321
|
-
}) : undefined;
|
|
1322
|
-
return text ?? bindFramePaint(edit, node.props.style, paint, scope, options, motion, environment, liveStyle, undefined,
|
|
1323
|
-
node.props.nativeRoundedArt)
|
|
1324
|
-
?? (eventPaint === undefined ? undefined
|
|
1325
|
-
: bindElementEvents(edit, {}, scope, options.newEventScope, options.elementEvents, undefined, true, undefined,
|
|
1326
|
-
eventPaint, styledInput !== undefined))
|
|
1327
|
-
?? finishViewNode(scope, mountViewNode(scope, group, "editbox", edit, node.props), node.props.nodeRef);
|
|
1328
|
-
}
|
|
1422
|
+
case "editbox":
|
|
1423
|
+
return mountEditBox(parent, node, scope, options, group, inputSkin, styledInput, skinnedHint, motion, environment, flow,
|
|
1424
|
+
liveStyle, rootControl, manualControl);
|
|
1329
1425
|
case "checkbox": {
|
|
1330
1426
|
const { checked, disabled, label, onChange } = node.props;
|
|
1331
1427
|
const check = createFrame("CheckButton", undefined, parent, "UICheckButtonTemplate");
|
|
@@ -1397,7 +1493,7 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1397
1493
|
?? finishViewNode(scope, logical, node.props.nodeRef);
|
|
1398
1494
|
}
|
|
1399
1495
|
case "range": {
|
|
1400
|
-
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;
|
|
1401
1497
|
if (!Number.isFinite(min) || !Number.isFinite(max) || !Number.isFinite(step) || max <= min || step <= 0) {
|
|
1402
1498
|
return fail("Invalid slider range");
|
|
1403
1499
|
}
|
|
@@ -1412,6 +1508,12 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1412
1508
|
caption.SetText(label);
|
|
1413
1509
|
}
|
|
1414
1510
|
let current = min;
|
|
1511
|
+
let changedByPointer = false;
|
|
1512
|
+
function cancelAdjustment(this: void) {
|
|
1513
|
+
if (!changedByPointer) return;
|
|
1514
|
+
changedByPointer = false;
|
|
1515
|
+
onCancel?.();
|
|
1516
|
+
}
|
|
1415
1517
|
const paint = createNativePaintState(node.props.style, environment);
|
|
1416
1518
|
const failure = placeFrame(slider, parent, node.props, scope, motion, false, flow, paint) ?? bind(scope, value, next => {
|
|
1417
1519
|
if (isSecret(next) || !Number.isFinite(next)) return;
|
|
@@ -1421,15 +1523,19 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1421
1523
|
if (isSecret(next)) return;
|
|
1422
1524
|
const enabled = !next && onChange !== undefined;
|
|
1423
1525
|
slider.SetEnabled(enabled);
|
|
1526
|
+
if (!enabled) cancelAdjustment();
|
|
1424
1527
|
paint?.set("disabled", !enabled);
|
|
1425
1528
|
});
|
|
1426
1529
|
if (failure) return failure;
|
|
1427
1530
|
if (rangeSkin !== undefined) hideStockControlArt(slider, caption);
|
|
1428
1531
|
if (caption !== undefined) options.range?.(slider, caption, node.props, scope);
|
|
1429
|
-
|
|
1532
|
+
if (onCommit !== undefined || onCancel !== undefined) {
|
|
1533
|
+
const hidden = hookScript(slider, "OnHide", cancelAdjustment, scope);
|
|
1534
|
+
if (!hidden.ok) return hidden;
|
|
1535
|
+
}
|
|
1430
1536
|
if (onCommit !== undefined) {
|
|
1431
|
-
const complete = hookScript(slider, "OnMouseUp", () => {
|
|
1432
|
-
if (!changedByPointer) return;
|
|
1537
|
+
const complete = hookScript(slider, "OnMouseUp", (_slider, button) => {
|
|
1538
|
+
if (reveal(button) !== "LeftButton" || !changedByPointer) return;
|
|
1433
1539
|
changedByPointer = false;
|
|
1434
1540
|
onCommit();
|
|
1435
1541
|
}, scope);
|
|
@@ -1437,11 +1543,11 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1437
1543
|
}
|
|
1438
1544
|
if (onChange !== undefined) {
|
|
1439
1545
|
slider.SetScript("OnValueChanged", (_, raw, userInput) => {
|
|
1440
|
-
if (!userInput || !scope.isActive()) return;
|
|
1546
|
+
if (!userInput || !scope.isActive() || reveal(slider.IsEnabled()) !== true) return;
|
|
1441
1547
|
const next = reveal(raw);
|
|
1442
1548
|
if (next === undefined || next === current) return;
|
|
1443
1549
|
slider.SetValue(current, false);
|
|
1444
|
-
changedByPointer = onCommit !== undefined;
|
|
1550
|
+
changedByPointer = onCommit !== undefined || onCancel !== undefined;
|
|
1445
1551
|
onChange(next);
|
|
1446
1552
|
});
|
|
1447
1553
|
scope.onDispose(() => slider.SetScript("OnValueChanged", undefined));
|
|
@@ -1533,24 +1639,27 @@ function mountLayoutRows(parent: Frame, node: Element<"keyedList">, scope: Runti
|
|
|
1533
1639
|
if (index >= 0) flow.children.splice(index, 1);
|
|
1534
1640
|
flow.enqueue();
|
|
1535
1641
|
});
|
|
1642
|
+
const rowOptions = keyedRowMount(node, options);
|
|
1536
1643
|
return node.props.mount(scope, {
|
|
1537
1644
|
mount: (tree, rowScope): Result<{ item?: NativeLayoutItem; logical: LogicalGroup }> => {
|
|
1538
1645
|
const row = mountLogicalGroup(rowScope, logical, false);
|
|
1646
|
+
const rowMount = rowOptions();
|
|
1539
1647
|
if (tree.kind === "frame" && motion === undefined && isAbsoluteFill(tree.props) && flowContainer(tree.props.style?.display)
|
|
1540
1648
|
&& tree.props.style?.mediaStyles === undefined && tree.props.style?.styleTokens === undefined) {
|
|
1541
|
-
const failure = mountChild(parent, tree, rowScope,
|
|
1649
|
+
const failure = mountChild(parent, tree, rowScope, rowMount, row, motion, environment, undefined, typography, {
|
|
1542
1650
|
attach: frame => { rowScope.onDispose(() => frame.Hide()); },
|
|
1543
1651
|
});
|
|
1544
1652
|
return failure ?? ok({ logical: row });
|
|
1545
1653
|
}
|
|
1546
|
-
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)
|
|
1547
1656
|
&& tree.props.directKeyedLayout === true && tree.props.anchor === undefined && tree.props.style?.position !== "absolute"
|
|
1548
1657
|
&& tree.props.style?.mediaStyles === undefined && tree.props.style?.styleTokens === undefined) {
|
|
1549
1658
|
// Keep the item detached until the keyed reconciler publishes its order.
|
|
1550
1659
|
const detached: NativeLayoutGroup = {
|
|
1551
1660
|
children: ownedArray(), enqueue: flow.enqueue, visibility: flow.visibility, textMeasure: flow.textMeasure,
|
|
1552
1661
|
};
|
|
1553
|
-
const failure = mountChild(parent, tree, rowScope,
|
|
1662
|
+
const failure = mountChild(parent, tree, rowScope, rowMount, row, motion, environment, detached, typography);
|
|
1554
1663
|
if (failure !== undefined) return failure;
|
|
1555
1664
|
const item = detached.children[0];
|
|
1556
1665
|
return item instanceof NativeLayoutItem ? ok({ item, logical: row }) : fail("Direct keyed row did not attach to its layout");
|
|
@@ -1560,14 +1669,14 @@ function mountLayoutRows(parent: Frame, node: Element<"keyedList">, scope: Runti
|
|
|
1560
1669
|
if (style && "position" in style && style.position === "absolute") {
|
|
1561
1670
|
frame.SetAllPoints(parent);
|
|
1562
1671
|
rowScope.onDispose(() => frame.Hide());
|
|
1563
|
-
const failure = mountChild(frame, tree, rowScope,
|
|
1672
|
+
const failure = mountChild(frame, tree, rowScope, rowMount, row, motion, environment, undefined, typography);
|
|
1564
1673
|
return failure ?? ok({ logical: row });
|
|
1565
1674
|
}
|
|
1566
1675
|
const gridColumn = style && "gridColumn" in style ? style.gridColumn : undefined;
|
|
1567
1676
|
const item = attachLayoutItem(flow, frame, parent, { style: { display: "flex", flexDirection: "column", gridColumn } },
|
|
1568
1677
|
rowScope, true, undefined, true);
|
|
1569
1678
|
if (!item.ok) return item;
|
|
1570
|
-
const failure = mountChild(frame, tree, rowScope,
|
|
1679
|
+
const failure = mountChild(frame, tree, rowScope, rowMount, row, motion, environment, item.value.group, typography);
|
|
1571
1680
|
return failure ?? ok({ item: item.value, logical: row });
|
|
1572
1681
|
},
|
|
1573
1682
|
order: rows => {
|
|
@@ -1653,7 +1762,7 @@ export function mountNativeRangeArt(this: void, slider: FrameMap["Slider"], owne
|
|
|
1653
1762
|
const bindings = manual?.scope ?? scope;
|
|
1654
1763
|
const result = scope.protect(() => {
|
|
1655
1764
|
const mountedOptions: MountOptions = { ...options as OwnedRecord<NativeRangeArtOptions> | undefined, newEventScope: () => scope.fork() };
|
|
1656
|
-
const theme =
|
|
1765
|
+
const theme = rootStyleEnvironment(options?.theme);
|
|
1657
1766
|
const art = mountRangeArtView(slider, thumbSize, render, bindings, mountedOptions, { scope: bindings }, theme);
|
|
1658
1767
|
if (!art.ok) return art;
|
|
1659
1768
|
const failure = art.value.installThumb();
|
|
@@ -1664,6 +1773,13 @@ export function mountNativeRangeArt(this: void, slider: FrameMap["Slider"], owne
|
|
|
1664
1773
|
return mounted;
|
|
1665
1774
|
}
|
|
1666
1775
|
|
|
1776
|
+
function rootStyleEnvironment(theme?: StyleVariables): StyleEnvironment | undefined {
|
|
1777
|
+
const defaults = addonManifest()?.styleVariables;
|
|
1778
|
+
const variables = defaults === undefined ? theme : theme === undefined ? defaults
|
|
1779
|
+
: { ...defaults as OwnedRecord<StyleVariables>, ...theme as OwnedRecord<StyleVariables> };
|
|
1780
|
+
return extendStyleEnvironment(undefined, variables, isSecret);
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1667
1783
|
function readRootLayer(layer: NativeRootLayer): Result<NativeRootLayer> {
|
|
1668
1784
|
const checked = protect(() => {
|
|
1669
1785
|
if (isSecret(layer) || typeof layer !== "object" || layer === null) return fail("Native root layer is unreadable");
|
|
@@ -1691,22 +1807,24 @@ function unprotected(region: LayerRegion): boolean {
|
|
|
1691
1807
|
return reveal(state) === false;
|
|
1692
1808
|
}
|
|
1693
1809
|
|
|
1694
|
-
function createRootFrame(parent: FrameParent, scope: RuntimeScope, backdrop?: NativeViewOptions["rootBackdrop"]
|
|
1695
|
-
|
|
1696
|
-
|
|
1810
|
+
function createRootFrame(parent: FrameParent, scope: RuntimeScope, backdrop?: NativeViewOptions["rootBackdrop"],
|
|
1811
|
+
secureStateHandler = false): Frame {
|
|
1812
|
+
const template = secureStateHandler ? backdrop === undefined ? "SecureHandlerStateTemplate" : "BackdropTemplate,SecureHandlerStateTemplate"
|
|
1813
|
+
: backdrop === undefined ? undefined : "BackdropTemplate";
|
|
1814
|
+
const frame = createFrame("Frame", backdrop?.name, parent, template);
|
|
1697
1815
|
scope.onDispose(() => frame.Hide());
|
|
1698
1816
|
return frame;
|
|
1699
1817
|
}
|
|
1700
1818
|
|
|
1701
1819
|
function createLayeredRoot(parent: FrameParent, scope: RuntimeScope, { strata, level }: NativeRootLayer,
|
|
1702
|
-
backdrop?: NativeViewOptions["rootBackdrop"]): Result<Frame> {
|
|
1820
|
+
backdrop?: NativeViewOptions["rootBackdrop"], secureStateHandler = false): Result<Frame> {
|
|
1703
1821
|
const created = protect(() => {
|
|
1704
1822
|
if (!accessibleLayerRegion(parent)) return fail("Native root parent is inaccessible");
|
|
1705
1823
|
const inCombat = reveal(api.InCombatLockdown());
|
|
1706
1824
|
if (typeof inCombat !== "boolean") return fail("Combat lockdown is unreadable");
|
|
1707
1825
|
if (inCombat && !unprotected(parent)) return fail("Cannot layer a native root under a protected parent in combat");
|
|
1708
1826
|
|
|
1709
|
-
const frame = createRootFrame(parent, scope, backdrop);
|
|
1827
|
+
const frame = createRootFrame(parent, scope, backdrop, secureStateHandler);
|
|
1710
1828
|
if (!accessibleLayerRegion(frame)) return fail("Native root frame is inaccessible");
|
|
1711
1829
|
if (inCombat && !unprotected(frame)) return fail("Cannot layer a protected native root in combat");
|
|
1712
1830
|
|
|
@@ -1727,48 +1845,36 @@ function isNativeRegionTree(tree: UIElement): boolean {
|
|
|
1727
1845
|
return (tree.kind === "text" || tree.kind === "image" || tree.kind === "texture") && children.length === 0;
|
|
1728
1846
|
}
|
|
1729
1847
|
|
|
1730
|
-
function initialLayoutQueue
|
|
1731
|
-
const
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
};
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
for (let pass = 0; jobs.size > 0; pass++) {
|
|
1740
|
-
if (pass === 16) return fail("Initial native layout did not settle");
|
|
1741
|
-
const pending = [...jobs];
|
|
1742
|
-
for (const job of pending) {
|
|
1743
|
-
// A parent can invalidate a child that has yet to run in this pass.
|
|
1744
|
-
jobs.delete(job);
|
|
1745
|
-
const failure = job();
|
|
1746
|
-
if (failure !== undefined) return failure;
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
});
|
|
1750
|
-
staging = false;
|
|
1751
|
-
jobs.clear();
|
|
1752
|
-
return result.ok ? result.value : result;
|
|
1753
|
-
}
|
|
1754
|
-
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;
|
|
1755
1857
|
}
|
|
1756
1858
|
|
|
1757
1859
|
/** Mount a WoW frame tree, an unstyled control, or scoped regions on a borrowed frame. */
|
|
1758
1860
|
export function mountNative(parent: FrameParent, runtime: Runtime, render: (this: void, scope: RuntimeScope) => UIElement,
|
|
1759
1861
|
options?: NativeViewOptions) {
|
|
1862
|
+
if (options?.unprotectedOnly === true && options.regionsOnly) return fail("Combat-updating views require an owned root");
|
|
1760
1863
|
const requestedLayer = options?.rootLayer;
|
|
1761
1864
|
const checkedLayer = requestedLayer === undefined ? undefined : readRootLayer(requestedLayer);
|
|
1762
1865
|
if (checkedLayer?.ok === false) return checkedLayer;
|
|
1763
1866
|
const layer = checkedLayer?.value;
|
|
1764
1867
|
const scope = runtime.scope();
|
|
1765
1868
|
const manual = options?.bindings === "manual" ? manualBindings(scope) : undefined;
|
|
1766
|
-
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);
|
|
1767
1872
|
let mountedTree = false;
|
|
1768
1873
|
const result = withReactiveScope(scope, () => {
|
|
1769
1874
|
const mark = markMediaReads();
|
|
1770
1875
|
let tree = attachMediaReads(render(scope), mark);
|
|
1771
|
-
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 };
|
|
1772
1878
|
if (manual !== undefined) mountedOptions.manualControl = (owner, nested) => {
|
|
1773
1879
|
const control = manual.control(owner, nested);
|
|
1774
1880
|
if (control === undefined) return;
|
|
@@ -1779,7 +1885,7 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1779
1885
|
} };
|
|
1780
1886
|
};
|
|
1781
1887
|
const owner = manual?.scope ?? scope;
|
|
1782
|
-
if (options?.regionsOnly
|
|
1888
|
+
if (options?.regionsOnly) {
|
|
1783
1889
|
if (layer !== undefined || options.rootScale !== undefined || options.rootBackdrop !== undefined) {
|
|
1784
1890
|
return fail("Native root layer, scale and backdrop require a frame root");
|
|
1785
1891
|
}
|
|
@@ -1789,7 +1895,7 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1789
1895
|
if (typeof frame.CreateTexture !== "function" || typeof frame.CreateFontString !== "function") {
|
|
1790
1896
|
return fail("Native region mounts require a frame parent");
|
|
1791
1897
|
}
|
|
1792
|
-
const theme =
|
|
1898
|
+
const theme = rootStyleEnvironment(options.theme);
|
|
1793
1899
|
const failure = mountChild(frame, tree, owner, mountedOptions, { scope: owner }, undefined, theme);
|
|
1794
1900
|
if (failure !== undefined) return failure;
|
|
1795
1901
|
mountedTree = true;
|
|
@@ -1807,6 +1913,8 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1807
1913
|
if (!child) return fail("A native view must return one root frame");
|
|
1808
1914
|
tree = child;
|
|
1809
1915
|
}
|
|
1916
|
+
const denied = rejectProtectedElement(tree, options);
|
|
1917
|
+
if (denied !== undefined) return denied;
|
|
1810
1918
|
if ((tree.kind === "button" || tree.kind === "editbox") && tree.props.unstyled === true) {
|
|
1811
1919
|
const kind = tree.kind === "button" ? "button" : "edit box";
|
|
1812
1920
|
if (layer !== undefined || options?.rootScale !== undefined) {
|
|
@@ -1815,7 +1923,7 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1815
1923
|
if (options?.rootBackdrop !== undefined) return fail("Native root backdrop requires a frame root");
|
|
1816
1924
|
if (!accessibleLayerRegion(parent)) return fail(`Native root ${kind} requires an accessible frame parent`);
|
|
1817
1925
|
let frame: Frame | undefined;
|
|
1818
|
-
const theme =
|
|
1926
|
+
const theme = rootStyleEnvironment(options?.theme);
|
|
1819
1927
|
const failure = mountChild(parent as Frame, tree, owner, mountedOptions, { scope: owner }, motion, theme, undefined, undefined, {
|
|
1820
1928
|
unanchored: options?.unanchoredRoot,
|
|
1821
1929
|
attach(this: void, control: Frame) {
|
|
@@ -1831,16 +1939,16 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1831
1939
|
if (tree.kind !== "frame") return fail("A native view must return a frame");
|
|
1832
1940
|
let frame: Frame;
|
|
1833
1941
|
if (layer === undefined) {
|
|
1834
|
-
frame = createRootFrame(parent, scope, options?.rootBackdrop);
|
|
1942
|
+
frame = createRootFrame(parent, scope, options?.rootBackdrop, tree.props.secureStateHandler);
|
|
1835
1943
|
} else {
|
|
1836
|
-
const created = createLayeredRoot(parent, scope, layer, options?.rootBackdrop);
|
|
1944
|
+
const created = createLayeredRoot(parent, scope, layer, options?.rootBackdrop, tree.props.secureStateHandler);
|
|
1837
1945
|
if (!created.ok) return created;
|
|
1838
1946
|
frame = created.value;
|
|
1839
1947
|
}
|
|
1840
1948
|
const rootScale = options?.rootScale;
|
|
1841
1949
|
const scaleFailure = bindFrameScale(frame, rootScale === undefined ? owner : scope, rootScale ?? tree.props.nativeScale);
|
|
1842
1950
|
if (scaleFailure !== undefined) return scaleFailure;
|
|
1843
|
-
const theme = extendStyleEnvironment(
|
|
1951
|
+
const theme = extendStyleEnvironment(rootStyleEnvironment(options?.theme), tree.props.cssVars, isSecret);
|
|
1844
1952
|
const media = tree.mediaReads !== undefined || tree.props.style?.mediaStyles !== undefined
|
|
1845
1953
|
? bindViewMedia(tree, owner, mountedOptions) : undefined;
|
|
1846
1954
|
if (media?.ok === false) return media;
|
|
@@ -1858,7 +1966,8 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1858
1966
|
return ok({ frame, dispose: scope.dispose, flushBindings: manual?.flush });
|
|
1859
1967
|
});
|
|
1860
1968
|
let mounted = result.ok ? result.value : result;
|
|
1861
|
-
if (mounted.ok &&
|
|
1969
|
+
if (mounted.ok && initialStages !== undefined) initialStages.start();
|
|
1970
|
+
else if (mounted.ok && initial !== undefined) mounted = commitInitialLayout(initial) ?? mounted;
|
|
1862
1971
|
if (!mounted.ok) protect(scope.dispose);
|
|
1863
1972
|
return mounted;
|
|
1864
1973
|
}
|