native-fn 1.0.61 → 1.0.62
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/index.d.ts +198 -0
- package/dist/native.cjs +32 -7
- package/dist/native.min.cjs +1 -1
- package/dist/native.min.mjs +1 -1
- package/dist/native.mjs +32 -7
- package/dist/native.umd.js +32 -7
- package/dist/native.umd.min.js +1 -1
- package/dist/plugin/app/index.cjs +134 -89
- package/dist/plugin/app/index.d.ts +59 -7
- package/dist/plugin/app/index.min.cjs +1 -1
- package/dist/plugin/app/index.min.mjs +1 -1
- package/dist/plugin/app/index.mjs +134 -89
- package/dist/plugin/app/index.umd.js +134 -89
- package/dist/plugin/app/index.umd.min.js +1 -1
- package/dist/plugin/app/src/constants/platform.d.ts +10 -0
- package/dist/plugin/app/src/plugin/app/utils/try-open-url.d.ts +15 -0
- package/dist/plugin/app/src/types/native.d.ts +8 -0
- package/dist/plugin/app/src/types/platform.d.ts +0 -3
- package/dist/plugin/camera/index.cjs +19 -6
- package/dist/plugin/camera/index.d.ts +150 -0
- package/dist/plugin/camera/index.min.cjs +1 -1
- package/dist/plugin/camera/index.min.mjs +1 -1
- package/dist/plugin/camera/index.mjs +19 -6
- package/dist/plugin/camera/index.umd.js +19 -6
- package/dist/plugin/camera/index.umd.min.js +1 -1
- package/dist/plugin/camera/src/constants/platform.d.ts +10 -0
- package/dist/plugin/camera/src/plugin/app/utils/try-open-url.d.ts +15 -0
- package/dist/plugin/camera/src/types/native.d.ts +8 -0
- package/dist/plugin/camera/src/types/platform.d.ts +0 -3
- package/dist/plugin/clipboard/index.cjs +225 -212
- package/dist/plugin/clipboard/index.d.ts +135 -0
- package/dist/plugin/clipboard/index.min.cjs +1 -1
- package/dist/plugin/clipboard/index.min.mjs +1 -1
- package/dist/plugin/clipboard/index.mjs +225 -212
- package/dist/plugin/clipboard/index.umd.js +225 -212
- package/dist/plugin/clipboard/index.umd.min.js +1 -1
- package/dist/plugin/clipboard/src/constants/platform.d.ts +10 -0
- package/dist/plugin/clipboard/src/plugin/app/utils/try-open-url.d.ts +15 -0
- package/dist/plugin/clipboard/src/types/native.d.ts +8 -0
- package/dist/plugin/clipboard/src/types/platform.d.ts +0 -3
- package/dist/plugin/fullscreen/index.cjs +26 -13
- package/dist/plugin/fullscreen/index.d.ts +119 -0
- package/dist/plugin/fullscreen/index.min.cjs +1 -1
- package/dist/plugin/fullscreen/index.min.mjs +1 -1
- package/dist/plugin/fullscreen/index.mjs +26 -13
- package/dist/plugin/fullscreen/index.umd.js +26 -13
- package/dist/plugin/fullscreen/index.umd.min.js +1 -1
- package/dist/plugin/fullscreen/src/constants/platform.d.ts +10 -0
- package/dist/plugin/fullscreen/src/plugin/app/utils/try-open-url.d.ts +15 -0
- package/dist/plugin/fullscreen/src/types/native.d.ts +8 -0
- package/dist/plugin/fullscreen/src/types/platform.d.ts +0 -3
- package/dist/plugin/theme/index.cjs +24 -11
- package/dist/plugin/theme/index.d.ts +150 -0
- package/dist/plugin/theme/index.min.cjs +1 -1
- package/dist/plugin/theme/index.min.mjs +1 -1
- package/dist/plugin/theme/index.mjs +24 -11
- package/dist/plugin/theme/index.umd.js +24 -11
- package/dist/plugin/theme/index.umd.min.js +1 -1
- package/dist/plugin/theme/src/constants/platform.d.ts +10 -0
- package/dist/plugin/theme/src/plugin/app/utils/try-open-url.d.ts +15 -0
- package/dist/plugin/theme/src/types/native.d.ts +8 -0
- package/dist/plugin/theme/src/types/platform.d.ts +0 -3
- package/dist/src/constants/platform.d.ts +10 -0
- package/dist/src/plugin/app/utils/try-open-url.d.ts +15 -0
- package/dist/src/types/native.d.ts +8 -0
- package/dist/src/types/platform.d.ts +0 -3
- package/package.json +1 -1
|
@@ -1,59 +1,5 @@
|
|
|
1
|
-
function createHiddenElement(tagName, focusable) {
|
|
2
|
-
if (focusable === void 0) { focusable = true; }
|
|
3
|
-
if (typeof globalThis.document === 'undefined')
|
|
4
|
-
return undefined;
|
|
5
|
-
var element = globalThis.document.createElement(tagName);
|
|
6
|
-
if ('width' in element)
|
|
7
|
-
element.width = '0';
|
|
8
|
-
if ('height' in element)
|
|
9
|
-
element.height = '0';
|
|
10
|
-
if ('border' in element)
|
|
11
|
-
element.border = '0';
|
|
12
|
-
if ('frameBorder' in element)
|
|
13
|
-
element.frameBorder = '0';
|
|
14
|
-
if ('scrolling' in element)
|
|
15
|
-
element.scrolling = 'no';
|
|
16
|
-
if ('cellPadding' in element)
|
|
17
|
-
element.cellPadding = '0';
|
|
18
|
-
if ('cellSpacing' in element)
|
|
19
|
-
element.cellSpacing = '0';
|
|
20
|
-
if ('frame' in element)
|
|
21
|
-
element.frame = 'void';
|
|
22
|
-
if ('rules' in element)
|
|
23
|
-
element.rules = 'none';
|
|
24
|
-
if ('noWrap' in element)
|
|
25
|
-
element.noWrap = true;
|
|
26
|
-
element.tabIndex = -1;
|
|
27
|
-
element.setAttribute('role', 'presentation');
|
|
28
|
-
if (focusable) {
|
|
29
|
-
element.style.width = '1px';
|
|
30
|
-
element.style.height = '1px';
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
element.setAttribute('aria-hidden', 'true');
|
|
34
|
-
element.style.width = '0';
|
|
35
|
-
element.style.height = '0';
|
|
36
|
-
element.style.zIndex = '-9999';
|
|
37
|
-
element.style.display = 'none';
|
|
38
|
-
element.style.visibility = 'hidden';
|
|
39
|
-
element.style.pointerEvents = 'none';
|
|
40
|
-
}
|
|
41
|
-
element.style.position = 'absolute';
|
|
42
|
-
element.style.top = '0';
|
|
43
|
-
element.style.left = '0';
|
|
44
|
-
element.style.padding = '0';
|
|
45
|
-
element.style.margin = '0';
|
|
46
|
-
element.style.border = 'none';
|
|
47
|
-
element.style.outline = 'none';
|
|
48
|
-
element.style.clip = 'rect(1px, 1px, 1px, 1px)';
|
|
49
|
-
element.style.clipPath = 'inset(50%)';
|
|
50
|
-
element.style.overflow = 'hidden';
|
|
51
|
-
element.style.whiteSpace = 'nowrap';
|
|
52
|
-
return element;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
1
|
function isSecureContext() {
|
|
56
|
-
if (
|
|
2
|
+
if (typeof globalThis.isSecureContext !== 'undefined')
|
|
57
3
|
return globalThis.isSecureContext;
|
|
58
4
|
var protocol = location.protocol;
|
|
59
5
|
var hostname = location.hostname;
|
|
@@ -63,148 +9,6 @@ function isSecureContext() {
|
|
|
63
9
|
hostname === '[::1]';
|
|
64
10
|
}
|
|
65
11
|
|
|
66
|
-
function capitalize(match) {
|
|
67
|
-
var groups = [];
|
|
68
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
69
|
-
groups[_i - 1] = arguments[_i];
|
|
70
|
-
}
|
|
71
|
-
var result = '';
|
|
72
|
-
for (var i = 0; i < groups.length - 2; i++) {
|
|
73
|
-
var arg = groups[i];
|
|
74
|
-
if (arg !== undefined)
|
|
75
|
-
result = result + arg.charAt(0).toUpperCase() + arg.slice(1);
|
|
76
|
-
}
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
function preventDefaultPolyfill() {
|
|
80
|
-
this.returnValue = false;
|
|
81
|
-
}
|
|
82
|
-
function stopPropagationPolyfill() {
|
|
83
|
-
this.cancelBubble = true;
|
|
84
|
-
}
|
|
85
|
-
var EVENT_TYPE_REGEXP = /(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;
|
|
86
|
-
var VENDORS = ['', 'webkit', 'moz', 'ms', 'MS', 'o', 'O'];
|
|
87
|
-
var LEGACY_TYPE_MAP = {
|
|
88
|
-
'wheel': ['wheel', 'mousewheel', 'DOMMouseScroll'],
|
|
89
|
-
'focus': ['focus', 'focusin'],
|
|
90
|
-
'blur': ['blur', 'focusout'],
|
|
91
|
-
'beforeinput': ['beforeinput', 'textInput'],
|
|
92
|
-
};
|
|
93
|
-
var EventListenerUtils = {
|
|
94
|
-
useStd: typeof globalThis.document !== 'undefined' && typeof globalThis.document.addEventListener === 'function',
|
|
95
|
-
add: function (target, eventListenerOptions) {
|
|
96
|
-
if (eventListenerOptions === void 0) { eventListenerOptions = { callback: null, options: false }; }
|
|
97
|
-
var callback = eventListenerOptions.callback;
|
|
98
|
-
if (target === undefined || callback === null)
|
|
99
|
-
return;
|
|
100
|
-
var type = EventListenerUtils.withVender(target, eventListenerOptions.type);
|
|
101
|
-
var options = eventListenerOptions.options;
|
|
102
|
-
if (typeof target.addEventListener === 'function') {
|
|
103
|
-
try {
|
|
104
|
-
return target.addEventListener(type, callback, options);
|
|
105
|
-
}
|
|
106
|
-
catch (_) {
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (typeof target.addListener === 'function') {
|
|
110
|
-
if (typeof target.matches === 'boolean') {
|
|
111
|
-
try {
|
|
112
|
-
return target.addListener(callback);
|
|
113
|
-
}
|
|
114
|
-
catch (_) {
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
try {
|
|
119
|
-
return target.addListener(type, callback);
|
|
120
|
-
}
|
|
121
|
-
catch (_) {
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function wrapper(event) {
|
|
126
|
-
if (event === undefined)
|
|
127
|
-
event = globalThis.event;
|
|
128
|
-
if (event === undefined)
|
|
129
|
-
return;
|
|
130
|
-
event.currentTarget = target;
|
|
131
|
-
if (typeof event.preventDefault !== 'function')
|
|
132
|
-
event.preventDefault = preventDefaultPolyfill;
|
|
133
|
-
if (typeof event.stopPropagation !== 'function')
|
|
134
|
-
event.stopPropagation = stopPropagationPolyfill;
|
|
135
|
-
if (typeof callback === 'function')
|
|
136
|
-
callback.call(target, event);
|
|
137
|
-
else if (callback && typeof callback.handleEvent === 'function')
|
|
138
|
-
callback.handleEvent.call(target, event);
|
|
139
|
-
}
|
|
140
|
-
if (typeof target.attachEvent === 'function') {
|
|
141
|
-
if (callback.__ieWrapper)
|
|
142
|
-
return target.attachEvent('on' + type, callback.__ieWrapper);
|
|
143
|
-
return target.attachEvent('on' + type, callback.__ieWrapper = wrapper);
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
remove: function (target, eventListenerOptions) {
|
|
147
|
-
if (eventListenerOptions === void 0) { eventListenerOptions = { callback: null, options: false }; }
|
|
148
|
-
var callback = eventListenerOptions.callback;
|
|
149
|
-
if (target === undefined || callback === null)
|
|
150
|
-
return;
|
|
151
|
-
var type = EventListenerUtils.withVender(target, eventListenerOptions.type);
|
|
152
|
-
var options = eventListenerOptions.options;
|
|
153
|
-
if (typeof target.removeEventListener === 'function') {
|
|
154
|
-
try {
|
|
155
|
-
return target.removeEventListener(type, callback, options);
|
|
156
|
-
}
|
|
157
|
-
catch (_) {
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (typeof target.removeListener === 'function') {
|
|
161
|
-
if (typeof target.matches === 'boolean') {
|
|
162
|
-
try {
|
|
163
|
-
return target.removeListener(callback);
|
|
164
|
-
}
|
|
165
|
-
catch (_) {
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
try {
|
|
170
|
-
return target.removeListener(type, callback);
|
|
171
|
-
}
|
|
172
|
-
catch (_) {
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (typeof target.detachEvent === 'function') {
|
|
177
|
-
var wrapper = callback.__ieWrapper;
|
|
178
|
-
if (wrapper !== undefined) {
|
|
179
|
-
target.detachEvent('on' + type, wrapper);
|
|
180
|
-
delete callback.__ieWrapper;
|
|
181
|
-
}
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
withVender: function (target, type) {
|
|
186
|
-
if (type === undefined)
|
|
187
|
-
return '';
|
|
188
|
-
if ('webkitEnterFullscreen' in target && ['webkitbeginfullscreen', 'webkitendfullscreen', 'webkitpresentationmodechanged'].indexOf(type) > -1)
|
|
189
|
-
return type;
|
|
190
|
-
var types;
|
|
191
|
-
if (type in LEGACY_TYPE_MAP)
|
|
192
|
-
types = LEGACY_TYPE_MAP[type];
|
|
193
|
-
else if (EVENT_TYPE_REGEXP.test(type))
|
|
194
|
-
types = [type, type.replace(EVENT_TYPE_REGEXP, capitalize)];
|
|
195
|
-
else
|
|
196
|
-
types = [type];
|
|
197
|
-
for (var i = 0; i < VENDORS.length; i++) {
|
|
198
|
-
for (var j = 0; j < types.length; j++) {
|
|
199
|
-
var name_1 = VENDORS[i] + types[j];
|
|
200
|
-
if (typeof target['on' + name_1] !== 'undefined')
|
|
201
|
-
return name_1;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return '';
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
12
|
function compareVersion(lhs, rhs) {
|
|
209
13
|
var pa = lhs.split('.');
|
|
210
14
|
var pb = rhs.split('.');
|
|
@@ -267,7 +71,10 @@ var Browsers;
|
|
|
267
71
|
Browsers["IE"] = "IE";
|
|
268
72
|
Browsers["SamsungInternet"] = "SamsungInternet";
|
|
269
73
|
})(Browsers || (Browsers = {}));
|
|
270
|
-
var userAgent = typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string' ? navigator.userAgent : '';
|
|
74
|
+
var userAgent = typeof globalThis.navigator !== 'undefined' && typeof globalThis.navigator.userAgent === 'string' ? globalThis.navigator.userAgent : '';
|
|
75
|
+
var IS_NODE_JS = typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined;
|
|
76
|
+
var IS_ELECTRON = (typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.electron !== undefined) || (/ electron\//i.test(userAgent));
|
|
77
|
+
var IS_REACT_NATIVE = typeof globalThis.navigator !== 'undefined' && globalThis.navigator.product === 'ReactNative';
|
|
271
78
|
var Platform = {
|
|
272
79
|
device: Devices.Unknown,
|
|
273
80
|
os: OS.Unknown,
|
|
@@ -282,9 +89,6 @@ var Platform = {
|
|
|
282
89
|
isDesktop: false,
|
|
283
90
|
isStandalone: false,
|
|
284
91
|
isWebview: /; ?wv|applewebkit(?!.*safari)/i.test(userAgent),
|
|
285
|
-
isNodeJS: typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined,
|
|
286
|
-
isElectron: (typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.electron !== undefined) || (/ electron\//i.test(userAgent)),
|
|
287
|
-
isReactNative: typeof navigator !== 'undefined' && navigator.product === 'ReactNative'
|
|
288
92
|
};
|
|
289
93
|
var OS_RESOLVER_MAP = [
|
|
290
94
|
[/windows nt (6\.[23]); arm/i, OS.Windows, resolveWindowsVersion],
|
|
@@ -594,7 +398,7 @@ for (var i = 0; i < BROWSER_RESOLVER_MAP.length; i++) {
|
|
|
594
398
|
break;
|
|
595
399
|
}
|
|
596
400
|
}
|
|
597
|
-
if (
|
|
401
|
+
if (IS_REACT_NATIVE) {
|
|
598
402
|
try {
|
|
599
403
|
var reactNative = require('react-native');
|
|
600
404
|
var platform = reactNative.Platform;
|
|
@@ -623,7 +427,7 @@ if (Platform.isReactNative) {
|
|
|
623
427
|
catch (_) {
|
|
624
428
|
}
|
|
625
429
|
}
|
|
626
|
-
if (
|
|
430
|
+
if (IS_NODE_JS) {
|
|
627
431
|
try {
|
|
628
432
|
var os = require('os');
|
|
629
433
|
var platform = os.platform();
|
|
@@ -653,6 +457,19 @@ if (Platform.isNodeJS) {
|
|
|
653
457
|
catch (_) {
|
|
654
458
|
}
|
|
655
459
|
}
|
|
460
|
+
document.addEventListener("deviceready", function () {
|
|
461
|
+
if (Platform.os === OS.Unknown && typeof globalThis.device !== 'undefined') {
|
|
462
|
+
switch (globalThis.device.platform) {
|
|
463
|
+
case 'Android':
|
|
464
|
+
Platform.os = OS.Android;
|
|
465
|
+
break;
|
|
466
|
+
case 'iOS':
|
|
467
|
+
Platform.os = OS.iOS;
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
Platform.osVersion = globalThis.device.version;
|
|
471
|
+
}
|
|
472
|
+
}, false);
|
|
656
473
|
if (navigator.userAgentData !== undefined && navigator.userAgentData.getHighEntropyValues !== undefined) {
|
|
657
474
|
navigator
|
|
658
475
|
.userAgentData
|
|
@@ -682,6 +499,208 @@ Platform.isMobile = Platform.device === Devices.Mobile;
|
|
|
682
499
|
Platform.isDesktop = Platform.device === Devices.Desktop;
|
|
683
500
|
Platform.isStandalone = getIsStandalone(Platform.os);
|
|
684
501
|
|
|
502
|
+
function createHiddenElement(tagName, focusable) {
|
|
503
|
+
if (focusable === void 0) { focusable = true; }
|
|
504
|
+
if (typeof globalThis.document === 'undefined')
|
|
505
|
+
return undefined;
|
|
506
|
+
var element = globalThis.document.createElement(tagName);
|
|
507
|
+
if ('width' in element)
|
|
508
|
+
element.width = '0';
|
|
509
|
+
if ('height' in element)
|
|
510
|
+
element.height = '0';
|
|
511
|
+
if ('border' in element)
|
|
512
|
+
element.border = '0';
|
|
513
|
+
if ('frameBorder' in element)
|
|
514
|
+
element.frameBorder = '0';
|
|
515
|
+
if ('scrolling' in element)
|
|
516
|
+
element.scrolling = 'no';
|
|
517
|
+
if ('cellPadding' in element)
|
|
518
|
+
element.cellPadding = '0';
|
|
519
|
+
if ('cellSpacing' in element)
|
|
520
|
+
element.cellSpacing = '0';
|
|
521
|
+
if ('frame' in element)
|
|
522
|
+
element.frame = 'void';
|
|
523
|
+
if ('rules' in element)
|
|
524
|
+
element.rules = 'none';
|
|
525
|
+
if ('noWrap' in element)
|
|
526
|
+
element.noWrap = true;
|
|
527
|
+
element.tabIndex = -1;
|
|
528
|
+
element.setAttribute('role', 'presentation');
|
|
529
|
+
if (focusable) {
|
|
530
|
+
element.style.width = '1px';
|
|
531
|
+
element.style.height = '1px';
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
element.setAttribute('aria-hidden', 'true');
|
|
535
|
+
element.style.width = '0';
|
|
536
|
+
element.style.height = '0';
|
|
537
|
+
element.style.zIndex = '-9999';
|
|
538
|
+
element.style.display = 'none';
|
|
539
|
+
element.style.visibility = 'hidden';
|
|
540
|
+
element.style.pointerEvents = 'none';
|
|
541
|
+
}
|
|
542
|
+
element.style.position = 'absolute';
|
|
543
|
+
element.style.top = '0';
|
|
544
|
+
element.style.left = '0';
|
|
545
|
+
element.style.padding = '0';
|
|
546
|
+
element.style.margin = '0';
|
|
547
|
+
element.style.border = 'none';
|
|
548
|
+
element.style.outline = 'none';
|
|
549
|
+
element.style.clip = 'rect(1px, 1px, 1px, 1px)';
|
|
550
|
+
element.style.clipPath = 'inset(50%)';
|
|
551
|
+
element.style.overflow = 'hidden';
|
|
552
|
+
element.style.whiteSpace = 'nowrap';
|
|
553
|
+
return element;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function capitalize(_) {
|
|
557
|
+
var groups = [];
|
|
558
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
559
|
+
groups[_i - 1] = arguments[_i];
|
|
560
|
+
}
|
|
561
|
+
var result = '';
|
|
562
|
+
for (var i = 0; i < groups.length - 2; i++) {
|
|
563
|
+
var arg = groups[i];
|
|
564
|
+
if (arg !== undefined)
|
|
565
|
+
result = result + arg.charAt(0).toUpperCase() + arg.slice(1);
|
|
566
|
+
}
|
|
567
|
+
return result;
|
|
568
|
+
}
|
|
569
|
+
function preventDefaultPolyfill() {
|
|
570
|
+
this.returnValue = false;
|
|
571
|
+
}
|
|
572
|
+
function stopPropagationPolyfill() {
|
|
573
|
+
this.cancelBubble = true;
|
|
574
|
+
}
|
|
575
|
+
var EVENT_TYPE_REGEXP = /(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;
|
|
576
|
+
var VENDORS = ['', 'webkit', 'moz', 'ms', 'MS', 'o', 'O'];
|
|
577
|
+
var LEGACY_TYPE_MAP = {
|
|
578
|
+
'wheel': ['wheel', 'mousewheel', 'DOMMouseScroll'],
|
|
579
|
+
'focus': ['focus', 'focusin'],
|
|
580
|
+
'blur': ['blur', 'focusout'],
|
|
581
|
+
'beforeinput': ['beforeinput', 'textInput'],
|
|
582
|
+
};
|
|
583
|
+
var EventListenerUtils = {
|
|
584
|
+
useStd: typeof globalThis.document !== 'undefined' && typeof globalThis.document.addEventListener === 'function',
|
|
585
|
+
add: function (target, eventListenerOptions) {
|
|
586
|
+
if (eventListenerOptions === void 0) { eventListenerOptions = { callback: null, options: false }; }
|
|
587
|
+
var callback = eventListenerOptions.callback;
|
|
588
|
+
if (target === undefined || callback === null)
|
|
589
|
+
return;
|
|
590
|
+
var type = EventListenerUtils.withVender(target, eventListenerOptions.type);
|
|
591
|
+
var options = eventListenerOptions.options;
|
|
592
|
+
if (typeof target.addEventListener === 'function') {
|
|
593
|
+
try {
|
|
594
|
+
return target.addEventListener(type, callback, options);
|
|
595
|
+
}
|
|
596
|
+
catch (_) {
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
if (typeof target.addListener === 'function') {
|
|
600
|
+
if (typeof target.matches === 'boolean') {
|
|
601
|
+
try {
|
|
602
|
+
return target.addListener(callback);
|
|
603
|
+
}
|
|
604
|
+
catch (_) {
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
try {
|
|
609
|
+
return target.addListener(type, callback);
|
|
610
|
+
}
|
|
611
|
+
catch (_) {
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function wrapper(event) {
|
|
616
|
+
if (event === undefined)
|
|
617
|
+
event = globalThis.event;
|
|
618
|
+
if (event === undefined)
|
|
619
|
+
return;
|
|
620
|
+
event.currentTarget = target;
|
|
621
|
+
if (typeof event.preventDefault !== 'function')
|
|
622
|
+
event.preventDefault = preventDefaultPolyfill;
|
|
623
|
+
if (typeof event.stopPropagation !== 'function')
|
|
624
|
+
event.stopPropagation = stopPropagationPolyfill;
|
|
625
|
+
if (typeof callback === 'function')
|
|
626
|
+
callback.call(target, event);
|
|
627
|
+
else if (callback && typeof callback.handleEvent === 'function')
|
|
628
|
+
callback.handleEvent.call(target, event);
|
|
629
|
+
}
|
|
630
|
+
if (typeof target.attachEvent === 'function') {
|
|
631
|
+
if (callback.__ieWrapper)
|
|
632
|
+
return target.attachEvent('on' + type, callback.__ieWrapper);
|
|
633
|
+
return target.attachEvent('on' + type, callback.__ieWrapper = wrapper);
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
remove: function (target, eventListenerOptions) {
|
|
637
|
+
if (eventListenerOptions === void 0) { eventListenerOptions = { callback: null, options: false }; }
|
|
638
|
+
var callback = eventListenerOptions.callback;
|
|
639
|
+
if (target === undefined || callback === null)
|
|
640
|
+
return;
|
|
641
|
+
var type = EventListenerUtils.withVender(target, eventListenerOptions.type);
|
|
642
|
+
var options = eventListenerOptions.options;
|
|
643
|
+
if (typeof target.removeEventListener === 'function') {
|
|
644
|
+
try {
|
|
645
|
+
return target.removeEventListener(type, callback, options);
|
|
646
|
+
}
|
|
647
|
+
catch (_) {
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (typeof target.removeListener === 'function') {
|
|
651
|
+
if (typeof target.matches === 'boolean') {
|
|
652
|
+
try {
|
|
653
|
+
return target.removeListener(callback);
|
|
654
|
+
}
|
|
655
|
+
catch (_) {
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
try {
|
|
660
|
+
return target.removeListener(type, callback);
|
|
661
|
+
}
|
|
662
|
+
catch (_) {
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
if (typeof target.detachEvent === 'function') {
|
|
667
|
+
var wrapper = callback.__ieWrapper;
|
|
668
|
+
if (wrapper !== undefined) {
|
|
669
|
+
target.detachEvent('on' + type, wrapper);
|
|
670
|
+
delete callback.__ieWrapper;
|
|
671
|
+
}
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
withVender: function (target, type) {
|
|
676
|
+
if (type === undefined)
|
|
677
|
+
return '';
|
|
678
|
+
if (target === globalThis.document && ['deviceready', 'pause', 'resume', 'backbutton', 'menubutton', 'searchbutton', 'startcallbutton', 'endcallbutton', 'volumedownbutton', 'volumeupbutton', 'activated', 'cordovacallbackerror'].indexOf(type) > -1)
|
|
679
|
+
return type;
|
|
680
|
+
if (typeof target.webkitEnterFullscreen !== 'undefined' && ['webkitbeginfullscreen', 'webkitendfullscreen', 'webkitpresentationmodechanged'].indexOf(type) > -1)
|
|
681
|
+
return type;
|
|
682
|
+
var types;
|
|
683
|
+
if (type in LEGACY_TYPE_MAP)
|
|
684
|
+
types = LEGACY_TYPE_MAP[type];
|
|
685
|
+
else if (EVENT_TYPE_REGEXP.test(type))
|
|
686
|
+
types = [type, type.replace(EVENT_TYPE_REGEXP, capitalize)];
|
|
687
|
+
else
|
|
688
|
+
types = [type];
|
|
689
|
+
for (var i = 0; i < VENDORS.length; i++) {
|
|
690
|
+
for (var j = 0; j < types.length; j++) {
|
|
691
|
+
var name_1 = VENDORS[i] + types[j];
|
|
692
|
+
if (typeof target['on' + name_1] !== 'undefined')
|
|
693
|
+
return name_1;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
return '';
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
var Clipboard = {
|
|
701
|
+
copy: copy,
|
|
702
|
+
paste: paste
|
|
703
|
+
};
|
|
685
704
|
function isObject(item) {
|
|
686
705
|
return item !== null && typeof item === 'object';
|
|
687
706
|
}
|
|
@@ -692,7 +711,7 @@ function isSerializable(item) {
|
|
|
692
711
|
return isObject(item) || isArray(item);
|
|
693
712
|
}
|
|
694
713
|
function isElement(item) {
|
|
695
|
-
return isObject(item) && '
|
|
714
|
+
return isObject(item) && typeof item.innerText !== 'undefined';
|
|
696
715
|
}
|
|
697
716
|
function convertToString(item) {
|
|
698
717
|
if (isElement(item)) {
|
|
@@ -722,7 +741,7 @@ function supportsClipboardReadAPI() {
|
|
|
722
741
|
}
|
|
723
742
|
function copy(item) {
|
|
724
743
|
var text = convertToString(item);
|
|
725
|
-
if (
|
|
744
|
+
if (IS_ELECTRON) {
|
|
726
745
|
return copyViaElectron(text);
|
|
727
746
|
}
|
|
728
747
|
else if (supportsClipboardWriteAPI()) {
|
|
@@ -849,7 +868,7 @@ function copyViaLegacy(text) {
|
|
|
849
868
|
return copyViaSelection(text) || copyViaClipboardData(text);
|
|
850
869
|
}
|
|
851
870
|
function paste() {
|
|
852
|
-
if (
|
|
871
|
+
if (IS_ELECTRON) {
|
|
853
872
|
return pasteViaElectron();
|
|
854
873
|
}
|
|
855
874
|
else if (supportsClipboardReadAPI()) {
|
|
@@ -994,12 +1013,6 @@ function cleanupPaste(div, onPaste) {
|
|
|
994
1013
|
globalThis.document.body.removeChild(div);
|
|
995
1014
|
EventListenerUtils.remove(globalThis.document, { type: 'paste', callback: onPaste });
|
|
996
1015
|
}
|
|
997
|
-
var ClipboardUtils = {
|
|
998
|
-
copy: copy,
|
|
999
|
-
paste: paste
|
|
1000
|
-
};
|
|
1001
|
-
|
|
1002
|
-
var Clipboard = ClipboardUtils;
|
|
1003
1016
|
|
|
1004
1017
|
var NativeClipboardPlugin = {
|
|
1005
1018
|
installed: false,
|