@overmvp/kumi 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -2
  3. package/animation/color-transition.ts +196 -0
  4. package/animation/cycle.ts +151 -0
  5. package/animation/ease.ts +29 -0
  6. package/animation/index.ts +13 -0
  7. package/animation/package.json +12 -0
  8. package/animation/presets.ts +376 -0
  9. package/animation/spec.ts +197 -0
  10. package/builder/Cargo.lock +192 -0
  11. package/builder/Cargo.toml +7 -0
  12. package/builder/css-v1.mjs +387 -0
  13. package/builder/css-v1.test.mjs +361 -0
  14. package/builder/generated-output.mjs +61 -0
  15. package/builder/generated-output.test.mjs +132 -0
  16. package/builder/jsx-form.mjs +93 -0
  17. package/builder/jsx-form.test.mjs +48 -0
  18. package/builder/jsx-lists.mjs +209 -0
  19. package/builder/link-addon-package.mjs +127 -0
  20. package/builder/lua-assets.mjs +74 -0
  21. package/builder/lua-builtin-values.mjs +57 -0
  22. package/builder/lua-builtin-values.test.mjs +155 -0
  23. package/builder/lua-loop-closures.mjs +183 -0
  24. package/builder/lua-loop-closures.test.mjs +89 -0
  25. package/builder/lua-truthiness.mjs +61 -0
  26. package/builder/lua-truthiness.test.mjs +113 -0
  27. package/builder/module-declarations.mjs +594 -0
  28. package/builder/module-declarations.test.mjs +435 -0
  29. package/builder/native-kernels.mjs +60 -0
  30. package/builder/native-lua.d.ts +57 -0
  31. package/builder/native-routes.mjs +51 -0
  32. package/builder/no-static-ref-read.mjs +93 -0
  33. package/builder/no-static-ref-read.test.mjs +181 -0
  34. package/builder/secure-snippet.mjs +317 -0
  35. package/builder/secure-snippet.test.mjs +101 -0
  36. package/builder/shared-lua-runtime.mjs +150 -0
  37. package/builder/src/addon-link.lua +29 -0
  38. package/builder/src/arrays.lua +260 -0
  39. package/builder/src/assets.rs +177 -0
  40. package/builder/src/classes.lua +75 -0
  41. package/builder/src/collections.lua +190 -0
  42. package/builder/src/compiler.rs +2336 -0
  43. package/builder/src/config.rs +42 -0
  44. package/builder/src/entries.rs +166 -0
  45. package/builder/src/errors.lua +15 -0
  46. package/builder/src/lua_data.rs +231 -0
  47. package/builder/src/main.rs +381 -0
  48. package/builder/src/native_ir.rs +65 -0
  49. package/builder/src/native_signal.rs +83 -0
  50. package/builder/src/numbers.lua +76 -0
  51. package/builder/src/project-front.mjs +3682 -0
  52. package/builder/src/records.lua +75 -0
  53. package/builder/src/routes.rs +124 -0
  54. package/builder/src/setup-store.lua +18 -0
  55. package/builder/src/signal-kernel.fingerprint +1 -0
  56. package/builder/src/strings.lua +103 -0
  57. package/builder/src/ts-lower.mjs +68 -0
  58. package/builder/src/wow-reads.lua +22 -0
  59. package/builder/src/wow_client.rs +253 -0
  60. package/builder/src/wow_types.rs +564 -0
  61. package/builder/style-modules.mjs +93 -0
  62. package/builder/style-states.mjs +100 -0
  63. package/builder/style-states.test.mjs +103 -0
  64. package/builder/vite-assets.mjs +53 -0
  65. package/builder/vite-project.mjs +10 -0
  66. package/config.ts +59 -0
  67. package/eslint.mjs +74 -0
  68. package/form/index.ts +526 -0
  69. package/form/package.json +13 -0
  70. package/motion/index.ts +2 -0
  71. package/motion/package.json +10 -0
  72. package/package.json +26 -4
  73. package/router/index.ts +50 -0
  74. package/router/navigation.ts +22 -0
  75. package/router/package.json +12 -0
  76. package/router/router-view.ts +134 -0
  77. package/router/routes.ts +64 -0
  78. package/scripts/addon-build.mjs +364 -0
  79. package/scripts/addon-project.mjs +78 -0
  80. package/scripts/kumi-cli.mjs +105 -0
  81. package/scripts/link-addons.mjs +61 -0
  82. package/src/bindings.ts +35 -0
  83. package/src/context.ts +15 -0
  84. package/src/css-tokens.ts +239 -0
  85. package/src/css-v1.ts +68 -0
  86. package/src/cvars.ts +91 -0
  87. package/src/element-node.ts +32 -0
  88. package/src/elements.ts +505 -0
  89. package/src/feature-scope.ts +82 -0
  90. package/src/flex-layout.ts +807 -0
  91. package/src/frame-scheduler.ts +336 -0
  92. package/src/grid-tracks.ts +165 -0
  93. package/src/image-imports.d.ts +24 -0
  94. package/src/images.ts +79 -0
  95. package/src/index.ts +29 -0
  96. package/src/jsx-dev-runtime.ts +2 -0
  97. package/src/jsx-runtime.ts +29 -0
  98. package/src/jsx.d.ts +12 -0
  99. package/src/keyed-list.ts +366 -0
  100. package/src/media-query.ts +144 -0
  101. package/src/module-ui.ts +147 -0
  102. package/src/module.ts +311 -0
  103. package/src/node-selectors.ts +114 -0
  104. package/src/owned-collections.ts +52 -0
  105. package/src/providers.ts +241 -0
  106. package/src/reactive-scope.ts +34 -0
  107. package/src/reactivity.ts +275 -0
  108. package/src/result.ts +64 -0
  109. package/src/runtime.ts +52 -0
  110. package/src/scheduler.ts +185 -0
  111. package/src/signal-kernel.ts +63 -0
  112. package/src/style-classes.ts +51 -0
  113. package/src/style-states.ts +134 -0
  114. package/src/style-variables.ts +53 -0
  115. package/src/text-children.ts +42 -0
  116. package/src/theme.ts +50 -0
  117. package/src/transition.ts +18 -0
  118. package/state/index.ts +9 -0
  119. package/state/package.json +12 -0
  120. package/state/setup-store-persistence.ts +206 -0
  121. package/state/setup-store-view.ts +10 -0
  122. package/state/setup-store.ts +342 -0
  123. package/state/store-bindings.ts +25 -0
  124. package/state/store.ts +84 -0
  125. package/styles/_layers.scss +14 -0
  126. package/templates/addon/.agents/skills/kumi-build-debug/SKILL.md +36 -0
  127. package/templates/addon/.agents/skills/kumi-feature/SKILL.md +50 -0
  128. package/templates/addon/.agents/skills/kumi-plugin/SKILL.md +36 -0
  129. package/templates/addon/.agents/skills/kumi-store/SKILL.md +47 -0
  130. package/templates/addon/.agents/skills/kumi-ui/SKILL.md +73 -0
  131. package/templates/addon/.agents/skills/kumi-wow-api/SKILL.md +30 -0
  132. package/templates/addon/.claude/skills/kumi-build-debug/SKILL.md +36 -0
  133. package/templates/addon/.claude/skills/kumi-feature/SKILL.md +50 -0
  134. package/templates/addon/.claude/skills/kumi-plugin/SKILL.md +36 -0
  135. package/templates/addon/.claude/skills/kumi-store/SKILL.md +47 -0
  136. package/templates/addon/.claude/skills/kumi-ui/SKILL.md +73 -0
  137. package/templates/addon/.claude/skills/kumi-wow-api/SKILL.md +30 -0
  138. package/templates/addon/AGENTS.md +34 -0
  139. package/templates/addon/Assets/Art/Corner10.tga +0 -0
  140. package/templates/addon/Assets/Art/Corner11.tga +0 -0
  141. package/templates/addon/Assets/Art/Corner12.tga +0 -0
  142. package/templates/addon/Assets/Art/Corner13.tga +0 -0
  143. package/templates/addon/Assets/Art/Corner14.tga +0 -0
  144. package/templates/addon/Assets/Art/Corner15.tga +0 -0
  145. package/templates/addon/Assets/Art/Corner16.tga +0 -0
  146. package/templates/addon/Assets/Art/Corner2.tga +0 -0
  147. package/templates/addon/Assets/Art/Corner3.tga +0 -0
  148. package/templates/addon/Assets/Art/Corner4.tga +0 -0
  149. package/templates/addon/Assets/Art/Corner5.tga +0 -0
  150. package/templates/addon/Assets/Art/Corner6.tga +0 -0
  151. package/templates/addon/Assets/Art/Corner7.tga +0 -0
  152. package/templates/addon/Assets/Art/Corner8.tga +0 -0
  153. package/templates/addon/Assets/Art/Corner9.tga +0 -0
  154. package/templates/addon/Assets/Art/Dot.tga +0 -0
  155. package/templates/addon/Assets/Art/Gear.tga +0 -0
  156. package/templates/addon/Assets/Art/Grip.tga +0 -0
  157. package/templates/addon/Assets/Art/Outline10.tga +0 -0
  158. package/templates/addon/Assets/Art/Outline12.tga +0 -0
  159. package/templates/addon/Assets/Art/Outline13.tga +0 -0
  160. package/templates/addon/Assets/Art/Outline14.tga +0 -0
  161. package/templates/addon/Assets/Art/Outline15.tga +0 -0
  162. package/templates/addon/Assets/Art/Outline2.tga +0 -0
  163. package/templates/addon/Assets/Art/Outline3.tga +0 -0
  164. package/templates/addon/Assets/Art/Outline5.tga +0 -0
  165. package/templates/addon/Assets/Art/Outline7.tga +0 -0
  166. package/templates/addon/Assets/Art/Outline9.tga +0 -0
  167. package/templates/addon/Assets/Art/Round11.tga +0 -0
  168. package/templates/addon/Assets/Art/Round11Border.tga +0 -0
  169. package/templates/addon/Assets/Art/Round4.tga +0 -0
  170. package/templates/addon/Assets/Art/Round4Border.tga +0 -0
  171. package/templates/addon/Assets/Art/Round6.tga +0 -0
  172. package/templates/addon/Assets/Art/Round6Border.tga +0 -0
  173. package/templates/addon/Assets/Art/Round8.tga +0 -0
  174. package/templates/addon/Assets/Art/Round8Border.tga +0 -0
  175. package/templates/addon/Assets/Art/Search.tga +0 -0
  176. package/templates/addon/CLAUDE.md +1 -0
  177. package/templates/addon/README.md +49 -0
  178. package/templates/addon/eslint.config.mjs +6 -0
  179. package/templates/addon/gitignore +9 -0
  180. package/templates/addon/kumi.config.ts +17 -0
  181. package/templates/addon/package.json +20 -0
  182. package/templates/addon/src/app/app.module.ts +18 -0
  183. package/templates/addon/src/app/commands.store.ts +11 -0
  184. package/templates/addon/src/app/layout/AppWindow.module.scss +92 -0
  185. package/templates/addon/src/app/layout/AppWindow.tsx +32 -0
  186. package/templates/addon/src/app/main.ts +5 -0
  187. package/templates/addon/src/app/routes/(window)/home/page.tsx +8 -0
  188. package/templates/addon/src/app/routes/(window)/plugins/page.tsx +38 -0
  189. package/templates/addon/src/app/routes/(window)/settings/page.tsx +8 -0
  190. package/templates/addon/src/app/theme.ts +6 -0
  191. package/templates/addon/src/modules/greeting/api/player.api.ts +29 -0
  192. package/templates/addon/src/modules/greeting/greeting.module.ts +18 -0
  193. package/templates/addon/src/modules/greeting/model/greeting.store.ts +81 -0
  194. package/templates/addon/src/modules/greeting/services/greeting.service.ts +38 -0
  195. package/templates/addon/src/modules/greeting/ui/Greeting.module.scss +105 -0
  196. package/templates/addon/src/modules/greeting/ui/GreetingCard.tsx +29 -0
  197. package/templates/addon/src/modules/greeting/widgets/GreetingHud.tsx +54 -0
  198. package/templates/addon/src/modules/greeting/widgets/GreetingOverview.tsx +18 -0
  199. package/templates/addon/src/modules/greeting/widgets/GreetingSettings.tsx +56 -0
  200. package/templates/addon/src/modules/playtime/api/clock.api.ts +6 -0
  201. package/templates/addon/src/modules/playtime/model/playtime.store.ts +19 -0
  202. package/templates/addon/src/modules/playtime/playtime.module.ts +18 -0
  203. package/templates/addon/src/modules/playtime/services/playtime.service.ts +18 -0
  204. package/templates/addon/src/modules/playtime/ui/Playtime.module.scss +25 -0
  205. package/templates/addon/src/modules/playtime/ui/PlaytimeBadge.tsx +10 -0
  206. package/templates/addon/src/modules/playtime/widgets/PlaytimePage.tsx +16 -0
  207. package/templates/addon/src/shared/api/native-art.ts +28 -0
  208. package/templates/addon/src/shared/assets/close.png +0 -0
  209. package/templates/addon/src/shared/lib/format.ts +20 -0
  210. package/templates/addon/src/shared/styles/_tokens.scss +12 -0
  211. package/templates/addon/src/shared/ui/Button.tsx +29 -0
  212. package/templates/addon/src/shared/ui/Choice.tsx +34 -0
  213. package/templates/addon/src/shared/ui/Controls.module.scss +93 -0
  214. package/templates/addon/src/shared/ui/Glyph.tsx +18 -0
  215. package/templates/addon/src/shared/ui/Slider.tsx +25 -0
  216. package/templates/addon/src/shared/ui/Toggle.tsx +29 -0
  217. package/templates/addon/src/shared/ui/focus-ref.ts +7 -0
  218. package/templates/addon/src/shared/ui/range-skin.tsx +15 -0
  219. package/templates/addon/tsconfig.json +63 -0
  220. package/translate/index.ts +14 -0
  221. package/translate/package.json +9 -0
  222. package/utils/colors.ts +76 -0
  223. package/utils/format.ts +37 -0
  224. package/utils/index.ts +4 -0
  225. package/utils/number.ts +17 -0
  226. package/utils/package.json +7 -0
  227. package/utils/text.ts +6 -0
  228. package/validate/index.ts +119 -0
  229. package/validate/package.json +9 -0
  230. package/wow/absolute-position.ts +142 -0
  231. package/wow/action-bar-layout.ts +108 -0
  232. package/wow/action-button.ts +219 -0
  233. package/wow/action-catalog.ts +98 -0
  234. package/wow/addon-manifest.ts +36 -0
  235. package/wow/animation.ts +428 -0
  236. package/wow/app-ui.ts +221 -0
  237. package/wow/aura-button.ts +76 -0
  238. package/wow/aura-container.ts +591 -0
  239. package/wow/aura-countdown.ts +201 -0
  240. package/wow/aura-slot.ts +153 -0
  241. package/wow/bar-shade.ts +93 -0
  242. package/wow/borrowed-slot.ts +216 -0
  243. package/wow/button-drag.ts +48 -0
  244. package/wow/cast-clock.ts +153 -0
  245. package/wow/cast-text.ts +83 -0
  246. package/wow/class-colors.ts +126 -0
  247. package/wow/clock.ts +7 -0
  248. package/wow/color-picker.ts +128 -0
  249. package/wow/commands.ts +17 -0
  250. package/wow/contained-frame.ts +128 -0
  251. package/wow/contract.ts +42 -0
  252. package/wow/cooldown-timing.ts +24 -0
  253. package/wow/css-box.ts +144 -0
  254. package/wow/css-color.ts +12 -0
  255. package/wow/css-style.ts +109 -0
  256. package/wow/css-surfaces.ts +603 -0
  257. package/wow/css-text.ts +399 -0
  258. package/wow/cursor.ts +45 -0
  259. package/wow/cvar-schema.ts +32 -0
  260. package/wow/cvars.ts +98 -0
  261. package/wow/dropdown-art.ts +39 -0
  262. package/wow/element-click.ts +20 -0
  263. package/wow/element-event-coordinator.ts +219 -0
  264. package/wow/element-events.ts +317 -0
  265. package/wow/event-dispatcher.ts +151 -0
  266. package/wow/events.ts +50 -0
  267. package/wow/font-cache.ts +92 -0
  268. package/wow/frame-access.ts +53 -0
  269. package/wow/frame-layer.ts +5 -0
  270. package/wow/frame-timing.ts +13 -0
  271. package/wow/frames.ts +236 -0
  272. package/wow/heal-prediction.ts +305 -0
  273. package/wow/hooks.ts +133 -0
  274. package/wow/image-layers.ts +55 -0
  275. package/wow/index.ts +111 -0
  276. package/wow/layout-view.ts +663 -0
  277. package/wow/locale-font.ts +15 -0
  278. package/wow/lua-string.ts +18 -0
  279. package/wow/lua-table.ts +18 -0
  280. package/wow/macro-book.ts +84 -0
  281. package/wow/map-position.ts +27 -0
  282. package/wow/media-query.ts +65 -0
  283. package/wow/module-events.ts +11 -0
  284. package/wow/native-hooks.ts +168 -0
  285. package/wow/native-placement.ts +88 -0
  286. package/wow/native.ts +153 -0
  287. package/wow/number-format.ts +8 -0
  288. package/wow/number-input.ts +10 -0
  289. package/wow/panel-host.ts +97 -0
  290. package/wow/pixel.ts +35 -0
  291. package/wow/plugins.ts +246 -0
  292. package/wow/protect.ts +48 -0
  293. package/wow/protected-layout.ts +133 -0
  294. package/wow/protected-view.ts +103 -0
  295. package/wow/range-art.ts +81 -0
  296. package/wow/readable-api.ts +120 -0
  297. package/wow/reparent-frame.ts +99 -0
  298. package/wow/rounded-texture.ts +183 -0
  299. package/wow/saved-variables.ts +109 -0
  300. package/wow/scroll-view.ts +64 -0
  301. package/wow/secret-ref.ts +14 -0
  302. package/wow/secure-bindings.ts +89 -0
  303. package/wow/secure-clicks.ts +432 -0
  304. package/wow/secure-snippet.ts +235 -0
  305. package/wow/secure-state.ts +130 -0
  306. package/wow/secure-target-visibility.ts +89 -0
  307. package/wow/secure-transaction.ts +331 -0
  308. package/wow/special-window.ts +269 -0
  309. package/wow/spell-cooldown.ts +36 -0
  310. package/wow/start-addon.ts +122 -0
  311. package/wow/state-paint.ts +256 -0
  312. package/wow/transition.ts +86 -0
  313. package/wow/unit-button.ts +39 -0
  314. package/wow/unit-cast.ts +92 -0
  315. package/wow/unit-health-text.ts +47 -0
  316. package/wow/view-nodes.ts +304 -0
  317. package/wow/view.ts +1864 -0
  318. package/wow/visible-frame-job.ts +34 -0
  319. package/wow/width-reserve.ts +108 -0
