✨ 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
|
--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]
|
#### [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`.
|
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
|
--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]
|
#### [title]
|
||||||
|
|
||||||
设置窗口标题栏文本。如果未指定,窗口标题将为空。
|
设置窗口标题栏文本。如果未指定,窗口标题将为空。
|
||||||
|
|||||||
16
bin/cli.ts
vendored
16
bin/cli.ts
vendored
@@ -135,6 +135,11 @@ program
|
|||||||
.default(DEFAULT.incognito)
|
.default(DEFAULT.incognito)
|
||||||
.hideHelp(),
|
.hideHelp(),
|
||||||
)
|
)
|
||||||
|
.addOption(
|
||||||
|
new Option('--wasm', 'Enable WebAssembly support (Flutter Web, etc.)')
|
||||||
|
.default(DEFAULT.wasm)
|
||||||
|
.hideHelp(),
|
||||||
|
)
|
||||||
.addOption(
|
.addOption(
|
||||||
new Option('--installer-language <string>', 'Installer language')
|
new Option('--installer-language <string>', 'Installer language')
|
||||||
.default(DEFAULT.installerLanguage)
|
.default(DEFAULT.installerLanguage)
|
||||||
@@ -145,15 +150,10 @@ program
|
|||||||
await checkUpdateTips();
|
await checkUpdateTips();
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
program.outputHelp((str) => {
|
program.help({
|
||||||
return str
|
error: false
|
||||||
.split('\n')
|
|
||||||
.filter(
|
|
||||||
(line) => !/((-h,|--help)|((-v|-V),|--version))\s+.+$/.test(line),
|
|
||||||
)
|
|
||||||
.join('\n');
|
|
||||||
});
|
});
|
||||||
process.exit(0);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.setDefaultLevel('info');
|
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',
|
installerLanguage: 'en-US',
|
||||||
hideOnClose: true,
|
hideOnClose: true,
|
||||||
incognito: false,
|
incognito: false,
|
||||||
|
wasm: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Just for cli development
|
// 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,
|
hideOnClose,
|
||||||
incognito,
|
incognito,
|
||||||
title,
|
title,
|
||||||
|
wasm,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
const { platform } = process;
|
const { platform } = process;
|
||||||
@@ -78,6 +79,7 @@ export async function mergeConfig(
|
|||||||
hide_on_close: hideOnClose,
|
hide_on_close: hideOnClose,
|
||||||
incognito: incognito,
|
incognito: incognito,
|
||||||
title: title || null,
|
title: title || null,
|
||||||
|
enable_wasm: wasm,
|
||||||
};
|
};
|
||||||
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
||||||
|
|
||||||
@@ -312,6 +314,16 @@ StartupNotify=true
|
|||||||
}
|
}
|
||||||
tauriConf.pake.proxy_url = proxyUrl || '';
|
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.
|
// Save config file.
|
||||||
const platformConfigPaths: PlatformMap = {
|
const platformConfigPaths: PlatformMap = {
|
||||||
win32: 'tauri.windows.conf.json',
|
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
|
// Launch app in incognito/private mode, default false
|
||||||
incognito: boolean;
|
incognito: boolean;
|
||||||
|
|
||||||
|
// Enable WebAssembly support (Flutter Web, etc.), default false
|
||||||
|
wasm: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PakeAppOptions extends PakeCliOptions {
|
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);
|
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;
|
const { platform } = process;
|
||||||
// Set Windows parameters.
|
// Set Windows parameters.
|
||||||
const tauriConfWindowOptions = {
|
const tauriConfWindowOptions = {
|
||||||
@@ -360,6 +360,7 @@ async function mergeConfig(url, options, tauriConf) {
|
|||||||
hide_on_close: hideOnClose,
|
hide_on_close: hideOnClose,
|
||||||
incognito: incognito,
|
incognito: incognito,
|
||||||
title: title || null,
|
title: title || null,
|
||||||
|
enable_wasm: wasm,
|
||||||
};
|
};
|
||||||
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
||||||
tauriConf.productName = name;
|
tauriConf.productName = name;
|
||||||
@@ -553,6 +554,15 @@ StartupNotify=true
|
|||||||
await fsExtra.writeFile(injectFilePath, '');
|
await fsExtra.writeFile(injectFilePath, '');
|
||||||
}
|
}
|
||||||
tauriConf.pake.proxy_url = proxyUrl || '';
|
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.
|
// Save config file.
|
||||||
const platformConfigPaths = {
|
const platformConfigPaths = {
|
||||||
win32: 'tauri.windows.conf.json',
|
win32: 'tauri.windows.conf.json',
|
||||||
@@ -1030,6 +1040,7 @@ const DEFAULT_PAKE_OPTIONS = {
|
|||||||
installerLanguage: 'en-US',
|
installerLanguage: 'en-US',
|
||||||
hideOnClose: true,
|
hideOnClose: true,
|
||||||
incognito: false,
|
incognito: false,
|
||||||
|
wasm: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
async function checkUpdateTips() {
|
async function checkUpdateTips() {
|
||||||
@@ -1481,6 +1492,9 @@ program
|
|||||||
.addOption(new Option('--incognito', 'Launch app in incognito/private mode')
|
.addOption(new Option('--incognito', 'Launch app in incognito/private mode')
|
||||||
.default(DEFAULT_PAKE_OPTIONS.incognito)
|
.default(DEFAULT_PAKE_OPTIONS.incognito)
|
||||||
.hideHelp())
|
.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')
|
.addOption(new Option('--installer-language <string>', 'Installer language')
|
||||||
.default(DEFAULT_PAKE_OPTIONS.installerLanguage)
|
.default(DEFAULT_PAKE_OPTIONS.installerLanguage)
|
||||||
.hideHelp())
|
.hideHelp())
|
||||||
@@ -1488,13 +1502,10 @@ program
|
|||||||
.action(async (url, options) => {
|
.action(async (url, options) => {
|
||||||
await checkUpdateTips();
|
await checkUpdateTips();
|
||||||
if (!url) {
|
if (!url) {
|
||||||
program.outputHelp((str) => {
|
program.help({
|
||||||
return str
|
error: false
|
||||||
.split('\n')
|
|
||||||
.filter((line) => !/((-h,|--help)|((-v|-V),|--version))\s+.+$/.test(line))
|
|
||||||
.join('\n');
|
|
||||||
});
|
});
|
||||||
process.exit(0);
|
return;
|
||||||
}
|
}
|
||||||
log.setDefaultLevel('info');
|
log.setDefaultLevel('info');
|
||||||
if (options.debug) {
|
if (options.debug) {
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "pake-cli",
|
"name": "pake-cli",
|
||||||
"version": "3.2.15",
|
"version": "3.2.16",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pake-cli",
|
"name": "pake-cli",
|
||||||
"version": "3.2.15",
|
"version": "3.2.16",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tauri-apps/api": "^2.8.0",
|
"@tauri-apps/api": "^2.8.0",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ pub struct WindowConfig {
|
|||||||
pub hide_on_close: bool,
|
pub hide_on_close: bool,
|
||||||
pub incognito: bool,
|
pub incognito: bool,
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
|
pub enable_wasm: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[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/style.js"))
|
||||||
.initialization_script(include_str!("../inject/custom.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
|
// Configure proxy if specified
|
||||||
if !config.proxy_url.is_empty() {
|
if !config.proxy_url.is_empty() {
|
||||||
if let Ok(proxy_url) = Url::from_str(&config.proxy_url) {
|
if let Ok(proxy_url) = Url::from_str(&config.proxy_url) {
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
"iconPath": "png/weekly_512.png",
|
"iconPath": "png/weekly_512.png",
|
||||||
"iconAsTemplate": false,
|
"iconAsTemplate": false,
|
||||||
"id": "pake-tray"
|
"id": "pake-tray"
|
||||||
|
},
|
||||||
|
"security": {
|
||||||
|
"headers": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
|
|||||||
Reference in New Issue
Block a user