@overmvp/kumi 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -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 +387 -0
  13. package/builder/css-v1.test.mjs +361 -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 +127 -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 +435 -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 +2336 -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 +381 -0
  48. package/builder/src/native_ir.rs +65 -0
  49. package/builder/src/native_signal.rs +83 -0
  50. package/builder/src/numbers.lua +76 -0
  51. package/builder/src/project-front.mjs +3682 -0
  52. package/builder/src/records.lua +75 -0
  53. package/builder/src/routes.rs +124 -0
  54. package/builder/src/setup-store.lua +18 -0
  55. package/builder/src/signal-kernel.fingerprint +1 -0
  56. package/builder/src/strings.lua +103 -0
  57. package/builder/src/ts-lower.mjs +68 -0
  58. package/builder/src/wow-reads.lua +22 -0
  59. package/builder/src/wow_client.rs +253 -0
  60. package/builder/src/wow_types.rs +564 -0
  61. package/builder/style-modules.mjs +93 -0
  62. package/builder/style-states.mjs +100 -0
  63. package/builder/style-states.test.mjs +103 -0
  64. package/builder/vite-assets.mjs +53 -0
  65. package/builder/vite-project.mjs +10 -0
  66. package/config.ts +59 -0
  67. package/eslint.mjs +74 -0
  68. package/form/index.ts +526 -0
  69. package/form/package.json +13 -0
  70. package/motion/index.ts +2 -0
  71. package/motion/package.json +10 -0
  72. package/package.json +26 -4
  73. package/router/index.ts +50 -0
  74. package/router/navigation.ts +22 -0
  75. package/router/package.json +12 -0
  76. package/router/router-view.ts +134 -0
  77. package/router/routes.ts +64 -0
  78. package/scripts/addon-build.mjs +364 -0
  79. package/scripts/addon-project.mjs +78 -0
  80. package/scripts/kumi-cli.mjs +105 -0
  81. package/scripts/link-addons.mjs +61 -0
  82. package/src/bindings.ts +35 -0
  83. package/src/context.ts +15 -0
  84. package/src/css-tokens.ts +239 -0
  85. package/src/css-v1.ts +68 -0
  86. package/src/cvars.ts +91 -0
  87. package/src/element-node.ts +32 -0
  88. package/src/elements.ts +505 -0
  89. package/src/feature-scope.ts +82 -0
  90. package/src/flex-layout.ts +807 -0
  91. package/src/frame-scheduler.ts +336 -0
  92. package/src/grid-tracks.ts +165 -0
  93. package/src/image-imports.d.ts +24 -0
  94. package/src/images.ts +79 -0
  95. package/src/index.ts +29 -0
  96. package/src/jsx-dev-runtime.ts +2 -0
  97. package/src/jsx-runtime.ts +29 -0
  98. package/src/jsx.d.ts +12 -0
  99. package/src/keyed-list.ts +366 -0
  100. package/src/media-query.ts +144 -0
  101. package/src/module-ui.ts +147 -0
  102. package/src/module.ts +311 -0
  103. package/src/node-selectors.ts +114 -0
  104. package/src/owned-collections.ts +52 -0
  105. package/src/providers.ts +241 -0
  106. package/src/reactive-scope.ts +34 -0
  107. package/src/reactivity.ts +275 -0
  108. package/src/result.ts +64 -0
  109. package/src/runtime.ts +52 -0
  110. package/src/scheduler.ts +185 -0
  111. package/src/signal-kernel.ts +63 -0
  112. package/src/style-classes.ts +51 -0
  113. package/src/style-states.ts +134 -0
  114. package/src/style-variables.ts +53 -0
  115. package/src/text-children.ts +42 -0
  116. package/src/theme.ts +50 -0
  117. package/src/transition.ts +18 -0
  118. package/state/index.ts +9 -0
  119. package/state/package.json +12 -0
  120. package/state/setup-store-persistence.ts +206 -0
  121. package/state/setup-store-view.ts +10 -0
  122. package/state/setup-store.ts +342 -0
  123. package/state/store-bindings.ts +25 -0
  124. package/state/store.ts +84 -0
  125. package/styles/_layers.scss +14 -0
  126. package/templates/addon/.agents/skills/kumi-build-debug/SKILL.md +36 -0
  127. package/templates/addon/.agents/skills/kumi-feature/SKILL.md +50 -0
  128. package/templates/addon/.agents/skills/kumi-plugin/SKILL.md +36 -0
  129. package/templates/addon/.agents/skills/kumi-store/SKILL.md +47 -0
  130. package/templates/addon/.agents/skills/kumi-ui/SKILL.md +73 -0
  131. package/templates/addon/.agents/skills/kumi-wow-api/SKILL.md +30 -0
  132. package/templates/addon/.claude/skills/kumi-build-debug/SKILL.md +36 -0
  133. package/templates/addon/.claude/skills/kumi-feature/SKILL.md +50 -0
  134. package/templates/addon/.claude/skills/kumi-plugin/SKILL.md +36 -0
  135. package/templates/addon/.claude/skills/kumi-store/SKILL.md +47 -0
  136. package/templates/addon/.claude/skills/kumi-ui/SKILL.md +73 -0
  137. package/templates/addon/.claude/skills/kumi-wow-api/SKILL.md +30 -0
  138. package/templates/addon/AGENTS.md +34 -0
  139. package/templates/addon/Assets/Art/Corner10.tga +0 -0
  140. package/templates/addon/Assets/Art/Corner11.tga +0 -0
  141. package/templates/addon/Assets/Art/Corner12.tga +0 -0
  142. package/templates/addon/Assets/Art/Corner13.tga +0 -0
  143. package/templates/addon/Assets/Art/Corner14.tga +0 -0
  144. package/templates/addon/Assets/Art/Corner15.tga +0 -0
  145. package/templates/addon/Assets/Art/Corner16.tga +0 -0
  146. package/templates/addon/Assets/Art/Corner2.tga +0 -0
  147. package/templates/addon/Assets/Art/Corner3.tga +0 -0
  148. package/templates/addon/Assets/Art/Corner4.tga +0 -0
  149. package/templates/addon/Assets/Art/Corner5.tga +0 -0
  150. package/templates/addon/Assets/Art/Corner6.tga +0 -0
  151. package/templates/addon/Assets/Art/Corner7.tga +0 -0
  152. package/templates/addon/Assets/Art/Corner8.tga +0 -0
  153. package/templates/addon/Assets/Art/Corner9.tga +0 -0
  154. package/templates/addon/Assets/Art/Dot.tga +0 -0
  155. package/templates/addon/Assets/Art/Gear.tga +0 -0
  156. package/templates/addon/Assets/Art/Grip.tga +0 -0
  157. package/templates/addon/Assets/Art/Outline10.tga +0 -0
  158. package/templates/addon/Assets/Art/Outline12.tga +0 -0
  159. package/templates/addon/Assets/Art/Outline13.tga +0 -0
  160. package/templates/addon/Assets/Art/Outline14.tga +0 -0
  161. package/templates/addon/Assets/Art/Outline15.tga +0 -0
  162. package/templates/addon/Assets/Art/Outline2.tga +0 -0
  163. package/templates/addon/Assets/Art/Outline3.tga +0 -0
  164. package/templates/addon/Assets/Art/Outline5.tga +0 -0
  165. package/templates/addon/Assets/Art/Outline7.tga +0 -0
  166. package/templates/addon/Assets/Art/Outline9.tga +0 -0
  167. package/templates/addon/Assets/Art/Round11.tga +0 -0
  168. package/templates/addon/Assets/Art/Round11Border.tga +0 -0
  169. package/templates/addon/Assets/Art/Round4.tga +0 -0
  170. package/templates/addon/Assets/Art/Round4Border.tga +0 -0
  171. package/templates/addon/Assets/Art/Round6.tga +0 -0
  172. package/templates/addon/Assets/Art/Round6Border.tga +0 -0
  173. package/templates/addon/Assets/Art/Round8.tga +0 -0
  174. package/templates/addon/Assets/Art/Round8Border.tga +0 -0
  175. package/templates/addon/Assets/Art/Search.tga +0 -0
  176. package/templates/addon/CLAUDE.md +1 -0
  177. package/templates/addon/README.md +49 -0
  178. package/templates/addon/eslint.config.mjs +6 -0
  179. package/templates/addon/gitignore +9 -0
  180. package/templates/addon/kumi.config.ts +17 -0
  181. package/templates/addon/package.json +20 -0
  182. package/templates/addon/src/app/app.module.ts +18 -0
  183. package/templates/addon/src/app/commands.store.ts +11 -0
  184. package/templates/addon/src/app/layout/AppWindow.module.scss +92 -0
  185. package/templates/addon/src/app/layout/AppWindow.tsx +32 -0
  186. package/templates/addon/src/app/main.ts +5 -0
  187. package/templates/addon/src/app/routes/(window)/home/page.tsx +8 -0
  188. package/templates/addon/src/app/routes/(window)/plugins/page.tsx +38 -0
  189. package/templates/addon/src/app/routes/(window)/settings/page.tsx +8 -0
  190. package/templates/addon/src/app/theme.ts +6 -0
  191. package/templates/addon/src/modules/greeting/api/player.api.ts +29 -0
  192. package/templates/addon/src/modules/greeting/greeting.module.ts +18 -0
  193. package/templates/addon/src/modules/greeting/model/greeting.store.ts +81 -0
  194. package/templates/addon/src/modules/greeting/services/greeting.service.ts +38 -0
  195. package/templates/addon/src/modules/greeting/ui/Greeting.module.scss +105 -0
  196. package/templates/addon/src/modules/greeting/ui/GreetingCard.tsx +29 -0
  197. package/templates/addon/src/modules/greeting/widgets/GreetingHud.tsx +54 -0
  198. package/templates/addon/src/modules/greeting/widgets/GreetingOverview.tsx +18 -0
  199. package/templates/addon/src/modules/greeting/widgets/GreetingSettings.tsx +56 -0
  200. package/templates/addon/src/modules/playtime/api/clock.api.ts +6 -0
  201. package/templates/addon/src/modules/playtime/model/playtime.store.ts +19 -0
  202. package/templates/addon/src/modules/playtime/playtime.module.ts +18 -0
  203. package/templates/addon/src/modules/playtime/services/playtime.service.ts +18 -0
  204. package/templates/addon/src/modules/playtime/ui/Playtime.module.scss +25 -0
  205. package/templates/addon/src/modules/playtime/ui/PlaytimeBadge.tsx +10 -0
  206. package/templates/addon/src/modules/playtime/widgets/PlaytimePage.tsx +16 -0
  207. package/templates/addon/src/shared/api/native-art.ts +28 -0
  208. package/templates/addon/src/shared/assets/close.png +0 -0
  209. package/templates/addon/src/shared/lib/format.ts +20 -0
  210. package/templates/addon/src/shared/styles/_tokens.scss +12 -0
  211. package/templates/addon/src/shared/ui/Button.tsx +29 -0
  212. package/templates/addon/src/shared/ui/Choice.tsx +34 -0
  213. package/templates/addon/src/shared/ui/Controls.module.scss +93 -0
  214. package/templates/addon/src/shared/ui/Glyph.tsx +18 -0
  215. package/templates/addon/src/shared/ui/Slider.tsx +25 -0
  216. package/templates/addon/src/shared/ui/Toggle.tsx +29 -0
  217. package/templates/addon/src/shared/ui/focus-ref.ts +7 -0
  218. package/templates/addon/src/shared/ui/range-skin.tsx +15 -0
  219. package/templates/addon/tsconfig.json +63 -0
  220. package/translate/index.ts +14 -0
  221. package/translate/package.json +9 -0
  222. package/utils/colors.ts +76 -0
  223. package/utils/format.ts +37 -0
  224. package/utils/index.ts +4 -0
  225. package/utils/number.ts +17 -0
  226. package/utils/package.json +7 -0
  227. package/utils/text.ts +6 -0
  228. package/validate/index.ts +119 -0
  229. package/validate/package.json +9 -0
  230. package/wow/absolute-position.ts +142 -0
  231. package/wow/action-bar-layout.ts +108 -0
  232. package/wow/action-button.ts +219 -0
  233. package/wow/action-catalog.ts +98 -0
  234. package/wow/addon-manifest.ts +36 -0
  235. package/wow/animation.ts +428 -0
  236. package/wow/app-ui.ts +221 -0
  237. package/wow/aura-button.ts +76 -0
  238. package/wow/aura-container.ts +591 -0
  239. package/wow/aura-countdown.ts +201 -0
  240. package/wow/aura-slot.ts +153 -0
  241. package/wow/bar-shade.ts +93 -0
  242. package/wow/borrowed-slot.ts +216 -0
  243. package/wow/button-drag.ts +48 -0
  244. package/wow/cast-clock.ts +153 -0
  245. package/wow/cast-text.ts +83 -0
  246. package/wow/class-colors.ts +126 -0
  247. package/wow/clock.ts +7 -0
  248. package/wow/color-picker.ts +128 -0
  249. package/wow/commands.ts +17 -0
  250. package/wow/contained-frame.ts +128 -0
  251. package/wow/contract.ts +42 -0
  252. package/wow/cooldown-timing.ts +24 -0
  253. package/wow/css-box.ts +144 -0
  254. package/wow/css-color.ts +12 -0
  255. package/wow/css-style.ts +109 -0
  256. package/wow/css-surfaces.ts +603 -0
  257. package/wow/css-text.ts +399 -0
  258. package/wow/cursor.ts +45 -0
  259. package/wow/cvar-schema.ts +32 -0
  260. package/wow/cvars.ts +98 -0
  261. package/wow/dropdown-art.ts +39 -0
  262. package/wow/element-click.ts +20 -0
  263. package/wow/element-event-coordinator.ts +219 -0
  264. package/wow/element-events.ts +317 -0
  265. package/wow/event-dispatcher.ts +151 -0
  266. package/wow/events.ts +50 -0
  267. package/wow/font-cache.ts +92 -0
  268. package/wow/frame-access.ts +53 -0
  269. package/wow/frame-layer.ts +5 -0
  270. package/wow/frame-timing.ts +13 -0
  271. package/wow/frames.ts +236 -0
  272. package/wow/heal-prediction.ts +305 -0
  273. package/wow/hooks.ts +133 -0
  274. package/wow/image-layers.ts +55 -0
  275. package/wow/index.ts +111 -0
  276. package/wow/layout-view.ts +663 -0
  277. package/wow/locale-font.ts +15 -0
  278. package/wow/lua-string.ts +18 -0
  279. package/wow/lua-table.ts +18 -0
  280. package/wow/macro-book.ts +84 -0
  281. package/wow/map-position.ts +27 -0
  282. package/wow/media-query.ts +65 -0
  283. package/wow/module-events.ts +11 -0
  284. package/wow/native-hooks.ts +168 -0
  285. package/wow/native-placement.ts +88 -0
  286. package/wow/native.ts +153 -0
  287. package/wow/number-format.ts +8 -0
  288. package/wow/number-input.ts +10 -0
  289. package/wow/panel-host.ts +97 -0
  290. package/wow/pixel.ts +35 -0
  291. package/wow/plugins.ts +246 -0
  292. package/wow/protect.ts +48 -0
  293. package/wow/protected-layout.ts +133 -0
  294. package/wow/protected-view.ts +103 -0
  295. package/wow/range-art.ts +81 -0
  296. package/wow/readable-api.ts +120 -0
  297. package/wow/reparent-frame.ts +99 -0
  298. package/wow/rounded-texture.ts +183 -0
  299. package/wow/saved-variables.ts +109 -0
  300. package/wow/scroll-view.ts +64 -0
  301. package/wow/secret-ref.ts +14 -0
  302. package/wow/secure-bindings.ts +89 -0
  303. package/wow/secure-clicks.ts +432 -0
  304. package/wow/secure-snippet.ts +235 -0
  305. package/wow/secure-state.ts +130 -0
  306. package/wow/secure-target-visibility.ts +89 -0
  307. package/wow/secure-transaction.ts +331 -0
  308. package/wow/special-window.ts +269 -0
  309. package/wow/spell-cooldown.ts +36 -0
  310. package/wow/start-addon.ts +122 -0
  311. package/wow/state-paint.ts +256 -0
  312. package/wow/transition.ts +86 -0
  313. package/wow/unit-button.ts +39 -0
  314. package/wow/unit-cast.ts +92 -0
  315. package/wow/unit-health-text.ts +47 -0
  316. package/wow/view-nodes.ts +304 -0
  317. package/wow/view.ts +1864 -0
  318. package/wow/visible-frame-job.ts +34 -0
  319. package/wow/width-reserve.ts +108 -0
