@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.
Files changed (201) hide show
  1. package/README.md +59 -6
  2. package/animation/index.ts +4 -0
  3. package/animation/motion-policy.ts +20 -0
  4. package/animation/slide.ts +61 -0
  5. package/animation/spring.ts +75 -0
  6. package/animation/staggered-reveal.ts +34 -0
  7. package/builder/css-gradients.mjs +74 -0
  8. package/builder/css-mask-assets.mjs +52 -0
  9. package/builder/css-mask-assets.test.mjs +31 -0
  10. package/builder/css-v1.mjs +127 -23
  11. package/builder/css-v1.test.mjs +82 -2
  12. package/builder/link-addon-package.mjs +47 -6
  13. package/builder/module-declarations.test.mjs +9 -18
  14. package/builder/native-kernels.mjs +1 -1
  15. package/builder/src/compiler.rs +205 -8
  16. package/builder/src/lua_upvalues.rs +641 -0
  17. package/builder/src/main.rs +20 -5
  18. package/builder/src/native_ir.rs +1 -1
  19. package/builder/src/native_signal.rs +46 -10
  20. package/builder/src/numbers.lua +14 -0
  21. package/builder/src/project-front.mjs +385 -34
  22. package/builder/src/routes.rs +11 -14
  23. package/builder/src/setup-store.lua +18 -0
  24. package/builder/src/signal-kernel.fingerprint +1 -1
  25. package/builder/src/ts-lower.mjs +2 -2
  26. package/builder/src/wow-reads.lua +22 -0
  27. package/builder/style-modules.mjs +111 -0
  28. package/builder/style-modules.test.mjs +24 -0
  29. package/builder/style-states.mjs +6 -4
  30. package/config.ts +56 -14
  31. package/eslint.mjs +74 -0
  32. package/form/index.ts +15 -11
  33. package/package.json +11 -7
  34. package/router/index.ts +10 -2
  35. package/router/link.tsx +32 -0
  36. package/router/navigation.ts +22 -0
  37. package/router/router-view.ts +134 -0
  38. package/scripts/addon-build.mjs +377 -0
  39. package/scripts/addon-project.mjs +89 -0
  40. package/scripts/kumi-cli.mjs +52 -17
  41. package/scripts/link-addons.mjs +12 -2
  42. package/src/bindings.ts +12 -6
  43. package/src/context.ts +31 -7
  44. package/src/css-tokens.ts +27 -13
  45. package/src/css-v1.ts +13 -0
  46. package/src/elements.ts +35 -0
  47. package/src/flex-layout.ts +26 -5
  48. package/src/frame-scheduler.ts +6 -2
  49. package/src/index.ts +2 -1
  50. package/src/jsx-runtime.ts +8 -1
  51. package/src/keyed-list.ts +17 -11
  52. package/src/module-ui.ts +163 -0
  53. package/src/module.ts +51 -8
  54. package/src/owned-collections.ts +8 -0
  55. package/src/providers.ts +7 -1
  56. package/src/reactive-scope.ts +3 -3
  57. package/src/reactivity.ts +42 -8
  58. package/src/result.ts +6 -0
  59. package/src/signal-kernel.ts +35 -2
  60. package/src/style-classes.ts +22 -1
  61. package/src/style-states.ts +13 -6
  62. package/state/index.ts +6 -0
  63. package/state/setup-store-persistence.ts +206 -0
  64. package/state/setup-store-view.ts +10 -0
  65. package/state/setup-store.ts +342 -0
  66. package/state/store.ts +2 -0
  67. package/templates/addon/.agents/skills/kumi-build-debug/SKILL.md +36 -0
  68. package/templates/addon/.agents/skills/kumi-feature/SKILL.md +50 -0
  69. package/templates/addon/.agents/skills/kumi-plugin/SKILL.md +36 -0
  70. package/templates/addon/.agents/skills/kumi-store/SKILL.md +47 -0
  71. package/templates/addon/.agents/skills/kumi-ui/SKILL.md +73 -0
  72. package/templates/addon/.agents/skills/kumi-wow-api/SKILL.md +30 -0
  73. package/templates/addon/.claude/skills/kumi-build-debug/SKILL.md +36 -0
  74. package/templates/addon/.claude/skills/kumi-feature/SKILL.md +50 -0
  75. package/templates/addon/.claude/skills/kumi-plugin/SKILL.md +36 -0
  76. package/templates/addon/.claude/skills/kumi-store/SKILL.md +47 -0
  77. package/templates/addon/.claude/skills/kumi-ui/SKILL.md +73 -0
  78. package/templates/addon/.claude/skills/kumi-wow-api/SKILL.md +30 -0
  79. package/templates/addon/AGENTS.md +34 -0
  80. package/templates/addon/Assets/Art/Corner10.tga +0 -0
  81. package/templates/addon/Assets/Art/Corner11.tga +0 -0
  82. package/templates/addon/Assets/Art/Corner12.tga +0 -0
  83. package/templates/addon/Assets/Art/Corner13.tga +0 -0
  84. package/templates/addon/Assets/Art/Corner14.tga +0 -0
  85. package/templates/addon/Assets/Art/Corner15.tga +0 -0
  86. package/templates/addon/Assets/Art/Corner16.tga +0 -0
  87. package/templates/addon/Assets/Art/Corner2.tga +0 -0
  88. package/templates/addon/Assets/Art/Corner3.tga +0 -0
  89. package/templates/addon/Assets/Art/Corner4.tga +0 -0
  90. package/templates/addon/Assets/Art/Corner5.tga +0 -0
  91. package/templates/addon/Assets/Art/Corner6.tga +0 -0
  92. package/templates/addon/Assets/Art/Corner7.tga +0 -0
  93. package/templates/addon/Assets/Art/Corner8.tga +0 -0
  94. package/templates/addon/Assets/Art/Corner9.tga +0 -0
  95. package/templates/addon/Assets/Art/Dot.tga +0 -0
  96. package/templates/addon/Assets/Art/Gear.tga +0 -0
  97. package/templates/addon/Assets/Art/Grip.tga +0 -0
  98. package/templates/addon/Assets/Art/Outline10.tga +0 -0
  99. package/templates/addon/Assets/Art/Outline12.tga +0 -0
  100. package/templates/addon/Assets/Art/Outline13.tga +0 -0
  101. package/templates/addon/Assets/Art/Outline14.tga +0 -0
  102. package/templates/addon/Assets/Art/Outline15.tga +0 -0
  103. package/templates/addon/Assets/Art/Outline2.tga +0 -0
  104. package/templates/addon/Assets/Art/Outline3.tga +0 -0
  105. package/templates/addon/Assets/Art/Outline5.tga +0 -0
  106. package/templates/addon/Assets/Art/Outline7.tga +0 -0
  107. package/templates/addon/Assets/Art/Outline9.tga +0 -0
  108. package/templates/addon/Assets/Art/Round11.tga +0 -0
  109. package/templates/addon/Assets/Art/Round11Border.tga +0 -0
  110. package/templates/addon/Assets/Art/Round4.tga +0 -0
  111. package/templates/addon/Assets/Art/Round4Border.tga +0 -0
  112. package/templates/addon/Assets/Art/Round6.tga +0 -0
  113. package/templates/addon/Assets/Art/Round6Border.tga +0 -0
  114. package/templates/addon/Assets/Art/Round8.tga +0 -0
  115. package/templates/addon/Assets/Art/Round8Border.tga +0 -0
  116. package/templates/addon/Assets/Art/Search.tga +0 -0
  117. package/templates/addon/CLAUDE.md +1 -0
  118. package/templates/addon/README.md +42 -7
  119. package/templates/addon/eslint.config.mjs +3 -9
  120. package/templates/addon/gitignore +1 -0
  121. package/templates/addon/kumi.config.ts +17 -0
  122. package/templates/addon/package.json +4 -5
  123. package/templates/addon/src/app/app.module.ts +18 -0
  124. package/templates/addon/src/app/commands.store.ts +11 -0
  125. package/templates/addon/src/app/layout/AppWindow.module.css +90 -0
  126. package/templates/addon/src/app/layout/AppWindow.tsx +32 -0
  127. package/templates/addon/src/app/main.ts +5 -0
  128. package/templates/addon/src/app/routes/(window)/home/page.tsx +8 -0
  129. package/templates/addon/src/app/routes/(window)/plugins/page.tsx +38 -0
  130. package/templates/addon/src/app/routes/(window)/settings/page.tsx +8 -0
  131. package/templates/addon/src/app/theme.ts +6 -0
  132. package/templates/addon/src/modules/greeting/api/player.api.ts +29 -0
  133. package/templates/addon/src/modules/greeting/greeting.module.ts +18 -0
  134. package/templates/addon/src/modules/greeting/model/greeting.store.ts +81 -0
  135. package/templates/addon/src/modules/greeting/services/greeting.service.ts +38 -0
  136. package/templates/addon/src/modules/greeting/ui/Greeting.module.css +103 -0
  137. package/templates/addon/src/modules/greeting/ui/GreetingCard.tsx +29 -0
  138. package/templates/addon/src/modules/greeting/widgets/GreetingHud.tsx +54 -0
  139. package/templates/addon/src/modules/greeting/widgets/GreetingOverview.tsx +18 -0
  140. package/templates/addon/src/modules/greeting/widgets/GreetingSettings.tsx +56 -0
  141. package/templates/addon/src/modules/playtime/api/clock.api.ts +6 -0
  142. package/templates/addon/src/modules/playtime/model/playtime.store.ts +19 -0
  143. package/templates/addon/src/modules/playtime/playtime.module.ts +18 -0
  144. package/templates/addon/src/modules/playtime/services/playtime.service.ts +18 -0
  145. package/templates/addon/src/modules/playtime/ui/Playtime.module.css +23 -0
  146. package/templates/addon/src/modules/playtime/ui/PlaytimeBadge.tsx +10 -0
  147. package/templates/addon/src/modules/playtime/widgets/PlaytimePage.tsx +16 -0
  148. package/templates/addon/src/shared/api/native-art.ts +28 -0
  149. package/templates/addon/src/shared/assets/close.png +0 -0
  150. package/templates/addon/src/shared/lib/format.ts +20 -0
  151. package/templates/addon/src/shared/styles/tokens.css +13 -0
  152. package/templates/addon/src/shared/ui/Button.tsx +29 -0
  153. package/templates/addon/src/shared/ui/Choice.tsx +34 -0
  154. package/templates/addon/src/shared/ui/Controls.module.css +91 -0
  155. package/templates/addon/src/shared/ui/Glyph.tsx +18 -0
  156. package/templates/addon/src/shared/ui/Slider.tsx +25 -0
  157. package/templates/addon/src/shared/ui/Toggle.tsx +29 -0
  158. package/templates/addon/src/shared/ui/focus-ref.ts +7 -0
  159. package/templates/addon/src/shared/ui/range-skin.tsx +15 -0
  160. package/templates/addon/tsconfig.json +49 -10
  161. package/wow/action-bar-layout.ts +108 -0
  162. package/wow/action-button.ts +244 -0
  163. package/wow/action-catalog.ts +98 -0
  164. package/wow/addon-manifest.ts +38 -0
  165. package/wow/animation.ts +3 -14
  166. package/wow/app-ui.ts +230 -0
  167. package/wow/cooldown-timing.ts +24 -0
  168. package/wow/css-background-image.ts +75 -0
  169. package/wow/css-box.ts +46 -10
  170. package/wow/css-image-mask.ts +32 -0
  171. package/wow/css-surfaces.ts +295 -43
  172. package/wow/cursor.ts +45 -0
  173. package/wow/element-events.ts +33 -13
  174. package/wow/frame-access.ts +23 -1
  175. package/wow/frame-timing.ts +13 -0
  176. package/wow/heal-prediction.ts +2 -4
  177. package/wow/hooks.ts +133 -0
  178. package/wow/index.ts +19 -4
  179. package/wow/layout-view.ts +44 -23
  180. package/wow/locale-font.ts +15 -0
  181. package/wow/module-replacements.ts +103 -0
  182. package/wow/native.ts +18 -0
  183. package/wow/panel-host.ts +97 -0
  184. package/wow/pixel.ts +35 -0
  185. package/wow/plugins.ts +246 -0
  186. package/wow/pointer-click.ts +35 -0
  187. package/wow/protect.ts +27 -3
  188. package/wow/protected-view.ts +139 -0
  189. package/wow/range-art.ts +7 -0
  190. package/wow/readable-api.ts +120 -0
  191. package/wow/rounded-texture.ts +38 -6
  192. package/wow/saved-variables.ts +67 -18
  193. package/wow/spell-cooldown.ts +36 -0
  194. package/wow/start-addon.ts +31 -8
  195. package/wow/state-paint.ts +5 -14
  196. package/wow/texture-fill.ts +10 -0
  197. package/wow/unit-cast.ts +6 -4
  198. package/wow/view.ts +458 -228
  199. package/templates/addon/__ADDON_NAME__.toc +0 -4
  200. package/templates/addon/scripts/build.mjs +0 -25
  201. package/templates/addon/src/app/main.tsx +0 -13
