@enact/core 4.7.10 → 4.9.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,7 +2,21 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact core module, newest changes on the top.
4
4
 
5
- ## [4.7.10] - 2024-03-05
5
+ ## [4.9.0-alpha.1] - 2024-04-09
6
+
7
+ ### Deprecated
8
+
9
+ - `core/platform` member `windowsPhone`, `edge`, `androidChrome`, `android`, `ie`, `ios`, `webos`, `androidFirefox`, `firefoxOS`, `blackberry`, and `tizen`, to be removed in 5.0.0
10
+ - `core/platform` member `gesture`, `node`, `platformName`, and `unknown`, to be removed in 5.0.0
11
+ - `core/platform` member `touch` and `touchscreen`, to be removed in 5.0.0
12
+
13
+ ### Added
14
+
15
+ - `core/platform` member `type` to detect a platform like 'desktop', 'mobile', 'webos', and 'node'
16
+ - `core/platform` member `browserName` and `browserVersion` to detect the compatible major browser name and version
17
+ - `core/platform` member `touchEvent` and `touchScreen` replacing legacy `touch` and `touchscreen` respectively
18
+
19
+ ## [4.8.0] - 2024-02-08
6
20
 
7
21
  No significant changes.
8
22
 
@@ -14,7 +14,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
14
14
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15
15
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
16
16
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
17
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
18
18
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19
19
  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; }
20
20
  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; }
@@ -22,7 +22,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
22
22
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23
23
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
24
24
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
25
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
26
26
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
27
27
  * Provides the `ApiDecorator` higher-order component
28
28
  *
