@enact/core 3.4.9-experimental-3 → 3.4.9-experimental-7

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.
Files changed (113) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/{build/dispatcher → dispatcher}/dispatcher.d.ts +0 -0
  3. package/dispatcher/dispatcher.js +76 -57
  4. package/dispatcher/listeners.js +31 -19
  5. package/dispatcher/tests/dispatcher-specs.js +75 -100
  6. package/{build/handle → handle}/handle.d.ts +0 -0
  7. package/handle/handle.js +260 -212
  8. package/handle/tests/handle-specs.js +476 -601
  9. package/{build/hoc → hoc}/hoc.d.ts +0 -0
  10. package/hoc/hoc.js +47 -33
  11. package/hoc/tests/hoc-specs.js +85 -126
  12. package/{build/index.d.ts → index.d.ts} +0 -0
  13. package/index.js +1 -0
  14. package/{build/internal → internal}/ApiDecorator/ApiDecorator.d.ts +0 -0
  15. package/internal/ApiDecorator/ApiDecorator.js +107 -61
  16. package/internal/ApiDecorator/tests/ApiDecorator-specs.js +106 -97
  17. package/{build/internal → internal}/Registry/Registry.d.ts +0 -0
  18. package/internal/Registry/Registry.js +68 -51
  19. package/internal/Registry/tests/Registry-specs.js +201 -143
  20. package/{build/internal → internal}/deprecate/deprecate.d.ts +0 -0
  21. package/internal/deprecate/deprecate.js +85 -60
  22. package/{build/internal → internal}/prop-types/prop-types.d.ts +0 -0
  23. package/internal/prop-types/prop-types.js +68 -61
  24. package/{build/keymap → keymap}/index.d.ts +0 -0
  25. package/keymap/index.js +27 -15
  26. package/keymap/keymap.js +67 -52
  27. package/keymap/tests/keymap-specs.js +75 -104
  28. package/kind/computed.js +29 -16
  29. package/{build/kind → kind}/kind.d.ts +0 -0
  30. package/kind/kind.js +150 -114
  31. package/kind/styles.js +62 -47
  32. package/kind/tests/computed-specs.js +87 -86
  33. package/kind/tests/kind-specs.js +216 -214
  34. package/kind/tests/styles-specs.js +170 -223
  35. package/kind/util.js +15 -7
  36. package/package.json +1 -1
  37. package/{build/platform → platform}/platform.d.ts +0 -0
  38. package/platform/platform.js +263 -169
  39. package/platform/tests/platform-specs.js +92 -90
  40. package/{build/snapshot → snapshot}/snapshot.d.ts +0 -0
  41. package/snapshot/snapshot.js +34 -27
  42. package/useChainRefs/tests/useChainRefs-specs.js +46 -30
  43. package/{build/useChainRefs → useChainRefs}/useChainRefs.d.ts +0 -0
  44. package/useChainRefs/useChainRefs.js +49 -29
  45. package/useClass/tests/useClass-specs.js +51 -46
  46. package/{build/useClass → useClass}/useClass.d.ts +0 -0
  47. package/useClass/useClass.js +27 -9
  48. package/useHandlers/Handlers.js +55 -30
  49. package/useHandlers/tests/useHandlers-specs.js +79 -95
  50. package/{build/useHandlers → useHandlers}/useHandlers.d.ts +0 -0
  51. package/useHandlers/useHandlers.js +18 -11
  52. package/util/Job.js +203 -241
  53. package/util/tests/Job-specs.js +216 -204
  54. package/util/tests/util-specs.js +123 -146
  55. package/{build/util → util}/util.d.ts +0 -0
  56. package/util/util.js +146 -103
  57. package/build/CHANGELOG.md +0 -699
  58. package/build/README.md +0 -33
  59. package/build/dispatcher/dispatcher.js +0 -160
  60. package/build/dispatcher/listeners.js +0 -37
  61. package/build/dispatcher/package.json +0 -3
  62. package/build/dispatcher/tests/dispatcher-specs.js +0 -75
  63. package/build/handle/handle.js +0 -846
  64. package/build/handle/package.json +0 -3
  65. package/build/handle/tests/handle-specs.js +0 -476
  66. package/build/hoc/hoc.js +0 -102
  67. package/build/hoc/package.json +0 -3
  68. package/build/hoc/tests/hoc-specs.js +0 -90
  69. package/build/index.js +0 -2
  70. package/build/internal/ApiDecorator/ApiDecorator.js +0 -143
  71. package/build/internal/ApiDecorator/package.json +0 -3
  72. package/build/internal/ApiDecorator/tests/ApiDecorator-specs.js +0 -106
  73. package/build/internal/Registry/Registry.js +0 -76
  74. package/build/internal/Registry/package.json +0 -3
  75. package/build/internal/Registry/tests/Registry-specs.js +0 -201
  76. package/build/internal/deprecate/deprecate.js +0 -116
  77. package/build/internal/deprecate/package.json +0 -3
  78. package/build/internal/prop-types/package.json +0 -3
  79. package/build/internal/prop-types/prop-types.js +0 -90
  80. package/build/keymap/index.js +0 -54
  81. package/build/keymap/keymap.js +0 -201
  82. package/build/keymap/package.json +0 -3
  83. package/build/keymap/tests/keymap-specs.js +0 -75
  84. package/build/kind/computed.js +0 -60
  85. package/build/kind/kind.js +0 -266
  86. package/build/kind/package.json +0 -3
  87. package/build/kind/styles.js +0 -105
  88. package/build/kind/tests/computed-specs.js +0 -87
  89. package/build/kind/tests/kind-specs.js +0 -216
  90. package/build/kind/tests/styles-specs.js +0 -170
  91. package/build/kind/util.js +0 -17
  92. package/build/package-lock.json +0 -206
  93. package/build/package.json +0 -38
  94. package/build/platform/package.json +0 -3
  95. package/build/platform/platform.js +0 -306
  96. package/build/platform/tests/platform-specs.js +0 -92
  97. package/build/snapshot/package.json +0 -3
  98. package/build/snapshot/snapshot.js +0 -89
  99. package/build/useChainRefs/package.json +0 -3
  100. package/build/useChainRefs/tests/useChainRefs-specs.js +0 -57
  101. package/build/useChainRefs/useChainRefs.js +0 -78
  102. package/build/useClass/package.json +0 -3
  103. package/build/useClass/tests/useClass-specs.js +0 -51
  104. package/build/useClass/useClass.js +0 -59
  105. package/build/useHandlers/Handlers.js +0 -55
  106. package/build/useHandlers/package.json +0 -3
  107. package/build/useHandlers/tests/useHandlers-specs.js +0 -84
  108. package/build/useHandlers/useHandlers.js +0 -36
  109. package/build/util/Job.js +0 -211
  110. package/build/util/package.json +0 -3
  111. package/build/util/tests/Job-specs.js +0 -216
  112. package/build/util/tests/util-specs.js +0 -123
  113. package/build/util/util.js +0 -322