package/src/keyed-list.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { captureContexts, withContexts } from "./context";
1
2
  import type { Element, ElementKey, UIElement } from "./elements";
2
3
  import type { OwnedArray, OwnedMap, OwnedReadonlyArray, OwnedRecord, OwnedSet } from "./owned-collections";
3
4
  import { withReactiveScope } from "./reactive-scope";
@@ -26,17 +27,20 @@ const layoutProps = new Set(["anchor", "width", "height", "opacity", "shown"]);
26
27
  const bindingProps: Partial<Record<UIElement["kind"], ReadonlySet<string>>> = {
27
28
  frame: new Set(["nativeScale", "nativeImageLayers"]),
28
29
  image: new Set(["nativeDesaturated", "verticalGradient"]),
30
+ texture: new Set(["src", "nativeDesaturated", "verticalGradient"]),
29
31
  text: new Set(["value", "color", "fontSize"]),
30
- button: new Set(["value", "disabled", "checked"]),
31
- editbox: new Set(["value"]),
32
+ button: new Set(["value", "disabled", "checked", "secureAction"]),
33
+ cooldown: new Set(["value"]),
34
+ editbox: new Set(["value", "nativeImageLayers"]),
32
35
  checkbox: new Set(["checked", "disabled"]),
33
36
  range: new Set(["value", "disabled"]),
34
37
  listbox: new Set(["value", "disabled"]),
35
38
  };
