native-fn 1.0.41 → 1.0.43
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 +380 -1
- package/dist/native.min.cjs +1 -1
- package/dist/native.min.mjs +1 -1
- package/dist/native.mjs +380 -1
- package/dist/native.umd.js +380 -1
- package/dist/native.umd.min.js +1 -1
- package/dist/plugin/app/index.cjs +262 -98
- package/dist/plugin/app/index.d.ts +18 -0
- package/dist/plugin/app/index.min.cjs +1 -1
- package/dist/plugin/app/index.min.mjs +1 -1
- package/dist/plugin/app/index.mjs +262 -98
- package/dist/plugin/app/index.umd.js +262 -98
- package/dist/plugin/app/index.umd.min.js +1 -1
- package/dist/plugin/app/src/constants/platform.d.ts +21 -12
- package/dist/plugin/app/src/types/platform.d.ts +17 -0
- package/dist/plugin/app/src/utils/create-custom-error.d.ts +5 -0
- package/dist/plugin/app/src/utils/create-hidden-element.d.ts +1 -1
- package/dist/plugin/app/src/utils/dynamic-import.d.ts +1 -0
- package/dist/plugin/camera/index.cjs +248 -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 +248 -86
- package/dist/plugin/camera/index.umd.js +248 -86
- package/dist/plugin/camera/index.umd.min.js +1 -1
- package/dist/plugin/camera/src/constants/platform.d.ts +21 -12
- package/dist/plugin/camera/src/types/platform.d.ts +17 -0
- package/dist/plugin/camera/src/utils/create-custom-error.d.ts +5 -0
- package/dist/plugin/camera/src/utils/create-hidden-element.d.ts +1 -1
- package/dist/plugin/camera/src/utils/dynamic-import.d.ts +1 -0
- package/dist/plugin/clipboard/index.cjs +7 -4
- package/dist/plugin/clipboard/index.min.cjs +1 -1
- package/dist/plugin/clipboard/index.min.mjs +1 -1
- package/dist/plugin/clipboard/index.mjs +7 -4
- package/dist/plugin/clipboard/index.umd.js +7 -4
- package/dist/plugin/clipboard/index.umd.min.js +1 -1
- package/dist/plugin/clipboard/src/constants/platform.d.ts +21 -12
- package/dist/plugin/clipboard/src/types/platform.d.ts +17 -0
- package/dist/plugin/clipboard/src/utils/create-custom-error.d.ts +5 -0
- package/dist/plugin/clipboard/src/utils/create-hidden-element.d.ts +1 -1
- package/dist/plugin/clipboard/src/utils/dynamic-import.d.ts +1 -0
- package/dist/plugin/fullscreen/index.cjs +241 -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 +241 -82
- package/dist/plugin/fullscreen/index.umd.js +241 -82
- package/dist/plugin/fullscreen/index.umd.min.js +1 -1
- package/dist/plugin/fullscreen/src/constants/platform.d.ts +21 -12
- package/dist/plugin/fullscreen/src/types/platform.d.ts +17 -0
- package/dist/plugin/fullscreen/src/utils/create-custom-error.d.ts +5 -0
- package/dist/plugin/fullscreen/src/utils/create-hidden-element.d.ts +1 -1
- package/dist/plugin/fullscreen/src/utils/dynamic-import.d.ts +1 -0
- package/dist/plugin/platform/index.cjs +7 -7
- package/dist/plugin/platform/index.d.ts +18 -0
- package/dist/plugin/platform/index.min.cjs +1 -1
- package/dist/plugin/platform/index.min.mjs +1 -1
- package/dist/plugin/platform/index.mjs +7 -7
- package/dist/plugin/platform/index.umd.js +7 -7
- package/dist/plugin/platform/index.umd.min.js +1 -1
- package/dist/plugin/platform/src/constants/platform.d.ts +19 -0
- package/dist/plugin/platform/src/utils/create-custom-error.d.ts +5 -0
- package/dist/plugin/platform/src/utils/dynamic-import.d.ts +1 -0
- package/dist/plugin/theme/index.cjs +252 -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 +252 -91
- package/dist/plugin/theme/index.umd.js +252 -91
- package/dist/plugin/theme/index.umd.min.js +1 -1
- package/dist/plugin/theme/src/constants/platform.d.ts +21 -12
- package/dist/plugin/theme/src/types/platform.d.ts +17 -0
- package/dist/plugin/theme/src/utils/create-custom-error.d.ts +5 -0
- package/dist/plugin/theme/src/utils/create-hidden-element.d.ts +1 -1
- package/dist/plugin/theme/src/utils/dynamic-import.d.ts +1 -0
- package/dist/src/constants/platform.d.ts +21 -12
- package/dist/src/types/platform.d.ts +17 -0
- package/dist/src/utils/create-custom-error.d.ts +5 -0
- package/dist/src/utils/create-hidden-element.d.ts +1 -1
- package/dist/src/utils/dynamic-import.d.ts +1 -0
- package/package.json +1 -8
|
@@ -4,7 +4,23 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Camera = factory());
|
|
5
5
|
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function dynamicImport(moduleName) {
|
|
8
|
+
if ('require' in globalThis && typeof globalThis.require === 'function') {
|
|
9
|
+
try {
|
|
10
|
+
return Promise.resolve(globalThis.require(moduleName));
|
|
11
|
+
}
|
|
12
|
+
catch (_) {
|
|
13
|
+
return Promise.resolve(null);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return import(moduleName)
|
|
17
|
+
.then(function (module) {
|
|
18
|
+
return (module.default || module);
|
|
19
|
+
})
|
|
20
|
+
.catch(function () {
|
|
21
|
+
return Promise.resolve(null);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
8
24
|
|
|
9
25
|
var OS;
|
|
10
26
|
(function (OS) {
|
|
@@ -45,47 +61,22 @@
|
|
|
45
61
|
Browsers["IE"] = "IE";
|
|
46
62
|
Browsers["SamsungInternet"] = "SamsungInternet";
|
|
47
63
|
})(Browsers || (Browsers = {}));
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
'NT 6.1': '7',
|
|
65
|
-
'NT 6.2': '8',
|
|
66
|
-
'NT 6.3': '8.1',
|
|
67
|
-
'NT 6.4': '10',
|
|
68
|
-
'NT 10.0': '10',
|
|
69
|
-
'ARM': 'RT'
|
|
70
|
-
}[string];
|
|
71
|
-
if (mapped !== undefined)
|
|
72
|
-
return mapped;
|
|
73
|
-
return string;
|
|
74
|
-
}
|
|
75
|
-
function resolveUnderscoreVersion(string) {
|
|
76
|
-
if (string === undefined)
|
|
77
|
-
return '';
|
|
78
|
-
return string.replace(/_/g, '.');
|
|
79
|
-
}
|
|
80
|
-
function resolveVersion(string, resolver) {
|
|
81
|
-
if (typeof resolver === 'function')
|
|
82
|
-
return resolver(string);
|
|
83
|
-
if (typeof resolver === 'string')
|
|
84
|
-
return resolver;
|
|
85
|
-
if (string === undefined)
|
|
86
|
-
return '';
|
|
87
|
-
return string;
|
|
88
|
-
}
|
|
64
|
+
var Platform = {
|
|
65
|
+
device: Devices.Unknown,
|
|
66
|
+
os: OS.Unknown,
|
|
67
|
+
osVersion: '',
|
|
68
|
+
engine: Engines.Unknown,
|
|
69
|
+
engineVersion: '',
|
|
70
|
+
browser: Browsers.Unknown,
|
|
71
|
+
browserVersion: '',
|
|
72
|
+
renderer: getRenderer(),
|
|
73
|
+
userAgent: navigator.userAgent,
|
|
74
|
+
isWebview: false,
|
|
75
|
+
isMobile: false,
|
|
76
|
+
isDesktop: false,
|
|
77
|
+
isStandalone: false,
|
|
78
|
+
isNodeJS: getIsNode(),
|
|
79
|
+
};
|
|
89
80
|
var OS_RESOLVER_MAP = [
|
|
90
81
|
[/windows nt (6\.[23]); arm/i, OS.Windows, resolveWindowsVersion],
|
|
91
82
|
[/windows (?:phone|mobile|iot)(?: os)?[\/ ]?([\d.]*( se)?)/i, OS.Windows, resolveWindowsVersion],
|
|
@@ -144,73 +135,240 @@
|
|
|
144
135
|
[/mobile vr; rv:([\w.]+)\).+firefox/i, Browsers.Firefox],
|
|
145
136
|
[/firefox\/([\w.]+)/i, Browsers.Firefox],
|
|
146
137
|
];
|
|
138
|
+
function resolveWindowsVersion(string) {
|
|
139
|
+
if (string === undefined)
|
|
140
|
+
return '';
|
|
141
|
+
var mapped = {
|
|
142
|
+
'4.90': 'ME',
|
|
143
|
+
'NT3.51': 'NT 3.11',
|
|
144
|
+
'NT4.0': 'NT 4.0',
|
|
145
|
+
'NT 5.0': '2000',
|
|
146
|
+
'NT 5.1': 'XP',
|
|
147
|
+
'NT 5.2': 'XP',
|
|
148
|
+
'NT 6.0': 'Vista',
|
|
149
|
+
'NT 6.1': '7',
|
|
150
|
+
'NT 6.2': '8',
|
|
151
|
+
'NT 6.3': '8.1',
|
|
152
|
+
'NT 6.4': '10',
|
|
153
|
+
'NT 10.0': '10',
|
|
154
|
+
'ARM': 'RT'
|
|
155
|
+
}[string];
|
|
156
|
+
if (mapped !== undefined)
|
|
157
|
+
return mapped;
|
|
158
|
+
return string;
|
|
159
|
+
}
|
|
160
|
+
function resolveUnderscoreVersion(string) {
|
|
161
|
+
if (string === undefined)
|
|
162
|
+
return '';
|
|
163
|
+
return string.replace(/_/g, '.');
|
|
164
|
+
}
|
|
165
|
+
function resolveVersion(string, resolver) {
|
|
166
|
+
if (typeof resolver === 'function')
|
|
167
|
+
return resolver(string);
|
|
168
|
+
if (typeof resolver === 'string')
|
|
169
|
+
return resolver;
|
|
170
|
+
if (string === undefined)
|
|
171
|
+
return '';
|
|
172
|
+
return string;
|
|
173
|
+
}
|
|
174
|
+
function normalizeBrand(entry) {
|
|
175
|
+
if (entry === null || entry === undefined)
|
|
176
|
+
return { brand: '', version: '' };
|
|
177
|
+
if (typeof entry === 'string')
|
|
178
|
+
return { brand: entry, version: '' };
|
|
179
|
+
return { brand: entry.brand, version: entry.version };
|
|
180
|
+
}
|
|
181
|
+
function getRenderer() {
|
|
182
|
+
if (typeof globalThis.document === 'undefined')
|
|
183
|
+
return '';
|
|
184
|
+
var canvas = globalThis.document.createElement('canvas');
|
|
185
|
+
if (typeof canvas.getContext !== 'function')
|
|
186
|
+
return '';
|
|
187
|
+
var context = canvas.getContext('webgl2') || canvas.getContext('experimental-webgl') || canvas.getContext('webgl');
|
|
188
|
+
if (context === null)
|
|
189
|
+
return '';
|
|
190
|
+
if (context instanceof WebGLRenderingContext || 'getParameter' in context && typeof context.getParameter === 'function') {
|
|
191
|
+
var extension = context.getExtension('WEBGL_debug_renderer_info');
|
|
192
|
+
if (extension === null)
|
|
193
|
+
return context.getParameter(context.RENDERER);
|
|
194
|
+
else
|
|
195
|
+
return context.getParameter(extension.UNMASKED_RENDERER_WEBGL);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
return '';
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function getIsStandalone(os) {
|
|
202
|
+
if (!('matchMedia' in globalThis))
|
|
203
|
+
return false;
|
|
204
|
+
if (os === OS.iOS)
|
|
205
|
+
return 'standalone' in navigator && !!navigator.standalone;
|
|
206
|
+
return globalThis.matchMedia('(display-mode: standalone)').matches;
|
|
207
|
+
}
|
|
208
|
+
function getIsWebview() {
|
|
209
|
+
return /; ?wv|applewebkit(?!.*safari)/i.test(Platform.userAgent);
|
|
210
|
+
}
|
|
211
|
+
function getIsNode() {
|
|
212
|
+
return typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined;
|
|
213
|
+
}
|
|
214
|
+
function getNodeOSVersion(string) {
|
|
215
|
+
var parts = string.split('.');
|
|
216
|
+
return {
|
|
217
|
+
major: parseInt(parts[0] || '0'),
|
|
218
|
+
minor: parseInt(parts[1] || '0'),
|
|
219
|
+
build: parseInt(parts[2] || '0')
|
|
220
|
+
};
|
|
221
|
+
}
|
|
147
222
|
for (var i = 0; i < OS_RESOLVER_MAP.length; i++) {
|
|
148
223
|
var map = OS_RESOLVER_MAP[i];
|
|
149
224
|
var regexp = map[0];
|
|
150
225
|
var os = map[1];
|
|
151
226
|
var resolver = map[2];
|
|
152
|
-
var matched =
|
|
227
|
+
var matched = Platform.userAgent.match(regexp);
|
|
153
228
|
if (matched !== null) {
|
|
154
|
-
|
|
155
|
-
|
|
229
|
+
Platform.os = os;
|
|
230
|
+
Platform.osVersion = resolveVersion(matched[1], resolver);
|
|
156
231
|
if (os === OS.iOS || os === OS.Android)
|
|
157
|
-
|
|
232
|
+
Platform.device = Devices.Mobile;
|
|
158
233
|
else if (os === OS.Windows || os === OS.MacOS)
|
|
159
|
-
|
|
234
|
+
Platform.device = Devices.Desktop;
|
|
160
235
|
break;
|
|
161
236
|
}
|
|
162
237
|
}
|
|
163
238
|
for (var i = 0; i < ENGINE_RESOLVER_MAP.length; i++) {
|
|
164
239
|
var map = ENGINE_RESOLVER_MAP[i];
|
|
165
240
|
var regexp = map[0];
|
|
166
|
-
map[1];
|
|
241
|
+
var engine = map[1];
|
|
167
242
|
var resolver = map[2];
|
|
168
|
-
var matched =
|
|
243
|
+
var matched = Platform.userAgent.match(regexp);
|
|
169
244
|
if (matched !== null) {
|
|
170
|
-
|
|
245
|
+
Platform.engine = engine;
|
|
246
|
+
Platform.engineVersion = resolveVersion(matched[1], resolver);
|
|
171
247
|
break;
|
|
172
248
|
}
|
|
173
249
|
}
|
|
174
250
|
for (var i = 0; i < BROWSER_RESOLVER_MAP.length; i++) {
|
|
175
251
|
var map = BROWSER_RESOLVER_MAP[i];
|
|
176
252
|
var regexp = map[0];
|
|
177
|
-
map[1];
|
|
253
|
+
var browser = map[1];
|
|
178
254
|
var resolver = map[2];
|
|
179
|
-
var matched =
|
|
255
|
+
var matched = Platform.userAgent.match(regexp);
|
|
180
256
|
if (matched !== null) {
|
|
181
|
-
|
|
257
|
+
Platform.browser = browser;
|
|
258
|
+
Platform.browserVersion = resolveVersion(matched[1], resolver);
|
|
182
259
|
break;
|
|
183
260
|
}
|
|
184
261
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
262
|
+
if (Platform.isNodeJS) {
|
|
263
|
+
dynamicImport('os')
|
|
264
|
+
.then(function (os) {
|
|
265
|
+
if (os === null)
|
|
266
|
+
return;
|
|
267
|
+
var platform = os.platform();
|
|
268
|
+
var release = os.release();
|
|
269
|
+
var version = getNodeOSVersion(release);
|
|
270
|
+
switch (platform) {
|
|
271
|
+
case 'win32':
|
|
272
|
+
Platform.os = OS.Windows;
|
|
273
|
+
if (version.major === 10 && version.minor === 0 && version.build >= 22000)
|
|
274
|
+
Platform.osVersion = '11';
|
|
275
|
+
else if (version.major === 10 && version.minor === 0 && version.build < 22000)
|
|
276
|
+
Platform.osVersion = '10';
|
|
277
|
+
else if (version.major === 6 && version.minor === 3)
|
|
278
|
+
Platform.osVersion = '8.1';
|
|
279
|
+
else if (version.major === 6 && version.minor === 2)
|
|
280
|
+
Platform.osVersion = '8';
|
|
281
|
+
else if (version.major === 6 && version.minor === 1)
|
|
282
|
+
Platform.osVersion = '7';
|
|
283
|
+
else if (version.major === 6 && version.minor === 0)
|
|
284
|
+
Platform.osVersion = 'Vista';
|
|
285
|
+
else if (version.major === 5 && version.minor === 1)
|
|
286
|
+
Platform.osVersion = 'XP';
|
|
287
|
+
else if (version.major === 5 && version.minor === 2)
|
|
288
|
+
Platform.osVersion = 'XP';
|
|
289
|
+
else if (version.major === 5 && version.minor === 0)
|
|
290
|
+
Platform.osVersion = '2000';
|
|
291
|
+
else if (version.major === 4 && version.minor === 90)
|
|
292
|
+
Platform.osVersion = 'ME';
|
|
293
|
+
else if (version.major === 4 && version.minor === 0)
|
|
294
|
+
Platform.osVersion = 'NT 4.0';
|
|
295
|
+
else if (version.major === 3 && version.minor === 51)
|
|
296
|
+
Platform.osVersion = 'NT 3.11';
|
|
297
|
+
else
|
|
298
|
+
Platform.osVersion = release;
|
|
299
|
+
break;
|
|
300
|
+
case 'darwin':
|
|
301
|
+
Platform.os = OS.MacOS;
|
|
302
|
+
if (version.major >= 24)
|
|
303
|
+
Platform.osVersion = '' + (version.major - 9);
|
|
304
|
+
else if (version.major === 23)
|
|
305
|
+
Platform.osVersion = '14';
|
|
306
|
+
else if (version.major === 22)
|
|
307
|
+
Platform.osVersion = '13';
|
|
308
|
+
else if (version.major === 21)
|
|
309
|
+
Platform.osVersion = '12';
|
|
310
|
+
else if (version.major === 20)
|
|
311
|
+
Platform.osVersion = '11';
|
|
312
|
+
else if (version.major === 19)
|
|
313
|
+
Platform.osVersion = '10.15';
|
|
314
|
+
else if (version.major === 18)
|
|
315
|
+
Platform.osVersion = '10.14';
|
|
316
|
+
else if (version.major === 17)
|
|
317
|
+
Platform.osVersion = '10.13';
|
|
318
|
+
else if (version.major === 16)
|
|
319
|
+
Platform.osVersion = '10.12';
|
|
320
|
+
else if (version.major === 15)
|
|
321
|
+
Platform.osVersion = '10.11';
|
|
322
|
+
else if (version.major === 14)
|
|
323
|
+
Platform.osVersion = '10.10';
|
|
324
|
+
else if (version.major === 13)
|
|
325
|
+
Platform.osVersion = '10.9';
|
|
326
|
+
else if (version.major >= 5 && version.major <= 12)
|
|
327
|
+
Platform.osVersion = '10.' + (version.major - 4);
|
|
328
|
+
else
|
|
329
|
+
Platform.osVersion = release;
|
|
330
|
+
break;
|
|
331
|
+
case 'android':
|
|
332
|
+
Platform.os = OS.Android;
|
|
333
|
+
Platform.osVersion = release;
|
|
334
|
+
break;
|
|
335
|
+
case 'linux':
|
|
336
|
+
if (/android/i.test(release)) {
|
|
337
|
+
Platform.os = OS.Android;
|
|
338
|
+
Platform.osVersion = release;
|
|
339
|
+
}
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
if (navigator.userAgentData !== undefined && navigator.userAgentData.getHighEntropyValues !== undefined) {
|
|
345
|
+
navigator
|
|
346
|
+
.userAgentData
|
|
347
|
+
.getHighEntropyValues(['brands', 'fullVersionList', 'mobile', 'model', 'platform', 'platformVersion', 'architecture', 'formFactors', 'bitness', 'uaFullVersion', 'wow64'])
|
|
348
|
+
.then(function (result) {
|
|
349
|
+
var brands = result.fullVersionList || result.brands || [];
|
|
350
|
+
var platformVersion = result.platformVersion;
|
|
351
|
+
for (var i = 0; i < brands.length; i++) {
|
|
352
|
+
var brand = normalizeBrand(brands[i]);
|
|
353
|
+
var brandName = brand.brand;
|
|
354
|
+
var brandVersion = brand.version;
|
|
355
|
+
if (/not.a.brand/i.test(brandName))
|
|
356
|
+
continue;
|
|
357
|
+
if (brandName === "Chromium")
|
|
358
|
+
Platform.engineVersion = brandVersion;
|
|
359
|
+
}
|
|
360
|
+
if (typeof platformVersion === 'string') {
|
|
361
|
+
if (Platform.os === OS.Windows && parseInt(platformVersion.replace(/[^\d.]/g, '').split('.')[0], 10) >= 13)
|
|
362
|
+
Platform.osVersion = '11';
|
|
363
|
+
else
|
|
364
|
+
Platform.osVersion = platformVersion;
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
Platform.isMobile = Platform.device === Devices.Mobile;
|
|
369
|
+
Platform.isDesktop = Platform.device === Devices.Desktop;
|
|
370
|
+
Platform.isWebview = getIsWebview();
|
|
371
|
+
Platform.isStandalone = getIsStandalone(Platform.os);
|
|
214
372
|
|
|
215
373
|
function getTopmostWindow() {
|
|
216
374
|
try {
|
|
@@ -243,6 +401,8 @@
|
|
|
243
401
|
|
|
244
402
|
function createHiddenElement(tagName, focusable) {
|
|
245
403
|
if (focusable === void 0) { focusable = true; }
|
|
404
|
+
if (typeof globalThis.document === 'undefined')
|
|
405
|
+
return undefined;
|
|
246
406
|
var element = globalThis.document.createElement(tagName);
|
|
247
407
|
if ('width' in element)
|
|
248
408
|
element.width = '0';
|
|
@@ -299,13 +459,15 @@
|
|
|
299
459
|
var input;
|
|
300
460
|
try {
|
|
301
461
|
input = createHiddenElement('input');
|
|
462
|
+
if (input === undefined)
|
|
463
|
+
return;
|
|
302
464
|
input.type = 'file';
|
|
303
465
|
input.tabIndex = -1;
|
|
304
466
|
input.accept = type + '/*';
|
|
305
467
|
if ('capture' in HTMLInputElement.prototype) {
|
|
306
468
|
input.capture = 'user';
|
|
307
469
|
}
|
|
308
|
-
else if (
|
|
470
|
+
else if (Platform.os === OS.Android) {
|
|
309
471
|
var capture = '';
|
|
310
472
|
if (type === 'image')
|
|
311
473
|
capture = 'camera';
|
|
@@ -347,16 +509,16 @@
|
|
|
347
509
|
open: open
|
|
348
510
|
};
|
|
349
511
|
function open(type) {
|
|
350
|
-
switch (
|
|
512
|
+
switch (Platform.os) {
|
|
351
513
|
case OS.Android:
|
|
352
514
|
tryOpenCamera(type);
|
|
353
515
|
break;
|
|
354
516
|
case OS.iOS:
|
|
355
|
-
if (compareVersion(
|
|
517
|
+
if (compareVersion(Platform.osVersion, '10.3') >= 0) {
|
|
356
518
|
tryOpenCamera(type);
|
|
357
519
|
}
|
|
358
520
|
else {
|
|
359
|
-
alert(
|
|
521
|
+
alert(Platform.osVersion);
|
|
360
522
|
}
|
|
361
523
|
break;
|
|
362
524
|
case OS.Windows:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e="undefined"!=typeof globalThis?globalThis:e||self).Camera=i()}(this,(function(){"use strict";var e,i,
|
|
1
|
+
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e="undefined"!=typeof globalThis?globalThis:e||self).Camera=i()}(this,(function(){"use strict";var e,i,o,n;!function(e){e.Unknown="Unknown",e.Android="Android",e.iOS="iOS",e.Windows="Windows",e.MacOS="MacOS"}(e||(e={})),function(e){e.Unknown="Unknown",e.Mobile="Mobile",e.Desktop="Desktop"}(i||(i={})),function(e){e.Unknown="Unknown",e.EdgeHTML="EdgeHTML",e.ArkWeb="ArkWeb",e.Blink="Blink",e.Presto="Presto",e.WebKit="WebKit",e.Trident="Trident",e.NetFront="NetFront",e.KHTML="KHTML",e.Tasman="Tasman",e.Gecko="Gecko"}(o||(o={})),function(e){e.Unknown="Unknown",e.Chrome="Chrome",e.Safari="Safari",e.Edge="Edge",e.Firefox="Firefox",e.Opera="Opera",e.IE="IE",e.SamsungInternet="SamsungInternet"}(n||(n={}));var r={device:i.Unknown,os:e.Unknown,osVersion:"",engine:o.Unknown,engineVersion:"",browser:n.Unknown,browserVersion:"",renderer:function(){if(void 0===globalThis.document)return"";var e=globalThis.document.createElement("canvas");if("function"!=typeof e.getContext)return"";var i=e.getContext("webgl2")||e.getContext("experimental-webgl")||e.getContext("webgl");if(null===i)return"";if(i instanceof WebGLRenderingContext||"getParameter"in i&&"function"==typeof i.getParameter){var o=i.getExtension("WEBGL_debug_renderer_info");return null===o?i.getParameter(i.RENDERER):i.getParameter(o.UNMASKED_RENDERER_WEBGL)}return""}(),userAgent:navigator.userAgent,isWebview:!1,isMobile:!1,isDesktop:!1,isStandalone:!1,isNodeJS:void 0!==globalThis.process&&void 0!==globalThis.process.versions&&void 0!==globalThis.process.versions.node},t=[[/windows nt (6\.[23]); arm/i,e.Windows,l],[/windows (?:phone|mobile|iot)(?: os)?[\/ ]?([\d.]*( se)?)/i,e.Windows,l],[/windows[\/ ](1[01]|2000|3\.1|7|8(\.1)?|9[58]|me|server 20\d\d( r2)?|vista|xp)/i,e.Windows,l],[/windows nt ?([\d.)]*)(?!.+xbox)/i,e.Windows,l],[/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d.;]*)/i,e.Windows,l],[/windows ce\/?([\d.]*)/i,e.Windows,l],[/[adehimnop]{4,7}\b(?:.*os (\w+) like mac|; opera)/i,e.iOS,d],[/(?:ios;fbsv|ios(?=.+ip(?:ad|hone))|ip(?:ad|hone)(?: |.+i(?:pad)?)os)[\/ ]([\w.]+)/i,e.iOS,d],[/cfnetwork\/.+darwin/i,e.iOS,d],[/mac os x ?([\w. ]*)/i,e.MacOS,d],[/(?:macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i,e.MacOS,d],[/droid ([\w.]+)\b.+(android[- ]x86)/i,e.Android],[/android\w*[-\/.; ]?([\d.]*)/i,e.Android]],a=[[/windows.+ edge\/([\w.]+)/i,o.EdgeHTML],[/arkweb\/([\w.]+)/i,o.ArkWeb],[/webkit\/537\.36.+chrome\/(?!27)([\w.]+)/i,o.Blink],[/presto\/([\w.]+)/i,o.Presto],[/webkit\/([\w.]+)/i,o.WebKit],[/trident\/([\w.]+)/i,o.Trident],[/netfront\/([\w.]+)/i,o.NetFront],[/khtml[\/ ]\(?([\w.]+)/i,o.KHTML],[/tasman[\/ ]\(?([\w.]+)/i,o.Tasman],[/rv:([\w.]{1,9})\b.+gecko/i,o.Gecko]],s=[[/\b(?:crmo|crios)\/([\w.]+)/i,n.Chrome],[/webview.+edge\/([\w.]+)/i,n.Edge],[/edg(?:e|ios|a)?\/([\w.]+)/i,n.Edge],[/opera mini\/([-\w.]+)/i,n.Opera],[/opera [mobileta]{3,6}\b.+version\/([-\w.]+)/i,n.Opera],[/opera(?:.+version\/|[\/ ]+)([\w.]+)/i,n.Opera],[/opios[\/ ]+([\w.]+)/i,n.Opera],[/\bop(?:rg)?x\/([\w.]+)/i,n.Opera],[/\bopr\/([\w.]+)/i,n.Opera],[/iemobile(?:browser|boat|jet)[\/ ]?([\d.]*)/i,n.IE],[/(?:ms|\()ie ([\w.]+)/i,n.IE],[/trident.+rv[: ]([\w.]{1,9})\b.+like gecko/i,n.IE],[/\bfocus\/([\w.]+)/i,n.Firefox],[/\bopt\/([\w.]+)/i,n.Opera],[/coast\/([\w.]+)/i,n.Opera],[/fxios\/([\w.-]+)/i,n.Firefox],[/samsungbrowser\/([\w.]+)/i,n.SamsungInternet],[/headlesschrome(?:\/([\w.]+)| )/i,n.Chrome],[/wv\).+chrome\/([\w.]+).+edgw\//i,n.Edge],[/ wv\).+(chrome)\/([\w.]+)/i,n.Chrome],[/chrome\/([\w.]+) mobile/i,n.Chrome],[/chrome\/v?([\w.]+)/i,n.Chrome],[/version\/([\w.,]+) .*mobile(?:\/\w+ | ?)safari/i,n.Safari],[/iphone .*mobile(?:\/\w+ | ?)safari/i,n.Safari],[/version\/([\w.,]+) .*safari/i,n.Safari],[/webkit.+?(?:mobile ?safari|safari)(\/[\w.]+)/i,n.Safari,"1"],[/(?:mobile|tablet);.*firefox\/([\w.-]+)/i,n.Firefox],[/mobile vr; rv:([\w.]+)\).+firefox/i,n.Firefox],[/firefox\/([\w.]+)/i,n.Firefox]];function l(e){if(void 0===e)return"";var i={"4.90":"ME","NT3.51":"NT 3.11","NT4.0":"NT 4.0","NT 5.0":"2000","NT 5.1":"XP","NT 5.2":"XP","NT 6.0":"Vista","NT 6.1":"7","NT 6.2":"8","NT 6.3":"8.1","NT 6.4":"10","NT 10.0":"10",ARM:"RT"}[e];return void 0!==i?i:e}function d(e){return void 0===e?"":e.replace(/_/g,".")}function c(e,i){return"function"==typeof i?i(e):"string"==typeof i?i:void 0===e?"":e}for(var m=0;m<t.length;m++){var w=(b=t[m])[0],u=b[1],f=b[2];if(null!==(g=r.userAgent.match(w))){r.os=u,r.osVersion=c(g[1],f),u===e.iOS||u===e.Android?r.device=i.Mobile:u!==e.Windows&&u!==e.MacOS||(r.device=i.Desktop);break}}for(m=0;m<a.length;m++){w=(b=a[m])[0];var p=b[1];f=b[2];if(null!==(g=r.userAgent.match(w))){r.engine=p,r.engineVersion=c(g[1],f);break}}for(m=0;m<s.length;m++){w=(b=s[m])[0];var b,g,h=b[1];f=b[2];if(null!==(g=r.userAgent.match(w))){r.browser=h,r.browserVersion=c(g[1],f);break}}function v(i){var o,n=function(){try{if(globalThis.top&&globalThis.top!==window)return globalThis.top.location.href,globalThis.top}catch(e){}return window}(),t=n.document;try{if(void 0===(o=function(e,i){if(void 0===i&&(i=!0),void 0!==globalThis.document){var o=globalThis.document.createElement(e);return"width"in o&&(o.width="0"),"height"in o&&(o.height="0"),"border"in o&&(o.border="0"),"frameBorder"in o&&(o.frameBorder="0"),"scrolling"in o&&(o.scrolling="no"),"cellPadding"in o&&(o.cellPadding="0"),"cellSpacing"in o&&(o.cellSpacing="0"),"frame"in o&&(o.frame="void"),"rules"in o&&(o.rules="none"),"noWrap"in o&&(o.noWrap=!0),o.tabIndex=-1,o.setAttribute("role","presentation"),i?(o.style.width="1px",o.style.height="1px"):(o.setAttribute("aria-hidden","true"),o.style.width="0",o.style.height="0",o.style.zIndex="-9999",o.style.display="none",o.style.visibility="hidden",o.style.pointerEvents="none"),o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.padding="0",o.style.margin="0",o.style.border="none",o.style.outline="none",o.style.clip="rect(1px, 1px, 1px, 1px)",o.style.clipPath="inset(50%)",o.style.overflow="hidden",o.style.whiteSpace="nowrap",o}}("input")))return;if(o.type="file",o.tabIndex=-1,o.accept=i+"/*","capture"in HTMLInputElement.prototype)o.capture="user";else if(r.os===e.Android){var a="";"image"===i?a="camera":"video"===i&&(a="camcorder"),o.accept=i+"/*;capture="+a}t.body.appendChild(o),function(e,i){var o;void 0===i&&(i=window);try{o=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:i})}catch(e){(o=globalThis.document.createEvent("MouseEvents")).initMouseEvent("click",!0,!0,i,0,0,0,0,0,!1,!1,!1,!1,0,null)}e.dispatchEvent(o)}(o,n)}catch(e){}}r.isNodeJS&&function(e){if("require"in globalThis&&"function"==typeof globalThis.require)try{return Promise.resolve(globalThis.require(e))}catch(e){return Promise.resolve(null)}return import(e).then((function(e){return e.default||e})).catch((function(){return Promise.resolve(null)}))}("os").then((function(i){if(null!==i){var o,n=i.platform(),t=i.release(),a=(o=t.split("."),{major:parseInt(o[0]||"0"),minor:parseInt(o[1]||"0"),build:parseInt(o[2]||"0")});switch(n){case"win32":r.os=e.Windows,r.osVersion=10===a.major&&0===a.minor&&a.build>=22e3?"11":10===a.major&&0===a.minor&&a.build<22e3?"10":6===a.major&&3===a.minor?"8.1":6===a.major&&2===a.minor?"8":6===a.major&&1===a.minor?"7":6===a.major&&0===a.minor?"Vista":5===a.major&&1===a.minor||5===a.major&&2===a.minor?"XP":5===a.major&&0===a.minor?"2000":4===a.major&&90===a.minor?"ME":4===a.major&&0===a.minor?"NT 4.0":3===a.major&&51===a.minor?"NT 3.11":t;break;case"darwin":r.os=e.MacOS,r.osVersion=a.major>=24?""+(a.major-9):23===a.major?"14":22===a.major?"13":21===a.major?"12":20===a.major?"11":19===a.major?"10.15":18===a.major?"10.14":17===a.major?"10.13":16===a.major?"10.12":15===a.major?"10.11":14===a.major?"10.10":13===a.major?"10.9":a.major>=5&&a.major<=12?"10."+(a.major-4):t;break;case"android":r.os=e.Android,r.osVersion=t;break;case"linux":/android/i.test(t)&&(r.os=e.Android,r.osVersion=t)}}})),void 0!==navigator.userAgentData&&void 0!==navigator.userAgentData.getHighEntropyValues&&navigator.userAgentData.getHighEntropyValues(["brands","fullVersionList","mobile","model","platform","platformVersion","architecture","formFactors","bitness","uaFullVersion","wow64"]).then((function(i){for(var o,n=i.fullVersionList||i.brands||[],t=i.platformVersion,a=0;a<n.length;a++){var s=null==(o=n[a])?{brand:"",version:""}:"string"==typeof o?{brand:o,version:""}:{brand:o.brand,version:o.version},l=s.brand,d=s.version;/not.a.brand/i.test(l)||"Chromium"===l&&(r.engineVersion=d)}"string"==typeof t&&(r.os===e.Windows&&parseInt(t.replace(/[^\d.]/g,"").split(".")[0],10)>=13?r.osVersion="11":r.osVersion=t)})),r.isMobile=r.device===i.Mobile,r.isDesktop=r.device===i.Desktop,r.isWebview=/; ?wv|applewebkit(?!.*safari)/i.test(r.userAgent),r.isStandalone=function(i){return"matchMedia"in globalThis&&(i===e.iOS?"standalone"in navigator&&!!navigator.standalone:globalThis.matchMedia("(display-mode: standalone)").matches)}(r.os);var T,k={open:function(i){switch(r.os){case e.Android:v(i);break;case e.iOS:(function(e,i){for(var o=e.split("."),n=i.split("."),r=Math.max(o.length,n.length),t=0;t<r;t++){var a=void 0,s=void 0;if((a=t<o.length?parseInt(o[t],10):0)>(s=t<n.length?parseInt(n[t],10):0))return 1;if(a<s)return-1}return 0})(r.osVersion,"10.3")>=0?v(i):alert(r.osVersion);case e.Windows:case e.MacOS:}}};return function(e){e.Image="image",e.Video="video"}(T||(T={})),{installed:!1,name:"Camera",module:k,Constants:{CameraType:T},Errors:{}}}));
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import { PlatformInstance } from "../types/platform";
|
|
2
|
+
declare global {
|
|
3
|
+
interface Navigator {
|
|
4
|
+
userAgentData?: UserAgentData;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
interface ModernUserAgentDataBrand {
|
|
8
|
+
brand: string;
|
|
9
|
+
version: string;
|
|
10
|
+
}
|
|
11
|
+
type UserAgentDataBrand = ModernUserAgentDataBrand | string | null | undefined;
|
|
12
|
+
interface UserAgentDataValues {
|
|
13
|
+
brands?: UserAgentDataBrand[];
|
|
14
|
+
fullVersionList?: UserAgentDataBrand[];
|
|
15
|
+
platformVersion?: string | null | undefined;
|
|
16
|
+
}
|
|
17
|
+
interface UserAgentData {
|
|
18
|
+
getHighEntropyValues?(hints: string[]): Promise<UserAgentDataValues>;
|
|
19
|
+
}
|
|
1
20
|
export declare enum OS {
|
|
2
21
|
Unknown = "Unknown",
|
|
3
22
|
Android = "Android",
|
|
@@ -33,15 +52,5 @@ export declare enum Browsers {
|
|
|
33
52
|
IE = "IE",
|
|
34
53
|
SamsungInternet = "SamsungInternet"
|
|
35
54
|
}
|
|
36
|
-
|
|
37
|
-
export
|
|
38
|
-
export declare let OS_VERSION: string;
|
|
39
|
-
export declare let ENGINE_NAME: Engines;
|
|
40
|
-
export declare let ENGINE_VERSION: string;
|
|
41
|
-
export declare let BROWSER_NAME: Browsers;
|
|
42
|
-
export declare let BROWSER_VERSION: string;
|
|
43
|
-
export declare const RENDERER: string;
|
|
44
|
-
export declare const IS_WEBVIEW: boolean;
|
|
45
|
-
export declare const IS_MOBILE: boolean;
|
|
46
|
-
export declare const IS_DESKTOP: boolean;
|
|
47
|
-
export declare const IS_STANDALONE: boolean;
|
|
55
|
+
declare const Platform: PlatformInstance;
|
|
56
|
+
export default Platform;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Browsers, Devices, Engines, OS } from "../constants/platform";
|
|
2
|
+
export declare interface PlatformInstance {
|
|
3
|
+
os: OS;
|
|
4
|
+
device: Devices;
|
|
5
|
+
engine: Engines;
|
|
6
|
+
browser: Browsers;
|
|
7
|
+
osVersion: string;
|
|
8
|
+
engineVersion: string;
|
|
9
|
+
browserVersion: string;
|
|
10
|
+
renderer: string;
|
|
11
|
+
userAgent: string;
|
|
12
|
+
isWebview: boolean;
|
|
13
|
+
isStandalone: boolean;
|
|
14
|
+
isMobile: boolean;
|
|
15
|
+
isDesktop: boolean;
|
|
16
|
+
isNodeJS: boolean;
|
|
17
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function createHiddenElement<K extends keyof HTMLElementTagNameMap>(tagName: K, focusable?: boolean): HTMLElementTagNameMap[K];
|
|
1
|
+
export default function createHiddenElement<K extends keyof HTMLElementTagNameMap>(tagName: K, focusable?: boolean): HTMLElementTagNameMap[K] | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function dynamicImport<T = any>(moduleName: string): Promise<T | null>;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
function createHiddenElement(tagName, focusable) {
|
|
4
4
|
if (focusable === void 0) { focusable = true; }
|
|
5
|
+
if (typeof globalThis.document === 'undefined')
|
|
6
|
+
return undefined;
|
|
5
7
|
var element = globalThis.document.createElement(tagName);
|
|
6
8
|
if ('width' in element)
|
|
7
9
|
element.width = '0';
|
|
@@ -293,6 +295,8 @@ function copyViaSelection(text) {
|
|
|
293
295
|
if (!globalThis.getSelection || !globalThis.document.createRange)
|
|
294
296
|
return false;
|
|
295
297
|
var div = createHiddenElement('div');
|
|
298
|
+
if (div === undefined)
|
|
299
|
+
return false;
|
|
296
300
|
div.contentEditable = 'true';
|
|
297
301
|
div.innerHTML = text;
|
|
298
302
|
div.style.whiteSpace = 'pre';
|
|
@@ -416,6 +420,8 @@ function pasteViaClipboardAPI() {
|
|
|
416
420
|
}
|
|
417
421
|
function pasteViaSelection() {
|
|
418
422
|
var div = createHiddenElement('div');
|
|
423
|
+
if (div === undefined)
|
|
424
|
+
return null;
|
|
419
425
|
div.contentEditable = 'true';
|
|
420
426
|
globalThis.document.body.appendChild(div);
|
|
421
427
|
div.focus();
|
|
@@ -475,10 +481,7 @@ var ClipboardUtils = {
|
|
|
475
481
|
paste: paste
|
|
476
482
|
};
|
|
477
483
|
|
|
478
|
-
var Clipboard =
|
|
479
|
-
copy: ClipboardUtils.copy,
|
|
480
|
-
paste: ClipboardUtils.paste,
|
|
481
|
-
};
|
|
484
|
+
var Clipboard = ClipboardUtils;
|
|
482
485
|
|
|
483
486
|
var NativeClipboardPlugin = {
|
|
484
487
|
installed: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function t(t,e){void 0===e&&(e=!0)
|
|
1
|
+
"use strict";function t(t,e){if(void 0===e&&(e=!0),void 0!==globalThis.document){var n=globalThis.document.createElement(t);return"width"in n&&(n.width="0"),"height"in n&&(n.height="0"),"border"in n&&(n.border="0"),"frameBorder"in n&&(n.frameBorder="0"),"scrolling"in n&&(n.scrolling="no"),"cellPadding"in n&&(n.cellPadding="0"),"cellSpacing"in n&&(n.cellSpacing="0"),"frame"in n&&(n.frame="void"),"rules"in n&&(n.rules="none"),"noWrap"in n&&(n.noWrap=!0),n.tabIndex=-1,n.setAttribute("role","presentation"),e?(n.style.width="1px",n.style.height="1px"):(n.setAttribute("aria-hidden","true"),n.style.width="0",n.style.height="0",n.style.zIndex="-9999",n.style.display="none",n.style.visibility="hidden",n.style.pointerEvents="none"),n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.padding="0",n.style.margin="0",n.style.border="none",n.style.outline="none",n.style.clip="rect(1px, 1px, 1px, 1px)",n.style.clipPath="inset(50%)",n.style.overflow="hidden",n.style.whiteSpace="nowrap",n}}function e(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r="",o=0;o<e.length-2;o++){var i=e[o];void 0!==i&&(r=r+i.charAt(0).toUpperCase()+i.slice(1))}return r}function n(){this.returnValue=!1}function r(){this.cancelBubble=!0}var o=/(animation)(start|iteration|end|cancel)|(transition)(start|run|end|cancel)|(fullscreen)(change|error)|(lost|got)(pointer)(capture)|(pointer)(lock)(change|error)|(pointer)(cancel|down|enter|leave|move|out|over|up)/i,i=["","webkit","moz","ms","MS","o","O"],a={wheel:["wheel","mousewheel","DOMMouseScroll"],focus:["focus","focusin"],blur:["blur","focusout"],beforeinput:["beforeinput","textInput"]},l={useStd:void 0!==globalThis.document&&"function"==typeof globalThis.document.addEventListener,add:function(t,e){void 0===e&&(e={callback:null,options:!1});var o=e.callback;if(void 0!==t&&null!==o){var i=l.withVender(t,e.type),a=e.options;if("function"==typeof t.addEventListener)try{return t.addEventListener(i,o,a)}catch(t){}if("function"==typeof t.addListener)if("boolean"==typeof t.matches)try{return t.addListener(o)}catch(t){}else try{return t.addListener(i,o)}catch(t){}return"function"==typeof t.attachEvent?o.__ieWrapper?t.attachEvent("on"+i,o.__ieWrapper):t.attachEvent("on"+i,o.__ieWrapper=function(e){void 0===e&&(e=globalThis.event),void 0!==e&&(e.currentTarget=t,"function"!=typeof e.preventDefault&&(e.preventDefault=n),"function"!=typeof e.stopPropagation&&(e.stopPropagation=r),"function"==typeof o?o.call(t,e):o&&"function"==typeof o.handleEvent&&o.handleEvent.call(t,e))}):void 0}},remove:function(t,e){void 0===e&&(e={callback:null,options:!1});var n=e.callback;if(void 0!==t&&null!==n){var r=l.withVender(t,e.type),o=e.options;if("function"==typeof t.removeEventListener)try{return t.removeEventListener(r,n,o)}catch(t){}if("function"==typeof t.removeListener)if("boolean"==typeof t.matches)try{return t.removeListener(n)}catch(t){}else try{return t.removeListener(r,n)}catch(t){}if("function"!=typeof t.detachEvent);else{var i=n.__ieWrapper;void 0!==i&&(t.detachEvent("on"+r,i),delete n.__ieWrapper)}}},withVender:function(t,n){if(void 0===n)return"";if("webkitEnterFullscreen"in t&&["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"].indexOf(n)>-1)return n;var r;r=n in a?a[n]:o.test(n)?[n,n.replace(o,e)]:[n];for(var l=0;l<i.length;l++)for(var c=0;c<r.length;c++){var u=i[l]+r[c];if(void 0!==t["on"+u])return u}return""}};function c(t){return null!==t&&"object"==typeof t}function u(t){return c(t)||function(t){return Array.isArray(t)}(t)}function s(t){if(function(t){return c(t)&&"innerHTML"in t}(t))return t.innerHTML;if(u(t))try{return JSON.stringify(t)}catch(e){return""+t}else if("string"!=typeof t)return""+t;return t}function d(){return function(){if("isSecureContext"in window)return globalThis.isSecureContext;var t=location.protocol,e=location.hostname;return"https:"===t||"localhost"===e||"127.0.0.1"===e||"[::1]"===e}()&&"undefined"!=typeof navigator&&"clipboard"in navigator}function p(e){return function(e){if(!globalThis.getSelection||!globalThis.document.createRange)return!1;var n=t("div");if(void 0===n)return!1;n.contentEditable="true",n.innerHTML=e,n.style.whiteSpace="pre",n.style.userSelect="text",n.style.setProperty("-webkit-user-select","text"),n.style.setProperty("-moz-user-select","text"),n.style.setProperty("-ms-user-select","text"),globalThis.document.body.appendChild(n);var r=globalThis.getSelection(),o=globalThis.document.createRange(),i=function(t){try{null!==t.clipboardData&&"function"==typeof t.clipboardData.setData&&(t.preventDefault(),t.clipboardData.setData("text/html",e),t.clipboardData.setData("text/plain",e))}catch(t){}};l.add(globalThis.document,{type:"copy",callback:i,options:{once:!0,capture:!0}});try{if(null===r)return h(n,r,i),!1;r.removeAllRanges(),o.selectNodeContents(n),r.addRange(o);var a=globalThis.document.execCommand("copy");return h(n,r,i),a}catch(t){return h(n,r,i),!1}}(e)||function(t){var e=window.clipboardData;if(void 0!==e&&"function"==typeof e.setData)try{return e.setData("Text",t)}catch(t){return!1}return!1}(e)}function f(){return function(){var e=t("div");if(void 0===e)return null;e.contentEditable="true",globalThis.document.body.appendChild(e),e.focus();var n=null,r=function(t){try{null!==t.clipboardData&&"function"==typeof t.clipboardData.getData&&(t.preventDefault(),n=t.clipboardData.getData("text/html")||t.clipboardData.getData("text/plain")||null)}catch(t){}};l.add(globalThis.document,{type:"paste",callback:r,options:{once:!0,capture:!0}});try{return globalThis.document.execCommand("paste")||n||(n=e.innerHTML||e.textContent||null),v(e,r),n}catch(t){return v(e,r),null}}()||function(){var t=window.clipboardData;if(void 0!==t&&"function"==typeof t.getData)try{return t.getData("Text")||null}catch(t){return null}return null}()||""}function h(t,e,n){null!==e&&e.removeAllRanges(),globalThis.document.body.removeChild(t),l.remove(globalThis.document,{type:"copy",callback:n})}function v(t,e){globalThis.document.body.removeChild(t),l.remove(globalThis.document,{type:"paste",callback:e})}var b={installed:!1,name:"Clipboard",module:{copy:function(t){var e=s(t);return d()&&("write"in navigator.clipboard||"writeText"in navigator.clipboard)?function(t){try{if("ClipboardItem"in window&&"write"in navigator.clipboard)return navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([t],{type:"text/plain"})})]).then((function(){return!0})).catch((function(){return!1}));if("writeText"in navigator.clipboard)return navigator.clipboard.writeText(t).then((function(){return!0})).catch((function(){return!1}))}catch(t){return Promise.resolve(!1)}return Promise.resolve(!1)}(e).then((function(t){return!!t||p(e)})).catch((function(){return p(e)})):Promise.resolve(p(e))},paste:function(){return d()&&("read"in navigator.clipboard||"readText"in navigator.clipboard)?function(){try{if("ClipboardItem"in window&&"read"in navigator.clipboard)return navigator.clipboard.read().then((function(t){if(0===t.length)return Promise.resolve(null);for(var e=t[0],n=e.types,r=0;r<n.length;r++)if("text/html"===n[r])return e.getType("text/html").then((function(t){return t.text()})).catch((function(){return null}));for(r=0;r<n.length;r++)if("text/plain"===n[r])return e.getType("text/plain").then((function(t){return t.text()})).catch((function(){return null}));return Promise.resolve(null)})).catch((function(){return null}));if("readText"in navigator.clipboard)return navigator.clipboard.readText().then((function(t){return t})).catch((function(){return null}))}catch(t){return Promise.resolve(null)}return Promise.resolve(null)}().then((function(t){return null!==t?t:f()})).catch((function(){return f()})):Promise.resolve(f())}},Constants:{},Errors:{}};module.exports=b;
|