@overmvp/kumi 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +14 -2
- package/animation/color-transition.ts +196 -0
- package/animation/cycle.ts +151 -0
- package/animation/ease.ts +29 -0
- package/animation/index.ts +13 -0
- package/animation/package.json +12 -0
- package/animation/presets.ts +376 -0
- package/animation/spec.ts +197 -0
- package/builder/Cargo.lock +192 -0
- package/builder/Cargo.toml +7 -0
- package/builder/css-v1.mjs +334 -0
- package/builder/css-v1.test.mjs +321 -0
- package/builder/generated-output.mjs +61 -0
- package/builder/generated-output.test.mjs +132 -0
- package/builder/jsx-form.mjs +93 -0
- package/builder/jsx-form.test.mjs +48 -0
- package/builder/jsx-lists.mjs +209 -0
- package/builder/link-addon-package.mjs +86 -0
- package/builder/lua-assets.mjs +74 -0
- package/builder/lua-builtin-values.mjs +57 -0
- package/builder/lua-builtin-values.test.mjs +155 -0
- package/builder/lua-loop-closures.mjs +183 -0
- package/builder/lua-loop-closures.test.mjs +89 -0
- package/builder/lua-truthiness.mjs +61 -0
- package/builder/lua-truthiness.test.mjs +113 -0
- package/builder/module-declarations.mjs +594 -0
- package/builder/module-declarations.test.mjs +444 -0
- package/builder/native-kernels.mjs +60 -0
- package/builder/native-lua.d.ts +57 -0
- package/builder/native-routes.mjs +51 -0
- package/builder/no-static-ref-read.mjs +93 -0
- package/builder/no-static-ref-read.test.mjs +181 -0
- package/builder/secure-snippet.mjs +317 -0
- package/builder/secure-snippet.test.mjs +101 -0
- package/builder/shared-lua-runtime.mjs +150 -0
- package/builder/src/addon-link.lua +29 -0
- package/builder/src/arrays.lua +260 -0
- package/builder/src/assets.rs +177 -0
- package/builder/src/classes.lua +75 -0
- package/builder/src/collections.lua +190 -0
- package/builder/src/compiler.rs +2164 -0
- package/builder/src/config.rs +42 -0
- package/builder/src/entries.rs +166 -0
- package/builder/src/errors.lua +15 -0
- package/builder/src/lua_data.rs +231 -0
- package/builder/src/main.rs +367 -0
- package/builder/src/native_ir.rs +65 -0
- package/builder/src/native_signal.rs +47 -0
- package/builder/src/numbers.lua +62 -0
- package/builder/src/project-front.mjs +3331 -0
- package/builder/src/records.lua +75 -0
- package/builder/src/routes.rs +127 -0
- package/builder/src/signal-kernel.fingerprint +1 -0
- package/builder/src/strings.lua +103 -0
- package/builder/src/ts-lower.mjs +68 -0
- package/builder/src/wow_client.rs +253 -0
- package/builder/src/wow_types.rs +564 -0
- package/builder/style-states.mjs +100 -0
- package/builder/style-states.test.mjs +103 -0
- package/builder/vite-assets.mjs +53 -0
- package/builder/vite-project.mjs +10 -0
- package/config.ts +17 -0
- package/form/index.ts +522 -0
- package/form/package.json +13 -0
- package/motion/index.ts +2 -0
- package/motion/package.json +10 -0
- package/package.json +22 -4
- package/router/index.ts +43 -0
- package/router/package.json +12 -0
- package/router/routes.ts +64 -0
- package/scripts/kumi-cli.mjs +70 -0
- package/scripts/link-addons.mjs +51 -0
- package/src/bindings.ts +35 -0
- package/src/context.ts +15 -0
- package/src/css-tokens.ts +234 -0
- package/src/css-v1.ts +58 -0
- package/src/cvars.ts +91 -0
- package/src/element-node.ts +32 -0
- package/src/elements.ts +479 -0
- package/src/feature-scope.ts +82 -0
- package/src/flex-layout.ts +807 -0
- package/src/frame-scheduler.ts +334 -0
- package/src/grid-tracks.ts +165 -0
- package/src/image-imports.d.ts +24 -0
- package/src/images.ts +79 -0
- package/src/index.ts +28 -0
- package/src/jsx-dev-runtime.ts +2 -0
- package/src/jsx-runtime.ts +22 -0
- package/src/jsx.d.ts +12 -0
- package/src/keyed-list.ts +363 -0
- package/src/media-query.ts +144 -0
- package/src/module.ts +277 -0
- package/src/node-selectors.ts +114 -0
- package/src/owned-collections.ts +44 -0
- package/src/providers.ts +235 -0
- package/src/reactive-scope.ts +34 -0
- package/src/reactivity.ts +254 -0
- package/src/result.ts +58 -0
- package/src/runtime.ts +52 -0
- package/src/scheduler.ts +185 -0
- package/src/signal-kernel.ts +30 -0
- package/src/style-classes.ts +51 -0
- package/src/style-states.ts +134 -0
- package/src/style-variables.ts +53 -0
- package/src/text-children.ts +42 -0
- package/src/theme.ts +50 -0
- package/src/transition.ts +18 -0
- package/state/index.ts +3 -0
- package/state/package.json +12 -0
- package/state/store-bindings.ts +25 -0
- package/state/store.ts +82 -0
- package/styles/_layers.scss +14 -0
- package/templates/addon/README.md +14 -0
- package/templates/addon/__ADDON_NAME__.toc +4 -0
- package/templates/addon/eslint.config.mjs +12 -0
- package/templates/addon/gitignore +8 -0
- package/templates/addon/package.json +21 -0
- package/templates/addon/scripts/build.mjs +25 -0
- package/templates/addon/src/app/main.tsx +13 -0
- package/templates/addon/tsconfig.json +24 -0
- package/translate/index.ts +14 -0
- package/translate/package.json +9 -0
- package/utils/colors.ts +76 -0
- package/utils/format.ts +37 -0
- package/utils/index.ts +4 -0
- package/utils/number.ts +17 -0
- package/utils/package.json +7 -0
- package/utils/text.ts +6 -0
- package/validate/index.ts +119 -0
- package/validate/package.json +9 -0
- package/wow/absolute-position.ts +142 -0
- package/wow/animation.ts +428 -0
- package/wow/aura-button.ts +76 -0
- package/wow/aura-container.ts +591 -0
- package/wow/aura-countdown.ts +201 -0
- package/wow/aura-slot.ts +153 -0
- package/wow/bar-shade.ts +93 -0
- package/wow/borrowed-slot.ts +216 -0
- package/wow/button-drag.ts +48 -0
- package/wow/cast-clock.ts +153 -0
- package/wow/cast-text.ts +83 -0
- package/wow/class-colors.ts +126 -0
- package/wow/clock.ts +7 -0
- package/wow/color-picker.ts +128 -0
- package/wow/commands.ts +17 -0
- package/wow/contained-frame.ts +128 -0
- package/wow/contract.ts +42 -0
- package/wow/css-box.ts +110 -0
- package/wow/css-color.ts +12 -0
- package/wow/css-style.ts +109 -0
- package/wow/css-surfaces.ts +398 -0
- package/wow/css-text.ts +399 -0
- package/wow/cvar-schema.ts +32 -0
- package/wow/cvars.ts +98 -0
- package/wow/dropdown-art.ts +39 -0
- package/wow/element-click.ts +20 -0
- package/wow/element-event-coordinator.ts +219 -0
- package/wow/element-events.ts +317 -0
- package/wow/event-dispatcher.ts +151 -0
- package/wow/events.ts +50 -0
- package/wow/font-cache.ts +92 -0
- package/wow/frame-access.ts +31 -0
- package/wow/frame-layer.ts +5 -0
- package/wow/frames.ts +236 -0
- package/wow/heal-prediction.ts +305 -0
- package/wow/image-layers.ts +55 -0
- package/wow/index.ts +97 -0
- package/wow/layout-view.ts +651 -0
- package/wow/lua-string.ts +18 -0
- package/wow/lua-table.ts +18 -0
- package/wow/macro-book.ts +84 -0
- package/wow/map-position.ts +27 -0
- package/wow/media-query.ts +65 -0
- package/wow/module-events.ts +11 -0
- package/wow/native-hooks.ts +168 -0
- package/wow/native-placement.ts +88 -0
- package/wow/native.ts +135 -0
- package/wow/number-format.ts +8 -0
- package/wow/number-input.ts +10 -0
- package/wow/protect.ts +24 -0
- package/wow/protected-layout.ts +133 -0
- package/wow/range-art.ts +74 -0
- package/wow/reparent-frame.ts +99 -0
- package/wow/rounded-texture.ts +156 -0
- package/wow/saved-variables.ts +60 -0
- package/wow/scroll-view.ts +64 -0
- package/wow/secret-ref.ts +14 -0
- package/wow/secure-bindings.ts +89 -0
- package/wow/secure-clicks.ts +432 -0
- package/wow/secure-snippet.ts +235 -0
- package/wow/secure-state.ts +130 -0
- package/wow/secure-target-visibility.ts +89 -0
- package/wow/secure-transaction.ts +331 -0
- package/wow/special-window.ts +269 -0
- package/wow/start-addon.ts +99 -0
- package/wow/state-paint.ts +256 -0
- package/wow/transition.ts +86 -0
- package/wow/unit-button.ts +39 -0
- package/wow/unit-cast.ts +92 -0
- package/wow/unit-health-text.ts +47 -0
- package/wow/view-nodes.ts +304 -0
- package/wow/view.ts +1746 -0
- package/wow/visible-frame-job.ts +34 -0
- package/wow/width-reserve.ts +108 -0
package/wow/events.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Cancel } from "../src";
|
|
2
|
+
import { fail, ok, type Result } from "../src/result";
|
|
3
|
+
import type { EventApi, EventOptions, EventScope, WoWEvent, WoWEventMap } from "./contract";
|
|
4
|
+
import { protect } from "./protect";
|
|
5
|
+
|
|
6
|
+
export type Subscribe = <E extends WoWEvent>(
|
|
7
|
+
this: void, owner: EventScope, event: E, handler: (this: void, event: E, ...payload: WoWEventMap[E]) => void,
|
|
8
|
+
options?: EventOptions,
|
|
9
|
+
) => Cancel;
|
|
10
|
+
|
|
11
|
+
type ScopedSubscribe = <E extends WoWEvent>(
|
|
12
|
+
this: void, owner: EventScope, event: E, handler: (this: void, event: E, ...payload: WoWEventMap[E]) => void,
|
|
13
|
+
options?: EventOptions,
|
|
14
|
+
) => Result<Cancel>;
|
|
15
|
+
|
|
16
|
+
export function createScopedEvents(subscribe: ScopedSubscribe): EventApi {
|
|
17
|
+
return {
|
|
18
|
+
on: (scope, event, handler, options) => {
|
|
19
|
+
if (!scope.isActive()) return fail("Cannot subscribe after the scope has been disposed");
|
|
20
|
+
let active = true;
|
|
21
|
+
let cancel: Cancel | undefined;
|
|
22
|
+
const subscription = scope.onDispose(stop);
|
|
23
|
+
if (!subscription.ok) return subscription;
|
|
24
|
+
const unlink = subscription.value;
|
|
25
|
+
function stop() {
|
|
26
|
+
if (!active) return;
|
|
27
|
+
active = false;
|
|
28
|
+
unlink();
|
|
29
|
+
cancel?.();
|
|
30
|
+
}
|
|
31
|
+
const result = subscribe(scope, event, (_, ...payload) => {
|
|
32
|
+
if (active) handler(...payload);
|
|
33
|
+
}, options);
|
|
34
|
+
if (!result.ok) {
|
|
35
|
+
stop();
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
cancel = result.value;
|
|
39
|
+
if (!active) {
|
|
40
|
+
const canceled = protect(cancel);
|
|
41
|
+
if (!canceled.ok) return canceled;
|
|
42
|
+
}
|
|
43
|
+
return ok(stop);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function createEvents(subscribe: Subscribe): EventApi {
|
|
49
|
+
return createScopedEvents((owner, event, handler, options) => protect(() => subscribe(owner, event, handler, options)));
|
|
50
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { SimpleFont } from "@kumi/wow-generated";
|
|
2
|
+
import type { OwnedRecord } from "../src/owned-collections";
|
|
3
|
+
import { api } from "./native";
|
|
4
|
+
|
|
5
|
+
export type FontObject = SimpleFont;
|
|
6
|
+
export type FontOutline = boolean | "thin" | "thick" | "none" | "OUTLINE" | "THICKOUTLINE";
|
|
7
|
+
type FontPaths<Face extends string> = Readonly<Record<Face, string>>;
|
|
8
|
+
|
|
9
|
+
export interface FontCacheOptions<Face extends string> {
|
|
10
|
+
namePrefix: string;
|
|
11
|
+
defaultFace: Face;
|
|
12
|
+
readFaces(this: void): FontPaths<Face>;
|
|
13
|
+
readScale(this: void): number;
|
|
14
|
+
minimumSize?: number;
|
|
15
|
+
shadow?: {
|
|
16
|
+
color: readonly [number, number, number, number];
|
|
17
|
+
offset: readonly [number, number];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface FontCache<Face extends string> {
|
|
22
|
+
get(this: void, size: number, face?: Face, outline?: FontOutline): FontObject;
|
|
23
|
+
refresh(this: void): void;
|
|
24
|
+
revision(this: void): number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type OutlineFlags = "" | "OUTLINE" | "THICKOUTLINE";
|
|
28
|
+
|
|
29
|
+
interface CachedFont<Face extends string> {
|
|
30
|
+
font: FontObject;
|
|
31
|
+
face: Face;
|
|
32
|
+
size: number;
|
|
33
|
+
flags: OutlineFlags;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function outlineFlags(outline: FontOutline | undefined): OutlineFlags {
|
|
37
|
+
if (outline === true || outline === "thin" || outline === "OUTLINE") return "OUTLINE";
|
|
38
|
+
if (outline === "thick" || outline === "THICKOUTLINE") return "THICKOUTLINE";
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function sameFaces<Face extends string>(previous: FontPaths<Face>, next: FontPaths<Face>): boolean {
|
|
43
|
+
const keys = Object.keys(next) as Face[];
|
|
44
|
+
return keys.length === Object.keys(previous).length && keys.every(face => previous[face] === next[face]);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function createFontCache<Face extends string>(this: void, {
|
|
48
|
+
namePrefix, defaultFace, readFaces, readScale, minimumSize = 6, shadow,
|
|
49
|
+
}: FontCacheOptions<Face>): FontCache<Face> {
|
|
50
|
+
const entries = new Map<string, CachedFont<Face>>();
|
|
51
|
+
let faces = { ...readFaces() as OwnedRecord<FontPaths<Face>> };
|
|
52
|
+
let scale = readScale();
|
|
53
|
+
let currentRevision = 0;
|
|
54
|
+
|
|
55
|
+
function applyFont(entry: CachedFont<Face>, paths: FontPaths<Face>, factor: number): void {
|
|
56
|
+
const height = Math.max(minimumSize, Math.floor(entry.size * factor + 0.5));
|
|
57
|
+
entry.font.SetFont(paths[entry.face], height, entry.flags);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
get(this: void, size, face = defaultFace, outline) {
|
|
62
|
+
const flags = outlineFlags(outline);
|
|
63
|
+
const key = `${face}:${size}:${flags}`;
|
|
64
|
+
const cached = entries.get(key);
|
|
65
|
+
if (cached) return cached.font;
|
|
66
|
+
|
|
67
|
+
const font = api.CreateFont(`${namePrefix}_${entries.size + 1}`);
|
|
68
|
+
const entry = { font, face, size, flags };
|
|
69
|
+
applyFont(entry, faces, scale);
|
|
70
|
+
if (shadow) {
|
|
71
|
+
font.SetShadowColor(...shadow.color);
|
|
72
|
+
font.SetShadowOffset(...shadow.offset);
|
|
73
|
+
}
|
|
74
|
+
entries.set(key, entry);
|
|
75
|
+
return font;
|
|
76
|
+
},
|
|
77
|
+
refresh(this: void) {
|
|
78
|
+
const nextFaces = readFaces();
|
|
79
|
+
const nextScale = readScale();
|
|
80
|
+
if (nextScale === scale && sameFaces(faces, nextFaces)) return;
|
|
81
|
+
|
|
82
|
+
const snapshot = { ...nextFaces as OwnedRecord<FontPaths<Face>> };
|
|
83
|
+
for (const entry of entries.values()) applyFont(entry, snapshot, nextScale);
|
|
84
|
+
faces = snapshot;
|
|
85
|
+
scale = nextScale;
|
|
86
|
+
currentRevision += 1;
|
|
87
|
+
},
|
|
88
|
+
revision(this: void) {
|
|
89
|
+
return currentRevision;
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { fail, ok, type Result } from "../src/result";
|
|
2
|
+
import type { Frame, FrameEventRegistration, Region, Texture } from "./frames";
|
|
3
|
+
import { reveal, type SecretValue } from "./native";
|
|
4
|
+
import { protect } from "./protect";
|
|
5
|
+
|
|
6
|
+
type NativeRegion = Pick<Frame, "IsForbidden">;
|
|
7
|
+
|
|
8
|
+
export function canAccessRegion<T extends NativeRegion>(region: T | SecretValue<T> | undefined): region is T {
|
|
9
|
+
const readable = reveal(region);
|
|
10
|
+
return readable !== undefined && reveal(readable.IsForbidden()) === false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Read a texture from a heterogeneous native region list. */
|
|
14
|
+
export function asTexture(region: Region | SecretValue<Region> | undefined): Texture | undefined {
|
|
15
|
+
if (canAccessRegion(region) && reveal(region.IsObjectType("Texture")) === true) {
|
|
16
|
+
return region as Texture;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Change one native subscription only when its current state is readable and differs. */
|
|
21
|
+
export function setFrameEventListening(frame: NativeRegion & FrameEventRegistration, event: string, enabled: boolean): Result<void> {
|
|
22
|
+
if (!canAccessRegion(frame)) return fail("Frame is inaccessible");
|
|
23
|
+
const [registered] = frame.IsEventRegistered(event);
|
|
24
|
+
const listening = reveal(registered);
|
|
25
|
+
if (listening === undefined) return fail("Event registration is unreadable");
|
|
26
|
+
if (listening === enabled) return ok(undefined);
|
|
27
|
+
return protect(() => {
|
|
28
|
+
if (enabled) frame.RegisterEvent(event);
|
|
29
|
+
else frame.UnregisterEvent(event);
|
|
30
|
+
});
|
|
31
|
+
}
|
package/wow/frames.ts
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Cooldown, GameTooltip, LuaMultiReturn, MinimapFrameAPI, SecretValue, SimpleAnimAPI, SimpleAnimAlphaAPI, SimpleAnimFlipBookAPI, SimpleAnimGroupAPI, SimpleAnimRotationAPI, SimpleAnimScaleAPI,
|
|
3
|
+
SimpleAnimTranslationAPI, SimpleButton, SimpleCheckbox, SimpleEditBox, SimpleFontString, SimpleFrame, SimpleHTML, SimpleMessageFrame,
|
|
4
|
+
SimpleLine, SimpleMaskTexture, SimpleModel, SimpleObject, SimpleRegion, SimpleScriptRegionAPI, SimpleScriptRegionResizingAPI, SimpleScrollFrame, SimpleSlider,
|
|
5
|
+
SimpleStatusBar, SimpleTexture,
|
|
6
|
+
} from "@kumi/wow-generated";
|
|
7
|
+
import { luaString } from "./lua-string";
|
|
8
|
+
import { weakKeys } from "./lua-table";
|
|
9
|
+
import { api, reveal } from "./native";
|
|
10
|
+
|
|
11
|
+
export type CommonScripts = {
|
|
12
|
+
OnShow: [];
|
|
13
|
+
OnHide: [];
|
|
14
|
+
OnEnter: [motion: boolean];
|
|
15
|
+
OnLeave: [motion: boolean];
|
|
16
|
+
OnUpdate: [elapsed: number];
|
|
17
|
+
OnSizeChanged: [width: number, height: number];
|
|
18
|
+
OnMouseDown: [button: string];
|
|
19
|
+
OnMouseUp: [button: string];
|
|
20
|
+
OnMouseWheel: [delta: number];
|
|
21
|
+
OnDragStart: [button: string];
|
|
22
|
+
OnDragStop: [];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type ButtonScripts = CommonScripts & {
|
|
26
|
+
OnEnable: [];
|
|
27
|
+
OnDisable: [];
|
|
28
|
+
OnClick: [button: string, down: boolean];
|
|
29
|
+
PreClick: [button: string, down: boolean];
|
|
30
|
+
PostClick: [button: string, down: boolean];
|
|
31
|
+
OnDoubleClick: [button: string];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type EditBoxScripts = CommonScripts & {
|
|
35
|
+
OnTextChanged: [userInput: boolean];
|
|
36
|
+
OnEnterPressed: [];
|
|
37
|
+
OnEscapePressed: [];
|
|
38
|
+
OnEditFocusGained: [];
|
|
39
|
+
OnEditFocusLost: [];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type ScrollScripts = CommonScripts & {
|
|
43
|
+
OnVerticalScroll: [offset: number];
|
|
44
|
+
OnHorizontalScroll: [offset: number];
|
|
45
|
+
OnScrollRangeChanged: [horizontal: number, vertical: number];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type Point = "TOP" | "BOTTOM" | "LEFT" | "RIGHT" | "CENTER" | "TOPLEFT" | "TOPRIGHT" | "BOTTOMLEFT" | "BOTTOMRIGHT";
|
|
49
|
+
|
|
50
|
+
type AnimationTypes = {
|
|
51
|
+
Alpha: SimpleAnimAlphaAPI;
|
|
52
|
+
FlipBook: SimpleAnimFlipBookAPI;
|
|
53
|
+
Rotation: SimpleAnimRotationAPI;
|
|
54
|
+
Scale: SimpleAnimScaleAPI;
|
|
55
|
+
Translation: SimpleAnimTranslationAPI;
|
|
56
|
+
};
|
|
57
|
+
/** A native animation of one kind, as `AnimationGroup.CreateAnimation(kind)` returns it. */
|
|
58
|
+
export type NativeAnimationOf<K extends keyof AnimationTypes> = SimpleAnimAPI & AnimationTypes[K];
|
|
59
|
+
export type NativeAnimationKind = keyof AnimationTypes;
|
|
60
|
+
export type AnimationGroup = Omit<SimpleAnimGroupAPI, "CreateAnimation"> & {
|
|
61
|
+
CreateAnimation<K extends keyof AnimationTypes>(this: object, kind: K, name?: string, template?: string):
|
|
62
|
+
SimpleAnimAPI & AnimationTypes[K];
|
|
63
|
+
CreateAnimation(this: object, kind?: string, name?: string, template?: string): SimpleAnimAPI;
|
|
64
|
+
};
|
|
65
|
+
interface AnchoredRegion {
|
|
66
|
+
SetPoint(this: object, point: Point, x: number, y: number): void;
|
|
67
|
+
SetPoint(this: object, point: Point, relativeTo?: FrameParent | string, relativePoint?: Point, x?: number, y?: number): void;
|
|
68
|
+
}
|
|
69
|
+
type LayeredRegion = AnchoredRegion
|
|
70
|
+
& Pick<SimpleScriptRegionAPI, "GetHeight" | "GetSize" | "GetWidth" | "Hide" | "IsShown" | "IsVisible" | "SetShown" | "Show">
|
|
71
|
+
& Pick<SimpleScriptRegionResizingAPI, "ClearAllPoints" | "GetNumPoints" | "GetPoint" | "SetAllPoints" | "SetHeight" | "SetSize" | "SetWidth">;
|
|
72
|
+
type NativeColorChannel = number | SecretValue<number>;
|
|
73
|
+
export type FontString = Omit<SimpleFontString, "SetText" | "SetTextColor"> & LayeredRegion & {
|
|
74
|
+
SetTextColor(this: object, r: NativeColorChannel, g: NativeColorChannel, b: NativeColorChannel, alpha?: NativeColorChannel): void;
|
|
75
|
+
SetText(this: object, text?: string | SecretValue<string>): void;
|
|
76
|
+
/** Font strings are animatable regions; the generated interfaces leave this out. */
|
|
77
|
+
CreateAnimationGroup(this: object, name?: string, template?: string): AnimationGroup;
|
|
78
|
+
};
|
|
79
|
+
interface TextureAsset {
|
|
80
|
+
SetTexture(this: object, asset?: string | number, wrapX?: string, wrapY?: string, filter?: string): boolean;
|
|
81
|
+
SetTexCoord(this: object, left: number, right: number, bottom: number, top: number): void;
|
|
82
|
+
SetTexCoord(this: object, ulX: number, ulY: number, llX: number, llY: number, urX: number, urY: number, lrX: number, lrY: number): void;
|
|
83
|
+
}
|
|
84
|
+
export type Texture = Omit<SimpleTexture, "CreateAnimationGroup" | "SetVertexColor" | keyof TextureAsset> & LayeredRegion & TextureAsset & {
|
|
85
|
+
SetVertexColor(this: object, r: NativeColorChannel, g: NativeColorChannel, b: NativeColorChannel, alpha?: NativeColorChannel): void;
|
|
86
|
+
CreateAnimationGroup(this: object, name?: string, template?: string): AnimationGroup;
|
|
87
|
+
};
|
|
88
|
+
export type MaskTexture = Omit<SimpleMaskTexture, keyof TextureAsset> & LayeredRegion & TextureAsset;
|
|
89
|
+
export type Region = SimpleRegion;
|
|
90
|
+
type ButtonTextureGetter = "GetNormalTexture" | "GetPushedTexture" | "GetHighlightTexture" | "GetDisabledTexture";
|
|
91
|
+
type NativeButton = Omit<SimpleButton, ButtonTextureGetter> & {
|
|
92
|
+
[Key in ButtonTextureGetter]: (this: object) => Texture | undefined;
|
|
93
|
+
};
|
|
94
|
+
type MenuDescription = {
|
|
95
|
+
CreateRadio(this: object, label: string, isSelected: (this: void) => boolean, select: (this: void) => void): void;
|
|
96
|
+
};
|
|
97
|
+
type DropdownButton = NativeButton & {
|
|
98
|
+
SetDefaultText(this: object, text: string): void;
|
|
99
|
+
SetupMenu(this: object, generate: (this: void, owner: FrameParent, menu: MenuDescription) => void): void;
|
|
100
|
+
GenerateMenu(this: object): void;
|
|
101
|
+
};
|
|
102
|
+
type Line = SimpleLine & Pick<LayeredRegion, "Hide" | "Show" | "SetShown" | "IsShown" | "IsVisible">;
|
|
103
|
+
type PlayerModel = SimpleModel & {
|
|
104
|
+
SetUnit(this: object, unit: string): void;
|
|
105
|
+
SetAnimation(this: object, animation: number): void;
|
|
106
|
+
SetDisplayInfo(this: object, displayId: number): void;
|
|
107
|
+
};
|
|
108
|
+
type Tooltip = Omit<GameTooltip, "SetText"> & {
|
|
109
|
+
SetOwner(this: object, owner: FrameParent, anchor: string, x?: number, y?: number): void;
|
|
110
|
+
IsOwned(this: object, owner: FrameParent): boolean;
|
|
111
|
+
SetItemByID?(this: object, itemId: number): void;
|
|
112
|
+
SetText(this: object, text: string | SecretValue<string>, r?: number, g?: number, b?: number,
|
|
113
|
+
alpha?: number | SecretValue<number>, wrap?: boolean | SecretValue<boolean>): void;
|
|
114
|
+
};
|
|
115
|
+
type NativeStatusBar = Omit<SimpleStatusBar, "SetValue" | "SetMinMaxValues" | "GetStatusBarTexture"> & {
|
|
116
|
+
GetStatusBarTexture(this: object): Texture | undefined;
|
|
117
|
+
SetValue(this: object, value: number | SecretValue<number>, interpolation?: Parameters<SimpleStatusBar["SetValue"]>[1]): void;
|
|
118
|
+
SetMinMaxValues(this: object, minValue: number | SecretValue<number>, maxValue: number | SecretValue<number>,
|
|
119
|
+
interpolation?: Parameters<SimpleStatusBar["SetMinMaxValues"]>[2]): void;
|
|
120
|
+
};
|
|
121
|
+
type ScriptHandler<Frame, Args extends unknown[]> = {
|
|
122
|
+
callback(this: void, frame: Frame, ...args: Args): void;
|
|
123
|
+
}["callback"];
|
|
124
|
+
|
|
125
|
+
type NativeFrame<T, Scripts extends { [K in keyof Scripts]: unknown[] }> =
|
|
126
|
+
Omit<T, "SetPoint" | "SetParent" | "SetScript" | "GetScript" | "HookScript" | "HasScript" | "RegisterEvent" | "RegisterUnitEvent"
|
|
127
|
+
| "CreateAnimationGroup" | "CreateTexture" | "CreateFontString" | "CreateMaskTexture" | "CreateLine"> & {
|
|
128
|
+
CreateAnimationGroup(this: object, name?: string, template?: string): AnimationGroup;
|
|
129
|
+
CreateTexture(this: object, name?: string, layer?: Parameters<SimpleFrame["CreateTexture"]>[1],
|
|
130
|
+
template?: string, subLevel?: number): Texture;
|
|
131
|
+
CreateFontString(this: object, name?: string, layer?: Parameters<SimpleFrame["CreateFontString"]>[1],
|
|
132
|
+
template?: string, subLevel?: number): FontString;
|
|
133
|
+
CreateMaskTexture(this: object, name?: string, layer?: Parameters<SimpleFrame["CreateMaskTexture"]>[1],
|
|
134
|
+
template?: string, subLevel?: number): MaskTexture;
|
|
135
|
+
CreateLine(this: object, name?: string, layer?: Parameters<SimpleFrame["CreateLine"]>[1],
|
|
136
|
+
template?: string, subLevel?: number): Line;
|
|
137
|
+
SetPoint(this: NativeFrame<T, Scripts>, point: Point, x: number, y: number): void;
|
|
138
|
+
SetPoint(this: NativeFrame<T, Scripts>, point: Point, relativeTo?: FrameParent | string,
|
|
139
|
+
relativePoint?: Point, x?: number, y?: number): void;
|
|
140
|
+
SetParent(this: object, parent?: FrameParent): void;
|
|
141
|
+
SetScript<K extends keyof Scripts>(this: NativeFrame<T, Scripts>, script: K,
|
|
142
|
+
handler?: (this: void, frame: NativeFrame<T, Scripts>, ...args: Scripts[K]) => void): void;
|
|
143
|
+
GetScript<K extends keyof Scripts>(this: object, script: K):
|
|
144
|
+
ScriptHandler<NativeFrame<T, Scripts>, Scripts[K]> | undefined;
|
|
145
|
+
HookScript<K extends keyof Scripts>(this: NativeFrame<T, Scripts>, script: K,
|
|
146
|
+
handler: (this: void, frame: NativeFrame<T, Scripts>, ...args: Scripts[K]) => void): void;
|
|
147
|
+
HasScript<K extends keyof Scripts>(this: NativeFrame<T, Scripts>, script: K): boolean;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export interface FrameMap {
|
|
151
|
+
Frame: NativeFrame<SimpleFrame, CommonScripts>;
|
|
152
|
+
Button: NativeFrame<NativeButton, ButtonScripts>;
|
|
153
|
+
CheckButton: NativeFrame<SimpleCheckbox, ButtonScripts>;
|
|
154
|
+
DropdownButton: NativeFrame<DropdownButton, ButtonScripts>;
|
|
155
|
+
EditBox: NativeFrame<SimpleEditBox, EditBoxScripts>;
|
|
156
|
+
Slider: NativeFrame<SimpleSlider, CommonScripts & { OnValueChanged: [value: number, userInput: boolean] }>;
|
|
157
|
+
StatusBar: NativeFrame<NativeStatusBar, CommonScripts & { OnValueChanged: [value: number | SecretValue<number>] }>;
|
|
158
|
+
ScrollFrame: Omit<NativeFrame<SimpleScrollFrame, ScrollScripts>, "SetScrollChild"> & {
|
|
159
|
+
SetScrollChild(this: object, child: FrameParent): void;
|
|
160
|
+
};
|
|
161
|
+
MessageFrame: NativeFrame<SimpleMessageFrame, CommonScripts>;
|
|
162
|
+
Model: NativeFrame<SimpleModel, CommonScripts>;
|
|
163
|
+
PlayerModel: NativeFrame<PlayerModel, CommonScripts>;
|
|
164
|
+
SimpleHTML: NativeFrame<SimpleHTML, CommonScripts>;
|
|
165
|
+
Cooldown: NativeFrame<Cooldown, CommonScripts & { OnCooldownDone: [] }>;
|
|
166
|
+
GameTooltip: NativeFrame<Tooltip, CommonScripts>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type Frame = FrameMap["Frame"];
|
|
170
|
+
export type Button = FrameMap["Button"];
|
|
171
|
+
export type MinimapFrame = Frame & MinimapFrameAPI;
|
|
172
|
+
export type StatusBar = FrameMap["StatusBar"];
|
|
173
|
+
export type FrameType = keyof FrameMap;
|
|
174
|
+
export type FrameParent = Pick<SimpleObject, "GetObjectType">;
|
|
175
|
+
export interface BackdropInfo {
|
|
176
|
+
bgFile?: string | number;
|
|
177
|
+
edgeFile?: string | number;
|
|
178
|
+
edgeSize?: number;
|
|
179
|
+
tile?: boolean;
|
|
180
|
+
tileEdge?: boolean;
|
|
181
|
+
tileSize?: number;
|
|
182
|
+
insets?: { left?: number; right?: number; top?: number; bottom?: number };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
type BackdropColorChannel = number | SecretValue<number>;
|
|
186
|
+
type BackdropColor = LuaMultiReturn<[] | [BackdropColorChannel, BackdropColorChannel, BackdropColorChannel, BackdropColorChannel]>;
|
|
187
|
+
|
|
188
|
+
/** Methods provided by Blizzard's BackdropTemplate mixin. */
|
|
189
|
+
export type BackdropFrame<T extends FrameType = "Frame"> = FrameMap[T] & {
|
|
190
|
+
SetBackdrop(this: object, info?: BackdropInfo): void;
|
|
191
|
+
GetBackdrop(this: object): BackdropInfo | undefined;
|
|
192
|
+
GetBackdropColor(this: object): BackdropColor;
|
|
193
|
+
GetBackdropBorderColor(this: object): BackdropColor;
|
|
194
|
+
SetBackdropColor(this: object, red: number, green: number, blue: number, alpha?: number): void;
|
|
195
|
+
SetBackdropBorderColor(this: object, red: number, green: number, blue: number, alpha?: number): void;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/** For adapters that restore event subscriptions on a Blizzard-owned frame. */
|
|
199
|
+
export type FrameEventRegistration = Pick<SimpleFrame, "RegisterEvent" | "UnregisterEvent" | "IsEventRegistered">;
|
|
200
|
+
|
|
201
|
+
declare function CreateFrame<T extends FrameType>(
|
|
202
|
+
this: void, kind: T, name?: string, parent?: FrameParent, template?: string, id?: number,
|
|
203
|
+
): FrameMap[T];
|
|
204
|
+
|
|
205
|
+
declare function rawget(this: void, table: object, key: object): true | undefined;
|
|
206
|
+
declare function rawset(this: void, table: object, key: object, value: true): void;
|
|
207
|
+
|
|
208
|
+
const secureStateFrames = weakKeys({});
|
|
209
|
+
|
|
210
|
+
export function createdWithSecureStateHandler(this: void, frame: object): boolean {
|
|
211
|
+
return rawget(secureStateFrames, frame) === true;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const smoothInterpolation = api.Enum?.StatusBarInterpolation?.ExponentialEaseOut;
|
|
215
|
+
|
|
216
|
+
export function smoothStatusBarValue(this: void, bar: Pick<StatusBar, "SetValue">, value: Parameters<StatusBar["SetValue"]>[0]): void {
|
|
217
|
+
if (smoothInterpolation === undefined) bar.SetValue(value);
|
|
218
|
+
else bar.SetValue(value, smoothInterpolation);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export function createFrame<T extends FrameType>(
|
|
222
|
+
kind: T, name: string | undefined, parent: FrameParent | undefined, template: "BackdropTemplate", id?: number,
|
|
223
|
+
): BackdropFrame<T>;
|
|
224
|
+
export function createFrame<T extends FrameType>(
|
|
225
|
+
kind: T, name?: string, parent?: FrameParent, template?: string, id?: number,
|
|
226
|
+
): FrameMap[T];
|
|
227
|
+
export function createFrame<T extends FrameType>(
|
|
228
|
+
kind: T, name?: string, parent?: FrameParent, template?: string, id?: number,
|
|
229
|
+
): FrameMap[T] {
|
|
230
|
+
const frame = CreateFrame(kind, name, parent, template, id);
|
|
231
|
+
const inherited = reveal(template);
|
|
232
|
+
if (inherited !== undefined && luaString.match("," + inherited + ",", ",%s*SecureHandlerStateTemplate%s*,") !== undefined) {
|
|
233
|
+
rawset(secureStateFrames, frame, true);
|
|
234
|
+
}
|
|
235
|
+
return frame;
|
|
236
|
+
}
|