@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,381 @@
|
|
|
1
|
+
use std::env;
|
|
2
|
+
use std::fs;
|
|
3
|
+
use std::io::{self, Write};
|
|
4
|
+
use std::path::{absolute, Path, PathBuf};
|
|
5
|
+
use std::process::{Command, ExitCode, Output, Stdio};
|
|
6
|
+
use std::thread;
|
|
7
|
+
|
|
8
|
+
mod assets;
|
|
9
|
+
mod compiler;
|
|
10
|
+
mod config;
|
|
11
|
+
mod entries;
|
|
12
|
+
mod lua_data;
|
|
13
|
+
mod native_ir;
|
|
14
|
+
mod native_signal;
|
|
15
|
+
mod routes;
|
|
16
|
+
mod wow_client;
|
|
17
|
+
mod wow_types;
|
|
18
|
+
|
|
19
|
+
fn modules(directory: &Path) -> io::Result<Vec<String>> {
|
|
20
|
+
let mut names = Vec::new();
|
|
21
|
+
for entry in fs::read_dir(directory)? {
|
|
22
|
+
let path = entry?.path();
|
|
23
|
+
if let Some(file) = path.file_name().and_then(|name| name.to_str()) {
|
|
24
|
+
if let Some(name) = file.strip_suffix(".module.json") {
|
|
25
|
+
names.push(name.to_owned());
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
names.sort();
|
|
30
|
+
Ok(names)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fn wait_for_node_output(
|
|
34
|
+
worker: io::Result<thread::ScopedJoinHandle<'_, io::Result<Output>>>,
|
|
35
|
+
) -> io::Result<Output> {
|
|
36
|
+
worker?
|
|
37
|
+
.join()
|
|
38
|
+
.unwrap_or_else(|_| Err(io::Error::other("Node build worker panicked")))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fn build() -> Result<bool, Box<dyn std::error::Error>> {
|
|
42
|
+
let root = env::current_dir()?;
|
|
43
|
+
let mut workspace = root.clone();
|
|
44
|
+
let mut selected = Vec::new();
|
|
45
|
+
let mut check = false;
|
|
46
|
+
let mut dev = false;
|
|
47
|
+
let mut api_only = false;
|
|
48
|
+
let mut diff = false;
|
|
49
|
+
let mut lua_only = false;
|
|
50
|
+
let mut jobs = 1;
|
|
51
|
+
let mut routes_only = false;
|
|
52
|
+
let mut legacy_routes_requested = false;
|
|
53
|
+
let mut compile_source = None;
|
|
54
|
+
let mut compile_config = None;
|
|
55
|
+
let mut compile_sdk = None;
|
|
56
|
+
let mut compile_addon = false;
|
|
57
|
+
let mut compile_test = false;
|
|
58
|
+
let mut compile_link = None;
|
|
59
|
+
let mut compile_assets = None;
|
|
60
|
+
let mut compile_output = None;
|
|
61
|
+
let mut compile_fragments = false;
|
|
62
|
+
let mut compile_plugin = None;
|
|
63
|
+
let mut native_emission = false;
|
|
64
|
+
let mut native_ir = None;
|
|
65
|
+
let mut native_out = None;
|
|
66
|
+
let mut native_kernels = "none";
|
|
67
|
+
let mut image_source = None;
|
|
68
|
+
let mut image_output = None;
|
|
69
|
+
let mut image_input_tga = false;
|
|
70
|
+
let mut packager = None;
|
|
71
|
+
let mut addons_dir = None;
|
|
72
|
+
let mut source = wow_client::Source {
|
|
73
|
+
docs: wow_client::path_option("KUMI_WOW_DOCS"),
|
|
74
|
+
install: wow_client::path_option("KUMI_WOW_INSTALL"),
|
|
75
|
+
product: env::var("KUMI_WOW_PRODUCT").unwrap_or_else(|_| "wow".to_owned()),
|
|
76
|
+
extractor: wow_client::path_option("KUMI_WOW_EXTRACTOR"),
|
|
77
|
+
listfile: wow_client::path_option("KUMI_WOW_LISTFILE"),
|
|
78
|
+
};
|
|
79
|
+
let mut args = env::args().skip(1);
|
|
80
|
+
while let Some(arg) = args.next() {
|
|
81
|
+
let value = || format!("Expected a value after {arg}");
|
|
82
|
+
match arg.as_str() {
|
|
83
|
+
"build" => {}
|
|
84
|
+
"wow-api" => api_only = true,
|
|
85
|
+
"routes" => routes_only = true,
|
|
86
|
+
"compile" => compile_source = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
87
|
+
"--tsconfig" => compile_config = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
88
|
+
"--sdk-root" => compile_sdk = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
89
|
+
"--addon-entry" => compile_addon = true,
|
|
90
|
+
"--test-entry" => {
|
|
91
|
+
compile_addon = true;
|
|
92
|
+
compile_test = true;
|
|
93
|
+
}
|
|
94
|
+
"--addon-link" => compile_link = Some(args.next().ok_or_else(value)?),
|
|
95
|
+
"--addon-fragments" => compile_fragments = true,
|
|
96
|
+
"--compile-output" => {
|
|
97
|
+
compile_output = Some(PathBuf::from(args.next().ok_or_else(value)?))
|
|
98
|
+
}
|
|
99
|
+
"--addon-plugin" => {
|
|
100
|
+
compile_plugin = Some(match args.next().as_deref() {
|
|
101
|
+
Some("external") => compiler::AddonPlugin::External,
|
|
102
|
+
Some("embeddable") => compiler::AddonPlugin::Embeddable,
|
|
103
|
+
_ => return Err("Expected --addon-plugin external or embeddable".into()),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
"--addon-assets-dir" => {
|
|
107
|
+
compile_assets = Some(PathBuf::from(args.next().ok_or_else(value)?))
|
|
108
|
+
}
|
|
109
|
+
"emit-native" => native_emission = true,
|
|
110
|
+
"--ir" => native_ir = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
111
|
+
"--out" => native_out = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
112
|
+
"--native-kernels" => {
|
|
113
|
+
native_kernels = match args.next().as_deref() {
|
|
114
|
+
Some("none") => "none",
|
|
115
|
+
Some("signal") => "signal",
|
|
116
|
+
_ => return Err("Expected --native-kernels none or signal".into()),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
"image" => image_source = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
120
|
+
"--image-output" => image_output = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
121
|
+
"--image-input-tga" => image_input_tga = true,
|
|
122
|
+
"--routes-dir" => {
|
|
123
|
+
let supplied = args.next().ok_or_else(value)?;
|
|
124
|
+
if Path::new(&supplied) != Path::new(routes::SOURCE_DIRECTORY) {
|
|
125
|
+
return Err(
|
|
126
|
+
format!("File routes belong in {}", routes::SOURCE_DIRECTORY).into(),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
// Existing hosts can still request route generation using the canonical path.
|
|
130
|
+
legacy_routes_requested = true;
|
|
131
|
+
}
|
|
132
|
+
"--check" => check = true,
|
|
133
|
+
"--diff" => diff = true,
|
|
134
|
+
"--dev" => dev = true,
|
|
135
|
+
"--lua-only" => lua_only = true,
|
|
136
|
+
"--jobs" => {
|
|
137
|
+
jobs = match args.next().as_deref() {
|
|
138
|
+
Some("1") => 1,
|
|
139
|
+
Some("2") => 2,
|
|
140
|
+
Some(value) => {
|
|
141
|
+
return Err(
|
|
142
|
+
format!("Invalid --jobs value {value:?}. Expected 1 or 2.").into()
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
None => return Err("Expected 1 or 2 after --jobs".into()),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
"--workspace" => workspace = absolute(args.next().ok_or_else(value)?)?,
|
|
149
|
+
"--packager" => packager = Some(absolute(args.next().ok_or_else(value)?)?),
|
|
150
|
+
"--addons-dir" => addons_dir = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
151
|
+
"--docs" => source.docs = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
152
|
+
"--wow" => source.install = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
153
|
+
"--product" => source.product = args.next().ok_or_else(value)?,
|
|
154
|
+
"--extractor" => source.extractor = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
155
|
+
"--listfile" => source.listfile = Some(PathBuf::from(args.next().ok_or_else(value)?)),
|
|
156
|
+
_ if !arg.starts_with('-') => {
|
|
157
|
+
if !selected.contains(&arg) {
|
|
158
|
+
selected.push(arg);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
_ => return Err(format!("Unknown option {arg}").into()),
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
let output = workspace.join(if dev { ".kumi" } else { "build" });
|
|
165
|
+
if native_emission {
|
|
166
|
+
let input = native_ir.ok_or("emit-native requires --ir")?;
|
|
167
|
+
let target = native_out.ok_or("emit-native requires --out")?;
|
|
168
|
+
compiler::emit_native(&workspace.join(input), &workspace.join(target))?;
|
|
169
|
+
return Ok(true);
|
|
170
|
+
}
|
|
171
|
+
if native_ir.is_some() || native_out.is_some() {
|
|
172
|
+
return Err("--ir and --out require emit-native".into());
|
|
173
|
+
}
|
|
174
|
+
if native_kernels == "signal" && !lua_only {
|
|
175
|
+
return Err("--native-kernels signal requires --lua-only".into());
|
|
176
|
+
}
|
|
177
|
+
if let Some(input) = image_source {
|
|
178
|
+
let output = image_output.ok_or("Expected --image-output for image")?;
|
|
179
|
+
let source = if input == Path::new("-") {
|
|
180
|
+
input
|
|
181
|
+
} else {
|
|
182
|
+
workspace.join(input)
|
|
183
|
+
};
|
|
184
|
+
assets::build(&source, &workspace.join(output), check, image_input_tga)?;
|
|
185
|
+
return Ok(true);
|
|
186
|
+
}
|
|
187
|
+
if image_output.is_some() {
|
|
188
|
+
return Err("--image-output requires the image command".into());
|
|
189
|
+
}
|
|
190
|
+
if image_input_tga {
|
|
191
|
+
return Err("--image-input-tga requires the image command".into());
|
|
192
|
+
}
|
|
193
|
+
if let Some(input) = compile_source {
|
|
194
|
+
if compile_link
|
|
195
|
+
.as_ref()
|
|
196
|
+
.is_some_and(|stamp| !compile_addon || stamp.trim().is_empty())
|
|
197
|
+
{
|
|
198
|
+
return Err("--addon-link requires --addon-entry and a build stamp".into());
|
|
199
|
+
}
|
|
200
|
+
if compile_assets.is_some() && !compile_addon {
|
|
201
|
+
return Err("--addon-assets-dir requires --addon-entry".into());
|
|
202
|
+
}
|
|
203
|
+
if compile_plugin.is_some() && !compile_addon {
|
|
204
|
+
return Err("--addon-plugin requires --addon-entry".into());
|
|
205
|
+
}
|
|
206
|
+
if compile_fragments && (compile_link.is_none() || compile_output.is_none()) {
|
|
207
|
+
return Err("--addon-fragments requires --addon-link and --compile-output".into());
|
|
208
|
+
}
|
|
209
|
+
let input = absolute(workspace.join(input))?;
|
|
210
|
+
let stem = input
|
|
211
|
+
.file_stem()
|
|
212
|
+
.and_then(|stem| stem.to_str())
|
|
213
|
+
.ok_or("Invalid TypeScript filename")?;
|
|
214
|
+
let sdk = compile_sdk.map_or_else(|| workspace.clone(), |path| workspace.join(path));
|
|
215
|
+
let config = compile_config.map(|path| workspace.join(path));
|
|
216
|
+
let assets = compile_assets.map(|path| workspace.join(path));
|
|
217
|
+
let output = compile_output.map_or_else(
|
|
218
|
+
|| output.join("compiler").join(format!("{stem}.lua")),
|
|
219
|
+
|path| workspace.join(path),
|
|
220
|
+
);
|
|
221
|
+
compiler::compile(
|
|
222
|
+
&root,
|
|
223
|
+
compiler::ProjectCompile {
|
|
224
|
+
workspace: &workspace,
|
|
225
|
+
sdk: &sdk,
|
|
226
|
+
config: config.as_deref(),
|
|
227
|
+
source: &input,
|
|
228
|
+
output: &output,
|
|
229
|
+
check,
|
|
230
|
+
addon: compile_addon,
|
|
231
|
+
test: compile_test,
|
|
232
|
+
link: compile_link.as_deref(),
|
|
233
|
+
assets: assets.as_deref(),
|
|
234
|
+
plugin: compile_plugin,
|
|
235
|
+
fragments: compile_fragments,
|
|
236
|
+
},
|
|
237
|
+
)?;
|
|
238
|
+
return Ok(true);
|
|
239
|
+
}
|
|
240
|
+
if compile_config.is_some()
|
|
241
|
+
|| compile_sdk.is_some()
|
|
242
|
+
|| compile_addon
|
|
243
|
+
|| compile_link.is_some()
|
|
244
|
+
|| compile_assets.is_some()
|
|
245
|
+
|| compile_output.is_some()
|
|
246
|
+
|| compile_plugin.is_some()
|
|
247
|
+
|| compile_fragments
|
|
248
|
+
{
|
|
249
|
+
return Err("Native compiler options require compile".into());
|
|
250
|
+
}
|
|
251
|
+
if routes_only || legacy_routes_requested {
|
|
252
|
+
routes::generate(&workspace, &output, check)?;
|
|
253
|
+
if routes_only {
|
|
254
|
+
return Ok(true);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
let package = !check && !dev && !lua_only && !api_only && selected.is_empty();
|
|
258
|
+
let install = if package {
|
|
259
|
+
match addons_dir {
|
|
260
|
+
Some(path) => Some(path),
|
|
261
|
+
None => config::addons_dir(&root)?,
|
|
262
|
+
}
|
|
263
|
+
} else if addons_dir.is_some() {
|
|
264
|
+
return Err("--addons-dir requires a complete addon build".into());
|
|
265
|
+
} else {
|
|
266
|
+
None
|
|
267
|
+
};
|
|
268
|
+
source.generate(&workspace, &output.join("types/wow-api.d.ts"), check, diff)?;
|
|
269
|
+
if api_only {
|
|
270
|
+
return Ok(true);
|
|
271
|
+
}
|
|
272
|
+
let available = modules(&root.join("modules"))?;
|
|
273
|
+
for module in &selected {
|
|
274
|
+
if !available.contains(module) {
|
|
275
|
+
return Err(
|
|
276
|
+
format!("Unknown module {module}. Modules: {}", available.join(", ")).into(),
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if selected.is_empty() {
|
|
281
|
+
selected = available;
|
|
282
|
+
}
|
|
283
|
+
if selected.is_empty() {
|
|
284
|
+
return Err("No module configurations found".into());
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
let entries = entries::generate(&workspace, &root, &output, &selected, check)?;
|
|
288
|
+
let executable = env::current_exe()?;
|
|
289
|
+
let mut succeeded = true;
|
|
290
|
+
for batch in selected.chunks(jobs) {
|
|
291
|
+
let outputs = thread::scope(|scope| {
|
|
292
|
+
let children: Vec<_> = batch
|
|
293
|
+
.iter()
|
|
294
|
+
.map(|module| {
|
|
295
|
+
let mut command = Command::new("node");
|
|
296
|
+
command
|
|
297
|
+
.current_dir(&root)
|
|
298
|
+
.args(["--v8-pool-size=1", "scripts/build.mjs", module])
|
|
299
|
+
.env("KUMI_OUTPUT", &output)
|
|
300
|
+
.env("KUMI_PACK_BIN", &executable)
|
|
301
|
+
.env("KUMI_NATIVE_KERNELS", native_kernels)
|
|
302
|
+
.env("UV_THREADPOOL_SIZE", "1")
|
|
303
|
+
.stdin(Stdio::inherit());
|
|
304
|
+
if let Some(entry) = entries.get(module) {
|
|
305
|
+
command.env("KUMI_BUNDLE_ENTRY", entry);
|
|
306
|
+
}
|
|
307
|
+
if check {
|
|
308
|
+
command.arg("--check");
|
|
309
|
+
}
|
|
310
|
+
thread::Builder::new().spawn_scoped(scope, move || command.output())
|
|
311
|
+
})
|
|
312
|
+
.collect();
|
|
313
|
+
children
|
|
314
|
+
.into_iter()
|
|
315
|
+
.map(wait_for_node_output)
|
|
316
|
+
.collect::<Vec<_>>()
|
|
317
|
+
});
|
|
318
|
+
for (module, result) in batch.iter().zip(outputs) {
|
|
319
|
+
match result {
|
|
320
|
+
Ok(output) => {
|
|
321
|
+
io::stdout().write_all(&output.stdout)?;
|
|
322
|
+
io::stderr().write_all(&output.stderr)?;
|
|
323
|
+
succeeded &= output.status.success();
|
|
324
|
+
}
|
|
325
|
+
Err(error) => {
|
|
326
|
+
eprintln!("{module}: {error}");
|
|
327
|
+
succeeded = false;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if succeeded && package {
|
|
333
|
+
if let Some(packager) = packager {
|
|
334
|
+
let mut command = Command::new("node");
|
|
335
|
+
command
|
|
336
|
+
.current_dir(&root)
|
|
337
|
+
.arg("--v8-pool-size=1")
|
|
338
|
+
.arg(packager)
|
|
339
|
+
.env("UV_THREADPOOL_SIZE", "1")
|
|
340
|
+
.env("KUMI_OUTPUT", &output);
|
|
341
|
+
if let Some(target) = install {
|
|
342
|
+
command.env("KUMI_ADDONS_DIR", workspace.join(target));
|
|
343
|
+
}
|
|
344
|
+
succeeded = command.status()?.success();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
Ok(succeeded)
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
fn main() -> ExitCode {
|
|
351
|
+
match build() {
|
|
352
|
+
Ok(true) => ExitCode::SUCCESS,
|
|
353
|
+
Ok(false) => ExitCode::FAILURE,
|
|
354
|
+
Err(error) => {
|
|
355
|
+
eprintln!("{error}");
|
|
356
|
+
ExitCode::FAILURE
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
#[cfg(test)]
|
|
362
|
+
mod tests {
|
|
363
|
+
use super::*;
|
|
364
|
+
|
|
365
|
+
#[test]
|
|
366
|
+
fn node_worker_failures_are_reported_as_io_errors() {
|
|
367
|
+
let denied = io::Error::from(io::ErrorKind::PermissionDenied);
|
|
368
|
+
assert_eq!(
|
|
369
|
+
wait_for_node_output(Err(denied)).unwrap_err().kind(),
|
|
370
|
+
io::ErrorKind::PermissionDenied
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
thread::scope(|scope| {
|
|
374
|
+
let worker = thread::Builder::new().spawn_scoped(scope, || panic!("worker failed"));
|
|
375
|
+
assert_eq!(
|
|
376
|
+
wait_for_node_output(worker).unwrap_err().to_string(),
|
|
377
|
+
"Node build worker panicked"
|
|
378
|
+
);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
use std::io::Read;
|
|
2
|
+
use std::path::Path;
|
|
3
|
+
|
|
4
|
+
type Compile<T> = Result<T, Box<dyn std::error::Error>>;
|
|
5
|
+
const LIMIT: u64 = 4096;
|
|
6
|
+
const FINGERPRINT: &str = include_str!("signal-kernel.fingerprint");
|
|
7
|
+
|
|
8
|
+
pub struct SignalFactory {
|
|
9
|
+
pub source_hash: String,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
fn hash(value: &str) -> bool {
|
|
13
|
+
value.len() == 64
|
|
14
|
+
&& value
|
|
15
|
+
.bytes()
|
|
16
|
+
.all(|byte| matches!(byte, b'0'..=b'9' | b'a'..=b'f'))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
pub fn signal_from_hashes(source: &str, fingerprint: &str) -> Compile<SignalFactory> {
|
|
20
|
+
if !hash(source) || fingerprint != FINGERPRINT.trim() {
|
|
21
|
+
return Err("Unsupported native Signal source hash or fingerprint".into());
|
|
22
|
+
}
|
|
23
|
+
Ok(SignalFactory {
|
|
24
|
+
source_hash: source.to_owned(),
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
pub fn read_signal(path: &Path) -> Compile<SignalFactory> {
|
|
29
|
+
let mut input = String::new();
|
|
30
|
+
std::fs::File::open(path)?
|
|
31
|
+
.take(LIMIT + 1)
|
|
32
|
+
.read_to_string(&mut input)?;
|
|
33
|
+
if input.len() as u64 > LIMIT {
|
|
34
|
+
return Err("Native IR exceeds the size limit".into());
|
|
35
|
+
}
|
|
36
|
+
let records: Vec<_> = input.lines().collect();
|
|
37
|
+
let ["kumi-native-1", "target\t5.1", "module\tsrc/signal-kernel", "intrinsic\tSignalFactoryV3", source, fingerprint, span, "export\tcreateSignalFactory\tno-self\t3\tscalar", "imports\t0", "end"] =
|
|
38
|
+
records.as_slice()
|
|
39
|
+
else {
|
|
40
|
+
return Err("Unsupported native IR schema, target, module, or ABI".into());
|
|
41
|
+
};
|
|
42
|
+
let source_hash = source
|
|
43
|
+
.strip_prefix("source\t")
|
|
44
|
+
.ok_or("Missing source hash")?;
|
|
45
|
+
let fingerprint = fingerprint
|
|
46
|
+
.strip_prefix("fingerprint\t")
|
|
47
|
+
.ok_or("Missing fingerprint")?;
|
|
48
|
+
let coordinates: Vec<_> = span
|
|
49
|
+
.strip_prefix("span\t")
|
|
50
|
+
.ok_or("Missing source span")?
|
|
51
|
+
.split('\t')
|
|
52
|
+
.collect();
|
|
53
|
+
if coordinates.len() != 4
|
|
54
|
+
|| coordinates.iter().any(|value| {
|
|
55
|
+
value
|
|
56
|
+
.parse::<u32>()
|
|
57
|
+
.ok()
|
|
58
|
+
.filter(|value| *value > 0)
|
|
59
|
+
.is_none()
|
|
60
|
+
})
|
|
61
|
+
{
|
|
62
|
+
return Err("Invalid native IR source span".into());
|
|
63
|
+
}
|
|
64
|
+
signal_from_hashes(source_hash, fingerprint)
|
|
65
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
use crate::native_ir::SignalFactory;
|
|
2
|
+
|
|
3
|
+
pub fn emit(ir: SignalFactory) -> String {
|
|
4
|
+
// Missing current falls through the non-value branch of __index.
|
|
5
|
+
// A first write to that slot falls through to rawset in __newindex.
|
|
6
|
+
format!(
|
|
7
|
+
r#"-- kumi-native-1 / SignalFactoryV3 / {source}
|
|
8
|
+
local module = {{}}
|
|
9
|
+
function module.createSignalFactory(track, notify, makeDependency)
|
|
10
|
+
local meta = {{}}
|
|
11
|
+
meta.__index = function(cell, key)
|
|
12
|
+
if key == "value" then
|
|
13
|
+
track(cell.observers)
|
|
14
|
+
return cell.current
|
|
15
|
+
end
|
|
16
|
+
return nil
|
|
17
|
+
end
|
|
18
|
+
meta.__newindex = function(cell, key, next)
|
|
19
|
+
if key ~= "value" then
|
|
20
|
+
rawset(cell, key, next)
|
|
21
|
+
return
|
|
22
|
+
end
|
|
23
|
+
local current = cell.current
|
|
24
|
+
local equals = cell.equals
|
|
25
|
+
if equals == true then
|
|
26
|
+
if next == current then return end
|
|
27
|
+
elseif equals ~= false and equals(current, next) then
|
|
28
|
+
return
|
|
29
|
+
end
|
|
30
|
+
cell.current = next
|
|
31
|
+
notify(cell.observers)
|
|
32
|
+
end
|
|
33
|
+
return {{
|
|
34
|
+
create = function(initial, equals)
|
|
35
|
+
if equals == nil then equals = true end
|
|
36
|
+
local cell = {{
|
|
37
|
+
current = initial,
|
|
38
|
+
equals = equals,
|
|
39
|
+
observers = makeDependency(),
|
|
40
|
+
}}
|
|
41
|
+
return (setmetatable(cell, meta))
|
|
42
|
+
end,
|
|
43
|
+
owns = function(value)
|
|
44
|
+
local owner = getmetatable(value)
|
|
45
|
+
return owner == meta or type(owner) == "table" and rawget(owner, "signal") == meta
|
|
46
|
+
end,
|
|
47
|
+
guard = function(cell, before)
|
|
48
|
+
if getmetatable(cell) ~= meta then return nil end
|
|
49
|
+
local guarded = {{
|
|
50
|
+
signal = meta,
|
|
51
|
+
__index = meta.__index,
|
|
52
|
+
__newindex = function(signal, key, next)
|
|
53
|
+
if key ~= "value" then
|
|
54
|
+
rawset(signal, key, next)
|
|
55
|
+
return
|
|
56
|
+
end
|
|
57
|
+
local current = signal.current
|
|
58
|
+
local equals = signal.equals
|
|
59
|
+
if equals == true then
|
|
60
|
+
if next == current then return end
|
|
61
|
+
elseif equals ~= false and equals(current, next) then
|
|
62
|
+
return
|
|
63
|
+
end
|
|
64
|
+
before(next)
|
|
65
|
+
signal.current = next
|
|
66
|
+
notify(signal.observers)
|
|
67
|
+
end,
|
|
68
|
+
}}
|
|
69
|
+
setmetatable(cell, guarded)
|
|
70
|
+
return {{
|
|
71
|
+
peek = function() return cell.current end,
|
|
72
|
+
detach = function()
|
|
73
|
+
if getmetatable(cell) == guarded then setmetatable(cell, meta) end
|
|
74
|
+
end,
|
|
75
|
+
}}
|
|
76
|
+
end,
|
|
77
|
+
}}
|
|
78
|
+
end
|
|
79
|
+
return module
|
|
80
|
+
"#,
|
|
81
|
+
source = ir.source_hash
|
|
82
|
+
)
|
|
83
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
local function numberFinite(value)
|
|
2
|
+
return type(value) == "number" and value > -math.huge and value < math.huge
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
local function numberNaN(value)
|
|
6
|
+
return type(value) == "number" and value ~= value
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
local function numberInteger(value)
|
|
10
|
+
return numberFinite(value) and value % 1 == 0
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
local function numberRound(value)
|
|
14
|
+
if not numberFinite(value) or value == 0 then return value end
|
|
15
|
+
local result = math.floor(value)
|
|
16
|
+
if value - result >= 0.5 then result = result + 1 end
|
|
17
|
+
if result == 0 and value < 0 then return -1 / math.huge end
|
|
18
|
+
return result
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
local function numberFixed(value, digits)
|
|
22
|
+
if value ~= value or value <= -1e21 or value >= 1e21 then return tostring(value) end
|
|
23
|
+
local precision = math.floor(digits or 0)
|
|
24
|
+
if precision < 0 or precision > 99 then
|
|
25
|
+
error("toFixed() digits argument must be between 0 and 99", 0)
|
|
26
|
+
end
|
|
27
|
+
return string.format("%." .. precision .. "f", value)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
local function numberValue(value)
|
|
31
|
+
local kind = type(value)
|
|
32
|
+
if kind == "number" then return value end
|
|
33
|
+
if kind == "boolean" then return value and 1 or 0 end
|
|
34
|
+
if kind == "string" then
|
|
35
|
+
local numeric = tonumber(value)
|
|
36
|
+
if numeric ~= nil then return numeric end
|
|
37
|
+
if value == "Infinity" then return math.huge end
|
|
38
|
+
if value == "-Infinity" then return -math.huge end
|
|
39
|
+
if value:match("^%s*$") then return 0 end
|
|
40
|
+
end
|
|
41
|
+
return 0 / 0
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
local function numberMin2(left, right)
|
|
45
|
+
if left ~= left then return left end
|
|
46
|
+
if right ~= right then return right end
|
|
47
|
+
if right < left or right == 0 and left == 0 and 1 / right < 0 then return right end
|
|
48
|
+
return left
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
local function numberMax2(left, right)
|
|
52
|
+
if left ~= left then return left end
|
|
53
|
+
if right ~= right then return right end
|
|
54
|
+
if right > left or right == 0 and left == 0 and 1 / right > 0 then return right end
|
|
55
|
+
return left
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
local function numberMin(...)
|
|
59
|
+
local best = math.huge
|
|
60
|
+
for index = 1, select("#", ...) do
|
|
61
|
+
local value = select(index, ...)
|
|
62
|
+
if value ~= value then return value end
|
|
63
|
+
if value < best or value == 0 and best == 0 and 1 / value < 0 then best = value end
|
|
64
|
+
end
|
|
65
|
+
return best
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
local function numberMax(...)
|
|
69
|
+
local best = -math.huge
|
|
70
|
+
for index = 1, select("#", ...) do
|
|
71
|
+
local value = select(index, ...)
|
|
72
|
+
if value ~= value then return value end
|
|
73
|
+
if value > best or value == 0 and best == 0 and 1 / value > 0 then best = value end
|
|
74
|
+
end
|
|
75
|
+
return best
|
|
76
|
+
end
|