Skip to content

Commit c812f19

Browse files
committed
update:simplecc引入错误捕获
1 parent f71c25f commit c812f19

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

libs/drpyS.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {existsSync, readFileSync} from 'fs';
33
import {fileURLToPath} from "url";
44
import {createRequire} from 'module';
55
import {XMLHttpRequest} from 'xmlhttprequest';
6-
import {simplecc} from "simplecc-wasm";
76
import path from "path";
87
import vm from 'vm';
98
import '../libs_drpy/es6-extend.js'
@@ -49,7 +48,6 @@ globalThis.Ali = Ali;
4948
globalThis.require = createRequire(import.meta.url);
5049
globalThis._fetch = fetch;
5150
globalThis.XMLHttpRequest = XMLHttpRequest;
52-
globalThis.simplecc = simplecc;
5351
globalThis.SparkAI = SparkAI;
5452
globalThis.pathLib = {
5553
basename: path.basename,
@@ -93,6 +91,7 @@ if (typeof fetchByHiker === 'undefined') { // 判断是海阔直接放弃导入p
9391
}
9492
}
9593
globalThis.pupWebview = pupWebview;
94+
9695
try {
9796
if (typeof fetchByHiker !== 'undefined' && typeof globalThis.import === 'function') {
9897
await globalThis.import('../libs_drpy/crypto-js-wasm.js'); // 海阔放在globalThis里去动态引入
@@ -113,6 +112,19 @@ try {
113112
};
114113
}
115114

115+
let simplecc = null;
116+
try {
117+
// 尝试动态导入模块puppeteerHelper
118+
const simWasm = await import('simplecc-wasm'); // 使用动态 import
119+
simplecc = simWasm.simplecc;
120+
console.log('simplecc imported successfully');
121+
} catch (error) {
122+
// console.log('Failed to import puppeteerHelper:', error);
123+
console.log(`Failed to import simplecc:${error.message}`);
124+
}
125+
globalThis.simplecc = simplecc;
126+
127+
116128
export async function getSandbox(env = {}) {
117129
const {getProxyUrl} = env;
118130
// (可选) 加载所有 wasm 文件

0 commit comments

Comments
 (0)