@@ -1,306 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.platform = exports.parseUserAgent = exports.detect = exports["default"] = void 0;
7
-
8
- var _uniq = _interopRequireDefault(require("ramda/src/uniq"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
-
12
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
13
-
14
- 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."); }
15
-
16
- 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); }
17
-
18
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
19
-
20
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
21
-
22
- 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; }
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
27
-
28
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
-
30
- var hasGesture = function hasGesture() {
31
- return Boolean('ongesturestart' in window || 'onmsgesturestart' in window && (window.navigator.msMaxTouchPoints > 1 || window.navigator.maxTouchPoints > 1));
32
- };
33
-
34
- var hasTouch = function hasTouch() {
35
- return Boolean('TouchEvent' in window || 'ontouchstart' in window || window.navigator.msMaxTouchPoints || window.navigator.msManipulationViewsEnabled && window.navigator.maxTouchPoints);
36
- }; // Adapted from https://patrickhlauke.github.io/touch/touchscreen-detection/
37
- // I've omitted the touch event fallback since that is covered by hasTouch and we're less concerned
38
- // with legacy browsers used in touchscreen environments.
39
-
40
-
41
- var hasTouchScreen = function hasTouchScreen() {
42
- return (// if Pointer Events are supported, just check maxTouchPoints
43
- window.PointerEvent && 'maxTouchPoints' in window.navigator && window.navigator.maxTouchPoints > 0 || // check for any-pointer:coarse which mostly means touchscreen
44
- window.matchMedia && window.matchMedia('(any-pointer:coarse)').matches
45
- );
46
- };
47
-
48
- var platforms = [// Windows Phone 7 - 10
49
- {
50
- platform: 'windowsPhone',
51
- regex: /Windows Phone (?:OS )?(\d+)[.\d]+/
52
- }, // Android 4+ using Chrome
53
- {
54
- platform: 'androidChrome',
55
- regex: /Android .* Chrome\/(\d+)[.\d]+/
56
- }, // Android 2 - 4
57
- {
58
- platform: 'android',
59
- regex: /Android(?:\s|\/)(\d+)/
60
- }, // Kindle Fire
61
- // Force version to 2, (desktop mode does not list android version)
62
- {
63
- platform: 'android',
64
- regex: /Silk\/1./,
65
- forceVersion: 2,
66
- extra: {
67
- silk: 1
68
- }
69
- }, // Kindle Fire HD (Silk versions 2 or 3)
70
- // Force version to 4
71
- {
72
- platform: 'android',
73
- regex: /Silk\/2./,
74
- forceVersion: 4,
75
- extra: {
76
- silk: 2
77
- }
78
- }, {
79
- platform: 'android',
80
- regex: /Silk\/3./,
81
- forceVersion: 4,
82
- extra: {
83
- silk: 3
84
- }
85
- }, // IE 8 - 10
86
- {
87
- platform: 'ie',
88
- regex: /MSIE (\d+)/
89
- }, // IE 11
90
- {
91
- platform: 'ie',
92
- regex: /Trident\/.*; rv:(\d+)/
93
- }, // Edge
94
- {
95
- platform: 'edge',
96
- regex: /Edge\/(\d+)/
97
- }, // iOS 3 - 5
98
- // Apple likes to make this complicated
99
- {
100
- platform: 'ios',
101
- regex: /iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/
102
- }, // LG webOS
103
- {
104
- platform: 'webos',
105
- regex: /Web0S;.*Safari\/537.41/,
106
- forceVersion: 1
107
- }, {
108
- platform: 'webos',
109
- regex: /Web0S;.*Safari\/538.2/,
110
- forceVersion: 2
111
- }, {
112
- platform: 'webos',
113
- regex: /Web0S;.*Chrome\/38/,
114
- forceVersion: 3
115
- }, {
116
- platform: 'webos',
117
- regex: /Web0S;.*Chrome\/53/,
118
- forceVersion: 4
119
- }, {
120
- platform: 'webos',
121
- regex: /Web0S;.*Chrome\/68/,
122
- forceVersion: 5
123
- }, // LG webOS of indeterminate version
124
- {
125
- platform: 'webos',
126
- regex: /Web0S;/,
127
- forceVersion: -1
128
- }, // LuneOS
129
- {
130
- platform: 'webos',
131
- regex: /LuneOS/,
132
- forceVersion: -1,
133
- extra: {
134
- luneos: 1
135
- }
136
- }, // Palm/HP/Open webOS
137
- {
138
- platform: 'webos',
139
- regex: /WebAppManager|Isis|webOS\./,
140
- forceVersion: -1,
141
- extra: {
142
- legacy: 4
143
- }
144
- }, {
145
- platform: 'webos',
146
- regex: /(?:web|hpw)OS\/1/,
147
- forceVersion: -1,
148
- extra: {
149
- legacy: 1
150
- }
151
- }, {
152
- platform: 'webos',
153
- regex: /(?:web|hpw)OS\/2/,
154
- forceVersion: -1,
155
- extra: {
156
- legacy: 2
157
- }
158
- }, {
159
- platform: 'webos',
160
- regex: /(?:web|hpw)OS\/3/,
161
- forceVersion: -1,
162
- extra: {
163
- legacy: 3
164
- }
165
- }, // desktop Safari
166
- {
167
- platform: 'safari',
168
- regex: /Version\/(\d+)[.\d]+\s+Safari/
169
- }, // desktop Chrome
170
- {
171
- platform: 'chrome',
172
- regex: /Chrome\/(\d+)[.\d]+/
173
- }, // Firefox on Android
174
- {
175
- platform: 'androidFirefox',
176
- regex: /Android;.*Firefox\/(\d+)/
177
- }, // FirefoxOS
178
- {
179
- platform: 'firefoxOS',
180
- regex: /Mobile;.*Firefox\/(\d+)/
181
- }, // desktop Firefox
182
- {
183
- platform: 'firefox',
184
- regex: /Firefox\/(\d+)/
185
- }, // Blackberry Playbook
186
- {
187
- platform: 'blackberry',
188
- regex: /PlayBook/i,
189
- forceVersion: 2
190
- }, // Blackberry 10+
191
- {
192
- platform: 'blackberry',
193
- regex: /BB1\d;.*Version\/(\d+\.\d+)/
194
- }, // Tizen
195
- {
196
- platform: 'tizen',
197
- regex: /Tizen (\d+)/
198
- }];
199
-
200
- var ua = function ua() {
201
- return window.navigator ? window.navigator.userAgent : '';
202
- };
203
-
204
- var _platform;
205
-
206
- var parseUserAgent = function parseUserAgent(userAgent) {
207
- var plat = {
208
- gesture: hasGesture(),
209
- node: false,
210
- touch: hasTouch(),
211
- touchscreen: hasTouchScreen(),
212
- unknown: true
213
- };
214
-
215
- for (var i = 0, p, m, v; p = platforms[i]; i++) {
216
- m = p.regex.exec(userAgent);
217
-
218
- if (m) {
219
- plat.unknown = false;
220
-
221
- if ('forceVersion' in p) {
222
- v = p.forceVersion;
223
- } else {
224
- v = Number(m[1]);
225
- }
226
-
227
- plat[p.platform] = v;
228
-
229
- if (p.extra) {
230
- plat = _objectSpread(_objectSpread({}, plat), p.extra);
231
- }
232
-
233
- plat.platformName = p.platform;
234
- break;
235
- }
236
- }
237
-
238
- return plat;
239
- };
240
- /**
241
- * @typedef {Object} PlatformDescription
242
- * @property {Object} [extra] - Additional information about the detected platform
243
- * @property {Boolean} gesture - `true` if the platform has native double-finger events
244
- * @property {Boolean} node - `true` only if `window` is `undefined`
245
- * @property {String} [platformName] - The name of the platform, if detected
246
- * @property {Boolean} touch - `true` if the platform has native single-finger events
247
- * @property {Boolean} touchsreen - `true` if the platform has a touch screen
248
- * @property {Boolean} unknown - `true` for any unknown system
249
- *
250
- * @memberof core/platform
251
- * @public
252
- */
253
-
254
- /**
255
- * Returns the {@link core/platform.platform} object.
256
- *
257
- * @function detect
258
- * @returns {PlatformDescription} The {@link core/platform.platform} object
259
- * @memberof core/platform
260
- * @public
261
- */
262
-
263
-
264
- exports.parseUserAgent = parseUserAgent;
265
-
266
- var detect = function detect() {
267
- if (_platform) {
268
- // if we've already determined the platform, we'll use that determination
269
- return _platform;
270
- } else if (typeof window === 'undefined') {
271
- return {
272
- gesture: false,
273
- node: true,
274
- touch: false,
275
- unknown: true
276
- };
277
- }
278
-
279
- var userAgent = ua();
280
- return _platform = parseUserAgent(userAgent);
281
- };
282
- /**
283
- * Provides basic information about the running platform.
284
- *
285
- * @type {PlatformDescription}
286
- * @memberof core/platform
287
- * @public
288
- */
289
-
290
-
291
- exports.detect = detect;
292
- var platform = {};
293
- exports.platform = platform;
294
- ['gesture', 'node', 'platformName', 'touch', 'touchscreen', 'unknown'].concat(_toConsumableArray((0, _uniq["default"])(platforms.map(function (p) {
295
- return p.platform;
296
- })))).forEach(function (name) {
297
- Object.defineProperty(platform, name, {
298
- enumerable: true,
299
- get: function get() {
300
- var p = detect();
301
- return p[name];
302
- }
303
- });
304
- });
305
- var _default = platform;
306
- exports["default"] = _default;
@@ -1,92 +0,0 @@
1
- "use strict";
2
-
3
- var _platform = require("../platform");
4
-
5
- describe('platform', function () {
6
- describe('webOS', function () {
7
- // From http://webostv.developer.lge.com/discover/specifications/web-engine/
8
- var webOSTV5 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 WebAppManager';
9
- var webOSTV4 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.1785.34 Safari/537.36 WebAppManager';
10
- 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';
11
- var webOSTV2 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/538.2 (KHTML, like Gecko) Large Screen WebAppManager Safari/538.2';
12
- var webOSTV1 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.41 (KHTML, like Gecko) Large Screen WebAppManager Safari/537.41'; // From https://developers.whatismybrowser.com/useragents/explore/operating_system_name/webos/
13
-
14
- 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';
15
- 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';
16
- 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';
17
- 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';
18
- 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';
19
- 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';
20
- 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';
21
- 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';
22
- var webOSOther = 'Mozilla/5.0 (Web0S; Linux) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3440.106 Safari/537.36 WebAppManager';
23
- test('should return webOS 1', function () {
24
- var expected = {
25
- webos: 1
26
- };
27
- var actual = (0, _platform.parseUserAgent)(webOSTV1);
28
- expect(actual).toMatchObject(expected);
29
- });
30
- test('should return webOS 2', function () {
31
- var expected = {
32
- webos: 2
33
- };
34
- var actual = (0, _platform.parseUserAgent)(webOSTV2);
35
- expect(actual).toMatchObject(expected);
36
- });
37
- test('should return webOS 3', function () {
38
- var expected = {
39
- webos: 3
40
- };
41
- var actual = (0, _platform.parseUserAgent)(webOSTV3);
42
- expect(actual).toMatchObject(expected);
43
- });
44
- test('should return webOS 4', function () {
45
- var expected = {
46
- webos: 4
47
- };
48
- var actual = (0, _platform.parseUserAgent)(webOSTV4);
49
- expect(actual).toMatchObject(expected);
50
- });
51
- test('should return webOS 5', function () {
52
- var expected = {
53
- webos: 5
54
- };
55
- var actual = (0, _platform.parseUserAgent)(webOSTV5);
56
- expect(actual).toMatchObject(expected);
57
- });
58
- test('should return webOS -1', function () {
59
- var expected = {
60
- webos: -1
61
- };
62
- var actual = (0, _platform.parseUserAgent)(webOSOther);
63
- expect(actual).toMatchObject(expected);
64
- });
65
- test('should return webOS -1 + LuneOS 1', function () {
66
- var expected = {
67
- webos: -1,
68
- luneos: 1
69
- };
70
- expect((0, _platform.parseUserAgent)(LuneOS1)).toMatchObject(expected);
71
- expect((0, _platform.parseUserAgent)(LuneOS2)).toMatchObject(expected);
72
- });
73
- test('should return webOS -1 + legacy 1', function () {
74
- var expected = {
75
- webos: -1,
76
- legacy: 1
77
- };
78
- expect((0, _platform.parseUserAgent)(webOS10)).toMatchObject(expected);
79
- expect((0, _platform.parseUserAgent)(webOS11)).toMatchObject(expected);
80
- expect((0, _platform.parseUserAgent)(webOS12)).toMatchObject(expected);
81
- expect((0, _platform.parseUserAgent)(webOS13)).toMatchObject(expected);
82
- expect((0, _platform.parseUserAgent)(webOS1351)).toMatchObject(expected);
83
- });
84
- test('should return webOS -1 + legacy 2', function () {
85
- var expected = {
86
- webos: -1,
87
- legacy: 2
88
- };
89
- expect((0, _platform.parseUserAgent)(webOS2)).toMatchObject(expected);
90
- });
91
- });
92
- });
@@ -1,3 +0,0 @@
1
- {
2
- "main": "snapshot.js"
3
- }
@@ -1,89 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isWindowReady = isWindowReady;
7
- exports.onWindowReady = onWindowReady;
8
- exports.windowReady = windowReady;
9
- exports["default"] = void 0;
10
-
11
- var _invariant = _interopRequireDefault(require("invariant"));
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
-
15
- /**
16
- * Utilities to facilitate integration with v8 snapshot builds
17
- *
18
- * @module core/snapshot
19
- * @exports isWindowReady
20
- * @exports onWindowReady
21
- * @exports windowReady
22
- * @public
23
- */
24
- var windowCallbacks = [];
25
- /**
26
- * Determines if the `window` is available
27
- *
28
- * @function
29
- *
30
- * @returns {Boolean} `true` when `window` is ready
31
- * @memberof core/snapshot
32
- * @public
33
- */
34
-
35
- function isWindowReady() {
36
- return typeof window !== 'undefined';
37
- }
38
- /**
39
- * Executes a callback, such as registering event handlers, when a valid `window` is available.
40
- *
41
- * During normal operation, the callback will be executed immediately. During a pre-rendering pass,
42
- * the callback is not be executed at all. When using snapshot, the callback is added to a queue
43
- * and is executed in order once the window is available.
44
- *
45
- * *Important Notes*
46
- * * The callback should not alter the initial HTML state. If it does, it will invalidate the
47
- * pre-render state and interfere with React rehydration.
48
- * * The callback should be limited to module-scoped actions and not component instance actions. If
49
- * the action is tied to a component, it should be invoked from within the component's lifecycle
50
- * methods.
51
- *
52
- * @function
53
- * @param {Function} callback Function to run when the window is ready
54
- *
55
- * @returns {undefined}
56
- * @memberof core/snapshot
57
- * @public
58
- */
59
-
60
-
61
- function onWindowReady(callback) {
62
- if (isWindowReady()) {
63
- callback();
64
- } else {
65
- windowCallbacks.push(callback);
66
- }
67
- }
68
- /**
69
- * Executes all queued window callbacks.
70
- *
71
- * Requires that the window be, in fact, available and will throw an `Error` if not.
72
- *
73
- * @function
74
- *
75
- * @returns {undefined}
76
- * @memberof core/snapshot
77
- * @public
78
- */
79
-
80
-
81
- function windowReady() {
82
- !isWindowReady() ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, 'windowReady cannot be run until the window is available') : invariant(false) : void 0;
83
- windowCallbacks.forEach(function (f) {
84
- return f();
85
- });
86
- }
87
-
88
- var _default = onWindowReady;
89
- exports["default"] = _default;
@@ -1,3 +0,0 @@
1
- {
2
- "main": "useChainRefs.js"
3
- }
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- var _enzyme = require("enzyme");
4
-
5
- var _react = _interopRequireDefault(require("react"));
6
-
7
- var _useChainRefs = _interopRequireDefault(require("../useChainRefs"));
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
-
11
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
-
13
- 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."); }
14
-
15
- 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); }
16
-
17
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
18
-
19
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
20
-
21
- 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; }
22
-
23
- describe('useChainRefs', function () {
24
- function Component(props) {
25
- var ref = _useChainRefs["default"].apply(void 0, _toConsumableArray(props.refs));
26
-
27
- return /*#__PURE__*/_react["default"].createElement("div", {
28
- ref: ref
29
- });
30
- }
31
-
32
- test('should call a single functional ref', function () {
33
- var ref = jest.fn();
34
- (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
35
- refs: [ref]
36
- }));
37
- expect(ref).toHaveBeenCalledTimes(1);
38
- });
39
- test('should call a single object ref', function () {
40
- var ref = /*#__PURE__*/_react["default"].createRef();
41
-
42
- (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
43
- refs: [ref]
44
- }));
45
- var expected = 'DIV';
46
- var actual = ref.current.nodeName;
47
- expect(actual).toBe(expected);
48
- });
49
- test('should ignore invalid refs', function () {
50
- var invalid = {};
51
- var ref = jest.fn();
52
- (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
53
- refs: [invalid, ref]
54
- }));
55
- expect(ref).toHaveBeenCalledTimes(1);
56
- });
57
- });
@@ -1,78 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useChainRefs = useChainRefs;
7
- exports.chainRefs = chainRefs;
8
- exports["default"] = void 0;
9
-
10
- var _react = _interopRequireDefault(require("react"));
11
-
12
- var _warning = _interopRequireDefault(require("warning"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
- /**
17
- * Updates multiple reference callbacks or objects
18
- *
19
- * @module core/useChainRefs
20
- * @exports useChainRefs
21
- * @exports chainRefs
22
- * @private
23
- */
24
- // Safely handles functional and object refs (and ignores invalid refs)
25
- function updateRef(ref, node) {
26
- if (ref) {
27
- if (typeof ref === 'function') {
28
- ref(node);
29
- } else if (Object.prototype.hasOwnProperty.call(ref, 'current')) {
30
- ref.current = node;
31
- } else {
32
- // warn for a truthy ref that isn't a function or is an object without `current`
33
- process.env.NODE_ENV !== "production" ? (0, _warning["default"])(ref, "Invalid ref \"".concat(ref, "\" passed to useChainRefs.")) : void 0;
34
- }
35
- }
36
- }
37
- /**
38
- * Creates a reference callback that updates each of the provided references
39
- *
40
- * @memberof core/useChainRefs
41
- * @param {Object|Function} ...handlers List of references to be updated.
42
- * @returns {Function} A callback that updates each reference
43
- * @public
44
- */
45
-
46
-
47
- function chainRefs() {
48
- for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
49
- refs[_key] = arguments[_key];
50
- }
51
-
52
- return function (node) {
53
- refs.forEach(function (ref) {
54
- return updateRef(ref, node);
55
- });
56
- };
57
- }
58
- /**
59
- * Creates a memoized reference callback that updates each of the provided references
60
- *
61
- * @memberof core/useChainRefs
62
- * @param {Object|Function} ...handlers List of references to be updated.
63
- * @returns {Function} A memoized callback that updates each reference
64
- * @public
65
- */
66
-
67
-
68
- function useChainRefs() {
69
- for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
70
- refs[_key2] = arguments[_key2];
71
- }
72
-
73
- // eslint-disable-next-line react-hooks/exhaustive-deps
74
- return _react["default"].useCallback(chainRefs.apply(void 0, refs), refs);
75
- }
76
-
77
- var _default = useChainRefs;
78
- exports["default"] = _default;
@@ -1,3 +0,0 @@
1
- {
2
- "main": "useClass.js"
3
- }
@@ -1,51 +0,0 @@
1
- "use strict";
2
-
3
- var _enzyme = require("enzyme");
4
-
5
- var _react = _interopRequireDefault(require("react"));
6
-
7
- var _useClass = _interopRequireDefault(require("../useClass"));
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
-
11
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
-
13
- describe('useClass', function () {
14
- var Class = function Class(arg) {
15
- _classCallCheck(this, Class);
16
-
17
- this.arg = arg;
18
- };
19
-
20
- function Component(props) {
21
- var instance = (0, _useClass["default"])(Class, props.arg);
22
- return /*#__PURE__*/_react["default"].createElement("div", {
23
- fromProps: props.arg,
24
- fromClass: instance.arg
25
- });
26
- }
27
-
28
- test('should pass arg to Class', function () {
29
- var arg = 'arg';
30
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
31
- arg: arg
32
- }));
33
- var expected = arg;
34
- var actual = subject.prop('fromClass');
35
- expect(actual).toBe(expected);
36
- });
37
- test('should use the same instance of Class across renders', function () {
38
- var arg = 'arg';
39
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
40
- arg: arg
41
- }));
42
- expect(subject.prop('fromProps')).toBe(arg);
43
- subject.setProps({
44
- arg: 'changed'
45
- }); // verify that the children still reflects the class value set at construction but the prop
46
- // value was updated when props were updated
47
-
48
- expect(subject.prop('fromClass')).toBe(arg);
49
- expect(subject.prop('fromProps')).toBe('changed');
50
- });
51
- });