@mearl/client 2.22.0 → 3.0.0-beta.0

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.
Files changed (88) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +40 -40
  3. package/dist/actionTimeouts.js +1 -1
  4. package/dist/artifacts.d.ts +1 -1
  5. package/dist/autoUpdate.js +1 -2
  6. package/dist/browserRegistry.d.ts +1 -1
  7. package/dist/check.d.ts +1 -1
  8. package/dist/check.js +4 -3
  9. package/dist/commands.d.ts +12 -12
  10. package/dist/commands.js +15 -14
  11. package/dist/index.d.ts +4 -7
  12. package/dist/index.js +1 -1
  13. package/dist/local.d.ts +3 -1
  14. package/dist/local.js +2 -1
  15. package/dist/pageEvalArguments.d.ts +1 -1
  16. package/dist/pageEvalArguments.js +1 -1
  17. package/dist/plugin.d.ts +1 -0
  18. package/dist/plugin.js +1 -0
  19. package/dist/pluginModelSessionWorker.d.ts +2 -2
  20. package/dist/plugins/clients/pluginHostConnection.d.ts +1 -1
  21. package/dist/plugins/clients/pluginHostConnection.js +1 -1
  22. package/dist/plugins/clients/pluginModels.d.ts +3 -3
  23. package/dist/plugins/clients/pluginPages.d.ts +2 -2
  24. package/dist/plugins/clients/pluginState.d.ts +2 -2
  25. package/dist/plugins/clients/pluginTasks.d.ts +3 -3
  26. package/dist/plugins/clients/pluginTasks.js +1 -1
  27. package/dist/plugins/officialPluginCatalog.d.ts +18 -21
  28. package/dist/plugins/officialPluginCatalog.js +120 -24
  29. package/dist/plugins/officialPluginInstaller.js +6 -1
  30. package/dist/plugins/pluginRegistry.d.ts +1 -1
  31. package/dist/plugins/pluginRegistry.js +2 -2
  32. package/dist/plugins/pluginTaskProtocol.d.ts +1 -1
  33. package/dist/plugins/runtime/pluginDiagnostics.d.ts +3 -3
  34. package/dist/plugins/runtime/pluginDiagnostics.js +2 -2
  35. package/dist/plugins/runtime/pluginExecution.d.ts +2 -2
  36. package/dist/plugins/runtime/pluginExecutor.d.ts +1 -1
  37. package/dist/plugins/runtime/pluginExecutorProtocol.d.ts +2 -2
  38. package/dist/plugins/runtime/pluginHost.d.ts +2 -2
  39. package/dist/plugins/runtime/pluginHostServer.js +1 -1
  40. package/dist/plugins/runtime/pluginModelCatalog.d.ts +1 -1
  41. package/dist/plugins/runtime/pluginPageManager.d.ts +3 -3
  42. package/dist/plugins/runtime/pluginPageManager.js +2 -2
  43. package/dist/plugins/runtime/pluginRevision.js +2 -1
  44. package/dist/plugins/runtime/pluginStateManager.d.ts +1 -1
  45. package/dist/plugins/runtime/pluginStateStore.d.ts +1 -1
  46. package/dist/plugins/runtime/pluginTaskManager.d.ts +10 -10
  47. package/dist/plugins/runtime/pluginTaskManager.js +1 -1
  48. package/dist/plugins/runtime/pluginTaskStore.d.ts +3 -3
  49. package/dist/plugins/runtime/pluginTaskStore.js +1 -1
  50. package/dist/plugins/runtime/pythonPlugin.d.ts +1 -1
  51. package/dist/plugins/sdk/plugin.d.ts +9 -12
  52. package/dist/plugins/sdk/plugin.js +4 -7
  53. package/dist/plugins/sdk/pluginAppProfiles.d.ts +1 -1
  54. package/dist/plugins/sdk/pluginAppProfiles.js +1 -1
  55. package/dist/plugins/sdk/pluginModelDefinition.d.ts +1 -1
  56. package/dist/plugins/sdk/pluginPageDefinition.d.ts +1 -1
  57. package/dist/plugins/sdk/pluginPageDefinition.js +1 -1
  58. package/dist/plugins/sdk/pluginRecoveryDefinition.d.ts +1 -1
  59. package/dist/plugins/sdk/pluginStateDefinition.d.ts +2 -2
  60. package/dist/plugins/skillManifest.d.ts +10 -0
  61. package/dist/plugins/skillManifest.js +56 -0
  62. package/dist/socket.d.ts +2 -0
  63. package/dist/socket.js +13 -3
  64. package/dist/unified.d.ts +1 -1
  65. package/dist/unified.js +1 -1
  66. package/package.json +9 -8
  67. package/dist/generated/app-profile-definition.d.ts +0 -130
  68. package/dist/generated/app-profile-definition.js +0 -458
  69. package/dist/generated/app-profile-runtime-types.d.ts +0 -213
  70. package/dist/generated/app-profile-runtime-types.js +0 -1
  71. package/dist/generated/browser-action-protocol.d.ts +0 -1147
  72. package/dist/generated/browser-action-protocol.js +0 -283
  73. package/dist/generated/plugin-diagnostics.d.ts +0 -110
  74. package/dist/generated/plugin-diagnostics.js +0 -1
  75. package/dist/generated/plugin-execution.d.ts +0 -27
  76. package/dist/generated/plugin-execution.js +0 -1
  77. package/dist/generated/plugin-models.d.ts +0 -64
  78. package/dist/generated/plugin-models.js +0 -1
  79. package/dist/generated/plugin-pages.d.ts +0 -76
  80. package/dist/generated/plugin-pages.js +0 -59
  81. package/dist/generated/plugin-recovery.d.ts +0 -32
  82. package/dist/generated/plugin-recovery.js +0 -1
  83. package/dist/generated/plugin-state.d.ts +0 -50
  84. package/dist/generated/plugin-state.js +0 -1
  85. package/dist/generated/plugin-tasks.d.ts +0 -74
  86. package/dist/generated/plugin-tasks.js +0 -7
  87. package/dist/generated/toolbox-icon.d.ts +0 -10
  88. package/dist/generated/toolbox-icon.js +0 -37
