@enact/core 4.6.2 → 4.7.0
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 +7 -1
- package/handle/handle.js +21 -21
- package/handle/tests/handle-specs.js +99 -0
- package/hoc/tests/hoc-specs.js +1 -1
- package/internal/ApiDecorator/ApiDecorator.js +6 -2
- package/kind/kind.d.ts +47 -11
- package/kind/kind.js +21 -14
- package/package.json +1 -1
- package/platform/platform.js +15 -1
- package/platform/tests/platform-specs.js +10 -0
- package/util/Job.js +118 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
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.0] - 2023-04-25
|
|
6
|
+
|
|
7
|
+
### Deprecated
|
|
8
|
+
|
|
9
|
+
- `windowsPhone` platform in `core/platform.platforms` to be removed in 5.0.0
|
|
10
|
+
|
|
5
11
|
## [4.6.2] - 2023-03-09
|
|
6
12
|
|
|
7
13
|
No significant changes.
|
|
@@ -14,7 +20,7 @@ No significant changes.
|
|
|
14
20
|
|
|
15
21
|
### Fixed
|
|
16
22
|
|
|
17
|
-
- `core/dispatcher`
|
|
23
|
+
- `core/dispatcher` to set the default target for event listeners properly when built with the snapshot option
|
|
18
24
|
|
|
19
25
|
## [4.0.12] - 2022-09-16
|
|
20
26
|
|
package/handle/handle.js
CHANGED
|
@@ -815,34 +815,34 @@ var forwardCustom = handle.forwardCustom = function (name, adapter) {
|
|
|
815
815
|
*/
|
|
816
816
|
exports.forwardCustom = forwardCustom;
|
|
817
817
|
var forwardCustomWithPrevent = handle.forwardCustomWithPrevent = named(function (name, adapter) {
|
|
818
|
-
|
|
819
|
-
var adapterWithPrevent = function adapterWithPrevent(ev) {
|
|
818
|
+
return function (ev) {
|
|
820
819
|
for (var _len8 = arguments.length, args = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
|
|
821
820
|
args[_key8 - 1] = arguments[_key8];
|
|
822
821
|
}
|
|
823
|
-
var
|
|
824
|
-
var
|
|
822
|
+
var prevented = false;
|
|
823
|
+
var adapterWithPrevent = function adapterWithPrevent() {
|
|
824
|
+
var customEventPayload = adapter ? adapter.apply(void 0, [ev].concat(args)) : null;
|
|
825
|
+
var existingPreventDefault = null;
|
|
825
826
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
}
|
|
835
|
-
customEventPayload.preventDefault = function () {
|
|
836
|
-
prevented = true;
|
|
837
|
-
if (typeof existingPreventDefault === 'function') {
|
|
838
|
-
existingPreventDefault();
|
|
827
|
+
// Handle either no adapter or a non-object return from the adapter
|
|
828
|
+
if (!customEventPayload || typeof customEventPayload !== 'object') {
|
|
829
|
+
customEventPayload = {};
|
|
830
|
+
}
|
|
831
|
+
if (typeof customEventPayload.preventDefault === 'function') {
|
|
832
|
+
existingPreventDefault = customEventPayload.preventDefault;
|
|
833
|
+
} else if (typeof (ev === null || ev === void 0 ? void 0 : ev.preventDefault) === 'function') {
|
|
834
|
+
existingPreventDefault = ev.preventDefault.bind(ev);
|
|
839
835
|
}
|
|
836
|
+
customEventPayload.preventDefault = function () {
|
|
837
|
+
prevented = true;
|
|
838
|
+
if (typeof existingPreventDefault === 'function') {
|
|
839
|
+
existingPreventDefault(ev);
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
return customEventPayload;
|
|
840
843
|
};
|
|
841
|
-
return
|
|
844
|
+
return forwardCustom(name, adapterWithPrevent).apply(void 0, [ev].concat(args)) && !prevented;
|
|
842
845
|
};
|
|
843
|
-
return handle(forwardCustom(name, adapterWithPrevent), function () {
|
|
844
|
-
return !prevented;
|
|
845
|
-
});
|
|
846
846
|
}, 'forwardCustomWithPrevent');
|
|
847
847
|
|
|
848
848
|
/**
|
|
@@ -446,4 +446,103 @@ describe('handle', function () {
|
|
|
446
446
|
expect(actual).toEqual(expected);
|
|
447
447
|
});
|
|
448
448
|
});
|
|
449
|
+
describe('#forwardCustomWithPrevent', function () {
|
|
450
|
+
test('should pass an object with `type` and `preventDefault` when no adapter is provided', function () {
|
|
451
|
+
var handler = jest.fn();
|
|
452
|
+
(0, _handle.forwardCustomWithPrevent)('onCustomEvent')(null, {
|
|
453
|
+
onCustomEvent: handler
|
|
454
|
+
});
|
|
455
|
+
var actual = handler.mock.calls[0][0];
|
|
456
|
+
expect(actual).toEqual(expect.objectContaining({
|
|
457
|
+
type: 'onCustomEvent',
|
|
458
|
+
preventDefault: expect.any(Function)
|
|
459
|
+
}));
|
|
460
|
+
});
|
|
461
|
+
test('should add `type` and `preventDefault` to object returned by adapter', function () {
|
|
462
|
+
var handler = jest.fn();
|
|
463
|
+
var adapter = function adapter() {
|
|
464
|
+
return {
|
|
465
|
+
index: 0
|
|
466
|
+
};
|
|
467
|
+
};
|
|
468
|
+
(0, _handle.forwardCustomWithPrevent)('onCustomEvent', adapter)(null, {
|
|
469
|
+
onCustomEvent: handler
|
|
470
|
+
});
|
|
471
|
+
var actual = handler.mock.calls[0][0];
|
|
472
|
+
expect(actual).toEqual(expect.objectContaining({
|
|
473
|
+
type: 'onCustomEvent',
|
|
474
|
+
preventDefault: expect.any(Function),
|
|
475
|
+
index: 0
|
|
476
|
+
}));
|
|
477
|
+
});
|
|
478
|
+
test('should create an event payload if the adapter returns nothing', function () {
|
|
479
|
+
var handler = jest.fn();
|
|
480
|
+
var adapter = function adapter() {
|
|
481
|
+
return null;
|
|
482
|
+
};
|
|
483
|
+
(0, _handle.forwardCustomWithPrevent)('onCustomEvent', adapter)(null, {
|
|
484
|
+
onCustomEvent: handler
|
|
485
|
+
});
|
|
486
|
+
var actual = handler.mock.calls[0][0];
|
|
487
|
+
expect(actual).toEqual(expect.objectContaining({
|
|
488
|
+
type: 'onCustomEvent',
|
|
489
|
+
preventDefault: expect.any(Function)
|
|
490
|
+
}));
|
|
491
|
+
});
|
|
492
|
+
test('should pass an object with `preventDefault` and `stopPropagation` when event has them', function () {
|
|
493
|
+
var ev = {
|
|
494
|
+
preventDefault: jest.fn(),
|
|
495
|
+
stopPropagation: function stopPropagation() {}
|
|
496
|
+
};
|
|
497
|
+
var handler = jest.fn();
|
|
498
|
+
var adapter = function adapter() {
|
|
499
|
+
return null;
|
|
500
|
+
};
|
|
501
|
+
(0, _handle.forwardCustomWithPrevent)('onCustomEvent', adapter)(ev, {
|
|
502
|
+
onCustomEvent: handler
|
|
503
|
+
});
|
|
504
|
+
var actual = handler.mock.calls[0][0];
|
|
505
|
+
expect(actual).toEqual(expect.objectContaining({
|
|
506
|
+
type: 'onCustomEvent',
|
|
507
|
+
preventDefault: expect.any(Function),
|
|
508
|
+
stopPropagation: expect.any(Function)
|
|
509
|
+
}));
|
|
510
|
+
actual.preventDefault();
|
|
511
|
+
expect(ev.preventDefault).toHaveBeenCalled();
|
|
512
|
+
});
|
|
513
|
+
test('should pass event, props, and context args to adapter', function () {
|
|
514
|
+
var adapter = jest.fn();
|
|
515
|
+
var args = [1,
|
|
516
|
+
// ev,
|
|
517
|
+
2,
|
|
518
|
+
// props,
|
|
519
|
+
3 // context
|
|
520
|
+
];
|
|
521
|
+
|
|
522
|
+
(0, _handle.forwardCustomWithPrevent)('onCustomEvent', adapter).apply(void 0, args);
|
|
523
|
+
var expected = args;
|
|
524
|
+
var actual = adapter.mock.calls[0];
|
|
525
|
+
expect(actual).toEqual(expected);
|
|
526
|
+
});
|
|
527
|
+
test('should call the next handler when `preventDefault` from provided props hasn\'t been called', function () {
|
|
528
|
+
var event = 'onMyClick';
|
|
529
|
+
var handler = jest.fn();
|
|
530
|
+
var callback = (0, _handle.handle)((0, _handle.forwardCustomWithPrevent)(event), handler);
|
|
531
|
+
callback();
|
|
532
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
533
|
+
});
|
|
534
|
+
test('should not call the next handler when `preventDefault` from provided props has been called', function () {
|
|
535
|
+
var event = 'onMyClick';
|
|
536
|
+
var handler = jest.fn();
|
|
537
|
+
var callback = (0, _handle.handle)((0, _handle.forwardCustomWithPrevent)(event), handler);
|
|
538
|
+
|
|
539
|
+
// should stop chain when `preventDefault()` has been called
|
|
540
|
+
callback({}, {
|
|
541
|
+
'onMyClick': function onMyClick(ev) {
|
|
542
|
+
return ev.preventDefault();
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
expect(handler).not.toHaveBeenCalled();
|
|
546
|
+
});
|
|
547
|
+
});
|
|
449
548
|
});
|
package/hoc/tests/hoc-specs.js
CHANGED
|
@@ -9,7 +9,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
9
9
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
10
|
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; }
|
|
11
11
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint-disable enact/display-name */
|
|
13
13
|
describe('hoc', function () {
|
|
14
14
|
var data;
|
|
15
15
|
var testID = 'test-HoC';
|
|
@@ -23,8 +23,12 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
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
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; } }
|
|
26
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
27
|
-
|
|
26
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
|
|
27
|
+
* Provides the `ApiDecorator` higher-order component
|
|
28
|
+
*
|
|
29
|
+
* @module core/internal/ApiDecorator
|
|
30
|
+
* @private
|
|
31
|
+
*/ // Gets a property from `provider`
|
|
28
32
|
var get = function get(provider, name) {
|
|
29
33
|
return function () {
|
|
30
34
|
if (provider) {
|
package/kind/kind.d.ts
CHANGED
|
@@ -20,19 +20,55 @@ export interface HandlerFunction {
|
|
|
20
20
|
* Configuration for CSS class name mapping
|
|
21
21
|
*/
|
|
22
22
|
export interface StylesBlock {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The CSS of the component
|
|
25
|
+
*/
|
|
26
|
+
css: { [key: string]: string }
|
|
27
|
+
/**
|
|
28
|
+
* The className of the component
|
|
29
|
+
*/;
|
|
30
|
+
className?: string /**
|
|
31
|
+
* Specifies which class names are overridable.
|
|
32
|
+
If this value is `true` , all of the class names of the component CSS will become public.
|
|
33
|
+
*/;
|
|
25
34
|
publicClassNames?: boolean | string | string[];
|
|
26
35
|
}
|
|
27
36
|
export interface KindConfig {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
/**
|
|
38
|
+
* The name of the component
|
|
39
|
+
*/
|
|
40
|
+
name?: string
|
|
41
|
+
/**
|
|
42
|
+
* Boolean controlling whether the returned component should be a functional component
|
|
43
|
+
*/;
|
|
44
|
+
functional?: boolean
|
|
45
|
+
/**
|
|
46
|
+
* Specifies expected props
|
|
47
|
+
*/;
|
|
48
|
+
propTypes?: { [key: string]: Function }
|
|
49
|
+
/**
|
|
50
|
+
* Sets the default props
|
|
51
|
+
*/;
|
|
52
|
+
defaultProps?: { [key: string]: any }
|
|
53
|
+
/**
|
|
54
|
+
* Specifies context type
|
|
55
|
+
*/;
|
|
56
|
+
contextType?: object
|
|
57
|
+
/**
|
|
58
|
+
* Configures styles with the static className to merge with user className
|
|
59
|
+
*/;
|
|
60
|
+
styles?: StylesBlock /**
|
|
61
|
+
* Adds event handlers that are cached between calls to prevent recreating each call.
|
|
62
|
+
Any handlers are added to the props passed to `render()` . See .
|
|
63
|
+
*/;
|
|
64
|
+
handlers?: { [key: string]: HandlerFunction }
|
|
65
|
+
/**
|
|
66
|
+
* Adds some computed properties, these are added to props passed to `render()`
|
|
67
|
+
*/;
|
|
68
|
+
computed?: { [key: string]: ComputedPropFunction }
|
|
69
|
+
/**
|
|
70
|
+
* The render function
|
|
71
|
+
*/;
|
|
36
72
|
render: RenderFunction;
|
|
37
73
|
}
|
|
38
74
|
/**
|
|
@@ -43,7 +79,7 @@ export interface KindConfig {
|
|
|
43
79
|
import css from './Button.module.less';
|
|
44
80
|
const Button = kind({
|
|
45
81
|
name: 'Button',
|
|
46
|
-
// Return a functional component
|
|
82
|
+
// Return a functional component
|
|
47
83
|
functional: true,
|
|
48
84
|
// expect color and onClick properties but neither required
|
|
49
85
|
propTypes: {
|
package/kind/kind.js
CHANGED
|
@@ -24,7 +24,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
24
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
25
|
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; }
|
|
26
26
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
27
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
27
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
|
|
28
|
+
* Provides the {@link core/kind.kind} method to create components
|
|
29
|
+
*
|
|
30
|
+
* @module core/kind
|
|
31
|
+
* @exports kind
|
|
32
|
+
*/
|
|
28
33
|
// Because contextType is optional and hooks must be called in the same order, we need a fallback
|
|
29
34
|
// context when none is specified. This likely has some overhead so we may want to deprecate and
|
|
30
35
|
// remove contextType support for 4.0 since the context APIs have improved since this was added.
|
|
@@ -59,23 +64,25 @@ var NoContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
|
59
64
|
*
|
|
60
65
|
* @typedef {Object} StylesBlock
|
|
61
66
|
* @memberof core/kind
|
|
62
|
-
* @property {Object.<string, string>} css
|
|
63
|
-
* @property {String} [className]
|
|
64
|
-
* @property {Boolean|String|String[]} [publicClassNames]
|
|
67
|
+
* @property {Object.<string, string>} css The CSS of the component
|
|
68
|
+
* @property {String} [className] The className of the component
|
|
69
|
+
* @property {Boolean|String|String[]} [publicClassNames] Specifies which class names are overridable.
|
|
70
|
+
* If this value is `true`, all of the class names of the component CSS will become public.
|
|
65
71
|
*/
|
|
66
72
|
|
|
67
73
|
/**
|
|
68
74
|
* @typedef {Object} KindConfig
|
|
69
75
|
* @memberof core/kind
|
|
70
|
-
* @property {String} [name]
|
|
71
|
-
* @property {Boolean} [functional]
|
|
72
|
-
* @property {Object.<string, Function>} [propTypes]
|
|
73
|
-
* @property {Object.<string, any>} [defaultProps]
|
|
74
|
-
* @property {Object} [contextType]
|
|
75
|
-
* @property {StylesBlock} [styles]
|
|
76
|
-
* @property {Object.<string, HandlerFunction>} [handlers]
|
|
77
|
-
*
|
|
78
|
-
* @property {
|
|
76
|
+
* @property {String} [name] The name of the component
|
|
77
|
+
* @property {Boolean} [functional] Boolean controlling whether the returned component should be a functional component
|
|
78
|
+
* @property {Object.<string, Function>} [propTypes] Specifies expected props
|
|
79
|
+
* @property {Object.<string, any>} [defaultProps] Sets the default props
|
|
80
|
+
* @property {Object} [contextType] Specifies context type
|
|
81
|
+
* @property {StylesBlock} [styles] Configures styles with the static className to merge with user className
|
|
82
|
+
* @property {Object.<string, HandlerFunction>} [handlers] Adds event handlers that are cached between calls to prevent recreating each call.
|
|
83
|
+
* Any handlers are added to the props passed to `render()`. See {@link core/handle.handle}.
|
|
84
|
+
* @property {Object.<string, ComputedPropFunction>} [computed] Adds some computed properties, these are added to props passed to `render()`
|
|
85
|
+
* @property {RenderFunction} render The render function
|
|
79
86
|
*/
|
|
80
87
|
|
|
81
88
|
/**
|
|
@@ -86,7 +93,7 @@ var NoContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
|
86
93
|
* import css from './Button.module.less';
|
|
87
94
|
* const Button = kind({
|
|
88
95
|
* name: 'Button',
|
|
89
|
-
* // Return a functional component
|
|
96
|
+
* // Return a functional component
|
|
90
97
|
* functional: true,
|
|
91
98
|
* // expect color and onClick properties but neither required
|
|
92
99
|
* propTypes: {
|
package/package.json
CHANGED
package/platform/platform.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.platform = exports.parseUserAgent = exports.detect = exports["default"] = void 0;
|
|
7
7
|
var _uniq = _interopRequireDefault(require("ramda/src/uniq"));
|
|
8
|
+
var _deprecate = _interopRequireDefault(require("../internal/deprecate"));
|
|
8
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
10
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
10
11
|
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."); }
|
|
@@ -16,7 +17,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
16
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
18
|
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
19
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
19
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
|
|
21
|
+
* Utilities for detecting basic platform capabilities.
|
|
22
|
+
*
|
|
23
|
+
* @module core/platform
|
|
24
|
+
* @exports detect
|
|
25
|
+
* @exports platform
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
20
28
|
var hasGesture = function hasGesture() {
|
|
21
29
|
return Boolean('ongesturestart' in window || 'onmsgesturestart' in window && (window.navigator.msMaxTouchPoints > 1 || window.navigator.maxTouchPoints > 1));
|
|
22
30
|
};
|
|
@@ -238,6 +246,12 @@ var parseUserAgent = function parseUserAgent(userAgent) {
|
|
|
238
246
|
break;
|
|
239
247
|
}
|
|
240
248
|
}
|
|
249
|
+
if (plat.platformName === 'windowsPhone') {
|
|
250
|
+
(0, _deprecate["default"])({
|
|
251
|
+
name: 'Windows Phone platform',
|
|
252
|
+
until: '5.0.0'
|
|
253
|
+
});
|
|
254
|
+
}
|
|
241
255
|
return plat;
|
|
242
256
|
};
|
|
243
257
|
|
|
@@ -106,6 +106,16 @@ describe('platform', function () {
|
|
|
106
106
|
expect((0, _platform.parseUserAgent)(webOS2)).toMatchObject(expected);
|
|
107
107
|
});
|
|
108
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
|
+
});
|
|
109
119
|
describe('parseUserAgent for User-Agent Reduction', function () {
|
|
110
120
|
var testVersion = '113';
|
|
111
121
|
var uaGenerator = function uaGenerator(unifiedPlatform) {
|
package/util/Job.js
CHANGED
|
@@ -163,6 +163,124 @@ var Job = /*#__PURE__*/function () {
|
|
|
163
163
|
* @memberof core/util.Job.prototype
|
|
164
164
|
* @public
|
|
165
165
|
*/
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Starts the job in `timeout` milliseconds
|
|
169
|
+
*
|
|
170
|
+
* @method
|
|
171
|
+
* @param {Number} timeout The number of milliseconds to wait before starting the job.
|
|
172
|
+
* This supersedes the timeout set at construction.
|
|
173
|
+
* @param {...*} [args] Any args passed are forwarded to the callback
|
|
174
|
+
*
|
|
175
|
+
* @returns {undefined}
|
|
176
|
+
* @memberof core/util.Job.prototype
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Stops the job.
|
|
182
|
+
*
|
|
183
|
+
* @method
|
|
184
|
+
*
|
|
185
|
+
* @returns {undefined}
|
|
186
|
+
* @memberof core/util.Job.prototype
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Executes the job immediately, then prevents any other calls to `throttle()` from running
|
|
192
|
+
* until the `timeout` configured at construction passes.
|
|
193
|
+
*
|
|
194
|
+
* @method
|
|
195
|
+
* @param {...*} args Any args passed are forwarded to the callback
|
|
196
|
+
*
|
|
197
|
+
* @returns {undefined}
|
|
198
|
+
* @memberof core/util.Job.prototype
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Executes the job immediately, then prevents any other calls to `throttle()` from running for
|
|
204
|
+
* `timeout` milliseconds.
|
|
205
|
+
*
|
|
206
|
+
* @method
|
|
207
|
+
* @param {Number} timeout The number of milliseconds to wait before allowing the job to
|
|
208
|
+
* be ran again. This supersedes the timeout set at construction.
|
|
209
|
+
* @param {...*} [args] Any args passed are forwarded to the callback
|
|
210
|
+
*
|
|
211
|
+
* @returns {undefined}
|
|
212
|
+
* @memberof core/util.Job.prototype
|
|
213
|
+
* @public
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Executes job when the CPU is idle.
|
|
218
|
+
*
|
|
219
|
+
* @method
|
|
220
|
+
* @param {...*} [args] Any args passed are forwarded to the callback
|
|
221
|
+
*
|
|
222
|
+
* @returns {undefined}
|
|
223
|
+
* @memberof core/util.Job.prototype
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Executes job when the CPU is idle, or when the timeout is reached, whichever occurs first.
|
|
229
|
+
*
|
|
230
|
+
* @method
|
|
231
|
+
* @param {Number} timeout The number of milliseconds to wait before executing the
|
|
232
|
+
* job. This guarantees that the job is run, if a positive value
|
|
233
|
+
* is specified.
|
|
234
|
+
* @param {...*} [args] Any args passed are forwarded to the callback
|
|
235
|
+
*
|
|
236
|
+
* @returns {undefined}
|
|
237
|
+
* @memberof core/util.Job.prototype
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Executes job before the next repaint.
|
|
243
|
+
*
|
|
244
|
+
* @method
|
|
245
|
+
* @param {...*} [args] Any args passed are forwarded to the callback
|
|
246
|
+
*
|
|
247
|
+
* @returns {undefined}
|
|
248
|
+
* @memberof core/util.Job.prototype
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Executes job before the next repaint after a given amount of timeout.
|
|
254
|
+
*
|
|
255
|
+
* @method
|
|
256
|
+
* @param {Number} timeout The number of milliseconds to wait before running `requestAnimationFrame`.
|
|
257
|
+
* @param {...*} [args] Any args passed are forwarded to the callback
|
|
258
|
+
*
|
|
259
|
+
* @returns {undefined}
|
|
260
|
+
* @memberof core/util.Job.prototype
|
|
261
|
+
* @public
|
|
262
|
+
*/
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Starts the job when `promise` resolves.
|
|
266
|
+
*
|
|
267
|
+
* The job execution is tied to the resolution of the last `Promise` passed. Like other methods
|
|
268
|
+
* on `Job`, calling `promise()` again with a new `Promise` will block execution of the job
|
|
269
|
+
* until that new `Promise` resolves. Any previous `Promise`s will still resolve normally but
|
|
270
|
+
* will not trigger job execution.
|
|
271
|
+
*
|
|
272
|
+
* Unlike other methods on `Job`, `promise()` returns a `Promise` which is the result of calling
|
|
273
|
+
* `then()` on the passed `promise`. That `Promise` resolves with either the result of job
|
|
274
|
+
* execution or `undefined` if `Promise` was superseded by a subsequent `Promise` passed as
|
|
275
|
+
* described above.
|
|
276
|
+
*
|
|
277
|
+
* @method
|
|
278
|
+
* @param {Promise} promise The promise that must resolve before the job is executed
|
|
279
|
+
*
|
|
280
|
+
* @returns {Promise}
|
|
281
|
+
* @memberof core/util.Job.prototype
|
|
282
|
+
* @public
|
|
283
|
+
*/
|
|
166
284
|
}]);
|
|
167
285
|
return Job;
|
|
168
286
|
}();
|