@mearl/browser-core 3.1.3 → 3.1.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.
@@ -86,7 +86,7 @@ export interface AppProfileDefinition {
86
86
  /** 容器的应用标识,由能力包定义 */
87
87
  appName: string;
88
88
  defaultAppVersion: string;
89
- /** UA 主体格式;未提供时使用标准浏览器 UA */
89
+ /** device-webview 模板中的浏览器平台和版本随设备预设变化。 */
90
90
  uaFamily?: string;
91
91
  uaTemplate?: {
92
92
  ios: string;
@@ -116,7 +116,8 @@ export function validateAppProfileDefinition(value) {
116
116
  if (!/^[a-z][a-z0-9-]*(?:\/[a-z][a-z0-9-]*)?$/.test(value.name))
117
117
  invalid('name');
118
118
  if (value.defaultAppId !== undefined &&
119
- (typeof value.defaultAppId !== 'string' || !/^[a-z][a-z0-9-]{0,79}$/.test(value.defaultAppId) ||
119
+ (typeof value.defaultAppId !== 'string' ||
120
+ !/^[a-z][a-z0-9-]{0,79}$/.test(value.defaultAppId) ||
120
121
  ['constructor', 'prototype'].includes(value.defaultAppId)))
121
122
  invalid('defaultAppId');
122
123
  if (value.usage !== undefined) {
@@ -124,11 +125,15 @@ export function validateAppProfileDefinition(value) {
124
125
  fields(usage, [], ['description', 'limitations', 'skills', 'documentation'], 'usage');
125
126
  if (new TextEncoder().encode(JSON.stringify(usage)).byteLength > 4096)
126
127
  invalid('usage exceeds 4 KiB');
127
- if (usage.description !== undefined && (!text(usage.description) || usage.description.length > 512))
128
+ if (usage.description !== undefined &&
129
+ (!text(usage.description) || usage.description.length > 512))
128
130
  invalid('usage.description');
129
131
  for (const key of ['limitations', 'skills']) {
130
132
  const items = usage[key];
131
- if (items !== undefined && (!Array.isArray(items) || items.length > 8 || items.some(item => !text(item) || !item || item.length > 256)))
133
+ if (items !== undefined &&
134
+ (!Array.isArray(items) ||
135
+ items.length > 8 ||
136
+ items.some(item => !text(item) || !item || item.length > 256)))
132
137
  invalid(`usage.${key}`);
133
138
  }
134
139
  if (usage.documentation !== undefined) {
@@ -136,7 +141,11 @@ export function validateAppProfileDefinition(value) {
136
141
  invalid('usage.documentation');
137
142
  for (const link of usage.documentation) {
138
143
  fields(link, ['title', 'url'], [], 'usage.documentation');
139
- if (!text(link.title) || !link.title || link.title.length > 128 || !text(link.url) || link.url.length > 1024)
144
+ if (!text(link.title) ||
145
+ !link.title ||
146
+ link.title.length > 128 ||
147
+ !text(link.url) ||
148
+ link.url.length > 1024)
140
149
  invalid('usage.documentation');
141
150
  let url;
142
151
  try {
@@ -181,7 +190,8 @@ export function validateAppProfileDefinition(value) {
181
190
  .split('.')
182
191
  .some(part => ['__proto__', 'prototype', 'constructor'].includes(part)) ||
183
192
  globals.has(bridge.global) ||
184
- (typeof bridge.style !== 'string' || !/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/.test(bridge.style)) ||
193
+ typeof bridge.style !== 'string' ||
194
+ !/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/.test(bridge.style) ||
185
195
  (bridge.persistent !== undefined && typeof bridge.persistent !== 'boolean'))
186
196
  invalid('bridge');
187
197
  globals.add(bridge.global);
@@ -189,12 +199,26 @@ export function validateAppProfileDefinition(value) {
189
199
  validateActions(value.actions);
190
200
  if (value.labels !== undefined) {
191
201
  fields(value.labels, ['en'], ['zh_CN'], 'labels');
192
- if (!text(value.labels.en) || !value.labels.en || value.labels.en.length > 120 || value.labels.zh_CN !== undefined && (!text(value.labels.zh_CN) || value.labels.zh_CN.length > 120))
202
+ if (!text(value.labels.en) ||
203
+ !value.labels.en ||
204
+ value.labels.en.length > 120 ||
205
+ (value.labels.zh_CN !== undefined &&
206
+ (!text(value.labels.zh_CN) || value.labels.zh_CN.length > 120)))
193
207
  invalid('labels');
194
208
  }
195
- if (value.actionIcon !== undefined && (typeof value.actionIcon !== 'string' || value.actionIcon.length > 32768 || !/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]*={0,2}$/.test(value.actionIcon)))
209
+ if (value.actionIcon !== undefined &&
210
+ (typeof value.actionIcon !== 'string' ||
211
+ value.actionIcon.length > 32768 ||
212
+ !/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]*={0,2}$/.test(value.actionIcon)))
196
213
  invalid('actionIcon');
197
- if (value.authorization !== undefined && (!record(value.authorization) || Object.keys(value.authorization).sort().join(',') !== 'hook,method' || typeof value.authorization.hook !== 'string' || !/^[a-z][a-zA-Z0-9_.-]{0,95}$/.test(value.authorization.hook) || typeof value.authorization.method !== 'string' || !value.authorization.method || value.authorization.method.length > 200))
214
+ if (value.authorization !== undefined &&
215
+ (!record(value.authorization) ||
216
+ Object.keys(value.authorization).sort().join(',') !== 'hook,method' ||
217
+ typeof value.authorization.hook !== 'string' ||
218
+ !/^[a-z][a-zA-Z0-9_.-]{0,95}$/.test(value.authorization.hook) ||
219
+ typeof value.authorization.method !== 'string' ||
220
+ !value.authorization.method ||
221
+ value.authorization.method.length > 200))
198
222
  invalid('authorization');
199
223
  if (value.settingsUi !== undefined && value.settingsUi !== 'runtime')
200
224
  throw new Error('Invalid App settings UI');
@@ -212,10 +236,10 @@ export function validateAppProfileDefinition(value) {
212
236
  if (value.policies !== undefined) {
213
237
  fields(value.policies, [], ['titleBar', 'navigatorLanguage', 'networkResult', 'languages', 'defaultLanguage'], 'policies');
214
238
  const p = value.policies;
215
- if (p.titleBar !== undefined &&
216
- (typeof p.titleBar !== 'string' || p.titleBar.length > 64))
239
+ if (p.titleBar !== undefined && (typeof p.titleBar !== 'string' || p.titleBar.length > 64))
217
240
  invalid('policies.titleBar');
218
- if (p.networkResult !== undefined && (typeof p.networkResult !== 'string' || p.networkResult.length > 64))
241
+ if (p.networkResult !== undefined &&
242
+ (typeof p.networkResult !== 'string' || p.networkResult.length > 64))
219
243
  invalid('policies.networkResult');
220
244
  if (p.navigatorLanguage !== undefined && typeof p.navigatorLanguage !== 'boolean')
221
245
  invalid('policies.navigatorLanguage');
@@ -308,7 +332,8 @@ export function validateAppProfileDefinition(value) {
308
332
  invalid('setting.option type');
309
333
  }
310
334
  }
311
- if (value.runtimeOptions !== undefined && (!record(value.runtimeOptions) || !json(value.runtimeOptions)))
335
+ if (value.runtimeOptions !== undefined &&
336
+ (!record(value.runtimeOptions) || !json(value.runtimeOptions)))
312
337
  invalid('runtimeOptions');
313
338
  for (const key of ['popBeforeOpenParam', 'messageEvent'])
314
339
  if (value[key] !== undefined && !text(value[key]))
@@ -224,6 +224,10 @@ export interface BrowserListResult {
224
224
  connectedCount: number;
225
225
  defaultBrowserId: string | null;
226
226
  browsers: BrowserInfo[];
227
+ /** Registered external Providers, including those without a browser instance. */
228
+ installedProviders?: Array<BrowserProviderIdentity & {
229
+ source?: BrowserSource;
230
+ }>;
227
231
  /** Partial discovery failures; successfully inspected browser sources remain in the result. */
228
232
  warnings?: string[];
229
233
  /** Present only for an explicit, source-local Provider launch-form query. */
@@ -31,6 +31,12 @@ export interface DevicePreset {
31
31
  appProfileModel: string;
32
32
  /** 与设备配套的 App 容器系统。 */
33
33
  appProfileOs: 'ios' | 'android';
34
+ /** iPad 的桌面 Safari 与 App WebView 使用不同的平台标识。 */
35
+ appProfileIosIdentity?: {
36
+ uaPlatform: string;
37
+ systemVersion: string;
38
+ navigatorPlatform: 'iPad';
39
+ };
34
40
  /** 竖屏时设备屏幕顶部的物理外观。 */
35
41
  appearance: DeviceAppearance;
36
42
  }
@@ -13,7 +13,11 @@ export function getDeviceChromeViewConfig(emulation) {
13
13
  const sideBarWidth = getDeviceSideBarWidth(emulation.presetName, emulation.orientation);
14
14
  return {
15
15
  platform,
16
- statusBarHeight: sideBarWidth ? 0 : emulation.orientation === 'landscape' ? 24 : emulation.safeAreaInsets.top,
16
+ statusBarHeight: sideBarWidth
17
+ ? 0
18
+ : emulation.orientation === 'landscape'
19
+ ? 24
20
+ : emulation.safeAreaInsets.top,
17
21
  bottomBarHeight: emulation.safeAreaInsets.bottom,
18
22
  ...(sideBarWidth ? { sideBarWidth } : {}),
19
23
  safeAreaInsets: { ...emulation.safeAreaInsets },
@@ -135,6 +139,11 @@ export const DEVICE_PRESETS = {
135
139
  landscapeSafeAreaInsets: { top: 0, right: 24, bottom: 20, left: 24 },
136
140
  appProfileModel: 'iPad mini (A17 Pro)',
137
141
  appProfileOs: 'ios',
142
+ appProfileIosIdentity: {
143
+ uaPlatform: 'iPad; CPU OS 18_6 like Mac OS X',
144
+ systemVersion: '26.0',
145
+ navigatorPlatform: 'iPad',
146
+ },
138
147
  appearance: { cutout: 'none' },
139
148
  },
140
149
  'galaxy-s26': {
@@ -234,6 +243,11 @@ export const DEVICE_PRESETS = {
234
243
  landscapeSafeAreaInsets: { top: 0, right: 24, bottom: 20, left: 24 },
235
244
  appProfileModel: 'iPad mini',
236
245
  appProfileOs: 'ios',
246
+ appProfileIosIdentity: {
247
+ uaPlatform: 'iPad; CPU OS 17_0 like Mac OS X',
248
+ systemVersion: '17.0',
249
+ navigatorPlatform: 'iPad',
250
+ },
237
251
  appearance: { cutout: 'none' },
238
252
  },
239
253
  'galaxy-s23': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mearl/browser-core",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "description": "Shared pure-logic utilities for Mearl — usable in both browser extension and Node.js environments",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",