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