@overmvp/kumi 0.1.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -6
- package/animation/index.ts +4 -0
- package/animation/motion-policy.ts +20 -0
- package/animation/slide.ts +61 -0
- package/animation/spring.ts +75 -0
- package/animation/staggered-reveal.ts +34 -0
- package/builder/css-gradients.mjs +74 -0
- package/builder/css-mask-assets.mjs +52 -0
- package/builder/css-mask-assets.test.mjs +31 -0
- package/builder/css-v1.mjs +127 -23
- package/builder/css-v1.test.mjs +82 -2
- package/builder/link-addon-package.mjs +47 -6
- package/builder/module-declarations.test.mjs +9 -18
- package/builder/native-kernels.mjs +1 -1
- package/builder/src/compiler.rs +205 -8
- package/builder/src/lua_upvalues.rs +641 -0
- package/builder/src/main.rs +20 -5
- package/builder/src/native_ir.rs +1 -1
- package/builder/src/native_signal.rs +46 -10
- package/builder/src/numbers.lua +14 -0
- package/builder/src/project-front.mjs +385 -34
- package/builder/src/routes.rs +11 -14
- package/builder/src/setup-store.lua +18 -0
- package/builder/src/signal-kernel.fingerprint +1 -1
- package/builder/src/ts-lower.mjs +2 -2
- package/builder/src/wow-reads.lua +22 -0
- package/builder/style-modules.mjs +111 -0
- package/builder/style-modules.test.mjs +24 -0
- package/builder/style-states.mjs +6 -4
- package/config.ts +56 -14
- package/eslint.mjs +74 -0
- package/form/index.ts +15 -11
- package/package.json +11 -7
- package/router/index.ts +10 -2
- package/router/link.tsx +32 -0
- package/router/navigation.ts +22 -0
- package/router/router-view.ts +134 -0
- package/scripts/addon-build.mjs +377 -0
- package/scripts/addon-project.mjs +89 -0
- package/scripts/kumi-cli.mjs +52 -17
- package/scripts/link-addons.mjs +12 -2
- package/src/bindings.ts +12 -6
- package/src/context.ts +31 -7
- package/src/css-tokens.ts +27 -13
- package/src/css-v1.ts +13 -0
- package/src/elements.ts +35 -0
- package/src/flex-layout.ts +26 -5
- package/src/frame-scheduler.ts +6 -2
- package/src/index.ts +2 -1
- package/src/jsx-runtime.ts +8 -1
- package/src/keyed-list.ts +17 -11
- package/src/module-ui.ts +163 -0
- package/src/module.ts +51 -8
- package/src/owned-collections.ts +8 -0
- package/src/providers.ts +7 -1
- package/src/reactive-scope.ts +3 -3
- package/src/reactivity.ts +42 -8
- package/src/result.ts +6 -0
- package/src/signal-kernel.ts +35 -2
- package/src/style-classes.ts +22 -1
- package/src/style-states.ts +13 -6
- package/state/index.ts +6 -0
- package/state/setup-store-persistence.ts +206 -0
- package/state/setup-store-view.ts +10 -0
- package/state/setup-store.ts +342 -0
- package/state/store.ts +2 -0
- package/templates/addon/.agents/skills/kumi-build-debug/SKILL.md +36 -0
- package/templates/addon/.agents/skills/kumi-feature/SKILL.md +50 -0
- package/templates/addon/.agents/skills/kumi-plugin/SKILL.md +36 -0
- package/templates/addon/.agents/skills/kumi-store/SKILL.md +47 -0
- package/templates/addon/.agents/skills/kumi-ui/SKILL.md +73 -0
- package/templates/addon/.agents/skills/kumi-wow-api/SKILL.md +30 -0
- package/templates/addon/.claude/skills/kumi-build-debug/SKILL.md +36 -0
- package/templates/addon/.claude/skills/kumi-feature/SKILL.md +50 -0
- package/templates/addon/.claude/skills/kumi-plugin/SKILL.md +36 -0
- package/templates/addon/.claude/skills/kumi-store/SKILL.md +47 -0
- package/templates/addon/.claude/skills/kumi-ui/SKILL.md +73 -0
- package/templates/addon/.claude/skills/kumi-wow-api/SKILL.md +30 -0
- package/templates/addon/AGENTS.md +34 -0
- package/templates/addon/Assets/Art/Corner10.tga +0 -0
- package/templates/addon/Assets/Art/Corner11.tga +0 -0
- package/templates/addon/Assets/Art/Corner12.tga +0 -0
- package/templates/addon/Assets/Art/Corner13.tga +0 -0
- package/templates/addon/Assets/Art/Corner14.tga +0 -0
- package/templates/addon/Assets/Art/Corner15.tga +0 -0
- package/templates/addon/Assets/Art/Corner16.tga +0 -0
- package/templates/addon/Assets/Art/Corner2.tga +0 -0
- package/templates/addon/Assets/Art/Corner3.tga +0 -0
- package/templates/addon/Assets/Art/Corner4.tga +0 -0
- package/templates/addon/Assets/Art/Corner5.tga +0 -0
- package/templates/addon/Assets/Art/Corner6.tga +0 -0
- package/templates/addon/Assets/Art/Corner7.tga +0 -0
- package/templates/addon/Assets/Art/Corner8.tga +0 -0
- package/templates/addon/Assets/Art/Corner9.tga +0 -0
- package/templates/addon/Assets/Art/Dot.tga +0 -0
- package/templates/addon/Assets/Art/Gear.tga +0 -0
- package/templates/addon/Assets/Art/Grip.tga +0 -0
- package/templates/addon/Assets/Art/Outline10.tga +0 -0
- package/templates/addon/Assets/Art/Outline12.tga +0 -0
- package/templates/addon/Assets/Art/Outline13.tga +0 -0
- package/templates/addon/Assets/Art/Outline14.tga +0 -0
- package/templates/addon/Assets/Art/Outline15.tga +0 -0
- package/templates/addon/Assets/Art/Outline2.tga +0 -0
- package/templates/addon/Assets/Art/Outline3.tga +0 -0
- package/templates/addon/Assets/Art/Outline5.tga +0 -0
- package/templates/addon/Assets/Art/Outline7.tga +0 -0
- package/templates/addon/Assets/Art/Outline9.tga +0 -0
- package/templates/addon/Assets/Art/Round11.tga +0 -0
- package/templates/addon/Assets/Art/Round11Border.tga +0 -0
- package/templates/addon/Assets/Art/Round4.tga +0 -0
- package/templates/addon/Assets/Art/Round4Border.tga +0 -0
- package/templates/addon/Assets/Art/Round6.tga +0 -0
- package/templates/addon/Assets/Art/Round6Border.tga +0 -0
- package/templates/addon/Assets/Art/Round8.tga +0 -0
- package/templates/addon/Assets/Art/Round8Border.tga +0 -0
- package/templates/addon/Assets/Art/Search.tga +0 -0
- package/templates/addon/CLAUDE.md +1 -0
- package/templates/addon/README.md +42 -7
- package/templates/addon/eslint.config.mjs +3 -9
- package/templates/addon/gitignore +1 -0
- package/templates/addon/kumi.config.ts +17 -0
- package/templates/addon/package.json +4 -5
- package/templates/addon/src/app/app.module.ts +18 -0
- package/templates/addon/src/app/commands.store.ts +11 -0
- package/templates/addon/src/app/layout/AppWindow.module.css +90 -0
- package/templates/addon/src/app/layout/AppWindow.tsx +32 -0
- package/templates/addon/src/app/main.ts +5 -0
- package/templates/addon/src/app/routes/(window)/home/page.tsx +8 -0
- package/templates/addon/src/app/routes/(window)/plugins/page.tsx +38 -0
- package/templates/addon/src/app/routes/(window)/settings/page.tsx +8 -0
- package/templates/addon/src/app/theme.ts +6 -0
- package/templates/addon/src/modules/greeting/api/player.api.ts +29 -0
- package/templates/addon/src/modules/greeting/greeting.module.ts +18 -0
- package/templates/addon/src/modules/greeting/model/greeting.store.ts +81 -0
- package/templates/addon/src/modules/greeting/services/greeting.service.ts +38 -0
- package/templates/addon/src/modules/greeting/ui/Greeting.module.css +103 -0
- package/templates/addon/src/modules/greeting/ui/GreetingCard.tsx +29 -0
- package/templates/addon/src/modules/greeting/widgets/GreetingHud.tsx +54 -0
- package/templates/addon/src/modules/greeting/widgets/GreetingOverview.tsx +18 -0
- package/templates/addon/src/modules/greeting/widgets/GreetingSettings.tsx +56 -0
- package/templates/addon/src/modules/playtime/api/clock.api.ts +6 -0
- package/templates/addon/src/modules/playtime/model/playtime.store.ts +19 -0
- package/templates/addon/src/modules/playtime/playtime.module.ts +18 -0
- package/templates/addon/src/modules/playtime/services/playtime.service.ts +18 -0
- package/templates/addon/src/modules/playtime/ui/Playtime.module.css +23 -0
- package/templates/addon/src/modules/playtime/ui/PlaytimeBadge.tsx +10 -0
- package/templates/addon/src/modules/playtime/widgets/PlaytimePage.tsx +16 -0
- package/templates/addon/src/shared/api/native-art.ts +28 -0
- package/templates/addon/src/shared/assets/close.png +0 -0
- package/templates/addon/src/shared/lib/format.ts +20 -0
- package/templates/addon/src/shared/styles/tokens.css +13 -0
- package/templates/addon/src/shared/ui/Button.tsx +29 -0
- package/templates/addon/src/shared/ui/Choice.tsx +34 -0
- package/templates/addon/src/shared/ui/Controls.module.css +91 -0
- package/templates/addon/src/shared/ui/Glyph.tsx +18 -0
- package/templates/addon/src/shared/ui/Slider.tsx +25 -0
- package/templates/addon/src/shared/ui/Toggle.tsx +29 -0
- package/templates/addon/src/shared/ui/focus-ref.ts +7 -0
- package/templates/addon/src/shared/ui/range-skin.tsx +15 -0
- package/templates/addon/tsconfig.json +49 -10
- package/wow/action-bar-layout.ts +108 -0
- package/wow/action-button.ts +244 -0
- package/wow/action-catalog.ts +98 -0
- package/wow/addon-manifest.ts +38 -0
- package/wow/animation.ts +3 -14
- package/wow/app-ui.ts +230 -0
- package/wow/cooldown-timing.ts +24 -0
- package/wow/css-background-image.ts +75 -0
- package/wow/css-box.ts +46 -10
- package/wow/css-image-mask.ts +32 -0
- package/wow/css-surfaces.ts +295 -43
- package/wow/cursor.ts +45 -0
- package/wow/element-events.ts +33 -13
- package/wow/frame-access.ts +23 -1
- package/wow/frame-timing.ts +13 -0
- package/wow/heal-prediction.ts +2 -4
- package/wow/hooks.ts +133 -0
- package/wow/index.ts +19 -4
- package/wow/layout-view.ts +44 -23
- package/wow/locale-font.ts +15 -0
- package/wow/module-replacements.ts +103 -0
- package/wow/native.ts +18 -0
- package/wow/panel-host.ts +97 -0
- package/wow/pixel.ts +35 -0
- package/wow/plugins.ts +246 -0
- package/wow/pointer-click.ts +35 -0
- package/wow/protect.ts +27 -3
- package/wow/protected-view.ts +139 -0
- package/wow/range-art.ts +7 -0
- package/wow/readable-api.ts +120 -0
- package/wow/rounded-texture.ts +38 -6
- package/wow/saved-variables.ts +67 -18
- package/wow/spell-cooldown.ts +36 -0
- package/wow/start-addon.ts +31 -8
- package/wow/state-paint.ts +5 -14
- package/wow/texture-fill.ts +10 -0
- package/wow/unit-cast.ts +6 -4
- package/wow/view.ts +458 -228
- package/templates/addon/__ADDON_NAME__.toc +0 -4
- package/templates/addon/scripts/build.mjs +0 -25
- package/templates/addon/src/app/main.tsx +0 -13
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kumi-feature
|
|
3
|
+
description: Add a new feature module to a Kumi addon with its api, services, model, ui and widgets layers, and wire it into the app module. Use when the user asks for a new feature, panel, tracker or system in a Kumi project.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Add a feature
|
|
7
|
+
|
|
8
|
+
1. Pick a short lowercase name, for example `loot`. Create `src/modules/loot/` with the folders you need: `api/`, `services/`, `model/`, `ui/`, `widgets/`.
|
|
9
|
+
2. **api/**: one function per WoW call, returning plain values.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// src/modules/loot/api/money.api.ts
|
|
13
|
+
import { api } from "@kumi/wow";
|
|
14
|
+
export function readMoney(): number { return api.GetMoney(); }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
3. **services/**: the logic, as an `@Injectable` class that calls `api/`.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
@Injectable()
|
|
21
|
+
export class LootService {
|
|
22
|
+
money() { return readMoney(); }
|
|
23
|
+
gained(start: number, now: number) { return Math.max(0, now - start); }
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
4. **model/**: a store that injects the service. See the kumi-store skill.
|
|
28
|
+
5. **ui/** and **widgets/**: components that read the store. See the kumi-ui skill.
|
|
29
|
+
6. **loot.module.ts**: the manifest and public API.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
export { useLootStore } from "./model/loot.store";
|
|
33
|
+
|
|
34
|
+
const metadata = {
|
|
35
|
+
id: "loot",
|
|
36
|
+
imports: [], // other features this one reads, by their module class
|
|
37
|
+
providers: [LootService],
|
|
38
|
+
stores: [useLootStore],
|
|
39
|
+
views: [], // HUD widgets to show while the feature runs
|
|
40
|
+
exports: {},
|
|
41
|
+
} as const;
|
|
42
|
+
|
|
43
|
+
@Module(metadata)
|
|
44
|
+
export class LootModule extends ModuleType<typeof metadata> {}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
7. Add `LootModule` to `imports` in `src/app/app.module.ts`. If the feature should be optional, make it a plugin instead (kumi-plugin skill) and do not import it.
|
|
48
|
+
8. Run `npm run check` and `npm run build -- --target forever`.
|
|
49
|
+
|
|
50
|
+
Rules: other features import only `loot.module.ts`. Components never import `api/` or `services/`.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kumi-plugin
|
|
3
|
+
description: Add a plugin to a Kumi addon - an optional part that players turn on or off, built as its own addon - or load a part on demand. Use when a feature should be optional, separately toggleable, or loaded only when opened.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Add a plugin
|
|
7
|
+
|
|
8
|
+
1. Write the plugin as a normal feature module under `src/modules/<id>/` (kumi-feature skill). It may import core modules, but core code must not import its files.
|
|
9
|
+
2. Add it to `kumi.config.ts`:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
plugins: {
|
|
13
|
+
loot: {
|
|
14
|
+
module: "src/modules/loot/loot.module.ts",
|
|
15
|
+
title: "Loot",
|
|
16
|
+
notes: "Counts gold and items",
|
|
17
|
+
load: "startup", // or "demand" to load on first use
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
pluginState: "character", // or "account"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
3. Do not add the module to `app.module.ts` imports. Kumi starts startup plugins itself.
|
|
24
|
+
4. Contribute UI from the plugin's module: `views` for HUD panels, `pages` for window pages, `extensions` for slots such as `"hud.footer"`.
|
|
25
|
+
5. For a demand plugin, load it from a store action or a button:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
const loaded = usePlugins().load("loot");
|
|
29
|
+
if (loaded.ok) { /* loaded.value has the module's exports */ }
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
6. Run `npm run check` (generates the typed plugin list) and `npm run build -- --target forever`. The build creates `build/addons/<Addon>_<id>/`. Run `npm run link -- <AddOns>` again once so the new folder is linked.
|
|
33
|
+
|
|
34
|
+
The Plugins page (`src/app/routes/(window)/plugins/page.tsx`) lists plugins with `usePlugins()`. Turning one off asks for a reload.
|
|
35
|
+
|
|
36
|
+
If the build says a file "belongs to plugin X, but <Addon> imports it": core code imports a file from the plugin's folder. Use `import type`, or move the shared code into a core module.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kumi-store
|
|
3
|
+
description: Create or change a Kumi store (defineStore) - state, computed values, actions that call services, saving to SavedVariables, batch updates, events and timers. Use when adding state, settings or saved data to a Kumi addon.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Write a store
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
// src/modules/loot/model/loot.store.ts
|
|
10
|
+
import { batch, computed, defineStore, inject, readonly, ref } from "@kumi/state";
|
|
11
|
+
import { useEvent } from "@kumi/wow";
|
|
12
|
+
import { LootService } from "../services/loot.service";
|
|
13
|
+
|
|
14
|
+
export const useLootStore = defineStore("loot", () => {
|
|
15
|
+
const loot = inject(LootService); // only in a store listed in a module's `stores`
|
|
16
|
+
const start = ref(loot.money());
|
|
17
|
+
const copper = ref(loot.money());
|
|
18
|
+
const best = ref(0);
|
|
19
|
+
|
|
20
|
+
useEvent("PLAYER_MONEY", () => { copper.value = loot.money(); });
|
|
21
|
+
|
|
22
|
+
const gained = computed(() => loot.gained(start.value, copper.value));
|
|
23
|
+
|
|
24
|
+
function reset(this: void) {
|
|
25
|
+
return batch(() => { // one save, rolled back together on failure
|
|
26
|
+
start.value = copper.value;
|
|
27
|
+
best.value = 0;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return { gained, best: readonly(best), start: readonly(start), reset };
|
|
32
|
+
}, { persist: { pick: ["best", "start"] } });
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Steps:
|
|
36
|
+
|
|
37
|
+
1. Put the store in the owning feature's `model/` and list it in that module's `stores`.
|
|
38
|
+
2. Return refs for state, `readonly(ref)` for state with rules, `computed` for derived state, functions for actions.
|
|
39
|
+
3. Save fields with `persist: { pick: [...] }`; add `perCharacter: true` for per-character data. The addon's `savedVariables` in `kumi.config.ts` holds them.
|
|
40
|
+
4. Actions call services. Never call WoW from a store; add an `api/` function and a service method.
|
|
41
|
+
5. Read it anywhere with `useLootStore()`. In JSX use `const { gained } = storeToRefs(useLootStore())`.
|
|
42
|
+
|
|
43
|
+
Notes:
|
|
44
|
+
|
|
45
|
+
- Inside setup, `computed(...).value` is a `Result`. Share a plain function between computed values instead of reading one from another.
|
|
46
|
+
- A store used by several features stays in the feature that owns the data; others import that feature's module.
|
|
47
|
+
- `store.$patch({ ... })` writes several writable fields from outside.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kumi-ui
|
|
3
|
+
description: Build Kumi UI - TSX components, widgets, HUD views, window pages, SCSS styles, forms and animations. Use when adding or changing anything the player sees in a Kumi addon.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build UI
|
|
7
|
+
|
|
8
|
+
## A component (`ui/`)
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import type { Binding, NodeRef } from "@kumi/core";
|
|
12
|
+
import styles from "@kumi/styles/modules/loot/ui/Loot";
|
|
13
|
+
|
|
14
|
+
interface LootRowProps {
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly value: Binding<string>;
|
|
17
|
+
readonly ref?: NodeRef<"frame">;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function LootRow(props: LootRowProps) {
|
|
21
|
+
return (
|
|
22
|
+
<div className={styles.row} nodeRef={props.ref}>
|
|
23
|
+
<span className={styles.label} value={props.label} />
|
|
24
|
+
<span className={styles.value} value={props.value} />
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
One read-only props object, an optional `ref`, changing data as bindings.
|
|
31
|
+
|
|
32
|
+
## A widget (`widgets/`)
|
|
33
|
+
|
|
34
|
+
Widgets read stores and compose components:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
export function LootPanel() {
|
|
38
|
+
const loot = useLootStore();
|
|
39
|
+
const { gained } = storeToRefs(loot);
|
|
40
|
+
return <LootRow label="Gold" value={computed(() => formatMoney(gained.value))} />;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- On screen all the time: list it in the module's `views`.
|
|
45
|
+
- As a window page: create `src/app/routes/(window)/<name>/page.tsx` with `export const title = "..."` and `export default function Page() { return <LootPanel />; }`.
|
|
46
|
+
- As a plugin page: list `{ path, title, component }` in the module's `pages`.
|
|
47
|
+
|
|
48
|
+
## Styles
|
|
49
|
+
|
|
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
|
+
|
|
52
|
+
## Lists
|
|
53
|
+
|
|
54
|
+
`{rows.value.map(row => <LootRow key={row.id} ... />)}` over a ref. For a store field: `const { rows } = storeToRefs(store)`.
|
|
55
|
+
|
|
56
|
+
## Forms
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const form = useForm<Settings>({ defaultValues: DEFAULTS, values: store, commit: store.updateSettings, validate });
|
|
60
|
+
<Form form={form}>{() => <Toggle {...form.register("enabled")} label="Enabled" />}</Form>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Animation
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
const refresh = useAnimation(presets.fadeIn({ from: 0.25 }));
|
|
67
|
+
watch(() => count.value, () => { refresh.play(); });
|
|
68
|
+
<span ref={refresh.ref} value={label} />
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Text: alpha presets (`fadeIn`, `flash`, `pulse`). Scale presets (`popIn`, `hop`) on icons and frames only: scaling text stretches it.
|
|
72
|
+
|
|
73
|
+
Reusable controls go in `src/shared/ui` and take everything through props.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kumi-wow-api
|
|
3
|
+
description: Call the World of Warcraft API from a Kumi addon - wrap a game function in the api layer, handle secret values, subscribe to events, and bind secure buttons for items, spells and toys. Use when a feature needs data or actions from the game.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Use the WoW API
|
|
7
|
+
|
|
8
|
+
1. Find the function in `build/types/wow-api.d.ts` (generated by `npm run check`). It has the exact parameters and results.
|
|
9
|
+
2. Wrap it in the feature's `api/` folder, returning plain values:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { api, readableApi } from "@kumi/wow";
|
|
13
|
+
|
|
14
|
+
export function readTargetName(): string | undefined {
|
|
15
|
+
const [name] = readableApi.UnitName("target"); // undefined while the client hides it
|
|
16
|
+
return name;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function readBagSlots(bag: number): number {
|
|
20
|
+
return api.C_Container.GetContainerNumSlots(bag);
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use `readableApi` when it has the function: it turns secret values into `undefined`. Destructure multiple results in one statement.
|
|
25
|
+
3. Call the `api/` function from a service. Stores call the service.
|
|
26
|
+
4. Events: `useEvent("BAG_UPDATE_DELAYED", () => { ... })` in a store setup, or `@OnEvent("BAG_UPDATE_DELAYED")` on a service method. Payloads are typed.
|
|
27
|
+
5. Actions that need a click (use an item, cast a spell): a button with `secureAction={{ kind: "item", id: 6948 }}` inside a module view. Cooldown: `readCooldownTiming(kind, id)` from `@kumi/wow` with `<cooldown value={timing} />`.
|
|
28
|
+
6. Disable protected actions during combat with `useCombat()`.
|
|
29
|
+
|
|
30
|
+
Never call WoW from `services/`, `model/`, `ui/` or `widgets/` directly; ESLint reports it.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kumi-build-debug
|
|
3
|
+
description: Run, build and debug a Kumi addon - check, build, link to the game, and fix TypeScript, ESLint, style and native compiler errors. Use when npm run check or npm run build fails, or to test a change in the game.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build and fix
|
|
7
|
+
|
|
8
|
+
```powershell
|
|
9
|
+
npm run check
|
|
10
|
+
npm run build -- --target forever
|
|
11
|
+
npm run link -- "<game>/_forever_/Interface/AddOns" # once
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Then `/reload` in the game. Lua errors appear in BugSack or the default error frame.
|
|
15
|
+
|
|
16
|
+
## Reading errors
|
|
17
|
+
|
|
18
|
+
Errors name `file:line:column`. Fix the first one and rerun.
|
|
19
|
+
|
|
20
|
+
| Message | Fix |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| `... import is restricted ...` | The code is in the wrong layer. Move the call down a layer (component → store action → service → api). |
|
|
23
|
+
| `Unsupported property X` | That CSS property is not supported. Use a supported one (see the kumi-ui skill). |
|
|
24
|
+
| `Iteration currently requires a native collection` | Loop over an array you created, or a store/ref value. For data from Lua tables, copy it into an array first. |
|
|
25
|
+
| `Array length requires a proven dense representation` | The array comes from outside; build your own array, or use a typed list from the SDK. |
|
|
26
|
+
| `Destructure native multiple results from calls` | Write `const [a, b] = api.F()` in one statement. |
|
|
27
|
+
| `Circular runtime import` | Two files import each other. Move the shared part into a third file. |
|
|
28
|
+
| `Method signatures require an explicit this type` | Often a RegExp or a library method. Use string methods instead of regular expressions. |
|
|
29
|
+
| `inject(X) works only inside the setup of a store listed in a module's stores` | List the store in its module's `stores`, and call `inject` at the top of setup. |
|
|
30
|
+
| `Store X persists fields but has no storage` | Set `addon.savedVariables` in `kumi.config.ts`. |
|
|
31
|
+
| `X belongs to plugin Y, but Z imports it` | Core code imports a plugin file. Use `import type` or move the code into a core module. |
|
|
32
|
+
|
|
33
|
+
## In the game
|
|
34
|
+
|
|
35
|
+
- Nothing appears: check that the addon and its plugins are enabled in the addon list, and that the build was linked.
|
|
36
|
+
- A plugin shows "Failed" in the Plugins page: its error text says why; fix it, rebuild, `/reload`.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kumi-feature
|
|
3
|
+
description: Add a new feature module to a Kumi addon with its api, services, model, ui and widgets layers, and wire it into the app module. Use when the user asks for a new feature, panel, tracker or system in a Kumi project.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Add a feature
|
|
7
|
+
|
|
8
|
+
1. Pick a short lowercase name, for example `loot`. Create `src/modules/loot/` with the folders you need: `api/`, `services/`, `model/`, `ui/`, `widgets/`.
|
|
9
|
+
2. **api/**: one function per WoW call, returning plain values.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// src/modules/loot/api/money.api.ts
|
|
13
|
+
import { api } from "@kumi/wow";
|
|
14
|
+
export function readMoney(): number { return api.GetMoney(); }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
3. **services/**: the logic, as an `@Injectable` class that calls `api/`.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
@Injectable()
|
|
21
|
+
export class LootService {
|
|
22
|
+
money() { return readMoney(); }
|
|
23
|
+
gained(start: number, now: number) { return Math.max(0, now - start); }
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
4. **model/**: a store that injects the service. See the kumi-store skill.
|
|
28
|
+
5. **ui/** and **widgets/**: components that read the store. See the kumi-ui skill.
|
|
29
|
+
6. **loot.module.ts**: the manifest and public API.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
export { useLootStore } from "./model/loot.store";
|
|
33
|
+
|
|
34
|
+
const metadata = {
|
|
35
|
+
id: "loot",
|
|
36
|
+
imports: [], // other features this one reads, by their module class
|
|
37
|
+
providers: [LootService],
|
|
38
|
+
stores: [useLootStore],
|
|
39
|
+
views: [], // HUD widgets to show while the feature runs
|
|
40
|
+
exports: {},
|
|
41
|
+
} as const;
|
|
42
|
+
|
|
43
|
+
@Module(metadata)
|
|
44
|
+
export class LootModule extends ModuleType<typeof metadata> {}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
7. Add `LootModule` to `imports` in `src/app/app.module.ts`. If the feature should be optional, make it a plugin instead (kumi-plugin skill) and do not import it.
|
|
48
|
+
8. Run `npm run check` and `npm run build -- --target forever`.
|
|
49
|
+
|
|
50
|
+
Rules: other features import only `loot.module.ts`. Components never import `api/` or `services/`.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kumi-plugin
|
|
3
|
+
description: Add a plugin to a Kumi addon - an optional part that players turn on or off, built as its own addon - or load a part on demand. Use when a feature should be optional, separately toggleable, or loaded only when opened.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Add a plugin
|
|
7
|
+
|
|
8
|
+
1. Write the plugin as a normal feature module under `src/modules/<id>/` (kumi-feature skill). It may import core modules, but core code must not import its files.
|
|
9
|
+
2. Add it to `kumi.config.ts`:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
plugins: {
|
|
13
|
+
loot: {
|
|
14
|
+
module: "src/modules/loot/loot.module.ts",
|
|
15
|
+
title: "Loot",
|
|
16
|
+
notes: "Counts gold and items",
|
|
17
|
+
load: "startup", // or "demand" to load on first use
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
pluginState: "character", // or "account"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
3. Do not add the module to `app.module.ts` imports. Kumi starts startup plugins itself.
|
|
24
|
+
4. Contribute UI from the plugin's module: `views` for HUD panels, `pages` for window pages, `extensions` for slots such as `"hud.footer"`.
|
|
25
|
+
5. For a demand plugin, load it from a store action or a button:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
const loaded = usePlugins().load("loot");
|
|
29
|
+
if (loaded.ok) { /* loaded.value has the module's exports */ }
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
6. Run `npm run check` (generates the typed plugin list) and `npm run build -- --target forever`. The build creates `build/addons/<Addon>_<id>/`. Run `npm run link -- <AddOns>` again once so the new folder is linked.
|
|
33
|
+
|
|
34
|
+
The Plugins page (`src/app/routes/(window)/plugins/page.tsx`) lists plugins with `usePlugins()`. Turning one off asks for a reload.
|
|
35
|
+
|
|
36
|
+
If the build says a file "belongs to plugin X, but <Addon> imports it": core code imports a file from the plugin's folder. Use `import type`, or move the shared code into a core module.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kumi-store
|
|
3
|
+
description: Create or change a Kumi store (defineStore) - state, computed values, actions that call services, saving to SavedVariables, batch updates, events and timers. Use when adding state, settings or saved data to a Kumi addon.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Write a store
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
// src/modules/loot/model/loot.store.ts
|
|
10
|
+
import { batch, computed, defineStore, inject, readonly, ref } from "@kumi/state";
|
|
11
|
+
import { useEvent } from "@kumi/wow";
|
|
12
|
+
import { LootService } from "../services/loot.service";
|
|
13
|
+
|
|
14
|
+
export const useLootStore = defineStore("loot", () => {
|
|
15
|
+
const loot = inject(LootService); // only in a store listed in a module's `stores`
|
|
16
|
+
const start = ref(loot.money());
|
|
17
|
+
const copper = ref(loot.money());
|
|
18
|
+
const best = ref(0);
|
|
19
|
+
|
|
20
|
+
useEvent("PLAYER_MONEY", () => { copper.value = loot.money(); });
|
|
21
|
+
|
|
22
|
+
const gained = computed(() => loot.gained(start.value, copper.value));
|
|
23
|
+
|
|
24
|
+
function reset(this: void) {
|
|
25
|
+
return batch(() => { // one save, rolled back together on failure
|
|
26
|
+
start.value = copper.value;
|
|
27
|
+
best.value = 0;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return { gained, best: readonly(best), start: readonly(start), reset };
|
|
32
|
+
}, { persist: { pick: ["best", "start"] } });
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Steps:
|
|
36
|
+
|
|
37
|
+
1. Put the store in the owning feature's `model/` and list it in that module's `stores`.
|
|
38
|
+
2. Return refs for state, `readonly(ref)` for state with rules, `computed` for derived state, functions for actions.
|
|
39
|
+
3. Save fields with `persist: { pick: [...] }`; add `perCharacter: true` for per-character data. The addon's `savedVariables` in `kumi.config.ts` holds them.
|
|
40
|
+
4. Actions call services. Never call WoW from a store; add an `api/` function and a service method.
|
|
41
|
+
5. Read it anywhere with `useLootStore()`. In JSX use `const { gained } = storeToRefs(useLootStore())`.
|
|
42
|
+
|
|
43
|
+
Notes:
|
|
44
|
+
|
|
45
|
+
- Inside setup, `computed(...).value` is a `Result`. Share a plain function between computed values instead of reading one from another.
|
|
46
|
+
- A store used by several features stays in the feature that owns the data; others import that feature's module.
|
|
47
|
+
- `store.$patch({ ... })` writes several writable fields from outside.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kumi-ui
|
|
3
|
+
description: Build Kumi UI - TSX components, widgets, HUD views, window pages, SCSS styles, forms and animations. Use when adding or changing anything the player sees in a Kumi addon.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build UI
|
|
7
|
+
|
|
8
|
+
## A component (`ui/`)
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import type { Binding, NodeRef } from "@kumi/core";
|
|
12
|
+
import styles from "@kumi/styles/modules/loot/ui/Loot";
|
|
13
|
+
|
|
14
|
+
interface LootRowProps {
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly value: Binding<string>;
|
|
17
|
+
readonly ref?: NodeRef<"frame">;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function LootRow(props: LootRowProps) {
|
|
21
|
+
return (
|
|
22
|
+
<div className={styles.row} nodeRef={props.ref}>
|
|
23
|
+
<span className={styles.label} value={props.label} />
|
|
24
|
+
<span className={styles.value} value={props.value} />
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
One read-only props object, an optional `ref`, changing data as bindings.
|
|
31
|
+
|
|
32
|
+
## A widget (`widgets/`)
|
|
33
|
+
|
|
34
|
+
Widgets read stores and compose components:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
export function LootPanel() {
|
|
38
|
+
const loot = useLootStore();
|
|
39
|
+
const { gained } = storeToRefs(loot);
|
|
40
|
+
return <LootRow label="Gold" value={computed(() => formatMoney(gained.value))} />;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- On screen all the time: list it in the module's `views`.
|
|
45
|
+
- As a window page: create `src/app/routes/(window)/<name>/page.tsx` with `export const title = "..."` and `export default function Page() { return <LootPanel />; }`.
|
|
46
|
+
- As a plugin page: list `{ path, title, component }` in the module's `pages`.
|
|
47
|
+
|
|
48
|
+
## Styles
|
|
49
|
+
|
|
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
|
+
|
|
52
|
+
## Lists
|
|
53
|
+
|
|
54
|
+
`{rows.value.map(row => <LootRow key={row.id} ... />)}` over a ref. For a store field: `const { rows } = storeToRefs(store)`.
|
|
55
|
+
|
|
56
|
+
## Forms
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const form = useForm<Settings>({ defaultValues: DEFAULTS, values: store, commit: store.updateSettings, validate });
|
|
60
|
+
<Form form={form}>{() => <Toggle {...form.register("enabled")} label="Enabled" />}</Form>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Animation
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
const refresh = useAnimation(presets.fadeIn({ from: 0.25 }));
|
|
67
|
+
watch(() => count.value, () => { refresh.play(); });
|
|
68
|
+
<span ref={refresh.ref} value={label} />
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Text: alpha presets (`fadeIn`, `flash`, `pulse`). Scale presets (`popIn`, `hop`) on icons and frames only: scaling text stretches it.
|
|
72
|
+
|
|
73
|
+
Reusable controls go in `src/shared/ui` and take everything through props.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kumi-wow-api
|
|
3
|
+
description: Call the World of Warcraft API from a Kumi addon - wrap a game function in the api layer, handle secret values, subscribe to events, and bind secure buttons for items, spells and toys. Use when a feature needs data or actions from the game.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Use the WoW API
|
|
7
|
+
|
|
8
|
+
1. Find the function in `build/types/wow-api.d.ts` (generated by `npm run check`). It has the exact parameters and results.
|
|
9
|
+
2. Wrap it in the feature's `api/` folder, returning plain values:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { api, readableApi } from "@kumi/wow";
|
|
13
|
+
|
|
14
|
+
export function readTargetName(): string | undefined {
|
|
15
|
+
const [name] = readableApi.UnitName("target"); // undefined while the client hides it
|
|
16
|
+
return name;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function readBagSlots(bag: number): number {
|
|
20
|
+
return api.C_Container.GetContainerNumSlots(bag);
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use `readableApi` when it has the function: it turns secret values into `undefined`. Destructure multiple results in one statement.
|
|
25
|
+
3. Call the `api/` function from a service. Stores call the service.
|
|
26
|
+
4. Events: `useEvent("BAG_UPDATE_DELAYED", () => { ... })` in a store setup, or `@OnEvent("BAG_UPDATE_DELAYED")` on a service method. Payloads are typed.
|
|
27
|
+
5. Actions that need a click (use an item, cast a spell): a button with `secureAction={{ kind: "item", id: 6948 }}` inside a module view. Cooldown: `readCooldownTiming(kind, id)` from `@kumi/wow` with `<cooldown value={timing} />`.
|
|
28
|
+
6. Disable protected actions during combat with `useCombat()`.
|
|
29
|
+
|
|
30
|
+
Never call WoW from `services/`, `model/`, `ui/` or `widgets/` directly; ESLint reports it.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Working on this addon
|
|
2
|
+
|
|
3
|
+
This addon is written with Kumi: TypeScript and TSX compiled to Lua 5.1 for World of Warcraft. Follow these rules; `npm run check` enforces most of them.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
- `src/app`: startup (`main.ts`), the root module (`app.module.ts`), the theme, the window layout and the window's pages in `routes/`. Pages are thin and render widgets.
|
|
8
|
+
- `src/modules/<feature>`: one folder per feature.
|
|
9
|
+
- `<feature>.module.ts`: the `@Module` manifest and the feature's public API. Other features import only this file.
|
|
10
|
+
- `api/`: one small function per WoW call, plain values in and out. The only place that uses `api`, `readableApi` or game globals.
|
|
11
|
+
- `services/`: `@Injectable` classes with the logic. They call `api/`.
|
|
12
|
+
- `model/`: stores (`defineStore`). Actions call services, which they get with `inject` during setup.
|
|
13
|
+
- `ui/`: components. `widgets/`: screens built from components (HUD views, page contents).
|
|
14
|
+
- `src/shared`: reusable code that knows nothing about the addon's features: `ui/` controls, `styles/` tokens, `lib/` helpers, `api/` art and fonts.
|
|
15
|
+
|
|
16
|
+
Dependencies go one way: `ui/widgets → model → services → api → @kumi/wow`.
|
|
17
|
+
|
|
18
|
+
## Code
|
|
19
|
+
|
|
20
|
+
- Components are PascalCase functions with one typed, read-only props object and an optional `ref` forwarded with `nodeRef`. Pass changing data as bindings (refs, computed values, `storeToRefs` fields); do not read `.value` once at setup.
|
|
21
|
+
- Lists in JSX: `{items.value.map(item => <Row key={item.id} ... />)}` over a ref, so the list updates.
|
|
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
|
+
- 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.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
|
+
- WoW events: `useEvent` in stores and components, `@OnEvent` in services. Timers: `useNow`. Combat: `useCombat`. Slash commands: `useSlashCommand`.
|
|
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
|
+
|
|
28
|
+
## Checks
|
|
29
|
+
|
|
30
|
+
Run `npm run check` and `npm run build -- --target forever` after every change. Fix the first error first; Kumi's errors name the file, line and fix.
|
|
31
|
+
|
|
32
|
+
## Skills
|
|
33
|
+
|
|
34
|
+
Step-by-step guides for common tasks are in `.claude/skills/` and `.agents/skills/`: a new feature, a store, UI, a plugin, a WoW call, and fixing a failed build.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|