web-launch-kit 0.0.1
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/README.md +241 -0
- package/dist/index.d.ts +147 -0
- package/dist/launch-kit.cjs +1986 -0
- package/dist/launch-kit.cjs.map +1 -0
- package/dist/launch-kit.min.cjs +2 -0
- package/dist/launch-kit.min.cjs.map +1 -0
- package/dist/launch-kit.min.mjs +2 -0
- package/dist/launch-kit.min.mjs.map +1 -0
- package/dist/launch-kit.mjs +1982 -0
- package/dist/launch-kit.mjs.map +1 -0
- package/dist/launch-kit.umd.js +1992 -0
- package/dist/launch-kit.umd.js.map +1 -0
- package/dist/launch-kit.umd.min.js +2 -0
- package/dist/launch-kit.umd.min.js.map +1 -0
- package/dist/utils/create-hidden-element.d.ts +1 -0
- package/dist/utils/event-listener-utils.d.ts +8 -0
- package/dist/utils/get-id.d.ts +16 -0
- package/dist/utils/get-topmost-window.d.ts +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,1992 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LaunchKit = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
var version$1 = "0.0.1";
|
|
8
|
+
var packageJSON$1 = {
|
|
9
|
+
version: version$1};
|
|
10
|
+
|
|
11
|
+
var version = "0.0.4";
|
|
12
|
+
var packageJSON = {
|
|
13
|
+
version: version};
|
|
14
|
+
|
|
15
|
+
var NAVIGATOR$1 = globalThis.navigator;
|
|
16
|
+
var USER_AGENT = typeof NAVIGATOR$1 !== 'undefined' ? NAVIGATOR$1.userAgent : '';
|
|
17
|
+
var USER_AGENT_DATA = typeof NAVIGATOR$1 !== 'undefined' ? NAVIGATOR$1.userAgentData : undefined;
|
|
18
|
+
var OS_RESOLVER_MAP = [
|
|
19
|
+
[/windows nt (6\.[23]); arm/i, 'windows', resolveWindowsVersion],
|
|
20
|
+
[/windows (?:phone|mobile|iot)(?: os)?[\/ ]?([\d.]*( se)?)/i, 'windows', resolveWindowsVersion],
|
|
21
|
+
[/windows[\/ ](1[01]|2000|3\.1|7|8(\.1)?|9[58]|me|server 20\d\d( r2)?|vista|xp)/i, 'windows', resolveWindowsVersion],
|
|
22
|
+
[/windows nt ?([\d.)]*)(?!.+xbox)/i, 'windows', resolveWindowsVersion],
|
|
23
|
+
[/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d.;]*)/i, 'windows', resolveWindowsVersion],
|
|
24
|
+
[/windows ce\/?([\d.]*)/i, 'windows', resolveWindowsVersion],
|
|
25
|
+
[/[adehimnop]{4,7}\b(?:.*os (\w+) like mac|; opera)/i, 'ios', resolveUnderscoreVersion],
|
|
26
|
+
[/(?:ios;fbsv|ios(?=.+ip(?:ad|hone))|ip(?:ad|hone)(?: |.+i(?:pad)?)os)[\/ ]([\w.]+)/i, 'ios', resolveUnderscoreVersion],
|
|
27
|
+
[/cfnetwork\/.+darwin/i, 'ios', resolveUnderscoreVersion],
|
|
28
|
+
[/mac os x ?([\w. ]*)/i, 'macos', resolveUnderscoreVersion],
|
|
29
|
+
[/(?:macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i, 'macos', resolveUnderscoreVersion],
|
|
30
|
+
[/droid ([\w.]+)\b.+(android[- ]x86)/i, 'android'],
|
|
31
|
+
[/android\w*[-\/.; ]?([\d.]*)/i, 'android'],
|
|
32
|
+
];
|
|
33
|
+
var BROWSER_RESOLVER_MAP = [
|
|
34
|
+
[/\b(?:crmo|crios)\/([\w.]+)/i, 'chrome'],
|
|
35
|
+
[/webview.+edge\/([\w.]+)/i, 'edge'],
|
|
36
|
+
[/edg(?:e|ios|a)?\/([\w.]+)/i, 'edge'],
|
|
37
|
+
[/opera mini\/([-\w.]+)/i, 'opera'],
|
|
38
|
+
[/opera [mobileta]{3,6}\b.+version\/([-\w.]+)/i, 'opera'],
|
|
39
|
+
[/opera(?:.+version\/|[\/ ]+)([\w.]+)/i, 'opera'],
|
|
40
|
+
[/opios[\/ ]+([\w.]+)/i, 'opera'],
|
|
41
|
+
[/\bop(?:rg)?x\/([\w.]+)/i, 'opera'],
|
|
42
|
+
[/\bopr\/([\w.]+)/i, 'opera'],
|
|
43
|
+
[/iemobile(?:browser|boat|jet)[\/ ]?([\d.]*)/i, 'ie'],
|
|
44
|
+
[/(?:ms|\()ie ([\w.]+)/i, 'ie'],
|
|
45
|
+
[/trident.+rv[: ]([\w.]{1,9})\b.+like gecko/i, 'ie'],
|
|
46
|
+
[/\bfocus\/([\w.]+)/i, 'firefox'],
|
|
47
|
+
[/\bopt\/([\w.]+)/i, 'opera'],
|
|
48
|
+
[/coast\/([\w.]+)/i, 'opera'],
|
|
49
|
+
[/fxios\/([\w.-]+)/i, 'firefox'],
|
|
50
|
+
[/samsungbrowser\/([\w.]+)/i, 'samsung'],
|
|
51
|
+
[/headlesschrome(?:\/([\w.]+)| )/i, 'chrome'],
|
|
52
|
+
[/wv\).+chrome\/([\w.]+).+edgw\//i, 'edge'],
|
|
53
|
+
[/ wv\).+(chrome)\/([\w.]+)/i, 'chrome'],
|
|
54
|
+
[/chrome\/([\w.]+) mobile/i, 'chrome'],
|
|
55
|
+
[/chrome\/v?([\w.]+)/i, 'chrome'],
|
|
56
|
+
[/version\/([\w.,]+) .*mobile(?:\/\w+ | ?)safari/i, 'safari'],
|
|
57
|
+
[/iphone .*mobile(?:\/\w+ | ?)safari/i, 'safari'],
|
|
58
|
+
[/version\/([\w.,]+) .*safari/i, 'safari'],
|
|
59
|
+
[/webkit.+?(?:mobile ?safari|safari)(\/[\w.]+)/i, 'safari', '1'],
|
|
60
|
+
[/(?:mobile|tablet);.*firefox\/([\w.-]+)/i, 'firefox'],
|
|
61
|
+
[/mobile vr; rv:([\w.]+)\).+firefox/i, 'firefox'],
|
|
62
|
+
[/firefox\/([\w.]+)/i, 'firefox'],
|
|
63
|
+
];
|
|
64
|
+
var ENGINE_RESOLVER_MAP = [
|
|
65
|
+
[/windows.+ edge\/([\w.]+)/i, 'edgeHtml'],
|
|
66
|
+
[/arkweb\/([\w.]+)/i, 'arkWeb'],
|
|
67
|
+
[/webkit\/537\.36.+chrome\/(?!27)([\w.]+)/i, 'blink'],
|
|
68
|
+
[/presto\/([\w.]+)/i, 'presto'],
|
|
69
|
+
[/webkit\/([\w.]+)/i, 'webKit'],
|
|
70
|
+
[/trident\/([\w.]+)/i, 'trident'],
|
|
71
|
+
[/netfront\/([\w.]+)/i, 'netFront'],
|
|
72
|
+
[/khtml[\/ ]\(?([\w.]+)/i, 'khtml'],
|
|
73
|
+
[/tasman[\/ ]\(?([\w.]+)/i, 'tasman'],
|
|
74
|
+
[/rv:([\w.]{1,9})\b.+gecko/i, 'gecko']
|
|
75
|
+
];
|
|
76
|
+
var HIGH_ENTROPY_BRAND_NAME_MAP = {
|
|
77
|
+
'Google Chrome': 'Chrome',
|
|
78
|
+
'Microsoft Edge': 'Edge',
|
|
79
|
+
'Microsoft Edge WebView2': 'Edge WebView2',
|
|
80
|
+
'Android WebView': 'Chrome WebView',
|
|
81
|
+
'HeadlessChrome': 'Chrome Headless',
|
|
82
|
+
'OperaMobile': 'Opera Mobi',
|
|
83
|
+
};
|
|
84
|
+
var currentUserAgent = USER_AGENT;
|
|
85
|
+
var parsedCache = null;
|
|
86
|
+
var parsedFromHighEntropyValuesOSName = undefined;
|
|
87
|
+
var parsedFromHighEntropyValuesOSVersion = undefined;
|
|
88
|
+
var parsedFromHighEntropyValuesBrowserName = undefined;
|
|
89
|
+
var parsedFromHighEntropyValuesBrowserVersion = undefined;
|
|
90
|
+
var parsedFromHighEntropyValuesEngineVersion = undefined;
|
|
91
|
+
var parsedFromHighEntropyValuesDevice = null;
|
|
92
|
+
var ready;
|
|
93
|
+
function resolveWindowsVersion(string) {
|
|
94
|
+
if (typeof string === 'undefined')
|
|
95
|
+
return '';
|
|
96
|
+
var mapped = {
|
|
97
|
+
'4.90': 'ME',
|
|
98
|
+
'NT3.51': 'NT 3.11',
|
|
99
|
+
'NT4.0': 'NT 4.0',
|
|
100
|
+
'NT 5.0': '2000',
|
|
101
|
+
'NT 5.1': 'XP',
|
|
102
|
+
'NT 5.2': 'XP',
|
|
103
|
+
'NT 6.0': 'Vista',
|
|
104
|
+
'NT 6.1': '7',
|
|
105
|
+
'NT 6.2': '8',
|
|
106
|
+
'NT 6.3': '8.1',
|
|
107
|
+
'NT 6.4': '10',
|
|
108
|
+
'NT 10.0': '10',
|
|
109
|
+
'ARM': 'RT'
|
|
110
|
+
}[string];
|
|
111
|
+
if (typeof mapped !== 'undefined')
|
|
112
|
+
return mapped;
|
|
113
|
+
return string;
|
|
114
|
+
}
|
|
115
|
+
function resolveUnderscoreVersion(string) {
|
|
116
|
+
if (typeof string === 'undefined')
|
|
117
|
+
return '';
|
|
118
|
+
return string.replace(/_/g, '.');
|
|
119
|
+
}
|
|
120
|
+
function resolveVersion(string, resolver) {
|
|
121
|
+
if (typeof resolver === 'function')
|
|
122
|
+
return resolver(string);
|
|
123
|
+
if (typeof resolver === 'string')
|
|
124
|
+
return resolver;
|
|
125
|
+
if (typeof string === 'undefined')
|
|
126
|
+
return '';
|
|
127
|
+
return string;
|
|
128
|
+
}
|
|
129
|
+
function parseOS() {
|
|
130
|
+
var name = 'unknown';
|
|
131
|
+
var version = '';
|
|
132
|
+
for (var i = 0; i < OS_RESOLVER_MAP.length; i++) {
|
|
133
|
+
var map = OS_RESOLVER_MAP[i];
|
|
134
|
+
var matched = currentUserAgent.match(map[0]);
|
|
135
|
+
if (matched !== null) {
|
|
136
|
+
name = map[1];
|
|
137
|
+
version = resolveVersion(matched[1], map[2]);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (name === 'ios' && PlatformKit.compareVersion(version, '18.6') === 0) {
|
|
142
|
+
var execs = /\) Version\/([\d.]+)/.exec(currentUserAgent);
|
|
143
|
+
if (execs !== null) {
|
|
144
|
+
var major = parseInt(execs[1].split('.')[0], 10);
|
|
145
|
+
if (major >= 26)
|
|
146
|
+
version = execs[1];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (currentUserAgent === USER_AGENT) {
|
|
150
|
+
if (typeof parsedFromHighEntropyValuesOSName !== 'undefined')
|
|
151
|
+
name = parsedFromHighEntropyValuesOSName;
|
|
152
|
+
if (typeof parsedFromHighEntropyValuesOSVersion !== 'undefined')
|
|
153
|
+
version = parsedFromHighEntropyValuesOSVersion;
|
|
154
|
+
if (name === 'macos' && typeof globalThis.navigator.standalone !== 'undefined' && typeof globalThis.navigator.maxTouchPoints !== 'undefined' && globalThis.navigator.maxTouchPoints > 2)
|
|
155
|
+
name = 'ios';
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
name: name,
|
|
159
|
+
version: version
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function parseBrowser() {
|
|
163
|
+
var name = 'unknown';
|
|
164
|
+
var version = '';
|
|
165
|
+
for (var i = 0; i < BROWSER_RESOLVER_MAP.length; i++) {
|
|
166
|
+
var map = BROWSER_RESOLVER_MAP[i];
|
|
167
|
+
var matched = currentUserAgent.match(map[0]);
|
|
168
|
+
if (matched !== null) {
|
|
169
|
+
name = map[1];
|
|
170
|
+
version = resolveVersion(matched[1], map[2]);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (currentUserAgent === USER_AGENT) {
|
|
175
|
+
if (typeof parsedFromHighEntropyValuesBrowserName !== 'undefined')
|
|
176
|
+
name = parsedFromHighEntropyValuesBrowserName;
|
|
177
|
+
if (typeof parsedFromHighEntropyValuesBrowserVersion !== 'undefined')
|
|
178
|
+
version = parsedFromHighEntropyValuesBrowserVersion;
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
name: name,
|
|
182
|
+
version: version
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function parseEngine() {
|
|
186
|
+
var name = 'unknown';
|
|
187
|
+
var version = '';
|
|
188
|
+
for (var i = 0; i < ENGINE_RESOLVER_MAP.length; i++) {
|
|
189
|
+
var map = ENGINE_RESOLVER_MAP[i];
|
|
190
|
+
var matched = currentUserAgent.match(map[0]);
|
|
191
|
+
if (matched !== null) {
|
|
192
|
+
name = map[1];
|
|
193
|
+
version = resolveVersion(matched[1], map[2]);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (currentUserAgent === USER_AGENT) {
|
|
198
|
+
if (typeof parsedFromHighEntropyValuesEngineVersion !== 'undefined')
|
|
199
|
+
version = parsedFromHighEntropyValuesEngineVersion;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
name: name,
|
|
203
|
+
version: version
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function getParsedCache() {
|
|
207
|
+
if (parsedCache !== null && parsedCache.userAgent === currentUserAgent)
|
|
208
|
+
return parsedCache;
|
|
209
|
+
parsedCache = {
|
|
210
|
+
userAgent: currentUserAgent,
|
|
211
|
+
os: parseOS(),
|
|
212
|
+
browser: parseBrowser(),
|
|
213
|
+
engine: parseEngine(),
|
|
214
|
+
};
|
|
215
|
+
return parsedCache;
|
|
216
|
+
}
|
|
217
|
+
function invalidateCache() {
|
|
218
|
+
parsedCache = null;
|
|
219
|
+
parsedFromHighEntropyValuesOSName = undefined;
|
|
220
|
+
parsedFromHighEntropyValuesOSVersion = undefined;
|
|
221
|
+
parsedFromHighEntropyValuesBrowserName = undefined;
|
|
222
|
+
parsedFromHighEntropyValuesBrowserVersion = undefined;
|
|
223
|
+
parsedFromHighEntropyValuesEngineVersion = undefined;
|
|
224
|
+
parsedFromHighEntropyValuesDevice = null;
|
|
225
|
+
}
|
|
226
|
+
function normalizeBrand(entry) {
|
|
227
|
+
if (entry === null || typeof entry === 'undefined')
|
|
228
|
+
return { brand: '', version: '' };
|
|
229
|
+
if (typeof entry === 'string')
|
|
230
|
+
return { brand: entry, version: '' };
|
|
231
|
+
return { brand: entry.brand, version: entry.version };
|
|
232
|
+
}
|
|
233
|
+
function parseFromHighEntropyValues() {
|
|
234
|
+
if (typeof USER_AGENT_DATA === 'undefined' || typeof USER_AGENT_DATA.getHighEntropyValues === 'undefined')
|
|
235
|
+
return Promise.resolve();
|
|
236
|
+
return USER_AGENT_DATA
|
|
237
|
+
.getHighEntropyValues(['brands', 'fullVersionList', 'mobile', 'model', 'platform', 'platformVersion', 'architecture', 'formFactors', 'bitness', 'uaFullVersion', 'wow64'])
|
|
238
|
+
.then(function (result) {
|
|
239
|
+
try {
|
|
240
|
+
var brands = result.fullVersionList || result.brands || [];
|
|
241
|
+
var platformVersion = result.platformVersion;
|
|
242
|
+
var platform = result.platform;
|
|
243
|
+
var browserName = getParsedCache().browser.name;
|
|
244
|
+
var prevBrandName = null;
|
|
245
|
+
for (var i = 0; i < brands.length; i++) {
|
|
246
|
+
var brand = normalizeBrand(brands[i]);
|
|
247
|
+
var brandVersion = brand.version;
|
|
248
|
+
var brandName = brand.brand;
|
|
249
|
+
if (/not.a.brand/i.test(brandName))
|
|
250
|
+
continue;
|
|
251
|
+
if (prevBrandName === null || (/Chrom/.test(prevBrandName) && brandName !== 'Chromium') || (prevBrandName === 'Edge' && /WebView2/.test(brandName))) {
|
|
252
|
+
brandName = HIGH_ENTROPY_BRAND_NAME_MAP[brandName] || brandName;
|
|
253
|
+
prevBrandName = browserName;
|
|
254
|
+
if (prevBrandName === null || /Chrom/.test(prevBrandName) || !/Chrom/.test(brandName)) {
|
|
255
|
+
browserName = brandName;
|
|
256
|
+
if (browserName === 'Chrome' || browserName === 'Chrome WebView' || browserName === 'Chrome Headless')
|
|
257
|
+
parsedFromHighEntropyValuesBrowserName = 'chrome';
|
|
258
|
+
else if (browserName === 'Edge' || browserName === 'Edge WebView2')
|
|
259
|
+
parsedFromHighEntropyValuesBrowserName = 'edge';
|
|
260
|
+
else if (browserName === 'Opera Mobi')
|
|
261
|
+
parsedFromHighEntropyValuesBrowserName = 'opera';
|
|
262
|
+
parsedFromHighEntropyValuesBrowserVersion = brandVersion;
|
|
263
|
+
}
|
|
264
|
+
prevBrandName = brandName;
|
|
265
|
+
}
|
|
266
|
+
if (brandName === 'Chromium')
|
|
267
|
+
parsedFromHighEntropyValuesEngineVersion = brandVersion;
|
|
268
|
+
}
|
|
269
|
+
if (typeof platformVersion === 'string') {
|
|
270
|
+
if (getParsedCache().os.name === 'windows') {
|
|
271
|
+
if (parseInt(platformVersion.split('.')[0], 10) >= 13)
|
|
272
|
+
parsedFromHighEntropyValuesOSVersion = '11';
|
|
273
|
+
else
|
|
274
|
+
parsedFromHighEntropyValuesOSVersion = '10';
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
parsedFromHighEntropyValuesOSVersion = platformVersion;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (typeof platform === 'string') {
|
|
281
|
+
if (/android/i.test(platform))
|
|
282
|
+
parsedFromHighEntropyValuesOSName = 'android';
|
|
283
|
+
else if (/ios|iphone|ipad/i.test(platform))
|
|
284
|
+
parsedFromHighEntropyValuesOSName = 'ios';
|
|
285
|
+
else if (/windows|win32/i.test(platform))
|
|
286
|
+
parsedFromHighEntropyValuesOSName = 'windows';
|
|
287
|
+
else if (/macos|macintel/i.test(platform))
|
|
288
|
+
parsedFromHighEntropyValuesOSName = 'macos';
|
|
289
|
+
}
|
|
290
|
+
if (result.mobile === true)
|
|
291
|
+
parsedFromHighEntropyValuesDevice = 'mobile';
|
|
292
|
+
parsedCache = null;
|
|
293
|
+
}
|
|
294
|
+
catch (_) {
|
|
295
|
+
}
|
|
296
|
+
})
|
|
297
|
+
.catch(function () {
|
|
298
|
+
parsedCache = null;
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
ready = parseFromHighEntropyValues();
|
|
302
|
+
var PlatformKit = {
|
|
303
|
+
version: packageJSON.version,
|
|
304
|
+
get ready() {
|
|
305
|
+
return ready;
|
|
306
|
+
},
|
|
307
|
+
set userAgent(userAgent) {
|
|
308
|
+
if (currentUserAgent === userAgent)
|
|
309
|
+
return;
|
|
310
|
+
currentUserAgent = userAgent;
|
|
311
|
+
invalidateCache();
|
|
312
|
+
ready = parseFromHighEntropyValues();
|
|
313
|
+
},
|
|
314
|
+
get userAgent() {
|
|
315
|
+
return currentUserAgent;
|
|
316
|
+
},
|
|
317
|
+
get os() {
|
|
318
|
+
return getParsedCache().os;
|
|
319
|
+
},
|
|
320
|
+
get browser() {
|
|
321
|
+
return getParsedCache().browser;
|
|
322
|
+
},
|
|
323
|
+
get engine() {
|
|
324
|
+
return getParsedCache().engine;
|
|
325
|
+
},
|
|
326
|
+
get device() {
|
|
327
|
+
if (currentUserAgent === USER_AGENT && parsedFromHighEntropyValuesDevice !== null)
|
|
328
|
+
return parsedFromHighEntropyValuesDevice;
|
|
329
|
+
var osName = getParsedCache().os.name;
|
|
330
|
+
if (osName === 'ios' || osName === 'android')
|
|
331
|
+
return 'mobile';
|
|
332
|
+
if (osName === 'windows' || osName === 'macos')
|
|
333
|
+
return 'desktop';
|
|
334
|
+
return 'unknown';
|
|
335
|
+
},
|
|
336
|
+
get webview() {
|
|
337
|
+
return /; ?wv|applewebkit(?!.*safari)/i.test(currentUserAgent);
|
|
338
|
+
},
|
|
339
|
+
get node() {
|
|
340
|
+
return typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && typeof globalThis.process.versions.node !== 'undefined';
|
|
341
|
+
},
|
|
342
|
+
get standalone() {
|
|
343
|
+
var osName = getParsedCache().os.name;
|
|
344
|
+
if (osName === 'ios')
|
|
345
|
+
return globalThis.navigator.standalone === true;
|
|
346
|
+
if (typeof globalThis.matchMedia === 'undefined')
|
|
347
|
+
return false;
|
|
348
|
+
return globalThis.matchMedia('(display-mode: standalone)').matches;
|
|
349
|
+
},
|
|
350
|
+
compareVersion: function (lhs, rhs) {
|
|
351
|
+
var pa = lhs.split('.');
|
|
352
|
+
var pb = rhs.split('.');
|
|
353
|
+
var length = Math.max(pa.length, pb.length);
|
|
354
|
+
for (var i = 0; i < length; i++) {
|
|
355
|
+
var a = void 0;
|
|
356
|
+
var b = void 0;
|
|
357
|
+
if (i < pa.length)
|
|
358
|
+
a = parseInt(pa[i], 10);
|
|
359
|
+
else
|
|
360
|
+
a = 0;
|
|
361
|
+
if (i < pb.length)
|
|
362
|
+
b = parseInt(pb[i], 10);
|
|
363
|
+
else
|
|
364
|
+
b = 0;
|
|
365
|
+
if (a > b)
|
|
366
|
+
return 1;
|
|
367
|
+
if (a < b)
|
|
368
|
+
return -1;
|
|
369
|
+
}
|
|
370
|
+
return 0;
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
function createHiddenElement(tagName, focusable) {
|
|
375
|
+
if (focusable === void 0) { focusable = true; }
|
|
376
|
+
var element = globalThis.document.createElement(tagName);
|
|
377
|
+
if (typeof element.width !== 'undefined')
|
|
378
|
+
element.width = '0';
|
|
379
|
+
if (typeof element.height !== 'undefined')
|
|
380
|
+
element.height = '0';
|
|
381
|
+
if (typeof element.border !== 'undefined')
|
|
382
|
+
element.border = '0';
|
|
383
|
+
if (typeof element.frameBorder !== 'undefined')
|
|
384
|
+
element.frameBorder = '0';
|
|
385
|
+
if (typeof element.scrolling !== 'undefined')
|
|
386
|
+
element.scrolling = 'no';
|
|
387
|
+
if (typeof element.cellPadding !== 'undefined')
|
|
388
|
+
element.cellPadding = '0';
|
|
389
|
+
if (typeof element.cellSpacing !== 'undefined')
|
|
390
|
+
element.cellSpacing = '0';
|
|
391
|
+
if (typeof element.frame !== 'undefined')
|
|
392
|
+
element.frame = 'void';
|
|
393
|
+
if (typeof element.rules !== 'undefined')
|
|
394
|
+
element.rules = 'none';
|
|
395
|
+
if (typeof element.noWrap !== 'undefined')
|
|
396
|
+
element.noWrap = true;
|
|
397
|
+
element.tabIndex = -1;
|
|
398
|
+
element.setAttribute('role', 'presentation');
|
|
399
|
+
if (focusable) {
|
|
400
|
+
element.setAttribute('aria-hidden', 'false');
|
|
401
|
+
element.style.width = '1px';
|
|
402
|
+
element.style.height = '1px';
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
element.setAttribute('aria-hidden', 'true');
|
|
406
|
+
element.style.width = '0';
|
|
407
|
+
element.style.height = '0';
|
|
408
|
+
element.style.zIndex = '-9999';
|
|
409
|
+
element.style.display = 'none';
|
|
410
|
+
element.style.visibility = 'hidden';
|
|
411
|
+
element.style.pointerEvents = 'none';
|
|
412
|
+
}
|
|
413
|
+
element.style.position = 'absolute';
|
|
414
|
+
element.style.top = '0';
|
|
415
|
+
element.style.left = '0';
|
|
416
|
+
element.style.padding = '0';
|
|
417
|
+
element.style.margin = '0';
|
|
418
|
+
element.style.border = 'none';
|
|
419
|
+
element.style.outline = 'hidden';
|
|
420
|
+
element.style.clip = 'rect(1px, 1px, 1px, 1px)';
|
|
421
|
+
element.style.clipPath = 'inset(50%)';
|
|
422
|
+
element.style.overflow = 'hidden';
|
|
423
|
+
element.style.whiteSpace = 'nowrap';
|
|
424
|
+
return element;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
var RTL_LANGUAGES = ['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'iw', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi'];
|
|
428
|
+
function normalizeLocale(locale) {
|
|
429
|
+
if (locale === null || typeof locale === 'undefined')
|
|
430
|
+
return locale;
|
|
431
|
+
if (locale.length === 0)
|
|
432
|
+
return null;
|
|
433
|
+
locale = locale.replace(/_/g, '-');
|
|
434
|
+
if (locale === 'C' || locale.toLowerCase() === 'posix')
|
|
435
|
+
return 'en-US';
|
|
436
|
+
if (locale.indexOf('.') !== -1)
|
|
437
|
+
return normalizeLocale(locale.split('.')[0]);
|
|
438
|
+
if (locale.indexOf('@') !== -1)
|
|
439
|
+
return normalizeLocale(locale.split('@')[0]);
|
|
440
|
+
var parts = locale.split('-');
|
|
441
|
+
if (parts.length === 0)
|
|
442
|
+
return null;
|
|
443
|
+
parts[0] = parts[0].toLowerCase();
|
|
444
|
+
if (parts.length > 1 && parts[1].length === 2)
|
|
445
|
+
parts[1] = parts[1].toUpperCase();
|
|
446
|
+
if (parts.length > 2 && parts[1].length === 4)
|
|
447
|
+
parts[1] = parts[1].charAt(0).toUpperCase() + parts[1].slice(1).toLowerCase();
|
|
448
|
+
return parts.join('-');
|
|
449
|
+
}
|
|
450
|
+
var language = null;
|
|
451
|
+
var languages = [];
|
|
452
|
+
var timezone = null;
|
|
453
|
+
var offset = 0;
|
|
454
|
+
var isRTLResolved = null;
|
|
455
|
+
function addLanguages(langs) {
|
|
456
|
+
for (var i = 0; i < langs.length; i++)
|
|
457
|
+
addLanguage(langs[i]);
|
|
458
|
+
}
|
|
459
|
+
function addLanguage(lang) {
|
|
460
|
+
lang = normalizeLocale(lang);
|
|
461
|
+
if (typeof lang === 'string' && languages.indexOf(lang) === -1) {
|
|
462
|
+
if (language === null)
|
|
463
|
+
language = lang;
|
|
464
|
+
languages.push(lang);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (typeof Intl !== 'undefined') {
|
|
468
|
+
try {
|
|
469
|
+
addLanguage(Intl.DateTimeFormat().resolvedOptions().locale);
|
|
470
|
+
}
|
|
471
|
+
catch (_) {
|
|
472
|
+
}
|
|
473
|
+
try {
|
|
474
|
+
timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
475
|
+
}
|
|
476
|
+
catch (_) {
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (typeof globalThis.navigator !== 'undefined') {
|
|
480
|
+
if (typeof globalThis.navigator.languages !== 'undefined')
|
|
481
|
+
addLanguages(globalThis.navigator.languages);
|
|
482
|
+
if (typeof globalThis.navigator.language !== 'undefined')
|
|
483
|
+
addLanguage(globalThis.navigator.language);
|
|
484
|
+
if (typeof globalThis.navigator.userLanguage !== 'undefined')
|
|
485
|
+
addLanguage(globalThis.navigator.userLanguage);
|
|
486
|
+
if (typeof globalThis.navigator.browserLanguage !== 'undefined')
|
|
487
|
+
addLanguage(globalThis.navigator.browserLanguage);
|
|
488
|
+
if (typeof globalThis.navigator.systemLanguage !== 'undefined')
|
|
489
|
+
addLanguage(globalThis.navigator.systemLanguage);
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
offset = new Date().getTimezoneOffset() * -1;
|
|
493
|
+
}
|
|
494
|
+
catch (_) {
|
|
495
|
+
}
|
|
496
|
+
if (typeof language === 'string') {
|
|
497
|
+
if (typeof Intl !== 'undefined' && typeof Intl.Locale !== 'undefined') {
|
|
498
|
+
try {
|
|
499
|
+
var intlLocale = new Intl.Locale(language);
|
|
500
|
+
if (typeof intlLocale.getTextInfo === 'function')
|
|
501
|
+
isRTLResolved = intlLocale.getTextInfo().direction === 'rtl';
|
|
502
|
+
else if (typeof intlLocale.textInfo !== 'undefined')
|
|
503
|
+
isRTLResolved = intlLocale.textInfo.direction === 'rtl';
|
|
504
|
+
}
|
|
505
|
+
catch (_) {
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (typeof isRTLResolved !== 'boolean') {
|
|
509
|
+
var matched = /^([A-Za-z]{1,8})(?:[-_][A-Za-z0-9]{1,8})*$/.exec(language);
|
|
510
|
+
if (matched !== null) {
|
|
511
|
+
var lang = matched[1].toLowerCase();
|
|
512
|
+
for (var i = 0; i < RTL_LANGUAGES.length; i++) {
|
|
513
|
+
if (RTL_LANGUAGES[i] === lang) {
|
|
514
|
+
isRTLResolved = true;
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
var LocaleKit = {
|
|
522
|
+
languages: languages};
|
|
523
|
+
|
|
524
|
+
var TRACK_ID = 'track-id';
|
|
525
|
+
var BUNDLE_ID = 'bundle-id';
|
|
526
|
+
var TRACK_ID_CACHE_TTL = 1000 * 60 * 60;
|
|
527
|
+
var idCache = (function () {
|
|
528
|
+
var supportsLocalStorage;
|
|
529
|
+
try {
|
|
530
|
+
if (typeof globalThis.localStorage === 'undefined') {
|
|
531
|
+
supportsLocalStorage = false;
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
var key = '__id_cache_test__';
|
|
535
|
+
globalThis.localStorage.setItem(key, '');
|
|
536
|
+
globalThis.localStorage.removeItem(key);
|
|
537
|
+
supportsLocalStorage = true;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
catch (_) {
|
|
541
|
+
supportsLocalStorage = false;
|
|
542
|
+
}
|
|
543
|
+
if (supportsLocalStorage) {
|
|
544
|
+
return {
|
|
545
|
+
get: function (mode, query) {
|
|
546
|
+
try {
|
|
547
|
+
var item = globalThis.localStorage.getItem(mode + ':' + query);
|
|
548
|
+
if (item == null)
|
|
549
|
+
return undefined;
|
|
550
|
+
var split = item.split('|');
|
|
551
|
+
if (split.length !== 2)
|
|
552
|
+
return undefined;
|
|
553
|
+
var expiry = +split[0];
|
|
554
|
+
if (isNotANumber(expiry) || expiry < getNow()) {
|
|
555
|
+
globalThis.localStorage.removeItem(mode + ':' + query);
|
|
556
|
+
return undefined;
|
|
557
|
+
}
|
|
558
|
+
return split[1];
|
|
559
|
+
}
|
|
560
|
+
catch (_) {
|
|
561
|
+
return undefined;
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
set: function (mode, query, id) {
|
|
565
|
+
try {
|
|
566
|
+
globalThis.localStorage.setItem(mode + ':' + query, getNow() + TRACK_ID_CACHE_TTL + '|' + id);
|
|
567
|
+
}
|
|
568
|
+
catch (_) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
if (typeof globalThis.Map !== 'undefined') {
|
|
575
|
+
var cache_1 = new Map();
|
|
576
|
+
return {
|
|
577
|
+
get: function (mode, query) {
|
|
578
|
+
var item = cache_1.get(mode + ':' + query);
|
|
579
|
+
if (typeof item === 'undefined')
|
|
580
|
+
return undefined;
|
|
581
|
+
var split = item.split('|');
|
|
582
|
+
if (split.length !== 2)
|
|
583
|
+
return undefined;
|
|
584
|
+
var expiry = +split[0];
|
|
585
|
+
if (isNotANumber(expiry) || expiry < getNow()) {
|
|
586
|
+
cache_1.delete(mode + ':' + query);
|
|
587
|
+
return undefined;
|
|
588
|
+
}
|
|
589
|
+
return split[1];
|
|
590
|
+
},
|
|
591
|
+
set: function (mode, query, id) {
|
|
592
|
+
cache_1.set(mode + ':' + query, getNow() + TRACK_ID_CACHE_TTL + '|' + id);
|
|
593
|
+
},
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
var cache = Object.create(null);
|
|
597
|
+
return {
|
|
598
|
+
get: function (mode, query) {
|
|
599
|
+
var item = cache[mode + ':' + query];
|
|
600
|
+
if (typeof item === 'undefined')
|
|
601
|
+
return undefined;
|
|
602
|
+
var split = item.split('|');
|
|
603
|
+
if (split.length !== 2)
|
|
604
|
+
return undefined;
|
|
605
|
+
var expiry = +split[0];
|
|
606
|
+
if (isNotANumber(expiry) || expiry < getNow()) {
|
|
607
|
+
try {
|
|
608
|
+
delete cache[mode + ':' + query];
|
|
609
|
+
}
|
|
610
|
+
catch (_) {
|
|
611
|
+
cache[mode + ':' + query] = undefined;
|
|
612
|
+
}
|
|
613
|
+
return undefined;
|
|
614
|
+
}
|
|
615
|
+
return split[1];
|
|
616
|
+
},
|
|
617
|
+
set: function (mode, query, id) {
|
|
618
|
+
cache[mode + ':' + query] = getNow() + TRACK_ID_CACHE_TTL + '|' + id;
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
})();
|
|
622
|
+
function isNotANumber(value) {
|
|
623
|
+
return value !== value;
|
|
624
|
+
}
|
|
625
|
+
function getNow() {
|
|
626
|
+
if (typeof Date.now !== 'undefined')
|
|
627
|
+
return Date.now();
|
|
628
|
+
return (new Date).getTime();
|
|
629
|
+
}
|
|
630
|
+
function requestGet(url, async) {
|
|
631
|
+
if (async === void 0) { async = false; }
|
|
632
|
+
if (typeof globalThis.fetch === 'function' && async) {
|
|
633
|
+
return globalThis.fetch(url)
|
|
634
|
+
.then(function (response) {
|
|
635
|
+
return response.json();
|
|
636
|
+
})
|
|
637
|
+
.catch(function (_) {
|
|
638
|
+
return undefined;
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
else {
|
|
642
|
+
try {
|
|
643
|
+
var xhr = new XMLHttpRequest();
|
|
644
|
+
xhr.open('GET', url, async);
|
|
645
|
+
xhr.send();
|
|
646
|
+
var status_1 = xhr.status;
|
|
647
|
+
if (status_1 >= 200 && status_1 < 300)
|
|
648
|
+
return JSON.parse(xhr.response);
|
|
649
|
+
return undefined;
|
|
650
|
+
}
|
|
651
|
+
catch (_) {
|
|
652
|
+
return undefined;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
function resolveGetProductIdURL(packageFamilyName) {
|
|
657
|
+
var locales = LocaleKit.languages;
|
|
658
|
+
var locale = 'en-US';
|
|
659
|
+
var country = 'US';
|
|
660
|
+
for (var i = 0; i < locales.length; i++) {
|
|
661
|
+
var candidate = locales[i];
|
|
662
|
+
if (candidate.indexOf('-') === -1)
|
|
663
|
+
continue;
|
|
664
|
+
var subtags = candidate.split('-');
|
|
665
|
+
for (var j = 1; j < subtags.length; j++) {
|
|
666
|
+
var subtag = subtags[j];
|
|
667
|
+
if (/^[A-Za-z]{2}$/.test(subtag) || /^\d{3}$/.test(subtag)) {
|
|
668
|
+
locale = candidate;
|
|
669
|
+
country = subtag;
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (locale === candidate)
|
|
674
|
+
break;
|
|
675
|
+
}
|
|
676
|
+
return 'https://displaycatalog.md.mp.microsoft.com/v7.0/products/lookup?value=' + globalThis.encodeURIComponent(packageFamilyName) + '&market=' + globalThis.encodeURIComponent(country) + '&languages=' + globalThis.encodeURIComponent(locale) + '&alternateId=PackageFamilyName';
|
|
677
|
+
}
|
|
678
|
+
function resolveGetTrackIdURL(bundleId) {
|
|
679
|
+
return 'https://itunes.apple.com/lookup?bundleId=' + globalThis.encodeURIComponent(bundleId);
|
|
680
|
+
}
|
|
681
|
+
function parseGetProductIdResponse(response) {
|
|
682
|
+
if (typeof response === 'undefined')
|
|
683
|
+
return undefined;
|
|
684
|
+
var product = undefined;
|
|
685
|
+
if (typeof response.Products !== 'undefined')
|
|
686
|
+
product = response.Products[0];
|
|
687
|
+
else if (typeof response.Product !== 'undefined')
|
|
688
|
+
product = response.Product;
|
|
689
|
+
if (typeof product === 'undefined' || product === null)
|
|
690
|
+
return undefined;
|
|
691
|
+
return product.ProductId;
|
|
692
|
+
}
|
|
693
|
+
function parseGetTrackIdResponse(response) {
|
|
694
|
+
if (typeof response === 'undefined' || typeof response.results === 'undefined')
|
|
695
|
+
return undefined;
|
|
696
|
+
var results = response.results;
|
|
697
|
+
if (results.length === 0)
|
|
698
|
+
return undefined;
|
|
699
|
+
var result = results[0];
|
|
700
|
+
if (typeof result === 'undefined')
|
|
701
|
+
return undefined;
|
|
702
|
+
return '' + result.trackId;
|
|
703
|
+
}
|
|
704
|
+
function getProductId(packageFamilyName) {
|
|
705
|
+
var cache = idCache.get(BUNDLE_ID, packageFamilyName);
|
|
706
|
+
if (typeof cache !== 'undefined')
|
|
707
|
+
return cache;
|
|
708
|
+
try {
|
|
709
|
+
var productId = parseGetProductIdResponse(requestGet(resolveGetProductIdURL(packageFamilyName)));
|
|
710
|
+
if (typeof productId === 'undefined')
|
|
711
|
+
return undefined;
|
|
712
|
+
idCache.set(BUNDLE_ID, packageFamilyName, productId);
|
|
713
|
+
return productId;
|
|
714
|
+
}
|
|
715
|
+
catch (_) {
|
|
716
|
+
return undefined;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
function getTrackId(bundleId) {
|
|
720
|
+
var cache = idCache.get(TRACK_ID, bundleId);
|
|
721
|
+
if (typeof cache !== 'undefined')
|
|
722
|
+
return cache;
|
|
723
|
+
try {
|
|
724
|
+
var trackId = parseGetTrackIdResponse(requestGet(resolveGetTrackIdURL(bundleId)));
|
|
725
|
+
if (typeof trackId === 'undefined')
|
|
726
|
+
return undefined;
|
|
727
|
+
idCache.set(TRACK_ID, bundleId, trackId);
|
|
728
|
+
return trackId;
|
|
729
|
+
}
|
|
730
|
+
catch (_) {
|
|
731
|
+
return undefined;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
function getProductIdAsync(packageFamilyName) {
|
|
735
|
+
var cache = idCache.get(BUNDLE_ID, packageFamilyName);
|
|
736
|
+
if (typeof cache !== 'undefined')
|
|
737
|
+
return Promise.resolve(cache);
|
|
738
|
+
try {
|
|
739
|
+
return requestGet(resolveGetProductIdURL(packageFamilyName), true)
|
|
740
|
+
.then(parseGetProductIdResponse)
|
|
741
|
+
.then(function (productId) {
|
|
742
|
+
if (typeof productId === 'undefined')
|
|
743
|
+
return undefined;
|
|
744
|
+
idCache.set(BUNDLE_ID, packageFamilyName, productId);
|
|
745
|
+
return productId;
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
catch (_) {
|
|
749
|
+
return Promise.resolve(undefined);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function getTrackIdAsync(bundleId) {
|
|
753
|
+
var cache = idCache.get(TRACK_ID, bundleId);
|
|
754
|
+
if (typeof cache !== 'undefined')
|
|
755
|
+
return Promise.resolve(cache);
|
|
756
|
+
try {
|
|
757
|
+
return requestGet(resolveGetTrackIdURL(bundleId), true)
|
|
758
|
+
.then(parseGetTrackIdResponse)
|
|
759
|
+
.then(function (trackId) {
|
|
760
|
+
if (typeof trackId === 'undefined')
|
|
761
|
+
return undefined;
|
|
762
|
+
idCache.set(TRACK_ID, bundleId, trackId);
|
|
763
|
+
return trackId;
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
catch (_) {
|
|
767
|
+
return Promise.resolve(undefined);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
function getTopmostWindow() {
|
|
772
|
+
try {
|
|
773
|
+
if (globalThis.top !== null && globalThis.top !== globalThis.window) {
|
|
774
|
+
void globalThis.top.location.href;
|
|
775
|
+
return globalThis.top;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
catch (_) {
|
|
779
|
+
}
|
|
780
|
+
return globalThis;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
var IE_WRAPPER_STORE = [];
|
|
784
|
+
var VENDORS = ['', 'webkit', 'moz', 'ms', 'MS', 'o', 'O'];
|
|
785
|
+
var LEGACY_TYPE_MAP = {
|
|
786
|
+
'focus': ['focus', 'focusin'],
|
|
787
|
+
'blur': ['blur', 'focusout'],
|
|
788
|
+
};
|
|
789
|
+
function resolveVendor(target, type) {
|
|
790
|
+
var types;
|
|
791
|
+
var legacy = LEGACY_TYPE_MAP[type];
|
|
792
|
+
if (typeof legacy !== 'undefined')
|
|
793
|
+
types = legacy;
|
|
794
|
+
else
|
|
795
|
+
types = [type];
|
|
796
|
+
for (var i = 0; i < VENDORS.length; i++) {
|
|
797
|
+
for (var j = 0; j < types.length; j++) {
|
|
798
|
+
var name_1 = VENDORS[i] + types[j];
|
|
799
|
+
if (typeof target['on' + name_1] !== 'undefined')
|
|
800
|
+
return name_1;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
return type;
|
|
804
|
+
}
|
|
805
|
+
function findIEWrapper(target, type, callback) {
|
|
806
|
+
for (var i = 0; i < IE_WRAPPER_STORE.length; i++) {
|
|
807
|
+
var wrapper = IE_WRAPPER_STORE[i];
|
|
808
|
+
if (wrapper.target === target && wrapper.type === type && wrapper.callback === callback)
|
|
809
|
+
return wrapper.wrapper;
|
|
810
|
+
}
|
|
811
|
+
return undefined;
|
|
812
|
+
}
|
|
813
|
+
function setIEWrapper(target, type, callback, wrapper) {
|
|
814
|
+
IE_WRAPPER_STORE.push({ target: target, type: type, callback: callback, wrapper: wrapper });
|
|
815
|
+
}
|
|
816
|
+
function removeIEWrapper(target, type, callback) {
|
|
817
|
+
for (var i = 0; i < IE_WRAPPER_STORE.length; i++) {
|
|
818
|
+
var wrapper = IE_WRAPPER_STORE[i];
|
|
819
|
+
if (wrapper.target === target && wrapper.type === type && wrapper.callback === callback) {
|
|
820
|
+
IE_WRAPPER_STORE.splice(i, 1);
|
|
821
|
+
return wrapper.wrapper;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return undefined;
|
|
825
|
+
}
|
|
826
|
+
function preventDefaultPolyfill() {
|
|
827
|
+
this.returnValue = false;
|
|
828
|
+
}
|
|
829
|
+
function stopPropagationPolyfill() {
|
|
830
|
+
this.cancelBubble = true;
|
|
831
|
+
}
|
|
832
|
+
function addEvent(target, type, callback) {
|
|
833
|
+
if (typeof target === 'undefined' || typeof type === 'undefined')
|
|
834
|
+
return;
|
|
835
|
+
type = resolveVendor(target, type);
|
|
836
|
+
if (typeof target.addEventListener === 'function') {
|
|
837
|
+
return target.addEventListener(type, callback);
|
|
838
|
+
}
|
|
839
|
+
if (typeof target.attachEvent === 'function') {
|
|
840
|
+
var existing = findIEWrapper(target, type, callback);
|
|
841
|
+
if (typeof existing === 'function')
|
|
842
|
+
return;
|
|
843
|
+
var wrapper = function (event) {
|
|
844
|
+
if (typeof event === 'undefined')
|
|
845
|
+
event = globalThis.event;
|
|
846
|
+
if (typeof event === 'undefined')
|
|
847
|
+
return;
|
|
848
|
+
try {
|
|
849
|
+
Object.defineProperty(event, 'currentTarget', { value: target, configurable: true });
|
|
850
|
+
}
|
|
851
|
+
catch (_) {
|
|
852
|
+
}
|
|
853
|
+
if (typeof event.preventDefault !== 'function')
|
|
854
|
+
event.preventDefault = preventDefaultPolyfill.bind(event);
|
|
855
|
+
if (typeof event.stopPropagation !== 'function')
|
|
856
|
+
event.stopPropagation = stopPropagationPolyfill.bind(event);
|
|
857
|
+
callback.call(target, event);
|
|
858
|
+
};
|
|
859
|
+
setIEWrapper(target, type, callback, wrapper);
|
|
860
|
+
return target.attachEvent('on' + type, wrapper);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
function removeEvent(target, type, callback) {
|
|
864
|
+
if (typeof target === 'undefined' || typeof type === 'undefined')
|
|
865
|
+
return;
|
|
866
|
+
type = resolveVendor(target, type);
|
|
867
|
+
if (typeof target.removeEventListener === 'function') {
|
|
868
|
+
return target.removeEventListener(type, callback);
|
|
869
|
+
}
|
|
870
|
+
if (typeof target.detachEvent === 'function') {
|
|
871
|
+
var wrapper = removeIEWrapper(target, type, callback);
|
|
872
|
+
if (typeof wrapper === 'function')
|
|
873
|
+
target.detachEvent('on' + type, wrapper);
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
exports.SettingType = void 0;
|
|
879
|
+
(function (SettingType) {
|
|
880
|
+
SettingType["General"] = "general";
|
|
881
|
+
SettingType["Network"] = "network";
|
|
882
|
+
SettingType["Display"] = "display";
|
|
883
|
+
SettingType["Appearance"] = "appearance";
|
|
884
|
+
SettingType["Accessibility"] = "accessibility";
|
|
885
|
+
SettingType["Battery"] = "battery";
|
|
886
|
+
SettingType["Datetime"] = "datetime";
|
|
887
|
+
SettingType["Language"] = "language";
|
|
888
|
+
SettingType["Accounts"] = "accounts";
|
|
889
|
+
SettingType["Storage"] = "storage";
|
|
890
|
+
})(exports.SettingType || (exports.SettingType = {}));
|
|
891
|
+
var SETTING_URL = {
|
|
892
|
+
android: {
|
|
893
|
+
general: 'intent:#Intent;action=android.settings.SETTINGS;end',
|
|
894
|
+
network: 'intent:#Intent;action=android.settings.WIFI_SETTINGS;end',
|
|
895
|
+
display: 'intent:#Intent;action=android.settings.DISPLAY_SETTINGS;end',
|
|
896
|
+
appearance: 'intent:#Intent;action=android.settings.DISPLAY_SETTINGS;end',
|
|
897
|
+
accessibility: 'intent:#Intent;action=android.settings.ACCESSIBILITY_SETTINGS;end',
|
|
898
|
+
battery: 'intent:#Intent;action=android.settings.BATTERY_SAVER_SETTINGS;end',
|
|
899
|
+
datetime: 'intent:#Intent;action=android.settings.DATE_SETTINGS;end',
|
|
900
|
+
language: 'intent:#Intent;action=android.settings.LOCALE_SETTINGS;end',
|
|
901
|
+
accounts: 'intent:#Intent;action=android.settings.SYNC_SETTINGS;end',
|
|
902
|
+
storage: 'intent:#Intent;action=android.settings.INTERNAL_STORAGE_SETTINGS;end',
|
|
903
|
+
},
|
|
904
|
+
windows: {
|
|
905
|
+
general: 'ms-settings:system',
|
|
906
|
+
network: 'ms-settings:network',
|
|
907
|
+
display: 'ms-settings:display',
|
|
908
|
+
appearance: 'ms-settings:colors',
|
|
909
|
+
accessibility: 'ms-settings:easeofaccess',
|
|
910
|
+
battery: 'ms-settings:batterysaver',
|
|
911
|
+
datetime: 'ms-settings:dateandtime',
|
|
912
|
+
language: 'ms-settings:regionlanguage',
|
|
913
|
+
accounts: 'ms-settings:emailandaccounts',
|
|
914
|
+
storage: 'ms-settings:storagesense',
|
|
915
|
+
},
|
|
916
|
+
macos: {
|
|
917
|
+
general: 'x-apple.systempreferences:',
|
|
918
|
+
network: 'x-apple.systempreferences:com.apple.preference.network',
|
|
919
|
+
display: 'x-apple.systempreferences:com.apple.preference.displays',
|
|
920
|
+
appearance: 'x-apple.systempreferences:com.apple.preference.general',
|
|
921
|
+
accessibility: 'x-apple.systempreferences:com.apple.preference.universalaccess',
|
|
922
|
+
battery: 'x-apple.systempreferences:com.apple.preference.energysaver',
|
|
923
|
+
datetime: 'x-apple.systempreferences:com.apple.preference.datetime',
|
|
924
|
+
language: 'x-apple.systempreferences:com.apple.Localization',
|
|
925
|
+
accounts: 'x-apple.systempreferences:com.apple.preferences.internetaccounts',
|
|
926
|
+
storage: 'x-apple.systempreferences:',
|
|
927
|
+
},
|
|
928
|
+
macos13: {
|
|
929
|
+
general: 'x-apple.systempreferences:com.apple.General-Settings.extension',
|
|
930
|
+
network: 'x-apple.systempreferences:com.apple.Network-Settings.extension',
|
|
931
|
+
display: 'x-apple.systempreferences:com.apple.Displays-Settings.extension',
|
|
932
|
+
appearance: 'x-apple.systempreferences:com.apple.Appearance-Settings.extension',
|
|
933
|
+
accessibility: 'x-apple.systempreferences:com.apple.Accessibility-Settings.extension',
|
|
934
|
+
battery: 'x-apple.systempreferences:com.apple.Battery-Settings.extension',
|
|
935
|
+
datetime: 'x-apple.systempreferences:com.apple.Date-Time-Settings.extension',
|
|
936
|
+
language: 'x-apple.systempreferences:com.apple.Localization-Settings.extension',
|
|
937
|
+
accounts: 'x-apple.systempreferences:com.apple.Internet-Accounts-Settings.extension',
|
|
938
|
+
storage: 'x-apple.systempreferences:com.apple.settings.Storage',
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
var ANDROID_DEFAULT_TIMEOUT = 1000;
|
|
942
|
+
var IOS_DEFAULT_TIMEOUT = 2000;
|
|
943
|
+
var WINDOWS_DEFAULT_TIMEOUT = 750;
|
|
944
|
+
var MACOS_DEFAULT_TIMEOUT = 750;
|
|
945
|
+
var SETTING_DEFAULT_TIMEOUT = 750;
|
|
946
|
+
var NAVIGATOR = globalThis.navigator;
|
|
947
|
+
var CLEANUP_INPUT_ELEMENT = null;
|
|
948
|
+
function createTypeGuard(tag) {
|
|
949
|
+
return function (value) {
|
|
950
|
+
return Object.prototype.toString.call(value) === '[object ' + tag + ']';
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
var isURL = createTypeGuard('URL');
|
|
954
|
+
var isDOMException = createTypeGuard('DOMException');
|
|
955
|
+
var isArray = createTypeGuard('Array');
|
|
956
|
+
var isPromise = createTypeGuard('Promise');
|
|
957
|
+
var isHTMLInputElement = createTypeGuard('HTMLInputElement');
|
|
958
|
+
function isHTMLInputElementLike(value) {
|
|
959
|
+
if (isHTMLInputElement(value))
|
|
960
|
+
return true;
|
|
961
|
+
var maybe = value;
|
|
962
|
+
return typeof maybe === 'object'
|
|
963
|
+
&& maybe !== null
|
|
964
|
+
&& maybe.nodeType === 1
|
|
965
|
+
&& typeof maybe.tagName === 'string'
|
|
966
|
+
&& maybe.tagName.toUpperCase() === 'INPUT';
|
|
967
|
+
}
|
|
968
|
+
function getDefaultTimeout() {
|
|
969
|
+
switch (PlatformKit.os.name) {
|
|
970
|
+
case 'android':
|
|
971
|
+
return ANDROID_DEFAULT_TIMEOUT;
|
|
972
|
+
case 'ios':
|
|
973
|
+
return IOS_DEFAULT_TIMEOUT;
|
|
974
|
+
case 'windows':
|
|
975
|
+
return WINDOWS_DEFAULT_TIMEOUT;
|
|
976
|
+
case 'macos':
|
|
977
|
+
return MACOS_DEFAULT_TIMEOUT;
|
|
978
|
+
default:
|
|
979
|
+
return WINDOWS_DEFAULT_TIMEOUT;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
function isDocumentHidden() {
|
|
983
|
+
var top = getTopmostWindow();
|
|
984
|
+
var topDocument = top.document;
|
|
985
|
+
if (topDocument.visibilityState === 'hidden')
|
|
986
|
+
return true;
|
|
987
|
+
if (topDocument.webkitVisibilityState === 'hidden')
|
|
988
|
+
return true;
|
|
989
|
+
if (topDocument.mozVisibilityState === 'hidden')
|
|
990
|
+
return true;
|
|
991
|
+
if (topDocument.msVisibilityState === 'hidden')
|
|
992
|
+
return true;
|
|
993
|
+
if (typeof topDocument.hidden !== 'undefined')
|
|
994
|
+
return topDocument.hidden;
|
|
995
|
+
if (typeof topDocument.webkitHidden !== 'undefined')
|
|
996
|
+
return topDocument.webkitHidden;
|
|
997
|
+
if (typeof topDocument.mozHidden !== 'undefined')
|
|
998
|
+
return topDocument.mozHidden;
|
|
999
|
+
if (typeof topDocument.msHidden !== 'undefined')
|
|
1000
|
+
return topDocument.msHidden;
|
|
1001
|
+
if (typeof topDocument.hasFocus === 'function')
|
|
1002
|
+
return !topDocument.hasFocus();
|
|
1003
|
+
return true;
|
|
1004
|
+
}
|
|
1005
|
+
function dispatchClickEvent(element, view) {
|
|
1006
|
+
if (view === void 0) { view = globalThis; }
|
|
1007
|
+
var fake;
|
|
1008
|
+
try {
|
|
1009
|
+
fake = new MouseEvent('click', {
|
|
1010
|
+
bubbles: true,
|
|
1011
|
+
cancelable: true,
|
|
1012
|
+
view: view
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
catch (_) {
|
|
1016
|
+
fake = globalThis.document.createEvent('MouseEvents');
|
|
1017
|
+
fake.initMouseEvent('click', true, true, view, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
1018
|
+
}
|
|
1019
|
+
element.dispatchEvent(fake);
|
|
1020
|
+
}
|
|
1021
|
+
function hasFocus(document) {
|
|
1022
|
+
if (typeof document.hasFocus === 'function')
|
|
1023
|
+
return document.hasFocus();
|
|
1024
|
+
return false;
|
|
1025
|
+
}
|
|
1026
|
+
function focus(target) {
|
|
1027
|
+
try {
|
|
1028
|
+
target.focus({ preventScroll: true });
|
|
1029
|
+
}
|
|
1030
|
+
catch (_) {
|
|
1031
|
+
try {
|
|
1032
|
+
target.focus();
|
|
1033
|
+
}
|
|
1034
|
+
catch (_) {
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
function restoreFocus() {
|
|
1039
|
+
var top = getTopmostWindow();
|
|
1040
|
+
var topDocument = top.document;
|
|
1041
|
+
focus(top);
|
|
1042
|
+
if (hasFocus(topDocument))
|
|
1043
|
+
return true;
|
|
1044
|
+
if (topDocument.body.tabIndex < 0)
|
|
1045
|
+
topDocument.body.tabIndex = -1;
|
|
1046
|
+
focus(topDocument.body);
|
|
1047
|
+
if (hasFocus(topDocument))
|
|
1048
|
+
return true;
|
|
1049
|
+
var input = undefined;
|
|
1050
|
+
try {
|
|
1051
|
+
input = createHiddenElement('input');
|
|
1052
|
+
if (typeof input === 'undefined')
|
|
1053
|
+
return false;
|
|
1054
|
+
input.type = 'text';
|
|
1055
|
+
input.readOnly = true;
|
|
1056
|
+
topDocument.body.appendChild(input);
|
|
1057
|
+
focus(input);
|
|
1058
|
+
try {
|
|
1059
|
+
input.select();
|
|
1060
|
+
}
|
|
1061
|
+
catch (_) {
|
|
1062
|
+
}
|
|
1063
|
+
if (hasFocus(topDocument))
|
|
1064
|
+
return true;
|
|
1065
|
+
}
|
|
1066
|
+
catch (_) {
|
|
1067
|
+
}
|
|
1068
|
+
finally {
|
|
1069
|
+
if (typeof input !== 'undefined' && input !== null) {
|
|
1070
|
+
try {
|
|
1071
|
+
input.blur();
|
|
1072
|
+
}
|
|
1073
|
+
catch (_) {
|
|
1074
|
+
}
|
|
1075
|
+
try {
|
|
1076
|
+
topDocument.body.removeChild(input);
|
|
1077
|
+
}
|
|
1078
|
+
catch (_) {
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
return hasFocus(topDocument);
|
|
1083
|
+
}
|
|
1084
|
+
function stripURL(value) {
|
|
1085
|
+
return typeof value === 'undefined' ? undefined : isURL(value) ? value.toString() : value;
|
|
1086
|
+
}
|
|
1087
|
+
function resolveFocusEventConfig() {
|
|
1088
|
+
var top = getTopmostWindow();
|
|
1089
|
+
var topDocument = top.document;
|
|
1090
|
+
if (typeof globalThis.cordova !== 'undefined') {
|
|
1091
|
+
return {
|
|
1092
|
+
focus: {
|
|
1093
|
+
target: topDocument,
|
|
1094
|
+
type: 'resume',
|
|
1095
|
+
},
|
|
1096
|
+
blur: {
|
|
1097
|
+
target: topDocument,
|
|
1098
|
+
type: 'pause',
|
|
1099
|
+
},
|
|
1100
|
+
visibilitychange: {}
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
else if (PlatformKit.os.name === 'ios') {
|
|
1104
|
+
if (PlatformKit.compareVersion(PlatformKit.os.version, '8.0') >= 0) {
|
|
1105
|
+
return {
|
|
1106
|
+
focus: {},
|
|
1107
|
+
blur: {},
|
|
1108
|
+
visibilitychange: {
|
|
1109
|
+
target: topDocument,
|
|
1110
|
+
type: 'visibilitychange',
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
else {
|
|
1115
|
+
return {
|
|
1116
|
+
focus: {
|
|
1117
|
+
target: top,
|
|
1118
|
+
type: 'pageshow',
|
|
1119
|
+
},
|
|
1120
|
+
blur: {
|
|
1121
|
+
target: top,
|
|
1122
|
+
type: 'pagehide',
|
|
1123
|
+
},
|
|
1124
|
+
visibilitychange: {}
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
else if (typeof globalThis.document.addEventListener === 'function') {
|
|
1129
|
+
return {
|
|
1130
|
+
focus: {
|
|
1131
|
+
target: top,
|
|
1132
|
+
type: 'focus',
|
|
1133
|
+
},
|
|
1134
|
+
blur: {
|
|
1135
|
+
target: top,
|
|
1136
|
+
type: 'blur',
|
|
1137
|
+
},
|
|
1138
|
+
visibilitychange: {
|
|
1139
|
+
target: topDocument,
|
|
1140
|
+
type: 'visibilitychange',
|
|
1141
|
+
}
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
else {
|
|
1145
|
+
return {
|
|
1146
|
+
focus: {
|
|
1147
|
+
target: topDocument,
|
|
1148
|
+
type: 'focus',
|
|
1149
|
+
},
|
|
1150
|
+
blur: {
|
|
1151
|
+
target: topDocument,
|
|
1152
|
+
type: 'blur',
|
|
1153
|
+
},
|
|
1154
|
+
visibilitychange: {
|
|
1155
|
+
target: topDocument,
|
|
1156
|
+
type: 'visibilitychange',
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
function openURL(tried, url, timeout) {
|
|
1162
|
+
var config = resolveFocusEventConfig();
|
|
1163
|
+
var top = getTopmostWindow();
|
|
1164
|
+
var topDocument = top.document;
|
|
1165
|
+
var anchor = undefined;
|
|
1166
|
+
var iframe = undefined;
|
|
1167
|
+
function open() {
|
|
1168
|
+
if (typeof globalThis.cordova !== 'undefined') {
|
|
1169
|
+
if (typeof globalThis.cordova.InAppBrowser !== 'undefined') {
|
|
1170
|
+
globalThis.cordova.InAppBrowser.open(url, '_system');
|
|
1171
|
+
}
|
|
1172
|
+
else {
|
|
1173
|
+
globalThis.open(url, '_system');
|
|
1174
|
+
}
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
if (isUserActivationActive() || tried === 0) {
|
|
1178
|
+
top.location.href = url;
|
|
1179
|
+
}
|
|
1180
|
+
else {
|
|
1181
|
+
try {
|
|
1182
|
+
anchor = createHiddenElement('a');
|
|
1183
|
+
anchor.href = url;
|
|
1184
|
+
topDocument.body.appendChild(anchor);
|
|
1185
|
+
dispatchClickEvent(anchor, top);
|
|
1186
|
+
}
|
|
1187
|
+
catch (_) {
|
|
1188
|
+
}
|
|
1189
|
+
finally {
|
|
1190
|
+
if (typeof anchor !== 'undefined') {
|
|
1191
|
+
try {
|
|
1192
|
+
topDocument.body.removeChild(anchor);
|
|
1193
|
+
}
|
|
1194
|
+
catch (_) {
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
try {
|
|
1200
|
+
iframe = createHiddenElement('iframe');
|
|
1201
|
+
iframe.src = url;
|
|
1202
|
+
topDocument.body.appendChild(iframe);
|
|
1203
|
+
globalThis.setTimeout(function () {
|
|
1204
|
+
if (typeof iframe !== 'undefined') {
|
|
1205
|
+
try {
|
|
1206
|
+
topDocument.body.removeChild(iframe);
|
|
1207
|
+
}
|
|
1208
|
+
catch (_) {
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}, 500);
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
catch (_) {
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
return new Promise(function (resolve, reject) {
|
|
1218
|
+
debugger;
|
|
1219
|
+
var timeoutId;
|
|
1220
|
+
var resolved = false;
|
|
1221
|
+
function cleanup() {
|
|
1222
|
+
if (typeof timeoutId !== 'undefined') {
|
|
1223
|
+
clearTimeout(timeoutId);
|
|
1224
|
+
timeoutId = undefined;
|
|
1225
|
+
}
|
|
1226
|
+
try {
|
|
1227
|
+
removeEvent(config.blur.target, config.blur.type, onblur);
|
|
1228
|
+
removeEvent(config.focus.target, config.focus.type, onfocus);
|
|
1229
|
+
removeEvent(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
|
|
1230
|
+
}
|
|
1231
|
+
catch (_) {
|
|
1232
|
+
}
|
|
1233
|
+
if (typeof anchor !== 'undefined') {
|
|
1234
|
+
try {
|
|
1235
|
+
topDocument.body.removeChild(anchor);
|
|
1236
|
+
}
|
|
1237
|
+
catch (_) {
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
if (typeof iframe !== 'undefined') {
|
|
1241
|
+
try {
|
|
1242
|
+
topDocument.body.removeChild(iframe);
|
|
1243
|
+
}
|
|
1244
|
+
catch (_) {
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
function done(success) {
|
|
1249
|
+
if (resolved)
|
|
1250
|
+
return;
|
|
1251
|
+
resolved = true;
|
|
1252
|
+
cleanup();
|
|
1253
|
+
if (success)
|
|
1254
|
+
resolve();
|
|
1255
|
+
else
|
|
1256
|
+
reject();
|
|
1257
|
+
}
|
|
1258
|
+
function onblur() {
|
|
1259
|
+
if (typeof timeoutId !== 'undefined') {
|
|
1260
|
+
clearTimeout(timeoutId);
|
|
1261
|
+
timeoutId = undefined;
|
|
1262
|
+
}
|
|
1263
|
+
removeEvent(config.blur.target, config.blur.type, onblur);
|
|
1264
|
+
addEvent(config.focus.target, config.focus.type, onfocus);
|
|
1265
|
+
}
|
|
1266
|
+
function onfocus() {
|
|
1267
|
+
done(true);
|
|
1268
|
+
}
|
|
1269
|
+
function onvisibilitychange() {
|
|
1270
|
+
if (isDocumentHidden())
|
|
1271
|
+
onblur();
|
|
1272
|
+
else
|
|
1273
|
+
onfocus();
|
|
1274
|
+
}
|
|
1275
|
+
timeoutId = globalThis.setTimeout(function () {
|
|
1276
|
+
done(false);
|
|
1277
|
+
}, timeout);
|
|
1278
|
+
addEvent(config.blur.target, config.blur.type, onblur);
|
|
1279
|
+
addEvent(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
|
|
1280
|
+
if (!hasFocus(topDocument))
|
|
1281
|
+
restoreFocus();
|
|
1282
|
+
try {
|
|
1283
|
+
open();
|
|
1284
|
+
}
|
|
1285
|
+
catch (_) {
|
|
1286
|
+
done(false);
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
function resolveOptions(option) {
|
|
1291
|
+
var resolved = [];
|
|
1292
|
+
var os = PlatformKit.os.name;
|
|
1293
|
+
if (os === 'unknown')
|
|
1294
|
+
throw new Error('Cannot resolve app open options: unsupported or undetected OS. (userAgent: "' + PlatformKit.userAgent + '")');
|
|
1295
|
+
var scheme;
|
|
1296
|
+
var fallback;
|
|
1297
|
+
var allowAppStore;
|
|
1298
|
+
var allowWebStore;
|
|
1299
|
+
var timeout;
|
|
1300
|
+
var intent;
|
|
1301
|
+
var packageName;
|
|
1302
|
+
var bundleId;
|
|
1303
|
+
var trackId;
|
|
1304
|
+
var universal;
|
|
1305
|
+
var packageFamilyName;
|
|
1306
|
+
var productId;
|
|
1307
|
+
switch (os) {
|
|
1308
|
+
case 'android':
|
|
1309
|
+
if (typeof option.android === 'undefined')
|
|
1310
|
+
return [[], 0];
|
|
1311
|
+
intent = stripURL(option.android.intent);
|
|
1312
|
+
scheme = stripURL(option.android.scheme);
|
|
1313
|
+
fallback = stripURL(option.android.fallback);
|
|
1314
|
+
packageName = option.android.packageName;
|
|
1315
|
+
allowAppStore = option.android.allowAppStore;
|
|
1316
|
+
allowWebStore = option.android.allowWebStore;
|
|
1317
|
+
timeout = option.android.timeout;
|
|
1318
|
+
if (typeof intent !== 'undefined' && (typeof scheme === 'undefined' || typeof packageName === 'undefined' || typeof fallback === 'undefined')) {
|
|
1319
|
+
var parsed = parseIntentURL(intent);
|
|
1320
|
+
if (typeof parsed.scheme !== 'undefined' && typeof scheme === 'undefined')
|
|
1321
|
+
scheme = parsed.scheme;
|
|
1322
|
+
if (typeof parsed.packageName !== 'undefined' && typeof packageName === 'undefined')
|
|
1323
|
+
packageName = parsed.packageName;
|
|
1324
|
+
if (typeof parsed.fallback !== 'undefined' && typeof fallback === 'undefined')
|
|
1325
|
+
fallback = parsed.fallback;
|
|
1326
|
+
}
|
|
1327
|
+
if (typeof scheme !== 'undefined' && typeof intent === 'undefined')
|
|
1328
|
+
intent = createIntentURL(scheme, packageName, fallback);
|
|
1329
|
+
if (typeof timeout === 'undefined')
|
|
1330
|
+
timeout = ANDROID_DEFAULT_TIMEOUT;
|
|
1331
|
+
if (typeof intent !== 'undefined' && canOpenIntent())
|
|
1332
|
+
resolved.push(['intent', intent]);
|
|
1333
|
+
if (typeof scheme !== 'undefined')
|
|
1334
|
+
resolved.push(['scheme', scheme]);
|
|
1335
|
+
if (typeof fallback !== 'undefined')
|
|
1336
|
+
resolved.push(['fallback', fallback]);
|
|
1337
|
+
if (typeof packageName !== 'undefined') {
|
|
1338
|
+
if (allowAppStore)
|
|
1339
|
+
resolved.push(['store', createAppStoreURL(packageName, os)]);
|
|
1340
|
+
if (allowWebStore)
|
|
1341
|
+
resolved.push(['store', createWebStoreURL(packageName, os)]);
|
|
1342
|
+
}
|
|
1343
|
+
return [resolved, timeout];
|
|
1344
|
+
case 'ios':
|
|
1345
|
+
if (typeof option.ios === 'undefined')
|
|
1346
|
+
return [[], 0];
|
|
1347
|
+
universal = stripURL(option.ios.universal);
|
|
1348
|
+
scheme = stripURL(option.ios.scheme);
|
|
1349
|
+
fallback = stripURL(option.ios.fallback);
|
|
1350
|
+
bundleId = option.ios.bundleId;
|
|
1351
|
+
trackId = option.ios.trackId;
|
|
1352
|
+
allowAppStore = option.ios.allowAppStore;
|
|
1353
|
+
allowWebStore = option.ios.allowWebStore;
|
|
1354
|
+
timeout = option.ios.timeout;
|
|
1355
|
+
if (typeof bundleId !== 'undefined' && typeof trackId === 'undefined')
|
|
1356
|
+
trackId = getTrackId(bundleId);
|
|
1357
|
+
if (typeof timeout === 'undefined')
|
|
1358
|
+
timeout = IOS_DEFAULT_TIMEOUT;
|
|
1359
|
+
if (typeof universal !== 'undefined' && canOpenUniversal())
|
|
1360
|
+
resolved.push(['universal', universal]);
|
|
1361
|
+
if (typeof scheme !== 'undefined')
|
|
1362
|
+
resolved.push(['scheme', scheme]);
|
|
1363
|
+
if (typeof fallback !== 'undefined')
|
|
1364
|
+
resolved.push(['fallback', fallback]);
|
|
1365
|
+
if (typeof trackId !== 'undefined') {
|
|
1366
|
+
if (allowAppStore)
|
|
1367
|
+
resolved.push(['store', createAppStoreURL(trackId, os)]);
|
|
1368
|
+
if (allowWebStore)
|
|
1369
|
+
resolved.push(['store', createWebStoreURL(trackId, os)]);
|
|
1370
|
+
}
|
|
1371
|
+
return [resolved, timeout];
|
|
1372
|
+
case 'windows':
|
|
1373
|
+
if (typeof option.windows === 'undefined')
|
|
1374
|
+
return [[], 0];
|
|
1375
|
+
scheme = stripURL(option.windows.scheme);
|
|
1376
|
+
fallback = stripURL(option.windows.fallback);
|
|
1377
|
+
packageFamilyName = option.windows.packageFamilyName;
|
|
1378
|
+
productId = option.windows.productId;
|
|
1379
|
+
allowAppStore = option.windows.allowAppStore;
|
|
1380
|
+
allowWebStore = option.windows.allowWebStore;
|
|
1381
|
+
timeout = option.windows.timeout;
|
|
1382
|
+
if (typeof packageFamilyName !== 'undefined' && typeof productId === 'undefined')
|
|
1383
|
+
productId = getProductId(packageFamilyName);
|
|
1384
|
+
if (typeof timeout === 'undefined')
|
|
1385
|
+
timeout = WINDOWS_DEFAULT_TIMEOUT;
|
|
1386
|
+
if (typeof scheme !== 'undefined')
|
|
1387
|
+
resolved.push(['scheme', scheme]);
|
|
1388
|
+
if (typeof fallback !== 'undefined')
|
|
1389
|
+
resolved.push(['fallback', fallback]);
|
|
1390
|
+
if (typeof productId !== 'undefined') {
|
|
1391
|
+
if (allowAppStore)
|
|
1392
|
+
resolved.push(['store', createAppStoreURL(productId, os)]);
|
|
1393
|
+
if (allowWebStore)
|
|
1394
|
+
resolved.push(['store', createWebStoreURL(productId, os)]);
|
|
1395
|
+
}
|
|
1396
|
+
return [resolved, timeout];
|
|
1397
|
+
case 'macos':
|
|
1398
|
+
if (typeof option.macos === 'undefined')
|
|
1399
|
+
return [[], 0];
|
|
1400
|
+
scheme = stripURL(option.macos.scheme);
|
|
1401
|
+
fallback = stripURL(option.macos.fallback);
|
|
1402
|
+
bundleId = option.macos.bundleId;
|
|
1403
|
+
trackId = option.macos.trackId;
|
|
1404
|
+
allowAppStore = option.macos.allowAppStore;
|
|
1405
|
+
allowWebStore = option.macos.allowWebStore;
|
|
1406
|
+
timeout = option.macos.timeout;
|
|
1407
|
+
if (typeof bundleId !== 'undefined' && typeof trackId === 'undefined')
|
|
1408
|
+
trackId = getTrackId(bundleId);
|
|
1409
|
+
if (typeof timeout === 'undefined')
|
|
1410
|
+
timeout = MACOS_DEFAULT_TIMEOUT;
|
|
1411
|
+
if (typeof scheme !== 'undefined')
|
|
1412
|
+
resolved.push(['scheme', scheme]);
|
|
1413
|
+
if (typeof fallback !== 'undefined')
|
|
1414
|
+
resolved.push(['fallback', fallback]);
|
|
1415
|
+
if (typeof trackId !== 'undefined') {
|
|
1416
|
+
if (allowAppStore)
|
|
1417
|
+
resolved.push(['store', createAppStoreURL(trackId, os)]);
|
|
1418
|
+
if (allowWebStore)
|
|
1419
|
+
resolved.push(['store', createWebStoreURL(trackId, os)]);
|
|
1420
|
+
}
|
|
1421
|
+
return [resolved, timeout];
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
function canOpenIntent() {
|
|
1425
|
+
if (PlatformKit.os.name !== 'android')
|
|
1426
|
+
return false;
|
|
1427
|
+
var browser = PlatformKit.browser.name;
|
|
1428
|
+
var version = PlatformKit.browser.version;
|
|
1429
|
+
if (browser === 'firefox' && PlatformKit.compareVersion(version, '41.0') < 0)
|
|
1430
|
+
return false;
|
|
1431
|
+
if (browser === 'firefox' && PlatformKit.compareVersion(version, '59.0') >= 0 && PlatformKit.compareVersion(version, '68.11.0') < 0)
|
|
1432
|
+
return false;
|
|
1433
|
+
if (browser === 'firefox' && PlatformKit.compareVersion(version, '80.0') >= 0 && PlatformKit.compareVersion(version, '82.0') < 0)
|
|
1434
|
+
return false;
|
|
1435
|
+
if (browser === 'firefox' && PlatformKit.compareVersion(version, '96.0') >= 0 && PlatformKit.compareVersion(version, '107.0') < 0)
|
|
1436
|
+
return false;
|
|
1437
|
+
if (browser === 'opera' && PlatformKit.compareVersion(version, '14.0') < 0)
|
|
1438
|
+
return false;
|
|
1439
|
+
return !(/(?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/[\w.]+;/i.test(PlatformKit.userAgent) || /instagram[\/ ][-\w.]+/i.test(PlatformKit.userAgent) || /micromessenger\/([\w.]+)/i.test(PlatformKit.userAgent) || /musical_ly(?:.+app_?version\/|_)[\w.]+/i.test(PlatformKit.userAgent) || /ultralite app_version\/[\w.]+/i.test(PlatformKit.userAgent));
|
|
1440
|
+
}
|
|
1441
|
+
function canOpenUniversal() {
|
|
1442
|
+
return PlatformKit.os.name === 'ios' && PlatformKit.compareVersion(PlatformKit.os.version, '9.0') >= 0;
|
|
1443
|
+
}
|
|
1444
|
+
function canOpenSetting() {
|
|
1445
|
+
var os = PlatformKit.os.name;
|
|
1446
|
+
var version = PlatformKit.os.version;
|
|
1447
|
+
return !(os === 'unknown'
|
|
1448
|
+
|| (os === 'android' && !canOpenIntent())
|
|
1449
|
+
|| os === 'ios'
|
|
1450
|
+
|| (os === 'windows' && (version === 'Vista' || version === 'XP' || version === '2000' || version === 'NT 4.0' || version === 'NT 3.11' || version === 'ME' || PlatformKit.compareVersion(version, '10') < 0))
|
|
1451
|
+
|| (os === 'macos' && PlatformKit.compareVersion(version, '10.10') < 0));
|
|
1452
|
+
}
|
|
1453
|
+
function parseIntentURL(intent) {
|
|
1454
|
+
var parsed = {};
|
|
1455
|
+
var split = intent.split('#Intent;');
|
|
1456
|
+
if (split.length !== 2)
|
|
1457
|
+
return parsed;
|
|
1458
|
+
var host = split[0].replace(/^intent:\/\//i, '');
|
|
1459
|
+
var parameterString = split[1].replace(/;?end\s*$/i, '');
|
|
1460
|
+
var parameters = parameterString.split(';');
|
|
1461
|
+
var extras = {};
|
|
1462
|
+
for (var i = 0; i < parameters.length; i++) {
|
|
1463
|
+
var part = parameters[i];
|
|
1464
|
+
var index = part.indexOf('=');
|
|
1465
|
+
if (index !== -1)
|
|
1466
|
+
extras[part.substring(0, index)] = part.substring(index + 1);
|
|
1467
|
+
}
|
|
1468
|
+
if (typeof extras['scheme'] !== 'undefined') {
|
|
1469
|
+
if (host.length > 0)
|
|
1470
|
+
parsed.scheme = extras['scheme'] + '://' + host;
|
|
1471
|
+
else
|
|
1472
|
+
parsed.scheme = extras['scheme'] + '://';
|
|
1473
|
+
}
|
|
1474
|
+
if (typeof extras['package'] !== 'undefined')
|
|
1475
|
+
parsed.packageName = extras['package'];
|
|
1476
|
+
if (typeof extras['S.browser_fallback_url'] !== 'undefined') {
|
|
1477
|
+
var fallback = extras['S.browser_fallback_url'];
|
|
1478
|
+
try {
|
|
1479
|
+
fallback = globalThis.decodeURIComponent(fallback);
|
|
1480
|
+
}
|
|
1481
|
+
catch (_) {
|
|
1482
|
+
}
|
|
1483
|
+
if (/^https?:\/\//i.test(fallback))
|
|
1484
|
+
parsed.fallback = fallback;
|
|
1485
|
+
}
|
|
1486
|
+
return parsed;
|
|
1487
|
+
}
|
|
1488
|
+
function createIntentURL(scheme, packageName, fallback) {
|
|
1489
|
+
var split = scheme.split('://');
|
|
1490
|
+
var prefix = split[0];
|
|
1491
|
+
var suffix = split[1];
|
|
1492
|
+
var intent = 'intent://';
|
|
1493
|
+
if (typeof suffix !== 'undefined')
|
|
1494
|
+
intent += suffix;
|
|
1495
|
+
intent += '#Intent;scheme=' + prefix + ';' + 'action=android.intent.action.VIEW;category=android.intent.category.BROWSABLE;';
|
|
1496
|
+
if (typeof packageName !== 'undefined')
|
|
1497
|
+
intent += 'package=' + packageName + ';';
|
|
1498
|
+
if (typeof fallback !== 'undefined' && typeof fallback === 'string')
|
|
1499
|
+
intent += 'S.browser_fallback_url=' + globalThis.encodeURIComponent(fallback) + ';';
|
|
1500
|
+
else if (typeof packageName !== 'undefined')
|
|
1501
|
+
intent += 'S.browser_fallback_url=' + globalThis.encodeURIComponent(createAppStoreURL(packageName, 'android')) + ';';
|
|
1502
|
+
return intent + 'end';
|
|
1503
|
+
}
|
|
1504
|
+
function createAppStoreURL(id, os) {
|
|
1505
|
+
switch (os) {
|
|
1506
|
+
case 'android':
|
|
1507
|
+
return 'market://details?id=' + id;
|
|
1508
|
+
case 'ios':
|
|
1509
|
+
return 'itms-apps://itunes.apple.com/app/id' + id + '?mt=8';
|
|
1510
|
+
case 'windows':
|
|
1511
|
+
return 'ms-windows-store://pdp/?ProductId=' + id;
|
|
1512
|
+
case 'macos':
|
|
1513
|
+
return 'macappstore://itunes.apple.com/app/id' + id + '?mt=12';
|
|
1514
|
+
default:
|
|
1515
|
+
return os;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
function createWebStoreURL(id, os) {
|
|
1519
|
+
switch (os) {
|
|
1520
|
+
case 'android':
|
|
1521
|
+
return 'https://play.google.com/store/apps/details?id=' + id;
|
|
1522
|
+
case 'ios':
|
|
1523
|
+
return 'https://itunes.apple.com/app/id' + id + '?mt=8';
|
|
1524
|
+
case 'windows':
|
|
1525
|
+
return 'https://apps.microsoft.com/detail/' + id;
|
|
1526
|
+
case 'macos':
|
|
1527
|
+
return 'https://apps.apple.com/app/id' + id + '?mt=12';
|
|
1528
|
+
default:
|
|
1529
|
+
return os;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
function escapeURIComponentString(value) {
|
|
1533
|
+
return globalThis.encodeURIComponent(value)
|
|
1534
|
+
.replace(/[!'()*]/g, function (char) {
|
|
1535
|
+
return '%' + char.charCodeAt(0).toString(16);
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
function sanitizeSMSRecipient(value) {
|
|
1539
|
+
return value.replace(/[^\d+\-.]/g, '');
|
|
1540
|
+
}
|
|
1541
|
+
function escapeURIComponentMailAddressString(value) {
|
|
1542
|
+
return escapeURIComponentString(value)
|
|
1543
|
+
.replace(/%40/g, '@')
|
|
1544
|
+
.replace(/%2C/gi, ',');
|
|
1545
|
+
}
|
|
1546
|
+
function encodeMailBody(value) {
|
|
1547
|
+
return escapeURIComponentString(value.replace(/\r\n|\n|\r/g, '\r\n'));
|
|
1548
|
+
}
|
|
1549
|
+
function toArray(value) {
|
|
1550
|
+
return typeof value === 'undefined' ? [] : typeof value === 'string' ? [value] : value;
|
|
1551
|
+
}
|
|
1552
|
+
function joining(values, mapfn, separator) {
|
|
1553
|
+
if (mapfn === void 0) { mapfn = undefined; }
|
|
1554
|
+
if (separator === void 0) { separator = ','; }
|
|
1555
|
+
var length = values.length;
|
|
1556
|
+
var result = '';
|
|
1557
|
+
for (var i = 0; i < length; i++) {
|
|
1558
|
+
if (i !== 0)
|
|
1559
|
+
result += separator;
|
|
1560
|
+
if (typeof mapfn !== 'undefined')
|
|
1561
|
+
result += mapfn(values[i]);
|
|
1562
|
+
else
|
|
1563
|
+
result += values[i];
|
|
1564
|
+
}
|
|
1565
|
+
return result;
|
|
1566
|
+
}
|
|
1567
|
+
function tokenize(string) {
|
|
1568
|
+
if (string === '')
|
|
1569
|
+
return [];
|
|
1570
|
+
return string
|
|
1571
|
+
.split(/\s*[,,]\s*/)
|
|
1572
|
+
.filter(function (string) {
|
|
1573
|
+
return string !== '';
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
function flatten(arrays) {
|
|
1577
|
+
var result = [];
|
|
1578
|
+
for (var i = 0; i < arrays.length; i++) {
|
|
1579
|
+
var sub = arrays[i];
|
|
1580
|
+
for (var j = 0; j < sub.length; j++) {
|
|
1581
|
+
result.push(sub[j]);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
return result;
|
|
1585
|
+
}
|
|
1586
|
+
function isUserActivationActive() {
|
|
1587
|
+
return typeof NAVIGATOR !== 'undefined' && typeof NAVIGATOR.userActivation !== 'undefined' && NAVIGATOR.userActivation.isActive;
|
|
1588
|
+
}
|
|
1589
|
+
function canShowDirectoryPicker() {
|
|
1590
|
+
return typeof globalThis.showDirectoryPicker === 'function';
|
|
1591
|
+
}
|
|
1592
|
+
function canShowOpenFilePicker() {
|
|
1593
|
+
return typeof globalThis.showOpenFilePicker === 'function';
|
|
1594
|
+
}
|
|
1595
|
+
function isFileSystemFileHandle(handle) {
|
|
1596
|
+
return handle.kind === 'file';
|
|
1597
|
+
}
|
|
1598
|
+
function isFileSystemDirectoryHandle(handle) {
|
|
1599
|
+
return handle.kind === 'directory';
|
|
1600
|
+
}
|
|
1601
|
+
function fileListToArray(fileList) {
|
|
1602
|
+
var files = [];
|
|
1603
|
+
if (fileList === null)
|
|
1604
|
+
return files;
|
|
1605
|
+
for (var i = 0; i < fileList.length; i++) {
|
|
1606
|
+
var file = fileList[i];
|
|
1607
|
+
files.push(file);
|
|
1608
|
+
}
|
|
1609
|
+
return files;
|
|
1610
|
+
}
|
|
1611
|
+
function setWebkitRelativePath(file, path) {
|
|
1612
|
+
if (path === void 0) { path = file.webkitRelativePath; }
|
|
1613
|
+
Object.defineProperty(file, 'webkitRelativePath', {
|
|
1614
|
+
value: path,
|
|
1615
|
+
writable: false,
|
|
1616
|
+
configurable: true,
|
|
1617
|
+
enumerable: true,
|
|
1618
|
+
});
|
|
1619
|
+
return file;
|
|
1620
|
+
}
|
|
1621
|
+
function resolveFile(module) {
|
|
1622
|
+
var top = getTopmostWindow();
|
|
1623
|
+
var topDocument = top.document;
|
|
1624
|
+
var config = resolveFocusEventConfig();
|
|
1625
|
+
function resolveFileSystemHandle(module, resolve, reject) {
|
|
1626
|
+
module
|
|
1627
|
+
.then(function (result) {
|
|
1628
|
+
if (isArray(result)) {
|
|
1629
|
+
var handles = [];
|
|
1630
|
+
for (var i = 0; i < result.length; i++)
|
|
1631
|
+
handles[i] = result[i].getFile();
|
|
1632
|
+
return Promise
|
|
1633
|
+
.all(handles)
|
|
1634
|
+
.then(resolve)
|
|
1635
|
+
.catch(reject);
|
|
1636
|
+
}
|
|
1637
|
+
else if (isFileSystemDirectoryHandle(result)) {
|
|
1638
|
+
return walk(result, result.name)
|
|
1639
|
+
.then(resolve)
|
|
1640
|
+
.catch(reject);
|
|
1641
|
+
}
|
|
1642
|
+
})
|
|
1643
|
+
.catch(function (error) {
|
|
1644
|
+
if (isDOMException(error) && error.name === 'AbortError')
|
|
1645
|
+
return resolve([]);
|
|
1646
|
+
reject(error);
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
function resolveInput(module, resolve) {
|
|
1650
|
+
var resolved = false;
|
|
1651
|
+
function done(success) {
|
|
1652
|
+
if (resolved)
|
|
1653
|
+
return;
|
|
1654
|
+
resolved = true;
|
|
1655
|
+
cleanup();
|
|
1656
|
+
if (!success)
|
|
1657
|
+
return resolve([]);
|
|
1658
|
+
resolve(fileListToArray(module.files));
|
|
1659
|
+
}
|
|
1660
|
+
function onfocus() {
|
|
1661
|
+
globalThis.setTimeout(function () {
|
|
1662
|
+
if (module.value.length > 0)
|
|
1663
|
+
done(true);
|
|
1664
|
+
else
|
|
1665
|
+
done(false);
|
|
1666
|
+
}, 1000);
|
|
1667
|
+
}
|
|
1668
|
+
function onvisibilitychange() {
|
|
1669
|
+
if (!isDocumentHidden())
|
|
1670
|
+
onfocus();
|
|
1671
|
+
}
|
|
1672
|
+
function onclick() {
|
|
1673
|
+
done(false);
|
|
1674
|
+
}
|
|
1675
|
+
module.onchange = function () {
|
|
1676
|
+
done(true);
|
|
1677
|
+
};
|
|
1678
|
+
if (CLEANUP_INPUT_ELEMENT !== null)
|
|
1679
|
+
CLEANUP_INPUT_ELEMENT();
|
|
1680
|
+
if (typeof module.oncancel !== 'undefined') {
|
|
1681
|
+
module.oncancel = function () {
|
|
1682
|
+
done(false);
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
else {
|
|
1686
|
+
module.onclick = function () {
|
|
1687
|
+
addEvent(config.focus.target, config.focus.type, onfocus);
|
|
1688
|
+
addEvent(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
|
|
1689
|
+
globalThis.setTimeout(function () {
|
|
1690
|
+
addEvent(topDocument, 'click', onclick);
|
|
1691
|
+
}, 100);
|
|
1692
|
+
CLEANUP_INPUT_ELEMENT = function () {
|
|
1693
|
+
done(false);
|
|
1694
|
+
};
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
function cleanup() {
|
|
1698
|
+
CLEANUP_INPUT_ELEMENT = null;
|
|
1699
|
+
try {
|
|
1700
|
+
removeEvent(config.focus.target, config.focus.type, onfocus);
|
|
1701
|
+
removeEvent(config.visibilitychange.target, config.visibilitychange.type, onvisibilitychange);
|
|
1702
|
+
removeEvent(topDocument, 'click', onclick);
|
|
1703
|
+
}
|
|
1704
|
+
catch (_) {
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
dispatchClickEvent(module);
|
|
1708
|
+
}
|
|
1709
|
+
return new Promise(function (resolve, reject) {
|
|
1710
|
+
if (isPromise(module))
|
|
1711
|
+
return resolveFileSystemHandle(module, resolve, reject);
|
|
1712
|
+
else if (isHTMLInputElementLike(module))
|
|
1713
|
+
return resolveInput(module, resolve);
|
|
1714
|
+
else
|
|
1715
|
+
reject(new TypeError('resolveFile expects an HTMLInputElement or a file-system handle Promise, but received: ' + Object.prototype.toString.call(module)));
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
function walk(directory, basePath) {
|
|
1719
|
+
if (basePath === void 0) { basePath = ''; }
|
|
1720
|
+
return new Promise(function (resolve, reject) {
|
|
1721
|
+
var iterator = directory.values();
|
|
1722
|
+
var handles = [];
|
|
1723
|
+
function collectNext() {
|
|
1724
|
+
iterator
|
|
1725
|
+
.next()
|
|
1726
|
+
.then(function (result) {
|
|
1727
|
+
if (result.done) {
|
|
1728
|
+
processHandles();
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
handles.push(result.value);
|
|
1732
|
+
collectNext();
|
|
1733
|
+
})
|
|
1734
|
+
.catch(reject);
|
|
1735
|
+
}
|
|
1736
|
+
function processHandles() {
|
|
1737
|
+
var promises = [];
|
|
1738
|
+
var _loop_1 = function (i) {
|
|
1739
|
+
var handle = handles[i];
|
|
1740
|
+
var name_1 = handle.name;
|
|
1741
|
+
var path;
|
|
1742
|
+
if (basePath === '')
|
|
1743
|
+
path = name_1;
|
|
1744
|
+
else
|
|
1745
|
+
path = basePath + '/' + name_1;
|
|
1746
|
+
if (isFileSystemFileHandle(handle)) {
|
|
1747
|
+
var filePromise = handle
|
|
1748
|
+
.getFile()
|
|
1749
|
+
.then(function (file) {
|
|
1750
|
+
return [setWebkitRelativePath(file, path)];
|
|
1751
|
+
});
|
|
1752
|
+
promises.push(filePromise);
|
|
1753
|
+
}
|
|
1754
|
+
else if (isFileSystemDirectoryHandle(handle)) {
|
|
1755
|
+
promises.push(walk(handle, path));
|
|
1756
|
+
}
|
|
1757
|
+
};
|
|
1758
|
+
for (var i = 0; i < handles.length; i++) {
|
|
1759
|
+
_loop_1(i);
|
|
1760
|
+
}
|
|
1761
|
+
Promise
|
|
1762
|
+
.all(promises)
|
|
1763
|
+
.then(flatten)
|
|
1764
|
+
.then(resolve)
|
|
1765
|
+
.catch(reject);
|
|
1766
|
+
}
|
|
1767
|
+
collectNext();
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
var LaunchKit = {
|
|
1771
|
+
SettingType: exports.SettingType,
|
|
1772
|
+
version: packageJSON$1.version,
|
|
1773
|
+
utils: {
|
|
1774
|
+
get canOpenIntent() {
|
|
1775
|
+
return canOpenIntent();
|
|
1776
|
+
},
|
|
1777
|
+
get canOpenUniversal() {
|
|
1778
|
+
return canOpenUniversal();
|
|
1779
|
+
},
|
|
1780
|
+
get canOpenSetting() {
|
|
1781
|
+
return canOpenSetting();
|
|
1782
|
+
},
|
|
1783
|
+
getTrackId: getTrackIdAsync,
|
|
1784
|
+
getProductId: getProductIdAsync,
|
|
1785
|
+
},
|
|
1786
|
+
app: function (options) {
|
|
1787
|
+
if (options === void 0) { options = {}; }
|
|
1788
|
+
var resolved;
|
|
1789
|
+
try {
|
|
1790
|
+
resolved = resolveOptions(options);
|
|
1791
|
+
}
|
|
1792
|
+
catch (error) {
|
|
1793
|
+
return Promise.reject(error);
|
|
1794
|
+
}
|
|
1795
|
+
var tried = [];
|
|
1796
|
+
var urls = resolved[0];
|
|
1797
|
+
var timeout = resolved[1];
|
|
1798
|
+
if (urls.length === 0)
|
|
1799
|
+
return Promise.reject(new Error('No openable URL candidates were resolved for the current OS ("' + PlatformKit.os.name + '"). Provide at least one of: scheme, intent, universal, fallback, or store id for this platform.'));
|
|
1800
|
+
return new Promise(function (resolve, reject) {
|
|
1801
|
+
function openURLSequential(index) {
|
|
1802
|
+
if (index === void 0) { index = 0; }
|
|
1803
|
+
if (index >= urls.length)
|
|
1804
|
+
return reject(new Error('Failed to open the application using all available URLs.\n\n' + 'Attempted URLs:\n' + joining(tried, undefined, '\n↓\n')));
|
|
1805
|
+
var entry = urls[index];
|
|
1806
|
+
var by = entry[0];
|
|
1807
|
+
var url = entry[1];
|
|
1808
|
+
if (typeof url === 'string') {
|
|
1809
|
+
tried[index] = url;
|
|
1810
|
+
return openURL(index, url, timeout)
|
|
1811
|
+
.then(function () {
|
|
1812
|
+
resolve(by);
|
|
1813
|
+
})
|
|
1814
|
+
.catch(function () {
|
|
1815
|
+
openURLSequential(index + 1);
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
else {
|
|
1819
|
+
tried[index] = '[function fallback]';
|
|
1820
|
+
url();
|
|
1821
|
+
resolve(by);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
return openURLSequential();
|
|
1825
|
+
});
|
|
1826
|
+
},
|
|
1827
|
+
telephone: function (options) {
|
|
1828
|
+
if (options === void 0) { options = {}; }
|
|
1829
|
+
var url = 'tel:';
|
|
1830
|
+
if (typeof options.to !== 'undefined')
|
|
1831
|
+
url += options.to.replace(/[^\d+*#]/g, '');
|
|
1832
|
+
return openURL(0, url, getDefaultTimeout());
|
|
1833
|
+
},
|
|
1834
|
+
message: function (options) {
|
|
1835
|
+
if (options === void 0) { options = {}; }
|
|
1836
|
+
var to = toArray(options.to);
|
|
1837
|
+
var url = 'sms:';
|
|
1838
|
+
if (to.length > 0)
|
|
1839
|
+
url += joining(to, sanitizeSMSRecipient);
|
|
1840
|
+
if (typeof options.body !== 'undefined') {
|
|
1841
|
+
if (PlatformKit.os.name !== 'ios')
|
|
1842
|
+
url += '?';
|
|
1843
|
+
else if (PlatformKit.compareVersion(PlatformKit.os.version, '8.0') >= 0)
|
|
1844
|
+
url += '&';
|
|
1845
|
+
else
|
|
1846
|
+
url += ';';
|
|
1847
|
+
url += 'body=' + escapeURIComponentString(options.body);
|
|
1848
|
+
}
|
|
1849
|
+
return openURL(0, url, getDefaultTimeout());
|
|
1850
|
+
},
|
|
1851
|
+
mail: function (options) {
|
|
1852
|
+
if (options === void 0) { options = {}; }
|
|
1853
|
+
var params = [];
|
|
1854
|
+
var to = toArray(options.to);
|
|
1855
|
+
var cc = toArray(options.cc);
|
|
1856
|
+
var bcc = toArray(options.bcc);
|
|
1857
|
+
var url = 'mailto:';
|
|
1858
|
+
if (to.length > 0)
|
|
1859
|
+
url += joining(to, escapeURIComponentMailAddressString);
|
|
1860
|
+
if (cc.length > 0)
|
|
1861
|
+
params.push('cc=' + joining(cc, escapeURIComponentMailAddressString));
|
|
1862
|
+
if (bcc.length > 0)
|
|
1863
|
+
params.push('bcc=' + joining(bcc, escapeURIComponentMailAddressString));
|
|
1864
|
+
if (typeof options.subject === 'string')
|
|
1865
|
+
params.push('subject=' + escapeURIComponentString(options.subject));
|
|
1866
|
+
if (typeof options.body === 'string')
|
|
1867
|
+
params.push('body=' + encodeMailBody(options.body));
|
|
1868
|
+
if (params.length > 0)
|
|
1869
|
+
url += '?' + joining(params, undefined, '&');
|
|
1870
|
+
return openURL(0, url, getDefaultTimeout());
|
|
1871
|
+
},
|
|
1872
|
+
filepicker: function (options) {
|
|
1873
|
+
if (options === void 0) { options = {}; }
|
|
1874
|
+
var module;
|
|
1875
|
+
var accepts = [];
|
|
1876
|
+
if (isArray(options.accept))
|
|
1877
|
+
accepts = options.accept;
|
|
1878
|
+
else if (typeof options.accept === 'string')
|
|
1879
|
+
accepts = tokenize(options.accept);
|
|
1880
|
+
if (options.directory) {
|
|
1881
|
+
if (canShowDirectoryPicker()) {
|
|
1882
|
+
var option = { mode: 'read' };
|
|
1883
|
+
if (typeof options.id !== 'undefined')
|
|
1884
|
+
option.id = options.id;
|
|
1885
|
+
if (typeof options.startIn !== 'undefined')
|
|
1886
|
+
option.startIn = options.startIn;
|
|
1887
|
+
module = globalThis.showDirectoryPicker(option);
|
|
1888
|
+
}
|
|
1889
|
+
else {
|
|
1890
|
+
var input = createHiddenElement('input');
|
|
1891
|
+
input.type = 'file';
|
|
1892
|
+
input.webkitdirectory = true;
|
|
1893
|
+
input.accept = accepts.join(',');
|
|
1894
|
+
module = input;
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
else {
|
|
1898
|
+
if (canShowOpenFilePicker()) {
|
|
1899
|
+
var option = {};
|
|
1900
|
+
if (typeof options.id !== 'undefined')
|
|
1901
|
+
option.id = options.id;
|
|
1902
|
+
if (typeof options.startIn !== 'undefined')
|
|
1903
|
+
option.startIn = options.startIn;
|
|
1904
|
+
if (typeof options.multiple !== 'undefined')
|
|
1905
|
+
option.multiple = options.multiple;
|
|
1906
|
+
if (accepts.length > 0) {
|
|
1907
|
+
var acceptObject = {};
|
|
1908
|
+
option.excludeAcceptAllOption = true;
|
|
1909
|
+
option.types = [{
|
|
1910
|
+
description: '',
|
|
1911
|
+
accept: acceptObject,
|
|
1912
|
+
}];
|
|
1913
|
+
for (var i = 0; i < accepts.length; i++) {
|
|
1914
|
+
var accept = accepts[i];
|
|
1915
|
+
if (accept.startsWith('.')) {
|
|
1916
|
+
if (typeof acceptObject['application/octet-stream'] === 'undefined')
|
|
1917
|
+
acceptObject['application/octet-stream'] = [];
|
|
1918
|
+
acceptObject['application/octet-stream'].push(accept);
|
|
1919
|
+
}
|
|
1920
|
+
else if (accept.includes('/')) {
|
|
1921
|
+
acceptObject[accept] = [];
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
module = globalThis.showOpenFilePicker(option);
|
|
1926
|
+
}
|
|
1927
|
+
else {
|
|
1928
|
+
var input = createHiddenElement('input');
|
|
1929
|
+
input.type = 'file';
|
|
1930
|
+
input.accept = accepts.join(',');
|
|
1931
|
+
if (typeof options.multiple !== 'undefined')
|
|
1932
|
+
input.multiple = options.multiple;
|
|
1933
|
+
module = input;
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
return resolveFile(module);
|
|
1937
|
+
},
|
|
1938
|
+
setting: function (type) {
|
|
1939
|
+
if (type === void 0) { type = exports.SettingType.General; }
|
|
1940
|
+
var os = PlatformKit.os.name;
|
|
1941
|
+
var version = PlatformKit.os.version;
|
|
1942
|
+
var urls = [];
|
|
1943
|
+
if (!canOpenSetting())
|
|
1944
|
+
return Promise.reject(new Error('Opening system settings is not supported on this platform. (userAgent: "' + PlatformKit.userAgent + '")'));
|
|
1945
|
+
switch (os) {
|
|
1946
|
+
case 'android':
|
|
1947
|
+
if ((type === 'accessibility' && PlatformKit.compareVersion(version, '2.0') < 0)
|
|
1948
|
+
|| (type === 'battery' && PlatformKit.compareVersion(version, '5.1') < 0)
|
|
1949
|
+
|| (type === 'accounts' && PlatformKit.compareVersion(version, '1.5') < 0)
|
|
1950
|
+
|| (type === 'storage' && PlatformKit.compareVersion(version, '1.5') < 0)
|
|
1951
|
+
|| type === 'general') {
|
|
1952
|
+
urls.push(SETTING_URL.android.general);
|
|
1953
|
+
break;
|
|
1954
|
+
}
|
|
1955
|
+
urls.push(SETTING_URL.android[type]);
|
|
1956
|
+
urls.push(SETTING_URL.android.general);
|
|
1957
|
+
break;
|
|
1958
|
+
case 'windows':
|
|
1959
|
+
urls.push(SETTING_URL.windows[type]);
|
|
1960
|
+
break;
|
|
1961
|
+
case 'macos':
|
|
1962
|
+
if (type === 'appearance' && PlatformKit.compareVersion(version, '10.14') < 0)
|
|
1963
|
+
urls.push(SETTING_URL.macos.general);
|
|
1964
|
+
else if (PlatformKit.compareVersion(version, '13.0') < 0)
|
|
1965
|
+
urls.push(SETTING_URL.macos[type]);
|
|
1966
|
+
else
|
|
1967
|
+
urls.push(SETTING_URL.macos13[type]);
|
|
1968
|
+
}
|
|
1969
|
+
return new Promise(function (resolve, reject) {
|
|
1970
|
+
function openURLSequential(index) {
|
|
1971
|
+
if (index === void 0) { index = 0; }
|
|
1972
|
+
if (index >= urls.length)
|
|
1973
|
+
return reject(new Error('Failed to open the "' + type + '" settings pane using all available URLs.\n\nAttempted URLs:\n' + joining(urls, undefined, '\n↓\n')));
|
|
1974
|
+
return openURL(index, urls[index], SETTING_DEFAULT_TIMEOUT)
|
|
1975
|
+
.then(function () {
|
|
1976
|
+
resolve();
|
|
1977
|
+
})
|
|
1978
|
+
.catch(function () {
|
|
1979
|
+
openURLSequential(index + 1);
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
return openURLSequential();
|
|
1983
|
+
});
|
|
1984
|
+
},
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1987
|
+
exports.default = LaunchKit;
|
|
1988
|
+
|
|
1989
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1990
|
+
|
|
1991
|
+
}));
|
|
1992
|
+
//# sourceMappingURL=launch-kit.umd.js.map
|