Comparing version 3.1.13 to 3.1.14
@@ -452,5 +452,15 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const iconLength = parseInt(yield blob.slice(0, 7).text()); | ||
const icon = yield tool.blob2DataUrl(blob.slice(7, 7 + iconLength)); | ||
const z = yield zip.get(blob.slice(7 + iconLength)); | ||
const head = yield tool.blob2Text(blob.slice(0, 5)); | ||
if (head !== '-CGA-') { | ||
return false; | ||
} | ||
const iconLength = parseInt(yield blob.slice(21, 28).text()); | ||
if (Number.isNaN(iconLength)) { | ||
return false; | ||
} | ||
const icon = iconLength ? yield tool.blob2DataUrl(blob.slice(28, 28 + iconLength)) : ''; | ||
const nb = new Blob([blob.slice(5, 21), blob.slice(28 + iconLength)], { | ||
'type': blob.type | ||
}); | ||
const z = yield zip.get(nb); | ||
if (!z) { | ||
@@ -506,2 +516,13 @@ return false; | ||
} | ||
if (!taskId && | ||
!url.startsWith('/clickgo/') && | ||
!url.startsWith('/storage/') && | ||
!url.startsWith('/mounted/') && | ||
!url.startsWith('/package/') && | ||
!url.startsWith('/current/') && | ||
!url.startsWith('http:') && | ||
!url.startsWith('https:') && | ||
!url.startsWith('file:')) { | ||
url = tool.urlResolve(location.href, url); | ||
} | ||
if (cga) { | ||
@@ -508,0 +529,0 @@ try { |
@@ -536,5 +536,15 @@ /** | ||
export async function readApp(blob: Blob): Promise<false | types.IApp> { | ||
const iconLength = parseInt(await blob.slice(0, 7).text()); | ||
const icon = await tool.blob2DataUrl(blob.slice(7, 7 + iconLength)); | ||
const z = await zip.get(blob.slice(7 + iconLength)); | ||
const head = await tool.blob2Text(blob.slice(0, 5)); | ||
if (head !== '-CGA-') { | ||
return false; | ||
} | ||
const iconLength = parseInt(await blob.slice(21, 28).text()); | ||
if (Number.isNaN(iconLength)) { | ||
return false; | ||
} | ||
const icon = iconLength ? await tool.blob2DataUrl(blob.slice(28, 28 + iconLength)) : ''; | ||
const nb = new Blob([blob.slice(5, 21), blob.slice(28 + iconLength)], { | ||
'type': blob.type | ||
}); | ||
const z = await zip.get(nb); | ||
if (!z) { | ||
@@ -602,2 +612,15 @@ return false; | ||
} | ||
// --- 非 taskId 模式下 current 以 location 为准 --- | ||
if (!taskId && | ||
!url.startsWith('/clickgo/') && | ||
!url.startsWith('/storage/') && | ||
!url.startsWith('/mounted/') && | ||
!url.startsWith('/package/') && | ||
!url.startsWith('/current/') && | ||
!url.startsWith('http:') && | ||
!url.startsWith('https:') && | ||
!url.startsWith('file:') | ||
) { | ||
url = tool.urlResolve(location.href, url); | ||
} | ||
// --- 如果是 cga 文件,直接读取并交给 readApp 函数处理 --- | ||
@@ -604,0 +627,0 @@ if (cga) { |
@@ -196,38 +196,47 @@ "use strict"; | ||
function run(url, opt = {}, ntid) { | ||
var _a, _b, _c, _d, _e; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!url.endsWith('/') && !url.endsWith('.cga')) { | ||
return 0; | ||
let app = null; | ||
if (typeof url === 'string') { | ||
if (!url.endsWith('/') && !url.endsWith('.cga')) { | ||
return 0; | ||
} | ||
let icon = __dirname + '/../icon.png'; | ||
if (opt.icon) { | ||
icon = opt.icon; | ||
} | ||
if (opt.notify === undefined) { | ||
opt.notify = true; | ||
} | ||
const notifyId = opt.notify ? form.notify({ | ||
'title': (_b = (_a = localeData[core.config.locale]) === null || _a === void 0 ? void 0 : _a.loading) !== null && _b !== void 0 ? _b : localeData['en'].loading, | ||
'content': url, | ||
'icon': icon, | ||
'timeout': 0, | ||
'progress': true | ||
}) : undefined; | ||
if (!ntid && | ||
!url.startsWith('/clickgo/') && | ||
!url.startsWith('/storage/') && | ||
!url.startsWith('/mounted/') && | ||
!url.startsWith('/package/') && | ||
!url.startsWith('/current/')) { | ||
url = tool.urlResolve(location.href, url); | ||
} | ||
app = yield core.fetchApp(url, { | ||
'notifyId': notifyId, | ||
'progress': opt.progress | ||
}, ntid); | ||
if (notifyId) { | ||
setTimeout(function () { | ||
form.hideNotify(notifyId); | ||
}, 2000); | ||
} | ||
} | ||
let icon = __dirname + '/../icon.png'; | ||
if (opt.icon) { | ||
icon = opt.icon; | ||
else if (url.type !== 'app') { | ||
return -1; | ||
} | ||
if (opt.notify === undefined) { | ||
opt.notify = true; | ||
else { | ||
app = url; | ||
} | ||
const notifyId = opt.notify ? form.notify({ | ||
'title': (_b = (_a = localeData[core.config.locale]) === null || _a === void 0 ? void 0 : _a.loading) !== null && _b !== void 0 ? _b : localeData['en'].loading, | ||
'content': url, | ||
'icon': icon, | ||
'timeout': 0, | ||
'progress': true | ||
}) : undefined; | ||
if (!ntid && | ||
!url.startsWith('/clickgo/') && | ||
!url.startsWith('/storage/') && | ||
!url.startsWith('/mounted/') && | ||
!url.startsWith('/package/') && | ||
!url.startsWith('/current/')) { | ||
url = tool.urlResolve(location.href, url); | ||
} | ||
const app = yield core.fetchApp(url, { | ||
'notifyId': notifyId, | ||
'progress': opt.progress | ||
}, ntid); | ||
if (notifyId) { | ||
setTimeout(function () { | ||
form.hideNotify(notifyId); | ||
}, 2000); | ||
} | ||
if (!app) { | ||
@@ -970,3 +979,3 @@ return -1; | ||
app.files['/invoke/clickgo.js'] = `module.exports = invokeClickgo;`; | ||
const path = url; | ||
const path = (_c = opt.path) !== null && _c !== void 0 ? _c : ((typeof url === 'string') ? url : '/runtime/' + tool.random(8, tool.RANDOM_LUN) + '.cga'); | ||
const lio = path.endsWith('.cga') ? path.lastIndexOf('/') : path.slice(0, -1).lastIndexOf('/'); | ||
@@ -986,3 +995,3 @@ const current = path.slice(0, lio); | ||
'dialogFormIds': [], | ||
'permissions': (_c = opt.permissions) !== null && _c !== void 0 ? _c : [] | ||
'permissions': (_d = opt.permissions) !== null && _d !== void 0 ? _d : [] | ||
}), | ||
@@ -1000,2 +1009,3 @@ 'forms': {}, | ||
} | ||
yield ((_e = opt.initProgress) === null || _e === void 0 ? void 0 : _e.call(opt, 'Load local ' + path + ' ...')); | ||
const lcontent = yield fs.getContent(path, { | ||
@@ -1011,3 +1021,3 @@ 'encoding': 'utf8' | ||
} | ||
catch (_f) { | ||
catch (_p) { | ||
} | ||
@@ -1041,2 +1051,3 @@ } | ||
dom.createToStyleList(taskId); | ||
yield ((_f = opt.initProgress) === null || _f === void 0 ? void 0 : _f.call(opt, 'Control initialization ...')); | ||
const r = yield control.init(taskId, invoke); | ||
@@ -1048,6 +1059,7 @@ if (r < 0) { | ||
} | ||
if ((_d = app.config.themes) === null || _d === void 0 ? void 0 : _d.length) { | ||
if ((_g = app.config.themes) === null || _g === void 0 ? void 0 : _g.length) { | ||
for (let path of app.config.themes) { | ||
path += '.cgt'; | ||
path = tool.urlResolve('/', path); | ||
yield ((_h = opt.initProgress) === null || _h === void 0 ? void 0 : _h.call(opt, 'Load theme ' + path + ' ...')); | ||
const file = yield fs.getContent(path, undefined, taskId); | ||
@@ -1064,2 +1076,3 @@ if (file && typeof file !== 'string') { | ||
if (theme.global) { | ||
yield ((_j = opt.initProgress) === null || _j === void 0 ? void 0 : _j.call(opt, 'Load global theme ...')); | ||
yield theme.load(undefined, taskId); | ||
@@ -1074,2 +1087,3 @@ } | ||
const r = tool.stylePrepend(style, 'cg-task' + taskId.toString() + '_'); | ||
yield ((_k = opt.initProgress) === null || _k === void 0 ? void 0 : _k.call(opt, 'Style initialization ...')); | ||
dom.pushStyle(taskId, yield tool.styleUrl2DataUrl(app.config.style, r.style, app.files)); | ||
@@ -1080,2 +1094,3 @@ } | ||
if (app.config.permissions) { | ||
yield ((_l = opt.initProgress) === null || _l === void 0 ? void 0 : _l.call(opt, 'Style initialization ...')); | ||
yield checkPermission(app.config.permissions, true, undefined, taskId); | ||
@@ -1085,3 +1100,4 @@ } | ||
exports.list[taskId].class = appCls; | ||
yield appCls.main((_e = opt.data) !== null && _e !== void 0 ? _e : {}); | ||
yield ((_m = opt.initProgress) === null || _m === void 0 ? void 0 : _m.call(opt, 'Starting ...')); | ||
yield appCls.main((_o = opt.data) !== null && _o !== void 0 ? _o : {}); | ||
return taskId; | ||
@@ -1088,0 +1104,0 @@ }); |
{ | ||
"name": "clickgo", | ||
"version": "3.1.13", | ||
"version": "3.1.14", | ||
"description": "Background interface, software interface, mobile phone APP interface operation library.", | ||
@@ -27,3 +27,6 @@ "keywords": [ | ||
"typescript": "^4.9.4" | ||
}, | ||
"dependencies": { | ||
"terser": "^5.16.1" | ||
} | ||
} |
@@ -31,3 +31,3 @@ # ClickGo | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/@litert/loader@3.4.9/dist/loader.min.js?path=index&npm={'clickgo':'3.1.13'}"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@litert/loader@3.4.9/dist/loader.min.js?path=index&npm={'clickgo':'3.1.14'}"></script> | ||
``` | ||
@@ -34,0 +34,0 @@ |
@@ -424,2 +424,4 @@ export * as control from '../dist/lib/control'; | ||
'progress'?: (loaded: number, total: number) => void | Promise<void>; | ||
/** --- 初始化进度回调 --- */ | ||
'initProgress'?: (state: string) => void | Promise<void>; | ||
/** --- 显示 notify 窗口 --- */ | ||
@@ -433,2 +435,4 @@ 'notify'?: boolean; | ||
'data'?: Record<string, any>; | ||
/** --- 执行文件的基路径,一般在传入 APP 包时使用,以 .cga 结尾或不以 / 结尾的路径 --- */ | ||
'path'?: string; | ||
} | ||
@@ -435,0 +439,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
26195
1221181
1
+ Addedterser@^5.16.1
+ Added@jridgewell/gen-mapping@0.3.8(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/source-map@0.3.6(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Addedacorn@8.14.1(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
+ Addedterser@5.39.0(transitive)