@@ -1,458 +0,0 @@
1
- const BRIDGE_STYLES = new Set([
2
- 'windvane',
3
- 'fliggy',
4
- 'alipay',
5
- 'callback',
6
- 'btrip',
7
- 'invoke',
8
- 'callHandler',
9
- 'amap',
10
- 'didi',
11
- 'easybikeNative',
12
- 'mega',
13
- 'wechat',
14
- 'wechatMiniProgram',
15
- ]);
16
- export const APP_BRIDGE_BEHAVIORS = [
17
- 'navigate',
18
- 'closeAll',
19
- 'closeBackData',
20
- 'postMessage',
21
- 'notifySubscribe',
22
- 'notifyUnsubscribe',
23
- 'notifyPost',
24
- 'sharedFileRead',
25
- 'sharedFileWrite',
26
- 'sharedDataGet',
27
- 'sharedDataSet',
28
- 'legacyBroadcastCreate',
29
- 'legacyBroadcastPost',
30
- 'legacyBroadcastClose',
31
- 'memoryGet',
32
- 'memorySet',
33
- 'memoryDelete',
34
- 'availabilityMap',
35
- 'userInfo',
36
- 'authCode',
37
- 'networkInfo',
38
- 'geolocation',
39
- 'permission',
40
- 'imagePicker',
41
- 'prefetch',
42
- 'fptTrack',
43
- 'mtopStream',
44
- 'previewFile',
45
- 'toast',
46
- 'unsupportedNativeInput',
47
- 'payment',
48
- 'userTrack',
49
- 'calendar',
50
- 'networkQualityMonitor',
51
- 'beaconRequest',
52
- 'voiceRecognition',
53
- ];
54
- const BEHAVIORS = new Set(APP_BRIDGE_BEHAVIORS);
55
- function record(value) {
56
- return value !== null && typeof value === 'object' && !Array.isArray(value);
57
- }
58
- function invalid(path) {
59
- throw new Error(`Invalid app profile: ${path}`);
60
- }
61
- function text(value) {
62
- return (typeof value === 'string' &&
63
- value.length <= 4096 &&
64
- Array.from(value).every(character => character.charCodeAt(0) > 8));
65
- }
66
- function strings(value) {
67
- return Array.isArray(value) && value.length <= 200 && value.every(text);
68
- }
69
- function fields(value, required, optional, path) {
70
- if (!record(value) ||
71
- required.some(key => !Object.hasOwn(value, key)) ||
72
- Object.keys(value).some(key => !required.includes(key) && !optional.includes(key)))
73
- invalid(path);
74
- }
75
- function stringMap(value) {
76
- return record(value) && Object.keys(value).length <= 200 && Object.values(value).every(text);
77
- }
78
- function json(value, depth = 0) {
79
- if (depth > 25)
80
- return false;
81
- if (value === null || typeof value === 'boolean' || text(value))
82
- return true;
83
- if (typeof value === 'number')
84
- return Number.isFinite(value);
85
- if (Array.isArray(value))
86
- return value.length <= 1000 && value.every(item => json(item, depth + 1));
87
- return (record(value) &&
88
- Object.entries(value).every(([key, item]) => !['__proto__', 'prototype', 'constructor'].includes(key) && json(item, depth + 1)));
89
- }
90
- function validateActions(value) {
91
- const arrays = [
92
- 'open',
93
- 'close',
94
- 'title',
95
- 'navigationBar',
96
- 'statusBar',
97
- 'systemInfo',
98
- 'mtop',
99
- 'kvGet',
100
- 'kvSet',
101
- 'kvDelete',
102
- 'pageContext',
103
- 'noop',
104
- 'silent',
105
- ];
106
- fields(value, ['open', 'close', 'title', 'systemInfo', 'mtop', 'noop'], [...arrays, 'responses', 'behaviors'], 'actions');
107
- for (const key of arrays)
108
- if (value[key] !== undefined && !strings(value[key]))
109
- invalid(`actions.${key}`);
110
- if (value.responses !== undefined && !record(value.responses))
111
- invalid('actions.responses');
112
- if (value.behaviors !== undefined &&
113
- (!stringMap(value.behaviors) ||
114
- !Object.values(value.behaviors).every(item => BEHAVIORS.has(item))))
115
- invalid('actions.behaviors');
116
- }
117
- /** Validate plain data before registration or compiling a document-start configuration. */
118
- export function validateAppProfileDefinition(value) {
119
- if (!json(value))
120
- invalid('JSON');
121
- if (JSON.stringify(value).length > 65_536)
122
- invalid('definition exceeds 64 KiB');
123
- const required = [
124
- 'name',
125
- 'label',
126
- 'appName',
127
- 'defaultAppVersion',
128
- 'uaTokens',
129
- 'globals',
130
- 'bridges',
131
- 'activeEvents',
132
- 'actions',
133
- 'schemes',
134
- ];
135
- const optional = [
136
- 'uaFamily',
137
- 'uaTemplate',
138
- 'policies',
139
- 'settings',
140
- 'settingsGroup',
141
- 'miniProgram',
142
- 'imagePicker',
143
- 'geolocation',
144
- 'urlSyncHostSuffixes',
145
- 'overlay',
146
- 'popBeforeOpenParam',
147
- 'messageEvent',
148
- 'nativeBack',
149
- 'layerUrlProxy',
150
- 'rootContainer',
151
- 'titleBarHiddenPathnames',
152
- 'statusBarBackgroundColors',
153
- 'titleBarHostStyles',
154
- 'forceH5Mtop',
155
- ];
156
- fields(value, required, optional, 'definition');
157
- for (const key of ['name', 'label', 'appName', 'defaultAppVersion'])
158
- if (!text(value[key]) || !value[key])
159
- invalid(key);
160
- if (!/^[a-z][a-z0-9-]*(?:\/[a-z][a-z0-9-]*)?$/.test(value.name))
161
- invalid('name');
162
- for (const key of [
163
- 'uaTokens',
164
- 'activeEvents',
165
- 'urlSyncHostSuffixes',
166
- 'titleBarHiddenPathnames',
167
- ]) {
168
- if (value[key] !== undefined && !strings(value[key]))
169
- invalid(key);
170
- }
171
- if (!stringMap(value.globals))
172
- invalid('globals');
173
- if (!Array.isArray(value.bridges) || value.bridges.length > 20)
174
- invalid('bridges');
175
- const globals = new Set();
176
- for (const bridge of value.bridges) {
177
- fields(bridge, ['global', 'style'], ['persistent'], 'bridges');
178
- if (!text(bridge.global) ||
179
- !/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(bridge.global) ||
180
- bridge.global
181
- .split('.')
182
- .some(part => ['__proto__', 'prototype', 'constructor'].includes(part)) ||
183
- globals.has(bridge.global) ||
184
- !BRIDGE_STYLES.has(bridge.style) ||
185
- (bridge.persistent !== undefined && typeof bridge.persistent !== 'boolean'))
186
- invalid('bridge');
187
- globals.add(bridge.global);
188
- }
189
- validateActions(value.actions);
190
- if (value.settingsGroup !== undefined &&
191
- !['fliggy', 'alipay'].includes(value.settingsGroup))
192
- invalid('settingsGroup');
193
- if (value.uaFamily !== undefined &&
194
- !['aliapp', 'wechatMiniProgram'].includes(value.uaFamily))
195
- invalid('uaFamily');
196
- if (value.uaTemplate !== undefined) {
197
- fields(value.uaTemplate, ['ios', 'android'], [], 'uaTemplate');
198
- if (!text(value.uaTemplate.ios) || !text(value.uaTemplate.android))
199
- invalid('uaTemplate');
200
- }
201
- if (value.policies !== undefined) {
202
- fields(value.policies, [], ['titleBar', 'navigatorLanguage', 'networkResult', 'languages', 'defaultLanguage'], 'policies');
203
- const p = value.policies;
204
- if (p.titleBar !== undefined &&
205
- !['default', 'taobao', 'fliggy', 'alipay', 'wechat'].includes(p.titleBar))
206
- invalid('policies.titleBar');
207
- if (p.networkResult !== undefined && !['default', 'alipay'].includes(p.networkResult))
208
- invalid('policies.networkResult');
209
- if (p.navigatorLanguage !== undefined && typeof p.navigatorLanguage !== 'boolean')
210
- invalid('policies.navigatorLanguage');
211
- if (p.languages !== undefined && (!strings(p.languages) || !p.languages.length))
212
- invalid('policies.languages');
213
- if (p.defaultLanguage !== undefined &&
214
- (!text(p.defaultLanguage) ||
215
- (p.languages && !p.languages.includes(p.defaultLanguage))))
216
- invalid('policies.defaultLanguage');
217
- }
218
- if (!Array.isArray(value.schemes) || value.schemes.length > 100)
219
- invalid('schemes');
220
- for (const rule of value.schemes) {
221
- fields(rule, ['match'], [
222
- 'hostSuffixes',
223
- 'param',
224
- 'useCurrentOrigin',
225
- 'targetPath',
226
- 'targetHostPrefix',
227
- 'targetParams',
228
- ], 'scheme');
229
- for (const key of ['match', 'param', 'targetPath', 'targetHostPrefix'])
230
- if (rule[key] !== undefined && !text(rule[key]))
231
- invalid(`scheme.${key}`);
232
- if (rule.hostSuffixes !== undefined && !strings(rule.hostSuffixes))
233
- invalid('scheme.hostSuffixes');
234
- if (rule.useCurrentOrigin !== undefined && typeof rule.useCurrentOrigin !== 'boolean')
235
- invalid('scheme.useCurrentOrigin');
236
- if (rule.targetParams !== undefined && !stringMap(rule.targetParams))
237
- invalid('scheme.targetParams');
238
- }
239
- if (value.settings !== undefined) {
240
- if (!Array.isArray(value.settings) || value.settings.length > 30)
241
- invalid('settings');
242
- const ids = new Set();
243
- for (const setting of value.settings) {
244
- fields(setting, ['id', 'label', 'type', 'target'], ['choices', 'minimum', 'maximum'], 'setting');
245
- if (!text(setting.id) ||
246
- !/^[a-z][a-zA-Z0-9-]*$/.test(setting.id) ||
247
- ids.has(setting.id) ||
248
- !text(setting.label) ||
249
- !['select', 'boolean', 'number', 'text', 'json'].includes(setting.type))
250
- invalid('setting');
251
- ids.add(setting.id);
252
- if (record(setting.target) && setting.target.option !== undefined) {
253
- fields(setting.target, ['option'], [], 'setting.target');
254
- if (setting.target.option !== 'language')
255
- invalid('setting.target.option');
256
- }
257
- else {
258
- fields(setting.target, ['method'], ['field'], 'setting.target');
259
- if (!text(setting.target.method) ||
260
- !setting.target.method ||
261
- ['__proto__', 'prototype', 'constructor'].includes(setting.target.method) ||
262
- (setting.target.field !== undefined &&
263
- (!text(setting.target.field) ||
264
- ['__proto__', 'prototype', 'constructor'].includes(setting.target.field))))
265
- invalid('setting.target.method');
266
- const method = setting.target.method;
267
- if ([
268
- 'open',
269
- 'close',
270
- 'title',
271
- 'navigationBar',
272
- 'statusBar',
273
- 'systemInfo',
274
- 'mtop',
275
- 'kvGet',
276
- 'kvSet',
277
- 'kvDelete',
278
- 'pageContext',
279
- ].some(key => value.actions[key]?.includes(method)))
280
- invalid('setting targets a structural method');
281
- }
282
- if (setting.choices !== undefined &&
283
- (!Array.isArray(setting.choices) ||
284
- !setting.choices.length ||
285
- setting.choices.some(choice => !record(choice) || !text(choice.label) || !text(choice.value))))
286
- invalid('setting.choices');
287
- for (const key of ['minimum', 'maximum'])
288
- if (setting[key] !== undefined && typeof setting[key] !== 'number')
289
- invalid(`setting.${key}`);
290
- if (setting.type === 'select' && !Array.isArray(setting.choices))
291
- invalid('setting.choices required');
292
- if (setting.minimum !== undefined &&
293
- setting.maximum !== undefined &&
294
- setting.minimum > setting.maximum)
295
- invalid('setting range');
296
- if ('option' in setting.target && !['select', 'text'].includes(setting.type))
297
- invalid('setting.option type');
298
- }
299
- }
300
- for (const key of ['forceH5Mtop'])
301
- if (value[key] !== undefined && typeof value[key] !== 'boolean')
302
- invalid(key);
303
- for (const key of ['popBeforeOpenParam', 'messageEvent'])
304
- if (value[key] !== undefined && !text(value[key]))
305
- invalid(key);
306
- if (value.statusBarBackgroundColors !== undefined && !stringMap(value.statusBarBackgroundColors))
307
- invalid('statusBarBackgroundColors');
308
- validateStructuredOptions(value);
309
- return JSON.parse(JSON.stringify(value));
310
- }
311
- function validateStructuredOptions(value) {
312
- const shapes = {
313
- nativeBack: [[], ['event', 'controlFunction', 'handler']],
314
- geolocation: [['reverseGeocodeApi', 'version'], []],
315
- layerUrlProxy: [
316
- ['sourceHostPrefix', 'pathPrefix', 'targetHostSuffixes'],
317
- ['defaultTargetHost'],
318
- ],
319
- imagePicker: [
320
- ['schemes', 'api', 'version', 'fcId', 'fcGroup', 'uploadUrlFunction', 'prefix', 'region'],
321
- [],
322
- ],
323
- overlay: [
324
- [
325
- 'enabledParam',
326
- 'topRatioParam',
327
- 'radiusParam',
328
- 'maskAlphaParam',
329
- 'tapCloseParam',
330
- 'defaultTopRatio',
331
- 'defaultRadius',
332
- 'defaultMaskAlpha',
333
- 'defaultTapClose',
334
- ],
335
- [
336
- 'heightRatioParam',
337
- 'tapCloseSelectors',
338
- 'silentTapClose',
339
- 'maxWidthPx',
340
- 'maxWidthMinAppVersion',
341
- ],
342
- ],
343
- };
344
- for (const [key, [required, optional]] of Object.entries(shapes)) {
345
- if (value[key] === undefined)
346
- continue;
347
- fields(value[key], required, optional, key);
348
- for (const [field, item] of Object.entries(value[key])) {
349
- const valid = field === 'maxWidthPx'
350
- ? typeof item === 'number' && Number.isFinite(item) && item > 0
351
- : field === 'maxWidthMinAppVersion'
352
- ? typeof item === 'string' && /^\d+(?:\.\d+)*$/.test(item)
353
- : field.startsWith('default') && field !== 'defaultTargetHost'
354
- ? field === 'defaultTapClose'
355
- ? typeof item === 'boolean'
356
- : typeof item === 'number'
357
- : field === 'silentTapClose'
358
- ? typeof item === 'boolean'
359
- : ['schemes', 'targetHostSuffixes', 'tapCloseSelectors'].includes(field)
360
- ? strings(item)
361
- : text(item);
362
- if (!valid)
363
- invalid(`${key}.${field}`);
364
- }
365
- }
366
- if (value.rootContainer !== undefined) {
367
- fields(value.rootContainer, [], ['statusBarHeightCookie'], 'rootContainer');
368
- if (value.rootContainer.statusBarHeightCookie !== undefined) {
369
- fields(value.rootContainer.statusBarHeightCookie, ['name'], ['domain', 'path'], 'rootContainer.statusBarHeightCookie');
370
- if (!Object.values(value.rootContainer.statusBarHeightCookie).every(text))
371
- invalid('rootContainer.statusBarHeightCookie');
372
- }
373
- }
374
- if (value.titleBarHostStyles !== undefined &&
375
- (!Array.isArray(value.titleBarHostStyles) ||
376
- value.titleBarHostStyles.some(rule => {
377
- fields(rule, ['hostSuffix'], ['titleBarBackgroundColor', 'statusBarBackgroundColor'], 'titleBarHostStyle');
378
- return !Object.values(rule).every(text);
379
- })))
380
- invalid('titleBarHostStyles');
381
- if (value.miniProgram !== undefined) {
382
- fields(value.miniProgram, [], ['paymentRoutes', 'nativeRoutes', 'messageRules'], 'miniProgram');
383
- const shapes = {
384
- paymentRoutes: [
385
- ['pathname', 'paymentParamsParam', 'successUrlParams', 'failureUrlParams'],
386
- ['hostSuffixes', 'successResultParam', 'forwardParams', 'useCurrentOrigin'],
387
- ],
388
- nativeRoutes: [['pathname', 'actions'], ['hostSuffixes']],
389
- messageRules: [['type', 'action'], ['hostSuffixes']],
390
- };
391
- for (const [key, list] of Object.entries(value.miniProgram)) {
392
- if (!Array.isArray(list) || list.length > 100)
393
- invalid(`miniProgram.${key}`);
394
- for (const rule of list) {
395
- fields(rule, ...shapes[key], `miniProgram.${key}`);
396
- for (const [field, item] of Object.entries(rule)) {
397
- if ([
398
- 'hostSuffixes',
399
- 'successUrlParams',
400
- 'failureUrlParams',
401
- 'forwardParams',
402
- 'actions',
403
- ].includes(field)
404
- ? !strings(item)
405
- : field === 'useCurrentOrigin'
406
- ? typeof item !== 'boolean'
407
- : !text(item))
408
- invalid(`miniProgram.${key}.${field}`);
409
- }
410
- if (key === 'messageRules' &&
411
- !['stageBackData', 'closeAll'].includes(rule.action))
412
- invalid('miniProgram.messageRules.action');
413
- if (key === 'nativeRoutes' &&
414
- !rule.actions.every(action => ['navigateMiniProgram', 'subscribeMessage'].includes(action)))
415
- invalid('miniProgram.nativeRoutes.actions');
416
- }
417
- }
418
- }
419
- }
420
- export function validateAppProfileContribution(value) {
421
- if (value === undefined)
422
- return undefined;
423
- fields(value, ['version', 'profiles'], [], 'contribution');
424
- if (value.version !== 1 ||
425
- !Array.isArray(value.profiles) ||
426
- !value.profiles.length ||
427
- value.profiles.length > 20)
428
- invalid('contribution');
429
- const profiles = value.profiles.map(validateAppProfileDefinition);
430
- if (JSON.stringify(profiles).length > 256_000)
431
- invalid('contribution exceeds 256 KiB');
432
- if (profiles.some(profile => profile.name.includes('/')))
433
- invalid('contribution names must be local identifiers');
434
- if (new Set(profiles.map(profile => profile.name)).size !== profiles.length)
435
- invalid('duplicate profile name');
436
- return { version: 1, profiles };
437
- }
438
- /** Deterministic identity for immutable definitions; this identifier grants no host permissions. */
439
- export function appProfileRevision(definition) {
440
- const canonical = (value) => {
441
- if (Array.isArray(value))
442
- return `[${value.map(canonical).join(',')}]`;
443
- if (record(value))
444
- return `{${Object.keys(value)
445
- .sort()
446
- .map(key => `${JSON.stringify(key)}:${canonical(value[key])}`)
447
- .join(',')}}`;
448
- return JSON.stringify(value);
449
- };
450
- const source = canonical(definition);
451
- let left = 2166136261;
452
- let right = 5381;
453
- for (let i = 0; i < source.length; i++) {
454
- left = Math.imul(left ^ source.charCodeAt(i), 16777619);
455
- right = Math.imul(right, 33) ^ source.charCodeAt(i);
456
- }
457
- return `v1-${(left >>> 0).toString(16).padStart(8, '0')}${(right >>> 0).toString(16).padStart(8, '0')}`;
458
- }
@@ -1,213 +0,0 @@
1
- import type { AppProfileBinding, AppProfilePolicies, AppProfileSetting } from './app-profile-definition.js';
2
- import type { BrowserDevicePresetName } from './browser-action-protocol.js';
3
- type DeviceCutout = 'none' | 'dynamic-island' | 'notch' | 'side-camera';
4
- /** 桥调用风格,与页面适配器使用的端内调用约定一一对应。 */
5
- export type AppBridgeStyle = 'windvane' | 'fliggy' | 'alipay' | 'callback' | 'btrip' | 'invoke' | 'callHandler' | 'amap' | 'didi' | 'easybikeNative' | 'mega' | 'wechat' | 'wechatMiniProgram';
6
- export interface AppBridgeSpec {
7
- global: string;
8
- style: AppBridgeStyle;
9
- /** 页面脚本重设全局对象时仍保留桥叶子,同时接纳页面对象上的其他 API。 */
10
- persistent?: boolean;
11
- }
12
- export type AppBridgeBehavior = 'navigate' | 'closeAll' | 'closeBackData' | 'postMessage' | 'notifySubscribe' | 'notifyUnsubscribe' | 'notifyPost' | 'sharedFileRead' | 'sharedFileWrite' | 'sharedDataGet' | 'sharedDataSet' | 'legacyBroadcastCreate' | 'legacyBroadcastPost' | 'legacyBroadcastClose' | 'memoryGet' | 'memorySet' | 'memoryDelete' | 'availabilityMap' | 'userInfo' | 'authCode' | 'networkInfo' | 'geolocation' | 'permission' | 'imagePicker' | 'prefetch' | 'fptTrack' | 'mtopStream' | 'previewFile' | 'toast' | 'unsupportedNativeInput' | 'payment' | 'userTrack' | 'calendar' | 'networkQualityMonitor' | 'beaconRequest' | 'voiceRecognition';
13
- /** 桥方法名到标准化动作的映射。WindVane 风格使用 `Class.method`,其余使用 api 名。 */
14
- export interface BridgeActionMap {
15
- open: string[];
16
- close: string[];
17
- title: string[];
18
- navigationBar?: string[];
19
- statusBar?: string[];
20
- systemInfo: string[];
21
- mtop: string[];
22
- kvGet?: string[];
23
- kvSet?: string[];
24
- kvDelete?: string[];
25
- pageContext?: string[];
26
- responses?: Record<string, unknown>;
27
- behaviors?: Record<string, AppBridgeBehavior>;
28
- noop: string[];
29
- silent?: string[];
30
- }
31
- export interface AppSchemeRule {
32
- match: string;
33
- /** 规则仅在目标或当前页面 host 命中这些根域时生效。 */
34
- hostSuffixes?: string[];
35
- param?: string;
36
- /** 将参数解出的 H5 地址保留 path/query/hash,并投影到当前页面 origin。 */
37
- useCurrentOrigin?: boolean;
38
- targetPath?: string;
39
- targetHostPrefix?: string;
40
- targetParams?: Record<string, string>;
41
- }
42
- export interface AppMiniProgramPaymentRoute {
43
- /** 小程序支付中转页 pathname。 */
44
- pathname: string;
45
- /** 限制业务根域,避免同名小程序路由被其他项目接管。 */
46
- hostSuffixes?: string[];
47
- /** JSON 字符串形式的支付桥入参。 */
48
- paymentParamsParam: string;
49
- /** 按顺序读取的支付成功回跳参数,前者为空时使用后者。 */
50
- successUrlParams: string[];
51
- /** 按顺序读取的支付失败或取消回跳参数。 */
52
- failureUrlParams: string[];
53
- /** 支付成功结果写入回跳 URL 的参数名。 */
54
- successResultParam?: string;
55
- /** 从支付页路由透传到回跳 URL 的默认参数。 */
56
- forwardParams?: string[];
57
- /** 将回跳 H5 的 path/query/hash 投影到当前页面 origin。 */
58
- useCurrentOrigin?: boolean;
59
- }
60
- export type AppMiniProgramMessageAction = 'stageBackData' | 'closeAll';
61
- export interface AppMiniProgramMessageRule {
62
- /** H5 通过 wx.miniProgram.postMessage 发送的 type。 */
63
- type: string;
64
- /** 容器只提供有限的页面栈动作,业务消息名由档案映射。 */
65
- action: AppMiniProgramMessageAction;
66
- /** 限制发送消息的 H5 根域。 */
67
- hostSuffixes?: string[];
68
- }
69
- export type AppMiniProgramNativeAction = 'navigateMiniProgram' | 'subscribeMessage';
70
- export interface AppMiniProgramNativeRoute {
71
- /** 承接微信原生能力的小程序页面 pathname。 */
72
- pathname: string;
73
- /** 该页面允许模拟的固定原生动作,动作名读取 URL 的 action 参数。 */
74
- actions: AppMiniProgramNativeAction[];
75
- /** 限制业务根域,避免其他小程序的同名页面被接管。 */
76
- hostSuffixes?: string[];
77
- }
78
- /** 微信小程序容器相关规则统一收口,避免为每种业务页增加顶层配置。 */
79
- export interface AppMiniProgramConfig {
80
- paymentRoutes?: AppMiniProgramPaymentRoute[];
81
- nativeRoutes?: AppMiniProgramNativeRoute[];
82
- messageRules?: AppMiniProgramMessageRule[];
83
- }
84
- export interface AppImagePickerConfig {
85
- schemes: string[];
86
- api: string;
87
- version: string;
88
- fcId: string;
89
- fcGroup: string;
90
- uploadUrlFunction: string;
91
- prefix: string;
92
- region: string;
93
- }
94
- export interface AppOverlayConfig {
95
- /** 半弹层最大 CSS 像素宽度,仍受所在视口和 maxWidth 比例参数约束。 */
96
- maxWidthPx?: number;
97
- /** 最大宽度限制开始生效的客户端版本,未设置时适用于所有版本。 */
98
- maxWidthMinAppVersion?: string;
99
- enabledParam: string;
100
- topRatioParam: string;
101
- /** 弹层高度占屏比例参数,与 topRatioParam 二选一即可。 */
102
- heightRatioParam?: string;
103
- radiusParam: string;
104
- maskAlphaParam: string;
105
- tapCloseParam: string;
106
- /** 蒙层关闭时优先触发当前 WebView 内的关闭控件,以复用页面定义的回传逻辑。 */
107
- tapCloseSelectors?: string[];
108
- /** 蒙层点击只退出当前 WebView,不调用页面关闭控件或打开回调。 */
109
- silentTapClose?: boolean;
110
- defaultTopRatio: number;
111
- defaultRadius: number;
112
- defaultMaskAlpha: number;
113
- defaultTapClose: boolean;
114
- }
115
- export interface AppNativeBackConfig {
116
- /** 原生返回键触发的 document 事件。 */
117
- event?: string;
118
- /** 返回 true 时由页面接管返回,再分发 event。 */
119
- controlFunction?: string;
120
- /** 原生返回键直接调用的 window 函数。 */
121
- handler?: string;
122
- }
123
- export interface AppLayerUrlProxyConfig {
124
- sourceHostPrefix: string;
125
- pathPrefix: string;
126
- targetHostSuffixes: string[];
127
- defaultTargetHost?: string;
128
- }
129
- export interface AppTitleBarConfig {
130
- navigationBarHeight: number;
131
- backgroundColor: string;
132
- textColor: string;
133
- hiddenPathnames?: string[];
134
- statusBarBackgroundColors?: Record<string, string>;
135
- hostStyles?: AppTitleBarHostStyle[];
136
- }
137
- export interface AppTitleBarHostStyle {
138
- /** 同时匹配该 host 与其全部子域,配置值不含前导点。 */
139
- hostSuffix: string;
140
- titleBarBackgroundColor?: string;
141
- statusBarBackgroundColor?: string;
142
- }
143
- export interface AppSafeAreaInsets {
144
- top: number;
145
- right: number;
146
- bottom: number;
147
- left: number;
148
- }
149
- /** App 运行时使用的设备外观快照,避免通过机型字符串反推物理特征。 */
150
- export interface AppDeviceAppearance {
151
- preset: BrowserDevicePresetName;
152
- orientation: 'portrait' | 'landscape';
153
- cutout: DeviceCutout;
154
- }
155
- export interface AppRootContainerCookie {
156
- name: string;
157
- value: string;
158
- domain?: string;
159
- path?: string;
160
- }
161
- export interface AppRootContainerConfig {
162
- enabled: boolean;
163
- initialCookies?: AppRootContainerCookie[];
164
- /** 横屏设备外壳中保留根页面,并将后续业务 WebView 呈现在右半屏。 */
165
- splitScreen?: boolean;
166
- }
167
- /** 注入页内的运行时配置,可经 Server-Timing 或 CDP new-document 脚本传输。 */
168
- export interface InjectedAppProfileConfig {
169
- binding?: AppProfileBinding;
170
- policies?: AppProfilePolicies;
171
- settings?: AppProfileSetting[];
172
- profile: string;
173
- label: string;
174
- globals: Record<string, string>;
175
- bridges: AppBridgeSpec[];
176
- activeEvents: string[];
177
- maxTouchPoints: number;
178
- statusBarHeight: number;
179
- safeAreaInsets?: AppSafeAreaInsets;
180
- /** 可选,以兼容未携带设备外观快照的持久化配置。 */
181
- deviceAppearance?: AppDeviceAppearance;
182
- userAgent: string;
183
- navigatorPlatform: string;
184
- platform: string;
185
- systemVersion: string;
186
- clientType: string;
187
- language: string;
188
- actions: BridgeActionMap;
189
- schemes: AppSchemeRule[];
190
- miniProgram?: AppMiniProgramConfig;
191
- imagePicker?: AppImagePickerConfig;
192
- /** 原生定位返回地址时使用的逆地理编码服务,复用容器的 MTop 传输。 */
193
- geolocation?: {
194
- reverseGeocodeApi: string;
195
- version: string;
196
- };
197
- overlay?: AppOverlayConfig;
198
- /** URL 参数为真时以新 WebView 替换当前业务层。 */
199
- popBeforeOpenParam?: string;
200
- /** 跨 WebView 消息抵达 opener 时分发的 document 事件。 */
201
- messageEvent?: string;
202
- nativeBack?: AppNativeBackConfig;
203
- layerUrlProxy?: AppLayerUrlProxyConfig;
204
- urlSyncHostSuffixes?: string[];
205
- animationMs?: number;
206
- forceH5Mtop?: boolean;
207
- titleBar?: AppTitleBarConfig;
208
- rootContainer?: AppRootContainerConfig;
209
- simulateSystemBars?: boolean;
210
- /** 物理状态栏与底部操作区由独立设备运行时渲染;本运行时只保留客户端导航栏。 */
211
- externalDeviceChrome?: boolean;
212
- }
213
- export {};
@@ -1 +0,0 @@
1
- export {};