@@ -0,0 +1,428 @@
1
+ import { ownedArray, type OwnedArray, type OwnedReadonlyArray, type OwnedRecord } from "../src/owned-collections";
2
+ import type { RuntimeScope } from "../src/runtime";
3
+ import { fail, ok, type Result } from "../src/result";
4
+ import { currentScope } from "../src/reactive-scope";
5
+ import { nativeSmoothing } from "../animation/ease";
6
+ import { finalAlpha, planAnimation, type AlphaStep, type AnimationPlan, type AnimationSpec, type AnimationStep, type FlipBookStep,
7
+ type MoveStep, type PlannedStep, type RegionAnimation, type RegionStep, type RotateStep, type ScaleStep } from "../animation/spec";
8
+ import { scaleFactors } from "../animation/cycle";
9
+ import type { AnimationGroup, Frame, NativeAnimationOf, Texture } from "./frames";
10
+ import { reveal } from "./native";
11
+ import { protect } from "./protect";
12
+
13
+ type NativeAnimation = ReturnType<AnimationGroup["CreateAnimation"]>;
14
+
15
+ /**
16
+ * A region that owns native animation groups: a frame, a texture or a font string.
17
+ * Animating a frame moves, scales and fades everything inside it.
18
+ */
19
+ export interface AnimationTarget {
20
+ CreateAnimationGroup(this: object, name?: string, template?: string): AnimationGroup;
21
+ SetAlpha(this: object, alpha: number): void;
22
+ }
23
+
24
+ /** The region type a spec needs: rotation and flipbooks work on textures only. */
25
+ export type TargetOf<Step extends AnimationStep> = [Exclude<Step, RegionStep>] extends [never] ? AnimationTarget : Texture;
26
+
27
+ /** "reduced" freezes loops on their first pose and finishes one-shots at once. */
28
+ export type MotionMode = "full" | "reduced";
29
+
30
+ export interface AnimationDefaults {
31
+ /** Read on every play of an animation that has no `motion` option of its own. */
32
+ motion?: (this: void) => MotionMode;
33
+ }
34
+
35
+ export interface NativeAnimationOptions {
36
+ /**
37
+ * Stops the group and clears its script when the scope is disposed. Inside a component's setup the
38
+ * component's scope is used when this is left out.
39
+ */
40
+ scope?: RuntimeScope;
41
+ /** Multiplies every move offset, for views that scale their art. */
42
+ distance?: number;
43
+ /** Native speed multiplier. */
44
+ speed?: number;
45
+ /** Overrides the default motion policy for this animation. Read on every play. */
46
+ motion?: (this: void) => MotionMode;
47
+ /**
48
+ * Called once a one-shot animation ends, and at once when reduced motion skips it.
49
+ * Leave it out for regions whose visibility the client controls with restricted values, such as aura buttons.
50
+ */
51
+ onFinish?: (this: void) => void;
52
+ }
53
+
54
+ export interface PlayOptions {
55
+ reverse?: boolean;
56
+ /** Seconds into the animation. */
57
+ offset?: number;
58
+ }
59
+
60
+ /** Fields a named step can change between plays. */
61
+ export type StepPatch = Partial<Pick<AnimationStep, "duration" | "delay" | "endDelay" | "ease">> & {
62
+ alpha?: AlphaStep["alpha"];
63
+ scale?: ScaleStep["scale"];
64
+ rotate?: number;
65
+ move?: MoveStep["move"];
66
+ };
67
+
68
+ /** Playback of one native animation group. */
69
+ export interface AnimationPlayback {
70
+ /** Start from the beginning, restarting a running animation. */
71
+ play(this: void, options?: PlayOptions): void;
72
+ /** Play a stopped or paused animation without restarting a running one. Use it to keep loops alive. */
73
+ resume(this: void): void;
74
+ pause(this: void): void;
75
+ stop(this: void): void;
76
+ isPlaying(this: void): boolean;
77
+ /** Change a named step. The timeline is planned again, so later steps follow a changed delay or duration. */
78
+ set(this: void, id: string, patch: StepPatch): Result<void>;
79
+ setSpeed(this: void, multiplier: number): void;
80
+ /** Seconds of one pass, after the latest `set`. */
81
+ length(this: void): number;
82
+ }
83
+
84
+ export interface AnimationControl extends AnimationPlayback {
85
+ /** Stop for good and clear the group's script. The native group itself cannot be destroyed. */
86
+ dispose(this: void): void;
87
+ /** The native group, for integrations the controller does not cover. */
88
+ readonly group: AnimationGroup;
89
+ }
90
+
91
+ const looping = { repeat: "REPEAT", bounce: "BOUNCE" } as const;
92
+ let defaults: AnimationDefaults = {};
93
+
94
+ /** Set application-wide defaults, such as the reduced motion setting of the player's profile. */
95
+ export function configureAnimations(this: void, options: AnimationDefaults): void {
96
+ defaults = { ...options as OwnedRecord<AnimationDefaults> };
97
+ }
98
+
99
+ function applyTiming(animation: NativeAnimation, step: PlannedStep) {
100
+ animation.SetOrder(1);
101
+ animation.SetDuration(step.duration);
102
+ animation.SetStartDelay(step.start);
103
+ animation.SetEndDelay(step.endDelay);
104
+ animation.SetSmoothing(nativeSmoothing(step.ease));
105
+ }
106
+
107
+ function applyValues(animation: NativeAnimation, step: AnimationStep, distance: number) {
108
+ if (step.alpha !== undefined) {
109
+ const alpha = animation as NativeAnimationOf<"Alpha">;
110
+ alpha.SetFromAlpha(step.alpha[0]);
111
+ alpha.SetToAlpha(step.alpha[1]);
112
+ } else if (step.scale !== undefined) {
113
+ const scale = animation as NativeAnimationOf<"Scale">;
114
+ const [fromX, fromY] = scaleFactors(step.scale[0]);
115
+ const [toX, toY] = scaleFactors(step.scale[1]);
116
+ scale.SetScaleFrom(fromX, fromY);
117
+ scale.SetScaleTo(toX, toY);
118
+ if (step.origin) scale.SetOrigin(step.origin.point, step.origin.x ?? 0, step.origin.y ?? 0);
119
+ } else if (step.rotate !== undefined) {
120
+ const rotation = animation as NativeAnimationOf<"Rotation">;
121
+ rotation.SetDegrees(step.rotate);
122
+ const origin = (step as RotateStep).origin;
123
+ if (origin) rotation.SetOrigin(origin.point, origin.x ?? 0, origin.y ?? 0);
124
+ } else if (step.move !== undefined) {
125
+ const move = animation as NativeAnimationOf<"Translation">;
126
+ move.SetOffset(step.move[0] * distance, step.move[1] * distance);
127
+ } else {
128
+ const book = animation as NativeAnimationOf<"FlipBook">;
129
+ const { rows, columns, frames, frameWidth, frameHeight } = (step as FlipBookStep).flipbook;
130
+ book.SetFlipBookRows(rows);
131
+ book.SetFlipBookColumns(columns);
132
+ book.SetFlipBookFrames(frames);
133
+ if (frameWidth !== undefined) book.SetFlipBookFrameWidth(frameWidth);
134
+ if (frameHeight !== undefined) book.SetFlipBookFrameHeight(frameHeight);
135
+ }
136
+ }
137
+
138
+ function createStep(group: AnimationGroup, step: PlannedStep): NativeAnimation {
139
+ switch (step.kind) {
140
+ case "alpha": return group.CreateAnimation("Alpha");
141
+ case "scale": return group.CreateAnimation("Scale");
142
+ case "rotate": return group.CreateAnimation("Rotation");
143
+ case "move": return group.CreateAnimation("Translation");
144
+ case "flipbook": return group.CreateAnimation("FlipBook");
145
+ }
146
+ }
147
+
148
+ function patchSteps(supplied: readonly AnimationStep[], id: string, patch: StepPatch): Result<{ steps: OwnedArray<AnimationStep>; index: number }> {
149
+ const steps = supplied as OwnedReadonlyArray<AnimationStep>;
150
+ const index = steps.findIndex(step => step.id === id);
151
+ if (index < 0) return fail("Unknown animation step " + id);
152
+ const step = steps[index];
153
+ // A patch keeps the step's kind. Changing it would need a new native animation.
154
+ if ((patch.alpha !== undefined && step.alpha === undefined) || (patch.scale !== undefined && step.scale === undefined)
155
+ || (patch.rotate !== undefined && step.rotate === undefined) || (patch.move !== undefined && step.move === undefined)) {
156
+ return fail("A step patch cannot change the kind of step");
157
+ }
158
+ const next = steps.slice() as OwnedArray<AnimationStep>;
159
+ next[index] = { ...step as OwnedRecord<AnimationStep>, ...patch as OwnedRecord<StepPatch> } as AnimationStep;
160
+ return ok({ steps: next, index });
161
+ }
162
+
163
+ /**
164
+ * Build one native animation group from a spec. The group is created once; play it as often as needed.
165
+ * Steps share order 1 and start through their delays, the layout of Blizzard's alert animations.
166
+ * Rotation and flipbook steps need a texture; the overloads check that at compile time.
167
+ */
168
+ export function createAnimation(this: void, target: AnimationTarget, spec: RegionAnimation, options?: NativeAnimationOptions): Result<AnimationControl>;
169
+ export function createAnimation(this: void, target: Texture, spec: AnimationSpec, options?: NativeAnimationOptions): Result<AnimationControl>;
170
+ export function createAnimation(this: void, target: AnimationTarget, spec: AnimationSpec,
171
+ options: NativeAnimationOptions = {}): Result<AnimationControl> {
172
+ return build(target, spec, options, options.scope ?? currentScope());
173
+ }
174
+
175
+ function build(target: AnimationTarget, spec: AnimationSpec, options: Omit<NativeAnimationOptions, "scope">,
176
+ scope: RuntimeScope | undefined): Result<AnimationControl> {
177
+ const planned = planAnimation(spec);
178
+ if (!planned.ok) return planned;
179
+ if (scope && !scope.isActive()) return fail("Cannot animate after the scope has been disposed");
180
+ const distance = options.distance ?? 1;
181
+ if (!Number.isFinite(distance)) return fail("Animation distance must be a number");
182
+
183
+ const created = protect(() => {
184
+ const group = target.CreateAnimationGroup();
185
+ if (planned.value.loop) group.SetLooping(looping[planned.value.loop]);
186
+ if (planned.value.keepFinalAlpha) group.SetToFinalAlpha(true);
187
+ const animations = ownedArray<NativeAnimation>();
188
+ for (const step of planned.value.steps as OwnedReadonlyArray<PlannedStep>) {
189
+ const animation = createStep(group, step);
190
+ applyTiming(animation, step);
191
+ applyValues(animation, step.step, distance);
192
+ animations.push(animation);
193
+ }
194
+ return { group, animations };
195
+ });
196
+ if (!created.ok) return created;
197
+ const { group, animations } = created.value;
198
+ let plan: AnimationPlan = planned.value;
199
+ let steps: readonly AnimationStep[] = spec.steps;
200
+ let released = false;
201
+ const onFinish = options.onFinish;
202
+ const scripted = onFinish !== undefined && !plan.loop;
203
+
204
+ if (scripted) group.SetScript("OnFinished", () => { if (!released) onFinish(); });
205
+ if (options.speed !== undefined) group.SetAnimationSpeedMultiplier(options.speed);
206
+
207
+ function reduced() {
208
+ return (options.motion ?? defaults.motion)?.() === "reduced";
209
+ }
210
+
211
+ function skipToEnd() {
212
+ group.Stop();
213
+ const alpha = plan.keepFinalAlpha ? finalAlpha(plan) : undefined;
214
+ if (alpha !== undefined) target.SetAlpha(alpha);
215
+ onFinish?.();
216
+ }
217
+
218
+ function freeze() {
219
+ // Pause on the first pose. The group's transforms stay applied while it is paused.
220
+ group.Stop();
221
+ group.Play();
222
+ group.Pause();
223
+ }
224
+
225
+ function dispose() {
226
+ if (released) return;
227
+ released = true;
228
+ group.Stop();
229
+ if (scripted) group.SetScript("OnFinished", undefined);
230
+ }
231
+
232
+ const control: AnimationControl = {
233
+ group,
234
+ play: playOptions => {
235
+ if (released) return;
236
+ if (reduced()) {
237
+ if (plan.loop) freeze();
238
+ else skipToEnd();
239
+ return;
240
+ }
241
+ group.Stop();
242
+ // Without options this is the plain Play() the addon already uses.
243
+ if (playOptions) group.Play(playOptions.reverse === true, playOptions.offset ?? 0);
244
+ else group.Play();
245
+ },
246
+ resume: () => {
247
+ if (released) return;
248
+ if (reduced()) {
249
+ if (plan.loop) freeze();
250
+ return;
251
+ }
252
+ if (reveal(group.IsPlaying()) !== true || reveal(group.IsPaused()) === true) group.Play();
253
+ },
254
+ pause: () => { group.Pause(); },
255
+ stop: () => { group.Stop(); },
256
+ isPlaying: () => reveal(group.IsPlaying()) === true && reveal(group.IsPaused()) !== true,
257
+ set: (id, patch) => {
258
+ const patched = patchSteps(steps, id, patch);
259
+ if (!patched.ok) return patched;
260
+ const replanned = planAnimation({ ...spec as OwnedRecord<AnimationSpec>, steps: patched.value.steps });
261
+ if (!replanned.ok) return replanned;
262
+ const applied = protect(() => {
263
+ for (const step of replanned.value.steps as OwnedReadonlyArray<PlannedStep>) applyTiming(animations[step.index], step);
264
+ applyValues(animations[patched.value.index], patched.value.steps[patched.value.index], distance);
265
+ });
266
+ if (!applied.ok) return applied;
267
+ plan = replanned.value;
268
+ steps = patched.value.steps;
269
+ return ok(undefined);
270
+ },
271
+ setSpeed: multiplier => {
272
+ if (Number.isFinite(multiplier) && multiplier > 0) group.SetAnimationSpeedMultiplier(multiplier);
273
+ },
274
+ length: () => plan.length,
275
+ dispose,
276
+ };
277
+
278
+ scope?.onDispose(dispose);
279
+ return ok(control);
280
+ }
281
+
282
+ export interface AnimationRefOptions extends Omit<NativeAnimationOptions, "scope"> {
283
+ /** Play when the element mounts. */
284
+ autoplay?: boolean;
285
+ }
286
+
287
+ /**
288
+ * An animation attached through a JSX `ref`. It is built when the element mounts and disposed with it, so it
289
+ * needs no scope. Playback calls before the mount are kept: `play` plays on mount and `set` changes the spec.
290
+ */
291
+ export interface AnimationRef<Target> extends AnimationPlayback {
292
+ readonly ref: (this: void, target?: Target) => void;
293
+ /** The mounted animation, or a failure explaining why there is none. */
294
+ control(this: void): Result<AnimationControl>;
295
+ }
296
+
297
+ const notMounted = fail("The animated element is not mounted");
298
+
299
+ /**
300
+ * Animate a JSX element through its `ref`. On a frame the animation moves, scales and fades everything inside it.
301
+ *
302
+ * ```tsx
303
+ * const pop = useAnimation(presets.popIn(), { autoplay: true });
304
+ * return <div ref={pop.ref} width={120} height={40}><span>Ready</span></div>;
305
+ * ```
306
+ */
307
+ export function useAnimation<const Step extends AnimationStep>(this: void, spec: AnimationSpec<Step>,
308
+ options: AnimationRefOptions = {}): AnimationRef<TargetOf<Step>> {
309
+ let current: AnimationSpec = spec;
310
+ let control: Result<AnimationControl> = notMounted;
311
+ let pending: PlayOptions | true | undefined = options.autoplay ? true : undefined;
312
+ let speed = options.speed;
313
+
314
+ function attach(target: AnimationTarget) {
315
+ if (control.ok) control.value.dispose();
316
+ // The element's mount owns the animation: the renderer calls the ref again with nothing on release.
317
+ control = build(target, current, { ...options as OwnedRecord<NativeAnimationOptions>, speed }, undefined);
318
+ if (!control.ok) return;
319
+ if (pending !== undefined) control.value.play(pending === true ? undefined : pending);
320
+ pending = options.autoplay ? true : undefined;
321
+ }
322
+
323
+ return {
324
+ ref: target => {
325
+ if (target === undefined) {
326
+ if (control.ok) control.value.dispose();
327
+ control = notMounted;
328
+ pending = options.autoplay ? true : undefined;
329
+ } else {
330
+ attach(target as AnimationTarget);
331
+ }
332
+ },
333
+ control: () => control,
334
+ play: playOptions => {
335
+ if (control.ok) control.value.play(playOptions);
336
+ else pending = playOptions ?? true;
337
+ },
338
+ resume: () => {
339
+ if (control.ok) control.value.resume();
340
+ else pending ??= true;
341
+ },
342
+ pause: () => { if (control.ok) control.value.pause(); },
343
+ stop: () => {
344
+ if (control.ok) control.value.stop();
345
+ else pending = undefined;
346
+ },
347
+ isPlaying: () => control.ok && control.value.isPlaying(),
348
+ set: (id, patch) => {
349
+ if (control.ok) {
350
+ const changed = control.value.set(id, patch);
351
+ if (!changed.ok) return changed;
352
+ }
353
+ const patched = patchSteps(current.steps, id, patch);
354
+ if (!patched.ok) return patched;
355
+ const next = { ...current as OwnedRecord<AnimationSpec>, steps: patched.value.steps };
356
+ const valid = planAnimation(next);
357
+ if (!valid.ok) return valid;
358
+ current = next;
359
+ return ok(undefined);
360
+ },
361
+ setSpeed: multiplier => {
362
+ if (!Number.isFinite(multiplier) || multiplier <= 0) return;
363
+ speed = multiplier;
364
+ if (control.ok) control.value.setSpeed(multiplier);
365
+ },
366
+ length: () => control.ok ? control.value.length() : lengthOf(current),
367
+ };
368
+ }
369
+
370
+ function lengthOf(spec: AnimationSpec) {
371
+ const plan = planAnimation(spec);
372
+ return plan.ok ? plan.value.length : 0;
373
+ }
374
+
375
+ /**
376
+ * Keep animations running only while a frame is visible. Hooks cannot be removed, so the scope only disables them.
377
+ * Do not use it on aura buttons or other frames the client shows and hides with restricted values.
378
+ */
379
+ export function playWhileVisible(this: void, frame: Frame, scope: RuntimeScope, ...controls: AnimationPlayback[]): void {
380
+ let active = scope.isActive();
381
+ scope.onDispose(() => { active = false; });
382
+ frame.HookScript("OnShow", () => {
383
+ if (active) for (const control of controls) control.resume();
384
+ });
385
+ frame.HookScript("OnHide", () => {
386
+ if (active) for (const control of controls) control.stop();
387
+ });
388
+ if (active && reveal(frame.IsVisible()) === true) for (const control of controls) control.resume();
389
+ }
390
+
391
+ export interface Ticker {
392
+ start(this: void): void;
393
+ stop(this: void): void;
394
+ isRunning(this: void): boolean;
395
+ }
396
+
397
+ /**
398
+ * Call `tick` every `interval` seconds from a looping native animation. The client keeps the time, so no
399
+ * Lua runs between ticks, unlike an OnUpdate counter. Return false from `tick` to stop.
400
+ * Inside a component's setup the ticker stops with the component when `scope` is left out.
401
+ */
402
+ export function createTicker(this: void, target: Pick<AnimationTarget, "CreateAnimationGroup">, interval: number,
403
+ tick: (this: void) => boolean | void, scope: RuntimeScope | undefined = currentScope()): Result<Ticker> {
404
+ if (!Number.isFinite(interval) || interval <= 0) return fail("A ticker needs a positive interval");
405
+ const created = protect(() => {
406
+ const group = target.CreateAnimationGroup();
407
+ group.SetLooping("REPEAT");
408
+ group.CreateAnimation("Animation").SetDuration(interval);
409
+ return group;
410
+ });
411
+ if (!created.ok) return created;
412
+ const group = created.value;
413
+ let released = false;
414
+ group.SetScript("OnLoop", () => {
415
+ if (released) return;
416
+ if (tick() === false) group.Stop();
417
+ });
418
+ scope?.onDispose(() => {
419
+ released = true;
420
+ group.Stop();
421
+ group.SetScript("OnLoop", undefined);
422
+ });
423
+ return ok({
424
+ start: () => { if (!released && reveal(group.IsPlaying()) !== true) group.Play(); },
425
+ stop: () => { group.Stop(); },
426
+ isRunning: () => reveal(group.IsPlaying()) === true,
427
+ });
428
+ }
package/wow/app-ui.ts ADDED
@@ -0,0 +1,221 @@
1
+ import { createContext } from "../src/context";
2
+ import { createElement } from "../src/elements";
3
+ import { installModuleUi, modulePages, type ModulePage, type ModuleUi, type ModuleView, type ModuleWindow, type ViewComponent } from "../src/module-ui";
4
+ import type { OwnedReadonlyArray, OwnedRecord } from "../src/owned-collections";
5
+ import { computed } from "../src/reactive-scope";
6
+ import { ref, type ReadonlyRef } from "../src/reactivity";
7
+ import { fail, formatFailure, ok, type Result } from "../src/result";
8
+ import type { Runtime, RuntimeScope } from "../src/runtime";
9
+ import { withRouterHost, type RoutePage, type RouterHost } from "../router/router-view";
10
+ import { defineStore, readonly } from "../state/setup-store";
11
+ import type { EventApi } from "./contract";
12
+ import type { FrameStrata } from "./frame-layer";
13
+ import { createNativePanel } from "./panel-host";
14
+ import { mountProtectedView } from "./protected-view";
15
+ import type { NativeViewOptions } from "./view";
16
+
17
+ /** App-wide options for every view Kumi mounts: textures, fonts, control skins and media queries. */
18
+ export type AppTheme = Omit<NativeViewOptions, "rootLayer" | "bindings" | "manualTextBindings" | "layoutDiagnostics" | "regionsOnly"
19
+ | "rootBackdrop" | "rootScale" | "unanchoredRoot" | "portalRoot">;
20
+
21
+ interface FileRouter {
22
+ readonly pages: OwnedReadonlyArray<{ readonly path: string; readonly title?: string; readonly order?: number }>;
23
+ has(this: void, path: string): boolean;
24
+ render(this: void, path: string, context: object): ReturnType<ViewComponent> | undefined;
25
+ }
26
+
27
+ interface AppContext {
28
+ readonly runtime: Runtime;
29
+ readonly scope: RuntimeScope;
30
+ readonly events: EventApi;
31
+ readonly theme: AppTheme;
32
+ }
33
+
34
+ interface ViewHost {
35
+ /** Apply pending changes to the view now instead of on the next frame. */
36
+ refresh(this: void): Result<void>;
37
+ /** The size of one physical pixel in the view's units. */
38
+ readonly pixel: ReadonlyRef<number>;
39
+ }
40
+
41
+ interface WindowState {
42
+ readonly config: ModuleWindow;
43
+ readonly router: FileRouter;
44
+ readonly owner: RuntimeScope;
45
+ show?: (this: void) => void;
46
+ hide?: (this: void) => void;
47
+ }
48
+
49
+ let app: AppContext | undefined;
50
+ const windowState = ref<WindowState | undefined>(undefined);
51
+ const windowOpen = ref(false);
52
+ const windowPath = ref<string | undefined>(undefined);
53
+ const viewContext = createContext<ViewHost>();
54
+
55
+ /** @internal The running addon, for hooks such as useEvent. */
56
+ export function appContext(this: void): AppContext | undefined {
57
+ return app;
58
+ }
59
+
60
+ function routeExists(path: string) {
61
+ const state = windowState.value;
62
+ if (state === undefined) return false;
63
+ if (state.router.has(path)) return true;
64
+ for (const page of modulePages().value as OwnedReadonlyArray<ModulePage>) if (page.path === path) return true;
65
+ return false;
66
+ }
67
+
68
+ function firstPath(state: WindowState) {
69
+ if (state.config.start !== undefined) return state.config.start;
70
+ for (const page of state.router.pages) return page.path;
71
+ for (const page of modulePages().value as OwnedReadonlyArray<ModulePage>) return page.path;
72
+ return undefined;
73
+ }
74
+
75
+ function mountWindow(state: WindowState): Result<void> {
76
+ const context = app;
77
+ if (context === undefined) return fail("The addon window needs a running addon");
78
+ const { config } = state;
79
+ const panel = createNativePanel(state.owner, context.events, config.width, config.height,
80
+ (config.strata ?? "DIALOG") as FrameStrata, 0);
81
+ if (!panel.ok) return panel;
82
+ const host: RouterHost = {
83
+ navigation: { path: windowPath as ReadonlyRef<string | undefined>, navigate: path => { navigateWindow(path); } },
84
+ render: path => state.router.has(path) ? state.router.render(path, {}) : undefined,
85
+ modulePages: modulePages(),
86
+ };
87
+ const mounted = panel.value.mount(context.runtime, owner => {
88
+ const layout = withRouterHost(host, () => createElement(config.layout, {}), owner.protect);
89
+ if (!layout.ok) throw new Error(layout.reason);
90
+ return layout.value;
91
+ }, {
92
+ cssFlow: true, initialLayout: "sync", ...context.theme as OwnedRecord<NativeViewOptions>,
93
+ });
94
+ if (!mounted.ok) return mounted;
95
+ state.owner.onDispose(mounted.value.dispose);
96
+ state.show = panel.value.show;
97
+ state.hide = panel.value.hide;
98
+ return ok(undefined);
99
+ }
100
+
101
+ function navigateWindow(path: string): Result<void> {
102
+ if (!routeExists(path)) return fail("The window has no page at " + path);
103
+ windowPath.value = path;
104
+ return ok(undefined);
105
+ }
106
+
107
+ function openWindow(path?: string): Result<void> {
108
+ const state = windowState.value;
109
+ if (state === undefined) return fail("The addon has no window. Declare window in the app module.");
110
+ if (!state.owner.isActive()) return fail("The addon window has closed");
111
+ const target = path ?? windowPath.value ?? firstPath(state);
112
+ if (target === undefined) return fail("The addon window has no pages");
113
+ const navigated = navigateWindow(target);
114
+ if (!navigated.ok) return navigated;
115
+ if (state.show === undefined) {
116
+ const mounted = mountWindow(state);
117
+ if (!mounted.ok) return mounted;
118
+ }
119
+ state.show?.();
120
+ windowOpen.value = true;
121
+ return ok(undefined);
122
+ }
123
+
124
+ function closeWindow() {
125
+ windowState.value?.hide?.();
126
+ windowOpen.value = false;
127
+ }
128
+
129
+ /**
130
+ * The addon window declared by the app module. Open it from a button, a slash command or a store.
131
+ *
132
+ * ```ts
133
+ * const window = useWindow();
134
+ * window.toggle("/settings");
135
+ * ```
136
+ */
137
+ export const useWindow = defineStore("kumi/window", () => {
138
+ const pages = computed(() => {
139
+ const rows: RoutePage[] = [];
140
+ const state = windowState.value;
141
+ if (state === undefined) return rows;
142
+ for (const page of state.router.pages) rows.push({ path: page.path, title: page.title ?? page.path, order: page.order ?? 0 });
143
+ for (const page of modulePages().value as OwnedReadonlyArray<ModulePage>) rows.push({ path: page.path, title: page.title, order: page.order ?? 0 });
144
+ return rows.sort((left, right) => left.order - right.order);
145
+ });
146
+
147
+ function open(this: void, path?: string): Result<void> {
148
+ return openWindow(path);
149
+ }
150
+
151
+ function close(this: void): void {
152
+ closeWindow();
153
+ }
154
+
155
+ function toggle(this: void, path?: string): Result<void> {
156
+ if (windowOpen.value && (path === undefined || path === windowPath.value)) {
157
+ closeWindow();
158
+ return ok(undefined);
159
+ }
160
+ return openWindow(path);
161
+ }
162
+
163
+ function navigate(this: void, path: string): Result<void> {
164
+ return navigateWindow(path);
165
+ }
166
+
167
+ return { isOpen: readonly(windowOpen), path: readonly(windowPath), pages, open, close, toggle, navigate };
168
+ });
169
+
170
+ /** Inside a HUD view: refresh it now, or read the size of one physical pixel. */
171
+ export function useViewHost(this: void): ViewHost {
172
+ const host = viewContext.use();
173
+ if (host === undefined) throw new Error("useViewHost works during the setup of a module view");
174
+ return host;
175
+ }
176
+
177
+ function mountView(context: AppContext, component: ViewComponent, strata: string, scope: RuntimeScope): Result<void> {
178
+ const mounted = mountProtectedView(context.runtime, scope, (_view, refresh, pixel) => {
179
+ const rendered = viewContext.run({ refresh, pixel }, () => createElement(component, {}), scope.protect);
180
+ if (!rendered.ok) throw new Error(formatFailure(rendered));
181
+ return rendered.value;
182
+ }, { ...context.theme as OwnedRecord<NativeViewOptions>, rootLayer: { strata: strata as FrameStrata } });
183
+ return mounted.ok ? ok(undefined) : mounted;
184
+ }
185
+
186
+ function mountUi(id: string, ui: ModuleUi, scope: RuntimeScope): Result<void> {
187
+ const context = app;
188
+ if (context === undefined) return fail("Module " + id + " declares UI but the addon is not running");
189
+ if (ui.window !== undefined) {
190
+ if (windowState.value !== undefined) return fail("Module " + id + ": the addon already has a window");
191
+ const router = ui.window.routes as Result<FileRouter>;
192
+ if (router === undefined || typeof router !== "object" || !("ok" in router)) {
193
+ return fail("Module " + id + ": window.routes must be the router from @kumi/routes");
194
+ }
195
+ if (!router.ok) return fail("Module " + id + ": " + router.reason);
196
+ windowState.value = { config: ui.window, router: router.value, owner: scope };
197
+ const released = scope.onDispose(() => {
198
+ closeWindow();
199
+ windowState.value = undefined;
200
+ });
201
+ if (!released.ok) return released;
202
+ }
203
+ for (const view of (ui.views ?? []) as OwnedReadonlyArray<ViewComponent | ModuleView>) {
204
+ const component = typeof view === "function" ? view : view.component;
205
+ const strata = typeof view === "function" ? "MEDIUM" : view.strata ?? "MEDIUM";
206
+ const mounted = mountView(context, component, strata, scope);
207
+ if (!mounted.ok) return fail("Module " + id + ": " + mounted.reason);
208
+ }
209
+ return ok(undefined);
210
+ }
211
+
212
+ /** @internal Called by startAddon before the root module activates. */
213
+ export function installAppUi(this: void, runtime: Runtime, scope: RuntimeScope, events: EventApi, theme: AppTheme): void {
214
+ app = { runtime, scope, events, theme };
215
+ installModuleUi(mountUi);
216
+ scope.onDispose(() => {
217
+ if (app?.scope === scope) app = undefined;
218
+ installModuleUi(undefined);
219
+ });
220
+ }
221
+