@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.
- package/LICENSE +21 -0
- package/README.md +67 -2
- package/animation/color-transition.ts +196 -0
- package/animation/cycle.ts +151 -0
- package/animation/ease.ts +29 -0
- package/animation/index.ts +13 -0
- package/animation/package.json +12 -0
- package/animation/presets.ts +376 -0
- package/animation/spec.ts +197 -0
- package/builder/Cargo.lock +192 -0
- package/builder/Cargo.toml +7 -0
- package/builder/css-v1.mjs +387 -0
- package/builder/css-v1.test.mjs +361 -0
- package/builder/generated-output.mjs +61 -0
- package/builder/generated-output.test.mjs +132 -0
- package/builder/jsx-form.mjs +93 -0
- package/builder/jsx-form.test.mjs +48 -0
- package/builder/jsx-lists.mjs +209 -0
- package/builder/link-addon-package.mjs +127 -0
- package/builder/lua-assets.mjs +74 -0
- package/builder/lua-builtin-values.mjs +57 -0
- package/builder/lua-builtin-values.test.mjs +155 -0
- package/builder/lua-loop-closures.mjs +183 -0
- package/builder/lua-loop-closures.test.mjs +89 -0
- package/builder/lua-truthiness.mjs +61 -0
- package/builder/lua-truthiness.test.mjs +113 -0
- package/builder/module-declarations.mjs +594 -0
- package/builder/module-declarations.test.mjs +435 -0
- package/builder/native-kernels.mjs +60 -0
- package/builder/native-lua.d.ts +57 -0
- package/builder/native-routes.mjs +51 -0
- package/builder/no-static-ref-read.mjs +93 -0
- package/builder/no-static-ref-read.test.mjs +181 -0
- package/builder/secure-snippet.mjs +317 -0
- package/builder/secure-snippet.test.mjs +101 -0
- package/builder/shared-lua-runtime.mjs +150 -0
- package/builder/src/addon-link.lua +29 -0
- package/builder/src/arrays.lua +260 -0
- package/builder/src/assets.rs +177 -0
- package/builder/src/classes.lua +75 -0
- package/builder/src/collections.lua +190 -0
- package/builder/src/compiler.rs +2336 -0
- package/builder/src/config.rs +42 -0
- package/builder/src/entries.rs +166 -0
- package/builder/src/errors.lua +15 -0
- package/builder/src/lua_data.rs +231 -0
- package/builder/src/main.rs +381 -0
- package/builder/src/native_ir.rs +65 -0
- package/builder/src/native_signal.rs +83 -0
- package/builder/src/numbers.lua +76 -0
- package/builder/src/project-front.mjs +3682 -0
- package/builder/src/records.lua +75 -0
- package/builder/src/routes.rs +124 -0
- package/builder/src/setup-store.lua +18 -0
- package/builder/src/signal-kernel.fingerprint +1 -0
- package/builder/src/strings.lua +103 -0
- package/builder/src/ts-lower.mjs +68 -0
- package/builder/src/wow-reads.lua +22 -0
- package/builder/src/wow_client.rs +253 -0
- package/builder/src/wow_types.rs +564 -0
- package/builder/style-modules.mjs +93 -0
- package/builder/style-states.mjs +100 -0
- package/builder/style-states.test.mjs +103 -0
- package/builder/vite-assets.mjs +53 -0
- package/builder/vite-project.mjs +10 -0
- package/config.ts +59 -0
- package/eslint.mjs +74 -0
- package/form/index.ts +526 -0
- package/form/package.json +13 -0
- package/motion/index.ts +2 -0
- package/motion/package.json +10 -0
- package/package.json +26 -4
- package/router/index.ts +50 -0
- package/router/navigation.ts +22 -0
- package/router/package.json +12 -0
- package/router/router-view.ts +134 -0
- package/router/routes.ts +64 -0
- package/scripts/addon-build.mjs +364 -0
- package/scripts/addon-project.mjs +78 -0
- package/scripts/kumi-cli.mjs +105 -0
- package/scripts/link-addons.mjs +61 -0
- package/src/bindings.ts +35 -0
- package/src/context.ts +15 -0
- package/src/css-tokens.ts +239 -0
- package/src/css-v1.ts +68 -0
- package/src/cvars.ts +91 -0
- package/src/element-node.ts +32 -0
- package/src/elements.ts +505 -0
- package/src/feature-scope.ts +82 -0
- package/src/flex-layout.ts +807 -0
- package/src/frame-scheduler.ts +336 -0
- package/src/grid-tracks.ts +165 -0
- package/src/image-imports.d.ts +24 -0
- package/src/images.ts +79 -0
- package/src/index.ts +29 -0
- package/src/jsx-dev-runtime.ts +2 -0
- package/src/jsx-runtime.ts +29 -0
- package/src/jsx.d.ts +12 -0
- package/src/keyed-list.ts +366 -0
- package/src/media-query.ts +144 -0
- package/src/module-ui.ts +147 -0
- package/src/module.ts +311 -0
- package/src/node-selectors.ts +114 -0
- package/src/owned-collections.ts +52 -0
- package/src/providers.ts +241 -0
- package/src/reactive-scope.ts +34 -0
- package/src/reactivity.ts +275 -0
- package/src/result.ts +64 -0
- package/src/runtime.ts +52 -0
- package/src/scheduler.ts +185 -0
- package/src/signal-kernel.ts +63 -0
- package/src/style-classes.ts +51 -0
- package/src/style-states.ts +134 -0
- package/src/style-variables.ts +53 -0
- package/src/text-children.ts +42 -0
- package/src/theme.ts +50 -0
- package/src/transition.ts +18 -0
- package/state/index.ts +9 -0
- package/state/package.json +12 -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-bindings.ts +25 -0
- package/state/store.ts +84 -0
- package/styles/_layers.scss +14 -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 +49 -0
- package/templates/addon/eslint.config.mjs +6 -0
- package/templates/addon/gitignore +9 -0
- package/templates/addon/kumi.config.ts +17 -0
- package/templates/addon/package.json +20 -0
- 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.scss +92 -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.scss +105 -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.scss +25 -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.scss +12 -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.scss +93 -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 +63 -0
- package/translate/index.ts +14 -0
- package/translate/package.json +9 -0
- package/utils/colors.ts +76 -0
- package/utils/format.ts +37 -0
- package/utils/index.ts +4 -0
- package/utils/number.ts +17 -0
- package/utils/package.json +7 -0
- package/utils/text.ts +6 -0
- package/validate/index.ts +119 -0
- package/validate/package.json +9 -0
- package/wow/absolute-position.ts +142 -0
- package/wow/action-bar-layout.ts +108 -0
- package/wow/action-button.ts +219 -0
- package/wow/action-catalog.ts +98 -0
- package/wow/addon-manifest.ts +36 -0
- package/wow/animation.ts +428 -0
- package/wow/app-ui.ts +221 -0
- package/wow/aura-button.ts +76 -0
- package/wow/aura-container.ts +591 -0
- package/wow/aura-countdown.ts +201 -0
- package/wow/aura-slot.ts +153 -0
- package/wow/bar-shade.ts +93 -0
- package/wow/borrowed-slot.ts +216 -0
- package/wow/button-drag.ts +48 -0
- package/wow/cast-clock.ts +153 -0
- package/wow/cast-text.ts +83 -0
- package/wow/class-colors.ts +126 -0
- package/wow/clock.ts +7 -0
- package/wow/color-picker.ts +128 -0
- package/wow/commands.ts +17 -0
- package/wow/contained-frame.ts +128 -0
- package/wow/contract.ts +42 -0
- package/wow/cooldown-timing.ts +24 -0
- package/wow/css-box.ts +144 -0
- package/wow/css-color.ts +12 -0
- package/wow/css-style.ts +109 -0
- package/wow/css-surfaces.ts +603 -0
- package/wow/css-text.ts +399 -0
- package/wow/cursor.ts +45 -0
- package/wow/cvar-schema.ts +32 -0
- package/wow/cvars.ts +98 -0
- package/wow/dropdown-art.ts +39 -0
- package/wow/element-click.ts +20 -0
- package/wow/element-event-coordinator.ts +219 -0
- package/wow/element-events.ts +317 -0
- package/wow/event-dispatcher.ts +151 -0
- package/wow/events.ts +50 -0
- package/wow/font-cache.ts +92 -0
- package/wow/frame-access.ts +53 -0
- package/wow/frame-layer.ts +5 -0
- package/wow/frame-timing.ts +13 -0
- package/wow/frames.ts +236 -0
- package/wow/heal-prediction.ts +305 -0
- package/wow/hooks.ts +133 -0
- package/wow/image-layers.ts +55 -0
- package/wow/index.ts +111 -0
- package/wow/layout-view.ts +663 -0
- package/wow/locale-font.ts +15 -0
- package/wow/lua-string.ts +18 -0
- package/wow/lua-table.ts +18 -0
- package/wow/macro-book.ts +84 -0
- package/wow/map-position.ts +27 -0
- package/wow/media-query.ts +65 -0
- package/wow/module-events.ts +11 -0
- package/wow/native-hooks.ts +168 -0
- package/wow/native-placement.ts +88 -0
- package/wow/native.ts +153 -0
- package/wow/number-format.ts +8 -0
- package/wow/number-input.ts +10 -0
- package/wow/panel-host.ts +97 -0
- package/wow/pixel.ts +35 -0
- package/wow/plugins.ts +246 -0
- package/wow/protect.ts +48 -0
- package/wow/protected-layout.ts +133 -0
- package/wow/protected-view.ts +103 -0
- package/wow/range-art.ts +81 -0
- package/wow/readable-api.ts +120 -0
- package/wow/reparent-frame.ts +99 -0
- package/wow/rounded-texture.ts +183 -0
- package/wow/saved-variables.ts +109 -0
- package/wow/scroll-view.ts +64 -0
- package/wow/secret-ref.ts +14 -0
- package/wow/secure-bindings.ts +89 -0
- package/wow/secure-clicks.ts +432 -0
- package/wow/secure-snippet.ts +235 -0
- package/wow/secure-state.ts +130 -0
- package/wow/secure-target-visibility.ts +89 -0
- package/wow/secure-transaction.ts +331 -0
- package/wow/special-window.ts +269 -0
- package/wow/spell-cooldown.ts +36 -0
- package/wow/start-addon.ts +122 -0
- package/wow/state-paint.ts +256 -0
- package/wow/transition.ts +86 -0
- package/wow/unit-button.ts +39 -0
- package/wow/unit-cast.ts +92 -0
- package/wow/unit-health-text.ts +47 -0
- package/wow/view-nodes.ts +304 -0
- package/wow/view.ts +1864 -0
- package/wow/visible-frame-job.ts +34 -0
- package/wow/width-reserve.ts +108 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
local function objectKeys(record)
|
|
2
|
+
local keys = {}
|
|
3
|
+
for key in pairs(record) do keys[#keys + 1] = key end
|
|
4
|
+
return keys
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
local function objectEntries(record)
|
|
8
|
+
local entries = {}
|
|
9
|
+
for key, value in pairs(record) do entries[#entries + 1] = { key, value } end
|
|
10
|
+
return entries
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
local function objectValues(record)
|
|
14
|
+
local values = {}
|
|
15
|
+
for _, value in pairs(record) do values[#values + 1] = value end
|
|
16
|
+
return values
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
local function objectFromEntries(entries)
|
|
20
|
+
local record = {}
|
|
21
|
+
for _, pair in ipairs(entries) do record[pair[1]] = pair[2] end
|
|
22
|
+
return record
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
local function objectDescriptor(record, key)
|
|
26
|
+
if type(record) ~= "table" then return end
|
|
27
|
+
local value = rawget(record, key)
|
|
28
|
+
if value ~= nil then
|
|
29
|
+
return { value = value, writable = true, enumerable = true, configurable = true }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
local function copyFields(target, source)
|
|
34
|
+
for key, value in pairs(source) do target[key] = value end
|
|
35
|
+
return target
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
local function copyAllFields(target, ...)
|
|
39
|
+
for index = 1, select("#", ...) do
|
|
40
|
+
copyFields(target, (select(index, ...)))
|
|
41
|
+
end
|
|
42
|
+
return target
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
local function copyStructuralFields(target, source)
|
|
46
|
+
if type(source) == "table" then
|
|
47
|
+
for key in pairs(source) do target[key] = source[key] end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
local function copyStructuralSources(target, ...)
|
|
52
|
+
for index = 1, select("#", ...) do
|
|
53
|
+
copyStructuralFields(target, (select(index, ...)))
|
|
54
|
+
end
|
|
55
|
+
return target
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
local function restFields(source, skipped)
|
|
59
|
+
local result = {}
|
|
60
|
+
for key, value in pairs(source) do
|
|
61
|
+
if not skipped[key] then result[key] = value end
|
|
62
|
+
end
|
|
63
|
+
return result
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
local function restStructuralFields(source, skipped)
|
|
67
|
+
local result = {}
|
|
68
|
+
for key in pairs(source) do
|
|
69
|
+
if not skipped[key] then result[key] = source[key] end
|
|
70
|
+
end
|
|
71
|
+
return result
|
|
72
|
+
end
|
|
73
|
+
local function tableHas(key, target)
|
|
74
|
+
return target[key] ~= nil
|
|
75
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
use std::collections::BTreeMap;
|
|
2
|
+
use std::fs;
|
|
3
|
+
use std::io;
|
|
4
|
+
use std::path::{Path, PathBuf};
|
|
5
|
+
|
|
6
|
+
pub const SOURCE_DIRECTORY: &str = "src/app/routes";
|
|
7
|
+
|
|
8
|
+
fn files(root: &Path, dir: &Path, found: &mut Vec<PathBuf>) -> io::Result<()> {
|
|
9
|
+
for entry in fs::read_dir(dir)? {
|
|
10
|
+
let entry = entry?;
|
|
11
|
+
let kind = entry.file_type()?;
|
|
12
|
+
let path = entry.path();
|
|
13
|
+
if kind.is_dir() {
|
|
14
|
+
files(root, &path, found)?;
|
|
15
|
+
} else if kind.is_file()
|
|
16
|
+
&& matches!(entry.file_name().to_str(), Some("page.tsx" | "layout.tsx"))
|
|
17
|
+
{
|
|
18
|
+
if let Ok(relative) = path.strip_prefix(root) {
|
|
19
|
+
found.push(relative.to_owned());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
Ok(())
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fn quoted(value: &str) -> String {
|
|
27
|
+
let escaped = value
|
|
28
|
+
.replace('\\', "\\\\")
|
|
29
|
+
.replace('"', "\\\"")
|
|
30
|
+
.replace('\n', "\\n")
|
|
31
|
+
.replace('\r', "\\r");
|
|
32
|
+
format!("\"{escaped}\"")
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fn slash(path: &Path) -> Result<String, Box<dyn std::error::Error>> {
|
|
36
|
+
Ok(path
|
|
37
|
+
.to_str()
|
|
38
|
+
.ok_or("Route paths must be UTF-8")?
|
|
39
|
+
.replace('\\', "/"))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
pub fn generate(
|
|
43
|
+
workspace: &Path,
|
|
44
|
+
output: &Path,
|
|
45
|
+
check: bool,
|
|
46
|
+
) -> Result<(), Box<dyn std::error::Error>> {
|
|
47
|
+
let base = Path::new(SOURCE_DIRECTORY);
|
|
48
|
+
let root = workspace.join(base);
|
|
49
|
+
let mut found = Vec::new();
|
|
50
|
+
files(&root, &root, &mut found).map_err(|error| {
|
|
51
|
+
io::Error::new(
|
|
52
|
+
error.kind(),
|
|
53
|
+
format!("Cannot discover routes in {}: {error}", root.display()),
|
|
54
|
+
)
|
|
55
|
+
})?;
|
|
56
|
+
found.sort();
|
|
57
|
+
let mut routes = BTreeMap::new();
|
|
58
|
+
let mut pages = Vec::new();
|
|
59
|
+
let mut layouts = Vec::new();
|
|
60
|
+
let mut manifest = String::from(
|
|
61
|
+
"// Generated by kumi-pack routes.\nimport { createRouter } from \"@kumi/router\";\nimport { routePaths } from \"./paths\";\nexport type { RoutePath } from \"./paths\";\n",
|
|
62
|
+
);
|
|
63
|
+
for (index, file) in found.iter().enumerate() {
|
|
64
|
+
let name = format!("route{index}");
|
|
65
|
+
let key = slash(file)?;
|
|
66
|
+
let source = format!("../../{}", slash(&base.join(file).with_extension(""))?);
|
|
67
|
+
if file.ends_with("page.tsx") {
|
|
68
|
+
let dirs = file.parent().ok_or("Missing route directory")?;
|
|
69
|
+
let path = slash(dirs)?
|
|
70
|
+
.split('/')
|
|
71
|
+
.filter(|part| !(part.starts_with('(') && part.ends_with(')')))
|
|
72
|
+
.collect::<Vec<_>>()
|
|
73
|
+
.join("/");
|
|
74
|
+
let path = format!("/{path}");
|
|
75
|
+
if let Some(previous) = routes.insert(path.clone(), key.clone()) {
|
|
76
|
+
return Err(format!("Duplicate route {path}: {previous} and {key}").into());
|
|
77
|
+
}
|
|
78
|
+
manifest.push_str(&format!("import * as {name} from {};\n", quoted(&source)));
|
|
79
|
+
pages.push(format!(" {}: {name},\n", quoted(&format!("./{key}"))));
|
|
80
|
+
} else {
|
|
81
|
+
manifest.push_str(&format!("import {name} from {};\n", quoted(&source)));
|
|
82
|
+
layouts.push(format!(" {}: {name},\n", quoted(&format!("./{key}"))));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
manifest.push_str("\nexport const pages = {\n");
|
|
86
|
+
manifest.extend(pages);
|
|
87
|
+
manifest.push_str("};\n\nexport const layouts = {\n");
|
|
88
|
+
manifest.extend(layouts);
|
|
89
|
+
manifest.push_str(
|
|
90
|
+
"};\n\nexport const router = createRouter({ pages, layouts, paths: routePaths });\n",
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
let mut types =
|
|
94
|
+
String::from("// Generated by kumi-pack routes.\nexport const routePaths = [\n");
|
|
95
|
+
for path in routes.keys() {
|
|
96
|
+
types.push_str(&format!(" {},\n", quoted(path)));
|
|
97
|
+
}
|
|
98
|
+
types.push_str("] as const;\n\nexport type RoutePath = typeof routePaths[number];\n");
|
|
99
|
+
let directory = output.join("routes");
|
|
100
|
+
write_generated(&directory.join("paths.ts"), &types, check)?;
|
|
101
|
+
write_generated(&directory.join("index.ts"), &manifest, check)?;
|
|
102
|
+
println!(
|
|
103
|
+
"{} route pages -> {}",
|
|
104
|
+
routes.len(),
|
|
105
|
+
directory.join("index.ts").display()
|
|
106
|
+
);
|
|
107
|
+
Ok(())
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
fn write_generated(file: &Path, source: &str, check: bool) -> io::Result<()> {
|
|
111
|
+
if fs::read_to_string(file).ok().as_deref() != Some(source) {
|
|
112
|
+
if check {
|
|
113
|
+
return Err(io::Error::other(format!(
|
|
114
|
+
"{} is stale; run kumi-pack routes",
|
|
115
|
+
file.display()
|
|
116
|
+
)));
|
|
117
|
+
}
|
|
118
|
+
if let Some(parent) = file.parent() {
|
|
119
|
+
fs::create_dir_all(parent)?;
|
|
120
|
+
}
|
|
121
|
+
fs::write(file, source)?;
|
|
122
|
+
}
|
|
123
|
+
Ok(())
|
|
124
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
local function setupStoreView(fields, accessors)
|
|
2
|
+
return setmetatable(fields, {
|
|
3
|
+
__index = function(_, key)
|
|
4
|
+
local accessor = accessors[key]
|
|
5
|
+
if accessor ~= nil then return (accessor.get()) end
|
|
6
|
+
end,
|
|
7
|
+
__newindex = function(store, key, value)
|
|
8
|
+
local accessor = accessors[key]
|
|
9
|
+
if accessor == nil then
|
|
10
|
+
rawset(store, key, value)
|
|
11
|
+
return
|
|
12
|
+
end
|
|
13
|
+
local write = accessor.set
|
|
14
|
+
if write == nil then error("Cannot assign readonly store field " .. tostring(key), 2) end
|
|
15
|
+
write(value)
|
|
16
|
+
end,
|
|
17
|
+
})
|
|
18
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
faac38b892cdbd3155b8fb05608b1e76e561bb056076bfad110ee59f477c30ca
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
local function byteCharAt(value, offset)
|
|
2
|
+
if offset ~= offset then offset = 0 end
|
|
3
|
+
if offset < 0 or offset >= #value then return "" end
|
|
4
|
+
return value:sub(offset + 1, offset + 1)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
local function byteAt(value, offset)
|
|
8
|
+
if offset >= 0 and offset < #value and offset == math.floor(offset) then
|
|
9
|
+
return value:sub(offset + 1, offset + 1)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
local function byteCharCodeAt(value, offset)
|
|
14
|
+
if offset ~= offset then offset = 0 end
|
|
15
|
+
if offset < 0 or offset >= #value then return 0 / 0 end
|
|
16
|
+
return value:byte(offset + 1)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
local function relativeOffset(offset, length, default)
|
|
20
|
+
if offset == nil then return default end
|
|
21
|
+
if offset ~= offset then return 0 end
|
|
22
|
+
if offset < 0 then return math.max(0, length + math.ceil(offset)) end
|
|
23
|
+
return math.min(length, math.floor(offset))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
local function byteSlice(value, first, last)
|
|
27
|
+
local length = #value
|
|
28
|
+
return value:sub(relativeOffset(first, length, 0) + 1, relativeOffset(last, length, length))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
local function byteSubstring(value, first, last)
|
|
32
|
+
if first < 0 or first ~= first then first = 0 end
|
|
33
|
+
if last ~= nil and (last < 0 or last ~= last) then last = 0 end
|
|
34
|
+
local length = #value
|
|
35
|
+
first = math.min(length, math.floor(first))
|
|
36
|
+
last = last == nil and length or math.min(length, math.floor(last))
|
|
37
|
+
if first > last then first, last = last, first end
|
|
38
|
+
return value:sub(first + 1, last)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
local function byteReplace(value, needle, replacement)
|
|
42
|
+
local first, last = value:find(needle, 1, true)
|
|
43
|
+
if first == nil then return value end
|
|
44
|
+
return value:sub(1, first - 1) .. replacement .. value:sub(last + 1)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
local function byteEndsWith(value, suffix, last)
|
|
48
|
+
local limit = #value
|
|
49
|
+
if last ~= nil then
|
|
50
|
+
if last ~= last or last <= 0 then limit = 0
|
|
51
|
+
else limit = math.min(limit, math.floor(last)) end
|
|
52
|
+
end
|
|
53
|
+
return #suffix <= limit and value:sub(limit - #suffix + 1, limit) == suffix
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
local function byteStartsWith(value, prefix, offset)
|
|
57
|
+
local start = relativeOffset(offset, #value, 0)
|
|
58
|
+
if offset ~= nil and offset < 0 then start = 0 end
|
|
59
|
+
return value:sub(start + 1, start + #prefix) == prefix
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
local function byteIndexOf(value, needle, offset)
|
|
63
|
+
local start = relativeOffset(offset, #value, 0)
|
|
64
|
+
if offset ~= nil and offset < 0 then start = 0 end
|
|
65
|
+
local found = value:find(needle, start + 1, true)
|
|
66
|
+
return found and found - 1 or -1
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
local function byteIncludes(value, needle, offset)
|
|
70
|
+
local start = relativeOffset(offset, #value, 0)
|
|
71
|
+
if offset ~= nil and offset < 0 then start = 0 end
|
|
72
|
+
return value:find(needle, start + 1, true) ~= nil
|
|
73
|
+
end
|
|
74
|
+
local function byteTrim(value)
|
|
75
|
+
return (value:match("^%s*(.-)%s*$"))
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
local function byteTrimEnd(value)
|
|
79
|
+
return (value:match("^(.-)[%s\194\160\239\187\191]*$"))
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
local function byteRepeat(value, count)
|
|
83
|
+
return value:rep(math.floor(count))
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
local function byteSplit(value, separator)
|
|
87
|
+
local parts = {}
|
|
88
|
+
if separator == nil then return { value } end
|
|
89
|
+
if separator == "" then
|
|
90
|
+
for index = 1, #value do parts[index] = value:sub(index, index) end
|
|
91
|
+
return parts
|
|
92
|
+
end
|
|
93
|
+
local start = 1
|
|
94
|
+
while true do
|
|
95
|
+
local first, last = value:find(separator, start, true)
|
|
96
|
+
if first == nil then
|
|
97
|
+
parts[#parts + 1] = value:sub(start)
|
|
98
|
+
return parts
|
|
99
|
+
end
|
|
100
|
+
parts[#parts + 1] = value:sub(start, first - 1)
|
|
101
|
+
start = last + 1
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
export const signalIntrinsic = {
|
|
6
|
+
file: "src/signal-kernel.ts",
|
|
7
|
+
module: "src/signal-kernel",
|
|
8
|
+
operation: "SignalFactoryV3",
|
|
9
|
+
abi: "createSignalFactory\tno-self\t3\tscalar",
|
|
10
|
+
fingerprint: readFileSync(new URL("./signal-kernel.fingerprint", import.meta.url), "utf8").trim(),
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const sha256 = value => createHash("sha256").update(value).digest("hex");
|
|
14
|
+
|
|
15
|
+
export function lowerSignalFactory(ts, program, sdkRoot, input = resolve(sdkRoot, signalIntrinsic.file)) {
|
|
16
|
+
const canonical = realpathSync(resolve(sdkRoot, signalIntrinsic.file));
|
|
17
|
+
const file = program.getSourceFile(input);
|
|
18
|
+
if (!file || realpathSync(file.fileName) !== canonical) {
|
|
19
|
+
throw new Error(`${input}: expected the Signal factory of the selected SDK`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const checker = program.getTypeChecker();
|
|
23
|
+
const module = checker.getSymbolAtLocation(file);
|
|
24
|
+
const [factory, ...otherExports] = module ? checker.getExportsOfModule(module) : [];
|
|
25
|
+
const declaration = factory?.valueDeclaration;
|
|
26
|
+
const invalid = (node, message) => {
|
|
27
|
+
const { line, character } = file.getLineAndCharacterOfPosition(node.getStart(file));
|
|
28
|
+
throw new Error(`${file.fileName}:${line + 1}:${character + 1}: ${message}`);
|
|
29
|
+
};
|
|
30
|
+
if (!declaration || declaration.getSourceFile() !== file || !ts.isFunctionDeclaration(declaration)
|
|
31
|
+
|| !declaration.body || factory.name !== "createSignalFactory" || otherExports.length !== 0) {
|
|
32
|
+
invalid(file, "expected the canonical createSignalFactory export");
|
|
33
|
+
}
|
|
34
|
+
// No outgoing runtime edges. Type-only imports do not introduce a loader cycle.
|
|
35
|
+
for (const statement of file.statements) {
|
|
36
|
+
if (statement === declaration || ts.isImportDeclaration(statement) && statement.importClause?.isTypeOnly) continue;
|
|
37
|
+
invalid(statement, "the native Signal module may only have type imports and the factory declaration");
|
|
38
|
+
}
|
|
39
|
+
const type = checker.getTypeOfSymbolAtLocation(factory, declaration);
|
|
40
|
+
if (type.getCallSignatures().length !== 1 || declaration.parameters.length !== 3) {
|
|
41
|
+
invalid(declaration, "unsupported createSignalFactory ABI");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// This intrinsic implements one specific fallback body. Include its type syntax
|
|
45
|
+
// in the proof so a changed callback receiver or arity also fails admission.
|
|
46
|
+
const printer = ts.createPrinter({ removeComments: true, newLine: ts.NewLineKind.LineFeed });
|
|
47
|
+
const fingerprint = sha256(printer.printFile(file));
|
|
48
|
+
if (fingerprint !== signalIntrinsic.fingerprint) {
|
|
49
|
+
invalid(declaration, `SignalFactoryV3 source changed (${fingerprint}); review the native lowering`);
|
|
50
|
+
}
|
|
51
|
+
const source = sha256(file.text);
|
|
52
|
+
const start = file.getLineAndCharacterOfPosition(declaration.getStart(file));
|
|
53
|
+
const end = file.getLineAndCharacterOfPosition(declaration.end);
|
|
54
|
+
const ir = [
|
|
55
|
+
"kumi-native-1",
|
|
56
|
+
"target\t5.1",
|
|
57
|
+
`module\t${signalIntrinsic.module}`,
|
|
58
|
+
`intrinsic\t${signalIntrinsic.operation}`,
|
|
59
|
+
`source\t${source}`,
|
|
60
|
+
`fingerprint\t${fingerprint}`,
|
|
61
|
+
`span\t${start.line + 1}\t${start.character + 1}\t${end.line + 1}\t${end.character + 1}`,
|
|
62
|
+
`export\t${signalIntrinsic.abi}`,
|
|
63
|
+
"imports\t0",
|
|
64
|
+
"end",
|
|
65
|
+
"",
|
|
66
|
+
].join("\n");
|
|
67
|
+
return { canonical, ir, source, fingerprint };
|
|
68
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
local function wowReadable(value)
|
|
2
|
+
local secret = issecretvalue
|
|
3
|
+
if secret ~= nil and secret(value) == true then return nil end
|
|
4
|
+
return value
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
local function wowReadableSecond(_, value)
|
|
8
|
+
local secret = issecretvalue
|
|
9
|
+
if secret ~= nil and secret(value) == true then return nil end
|
|
10
|
+
return value
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
local function wowReadableThird(_, _, value)
|
|
14
|
+
local secret = issecretvalue
|
|
15
|
+
if secret ~= nil and secret(value) == true then return nil end
|
|
16
|
+
return value
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
local function wowOptionalReadable(read, ...)
|
|
20
|
+
if read == nil then return nil end
|
|
21
|
+
return wowReadable((read(...)))
|
|
22
|
+
end
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
use crate::wow_types::{self, DIRECTORY};
|
|
2
|
+
use std::env;
|
|
3
|
+
use std::fs;
|
|
4
|
+
use std::io;
|
|
5
|
+
use std::path::{absolute, Path, PathBuf};
|
|
6
|
+
use std::process::Command;
|
|
7
|
+
|
|
8
|
+
const API_PATH: &str = "interface/addons/blizzard_apidocumentationgenerated/";
|
|
9
|
+
const LIST_URL: &str =
|
|
10
|
+
"https://github.com/wowdev/wow-listfile/releases/latest/download/community-listfile.csv";
|
|
11
|
+
|
|
12
|
+
pub struct Source {
|
|
13
|
+
pub docs: Option<PathBuf>,
|
|
14
|
+
pub install: Option<PathBuf>,
|
|
15
|
+
pub product: String,
|
|
16
|
+
pub extractor: Option<PathBuf>,
|
|
17
|
+
pub listfile: Option<PathBuf>,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fn local_build(
|
|
21
|
+
install: &Path,
|
|
22
|
+
product: &str,
|
|
23
|
+
) -> Result<(String, String), Box<dyn std::error::Error>> {
|
|
24
|
+
let info = fs::read_to_string(install.join(".build.info"))?;
|
|
25
|
+
let mut rows = info.lines();
|
|
26
|
+
let headers: Vec<_> = rows
|
|
27
|
+
.next()
|
|
28
|
+
.ok_or("Empty .build.info")?
|
|
29
|
+
.split('|')
|
|
30
|
+
.map(|value| {
|
|
31
|
+
value
|
|
32
|
+
.trim_start_matches('\u{feff}')
|
|
33
|
+
.split('!')
|
|
34
|
+
.next()
|
|
35
|
+
.unwrap()
|
|
36
|
+
})
|
|
37
|
+
.collect();
|
|
38
|
+
let column = |name| {
|
|
39
|
+
headers
|
|
40
|
+
.iter()
|
|
41
|
+
.position(|header| *header == name)
|
|
42
|
+
.ok_or_else(|| format!("Missing .build.info column {name}"))
|
|
43
|
+
};
|
|
44
|
+
let (active, kind, version, key) = (
|
|
45
|
+
column("Active")?,
|
|
46
|
+
column("Product")?,
|
|
47
|
+
column("Version")?,
|
|
48
|
+
column("Build Key")?,
|
|
49
|
+
);
|
|
50
|
+
for row in rows {
|
|
51
|
+
let fields: Vec<_> = row.split('|').collect();
|
|
52
|
+
if fields.get(active) != Some(&"1") || fields.get(kind) != Some(&product) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
let version = *fields.get(version).ok_or("Missing installed WoW version")?;
|
|
56
|
+
let key = *fields.get(key).ok_or("Missing installed WoW build key")?;
|
|
57
|
+
if version.is_empty()
|
|
58
|
+
|| !version.bytes().all(|b| b.is_ascii_digit() || b == b'.')
|
|
59
|
+
|| key.len() != 32
|
|
60
|
+
|| !key.bytes().all(|b| b.is_ascii_hexdigit())
|
|
61
|
+
{
|
|
62
|
+
return Err("Invalid WoW version or build key in .build.info".into());
|
|
63
|
+
}
|
|
64
|
+
return Ok((version.to_owned(), key.to_owned()));
|
|
65
|
+
}
|
|
66
|
+
Err(format!("No active {product} installation in {}", install.display()).into())
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
fn docs_path(path: &Path) -> PathBuf {
|
|
70
|
+
for candidate in [
|
|
71
|
+
path.to_owned(),
|
|
72
|
+
path.join("Interface/AddOns/Blizzard_APIDocumentationGenerated"),
|
|
73
|
+
path.join("BlizzardInterfaceCode/Interface/AddOns/Blizzard_APIDocumentationGenerated"),
|
|
74
|
+
] {
|
|
75
|
+
if candidate.read_dir().is_ok_and(|files| {
|
|
76
|
+
files.flatten().any(|entry| {
|
|
77
|
+
entry
|
|
78
|
+
.file_name()
|
|
79
|
+
.eq_ignore_ascii_case("blizzard_apidocumentationgenerated.toc")
|
|
80
|
+
})
|
|
81
|
+
}) {
|
|
82
|
+
return candidate;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
path.to_owned()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
fn api_list(source: &Path, target: &Path) -> io::Result<()> {
|
|
89
|
+
let list = fs::read_to_string(source)?;
|
|
90
|
+
let mut selected = String::new();
|
|
91
|
+
for line in list.lines() {
|
|
92
|
+
let Some((id, name)) = line.trim_start_matches('\u{feff}').split_once(';') else {
|
|
93
|
+
continue;
|
|
94
|
+
};
|
|
95
|
+
let name = name.replace('\\', "/").to_ascii_lowercase();
|
|
96
|
+
let Some(file) = name.strip_prefix(API_PATH) else {
|
|
97
|
+
continue;
|
|
98
|
+
};
|
|
99
|
+
if id.parse::<u32>().is_ok()
|
|
100
|
+
&& file
|
|
101
|
+
.bytes()
|
|
102
|
+
.all(|b| b.is_ascii_alphanumeric() || b == b'_' || b == b'.')
|
|
103
|
+
&& (file.ends_with(".lua") || file.ends_with(".toc"))
|
|
104
|
+
{
|
|
105
|
+
selected.push_str(id);
|
|
106
|
+
selected.push(';');
|
|
107
|
+
selected.push_str(&name);
|
|
108
|
+
selected.push('\n');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if selected.is_empty() {
|
|
112
|
+
return Err(io::Error::new(
|
|
113
|
+
io::ErrorKind::InvalidData,
|
|
114
|
+
"Listfile has no Blizzard API documentation",
|
|
115
|
+
));
|
|
116
|
+
}
|
|
117
|
+
fs::write(target, selected)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
impl Source {
|
|
121
|
+
pub fn generate(
|
|
122
|
+
&self,
|
|
123
|
+
workspace: &Path,
|
|
124
|
+
output: &Path,
|
|
125
|
+
check: bool,
|
|
126
|
+
diff: bool,
|
|
127
|
+
) -> Result<(), Box<dyn std::error::Error>> {
|
|
128
|
+
let (systems, origin) = if let Some(docs) = &self.docs {
|
|
129
|
+
(
|
|
130
|
+
wow_types::load(&docs_path(docs))?,
|
|
131
|
+
"supplied Blizzard export".to_owned(),
|
|
132
|
+
)
|
|
133
|
+
} else {
|
|
134
|
+
if self.product.is_empty()
|
|
135
|
+
|| !self
|
|
136
|
+
.product
|
|
137
|
+
.bytes()
|
|
138
|
+
.all(|b| b.is_ascii_alphanumeric() || b == b'_')
|
|
139
|
+
{
|
|
140
|
+
return Err("Invalid WoW product name".into());
|
|
141
|
+
}
|
|
142
|
+
let start = self.install.as_deref().unwrap_or(workspace);
|
|
143
|
+
let install = start
|
|
144
|
+
.ancestors()
|
|
145
|
+
.find(|path| path.join(".build.info").is_file())
|
|
146
|
+
.ok_or("WoW installation not found. Pass --wow <install> or --docs <export>.")?;
|
|
147
|
+
let install = absolute(install)?;
|
|
148
|
+
let (version, key) = local_build(&install, &self.product)?;
|
|
149
|
+
let cache = workspace
|
|
150
|
+
.join(".kumi/wow")
|
|
151
|
+
.join(format!("{}-{version}-{key}", self.product));
|
|
152
|
+
let docs = cache.join("interface/addons").join(DIRECTORY);
|
|
153
|
+
let systems = match wow_types::load(&docs) {
|
|
154
|
+
Ok(systems) => systems,
|
|
155
|
+
Err(error) if error.kind() == io::ErrorKind::NotFound => {
|
|
156
|
+
self.extract(workspace, &install, &cache)?;
|
|
157
|
+
wow_types::load(&docs)?
|
|
158
|
+
}
|
|
159
|
+
Err(error) => return Err(error.into()),
|
|
160
|
+
};
|
|
161
|
+
(systems, format!("WoW {} {version} ({key})", self.product))
|
|
162
|
+
};
|
|
163
|
+
let (typescript, functions, events) = wow_types::generate(&systems, &origin);
|
|
164
|
+
let previous = fs::read_to_string(output).ok();
|
|
165
|
+
if diff {
|
|
166
|
+
if let Some(previous) = &previous {
|
|
167
|
+
wow_types::report_changes(previous, &typescript);
|
|
168
|
+
} else {
|
|
169
|
+
println!("No previous WoW declarations at {}", output.display());
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if previous.as_deref() != Some(&typescript) {
|
|
173
|
+
if check {
|
|
174
|
+
return Err("WoW declarations are stale. Run kumi-pack build.".into());
|
|
175
|
+
}
|
|
176
|
+
fs::create_dir_all(output.parent().unwrap())?;
|
|
177
|
+
fs::write(output, typescript)?;
|
|
178
|
+
}
|
|
179
|
+
println!(
|
|
180
|
+
"WoW API: {origin}, {} documentation files, {functions} functions, {events} events",
|
|
181
|
+
systems.len()
|
|
182
|
+
);
|
|
183
|
+
Ok(())
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
fn extract(
|
|
187
|
+
&self,
|
|
188
|
+
workspace: &Path,
|
|
189
|
+
install: &Path,
|
|
190
|
+
cache: &Path,
|
|
191
|
+
) -> Result<(), Box<dyn std::error::Error>> {
|
|
192
|
+
fs::create_dir_all(cache)?;
|
|
193
|
+
let candidate = workspace.join(".kumi/tools/CASCConsole.exe");
|
|
194
|
+
let tool = self.extractor.clone().unwrap_or_else(|| {
|
|
195
|
+
if candidate.is_file() {
|
|
196
|
+
candidate
|
|
197
|
+
} else {
|
|
198
|
+
PathBuf::from("CASCConsole")
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
let tool = if tool.is_file() {
|
|
202
|
+
absolute(tool)?
|
|
203
|
+
} else {
|
|
204
|
+
tool
|
|
205
|
+
};
|
|
206
|
+
let list = cache.join("api-listfile.csv");
|
|
207
|
+
if let Some(path) = &self.listfile {
|
|
208
|
+
api_list(path, &list)?;
|
|
209
|
+
} else {
|
|
210
|
+
let full = cache.join("community-listfile.csv");
|
|
211
|
+
let status = Command::new("curl")
|
|
212
|
+
.args([
|
|
213
|
+
"--fail",
|
|
214
|
+
"--location",
|
|
215
|
+
"--silent",
|
|
216
|
+
"--show-error",
|
|
217
|
+
LIST_URL,
|
|
218
|
+
"-o",
|
|
219
|
+
])
|
|
220
|
+
.arg(&full)
|
|
221
|
+
.status()?;
|
|
222
|
+
if !status.success() {
|
|
223
|
+
return Err("Unable to download the WoW file list. Pass --listfile <csv>.".into());
|
|
224
|
+
}
|
|
225
|
+
api_list(&full, &list)?;
|
|
226
|
+
fs::remove_file(full)?;
|
|
227
|
+
}
|
|
228
|
+
let result = Command::new(&tool)
|
|
229
|
+
.args(["-m", "Listfile", "-e"]).arg(&list)
|
|
230
|
+
.arg("-d").arg(cache)
|
|
231
|
+
.args(["-l", "All_WoW", "-p", &self.product, "-s"]).arg(install)
|
|
232
|
+
.current_dir(cache).output().map_err(|error| format!(
|
|
233
|
+
"Could not run {}: {error}. Install CASCConsole, pass --extractor, or use --docs.", tool.display()))?;
|
|
234
|
+
let mut log = result.stdout;
|
|
235
|
+
log.extend(result.stderr);
|
|
236
|
+
let log_path = cache.join("extract.log");
|
|
237
|
+
fs::write(&log_path, log)?;
|
|
238
|
+
if !result.status.success() || !cache.join("interface/addons").join(DIRECTORY).is_dir() {
|
|
239
|
+
return Err(format!(
|
|
240
|
+
"Unable to extract the client API. See {}",
|
|
241
|
+
log_path.display()
|
|
242
|
+
)
|
|
243
|
+
.into());
|
|
244
|
+
}
|
|
245
|
+
Ok(())
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
pub fn path_option(var: &str) -> Option<PathBuf> {
|
|
250
|
+
env::var_os(var)
|
|
251
|
+
.filter(|value| !value.is_empty())
|
|
252
|
+
.map(PathBuf::from)
|
|
253
|
+
}
|