@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.
Files changed (66) hide show
  1. package/animation/index.ts +4 -0
  2. package/animation/motion-policy.ts +20 -0
  3. package/animation/slide.ts +61 -0
  4. package/animation/spring.ts +75 -0
  5. package/animation/staggered-reveal.ts +34 -0
  6. package/builder/css-gradients.mjs +74 -0
  7. package/builder/css-mask-assets.mjs +52 -0
  8. package/builder/css-mask-assets.test.mjs +31 -0
  9. package/builder/css-v1.mjs +73 -22
  10. package/builder/css-v1.test.mjs +42 -2
  11. package/builder/src/compiler.rs +25 -0
  12. package/builder/src/lua_upvalues.rs +641 -0
  13. package/builder/src/main.rs +1 -0
  14. package/builder/style-modules.mjs +21 -3
  15. package/builder/style-modules.test.mjs +24 -0
  16. package/builder/style-states.mjs +6 -4
  17. package/package.json +1 -1
  18. package/router/index.ts +1 -0
  19. package/router/link.tsx +32 -0
  20. package/scripts/addon-build.mjs +15 -2
  21. package/scripts/addon-project.mjs +22 -11
  22. package/src/bindings.ts +10 -4
  23. package/src/context.ts +31 -7
  24. package/src/css-tokens.ts +11 -2
  25. package/src/css-v1.ts +3 -0
  26. package/src/elements.ts +9 -0
  27. package/src/flex-layout.ts +26 -5
  28. package/src/frame-scheduler.ts +3 -1
  29. package/src/index.ts +2 -2
  30. package/src/keyed-list.ts +9 -6
  31. package/src/module-ui.ts +18 -2
  32. package/src/module.ts +12 -3
  33. package/src/reactivity.ts +14 -1
  34. package/src/style-classes.ts +22 -1
  35. package/src/style-states.ts +13 -6
  36. package/state/setup-store.ts +3 -3
  37. package/templates/addon/.agents/skills/kumi-ui/SKILL.md +1 -1
  38. package/templates/addon/.claude/skills/kumi-ui/SKILL.md +1 -1
  39. package/templates/addon/AGENTS.md +1 -1
  40. package/templates/addon/kumi.config.ts +17 -17
  41. package/templates/addon/src/app/layout/{AppWindow.module.scss → AppWindow.module.css} +10 -12
  42. package/templates/addon/src/modules/greeting/ui/{Greeting.module.scss → Greeting.module.css} +9 -11
  43. package/templates/addon/src/modules/playtime/ui/{Playtime.module.scss → Playtime.module.css} +3 -5
  44. package/templates/addon/src/shared/styles/tokens.css +13 -0
  45. package/templates/addon/src/shared/ui/{Controls.module.scss → Controls.module.css} +18 -20
  46. package/wow/action-button.ts +26 -1
  47. package/wow/addon-manifest.ts +2 -0
  48. package/wow/animation.ts +3 -14
  49. package/wow/app-ui.ts +19 -10
  50. package/wow/css-background-image.ts +75 -0
  51. package/wow/css-box.ts +7 -5
  52. package/wow/css-image-mask.ts +32 -0
  53. package/wow/css-surfaces.ts +78 -31
  54. package/wow/element-events.ts +33 -13
  55. package/wow/heal-prediction.ts +2 -4
  56. package/wow/index.ts +2 -1
  57. package/wow/layout-view.ts +18 -9
  58. package/wow/module-replacements.ts +103 -0
  59. package/wow/pointer-click.ts +35 -0
  60. package/wow/protected-view.ts +49 -13
  61. package/wow/rounded-texture.ts +9 -4
  62. package/wow/state-paint.ts +5 -14
  63. package/wow/texture-fill.ts +10 -0
  64. package/wow/unit-cast.ts +6 -4
  65. package/wow/view.ts +287 -175
  66. 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";
@@ -1,5 +1,6 @@
1
1
  import type { Binding, Element, RuntimeScope } from "../src";