@@ -0,0 +1 @@
1
+ @AGENTS.md
@@ -0,0 +1,49 @@
1
+ # __ADDON_NAME__
2
+
3
+ A World of Warcraft addon built with [Kumi](https://github.com/OverMVP/kumi): TypeScript and TSX, compiled to Lua.
4
+
5
+ ## Commands
6
+
7
+ ```powershell
8
+ npm install
9
+ npm run check # types, styles, routes and project rules
10
+ npm run build -- --target forever # or --target retail
11
+ npm run link -- "D:/Games/World of Warcraft/_forever_/Interface/AddOns"
12
+ ```
13
+
14
+ `check` and `build` need the WoW API documentation export in `KUMI_WOW_DOCS`. Link once; after that `npm run build` and `/reload` in the game.
15
+
16
+ In the game, type `/__ADDON_SLASH__` to open the window.
17
+
18
+ ## What is inside
19
+
20
+ ```text
21
+ kumi.config.ts Addon name, title, SavedVariables and plugins
22
+ src/app/ Startup, the root module, the window and its pages
23
+ src/modules/greeting/ A feature with every layer:
24
+ api/ WoW calls
25
+ services/ logic
26
+ model/ the store, saved in SavedVariables
27
+ ui/, widgets/ components, the HUD panel, the settings form
28
+ greeting.module.ts the feature's public API
29
+ src/modules/playtime/ A plugin: its own addon, turned on or off in the Plugins page
30
+ src/shared/ Reusable controls, tokens and helpers
31
+ ```
32
+
33
+ Code in a feature depends in one direction: `ui/widgets → model → services → api → WoW`. `npm run check` enforces it.
34
+
35
+ ## Common tasks
36
+
37
+ | Task | Where |
38
+ | --- | --- |
39
+ | Change a text or a rule | `services/` |
40
+ | Add saved state | the feature's store in `model/`, add the field to `persist.pick` |
41
+ | Add a control | `src/shared/ui`, then use it in a widget |
42
+ | Add a window page | `src/app/routes/(window)/<name>/page.tsx`, rendering a widget |
43
+ | Add a panel on screen | a widget, listed in the module's `views` |
44
+ | Add a plugin | a module under `src/modules`, listed in `plugins` in `kumi.config.ts` |
45
+
46
+ ## Learn more
47
+
48
+ - [Kumi guides](https://github.com/OverMVP/kumi/tree/main/docs)
49
+ - `AGENTS.md` and `.claude/skills/` for AI coding agents
@@ -0,0 +1,6 @@
1
+ import ts from "@typescript-eslint/eslint-plugin";
2
+ import parser from "@typescript-eslint/parser";
3
+ import { kumiRules } from "__KUMI_PACKAGE__/eslint.mjs";
4
+
5
+ // Kumi's rules: feature layers (api → services → model → ui → widgets), module public APIs and the WoW boundary.
6
+ export default kumiRules({ parser, plugin: ts });
@@ -0,0 +1,9 @@
1
+ /node_modules/
2
+ /build/
3
+ /dist/
4
+ /.kumi/
5
+ *.tgz
6
+ *.log
7
+ .env
8
+ .env.*
9
+ /.local/
@@ -0,0 +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;
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "typecheck": "kumi check --types-only",
8
+ "lint": "eslint src",
9
+ "check": "kumi check",
10
+ "build": "kumi build",
11
+ "link": "kumi link"
12
+ },
13
+ "devDependencies": {
14
+ "__KUMI_PACKAGE__": "__KUMI_VERSION__",
15
+ "@typescript-eslint/eslint-plugin": "8.72.2",
16
+ "@typescript-eslint/parser": "8.72.2",
17
+ "eslint": "10.14.0",
18
+ "typescript": "6.0.2"
19
+ }
20
+ }
@@ -0,0 +1,18 @@
1
+ import { Module, ModuleType } from "@kumi/core";
2
+ import { router } from "@kumi/routes";
3
+ import { GreetingModule } from "../modules/greeting/greeting.module";
4
+ import { useCommands } from "./commands.store";
5
+ import { AppWindow } from "./layout/AppWindow";
6
+
7
+ // The root module: the core features, the addon window and app-wide stores.
8
+ const metadata = {
9
+ id: "app",
10
+ imports: [GreetingModule],
11
+ providers: [],
12
+ stores: [useCommands],
13
+ window: { routes: router, layout: AppWindow, width: 460, height: 360, start: "/home" },
14
+ exports: {},
15
+ } as const;
16
+
17
+ @Module(metadata)
18
+ export class AppModule extends ModuleType<typeof metadata> {}
@@ -0,0 +1,11 @@
1
+ import { defineStore } from "@kumi/state";
2
+ import { useSlashCommand, useWindow } from "@kumi/wow";
3
+
4
+ /** Slash commands of the addon. `/__ADDON_SLASH__` opens the window, `/__ADDON_SLASH__ settings` the settings page. */
5
+ export const useCommands = defineStore("commands", () => {
6
+ const window = useWindow();
7
+ useSlashCommand(["/__ADDON_SLASH__"], input => {
8
+ window.toggle(input === "settings" ? "/settings" : undefined);
9
+ });
10
+ return {};
11
+ });
@@ -0,0 +1,92 @@
1
+ @use "../../shared/styles/tokens" as *;
2
+
3
+ .window {
4
+ display: flex;
5
+ flex-direction: column;
6
+ width: 460px;
7
+ height: 360px;
8
+ background-color: $panel;
9
+ border: 1px solid $line;
10
+ border-radius: 8px;
11
+ }
12
+
13
+ .header {
14
+ display: flex;
15
+ align-items: center;
16
+ gap: 10px;
17
+ height: 36px;
18
+ padding: 0 12px 0 16px;
19
+ margin: 1px 1px 0;
20
+ background-color: $header;
21
+ border-radius: 6px;
22
+ }
23
+
24
+ .title {
25
+ flex-grow: 1;
26
+ font-size: 15px;
27
+ text-align: left;
28
+ color: $gold;
29
+ }
30
+
31
+ .close {
32
+ width: 26px;
33
+ min-width: 26px;
34
+ height: 26px;
35
+ border-radius: 4px;
36
+ background-color: $header;
37
+ }
38
+
39
+ .close:hover { background-color: $raised; }
40
+
41
+ .tabs {
42
+ display: flex;
43
+ gap: 6px;
44
+ padding: 8px 16px 0;
45
+ border-bottom: 1px solid $line;
46
+ }
47
+
48
+ .content {
49
+ flex-grow: 1;
50
+ min-height: 0;
51
+ }
52
+
53
+ .page {
54
+ position: absolute;
55
+ inset: 0;
56
+ display: flex;
57
+ flex-direction: column;
58
+ }
59
+
60
+ .list {
61
+ display: flex;
62
+ flex-direction: column;
63
+ gap: 10px;
64
+ padding: 16px;
65
+ }
66
+
67
+ .listRow {
68
+ display: flex;
69
+ align-items: center;
70
+ gap: 12px;
71
+ height: 44px;
72
+ border-bottom: 1px solid $line;
73
+ }
74
+
75
+ .listText {
76
+ display: flex;
77
+ flex-direction: column;
78
+ flex-grow: 1;
79
+ gap: 2px;
80
+ }
81
+
82
+ .listTitle {
83
+ font-size: 14px;
84
+ text-align: left;
85
+ color: $text;
86
+ }
87
+
88
+ .listNote {
89
+ font-size: 12px;
90
+ text-align: left;
91
+ color: $muted;
92
+ }
@@ -0,0 +1,32 @@
1
+ import { computed, storeToRefs } from "@kumi/state";
2
+ import { RouterView } from "@kumi/router";
3
+ import styles from "@kumi/styles/app/layout/AppWindow";
4
+ import { useWindow } from "@kumi/wow";
5
+ import { Button } from "../../shared/ui/Button";
6
+ import { Glyph } from "../../shared/ui/Glyph";
7
+
8
+ /** The frame of the addon window: title, page tabs and the active page. */
9
+ export function AppWindow() {
10
+ const window = useWindow();
11
+ // storeToRefs gives refs, so the tab list follows pages that plugins add later.
12
+ const { pages, path } = storeToRefs(window);
13
+ return (
14
+ <div fullWidth className={styles.window}>
15
+ <div className={styles.header}>
16
+ <span className={styles.title} value="__ADDON_NAME__" />
17
+ <button unstyled className={styles.close} ariaLabel="Close" onClick={window.close}>
18
+ <Glyph name="Close" />
19
+ </button>
20
+ </div>
21
+ <div className={styles.tabs}>
22
+ {pages.value.map(page => (
23
+ <Button key={page.path} label={page.title} checked={computed(() => path.value === page.path)}
24
+ onClick={() => { window.navigate(page.path); }} />
25
+ ))}
26
+ </div>
27
+ <div className={styles.content}>
28
+ <RouterView className={styles.page} />
29
+ </div>
30
+ </div>
31
+ );
32
+ }
@@ -0,0 +1,5 @@
1
+ import { startAddon } from "@kumi/wow";
2
+ import { AppModule } from "./app.module";
3
+ import { theme } from "./theme";
4
+
5
+ export const addon = startAddon(AppModule, { theme });
@@ -0,0 +1,8 @@
1
+ import { GreetingOverview } from "../../../../modules/greeting/widgets/GreetingOverview";
2
+
3
+ export const title = "Home";
4
+ export const order = 0;
5
+
6
+ export default function HomePage() {
7
+ return <GreetingOverview />;
8
+ }
@@ -0,0 +1,38 @@
1
+ import { computed, ref, storeToRefs } from "@kumi/state";
2
+ import styles from "@kumi/styles/app/layout/AppWindow";
3
+ import { usePlugins, type PluginInfo } from "@kumi/wow";
4
+ import { Button } from "../../../../shared/ui/Button";
5
+ import { Toggle } from "../../../../shared/ui/Toggle";
6
+
7
+ export const title = "Plugins";
8
+ export const order = 90;
9
+
10
+ const STATUS: Record<PluginInfo["status"], string> = {
11
+ off: "Off",
12
+ waiting: "Starts after a reload",
13
+ loading: "Loading",
14
+ ready: "Running",
15
+ error: "Failed",
16
+ };
17
+
18
+ /** Turn plugins on or off. Kumi changes the addon list and asks for a reload. */
19
+ export default function PluginsPage() {
20
+ const plugins = usePlugins();
21
+ const { list, reloadRequired } = storeToRefs(plugins);
22
+ return (
23
+ <div className={styles.list}>
24
+ {list.value.map(plugin => (
25
+ <div key={plugin.id} className={styles.listRow}>
26
+ <div className={styles.listText}>
27
+ <span className={styles.listTitle} value={plugin.title} />
28
+ <span className={styles.listNote} value={plugin.error ?? STATUS[plugin.status] + (plugin.notes === "" ? "" : " · " + plugin.notes)} />
29
+ </div>
30
+ <Toggle label={plugin.title} value={ref(plugin.enabled)}
31
+ onChange={enabled => { plugins.setEnabled(plugin.id, enabled); }} />
32
+ </div>
33
+ ))}
34
+ <span className={styles.listNote} shown={computed(() => list.value.length === 0)} value="This addon has no plugins." />
35
+ <Button primary label="Reload UI" shown={reloadRequired} onClick={plugins.reload} />
36
+ </div>
37
+ );
38
+ }
@@ -0,0 +1,8 @@
1
+ import { GreetingSettings } from "../../../../modules/greeting/widgets/GreetingSettings";
2
+
3
+ export const title = "Settings";
4
+ export const order = 10;
5
+
6
+ export default function SettingsPage() {
7
+ return <GreetingSettings />;
8
+ }
@@ -0,0 +1,6 @@
1
+ import type { AppTheme } from "@kumi/wow";
2
+ import { rounded, uiFont } from "../shared/api/native-art";
3
+ import { rangeSkin } from "../shared/ui/range-skin";
4
+
5
+ /** Textures, fonts and control skins for every view and window of the addon. */
6
+ export const theme: AppTheme = { rounded, fontSize: uiFont, rangeSkin };
@@ -0,0 +1,29 @@
1
+ import { api, readableApi, reveal } from "@kumi/wow";
2
+
3
+ // The api/ layer is the only place that calls WoW. Each function returns plain values.
4
+
5
+ /** The player's name. Undefined while the client keeps it hidden. */
6
+ export function readPlayerName(): string | undefined {
7
+ const [name] = readableApi.UnitName("player");
8
+ return name;
9
+ }
10
+
11
+ export function readPlayerLevel(): number {
12
+ return api.UnitLevel("player");
13
+ }
14
+
15
+ /** The player's money in copper. */
16
+ export function readMoney(): number {
17
+ return api.GetMoney();
18
+ }
19
+
20
+ /** Play an emote such as "WAVE", like typing /wave. False when the game does not allow it right now. */
21
+ export function performEmote(emote: string): boolean {
22
+ const perform = api.C_ChatInfo?.PerformEmote;
23
+ if (typeof perform === "function") return reveal(perform(emote)) === true;
24
+ // Clients without C_ChatInfo.PerformEmote still have the older global.
25
+ const legacy = (api as { DoEmote?: (this: void, token: string) => void }).DoEmote;
26
+ if (typeof legacy !== "function") return false;
27
+ legacy(emote);
28
+ return true;
29
+ }
@@ -0,0 +1,18 @@
1
+ import { Module, ModuleType } from "@kumi/core";
2
+ import { useGreetingStore } from "./model/greeting.store";
3
+ import { GreetingService } from "./services/greeting.service";
4
+ import { GreetingHud } from "./widgets/GreetingHud";
5
+
6
+ // The module file is the feature's public API: what it provides, owns, shows and exports.
7
+ export { useGreetingStore } from "./model/greeting.store";
8
+
9
+ const metadata = {
10
+ id: "greeting",
11
+ providers: [GreetingService],
12
+ stores: [useGreetingStore],
13
+ views: [GreetingHud],
14
+ exports: { greeting: GreetingService },
15
+ } as const;
16
+
17
+ @Module(metadata)
18
+ export class GreetingModule extends ModuleType<typeof metadata> {}
@@ -0,0 +1,81 @@
1
+ import { fail, ok, type Result } from "@kumi/core";
2
+ import { batch, computed, defineStore, inject, readonly, ref } from "@kumi/state";
3
+ import { useEvent } from "@kumi/wow";
4
+ import { formatMoney } from "../../../shared/lib/format";
5
+ import { GreetingService, type GreetingStyle } from "../services/greeting.service";
6
+
7
+ export type { GreetingStyle };
8
+
9
+ export interface GreetingSettings {
10
+ style: GreetingStyle;
11
+ showHud: boolean;
12
+ opacity: number;
13
+ }
14
+
15
+ export const GREETING_DEFAULTS: GreetingSettings = { style: "friendly", showHud: true, opacity: 100 };
16
+ export const OPACITY_RANGE = { min: 30, max: 100 } as const;
17
+
18
+ /**
19
+ * The greeting feature's state. Other modules use it through `useGreetingStore()`.
20
+ * Settings and the HUD position are saved in SavedVariables under "greeting".
21
+ */
22
+ export const useGreetingStore = defineStore("greeting", () => {
23
+ const greetings = inject(GreetingService);
24
+ const style = ref<GreetingStyle>(GREETING_DEFAULTS.style);
25
+ const showHud = ref(GREETING_DEFAULTS.showHud);
26
+ const opacity = ref(GREETING_DEFAULTS.opacity);
27
+ const waves = ref(0);
28
+ const x = ref(0);
29
+ const y = ref(-160);
30
+ const player = ref(greetings.player());
31
+ const copper = ref(greetings.money());
32
+ const notice = ref("");
33
+
34
+ // WoW events update the store while it is alive.
35
+ useEvent("PLAYER_MONEY", () => { copper.value = greetings.money(); });
36
+ useEvent("PLAYER_LEVEL_UP", () => { player.value = greetings.player(); });
37
+
38
+ const message = computed(() => greetings.message(style.value, player.value, waves.value));
39
+ const money = computed(() => formatMoney(copper.value));
40
+
41
+ /** Play the /wave emote and count it. */
42
+ function wave(this: void): Result<void> {
43
+ if (!greetings.wave()) {
44
+ notice.value = "You can't wave right now.";
45
+ return fail(notice.value);
46
+ }
47
+ notice.value = "";
48
+ waves.value += 1;
49
+ return ok(undefined);
50
+ }
51
+
52
+ function updateSettings(this: void, values: Partial<GreetingSettings>): Result<void> {
53
+ const next = values.opacity;
54
+ if (next !== undefined && (next < OPACITY_RANGE.min || next > OPACITY_RANGE.max)) return fail("Opacity is out of range");
55
+ // A batch saves every changed field once and restores them all if saving fails.
56
+ return batch(() => {
57
+ if (values.style !== undefined) style.value = values.style;
58
+ if (values.showHud !== undefined) showHud.value = values.showHud;
59
+ if (next !== undefined) opacity.value = Math.floor(next);
60
+ });
61
+ }
62
+
63
+ function moveHud(this: void, nextX: number, nextY: number): Result<void> {
64
+ return batch(() => {
65
+ x.value = Math.floor(nextX);
66
+ y.value = Math.floor(nextY);
67
+ });
68
+ }
69
+
70
+ function resetHud(this: void): Result<void> {
71
+ const reset = moveHud(0, -160);
72
+ return reset.ok ? updateSettings(GREETING_DEFAULTS) : reset;
73
+ }
74
+
75
+ return {
76
+ style: readonly(style), showHud: readonly(showHud), opacity: readonly(opacity), waves: readonly(waves),
77
+ x: readonly(x), y: readonly(y), player: readonly(player), notice: readonly(notice),
78
+ message, money, wave, updateSettings, moveHud, resetHud,
79
+ };
80
+ }, { persist: { pick: ["style", "showHud", "opacity", "waves", "x", "y"] } });
81
+
@@ -0,0 +1,38 @@
1
+ import { Injectable } from "@kumi/core";
2
+ import { performEmote, readMoney, readPlayerLevel, readPlayerName } from "../api/player.api";
3
+
4
+ export type GreetingStyle = "friendly" | "formal" | "pirate";
5
+
6
+ export interface Player {
7
+ readonly name: string;
8
+ readonly level: number;
9
+ }
10
+
11
+ const OPENERS: Record<GreetingStyle, string> = {
12
+ friendly: "Hi",
13
+ formal: "Good day",
14
+ pirate: "Ahoy",
15
+ };
16
+
17
+ /** Logic of the greeting feature. Stores call it; it calls the feature's api/ for WoW data. */
18
+ @Injectable()
19
+ export class GreetingService {
20
+ player(): Player {
21
+ return { name: readPlayerName() ?? "adventurer", level: readPlayerLevel() };
22
+ }
23
+
24
+ money(): number {
25
+ return readMoney();
26
+ }
27
+
28
+ /** Wave at everyone nearby. False when the game does not allow emotes right now. */
29
+ wave(): boolean {
30
+ return performEmote("WAVE");
31
+ }
32
+
33
+ message(style: GreetingStyle, player: Player, waves: number): string {
34
+ const greeting = OPENERS[style] + ", " + player.name + "!";
35
+ if (waves === 0) return greeting + " Press Wave to wave at everyone nearby.";
36
+ return greeting + " You waved " + String(waves) + (waves === 1 ? " time." : " times.");
37
+ }
38
+ }
@@ -0,0 +1,105 @@
1
+ @use "../../../shared/styles/tokens" as *;
2
+
3
+ .card {
4
+ display: flex;
5
+ flex-direction: column;
6
+ gap: 6px;
7
+ }
8
+
9
+ // Room for two lines, so the panel keeps its height when the text gets shorter.
10
+ .message {
11
+ height: 36px;
12
+ font-size: 15px;
13
+ text-align: left;
14
+ color: $text;
15
+ }
16
+
17
+ .money {
18
+ font-size: 13px;
19
+ text-align: left;
20
+ color: $gold;
21
+ }
22
+
23
+ .notice {
24
+ font-size: 12px;
25
+ text-align: left;
26
+ color: $muted;
27
+ }
28
+
29
+ .hud {
30
+ display: flex;
31
+ flex-direction: column;
32
+ gap: 10px;
33
+ width: 280px;
34
+ padding: 10px 12px 12px;
35
+ background-color: $panel;
36
+ border: 1px solid $line;
37
+ border-radius: 8px;
38
+ }
39
+
40
+ .hudHeader {
41
+ display: flex;
42
+ align-items: center;
43
+ gap: 8px;
44
+ height: 24px;
45
+ }
46
+
47
+ .hudTitle {
48
+ flex-grow: 1;
49
+ font-size: 14px;
50
+ text-align: left;
51
+ color: $muted;
52
+ }
53
+
54
+ .iconButton {
55
+ width: 26px;
56
+ min-width: 26px;
57
+ height: 24px;
58
+ }
59
+
60
+ .grip {
61
+ width: 20px;
62
+ height: 20px;
63
+ }
64
+
65
+ .footer {
66
+ display: flex;
67
+ align-items: center;
68
+ gap: 8px;
69
+ }
70
+
71
+ .spacer { flex-grow: 1; }
72
+
73
+ .settings {
74
+ display: flex;
75
+ flex-direction: column;
76
+ gap: 14px;
77
+ padding: 16px;
78
+ }
79
+
80
+ .row {
81
+ display: flex;
82
+ align-items: center;
83
+ gap: 12px;
84
+ height: 32px;
85
+ }
86
+
87
+ .rowLabel {
88
+ width: 120px;
89
+ font-size: 14px;
90
+ text-align: left;
91
+ color: $text;
92
+ }
93
+
94
+ .hint {
95
+ font-size: 13px;
96
+ text-align: left;
97
+ color: $muted;
98
+ }
99
+
100
+ .overview {
101
+ display: flex;
102
+ flex-direction: column;
103
+ gap: 14px;
104
+ padding: 16px;
105
+ }