@binblink/wasmnest-plugin-sdk-desktop 0.0.0-stage → 0.0.1
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 +287 -2
- package/README_en.md +284 -0
- package/bin/cli.js +602 -0
- package/bin/manifest-gen.js +454 -0
- package/bin/manifest-validate.js +432 -0
- package/bin/permission-vocabulary.json +5 -0
- package/bin/plugin-watch.js +331 -0
- package/bin/wasm-hash.js +124 -0
- package/dev-shell/README.md +121 -0
- package/dev-shell/index.html +12 -0
- package/dev-shell/package.json +28 -0
- package/dev-shell/pnpm-workspace.yaml +9 -0
- package/dev-shell/postcss.config.js +6 -0
- package/dev-shell/src/App.vue +90 -0
- package/dev-shell/src/components/LogPanel.vue +90 -0
- package/dev-shell/src/loader.ts +109 -0
- package/dev-shell/src/locale.ts +29 -0
- package/dev-shell/src/locales.ts +50 -0
- package/dev-shell/src/main.ts +46 -0
- package/dev-shell/src/mock/agent-hub-commands.ts +1065 -0
- package/dev-shell/src/mock/agent-hub.ts +42 -0
- package/dev-shell/src/mock/app-env.ts +102 -0
- package/dev-shell/src/mock/commands.ts +54 -0
- package/dev-shell/src/mock/domain-context.ts +46 -0
- package/dev-shell/src/mock/events.ts +16 -0
- package/dev-shell/src/mock/file-transfer.ts +512 -0
- package/dev-shell/src/mock/tauri-ipc.ts +109 -0
- package/dev-shell/src/registry.ts +90 -0
- package/dev-shell/src/shell/components/AppMountSlot.vue +241 -0
- package/dev-shell/src/shell/components/ShellIcon.vue +141 -0
- package/dev-shell/src/shell/components/ShellStatusBar.vue +87 -0
- package/dev-shell/src/shell/components/ShellToolbar.vue +287 -0
- package/dev-shell/src/shell/mount/appSession.ts +45 -0
- package/dev-shell/src/shell/mount/devAppMount.ts +80 -0
- package/dev-shell/src/shell/types.ts +132 -0
- package/dev-shell/src/styles/dev.css +27 -0
- package/dev-shell/src/styles/shell.css +546 -0
- package/dev-shell/src/styles/style.css +1132 -0
- package/dev-shell/src/theme.ts +140 -0
- package/dev-shell/src/vite-env.d.ts +24 -0
- package/dev-shell/tailwind.config.js +98 -0
- package/dev-shell/vite.config.ts +174 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +170 -0
- package/dist/types.d.ts +585 -0
- package/dist/types.js +0 -0
- package/dist/vite-plugin.d.ts +25 -0
- package/dist/vite-plugin.js +80 -0
- package/package.json +89 -3
- package/src/config.ts +49 -0
- package/src/global-dialog.ts +169 -0
- package/src/index.ts +80 -0
- package/src/runtime.ts +54 -0
- package/src/types.ts +630 -0
- package/src/ui/MarkdownEditor.vue +520 -0
- package/src/ui/PluginGlobalDialog.vue +401 -0
- package/src/ui/Select.d.ts +36 -0
- package/src/ui/Select.vue +220 -0
- package/src/ui/TerminalInputRail.vue +184 -0
- package/src/ui/apply-select-position.ts +65 -0
- package/src/ui/markdown-editor-syntax.ts +234 -0
- package/src/ui/markdown-editor.d.ts +36 -0
- package/src/ui/plugin-global-dialog.d.ts +12 -0
- package/src/ui/select-position.ts +79 -0
- package/src/ui/terminal-input-rail.d.ts +30 -0
- package/src/ui/zoom-compensation.d.ts +9 -0
- package/src/ui/zoom-compensation.ts +52 -0
- package/src/vite-plugin.ts +124 -0
- package/template/README.md +39 -0
- package/template/package.json +23 -0
- package/template/plugin.json +14 -0
- package/template/rust/Cargo.toml +21 -0
- package/template/rust/src/lib.rs +39 -0
- package/template/src/env.d.ts +24 -0
- package/template/src/index.ts +37 -0
- package/template/tsconfig.json +17 -0
- package/template/vite.config.ts +21 -0
- package/tools/componentize/Cargo.lock +270 -0
- package/tools/componentize/Cargo.toml +15 -0
- package/tools/componentize/src/main.rs +94 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "wasmnest-componentize"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
license = "MIT"
|
|
5
|
+
edition = "2021"
|
|
6
|
+
description = "WasmNest 插件组件化工具(仓库级,双端共用)— 将 wit-bindgen 产出的 core module 编码为 Component Model 组件(等价 wasm-tools component new)"
|
|
7
|
+
|
|
8
|
+
[[bin]]
|
|
9
|
+
name = "componentize"
|
|
10
|
+
path = "src/main.rs"
|
|
11
|
+
|
|
12
|
+
[dependencies]
|
|
13
|
+
# 与宿主 src-tauri dev-dep 同版本(spike 实证 0.256 编码产物 00 61 73 6d 0d 00 01 00),
|
|
14
|
+
# 保证编码行为一致;与 wit-bindgen 版本无锁(独立演进,见迁移 spec §4 S2)
|
|
15
|
+
wit-component = "=0.256.0"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//! 插件组件化工具(迁移阶段 B 构建链)
|
|
2
|
+
//!
|
|
3
|
+
//! 将 wit-bindgen 产出的 core module(含 `component-type` 自定义段)编码为
|
|
4
|
+
//! Component Model 组件,等价于 `wasm-tools component new`:
|
|
5
|
+
//! - 产物已是组件(魔法字节 `0d 00 01 00`)时直接复制(幂等,支持增量构建)
|
|
6
|
+
//! - 编码失败的输入(无组件元数据)给出明确错误
|
|
7
|
+
//!
|
|
8
|
+
//! 用法:`componentize <input.wasm> -o <output.wasm>`
|
|
9
|
+
//! 插件构建脚本(wasm-apps/*/scripts/build.js)在 cargo build 后调用本工具。
|
|
10
|
+
|
|
11
|
+
use std::process::ExitCode;
|
|
12
|
+
|
|
13
|
+
fn main() -> ExitCode {
|
|
14
|
+
let args: Vec<String> = std::env::args().collect();
|
|
15
|
+
let mut input: Option<String> = None;
|
|
16
|
+
let mut output: Option<String> = None;
|
|
17
|
+
|
|
18
|
+
let mut i = 1;
|
|
19
|
+
while i < args.len() {
|
|
20
|
+
match args[i].as_str() {
|
|
21
|
+
"-o" | "--output" => {
|
|
22
|
+
if i + 1 < args.len() {
|
|
23
|
+
output = Some(args[i + 1].clone());
|
|
24
|
+
i += 1;
|
|
25
|
+
} else {
|
|
26
|
+
eprintln!("Missing value after {}", args[i]);
|
|
27
|
+
return ExitCode::FAILURE;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
a if a.starts_with('-') => {
|
|
31
|
+
eprintln!("Unknown option: {}", a);
|
|
32
|
+
return ExitCode::FAILURE;
|
|
33
|
+
}
|
|
34
|
+
a => input = Some(a.to_string()),
|
|
35
|
+
}
|
|
36
|
+
i += 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let (Some(input), Some(output)) = (input, output) else {
|
|
40
|
+
eprintln!("Usage: componentize <input.wasm> -o <output.wasm>");
|
|
41
|
+
return ExitCode::FAILURE;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
let bytes = match std::fs::read(&input) {
|
|
45
|
+
Ok(b) => b,
|
|
46
|
+
Err(e) => {
|
|
47
|
+
eprintln!("Failed to read {}: {}", input, e);
|
|
48
|
+
return ExitCode::FAILURE;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// 幂等:产物已是组件(版本字 0d 00 01 00)则直接复制
|
|
53
|
+
if bytes.len() >= 8 && &bytes[0..4] == b"\0asm" && &bytes[4..8] == [0x0d, 0x00, 0x01, 0x00] {
|
|
54
|
+
return match std::fs::write(&output, &bytes) {
|
|
55
|
+
Ok(()) => {
|
|
56
|
+
println!("componentize: {} already a component, copied to {}", input, output);
|
|
57
|
+
ExitCode::SUCCESS
|
|
58
|
+
}
|
|
59
|
+
Err(e) => {
|
|
60
|
+
eprintln!("Failed to write {}: {}", output, e);
|
|
61
|
+
ExitCode::FAILURE
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let mut encoder = match wit_component::ComponentEncoder::default().module(&bytes) {
|
|
67
|
+
Ok(e) => e,
|
|
68
|
+
Err(e) => {
|
|
69
|
+
eprintln!(
|
|
70
|
+
"componentize: {} is not a componentizable core module (missing WIT metadata): {}",
|
|
71
|
+
input, e
|
|
72
|
+
);
|
|
73
|
+
return ExitCode::FAILURE;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
let encoded = match encoder.encode() {
|
|
77
|
+
Ok(b) => b,
|
|
78
|
+
Err(e) => {
|
|
79
|
+
eprintln!("componentize: encode {} failed: {}", input, e);
|
|
80
|
+
return ExitCode::FAILURE;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
match std::fs::write(&output, &encoded) {
|
|
85
|
+
Ok(()) => {
|
|
86
|
+
println!("componentize: {} -> {} ({} bytes)", input, output, encoded.len());
|
|
87
|
+
ExitCode::SUCCESS
|
|
88
|
+
}
|
|
89
|
+
Err(e) => {
|
|
90
|
+
eprintln!("Failed to write {}: {}", output, e);
|
|
91
|
+
ExitCode::FAILURE
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|