@@ -15,7 +15,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
15
15
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16
16
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
17
17
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
18
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
19
19
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20
20
  describe('ApiDecorator', function () {
21
21
  var _class, _class2;
@@ -22,7 +22,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
22
22
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23
23
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
24
24
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
25
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
26
26
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
27
27
  var SomeContext = /*#__PURE__*/(0, _react.createContext)();
28
28
  describe('Registry', function () {
@@ -16,7 +16,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
16
16
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
17
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
18
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
19
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
20
20
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
21
  describe('prop-types', function () {
22
22
  var DummyElement = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
package/kind/kind.js CHANGED
@@ -18,7 +18,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
18
18
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19
19
  function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
20
20
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
21
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
21
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
22
22
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23
23
  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; }
24
24
  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; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/core",
3
- "version": "4.7.10",
3
+ "version": "4.9.0-alpha.1",
4
4
  "description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,6 +11,7 @@
11
11
  "main": "index.js",
12
12
  "scripts": {
13
13
  "clean": "enact clean",
14
+ "interlink": "echo \"No interlink\" && exit 0",
14
15
  "lint": "enact lint --strict",
15
16
  "test": "enact test",
16
17
  "test-json": "enact test --json",
@@ -31,7 +32,7 @@
31
32
  }
32
33
  },
33
34
  "dependencies": {
34
- "classnames": "^2.3.2",
35
+ "classnames": "^2.5.1",
35
36
  "invariant": "^2.2.4",
36
37
  "prop-types": "^15.8.1",
37
38
  "ramda": "^0.29.1",
@@ -5,25 +5,49 @@ type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
5
5
 
6
6
  export interface PlatformDescription {
7
7
  /**
8
- * Additional information about the detected platform
8
+ * The name of the detected browser
9
9
  */
10
+ browserName: string /**
11
+ * The version of the detected browser
12
+ */;
13
+ browserVersion: number /**
14
+ * The version of the detected browser, if chrome browser is detected
15
+ */;
16
+ chrome: number /**
17
+ * Additional information about the detected platform. Deprecated: will be removed in 5.0.0.
18
+ */;
10
19
  extra?: object /**
11
- * `true` if the platform has native double-finger events
20
+ * The version of the detected browser, if firefox browser is detected
21
+ */;
22
+ firefox: number /**
23
+ * `true` if the platform has native double-finger events. Deprecated: will be removed in 5.0.0.
12
24
  */;
13
25
  gesture: boolean /**
14
- * `true` only if `window` is `undefined`
26
+ * `true` only if `window` is `undefined` . Deprecated: will be removed in 5.0.0. Use `type` instead.
15
27
  */;
16
28
  node: boolean /**
17
- * The name of the platform, if detected
29
+ * The name of the platform, if detected. Deprecated: will be removed in 5.0.0. Use `browserName` instead for browser names.
18
30
  */;
19
31
  platformName?: string /**
20
- * `true` if the platform has native single-finger events
32
+ * The version of the detected browser, if safari browser is detected
33
+ */;
34
+ safari: number /**
35
+ * `true` if the platform has native single-finger events. Deprecated: will be removed in 5.0.0. Use `touchEvent` instead.
21
36
  */;
22
37
  touch: boolean /**
23
- * `true` if the platform has a touch screen
38
+ * `true` if the browser has native touch events
39
+ */;
40
+ touchEvent: boolean /**
41
+ * `true` if the platform has a touch screen. Deprecated: will be removed in 5.0.0. Use `touchScreen` instead.
24
42
  */;
25
43
  touchscreen: boolean /**
26
- * `true` for any unknown system
44
+ * `true` if the platform has a touch screen
45
+ */;
46
+ touchScreen: boolean /**
47
+ * The type of the detected platform. One of 'desktop', 'mobile', 'webos', 'node', or 'unknown'
48
+ */;
49
+ type: string /**
50
+ * `true` for any unknown system. Deprecated: will be removed in 5.0.0. Use `type` instead.
27
51
  */;
28
52
  unknown: boolean;
29
53
  }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.platform = exports.parseUserAgent = exports.detect = exports["default"] = void 0;
7
- var _uniq = _interopRequireDefault(require("ramda/src/uniq"));
8
7
  var _deprecate = _interopRequireDefault(require("../internal/deprecate"));
9
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
9
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -17,7 +16,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
17
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; }
18
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; }
19
18
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
20
- 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); } /**
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 */ /**
21
20
  * Utilities for detecting basic platform capabilities.
22
21
  *
23
22
  * @module core/platform
@@ -25,22 +24,43 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
25
24
  * @exports platform
26
25
  * @public
27
26
  */
28
- var hasGesture = function hasGesture() {
29
- return Boolean('ongesturestart' in window || 'onmsgesturestart' in window && (window.navigator.msMaxTouchPoints > 1 || window.navigator.maxTouchPoints > 1));
27
+ // Refer the following for more details: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
28
+ var browserEnvironment = function browserEnvironment() {
29
+ return !!globalThis.window;
30
30
  };
31
- var hasTouch = function hasTouch() {
32
- return Boolean('TouchEvent' in window || 'ontouchstart' in window || window.navigator.msMaxTouchPoints || window.navigator.msManipulationViewsEnabled && window.navigator.maxTouchPoints);
31
+
32
+ // Note: Always true for Chrome v70 or higher: https://chromestatus.com/feature/4764225348042752
33
+ var featureTouchEvent = function featureTouchEvent() {
34
+ return browserEnvironment() && 'TouchEvent' in globalThis;
33
35
  };
34
36
 
35
- // Adapted from https://patrickhlauke.github.io/touch/touchscreen-detection/
36
- // I've omitted the touch event fallback since that is covered by hasTouch and we're less concerned
37
- // with legacy browsers used in touchscreen environments.
38
- var hasTouchScreen = function hasTouchScreen() {
39
- return (
40
- // if Pointer Events are supported, just check maxTouchPoints
41
- window.PointerEvent && 'maxTouchPoints' in window.navigator && window.navigator.maxTouchPoints > 0 ||
42
- // check for any-pointer:coarse which mostly means touchscreen
43
- window.matchMedia && window.matchMedia('(any-pointer:coarse)').matches
37
+ // Refer https://patrickhlauke.github.io/touch/touchscreen-detection/
38
+ var deviceTouchScreen = function deviceTouchScreen() {
39
+ var _globalThis$navigator, _globalThis$matchMedi;
40
+ return browserEnvironment() && (
41
+ // check if maxTouchPoints is greater than 0 first
42
+ ((_globalThis$navigator = globalThis.navigator) === null || _globalThis$navigator === void 0 ? void 0 : _globalThis$navigator.maxTouchPoints) > 0 || ( // check for any-pointer: coarse which mostly means touchscreen
43
+ (_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
+ };
45
+
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
44
64
  );
45
65
  };
46
66
  var webOSVersion = {
@@ -129,7 +149,7 @@ var platforms = [
129
149
  platform: 'webos',
130
150
  regex: /Web0S;.*Chrome\/(\d+)/
131
151
  },
132
- // LG webOS of indeterminate versionre
152
+ // LG webOS indeterminate versions
133
153
  {
134
154
  platform: 'webos',
135
155
  regex: /Web0S;/,
@@ -215,16 +235,12 @@ var platforms = [
215
235
  platform: 'tizen',
216
236
  regex: /Tizen (\d+)/
217
237
  }];
218
- var ua = function ua() {
219
- return window.navigator ? window.navigator.userAgent : '';
220
- };
221
- var _platform;
222
- var parseUserAgent = exports.parseUserAgent = function parseUserAgent(userAgent) {
238
+ var parseUserAgentLegacy = function parseUserAgentLegacy(userAgent) {
223
239
  var plat = {
224
240
  gesture: hasGesture(),
225
241
  node: false,
226
242
  touch: hasTouch(),
227
- touchscreen: hasTouchScreen(),
243
+ touchscreen: deviceTouchScreen(),
228
244
  unknown: true
229
245
  };
230
246
  for (var i = 0, p, m, v; p = platforms[i]; i++) {
@@ -252,28 +268,112 @@ var parseUserAgent = exports.parseUserAgent = function parseUserAgent(userAgent)
252
268
  break;
253
269
  }
254
270
  }
255
- if (plat.platformName === 'windowsPhone') {
271
+ if ('webos' === plat.platformName) {
272
+ (0, _deprecate["default"])({
273
+ name: plat.platformName,
274
+ message: 'Refer `@enact/webos`\'s `platform` for webOS specific information.',
275
+ until: '5.0.0'
276
+ });
277
+ } else if (!['chrome', 'safari', 'firefox'].includes(plat.platformName)) {
256
278
  (0, _deprecate["default"])({
257
- name: 'Windows Phone platform',
279
+ name: plat.platformName,
258
280
  until: '5.0.0'
259
281
  });
260
282
  }
261
283
  return plat;
262
284
  };
263
285
 
286
+ /*
287
+ * The end of Legacy Code to be removed in the next major release
288
+ */
289
+
290
+ // Refer https://www.whatismybrowser.com/guides/the-latest-user-agent/ for latest user agents of major browsers
291
+ var userAgentPatterns = [
292
+ // Normal cases except iOS
293
+ {
294
+ browserName: 'safari',
295
+ regex: /\s+Version\/(\d+)(?:\.(\d+))?\s+Safari/
296
+ }, {
297
+ browserName: 'chrome',
298
+ regex: /\s+Chrome\/(\d+)[.\d]+/
299
+ }, {
300
+ browserName: 'firefox',
301
+ regex: /\s+Firefox\/(\d+)[.\d]+/
302
+ },
303
+ // iOS
304
+ {
305
+ browserName: 'safari',
306
+ regex: /\((?:iPhone|iPad);.+\sOS\s(\d+)_(\d+)/
307
+ }];
308
+
309
+ // The base supported versions: Used in DEPRECATED warning
310
+ var supportedVersions = {
311
+ safari: 15.6,
312
+ chrome: 94,
313
+ firefox: 115
314
+ };
315
+ var parseUserAgent = exports.parseUserAgent = function parseUserAgent(userAgent) {
316
+ var detectedInfo = {
317
+ type: 'unknown',
318
+ browserName: 'unknown',
319
+ browserVersion: 0
320
+ };
321
+ var index;
322
+ for (index = 0; index < userAgentPatterns.length; index++) {
323
+ var testPlatform = userAgentPatterns[index];
324
+ var match = testPlatform.regex.exec(userAgent);
325
+ if (match) {
326
+ detectedInfo.browserName = testPlatform.browserName;
327
+ detectedInfo.browserVersion = Number("".concat(match[1], ".").concat(match[2] || 0));
328
+ break;
329
+ }
330
+ }
331
+ if (index < userAgentPatterns.length) {
332
+ if (userAgent.includes('Web0S;')) {
333
+ detectedInfo.type = 'webos';
334
+ } else if (userAgent.includes(' Mobile')) {
335
+ // Note that we don't catch 'Tablet' of Firefox as it can't be normalized with other browsers
336
+ detectedInfo.type = 'mobile';
337
+ } else {
338
+ detectedInfo.type = 'desktop';
339
+ }
340
+ detectedInfo[detectedInfo.browserName] = detectedInfo.browserVersion;
341
+ }
342
+
343
+ // deprecation warning for browser versions older than our support policy
344
+ if (supportedVersions[detectedInfo.browserName] > detectedInfo.browserVersion) {
345
+ (0, _deprecate["default"])({
346
+ name: "supporting ".concat(detectedInfo.browserName, " version before ").concat(supportedVersions[detectedInfo.browserName]),
347
+ until: '5.0.0'
348
+ });
349
+ }
350
+
351
+ // Merge legacy platform info
352
+ return _objectSpread(_objectSpread({}, parseUserAgentLegacy(userAgent)), detectedInfo);
353
+ };
354
+
264
355
  /**
265
356
  * @typedef {Object} PlatformDescription
266
- * @property {Object} [extra] - Additional information about the detected platform
267
- * @property {Boolean} gesture - `true` if the platform has native double-finger events
268
- * @property {Boolean} node - `true` only if `window` is `undefined`
269
- * @property {String} [platformName] - The name of the platform, if detected
270
- * @property {Boolean} touch - `true` if the platform has native single-finger events
271
- * @property {Boolean} touchscreen - `true` if the platform has a touch screen
272
- * @property {Boolean} unknown - `true` for any unknown system
357
+ * @property {String} browserName - The name of the detected browser
358
+ * @property {Number} browserVersion - The version of the detected browser
359
+ * @property {Number} chrome - The version of the detected browser, if chrome browser is detected
360
+ * @property {Object} [extra] - Additional information about the detected platform. Deprecated: will be removed in 5.0.0.
361
+ * @property {Number} firefox - The version of the detected browser, if firefox browser is detected
362
+ * @property {Boolean} gesture - `true` if the platform has native double-finger events. Deprecated: will be removed in 5.0.0.
363
+ * @property {Boolean} node - `true` only if `window` is `undefined`. Deprecated: will be removed in 5.0.0. Use `type` instead.
364
+ * @property {String} [platformName] - The name of the platform, if detected. Deprecated: will be removed in 5.0.0. Use `browserName` instead for browser names.
365
+ * @property {Number} safari - The version of the detected browser, if safari browser is detected
366
+ * @property {Boolean} touch - `true` if the platform has native single-finger events. Deprecated: will be removed in 5.0.0. Use `touchEvent` instead.
367
+ * @property {Boolean} touchEvent - `true` if the browser has native touch events
368
+ * @property {Boolean} touchscreen - `true` if the platform has a touch screen. Deprecated: will be removed in 5.0.0. Use `touchScreen` instead.
369
+ * @property {Boolean} touchScreen - `true` if the platform has a touch screen
370
+ * @property {String} type - The type of the detected platform. One of 'desktop', 'mobile', 'webos', 'node', or 'unknown'
371
+ * @property {Boolean} unknown - `true` for any unknown system. Deprecated: will be removed in 5.0.0. Use `type` instead.
273
372
  *
274
373
  * @memberof core/platform
275
374
  * @public
276
375
  */
376
+ var detectedPlatform = null;
277
377
 
278
378
  /**
279
379
  * Returns the {@link core/platform.platform} object.
@@ -284,19 +384,36 @@ var parseUserAgent = exports.parseUserAgent = function parseUserAgent(userAgent)
284
384
  * @public
285
385
  */
286
386
  var detect = exports.detect = function detect() {
287
- if (_platform) {
288
- // if we've already determined the platform, we'll use that determination
289
- return _platform;
290
- } else if (typeof window === 'undefined') {
291
- return {
387
+ if (detectedPlatform !== null) {
388
+ // once detected, don't bother detecting again
389
+ return detectedPlatform;
390
+ }
391
+
392
+ // Parse User Agent string first
393
+ if (browserEnvironment()) {
394
+ var _globalThis$navigator2;
395
+ detectedPlatform = parseUserAgent(((_globalThis$navigator2 = globalThis.navigator) === null || _globalThis$navigator2 === void 0 ? void 0 : _globalThis$navigator2.userAgent) || '');
396
+ } else {
397
+ // node or compatible environment (e.g. prerendering or snapshot runs)
398
+ detectedPlatform = {
399
+ // the following properties are deprecated and will be removed in the next major release
292
400
  gesture: false,
293
401
  node: true,
294
402
  touch: false,
295
- unknown: true
403
+ unknown: true,
404
+ // the following properties are new and will be available in the next major release
405
+ type: 'node',
406
+ browserName: 'unknown',
407
+ browserVersion: 0 /* magic number for unknown */
296
408
  };
297
409
  }
298
- var userAgent = ua();
299
- return _platform = parseUserAgent(userAgent);
410
+
411
+ // Detect features
412
+ detectedPlatform.touchEvent = featureTouchEvent();
413
+
414
+ // Detect devices
415
+ detectedPlatform.touchScreen = deviceTouchScreen();
416
+ return detectedPlatform;
300
417
  };
301
418
 
302
419
  /**
@@ -307,12 +424,50 @@ var detect = exports.detect = function detect() {
307
424
  * @public
308
425
  */
309
426
  var platform = exports.platform = {};
310
- ['gesture', 'node', 'platformName', 'touch', 'touchscreen', 'unknown'].concat(_toConsumableArray((0, _uniq["default"])(platforms.map(function (p) {
427
+ [
428
+ // the following properties are deprecated and will be removed in the next major release
429
+ 'gesture', 'node', 'platformName', 'touch', 'touchscreen', 'unknown',
430
+ // the following properties are new and will be available in the next major release
431
+ 'browserName', 'browserVersion', 'touchEvent', 'touchScreen', 'type'].concat(_toConsumableArray(new Set(platforms.map(function (p) {
311
432
  return p.platform;
312
433
  })))).forEach(function (name) {
313
434
  Object.defineProperty(platform, name, {
314
435
  enumerable: true,
315
436
  get: function get() {
437
+ if (name === 'gesture' || name === 'unknown') {
438
+ (0, _deprecate["default"])({
439
+ name: name,
440
+ until: '5.0.0'
441
+ });
442
+ }
443
+ if (name === 'node') {
444
+ (0, _deprecate["default"])({
445
+ name: name,
446
+ until: '5.0.0',
447
+ replacedBy: 'type'
448
+ });
449
+ }
450
+ if (name === 'platformName') {
451
+ (0, _deprecate["default"])({
452
+ name: name,
453
+ until: '5.0.0',
454
+ replacedBy: 'browserName'
455
+ });
456
+ }
457
+ if (name === 'touch') {
458
+ (0, _deprecate["default"])({
459
+ name: name,
460
+ until: '5.0.0',
461
+ replacedBy: 'touchEvent'
462
+ });
463
+ }
464
+ if (name === 'touchscreen') {
465
+ (0, _deprecate["default"])({
466
+ name: name,
467
+ until: '5.0.0',
468
+ replacedBy: 'touchScreen'
469
+ });
470
+ }
316
471
  var p = detect();
317
472
  return p[name];
318
473
  }
@@ -197,13 +197,154 @@ describe('platform', function () {
197
197
  }
198
198
  });
199
199
  });
200
+ describe('parseUserAgent for Safari', function () {
201
+ test('should detect Safari browsers', function () {
202
+ var knownUserAgents = {
203
+ userAgentList: [
204
+ // Safari on macOS
205
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Safari/605.1.15', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Safari/605.1.15'],
206
+ expected: {
207
+ type: 'desktop',
208
+ browserName: 'safari',
209
+ browserVersion: 17.3,
210
+ safari: 17.3
211
+ }
212
+ };
213
+ for (var i = 0; i < knownUserAgents.userAgentList.length; i++) {
214
+ var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]);
215
+ expect(actual).toMatchObject(knownUserAgents.expected);
216
+ }
217
+ });
218
+ test('should detect mobile Safari browsers', function () {
219
+ var knownUserAgents = {
220
+ //
221
+ userAgentList: [
222
+ // Safari on iPhone, iPad
223
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Mobile/15E148 Safari/604.1', 'Mozilla/5.0 (iPad; CPU OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Mobile/15E148 Safari/604.1',
224
+ // Chrome on iPhone, iPad
225
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/121.0.6167.138 Mobile/15E148 Safari/604.1', 'Mozilla/5.0 (iPad; CPU OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/121.0.6167.138 Mobile/15E148 Safari/604.1',
226
+ // Edge on iPhone
227
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 EdgiOS/121.2277.99 Mobile/15E148 Safari/605.1.15',
228
+ // Firefox on iPhone, iPad
229
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/122.0 Mobile/15E148 Safari/605.1.15', 'Mozilla/5.0 (iPad; CPU OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/122.0 Mobile/15E148 Safari/605.1.15'],
230
+ expected: {
231
+ type: 'mobile',
232
+ browserName: 'safari',
233
+ browserVersion: 17.3,
234
+ safari: 17.3
235
+ }
236
+ };
237
+ for (var i = 0; i < knownUserAgents.userAgentList.length; i++) {
238
+ var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]);
239
+ expect(actual).toMatchObject(knownUserAgents.expected);
240
+ }
241
+ });
242
+ });
243
+ describe('parseUserAgent for Chrome', function () {
244
+ test('should detect Chrome browsers', function () {
245
+ var knownUserAgents = {
246
+ // Chrome on Windows, macOS, Linux, Edge on Windows, macOS, respectively
247
+ userAgentList: [
248
+ // Chrome on Windows, macOS, Linux
249
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
250
+ // Edge on Windows, macOS
251
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.2277.98', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.2277.98'],
252
+ expected: {
253
+ type: 'desktop',
254
+ browserName: 'chrome',
255
+ browserVersion: 121,
256
+ chrome: 121
257
+ }
258
+ };
259
+ for (var i = 0; i < knownUserAgents.userAgentList.length; i++) {
260
+ var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]);
261
+ expect(actual).toMatchObject(knownUserAgents.expected);
262
+ }
263
+ });
264
+ test('should detect mobile Chrome browsers', function () {
265
+ var knownUserAgents = {
266
+ userAgentList: [
267
+ // Chrome on Android
268
+ 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.6167.143 Mobile Safari/537.36',
269
+ // Edge on Android
270
+ 'Mozilla/5.0 (Linux; Android 10; Pixel 3 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.6167.143 Mobile Safari/537.36 EdgA/120.0.2210.157'],
271
+ expected: {
272
+ type: 'mobile',
273
+ browserName: 'chrome',
274
+ browserVersion: 121,
275
+ chrome: 121
276
+ }
277
+ };
278
+ for (var i = 0; i < knownUserAgents.userAgentList.length; i++) {
279
+ var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]);
280
+ expect(actual).toMatchObject(knownUserAgents.expected);
281
+ }
282
+ });
283
+ });
284
+ describe('parseUserAgent for Firefox', function () {
285
+ test('should detect Firefox browsers', function () {
286
+ var knownUserAgents = {
287
+ userAgentList: [
288
+ // Firefox on Windows, macOS, Linux
289
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14.3; rv:122.0) Gecko/20100101 Firefox/122.0', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0'],
290
+ expected: {
291
+ type: 'desktop',
292
+ browserName: 'firefox',
293
+ browserVersion: 122,
294
+ firefox: 122
295
+ }
296
+ };
297
+ for (var i = 0; i < knownUserAgents.userAgentList.length; i++) {
298
+ var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]);
299
+ expect(actual).toMatchObject(knownUserAgents.expected);
300
+ }
301
+ });
302
+ test('should detect mobile Firefox browsers', function () {
303
+ var knownUserAgents = {
304
+ userAgentList: [
305
+ // Firefox on Android
306
+ 'Mozilla/5.0 (Android 14; Mobile; rv:122.0) Gecko/122.0 Firefox/122.0'],
307
+ expected: {
308
+ type: 'mobile',
309
+ browserName: 'firefox',
310
+ browserVersion: 122,
311
+ firefox: 122
312
+ }
313
+ };
314
+ for (var i = 0; i < knownUserAgents.userAgentList.length; i++) {
315
+ var actual = (0, _platform.parseUserAgent)(knownUserAgents.userAgentList[i]);
316
+ expect(actual).toMatchObject(knownUserAgents.expected);
317
+ }
318
+ });
319
+ });
320
+ describe('parseUserAgent for Chrome on webOS', function () {
321
+ test('should detect Chrome browsers on webOS', function () {
322
+ var knownUserAgent = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 WebAppManager';
323
+ var expected = {
324
+ type: 'webos',
325
+ browserName: 'chrome',
326
+ browserVersion: 108,
327
+ chrome: 108
328
+ };
329
+ var actual = (0, _platform.parseUserAgent)(knownUserAgent);
330
+ expect(actual).toMatchObject(expected);
331
+ });
332
+ });
200
333
  describe('platform', function () {
201
- test('should return `true` for `node` if window does not exist', function () {
334
+ test('should detect node environment if \'window\' does not exist', function () {
202
335
  var windowSpy = jest.spyOn(window, 'window', 'get').mockImplementation(function () {});
203
- expect(_platform.platform['node']).toBe(true);
336
+ var expected = {
337
+ node: true,
338
+ // Deprecated: will be removed in 5.0.0.
339
+ type: 'node',
340
+ browserName: 'unknown',
341
+ browserVersion: 0
342
+ };
343
+ expect(_platform.platform).toMatchObject(expected);
204
344
  windowSpy.mockRestore();
205
345
  });
206
346
  test('should return `true` for `unknown` in the testing environment', function () {
347
+ // Deprecated: will be removed in 5.0.0
207
348
  // The first access invokes detecting based on user agent value
208
349
  expect(_platform.platform['unknown']).toBe(true);
209
350
  // The second access makes the module to return already detected platform information
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports["default"] = void 0;
7
7
  exports.useClass = useClass;
8
8
  var _react = require("react");
9
- function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
10
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
9
+ function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
10
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
11
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
12
  /**
13
13
  * Creates one instance of the class, `Ctor` with the provided `args`, for the life of the
package/util/util.js CHANGED
@@ -259,7 +259,7 @@ var memoize = exports.memoize = function memoize(fn) {
259
259
  *
260
260
  * @returns {*} The processed children or the value of `children` if not an array.
261
261
  * @memberof core/util
262
- * @see https://reactjs.org/docs/react-api.html#reactchildrenmap
262
+ * @see https://react.dev/reference/react/Children#children-map
263
263
  * @public
264
264
  */
265
265
  var mapAndFilterChildren = exports.mapAndFilterChildren = function mapAndFilterChildren(children, callback, filter) {