@overmvp/kumi 0.3.0 → 0.4.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/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/scripts/addon-build.mjs +15 -2
- package/scripts/addon-project.mjs +22 -11
- 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 +9 -0
- 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 +18 -2
- package/src/module.ts +12 -3
- 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/layout/{AppWindow.module.scss → AppWindow.module.css} +10 -12
- package/templates/addon/src/modules/greeting/ui/{Greeting.module.scss → Greeting.module.css} +9 -11
- 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/wow/action-button.ts +26 -1
- package/wow/addon-manifest.ts +2 -0
- package/wow/animation.ts +3 -14
- package/wow/app-ui.ts +19 -10
- package/wow/css-background-image.ts +75 -0
- package/wow/css-box.ts +7 -5
- package/wow/css-image-mask.ts +32 -0
- package/wow/css-surfaces.ts +78 -31
- package/wow/element-events.ts +33 -13
- package/wow/heal-prediction.ts +2 -4
- package/wow/index.ts +2 -1
- package/wow/layout-view.ts +18 -9
- package/wow/module-replacements.ts +103 -0
- package/wow/pointer-click.ts +35 -0
- package/wow/protected-view.ts +49 -13
- package/wow/rounded-texture.ts +9 -4
- package/wow/state-paint.ts +5 -14
- package/wow/texture-fill.ts +10 -0
- package/wow/unit-cast.ts +6 -4
- package/wow/view.ts +287 -175
- 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, StatusBarValue, StyleClass, TransitionOptions, UIElement } from "../src";
|
|
1
|
+
import type { Anchor, Binding, CooldownValue, Element, Job, NativeStyle, ReadonlyRef, Runtime, RuntimeScope, StatusBarValue, 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";
|
|
@@ -16,15 +16,17 @@ import { bindAbsolutePosition, type NativeEndTarget, type NativeStartTarget, typ
|
|
|
16
16
|
import { bindBorrowedSlot, type BorrowedSlot } from "./borrowed-slot";
|
|
17
17
|
import { prepareCssStyle, type ReadCssStyle } from "./css-style";
|
|
18
18
|
import { readCssColor } from "./css-color";
|
|
19
|
+
import { mountImageMask } from "./css-image-mask";
|
|
19
20
|
import { bindEditTextAlign, bindTextColor, bindTextTypography, createTextContent, inheritTextStyle, type NativeTextHost, type NativeTextStyle } from "./css-text";
|
|
20
21
|
import { hasCssSurface, includeCssBorderPadding, mountCssContent, mountCssSurface } from "./css-box";
|
|
21
22
|
import type { CssSurfaceOptions } from "./css-surfaces";
|
|
22
23
|
import { prepareDropdownArt } from "./dropdown-art";
|
|
23
24
|
import { frameStrata, maximumFrameLevel, type FrameStrata } from "./frame-layer";
|
|
25
|
+
import { addonManifest } from "./addon-manifest";
|
|
24
26
|
import { mountImageLayers } from "./image-layers";
|
|
25
27
|
import { mountScrollView, type CreateScrollArea, type ScrollArea } from "./scroll-view";
|
|
26
28
|
import { bindButtonDrag } from "./button-drag";
|
|
27
|
-
import { bindActionVisibility, bindButtonMove, bindSecureAction, listenForDrop, unlockedActionSlot } from "./action-button";
|
|
29
|
+
import { bindActionVisibility, bindButtonMove, bindSecureAction, bindSecureMacro, listenForDrop, unlockedActionSlot } from "./action-button";
|
|
28
30
|
import { bindElementEvents, hasElementInput, type NativeElementEventHost } from "./element-events";
|
|
29
31
|
import { api, isSecret, reveal } from "./native";
|
|
30
32
|
import { hookScript, hookSecureMethod } from "./native-hooks";
|
|
@@ -37,7 +39,7 @@ import { attachLayoutItem, isAbsoluteFill, mountLayoutRoot, NativeLayoutItem, re
|
|
|
37
39
|
import { finishViewNode, mountLogicalGroup, mountViewNode, orderLogicalRows, type LogicalGroup, type LogicalNode } from "./view-nodes";
|
|
38
40
|
import { bindStatePaint, createNativePaintState, type ButtonPaintTiming, type NativeButtonPaintMotion, type NativePaintState,
|
|
39
41
|
type NativeStateColor, type TextColorStateChange } from "./state-paint";
|
|
40
|
-
import type
|
|
42
|
+
import { isIntrinsicWidth, type FlexNode } from "../src/flex-layout";
|
|
41
43
|
|
|
42
44
|
type Frame = FrameMap["Frame"];
|
|
43
45
|
declare const GameFontNormal: Parameters<FrameMap["EditBox"]["SetFontObject"]>[0];
|
|
@@ -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;
|
|
@@ -297,7 +301,20 @@ function placeFrame(frame: Region & Pick<Frame, "SetFrameLevel">, parent: FrameP
|
|
|
297
301
|
return place(frame, parent, props, scope, motion, flex, undefined, undefined, paint, undefined, startAfter, endBefore);
|
|
298
302
|
}
|
|
299
303
|
|
|
300
|
-
function
|
|
304
|
+
function boundSize(scope: RuntimeScope, size: NativeStyle["width"], min: NativeStyle["minWidth"], max: NativeStyle["maxWidth"]): NativeStyle["width"] {
|
|
305
|
+
if (size === undefined || min === undefined && max === undefined) return size;
|
|
306
|
+
return scope.computedResult(() => {
|
|
307
|
+
const requested = readLayoutValue(size);
|
|
308
|
+
if (!requested.ok || typeof requested.value !== "number") return requested.ok ? ok(requested.value ?? "auto") : requested;
|
|
309
|
+
const minimum = readLayoutValue(min);
|
|
310
|
+
if (!minimum.ok) return minimum;
|
|
311
|
+
const maximum = readLayoutValue(max);
|
|
312
|
+
if (!maximum.ok) return maximum;
|
|
313
|
+
return ok(Math.max(minimum.value ?? 0, Math.min(maximum.value ?? Infinity, requested.value)));
|
|
314
|
+
}, "CSS size limits");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function bindNativeSize(region: Region, scope: RuntimeScope, width: NativeStyle["width"], height: NativeStyle["width"],
|
|
301
318
|
combine: boolean, afterWidth?: (this: void, width: number) => void): Failure | undefined {
|
|
302
319
|
if (combine && afterWidth === undefined && typeof region.SetSize === "function") {
|
|
303
320
|
if (typeof width === "number" && typeof height === "number" && !isSecret(width) && !isSecret(height)
|
|
@@ -342,8 +359,8 @@ function place(region: Region, parent: FrameParent, props: Layout, scope: Runtim
|
|
|
342
359
|
let x = 0, y = 0, motionOffset = 0;
|
|
343
360
|
let opacity = 1, motionAlpha = 1;
|
|
344
361
|
let stateOpacity: number | undefined, lastAlpha: number | undefined;
|
|
345
|
-
const width = props.width ?? props.style?.width;
|
|
346
|
-
const height = props.height ?? props.style?.height;
|
|
362
|
+
const width = boundSize(scope, props.width ?? props.style?.width, props.style?.minWidth, props.style?.maxWidth);
|
|
363
|
+
const height = boundSize(scope, props.height ?? props.style?.height, props.style?.minHeight, props.style?.maxHeight);
|
|
347
364
|
const absoluteOffset = absolute && motion !== undefined ? ref(0) : undefined;
|
|
348
365
|
const baseOpacity = props.opacity ?? props.style?.opacity;
|
|
349
366
|
const drawAlpha = paint?.usesOpacity === true ? (force = false) => {
|
|
@@ -741,10 +758,13 @@ function bindSkinCaption(caption: FontString, label: string, style: StyleClass,
|
|
|
741
758
|
?? bindTextColor(caption, scope, appearance?.color, position?.onTextPaint);
|
|
742
759
|
}
|
|
743
760
|
|
|
761
|
+
const protectedCombatView = fail("Combat-updating views require owned, unprotected JSX");
|
|
762
|
+
|
|
744
763
|
function mountFrame(frame: Frame, parent: FrameParent, node: Element<"frame">, scope: RuntimeScope,
|
|
745
764
|
options: MountOptions, group: LogicalGroup, motion?: TransitionOptions, environment?: StyleEnvironment, skipStyleLevel = false,
|
|
746
765
|
flow?: NativeLayoutGroup, typography?: NativeTextStyle, liveStyle?: ReadCssStyle, unanchored = false): Failure | undefined {
|
|
747
766
|
const { style } = node.props;
|
|
767
|
+
if (options.unprotectedOnly === true && options.scrollArea !== undefined && style?.overflow === "scroll") return protectedCombatView;
|
|
748
768
|
const display = style?.display;
|
|
749
769
|
const container = flowContainer(display) && style?.overflow !== "scroll";
|
|
750
770
|
const decorativeBorder = node.props.nativeRoundedArt === true;
|
|
@@ -912,6 +932,10 @@ function mountImage(parent: Frame, node: Element<"image"> | Element<"texture">,
|
|
|
912
932
|
} : undefined, undefined, paint);
|
|
913
933
|
if (placed) return placed;
|
|
914
934
|
const logical = mountViewNode(scope, group, "image", texture, node.props);
|
|
935
|
+
if (style?.maskImage !== undefined) {
|
|
936
|
+
const applied = mountImageMask(scope, parent, texture, style.maskImage);
|
|
937
|
+
if (!applied.ok) return applied;
|
|
938
|
+
}
|
|
915
939
|
if (nativeDesaturated !== undefined) {
|
|
916
940
|
const desaturated = bind(scope, nativeDesaturated, value => texture.SetDesaturated(value));
|
|
917
941
|
if (desaturated !== undefined) return desaturated;
|
|
@@ -951,11 +975,11 @@ function hasInteractivePaint(style: NativeStyle | undefined, kind: UIElement["ki
|
|
|
951
975
|
function mountButtonContent(button: FrameMap["Button"], node: Element<"button">, scope: RuntimeScope, options: MountOptions,
|
|
952
976
|
group: LogicalGroup, paint: NativePaintState | undefined, motion: TransitionOptions | undefined,
|
|
953
977
|
environment: StyleEnvironment | undefined, typography: NativeTextStyle | undefined, liveStyle: ReadCssStyle | undefined,
|
|
954
|
-
buttonTiming: ButtonPaintTiming | undefined): Failure | undefined {
|
|
978
|
+
buttonTiming: ButtonPaintTiming | undefined, flow?: NativeLayoutGroup): Failure | undefined {
|
|
955
979
|
const appearance = inheritTextStyle(typography, node.props.style, environment, paint, undefined, liveStyle,
|
|
956
980
|
options.inheritedTextColorDuration, buttonTiming);
|
|
957
981
|
for (const child of node.children as NativeChildren) {
|
|
958
|
-
const failure = mountChild(button, child, scope, options, group, undefined, environment,
|
|
982
|
+
const failure = mountChild(button, child, scope, options, group, undefined, environment, flow, appearance);
|
|
959
983
|
if (failure) return failure;
|
|
960
984
|
}
|
|
961
985
|
const label = paint?.usesColor === true ? button.GetFontString() : undefined;
|
|
@@ -969,8 +993,9 @@ function mountButton(parent: Frame, node: Element<"button">, scope: RuntimeScope
|
|
|
969
993
|
typography: NativeTextStyle | undefined, rootControl: { unanchored?: boolean; attach(this: void, frame: Frame): void } | undefined,
|
|
970
994
|
liveStyle: ReadCssStyle | undefined, manualControl: ManualControlBindings | undefined): Failure | undefined {
|
|
971
995
|
const { value, unstyled, disabled, checked } = node.props;
|
|
972
|
-
const { secureAction, onReceiveDrag } = node.props;
|
|
973
|
-
|
|
996
|
+
const { secureAction, secureMacro, onReceiveDrag } = node.props;
|
|
997
|
+
if (secureAction !== undefined && secureMacro !== undefined) return fail("A button can have only one secure action");
|
|
998
|
+
const secure = secureAction !== undefined || secureMacro !== undefined;
|
|
974
999
|
if (secure && !unlockedActionSlot()) return fail("Secure action buttons must mount outside combat");
|
|
975
1000
|
const plain = unstyled === true || secure;
|
|
976
1001
|
const factory = plain ? undefined : options?.createButton;
|
|
@@ -989,9 +1014,27 @@ function mountButton(parent: Frame, node: Element<"button">, scope: RuntimeScope
|
|
|
989
1014
|
const deferred = secure && node.props.deferContentUntilShown === true && node.props.anchor !== undefined
|
|
990
1015
|
&& options.bindings !== "manual" && motion === undefined && node.props.style?.display !== "none" ? node.props.shown : undefined;
|
|
991
1016
|
const unanchored = rootControl?.unanchored === true;
|
|
992
|
-
const
|
|
993
|
-
|
|
994
|
-
|
|
1017
|
+
const width = !secure && node.props.width === undefined ? readLayoutValue(node.props.style?.width) : undefined;
|
|
1018
|
+
if (width?.ok === false) return width;
|
|
1019
|
+
const intrinsic = isIntrinsicWidth(width?.value);
|
|
1020
|
+
const display = node.props.style?.display;
|
|
1021
|
+
const contentFlow = !secure && (node.children as NativeChildren).length > 0 && (intrinsic || flowContainer(display));
|
|
1022
|
+
let geometry: Layout = node.props;
|
|
1023
|
+
if (unanchored || deferred !== undefined) geometry = { ...geometry as OwnedRecord<Layout>, unanchored, shown: deferred === undefined ? node.props.shown : undefined };
|
|
1024
|
+
if (contentFlow && !flowContainer(display)) {
|
|
1025
|
+
geometry = { ...geometry as OwnedRecord<Layout>, style: { ...geometry.style as OwnedRecord<NativeStyle>, display: "flex" } };
|
|
1026
|
+
}
|
|
1027
|
+
if (intrinsic || contentFlow) geometry = includeCssBorderPadding(scope, geometry, liveStyle, node.props.nativeRoundedArt);
|
|
1028
|
+
const measure = intrinsic && !contentFlow ? () => {
|
|
1029
|
+
const label = button.GetFontString();
|
|
1030
|
+
return { width: reveal(label?.GetUnboundedStringWidth()) ?? 0, height: reveal(label?.GetStringHeight()) ?? 0 };
|
|
1031
|
+
} : undefined;
|
|
1032
|
+
const layout = !intrinsic && !contentFlow ? undefined
|
|
1033
|
+
: flow !== undefined && geometry.anchor === undefined && geometry.style?.position !== "absolute"
|
|
1034
|
+
? attachLayoutItem(flow, button, parent, geometry, scope, contentFlow, measure)
|
|
1035
|
+
: mountLayoutRoot(button, parent, geometry, scope, options.layoutDiagnostics, options.stageInitialLayout, measure);
|
|
1036
|
+
if (layout?.ok === false) return layout;
|
|
1037
|
+
const item = layout?.value;
|
|
995
1038
|
const bindFlags = () => (disabled === undefined ? undefined : bind(scope, disabled, next => {
|
|
996
1039
|
if (isSecret(next)) return;
|
|
997
1040
|
button.SetEnabled(!next);
|
|
@@ -1003,21 +1046,26 @@ function mountButton(parent: Frame, node: Element<"button">, scope: RuntimeScope
|
|
|
1003
1046
|
// In a manual paint batch the authored flags must refresh before opacity and color consume them.
|
|
1004
1047
|
const flagsFirst = options.bindings === "manual" || buttonTiming !== undefined;
|
|
1005
1048
|
const failure = (flagsFirst ? bindFlags() : undefined)
|
|
1006
|
-
?? placeFrame(button, parent, geometry, scope, motion, false, flow, paint,
|
|
1049
|
+
?? placeFrame(button, parent, geometry, scope, motion, false, item ?? flow, paint,
|
|
1007
1050
|
startAfter === undefined ? undefined : { kind: "button", target: startAfter })
|
|
1008
|
-
?? (plain ? undefined : bind(scope, value, next =>
|
|
1051
|
+
?? (plain ? undefined : bind(scope, value, next => {
|
|
1052
|
+
button.SetText(next);
|
|
1053
|
+
if (measure !== undefined) item?.group.enqueue();
|
|
1054
|
+
}))
|
|
1009
1055
|
?? (flagsFirst ? undefined : bindFlags());
|
|
1010
1056
|
if (failure) return failure;
|
|
1011
1057
|
if (disabled === undefined && paint?.needs("disabled") === true) paint.set("disabled", reveal(button.IsEnabled()) === false);
|
|
1012
1058
|
const logical = mountViewNode(scope, group, "button", button, node.props);
|
|
1013
|
-
const action = secureAction
|
|
1014
|
-
:
|
|
1059
|
+
const action = secureAction !== undefined ? bindSecureAction(button, scope, secureAction, onReceiveDrag)
|
|
1060
|
+
: secureMacro !== undefined ? bindSecureMacro(button, scope, secureMacro) ?? listenForDrop(button, scope, onReceiveDrag)
|
|
1061
|
+
: listenForDrop(button, scope, onReceiveDrag);
|
|
1015
1062
|
if (action !== undefined) return action;
|
|
1016
1063
|
const move = bindButtonMove(button, scope, node.props);
|
|
1017
1064
|
if (move !== undefined) return move;
|
|
1018
1065
|
bindButtonDrag(button, scope, node.props);
|
|
1019
1066
|
const content = deferred === undefined
|
|
1020
|
-
? mountButtonContent(button, node, scope, options, logical, paint, motion, environment, typography, liveStyle, buttonTiming
|
|
1067
|
+
? mountButtonContent(button, node, scope, options, logical, paint, motion, environment, typography, liveStyle, buttonTiming,
|
|
1068
|
+
contentFlow ? item?.group : undefined)
|
|
1021
1069
|
: bindActionVisibility(button, scope, deferred, owner => mountButtonContent(button, node, owner, options,
|
|
1022
1070
|
mountLogicalGroup(owner, logical), paint, motion, environment, typography, liveStyle, buttonTiming));
|
|
1023
1071
|
if (content !== undefined) return content;
|
|
@@ -1033,9 +1081,198 @@ function mountButton(parent: Frame, node: Element<"button">, scope: RuntimeScope
|
|
|
1033
1081
|
?? finishViewNode(scope, logical, node.props.nodeRef);
|
|
1034
1082
|
}
|
|
1035
1083
|
|
|
1084
|
+
function usableCooldown(value: CooldownValue | undefined): value is CooldownValue {
|
|
1085
|
+
if (isSecret(value) || typeof value !== "object" || value === null) return false;
|
|
1086
|
+
const start = reveal(value.start);
|
|
1087
|
+
const duration = reveal(value.duration);
|
|
1088
|
+
const rate = reveal(value.rate);
|
|
1089
|
+
return typeof start === "number" && Number.isFinite(start) && start >= 0
|
|
1090
|
+
&& typeof duration === "number" && Number.isFinite(duration) && duration > 0
|
|
1091
|
+
&& typeof rate === "number" && Number.isFinite(rate) && rate > 0;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
function sameCooldown(previous: CooldownValue | undefined, next: CooldownValue | undefined): boolean {
|
|
1095
|
+
if (!usableCooldown(previous)) return !usableCooldown(next);
|
|
1096
|
+
return usableCooldown(next) && previous.start === next.start && previous.duration === next.duration && previous.rate === next.rate;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
function mountCooldown(parent: Frame, node: Element<"cooldown">, scope: RuntimeScope, motion?: TransitionOptions,
|
|
1100
|
+
environment?: StyleEnvironment, flow?: NativeLayoutGroup): Failure | undefined {
|
|
1101
|
+
const cooldown = createFrame("Cooldown", undefined, parent, "CooldownFrameTemplate");
|
|
1102
|
+
scope.onDispose(() => cooldown.Hide());
|
|
1103
|
+
cooldown.EnableMouse(false);
|
|
1104
|
+
if (node.props.reverse !== undefined) cooldown.SetReverse(node.props.reverse);
|
|
1105
|
+
if (node.props.swipeTexture !== undefined) {
|
|
1106
|
+
cooldown.SetSwipeTexture(node.props.swipeTexture, 1, 1, 1, 1);
|
|
1107
|
+
cooldown.SetDrawEdge(false);
|
|
1108
|
+
cooldown.SetDrawBling(false);
|
|
1109
|
+
cooldown.SetHideCountdownNumbers(true);
|
|
1110
|
+
const color = node.props.style?.color;
|
|
1111
|
+
const tinted = color === undefined ? undefined : bindColor(scope, color, environment, literal => {
|
|
1112
|
+
const rgba = readCssColor(literal);
|
|
1113
|
+
if (rgba !== undefined) cooldown.SetSwipeColor(...rgba);
|
|
1114
|
+
});
|
|
1115
|
+
if (tinted !== undefined) return tinted;
|
|
1116
|
+
}
|
|
1117
|
+
const placed = placeFrame(cooldown, parent, node.props, scope, motion, false, flow);
|
|
1118
|
+
if (placed !== undefined) return placed;
|
|
1119
|
+
return bindValue(scope, node.props.value, timing => {
|
|
1120
|
+
if (usableCooldown(timing)) cooldown.SetCooldown(timing.start, timing.duration, timing.rate);
|
|
1121
|
+
else cooldown.Clear();
|
|
1122
|
+
}, sameCooldown);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
function mountEditBox(parent: Frame, node: Element<"editbox">, scope: RuntimeScope, options: MountOptions, group: LogicalGroup,
|
|
1126
|
+
inputSkin: NativeViewOptions["inputSkin"], styledInput: NativeViewOptions["inputSkin"], skinnedHint: boolean,
|
|
1127
|
+
motion?: TransitionOptions, environment?: StyleEnvironment, flow?: NativeLayoutGroup, liveStyle?: ReadCssStyle,
|
|
1128
|
+
rootControl?: { unanchored?: boolean; attach(this: void, frame: Frame): void }, manualControl?: ManualControlBindings): Failure | undefined {
|
|
1129
|
+
const { style } = node.props;
|
|
1130
|
+
const { value, type, placeholder, unstyled, maxLetters, disabled, onChange, onFocus, onBlur, onEnter, onEscape, ref } = node.props;
|
|
1131
|
+
const edit = createFrame("EditBox", undefined, parent, unstyled ? undefined : "InputBoxTemplate");
|
|
1132
|
+
rootControl?.attach(edit);
|
|
1133
|
+
if (styledInput !== undefined) {
|
|
1134
|
+
for (const raw of [...edit.GetRegions()]) {
|
|
1135
|
+
const region = reveal(raw) as Texture | undefined;
|
|
1136
|
+
if (region !== undefined && reveal(region.GetObjectType()) === "Texture") region.Hide();
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
if (unstyled) edit.SetFontObject(GameFontNormal);
|
|
1140
|
+
const paint = createNativePaintState(node.props.style, environment);
|
|
1141
|
+
const eventPaint = interactiveControlPaint(paint, manualControl?.flush);
|
|
1142
|
+
const geometry = rootControl?.unanchored === true ? { ...node.props as OwnedRecord<typeof node.props>, unanchored: true } : node.props;
|
|
1143
|
+
const placed = placeFrame(edit, parent, geometry, scope, motion, false, flow, paint);
|
|
1144
|
+
if (placed) return placed;
|
|
1145
|
+
edit.SetAutoFocus(false);
|
|
1146
|
+
if (type === "password") edit.SetPassword(true);
|
|
1147
|
+
if (maxLetters !== undefined) edit.SetMaxLetters(maxLetters);
|
|
1148
|
+
const hint = placeholder !== undefined || skinnedHint ? edit.CreateFontString(undefined, "OVERLAY", "GameFontDisableSmall") : undefined;
|
|
1149
|
+
if (hint !== undefined) {
|
|
1150
|
+
if (styledInput?.unstyled !== true || styledInput.caption.position !== "absolute") {
|
|
1151
|
+
hint.SetPoint("LEFT", edit, "LEFT", 5, 0);
|
|
1152
|
+
hint.SetPoint("RIGHT", edit, "RIGHT", -5, 0);
|
|
1153
|
+
hint.SetJustifyH("LEFT");
|
|
1154
|
+
}
|
|
1155
|
+
hint.SetText(placeholder ?? "");
|
|
1156
|
+
}
|
|
1157
|
+
let enabled = true;
|
|
1158
|
+
const bound = bind(scope, value, next => {
|
|
1159
|
+
if (isSecret(next)) return;
|
|
1160
|
+
if (reveal(edit.GetText()) !== next) edit.SetText(next);
|
|
1161
|
+
hint?.SetShown(next === "");
|
|
1162
|
+
}) ?? (disabled === undefined ? undefined : bind(scope, disabled, next => {
|
|
1163
|
+
if (isSecret(next)) return;
|
|
1164
|
+
enabled = !next;
|
|
1165
|
+
edit.SetEnabled(enabled);
|
|
1166
|
+
paint?.set("disabled", next);
|
|
1167
|
+
}));
|
|
1168
|
+
if (bound) return bound;
|
|
1169
|
+
if (onChange !== undefined || hint !== undefined) {
|
|
1170
|
+
edit.SetScript("OnTextChanged", (_, userInput) => {
|
|
1171
|
+
if (!scope.isActive()) return;
|
|
1172
|
+
if (userInput ? !enabled : !skinnedHint) return;
|
|
1173
|
+
const text = reveal(edit.GetText());
|
|
1174
|
+
if (text === undefined) return;
|
|
1175
|
+
hint?.SetShown(text === "");
|
|
1176
|
+
if (userInput) onChange?.(text);
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
const focusPaint = paint?.needs("focus") === true;
|
|
1180
|
+
const nativeFocus = styledInput === undefined ? undefined : edit.GetScript("OnEditFocusGained");
|
|
1181
|
+
const nativeBlur = styledInput === undefined ? undefined : edit.GetScript("OnEditFocusLost");
|
|
1182
|
+
if (onFocus || focusPaint) edit.SetScript("OnEditFocusGained", frame => {
|
|
1183
|
+
nativeFocus?.(frame);
|
|
1184
|
+
if (!enabled || !scope.isActive()) return;
|
|
1185
|
+
if (focusPaint) eventPaint?.set("focus", true);
|
|
1186
|
+
onFocus?.();
|
|
1187
|
+
});
|
|
1188
|
+
if (onBlur || focusPaint) edit.SetScript("OnEditFocusLost", frame => {
|
|
1189
|
+
nativeBlur?.(frame);
|
|
1190
|
+
if (!scope.isActive()) return;
|
|
1191
|
+
if (focusPaint) eventPaint?.set("focus", false);
|
|
1192
|
+
onBlur?.();
|
|
1193
|
+
});
|
|
1194
|
+
if (onEnter) edit.SetScript("OnEnterPressed", () => {
|
|
1195
|
+
if (!enabled || !scope.isActive()) return;
|
|
1196
|
+
const text = reveal(edit.GetText());
|
|
1197
|
+
if (text !== undefined) onEnter(text);
|
|
1198
|
+
});
|
|
1199
|
+
if (onEscape) edit.SetScript("OnEscapePressed", () => { if (enabled && scope.isActive()) onEscape(); });
|
|
1200
|
+
scope.onDispose(() => {
|
|
1201
|
+
edit.SetScript("OnTextChanged", undefined);
|
|
1202
|
+
if (onFocus || focusPaint) edit.SetScript("OnEditFocusGained", nativeFocus);
|
|
1203
|
+
edit.SetScript("OnEditFocusLost", nativeBlur);
|
|
1204
|
+
if (onEnter) edit.SetScript("OnEnterPressed", undefined);
|
|
1205
|
+
if (onEscape) edit.SetScript("OnEscapePressed", undefined);
|
|
1206
|
+
edit.ClearFocus();
|
|
1207
|
+
});
|
|
1208
|
+
if (ref) {
|
|
1209
|
+
ref({
|
|
1210
|
+
focus: () => {
|
|
1211
|
+
if (!scope.isActive() || !enabled || reveal(edit.IsVisible()) !== true) return false;
|
|
1212
|
+
edit.SetFocus();
|
|
1213
|
+
return true;
|
|
1214
|
+
},
|
|
1215
|
+
blur: () => {
|
|
1216
|
+
if (scope.isActive()) edit.ClearFocus();
|
|
1217
|
+
},
|
|
1218
|
+
});
|
|
1219
|
+
scope.onDispose(() => ref(undefined));
|
|
1220
|
+
}
|
|
1221
|
+
if (node.props.nativeImageLayers !== undefined) {
|
|
1222
|
+
const layers = mountImageLayers(edit, scope, node.props.nativeImageLayers);
|
|
1223
|
+
if (layers !== undefined) return layers;
|
|
1224
|
+
}
|
|
1225
|
+
options?.input?.(edit, node.props, scope, hint);
|
|
1226
|
+
if (styledInput !== undefined) {
|
|
1227
|
+
function syncEnabled() {
|
|
1228
|
+
const actual = reveal(edit.IsEnabled());
|
|
1229
|
+
if (actual === undefined) return;
|
|
1230
|
+
enabled = actual;
|
|
1231
|
+
eventPaint?.set("disabled", !actual);
|
|
1232
|
+
}
|
|
1233
|
+
syncEnabled();
|
|
1234
|
+
const hooked = hookSecureMethod(edit, "SetEnabled", syncEnabled, scope);
|
|
1235
|
+
if (!hooked.ok) return hooked;
|
|
1236
|
+
}
|
|
1237
|
+
if (hint !== undefined && placeholder !== undefined && inputSkin !== undefined) {
|
|
1238
|
+
const styled = bindSkinCaption(hint, placeholder, inputSkin.caption, scope, options, environment,
|
|
1239
|
+
styledInput === undefined ? undefined : { parent: edit });
|
|
1240
|
+
if (styled !== undefined) return styled;
|
|
1241
|
+
}
|
|
1242
|
+
const insets = unstyled || styledInput !== undefined ? bindEditInsets(edit, style?.padding, scope) : undefined;
|
|
1243
|
+
if (insets !== undefined) return insets;
|
|
1244
|
+
const alignment = bindEditTextAlign(edit, scope, style, liveStyle);
|
|
1245
|
+
if (alignment !== undefined) return alignment;
|
|
1246
|
+
const authoredColor = (unstyled || styledInput !== undefined) && (style?.color !== undefined || mediaPaint(style, "color"));
|
|
1247
|
+
const text = paint?.usesColor === true || authoredColor
|
|
1248
|
+
? bindStatePaint(scope, paint, { environment, motion, reduceMotion: options.reduceMotion, liveStyle }, undefined, {
|
|
1249
|
+
fallback: () => ok((liveStyle?.() ?? style)?.color),
|
|
1250
|
+
read: () => edit.GetTextColor(),
|
|
1251
|
+
write: (r, g, b, a) => edit.SetTextColor(r, g, b, a),
|
|
1252
|
+
}) : undefined;
|
|
1253
|
+
return text ?? bindFramePaint(edit, node.props.style, paint, scope, options, motion, environment, liveStyle, undefined,
|
|
1254
|
+
node.props.nativeRoundedArt)
|
|
1255
|
+
?? (eventPaint === undefined ? undefined
|
|
1256
|
+
: bindElementEvents(edit, {}, scope, options.newEventScope, options.elementEvents, undefined, true, undefined,
|
|
1257
|
+
eventPaint, styledInput !== undefined))
|
|
1258
|
+
?? finishViewNode(scope, mountViewNode(scope, group, "editbox", edit, node.props), node.props.nodeRef);
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
function rejectProtectedElement(node: UIElement, options: NativeViewOptions | undefined): Failure | undefined {
|
|
1262
|
+
if (options?.unprotectedOnly !== true) return;
|
|
1263
|
+
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
|
|
1265
|
+
|| options.createButton !== undefined && node.props.unstyled !== true)
|
|
1266
|
+
|| node.kind === "scrollview" && options.scrollArea !== undefined) {
|
|
1267
|
+
return protectedCombatView;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1036
1271
|
function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options: MountOptions, group: LogicalGroup,
|
|
1037
1272
|
motion?: TransitionOptions, inherited?: StyleEnvironment, flow?: NativeLayoutGroup, typography?: NativeTextStyle,
|
|
1038
1273
|
rootControl?: { unanchored?: boolean; attach(this: void, frame: Frame): void }): Failure | undefined {
|
|
1274
|
+
const denied = rejectProtectedElement(node, options);
|
|
1275
|
+
if (denied !== undefined) return denied;
|
|
1039
1276
|
const checkboxSkin = node.kind === "checkbox" ? options.checkboxSkin : undefined;
|
|
1040
1277
|
const rangeSkin = node.kind === "range" ? options.rangeSkin : undefined;
|
|
1041
1278
|
const listboxSkin = node.kind === "listbox" ? options.listboxSkin : undefined;
|
|
@@ -1084,8 +1321,8 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1084
1321
|
node = { ...node as OwnedRecord<typeof node>, props: { ...node.props as OwnedRecord<typeof node.props>, anchor: { point: "TOPLEFT" } } };
|
|
1085
1322
|
}
|
|
1086
1323
|
}
|
|
1087
|
-
if (node.kind !== "frame" && (style?.display === "flex" || style?.display === "grid" || style?.display === "block")) {
|
|
1088
|
-
return fail("Layout containers require a native frame");
|
|
1324
|
+
if (node.kind !== "frame" && node.kind !== "button" && (style?.display === "flex" || style?.display === "grid" || style?.display === "block")) {
|
|
1325
|
+
return fail("Layout containers require a native frame or button");
|
|
1089
1326
|
}
|
|
1090
1327
|
if (node.kind !== "frame" && style?.overflow === "scroll") {
|
|
1091
1328
|
return fail("CSS overflow scroll requires a native frame");
|
|
@@ -1125,7 +1362,7 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1125
1362
|
case "portal":
|
|
1126
1363
|
return mountPortal(parent, node, scope, options, group, environment, typography);
|
|
1127
1364
|
case "frame": {
|
|
1128
|
-
const frame = createFrame("Frame", undefined, parent);
|
|
1365
|
+
const frame = createFrame("Frame", undefined, parent, node.props.secureStateHandler === true ? "SecureHandlerStateTemplate" : undefined);
|
|
1129
1366
|
rootControl?.attach(frame);
|
|
1130
1367
|
return bindFrameScale(frame, scope, node.props.nativeScale)
|
|
1131
1368
|
?? mountFrame(frame, parent, node, scope, options, group, motion, environment, false, flow, typography, liveStyle);
|
|
@@ -1165,17 +1402,8 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1165
1402
|
case "image":
|
|
1166
1403
|
case "texture":
|
|
1167
1404
|
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
|
-
}
|
|
1405
|
+
case "cooldown":
|
|
1406
|
+
return mountCooldown(parent, node, scope, motion, environment, flow);
|
|
1179
1407
|
case "statusbar": {
|
|
1180
1408
|
const bar = createFrame("StatusBar", undefined, parent);
|
|
1181
1409
|
scope.onDispose(() => bar.Hide());
|
|
@@ -1195,137 +1423,9 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1195
1423
|
}
|
|
1196
1424
|
case "button":
|
|
1197
1425
|
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
|
-
}
|
|
1426
|
+
case "editbox":
|
|
1427
|
+
return mountEditBox(parent, node, scope, options, group, inputSkin, styledInput, skinnedHint, motion, environment, flow,
|
|
1428
|
+
liveStyle, rootControl, manualControl);
|
|
1329
1429
|
case "checkbox": {
|
|
1330
1430
|
const { checked, disabled, label, onChange } = node.props;
|
|
1331
1431
|
const check = createFrame("CheckButton", undefined, parent, "UICheckButtonTemplate");
|
|
@@ -1543,7 +1643,7 @@ function mountLayoutRows(parent: Frame, node: Element<"keyedList">, scope: Runti
|
|
|
1543
1643
|
});
|
|
1544
1644
|
return failure ?? ok({ logical: row });
|
|
1545
1645
|
}
|
|
1546
|
-
if ((tree.kind === "frame" || tree.kind === "button" && tree.props.secureAction === undefined)
|
|
1646
|
+
if ((tree.kind === "frame" || tree.kind === "button" && tree.props.secureAction === undefined && tree.props.secureMacro === undefined)
|
|
1547
1647
|
&& tree.props.directKeyedLayout === true && tree.props.anchor === undefined && tree.props.style?.position !== "absolute"
|
|
1548
1648
|
&& tree.props.style?.mediaStyles === undefined && tree.props.style?.styleTokens === undefined) {
|
|
1549
1649
|
// Keep the item detached until the keyed reconciler publishes its order.
|
|
@@ -1653,7 +1753,7 @@ export function mountNativeRangeArt(this: void, slider: FrameMap["Slider"], owne
|
|
|
1653
1753
|
const bindings = manual?.scope ?? scope;
|
|
1654
1754
|
const result = scope.protect(() => {
|
|
1655
1755
|
const mountedOptions: MountOptions = { ...options as OwnedRecord<NativeRangeArtOptions> | undefined, newEventScope: () => scope.fork() };
|
|
1656
|
-
const theme =
|
|
1756
|
+
const theme = rootStyleEnvironment(options?.theme);
|
|
1657
1757
|
const art = mountRangeArtView(slider, thumbSize, render, bindings, mountedOptions, { scope: bindings }, theme);
|
|
1658
1758
|
if (!art.ok) return art;
|
|
1659
1759
|
const failure = art.value.installThumb();
|
|
@@ -1664,6 +1764,13 @@ export function mountNativeRangeArt(this: void, slider: FrameMap["Slider"], owne
|
|
|
1664
1764
|
return mounted;
|
|
1665
1765
|
}
|
|
1666
1766
|
|
|
1767
|
+
function rootStyleEnvironment(theme?: StyleVariables): StyleEnvironment | undefined {
|
|
1768
|
+
const defaults = addonManifest()?.styleVariables;
|
|
1769
|
+
const variables = defaults === undefined ? theme : theme === undefined ? defaults
|
|
1770
|
+
: { ...defaults as OwnedRecord<StyleVariables>, ...theme as OwnedRecord<StyleVariables> };
|
|
1771
|
+
return extendStyleEnvironment(undefined, variables, isSecret);
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1667
1774
|
function readRootLayer(layer: NativeRootLayer): Result<NativeRootLayer> {
|
|
1668
1775
|
const checked = protect(() => {
|
|
1669
1776
|
if (isSecret(layer) || typeof layer !== "object" || layer === null) return fail("Native root layer is unreadable");
|
|
@@ -1691,22 +1798,24 @@ function unprotected(region: LayerRegion): boolean {
|
|
|
1691
1798
|
return reveal(state) === false;
|
|
1692
1799
|
}
|
|
1693
1800
|
|
|
1694
|
-
function createRootFrame(parent: FrameParent, scope: RuntimeScope, backdrop?: NativeViewOptions["rootBackdrop"]
|
|
1695
|
-
|
|
1696
|
-
|
|
1801
|
+
function createRootFrame(parent: FrameParent, scope: RuntimeScope, backdrop?: NativeViewOptions["rootBackdrop"],
|
|
1802
|
+
secureStateHandler = false): Frame {
|
|
1803
|
+
const template = secureStateHandler ? backdrop === undefined ? "SecureHandlerStateTemplate" : "BackdropTemplate,SecureHandlerStateTemplate"
|
|
1804
|
+
: backdrop === undefined ? undefined : "BackdropTemplate";
|
|
1805
|
+
const frame = createFrame("Frame", backdrop?.name, parent, template);
|
|
1697
1806
|
scope.onDispose(() => frame.Hide());
|
|
1698
1807
|
return frame;
|
|
1699
1808
|
}
|
|
1700
1809
|
|
|
1701
1810
|
function createLayeredRoot(parent: FrameParent, scope: RuntimeScope, { strata, level }: NativeRootLayer,
|
|
1702
|
-
backdrop?: NativeViewOptions["rootBackdrop"]): Result<Frame> {
|
|
1811
|
+
backdrop?: NativeViewOptions["rootBackdrop"], secureStateHandler = false): Result<Frame> {
|
|
1703
1812
|
const created = protect(() => {
|
|
1704
1813
|
if (!accessibleLayerRegion(parent)) return fail("Native root parent is inaccessible");
|
|
1705
1814
|
const inCombat = reveal(api.InCombatLockdown());
|
|
1706
1815
|
if (typeof inCombat !== "boolean") return fail("Combat lockdown is unreadable");
|
|
1707
1816
|
if (inCombat && !unprotected(parent)) return fail("Cannot layer a native root under a protected parent in combat");
|
|
1708
1817
|
|
|
1709
|
-
const frame = createRootFrame(parent, scope, backdrop);
|
|
1818
|
+
const frame = createRootFrame(parent, scope, backdrop, secureStateHandler);
|
|
1710
1819
|
if (!accessibleLayerRegion(frame)) return fail("Native root frame is inaccessible");
|
|
1711
1820
|
if (inCombat && !unprotected(frame)) return fail("Cannot layer a protected native root in combat");
|
|
1712
1821
|
|
|
@@ -1757,6 +1866,7 @@ function initialLayoutQueue() {
|
|
|
1757
1866
|
/** Mount a WoW frame tree, an unstyled control, or scoped regions on a borrowed frame. */
|
|
1758
1867
|
export function mountNative(parent: FrameParent, runtime: Runtime, render: (this: void, scope: RuntimeScope) => UIElement,
|
|
1759
1868
|
options?: NativeViewOptions) {
|
|
1869
|
+
if (options?.unprotectedOnly === true && options.regionsOnly === true) return fail("Combat-updating views require an owned root");
|
|
1760
1870
|
const requestedLayer = options?.rootLayer;
|
|
1761
1871
|
const checkedLayer = requestedLayer === undefined ? undefined : readRootLayer(requestedLayer);
|
|
1762
1872
|
if (checkedLayer?.ok === false) return checkedLayer;
|
|
@@ -1789,7 +1899,7 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1789
1899
|
if (typeof frame.CreateTexture !== "function" || typeof frame.CreateFontString !== "function") {
|
|
1790
1900
|
return fail("Native region mounts require a frame parent");
|
|
1791
1901
|
}
|
|
1792
|
-
const theme =
|
|
1902
|
+
const theme = rootStyleEnvironment(options.theme);
|
|
1793
1903
|
const failure = mountChild(frame, tree, owner, mountedOptions, { scope: owner }, undefined, theme);
|
|
1794
1904
|
if (failure !== undefined) return failure;
|
|
1795
1905
|
mountedTree = true;
|
|
@@ -1807,6 +1917,8 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1807
1917
|
if (!child) return fail("A native view must return one root frame");
|
|
1808
1918
|
tree = child;
|
|
1809
1919
|
}
|
|
1920
|
+
const denied = rejectProtectedElement(tree, options);
|
|
1921
|
+
if (denied !== undefined) return denied;
|
|
1810
1922
|
if ((tree.kind === "button" || tree.kind === "editbox") && tree.props.unstyled === true) {
|
|
1811
1923
|
const kind = tree.kind === "button" ? "button" : "edit box";
|
|
1812
1924
|
if (layer !== undefined || options?.rootScale !== undefined) {
|
|
@@ -1815,7 +1927,7 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1815
1927
|
if (options?.rootBackdrop !== undefined) return fail("Native root backdrop requires a frame root");
|
|
1816
1928
|
if (!accessibleLayerRegion(parent)) return fail(`Native root ${kind} requires an accessible frame parent`);
|
|
1817
1929
|
let frame: Frame | undefined;
|
|
1818
|
-
const theme =
|
|
1930
|
+
const theme = rootStyleEnvironment(options?.theme);
|
|
1819
1931
|
const failure = mountChild(parent as Frame, tree, owner, mountedOptions, { scope: owner }, motion, theme, undefined, undefined, {
|
|
1820
1932
|
unanchored: options?.unanchoredRoot,
|
|
1821
1933
|
attach(this: void, control: Frame) {
|
|
@@ -1831,16 +1943,16 @@ export function mountNative(parent: FrameParent, runtime: Runtime, render: (this
|
|
|
1831
1943
|
if (tree.kind !== "frame") return fail("A native view must return a frame");
|
|
1832
1944
|
let frame: Frame;
|
|
1833
1945
|
if (layer === undefined) {
|
|
1834
|
-
frame = createRootFrame(parent, scope, options?.rootBackdrop);
|
|
1946
|
+
frame = createRootFrame(parent, scope, options?.rootBackdrop, tree.props.secureStateHandler);
|
|
1835
1947
|
} else {
|
|
1836
|
-
const created = createLayeredRoot(parent, scope, layer, options?.rootBackdrop);
|
|
1948
|
+
const created = createLayeredRoot(parent, scope, layer, options?.rootBackdrop, tree.props.secureStateHandler);
|
|
1837
1949
|
if (!created.ok) return created;
|
|
1838
1950
|
frame = created.value;
|
|
1839
1951
|
}
|
|
1840
1952
|
const rootScale = options?.rootScale;
|
|
1841
1953
|
const scaleFailure = bindFrameScale(frame, rootScale === undefined ? owner : scope, rootScale ?? tree.props.nativeScale);
|
|
1842
1954
|
if (scaleFailure !== undefined) return scaleFailure;
|
|
1843
|
-
const theme = extendStyleEnvironment(
|
|
1955
|
+
const theme = extendStyleEnvironment(rootStyleEnvironment(options?.theme), tree.props.cssVars, isSecret);
|
|
1844
1956
|
const media = tree.mediaReads !== undefined || tree.props.style?.mediaStyles !== undefined
|
|
1845
1957
|
? bindViewMedia(tree, owner, mountedOptions) : undefined;
|
|
1846
1958
|
if (media?.ok === false) return media;
|