native-fn 1.0.42 → 1.0.44
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/native.cjs +372 -11
- package/dist/native.min.cjs +1 -1
- package/dist/native.min.mjs +1 -1
- package/dist/native.mjs +372 -11
- package/dist/native.umd.js +372 -11
- package/dist/native.umd.min.js +1 -1
- package/dist/plugin/app/index.cjs +317 -151
- package/dist/plugin/app/index.d.ts +5 -1
- package/dist/plugin/app/index.min.cjs +1 -1
- package/dist/plugin/app/index.min.mjs +1 -1
- package/dist/plugin/app/index.mjs +317 -151
- package/dist/plugin/app/index.umd.js +317 -151
- package/dist/plugin/app/index.umd.min.js +1 -1
- package/dist/plugin/app/src/constants/platform.d.ts +3 -13
- package/dist/plugin/app/src/plugin/app/types/app.d.ts +4 -0
- package/dist/plugin/app/src/types/platform.d.ts +17 -0
- package/dist/plugin/app/src/utils/create-hidden-element.d.ts +1 -1
- package/dist/plugin/camera/index.cjs +253 -86
- package/dist/plugin/camera/index.min.cjs +1 -1
- package/dist/plugin/camera/index.min.mjs +1 -1
- package/dist/plugin/camera/index.mjs +253 -86
- package/dist/plugin/camera/index.umd.js +253 -86
- package/dist/plugin/camera/index.umd.min.js +1 -1
- package/dist/plugin/camera/src/constants/platform.d.ts +3 -13
- package/dist/plugin/camera/src/plugin/app/types/app.d.ts +4 -0
- package/dist/plugin/camera/src/types/platform.d.ts +17 -0
- package/dist/plugin/camera/src/utils/create-hidden-element.d.ts +1 -1
- package/dist/plugin/clipboard/index.cjs +6 -0
- package/dist/plugin/clipboard/index.min.cjs +1 -1
- package/dist/plugin/clipboard/index.min.mjs +1 -1
- package/dist/plugin/clipboard/index.mjs +6 -0
- package/dist/plugin/clipboard/index.umd.js +6 -0
- package/dist/plugin/clipboard/index.umd.min.js +1 -1
- package/dist/plugin/clipboard/src/constants/platform.d.ts +3 -13
- package/dist/plugin/clipboard/src/plugin/app/types/app.d.ts +4 -0
- package/dist/plugin/clipboard/src/types/platform.d.ts +17 -0
- package/dist/plugin/clipboard/src/utils/create-hidden-element.d.ts +1 -1
- package/dist/plugin/fullscreen/index.cjs +246 -82
- package/dist/plugin/fullscreen/index.min.cjs +1 -1
- package/dist/plugin/fullscreen/index.min.mjs +1 -1
- package/dist/plugin/fullscreen/index.mjs +246 -82
- package/dist/plugin/fullscreen/index.umd.js +246 -82
- package/dist/plugin/fullscreen/index.umd.min.js +1 -1
- package/dist/plugin/fullscreen/src/constants/platform.d.ts +3 -13
- package/dist/plugin/fullscreen/src/plugin/app/types/app.d.ts +4 -0
- package/dist/plugin/fullscreen/src/types/platform.d.ts +17 -0
- package/dist/plugin/fullscreen/src/utils/create-hidden-element.d.ts +1 -1
- package/dist/plugin/theme/index.cjs +257 -91
- package/dist/plugin/theme/index.min.cjs +1 -1
- package/dist/plugin/theme/index.min.mjs +1 -1
- package/dist/plugin/theme/index.mjs +257 -91
- package/dist/plugin/theme/index.umd.js +257 -91
- package/dist/plugin/theme/index.umd.min.js +1 -1
- package/dist/plugin/theme/src/constants/platform.d.ts +3 -13
- package/dist/plugin/theme/src/plugin/app/types/app.d.ts +4 -0
- package/dist/plugin/theme/src/types/platform.d.ts +17 -0
- package/dist/plugin/theme/src/utils/create-hidden-element.d.ts +1 -1
- package/dist/src/constants/platform.d.ts +3 -13
- package/dist/src/plugin/app/types/app.d.ts +4 -0
- package/dist/src/types/platform.d.ts +17 -0
- package/dist/src/utils/create-hidden-element.d.ts +1 -1
- package/package.json +1 -8
|
@@ -15,7 +15,28 @@ var MessengerType;
|
|
|
15
15
|
MessengerType["Mail"] = "mail";
|
|
16
16
|
})(MessengerType || (MessengerType = {}));
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
function dynamicImport(moduleName) {
|
|
19
|
+
if ('require' in globalThis && typeof globalThis.require === 'function') {
|
|
20
|
+
try {
|
|
21
|
+
return Promise.resolve(globalThis.require(moduleName));
|
|
22
|
+
}
|
|
23
|
+
catch (_) {
|
|
24
|
+
return Promise.resolve(null);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
return import(moduleName)
|
|
29
|
+
.then(function (module) {
|
|
30
|
+
return (module.default || module);
|
|
31
|
+
})
|
|
32
|
+
.catch(function () {
|
|
33
|
+
return Promise.resolve(null);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (_) {
|
|
37
|
+
return Promise.resolve(null);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
19
40
|
|
|
20
41
|
var OS;
|
|
21
42
|
(function (OS) {
|
|
@@ -56,42 +77,22 @@ var Browsers;
|
|
|
56
77
|
Browsers["IE"] = "IE";
|
|
57
78
|
Browsers["SamsungInternet"] = "SamsungInternet";
|
|
58
79
|
})(Browsers || (Browsers = {}));
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
'ARM': 'RT'
|
|
76
|
-
}[string];
|
|
77
|
-
if (mapped !== undefined)
|
|
78
|
-
return mapped;
|
|
79
|
-
return string;
|
|
80
|
-
}
|
|
81
|
-
function resolveUnderscoreVersion(string) {
|
|
82
|
-
if (string === undefined)
|
|
83
|
-
return '';
|
|
84
|
-
return string.replace(/_/g, '.');
|
|
85
|
-
}
|
|
86
|
-
function resolveVersion(string, resolver) {
|
|
87
|
-
if (typeof resolver === 'function')
|
|
88
|
-
return resolver(string);
|
|
89
|
-
if (typeof resolver === 'string')
|
|
90
|
-
return resolver;
|
|
91
|
-
if (string === undefined)
|
|
92
|
-
return '';
|
|
93
|
-
return string;
|
|
94
|
-
}
|
|
80
|
+
var Platform = {
|
|
81
|
+
device: Devices.Unknown,
|
|
82
|
+
os: OS.Unknown,
|
|
83
|
+
osVersion: '',
|
|
84
|
+
engine: Engines.Unknown,
|
|
85
|
+
engineVersion: '',
|
|
86
|
+
browser: Browsers.Unknown,
|
|
87
|
+
browserVersion: '',
|
|
88
|
+
renderer: getRenderer(),
|
|
89
|
+
userAgent: navigator.userAgent,
|
|
90
|
+
isWebview: false,
|
|
91
|
+
isMobile: false,
|
|
92
|
+
isDesktop: false,
|
|
93
|
+
isStandalone: false,
|
|
94
|
+
isNodeJS: getIsNode(),
|
|
95
|
+
};
|
|
95
96
|
var OS_RESOLVER_MAP = [
|
|
96
97
|
[/windows nt (6\.[23]); arm/i, OS.Windows, resolveWindowsVersion],
|
|
97
98
|
[/windows (?:phone|mobile|iot)(?: os)?[\/ ]?([\d.]*( se)?)/i, OS.Windows, resolveWindowsVersion],
|
|
@@ -150,36 +151,115 @@ var BROWSER_RESOLVER_MAP = [
|
|
|
150
151
|
[/mobile vr; rv:([\w.]+)\).+firefox/i, Browsers.Firefox],
|
|
151
152
|
[/firefox\/([\w.]+)/i, Browsers.Firefox],
|
|
152
153
|
];
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
function resolveWindowsVersion(string) {
|
|
155
|
+
if (string === undefined)
|
|
156
|
+
return '';
|
|
157
|
+
var mapped = {
|
|
158
|
+
'4.90': 'ME',
|
|
159
|
+
'NT3.51': 'NT 3.11',
|
|
160
|
+
'NT4.0': 'NT 4.0',
|
|
161
|
+
'NT 5.0': '2000',
|
|
162
|
+
'NT 5.1': 'XP',
|
|
163
|
+
'NT 5.2': 'XP',
|
|
164
|
+
'NT 6.0': 'Vista',
|
|
165
|
+
'NT 6.1': '7',
|
|
166
|
+
'NT 6.2': '8',
|
|
167
|
+
'NT 6.3': '8.1',
|
|
168
|
+
'NT 6.4': '10',
|
|
169
|
+
'NT 10.0': '10',
|
|
170
|
+
'ARM': 'RT'
|
|
171
|
+
}[string];
|
|
172
|
+
if (mapped !== undefined)
|
|
173
|
+
return mapped;
|
|
174
|
+
return string;
|
|
175
|
+
}
|
|
176
|
+
function resolveUnderscoreVersion(string) {
|
|
177
|
+
if (string === undefined)
|
|
178
|
+
return '';
|
|
179
|
+
return string.replace(/_/g, '.');
|
|
180
|
+
}
|
|
181
|
+
function resolveVersion(string, resolver) {
|
|
182
|
+
if (typeof resolver === 'function')
|
|
183
|
+
return resolver(string);
|
|
184
|
+
if (typeof resolver === 'string')
|
|
185
|
+
return resolver;
|
|
186
|
+
if (string === undefined)
|
|
187
|
+
return '';
|
|
188
|
+
return string;
|
|
189
|
+
}
|
|
190
|
+
function normalizeBrand(entry) {
|
|
191
|
+
if (entry === null || entry === undefined)
|
|
192
|
+
return { brand: '', version: '' };
|
|
193
|
+
if (typeof entry === 'string')
|
|
194
|
+
return { brand: entry, version: '' };
|
|
195
|
+
return { brand: entry.brand, version: entry.version };
|
|
196
|
+
}
|
|
197
|
+
function getRenderer() {
|
|
198
|
+
if (typeof globalThis.document === 'undefined')
|
|
199
|
+
return '';
|
|
200
|
+
var canvas = globalThis.document.createElement('canvas');
|
|
201
|
+
if (typeof canvas.getContext !== 'function')
|
|
202
|
+
return '';
|
|
203
|
+
var context = canvas.getContext('webgl2') || canvas.getContext('experimental-webgl') || canvas.getContext('webgl');
|
|
204
|
+
if (context === null)
|
|
205
|
+
return '';
|
|
206
|
+
if (context instanceof WebGLRenderingContext || 'getParameter' in context && typeof context.getParameter === 'function') {
|
|
207
|
+
var extension = context.getExtension('WEBGL_debug_renderer_info');
|
|
208
|
+
if (extension === null)
|
|
209
|
+
return context.getParameter(context.RENDERER);
|
|
210
|
+
else
|
|
211
|
+
return context.getParameter(extension.UNMASKED_RENDERER_WEBGL);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
return '';
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function getIsStandalone(os) {
|
|
218
|
+
if (!('matchMedia' in globalThis))
|
|
219
|
+
return false;
|
|
220
|
+
if (os === OS.iOS)
|
|
221
|
+
return 'standalone' in navigator && !!navigator.standalone;
|
|
222
|
+
return globalThis.matchMedia('(display-mode: standalone)').matches;
|
|
223
|
+
}
|
|
224
|
+
function getIsWebview() {
|
|
225
|
+
return /; ?wv|applewebkit(?!.*safari)/i.test(Platform.userAgent);
|
|
226
|
+
}
|
|
227
|
+
function getIsNode() {
|
|
228
|
+
return typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined;
|
|
229
|
+
}
|
|
230
|
+
function getNodeOSVersion(string) {
|
|
231
|
+
var parts = string.split('.');
|
|
232
|
+
return {
|
|
233
|
+
major: parseInt(parts[0] || '0'),
|
|
234
|
+
minor: parseInt(parts[1] || '0'),
|
|
235
|
+
build: parseInt(parts[2] || '0')
|
|
236
|
+
};
|
|
237
|
+
}
|
|
159
238
|
for (var i = 0; i < OS_RESOLVER_MAP.length; i++) {
|
|
160
239
|
var map = OS_RESOLVER_MAP[i];
|
|
161
240
|
var regexp = map[0];
|
|
162
241
|
var os = map[1];
|
|
163
242
|
var resolver = map[2];
|
|
164
|
-
var matched =
|
|
243
|
+
var matched = Platform.userAgent.match(regexp);
|
|
165
244
|
if (matched !== null) {
|
|
166
|
-
|
|
167
|
-
|
|
245
|
+
Platform.os = os;
|
|
246
|
+
Platform.osVersion = resolveVersion(matched[1], resolver);
|
|
168
247
|
if (os === OS.iOS || os === OS.Android)
|
|
169
|
-
|
|
248
|
+
Platform.device = Devices.Mobile;
|
|
170
249
|
else if (os === OS.Windows || os === OS.MacOS)
|
|
171
|
-
|
|
250
|
+
Platform.device = Devices.Desktop;
|
|
172
251
|
break;
|
|
173
252
|
}
|
|
174
253
|
}
|
|
175
254
|
for (var i = 0; i < ENGINE_RESOLVER_MAP.length; i++) {
|
|
176
255
|
var map = ENGINE_RESOLVER_MAP[i];
|
|
177
256
|
var regexp = map[0];
|
|
178
|
-
map[1];
|
|
257
|
+
var engine = map[1];
|
|
179
258
|
var resolver = map[2];
|
|
180
|
-
var matched =
|
|
259
|
+
var matched = Platform.userAgent.match(regexp);
|
|
181
260
|
if (matched !== null) {
|
|
182
|
-
|
|
261
|
+
Platform.engine = engine;
|
|
262
|
+
Platform.engineVersion = resolveVersion(matched[1], resolver);
|
|
183
263
|
break;
|
|
184
264
|
}
|
|
185
265
|
}
|
|
@@ -188,42 +268,123 @@ for (var i = 0; i < BROWSER_RESOLVER_MAP.length; i++) {
|
|
|
188
268
|
var regexp = map[0];
|
|
189
269
|
var browser = map[1];
|
|
190
270
|
var resolver = map[2];
|
|
191
|
-
var matched =
|
|
271
|
+
var matched = Platform.userAgent.match(regexp);
|
|
192
272
|
if (matched !== null) {
|
|
193
|
-
|
|
194
|
-
|
|
273
|
+
Platform.browser = browser;
|
|
274
|
+
Platform.browserVersion = resolveVersion(matched[1], resolver);
|
|
195
275
|
break;
|
|
196
276
|
}
|
|
197
277
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
278
|
+
if (Platform.isNodeJS) {
|
|
279
|
+
dynamicImport('os')
|
|
280
|
+
.then(function (os) {
|
|
281
|
+
if (os === null)
|
|
282
|
+
return;
|
|
283
|
+
var platform = os.platform();
|
|
284
|
+
var release = os.release();
|
|
285
|
+
var version = getNodeOSVersion(release);
|
|
286
|
+
switch (platform) {
|
|
287
|
+
case 'win32':
|
|
288
|
+
Platform.os = OS.Windows;
|
|
289
|
+
if (version.major === 10 && version.minor === 0 && version.build >= 22000)
|
|
290
|
+
Platform.osVersion = '11';
|
|
291
|
+
else if (version.major === 10 && version.minor === 0 && version.build < 22000)
|
|
292
|
+
Platform.osVersion = '10';
|
|
293
|
+
else if (version.major === 6 && version.minor === 3)
|
|
294
|
+
Platform.osVersion = '8.1';
|
|
295
|
+
else if (version.major === 6 && version.minor === 2)
|
|
296
|
+
Platform.osVersion = '8';
|
|
297
|
+
else if (version.major === 6 && version.minor === 1)
|
|
298
|
+
Platform.osVersion = '7';
|
|
299
|
+
else if (version.major === 6 && version.minor === 0)
|
|
300
|
+
Platform.osVersion = 'Vista';
|
|
301
|
+
else if (version.major === 5 && version.minor === 1)
|
|
302
|
+
Platform.osVersion = 'XP';
|
|
303
|
+
else if (version.major === 5 && version.minor === 2)
|
|
304
|
+
Platform.osVersion = 'XP';
|
|
305
|
+
else if (version.major === 5 && version.minor === 0)
|
|
306
|
+
Platform.osVersion = '2000';
|
|
307
|
+
else if (version.major === 4 && version.minor === 90)
|
|
308
|
+
Platform.osVersion = 'ME';
|
|
309
|
+
else if (version.major === 4 && version.minor === 0)
|
|
310
|
+
Platform.osVersion = 'NT 4.0';
|
|
311
|
+
else if (version.major === 3 && version.minor === 51)
|
|
312
|
+
Platform.osVersion = 'NT 3.11';
|
|
313
|
+
else
|
|
314
|
+
Platform.osVersion = release;
|
|
315
|
+
break;
|
|
316
|
+
case 'darwin':
|
|
317
|
+
Platform.os = OS.MacOS;
|
|
318
|
+
if (version.major >= 24)
|
|
319
|
+
Platform.osVersion = '' + (version.major - 9) + '.' + version.minor + '.' + version.build;
|
|
320
|
+
else if (version.major === 23)
|
|
321
|
+
Platform.osVersion = '14.' + version.minor + '.' + version.build;
|
|
322
|
+
else if (version.major === 22)
|
|
323
|
+
Platform.osVersion = '13.' + version.minor + '.' + version.build;
|
|
324
|
+
else if (version.major === 21)
|
|
325
|
+
Platform.osVersion = '12.' + version.minor + '.' + version.build;
|
|
326
|
+
else if (version.major === 20)
|
|
327
|
+
Platform.osVersion = '11.' + version.minor + '.' + version.build;
|
|
328
|
+
else if (version.major === 19)
|
|
329
|
+
Platform.osVersion = '10.15.' + version.minor;
|
|
330
|
+
else if (version.major === 18)
|
|
331
|
+
Platform.osVersion = '10.14.' + version.minor;
|
|
332
|
+
else if (version.major === 17)
|
|
333
|
+
Platform.osVersion = '10.13.' + version.minor;
|
|
334
|
+
else if (version.major === 16)
|
|
335
|
+
Platform.osVersion = '10.12.' + version.minor;
|
|
336
|
+
else if (version.major === 15)
|
|
337
|
+
Platform.osVersion = '10.11.' + version.minor;
|
|
338
|
+
else if (version.major === 14)
|
|
339
|
+
Platform.osVersion = '10.10.' + version.minor;
|
|
340
|
+
else if (version.major === 13)
|
|
341
|
+
Platform.osVersion = '10.9.' + version.minor;
|
|
342
|
+
else if (version.major >= 5 && version.major <= 12)
|
|
343
|
+
Platform.osVersion = '10.' + (version.major - 4) + '.' + version.minor;
|
|
344
|
+
else
|
|
345
|
+
Platform.osVersion = release;
|
|
346
|
+
break;
|
|
347
|
+
case 'android':
|
|
348
|
+
Platform.os = OS.Android;
|
|
349
|
+
Platform.osVersion = release;
|
|
350
|
+
break;
|
|
351
|
+
case 'linux':
|
|
352
|
+
if (/android/i.test(release)) {
|
|
353
|
+
Platform.os = OS.Android;
|
|
354
|
+
Platform.osVersion = release;
|
|
355
|
+
}
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
if (navigator.userAgentData !== undefined && navigator.userAgentData.getHighEntropyValues !== undefined) {
|
|
361
|
+
navigator
|
|
362
|
+
.userAgentData
|
|
363
|
+
.getHighEntropyValues(['brands', 'fullVersionList', 'mobile', 'model', 'platform', 'platformVersion', 'architecture', 'formFactors', 'bitness', 'uaFullVersion', 'wow64'])
|
|
364
|
+
.then(function (result) {
|
|
365
|
+
var brands = result.fullVersionList || result.brands || [];
|
|
366
|
+
var platformVersion = result.platformVersion;
|
|
367
|
+
for (var i = 0; i < brands.length; i++) {
|
|
368
|
+
var brand = normalizeBrand(brands[i]);
|
|
369
|
+
var brandName = brand.brand;
|
|
370
|
+
var brandVersion = brand.version;
|
|
371
|
+
if (/not.a.brand/i.test(brandName))
|
|
372
|
+
continue;
|
|
373
|
+
if (brandName === "Chromium")
|
|
374
|
+
Platform.engineVersion = brandVersion;
|
|
375
|
+
}
|
|
376
|
+
if (typeof platformVersion === 'string') {
|
|
377
|
+
if (Platform.os === OS.Windows && parseInt(platformVersion.replace(/[^\d.]/g, '').split('.')[0], 10) >= 13)
|
|
378
|
+
Platform.osVersion = '11';
|
|
379
|
+
else
|
|
380
|
+
Platform.osVersion = platformVersion;
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
Platform.isMobile = Platform.device === Devices.Mobile;
|
|
385
|
+
Platform.isDesktop = Platform.device === Devices.Desktop;
|
|
386
|
+
Platform.isWebview = getIsWebview();
|
|
387
|
+
Platform.isStandalone = getIsStandalone(Platform.os);
|
|
227
388
|
|
|
228
389
|
function capitalize(match) {
|
|
229
390
|
var groups = [];
|
|
@@ -398,6 +559,8 @@ function dispatchClickEvent(element, view) {
|
|
|
398
559
|
|
|
399
560
|
function createHiddenElement(tagName, focusable) {
|
|
400
561
|
if (focusable === void 0) { focusable = true; }
|
|
562
|
+
if (typeof globalThis.document === 'undefined')
|
|
563
|
+
return undefined;
|
|
401
564
|
var element = globalThis.document.createElement(tagName);
|
|
402
565
|
if ('width' in element)
|
|
403
566
|
element.width = '0';
|
|
@@ -481,6 +644,8 @@ function openURLViaHref(url, index) {
|
|
|
481
644
|
return;
|
|
482
645
|
}
|
|
483
646
|
a = createHiddenElement('a');
|
|
647
|
+
if (a === undefined)
|
|
648
|
+
return;
|
|
484
649
|
a.href = url;
|
|
485
650
|
document.body.appendChild(a);
|
|
486
651
|
dispatchClickEvent(a, top);
|
|
@@ -502,6 +667,8 @@ function openURLViaIframe(url) {
|
|
|
502
667
|
var iframe = undefined;
|
|
503
668
|
try {
|
|
504
669
|
iframe = createHiddenElement('iframe');
|
|
670
|
+
if (iframe === undefined)
|
|
671
|
+
return;
|
|
505
672
|
iframe.src = url;
|
|
506
673
|
top.document.body.appendChild(iframe);
|
|
507
674
|
globalThis.setTimeout(function () {
|
|
@@ -571,6 +738,8 @@ function restoreFocus() {
|
|
|
571
738
|
var input = undefined;
|
|
572
739
|
try {
|
|
573
740
|
input = createHiddenElement('input');
|
|
741
|
+
if (input === undefined)
|
|
742
|
+
return false;
|
|
574
743
|
input.type = 'text';
|
|
575
744
|
input.readOnly = true;
|
|
576
745
|
document.body.appendChild(input);
|
|
@@ -606,8 +775,8 @@ function tryOpenUrl(url, index, timeout) {
|
|
|
606
775
|
var document = top.document;
|
|
607
776
|
var eventType = { focus: undefined, blur: undefined, visibilitychange: undefined };
|
|
608
777
|
var eventTarget = { focus: undefined, blur: undefined, visibilitychange: undefined };
|
|
609
|
-
if (
|
|
610
|
-
if (compareVersion(
|
|
778
|
+
if (Platform.os === OS.iOS) {
|
|
779
|
+
if (compareVersion(Platform.osVersion, '8.0') >= 0) {
|
|
611
780
|
eventTarget = { visibilitychange: document };
|
|
612
781
|
eventType = { visibilitychange: 'visibilitychange' };
|
|
613
782
|
}
|
|
@@ -860,7 +1029,7 @@ function createAppStoreURL(packageName, os) {
|
|
|
860
1029
|
case OS.MacOS:
|
|
861
1030
|
return 'macappstore://itunes.apple.com/app/id' + packageName + '?mt=12';
|
|
862
1031
|
default:
|
|
863
|
-
throw new URLOpenError('Unsupported OS: \"' +
|
|
1032
|
+
throw new URLOpenError('Unsupported OS: \"' + Platform.userAgent + '\"');
|
|
864
1033
|
}
|
|
865
1034
|
}
|
|
866
1035
|
function createWebStoreURL(packageName, os) {
|
|
@@ -876,7 +1045,7 @@ function createWebStoreURL(packageName, os) {
|
|
|
876
1045
|
case OS.MacOS:
|
|
877
1046
|
return 'https://apps.apple.com/app/id' + packageName + '?mt=12';
|
|
878
1047
|
default:
|
|
879
|
-
throw new URLOpenError('Unsupported OS: \"' +
|
|
1048
|
+
throw new URLOpenError('Unsupported OS: \"' + Platform.userAgent + '\"');
|
|
880
1049
|
}
|
|
881
1050
|
}
|
|
882
1051
|
function getDefaultTimeoutByOS(os) {
|
|
@@ -890,26 +1059,26 @@ function getDefaultTimeoutByOS(os) {
|
|
|
890
1059
|
}
|
|
891
1060
|
}
|
|
892
1061
|
function canOpenIntentURL() {
|
|
893
|
-
if (
|
|
1062
|
+
if (Platform.os !== OS.Android)
|
|
894
1063
|
return false;
|
|
895
|
-
if (
|
|
1064
|
+
if (Platform.browser === Browsers.SamsungInternet && compareVersion(Platform.browserVersion, '17.0.1.69') >= 0 && compareVersion(Platform.browserVersion, '17.0.7.34') < 0)
|
|
896
1065
|
return false;
|
|
897
|
-
if (
|
|
1066
|
+
if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '41.0') < 0)
|
|
898
1067
|
return false;
|
|
899
|
-
if (
|
|
1068
|
+
if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '58.0') >= 0 && compareVersion(Platform.browserVersion, '68.11.0') < 0)
|
|
900
1069
|
return false;
|
|
901
|
-
if (
|
|
1070
|
+
if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '79.0') >= 0 && compareVersion(Platform.browserVersion, '81.2.0') < 0)
|
|
902
1071
|
return false;
|
|
903
|
-
if (
|
|
1072
|
+
if (Platform.browser === Browsers.Firefox && compareVersion(Platform.browserVersion, '96.0') >= 0 && compareVersion(Platform.browserVersion, '107.0') < 0)
|
|
904
1073
|
return false;
|
|
905
|
-
if (
|
|
1074
|
+
if (Platform.browser === Browsers.Opera && compareVersion(Platform.browserVersion, '14.0') < 0)
|
|
906
1075
|
return false;
|
|
907
|
-
if (/(?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/[\w.]+;/i.test(
|
|
1076
|
+
if (/(?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/[\w.]+;/i.test(Platform.userAgent) || /instagram[\/ ][-\w.]+/i.test(Platform.userAgent) || /micromessenger\/([\w.]+)/i.test(Platform.userAgent) || /musical_ly(?:.+app_?version\/|_)[\w.]+/i.test(Platform.userAgent) || /ultralite app_version\/[\w.]+/i.test(Platform.userAgent))
|
|
908
1077
|
return false;
|
|
909
1078
|
return true;
|
|
910
1079
|
}
|
|
911
1080
|
function canOpenUniversalURL() {
|
|
912
|
-
return
|
|
1081
|
+
return Platform.os === OS.iOS && compareVersion(Platform.osVersion, '9.0') >= 0;
|
|
913
1082
|
}
|
|
914
1083
|
function getURLOpenError(tried) {
|
|
915
1084
|
var triedUrlString = '';
|
|
@@ -920,87 +1089,84 @@ function getURLOpenError(tried) {
|
|
|
920
1089
|
return new URLOpenError('Failed to open any of the provided URLs: ' + triedUrlString);
|
|
921
1090
|
}
|
|
922
1091
|
function open(options) {
|
|
923
|
-
var os =
|
|
1092
|
+
var os = Platform.os;
|
|
924
1093
|
var urls = [];
|
|
925
1094
|
var tried = [];
|
|
1095
|
+
var infos = {};
|
|
926
1096
|
var timeout;
|
|
927
1097
|
if (os === OS.Android) {
|
|
928
1098
|
var option = options[OS.Android];
|
|
929
1099
|
if (option === undefined)
|
|
930
1100
|
return Promise.reject(getURLOpenError(tried));
|
|
931
1101
|
timeout = option.timeout;
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
if (parsed.
|
|
942
|
-
|
|
943
|
-
if (parsed.
|
|
944
|
-
|
|
1102
|
+
infos.scheme = urlToString(option.scheme);
|
|
1103
|
+
infos.intent = urlToString(option.intent);
|
|
1104
|
+
infos.packageName = option.packageName;
|
|
1105
|
+
infos.fallback = urlToString(option.fallback);
|
|
1106
|
+
infos.appStore = createAppStoreURL(infos.packageName, OS.Android);
|
|
1107
|
+
infos.webStore = createWebStoreURL(infos.packageName, OS.Android);
|
|
1108
|
+
infos.allowWebStore = option.allowWebStore;
|
|
1109
|
+
if (infos.intent !== undefined && (infos.scheme === undefined || infos.packageName === undefined || infos.fallback === undefined)) {
|
|
1110
|
+
var parsed = parseIntentURL(infos.intent);
|
|
1111
|
+
if (parsed.scheme !== undefined && infos.scheme === undefined)
|
|
1112
|
+
infos.scheme = parsed.scheme;
|
|
1113
|
+
if (parsed.packageName !== undefined && infos.packageName === undefined)
|
|
1114
|
+
infos.packageName = parsed.packageName;
|
|
1115
|
+
if (parsed.fallback !== undefined && infos.fallback === undefined)
|
|
1116
|
+
infos.fallback = parsed.fallback;
|
|
945
1117
|
}
|
|
946
|
-
if (scheme !== undefined && intent === undefined)
|
|
947
|
-
intent = createIntentURL(scheme, packageName, fallback);
|
|
948
|
-
pushUrl(urls, intent, AppOpenState.Intent, canOpenIntentURL());
|
|
949
|
-
pushUrl(urls, scheme, AppOpenState.Scheme);
|
|
950
|
-
pushUrl(urls, fallback, AppOpenState.Fallback);
|
|
951
|
-
pushUrl(urls, createAppStoreURL(packageName, OS.Android), AppOpenState.Store);
|
|
952
|
-
pushUrl(urls, createWebStoreURL(packageName, OS.Android), AppOpenState.Store, allowWebStore);
|
|
1118
|
+
if (infos.scheme !== undefined && infos.intent === undefined)
|
|
1119
|
+
infos.intent = createIntentURL(infos.scheme, infos.packageName, infos.fallback);
|
|
953
1120
|
}
|
|
954
1121
|
else if (os === OS.iOS) {
|
|
955
1122
|
var option = options[OS.iOS];
|
|
956
1123
|
if (option === undefined)
|
|
957
1124
|
return Promise.reject(getURLOpenError(tried));
|
|
958
1125
|
timeout = option.timeout;
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
pushUrl(urls, fallback, AppOpenState.Fallback);
|
|
970
|
-
pushUrl(urls, createAppStoreURL(trackId, OS.iOS), AppOpenState.Store);
|
|
971
|
-
pushUrl(urls, createWebStoreURL(trackId, OS.iOS), AppOpenState.Store, allowWebStore);
|
|
1126
|
+
infos.scheme = urlToString(option.scheme);
|
|
1127
|
+
infos.bundleId = option.bundleId;
|
|
1128
|
+
infos.trackId = option.trackId;
|
|
1129
|
+
infos.universal = urlToString(option.universal);
|
|
1130
|
+
infos.fallback = urlToString(option.fallback);
|
|
1131
|
+
infos.appStore = createAppStoreURL(infos.trackId, OS.iOS);
|
|
1132
|
+
infos.webStore = createWebStoreURL(infos.trackId, OS.iOS);
|
|
1133
|
+
infos.allowWebStore = option.allowWebStore;
|
|
1134
|
+
if (infos.bundleId !== undefined && infos.trackId === undefined)
|
|
1135
|
+
infos.trackId = getTrackId(infos.bundleId);
|
|
972
1136
|
}
|
|
973
1137
|
else if (os === OS.Windows) {
|
|
974
1138
|
var option = options[OS.Windows];
|
|
975
1139
|
if (option === undefined)
|
|
976
1140
|
return Promise.reject(getURLOpenError(tried));
|
|
977
1141
|
timeout = option.timeout;
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
pushUrl(urls, createAppStoreURL(productId, OS.Windows), AppOpenState.Store);
|
|
985
|
-
pushUrl(urls, createWebStoreURL(productId, OS.Windows), AppOpenState.Store, allowWebStore);
|
|
1142
|
+
infos.scheme = urlToString(option.scheme);
|
|
1143
|
+
infos.productId = option.productId;
|
|
1144
|
+
infos.fallback = urlToString(option.fallback);
|
|
1145
|
+
infos.appStore = createAppStoreURL(infos.productId, OS.Windows);
|
|
1146
|
+
infos.webStore = createWebStoreURL(infos.productId, OS.Windows);
|
|
1147
|
+
infos.allowWebStore = option.allowWebStore;
|
|
986
1148
|
}
|
|
987
1149
|
else if (os === OS.MacOS) {
|
|
988
1150
|
var option = options[OS.MacOS];
|
|
989
1151
|
if (option === undefined)
|
|
990
1152
|
return Promise.reject(getURLOpenError(tried));
|
|
991
1153
|
timeout = option.timeout;
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
pushUrl(urls, createAppStoreURL(trackId, OS.MacOS), AppOpenState.Store);
|
|
1002
|
-
pushUrl(urls, createWebStoreURL(trackId, OS.MacOS), AppOpenState.Store, allowWebStore);
|
|
1154
|
+
infos.scheme = urlToString(option.scheme);
|
|
1155
|
+
infos.bundleId = option.bundleId;
|
|
1156
|
+
infos.trackId = option.trackId;
|
|
1157
|
+
infos.fallback = urlToString(option.fallback);
|
|
1158
|
+
infos.appStore = createAppStoreURL(infos.trackId, OS.MacOS);
|
|
1159
|
+
infos.webStore = createWebStoreURL(infos.trackId, OS.MacOS);
|
|
1160
|
+
infos.allowWebStore = option.allowWebStore;
|
|
1161
|
+
if (infos.bundleId !== undefined && infos.trackId === undefined)
|
|
1162
|
+
infos.trackId = getTrackId(infos.bundleId);
|
|
1003
1163
|
}
|
|
1164
|
+
pushUrl(urls, infos.intent, AppOpenState.Intent, canOpenIntentURL());
|
|
1165
|
+
pushUrl(urls, infos.universal, AppOpenState.Universal, canOpenUniversalURL());
|
|
1166
|
+
pushUrl(urls, infos.scheme, AppOpenState.Scheme);
|
|
1167
|
+
pushUrl(urls, infos.fallback, AppOpenState.Fallback);
|
|
1168
|
+
pushUrl(urls, infos.appStore, AppOpenState.Store);
|
|
1169
|
+
pushUrl(urls, infos.webStore, AppOpenState.Store, infos.allowWebStore);
|
|
1004
1170
|
if (timeout === undefined)
|
|
1005
1171
|
timeout = getDefaultTimeoutByOS(os);
|
|
1006
1172
|
return new Promise(function (resolve, reject) {
|
|
@@ -1032,7 +1198,7 @@ function open(options) {
|
|
|
1032
1198
|
}
|
|
1033
1199
|
function pushUrl(urls, url, state, condition) {
|
|
1034
1200
|
if (condition === void 0) { condition = true; }
|
|
1035
|
-
if (url
|
|
1201
|
+
if ((typeof url === 'function' || typeof url === 'string') && condition)
|
|
1036
1202
|
urls.push([state, url]);
|
|
1037
1203
|
}
|
|
1038
1204
|
function isArrayLike(value) {
|
|
@@ -1160,7 +1326,7 @@ function openMessenger(options, type) {
|
|
|
1160
1326
|
+ '?cc=' + options.cc
|
|
1161
1327
|
+ '&bcc=' + options.bcc
|
|
1162
1328
|
+ '&subject=' + options.subject
|
|
1163
|
-
+ '&body=' + options.body, 0, getDefaultTimeoutByOS(
|
|
1329
|
+
+ '&body=' + options.body, 0, getDefaultTimeoutByOS(Platform.os));
|
|
1164
1330
|
}
|
|
1165
1331
|
function openMessengerTelephone(options) {
|
|
1166
1332
|
return openMessenger(options, 'tel');
|
|
@@ -65,6 +65,10 @@ declare interface MacOSAppInfo extends AppInfo {
|
|
|
65
65
|
bundleId?: string;
|
|
66
66
|
trackId?: string;
|
|
67
67
|
}
|
|
68
|
+
declare interface StoreInfo {
|
|
69
|
+
appStore?: string;
|
|
70
|
+
webStore?: string;
|
|
71
|
+
}
|
|
68
72
|
declare interface AppOpenOptions {
|
|
69
73
|
[OS.Android]?: AndroidAppInfo;
|
|
70
74
|
[OS.iOS]?: IOSAppInfo;
|
|
@@ -112,4 +116,4 @@ declare const NativeAppPlugin: NativePlugin<'App', AppInstance, {
|
|
|
112
116
|
}>;
|
|
113
117
|
|
|
114
118
|
export { NativeAppPlugin as default };
|
|
115
|
-
export type { AndroidAppInfo, AppInfo, AppInstance, AppOpenOptions, IOSAppInfo, MacOSAppInfo, Messenger, MessengerOpenOptions, Stringifiable, StringifiableSequence, URLCandidate, URLCandidateOrFallback, URLStringOrFallback, WindowsAppInfo };
|
|
119
|
+
export type { AndroidAppInfo, AppInfo, AppInstance, AppOpenOptions, IOSAppInfo, MacOSAppInfo, Messenger, MessengerOpenOptions, StoreInfo, Stringifiable, StringifiableSequence, URLCandidate, URLCandidateOrFallback, URLStringOrFallback, WindowsAppInfo };
|