@overmvp/kumi 0.1.0 → 0.3.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/README.md +59 -6
- package/builder/css-v1.mjs +54 -1
- package/builder/css-v1.test.mjs +40 -0
- package/builder/link-addon-package.mjs +47 -6
- package/builder/module-declarations.test.mjs +9 -18
- package/builder/native-kernels.mjs +1 -1
- package/builder/src/compiler.rs +180 -8
- package/builder/src/main.rs +19 -5
- package/builder/src/native_ir.rs +1 -1
- package/builder/src/native_signal.rs +46 -10
- package/builder/src/numbers.lua +14 -0
- package/builder/src/project-front.mjs +385 -34
- package/builder/src/routes.rs +11 -14
- package/builder/src/setup-store.lua +18 -0
- package/builder/src/signal-kernel.fingerprint +1 -1
- package/builder/src/ts-lower.mjs +2 -2
- package/builder/src/wow-reads.lua +22 -0
- package/builder/style-modules.mjs +93 -0
- package/config.ts +56 -14
- package/eslint.mjs +74 -0
- package/form/index.ts +15 -11
- package/package.json +11 -7
- package/router/index.ts +9 -2
- package/router/navigation.ts +22 -0
- package/router/router-view.ts +134 -0
- package/scripts/addon-build.mjs +364 -0
- package/scripts/addon-project.mjs +78 -0
- package/scripts/kumi-cli.mjs +52 -17
- package/scripts/link-addons.mjs +12 -2
- package/src/bindings.ts +2 -2
- package/src/css-tokens.ts +16 -11
- package/src/css-v1.ts +10 -0
- package/src/elements.ts +26 -0
- package/src/frame-scheduler.ts +3 -1
- package/src/index.ts +1 -0
- package/src/jsx-runtime.ts +8 -1
- package/src/keyed-list.ts +8 -5
- package/src/module-ui.ts +147 -0
- package/src/module.ts +42 -8
- package/src/owned-collections.ts +8 -0
- package/src/providers.ts +7 -1
- package/src/reactive-scope.ts +3 -3
- package/src/reactivity.ts +28 -7
- package/src/result.ts +6 -0
- package/src/signal-kernel.ts +35 -2
- package/state/index.ts +6 -0
- package/state/setup-store-persistence.ts +206 -0
- package/state/setup-store-view.ts +10 -0
- package/state/setup-store.ts +342 -0
- package/state/store.ts +2 -0
- package/templates/addon/.agents/skills/kumi-build-debug/SKILL.md +36 -0
- package/templates/addon/.agents/skills/kumi-feature/SKILL.md +50 -0
- package/templates/addon/.agents/skills/kumi-plugin/SKILL.md +36 -0
- package/templates/addon/.agents/skills/kumi-store/SKILL.md +47 -0
- package/templates/addon/.agents/skills/kumi-ui/SKILL.md +73 -0
- package/templates/addon/.agents/skills/kumi-wow-api/SKILL.md +30 -0
- package/templates/addon/.claude/skills/kumi-build-debug/SKILL.md +36 -0
- package/templates/addon/.claude/skills/kumi-feature/SKILL.md +50 -0
- package/templates/addon/.claude/skills/kumi-plugin/SKILL.md +36 -0
- package/templates/addon/.claude/skills/kumi-store/SKILL.md +47 -0
- package/templates/addon/.claude/skills/kumi-ui/SKILL.md +73 -0
- package/templates/addon/.claude/skills/kumi-wow-api/SKILL.md +30 -0
- package/templates/addon/AGENTS.md +34 -0
- package/templates/addon/Assets/Art/Corner10.tga +0 -0
- package/templates/addon/Assets/Art/Corner11.tga +0 -0
- package/templates/addon/Assets/Art/Corner12.tga +0 -0
- package/templates/addon/Assets/Art/Corner13.tga +0 -0
- package/templates/addon/Assets/Art/Corner14.tga +0 -0
- package/templates/addon/Assets/Art/Corner15.tga +0 -0
- package/templates/addon/Assets/Art/Corner16.tga +0 -0
- package/templates/addon/Assets/Art/Corner2.tga +0 -0
- package/templates/addon/Assets/Art/Corner3.tga +0 -0
- package/templates/addon/Assets/Art/Corner4.tga +0 -0
- package/templates/addon/Assets/Art/Corner5.tga +0 -0
- package/templates/addon/Assets/Art/Corner6.tga +0 -0
- package/templates/addon/Assets/Art/Corner7.tga +0 -0
- package/templates/addon/Assets/Art/Corner8.tga +0 -0
- package/templates/addon/Assets/Art/Corner9.tga +0 -0
- package/templates/addon/Assets/Art/Dot.tga +0 -0
- package/templates/addon/Assets/Art/Gear.tga +0 -0
- package/templates/addon/Assets/Art/Grip.tga +0 -0
- package/templates/addon/Assets/Art/Outline10.tga +0 -0
- package/templates/addon/Assets/Art/Outline12.tga +0 -0
- package/templates/addon/Assets/Art/Outline13.tga +0 -0
- package/templates/addon/Assets/Art/Outline14.tga +0 -0
- package/templates/addon/Assets/Art/Outline15.tga +0 -0
- package/templates/addon/Assets/Art/Outline2.tga +0 -0
- package/templates/addon/Assets/Art/Outline3.tga +0 -0
- package/templates/addon/Assets/Art/Outline5.tga +0 -0
- package/templates/addon/Assets/Art/Outline7.tga +0 -0
- package/templates/addon/Assets/Art/Outline9.tga +0 -0
- package/templates/addon/Assets/Art/Round11.tga +0 -0
- package/templates/addon/Assets/Art/Round11Border.tga +0 -0
- package/templates/addon/Assets/Art/Round4.tga +0 -0
- package/templates/addon/Assets/Art/Round4Border.tga +0 -0
- package/templates/addon/Assets/Art/Round6.tga +0 -0
- package/templates/addon/Assets/Art/Round6Border.tga +0 -0
- package/templates/addon/Assets/Art/Round8.tga +0 -0
- package/templates/addon/Assets/Art/Round8Border.tga +0 -0
- package/templates/addon/Assets/Art/Search.tga +0 -0
- package/templates/addon/CLAUDE.md +1 -0
- package/templates/addon/README.md +42 -7
- package/templates/addon/eslint.config.mjs +3 -9
- package/templates/addon/gitignore +1 -0
- package/templates/addon/kumi.config.ts +17 -0
- package/templates/addon/package.json +4 -5
- package/templates/addon/src/app/app.module.ts +18 -0
- package/templates/addon/src/app/commands.store.ts +11 -0
- package/templates/addon/src/app/layout/AppWindow.module.scss +92 -0
- package/templates/addon/src/app/layout/AppWindow.tsx +32 -0
- package/templates/addon/src/app/main.ts +5 -0
- package/templates/addon/src/app/routes/(window)/home/page.tsx +8 -0
- package/templates/addon/src/app/routes/(window)/plugins/page.tsx +38 -0
- package/templates/addon/src/app/routes/(window)/settings/page.tsx +8 -0
- package/templates/addon/src/app/theme.ts +6 -0
- package/templates/addon/src/modules/greeting/api/player.api.ts +29 -0
- package/templates/addon/src/modules/greeting/greeting.module.ts +18 -0
- package/templates/addon/src/modules/greeting/model/greeting.store.ts +81 -0
- package/templates/addon/src/modules/greeting/services/greeting.service.ts +38 -0
- package/templates/addon/src/modules/greeting/ui/Greeting.module.scss +105 -0
- package/templates/addon/src/modules/greeting/ui/GreetingCard.tsx +29 -0
- package/templates/addon/src/modules/greeting/widgets/GreetingHud.tsx +54 -0
- package/templates/addon/src/modules/greeting/widgets/GreetingOverview.tsx +18 -0
- package/templates/addon/src/modules/greeting/widgets/GreetingSettings.tsx +56 -0
- package/templates/addon/src/modules/playtime/api/clock.api.ts +6 -0
- package/templates/addon/src/modules/playtime/model/playtime.store.ts +19 -0
- package/templates/addon/src/modules/playtime/playtime.module.ts +18 -0
- package/templates/addon/src/modules/playtime/services/playtime.service.ts +18 -0
- package/templates/addon/src/modules/playtime/ui/Playtime.module.scss +25 -0
- package/templates/addon/src/modules/playtime/ui/PlaytimeBadge.tsx +10 -0
- package/templates/addon/src/modules/playtime/widgets/PlaytimePage.tsx +16 -0
- package/templates/addon/src/shared/api/native-art.ts +28 -0
- package/templates/addon/src/shared/assets/close.png +0 -0
- package/templates/addon/src/shared/lib/format.ts +20 -0
- package/templates/addon/src/shared/styles/_tokens.scss +12 -0
- package/templates/addon/src/shared/ui/Button.tsx +29 -0
- package/templates/addon/src/shared/ui/Choice.tsx +34 -0
- package/templates/addon/src/shared/ui/Controls.module.scss +93 -0
- package/templates/addon/src/shared/ui/Glyph.tsx +18 -0
- package/templates/addon/src/shared/ui/Slider.tsx +25 -0
- package/templates/addon/src/shared/ui/Toggle.tsx +29 -0
- package/templates/addon/src/shared/ui/focus-ref.ts +7 -0
- package/templates/addon/src/shared/ui/range-skin.tsx +15 -0
- package/templates/addon/tsconfig.json +49 -10
- package/wow/action-bar-layout.ts +108 -0
- package/wow/action-button.ts +219 -0
- package/wow/action-catalog.ts +98 -0
- package/wow/addon-manifest.ts +36 -0
- package/wow/app-ui.ts +221 -0
- package/wow/cooldown-timing.ts +24 -0
- package/wow/css-box.ts +40 -6
- package/wow/css-surfaces.ts +229 -24
- package/wow/cursor.ts +45 -0
- package/wow/frame-access.ts +23 -1
- package/wow/frame-timing.ts +13 -0
- package/wow/hooks.ts +133 -0
- package/wow/index.ts +18 -4
- package/wow/layout-view.ts +26 -14
- package/wow/locale-font.ts +15 -0
- package/wow/native.ts +18 -0
- package/wow/panel-host.ts +97 -0
- package/wow/pixel.ts +35 -0
- package/wow/plugins.ts +246 -0
- package/wow/protect.ts +27 -3
- package/wow/protected-view.ts +103 -0
- package/wow/range-art.ts +7 -0
- package/wow/readable-api.ts +120 -0
- package/wow/rounded-texture.ts +33 -6
- package/wow/saved-variables.ts +67 -18
- package/wow/spell-cooldown.ts +36 -0
- package/wow/start-addon.ts +31 -8
- package/wow/view.ts +201 -83
- package/templates/addon/__ADDON_NAME__.toc +0 -4
- package/templates/addon/scripts/build.mjs +0 -25
- package/templates/addon/src/app/main.tsx +0 -13
package/wow/view.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { bindValue } from "../src/bindings";
|
|
|
3
3
|
import type { CssTokenRecipe } from "../src/css-v1";
|
|
4
4
|
import { bindImageSize, imageSize, positiveImageDimension } from "../src/images";
|
|
5
5
|
import { attachMediaReads, markMediaReads, type MediaRead } from "../src/media-query";
|
|
6
|
-
import { ownedMap, ownedSet, type OwnedArray, type OwnedReadonlyArray, type OwnedRecord, type OwnedSet } from "../src/owned-collections";
|
|
6
|
+
import { ownedArray, ownedMap, ownedSet, type OwnedArray, type OwnedReadonlyArray, type OwnedRecord, type OwnedSet } from "../src/owned-collections";
|
|
7
7
|
import { ref } from "../src/reactivity";
|
|
8
8
|
import { withReactiveScope } from "../src/reactive-scope";
|
|
9
9
|
import { fail, ok, type Failure, type Result } from "../src/result";
|
|
@@ -24,15 +24,16 @@ import { frameStrata, maximumFrameLevel, type FrameStrata } from "./frame-layer"
|
|
|
24
24
|
import { mountImageLayers } from "./image-layers";
|
|
25
25
|
import { mountScrollView, type CreateScrollArea, type ScrollArea } from "./scroll-view";
|
|
26
26
|
import { bindButtonDrag } from "./button-drag";
|
|
27
|
+
import { bindActionVisibility, bindButtonMove, bindSecureAction, listenForDrop, unlockedActionSlot } from "./action-button";
|
|
27
28
|
import { bindElementEvents, hasElementInput, type NativeElementEventHost } from "./element-events";
|
|
28
29
|
import { api, isSecret, reveal } from "./native";
|
|
29
|
-
import { hookSecureMethod } from "./native-hooks";
|
|
30
|
+
import { hookScript, hookSecureMethod } from "./native-hooks";
|
|
30
31
|
import { rawField } from "./lua-table";
|
|
31
32
|
import { observeContainer, type NativeMediaOptions } from "./media-query";
|
|
32
33
|
import { mountRangeArt } from "./range-art";
|
|
33
34
|
import { protect } from "./protect";
|
|
34
35
|
import { animateVisibility } from "./transition";
|
|
35
|
-
import { attachLayoutItem, mountLayoutRoot, NativeLayoutItem, readLayoutValue, type NativeLayoutDiagnostics, type NativeLayoutGroup, type StageInitialLayout } from "./layout-view";
|
|
36
|
+
import { attachLayoutItem, isAbsoluteFill, mountLayoutRoot, NativeLayoutItem, readLayoutValue, type NativeLayoutDiagnostics, type NativeLayoutGroup, type StageInitialLayout } from "./layout-view";
|
|
36
37
|
import { finishViewNode, mountLogicalGroup, mountViewNode, orderLogicalRows, type LogicalGroup, type LogicalNode } from "./view-nodes";
|
|
37
38
|
import { bindStatePaint, createNativePaintState, type ButtonPaintTiming, type NativeButtonPaintMotion, type NativePaintState,
|
|
38
39
|
type NativeStateColor, type TextColorStateChange } from "./state-paint";
|
|
@@ -40,6 +41,7 @@ import type { FlexNode } from "../src/flex-layout";
|
|
|
40
41
|
|
|
41
42
|
type Frame = FrameMap["Frame"];
|
|
42
43
|
declare const GameFontNormal: Parameters<FrameMap["EditBox"]["SetFontObject"]>[0];
|
|
44
|
+
declare function rawequal(this: void, left: unknown, right: unknown): boolean;
|
|
43
45
|
type Region = Pick<FontString, "ClearAllPoints" | "SetWidth" | "SetHeight" | "SetSize" | "SetPoint" | "SetShown" | "IsShown"
|
|
44
46
|
| "SetAlpha" | "GetSize" | "IsForbidden" | "GetObjectType">;
|
|
45
47
|
type LayoutParent = NativeLayoutGroup | NativeLayoutItem;
|
|
@@ -232,7 +234,7 @@ function bindViewMedia(node: UIElement, scope: RuntimeScope, options: MountOptio
|
|
|
232
234
|
return result;
|
|
233
235
|
}
|
|
234
236
|
|
|
235
|
-
function bind<T extends string | boolean | number | Anchor>(scope: RuntimeScope, value: Binding<T>,
|
|
237
|
+
function bind<T extends string | boolean | number | Anchor | undefined>(scope: RuntimeScope, value: Binding<T>,
|
|
236
238
|
apply: (this: void, value: T) => void, validate?: (this: void, value: T) => Failure | undefined) {
|
|
237
239
|
return bindValue(scope, value, apply, (previous, current) => !isSecret(previous) && !isSecret(current) && previous === current, validate);
|
|
238
240
|
}
|
|
@@ -295,6 +297,36 @@ function placeFrame(frame: Region & Pick<Frame, "SetFrameLevel">, parent: FrameP
|
|
|
295
297
|
return place(frame, parent, props, scope, motion, flex, undefined, undefined, paint, undefined, startAfter, endBefore);
|
|
296
298
|
}
|
|
297
299
|
|
|
300
|
+
function bindNativeSize(region: Region, scope: RuntimeScope, width: NativeStyle["width"], height: NativeStyle["height"],
|
|
301
|
+
combine: boolean, afterWidth?: (this: void, width: number) => void): Failure | undefined {
|
|
302
|
+
if (combine && afterWidth === undefined && typeof region.SetSize === "function") {
|
|
303
|
+
if (typeof width === "number" && typeof height === "number" && !isSecret(width) && !isSecret(height)
|
|
304
|
+
&& Number.isFinite(width) && Number.isFinite(height) && width >= 0 && height >= 0) {
|
|
305
|
+
region.SetSize(width, height);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
if (typeof width === "object" && !isSecret(width) && !isSecret(height) && rawequal(width, height)) {
|
|
309
|
+
return bind(scope, width, value => {
|
|
310
|
+
if (typeof value !== "number") return;
|
|
311
|
+
if (!isSecret(value) && Number.isFinite(value) && value >= 0) region.SetSize(value, value);
|
|
312
|
+
else {
|
|
313
|
+
region.SetWidth(value);
|
|
314
|
+
region.SetHeight(value);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
// A percent size needs a flow to resolve against; out of flow it is an auto size.
|
|
320
|
+
return (width === undefined ? undefined : bind(scope, width, value => {
|
|
321
|
+
if (typeof value !== "number") return;
|
|
322
|
+
region.SetWidth(value);
|
|
323
|
+
const plain = reveal(value);
|
|
324
|
+
if (plain !== undefined) afterWidth?.(plain);
|
|
325
|
+
})) ?? (height === undefined ? undefined : bind(scope, height, value => {
|
|
326
|
+
if (typeof value === "number") region.SetHeight(value);
|
|
327
|
+
}));
|
|
328
|
+
}
|
|
329
|
+
|
|
298
330
|
function place(region: Region, parent: FrameParent, props: Layout, scope: RuntimeScope, motion?: TransitionOptions,
|
|
299
331
|
flex?: LayoutParent, measure?: FlexNode["measure"], minContentWidth?: FlexNode["minContentWidth"], paint?: NativePaintState,
|
|
300
332
|
afterWidth?: (this: void, width: number) => void, startAfter?: NativeStartTarget, endBefore?: NativeEndTarget) {
|
|
@@ -342,17 +374,7 @@ function place(region: Region, parent: FrameParent, props: Layout, scope: Runtim
|
|
|
342
374
|
anchor(point, x, y + motionOffset);
|
|
343
375
|
});
|
|
344
376
|
const layoutFailure = anchored
|
|
345
|
-
|
|
346
|
-
?? (item === undefined && !props.fullWidth && width !== undefined ? bind(scope, width, value => {
|
|
347
|
-
if (typeof value === "number") {
|
|
348
|
-
region.SetWidth(value);
|
|
349
|
-
const plain = reveal(value);
|
|
350
|
-
if (plain !== undefined) afterWidth?.(plain);
|
|
351
|
-
}
|
|
352
|
-
}) : undefined)
|
|
353
|
-
?? (item === undefined && height !== undefined ? bind(scope, height, value => {
|
|
354
|
-
if (typeof value === "number") region.SetHeight(value);
|
|
355
|
-
}) : undefined)
|
|
377
|
+
?? (item === undefined ? bindNativeSize(region, scope, props.fullWidth ? undefined : width, height, !absolute, afterWidth) : undefined)
|
|
356
378
|
?? (baseOpacity !== undefined ? bind(scope, baseOpacity, value => {
|
|
357
379
|
const next = reveal(value);
|
|
358
380
|
if (next === undefined) return;
|
|
@@ -510,7 +532,7 @@ function mountPortal(parent: Frame, node: Element<"portal">, scope: RuntimeScope
|
|
|
510
532
|
}
|
|
511
533
|
}
|
|
512
534
|
|
|
513
|
-
function bindRegionEvents(parent: Frame, region: Region, props: Element<"text"
|
|
535
|
+
function bindRegionEvents(parent: Frame, region: Region, props: Element<"text" | "image" | "texture">["props"],
|
|
514
536
|
scope: RuntimeScope, options: MountOptions, logical: LogicalNode, paint?: NativePaintState) {
|
|
515
537
|
if (!hasElementInput(props) && paint?.needs("hover") !== true && paint?.needs("active") !== true) return;
|
|
516
538
|
if (options.regionsOnly === true) return fail("Native region mounts do not create input frames");
|
|
@@ -651,7 +673,8 @@ function fixedSize<T>(size: T): Exclude<T, `${number}%`> | undefined {
|
|
|
651
673
|
}
|
|
652
674
|
|
|
653
675
|
const inlineBlocks: Partial<Record<UIElement["kind"], true>> = {
|
|
654
|
-
button: true, checkbox: true, range: true, listbox: true, editbox: true, image: true,
|
|
676
|
+
button: true, checkbox: true, range: true, listbox: true, editbox: true, image: true, texture: true,
|
|
677
|
+
statusbar: true, cooldown: true,
|
|
655
678
|
};
|
|
656
679
|
|
|
657
680
|
/**
|
|
@@ -832,10 +855,13 @@ function mountText(parent: Frame, node: Element<"text">, scope: RuntimeScope, op
|
|
|
832
855
|
?? finishViewNode(scope, logical, node.props.nodeRef);
|
|
833
856
|
}
|
|
834
857
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
858
|
+
const noIntrinsicImage: Element<"image">["props"]["src"] = { path: "" };
|
|
859
|
+
|
|
860
|
+
function mountImage(parent: Frame, node: Element<"image"> | Element<"texture">, scope: RuntimeScope, options: MountOptions,
|
|
861
|
+
group: LogicalGroup, motion?: TransitionOptions, environment?: StyleEnvironment, flow?: NativeLayoutGroup,
|
|
862
|
+
typography?: NativeTextStyle, liveStyle?: ReadCssStyle): Failure | undefined {
|
|
863
|
+
const { width, height, style, verticalGradient, nativePixelSnap, nativeDesaturated } = node.props;
|
|
864
|
+
const src = node.kind === "image" ? node.props.src : noIntrinsicImage;
|
|
839
865
|
const automatic = flow !== undefined && node.props.anchor === undefined;
|
|
840
866
|
const absolute = node.props.anchor === undefined && style?.position === "absolute"
|
|
841
867
|
&& style.margin === undefined && style.autoMargin === undefined;
|
|
@@ -857,8 +883,21 @@ function mountImage(parent: Frame, node: Element<"image">, scope: RuntimeScope,
|
|
|
857
883
|
texture.SetSnapToPixelGrid?.(false);
|
|
858
884
|
texture.SetTexelSnappingBias?.(0);
|
|
859
885
|
}
|
|
860
|
-
|
|
861
|
-
|
|
886
|
+
if (node.kind === "image") {
|
|
887
|
+
texture.SetTexture(src.path);
|
|
888
|
+
texture.SetTexCoord(0, src.uMax ?? 1, 0, src.vMax ?? 1);
|
|
889
|
+
} else {
|
|
890
|
+
const { src: source, texCoords, onSourceChange } = node.props;
|
|
891
|
+
if (texCoords !== undefined) texture.SetTexCoord(...texCoords);
|
|
892
|
+
let mounted = false;
|
|
893
|
+
const bound = bind(scope, source, value => {
|
|
894
|
+
if (isSecret(value)) return;
|
|
895
|
+
texture.SetTexture(value);
|
|
896
|
+
if (mounted) onSourceChange?.(value);
|
|
897
|
+
});
|
|
898
|
+
if (bound !== undefined) return bound;
|
|
899
|
+
mounted = true;
|
|
900
|
+
}
|
|
862
901
|
const paint = createNativePaintState(style, environment);
|
|
863
902
|
// Both native points carry the parent size, including resizes after this image is mounted.
|
|
864
903
|
const geometry = fillsWidth || fillsHeight
|
|
@@ -887,7 +926,7 @@ function mountImage(parent: Frame, node: Element<"image">, scope: RuntimeScope,
|
|
|
887
926
|
});
|
|
888
927
|
if (gradientFailure !== undefined) return gradientFailure;
|
|
889
928
|
}
|
|
890
|
-
options?.image?.(texture, parent, node.props);
|
|
929
|
+
if (node.kind === "image") options?.image?.(texture, parent, node.props);
|
|
891
930
|
const inherited = node.props.inheritColor === true ? typography : undefined;
|
|
892
931
|
return bindNativeTint(scope, style, paint, options, (r, g, b, a) => texture.SetVertexColor(r, g, b, a),
|
|
893
932
|
() => captureImageTint(texture), motion, environment, liveStyle, inherited?.color,
|
|
@@ -909,6 +948,91 @@ function hasInteractivePaint(style: NativeStyle | undefined, kind: UIElement["ki
|
|
|
909
948
|
return false;
|
|
910
949
|
}
|
|
911
950
|
|
|
951
|
+
function mountButtonContent(button: FrameMap["Button"], node: Element<"button">, scope: RuntimeScope, options: MountOptions,
|
|
952
|
+
group: LogicalGroup, paint: NativePaintState | undefined, motion: TransitionOptions | undefined,
|
|
953
|
+
environment: StyleEnvironment | undefined, typography: NativeTextStyle | undefined, liveStyle: ReadCssStyle | undefined,
|
|
954
|
+
buttonTiming: ButtonPaintTiming | undefined): Failure | undefined {
|
|
955
|
+
const appearance = inheritTextStyle(typography, node.props.style, environment, paint, undefined, liveStyle,
|
|
956
|
+
options.inheritedTextColorDuration, buttonTiming);
|
|
957
|
+
for (const child of node.children as NativeChildren) {
|
|
958
|
+
const failure = mountChild(button, child, scope, options, group, undefined, environment, undefined, appearance);
|
|
959
|
+
if (failure) return failure;
|
|
960
|
+
}
|
|
961
|
+
const label = paint?.usesColor === true ? button.GetFontString() : undefined;
|
|
962
|
+
return bindFramePaint(button, node.props.style, paint, scope, options, motion, environment, liveStyle,
|
|
963
|
+
label === undefined ? undefined : { read: () => label.GetTextColor(), write: (r, g, b, a) => label.SetTextColor(r, g, b, a) },
|
|
964
|
+
node.props.nativeRoundedArt, buttonTiming);
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
function mountButton(parent: Frame, node: Element<"button">, scope: RuntimeScope, options: MountOptions, group: LogicalGroup,
|
|
968
|
+
motion: TransitionOptions | undefined, environment: StyleEnvironment | undefined, flow: NativeLayoutGroup | undefined,
|
|
969
|
+
typography: NativeTextStyle | undefined, rootControl: { unanchored?: boolean; attach(this: void, frame: Frame): void } | undefined,
|
|
970
|
+
liveStyle: ReadCssStyle | undefined, manualControl: ManualControlBindings | undefined): Failure | undefined {
|
|
971
|
+
const { value, unstyled, disabled, checked } = node.props;
|
|
972
|
+
const { secureAction, onReceiveDrag } = node.props;
|
|
973
|
+
const secure = secureAction !== undefined;
|
|
974
|
+
if (secure && !unlockedActionSlot()) return fail("Secure action buttons must mount outside combat");
|
|
975
|
+
const plain = unstyled === true || secure;
|
|
976
|
+
const factory = plain ? undefined : options?.createButton;
|
|
977
|
+
const created = factory === undefined ? undefined : protect(() => factory(parent, node.props, scope));
|
|
978
|
+
if (created?.ok === false) return created;
|
|
979
|
+
const custom = created?.value;
|
|
980
|
+
const button = custom ?? createFrame("Button", undefined, parent,
|
|
981
|
+
secure ? "SecureActionButtonTemplate" : plain ? undefined : "UIPanelButtonTemplate");
|
|
982
|
+
rootControl?.attach(button);
|
|
983
|
+
const duration = options.inheritedTextColorDuration;
|
|
984
|
+
const colorMotion = options.buttonPaintMotion?.(button, node.props);
|
|
985
|
+
const paint = createNativePaintState(node.props.style, environment, duration !== undefined, colorMotion?.repaint);
|
|
986
|
+
const buttonTiming: ButtonPaintTiming | undefined = colorMotion === undefined ? undefined
|
|
987
|
+
: { ...colorMotion as OwnedRecord<typeof colorMotion>, change: paint?.colorChange, visible: () => reveal(button.IsVisible()) === true };
|
|
988
|
+
const startAfter = options.buttonStartAfter?.(parent, node.props);
|
|
989
|
+
const deferred = secure && node.props.deferContentUntilShown === true && node.props.anchor !== undefined
|
|
990
|
+
&& options.bindings !== "manual" && motion === undefined && node.props.style?.display !== "none" ? node.props.shown : undefined;
|
|
991
|
+
const unanchored = rootControl?.unanchored === true;
|
|
992
|
+
const geometry = unanchored || deferred !== undefined ? {
|
|
993
|
+
...node.props as OwnedRecord<typeof node.props>, unanchored, shown: deferred === undefined ? node.props.shown : undefined,
|
|
994
|
+
} : node.props;
|
|
995
|
+
const bindFlags = () => (disabled === undefined ? undefined : bind(scope, disabled, next => {
|
|
996
|
+
if (isSecret(next)) return;
|
|
997
|
+
button.SetEnabled(!next);
|
|
998
|
+
paint?.set("disabled", next);
|
|
999
|
+
})) ?? (paint?.needs("checked") !== true || checked === undefined ? undefined : bind(scope, checked, next => {
|
|
1000
|
+
const selected = reveal(next);
|
|
1001
|
+
if (selected !== undefined) paint.set("checked", selected);
|
|
1002
|
+
}));
|
|
1003
|
+
// In a manual paint batch the authored flags must refresh before opacity and color consume them.
|
|
1004
|
+
const flagsFirst = options.bindings === "manual" || buttonTiming !== undefined;
|
|
1005
|
+
const failure = (flagsFirst ? bindFlags() : undefined)
|
|
1006
|
+
?? placeFrame(button, parent, geometry, scope, motion, false, flow, paint,
|
|
1007
|
+
startAfter === undefined ? undefined : { kind: "button", target: startAfter })
|
|
1008
|
+
?? (plain ? undefined : bind(scope, value, next => button.SetText(next)))
|
|
1009
|
+
?? (flagsFirst ? undefined : bindFlags());
|
|
1010
|
+
if (failure) return failure;
|
|
1011
|
+
if (disabled === undefined && paint?.needs("disabled") === true) paint.set("disabled", reveal(button.IsEnabled()) === false);
|
|
1012
|
+
const logical = mountViewNode(scope, group, "button", button, node.props);
|
|
1013
|
+
const action = secureAction === undefined ? listenForDrop(button, scope, onReceiveDrag)
|
|
1014
|
+
: bindSecureAction(button, scope, secureAction, onReceiveDrag);
|
|
1015
|
+
if (action !== undefined) return action;
|
|
1016
|
+
const move = bindButtonMove(button, scope, node.props);
|
|
1017
|
+
if (move !== undefined) return move;
|
|
1018
|
+
bindButtonDrag(button, scope, node.props);
|
|
1019
|
+
const content = deferred === undefined
|
|
1020
|
+
? mountButtonContent(button, node, scope, options, logical, paint, motion, environment, typography, liveStyle, buttonTiming)
|
|
1021
|
+
: bindActionVisibility(button, scope, deferred, owner => mountButtonContent(button, node, owner, options,
|
|
1022
|
+
mountLogicalGroup(owner, logical), paint, motion, environment, typography, liveStyle, buttonTiming));
|
|
1023
|
+
if (content !== undefined) return content;
|
|
1024
|
+
const observedState = options.buttonPaintStateChanged;
|
|
1025
|
+
const stateChanged = observedState === undefined && buttonTiming === undefined ? undefined
|
|
1026
|
+
: (state: Parameters<NativePaintState["set"]>[0], active: boolean) => {
|
|
1027
|
+
const refresh = observedState?.(button, state, active);
|
|
1028
|
+
return buttonTiming !== undefined || refresh === true;
|
|
1029
|
+
};
|
|
1030
|
+
return attachRef(scope, node.props.ref, button)
|
|
1031
|
+
?? bindElementEvents(button, node.props, scope, options.newEventScope, options.elementEvents, button, custom !== undefined,
|
|
1032
|
+
logical, interactiveControlPaint(paint, manualControl?.flush, stateChanged))
|
|
1033
|
+
?? finishViewNode(scope, logical, node.props.nodeRef);
|
|
1034
|
+
}
|
|
1035
|
+
|
|
912
1036
|
function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options: MountOptions, group: LogicalGroup,
|
|
913
1037
|
motion?: TransitionOptions, inherited?: StyleEnvironment, flow?: NativeLayoutGroup, typography?: NativeTextStyle,
|
|
914
1038
|
rootControl?: { unanchored?: boolean; attach(this: void, frame: Frame): void }): Failure | undefined {
|
|
@@ -1002,6 +1126,7 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1002
1126
|
return mountPortal(parent, node, scope, options, group, environment, typography);
|
|
1003
1127
|
case "frame": {
|
|
1004
1128
|
const frame = createFrame("Frame", undefined, parent);
|
|
1129
|
+
rootControl?.attach(frame);
|
|
1005
1130
|
return bindFrameScale(frame, scope, node.props.nativeScale)
|
|
1006
1131
|
?? mountFrame(frame, parent, node, scope, options, group, motion, environment, false, flow, typography, liveStyle);
|
|
1007
1132
|
}
|
|
@@ -1038,7 +1163,19 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1038
1163
|
return failure;
|
|
1039
1164
|
}
|
|
1040
1165
|
case "image":
|
|
1166
|
+
case "texture":
|
|
1041
1167
|
return mountImage(parent, node, scope, options, group, motion, environment, flow, typography, liveStyle);
|
|
1168
|
+
case "cooldown": {
|
|
1169
|
+
const cooldown = createFrame("Cooldown", undefined, parent, "CooldownFrameTemplate");
|
|
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
|
+
}
|
|
1042
1179
|
case "statusbar": {
|
|
1043
1180
|
const bar = createFrame("StatusBar", undefined, parent);
|
|
1044
1181
|
scope.onDispose(() => bar.Hide());
|
|
@@ -1056,61 +1193,8 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1056
1193
|
?? bindElementEvents(bar, node.props, scope, options.newEventScope, options.elementEvents, undefined, false, logical, paint)
|
|
1057
1194
|
?? finishViewNode(scope, logical, node.props.nodeRef);
|
|
1058
1195
|
}
|
|
1059
|
-
case "button":
|
|
1060
|
-
|
|
1061
|
-
const plain = unstyled === true;
|
|
1062
|
-
const factory = plain ? undefined : options?.createButton;
|
|
1063
|
-
const created = factory === undefined ? undefined : protect(() => factory(parent, node.props, scope));
|
|
1064
|
-
if (created?.ok === false) return created;
|
|
1065
|
-
const custom = created?.value;
|
|
1066
|
-
const button = custom ?? createFrame("Button", undefined, parent, plain ? undefined : "UIPanelButtonTemplate");
|
|
1067
|
-
rootControl?.attach(button);
|
|
1068
|
-
const duration = options.inheritedTextColorDuration;
|
|
1069
|
-
const colorMotion = options.buttonPaintMotion?.(button, node.props);
|
|
1070
|
-
const paint = createNativePaintState(node.props.style, environment, duration !== undefined, colorMotion?.repaint);
|
|
1071
|
-
const buttonTiming: ButtonPaintTiming | undefined = colorMotion === undefined ? undefined
|
|
1072
|
-
: { ...colorMotion as OwnedRecord<typeof colorMotion>, change: paint?.colorChange, visible: () => reveal(button.IsVisible()) === true };
|
|
1073
|
-
const startAfter = options.buttonStartAfter?.(parent, node.props);
|
|
1074
|
-
const geometry = rootControl?.unanchored === true ? { ...node.props as OwnedRecord<typeof node.props>, unanchored: true } : node.props;
|
|
1075
|
-
const bindFlags = () => (disabled === undefined ? undefined : bind(scope, disabled, next => {
|
|
1076
|
-
if (isSecret(next)) return;
|
|
1077
|
-
button.SetEnabled(!next);
|
|
1078
|
-
paint?.set("disabled", next);
|
|
1079
|
-
})) ?? (paint?.needs("checked") !== true || checked === undefined ? undefined : bind(scope, checked, next => {
|
|
1080
|
-
const selected = reveal(next);
|
|
1081
|
-
if (selected !== undefined) paint.set("checked", selected);
|
|
1082
|
-
}));
|
|
1083
|
-
// In a manual paint batch the authored flags must refresh before opacity and color consume them.
|
|
1084
|
-
const flagsFirst = options.bindings === "manual" || buttonTiming !== undefined;
|
|
1085
|
-
const failure = (flagsFirst ? bindFlags() : undefined)
|
|
1086
|
-
?? placeFrame(button, parent, geometry, scope, motion, false, flow, paint,
|
|
1087
|
-
startAfter === undefined ? undefined : { kind: "button", target: startAfter })
|
|
1088
|
-
?? (plain ? undefined : bind(scope, value, next => button.SetText(next)))
|
|
1089
|
-
?? (flagsFirst ? undefined : bindFlags());
|
|
1090
|
-
if (failure) return failure;
|
|
1091
|
-
if (disabled === undefined && paint?.needs("disabled") === true) paint.set("disabled", reveal(button.IsEnabled()) === false);
|
|
1092
|
-
const logical = mountViewNode(scope, group, "button", button, node.props);
|
|
1093
|
-
bindButtonDrag(button, scope, node.props);
|
|
1094
|
-
const appearance = inheritTextStyle(typography, node.props.style, environment, paint, undefined, liveStyle, duration, buttonTiming);
|
|
1095
|
-
for (const child of node.children as NativeChildren) {
|
|
1096
|
-
const childFailure = mountChild(button, child, scope, options, logical, undefined, environment, undefined, appearance);
|
|
1097
|
-
if (childFailure) return childFailure;
|
|
1098
|
-
}
|
|
1099
|
-
const label = paint?.usesColor === true ? button.GetFontString() : undefined;
|
|
1100
|
-
const observedState = options.buttonPaintStateChanged;
|
|
1101
|
-
const stateChanged = observedState === undefined && buttonTiming === undefined ? undefined
|
|
1102
|
-
: (state: Parameters<NativePaintState["set"]>[0], active: boolean) => {
|
|
1103
|
-
const refresh = observedState?.(button, state, active);
|
|
1104
|
-
return buttonTiming !== undefined || refresh === true;
|
|
1105
|
-
};
|
|
1106
|
-
return bindFramePaint(button, node.props.style, paint, scope, options, motion, environment, liveStyle,
|
|
1107
|
-
label === undefined ? undefined : { read: () => label.GetTextColor(), write: (r, g, b, a) => label.SetTextColor(r, g, b, a) },
|
|
1108
|
-
node.props.nativeRoundedArt, buttonTiming)
|
|
1109
|
-
?? attachRef(scope, node.props.ref, button)
|
|
1110
|
-
?? bindElementEvents(button, node.props, scope, options.newEventScope, options.elementEvents, button, custom !== undefined,
|
|
1111
|
-
logical, interactiveControlPaint(paint, manualControl?.flush, stateChanged))
|
|
1112
|
-
?? finishViewNode(scope, logical, node.props.nodeRef);
|
|
1113
|
-
}
|
|
1196
|
+
case "button":
|
|
1197
|
+
return mountButton(parent, node, scope, options, group, motion, environment, flow, typography, rootControl, liveStyle, manualControl);
|
|
1114
1198
|
case "editbox": {
|
|
1115
1199
|
const { value, type, placeholder, unstyled, maxLetters, disabled, onChange, onFocus, onBlur, onEnter, onEscape, ref } = node.props;
|
|
1116
1200
|
const edit = createFrame("EditBox", undefined, parent, unstyled ? undefined : "InputBoxTemplate");
|
|
@@ -1203,6 +1287,10 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1203
1287
|
});
|
|
1204
1288
|
scope.onDispose(() => ref(undefined));
|
|
1205
1289
|
}
|
|
1290
|
+
if (node.props.nativeImageLayers !== undefined) {
|
|
1291
|
+
const layers = mountImageLayers(edit, scope, node.props.nativeImageLayers);
|
|
1292
|
+
if (layers !== undefined) return layers;
|
|
1293
|
+
}
|
|
1206
1294
|
options?.input?.(edit, node.props, scope, hint);
|
|
1207
1295
|
if (styledInput !== undefined) {
|
|
1208
1296
|
function syncEnabled() {
|
|
@@ -1309,7 +1397,7 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1309
1397
|
?? finishViewNode(scope, logical, node.props.nodeRef);
|
|
1310
1398
|
}
|
|
1311
1399
|
case "range": {
|
|
1312
|
-
const { value, disabled, label, hideLabel, min, max, step = 1, onChange } = node.props;
|
|
1400
|
+
const { value, disabled, label, hideLabel, min, max, step = 1, onChange, onCommit } = node.props;
|
|
1313
1401
|
if (!Number.isFinite(min) || !Number.isFinite(max) || !Number.isFinite(step) || max <= min || step <= 0) {
|
|
1314
1402
|
return fail("Invalid slider range");
|
|
1315
1403
|
}
|
|
@@ -1338,12 +1426,22 @@ function mountChild(parent: Frame, node: UIElement, scope: RuntimeScope, options
|
|
|
1338
1426
|
if (failure) return failure;
|
|
1339
1427
|
if (rangeSkin !== undefined) hideStockControlArt(slider, caption);
|
|
1340
1428
|
if (caption !== undefined) options.range?.(slider, caption, node.props, scope);
|
|
1429
|
+
let changedByPointer = false;
|
|
1430
|
+
if (onCommit !== undefined) {
|
|
1431
|
+
const complete = hookScript(slider, "OnMouseUp", () => {
|
|
1432
|
+
if (!changedByPointer) return;
|
|
1433
|
+
changedByPointer = false;
|
|
1434
|
+
onCommit();
|
|
1435
|
+
}, scope);
|
|
1436
|
+
if (!complete.ok) return complete;
|
|
1437
|
+
}
|
|
1341
1438
|
if (onChange !== undefined) {
|
|
1342
1439
|
slider.SetScript("OnValueChanged", (_, raw, userInput) => {
|
|
1343
1440
|
if (!userInput || !scope.isActive()) return;
|
|
1344
1441
|
const next = reveal(raw);
|
|
1345
1442
|
if (next === undefined || next === current) return;
|
|
1346
1443
|
slider.SetValue(current, false);
|
|
1444
|
+
changedByPointer = onCommit !== undefined;
|
|
1347
1445
|
onChange(next);
|
|
1348
1446
|
});
|
|
1349
1447
|
scope.onDispose(() => slider.SetScript("OnValueChanged", undefined));
|
|
@@ -1437,9 +1535,28 @@ function mountLayoutRows(parent: Frame, node: Element<"keyedList">, scope: Runti
|
|
|
1437
1535
|
});
|
|
1438
1536
|
return node.props.mount(scope, {
|
|
1439
1537
|
mount: (tree, rowScope): Result<{ item?: NativeLayoutItem; logical: LogicalGroup }> => {
|
|
1538
|
+
const row = mountLogicalGroup(rowScope, logical, false);
|
|
1539
|
+
if (tree.kind === "frame" && motion === undefined && isAbsoluteFill(tree.props) && flowContainer(tree.props.style?.display)
|
|
1540
|
+
&& tree.props.style?.mediaStyles === undefined && tree.props.style?.styleTokens === undefined) {
|
|
1541
|
+
const failure = mountChild(parent, tree, rowScope, options, row, motion, environment, undefined, typography, {
|
|
1542
|
+
attach: frame => { rowScope.onDispose(() => frame.Hide()); },
|
|
1543
|
+
});
|
|
1544
|
+
return failure ?? ok({ logical: row });
|
|
1545
|
+
}
|
|
1546
|
+
if ((tree.kind === "frame" || tree.kind === "button" && tree.props.secureAction === undefined)
|
|
1547
|
+
&& tree.props.directKeyedLayout === true && tree.props.anchor === undefined && tree.props.style?.position !== "absolute"
|
|
1548
|
+
&& tree.props.style?.mediaStyles === undefined && tree.props.style?.styleTokens === undefined) {
|
|
1549
|
+
// Keep the item detached until the keyed reconciler publishes its order.
|
|
1550
|
+
const detached: NativeLayoutGroup = {
|
|
1551
|
+
children: ownedArray(), enqueue: flow.enqueue, visibility: flow.visibility, textMeasure: flow.textMeasure,
|
|
1552
|
+
};
|
|
1553
|
+
const failure = mountChild(parent, tree, rowScope, options, row, motion, environment, detached, typography);
|
|
1554
|
+
if (failure !== undefined) return failure;
|
|
1555
|
+
const item = detached.children[0];
|
|
1556
|
+
return item instanceof NativeLayoutItem ? ok({ item, logical: row }) : fail("Direct keyed row did not attach to its layout");
|
|
1557
|
+
}
|
|
1440
1558
|
const frame = createFrame("Frame", undefined, parent);
|
|
1441
1559
|
const style = "style" in tree.props ? tree.props.style : undefined;
|
|
1442
|
-
const row = mountLogicalGroup(rowScope, logical, false);
|
|
1443
1560
|
if (style && "position" in style && style.position === "absolute") {
|
|
1444
1561
|
frame.SetAllPoints(parent);
|
|
1445
1562
|
rowScope.onDispose(() => frame.Hide());
|
|
@@ -1607,7 +1724,7 @@ function createLayeredRoot(parent: FrameParent, scope: RuntimeScope, { strata, l
|
|
|
1607
1724
|
function isNativeRegionTree(tree: UIElement): boolean {
|
|
1608
1725
|
const children = tree.children as NativeChildren;
|
|
1609
1726
|
if (tree.kind === "fragment") return children.every(child => isNativeRegionTree(child));
|
|
1610
|
-
return (tree.kind === "text" || tree.kind === "image") && children.length === 0;
|
|
1727
|
+
return (tree.kind === "text" || tree.kind === "image" || tree.kind === "texture") && children.length === 0;
|
|
1611
1728
|
}
|
|
1612
1729
|
|
|
1613
1730
|
function initialLayoutQueue() {
|
|
@@ -1622,8 +1739,9 @@ function initialLayoutQueue() {
|
|
|
1622
1739
|
for (let pass = 0; jobs.size > 0; pass++) {
|
|
1623
1740
|
if (pass === 16) return fail("Initial native layout did not settle");
|
|
1624
1741
|
const pending = [...jobs];
|
|
1625
|
-
jobs.clear();
|
|
1626
1742
|
for (const job of pending) {
|
|
1743
|
+
// A parent can invalidate a child that has yet to run in this pass.
|
|
1744
|
+
jobs.delete(job);
|
|
1627
1745
|
const failure = job();
|
|
1628
1746
|
if (failure !== undefined) return failure;
|
|
1629
1747
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { copyFileSync, existsSync, mkdirSync } from "node:fs";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
|
|
5
|
-
const cli = fileURLToPath(import.meta.resolve("__KUMI_PACKAGE__/scripts/kumi-cli.mjs"));
|
|
6
|
-
const mode = process.argv[2];
|
|
7
|
-
if (mode !== "types" && mode !== "build") throw new Error("Expected types or build");
|
|
8
|
-
|
|
9
|
-
function pack(...args) {
|
|
10
|
-
const child = spawnSync(process.execPath, ["--v8-pool-size=1", cli, "pack", ...args], {
|
|
11
|
-
stdio: "inherit", windowsHide: true,
|
|
12
|
-
});
|
|
13
|
-
if (child.error) throw child.error;
|
|
14
|
-
if (child.status !== 0) process.exit(child.status ?? 1);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (!existsSync("build/types/wow-api.d.ts")) pack("wow-api");
|
|
18
|
-
if (mode === "build") {
|
|
19
|
-
const addon = "build/addons/__ADDON_NAME__";
|
|
20
|
-
mkdirSync(addon, { recursive: true });
|
|
21
|
-
pack("compile", "src/app/main.tsx", "--tsconfig", "tsconfig.json", "--addon-entry",
|
|
22
|
-
"--compile-output", addon + "/__ADDON_NAME__.lua");
|
|
23
|
-
copyFileSync("__ADDON_NAME__.toc", addon + "/__ADDON_NAME__.toc");
|
|
24
|
-
console.log("Addon available at " + addon);
|
|
25
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createElement, createRuntime } from "@kumi/core";
|
|
2
|
-
import { computed, ref } from "@kumi/state";
|
|
3
|
-
import { api, clock, mountNative, protect } from "@kumi/wow";
|
|
4
|
-
|
|
5
|
-
const runtime = createRuntime(clock, failure => api.geterrorhandler()(failure.reason), protect);
|
|
6
|
-
const mounted = mountNative(api.UIParent, runtime, () => {
|
|
7
|
-
const count = ref(0);
|
|
8
|
-
const caption = computed(() => String(count.value));
|
|
9
|
-
return <div width={160} height={52} anchor={{ point: "CENTER" }}>
|
|
10
|
-
<button width={140} height={32} anchor={{ point: "CENTER" }} value={caption} onClick={() => { count.value += 1; }} />
|
|
11
|
-
</div>;
|
|
12
|
-
});
|
|
13
|
-
if (!mounted.ok) api.geterrorhandler()(mounted.reason);
|