@overmvp/kumi 0.3.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 (66) 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/src/compiler.rs +25 -0
  12. package/builder/src/lua_upvalues.rs +641 -0
  13. package/builder/src/main.rs +1 -0
  14. package/builder/style-modules.mjs +21 -3
  15. package/builder/style-modules.test.mjs +24 -0
  16. package/builder/style-states.mjs +6 -4
  17. package/package.json +1 -1
  18. package/router/index.ts +1 -0
  19. package/router/link.tsx +32 -0
  20. package/scripts/addon-build.mjs +15 -2
  21. package/scripts/addon-project.mjs +22 -11
  22. package/src/bindings.ts +10 -4
  23. package/src/context.ts +31 -7
  24. package/src/css-tokens.ts +11 -2
  25. package/src/css-v1.ts +3 -0
  26. package/src/elements.ts +9 -0
  27. package/src/flex-layout.ts +26 -5
  28. package/src/frame-scheduler.ts +3 -1
  29. package/src/index.ts +2 -2
  30. package/src/keyed-list.ts +9 -6
  31. package/src/module-ui.ts +18 -2
  32. package/src/module.ts +12 -3
  33. package/src/reactivity.ts +14 -1
  34. package/src/style-classes.ts +22 -1
  35. package/src/style-states.ts +13 -6
  36. package/state/setup-store.ts +3 -3
  37. package/templates/addon/.agents/skills/kumi-ui/SKILL.md +1 -1
  38. package/templates/addon/.claude/skills/kumi-ui/SKILL.md +1 -1
  39. package/templates/addon/AGENTS.md +1 -1
  40. package/templates/addon/kumi.config.ts +17 -17
  41. package/templates/addon/src/app/layout/{AppWindow.module.scss → AppWindow.module.css} +10 -12
  42. package/templates/addon/src/modules/greeting/ui/{Greeting.module.scss → Greeting.module.css} +9 -11
  43. package/templates/addon/src/modules/playtime/ui/{Playtime.module.scss → Playtime.module.css} +3 -5
  44. package/templates/addon/src/shared/styles/tokens.css +13 -0
  45. package/templates/addon/src/shared/ui/{Controls.module.scss → Controls.module.css} +18 -20
  46. package/wow/action-button.ts +26 -1
  47. package/wow/addon-manifest.ts +2 -0
  48. package/wow/animation.ts +3 -14
  49. package/wow/app-ui.ts +19 -10
  50. package/wow/css-background-image.ts +75 -0
  51. package/wow/css-box.ts +7 -5
  52. package/wow/css-image-mask.ts +32 -0
  53. package/wow/css-surfaces.ts +78 -31
  54. package/wow/element-events.ts +33 -13
  55. package/wow/heal-prediction.ts +2 -4
  56. package/wow/index.ts +2 -1
  57. package/wow/layout-view.ts +18 -9
  58. package/wow/module-replacements.ts +103 -0
  59. package/wow/pointer-click.ts +35 -0
  60. package/wow/protected-view.ts +49 -13
  61. package/wow/rounded-texture.ts +9 -4
  62. package/wow/state-paint.ts +5 -14
  63. package/wow/texture-fill.ts +10 -0
  64. package/wow/unit-cast.ts +6 -4
  65. package/wow/view.ts +287 -175
  66. package/templates/addon/src/shared/styles/_tokens.scss +0 -12
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. */
@@ -45,6 +55,7 @@ export interface ModuleWindow {
45
55
  /** UI a module contributes. Kumi mounts and removes it with the module. */
46
56
  export interface ModuleUi {
47
57
  readonly views?: readonly (ViewComponent | ModuleView)[];
58
+ readonly replaces?: readonly ModuleReplacement[];
48
59
  readonly extensions?: Readonly<Record<string, ExtensionComponent | readonly ExtensionComponent[]>>;
49
60
  readonly pages?: readonly ModulePage[];
50
61
  readonly window?: ModuleWindow;
@@ -97,6 +108,12 @@ export function modulePages(this: void): ReadonlyRef<readonly ModulePage[]> {
97
108
 
98
109
  /** @internal Register a module's extensions and pages, then let the platform mount its views and window. */
99
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
+
100
117
  const extensions = ui.extensions;
101
118
  if (extensions !== undefined) {
102
119
  for (const name of Object.keys(extensions)) {
@@ -126,8 +143,7 @@ export function mountModuleUi(this: void, id: string, ui: ModuleUi, scope: Runti
126
143
  });
127
144
  if (!removed.ok) return removed;
128
145
  }
129
- const views = ui.views as OwnedReadonlyArray<ViewComponent | ModuleView> | undefined;
130
- if ((views === undefined || views.length === 0) && ui.window === undefined) return ok(undefined);
146
+ if (!hasViews && ui.window === undefined) return ok(undefined);
131
147
  if (platform === undefined) return fail("Module " + id + " declares views or a window. Start the addon with startAddon.");
132
148
  return platform(id, ui, scope);
133
149
  }
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>;
@@ -195,8 +195,11 @@ function createServiceModule<Exports extends ServiceExports>(id: string, imports
195
195
  }
196
196
  const declarations = providers as OwnedReadonlyArray<ProviderDeclaration>;
197
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;
198
200
  const hasStores = owned !== undefined && owned.length > 0;
199
- const hasUi = ui !== undefined && (ui.views !== undefined || ui.extensions !== undefined || ui.pages !== undefined || ui.window !== undefined);
201
+ const hasUi = ui !== undefined && (ui.views !== undefined || ui.replaces !== undefined
202
+ || ui.extensions !== undefined || ui.pages !== undefined || ui.window !== undefined);
200
203
  // Stores open after the providers, and UI mounts after the stores it reads.
201
204
  const ready = !hasStores && !hasUi ? undefined : (inject: (this: void, token: ServiceToken<object>) => Result<object>) => {
202
205
  if (scope === undefined || hasStores && storeHost === undefined) return fail("Module " + id + " needs a module container");
@@ -206,7 +209,13 @@ function createServiceModule<Exports extends ServiceExports>(id: string, imports
206
209
  const opened = openModuleStores(storeHost, id, owned, owning.value, inject);
207
210
  if (!opened.ok) return opened;
208
211
  }
209
- return ui === undefined ? ok(undefined) : mountModuleUi(id, ui, owning.value);
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());
210
219
  };
211
220
  const services = resolveProviders(id, declarations.map(provider => createServiceProvider(provider)), exports, imported,
212
221
  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;
@@ -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,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 {
@@ -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
+ }
@@ -1,27 +1,25 @@
1
- @use "../styles/tokens" as *;
2
-
3
1
  .button {
4
2
  height: 28px;
5
3
  min-width: 72px;
6
- border: 1px solid $line;
4
+ border: 1px solid var(--color-line);
7
5
  border-radius: 4px;
8
- background-color: $control;
6
+ background-color: var(--color-control);
9
7
  font-size: 14px;
10
- color: $text;
8
+ color: var(--color-text);
11
9
  }
12
10
 
13
- .button:hover { background-color: $raised; }
14
- .button:checked { background-color: $selected; border-color: $gold; }
11
+ .button:hover { background-color: var(--color-raised); }
12
+ .button:checked { background-color: var(--color-selected); border-color: var(--color-gold); }
15
13
  .button:disabled { opacity: 0.55; }
16
14
 
17
15
  .primary {
18
16
  height: 28px;
19
17
  min-width: 96px;
20
- border: 1px solid $gold;
18
+ border: 1px solid var(--color-gold);
21
19
  border-radius: 4px;
22
- background-color: $gold-dark;
20
+ background-color: var(--color-gold-dark);
23
21
  font-size: 14px;
24
- color: $text;
22
+ color: var(--color-text);
25
23
  }
26
24
 
27
25
  .primary:hover { background-color: #ad7528; }
@@ -36,18 +34,18 @@
36
34
  .glyph {
37
35
  width: 16px;
38
36
  height: 16px;
39
- color: $muted;
37
+ color: var(--color-muted);
40
38
  }
41
39
 
42
40
  .switch {
43
41
  width: 46px;
44
42
  height: 22px;
45
- border: 1px solid $edge;
43
+ border: 1px solid var(--color-edge);
46
44
  border-radius: 11px;
47
- background-color: $control;
45
+ background-color: var(--color-control);
48
46
  }
49
47
 
50
- .switch:checked { border-color: $gold; background-color: $selected; }
48
+ .switch:checked { border-color: var(--color-gold); background-color: var(--color-selected); }
51
49
  .switch:disabled { opacity: 0.55; }
52
50
 
53
51
  .knobOff, .knobOn {
@@ -57,8 +55,8 @@
57
55
  height: 16px;
58
56
  }
59
57
 
60
- .knobOff { left: 3px; color: $muted; }
61
- .knobOn { right: 3px; color: $gold; }
58
+ .knobOff { left: 3px; color: var(--color-muted); }
59
+ .knobOn { right: 3px; color: var(--color-gold); }
62
60
 
63
61
  .choice {
64
62
  display: flex;
@@ -72,22 +70,22 @@
72
70
 
73
71
  .track {
74
72
  height: 6px;
75
- background-color: $line;
73
+ background-color: var(--color-line);
76
74
  }
77
75
 
78
76
  .fill {
79
77
  height: 6px;
80
- background-color: $gold;
78
+ background-color: var(--color-gold);
81
79
  }
82
80
 
83
81
  .thumb {
84
82
  width: 16px;
85
83
  height: 16px;
86
- color: $gold;
84
+ color: var(--color-gold);
87
85
  }
88
86
 
89
87
  .sliderCaption {
90
88
  text-align: left;
91
89
  font-size: 13px;
92
- color: $muted;
90
+ color: var(--color-muted);
93
91
  }
@@ -55,10 +55,35 @@ function sameAction(previous: ActionSlot | undefined, next: ActionSlot | undefin
55
55
  return previous?.kind === next?.kind && previous?.id === next?.id;
56
56
  }
57
57
 
58
- export function bindSecureAction(button: Button, scope: RuntimeScope, source: Binding<ActionSlot | undefined>, receive?: Receive) {
58
+ function prepareSecureButton(button: Button) {
59
59
  const target = button as SecureButton;
60
60
  target.SetAttribute("useOnKeyDown", false);
61
61
  button.RegisterForClicks("LeftButtonUp");
62
+ return target;
63
+ }
64
+
65
+ export function bindSecureMacro(button: Button, scope: RuntimeScope, source: Binding<string | undefined>) {
66
+ const target = prepareSecureButton(button);
67
+ let applied: string | undefined;
68
+ let pending: string | undefined;
69
+ const write = createProtectedLayoutUpdate(() => {
70
+ if (applied === pending) return;
71
+ if (pending === undefined) target.SetAttribute("type", undefined);
72
+ target.SetAttribute("macrotext", pending);
73
+ if (applied === undefined && pending !== undefined) target.SetAttribute("type", "macro");
74
+ applied = pending;
75
+ }, { scope, label: "Secure macro button" });
76
+ if (!write.ok) return write;
77
+ return bindValue(scope, source, text => {
78
+ if (isSecret(text)) return;
79
+ pending = typeof text === "string" && text.trim() !== "" ? text : undefined;
80
+ const result = write.value.request();
81
+ if (!result.ok) report(result);
82
+ }, (previous, next) => !isSecret(previous) && !isSecret(next) && previous === next);
83
+ }
84
+
85
+ export function bindSecureAction(button: Button, scope: RuntimeScope, source: Binding<ActionSlot | undefined>, receive?: Receive) {
86
+ const target = prepareSecureButton(button);
62
87
  let applied: ActionSlot | undefined;
63
88
  let pending: ActionSlot | undefined;
64
89
  const protectedWrite = createProtectedLayoutUpdate(() => {
@@ -1,4 +1,5 @@
1
1
  import type { OwnedLuaArray } from "../src/owned-collections";
2
+ import type { StyleVariables } from "../src/style-variables";
2
3
  import { rawField } from "./lua-table";
3
4
 
4
5
  // The compiler binds this to the addon's private table: the second value WoW passes to each addon file.
@@ -18,6 +19,7 @@ export interface AddonManifest {
18
19
  readonly name: string;
19
20
  readonly savedVariables?: string;
20
21
  readonly savedVariablesPerCharacter?: string;
22
+ readonly styleVariables?: StyleVariables;
21
23
  readonly pluginState: "account" | "character";
22
24
  /** A Lua list written by KumiAddon.lua. Read it with an index loop. */
23
25
  readonly plugins: OwnedLuaArray<PluginManifest>;