@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.
Files changed (205) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +14 -2
  3. package/animation/color-transition.ts +196 -0
  4. package/animation/cycle.ts +151 -0
  5. package/animation/ease.ts +29 -0
  6. package/animation/index.ts +13 -0
  7. package/animation/package.json +12 -0
  8. package/animation/presets.ts +376 -0
  9. package/animation/spec.ts +197 -0
  10. package/builder/Cargo.lock +192 -0
  11. package/builder/Cargo.toml +7 -0
  12. package/builder/css-v1.mjs +334 -0
  13. package/builder/css-v1.test.mjs +321 -0
  14. package/builder/generated-output.mjs +61 -0
  15. package/builder/generated-output.test.mjs +132 -0
  16. package/builder/jsx-form.mjs +93 -0
  17. package/builder/jsx-form.test.mjs +48 -0
  18. package/builder/jsx-lists.mjs +209 -0
  19. package/builder/link-addon-package.mjs +86 -0
  20. package/builder/lua-assets.mjs +74 -0
  21. package/builder/lua-builtin-values.mjs +57 -0
  22. package/builder/lua-builtin-values.test.mjs +155 -0
  23. package/builder/lua-loop-closures.mjs +183 -0
  24. package/builder/lua-loop-closures.test.mjs +89 -0
  25. package/builder/lua-truthiness.mjs +61 -0
  26. package/builder/lua-truthiness.test.mjs +113 -0
  27. package/builder/module-declarations.mjs +594 -0
  28. package/builder/module-declarations.test.mjs +444 -0
  29. package/builder/native-kernels.mjs +60 -0
  30. package/builder/native-lua.d.ts +57 -0
  31. package/builder/native-routes.mjs +51 -0
  32. package/builder/no-static-ref-read.mjs +93 -0
  33. package/builder/no-static-ref-read.test.mjs +181 -0
  34. package/builder/secure-snippet.mjs +317 -0
  35. package/builder/secure-snippet.test.mjs +101 -0
  36. package/builder/shared-lua-runtime.mjs +150 -0
  37. package/builder/src/addon-link.lua +29 -0
  38. package/builder/src/arrays.lua +260 -0
  39. package/builder/src/assets.rs +177 -0
  40. package/builder/src/classes.lua +75 -0
  41. package/builder/src/collections.lua +190 -0
  42. package/builder/src/compiler.rs +2164 -0
  43. package/builder/src/config.rs +42 -0
  44. package/builder/src/entries.rs +166 -0
  45. package/builder/src/errors.lua +15 -0
  46. package/builder/src/lua_data.rs +231 -0
  47. package/builder/src/main.rs +367 -0
  48. package/builder/src/native_ir.rs +65 -0
  49. package/builder/src/native_signal.rs +47 -0
  50. package/builder/src/numbers.lua +62 -0
  51. package/builder/src/project-front.mjs +3331 -0
  52. package/builder/src/records.lua +75 -0
  53. package/builder/src/routes.rs +127 -0
  54. package/builder/src/signal-kernel.fingerprint +1 -0
  55. package/builder/src/strings.lua +103 -0
  56. package/builder/src/ts-lower.mjs +68 -0
  57. package/builder/src/wow_client.rs +253 -0
  58. package/builder/src/wow_types.rs +564 -0
  59. package/builder/style-states.mjs +100 -0
  60. package/builder/style-states.test.mjs +103 -0
  61. package/builder/vite-assets.mjs +53 -0
  62. package/builder/vite-project.mjs +10 -0
  63. package/config.ts +17 -0
  64. package/form/index.ts +522 -0
  65. package/form/package.json +13 -0
  66. package/motion/index.ts +2 -0
  67. package/motion/package.json +10 -0
  68. package/package.json +22 -4
  69. package/router/index.ts +43 -0
  70. package/router/package.json +12 -0
  71. package/router/routes.ts +64 -0
  72. package/scripts/kumi-cli.mjs +70 -0
  73. package/scripts/link-addons.mjs +51 -0
  74. package/src/bindings.ts +35 -0
  75. package/src/context.ts +15 -0
  76. package/src/css-tokens.ts +234 -0
  77. package/src/css-v1.ts +58 -0
  78. package/src/cvars.ts +91 -0
  79. package/src/element-node.ts +32 -0
  80. package/src/elements.ts +479 -0
  81. package/src/feature-scope.ts +82 -0
  82. package/src/flex-layout.ts +807 -0
  83. package/src/frame-scheduler.ts +334 -0
  84. package/src/grid-tracks.ts +165 -0
  85. package/src/image-imports.d.ts +24 -0
  86. package/src/images.ts +79 -0
  87. package/src/index.ts +28 -0
  88. package/src/jsx-dev-runtime.ts +2 -0
  89. package/src/jsx-runtime.ts +22 -0
  90. package/src/jsx.d.ts +12 -0
  91. package/src/keyed-list.ts +363 -0
  92. package/src/media-query.ts +144 -0
  93. package/src/module.ts +277 -0
  94. package/src/node-selectors.ts +114 -0
  95. package/src/owned-collections.ts +44 -0
  96. package/src/providers.ts +235 -0
  97. package/src/reactive-scope.ts +34 -0
  98. package/src/reactivity.ts +254 -0
  99. package/src/result.ts +58 -0
  100. package/src/runtime.ts +52 -0
  101. package/src/scheduler.ts +185 -0
  102. package/src/signal-kernel.ts +30 -0
  103. package/src/style-classes.ts +51 -0
  104. package/src/style-states.ts +134 -0
  105. package/src/style-variables.ts +53 -0
  106. package/src/text-children.ts +42 -0
  107. package/src/theme.ts +50 -0
  108. package/src/transition.ts +18 -0
  109. package/state/index.ts +3 -0
  110. package/state/package.json +12 -0
  111. package/state/store-bindings.ts +25 -0
  112. package/state/store.ts +82 -0
  113. package/styles/_layers.scss +14 -0
  114. package/templates/addon/README.md +14 -0
  115. package/templates/addon/__ADDON_NAME__.toc +4 -0
  116. package/templates/addon/eslint.config.mjs +12 -0
  117. package/templates/addon/gitignore +8 -0
  118. package/templates/addon/package.json +21 -0
  119. package/templates/addon/scripts/build.mjs +25 -0
  120. package/templates/addon/src/app/main.tsx +13 -0
  121. package/templates/addon/tsconfig.json +24 -0
  122. package/translate/index.ts +14 -0
  123. package/translate/package.json +9 -0
  124. package/utils/colors.ts +76 -0
  125. package/utils/format.ts +37 -0
  126. package/utils/index.ts +4 -0
  127. package/utils/number.ts +17 -0
  128. package/utils/package.json +7 -0
  129. package/utils/text.ts +6 -0
  130. package/validate/index.ts +119 -0
  131. package/validate/package.json +9 -0
  132. package/wow/absolute-position.ts +142 -0
  133. package/wow/animation.ts +428 -0
  134. package/wow/aura-button.ts +76 -0
  135. package/wow/aura-container.ts +591 -0
  136. package/wow/aura-countdown.ts +201 -0
  137. package/wow/aura-slot.ts +153 -0
  138. package/wow/bar-shade.ts +93 -0
  139. package/wow/borrowed-slot.ts +216 -0
  140. package/wow/button-drag.ts +48 -0
  141. package/wow/cast-clock.ts +153 -0
  142. package/wow/cast-text.ts +83 -0
  143. package/wow/class-colors.ts +126 -0
  144. package/wow/clock.ts +7 -0
  145. package/wow/color-picker.ts +128 -0
  146. package/wow/commands.ts +17 -0
  147. package/wow/contained-frame.ts +128 -0
  148. package/wow/contract.ts +42 -0
  149. package/wow/css-box.ts +110 -0
  150. package/wow/css-color.ts +12 -0
  151. package/wow/css-style.ts +109 -0
  152. package/wow/css-surfaces.ts +398 -0
  153. package/wow/css-text.ts +399 -0
  154. package/wow/cvar-schema.ts +32 -0
  155. package/wow/cvars.ts +98 -0
  156. package/wow/dropdown-art.ts +39 -0
  157. package/wow/element-click.ts +20 -0
  158. package/wow/element-event-coordinator.ts +219 -0
  159. package/wow/element-events.ts +317 -0
  160. package/wow/event-dispatcher.ts +151 -0
  161. package/wow/events.ts +50 -0
  162. package/wow/font-cache.ts +92 -0
  163. package/wow/frame-access.ts +31 -0
  164. package/wow/frame-layer.ts +5 -0
  165. package/wow/frames.ts +236 -0
  166. package/wow/heal-prediction.ts +305 -0
  167. package/wow/image-layers.ts +55 -0
  168. package/wow/index.ts +97 -0
  169. package/wow/layout-view.ts +651 -0
  170. package/wow/lua-string.ts +18 -0
  171. package/wow/lua-table.ts +18 -0
  172. package/wow/macro-book.ts +84 -0
  173. package/wow/map-position.ts +27 -0
  174. package/wow/media-query.ts +65 -0
  175. package/wow/module-events.ts +11 -0
  176. package/wow/native-hooks.ts +168 -0
  177. package/wow/native-placement.ts +88 -0
  178. package/wow/native.ts +135 -0
  179. package/wow/number-format.ts +8 -0
  180. package/wow/number-input.ts +10 -0
  181. package/wow/protect.ts +24 -0
  182. package/wow/protected-layout.ts +133 -0
  183. package/wow/range-art.ts +74 -0
  184. package/wow/reparent-frame.ts +99 -0
  185. package/wow/rounded-texture.ts +156 -0
  186. package/wow/saved-variables.ts +60 -0
  187. package/wow/scroll-view.ts +64 -0
  188. package/wow/secret-ref.ts +14 -0
  189. package/wow/secure-bindings.ts +89 -0
  190. package/wow/secure-clicks.ts +432 -0
  191. package/wow/secure-snippet.ts +235 -0
  192. package/wow/secure-state.ts +130 -0
  193. package/wow/secure-target-visibility.ts +89 -0
  194. package/wow/secure-transaction.ts +331 -0
  195. package/wow/special-window.ts +269 -0
  196. package/wow/start-addon.ts +99 -0
  197. package/wow/state-paint.ts +256 -0
  198. package/wow/transition.ts +86 -0
  199. package/wow/unit-button.ts +39 -0
  200. package/wow/unit-cast.ts +92 -0
  201. package/wow/unit-health-text.ts +47 -0
  202. package/wow/view-nodes.ts +304 -0
  203. package/wow/view.ts +1746 -0
  204. package/wow/visible-frame-job.ts +34 -0
  205. package/wow/width-reserve.ts +108 -0
