✨ Parameters support web wasm scenarios
This commit is contained in:
13
bin/README.md
vendored
13
bin/README.md
vendored
@@ -271,6 +271,19 @@ Launch the application in incognito/private browsing mode. Default is `false`. W
|
||||
--incognito
|
||||
```
|
||||
|
||||
#### [wasm]
|
||||
|
||||
Enable WebAssembly support with cross-origin isolation headers. Required for Flutter Web applications and other web applications that use WebAssembly modules like `sqlite3.wasm`, `canvaskit.wasm`. Default is `false`.
|
||||
|
||||
This option adds necessary HTTP headers (`Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`) and browser flags to enable SharedArrayBuffer and WebAssembly features.
|
||||
|
||||
```shell
|
||||
--wasm
|
||||
|
||||
# Example: Package a Flutter Web app with WASM support
|
||||
pake https://flutter.dev --name FlutterApp --wasm
|
||||
```
|
||||
|
||||
#### [installer-language]
|
||||
|
||||
Set the Windows Installer language. Options include `zh-CN`, `ja-JP`, More at [Tauri Document](https://tauri.app/distribute/windows-installer/#internationalization). Default is `en-US`.
|
||||
|
||||
13
bin/README_CN.md
vendored
13
bin/README_CN.md
vendored
@@ -259,6 +259,19 @@ pake [url] [options]
|
||||
--incognito
|
||||
```
|
||||
|
||||
#### [wasm]
|
||||
|
||||
启用 WebAssembly 支持,添加跨域隔离头部,适用于 Flutter Web 应用以及其他使用 WebAssembly 模块(如 `sqlite3.wasm`、`canvaskit.wasm`)的 Web 应用,默认为 `false`。
|
||||
|
||||
此选项会添加必要的 HTTP 头部(`Cross-Origin-Opener-Policy: same-origin` 和 `Cross-Origin-Embedder-Policy: require-corp`)以及浏览器标志,以启用 SharedArrayBuffer 和 WebAssembly 功能。
|
||||
|
||||
```shell
|
||||
--wasm
|
||||
|
||||
# 示例:打包支持 WASM 的 Flutter Web 应用
|
||||
pake https://flutter.dev --name FlutterApp --wasm
|
||||
```
|
||||
|
||||
#### [title]
|
||||
|
||||
设置窗口标题栏文本。如果未指定,窗口标题将为空。
|
||||
|
||||
16
bin/cli.ts
vendored
16
bin/cli.ts
vendored
@@ -135,6 +135,11 @@ program
|
||||
.default(DEFAULT.incognito)
|
||||
.hideHelp(),
|
||||
)
|
||||
.addOption(
|
||||
new Option('--wasm', 'Enable WebAssembly support (Flutter Web, etc.)')
|
||||
.default(DEFAULT.wasm)
|
||||
.hideHelp(),
|
||||
)
|
||||
.addOption(
|
||||
new Option('--installer-language <string>', 'Installer language')
|
||||
.default(DEFAULT.installerLanguage)
|
||||
@@ -145,15 +150,10 @@ program
|
||||
await checkUpdateTips();
|
||||
|
||||
if (!url) {
|
||||
program.outputHelp((str) => {
|
||||
return str
|
||||
.split('\n')
|
||||
.filter(
|
||||
(line) => !/((-h,|--help)|((-v|-V),|--version))\s+.+$/.test(line),
|
||||
)
|
||||
.join('\n');
|
||||
program.help({
|
||||
error: false
|
||||
});
|
||||
process.exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
log.setDefaultLevel('info');
|
||||
|
||||
1
bin/defaults.ts
vendored
1
bin/defaults.ts
vendored
@@ -24,6 +24,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
|
||||
installerLanguage: 'en-US',
|
||||
hideOnClose: true,
|
||||
incognito: false,
|
||||
wasm: false,
|
||||
};
|
||||
|
||||
// Just for cli development
|
||||
|
||||
12
bin/helpers/merge.ts
vendored
12
bin/helpers/merge.ts
vendored
@@ -60,6 +60,7 @@ export async function mergeConfig(
|
||||
hideOnClose,
|
||||
incognito,
|
||||
title,
|
||||
wasm,
|
||||
} = options;
|
||||
|
||||
const { platform } = process;
|
||||
@@ -78,6 +79,7 @@ export async function mergeConfig(
|
||||
hide_on_close: hideOnClose,
|
||||
incognito: incognito,
|
||||
title: title || null,
|
||||
enable_wasm: wasm,
|
||||
};
|
||||
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
||||
|
||||
@@ -312,6 +314,16 @@ StartupNotify=true
|
||||
}
|
||||
tauriConf.pake.proxy_url = proxyUrl || '';
|
||||
|
||||
// Configure WASM support with required HTTP headers
|
||||
if (wasm) {
|
||||
tauriConf.app.security = {
|
||||
headers: {
|
||||
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||
'Cross-Origin-Embedder-Policy': 'require-corp'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Save config file.
|
||||
const platformConfigPaths: PlatformMap = {
|
||||
win32: 'tauri.windows.conf.json',
|
||||
|
||||
3
bin/types.ts
vendored
3
bin/types.ts
vendored
@@ -78,6 +78,9 @@ export interface PakeCliOptions {
|
||||
|
||||
// Launch app in incognito/private mode, default false
|
||||
incognito: boolean;
|
||||
|
||||
// Enable WebAssembly support (Flutter Web, etc.), default false
|
||||
wasm: boolean;
|
||||
}
|
||||
|
||||
export interface PakeAppOptions extends PakeCliOptions {
|
||||
|
||||
25
dist/cli.js
vendored
25
dist/cli.js
vendored
@@ -344,7 +344,7 @@ async function mergeConfig(url, options, tauriConf) {
|
||||
await fsExtra.copy(sourcePath, destPath);
|
||||
}
|
||||
}));
|
||||
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, } = options;
|
||||
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, } = options;
|
||||
const { platform } = process;
|
||||
// Set Windows parameters.
|
||||
const tauriConfWindowOptions = {
|
||||
@@ -360,6 +360,7 @@ async function mergeConfig(url, options, tauriConf) {
|
||||
hide_on_close: hideOnClose,
|
||||
incognito: incognito,
|
||||
title: title || null,
|
||||
enable_wasm: wasm,
|
||||
};
|
||||
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
||||
tauriConf.productName = name;
|
||||
@@ -553,6 +554,15 @@ StartupNotify=true
|
||||
await fsExtra.writeFile(injectFilePath, '');
|
||||
}
|
||||
tauriConf.pake.proxy_url = proxyUrl || '';
|
||||
// Configure WASM support with required HTTP headers
|
||||
if (wasm) {
|
||||
tauriConf.app.security = {
|
||||
headers: {
|
||||
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||
'Cross-Origin-Embedder-Policy': 'require-corp'
|
||||
}
|
||||
};
|
||||
}
|
||||
// Save config file.
|
||||
const platformConfigPaths = {
|
||||
win32: 'tauri.windows.conf.json',
|
||||
@@ -1030,6 +1040,7 @@ const DEFAULT_PAKE_OPTIONS = {
|
||||
installerLanguage: 'en-US',
|
||||
hideOnClose: true,
|
||||
incognito: false,
|
||||
wasm: false,
|
||||
};
|
||||
|
||||
async function checkUpdateTips() {
|
||||
@@ -1481,6 +1492,9 @@ program
|
||||
.addOption(new Option('--incognito', 'Launch app in incognito/private mode')
|
||||
.default(DEFAULT_PAKE_OPTIONS.incognito)
|
||||
.hideHelp())
|
||||
.addOption(new Option('--wasm', 'Enable WebAssembly support (Flutter Web, etc.)')
|
||||
.default(DEFAULT_PAKE_OPTIONS.wasm)
|
||||
.hideHelp())
|
||||
.addOption(new Option('--installer-language <string>', 'Installer language')
|
||||
.default(DEFAULT_PAKE_OPTIONS.installerLanguage)
|
||||
.hideHelp())
|
||||
@@ -1488,13 +1502,10 @@ program
|
||||
.action(async (url, options) => {
|
||||
await checkUpdateTips();
|
||||
if (!url) {
|
||||
program.outputHelp((str) => {
|
||||
return str
|
||||
.split('\n')
|
||||
.filter((line) => !/((-h,|--help)|((-v|-V),|--version))\s+.+$/.test(line))
|
||||
.join('\n');
|
||||
program.help({
|
||||
error: false
|
||||
});
|
||||
process.exit(0);
|
||||
return;
|
||||
}
|
||||
log.setDefaultLevel('info');
|
||||
if (options.debug) {
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "pake-cli",
|
||||
"version": "3.2.15",
|
||||
"version": "3.2.16",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "pake-cli",
|
||||
"version": "3.2.15",
|
||||
"version": "3.2.16",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.8.0",
|
||||
|
||||
@@ -16,6 +16,7 @@ pub struct WindowConfig {
|
||||
pub hide_on_close: bool,
|
||||
pub incognito: bool,
|
||||
pub title: Option<String>,
|
||||
pub enable_wasm: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
||||
@@ -46,6 +46,13 @@ pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) ->
|
||||
.initialization_script(include_str!("../inject/style.js"))
|
||||
.initialization_script(include_str!("../inject/custom.js"));
|
||||
|
||||
// Configure WASM support with required headers for SharedArrayBuffer
|
||||
if window_config.enable_wasm {
|
||||
window_builder = window_builder
|
||||
.additional_browser_args("--enable-features=SharedArrayBuffer")
|
||||
.additional_browser_args("--enable-unsafe-webgpu");
|
||||
}
|
||||
|
||||
// Configure proxy if specified
|
||||
if !config.proxy_url.is_empty() {
|
||||
if let Ok(proxy_url) = Url::from_str(&config.proxy_url) {
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
"iconPath": "png/weekly_512.png",
|
||||
"iconAsTemplate": false,
|
||||
"id": "pake-tray"
|
||||
},
|
||||
"security": {
|
||||
"headers": {}
|
||||
}
|
||||
},
|
||||
"build": {
|
||||
|
||||
Reference in New Issue
Block a user