@mearl/client 2.20.3 → 2.20.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pluginPageBundle.js +12 -1
- package/dist/pluginRegistry.d.ts +3 -0
- package/dist/pluginRegistry.js +11 -0
- package/package.json +3 -3
package/dist/pluginPageBundle.js
CHANGED
|
@@ -30,6 +30,7 @@ const PAGE_BRIDGE_SCRIPT = String.raw `(() => {
|
|
|
30
30
|
let requestSequence = 0;
|
|
31
31
|
const pending = new Map();
|
|
32
32
|
const pageEventListeners = new Map();
|
|
33
|
+
const contextListeners = new Set();
|
|
33
34
|
let subscriptionSequence = 0;
|
|
34
35
|
let resolveReady;
|
|
35
36
|
const ready = new Promise(resolve => { resolveReady = resolve; });
|
|
@@ -397,7 +398,13 @@ const PAGE_BRIDGE_SCRIPT = String.raw `(() => {
|
|
|
397
398
|
return query;
|
|
398
399
|
};
|
|
399
400
|
|
|
400
|
-
const
|
|
401
|
+
const onContextChange = listener => {
|
|
402
|
+
if (typeof listener !== 'function') throw new Error('Invalid context listener');
|
|
403
|
+
contextListeners.add(listener);
|
|
404
|
+
if (context) listener(context);
|
|
405
|
+
return () => contextListeners.delete(listener);
|
|
406
|
+
};
|
|
407
|
+
const api = { invoke, subscribe, onContextChange, ready: async () => { await ready; return context; }, runAgentTask, setAgentGuides, setAgentPanelVisible, setQueryParam };
|
|
401
408
|
const ui = globalThis.__mearlToolboxUi;
|
|
402
409
|
if (ui !== undefined) {
|
|
403
410
|
if (!ui || typeof ui !== 'object' || ui.runtime !== 'preact') {
|
|
@@ -421,6 +428,10 @@ const PAGE_BRIDGE_SCRIPT = String.raw `(() => {
|
|
|
421
428
|
document.documentElement.style.colorScheme = theme;
|
|
422
429
|
if (/^\d+(?:\.\d+)?px$/.test(fontSize)) document.documentElement.style.fontSize = fontSize;
|
|
423
430
|
context = Object.freeze({ ...(context || {}), ...(nextContext || {}), theme });
|
|
431
|
+
for (const listener of contextListeners) {
|
|
432
|
+
try { listener(context); }
|
|
433
|
+
catch (error) { console.error('Toolbox context listener failed', error); }
|
|
434
|
+
}
|
|
424
435
|
return context;
|
|
425
436
|
};
|
|
426
437
|
|
package/dist/pluginRegistry.d.ts
CHANGED
package/dist/pluginRegistry.js
CHANGED
|
@@ -199,6 +199,17 @@ export function normalizePluginToolboxContribution(value) {
|
|
|
199
199
|
entry: pageEntry,
|
|
200
200
|
commands,
|
|
201
201
|
};
|
|
202
|
+
if (pageCandidate.lifecycle !== undefined) {
|
|
203
|
+
const lifecycle = pageCandidate.lifecycle;
|
|
204
|
+
if (!lifecycle ||
|
|
205
|
+
typeof lifecycle !== 'object' ||
|
|
206
|
+
Array.isArray(lifecycle) ||
|
|
207
|
+
typeof lifecycle.onNavigation !== 'string' ||
|
|
208
|
+
!commands.includes(lifecycle.onNavigation)) {
|
|
209
|
+
throw new Error('toolbox.page.lifecycle.onNavigation 必须是 page.commands 中的命令名称');
|
|
210
|
+
}
|
|
211
|
+
page.lifecycle = { onNavigation: lifecycle.onNavigation };
|
|
212
|
+
}
|
|
202
213
|
let agent;
|
|
203
214
|
if (candidate.agent !== undefined) {
|
|
204
215
|
if (!candidate.agent || typeof candidate.agent !== 'object' || Array.isArray(candidate.agent)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mearl/client",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.4",
|
|
4
4
|
"description": "Unified Mearl SDK & CLI for local and remote browsers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"commander": "^15.0.0",
|
|
60
60
|
"fastest-levenshtein": "^1.0.16",
|
|
61
61
|
"ws": "^8.18.0",
|
|
62
|
-
"@mearl/cloud-types": "2.20.
|
|
63
|
-
"@mearl/provider": "2.20.
|
|
62
|
+
"@mearl/cloud-types": "2.20.4",
|
|
63
|
+
"@mearl/provider": "2.20.4"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "^24.9.1",
|