36
39
  // `ref` is not proxied: a ref owns the handle it received, so a row with a different ref is mounted again.
37
- const callbackProps = new Set(["onClick", "onChange", "onFocus", "onBlur", "onEnter", "onEscape", "onPointerEnter", "onPointerLeave",
38
- "onDrag", "onDragEnd", "onDragCancel", "onShow", "onHide", "onClickOutside", "onDismiss"]);
39
- const descriptorProps = new Set(["style", "src", "items", "data"]);
40
+ const callbackProps = new Set(["onClick", "onChange", "onCommit", "onFocus", "onBlur", "onEnter", "onEscape", "onPointerEnter", "onPointerLeave",
41
+ "onDrag", "onDragEnd", "onDragCancel", "onReceiveDrag", "onMove", "onMoveEnd", "onMoveCancel",
42
+ "onShow", "onHide", "onClickOutside", "onDismiss", "onSourceChange"]);
43
+ const descriptorProps = new Set(["style", "src", "texCoords", "items", "data"]);
40
44
 
41
45
  function propertyNames(props: Props) {
42
46
  return Object.keys(props).filter(name => name !== "children" && name !== "key" && props[name] !== undefined) as OwnedArray<string>;
@@ -223,7 +227,8 @@ interface MapRow<Item, View> {
223
227
 
224
228
  function mountMapRow<Item, Key extends ElementKey, View>(key: Key, initial: MapInput<Item>,
225
229
  render: (this: void, item: Item, index: number, key: Key) => UIElement,
226
- parent: RuntimeScope, host: ListHost<View>, reorder: (this: void) => void): Result<MapRow<Item, View>> {
230
+ parent: RuntimeScope, host: ListHost<View>, reorder: (this: void) => void,
231
+ contexts: ReturnType<typeof captureContexts>): Result<MapRow<Item, View>> {
227
232
  const scope = parent.fork();
228
233
  const input = ref(initial);
229
234
  let mounted: Row<View> | undefined;
@@ -232,10 +237,10 @@ function mountMapRow<Item, Key extends ElementKey, View>(key: Key, initial: MapI
232
237
  const subscription = scope.watch(() => {
233
238
  const { item, index } = input.value;
234
239
  const candidate = scope.fork();
235
- const result = withReactiveScope(candidate, () => {
240
+ const result = withContexts(contexts, () => withReactiveScope(candidate, () => {
236
241
  const node = render(item, index, key);
237
242
  return node.key === key ? node : { ...node as OwnedRecord<UIElement>, key };
238
- });
243
+ }));
239
244
  return { candidate, result };
240
245
  }, ({ candidate, result }) => {
241
246
  if (!result.ok) {
@@ -283,7 +288,7 @@ function mountMapRow<Item, Key extends ElementKey, View>(key: Key, initial: MapI
283
288
  function mountMap<Item, Key extends ElementKey, View>(read: (this: void) => readonly Item[],
284
289
  keyBy: (this: void, item: Item, index: number) => Key,
285
290
  render: (this: void, item: Item, index: number, key: Key) => UIElement,
286
- usesIndex: boolean, scope: RuntimeScope, host: ListHost<View>): Failure | undefined {
291
+ usesIndex: boolean, scope: RuntimeScope, host: ListHost<View>, contexts: ReturnType<typeof captureContexts>): Failure | undefined {
287
292
  let rows = new Map<Key, MapRow<Item, View>>() as OwnedMap<Key, MapRow<Item, View>>;
288
293
  let orderPending = false;
289
294
 
@@ -323,7 +328,7 @@ function mountMap<Item, Key extends ElementKey, View>(read: (this: void) => read
323
328
  for (const [key, input] of inputs) {
324
329
  let row = rows.get(key);
325
330
  if (!row) {
326
- const mounted = mountMapRow(key, input, render, scope, host, reorder);
331
+ const mounted = mountMapRow(key, input, render, scope, host, reorder, contexts);
327
332
  if (!mounted.ok) {
328
333
  for (const staged of created) staged.dispose();
329
334
  return mounted;
@@ -359,5 +364,6 @@ function mountMap<Item, Key extends ElementKey, View>(read: (this: void) => read
359
364
  export function jsxMap<Item, Key extends ElementKey>(this: void, read: (this: void) => readonly Item[],
360
365
  keyBy: (this: void, item: Item, index: number) => Key,
361
366
  render: (this: void, item: Item, index: number, key: Key) => UIElement, usesIndex = false): Element<"keyedList"> {
362
- return { kind: "keyedList", props: { mount: (scope, host) => mountMap(read, keyBy, render, usesIndex, scope, host) }, children: [] };
367
+ const contexts = captureContexts();
368
+ return { kind: "keyedList", props: { mount: (scope, host) => mountMap(read, keyBy, render, usesIndex, scope, host, contexts) }, children: [] };
363
369
  }
@@ -0,0 +1,163 @@
1
+ import { createElement, type UIElement } from "./elements";
2
+ import { jsxMap } from "./keyed-list";
3
+ import { ownedArray, ownedMap, type OwnedReadonlyArray } from "./owned-collections";
4
+ import { ref, type ReadonlyRef, type SignalRef } from "./reactivity";
5
+ import { fail, ok, type Result } from "./result";
6
+ import type { RuntimeScope } from "./runtime";
7
+
8
+ /** A component that takes no props, such as a HUD view or a page. It reads its data from stores. */
9
+ export type ViewComponent = (this: void, props: Record<string, never>) => UIElement;
10
+ /** A component another module renders through `<Extensions name>`. */
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ export type ExtensionComponent = (this: void, props: any) => UIElement;
13
+
14
+ /** A view a module shows on screen while it is active. */
15
+ export interface ModuleView {
16
+ readonly component: ViewComponent;
17
+ /** The frame strata of the view's root, `"MEDIUM"` by default. */
18
+ readonly strata?: string;
19
+ /** Allow an already mounted, unprotected visual tree to update during combat. */
20
+ readonly combatUpdates?: true;
21
+ }
22
+
23
+ /** A synchronous WoW adapter for the native UI displaced by a module's views. */
24
+ export interface ModuleReplacement {
25
+ /** Capture the native state, hide the frame and unregister its events. */
26
+ readonly disable: (this: void) => Result<void> | void;
27
+ /** Restore the captured state, including after an incomplete disable. */
28
+ readonly restore: (this: void) => Result<void> | void;
29
+ }
30
+
31
+ /** A page a module adds to the addon window while it is active. */
32
+ export interface ModulePage {
33
+ /** The page's path in the window, such as `"/history"`. */
34
+ readonly path: string;
35
+ readonly title: string;
36
+ readonly component: ViewComponent;
37
+ /** Position among the window's pages. Lower values come first. */
38
+ readonly order?: number;
39
+ }
40
+
41
+ /** The addon's main window, declared once by the app module. */
42
+ export interface ModuleWindow {
43
+ /** The generated router: `import { router } from "@kumi/routes"`. */
44
+ readonly routes: unknown;
45
+ /** The window's frame. Render `<RouterView />` where the active page goes. */
46
+ readonly layout: ViewComponent;
47
+ readonly width: number;
48
+ readonly height: number;
49
+ /** The page to open first. Defaults to the first file route. */
50
+ readonly start?: string;
51
+ /** `"DIALOG"` by default. */
52
+ readonly strata?: string;
53
+ }
54
+
55
+ /** UI a module contributes. Kumi mounts and removes it with the module. */
56
+ export interface ModuleUi {
57
+ readonly views?: readonly (ViewComponent | ModuleView)[];
58
+ readonly replaces?: readonly ModuleReplacement[];
59
+ readonly extensions?: Readonly<Record<string, ExtensionComponent | readonly ExtensionComponent[]>>;
60
+ readonly pages?: readonly ModulePage[];
61
+ readonly window?: ModuleWindow;
62
+ }
63
+
64
+ type PlatformUi = (this: void, id: string, ui: ModuleUi, scope: RuntimeScope) => Result<void>;
65
+
66
+ interface Extension {
67
+ readonly id: number;
68
+ readonly component: ExtensionComponent;
69
+ }
70
+
71
+ let platform: PlatformUi | undefined;
72
+ let lastExtension = 0;
73
+ const points = ownedMap<string, SignalRef<readonly Extension[]>>();
74
+ const pages = ref<readonly ModulePage[]>([]);
75
+
76
+ // Copy into SDK-owned arrays: the native compiler needs proven sequences for loops and spreads.
77
+ function joined<Item extends object>(first: readonly Item[], second: readonly Item[]): readonly Item[] {
78
+ const list = ownedArray<Item>();
79
+ for (const item of first as OwnedReadonlyArray<Item>) list.push(item);
80
+ for (const item of second as OwnedReadonlyArray<Item>) list.push(item);
81
+ return list;
82
+ }
83
+
84
+ function without<Item extends object>(list: readonly Item[], removed: readonly Item[]): readonly Item[] {
85
+ const kept = ownedArray<Item>();
86
+ for (const item of list as OwnedReadonlyArray<Item>) if (!(removed as OwnedReadonlyArray<Item>).includes(item)) kept.push(item);
87
+ return kept;
88
+ }
89
+
90
+ function point(name: string) {
91
+ let entries = points.get(name);
92
+ if (entries === undefined) {
93
+ entries = ref<readonly Extension[]>([]);
94
+ points.set(name, entries);
95
+ }
96
+ return entries;
97
+ }
98
+
99
+ /** @internal The platform mounts views and the window. */
100
+ export function installModuleUi(this: void, host: PlatformUi | undefined): void {
101
+ platform = host;
102
+ }
103
+
104
+ /** The pages modules added to the window, in order. */
105
+ export function modulePages(this: void): ReadonlyRef<readonly ModulePage[]> {
106
+ return pages;
107
+ }
108
+
109
+ /** @internal Register a module's extensions and pages, then let the platform mount its views and window. */
110
+ export function mountModuleUi(this: void, id: string, ui: ModuleUi, scope: RuntimeScope): Result<void> {
111
+ const views = ui.views as OwnedReadonlyArray<ViewComponent | ModuleView> | undefined;
112
+ const replaces = ui.replaces as OwnedReadonlyArray<ModuleReplacement> | undefined;
113
+ const hasViews = views !== undefined && views.length > 0;
114
+ const hasReplacements = replaces !== undefined && replaces.length > 0;
115
+ if (hasReplacements && !hasViews) return fail("Module " + id + ": replaces requires at least one view");
116
+
117
+ const extensions = ui.extensions;
118
+ if (extensions !== undefined) {
119
+ for (const name of Object.keys(extensions)) {
120
+ const value = extensions[name];
121
+ const components = (typeof value === "function" ? [value] : value) as OwnedReadonlyArray<ExtensionComponent>;
122
+ const entries = point(name);
123
+ const added = ownedArray<Extension>();
124
+ for (const component of components) added.push({ id: ++lastExtension, component });
125
+ entries.value = joined(entries.value, added);
126
+ const removed = scope.onDispose(() => {
127
+ entries.value = without(entries.value, added);
128
+ });
129
+ if (!removed.ok) return removed;
130
+ }
131
+ }
132
+ const added = ui.pages as OwnedReadonlyArray<ModulePage> | undefined;
133
+ if (added !== undefined && added.length > 0) {
134
+ for (const page of added) {
135
+ if (!page.path.startsWith("/")) return fail("Module " + id + ": page path " + page.path + " must start with /");
136
+ }
137
+ const sorted = ownedArray<ModulePage>();
138
+ for (const page of joined(pages.value, added) as OwnedReadonlyArray<ModulePage>) sorted.push(page);
139
+ sorted.sort((left, right) => (left.order ?? 0) - (right.order ?? 0));
140
+ pages.value = sorted;
141
+ const removed = scope.onDispose(() => {
142
+ pages.value = without(pages.value, added);
143
+ });
144
+ if (!removed.ok) return removed;
145
+ }
146
+ if (!hasViews && ui.window === undefined) return ok(undefined);
147
+ if (platform === undefined) return fail("Module " + id + " declares views or a window. Start the addon with startAddon.");
148
+ return platform(id, ui, scope);
149
+ }
150
+
151
+ /**
152
+ * Render the components that active modules add to an extension point.
153
+ * A plugin's extensions appear when it starts and disappear when it stops.
154
+ *
155
+ * ```tsx
156
+ * <Extensions name="hud.sections" />
157
+ * ```
158
+ */
159
+ export function Extensions(this: void, props: { readonly name: string; readonly props?: object }): UIElement {
160
+ const entries = point(props.name);
161
+ const inputs = props.props ?? {};
162
+ return jsxMap(() => entries.value, entry => entry.id, entry => createElement(entry.component, inputs));
163
+ }
package/src/module.ts CHANGED
@@ -4,6 +4,8 @@ import { createServiceProvider, resolveProviders, serviceToken, type CheckedProv
4
4
  import type { RuntimeScope } from "./runtime";
5
5
  import { createFeatureLifecycle, type FeatureLifecycle } from "./feature-scope";
6
6
  import type { OwnedReadonlyArray } from "./owned-collections";
7
+ import { createStoreHost, openModuleStores, type AnyStoreFactory, type StoreHost } from "../state/setup-store";
8
+ import { mountModuleUi, type ModuleReplacement, type ModuleUi } from "./module-ui";
7
9
 
8
10
  export interface ModuleContext<Services extends object> {
9
11
  readonly services: Readonly<Services>;
@@ -20,7 +22,7 @@ export interface ModuleDeclaration<Exports extends object> {
20
22
  readonly serviceExports?: ServiceExports;
21
23
  readonly feature?: boolean;
22
24
  readonly initialize: (this: void, resolve: ResolveModule, scope?: ResolveModuleScope,
23
- attachFeature?: (this: void, controller: FeatureLifecycle) => void) => Result<Readonly<Exports>>;
25
+ attachFeature?: (this: void, controller: FeatureLifecycle) => void, stores?: StoreHost) => Result<Readonly<Exports>>;
24
26
  }
25
27
 
26
28
  declare const moduleExports: unique symbol;
@@ -73,11 +75,13 @@ export interface Module<Exports extends object> {
73
75
  }
74
76
 
75
77
  interface DeclarativeModuleOptions<Providers extends readonly ProviderDeclaration[], Exports extends ServiceExports,
76
- InferConstructor extends boolean = false> {
78
+ InferConstructor extends boolean = false> extends ModuleUi {
77
79
  readonly id: string;
78
80
  readonly imports?: readonly ModuleDependency<object>[];
79
81
  readonly feature?: boolean;
80
82
  readonly providers: Providers & NoInfer<CheckedProviders<Providers, InferConstructor>>;
83
+ /** Stores this module owns. They open when the module activates, and their setup can inject the module's services. */
84
+ readonly stores?: readonly AnyStoreFactory[];
81
85
  readonly exports: Exports;
82
86
  }
83
87
 
@@ -118,7 +122,7 @@ export function defineModule<
118
122
  if (!("providers" in definition)) return { exports: definition.exports({ services: definition.imports }) };
119
123
  if (typeof definition.providers !== "function") {
120
124
  const module = definition as DeclarativeModuleOptions<readonly ProviderDeclaration[], ServiceTokens>;
121
- return createServiceModule(module.id, module.imports ?? [], module.providers, module.exports, module.feature);
125
+ return createServiceModule(module.id, module.imports ?? [], module.providers, module.exports, module.feature, module.stores, module);
122
126
  }
123
127
  const legacy = definition as ModuleOptions<Dependencies, Providers, Exports> | ServiceModuleOptions<Dependencies, ServiceTokens>;
124
128
  return {
@@ -154,13 +158,14 @@ function hostInputs(resolve: ResolveModule, scope?: ResolveModuleScope) {
154
158
  }
155
159
 
156
160
  function createServiceModule<Exports extends ServiceExports>(id: string, imports: readonly ModuleDependency<object>[],
157
- providers: readonly ProviderDeclaration[], exports: Exports, feature?: boolean): ModuleDeclaration<PublicServices<Exports>> {
161
+ providers: readonly ProviderDeclaration[], exports: Exports, feature?: boolean,
162
+ stores?: readonly AnyStoreFactory[], ui?: ModuleUi): ModuleDeclaration<PublicServices<Exports>> {
158
163
  return {
159
164
  kind: "module",
160
165
  id,
161
166
  serviceExports: exports,
162
167
  feature,
163
- initialize(this: void, resolve, scope, attachFeature) {
168
+ initialize(this: void, resolve, scope, attachFeature, storeHost) {
164
169
  const imported = new Map<ServiceToken<object>, object>();
165
170
  const seen = new Set<string>();
166
171
  for (const reference of imports as OwnedReadonlyArray<ModuleDependency<object>>) {
@@ -189,8 +194,31 @@ function createServiceModule<Exports extends ServiceExports>(id: string, imports
189
194
  lifecycle = created.value;
190
195
  }
191
196
  const declarations = providers as OwnedReadonlyArray<ProviderDeclaration>;
197
+ const owned = stores as OwnedReadonlyArray<AnyStoreFactory> | undefined;
198
+ const replacements = ui?.replaces as OwnedReadonlyArray<ModuleReplacement> | undefined;
199
+ const hasReplacements = replacements !== undefined && replacements.length > 0;
200
+ const hasStores = owned !== undefined && owned.length > 0;
201
+ const hasUi = ui !== undefined && (ui.views !== undefined || ui.replaces !== undefined
202
+ || ui.extensions !== undefined || ui.pages !== undefined || ui.window !== undefined);
203
+ // Stores open after the providers, and UI mounts after the stores it reads.
204
+ const ready = !hasStores && !hasUi ? undefined : (inject: (this: void, token: ServiceToken<object>) => Result<object>) => {
205
+ if (scope === undefined || hasStores && storeHost === undefined) return fail("Module " + id + " needs a module container");
206
+ const owning = scope();
207
+ if (!owning.ok) return owning;
208
+ if (hasStores && storeHost !== undefined) {
209
+ const opened = openModuleStores(storeHost, id, owned, owning.value, inject);
210
+ if (!opened.ok) return opened;
211
+ }
212
+ if (ui === undefined) return ok(undefined);
213
+ if (!hasReplacements) return mountModuleUi(id, ui, owning.value);
214
+ if (lifecycle !== undefined) {
215
+ lifecycle.add({ enable: active => mountModuleUi(id, ui, active) });
216
+ return ok(undefined);
217
+ }
218
+ return mountModuleUi(id, ui, owning.value.fork());
219
+ };
192
220
  const services = resolveProviders(id, declarations.map(provider => createServiceProvider(provider)), exports, imported,
193
- hostInputs(resolve, scope), scope, lifecycle);
221
+ hostInputs(resolve, scope), scope, lifecycle, ready);
194
222
  if (services.ok && lifecycle !== undefined) attachFeature?.(lifecycle);
195
223
  return services;
196
224
  },
@@ -198,6 +226,8 @@ function createServiceModule<Exports extends ServiceExports>(id: string, imports
198
226
  }
199
227
 
200
228
  export interface ModuleContainer {
229
+ /** @internal The addon's stores. One instance per store ID across every module of the container. */
230
+ readonly stores: StoreHost;
201
231
  readonly bind: <Value extends object>(this: void, input: ModuleInput<Value>, value: NoInfer<Value>) => void;
202
232
  readonly resolve: ResolveModule;
203
233
  readonly setFeatureEnabled: <Value extends object>(this: void, module: ModuleDependency<Value>, enabled: boolean) => Result<void>;
@@ -211,6 +241,12 @@ export interface ModuleContainerOptions {
211
241
  export function createModuleContainer(protect: Protect = direct, options?: ModuleContainerOptions): ModuleContainer {
212
242
  const bindings = new Map<string, object>();
213
243
  const instances = new Map<string, object>();
244
+ const declared = new Map<string, object>();
245
+ let storeRoot: RuntimeScope | undefined;
246
+ const stores = createStoreHost(() => {
247
+ if (storeRoot === undefined || !storeRoot.isActive()) storeRoot = options?.forkScope();
248
+ return storeRoot;
249
+ });
214
250
  const features = new Map<string, FeatureLifecycle>();
215
251
  const path: string[] = [];
216
252
 
@@ -223,6 +259,8 @@ export function createModuleContainer(protect: Protect = direct, options?: Modul
223
259
  ? fail(`Missing module input: ${[...path, id].join(" -> ")}`)
224
260
  : ok(value as Readonly<Value>);
225
261
  }
262
+ const known = declared.get(id);
263
+ if (known !== undefined && known !== reference) return fail(`Duplicate module ID: ${id}. Each module needs its own ID.`);
226
264
  const existing = instances.get(id);
227
265
  if (existing !== undefined) return ok(existing as Readonly<Value>);
228
266
  const cycle = path.indexOf(id);
@@ -239,8 +277,9 @@ export function createModuleContainer(protect: Protect = direct, options?: Modul
239
277
  }
240
278
 
241
279
  path.push(id);
280
+ declared.set(id, reference);
242
281
  const initialized = protect(() => reference.initialize(resolve, getScope,
243
- reference.feature === true ? feature => { features.set(id, feature); } : undefined));
282
+ reference.feature === true ? feature => { features.set(id, feature); } : undefined, stores));
244
283
  let result = initialized.ok ? initialized.value : fail(`Module ${id}: ${initialized.reason}`);
245
284
  if (result.ok && reference.feature === true && scope !== undefined) {
246
285
  const cleanup = scope.onDispose(() => { features.delete(id); });
@@ -248,7 +287,10 @@ export function createModuleContainer(protect: Protect = direct, options?: Modul
248
287
  }
249
288
  if (result.ok) {
250
289
  instances.set(id, result.value);
251
- } else if (scope !== undefined) {
290
+ } else {
291
+ declared.delete(id);
292
+ }
293
+ if (!result.ok && scope !== undefined) {
252
294
  if (reference.feature === true) features.delete(id);
253
295
  const stopped = protect(scope.dispose);
254
296
  const cleanup = stopped.ok ? stopped.value : stopped;
@@ -259,6 +301,7 @@ export function createModuleContainer(protect: Protect = direct, options?: Modul
259
301
  };
260
302
 
261
303
  return {
304
+ stores,
262
305
  bind: (input, value) => { bindings.set(input.id, value); },
263
306
  resolve,
264
307
  setFeatureEnabled: (module, enabled) => {
@@ -9,6 +9,10 @@ export interface OwnedReadonlyMap<Key, Value> extends ReadonlyMap<Key, Value> {
9
9
  readonly [collectionOwner]: "map";
10
10
  }
11
11
 
12
+ export interface OwnedWeakMap<Key extends object, Value> extends WeakMap<Key, Value> {
13
+ readonly [collectionOwner]: "weakmap";
14
+ }
15
+
12
16
  export interface OwnedSet<Value> extends Set<Value> {
13
17
  readonly [collectionOwner]: "set";
14
18
  }
@@ -34,6 +38,10 @@ export function ownedMap<Key, Value>(): OwnedMap<Key, Value> {
34
38
  return new Map<Key, Value>() as OwnedMap<Key, Value>;
35
39
  }
36
40
 
41
+ export function ownedWeakMap<Key extends object, Value>(): OwnedWeakMap<Key, Value> {
42
+ return new WeakMap<Key, Value>() as OwnedWeakMap<Key, Value>;
43
+ }
44
+
37
45
  export function ownedSet<Value>(): OwnedSet<Value> {
38
46
  return new Set<Value>() as OwnedSet<Value>;
39
47
  }
package/src/providers.ts CHANGED
@@ -111,7 +111,8 @@ export function resolveProviders<Exports extends ServiceExports>(moduleId: strin
111
111
  providers: readonly ServiceProvider[], publicTokens: Exports,
112
112
  imported: ReadonlyMap<ServiceToken<object>, object> = new Map(),
113
113
  resolveInput?: (this: void, token: ServiceToken<object>) => Result<object> | undefined,
114
- resolveScope?: (this: void) => Result<RuntimeScope>, feature?: FeatureLifecycle): Result<PublicServices<Exports>> {
114
+ resolveScope?: (this: void) => Result<RuntimeScope>, feature?: FeatureLifecycle,
115
+ ready?: (this: void, resolve: (this: void, token: ServiceToken<object>) => Result<object>) => Result<void>): Result<PublicServices<Exports>> {
115
116
  const definitions = new Map<ServiceToken<object>, ServiceProvider>();
116
117
  const inherited = imported as OwnedMap<ServiceToken<object>, object>;
117
118
  const values = new Map(inherited);
@@ -225,6 +226,11 @@ export function resolveProviders<Exports extends ServiceExports>(moduleId: strin
225
226
  }
226
227
  }
227
228
 
229
+ // Stores open after every provider and its lifecycle, so their setup can inject initialized services.
230
+ if (ready !== undefined) {
231
+ const injected = ready(token => resolve(token));
232
+ if (!injected.ok) return injected;
233
+ }
228
234
  const exports: Record<string, object> = {};
229
235
  for (const [name, token] of Object.entries(publicTokens)) {
230
236
  const result = resolve(token);
@@ -1,5 +1,5 @@
1
1
  import { createContext } from "./context";
2
- import { ref } from "./reactivity";
2
+ import { ref, type ComputedRef } from "./reactivity";
3
3
  import { fail, type Result } from "./result";
4
4
  import type { RuntimeScope } from "./runtime";
5
5
 
@@ -20,11 +20,11 @@ function missingComputationScope(operation: "computed" | "computedResult", name?
20
20
  }
21
21
 
22
22
  export function computed<Value>(read: (this: void) => Value, name?: string) {
23
- return context.use()?.computed(read, name) ?? ref<Result<Value>>(missingComputationScope("computed", name));
23
+ return context.use()?.computed(read, name) ?? ref<Result<Value>>(missingComputationScope("computed", name)) as unknown as ComputedRef<Value>;
24
24
  }
25
25
 
26
26
  export function computedResult<Value>(read: (this: void) => Result<Value>, name?: string) {
27
- return context.use()?.computedResult(read, name) ?? ref<Result<Value>>(missingComputationScope("computedResult", name));
27
+ return context.use()?.computedResult(read, name) ?? ref<Result<Value>>(missingComputationScope("computedResult", name)) as unknown as ComputedRef<Value>;
28
28
  }
29
29
 
30
30
  export const watch: RuntimeScope["watch"] = (read, change, options) =>
package/src/reactivity.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Cancel, Job, Scheduler } from "./scheduler";
2
2
  import { fail, ok, type Failure, type Protect, type Result } from "./result";
3
3
  import { createSignalFactory } from "./signal-kernel";
4
- import { ownedArray, ownedSet, type OwnedArray, type OwnedSet } from "./owned-collections";
4
+ import { ownedArray, ownedSet, ownedWeakMap, type OwnedArray, type OwnedSet } from "./owned-collections";
5
5
 
6
6
  export interface ReadonlyRef<T> {
7
7
  readonly value: T;
@@ -11,6 +11,17 @@ export interface Ref<T> extends ReadonlyRef<T> {
11
11
  value: T;
12
12
  }
13
13
 
14
+ declare const signalSource: unique symbol;
15
+ declare const computedSource: unique symbol;
16
+
17
+ export interface SignalRef<T> extends Ref<T> {
18
+ readonly [signalSource]: true;
19
+ }
20
+
21
+ export interface ComputedRef<T> extends ReadonlyRef<Result<T>> {
22
+ readonly [computedSource]: true;
23
+ }
24
+
14
25
  /** A pure comparison, or false to invalidate on every write or tracked read. */
15
26
  export type Equality<T> = false | ((this: void, previous: T, next: T) => boolean);
16
27
 
@@ -104,10 +115,13 @@ function collect<T>(observer: Observer, read: (this: void) => T, protect: Protec
104
115
  return result;
105
116
  }
106
117
 
107
- const newSignal = createSignalFactory(track, notify, createDependency);
118
+ const signalFactory = createSignalFactory(track, notify, createDependency);
119
+ const newSignal = signalFactory.create;
120
+ /** @internal Used only by setup-store persistence. Ordinary signals keep their original setter. */
121
+ export const guardSetupSignal = signalFactory.guard;
108
122
 
109
- export function ref<T>(value: T, options?: RefOptions<T>): Ref<T> {
110
- return newSignal(value, options?.equals);
123
+ export function ref<T>(value: T, options?: RefOptions<T>): SignalRef<T> {
124
+ return newSignal(value, options?.equals) as SignalRef<T>;
111
125
  }
112
126
 
113
127
  class Computed<T> implements ReadonlyRef<Result<T>> {
@@ -154,6 +168,26 @@ class Computed<T> implements ReadonlyRef<Result<T>> {
154
168
  }
155
169
  }
156
170
 
171
+ export function setupRefKind(value: unknown): "signal" | "computed" | undefined {
172
+ if (value == null || typeof value !== "object") return undefined;
173
+ if (signalFactory.owns(value)) return "signal";
174
+ if (value instanceof Computed) return "computed";
175
+ return undefined;
176
+ }
177
+
178
+ const refViews = ownedWeakMap<object, true>();
179
+
180
+ /** @internal Keep ref views recognizable when their getter returns nil in Lua. */
181
+ export function registerRefView<View extends ReadonlyRef<unknown>>(view: View): View {
182
+ refViews.set(view, true);
183
+ return view;
184
+ }
185
+
186
+ /** @internal Recognize Kumi refs and their views without reading the current value. */
187
+ export function isReactiveRef(value: unknown): value is ReadonlyRef<unknown> {
188
+ return value !== null && typeof value === "object" && (refViews.has(value) || setupRefKind(value) !== undefined);
189
+ }
190
+
157
191
  function cleanupFailure(value: unknown): Failure | undefined {
158
192
  if (value == null || typeof value !== "object") return;
159
193
  const candidate = value as Partial<Failure>;
@@ -172,14 +206,14 @@ export function createScope(scheduler: Scheduler) {
172
206
  return ok(() => cleanup.delete(stop));
173
207
  }
174
208
 
175
- function computedResult<T>(read: (this: void) => Result<T>, name?: string): ReadonlyRef<Result<T>> {
176
- if (disposed) return ref<Result<T>>(closed);
209
+ function computedResult<T>(read: (this: void) => Result<T>, name?: string): ComputedRef<T> {
210
+ if (disposed) return ref<Result<T>>(closed) as unknown as ComputedRef<T>;
177
211
  const value = new Computed(read, protect, name);
178
212
  cleanup.add(() => value.stop());
179
- return value;
213
+ return value as unknown as ComputedRef<T>;
180
214
  }
181
215
 
182
- function computed<T>(read: (this: void) => T, name?: string): ReadonlyRef<Result<T>> {
216
+ function computed<T>(read: (this: void) => T, name?: string): ComputedRef<T> {
183
217
  return computedResult(() => ok(read()), name);
184
218
  }
185
219
 
package/src/result.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export interface Failure {
2
2
  readonly ok: false;
3
3
  readonly reason: string;
4
+ readonly trace?: string;
4
5
  }
5
6
 
6
7
  export interface Success<Value> {
@@ -18,6 +19,11 @@ export function fail(reason: string): Failure {
18
19
  return { ok: false, reason };
19
20
  }
20
21
 
22
+ /** Format a diagnostic while keeping the reason available separately to callers. */
23
+ export function formatFailure(failure: Failure): string {
24
+ return failure.trace === undefined ? failure.reason : failure.reason + "\n" + failure.trace;
25
+ }
26
+
21
27
  export type Protect = <Value>(this: void, run: (this: void) => Value) => Result<Value>;
22
28
 
23
29
  /** For callbacks which already report errors as values. Hosts may inject a protected boundary. */
@@ -5,7 +5,12 @@ export function createSignalFactory<Dependency>(
5
5
  track: (this: void, dependency: Dependency) => void,
6
6
  notify: (this: void, dependency: Dependency) => void,
7
7
  makeDependency: (this: void) => Dependency,
8
- ): <Value>(this: void, initial: Value, equals?: Equality<Value>) => Ref<Value> {
8
+ ): {
9
+ create<Value>(this: void, initial: Value, equals?: Equality<Value>): Ref<Value>;
10
+ owns(this: void, value: unknown): boolean;
11
+ guard<Value>(this: void, signal: Ref<Value>, before: (this: void, next: Value) => void):
12
+ { peek(this: void): Value; detach(this: void): void } | undefined;
13
+ } {
9
14
  class Signal<Value> implements Ref<Value> {
10
15
  private readonly observers = makeDependency();
11
16
 
@@ -24,7 +29,35 @@ export function createSignalFactory<Dependency>(
24
29
  this.current = next;
25
30
  notify(this.observers);
26
31
  }
32
+
33
+ guard(before: (this: void, next: Value) => void) {
34
+ if (Object.getOwnPropertyDescriptor(this, "value") !== undefined) return undefined;
35
+ Object.defineProperty(this, "value", {
36
+ configurable: true,
37
+ get: () => {
38
+ track(this.observers);
39
+ return this.current;
40
+ },
41
+ set: (next: Value) => {
42
+ const { current, equals } = this;
43
+ if (equals === true) {
44
+ if (next === current) return;
45
+ } else if (equals !== false && equals(current, next)) return;
46
+ before(next);
47
+ this.current = next;
48
+ notify(this.observers);
49
+ },
50
+ });
51
+ return {
52
+ peek: () => this.current,
53
+ detach: () => { delete (this as { value?: Value }).value; },
54
+ };
55
+ }
27
56
  }
28
57
 
29
- return (initial, equals) => new Signal(initial, equals);
58
+ return {
59
+ create: (initial, equals) => new Signal(initial, equals),
60
+ owns: value => value instanceof Signal,
61
+ guard: (signal, before) => signal instanceof Signal ? signal.guard(before) : undefined,
62
+ };
30
63
  }
@@ -1,6 +1,6 @@
1
1
  import type { MediaStyleVariant, NativeStyle } from "./elements";
2
2
  import { mergeCssTokens } from "./css-tokens";
3
- import { ownedArray, type OwnedArray, type OwnedReadonlyArray, type OwnedRecord } from "./owned-collections";
3
+ import { ownedArray, type OwnedArray, type OwnedLuaArray, type OwnedReadonlyArray, type OwnedRecord } from "./owned-collections";
4
4
  import type { StateStyleVariant } from "./style-states";
5
5
 
6
6
  export interface StyleClass extends NativeStyle {
@@ -8,6 +8,27 @@ export interface StyleClass extends NativeStyle {
8
8
  }
9
9
 
10
10
  export type ClassNames = string | StyleClass | readonly (string | StyleClass)[];
11
+ export type ClassValue = string | StyleClass | boolean | null | undefined | readonly ClassValue[];
12
+
13
+ function appendClasses(values: readonly ClassValue[], output: OwnedArray<string | StyleClass>) {
14
+ // Lua arrays can have missing slots. Enumerate present indices and sort them
15
+ // to preserve argument order across both the web and native runtimes.
16
+ const entries = Object.entries(values as OwnedLuaArray<ClassValue>);
17
+ entries.sort(([left], [right]) => Number(left) - Number(right));
18
+ for (const [, value] of entries) {
19
+ if (typeof value === "string" && value !== "") output.push(value);
20
+ if (typeof value !== "object" || value === null) continue;
21
+ if ("className" in value) output.push(value);
22
+ else appendClasses(value, output);
23
+ }
24
+ }
25
+
26
+ /** Compose ordered class names and generated styles, skipping empty conditions. */
27
+ export function clsx(this: void, ...values: readonly ClassValue[]): readonly (string | StyleClass)[] {
28
+ const output = ownedArray<string | StyleClass>();
29
+ appendClasses(values, output);
30
+ return output;
31
+ }
11
32
 
12
33
  export function resolveStyleClasses(this: void, classes: Exclude<ClassNames, string>, inline?: NativeStyle) {
13
34
  const list: readonly (string | StyleClass)[] = Array.isArray(classes) ? classes : [classes as StyleClass];