Skip to content

Commit e6819af

Browse files
committed
🐛 [desktop-dev] 修复createProcess参数错误
1 parent a38392b commit e6819af

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

desktop-dev/scripts/dnt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ await dnt.build({
111111
target: [
112112
{ target: "deb", arch: ["x64", "arm64"] },
113113
// { target: "rpm", arch: ["x64", "arm64"] },
114-
// { target: "tar.xz", arch: ["x64", "arm64"] },
114+
{ target: "tar.xz", arch: ["x64", "arm64"] },
115115
],
116116
},
117117
},

desktop-dev/src/browser/jmm/micro-module.js.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,29 @@ export class JsMicroModule extends MicroModule {
117117
*/
118118
private _process_id?: string;
119119

120+
static readonly VERSION: number = 1;
121+
static readonly PATCH: number = 0;
122+
120123
/** 每个 JMM 启动都要依赖于某一个js */
121124
async _bootstrap(context: $BootstrapContext) {
122125
console.always("jsmm", `[${this.metadata.config.id} micro-module.js.ct _bootstrap ${this.mmid}]`);
126+
console.always(
127+
"jsmm",
128+
`bootstrap minTarget: ${this.metadata.config.minTarget} maxTarget: ${this.metadata.config.maxTarget}`
129+
);
130+
131+
this.metadata.canSupportTarget(JsMicroModule.VERSION, (minTarget) => {
132+
throw new Error(
133+
`应用${this.mmid}与容器版本不匹配,当前版本:${JsMicroModule.VERSION},应用最低要求:${minTarget}",
134+
${this.short_name} 无法启动`
135+
);
136+
}, (maxTarget) => {
137+
throw new Error(
138+
`应用${this.mmid}与容器版本不匹配,当前版本:${JsMicroModule.VERSION},应用最高兼容到:${maxTarget}",
139+
${this.short_name} 无法启动`
140+
);
141+
});
142+
123143
const pid = Math.ceil(Math.random() * 1000).toString();
124144
this._process_id = pid;
125145
// 这个 streamIpc 专门服务于 file://js.browser.dweb/create-process
@@ -298,4 +318,19 @@ class JmmIpc extends Native2JsIpc {}
298318

299319
export class JsMMMetadata {
300320
constructor(readonly config: $JmmAppInstallManifest) {}
321+
322+
public canSupportTarget(
323+
version: number,
324+
disMatchMinTarget: (minTarget: number) => boolean,
325+
disMatchMaxTarget: (maxTarget: number) => boolean
326+
): boolean {
327+
if (this.config.minTarget > version) {
328+
return disMatchMinTarget(this.config.minTarget)
329+
}
330+
if (this.config.maxTarget != null && this.config.maxTarget < version) {
331+
return disMatchMaxTarget(this.config.maxTarget!);
332+
}
333+
334+
return true;
335+
}
301336
}

desktop-dev/src/browser/js-process/js-process.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { z, zq } from "../../helper/zodHelper.ts";
1616
import { closeHttpDwebServer, createHttpDwebServer } from "../../std/http/helper/$createHttpDwebServer.ts";
1717
import { saveNative2JsIpcPort } from "./ipc.native2js.ts";
1818
import { jsProcessOpenWindow } from "./js-process.openWindow.ts";
19+
import { JsMicroModule } from "../jmm/micro-module.js.ts";
1920

2021
type $APIS = typeof import("./assets/main/index.ts")["APIS"];
2122

@@ -323,9 +324,9 @@ export class JsProcessNMM extends NativeMicroModule {
323324
bootstrap_url,
324325
metadata,
325326
env,
326-
// JSON.stringify(metadata),
327-
// JSON.stringify(env),
328-
transfer(channel_for_worker.port2, [channel_for_worker.port2])
327+
transfer(channel_for_worker.port2, [channel_for_worker.port2]),
328+
httpDwebServer.startResult.urlInfo.host,
329+
JSON.stringify({jsMicroModule: `${JsMicroModule.VERSION}.${JsMicroModule.PATCH}`})
329330
);
330331

331332
/**

0 commit comments

Comments
 (0)