@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
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import { compareStyleStates, parseLocalStyleSelector, parseMediaQuery, parseStateDeclaration } from "./style-states.mjs";
|
|
4
|
+
|
|
5
|
+
test("resolves media widths to known breakpoint names at build time", () => {
|
|
6
|
+
const widths = new Map([[0, "base"], [530, "compact"], [760, "narrow"]]);
|
|
7
|
+
assert.deepEqual(parseMediaQuery("(min-width: 530px)", widths), { minWidth: "compact" });
|
|
8
|
+
assert.deepEqual(parseMediaQuery("(max-width: 760px)", widths), { maxWidth: "narrow" });
|
|
9
|
+
assert.deepEqual(parseMediaQuery("(prefers-reduced-motion: reduce)", widths), { reducedMotion: true });
|
|
10
|
+
assert.throws(() => parseMediaQuery("(max-width: 640px)", widths), /Undefined media breakpoint/);
|
|
11
|
+
assert.throws(() => parseMediaQuery("(orientation: landscape)", widths), /Unsupported media query/);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("reads the existing base syntax and single or combined state selectors", () => {
|
|
15
|
+
assert.deepEqual(parseLocalStyleSelector(".tabItem1"), { name: "tabItem1", when: [] });
|
|
16
|
+
for (const state of ["hover", "active", "focus", "disabled", "checked"]) {
|
|
17
|
+
assert.deepEqual(parseLocalStyleSelector(`.tab:${state}`), { name: "tab", when: [state] });
|
|
18
|
+
}
|
|
19
|
+
assert.deepEqual(parseLocalStyleSelector(".tab:checked:hover"), { name: "tab", when: ["checked", "hover"] });
|
|
20
|
+
assert.deepEqual(parseLocalStyleSelector(".tab:active:focus:disabled"), {
|
|
21
|
+
name: "tab", when: ["active", "focus", "disabled"],
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("rejects duplicate and unsupported states and selector shapes", () => {
|
|
26
|
+
assert.throws(() => parseLocalStyleSelector(".tab:hover:checked:hover"), /Duplicate style state :hover/);
|
|
27
|
+
assert.throws(() => parseLocalStyleSelector(".tab:selected"), /Unsupported style state :selected/);
|
|
28
|
+
for (const selector of [
|
|
29
|
+
".Tab:hover", ".tab-item:hover", "#tab:hover", "tab:hover", ".tab:hover:",
|
|
30
|
+
".tab::before", ".tab:not(:checked)", ".tab:has(.child)", ".tab:nth-child(2)",
|
|
31
|
+
".tab:hover, .other:active", ".tab .child:hover", ".tab:hover .child", ".tab:hover + .other",
|
|
32
|
+
".tab:hover > .other", ".tab:hover[part=x]", ".tab:hover.other", ".tab :hover",
|
|
33
|
+
]) {
|
|
34
|
+
assert.throws(() => parseLocalStyleSelector(selector), { name: "Error" }, selector);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("parses state paint in the native style format and resolves typed tokens", () => {
|
|
39
|
+
const tokens = new Map([["--bright", "#aBC102"], ["--dim", "0.5"], ["--tab-art", "atlas(tab-active)"]]);
|
|
40
|
+
assert.deepEqual(parseStateDeclaration("color", "#aBC102"), ["color", "#aBC102"]);
|
|
41
|
+
assert.deepEqual(parseStateDeclaration("background-color", "#123456"), ["backgroundColor", "#123456"]);
|
|
42
|
+
assert.deepEqual(parseStateDeclaration("border-color", "#aBC102"), ["borderColor", "#aBC102"]);
|
|
43
|
+
assert.deepEqual(parseStateDeclaration("color", "var(--bright)", tokens), ["color", "var(--bright, #aBC102)"]);
|
|
44
|
+
assert.deepEqual(parseStateDeclaration("background-color", "var(--bright)", tokens), [
|
|
45
|
+
"backgroundColor", "var(--bright, #aBC102)",
|
|
46
|
+
]);
|
|
47
|
+
assert.deepEqual(parseStateDeclaration("border-color", "var(--bright)", tokens), ["borderColor", "var(--bright, #aBC102)"]);
|
|
48
|
+
assert.deepEqual(parseStateDeclaration("opacity", "0"), ["opacity", 0]);
|
|
49
|
+
assert.deepEqual(parseStateDeclaration("opacity", "1.000"), ["opacity", 1]);
|
|
50
|
+
assert.deepEqual(parseStateDeclaration("opacity", "var(--dim)", tokens), ["opacity", 0.5]);
|
|
51
|
+
assert.deepEqual(parseStateDeclaration("background-image", "var(--tab-art)", tokens), [
|
|
52
|
+
"backgroundImage", { atlas: "tab-active" },
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
for (const property of ["width", "padding", "gap", "position", "display", "font-size", "z-index", "__proto__"]) {
|
|
56
|
+
assert.throws(() => parseStateDeclaration(property, "0"), /Unsupported property .* in a style state/);
|
|
57
|
+
}
|
|
58
|
+
assert.throws(() => parseStateDeclaration("color", "var(--missing)", tokens), /Unknown token --missing/);
|
|
59
|
+
assert.throws(() => parseStateDeclaration("color", "var(--dim)", tokens), /Invalid value for color/);
|
|
60
|
+
assert.throws(() => parseStateDeclaration("opacity", "var(--bright)", tokens), /Invalid value for opacity/);
|
|
61
|
+
assert.throws(() => parseStateDeclaration("color", "red"), /Invalid value for color/);
|
|
62
|
+
for (const value of ["1.001", "-0.1", "50%", "Infinity"]) {
|
|
63
|
+
assert.throws(() => parseStateDeclaration("opacity", value), /Invalid value for opacity/);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("allows a single local texture path or atlas", () => {
|
|
68
|
+
assert.deepEqual(parseStateDeclaration("background-image", 'url("Interface/AddOns/Kumi/Textures/Tab Active.tga")'), [
|
|
69
|
+
"backgroundImage", { path: "Interface/AddOns/Kumi/Textures/Tab Active.tga" },
|
|
70
|
+
]);
|
|
71
|
+
assert.deepEqual(parseStateDeclaration("background-image", "url( './textures/tab.blp' )"), [
|
|
72
|
+
"backgroundImage", { path: "./textures/tab.blp" },
|
|
73
|
+
]);
|
|
74
|
+
assert.deepEqual(parseStateDeclaration("background-image", "atlas(UI-Panel_Active)"), [
|
|
75
|
+
"backgroundImage", { atlas: "UI-Panel_Active" },
|
|
76
|
+
]);
|
|
77
|
+
assert.deepEqual(parseStateDeclaration("background-image", 'atlas("UI-Panel_Active")'), [
|
|
78
|
+
"backgroundImage", { atlas: "UI-Panel_Active" },
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
for (const value of [
|
|
82
|
+
'url("https://example.com/tab.tga")', 'url("//example.com/tab.tga")', 'url("data:image/png;base64,ABC")',
|
|
83
|
+
'url("file:///tab.tga")', 'url("C:/tab.tga")', 'url("/tab.tga")', 'url("../tab.tga")',
|
|
84
|
+
'url("textures/../tab.tga")', 'url("textures/%2e%2e/tab.tga")', 'url("textures\\..\\tab.tga")',
|
|
85
|
+
'url("textures//tab.tga")', 'url("tab.tga?query")', 'url("tab.tga#fragment")',
|
|
86
|
+
'url("tab.tga"), url("other.tga")', 'url("tab.tga") center', 'url("")', "url(tab.tga)",
|
|
87
|
+
'atlas("x/y")', 'atlas("x y")', "atlas()", "linear-gradient(#123456, #ffffff)", "none",
|
|
88
|
+
]) {
|
|
89
|
+
assert.throws(() => parseStateDeclaration("background-image", value), /Invalid value for background-image/, value);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("orders by specificity, disabled tiebreak, then source", () => {
|
|
94
|
+
const selectors = [
|
|
95
|
+
".tab:focus:checked", ".tab:checked:disabled", ".tab:disabled", ".tab:hover",
|
|
96
|
+
".tab:active", ".tab:disabled:hover", ".tab:checked:hover", ".tab:hover:checked", ".tab",
|
|
97
|
+
];
|
|
98
|
+
const variants = selectors.map(selector => ({ ...parseLocalStyleSelector(selector), selector, paint: {} }));
|
|
99
|
+
assert.deepEqual(variants.sort(compareStyleStates).map(({ selector }) => selector), [
|
|
100
|
+
".tab", ".tab:hover", ".tab:active", ".tab:disabled", ".tab:focus:checked",
|
|
101
|
+
".tab:checked:hover", ".tab:hover:checked", ".tab:checked:disabled", ".tab:disabled:hover",
|
|
102
|
+
]);
|
|
103
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
|
|
7
|
+
const imageExtension = /\.(?:png|jpe?g|webp|tga)$/;
|
|
8
|
+
const prefix = "\0kumi-image:";
|
|
9
|
+
const tgaQuery = "?kumi-tga";
|
|
10
|
+
const run = promisify(execFile);
|
|
11
|
+
|
|
12
|
+
export function viteImageAssets({ pack, cacheDir } = {}) {
|
|
13
|
+
return {
|
|
14
|
+
name: "kumi-image-assets",
|
|
15
|
+
enforce: "pre",
|
|
16
|
+
async resolveId(source, importer) {
|
|
17
|
+
if (!importer || !imageExtension.test(source) || !/^\.\.?\//.test(source)) return;
|
|
18
|
+
if (source.endsWith(".tga")) {
|
|
19
|
+
const resolved = await this.resolve(source, importer, { skipSelf: true });
|
|
20
|
+
if (resolved) return resolved.id + tgaQuery;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const resolved = await this.resolve(source + "?url", importer, { skipSelf: true });
|
|
24
|
+
if (resolved) return prefix + resolved.id;
|
|
25
|
+
},
|
|
26
|
+
async load(id) {
|
|
27
|
+
if (id.endsWith(tgaQuery)) {
|
|
28
|
+
if (!pack || !cacheDir) throw new Error("Set pack and cacheDir in viteImageAssets to preview TGA images");
|
|
29
|
+
const file = id.slice(0, -tgaQuery.length);
|
|
30
|
+
this.addWatchFile(file);
|
|
31
|
+
const source = await readFile(file);
|
|
32
|
+
const hash = createHash("sha256").update(source).digest("hex");
|
|
33
|
+
const png = resolve(cacheDir, hash + ".png");
|
|
34
|
+
let data;
|
|
35
|
+
try {
|
|
36
|
+
data = await readFile(png);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error.code !== "ENOENT") throw error;
|
|
39
|
+
const conversion = run(pack, ["image", "-", "--image-input-tga", "--image-output", png], { windowsHide: true });
|
|
40
|
+
conversion.child.stdin.on("error", () => {});
|
|
41
|
+
conversion.child.stdin.end(source);
|
|
42
|
+
await conversion;
|
|
43
|
+
data = await readFile(png);
|
|
44
|
+
}
|
|
45
|
+
const image = { path: "data:image/png;base64," + data.toString("base64"),
|
|
46
|
+
width: data.readUInt32BE(16), height: data.readUInt32BE(20) };
|
|
47
|
+
return `export default ${JSON.stringify(image)};`;
|
|
48
|
+
}
|
|
49
|
+
if (!id.startsWith(prefix)) return;
|
|
50
|
+
return `import path from ${JSON.stringify(id.slice(prefix.length))}; export default { path };`;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
|
|
3
|
+
export function viteProjectAliases({ root, source = "src" } = {}) {
|
|
4
|
+
return {
|
|
5
|
+
name: "kumi-project-aliases",
|
|
6
|
+
config(config) {
|
|
7
|
+
return { resolve: { alias: { "@": resolve(root ?? config.root ?? process.cwd(), source) } } };
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
}
|
package/config.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface BundleImport<Bundle extends string = string> {
|
|
2
|
+
bundle: Bundle;
|
|
3
|
+
mode: "embedded" | "plugin";
|
|
4
|
+
/** Generate the Lua build entry from the feature module's activate export. */
|
|
5
|
+
entry?: "module";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface KumiConfig<Bundle extends string = string> {
|
|
9
|
+
build?: {
|
|
10
|
+
/** AddOns directory. Relative paths start at the project workspace. */
|
|
11
|
+
addonsDir?: string;
|
|
12
|
+
imports?: readonly BundleImport<Bundle>[];
|
|
13
|
+
};
|
|
14
|
+
dev?: {
|
|
15
|
+
port?: number;
|
|
16
|
+
};
|
|
17
|
+
}
|