@enact/core 4.9.2 → 5.0.0-alpha.2
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/CHANGELOG.md +18 -0
- package/dispatcher/dispatcher.js +1 -1
- package/handle/handle.js +1 -1
- package/handle/tests/handle-specs.js +20 -24
- package/hoc/hoc.js +1 -1
- package/hoc/tests/hoc-specs.js +3 -3
- package/internal/ApiDecorator/ApiDecorator.js +21 -23
- package/internal/ApiDecorator/tests/ApiDecorator-specs.js +23 -27
- package/internal/Registry/tests/Registry-specs.js +20 -24
- package/internal/WithRef/WithRef.js +4 -4
- package/internal/WithRef/tests/WithRef-specs.js +17 -19
- package/internal/deprecate/tests/deprecate-specs.js +1 -1
- package/internal/prop-types/prop-types.js +1 -1
- package/internal/prop-types/tests/prop-types-specs.js +24 -32
- package/keymap/keymap.js +1 -1
- package/keymap/tests/keymap-specs.js +1 -1
- package/kind/kind.js +18 -20
- package/kind/styles.js +1 -1
- package/kind/tests/computed-specs.js +1 -1
- package/kind/tests/kind-specs.js +11 -11
- package/kind/tests/styles-specs.js +1 -1
- package/package.json +1 -1
- package/platform/platform.d.ts +1 -22
- package/platform/platform.js +8 -310
- package/platform/tests/platform-specs.js +10 -189
- package/snapshot/snapshot.js +1 -1
- package/useChainRefs/tests/useChainRefs-specs.js +6 -6
- package/useChainRefs/useChainRefs.js +1 -1
- package/useClass/tests/useClass-specs.js +5 -5
- package/useClass/useClass.js +1 -1
- package/useHandlers/Handlers.js +5 -6
- package/useHandlers/tests/useHandlers-specs.js +3 -3
- package/useHandlers/useHandlers.js +1 -1
- package/usePublicClassNames/tests/usePublicClassNames-specs.js +1 -1
- package/util/Job.js +6 -7
- package/util/tests/Job-specs.js +1 -1
- package/util/util.js +2 -2
package/platform/platform.js
CHANGED
|
@@ -5,18 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.platform = exports.parseUserAgent = exports.detect = exports["default"] = void 0;
|
|
7
7
|
var _deprecate = _interopRequireDefault(require("../internal/deprecate"));
|
|
8
|
-
function _interopRequireDefault(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
13
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
14
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
15
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
19
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* global globalThis */ /**
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
/* global globalThis */
|
|
10
|
+
/**
|
|
20
11
|
* Utilities for detecting basic platform capabilities.
|
|
21
12
|
*
|
|
22
13
|
* @module core/platform
|
|
@@ -24,6 +15,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
24
15
|
* @exports platform
|
|
25
16
|
* @public
|
|
26
17
|
*/
|
|
18
|
+
|
|
27
19
|
// Refer the following for more details: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
|
|
28
20
|
var browserEnvironment = function browserEnvironment() {
|
|
29
21
|
return !!globalThis.window;
|
|
@@ -43,238 +35,6 @@ var deviceTouchScreen = function deviceTouchScreen() {
|
|
|
43
35
|
(_globalThis$matchMedi = globalThis.matchMedia) === null || _globalThis$matchMedi === void 0 || (_globalThis$matchMedi = _globalThis$matchMedi.call(globalThis, "(any-pointer: coarse)")) === null || _globalThis$matchMedi === void 0 ? void 0 : _globalThis$matchMedi.matches));
|
|
44
36
|
};
|
|
45
37
|
|
|
46
|
-
/*
|
|
47
|
-
* Legacy Code to be removed in the next major release
|
|
48
|
-
*/
|
|
49
|
-
var hasGesture = function hasGesture() {
|
|
50
|
-
return Boolean('ongesturestart' in window ||
|
|
51
|
-
// non-standard and no major browser supports gesture events
|
|
52
|
-
'onmsgesturestart' in window && (
|
|
53
|
-
// Internet Explorer 10 only
|
|
54
|
-
window.navigator.msMaxTouchPoints > 1 ||
|
|
55
|
-
// Internet Explorer 10 only
|
|
56
|
-
window.navigator.maxTouchPoints > 1));
|
|
57
|
-
};
|
|
58
|
-
var hasTouch = function hasTouch() {
|
|
59
|
-
return Boolean(featureTouchEvent() || 'ontouchstart' in window ||
|
|
60
|
-
// featureTouchEvent covers recent Firefox and Safari also, so no need when we deprecate old browsers
|
|
61
|
-
window.navigator.msMaxTouchPoints ||
|
|
62
|
-
// Internet Explorer 10 only
|
|
63
|
-
window.navigator.msManipulationViewsEnabled && window.navigator.maxTouchPoints // Internet Explorer only
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
var webOSVersion = {
|
|
67
|
-
38: 3,
|
|
68
|
-
53: 4,
|
|
69
|
-
68: 5,
|
|
70
|
-
79: 6
|
|
71
|
-
};
|
|
72
|
-
var platforms = [
|
|
73
|
-
// Windows Phone 7 - 10
|
|
74
|
-
{
|
|
75
|
-
platform: 'windowsPhone',
|
|
76
|
-
regex: /Windows Phone (?:OS )?(\d+)[.\d]+/
|
|
77
|
-
},
|
|
78
|
-
// Edge
|
|
79
|
-
{
|
|
80
|
-
platform: 'edge',
|
|
81
|
-
regex: /Chrome\/(\d+)[.\d]+.*Edg(?:e|A|iOS)?\/(\d+)[.\d]+/
|
|
82
|
-
}, {
|
|
83
|
-
platform: 'edge',
|
|
84
|
-
regex: /Edg(?:e|A|iOS)?\/(\d+)[.\d]+/
|
|
85
|
-
},
|
|
86
|
-
// Android 4+ using Chrome
|
|
87
|
-
{
|
|
88
|
-
platform: 'androidChrome',
|
|
89
|
-
regex: /Android .* Chrome\/(\d+)[.\d]+/
|
|
90
|
-
},
|
|
91
|
-
// Android 2 - 4
|
|
92
|
-
{
|
|
93
|
-
platform: 'android',
|
|
94
|
-
regex: /Android(?:\s|\/)(\d+)/
|
|
95
|
-
},
|
|
96
|
-
// Kindle Fire
|
|
97
|
-
// Force version to 2, (desktop mode does not list android version)
|
|
98
|
-
{
|
|
99
|
-
platform: 'android',
|
|
100
|
-
regex: /Silk\/1./,
|
|
101
|
-
forceVersion: 2,
|
|
102
|
-
extra: {
|
|
103
|
-
silk: 1
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
// Kindle Fire HD (Silk versions 2 or 3)
|
|
107
|
-
// Force version to 4
|
|
108
|
-
{
|
|
109
|
-
platform: 'android',
|
|
110
|
-
regex: /Silk\/2./,
|
|
111
|
-
forceVersion: 4,
|
|
112
|
-
extra: {
|
|
113
|
-
silk: 2
|
|
114
|
-
}
|
|
115
|
-
}, {
|
|
116
|
-
platform: 'android',
|
|
117
|
-
regex: /Silk\/3./,
|
|
118
|
-
forceVersion: 4,
|
|
119
|
-
extra: {
|
|
120
|
-
silk: 3
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
// IE 8 - 10
|
|
124
|
-
{
|
|
125
|
-
platform: 'ie',
|
|
126
|
-
regex: /MSIE (\d+)/
|
|
127
|
-
},
|
|
128
|
-
// IE 11
|
|
129
|
-
{
|
|
130
|
-
platform: 'ie',
|
|
131
|
-
regex: /Trident\/.*; rv:(\d+)/
|
|
132
|
-
},
|
|
133
|
-
// iOS 3 - 5
|
|
134
|
-
// Apple likes to make this complicated
|
|
135
|
-
{
|
|
136
|
-
platform: 'ios',
|
|
137
|
-
regex: /iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/
|
|
138
|
-
},
|
|
139
|
-
// LG webOS
|
|
140
|
-
{
|
|
141
|
-
platform: 'webos',
|
|
142
|
-
regex: /Web0S;.*Safari\/537.41/,
|
|
143
|
-
forceVersion: 1
|
|
144
|
-
}, {
|
|
145
|
-
platform: 'webos',
|
|
146
|
-
regex: /Web0S;.*Safari\/538.2/,
|
|
147
|
-
forceVersion: 2
|
|
148
|
-
}, {
|
|
149
|
-
platform: 'webos',
|
|
150
|
-
regex: /Web0S;.*Chrome\/(\d+)/
|
|
151
|
-
},
|
|
152
|
-
// LG webOS indeterminate versions
|
|
153
|
-
{
|
|
154
|
-
platform: 'webos',
|
|
155
|
-
regex: /Web0S;/,
|
|
156
|
-
forceVersion: -1
|
|
157
|
-
},
|
|
158
|
-
// LuneOS
|
|
159
|
-
{
|
|
160
|
-
platform: 'webos',
|
|
161
|
-
regex: /LuneOS/,
|
|
162
|
-
forceVersion: -1,
|
|
163
|
-
extra: {
|
|
164
|
-
luneos: 1
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
// Palm/HP/Open webOS
|
|
168
|
-
{
|
|
169
|
-
platform: 'webos',
|
|
170
|
-
regex: /WebAppManager|Isis|webOS\./,
|
|
171
|
-
forceVersion: -1,
|
|
172
|
-
extra: {
|
|
173
|
-
legacy: 4
|
|
174
|
-
}
|
|
175
|
-
}, {
|
|
176
|
-
platform: 'webos',
|
|
177
|
-
regex: /(?:web|hpw)OS\/1/,
|
|
178
|
-
forceVersion: -1,
|
|
179
|
-
extra: {
|
|
180
|
-
legacy: 1
|
|
181
|
-
}
|
|
182
|
-
}, {
|
|
183
|
-
platform: 'webos',
|
|
184
|
-
regex: /(?:web|hpw)OS\/2/,
|
|
185
|
-
forceVersion: -1,
|
|
186
|
-
extra: {
|
|
187
|
-
legacy: 2
|
|
188
|
-
}
|
|
189
|
-
}, {
|
|
190
|
-
platform: 'webos',
|
|
191
|
-
regex: /(?:web|hpw)OS\/3/,
|
|
192
|
-
forceVersion: -1,
|
|
193
|
-
extra: {
|
|
194
|
-
legacy: 3
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
// desktop Safari
|
|
198
|
-
{
|
|
199
|
-
platform: 'safari',
|
|
200
|
-
regex: /Version\/(\d+)[.\d]+\s+Safari/
|
|
201
|
-
},
|
|
202
|
-
// desktop Chrome
|
|
203
|
-
{
|
|
204
|
-
platform: 'chrome',
|
|
205
|
-
regex: /Chrome\/(\d+)[.\d]+/
|
|
206
|
-
},
|
|
207
|
-
// Firefox on Android
|
|
208
|
-
{
|
|
209
|
-
platform: 'androidFirefox',
|
|
210
|
-
regex: /Android;.*Firefox\/(\d+)/
|
|
211
|
-
},
|
|
212
|
-
// FirefoxOS
|
|
213
|
-
{
|
|
214
|
-
platform: 'firefoxOS',
|
|
215
|
-
regex: /Mobile;.*Firefox\/(\d+)/
|
|
216
|
-
},
|
|
217
|
-
// desktop Firefox
|
|
218
|
-
{
|
|
219
|
-
platform: 'firefox',
|
|
220
|
-
regex: /Firefox\/(\d+)/
|
|
221
|
-
},
|
|
222
|
-
// Blackberry Playbook
|
|
223
|
-
{
|
|
224
|
-
platform: 'blackberry',
|
|
225
|
-
regex: /PlayBook/i,
|
|
226
|
-
forceVersion: 2
|
|
227
|
-
},
|
|
228
|
-
// Blackberry 10+
|
|
229
|
-
{
|
|
230
|
-
platform: 'blackberry',
|
|
231
|
-
regex: /BB1\d;.*Version\/(\d+\.\d+)/
|
|
232
|
-
},
|
|
233
|
-
// Tizen
|
|
234
|
-
{
|
|
235
|
-
platform: 'tizen',
|
|
236
|
-
regex: /Tizen (\d+)/
|
|
237
|
-
}];
|
|
238
|
-
var parseUserAgentLegacy = function parseUserAgentLegacy(userAgent) {
|
|
239
|
-
var plat = {
|
|
240
|
-
gesture: hasGesture(),
|
|
241
|
-
node: false,
|
|
242
|
-
touch: hasTouch(),
|
|
243
|
-
touchscreen: deviceTouchScreen(),
|
|
244
|
-
unknown: true
|
|
245
|
-
};
|
|
246
|
-
for (var i = 0, p, m, v; p = platforms[i]; i++) {
|
|
247
|
-
m = p.regex.exec(userAgent);
|
|
248
|
-
if (m) {
|
|
249
|
-
plat.unknown = false;
|
|
250
|
-
if ('forceVersion' in p) {
|
|
251
|
-
v = p.forceVersion;
|
|
252
|
-
} else if (p.platform === 'webos') {
|
|
253
|
-
v = webOSVersion[m[1]] || -1;
|
|
254
|
-
if (v >= 7 || v === -1) {
|
|
255
|
-
plat.chrome = Number(m[1]);
|
|
256
|
-
}
|
|
257
|
-
} else if (p.platform === 'edge' && m[2]) {
|
|
258
|
-
plat.chrome = Number(m[1]);
|
|
259
|
-
v = Number(m[2]);
|
|
260
|
-
} else {
|
|
261
|
-
v = Number(m[1]);
|
|
262
|
-
}
|
|
263
|
-
plat[p.platform] = v;
|
|
264
|
-
if (p.extra) {
|
|
265
|
-
plat = _objectSpread(_objectSpread({}, plat), p.extra);
|
|
266
|
-
}
|
|
267
|
-
plat.platformName = p.platform;
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
return plat;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
/*
|
|
275
|
-
* The end of Legacy Code to be removed in the next major release
|
|
276
|
-
*/
|
|
277
|
-
|
|
278
38
|
// Refer https://www.whatismybrowser.com/guides/the-latest-user-agent/ for latest user agents of major browsers
|
|
279
39
|
var userAgentPatterns = [
|
|
280
40
|
// Normal cases except iOS
|
|
@@ -331,13 +91,11 @@ var parseUserAgent = exports.parseUserAgent = function parseUserAgent(userAgent)
|
|
|
331
91
|
// deprecation warning for browser versions older than our support policy
|
|
332
92
|
if (supportedVersions[detectedInfo.browserName] > detectedInfo.browserVersion) {
|
|
333
93
|
(0, _deprecate["default"])({
|
|
334
|
-
name: "supporting ".concat(detectedInfo.browserName, " version
|
|
94
|
+
name: "supporting ".concat(detectedInfo.browserName, " version older than ").concat(supportedVersions[detectedInfo.browserName]),
|
|
335
95
|
until: '5.0.0'
|
|
336
96
|
});
|
|
337
97
|
}
|
|
338
|
-
|
|
339
|
-
// Merge legacy platform info
|
|
340
|
-
return _objectSpread(_objectSpread({}, parseUserAgentLegacy(userAgent)), detectedInfo);
|
|
98
|
+
return detectedInfo;
|
|
341
99
|
};
|
|
342
100
|
|
|
343
101
|
/**
|
|
@@ -345,18 +103,11 @@ var parseUserAgent = exports.parseUserAgent = function parseUserAgent(userAgent)
|
|
|
345
103
|
* @property {String} browserName - The name of the detected browser
|
|
346
104
|
* @property {Number} browserVersion - The version of the detected browser
|
|
347
105
|
* @property {Number} chrome - The version of the detected browser, if chrome browser is detected
|
|
348
|
-
* @property {Object} [extra] - Additional information about the detected platform. Deprecated: will be removed in 5.0.0.
|
|
349
106
|
* @property {Number} firefox - The version of the detected browser, if firefox browser is detected
|
|
350
|
-
* @property {Boolean} gesture - `true` if the platform has native double-finger events. Deprecated: will be removed in 5.0.0.
|
|
351
|
-
* @property {Boolean} node - `true` only if `window` is `undefined`. Deprecated: will be removed in 5.0.0. Use `type` instead.
|
|
352
|
-
* @property {String} [platformName] - The name of the platform, if detected. Deprecated: will be removed in 5.0.0. Use `browserName` instead for browser names.
|
|
353
107
|
* @property {Number} safari - The version of the detected browser, if safari browser is detected
|
|
354
|
-
* @property {Boolean} touch - `true` if the platform has native single-finger events. Deprecated: will be removed in 5.0.0. Use `touchEvent` instead.
|
|
355
108
|
* @property {Boolean} touchEvent - `true` if the browser has native touch events
|
|
356
|
-
* @property {Boolean} touchscreen - `true` if the platform has a touch screen. Deprecated: will be removed in 5.0.0. Use `touchScreen` instead.
|
|
357
109
|
* @property {Boolean} touchScreen - `true` if the platform has a touch screen
|
|
358
110
|
* @property {String} type - The type of the detected platform. One of 'desktop', 'mobile', 'webos', 'node', or 'unknown'
|
|
359
|
-
* @property {Boolean} unknown - `true` for any unknown system. Deprecated: will be removed in 5.0.0. Use `type` instead.
|
|
360
111
|
*
|
|
361
112
|
* @memberof core/platform
|
|
362
113
|
* @public
|
|
@@ -372,7 +123,7 @@ var detectedPlatform = null;
|
|
|
372
123
|
* @public
|
|
373
124
|
*/
|
|
374
125
|
var detect = exports.detect = function detect() {
|
|
375
|
-
if (detectedPlatform !== null) {
|
|
126
|
+
if (detectedPlatform !== null && !(process.env.NODE_ENV !== "production")) {
|
|
376
127
|
// once detected, don't bother detecting again
|
|
377
128
|
return detectedPlatform;
|
|
378
129
|
}
|
|
@@ -384,12 +135,6 @@ var detect = exports.detect = function detect() {
|
|
|
384
135
|
} else {
|
|
385
136
|
// node or compatible environment (e.g. prerendering or snapshot runs)
|
|
386
137
|
detectedPlatform = {
|
|
387
|
-
// the following properties are deprecated and will be removed in the next major release
|
|
388
|
-
gesture: false,
|
|
389
|
-
node: true,
|
|
390
|
-
touch: false,
|
|
391
|
-
unknown: true,
|
|
392
|
-
// the following properties are new and will be available in the next major release
|
|
393
138
|
type: 'node',
|
|
394
139
|
browserName: 'unknown',
|
|
395
140
|
browserVersion: 0 /* magic number for unknown */
|
|
@@ -412,57 +157,10 @@ var detect = exports.detect = function detect() {
|
|
|
412
157
|
* @public
|
|
413
158
|
*/
|
|
414
159
|
var platform = exports.platform = {};
|
|
415
|
-
[
|
|
416
|
-
// the following properties are deprecated and will be removed in the next major release
|
|
417
|
-
'gesture', 'node', 'platformName', 'touch', 'touchscreen', 'unknown',
|
|
418
|
-
// the following properties are new and will be available in the next major release
|
|
419
|
-
'browserName', 'browserVersion', 'touchEvent', 'touchScreen', 'type'].concat(_toConsumableArray(new Set(platforms.map(function (p) {
|
|
420
|
-
return p.platform;
|
|
421
|
-
})))).forEach(function (name) {
|
|
160
|
+
['browserName', 'browserVersion', 'chrome', 'firefox', 'safari', 'touchEvent', 'touchScreen', 'type'].forEach(function (name) {
|
|
422
161
|
Object.defineProperty(platform, name, {
|
|
423
162
|
enumerable: true,
|
|
424
163
|
get: function get() {
|
|
425
|
-
if (name === 'gesture' || name === 'unknown') {
|
|
426
|
-
(0, _deprecate["default"])({
|
|
427
|
-
name: name,
|
|
428
|
-
until: '5.0.0'
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
if (name === 'node') {
|
|
432
|
-
(0, _deprecate["default"])({
|
|
433
|
-
name: name,
|
|
434
|
-
until: '5.0.0',
|
|
435
|
-
replacedBy: 'type'
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
if (name === 'platformName') {
|
|
439
|
-
(0, _deprecate["default"])({
|
|
440
|
-
name: name,
|
|
441
|
-
until: '5.0.0',
|
|
442
|
-
replacedBy: 'browserName'
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
if (name === 'touch') {
|
|
446
|
-
(0, _deprecate["default"])({
|
|
447
|
-
name: name,
|
|
448
|
-
until: '5.0.0',
|
|
449
|
-
replacedBy: 'touchEvent'
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
if (name === 'touchscreen') {
|
|
453
|
-
(0, _deprecate["default"])({
|
|
454
|
-
name: name,
|
|
455
|
-
until: '5.0.0',
|
|
456
|
-
replacedBy: 'touchScreen'
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
if (name === 'webos') {
|
|
460
|
-
(0, _deprecate["default"])({
|
|
461
|
-
name: name,
|
|
462
|
-
message: 'Refer `@enact/webos`\'s `platform` for webOS specific information.',
|
|
463
|
-
until: '5.0.0'
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
164
|
var p = detect();
|
|
467
165
|
return p[name];
|
|
468
166
|
}
|
|
@@ -1,187 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _platform = require("../platform");
|
|
4
|
-
|
|
5
|
-
describe('parseUserAgent for webOS', function () {
|
|
6
|
-
// From http://webostv.developer.lge.com/discover/specifications/web-engine/
|
|
7
|
-
var webOSTVNext = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 WebAppManager';
|
|
8
|
-
var webOSTV6 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3440.106 Safari/537.36 WebAppManager';
|
|
9
|
-
var webOSTV5 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 WebAppManager';
|
|
10
|
-
var webOSTV4 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.1785.34 Safari/537.36 WebAppManager';
|
|
11
|
-
var webOSTV3 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.1.1 Chrome/38.0.2125.122 Safari/537.36 WebAppManager';
|
|
12
|
-
var webOSTV2 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/538.2 (KHTML, like Gecko) Large Screen WebAppManager Safari/538.2';
|
|
13
|
-
var webOSTV1 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.41 (KHTML, like Gecko) Large Screen WebAppManager Safari/537.41';
|
|
4
|
+
/* global globalThis */
|
|
14
5
|
|
|
15
|
-
|
|
16
|
-
var LuneOS2 = 'Mozilla/5.0 (LuneOS, like webOS/3.0.5; Tablet) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.9.2 Chrome/56.0.2924.103 Safari/537.36';
|
|
17
|
-
var LuneOS1 = 'Mozilla/5.0 (LuneOS, like webOS/3.0.5; Tablet) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.6.2 Chrome/45.0.2454.103 Safari/537.36';
|
|
18
|
-
var webOS10 = 'Mozilla/5.0 (webOS/1.0; U; en-US) AppleWebKit/525.27.1 (KHTML, like Geko) Version/1.0 Safari/525.27.1 Pre/1.0';
|
|
19
|
-
var webOS11 = 'Mozilla/5.0 (webOS/1.1; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0';
|
|
20
|
-
var webOS12 = 'Mozilla/5.0 (webOS/1.2; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0';
|
|
21
|
-
var webOS13 = 'Mozilla/5.0 (webOS/1.3.1; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0';
|
|
22
|
-
var webOS1351 = 'Mozilla/5.0 (webOS/1.3.5.1; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.1';
|
|
23
|
-
var webOS2 = 'Mozilla/5.0 (webOS/2.0.1; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pre/1.2';
|
|
24
|
-
var webOSOther = 'Mozilla/5.0 (Web0S; Linux) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36 WebAppManager';
|
|
25
|
-
test('should return webOS 1', function () {
|
|
26
|
-
var expected = {
|
|
27
|
-
webos: 1
|
|
28
|
-
};
|
|
29
|
-
var actual = (0, _platform.parseUserAgent)(webOSTV1);
|
|
30
|
-
expect(actual).toMatchObject(expected);
|
|
31
|
-
});
|
|
32
|
-
test('should return webOS 2', function () {
|
|
33
|
-
var expected = {
|
|
34
|
-
webos: 2
|
|
35
|
-
};
|
|
36
|
-
var actual = (0, _platform.parseUserAgent)(webOSTV2);
|
|
37
|
-
expect(actual).toMatchObject(expected);
|
|
38
|
-
});
|
|
39
|
-
test('should return webOS 3', function () {
|
|
40
|
-
var expected = {
|
|
41
|
-
webos: 3
|
|
42
|
-
};
|
|
43
|
-
var actual = (0, _platform.parseUserAgent)(webOSTV3);
|
|
44
|
-
expect(actual).toMatchObject(expected);
|
|
45
|
-
});
|
|
46
|
-
test('should return webOS 4', function () {
|
|
47
|
-
var expected = {
|
|
48
|
-
webos: 4
|
|
49
|
-
};
|
|
50
|
-
var actual = (0, _platform.parseUserAgent)(webOSTV4);
|
|
51
|
-
expect(actual).toMatchObject(expected);
|
|
52
|
-
});
|
|
53
|
-
test('should return webOS 5', function () {
|
|
54
|
-
var expected = {
|
|
55
|
-
webos: 5
|
|
56
|
-
};
|
|
57
|
-
var actual = (0, _platform.parseUserAgent)(webOSTV5);
|
|
58
|
-
expect(actual).toMatchObject(expected);
|
|
59
|
-
});
|
|
60
|
-
test('should return webOS 6', function () {
|
|
61
|
-
var expected = {
|
|
62
|
-
webos: 6
|
|
63
|
-
};
|
|
64
|
-
var actual = (0, _platform.parseUserAgent)(webOSTV6);
|
|
65
|
-
expect(actual).toMatchObject(expected);
|
|
66
|
-
});
|
|
67
|
-
test('should return webOS Next and chrome 87', function () {
|
|
68
|
-
var expected = {
|
|
69
|
-
webos: -1,
|
|
70
|
-
chrome: 87
|
|
71
|
-
};
|
|
72
|
-
var actual = (0, _platform.parseUserAgent)(webOSTVNext);
|
|
73
|
-
expect(actual).toMatchObject(expected);
|
|
74
|
-
});
|
|
75
|
-
test('should return webOS -1', function () {
|
|
76
|
-
var expected = {
|
|
77
|
-
webos: -1
|
|
78
|
-
};
|
|
79
|
-
var actual = (0, _platform.parseUserAgent)(webOSOther);
|
|
80
|
-
expect(actual).toMatchObject(expected);
|
|
81
|
-
});
|
|
82
|
-
test('should return webOS -1 + LuneOS 1', function () {
|
|
83
|
-
var expected = {
|
|
84
|
-
webos: -1,
|
|
85
|
-
luneos: 1
|
|
86
|
-
};
|
|
87
|
-
expect((0, _platform.parseUserAgent)(LuneOS1)).toMatchObject(expected);
|
|
88
|
-
expect((0, _platform.parseUserAgent)(LuneOS2)).toMatchObject(expected);
|
|
89
|
-
});
|
|
90
|
-
test('should return webOS -1 + legacy 1', function () {
|
|
91
|
-
var expected = {
|
|
92
|
-
webos: -1,
|
|
93
|
-
legacy: 1
|
|
94
|
-
};
|
|
95
|
-
expect((0, _platform.parseUserAgent)(webOS10)).toMatchObject(expected);
|
|
96
|
-
expect((0, _platform.parseUserAgent)(webOS11)).toMatchObject(expected);
|
|
97
|
-
expect((0, _platform.parseUserAgent)(webOS12)).toMatchObject(expected);
|
|
98
|
-
expect((0, _platform.parseUserAgent)(webOS13)).toMatchObject(expected);
|
|
99
|
-
expect((0, _platform.parseUserAgent)(webOS1351)).toMatchObject(expected);
|
|
100
|
-
});
|
|
101
|
-
test('should return webOS -1 + legacy 2', function () {
|
|
102
|
-
var expected = {
|
|
103
|
-
webos: -1,
|
|
104
|
-
legacy: 2
|
|
105
|
-
};
|
|
106
|
-
expect((0, _platform.parseUserAgent)(webOS2)).toMatchObject(expected);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
describe('parseUserAgent for Windows Phone', function () {
|
|
110
|
-
var windowsPhone = 'Mozilla/5.0 (Windows Phone 8.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4103.84 Mobile Safari/537.36';
|
|
111
|
-
test('should return platformName `windowsPhone`', function () {
|
|
112
|
-
var expected = {
|
|
113
|
-
platformName: 'windowsPhone'
|
|
114
|
-
};
|
|
115
|
-
var actual = (0, _platform.parseUserAgent)(windowsPhone);
|
|
116
|
-
expect(actual).toMatchObject(expected);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
describe('parseUserAgent for Edge', function () {
|
|
120
|
-
var edge1 = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42';
|
|
121
|
-
var edge2 = 'Mozilla/5.0 (Linux; Android 10; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5672.76 Mobile Safari/537.36 EdgA/113.0.1774.38';
|
|
122
|
-
var edge3 = 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 EdgiOS/113.1774.42 Mobile/15E148 Safari/605.1.15';
|
|
123
|
-
var edge4 = 'Mozilla/5.0 (Windows Mobile 10; Android 10.0; Microsoft; Lumia 950XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Mobile Safari/537.36 Edge/40.15254.603';
|
|
124
|
-
test('should return edge for Edg', function () {
|
|
125
|
-
var expected = {
|
|
126
|
-
platformName: 'edge'
|
|
127
|
-
};
|
|
128
|
-
var actual = (0, _platform.parseUserAgent)(edge1);
|
|
129
|
-
expect(actual).toMatchObject(expected);
|
|
130
|
-
expected = {
|
|
131
|
-
chrome: 113
|
|
132
|
-
};
|
|
133
|
-
expect(actual).toMatchObject(expected);
|
|
134
|
-
expected = {
|
|
135
|
-
edge: 113
|
|
136
|
-
};
|
|
137
|
-
expect(actual).toMatchObject(expected);
|
|
138
|
-
});
|
|
139
|
-
test('should return edge for EdgA', function () {
|
|
140
|
-
var expected = {
|
|
141
|
-
platformName: 'edge'
|
|
142
|
-
};
|
|
143
|
-
var actual = (0, _platform.parseUserAgent)(edge2);
|
|
144
|
-
expect(actual).toMatchObject(expected);
|
|
145
|
-
expected = {
|
|
146
|
-
chrome: 113
|
|
147
|
-
};
|
|
148
|
-
expect(actual).toMatchObject(expected);
|
|
149
|
-
expected = {
|
|
150
|
-
edge: 113
|
|
151
|
-
};
|
|
152
|
-
expect(actual).toMatchObject(expected);
|
|
153
|
-
});
|
|
154
|
-
test('should return edge for EdgiOS', function () {
|
|
155
|
-
var expected = {
|
|
156
|
-
platformName: 'edge'
|
|
157
|
-
};
|
|
158
|
-
var actual = (0, _platform.parseUserAgent)(edge3);
|
|
159
|
-
expect(actual).toMatchObject(expected);
|
|
160
|
-
expected = {
|
|
161
|
-
chrome: 113
|
|
162
|
-
};
|
|
163
|
-
expect(actual).not.toMatchObject(expected);
|
|
164
|
-
expected = {
|
|
165
|
-
edge: 113
|
|
166
|
-
};
|
|
167
|
-
expect(actual).toMatchObject(expected);
|
|
168
|
-
});
|
|
169
|
-
test('should return edge for Edge', function () {
|
|
170
|
-
var expected = {
|
|
171
|
-
platformName: 'edge'
|
|
172
|
-
};
|
|
173
|
-
var actual = (0, _platform.parseUserAgent)(edge4);
|
|
174
|
-
expect(actual).toMatchObject(expected);
|
|
175
|
-
expected = {
|
|
176
|
-
chrome: 113
|
|
177
|
-
};
|
|
178
|
-
expect(actual).toMatchObject(expected);
|
|
179
|
-
expected = {
|
|
180
|
-
edge: 40
|
|
181
|
-
};
|
|
182
|
-
expect(actual).toMatchObject(expected);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
6
|
+
describe('platform', function () {
|
|
185
7
|
describe('parseUserAgent for User-Agent Reduction', function () {
|
|
186
8
|
var testVersion = '113';
|
|
187
9
|
var uaGenerator = function uaGenerator(unifiedPlatform) {
|
|
@@ -189,7 +11,7 @@ describe('platform', function () {
|
|
|
189
11
|
var majorVersion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : testVersion;
|
|
190
12
|
return "Mozilla/5.0 (".concat(unifiedPlatform, ") AppleWebKit/537.36 (KHTML, like Gecko) Chrome/").concat(majorVersion, ".0.0.0 ").concat(deviceCompatibility, " Safari/537.36");
|
|
191
13
|
};
|
|
192
|
-
var testCases = [[uaGenerator('Macintosh; Intel Mac OS X 10_15_7'), 'chrome'], [uaGenerator('Windows NT 10.0; Win64; x64'), 'chrome'], [uaGenerator('X11; Linux x86_64'), 'chrome'], [uaGenerator('X11; CrOS x86_64 14541.0.0'), 'chrome'], [uaGenerator('Fuchsia'), 'chrome'], [uaGenerator('Linux; Android 10; K', 'Mobile'), '
|
|
14
|
+
var testCases = [[uaGenerator('Macintosh; Intel Mac OS X 10_15_7'), 'chrome'], [uaGenerator('Windows NT 10.0; Win64; x64'), 'chrome'], [uaGenerator('X11; Linux x86_64'), 'chrome'], [uaGenerator('X11; CrOS x86_64 14541.0.0'), 'chrome'], [uaGenerator('Fuchsia'), 'chrome'], [uaGenerator('Linux; Android 10; K', 'Mobile'), 'chrome']];
|
|
193
15
|
test("should return object including chrome ".concat(testVersion), function () {
|
|
194
16
|
for (var i = 0; i < testCases.length; i++) {
|
|
195
17
|
var _parseUserAgent;
|
|
@@ -334,8 +156,6 @@ describe('platform', function () {
|
|
|
334
156
|
test('should detect node environment if \'window\' does not exist', function () {
|
|
335
157
|
var windowSpy = jest.spyOn(window, 'window', 'get').mockImplementation(function () {});
|
|
336
158
|
var expected = {
|
|
337
|
-
node: true,
|
|
338
|
-
// Deprecated: will be removed in 5.0.0.
|
|
339
159
|
type: 'node',
|
|
340
160
|
browserName: 'unknown',
|
|
341
161
|
browserVersion: 0
|
|
@@ -343,12 +163,13 @@ describe('platform', function () {
|
|
|
343
163
|
expect(_platform.platform).toMatchObject(expected);
|
|
344
164
|
windowSpy.mockRestore();
|
|
345
165
|
});
|
|
346
|
-
test('should return `
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
expect(_platform.platform
|
|
166
|
+
test('should return `webos` for `type` in webOS environment', function () {
|
|
167
|
+
Object.defineProperty(globalThis.navigator, 'userAgent', {
|
|
168
|
+
value: 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.5359.211 Safari/537.36 WebAppManager',
|
|
169
|
+
configurable: true
|
|
170
|
+
});
|
|
171
|
+
expect(_platform.platform.type).toBe('webos');
|
|
172
|
+
delete globalThis.navigator.userAgent;
|
|
352
173
|
});
|
|
353
174
|
});
|
|
354
175
|
});
|
package/snapshot/snapshot.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.isWindowReady = isWindowReady;
|
|
|
8
8
|
exports.onWindowReady = onWindowReady;
|
|
9
9
|
exports.windowReady = windowReady;
|
|
10
10
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
11
|
-
function _interopRequireDefault(
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
12
|
/**
|
|
13
13
|
* Utilities to facilitate integration with v8 snapshot builds
|
|
14
14
|
*
|
|
@@ -5,13 +5,13 @@ var _react = require("@testing-library/react");
|
|
|
5
5
|
var _react2 = require("react");
|
|
6
6
|
var _useChainRefs = _interopRequireDefault(require("../useChainRefs"));
|
|
7
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
-
function _interopRequireDefault(
|
|
9
|
-
function _toConsumableArray(
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
10
10
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
-
function _unsupportedIterableToArray(
|
|
12
|
-
function _iterableToArray(
|
|
13
|
-
function _arrayWithoutHoles(
|
|
14
|
-
function _arrayLikeToArray(
|
|
11
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
12
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
13
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
15
|
describe('useChainRefs', function () {
|
|
16
16
|
function Component(props) {
|
|
17
17
|
var ref = _useChainRefs["default"].apply(void 0, _toConsumableArray(props.refs));
|
|
@@ -8,7 +8,7 @@ exports["default"] = void 0;
|
|
|
8
8
|
exports.useChainRefs = useChainRefs;
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _warning = _interopRequireDefault(require("warning"));
|
|
11
|
-
function _interopRequireDefault(
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
12
|
/**
|
|
13
13
|
* Updates multiple reference callbacks or objects
|
|
14
14
|
*
|