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