@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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Binding, Element, RuntimeScope, StatusBarValue } from "../src";
|
|
2
|
+
import { ok, type Failure, type Result } from "../src/result";
|
|
3
|
+
import type { StatusBar } from "./frames";
|
|
4
|
+
import { api } from "./native";
|
|
5
|
+
|
|
6
|
+
type StatusBarProps = Element<"statusbar">["props"];
|
|
7
|
+
type NativeValue = Parameters<StatusBar["SetValue"]>[0];
|
|
8
|
+
|
|
9
|
+
/** Box a WoW number so application refs can publish it without comparing the number. */
|
|
10
|
+
export function statusBarValue(this: void, value: NativeValue): StatusBarValue {
|
|
11
|
+
return { nativeValue: value } as StatusBarValue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function readBinding(binding: Binding<number>): Result<number>;
|
|
15
|
+
function readBinding(binding: Binding<StatusBarValue>): Result<StatusBarValue>;
|
|
16
|
+
function readBinding(binding: Binding<StatusBarValue>): Result<StatusBarValue> {
|
|
17
|
+
if (typeof binding === "number" || "nativeValue" in binding) return ok(binding);
|
|
18
|
+
const value = binding.value;
|
|
19
|
+
return typeof value === "object" && "ok" in value ? value : ok(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function unwrap(value: StatusBarValue): NativeValue {
|
|
23
|
+
return typeof value === "number" ? value : value.nativeValue as NativeValue;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function bindStatusBar(this: void, scope: RuntimeScope, bar: StatusBar,
|
|
27
|
+
{ min, max, value, smooth, resetKey = 0 }: StatusBarProps, reduceMotion?: (this: void) => boolean): Failure | undefined {
|
|
28
|
+
const nativeInterpolation = smooth === true ? api.Enum?.StatusBarInterpolation?.ExponentialEaseOut : undefined;
|
|
29
|
+
let previousMin: StatusBarValue | undefined;
|
|
30
|
+
let previousMax: StatusBarValue | undefined;
|
|
31
|
+
let previousValue: StatusBarValue | undefined;
|
|
32
|
+
let previousKey: number | undefined;
|
|
33
|
+
let wasSmoothing = false;
|
|
34
|
+
const subscription = scope.watchEffect(() => {
|
|
35
|
+
const nextMin = readBinding(min);
|
|
36
|
+
const nextMax = readBinding(max);
|
|
37
|
+
const nextValue = readBinding(value);
|
|
38
|
+
const nextKey = readBinding(resetKey);
|
|
39
|
+
if (!nextMin.ok) return nextMin;
|
|
40
|
+
if (!nextMax.ok) return nextMax;
|
|
41
|
+
if (!nextValue.ok) return nextValue;
|
|
42
|
+
if (!nextKey.ok) return nextKey;
|
|
43
|
+
|
|
44
|
+
// Compare only readable bounds and wrapper identities. Native setters consume the payloads.
|
|
45
|
+
const boundsChanged = previousMin !== nextMin.value || previousMax !== nextMax.value;
|
|
46
|
+
const canSmooth = nativeInterpolation !== undefined && reduceMotion?.() !== true;
|
|
47
|
+
const reset = boundsChanged || previousKey !== nextKey.value;
|
|
48
|
+
if (boundsChanged) bar.SetMinMaxValues(unwrap(nextMin.value), unwrap(nextMax.value));
|
|
49
|
+
if (reset || previousValue !== nextValue.value || (wasSmoothing && !canSmooth)) {
|
|
50
|
+
const interpolate = canSmooth && !reset;
|
|
51
|
+
if (interpolate) {
|
|
52
|
+
bar.SetValue(unwrap(nextValue.value), nativeInterpolation);
|
|
53
|
+
} else {
|
|
54
|
+
bar.SetValue(unwrap(nextValue.value));
|
|
55
|
+
if (wasSmoothing) bar.SetToTargetValue?.();
|
|
56
|
+
}
|
|
57
|
+
wasSmoothing = interpolate;
|
|
58
|
+
}
|
|
59
|
+
previousMin = nextMin.value;
|
|
60
|
+
previousMax = nextMax.value;
|
|
61
|
+
previousValue = nextValue.value;
|
|
62
|
+
previousKey = nextKey.value;
|
|
63
|
+
});
|
|
64
|
+
return subscription.ok ? undefined : subscription;
|
|
65
|
+
}
|
|
@@ -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-button.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { fail, type Result } from "../src/result";
|
|
1
|
+
import { fail, type Failure, type Result } from "../src/result";
|
|
2
|
+
import type { RuntimeScope } from "../src/runtime";
|
|
2
3
|
import { createFrame, type Button, type FrameParent } from "./frames";
|
|
4
|
+
import { luaString } from "./lua-string";
|
|
3
5
|
import { api, isSecret } from "./native";
|
|
4
6
|
import { protect } from "./protect";
|
|
7
|
+
import { stateDriver } from "./secure-state";
|
|
5
8
|
|
|
6
9
|
export interface SecureUnitButtonOptions {
|
|
7
10
|
unit: string;
|
|
@@ -13,6 +16,26 @@ const secureTemplate = "SecureUnitButtonTemplate";
|
|
|
13
16
|
const pingTemplate = "PingableUnitFrameTemplate";
|
|
14
17
|
let unitTemplate: string | undefined;
|
|
15
18
|
|
|
19
|
+
function configureUnit(button: Button, unit: string, menu: boolean) {
|
|
20
|
+
button.SetAttribute("unit", unit);
|
|
21
|
+
button.SetAttribute("*type1", "target");
|
|
22
|
+
if (menu) button.SetAttribute("*type2", "togglemenu");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Configure the secure button allocated by the JSX renderer. */
|
|
26
|
+
export function bindSecureUnit(button: Button, scope: RuntimeScope, unit: string, menu = false): Failure | undefined {
|
|
27
|
+
if (isSecret(unit) || typeof unit !== "string" || luaString.match(unit, "^[a-z][a-z0-9]*$") === undefined) {
|
|
28
|
+
return fail("A secure unit button needs a readable unit token");
|
|
29
|
+
}
|
|
30
|
+
configureUnit(button, unit, menu);
|
|
31
|
+
const clicks = button as Button & { SetAttribute(this: object, key: string, value: boolean): void };
|
|
32
|
+
clicks.SetAttribute("useOnKeyDown", false);
|
|
33
|
+
button.RegisterForClicks("LeftButtonUp", "RightButtonUp");
|
|
34
|
+
button.Hide();
|
|
35
|
+
const visibility = stateDriver(button, "visibility", "[@" + unit + ",exists] show; hide", { scope });
|
|
36
|
+
return visibility.ok ? undefined : visibility;
|
|
37
|
+
}
|
|
38
|
+
|
|
16
39
|
function templateFor(pingable: boolean) {
|
|
17
40
|
if (!pingable) return secureTemplate;
|
|
18
41
|
if (unitTemplate === undefined) {
|
|
@@ -30,9 +53,7 @@ export function createSecureUnitButton(this: void, parent: FrameParent, { unit,
|
|
|
30
53
|
return protect(() => {
|
|
31
54
|
const button = createFrame("Button", name, parent, templateFor(pingable));
|
|
32
55
|
// The ping mixin must resolve the token from the secure attribute.
|
|
33
|
-
button
|
|
34
|
-
button.SetAttribute("*type1", "target");
|
|
35
|
-
button.SetAttribute("*type2", "togglemenu");
|
|
56
|
+
configureUnit(button, unit, true);
|
|
36
57
|
button.RegisterForClicks("AnyUp");
|
|
37
58
|
return button;
|
|
38
59
|
});
|
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
|
|
package/wow/view-nodes.ts
CHANGED
|
@@ -295,10 +295,17 @@ export function mountViewNode<Kind extends MountedElementKind>(this: void, scope
|
|
|
295
295
|
return node;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
/** Clear an attached ref even if its callback disposes the view synchronously. */
|
|
299
|
+
export function attachViewRef<Value>(this: void, scope: RuntimeScope, ref: ((this: void, value?: Value) => void) | undefined,
|
|
300
|
+
value: (this: void) => Value): Failure | undefined {
|
|
300
301
|
if (ref === undefined) return;
|
|
301
|
-
const
|
|
302
|
+
const cleanup = scope.onDispose(() => ref(undefined));
|
|
303
|
+
if (!cleanup.ok) return cleanup;
|
|
304
|
+
const exposed = scope.protect(() => ref(value()));
|
|
302
305
|
if (!exposed.ok) return exposed;
|
|
303
|
-
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function finishViewNode<Kind extends MountedElementKind>(this: void, scope: RuntimeScope, node: LogicalNode<Kind>,
|
|
309
|
+
ref?: (this: void, value?: KumiNode<Kind>) => void): Failure | undefined {
|
|
310
|
+
if (ref !== undefined) return attachViewRef(scope, ref, () => expose(node));
|
|
304
311
|
}
|