@overmvp/kumi 0.3.0 → 0.5.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 (89) hide show
  1. package/animation/index.ts +4 -0
  2. package/animation/motion-policy.ts +20 -0
  3. package/animation/slide.ts +61 -0
  4. package/animation/spring.ts +75 -0
  5. package/animation/staggered-reveal.ts +34 -0
  6. package/builder/css-gradients.mjs +74 -0
  7. package/builder/css-mask-assets.mjs +52 -0
  8. package/builder/css-mask-assets.test.mjs +31 -0
  9. package/builder/css-v1.mjs +73 -22
  10. package/builder/css-v1.test.mjs +42 -2
  11. package/builder/module-declarations.mjs +2 -2
  12. package/builder/module-declarations.test.mjs +4 -2
  13. package/builder/src/compiler.rs +25 -0
  14. package/builder/src/lua_upvalues.rs +641 -0
  15. package/builder/src/main.rs +1 -0
  16. package/builder/style-modules.mjs +21 -3
  17. package/builder/style-modules.test.mjs +24 -0
  18. package/builder/style-states.mjs +6 -4
  19. package/package.json +1 -1
  20. package/router/index.ts +1 -0
  21. package/router/link.tsx +32 -0
  22. package/router/router-view.ts +5 -3
  23. package/scripts/addon-build.mjs +17 -2
  24. package/scripts/addon-project.mjs +22 -11
  25. package/scripts/kumi-cli.mjs +0 -0
  26. package/src/bindings.ts +10 -4
  27. package/src/context.ts +31 -7
  28. package/src/css-tokens.ts +11 -2
  29. package/src/css-v1.ts +3 -0
  30. package/src/elements.ts +20 -1
  31. package/src/flex-layout.ts +26 -5
  32. package/src/frame-scheduler.ts +3 -1
  33. package/src/index.ts +2 -2
  34. package/src/keyed-list.ts +9 -6
  35. package/src/module-ui.ts +22 -2
  36. package/src/module.ts +26 -7
  37. package/src/reactivity.ts +14 -1
  38. package/src/style-classes.ts +22 -1
  39. package/src/style-states.ts +13 -6
  40. package/state/setup-store.ts +3 -3
  41. package/templates/addon/.agents/skills/kumi-ui/SKILL.md +1 -1
  42. package/templates/addon/.claude/skills/kumi-ui/SKILL.md +1 -1
  43. package/templates/addon/AGENTS.md +1 -1
  44. package/templates/addon/kumi.config.ts +17 -17
  45. package/templates/addon/src/app/app.module.ts +3 -5
  46. package/templates/addon/src/app/layout/{AppWindow.module.scss → AppWindow.module.css} +10 -12
  47. package/templates/addon/src/modules/greeting/greeting.module.ts +2 -2
  48. package/templates/addon/src/modules/greeting/ui/{Greeting.module.scss → Greeting.module.css} +9 -11
  49. package/templates/addon/src/modules/playtime/playtime.module.ts +3 -5
  50. package/templates/addon/src/modules/playtime/ui/{Playtime.module.scss → Playtime.module.css} +3 -5
  51. package/templates/addon/src/shared/styles/tokens.css +13 -0
  52. package/templates/addon/src/shared/ui/{Controls.module.scss → Controls.module.css} +18 -20
  53. package/utils/format.ts +13 -0
  54. package/utils/index.ts +1 -1
  55. package/wow/action-button.ts +26 -1
  56. package/wow/addon-manifest.ts +2 -0
  57. package/wow/animation.ts +19 -18
  58. package/wow/app-ui.ts +150 -31
  59. package/wow/aura-container.ts +132 -38
  60. package/wow/aura-countdown.ts +19 -3
  61. package/wow/aura-follower.ts +32 -0
  62. package/wow/aura-view.ts +49 -0
  63. package/wow/css-background-image.ts +75 -0
  64. package/wow/css-box.ts +14 -9
  65. package/wow/css-image-mask.ts +32 -0
  66. package/wow/css-surfaces.ts +88 -35
  67. package/wow/element-events.ts +33 -13
  68. package/wow/frames.ts +2 -0
  69. package/wow/heal-prediction.ts +2 -4
  70. package/wow/hooks.ts +17 -0
  71. package/wow/hotkeys.ts +221 -0
  72. package/wow/index.ts +11 -6
  73. package/wow/initial-view.ts +99 -0
  74. package/wow/layout-view.ts +19 -10
  75. package/wow/module-replacements.ts +103 -0
  76. package/wow/native.ts +1 -0
  77. package/wow/pixel.ts +25 -0
  78. package/wow/pointer-click.ts +35 -0
  79. package/wow/protected-view.ts +49 -13
  80. package/wow/rounded-texture.ts +9 -4
  81. package/wow/scroll-view.ts +5 -4
  82. package/wow/state-paint.ts +5 -14
  83. package/wow/status-bar.ts +65 -0
  84. package/wow/texture-fill.ts +10 -0
  85. package/wow/unit-button.ts +25 -4
  86. package/wow/unit-cast.ts +6 -4
  87. package/wow/view-nodes.ts +11 -4
  88. package/wow/view.ts +387 -278
  89. package/templates/addon/src/shared/styles/_tokens.scss +0 -12
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";
@@ -226,7 +227,8 @@ interface MapRow<Item, View> {
226
227
 
227
228
  function mountMapRow<Item, Key extends ElementKey, View>(key: Key, initial: MapInput<Item>,
228
229
  render: (this: void, item: Item, index: number, key: Key) => UIElement,
229
- 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>> {
230
232
  const scope = parent.fork();
231
233
  const input = ref(initial);
232
234
  let mounted: Row<View> | undefined;
@@ -235,10 +237,10 @@ function mountMapRow<Item, Key extends ElementKey, View>(key: Key, initial: MapI
235
237
  const subscription = scope.watch(() => {
236
238
  const { item, index } = input.value;
237
239
  const candidate = scope.fork();
238
- const result = withReactiveScope(candidate, () => {
240
+ const result = withContexts(contexts, () => withReactiveScope(candidate, () => {
239
241
  const node = render(item, index, key);
240
242
  return node.key === key ? node : { ...node as OwnedRecord<UIElement>, key };
241
- });
243
+ }));
242
244
  return { candidate, result };
243
245
  }, ({ candidate, result }) => {
244
246
  if (!result.ok) {
@@ -286,7 +288,7 @@ function mountMapRow<Item, Key extends ElementKey, View>(key: Key, initial: MapI
286
288
  function mountMap<Item, Key extends ElementKey, View>(read: (this: void) => readonly Item[],
287
289
  keyBy: (this: void, item: Item, index: number) => Key,
288
290
  render: (this: void, item: Item, index: number, key: Key) => UIElement,
289
- usesIndex: boolean, scope: RuntimeScope, host: ListHost<View>): Failure | undefined {
291
+ usesIndex: boolean, scope: RuntimeScope, host: ListHost<View>, contexts: ReturnType<typeof captureContexts>): Failure | undefined {
290
292
  let rows = new Map<Key, MapRow<Item, View>>() as OwnedMap<Key, MapRow<Item, View>>;
291
293
  let orderPending = false;
292
294
 
@@ -326,7 +328,7 @@ function mountMap<Item, Key extends ElementKey, View>(read: (this: void) => read
326
328
  for (const [key, input] of inputs) {
327
329
  let row = rows.get(key);
328
330
  if (!row) {
329
- const mounted = mountMapRow(key, input, render, scope, host, reorder);
331
+ const mounted = mountMapRow(key, input, render, scope, host, reorder, contexts);
330
332
  if (!mounted.ok) {
331
333
  for (const staged of created) staged.dispose();
332
334
  return mounted;
@@ -362,5 +364,6 @@ function mountMap<Item, Key extends ElementKey, View>(read: (this: void) => read
362
364
  export function jsxMap<Item, Key extends ElementKey>(this: void, read: (this: void) => readonly Item[],
363
365
  keyBy: (this: void, item: Item, index: number) => Key,
364
366
  render: (this: void, item: Item, index: number, key: Key) => UIElement, usesIndex = false): Element<"keyedList"> {
365
- 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: [] };
366
369
  }
package/src/module-ui.ts CHANGED
@@ -16,6 +16,16 @@ export interface ModuleView {
16
16
  readonly component: ViewComponent;
17
17
  /** The frame strata of the view's root, `"MEDIUM"` by default. */
18
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;
19
29
  }
20
30
 
21
31
  /** A page a module adds to the addon window while it is active. */
@@ -38,6 +48,10 @@ export interface ModuleWindow {
38
48
  readonly height: number;
39
49
  /** The page to open first. Defaults to the first file route. */
40
50
  readonly start?: string;
51
+ /** Build the first unprotected window across frames, then reveal it once layout is ready. */
52
+ readonly mount?: "staged";
53
+ /** Hide the window in combat and restore its previous page when combat ends. */
54
+ readonly suspendInCombat?: true;
41
55
  /** `"DIALOG"` by default. */
42
56
  readonly strata?: string;
43
57
  }
@@ -45,6 +59,7 @@ export interface ModuleWindow {
45
59
  /** UI a module contributes. Kumi mounts and removes it with the module. */
46
60
  export interface ModuleUi {
47
61
  readonly views?: readonly (ViewComponent | ModuleView)[];
62
+ readonly replaces?: readonly ModuleReplacement[];
48
63
  readonly extensions?: Readonly<Record<string, ExtensionComponent | readonly ExtensionComponent[]>>;
49
64
  readonly pages?: readonly ModulePage[];
50
65
  readonly window?: ModuleWindow;
@@ -97,6 +112,12 @@ export function modulePages(this: void): ReadonlyRef<readonly ModulePage[]> {
97
112
 
98
113
  /** @internal Register a module's extensions and pages, then let the platform mount its views and window. */
99
114
  export function mountModuleUi(this: void, id: string, ui: ModuleUi, scope: RuntimeScope): Result<void> {
115
+ const views = ui.views as OwnedReadonlyArray<ViewComponent | ModuleView> | undefined;
116
+ const replaces = ui.replaces as OwnedReadonlyArray<ModuleReplacement> | undefined;
117
+ const hasViews = views !== undefined && views.length > 0;
118
+ const hasReplacements = replaces !== undefined && replaces.length > 0;
119
+ if (hasReplacements && !hasViews) return fail("Module " + id + ": replaces requires at least one view");
120
+
100
121
  const extensions = ui.extensions;
101
122
  if (extensions !== undefined) {
102
123
  for (const name of Object.keys(extensions)) {
@@ -126,8 +147,7 @@ export function mountModuleUi(this: void, id: string, ui: ModuleUi, scope: Runti
126
147
  });
127
148
  if (!removed.ok) return removed;
128
149
  }
129
- const views = ui.views as OwnedReadonlyArray<ViewComponent | ModuleView> | undefined;
130
- if ((views === undefined || views.length === 0) && ui.window === undefined) return ok(undefined);
150
+ if (!hasViews && ui.window === undefined) return ok(undefined);
131
151
  if (platform === undefined) return fail("Module " + id + " declares views or a window. Start the addon with startAddon.");
132
152
  return platform(id, ui, scope);
133
153
  }
package/src/module.ts CHANGED
@@ -5,7 +5,7 @@ import type { RuntimeScope } from "./runtime";
5
5
  import { createFeatureLifecycle, type FeatureLifecycle } from "./feature-scope";
6
6
  import type { OwnedReadonlyArray } from "./owned-collections";
7
7
  import { createStoreHost, openModuleStores, type AnyStoreFactory, type StoreHost } from "../state/setup-store";
8
- import { mountModuleUi, type ModuleUi } from "./module-ui";
8
+ import { mountModuleUi, type ModuleReplacement, type ModuleUi } from "./module-ui";
9
9
 
10
10
  export interface ModuleContext<Services extends object> {
11
11
  readonly services: Readonly<Services>;
@@ -30,7 +30,8 @@ declare const moduleExports: unique symbol;
30
30
  type DecoratedModule<Exports extends object> = abstract new () => { readonly [moduleExports]: Readonly<Exports> };
31
31
  type ModuleDependency<Exports extends object> = ModuleDeclaration<Exports> | DecoratedModule<Exports>;
32
32
 
33
- export declare abstract class ModuleType<Definition extends { readonly exports: ServiceExports }> {
33
+ export declare abstract class ModuleType<Definition extends { readonly exports: ServiceExports } =
34
+ { readonly exports: Record<never, never> }> {
34
35
  readonly [moduleExports]: PublicServices<Definition["exports"]>;
35
36
  }
36
37
 
@@ -74,14 +75,23 @@ export interface Module<Exports extends object> {
74
75
  readonly exports: Readonly<Exports>;
75
76
  }
76
77
 
77
- interface DeclarativeModuleOptions<Providers extends readonly ProviderDeclaration[], Exports extends ServiceExports,
78
- InferConstructor extends boolean = false> extends ModuleUi {
78
+ /** Public metadata for a module declared with @Module. */
79
+ export interface ModuleMetadata extends ModuleUi {
80
+ /** Stable, unique identifier within the addon's module graph. */
79
81
  readonly id: string;
80
82
  readonly imports?: readonly ModuleDependency<object>[];
81
83
  readonly feature?: boolean;
82
- readonly providers: Providers & NoInfer<CheckedProviders<Providers, InferConstructor>>;
84
+ /** Services owned by the module. Use an empty array if it owns none. */
85
+ readonly providers: readonly ProviderDeclaration[];
83
86
  /** Stores this module owns. They open when the module activates, and their setup can inject the module's services. */
84
87
  readonly stores?: readonly AnyStoreFactory[];
88
+ /** Public service tokens. Use an empty object for a module without public services. */
89
+ readonly exports: ServiceExports;
90
+ }
91
+
92
+ interface DeclarativeModuleOptions<Providers extends readonly ProviderDeclaration[], Exports extends ServiceExports,
93
+ InferConstructor extends boolean = false> extends ModuleMetadata {
94
+ readonly providers: Providers & NoInfer<CheckedProviders<Providers, InferConstructor>>;
85
95
  readonly exports: Exports;
86
96
  }
87
97
 
@@ -195,8 +205,11 @@ function createServiceModule<Exports extends ServiceExports>(id: string, imports
195
205
  }
196
206
  const declarations = providers as OwnedReadonlyArray<ProviderDeclaration>;
197
207
  const owned = stores as OwnedReadonlyArray<AnyStoreFactory> | undefined;
208
+ const replacements = ui?.replaces as OwnedReadonlyArray<ModuleReplacement> | undefined;
209
+ const hasReplacements = replacements !== undefined && replacements.length > 0;
198
210
  const hasStores = owned !== undefined && owned.length > 0;
199
- const hasUi = ui !== undefined && (ui.views !== undefined || ui.extensions !== undefined || ui.pages !== undefined || ui.window !== undefined);
211
+ const hasUi = ui !== undefined && (ui.views !== undefined || ui.replaces !== undefined
212
+ || ui.extensions !== undefined || ui.pages !== undefined || ui.window !== undefined);
200
213
  // Stores open after the providers, and UI mounts after the stores it reads.
201
214
  const ready = !hasStores && !hasUi ? undefined : (inject: (this: void, token: ServiceToken<object>) => Result<object>) => {
202
215
  if (scope === undefined || hasStores && storeHost === undefined) return fail("Module " + id + " needs a module container");
@@ -206,7 +219,13 @@ function createServiceModule<Exports extends ServiceExports>(id: string, imports
206
219
  const opened = openModuleStores(storeHost, id, owned, owning.value, inject);
207
220
  if (!opened.ok) return opened;
208
221
  }
209
- return ui === undefined ? ok(undefined) : mountModuleUi(id, ui, owning.value);
222
+ if (ui === undefined) return ok(undefined);
223
+ if (!hasReplacements) return mountModuleUi(id, ui, owning.value);
224
+ if (lifecycle !== undefined) {
225
+ lifecycle.add({ enable: active => mountModuleUi(id, ui, active) });
226
+ return ok(undefined);
227
+ }
228
+ return mountModuleUi(id, ui, owning.value.fork());
210
229
  };
211
230
  const services = resolveProviders(id, declarations.map(provider => createServiceProvider(provider)), exports, imported,
212
231
  hostInputs(resolve, scope), scope, lifecycle, ready);
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;
@@ -175,6 +175,19 @@ export function setupRefKind(value: unknown): "signal" | "computed" | undefined
175
175
  return undefined;
176
176
  }
177
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
+
178
191
  function cleanupFailure(value: unknown): Failure | undefined {
179
192
  if (value == null || typeof value !== "object") return;
180
193
  const candidate = value as Partial<Failure>;
@@ -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];
@@ -4,12 +4,18 @@ import type { OwnedArray, OwnedReadonlyArray } from "./owned-collections";
4
4
 
5
5
  export type StyleState = "hover" | "active" | "focus" | "disabled" | "checked";
6
6
 
7
+ export interface CssLinearGradient {
8
+ readonly axis: "HORIZONTAL" | "VERTICAL";
9
+ readonly min: string;
10
+ readonly max: string;
11
+ }
12
+
7
13
  export interface StatePaint {
8
14
  color?: string;
9
15
  backgroundColor?: string;
10
16
  borderColor?: string;
11
17
  opacity?: number;
12
- backgroundImage?: Readonly<{ path: string } | { atlas: string }>;
18
+ backgroundImage?: Readonly<{ path: string } | { atlas: string } | { gradient: CssLinearGradient }>;
13
19
  styleTokens?: readonly CssTokenRecipe[];
14
20
  }
15
21
 
@@ -51,12 +57,13 @@ function matches(required: number, active: number) {
51
57
  return true;
52
58
  }
53
59
 
54
- function sameImage(left: StatePaint["backgroundImage"], right: StatePaint["backgroundImage"]) {
60
+ export function sameBackgroundImage(left: StatePaint["backgroundImage"], right: StatePaint["backgroundImage"]) {
55
61
  if (left === right) return true;
56
62
  if (left === undefined || right === undefined) return false;
57
- return "path" in left
58
- ? "path" in right && left.path === right.path
59
- : "atlas" in right && left.atlas === right.atlas;
63
+ if ("path" in left) return "path" in right && left.path === right.path;
64
+ if ("atlas" in left) return "atlas" in right && left.atlas === right.atlas;
65
+ return "gradient" in right && left.gradient.axis === right.gradient.axis
66
+ && left.gradient.min === right.gradient.min && left.gradient.max === right.gradient.max;
60
67
  }
61
68
 
62
69
  function sameTokens(left: StatePaint["styleTokens"], right: StatePaint["styleTokens"]) {
@@ -100,7 +107,7 @@ export function prepareStyleStates(this: void, base: Readonly<StatePaint>, varia
100
107
  }
101
108
  for (const paint of snapshots) {
102
109
  if (paint.color === color && paint.backgroundColor === backgroundColor && paint.borderColor === borderColor && paint.opacity === opacity
103
- && sameImage(paint.backgroundImage, backgroundImage) && sameTokens(paint.styleTokens, styleTokens)) return paint;
110
+ && sameBackgroundImage(paint.backgroundImage, backgroundImage) && sameTokens(paint.styleTokens, styleTokens)) return paint;
104
111
  }
105
112
  const paint: StatePaint = {};
106
113
  if (color !== undefined) paint.color = color;
@@ -1,6 +1,6 @@
1
1
  import { direct, fail, formatFailure, ok, type Result } from "../src/result";
2
2
  import { withReactiveScope } from "../src/reactive-scope";
3
- import { setupRefKind, type ComputedRef, type ReadonlyRef, type Ref, type SignalRef } from "../src/reactivity";
3
+ import { registerRefView, setupRefKind, type ComputedRef, type ReadonlyRef, type Ref, type SignalRef } from "../src/reactivity";
4
4
  import type { RuntimeScope } from "../src/runtime";
5
5
  import type { ServiceToken } from "../src/providers";
6
6
  import { ownedArray, ownedMap, ownedWeakMap, type OwnedMap, type OwnedReadonlyArray, type OwnedWeakMap } from "../src/owned-collections";
@@ -120,7 +120,7 @@ let activeInject: Inject | undefined;
120
120
 
121
121
  /** Expose a ref read-only. Store actions keep writing the ref you pass in. */
122
122
  export function readonly<T>(this: void, source: Ref<T>): StoreReadonly<T> {
123
- return new ReadonlyView(source) as unknown as StoreReadonly<T>;
123
+ return registerRefView(new ReadonlyView(source)) as unknown as StoreReadonly<T>;
124
124
  }
125
125
 
126
126
  /**
@@ -154,7 +154,7 @@ function createStoreFields(id: string, source: Record<string, unknown>) {
154
154
  cells[key] = cell;
155
155
  accessors[key] = { get: () => cell.value, set: next => { cell.value = next; }, enumerable: true };
156
156
  } else if (kind === "computed") {
157
- const cell = new StoreComputed(value as ComputedRef<unknown>, id + "." + key);
157
+ const cell = registerRefView(new StoreComputed(value as ComputedRef<unknown>, id + "." + key));
158
158
  refs[key] = cell;
159
159
  accessors[key] = { get: () => cell.value, enumerable: true };
160
160
  } else if (value instanceof ReadonlyView) {
@@ -47,7 +47,7 @@ export function LootPanel() {
47
47
 
48
48
  ## Styles
49
49
 
50
- `ui/Loot.module.scss` next to the components; import from `@kumi/styles/modules/loot/ui/Loot`. Use tokens from `src/shared/styles/_tokens.scss`. Run `npm run check` once after adding a stylesheet. Supported properties: flex layout, sizes, margin, padding, position, colors, borders (`border`, `border-width`, `border-color`, `border-radius` 0-9/11/12px), font size and weight, states `:hover :active :focus :disabled :checked`.
50
+ `ui/Loot.module.css` next to the components; import from `@kumi/styles/modules/loot/ui/Loot`. Define shared CSS variables in `src/shared/styles/tokens.css` and use `var(--…)` in modules and inline JSX colors. Run `npm run check` once after adding a stylesheet. Supported properties: flex layout, sizes, margin, padding, position, colors, borders (`border`, `border-width`, `border-color`, `border-radius` 0-9/11/12px), font size and weight, states `:hover :active :focus :disabled :checked`.
51
51
 
52
52
  ## Lists
53
53
 
@@ -47,7 +47,7 @@ export function LootPanel() {
47
47
 
48
48
  ## Styles
49
49
 
50
- `ui/Loot.module.scss` next to the components; import from `@kumi/styles/modules/loot/ui/Loot`. Use tokens from `src/shared/styles/_tokens.scss`. Run `npm run check` once after adding a stylesheet. Supported properties: flex layout, sizes, margin, padding, position, colors, borders (`border`, `border-width`, `border-color`, `border-radius` 0-9/11/12px), font size and weight, states `:hover :active :focus :disabled :checked`.
50
+ `ui/Loot.module.css` next to the components; import from `@kumi/styles/modules/loot/ui/Loot`. Define shared CSS variables in `src/shared/styles/tokens.css` and use `var(--…)` in modules and inline JSX colors. Run `npm run check` once after adding a stylesheet. Supported properties: flex layout, sizes, margin, padding, position, colors, borders (`border`, `border-width`, `border-color`, `border-radius` 0-9/11/12px), font size and weight, states `:hover :active :focus :disabled :checked`.
51
51
 
52
52
  ## Lists
53
53
 
@@ -21,7 +21,7 @@ Dependencies go one way: `ui/widgets → model → services → api → @kumi/wo
21
21
  - Lists in JSX: `{items.value.map(item => <Row key={item.id} ... />)}` over a ref, so the list updates.
22
22
  - Stores: `ref` for state, `readonly(ref)` for state only actions change, `computed` for derived state, functions for actions. Save fields with `persist: { pick: [...] }`. Change several saved fields with `batch`. Every `useX()` returns the same store.
23
23
  - A store used by several features lives in the feature that owns its data. Other features import that feature's module.
24
- - Styles live in `.module.scss` next to the components, imported from `@kumi/styles/<path>`. Colors and sizes come from `src/shared/styles/_tokens.scss`. No sizes or colors in TSX.
24
+ - Styles live in `.module.css` next to the components, imported from `@kumi/styles/<path>`. Define shared CSS variables in `src/shared/styles/tokens.css` and reference them with `var(--…)`.
25
25
  - WoW events: `useEvent` in stores and components, `@OnEvent` in services. Timers: `useNow`. Combat: `useCombat`. Slash commands: `useSlashCommand`.
26
26
  - Kumi's compiler: no regular expressions, no circular imports, destructure WoW multiple results in one statement, and write explicit conditions (`count > 0`), because `0` and `""` are true in Lua.
27
27
 
@@ -1,17 +1,17 @@
1
- import type { KumiConfig } from "__KUMI_PACKAGE__/config";
2
-
3
- export default {
4
- addon: {
5
- name: "__ADDON_NAME__",
6
- title: "__ADDON_NAME__",
7
- notes: "A Kumi addon",
8
- savedVariables: "__ADDON_DB__",
9
- },
10
- plugins: {
11
- playtime: {
12
- module: "src/modules/playtime/playtime.module.ts",
13
- title: "Playtime",
14
- notes: "Shows how long you have played this session",
15
- },
16
- },
17
- } satisfies KumiConfig;
1
+ import type { KumiConfig } from "__KUMI_PACKAGE__/config";
2
+
3
+ export default {
4
+ addon: {
5
+ name: "__ADDON_NAME__",
6
+ title: "__ADDON_NAME__",
7
+ notes: "A Kumi addon",
8
+ savedVariables: "__ADDON_DB__",
9
+ },
10
+ plugins: {
11
+ playtime: {
12
+ module: "src/modules/playtime/playtime.module.ts",
13
+ title: "Playtime",
14
+ notes: "Shows how long you have played this session",
15
+ },
16
+ },
17
+ } satisfies KumiConfig;
@@ -5,14 +5,12 @@ import { useCommands } from "./commands.store";
5
5
  import { AppWindow } from "./layout/AppWindow";
6
6
 
7
7
  // The root module: the core features, the addon window and app-wide stores.
8
- const metadata = {
8
+ @Module({
9
9
  id: "app",
10
10
  imports: [GreetingModule],
11
11
  providers: [],
12
12
  stores: [useCommands],
13
13
  window: { routes: router, layout: AppWindow, width: 460, height: 360, start: "/home" },
14
14
  exports: {},
15
- } as const;
16
-
17
- @Module(metadata)
18
- export class AppModule extends ModuleType<typeof metadata> {}
15
+ })
16
+ export class AppModule extends ModuleType {}
@@ -1,12 +1,10 @@
1
- @use "../../shared/styles/tokens" as *;
2
-
3
1
  .window {
4
2
  display: flex;
5
3
  flex-direction: column;
6
4
  width: 460px;
7
5
  height: 360px;
8
- background-color: $panel;
9
- border: 1px solid $line;
6
+ background-color: var(--color-panel);
7
+ border: 1px solid var(--color-line);
10
8
  border-radius: 8px;
11
9
  }
12
10
 
@@ -17,7 +15,7 @@
17
15
  height: 36px;
18
16
  padding: 0 12px 0 16px;
19
17
  margin: 1px 1px 0;
20
- background-color: $header;
18
+ background-color: var(--color-header);
21
19
  border-radius: 6px;
22
20
  }
23
21
 
@@ -25,7 +23,7 @@
25
23
  flex-grow: 1;
26
24
  font-size: 15px;
27
25
  text-align: left;
28
- color: $gold;
26
+ color: var(--color-gold);
29
27
  }
30
28
 
31
29
  .close {
@@ -33,16 +31,16 @@
33
31
  min-width: 26px;
34
32
  height: 26px;
35
33
  border-radius: 4px;
36
- background-color: $header;
34
+ background-color: var(--color-header);
37
35
  }
38
36
 
39
- .close:hover { background-color: $raised; }
37
+ .close:hover { background-color: var(--color-raised); }
40
38
 
41
39
  .tabs {
42
40
  display: flex;
43
41
  gap: 6px;
44
42
  padding: 8px 16px 0;
45
- border-bottom: 1px solid $line;
43
+ border-bottom: 1px solid var(--color-line);
46
44
  }
47
45
 
48
46
  .content {
@@ -69,7 +67,7 @@
69
67
  align-items: center;
70
68
  gap: 12px;
71
69
  height: 44px;
72
- border-bottom: 1px solid $line;
70
+ border-bottom: 1px solid var(--color-line);
73
71
  }
74
72
 
75
73
  .listText {
@@ -82,11 +80,11 @@
82
80
  .listTitle {
83
81
  font-size: 14px;
84
82
  text-align: left;
85
- color: $text;
83
+ color: var(--color-text);
86
84
  }
87
85
 
88
86
  .listNote {
89
87
  font-size: 12px;
90
88
  text-align: left;
91
- color: $muted;
89
+ color: var(--color-muted);
92
90
  }
@@ -1,4 +1,4 @@
1
- import { Module, ModuleType } from "@kumi/core";
1
+ import { Module, ModuleType, type ModuleMetadata } from "@kumi/core";
2
2
  import { useGreetingStore } from "./model/greeting.store";
3
3
  import { GreetingService } from "./services/greeting.service";
4
4
  import { GreetingHud } from "./widgets/GreetingHud";
@@ -12,7 +12,7 @@ const metadata = {
12
12
  stores: [useGreetingStore],
13
13
  views: [GreetingHud],
14
14
  exports: { greeting: GreetingService },
15
- } as const;
15
+ } as const satisfies ModuleMetadata;
16
16
 
17
17
  @Module(metadata)
18
18
  export class GreetingModule extends ModuleType<typeof metadata> {}
@@ -1,29 +1,27 @@
1
- @use "../../../shared/styles/tokens" as *;
2
-
3
1
  .card {
4
2
  display: flex;
5
3
  flex-direction: column;
6
4
  gap: 6px;
7
5
  }
8
6
 
9
- // Room for two lines, so the panel keeps its height when the text gets shorter.
7
+ /* Room for two lines, so the panel keeps its height when the text gets shorter. */
10
8
  .message {
11
9
  height: 36px;
12
10
  font-size: 15px;
13
11
  text-align: left;
14
- color: $text;
12
+ color: var(--color-text);
15
13
  }
16
14
 
17
15
  .money {
18
16
  font-size: 13px;
19
17
  text-align: left;
20
- color: $gold;
18
+ color: var(--color-gold);
21
19
  }
22
20
 
23
21
  .notice {
24
22
  font-size: 12px;
25
23
  text-align: left;
26
- color: $muted;
24
+ color: var(--color-muted);
27
25
  }
28
26
 
29
27
  .hud {
@@ -32,8 +30,8 @@
32
30
  gap: 10px;
33
31
  width: 280px;
34
32
  padding: 10px 12px 12px;
35
- background-color: $panel;
36
- border: 1px solid $line;
33
+ background-color: var(--color-panel);
34
+ border: 1px solid var(--color-line);
37
35
  border-radius: 8px;
38
36
  }
39
37
 
@@ -48,7 +46,7 @@
48
46
  flex-grow: 1;
49
47
  font-size: 14px;
50
48
  text-align: left;
51
- color: $muted;
49
+ color: var(--color-muted);
52
50
  }
53
51
 
54
52
  .iconButton {
@@ -88,13 +86,13 @@
88
86
  width: 120px;
89
87
  font-size: 14px;
90
88
  text-align: left;
91
- color: $text;
89
+ color: var(--color-text);
92
90
  }
93
91
 
94
92
  .hint {
95
93
  font-size: 13px;
96
94
  text-align: left;
97
- color: $muted;
95
+ color: var(--color-muted);
98
96
  }
99
97
 
100
98
  .overview {
@@ -5,14 +5,12 @@ import { PlaytimeBadge } from "./ui/PlaytimeBadge";
5
5
  import { PlaytimePage } from "./widgets/PlaytimePage";
6
6
 
7
7
  // A plugin: kumi.config.ts lists this module under plugins, so it builds as its own addon.
8
- const metadata = {
8
+ @Module({
9
9
  id: "playtime",
10
10
  providers: [PlaytimeService],
11
11
  stores: [usePlaytimeStore],
12
12
  extensions: { "hud.footer": PlaytimeBadge },
13
13
  pages: [{ path: "/playtime", title: "Playtime", component: PlaytimePage, order: 20 }],
14
14
  exports: {},
15
- } as const;
16
-
17
- @Module(metadata)
18
- export class PlaytimeModule extends ModuleType<typeof metadata> {}
15
+ })
16
+ export class PlaytimeModule extends ModuleType {}
@@ -1,8 +1,6 @@
1
- @use "../../../shared/styles/tokens" as *;
2
-
3
1
  .badge {
4
2
  font-size: 13px;
5
- color: $muted;
3
+ color: var(--color-muted);
6
4
  }
7
5
 
8
6
  .page {
@@ -15,11 +13,11 @@
15
13
  .big {
16
14
  font-size: 28px;
17
15
  text-align: left;
18
- color: $gold;
16
+ color: var(--color-gold);
19
17
  }
20
18
 
21
19
  .note {
22
20
  font-size: 13px;
23
21
  text-align: left;
24
- color: $muted;
22
+ color: var(--color-muted);
25
23
  }
@@ -0,0 +1,13 @@
1
+ :root {
2
+ --color-panel: #101721;
3
+ --color-header: #17212e;
4
+ --color-control: #1b2533;
5
+ --color-raised: #263345;
6
+ --color-line: #405168;
7
+ --color-edge: #536682;
8
+ --color-text: #edf2fb;
9
+ --color-muted: #a7bdd3;
10
+ --color-gold: #efbf68;
11
+ --color-gold-dark: #936222;
12
+ --color-selected: #483921;
13
+ }