@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/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { createFontCache, type FontCache, type FontCacheOptions, type FontObject
|
|
|
13
13
|
export { createLocaleFont } from "./locale-font";
|
|
14
14
|
export { createRoundedTextures, type MaskedStatusBarFill, type RoundedBorderCorner, type RoundedTextureOptions, type RoundedTextureResolverOptions, type RoundedTextures, type RoundedTextureSide } from "./rounded-texture";
|
|
15
15
|
export { createBarShade, type BarShade, type BarShadeOptions, type BarShadeStyle } from "./bar-shade";
|
|
16
|
+
export { setTextureFill } from "./texture-fill";
|
|
16
17
|
export { reparentFrame } from "./reparent-frame";
|
|
17
18
|
export { bindContainedFrame, createContainedFrame } from "./contained-frame";
|
|
18
19
|
export { bindAbsolutePosition } from "./absolute-position";
|
|
@@ -29,7 +30,7 @@ export { secureChildUpdateSnippet, secureSnippet, secureStateSnippet, wrapSecure
|
|
|
29
30
|
export type { SecureFrameHandle, SecureSnippet, SecureSnippetEvent, SecureSnippetOptions, SecureSnippetValue, WrapSecureSnippetOptions } from "./secure-snippet";
|
|
30
31
|
export type { SecureButton, SecureFrame, SecureInstallation, SecureOptions } from "./secure-transaction";
|
|
31
32
|
export { createProtectedLayoutUpdate, type ProtectedLayoutOptions, type ProtectedLayoutUpdate } from "./protected-layout";
|
|
32
|
-
export { mountProtectedView } from "./protected-view";
|
|
33
|
+
export { mountProtectedView, type ProtectedViewOptions } from "./protected-view";
|
|
33
34
|
export { useActionBarLayout, type ActionBarLayoutOptions, type ActionBarPosition } from "./action-bar-layout";
|
|
34
35
|
export { createNativePanel } from "./panel-host";
|
|
35
36
|
export { scheduleVisibleFrameUpdate } from "./visible-frame-job";
|
|
@@ -56,28 +57,31 @@ export { createClassColorLookup, readClassColor, type ClassColorLookup } from ".
|
|
|
56
57
|
export { bindAuraDispelTexture, configureAuraMouse } from "./aura-button";
|
|
57
58
|
export type { AuraDispelColorMap, AuraDispelTextureOptions, AuraTooltipMode } from "./aura-button";
|
|
58
59
|
export { createAuraContainer } from "./aura-container";
|
|
60
|
+
export { mountAuraButton, type AuraButtonRegions } from "./aura-view";
|
|
59
61
|
export { bindAuraDurationText, bindAuraStackText, setAuraCountdownFormat, type AuraDurationTextOptions, type AuraStackTextOptions } from "./aura-countdown";
|
|
60
62
|
export { createAuraSlot, type AuraSlot, type AuraSlotOptions } from "./aura-slot";
|
|
61
63
|
export { createHealPrediction, type HealPrediction, type HealPredictionLook, type HealPredictionOptions, type HealPredictionStyle } from "./heal-prediction";
|
|
62
64
|
export { openColorPicker, type ColorPickerOptions } from "./color-picker";
|
|
63
|
-
export type { AuraButton, AuraCandidateFilters, AuraContainer, AuraContainerGroup, AuraContainerOptions, AuraContainerSlot, AuraGroupFilter } from "./aura-container";
|
|
65
|
+
export type { AuraButton, AuraCandidateFilters, AuraContainer, AuraContainerGroup, AuraContainerOptions, AuraContainerSlot, AuraFlowLayout, AuraGroupFilter } from "./aura-container";
|
|
66
|
+
export { anchorAuraFollower } from "./aura-follower";
|
|
64
67
|
export { findSlashCommand } from "./commands";
|
|
65
68
|
export { macroBook } from "./macro-book";
|
|
66
69
|
export { createWoWCVars, cvars, rawCVars } from "./cvars";
|
|
67
70
|
export type { WoWCVarEntry, WoWCVarInfo, WoWRawCVars } from "./cvars";
|
|
68
71
|
export { wowCVarSchema } from "./cvar-schema";
|
|
69
72
|
export type { WoWCVarName, WoWCVarSchema, WoWCVarValue } from "./cvar-schema";
|
|
70
|
-
export { configureAnimations, createAnimation, createTicker, playWhileVisible, useAnimation } from "./animation";
|
|
73
|
+
export { configureAnimations, createAnimation, createTicker, playWhileVisible, useAnimation, useAnimationWhile } from "./animation";
|
|
71
74
|
export type { AnimationControl, AnimationDefaults, AnimationPlayback, AnimationRef, AnimationRefOptions, AnimationTarget, MotionMode,
|
|
72
75
|
NativeAnimationOptions, PlayOptions, StepPatch, TargetOf, Ticker } from "./animation";
|
|
73
|
-
export {
|
|
76
|
+
export { statusBarValue } from "./status-bar";
|
|
77
|
+
export { applyFrameScale, mountNative, mountNativeRangeArt } from "./view";
|
|
74
78
|
export type { NativeRootLayer, NativeViewOptions } from "./view";
|
|
75
79
|
export type { NativeLayoutDiagnostics } from "./layout-view";
|
|
76
80
|
export type { FrameStrata } from "./frame-layer";
|
|
77
81
|
export type { CreateScrollArea, ScrollArea } from "./scroll-view";
|
|
78
82
|
export { protect } from "./protect";
|
|
79
83
|
export { luaString } from "./lua-string";
|
|
80
|
-
export { physicalPixel, snapPixel, watchDisplayMetrics } from "./pixel";
|
|
84
|
+
export { physicalPixel, snapPixel, useFramePixel, watchDisplayMetrics } from "./pixel";
|
|
81
85
|
export { formatWoWNumber } from "./number-format";
|
|
82
86
|
export { clampWoWNumber } from "./number-input";
|
|
83
87
|
export { formatMapCoordinates, readPlayerMapPosition } from "./map-position";
|
|
@@ -85,7 +89,8 @@ export { rawField, setRawField, weakKeys } from "./lua-table";
|
|
|
85
89
|
export { savedVariablesStorage, type SavedRecord, type SavedValue, type SavedVariablesOptions } from "./saved-variables";
|
|
86
90
|
export { usePlugins, type KumiPlugins, type PluginId, type PluginInfo, type PluginServices, type PluginStatus } from "./plugins";
|
|
87
91
|
export { useViewHost, useWindow, type AppTheme } from "./app-ui";
|
|
88
|
-
export { onCleanup, useCombat, useEvent, useNow, useSlashCommand } from "./hooks";
|
|
92
|
+
export { onCleanup, useCombat, useEvent, useNow, useScreenSize, useSlashCommand } from "./hooks";
|
|
93
|
+
export { useHotkeys, type FrameHotkeyOptions, type GlobalHotkeyOptions, type HotkeyActions } from "./hotkeys";
|
|
89
94
|
export type { EventApi, EventOptions, EventScope, WoWEvent, WoWEventMap } from "./contract";
|
|
90
95
|
|
|
91
96
|
declare const DoReadyCheck: ((this: void) => void) | undefined;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ownedArray, ownedSet, type OwnedReadonlyArray } from "../src/owned-collections";
|
|
2
|
+
import { withReactiveScope } from "../src/reactive-scope";
|
|
3
|
+
import { fail, type Failure } from "../src/result";
|
|
4
|
+
import type { RuntimeScope } from "../src/runtime";
|
|
5
|
+
import type { Job } from "../src/scheduler";
|
|
6
|
+
|
|
7
|
+
/** Hold the first layout until the whole initial tree is available. */
|
|
8
|
+
export function initialLayoutQueue() {
|
|
9
|
+
const jobs = ownedSet<Job>();
|
|
10
|
+
let pending: OwnedReadonlyArray<Job> | undefined;
|
|
11
|
+
let index = 0;
|
|
12
|
+
let pass = 0;
|
|
13
|
+
let collecting = true;
|
|
14
|
+
|
|
15
|
+
function stop() {
|
|
16
|
+
collecting = false;
|
|
17
|
+
pending = undefined;
|
|
18
|
+
jobs.clear();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function step(): true | Failure | undefined {
|
|
22
|
+
if (pending !== undefined && index < pending.length) {
|
|
23
|
+
const job = pending[index++];
|
|
24
|
+
jobs.delete(job);
|
|
25
|
+
return job() ?? true;
|
|
26
|
+
}
|
|
27
|
+
if (jobs.size === 0) { stop(); return; }
|
|
28
|
+
if (++pass > 16) { stop(); return fail("Initial native layout did not settle"); }
|
|
29
|
+
const snapshot = ownedArray<Job>();
|
|
30
|
+
for (const job of jobs) snapshot.push(job);
|
|
31
|
+
pending = snapshot;
|
|
32
|
+
index = 0;
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
stage: (job: Job) => {
|
|
38
|
+
if (collecting) jobs.add(job);
|
|
39
|
+
return collecting;
|
|
40
|
+
},
|
|
41
|
+
step,
|
|
42
|
+
stop,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface InitialViewStages {
|
|
47
|
+
accepts(this: void): boolean;
|
|
48
|
+
push(this: void, owner: RuntimeScope, job: Job): void;
|
|
49
|
+
start(this: void): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Drain the native children in mount order. First layout runs only after the last child. */
|
|
53
|
+
export function stageInitialView(this: void, scope: RuntimeScope, layout: ReturnType<typeof initialLayoutQueue>,
|
|
54
|
+
complete: (this: void, failure?: Failure) => void | Failure): InitialViewStages {
|
|
55
|
+
const jobs = ownedArray<{ readonly owner: RuntimeScope; readonly run: Job }>();
|
|
56
|
+
const key = {};
|
|
57
|
+
let mounting = true;
|
|
58
|
+
|
|
59
|
+
function finish(failure?: Failure) {
|
|
60
|
+
mounting = false;
|
|
61
|
+
if (failure !== undefined) scope.dispose();
|
|
62
|
+
return complete(failure);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function advance() {
|
|
66
|
+
for (let count = 0; count < 32 && (count === 0 || scope.frameJobs.remainingMs() > 0); count++) {
|
|
67
|
+
if (!scope.isActive()) return;
|
|
68
|
+
if (mounting) {
|
|
69
|
+
const item = jobs.pop();
|
|
70
|
+
if (item === undefined) {
|
|
71
|
+
mounting = false;
|
|
72
|
+
return true; // Give layout its own frame budget.
|
|
73
|
+
}
|
|
74
|
+
if (!item.owner.isActive()) continue;
|
|
75
|
+
const result = withReactiveScope(item.owner, item.run);
|
|
76
|
+
const failure = result.ok ? result.value : result;
|
|
77
|
+
if (failure !== undefined) return finish(failure);
|
|
78
|
+
} else {
|
|
79
|
+
const result = scope.protect(layout.step);
|
|
80
|
+
const step = result.ok ? result.value : result;
|
|
81
|
+
if (step === true) continue;
|
|
82
|
+
return finish(step);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
scope.onDispose(() => {
|
|
89
|
+
mounting = false;
|
|
90
|
+
jobs.length = 0;
|
|
91
|
+
layout.stop();
|
|
92
|
+
scope.frameJobs.cancel(key);
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
accepts: () => mounting,
|
|
96
|
+
push: (owner, run) => { jobs.push({ owner, run }); },
|
|
97
|
+
start: () => { scope.frameJobs.queue(key, advance, { lane: "user", label: "Initial window view" }); },
|
|
98
|
+
};
|
|
99
|
+
}
|
package/wow/layout-view.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Binding, Element, RuntimeScope } from "../src";
|
|
2
|
-
import {
|
|
2
|
+
import { isBindingRef } from "../src/bindings";
|
|
3
|
+
import { isIntrinsicWidth, layoutPercent, solveLayout, type FlexLayout, type FlexNode, type LayoutStyle, type LayoutRect, type LayoutSize } from "../src/flex-layout";
|
|
3
4
|
import { parseGridSpan, parseGridTracks } from "../src/grid-tracks";
|
|
4
5
|
import type { OwnedArray, OwnedLuaArray, OwnedReadonlyArray, OwnedRecord, OwnedSet } from "../src/owned-collections";
|
|
5
6
|
import { fail, ok, type Failure, type Result } from "../src/result";
|
|
@@ -55,7 +56,7 @@ export function readLayoutValue<T>(this: void, binding: Binding<T> | undefined):
|
|
|
55
56
|
if (isSecret(binding)) return fail("Layout properties require readable values");
|
|
56
57
|
if (binding === undefined) return missingLayoutValue;
|
|
57
58
|
if (binding === null) return fail("Invalid layout binding");
|
|
58
|
-
if (
|
|
59
|
+
if (!isBindingRef(binding)) return ok(binding as T);
|
|
59
60
|
const value = binding.value;
|
|
60
61
|
if (isSecret(value)) return fail("Layout properties require readable values");
|
|
61
62
|
if (typeof value === "object" && value !== null && "ok" in value) {
|
|
@@ -102,10 +103,12 @@ function resolveLayout(props: Layout): Result<LayoutStyle> {
|
|
|
102
103
|
const size = readLayoutValue(key === "flexBasis" ? style?.flexBasis : props[key] ?? style?.[key]);
|
|
103
104
|
if (!size.ok) return size;
|
|
104
105
|
if (size.value === undefined) continue;
|
|
105
|
-
if (size.value !== "auto" && !validNumber(size.value)
|
|
106
|
+
if (size.value !== "auto" && !validNumber(size.value)
|
|
107
|
+
&& !(key === "width" && isIntrinsicWidth(size.value)) && (key === "flexBasis" || layoutPercent(size.value) === undefined)) {
|
|
106
108
|
return fail("Invalid layout " + key);
|
|
107
109
|
}
|
|
108
|
-
|
|
110
|
+
if (key === "width") result.width = size.value;
|
|
111
|
+
else if (!isIntrinsicWidth(size.value)) result[key] = size.value;
|
|
109
112
|
}
|
|
110
113
|
for (const key of insetKeys) {
|
|
111
114
|
const inset = readLayoutValue(style?.[key]);
|
|
@@ -284,6 +287,13 @@ export class NativeLayoutItem {
|
|
|
284
287
|
this.updateVisibility();
|
|
285
288
|
}
|
|
286
289
|
|
|
290
|
+
retire(): void {
|
|
291
|
+
// A keyed list can still reference the row until it publishes its new order.
|
|
292
|
+
this.shown = false;
|
|
293
|
+
this.group.visibility.delete(this);
|
|
294
|
+
if (acceptRegion(this.region).ok) this.region.SetShown(false);
|
|
295
|
+
}
|
|
296
|
+
|
|
287
297
|
private updateVisibility() {
|
|
288
298
|
if (this.lastRect === undefined) return;
|
|
289
299
|
if (acceptRegion(this.region).ok) this.commitVisibility();
|
|
@@ -519,7 +529,7 @@ export function isAbsoluteFill(this: void, props: Layout): boolean {
|
|
|
519
529
|
}
|
|
520
530
|
|
|
521
531
|
export function mountLayoutRoot(this: void, frame: Frame, parent: FrameParent, props: Layout, scope: RuntimeScope,
|
|
522
|
-
diagnostics?: NativeLayoutDiagnostics, stageInitial?: StageInitialLayout): Result<NativeLayoutItem> {
|
|
532
|
+
diagnostics?: NativeLayoutDiagnostics, stageInitial?: StageInitialLayout, measure?: Measure): Result<NativeLayoutItem> {
|
|
523
533
|
// The root keeps its own anchors. A zero-inset absolute root gets both axes from its containing block.
|
|
524
534
|
const supported = acceptParent(parent, "ancestor");
|
|
525
535
|
if (!supported.ok) return supported;
|
|
@@ -539,7 +549,7 @@ export function mountLayoutRoot(this: void, frame: Frame, parent: FrameParent, p
|
|
|
539
549
|
let lastFailure: string | undefined;
|
|
540
550
|
let root: NativeLayoutItem;
|
|
541
551
|
const visibility = new Set<NativeLayoutItem>() as OwnedSet<NativeLayoutItem>;
|
|
542
|
-
const initial = stageInitial === undefined ? undefined : () => layout(true);
|
|
552
|
+
const initial = stageInitial === undefined ? undefined : () => scope.isActive() ? layout(true) : undefined;
|
|
543
553
|
const enqueue = () => {
|
|
544
554
|
if (!scope.isActive() || waiting) return;
|
|
545
555
|
if (initial !== undefined && stageInitial?.(initial) === true) return;
|
|
@@ -615,8 +625,8 @@ export function mountLayoutRoot(this: void, frame: Frame, parent: FrameParent, p
|
|
|
615
625
|
}
|
|
616
626
|
}
|
|
617
627
|
|
|
618
|
-
root = new NativeLayoutItem(frame, parent, false, props.fullWidth === true,
|
|
619
|
-
{ enqueue, children: [] as Flow[] as OwnedArray<Flow>, visibility, textMeasure });
|
|
628
|
+
root = new NativeLayoutItem(frame, parent, false, props.fullWidth === true, measure === undefined,
|
|
629
|
+
{ enqueue, children: [] as Flow[] as OwnedArray<Flow>, visibility, textMeasure }, measure);
|
|
620
630
|
const cleanup = scope.onDispose(() => {
|
|
621
631
|
scope.frameJobs.cancel(key);
|
|
622
632
|
scope.frameJobs.cancel(repairKey);
|
|
@@ -651,8 +661,7 @@ export function attachLayoutItem(this: void, group: NativeLayoutGroup, region: G
|
|
|
651
661
|
const remove = scope.onDispose(() => {
|
|
652
662
|
const index = group.children.indexOf(item);
|
|
653
663
|
if (index >= 0) group.children.splice(index, 1);
|
|
654
|
-
|
|
655
|
-
if (acceptRegion(region).ok) region.SetShown(false);
|
|
664
|
+
item.retire();
|
|
656
665
|
group.enqueue();
|
|
657
666
|
});
|
|
658
667
|
if (!remove.ok) return remove;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ModuleReplacement } from "../src/module-ui";
|
|
2
|
+
import { ownedMap, ownedSet, type OwnedReadonlyArray } from "../src/owned-collections";
|
|
3
|
+
import { fail, ok, type Failure, type Result } from "../src/result";
|
|
4
|
+
import type { Runtime, RuntimeScope } from "../src/runtime";
|
|
5
|
+
import { protect } from "./protect";
|
|
6
|
+
import { createProtectedLayoutUpdate, type ProtectedLayoutUpdate } from "./protected-layout";
|
|
7
|
+
|
|
8
|
+
const restoring = ownedMap<string, ProtectedLayoutUpdate>();
|
|
9
|
+
|
|
10
|
+
function runAdapter(id: string, index: number, action: "disable" | "restore", run: ModuleReplacement["disable"]): Result<void> {
|
|
11
|
+
const called = protect(run);
|
|
12
|
+
const result = called.ok ? called.value ?? ok(undefined) : called;
|
|
13
|
+
return result.ok ? result : {
|
|
14
|
+
ok: false,
|
|
15
|
+
reason: "Module " + id + ": " + action + " replacement " + (index + 1) + ": " + result.reason,
|
|
16
|
+
trace: result.trace,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function combine(first: Result<void>, second: Result<void>): Result<void> {
|
|
21
|
+
if (first.ok) return second;
|
|
22
|
+
return second.ok ? first : { ok: false, reason: first.reason + "\n" + second.reason, trace: first.trace ?? second.trace };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Pair native frame takeover with a fully mounted batch of module views. */
|
|
26
|
+
export function mountModuleReplacements(this: void, runtime: Runtime, owner: RuntimeScope, id: string,
|
|
27
|
+
adapters: OwnedReadonlyArray<ModuleReplacement>, mount: (this: void, scope: RuntimeScope) => Result<void>): Result<void> {
|
|
28
|
+
let views: RuntimeScope | undefined;
|
|
29
|
+
let attempted = 0;
|
|
30
|
+
let activating = false;
|
|
31
|
+
let initialRequest = true;
|
|
32
|
+
|
|
33
|
+
function release() {
|
|
34
|
+
const mounted = views;
|
|
35
|
+
if (mounted === undefined || activating) return;
|
|
36
|
+
views = undefined;
|
|
37
|
+
const cleanup = runtime.scope();
|
|
38
|
+
const restored = ownedSet<number>();
|
|
39
|
+
const update = createProtectedLayoutUpdate(() => {
|
|
40
|
+
let result: Result<void> = ok(undefined);
|
|
41
|
+
for (let index = attempted - 1; index >= 0; index--) {
|
|
42
|
+
if (restored.has(index)) continue;
|
|
43
|
+
const step = runAdapter(id, index, "restore", adapters[index].restore);
|
|
44
|
+
if (step.ok) restored.add(index);
|
|
45
|
+
else result = combine(result, step);
|
|
46
|
+
}
|
|
47
|
+
if (!result.ok) return result;
|
|
48
|
+
const stopped = mounted.dispose();
|
|
49
|
+
restoring.delete(id);
|
|
50
|
+
cleanup.dispose();
|
|
51
|
+
if (!stopped.ok) return stopped;
|
|
52
|
+
}, { scope: cleanup, label: "Restore native UI for " + id });
|
|
53
|
+
if (!update.ok) {
|
|
54
|
+
cleanup.dispose();
|
|
55
|
+
return update;
|
|
56
|
+
}
|
|
57
|
+
restoring.set(id, update.value);
|
|
58
|
+
return update.value.request();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function mountAndDisable(mounted: RuntimeScope): Result<void> {
|
|
62
|
+
const started = protect(() => mount(mounted));
|
|
63
|
+
const result = started.ok ? started.value : started;
|
|
64
|
+
if (!result.ok) return result;
|
|
65
|
+
for (const adapter of adapters) {
|
|
66
|
+
if (!owner.isActive()) break;
|
|
67
|
+
const index = attempted++;
|
|
68
|
+
const disabled = runAdapter(id, index, "disable", adapter.disable);
|
|
69
|
+
if (!disabled.ok) return disabled;
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function activate(): Result<void> {
|
|
75
|
+
// An earlier unload can still be queued on the frame budget after combat.
|
|
76
|
+
const previous = restoring.get(id);
|
|
77
|
+
if (previous !== undefined) {
|
|
78
|
+
const restored = previous.request();
|
|
79
|
+
if (!restored.ok) return restored;
|
|
80
|
+
if (restoring.has(id)) return fail("Module " + id + ": previous replacement is still restoring");
|
|
81
|
+
}
|
|
82
|
+
if (!owner.isActive()) return ok(undefined);
|
|
83
|
+
const mounted = runtime.scope();
|
|
84
|
+
views = mounted;
|
|
85
|
+
activating = true;
|
|
86
|
+
const result = mountAndDisable(mounted);
|
|
87
|
+
activating = false;
|
|
88
|
+
return result.ok && owner.isActive() ? result : combine(result, release() ?? ok(undefined));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const cleanup = owner.onDispose(release);
|
|
92
|
+
if (!cleanup.ok) return cleanup;
|
|
93
|
+
const update = createProtectedLayoutUpdate((): Failure | void => {
|
|
94
|
+
const result = activate();
|
|
95
|
+
if (result.ok) return;
|
|
96
|
+
const rolledBack = initialRequest ? result : combine(result, owner.dispose());
|
|
97
|
+
if (!rolledBack.ok) return rolledBack;
|
|
98
|
+
}, { scope: owner, label: "Replace native UI for " + id });
|
|
99
|
+
if (!update.ok) return update;
|
|
100
|
+
const requested = update.value.request();
|
|
101
|
+
initialRequest = false;
|
|
102
|
+
return requested;
|
|
103
|
+
}
|
package/wow/native.ts
CHANGED
|
@@ -63,6 +63,7 @@ interface LegacyGlobals {
|
|
|
63
63
|
]>;
|
|
64
64
|
GetInventoryItemTexture?(this: void, unit: string, slot: number): number | string | SecretValue<number | string> | undefined;
|
|
65
65
|
IsInRaid(this: void, category?: number): boolean;
|
|
66
|
+
UnitHasIncomingResurrection?(this: void, unit: string): boolean | SecretValue<boolean>;
|
|
66
67
|
readonly RAID_CLASS_COLORS?: Readonly<Partial<Record<string, { readonly r: number; readonly g: number; readonly b: number }>>>;
|
|
67
68
|
readonly SlashCmdList?: Record<string, (this: void, input: string) => void>;
|
|
68
69
|
readonly TooltipDataProcessor?: {
|
package/wow/pixel.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { currentScope } from "../src/reactive-scope";
|
|
2
|
+
import { ref } from "../src/reactivity";
|
|
1
3
|
import { ok } from "../src/result";
|
|
2
4
|
import type { RuntimeScope } from "../src/runtime";
|
|
3
5
|
import { createEventDispatcher } from "./event-dispatcher";
|
|
@@ -33,3 +35,26 @@ export function watchDisplayMetrics(this: void, scope: RuntimeScope, refresh: (t
|
|
|
33
35
|
if (!size.ok) { scale.value(); return size; }
|
|
34
36
|
return ok(undefined);
|
|
35
37
|
}
|
|
38
|
+
|
|
39
|
+
/** Follow the display pixel in an owned frame's local units. Read the frame's authored scale in readScale. */
|
|
40
|
+
export function useFramePixel(this: void, readScale: (this: void) => number) {
|
|
41
|
+
const scope = currentScope();
|
|
42
|
+
if (scope === undefined) throw new Error("useFramePixel needs an active scope");
|
|
43
|
+
const pixel = ref(1);
|
|
44
|
+
let frame: Pick<Frame, "GetEffectiveScale"> | undefined;
|
|
45
|
+
|
|
46
|
+
function refresh(this: void): void {
|
|
47
|
+
if (frame !== undefined) pixel.value = physicalPixel(frame);
|
|
48
|
+
}
|
|
49
|
+
function schedule(this: void): void { scope?.nextTick(refresh); }
|
|
50
|
+
function bind(this: void, value?: Pick<Frame, "GetEffectiveScale">): void {
|
|
51
|
+
frame = value;
|
|
52
|
+
refresh();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const subscription = watchDisplayMetrics(scope, schedule);
|
|
56
|
+
if (!subscription.ok) throw new Error(subscription.reason);
|
|
57
|
+
const scaled = scope.watch(readScale, schedule);
|
|
58
|
+
if (!scaled.ok) throw new Error(scaled.reason);
|
|
59
|
+
return { pixel, refresh, bind };
|
|
60
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MouseButton } from "../src/elements";
|
|
2
|
+
import { api, reveal } from "./native";
|
|
3
|
+
|
|
4
|
+
const releaseGrace = 0.05;
|
|
5
|
+
|
|
6
|
+
/** A button's native OnClick can follow OnMouseUp or a drag-stop callback. */
|
|
7
|
+
export function createPointerClickGate(maxDuration: number) {
|
|
8
|
+
let button: MouseButton | undefined;
|
|
9
|
+
let started: number | undefined;
|
|
10
|
+
let released: number | undefined;
|
|
11
|
+
let dragged = false;
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
press: (next: MouseButton) => {
|
|
15
|
+
button = next;
|
|
16
|
+
started = reveal(api.GetTime());
|
|
17
|
+
released = undefined;
|
|
18
|
+
dragged = false;
|
|
19
|
+
},
|
|
20
|
+
drag: () => { dragged = true; },
|
|
21
|
+
release: (next: MouseButton) => {
|
|
22
|
+
if (next === button) released = reveal(api.GetTime());
|
|
23
|
+
},
|
|
24
|
+
clear: () => { button = undefined; },
|
|
25
|
+
accept: (next: MouseButton) => {
|
|
26
|
+
if (button !== next) return true;
|
|
27
|
+
button = undefined;
|
|
28
|
+
const now = reveal(api.GetTime());
|
|
29
|
+
// A later activation without a fresh pointer press is not part of this gesture.
|
|
30
|
+
if (now !== undefined && released !== undefined && now - released > releaseGrace) return true;
|
|
31
|
+
const end = released ?? now;
|
|
32
|
+
return !dragged && (started === undefined || end === undefined || end - started <= maxDuration);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
package/wow/protected-view.ts
CHANGED
|
@@ -6,8 +6,9 @@ import { formatFailure, ok, type Failure, type Result } from "../src/result";
|
|
|
6
6
|
import { createRuntime, type Runtime, type RuntimeScope } from "../src/runtime";
|
|
7
7
|
import { unlockedActionSlot } from "./action-button";
|
|
8
8
|
import { clock } from "./clock";
|
|
9
|
+
import { canAccessRegion } from "./frame-access";
|
|
9
10
|
import type { Frame } from "./frames";
|
|
10
|
-
import { api } from "./native";
|
|
11
|
+
import { api, reveal } from "./native";
|
|
11
12
|
import { physicalPixel } from "./pixel";
|
|
12
13
|
import { protect } from "./protect";
|
|
13
14
|
import { createProtectedLayoutUpdate } from "./protected-layout";
|
|
@@ -19,24 +20,36 @@ interface ProtectedView {
|
|
|
19
20
|
refreshDisplay(this: void): Result<void>;
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
export interface ProtectedViewOptions extends Omit<NativeViewOptions, "unprotectedOnly"> {
|
|
24
|
+
/** Opt in to combat updates for an unprotected visual tree after it mounts. */
|
|
25
|
+
readonly combatUpdates?: true;
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
function report(error: Failure) {
|
|
23
29
|
api.geterrorhandler()(formatFailure(error));
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
function canUpdateInCombat(frame: Frame): boolean {
|
|
33
|
+
if (!canAccessRegion(frame)) return false;
|
|
34
|
+
const [state] = frame.IsProtected();
|
|
35
|
+
return reveal(state) === false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Mount and dispose out of combat. An opted-in visual view can update while its root stays unprotected. */
|
|
27
39
|
export function mountProtectedView(this: void, host: Runtime, owner: RuntimeScope,
|
|
28
40
|
render: (this: void, scope: RuntimeScope, refresh: ProtectedView["refresh"], pixel: ReadonlyRef<number>) => UIElement,
|
|
29
|
-
options:
|
|
41
|
+
options: ProtectedViewOptions = {}): Result<ProtectedView> {
|
|
30
42
|
type Mount = Extract<ReturnType<typeof mountNative>, { ok: true }>["value"];
|
|
31
43
|
let view: Mount | undefined;
|
|
32
44
|
const pixel = ref(physicalPixel(api.UIParent as Frame));
|
|
33
45
|
const key = {};
|
|
34
46
|
let measure = false;
|
|
35
47
|
let flush = false;
|
|
48
|
+
let refreshingInCombat = false;
|
|
36
49
|
|
|
37
50
|
function drive() {
|
|
38
51
|
if (!owner.isActive()) return;
|
|
39
|
-
const updated =
|
|
52
|
+
const updated = requestUpdate();
|
|
40
53
|
if (!updated.ok) return updated;
|
|
41
54
|
}
|
|
42
55
|
|
|
@@ -54,19 +67,25 @@ export function mountProtectedView(this: void, host: Runtime, owner: RuntimeScop
|
|
|
54
67
|
},
|
|
55
68
|
};
|
|
56
69
|
const runtime = createRuntime(clock, report, protect, { driver });
|
|
70
|
+
|
|
71
|
+
function refreshMounted(mounted: Mount) {
|
|
72
|
+
if (measure) {
|
|
73
|
+
pixel.value = physicalPixel(mounted.frame as Frame);
|
|
74
|
+
measure = false;
|
|
75
|
+
}
|
|
76
|
+
const urgent = flush;
|
|
77
|
+
flush = false;
|
|
78
|
+
runtime.frameJobs.step(urgent);
|
|
79
|
+
}
|
|
80
|
+
|
|
57
81
|
const guarded = createProtectedLayoutUpdate(() => {
|
|
58
82
|
if (view !== undefined) {
|
|
59
|
-
|
|
60
|
-
pixel.value = physicalPixel(view.frame as Frame);
|
|
61
|
-
measure = false;
|
|
62
|
-
}
|
|
63
|
-
const urgent = flush;
|
|
64
|
-
flush = false;
|
|
65
|
-
runtime.frameJobs.step(urgent);
|
|
83
|
+
refreshMounted(view);
|
|
66
84
|
return;
|
|
67
85
|
}
|
|
68
86
|
const mounted = mountNative(api.UIParent, runtime, scope => render(scope, refresh, pixel), {
|
|
69
87
|
...options as OwnedRecord<NativeViewOptions>, bindings: undefined, initialLayout: "sync",
|
|
88
|
+
unprotectedOnly: options.combatUpdates,
|
|
70
89
|
});
|
|
71
90
|
if (!mounted.ok) return mounted;
|
|
72
91
|
view = mounted.value;
|
|
@@ -76,7 +95,24 @@ export function mountProtectedView(this: void, host: Runtime, owner: RuntimeScop
|
|
|
76
95
|
}, { scope: owner, label: "Protected JSX view" });
|
|
77
96
|
if (!guarded.ok) return guarded;
|
|
78
97
|
const update = guarded.value;
|
|
79
|
-
|
|
98
|
+
|
|
99
|
+
function requestUpdate(): Result<void> {
|
|
100
|
+
const mounted = view;
|
|
101
|
+
if (!owner.isActive() || mounted === undefined || options.combatUpdates !== true
|
|
102
|
+
|| reveal(api.InCombatLockdown()) !== true || !canUpdateInCombat(mounted.frame as Frame)) {
|
|
103
|
+
return update.request();
|
|
104
|
+
}
|
|
105
|
+
if (refreshingInCombat) {
|
|
106
|
+
owner.frameJobs.queue(key, drive);
|
|
107
|
+
return ok(undefined);
|
|
108
|
+
}
|
|
109
|
+
refreshingInCombat = true;
|
|
110
|
+
const refreshed = protect(() => refreshMounted(mounted));
|
|
111
|
+
refreshingInCombat = false;
|
|
112
|
+
return refreshed;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const refresh = () => { flush = true; return requestUpdate(); };
|
|
80
116
|
|
|
81
117
|
const subscription = owner.onDispose(() => {
|
|
82
118
|
owner.frameJobs.cancel(key);
|
|
@@ -98,6 +134,6 @@ export function mountProtectedView(this: void, host: Runtime, owner: RuntimeScop
|
|
|
98
134
|
const mounted = refresh();
|
|
99
135
|
return mounted.ok ? ok({
|
|
100
136
|
refresh,
|
|
101
|
-
refreshDisplay: () => { measure = true; return
|
|
137
|
+
refreshDisplay: () => { measure = true; return requestUpdate(); },
|
|
102
138
|
}) : mounted;
|
|
103
139
|
}
|
package/wow/rounded-texture.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface RoundedTextureOptions {
|
|
|
21
21
|
readonly stretched?: number;
|
|
22
22
|
/** Resolve a sliced outline with a one-texel stroke at the requested physical radius. */
|
|
23
23
|
resolveBorderOutline?(this: void, radius: number): TextureAsset | undefined;
|
|
24
|
+
/** Matching solid fill on the physical pixel grid. Also provides exact CSS masks for integer radii. */
|
|
25
|
+
resolveBorderFill?(this: void, radius: number): TextureAsset | undefined;
|
|
24
26
|
/** Resolve the inner cutout for a one-texel stroke at an integer display radius. */
|
|
25
27
|
resolveBorderCorner?(this: void, radius: number): RoundedBorderCorner | undefined;
|
|
26
28
|
}
|
|
@@ -46,6 +48,7 @@ export interface RoundedTextures {
|
|
|
46
48
|
readonly borderOutline?: {
|
|
47
49
|
readonly stretched: number;
|
|
48
50
|
resolve(this: void, radius: number): TextureAsset | undefined;
|
|
51
|
+
resolveFill?(this: void, radius: number): TextureAsset | undefined;
|
|
49
52
|
};
|
|
50
53
|
resolveBorderCorner?(this: void, radius: number): RoundedBorderCorner | undefined;
|
|
51
54
|
bindStatusBarFill(this: void, bar: StatusBar, fill: Texture): MaskedStatusBarFill;
|
|
@@ -54,7 +57,7 @@ export interface RoundedTextures {
|
|
|
54
57
|
const maskWrap = "CLAMPTOBLACKADDITIVE";
|
|
55
58
|
|
|
56
59
|
/** Apply host-supplied Round textures with native nine-slice margins. */
|
|
57
|
-
export function createRoundedTextures(this: void, { directory, resolveArt, fallback, radii, stretched, resolveBorderCorner, resolveBorderOutline }:
|
|
60
|
+
export function createRoundedTextures(this: void, { directory, resolveArt, fallback, radii, stretched, resolveBorderCorner, resolveBorderOutline, resolveBorderFill }:
|
|
58
61
|
RoundedTextureOptions | RoundedTextureResolverOptions): RoundedTextures {
|
|
59
62
|
const rounded = (radii as OwnedReadonlyArray<number>).filter(radius => radius > 0).sort((left, right) => right - left);
|
|
60
63
|
const square = [0];
|
|
@@ -120,10 +123,12 @@ export function createRoundedTextures(this: void, { directory, resolveArt, fallb
|
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
function applyExact(texture: SliceTexture, radius: number, wrap?: string): boolean {
|
|
123
|
-
if (stretched === undefined ||
|
|
126
|
+
if (stretched === undefined || typeof texture.SetTextureSliceMargins !== "function"
|
|
124
127
|
|| typeof texture.SetTextureSliceMode !== "function") return false;
|
|
125
128
|
const prefix = directory === undefined ? "" : directory() + "Round";
|
|
126
|
-
|
|
129
|
+
if (rounded.includes(radius) && setArt(texture, readArt(prefix, radius, false), radius, wrap)) return true;
|
|
130
|
+
return Number.isFinite(radius) && radius > 0 && Math.floor(radius) === radius
|
|
131
|
+
&& setArt(texture, resolveBorderFill?.(radius), radius, wrap);
|
|
127
132
|
}
|
|
128
133
|
|
|
129
134
|
function applyMask(this: void, mask: FillMask, radius: number): boolean {
|
|
@@ -178,6 +183,6 @@ export function createRoundedTextures(this: void, { directory, resolveArt, fallb
|
|
|
178
183
|
}
|
|
179
184
|
|
|
180
185
|
const borderOutline = stretched === undefined || resolveBorderOutline === undefined
|
|
181
|
-
? undefined : { stretched, resolve: resolveBorderOutline };
|
|
186
|
+
? undefined : { stretched, resolve: resolveBorderOutline, resolveFill: resolveBorderFill };
|
|
182
187
|
return { create, apply, applyMask, applyExactFill, bindStatusBarFill, resolveBorderCorner, borderOutline };
|
|
183
188
|
}
|
package/wow/scroll-view.ts
CHANGED
|
@@ -10,12 +10,12 @@ export type ScrollArea = FrameMap["ScrollFrame"] & {
|
|
|
10
10
|
|
|
11
11
|
export type CreateScrollArea = (this: void, parent: Frame) => ScrollArea;
|
|
12
12
|
|
|
13
|
-
function createDefaultArea(parent: Frame) {
|
|
13
|
+
function createDefaultArea(parent: Frame, layoutOwnsWidth: boolean) {
|
|
14
14
|
const viewport = createFrame("ScrollFrame", undefined, parent);
|
|
15
15
|
const content = createFrame("Frame", undefined, viewport);
|
|
16
16
|
content.SetSize(1, 1);
|
|
17
17
|
viewport.SetScrollChild(content);
|
|
18
|
-
viewport.SetScript("OnSizeChanged", (_, width) => {
|
|
18
|
+
if (!layoutOwnsWidth) viewport.SetScript("OnSizeChanged", (_, width) => {
|
|
19
19
|
const available = reveal(width);
|
|
20
20
|
if (available !== undefined) content.SetWidth(Math.max(1, available));
|
|
21
21
|
});
|
|
@@ -33,8 +33,9 @@ function createDefaultArea(parent: Frame) {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export function mountScrollView(parent: Frame, scope: RuntimeScope, props: Element<"scrollview">["props"], create?: CreateScrollArea
|
|
37
|
-
|
|
36
|
+
export function mountScrollView(parent: Frame, scope: RuntimeScope, props: Element<"scrollview">["props"], create?: CreateScrollArea,
|
|
37
|
+
layoutOwnsWidth = false) {
|
|
38
|
+
const frame = create?.(parent) ?? createDefaultArea(parent, layoutOwnsWidth);
|
|
38
39
|
const failure = bindValue(scope, props.contentHeight, height => {
|
|
39
40
|
const visible = reveal(height);
|
|
40
41
|
if (visible !== undefined && Number.isFinite(visible)) frame.SetContentHeight(Math.max(1, visible));
|
package/wow/state-paint.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { prepareStyleStates, type StatePaint, type StateStyleVariant, type Style
|
|
|
10
10
|
import { resolveStyleValue, styleValue, type StyleEnvironment } from "../src/style-variables";
|
|
11
11
|
import type { TransitionOptions } from "../src/transition";
|
|
12
12
|
import type { RGBA } from "../utils/colors";
|
|
13
|
+
import { createBackgroundPainter } from "./css-background-image";
|
|
13
14
|
import { readCssColor } from "./css-color";
|
|
14
15
|
import type { ElementStyleInput } from "./element-events";
|
|
15
16
|
import { borderSides, type CssSurface } from "./css-surfaces";
|
|
@@ -231,25 +232,15 @@ export function bindStatePaint(this: void, scope: RuntimeScope, state: NativePai
|
|
|
231
232
|
}
|
|
232
233
|
if (state?.usesBackgroundImage === true || surface.base?.backgroundImage !== undefined) {
|
|
233
234
|
const background = surface.css === undefined ? layer(surface, -7) : undefined;
|
|
234
|
-
let previous: StatePaint["backgroundImage"];
|
|
235
235
|
background?.Hide();
|
|
236
|
+
if (background !== undefined) scope.onDispose(() => background.Hide());
|
|
237
|
+
const draw = surface.css?.setBackgroundImage ?? createBackgroundPainter(background!, visible => background!.SetShown(visible), options.environment);
|
|
236
238
|
const observed = scope.watchEffect(() => {
|
|
237
239
|
const appearance = state?.evaluate() ?? ok(empty);
|
|
238
240
|
if (!appearance.ok) return appearance;
|
|
239
241
|
const image = appearance.value.backgroundImage ?? (options.liveStyle?.() ?? base)?.backgroundImage;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (surface.css !== undefined) {
|
|
243
|
-
surface.css.setBackgroundImage(image);
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (background === undefined) return;
|
|
247
|
-
if (image === undefined) background.Hide();
|
|
248
|
-
else if ("path" in image) background.SetShown(background.SetTexture(image.path.split("/").join("\\")));
|
|
249
|
-
else {
|
|
250
|
-
background.SetAtlas(image.atlas, false);
|
|
251
|
-
background.Show();
|
|
252
|
-
}
|
|
242
|
+
const drawn = draw(image);
|
|
243
|
+
if (!drawn.ok) return drawn;
|
|
253
244
|
});
|
|
254
245
|
if (!observed.ok) return observed;
|
|
255
246
|
}
|