@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 @@
|
|
|
1
|
+
@AGENTS.md
|
|
@@ -1,14 +1,49 @@
|
|
|
1
1
|
# __ADDON_NAME__
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A World of Warcraft addon built with [Kumi](https://github.com/OverMVP/kumi): TypeScript and TSX, compiled to Lua.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Commands
|
|
6
6
|
|
|
7
|
-
```
|
|
7
|
+
```powershell
|
|
8
8
|
npm install
|
|
9
|
-
npm run check
|
|
10
|
-
npm run build
|
|
11
|
-
npm run link -- "
|
|
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
12
|
```
|
|
13
13
|
|
|
14
|
-
|
|
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
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import ts from "@typescript-eslint/eslint-plugin";
|
|
2
2
|
import parser from "@typescript-eslint/parser";
|
|
3
|
+
import { kumiRules } from "__KUMI_PACKAGE__/eslint.mjs";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
languageOptions: { parser },
|
|
7
|
-
plugins: { "@typescript-eslint": ts },
|
|
8
|
-
rules: {
|
|
9
|
-
"no-debugger": "error",
|
|
10
|
-
"@typescript-eslint/consistent-type-imports": "error",
|
|
11
|
-
},
|
|
12
|
-
}];
|
|
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,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;
|
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"typecheck": "npm run prepare:types && tsc -p tsconfig.json",
|
|
7
|
+
"typecheck": "kumi check --types-only",
|
|
9
8
|
"lint": "eslint src",
|
|
10
|
-
"check": "
|
|
11
|
-
"build": "
|
|
12
|
-
"link": "kumi link
|
|
9
|
+
"check": "kumi check",
|
|
10
|
+
"build": "kumi build",
|
|
11
|
+
"link": "kumi link"
|
|
13
12
|
},
|
|
14
13
|
"devDependencies": {
|
|
15
14
|
"__KUMI_PACKAGE__": "__KUMI_VERSION__",
|
|
@@ -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,90 @@
|
|
|
1
|
+
.window {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
width: 460px;
|
|
5
|
+
height: 360px;
|
|
6
|
+
background-color: var(--color-panel);
|
|
7
|
+
border: 1px solid var(--color-line);
|
|
8
|
+
border-radius: 8px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.header {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: 10px;
|
|
15
|
+
height: 36px;
|
|
16
|
+
padding: 0 12px 0 16px;
|
|
17
|
+
margin: 1px 1px 0;
|
|
18
|
+
background-color: var(--color-header);
|
|
19
|
+
border-radius: 6px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.title {
|
|
23
|
+
flex-grow: 1;
|
|
24
|
+
font-size: 15px;
|
|
25
|
+
text-align: left;
|
|
26
|
+
color: var(--color-gold);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.close {
|
|
30
|
+
width: 26px;
|
|
31
|
+
min-width: 26px;
|
|
32
|
+
height: 26px;
|
|
33
|
+
border-radius: 4px;
|
|
34
|
+
background-color: var(--color-header);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.close:hover { background-color: var(--color-raised); }
|
|
38
|
+
|
|
39
|
+
.tabs {
|
|
40
|
+
display: flex;
|
|
41
|
+
gap: 6px;
|
|
42
|
+
padding: 8px 16px 0;
|
|
43
|
+
border-bottom: 1px solid var(--color-line);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.content {
|
|
47
|
+
flex-grow: 1;
|
|
48
|
+
min-height: 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.page {
|
|
52
|
+
position: absolute;
|
|
53
|
+
inset: 0;
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.list {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
gap: 10px;
|
|
62
|
+
padding: 16px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.listRow {
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
gap: 12px;
|
|
69
|
+
height: 44px;
|
|
70
|
+
border-bottom: 1px solid var(--color-line);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.listText {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
flex-grow: 1;
|
|
77
|
+
gap: 2px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.listTitle {
|
|
81
|
+
font-size: 14px;
|
|
82
|
+
text-align: left;
|
|
83
|
+
color: var(--color-text);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.listNote {
|
|
87
|
+
font-size: 12px;
|
|
88
|
+
text-align: left;
|
|
89
|
+
color: var(--color-muted);
|
|
90
|
+
}
|
|
@@ -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,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,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,103 @@
|
|
|
1
|
+
.card {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 6px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/* Room for two lines, so the panel keeps its height when the text gets shorter. */
|
|
8
|
+
.message {
|
|
9
|
+
height: 36px;
|
|
10
|
+
font-size: 15px;
|
|
11
|
+
text-align: left;
|
|
12
|
+
color: var(--color-text);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.money {
|
|
16
|
+
font-size: 13px;
|
|
17
|
+
text-align: left;
|
|
18
|
+
color: var(--color-gold);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.notice {
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
text-align: left;
|
|
24
|
+
color: var(--color-muted);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.hud {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
gap: 10px;
|
|
31
|
+
width: 280px;
|
|
32
|
+
padding: 10px 12px 12px;
|
|
33
|
+
background-color: var(--color-panel);
|
|
34
|
+
border: 1px solid var(--color-line);
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.hudHeader {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: 8px;
|
|
42
|
+
height: 24px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.hudTitle {
|
|
46
|
+
flex-grow: 1;
|
|
47
|
+
font-size: 14px;
|
|
48
|
+
text-align: left;
|
|
49
|
+
color: var(--color-muted);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.iconButton {
|
|
53
|
+
width: 26px;
|
|
54
|
+
min-width: 26px;
|
|
55
|
+
height: 24px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.grip {
|
|
59
|
+
width: 20px;
|
|
60
|
+
height: 20px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.footer {
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
gap: 8px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.spacer { flex-grow: 1; }
|
|
70
|
+
|
|
71
|
+
.settings {
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
gap: 14px;
|
|
75
|
+
padding: 16px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.row {
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
gap: 12px;
|
|
82
|
+
height: 32px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.rowLabel {
|
|
86
|
+
width: 120px;
|
|
87
|
+
font-size: 14px;
|
|
88
|
+
text-align: left;
|
|
89
|
+
color: var(--color-text);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.hint {
|
|
93
|
+
font-size: 13px;
|
|
94
|
+
text-align: left;
|
|
95
|
+
color: var(--color-muted);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.overview {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
gap: 14px;
|
|
102
|
+
padding: 16px;
|
|
103
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Binding, NodeRef } from "@kumi/core";
|
|
2
|
+
import { presets } from "@kumi/animation";
|
|
3
|
+
import { computed, watch, type ReadonlyRef } from "@kumi/state";
|
|
4
|
+
import styles from "@kumi/styles/modules/greeting/ui/Greeting";
|
|
5
|
+
import { useAnimation } from "@kumi/wow";
|
|
6
|
+
|
|
7
|
+
interface GreetingCardProps {
|
|
8
|
+
readonly message: Binding<string>;
|
|
9
|
+
readonly money: Binding<string>;
|
|
10
|
+
/** A short note under the money, such as why an action did not work. Hidden while empty. */
|
|
11
|
+
readonly notice: ReadonlyRef<string>;
|
|
12
|
+
/** Each change fades the message in again. */
|
|
13
|
+
readonly waves: ReadonlyRef<number>;
|
|
14
|
+
readonly ref?: NodeRef<"frame">;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The greeting text and the player's money. */
|
|
18
|
+
export function GreetingCard(props: GreetingCardProps) {
|
|
19
|
+
// Fade the new text in. Text uses alpha, not scale: scaling a font string stretches its glyphs.
|
|
20
|
+
const refresh = useAnimation(presets.fadeIn({ from: 0.25, duration: 0.3 }));
|
|
21
|
+
watch(() => props.waves.value, () => { refresh.play(); });
|
|
22
|
+
return (
|
|
23
|
+
<div className={styles.card} nodeRef={props.ref}>
|
|
24
|
+
<span className={styles.message} value={props.message} ref={refresh.ref} />
|
|
25
|
+
<span className={styles.money} value={props.money} />
|
|
26
|
+
<span className={styles.notice} value={props.notice} shown={computed(() => props.notice.value !== "")} />
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|