2
- import { layoutPercent, solveLayout, type FlexLayout, type FlexNode, type LayoutStyle, type LayoutRect, type LayoutSize } from "../src/flex-layout";
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 (typeof binding !== "object" || !("value" in binding)) return ok(binding as T);
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) && (key === "flexBasis" || layoutPercent(size.value) === undefined)) {
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
- result[key] = size.value;
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;
@@ -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, 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
- group.visibility.delete(item);
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
+ }
@@ -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
+ }
@@ -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
- /** Run only invalidated JSX effects when a protected view may write to the client. */
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: NativeViewOptions = {}): Result<ProtectedView> {
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 = update.request();
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
- if (measure) {
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
- const refresh = () => { flush = true; return update.request(); };
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 update.request(); },
137
+ refreshDisplay: () => { measure = true; return requestUpdate(); },
102
138
  }) : mounted;
103
139
  }
@@ -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 || !rounded.includes(radius) || typeof texture.SetTextureSliceMargins !== "function"
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
- return setArt(texture, readArt(prefix, radius, false), radius, wrap);
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
  }
@@ -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
- if (image === previous) return;
241
- previous = image;
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
  }
@@ -0,0 +1,10 @@
1
+ import type { Texture } from "./frames";
2
+
3
+ /** Paint an existing texture. Tiled axes need repeat sampling as well as the native tile flags. */
4
+ export function setTextureFill(this: void, texture: Texture, asset: string | number, tileX = false, tileY = false): boolean {
5
+ const loaded = texture.SetTexture(asset, tileX ? "REPEAT" : "CLAMP", tileY ? "REPEAT" : "CLAMP");
6
+ if (loaded === false) return false;
7
+ texture.SetHorizTile(tileX);
8
+ texture.SetVertTile(tileY);
9
+ return true;
10
+ }
package/wow/unit-cast.ts CHANGED
@@ -19,6 +19,8 @@ export interface UnitCast {
19
19
  readonly endMS?: CastingInfo[4];
20
20
  readonly notInterruptible?: CastingInfo[7];
21
21
  readonly spellID?: CastingInfo[8];
22
+ readonly castGUID?: CastingInfo[6];
23
+ readonly castBarID?: CastingInfo[9];
22
24
  readonly empowerStages?: number;
23
25
  }
24
26
 
@@ -41,11 +43,11 @@ function readCast(unit: string): UnitCast | undefined {
41
43
  }
42
44
 
43
45
  if (!channel) {
44
- const [name, , icon, startMS, endMS, , , notInterruptible, spellID] = api.UnitCastingInfo(unit);
45
- if (present(name)) return { unit, channel: false, duration, name, icon, startMS, endMS, notInterruptible, spellID };
46
+ const [name, , icon, startMS, endMS, , castGUID, notInterruptible, spellID, castBarID] = api.UnitCastingInfo(unit);
47
+ if (present(name)) return { unit, channel: false, duration, name, icon, startMS, endMS, notInterruptible, spellID, castGUID, castBarID };
46
48
  }
47
49
 
48
- const [name, , icon, startMS, rawEndMS, , notInterruptible, spellID, , rawStages] = api.UnitChannelInfo(unit);
50
+ const [name, , icon, startMS, rawEndMS, , notInterruptible, spellID, , rawStages, castBarID] = api.UnitChannelInfo(unit);
49
51
  const stages = reveal(rawStages);
50
52
  const empowerStages = stages !== undefined && stages > 0 ? stages : undefined;
51
53
  let endMS = rawEndMS;
@@ -59,7 +61,7 @@ function readCast(unit: string): UnitCast | undefined {
59
61
  }
60
62
 
61
63
  if (present(name) || present(duration)) {
62
- return { unit, channel: true, duration, name, icon, startMS, endMS, notInterruptible, spellID, empowerStages };
64
+ return { unit, channel: true, duration, name, icon, startMS, endMS, notInterruptible, spellID, castBarID, empowerStages };
63
65
  }
64
66
  }
65
67