@@ -0,0 +1,34 @@
1
+ import type { RuntimeScope } from "../src/runtime";
2
+ import type { Frame } from "./frames";
3
+ import { reveal } from "./native";
4
+ import { hookScript } from "./native-hooks";
5
+ import { protect } from "./protect";
6
+
7
+ /** Coalesce updates while hidden and resume the latest one when the frame is shown. */
8
+ export function scheduleVisibleFrameUpdate<T>(this: void, scope: RuntimeScope, stage: Frame, label: string,
9
+ apply: (this: void, value: T) => void, report: (this: void, reason: string) => void): (this: void, value: T) => void {
10
+ const key = {};
11
+ let pending: { value: T } | undefined;
12
+ const cancel = () => scope.frameJobs.cancel(key);
13
+ const ready = () => scope.isActive() && reveal(stage.IsVisible()) === true;
14
+ const queue = () => {
15
+ if (pending === undefined || !ready()) return;
16
+ scope.frameJobs.queue(key, () => {
17
+ if (pending === undefined || !ready()) return;
18
+ const { value } = pending;
19
+ pending = undefined;
20
+ const result = protect(() => apply(value));
21
+ if (!result.ok) report(result.reason);
22
+ }, { lane: "normal", label });
23
+ };
24
+ const shown = hookScript(stage, "OnShow", queue, scope);
25
+ if (!shown.ok) report(shown.reason);
26
+ const hidden = hookScript(stage, "OnHide", cancel, scope);
27
+ if (!hidden.ok) report(hidden.reason);
28
+ scope.onDispose(() => { pending = undefined; cancel(); });
29
+ return (value: T) => {
30
+ if (!scope.isActive()) return;
31
+ pending = { value };
32
+ queue();
33
+ };
34
+ }
@@ -0,0 +1,108 @@
1
+ import { ownedArray } from "../src/owned-collections";
2
+ import { fail, ok, type Result } from "../src/result";
3
+ import type { RuntimeScope } from "../src/runtime";
4
+ import { createFrame, type FontString, type Frame, type FrameParent } from "./frames";
5
+ import { hookScript } from "./native-hooks";
6
+ import { readNativeAnchor, type NativeAnchor } from "./native-placement";
7
+ import { isSecret, reveal } from "./native";
8
+ import { protect } from "./protect";
9
+
10
+ type RightAnchor = Pick<FontString, "SetPoint">;
11
+ type HorizontalEdge = "LEFT" | "RIGHT";
12
+
13
+ interface HolderPort {
14
+ current(this: void): Frame | undefined;
15
+ assign(this: void, frame: Frame): void;
16
+ }
17
+
18
+ function anchorRight(region: RightAnchor, target: FrameParent, inset: number, edge: HorizontalEdge) {
19
+ region.SetPoint("RIGHT", target, edge, -inset, 0);
20
+ }
21
+
22
+ /** Replace the native right point without taking over the region's other anchors. */
23
+ export function setNativeRightInset(this: void, region: RightAnchor, target: FrameParent, inset: number,
24
+ edge: HorizontalEdge = "RIGHT"): Result<void> {
25
+ if (isSecret(inset) || !Number.isFinite(inset)) return fail("Native right inset is unreadable");
26
+ return protect(() => anchorRight(region, target, inset, edge));
27
+ }
28
+
29
+ function captureControl(control: Frame) {
30
+ const parent = control.GetParent();
31
+ const count = reveal(control.GetNumPoints());
32
+ if (isSecret(parent) || count === undefined) return fail("The native control placement is unreadable");
33
+ const points = ownedArray<NativeAnchor>();
34
+ for (let index = 1; index <= count; index++) {
35
+ const anchor = readNativeAnchor(control, index);
36
+ if (anchor === undefined) return fail("A native control anchor is unreadable");
37
+ points.push(anchor);
38
+ }
39
+ return ok({ parent: parent as FrameParent | undefined, points });
40
+ }
41
+
42
+ /** Wrap a caller-owned control in a wider holder. Only the width subscription ends with the scope. */
43
+ export function mountNativeWidthReserve(this: void, parent: Frame, control: Frame, inset: number, slot: HolderPort,
44
+ scope: RuntimeScope): Result<void> {
45
+ if (isSecret(inset) || !Number.isFinite(inset) || inset < 0) return fail("Invalid native width reserve");
46
+ if (!scope.isActive()) return fail("The reactive scope has been disposed");
47
+ const captured = scope.protect(() => captureControl(control));
48
+ const original = captured.ok ? captured.value : captured;
49
+ if (!original.ok) return original;
50
+ const { parent: previousParent, points } = original.value;
51
+ let holder: Frame | undefined;
52
+ let published = false;
53
+ const installed = scope.protect(() => {
54
+ if (reveal(slot.current()) !== control) return fail("The slot no longer owns the native control");
55
+ const host = createFrame("Frame", undefined, parent);
56
+ holder = host;
57
+ const width = reveal(control.GetWidth());
58
+ const height = reveal(control.GetHeight());
59
+ if (width !== undefined && height !== undefined) host.SetSize(width + inset, height);
60
+ published = true;
61
+ slot.assign(host);
62
+ // A legacy setter can keep exposing the control while using the holder only for layout.
63
+ const selected = reveal(slot.current());
64
+ if (!scope.isActive() || (selected !== host && selected !== control)) return fail("The slot changed during native control placement");
65
+ const currentParent = control.GetParent();
66
+ if (isSecret(currentParent) || (currentParent !== previousParent && currentParent !== host)) {
67
+ return fail("The native control changed owner during placement");
68
+ }
69
+ control.SetParent(host);
70
+ if (reveal(control.GetParent()) !== host) return fail("The client did not adopt the native control");
71
+ if (reveal(slot.current()) !== selected) return fail("The slot changed during native control placement");
72
+ control.ClearAllPoints();
73
+ anchorRight(control, host, inset, "RIGHT");
74
+ const stillOwned = () => reveal(slot.current()) === selected && reveal(control.GetParent()) === host;
75
+ if (!stillOwned()) return fail("The native control changed owner during placement");
76
+ const resized = hookScript(control, "OnSizeChanged", (_, observedWidth) => {
77
+ if (!stillOwned()) return;
78
+ const measured = reveal(observedWidth);
79
+ if (measured !== undefined) host.SetWidth(measured + inset);
80
+ }, scope);
81
+ return resized.ok ? ok(undefined) : resized;
82
+ });
83
+ const result = installed.ok ? installed.value : installed;
84
+ const host = holder;
85
+ if (result.ok || host === undefined) return result;
86
+
87
+ const cleanup = scope.protect(() => {
88
+ if (!published) { host.Hide(); return; }
89
+ const current = reveal(slot.current());
90
+ if (current !== host && current !== control) return;
91
+ const owner = control.GetParent();
92
+ if (isSecret(owner) || (owner !== host && owner !== previousParent)) return;
93
+ const released = scope.protect(() => slot.assign(control));
94
+ const selected = reveal(slot.current());
95
+ if (selected === host) return released.ok ? fail("The slot retained the failed native control holder") : released;
96
+ if (selected !== control) return;
97
+ const currentParent = control.GetParent();
98
+ if (isSecret(currentParent) || (currentParent !== host && currentParent !== previousParent)) return;
99
+ if (currentParent !== previousParent) control.SetParent(previousParent);
100
+ if (reveal(control.GetParent()) !== previousParent) return fail("The original native control parent was not restored");
101
+ control.ClearAllPoints();
102
+ for (const point of points) control.SetPoint(point.point, point.target, point.relative, point.x, point.y);
103
+ host.Hide();
104
+ return released.ok ? undefined : released;
105
+ });
106
+ const failure = cleanup.ok ? cleanup.value : cleanup;
107
+ return failure === undefined ? result : fail(result.reason + ". Could not restore the native control: " + failure.reason);
108
+ }