@overmvp/kumi 0.1.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -6
- package/animation/index.ts +4 -0
- package/animation/motion-policy.ts +20 -0
- package/animation/slide.ts +61 -0
- package/animation/spring.ts +75 -0
- package/animation/staggered-reveal.ts +34 -0
- package/builder/css-gradients.mjs +74 -0
- package/builder/css-mask-assets.mjs +52 -0
- package/builder/css-mask-assets.test.mjs +31 -0
- package/builder/css-v1.mjs +127 -23
- package/builder/css-v1.test.mjs +82 -2
- 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 +205 -8
- package/builder/src/lua_upvalues.rs +641 -0
- package/builder/src/main.rs +20 -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 +111 -0
- package/builder/style-modules.test.mjs +24 -0
- package/builder/style-states.mjs +6 -4
- 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 +10 -2
- package/router/link.tsx +32 -0
- package/router/navigation.ts +22 -0
- package/router/router-view.ts +134 -0
- package/scripts/addon-build.mjs +377 -0
- package/scripts/addon-project.mjs +89 -0
- package/scripts/kumi-cli.mjs +52 -17
- package/scripts/link-addons.mjs +12 -2
- package/src/bindings.ts +12 -6
- package/src/context.ts +31 -7
- package/src/css-tokens.ts +27 -13
- package/src/css-v1.ts +13 -0
- package/src/elements.ts +35 -0
- package/src/flex-layout.ts +26 -5
- package/src/frame-scheduler.ts +6 -2
- package/src/index.ts +2 -1
- package/src/jsx-runtime.ts +8 -1
- package/src/keyed-list.ts +17 -11
- package/src/module-ui.ts +163 -0
- package/src/module.ts +51 -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 +42 -8
- package/src/result.ts +6 -0
- package/src/signal-kernel.ts +35 -2
- package/src/style-classes.ts +22 -1
- package/src/style-states.ts +13 -6
- 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.css +90 -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.css +103 -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.css +23 -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.css +13 -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.css +91 -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 +244 -0
- package/wow/action-catalog.ts +98 -0
- package/wow/addon-manifest.ts +38 -0
- package/wow/animation.ts +3 -14
- package/wow/app-ui.ts +230 -0
- package/wow/cooldown-timing.ts +24 -0
- package/wow/css-background-image.ts +75 -0
- package/wow/css-box.ts +46 -10
- package/wow/css-image-mask.ts +32 -0
- package/wow/css-surfaces.ts +295 -43
- package/wow/cursor.ts +45 -0
- package/wow/element-events.ts +33 -13
- package/wow/frame-access.ts +23 -1
- package/wow/frame-timing.ts +13 -0
- package/wow/heal-prediction.ts +2 -4
- package/wow/hooks.ts +133 -0
- package/wow/index.ts +19 -4
- package/wow/layout-view.ts +44 -23
- package/wow/locale-font.ts +15 -0
- package/wow/module-replacements.ts +103 -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/pointer-click.ts +35 -0
- package/wow/protect.ts +27 -3
- package/wow/protected-view.ts +139 -0
- package/wow/range-art.ts +7 -0
- package/wow/readable-api.ts +120 -0
- package/wow/rounded-texture.ts +38 -6
- package/wow/saved-variables.ts +67 -18
- package/wow/spell-cooldown.ts +36 -0
- package/wow/start-addon.ts +31 -8
- package/wow/state-paint.ts +5 -14
- package/wow/texture-fill.ts +10 -0
- package/wow/unit-cast.ts +6 -4
- package/wow/view.ts +458 -228
- 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/scripts/kumi-cli.mjs
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
|
-
import { mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { basename, join, resolve } from "node:path";
|
|
3
|
+
import { constants, copyFileSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { basename, extname, join, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
6
7
|
import { linkAddons } from "./link-addons.mjs";
|
|
7
8
|
|
|
8
9
|
const sdk = fileURLToPath(new URL("../", import.meta.url));
|
|
9
10
|
const { name, version } = JSON.parse(readFileSync(join(sdk, "package.json"), "utf8"));
|
|
10
11
|
const template = join(sdk, "templates", "addon");
|
|
11
|
-
const usage =
|
|
12
|
+
const usage = `Usage:
|
|
13
|
+
kumi init <AddonName>
|
|
14
|
+
kumi check [--types-only]
|
|
15
|
+
kumi build [--target retail|forever] [--toc number]
|
|
16
|
+
kumi link <AddOns-dir> [--dry-run]
|
|
17
|
+
kumi --version`;
|
|
18
|
+
|
|
19
|
+
const TEMPLATE_TEXT_EXTENSIONS = new Set([".css", ".json", ".md", ".mjs", ".scss", ".toc", ".ts", ".tsx"]);
|
|
12
20
|
|
|
13
21
|
function init(destination) {
|
|
14
22
|
const target = resolve(destination);
|
|
@@ -16,11 +24,13 @@ function init(destination) {
|
|
|
16
24
|
if (!/^[A-Za-z][A-Za-z0-9_-]{0,62}$/u.test(addon)) throw new Error("Use a folder name such as MyAddon");
|
|
17
25
|
const replacements = {
|
|
18
26
|
__ADDON_NAME__: addon,
|
|
27
|
+
__ADDON_DB__: addon.replace(/[^A-Za-z0-9_]/g, "_") + "DB",
|
|
19
28
|
__PROJECT_NAME__: addon.toLowerCase(),
|
|
20
29
|
__KUMI_PACKAGE__: name,
|
|
21
30
|
__KUMI_VERSION__: version,
|
|
31
|
+
__ADDON_SLASH__: addon.toLowerCase().replace(/[^a-z0-9]/gu, ""),
|
|
22
32
|
};
|
|
23
|
-
const fill = text => text.replace(/__(ADDON_NAME|PROJECT_NAME|KUMI_PACKAGE|KUMI_VERSION)__/gu, key => replacements[key]);
|
|
33
|
+
const fill = text => text.replace(/__(ADDON_NAME|ADDON_DB|ADDON_SLASH|PROJECT_NAME|KUMI_PACKAGE|KUMI_VERSION)__/gu, key => replacements[key]);
|
|
24
34
|
function copy(from, to) {
|
|
25
35
|
for (const entry of readdirSync(from, { withFileTypes: true })) {
|
|
26
36
|
const source = join(from, entry.name);
|
|
@@ -28,7 +38,13 @@ function init(destination) {
|
|
|
28
38
|
if (entry.isDirectory()) {
|
|
29
39
|
mkdirSync(output);
|
|
30
40
|
copy(source, output);
|
|
31
|
-
} else if (entry.isFile())
|
|
41
|
+
} else if (entry.isFile()) {
|
|
42
|
+
if (entry.name === "gitignore" || TEMPLATE_TEXT_EXTENSIONS.has(extname(entry.name))) {
|
|
43
|
+
writeFileSync(output, fill(readFileSync(source, "utf8")), { flag: "wx" });
|
|
44
|
+
} else {
|
|
45
|
+
copyFileSync(source, output, constants.COPYFILE_EXCL);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
32
48
|
}
|
|
33
49
|
}
|
|
34
50
|
mkdirSync(target);
|
|
@@ -42,16 +58,29 @@ function run(command, args, env) {
|
|
|
42
58
|
if (command === "cargo" && result.error.code === "ENOENT") throw new Error("Install Rust with Cargo on PATH to build Lua");
|
|
43
59
|
throw result.error;
|
|
44
60
|
}
|
|
45
|
-
if (result.status !== 0)
|
|
61
|
+
if (result.status !== 0) throw Object.assign(new Error("Kumi subprocess failed"), { exitStatus: result.status ?? 1 });
|
|
46
62
|
}
|
|
47
63
|
|
|
48
|
-
function
|
|
49
|
-
const target =
|
|
64
|
+
function createPackRunner(workspace) {
|
|
65
|
+
const target = join(workspace, "build", "toolchain");
|
|
50
66
|
const env = { ...process.env, CARGO_TARGET_DIR: target, CARGO_BUILD_JOBS: "1", UV_THREADPOOL_SIZE: "1" };
|
|
51
|
-
run("cargo", ["build", "--locked", "--jobs", "1", "--manifest-path", join(sdk, "builder", "Cargo.toml")], env);
|
|
52
67
|
const packer = join(target, "debug", process.platform === "win32" ? "kumi-pack.exe" : "kumi-pack");
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
let ready = false;
|
|
69
|
+
return args => {
|
|
70
|
+
if (!ready) {
|
|
71
|
+
run("cargo", ["build", "--locked", "--jobs", "1", "--manifest-path", join(sdk, "builder", "Cargo.toml")], env);
|
|
72
|
+
ready = true;
|
|
73
|
+
}
|
|
74
|
+
run(packer, [ ...(args.includes("--workspace") ? [] : ["--workspace", workspace]),
|
|
75
|
+
...(args.includes("compile") && !args.includes("--sdk-root") ? ["--sdk-root", sdk] : []), ...args], env);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function link(args) {
|
|
80
|
+
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { "dry-run": { type: "boolean" } } });
|
|
81
|
+
if (positionals.length === 1) linkAddons(join("build", "addons"), positionals[0], values["dry-run"]);
|
|
82
|
+
else if (positionals.length === 2) linkAddons(positionals[0], positionals[1], values["dry-run"]);
|
|
83
|
+
else throw new Error(usage);
|
|
55
84
|
}
|
|
56
85
|
|
|
57
86
|
const [command, ...args] = process.argv.slice(2);
|
|
@@ -59,12 +88,18 @@ try {
|
|
|
59
88
|
if (command === "--version") console.log(version);
|
|
60
89
|
else if (command === undefined || command === "--help" || command === "-h") console.log(usage);
|
|
61
90
|
else if (command === "init" && args.length === 1 && !args[0].startsWith("-")) init(args[0]);
|
|
62
|
-
else if (command === "
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
91
|
+
else if (command === "check" || command === "build") {
|
|
92
|
+
const { checkAddon, buildAddon } = await import("./addon-project.mjs");
|
|
93
|
+
const workspace = process.cwd();
|
|
94
|
+
const pack = createPackRunner(workspace);
|
|
95
|
+
if (command === "check") await checkAddon(workspace, args, pack, run);
|
|
96
|
+
else await buildAddon(workspace, args, pack);
|
|
97
|
+
} else if (command === "pack" && args.length > 0) createPackRunner(process.cwd())(args);
|
|
98
|
+
else if (command === "link") link(args);
|
|
66
99
|
else throw new Error(usage);
|
|
67
100
|
} catch (error) {
|
|
68
|
-
|
|
69
|
-
|
|
101
|
+
if (error.exitStatus === undefined) {
|
|
102
|
+
console.error(`kumi: ${error.code === "EEXIST" ? "The destination already exists. Choose a new directory." : error.message}`);
|
|
103
|
+
}
|
|
104
|
+
process.exitCode = error.exitStatus ?? 1;
|
|
70
105
|
}
|
package/scripts/link-addons.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { lstatSync, realpathSync, readdirSync, statSync, symlinkSync, unlinkSync } from "node:fs";
|
|
2
|
-
import { basename, join } from "node:path";
|
|
1
|
+
import { lstatSync, readlinkSync, realpathSync, readdirSync, statSync, symlinkSync, unlinkSync } from "node:fs";
|
|
2
|
+
import { basename, join, resolve, sep } from "node:path";
|
|
3
3
|
|
|
4
4
|
function inspect(path) {
|
|
5
5
|
return lstatSync(path, { throwIfNoEntry: false });
|
|
@@ -11,6 +11,16 @@ export function linkAddons(buildDirectory, addonsDirectory, dryRun) {
|
|
|
11
11
|
if (!statSync(build).isDirectory() || !statSync(addons).isDirectory() || build === addons) {
|
|
12
12
|
throw new Error("Specify a build folder and a different existing AddOns folder");
|
|
13
13
|
}
|
|
14
|
+
// Remove links into this build whose folder no longer exists, such as a plugin removed from kumi.config.ts.
|
|
15
|
+
for (const entry of readdirSync(addons, { withFileTypes: true })) {
|
|
16
|
+
const destination = join(addons, entry.name);
|
|
17
|
+
const link = inspect(destination);
|
|
18
|
+
if (!link?.isSymbolicLink() || statSync(destination, { throwIfNoEntry: false }) !== undefined) continue;
|
|
19
|
+
const target = resolve(addons, readlinkSync(destination));
|
|
20
|
+
if (!target.toLowerCase().startsWith(build.toLowerCase() + sep)) continue;
|
|
21
|
+
if (!dryRun) unlinkSync(destination);
|
|
22
|
+
console.log(`Removed stale link ${destination}`);
|
|
23
|
+
}
|
|
14
24
|
const plan = [];
|
|
15
25
|
let found = 0;
|
|
16
26
|
for (const entry of readdirSync(build, { withFileTypes: true })) {
|
package/src/bindings.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import type { Anchor, Binding } from "./elements";
|
|
1
|
+
import type { ActionSlot, Anchor, Binding, CooldownValue } from "./elements";
|
|
2
2
|
import type { ImageVerticalGradient } from "./images";
|
|
3
|
-
import type
|
|
3
|
+
import { isReactiveRef, type ReadonlyRef } from "./reactivity";
|
|
4
4
|
import type { RuntimeScope } from "./runtime";
|
|
5
5
|
import type { Failure, Result } from "./result";
|
|
6
6
|
import { TextBinding } from "./text-children";
|
|
7
7
|
|
|
8
|
-
type BoundValue = string | boolean | number | Anchor | ImageVerticalGradient;
|
|
8
|
+
type BoundValue = string | boolean | number | ActionSlot | Anchor | CooldownValue | ImageVerticalGradient | undefined;
|
|
9
|
+
|
|
10
|
+
/** @internal Recognize reactive values before falling back to structural refs. */
|
|
11
|
+
export function isBindingRef(value: unknown): value is ReadonlyRef<unknown> {
|
|
12
|
+
return value !== null && typeof value === "object" && (isReactiveRef(value) || value instanceof TextBinding || "value" in value);
|
|
13
|
+
}
|
|
9
14
|
|
|
10
15
|
/** Apply a static property once or subscribe to one reactive property for the mount's lifetime. */
|
|
11
16
|
export function bindValue<T extends BoundValue>(scope: RuntimeScope, value: Binding<T>,
|
|
12
17
|
apply: (this: void, value: T) => void,
|
|
13
18
|
equals: (this: void, previous: T | undefined, current: T) => boolean = (previous, current) => previous === current,
|
|
14
19
|
validate?: (this: void, value: T) => Failure | undefined): Failure | undefined {
|
|
15
|
-
|
|
16
|
-
if (typeof value !== "object" || !((value as object) instanceof TextBinding || "value" in value)) {
|
|
20
|
+
if (!isBindingRef(value)) {
|
|
17
21
|
const failure = validate?.(value as T);
|
|
18
22
|
if (failure !== undefined) return failure;
|
|
19
23
|
apply(value as T);
|
|
@@ -21,15 +25,17 @@ export function bindValue<T extends BoundValue>(scope: RuntimeScope, value: Bind
|
|
|
21
25
|
}
|
|
22
26
|
const ref = value as ReadonlyRef<T | Result<T>>;
|
|
23
27
|
let previous: T | undefined;
|
|
28
|
+
let initialized = false;
|
|
24
29
|
const subscription = scope.watchEffect(() => {
|
|
25
30
|
const next = ref.value;
|
|
26
31
|
if (typeof next === "object" && "ok" in next && !next.ok) return next;
|
|
27
32
|
const current = typeof next === "object" && "ok" in next ? next.value : next;
|
|
28
33
|
const failure = validate?.(current);
|
|
29
34
|
if (failure !== undefined) return failure;
|
|
30
|
-
if (equals(previous, current)) return;
|
|
35
|
+
if (initialized && equals(previous, current)) return;
|
|
31
36
|
apply(current);
|
|
32
37
|
previous = current;
|
|
38
|
+
initialized = true;
|
|
33
39
|
});
|
|
34
40
|
return subscription.ok ? undefined : subscription;
|
|
35
41
|
}
|
package/src/context.ts
CHANGED
|
@@ -1,15 +1,39 @@
|
|
|
1
1
|
import type { Protect } from "./result";
|
|
2
2
|
|
|
3
|
+
interface ContextFrame {
|
|
4
|
+
readonly key: object;
|
|
5
|
+
readonly value: unknown;
|
|
6
|
+
readonly previous?: ContextFrame;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let current: ContextFrame | undefined;
|
|
10
|
+
|
|
11
|
+
/** @internal Save the context of a render callback that will run later. */
|
|
12
|
+
export function captureContexts() {
|
|
13
|
+
return current;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** @internal Run a protected callback with the context it was created in. */
|
|
17
|
+
export function withContexts<Output>(captured: ContextFrame | undefined, render: (this: void) => Output): Output {
|
|
18
|
+
const previous = current;
|
|
19
|
+
current = captured;
|
|
20
|
+
const result = render();
|
|
21
|
+
current = previous;
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
|
|
3
25
|
export function createContext<Value>() {
|
|
4
|
-
|
|
26
|
+
const key = {};
|
|
5
27
|
|
|
6
28
|
function run<Output>(value: Value, render: (this: void) => Output, protect: Protect) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
29
|
+
return withContexts({ key, value, previous: current }, () => protect(render));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function use(): Value | undefined {
|
|
33
|
+
for (let frame = current; frame !== undefined; frame = frame.previous) {
|
|
34
|
+
if (frame.key === key) return frame.value as Value;
|
|
35
|
+
}
|
|
12
36
|
}
|
|
13
37
|
|
|
14
|
-
return { run, use
|
|
38
|
+
return { run, use };
|
|
15
39
|
}
|
package/src/css-tokens.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { CssTokenRecipe } from "./css-v1";
|
|
2
|
+
import { isIntrinsicWidth } from "./flex-layout";
|
|
2
3
|
import { parseGridSpan, parseGridTracks } from "./grid-tracks";
|
|
3
4
|
import { ownedArray, type OwnedArray, type OwnedLuaArray, type OwnedReadonlyArray, type OwnedRecord } from "./owned-collections";
|
|
4
5
|
import { fail, ok, type Result } from "./result";
|
|
5
|
-
import type
|
|
6
|
+
import { resolveStyleValue, type StyleEnvironment } from "./style-variables";
|
|
6
7
|
|
|
7
8
|
type WithRecipes = { readonly styleTokens?: readonly CssTokenRecipe[] };
|
|
8
9
|
type Field = string | number;
|
|
@@ -11,25 +12,30 @@ type Bag = Record<Field, unknown>;
|
|
|
11
12
|
function digit(code: number) { return code >= 48 && code <= 57; }
|
|
12
13
|
|
|
13
14
|
function decimal(text: string): number | undefined {
|
|
15
|
+
const length = text.length;
|
|
14
16
|
const start = text.startsWith("-") || text.startsWith("+") ? 1 : 0;
|
|
15
17
|
let index = start;
|
|
16
|
-
while (digit(text.charCodeAt(index))) index
|
|
18
|
+
while (index < length && digit(text.charCodeAt(index))) index += 1;
|
|
17
19
|
const hasWhole = index > start;
|
|
18
|
-
if (text.charCodeAt(index) === 46) {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
if (index < length && text.charCodeAt(index) === 46) {
|
|
21
|
+
index += 1;
|
|
22
|
+
const fraction = index;
|
|
23
|
+
while (index < length && digit(text.charCodeAt(index))) index += 1;
|
|
21
24
|
if (fraction === index) return;
|
|
22
25
|
} else if (!hasWhole) return;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (
|
|
26
|
+
if (index < length) {
|
|
27
|
+
const separator = text.charCodeAt(index);
|
|
28
|
+
if (separator !== 69 && separator !== 101) return;
|
|
29
|
+
index += 1;
|
|
30
|
+
if (index < length) {
|
|
31
|
+
const sign = text.charCodeAt(index);
|
|
32
|
+
if (sign === 43 || sign === 45) index += 1;
|
|
33
|
+
}
|
|
28
34
|
const exponent = index;
|
|
29
|
-
while (digit(text.charCodeAt(index))) index
|
|
35
|
+
while (index < length && digit(text.charCodeAt(index))) index += 1;
|
|
30
36
|
if (exponent === index) return;
|
|
31
37
|
}
|
|
32
|
-
if (index !==
|
|
38
|
+
if (index !== length) return;
|
|
33
39
|
const number = Number(text);
|
|
34
40
|
return Number.isFinite(number) ? number : undefined;
|
|
35
41
|
}
|
|
@@ -157,7 +163,10 @@ function decode(raw: string, recipe: CssTokenRecipe): unknown {
|
|
|
157
163
|
const columns = parseGridSpan(text);
|
|
158
164
|
return columns === undefined ? undefined : `span ${columns}`;
|
|
159
165
|
}
|
|
160
|
-
if (kind === "size" &&
|
|
166
|
+
if (kind === "size" && add === undefined) {
|
|
167
|
+
if (text === "auto" || (recipe.path as OwnedReadonlyArray<Field>)[0] === "width" && isIntrinsicWidth(text)) return text;
|
|
168
|
+
if (text.endsWith("%") && (decimal(text.slice(0, -1)) ?? -1) >= 0) return text;
|
|
169
|
+
}
|
|
161
170
|
const length = kind === "length" || kind === "signedLength" || kind === "positiveLength" || kind === "size" || kind === "radius";
|
|
162
171
|
const number = kind === "fontWeight" && add === undefined && (text === "normal" || text === "bold")
|
|
163
172
|
? text === "normal" ? 400 : 700 : length ? pixels(text) : decimal(text);
|
|
@@ -201,6 +210,11 @@ export function resolveCssTokens<Style extends WithRecipes>(this: void, base: St
|
|
|
201
210
|
token = authored.value ?? false;
|
|
202
211
|
sourced[recipe.token] = token;
|
|
203
212
|
}
|
|
213
|
+
if (token === false && recipe.fallbackExpression !== undefined) {
|
|
214
|
+
const fallback = resolveStyleValue(recipe.fallbackExpression, environment);
|
|
215
|
+
if (!fallback.ok) return fallback;
|
|
216
|
+
token = fallback.value ?? false;
|
|
217
|
+
}
|
|
204
218
|
if (token === false || token === recipe.source) continue;
|
|
205
219
|
const parsed = decode(token, recipe);
|
|
206
220
|
const path = recipe.path as OwnedReadonlyArray<Field>;
|
package/src/css-v1.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RGBA } from "../utils/colors";
|
|
1
2
|
import type { Binding } from "./elements";
|
|
2
3
|
import type { StatePaint } from "./style-states";
|
|
3
4
|
import type { LayoutDisplay, LayoutPosition } from "./flex-layout";
|
|
@@ -14,6 +15,13 @@ export interface CssBorderEdge {
|
|
|
14
15
|
|
|
15
16
|
export type CssBorder = Readonly<Partial<Record<CssSide, CssBorderEdge>>>;
|
|
16
17
|
|
|
18
|
+
/** @internal Normalized paint for a compiled fixed uniform border. */
|
|
19
|
+
export interface CssBorderPaintPlan {
|
|
20
|
+
readonly width: number;
|
|
21
|
+
readonly literal: string;
|
|
22
|
+
readonly rgba: RGBA;
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
export interface CssTextShadow {
|
|
18
26
|
readonly x: number;
|
|
19
27
|
readonly y: number;
|
|
@@ -27,6 +35,8 @@ export interface CssTokenRecipe {
|
|
|
27
35
|
readonly fallback: unknown;
|
|
28
36
|
/** @internal Exact compiler-validated token text whose decoded value is `fallback`. */
|
|
29
37
|
readonly source?: string;
|
|
38
|
+
/** @internal Optional CSS fallback evaluated when the named variable is missing. */
|
|
39
|
+
readonly fallbackExpression?: string;
|
|
30
40
|
readonly add?: number;
|
|
31
41
|
readonly part?: string | number;
|
|
32
42
|
readonly values?: readonly (string | number)[];
|
|
@@ -43,8 +53,11 @@ export interface CssV1Style {
|
|
|
43
53
|
* between them, its own size or its content's (as `width: fit-content`). */
|
|
44
54
|
autoMargin?: Binding<readonly [boolean, boolean, boolean, boolean]>;
|
|
45
55
|
border?: CssBorder;
|
|
56
|
+
/** @internal A hint for the final border after class and inline styles are combined. */
|
|
57
|
+
borderPaint?: CssBorderPaintPlan;
|
|
46
58
|
borderRadius?: number;
|
|
47
59
|
backgroundImage?: StatePaint["backgroundImage"];
|
|
60
|
+
maskImage?: Readonly<{ path: string }>;
|
|
48
61
|
fontWeight?: CssFontWeight;
|
|
49
62
|
textAlign?: CssTextAlign;
|
|
50
63
|
textShadow?: CssTextShadow;
|
package/src/elements.ts
CHANGED
|
@@ -34,6 +34,10 @@ export interface Anchor {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export type Binding<T> = T | ReadonlyRef<T> | ReadonlyRef<Result<T>>;
|
|
37
|
+
export type TextureSource = string | number | undefined;
|
|
38
|
+
export type TextureCoordinates = readonly [left: number, right: number, bottom: number, top: number];
|
|
39
|
+
export type ActionSlot = Readonly<{ kind: "item" | "spell" | "toy"; id: number }>;
|
|
40
|
+
export type CooldownValue = Readonly<{ start: number; duration: number; rate: number }>;
|
|
37
41
|
|
|
38
42
|
declare const nativeStatusBarValue: unique symbol;
|
|
39
43
|
|
|
@@ -150,8 +154,12 @@ type ElementLayout<Kind extends MountedElementKind> = NativeLayout & { nodeRef?:
|
|
|
150
154
|
interface NativeProps {
|
|
151
155
|
frame: ElementLayout<"frame"> & ElementEvents & {
|
|
152
156
|
ref?: ElementRef<"frame">;
|
|
157
|
+
/** Allow the frame to run snippets installed with secureStateSnippet. */
|
|
158
|
+
secureStateHandler?: true;
|
|
153
159
|
/** The native frame's own scale in parent coordinates. */
|
|
154
160
|
nativeScale?: Binding<number>;
|
|
161
|
+
/** Lay out this keyed frame directly in its parent CSS container. */
|
|
162
|
+
directKeyedLayout?: true;
|
|
155
163
|
/** Decorative artwork for WoW, reconciled as a single layer without child frames. */
|
|
156
164
|
nativeImageLayers?: Binding<readonly NativeImageLayer[]>;
|
|
157
165
|
/** Use the host's two native nine-slice textures for a rounded fill and decorative 1px border. */
|
|
@@ -170,6 +178,17 @@ interface NativeProps {
|
|
|
170
178
|
nativeDesaturated?: Binding<boolean>;
|
|
171
179
|
ref?: ElementRef<"image">;
|
|
172
180
|
};
|
|
181
|
+
texture: Omit<NativeProps["image"], "src"> & {
|
|
182
|
+
src: Binding<TextureSource>;
|
|
183
|
+
texCoords?: TextureCoordinates;
|
|
184
|
+
onSourceChange?(this: void, source: TextureSource): void;
|
|
185
|
+
};
|
|
186
|
+
cooldown: NativeLayout & {
|
|
187
|
+
value: Binding<CooldownValue | undefined>;
|
|
188
|
+
/** Custom texture for the swipe. With this option the swipe is the sole timer visual. */
|
|
189
|
+
swipeTexture?: string;
|
|
190
|
+
reverse?: boolean;
|
|
191
|
+
};
|
|
173
192
|
scrollview: ElementLayout<"scrollview"> & {
|
|
174
193
|
contentHeight: Binding<number>;
|
|
175
194
|
ref?: ElementRef<"scrollview">;
|
|
@@ -206,6 +225,19 @@ interface NativeProps {
|
|
|
206
225
|
disabled?: Binding<boolean>;
|
|
207
226
|
checked?: Binding<boolean>;
|
|
208
227
|
ref?: ElementRef<"button">;
|
|
228
|
+
/** Maximum pointer hold in seconds for onClick. Pointer drags also suppress onClick. */
|
|
229
|
+
clickMaxDuration?: number;
|
|
230
|
+
secureAction?: Binding<ActionSlot | undefined>;
|
|
231
|
+
/** Macro text run by a hardware click. Use this in place of `secureAction`. */
|
|
232
|
+
secureMacro?: Binding<string | undefined>;
|
|
233
|
+
/** An anchored secure button keeps its identity and mounts paint and children on its first show. */
|
|
234
|
+
deferContentUntilShown?: true;
|
|
235
|
+
/** Lay out this keyed button directly in its parent CSS container. */
|
|
236
|
+
directKeyedLayout?: true;
|
|
237
|
+
onReceiveDrag?(this: void): Result<boolean> | void;
|
|
238
|
+
onMove?(this: void, x: number, y: number): void;
|
|
239
|
+
onMoveEnd?(this: void, x: number, y: number): void;
|
|
240
|
+
onMoveCancel?(this: void): void;
|
|
209
241
|
onDrag?(this: void, offsetY: number): void;
|
|
210
242
|
onDragEnd?(this: void, offsetY: number): void;
|
|
211
243
|
onDragCancel?(this: void): void;
|
|
@@ -216,6 +248,7 @@ interface NativeProps {
|
|
|
216
248
|
label?: string;
|
|
217
249
|
placeholder?: string;
|
|
218
250
|
unstyled?: boolean;
|
|
251
|
+
nativeImageLayers?: Binding<readonly NativeImageLayer[]>;
|
|
219
252
|
nativeRoundedArt?: true;
|
|
220
253
|
disabled?: Binding<boolean>;
|
|
221
254
|
maxLetters?: number;
|
|
@@ -243,6 +276,8 @@ interface NativeProps {
|
|
|
243
276
|
max: number;
|
|
244
277
|
step?: number;
|
|
245
278
|
onChange?(this: void, value: number): void;
|
|
279
|
+
/** Runs after a pointer adjustment that changed the value. */
|
|
280
|
+
onCommit?(this: void): void;
|
|
246
281
|
};
|
|
247
282
|
listbox: ElementLayout<"listbox"> & {
|
|
248
283
|
value: Binding<string>;
|
package/src/flex-layout.ts
CHANGED
|
@@ -7,9 +7,10 @@ type Insets = number | readonly [number, number] | readonly [number, number, num
|
|
|
7
7
|
/** A border-box length; a percentage resolves against the parent's content box when that is known. */
|
|
8
8
|
export type LayoutLength = number | `${number}%`;
|
|
9
9
|
type Size = LayoutLength | "auto";
|
|
10
|
+
type IntrinsicWidth = "fit-content" | "min-content" | "max-content";
|
|
10
11
|
|
|
11
12
|
export interface FlexStyle {
|
|
12
|
-
width?: Size;
|
|
13
|
+
width?: Size | IntrinsicWidth;
|
|
13
14
|
height?: Size;
|
|
14
15
|
minWidth?: number;
|
|
15
16
|
minHeight?: number;
|
|
@@ -87,6 +88,7 @@ interface Axis {
|
|
|
87
88
|
minimum: number;
|
|
88
89
|
maximum: number;
|
|
89
90
|
specified?: number;
|
|
91
|
+
intrinsic?: IntrinsicWidth;
|
|
90
92
|
/** A percentage size, resolved against the parent's content box during placement. */
|
|
91
93
|
percent?: number;
|
|
92
94
|
preferred: number;
|
|
@@ -124,7 +126,11 @@ export function layoutPercent(this: void, size: unknown): number | undefined {
|
|
|
124
126
|
return Number.isFinite(value) && value >= 0 ? value : undefined;
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
function
|
|
129
|
+
export function isIntrinsicWidth(this: void, value: unknown): value is IntrinsicWidth {
|
|
130
|
+
return value === "fit-content" || value === "min-content" || value === "max-content";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function axis(size: Size | IntrinsicWidth | undefined, minimum: number | undefined, maximum: number | undefined,
|
|
128
134
|
paddingStart: number, paddingEnd: number, marginStart: number, marginEnd: number): Axis {
|
|
129
135
|
const floor = Math.max(paddingStart + paddingEnd, minimum ?? 0);
|
|
130
136
|
return {
|
|
@@ -132,6 +138,7 @@ function axis(size: Size | undefined, minimum: number | undefined, maximum: numb
|
|
|
132
138
|
minimum: floor,
|
|
133
139
|
maximum: Math.max(floor, maximum ?? Infinity),
|
|
134
140
|
specified: typeof size === "number" ? size : undefined,
|
|
141
|
+
intrinsic: isIntrinsicWidth(size) ? size : undefined,
|
|
135
142
|
percent: layoutPercent(size),
|
|
136
143
|
preferred: 0,
|
|
137
144
|
};
|
|
@@ -238,6 +245,11 @@ function measureLeaf(item: Item, dimension: Dimension) {
|
|
|
238
245
|
}
|
|
239
246
|
|
|
240
247
|
function measureAxis(item: Item, dimension: Dimension) {
|
|
248
|
+
measurePreferred(item, dimension);
|
|
249
|
+
if (item[dimension].intrinsic === "min-content") item.width.preferred = minContentBox(item);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function measurePreferred(item: Item, dimension: Dimension) {
|
|
241
253
|
const { children } = item;
|
|
242
254
|
const target = item[dimension];
|
|
243
255
|
if (children === undefined) {
|
|
@@ -304,6 +316,7 @@ function preferredSize(item: Item, dimension: Dimension, available: number) {
|
|
|
304
316
|
const box = item[dimension];
|
|
305
317
|
if (dimension === "width" && item.source.fullWidth === true) return Math.max(0, available - margins(box));
|
|
306
318
|
if (box.percent !== undefined) return available * box.percent / 100;
|
|
319
|
+
if (box.intrinsic === "fit-content") return Math.min(box.preferred, Math.max(minContentBox(item), available - margins(box)));
|
|
307
320
|
return box.preferred;
|
|
308
321
|
}
|
|
309
322
|
|
|
@@ -483,7 +496,7 @@ function positionAligned(child: Item, dimension: Dimension, start: number, inner
|
|
|
483
496
|
alignment: GridAlignment | FlexAlignment) {
|
|
484
497
|
const box = child[dimension];
|
|
485
498
|
const available = inner - margins(box);
|
|
486
|
-
const preferred = alignment === "stretch" && box.specified === undefined && box.percent === undefined ? Math.max(0, available)
|
|
499
|
+
const preferred = alignment === "stretch" && box.specified === undefined && box.percent === undefined && box.intrinsic === undefined ? Math.max(0, available)
|
|
487
500
|
: preferredSize(child, dimension, inner);
|
|
488
501
|
const target = clamp(preferred, box);
|
|
489
502
|
const offset = alignedOffset(alignment, available - target);
|
|
@@ -523,8 +536,10 @@ function positionAbsolutes(item: Item, dimension: Dimension, size: number) {
|
|
|
523
536
|
const style = child.source.style;
|
|
524
537
|
const start = dimension === "width" ? style.left : style.top;
|
|
525
538
|
const end = dimension === "width" ? style.right : style.bottom;
|
|
526
|
-
|
|
527
|
-
|
|
539
|
+
const available = size - (start ?? 0) - (end ?? 0);
|
|
540
|
+
let target = box.intrinsic !== undefined ? preferredSize(child, dimension, available)
|
|
541
|
+
: box.specified ?? (box.percent !== undefined ? size * box.percent / 100
|
|
542
|
+
: start !== undefined && end !== undefined ? available - margins(box) : box.preferred);
|
|
528
543
|
target = clamp(target, box);
|
|
529
544
|
const at = start !== undefined ? start + box.marginStart
|
|
530
545
|
: end !== undefined ? size - end - box.marginEnd - target : item[dimension].paddingStart + box.marginStart;
|
|
@@ -643,6 +658,12 @@ function minContent(item: Item): number {
|
|
|
643
658
|
return widest + padding;
|
|
644
659
|
}
|
|
645
660
|
|
|
661
|
+
function minContentBox(item: Item): number {
|
|
662
|
+
if (item.children !== undefined) return minContent(item);
|
|
663
|
+
const own = item.source.minContentWidth?.();
|
|
664
|
+
return own === undefined ? item.width.preferred : own + item.width.paddingStart + item.width.paddingEnd;
|
|
665
|
+
}
|
|
666
|
+
|
|
646
667
|
function minimumContribution(item: Item, dimension: Dimension) {
|
|
647
668
|
const box = item[dimension];
|
|
648
669
|
const explicitMinimum = dimension === "width" ? item.source.style.minWidth : item.source.style.minHeight;
|
package/src/frame-scheduler.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface FrameLimits {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export interface FrameScheduler {
|
|
34
|
+
/** @internal Frame clock for animations, when supplied by the driver. */
|
|
35
|
+
readonly nowMs?: FrameTiming["nowMs"];
|
|
34
36
|
queue(this: void, key: FrameKey, run: FrameJob, options?: FrameJobOptions): void;
|
|
35
37
|
cancel(this: void, key: FrameKey): void;
|
|
36
38
|
queued(this: void, key: FrameKey): FrameLane | undefined;
|
|
@@ -202,7 +204,9 @@ export function createFrameScheduler(
|
|
|
202
204
|
|
|
203
205
|
function remainingMs() {
|
|
204
206
|
const own = deadline === undefined ? budget() : deadline - now();
|
|
205
|
-
|
|
207
|
+
const parent = driver.remainingMs?.();
|
|
208
|
+
const available = parent !== undefined && (parent < own || Number.isNaN(parent)) ? parent : own;
|
|
209
|
+
return available <= 0 ? 0 : available;
|
|
206
210
|
}
|
|
207
211
|
|
|
208
212
|
function roll(time: number) {
|
|
@@ -330,5 +334,5 @@ export function createFrameScheduler(
|
|
|
330
334
|
wake();
|
|
331
335
|
}
|
|
332
336
|
|
|
333
|
-
return { queue, cancel, remainingMs, queued: key => byKey.get(key)?.lane, combatChanged: wake, step, inspect };
|
|
337
|
+
return { nowMs: driver.nowMs, queue, cancel, remainingMs, queued: key => byKey.get(key)?.lane, combatChanged: wake, step, inspect };
|
|
334
338
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference path="./jsx.d.ts" />
|
|
3
3
|
export * from "./elements";
|
|
4
4
|
export type { StatePaint, StateStyleVariant, StyleState } from "./style-states";
|
|
5
|
-
export type
|
|
5
|
+
export { clsx, type ClassNames, type ClassValue, type StyleClass } from "./style-classes";
|
|
6
6
|
export type { KumiNode, MountedElementKind, NodeRect, NodeRef } from "./element-node";
|
|
7
7
|
export type { NodeQuery, SelectorError } from "./node-selectors";
|
|
8
8
|
export * from "./bindings";
|
|
@@ -11,6 +11,7 @@ export * from "./cvars";
|
|
|
11
11
|
export * from "./frame-scheduler";
|
|
12
12
|
export { solveLayout, type LayoutRect, type LayoutSize, type LayoutStyle } from "./flex-layout";
|
|
13
13
|
export * from "./module";
|
|
14
|
+
export { Extensions, modulePages, type ExtensionComponent, type ModulePage, type ModuleReplacement, type ModuleUi, type ModuleView, type ModuleWindow, type ViewComponent } from "./module-ui";
|
|
14
15
|
export { provide, serviceToken, type ResolveProviderInput, type ServiceProvider, type ServiceToken } from "./providers";
|
|
15
16
|
export * from "./images";
|
|
16
17
|
export * from "./keyed-list";
|
package/src/jsx-runtime.ts
CHANGED
|
@@ -14,7 +14,14 @@ export function jsx<Props, Node extends UIElement>(this: void, component: (this:
|
|
|
14
14
|
props: Props, key?: ElementKey): Node;
|
|
15
15
|
export function jsx<Props>(this: void, component: IntrinsicTag | ((this: void, props: Props) => UIElement),
|
|
16
16
|
props: Props, key?: ElementKey) {
|
|
17
|
-
|
|
17
|
+
let inputs = props;
|
|
18
|
+
if (key !== undefined) {
|
|
19
|
+
const keyed: Record<string, unknown> = {};
|
|
20
|
+
const source = props as Record<string, unknown>;
|
|
21
|
+
for (const name of Object.keys(source)) keyed[name] = source[name];
|
|
22
|
+
keyed.key = key;
|
|
23
|
+
inputs = keyed as Props;
|
|
24
|
+
}
|
|
18
25
|
if (typeof component === "string") return createElement(component, inputs as KumiIntrinsicElements[IntrinsicTag]);
|
|
19
26
|
return createElement(component, inputs);
|
|
20
27
|
}
|