@studiometa/js-toolkit 2.2.0-alpha.0 → 2.2.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/Base/managers/EventsManager.cjs +19 -6
- package/Base/managers/EventsManager.d.ts +0 -4
- package/Base/managers/EventsManager.js +19 -6
- package/Base/managers/OptionsManager.cjs +1 -1
- package/Base/managers/OptionsManager.js +1 -1
- package/decorators/withVue2.cjs +1 -1
- package/decorators/withVue2.js +1 -1
- package/package.json +2 -2
- package/utils/css/animate.d.ts +5 -7
- package/utils/css/transition.cjs +6 -6
- package/utils/css/transition.js +1 -1
- package/utils/index.cjs +2 -2
- package/utils/index.d.ts +1 -1
- package/utils/index.js +14 -14
- package/utils/math/createEases.cjs +32 -0
- package/utils/math/createEases.d.ts +18 -0
- package/utils/math/createEases.js +10 -0
- package/utils/math/ease.cjs +15 -22
- package/utils/math/ease.d.ts +16 -33
- package/utils/math/ease.js +1 -8
- package/utils/math/index.cjs +1 -0
- package/utils/math/index.d.ts +1 -0
- package/utils/math/index.js +1 -0
- package/utils/nextFrame.cjs +2 -2
- package/utils/nextFrame.d.ts +1 -1
- package/utils/nextFrame.js +2 -2
- package/utils/scheduler.cjs +5 -3
- package/utils/scheduler.js +5 -3
|
@@ -35,21 +35,34 @@ module.exports = __toCommonJS(EventsManager_exports);
|
|
|
35
35
|
var import_getAllProperties = __toESM(require("../../utils/object/getAllProperties.cjs"), 1);
|
|
36
36
|
var import_AbstractManager = __toESM(require("./AbstractManager.cjs"), 1);
|
|
37
37
|
var import_RefsManager = require("./RefsManager.cjs");
|
|
38
|
+
var names = /* @__PURE__ */ new Map();
|
|
38
39
|
function normalizeName(name) {
|
|
39
|
-
|
|
40
|
+
if (!names.has(name)) {
|
|
41
|
+
names.set(name, name.replace(/[A-Z]([A-Z].*)/g, (c) => c.toLowerCase()).replace(/[^a-zA-Z\d\s:]/g, " ").replace(/(^\w|\s+\w)/g, (c) => c.trim().toUpperCase()).trim());
|
|
42
|
+
}
|
|
43
|
+
return names.get(name);
|
|
40
44
|
}
|
|
45
|
+
var eventNames = /* @__PURE__ */ new Map();
|
|
41
46
|
function normalizeEventName(name) {
|
|
42
|
-
|
|
47
|
+
if (!eventNames.has(name)) {
|
|
48
|
+
eventNames.set(name, name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace(/^-/, ""));
|
|
49
|
+
}
|
|
50
|
+
return eventNames.get(name);
|
|
51
|
+
}
|
|
52
|
+
var regexes = /* @__PURE__ */ new Map();
|
|
53
|
+
function getRegex(regex) {
|
|
54
|
+
if (!regexes.has(regex)) {
|
|
55
|
+
regexes.set(regex, new RegExp(regex));
|
|
56
|
+
}
|
|
57
|
+
return regexes.get(regex);
|
|
43
58
|
}
|
|
44
59
|
function __getEventNameByMethod(that, method, name = "") {
|
|
45
|
-
const
|
|
46
|
-
const regex = new RegExp(`^on${normalizedName}([A-Z].*)$`);
|
|
60
|
+
const regex = getRegex(`^on${normalizeName(name)}([A-Z].*)$`);
|
|
47
61
|
const [, event] = method.match(regex);
|
|
48
62
|
return normalizeEventName(event);
|
|
49
63
|
}
|
|
50
64
|
function __getEventMethodsByName(that, name = "") {
|
|
51
|
-
const
|
|
52
|
-
const regex = new RegExp(`^on${normalizedName}[A-Z].*$`);
|
|
65
|
+
const regex = getRegex(`^on${normalizeName(name)}[A-Z].*$`);
|
|
53
66
|
const key = regex.toString();
|
|
54
67
|
let methods = that.__methodsCache.get(key);
|
|
55
68
|
if (!methods) {
|
|
@@ -7,21 +7,34 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
import getAllProperties from "../../utils/object/getAllProperties.js";
|
|
8
8
|
import AbstractManager from "./AbstractManager.js";
|
|
9
9
|
import { normalizeRefName } from "./RefsManager.js";
|
|
10
|
+
const names = /* @__PURE__ */ new Map();
|
|
10
11
|
function normalizeName(name) {
|
|
11
|
-
|
|
12
|
+
if (!names.has(name)) {
|
|
13
|
+
names.set(name, name.replace(/[A-Z]([A-Z].*)/g, (c) => c.toLowerCase()).replace(/[^a-zA-Z\d\s:]/g, " ").replace(/(^\w|\s+\w)/g, (c) => c.trim().toUpperCase()).trim());
|
|
14
|
+
}
|
|
15
|
+
return names.get(name);
|
|
12
16
|
}
|
|
17
|
+
const eventNames = /* @__PURE__ */ new Map();
|
|
13
18
|
function normalizeEventName(name) {
|
|
14
|
-
|
|
19
|
+
if (!eventNames.has(name)) {
|
|
20
|
+
eventNames.set(name, name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace(/^-/, ""));
|
|
21
|
+
}
|
|
22
|
+
return eventNames.get(name);
|
|
23
|
+
}
|
|
24
|
+
const regexes = /* @__PURE__ */ new Map();
|
|
25
|
+
function getRegex(regex) {
|
|
26
|
+
if (!regexes.has(regex)) {
|
|
27
|
+
regexes.set(regex, new RegExp(regex));
|
|
28
|
+
}
|
|
29
|
+
return regexes.get(regex);
|
|
15
30
|
}
|
|
16
31
|
function __getEventNameByMethod(that, method, name = "") {
|
|
17
|
-
const
|
|
18
|
-
const regex = new RegExp(`^on${normalizedName}([A-Z].*)$`);
|
|
32
|
+
const regex = getRegex(`^on${normalizeName(name)}([A-Z].*)$`);
|
|
19
33
|
const [, event] = method.match(regex);
|
|
20
34
|
return normalizeEventName(event);
|
|
21
35
|
}
|
|
22
36
|
function __getEventMethodsByName(that, name = "") {
|
|
23
|
-
const
|
|
24
|
-
const regex = new RegExp(`^on${normalizedName}[A-Z].*$`);
|
|
37
|
+
const regex = getRegex(`^on${normalizeName(name)}[A-Z].*$`);
|
|
25
38
|
const key = regex.toString();
|
|
26
39
|
let methods = that.__methodsCache.get(key);
|
|
27
40
|
if (!methods) {
|
|
@@ -76,12 +76,12 @@ function __register(that, name, config) {
|
|
|
76
76
|
}
|
|
77
77
|
var OptionsManager = class extends import_AbstractManager.default {
|
|
78
78
|
constructor(base) {
|
|
79
|
+
var _a, _b;
|
|
79
80
|
super(base);
|
|
80
81
|
__publicField(this, "__values", {});
|
|
81
82
|
__publicField(this, "name", "Base");
|
|
82
83
|
__publicField(this, "debug", false);
|
|
83
84
|
__publicField(this, "log", false);
|
|
84
|
-
var _a, _b;
|
|
85
85
|
this.__hideProperties(["__values", "__defaultValues"]);
|
|
86
86
|
const schema = this.__config.options || {};
|
|
87
87
|
this.name = this.__config.name;
|
|
@@ -49,12 +49,12 @@ function __register(that, name, config) {
|
|
|
49
49
|
}
|
|
50
50
|
class OptionsManager extends AbstractManager {
|
|
51
51
|
constructor(base) {
|
|
52
|
+
var _a, _b;
|
|
52
53
|
super(base);
|
|
53
54
|
__publicField(this, "__values", {});
|
|
54
55
|
__publicField(this, "name", "Base");
|
|
55
56
|
__publicField(this, "debug", false);
|
|
56
57
|
__publicField(this, "log", false);
|
|
57
|
-
var _a, _b;
|
|
58
58
|
this.__hideProperties(["__values", "__defaultValues"]);
|
|
59
59
|
const schema = this.__config.options || {};
|
|
60
60
|
this.name = this.__config.name;
|
package/decorators/withVue2.cjs
CHANGED
|
@@ -31,9 +31,9 @@ var withVue2_default = (BaseClass, Vue) => {
|
|
|
31
31
|
var _a, _b, _c;
|
|
32
32
|
return _c = class extends BaseClass {
|
|
33
33
|
constructor(element) {
|
|
34
|
+
var _a2;
|
|
34
35
|
super(element);
|
|
35
36
|
__publicField(this, "$vue");
|
|
36
|
-
var _a2;
|
|
37
37
|
const vueConfig = (_a2 = this.vueConfig) != null ? _a2 : this.constructor.vueConfig;
|
|
38
38
|
if (!vueConfig) {
|
|
39
39
|
throw new Error("[withVue] You must define a `vueConfig` object.");
|
package/decorators/withVue2.js
CHANGED
|
@@ -8,9 +8,9 @@ var withVue2_default = (BaseClass, Vue) => {
|
|
|
8
8
|
var _a, _b, _c;
|
|
9
9
|
return _c = class extends BaseClass {
|
|
10
10
|
constructor(element) {
|
|
11
|
+
var _a2;
|
|
11
12
|
super(element);
|
|
12
13
|
__publicField(this, "$vue");
|
|
13
|
-
var _a2;
|
|
14
14
|
const vueConfig = (_a2 = this.vueConfig) != null ? _a2 : this.constructor.vueConfig;
|
|
15
15
|
if (!vueConfig) {
|
|
16
16
|
throw new Error("[withVue] You must define a `vueConfig` object.");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiometa/js-toolkit",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "A set of useful little bits of JavaScript to boost your project! 🚀",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"toolkit"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@motionone/easing": "^10.
|
|
42
|
+
"@motionone/easing": "^10.9.0",
|
|
43
43
|
"deepmerge": "^4.2.2"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/utils/css/animate.d.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import('./transform.js').TransformProps} TransformProps
|
|
3
|
-
* @typedef {import('../math/ease.js').EasingFunction} EasingFn
|
|
4
3
|
* @typedef {[number, number, number, number]} BezierCurve
|
|
5
4
|
* @typedef {{
|
|
6
5
|
* duration?: number;
|
|
7
|
-
* easing?:
|
|
6
|
+
* easing?: import('../math/createEases.js').EasingFunction|BezierCurve;
|
|
8
7
|
* onProgress?: (progress: number, easedProgress: number) => void;
|
|
9
8
|
* onFinish?: (progress: number, easedProgress: number) => void;
|
|
10
9
|
* }} Options
|
|
11
10
|
* @typedef {TransformProps & {
|
|
12
11
|
* opacity?: number;
|
|
13
12
|
* transformOrigin?: string;
|
|
14
|
-
* easing?:
|
|
13
|
+
* easing?: import('../math/createEases.js').EasingFunction|BezierCurve;
|
|
15
14
|
* offset?: number;
|
|
16
15
|
* }} Keyframe
|
|
17
16
|
* @typedef {Keyframe & {
|
|
18
|
-
* easing:
|
|
17
|
+
* easing: import('../math/createEases.js').EasingFunction;
|
|
19
18
|
* offset: number;
|
|
20
19
|
* }} NormalizedKeyframe
|
|
21
20
|
* @typedef {{
|
|
@@ -35,17 +34,16 @@
|
|
|
35
34
|
*/
|
|
36
35
|
export function animate(element: HTMLElement, keyframes: Keyframe[], options?: Options): Animate;
|
|
37
36
|
export type TransformProps = import('./transform.js').TransformProps;
|
|
38
|
-
export type EasingFn = import('../math/ease.js').EasingFunction;
|
|
39
37
|
export type BezierCurve = [number, number, number, number];
|
|
40
38
|
export type Options = Options;
|
|
41
39
|
export type Keyframe = TransformProps & {
|
|
42
40
|
opacity?: number;
|
|
43
41
|
transformOrigin?: string;
|
|
44
|
-
easing?:
|
|
42
|
+
easing?: import('../math/createEases.js').EasingFunction | [number, number, number, number];
|
|
45
43
|
offset?: number;
|
|
46
44
|
};
|
|
47
45
|
export type NormalizedKeyframe = Keyframe & {
|
|
48
|
-
easing:
|
|
46
|
+
easing: import('../math/createEases.js').EasingFunction;
|
|
49
47
|
offset: number;
|
|
50
48
|
};
|
|
51
49
|
export type Animate = {
|
package/utils/css/transition.cjs
CHANGED
|
@@ -31,7 +31,7 @@ __export(transition_exports, {
|
|
|
31
31
|
setClassesOrStyles: () => setClassesOrStyles
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(transition_exports);
|
|
34
|
-
var import_nextFrame =
|
|
34
|
+
var import_nextFrame = require("../nextFrame.cjs");
|
|
35
35
|
var classes = __toESM(require("./classes.cjs"), 1);
|
|
36
36
|
var styles = __toESM(require("./styles.cjs"), 1);
|
|
37
37
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -67,11 +67,11 @@ async function start(element, classesOrStyles) {
|
|
|
67
67
|
const trs = Transition.getInstance(element);
|
|
68
68
|
trs.isTransitioning = true;
|
|
69
69
|
setClassesOrStyles(element, classesOrStyles.from);
|
|
70
|
-
await (0, import_nextFrame.
|
|
71
|
-
await (0, import_nextFrame.
|
|
70
|
+
await (0, import_nextFrame.nextFrame)();
|
|
71
|
+
await (0, import_nextFrame.nextFrame)();
|
|
72
72
|
setClassesOrStyles(element, classesOrStyles.active);
|
|
73
|
-
await (0, import_nextFrame.
|
|
74
|
-
await (0, import_nextFrame.
|
|
73
|
+
await (0, import_nextFrame.nextFrame)();
|
|
74
|
+
await (0, import_nextFrame.nextFrame)();
|
|
75
75
|
}
|
|
76
76
|
async function next(element, classesOrStyles) {
|
|
77
77
|
const hasTransition = testTransition(element);
|
|
@@ -83,7 +83,7 @@ async function next(element, classesOrStyles) {
|
|
|
83
83
|
}
|
|
84
84
|
setClassesOrStyles(element, classesOrStyles.from, "remove");
|
|
85
85
|
setClassesOrStyles(element, classesOrStyles.to);
|
|
86
|
-
await (0, import_nextFrame.
|
|
86
|
+
await (0, import_nextFrame.nextFrame)();
|
|
87
87
|
if (!hasTransition) {
|
|
88
88
|
resolve();
|
|
89
89
|
}
|
package/utils/css/transition.js
CHANGED
|
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import nextFrame from "../nextFrame.js";
|
|
7
|
+
import { nextFrame } from "../nextFrame.js";
|
|
8
8
|
import * as classes from "./classes.js";
|
|
9
9
|
import * as styles from "./styles.js";
|
|
10
10
|
const cache = /* @__PURE__ */ new WeakMap();
|
package/utils/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ __export(utils_exports, {
|
|
|
31
31
|
isFunction: () => import_isFunction.default,
|
|
32
32
|
keyCodes: () => import_keyCodes.default,
|
|
33
33
|
memoize: () => import_memoize.default,
|
|
34
|
-
nextFrame: () => import_nextFrame.
|
|
34
|
+
nextFrame: () => import_nextFrame.nextFrame,
|
|
35
35
|
nextMicrotask: () => import_nextMicrotask.default,
|
|
36
36
|
nextTick: () => import_nextTick.default,
|
|
37
37
|
objectToURLSearchParams: () => import_history.objectToURLSearchParams,
|
|
@@ -43,7 +43,7 @@ var import_debounce = __toESM(require("./debounce.cjs"), 1);
|
|
|
43
43
|
var import_focusTrap = __toESM(require("./focusTrap.cjs"), 1);
|
|
44
44
|
var import_keyCodes = __toESM(require("./keyCodes.cjs"), 1);
|
|
45
45
|
var import_memoize = __toESM(require("./memoize.cjs"), 1);
|
|
46
|
-
var import_nextFrame =
|
|
46
|
+
var import_nextFrame = require("./nextFrame.cjs");
|
|
47
47
|
var import_nextTick = __toESM(require("./nextTick.cjs"), 1);
|
|
48
48
|
var import_nextMicrotask = __toESM(require("./nextMicrotask.cjs"), 1);
|
|
49
49
|
var import_throttle = __toESM(require("./throttle.cjs"), 1);
|
package/utils/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { default as debounce } from "./debounce.js";
|
|
|
2
2
|
export { default as focusTrap } from "./focusTrap.js";
|
|
3
3
|
export { default as keyCodes } from "./keyCodes.js";
|
|
4
4
|
export { default as memoize } from "./memoize.js";
|
|
5
|
-
export {
|
|
5
|
+
export { nextFrame } from "./nextFrame.js";
|
|
6
6
|
export { default as nextTick } from "./nextTick.js";
|
|
7
7
|
export { default as nextMicrotask } from "./nextMicrotask.js";
|
|
8
8
|
export { default as throttle } from "./throttle.js";
|
package/utils/index.js
CHANGED
|
@@ -2,13 +2,13 @@ import { default as default2 } from "./debounce.js";
|
|
|
2
2
|
import { default as default3 } from "./focusTrap.js";
|
|
3
3
|
import { default as default4 } from "./keyCodes.js";
|
|
4
4
|
import { default as default5 } from "./memoize.js";
|
|
5
|
-
import {
|
|
6
|
-
import { default as
|
|
7
|
-
import { default as
|
|
8
|
-
import { default as
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as
|
|
5
|
+
import { nextFrame } from "./nextFrame.js";
|
|
6
|
+
import { default as default6 } from "./nextTick.js";
|
|
7
|
+
import { default as default7 } from "./nextMicrotask.js";
|
|
8
|
+
import { default as default8 } from "./throttle.js";
|
|
9
|
+
import { default as default9 } from "./scrollTo.js";
|
|
10
|
+
import { default as default10 } from "./isDefined.js";
|
|
11
|
+
import { default as default11 } from "./isFunction.js";
|
|
12
12
|
export * from "./css/index.js";
|
|
13
13
|
import {
|
|
14
14
|
objectToURLSearchParams,
|
|
@@ -24,14 +24,14 @@ export {
|
|
|
24
24
|
default3 as focusTrap,
|
|
25
25
|
push as historyPush,
|
|
26
26
|
replace as historyReplace,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
default10 as isDefined,
|
|
28
|
+
default11 as isFunction,
|
|
29
29
|
default4 as keyCodes,
|
|
30
30
|
default5 as memoize,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
nextFrame,
|
|
32
|
+
default7 as nextMicrotask,
|
|
33
|
+
default6 as nextTick,
|
|
34
34
|
objectToURLSearchParams,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
default9 as scrollTo,
|
|
36
|
+
default8 as throttle
|
|
37
37
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/math/createEases.js
|
|
20
|
+
var createEases_exports = {};
|
|
21
|
+
__export(createEases_exports, {
|
|
22
|
+
createEaseInOut: () => createEaseInOut,
|
|
23
|
+
createEaseOut: () => createEaseOut
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(createEases_exports);
|
|
26
|
+
function createEaseOut(easeIn) {
|
|
27
|
+
return (progress) => 1 - easeIn(1 - progress);
|
|
28
|
+
}
|
|
29
|
+
function createEaseInOut(easeIn) {
|
|
30
|
+
return (progress) => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
|
|
31
|
+
}
|
|
32
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {(progress: number) => number} EasingFunction
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Create an out easing function.
|
|
6
|
+
*
|
|
7
|
+
* @param {EasingFunction} easeIn The ease in function.
|
|
8
|
+
* @returns {EasingFunction} The out function.
|
|
9
|
+
*/
|
|
10
|
+
export function createEaseOut(easeIn: EasingFunction): EasingFunction;
|
|
11
|
+
/**
|
|
12
|
+
* Create an in-out easing function.
|
|
13
|
+
*
|
|
14
|
+
* @param {EasingFunction} easeIn The ease in function.
|
|
15
|
+
* @returns {EasingFunction} The in-out function.
|
|
16
|
+
*/
|
|
17
|
+
export function createEaseInOut(easeIn: EasingFunction): EasingFunction;
|
|
18
|
+
export type EasingFunction = (progress: number) => number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function createEaseOut(easeIn) {
|
|
2
|
+
return (progress) => 1 - easeIn(1 - progress);
|
|
3
|
+
}
|
|
4
|
+
function createEaseInOut(easeIn) {
|
|
5
|
+
return (progress) => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
createEaseInOut,
|
|
9
|
+
createEaseOut
|
|
10
|
+
};
|
package/utils/math/ease.cjs
CHANGED
|
@@ -19,8 +19,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// packages/js-toolkit/utils/math/ease.js
|
|
20
20
|
var ease_exports = {};
|
|
21
21
|
__export(ease_exports, {
|
|
22
|
-
createEaseInOut: () => createEaseInOut,
|
|
23
|
-
createEaseOut: () => createEaseOut,
|
|
24
22
|
easeInCirc: () => easeInCirc,
|
|
25
23
|
easeInCubic: () => easeInCubic,
|
|
26
24
|
easeInExpo: () => easeInExpo,
|
|
@@ -44,45 +42,40 @@ __export(ease_exports, {
|
|
|
44
42
|
easeOutSine: () => easeOutSine
|
|
45
43
|
});
|
|
46
44
|
module.exports = __toCommonJS(ease_exports);
|
|
47
|
-
|
|
48
|
-
return (progress) => 1 - easeIn(1 - progress);
|
|
49
|
-
}
|
|
50
|
-
function createEaseInOut(easeIn) {
|
|
51
|
-
return (progress) => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
|
|
52
|
-
}
|
|
45
|
+
var import_createEases = require("./createEases.cjs");
|
|
53
46
|
function easeInQuad(progress) {
|
|
54
47
|
return progress ** 2;
|
|
55
48
|
}
|
|
56
|
-
var easeOutQuad = createEaseOut(easeInQuad);
|
|
57
|
-
var easeInOutQuad = createEaseInOut(easeInQuad);
|
|
49
|
+
var easeOutQuad = (0, import_createEases.createEaseOut)(easeInQuad);
|
|
50
|
+
var easeInOutQuad = (0, import_createEases.createEaseInOut)(easeInQuad);
|
|
58
51
|
function easeInCubic(progress) {
|
|
59
52
|
return progress ** 3;
|
|
60
53
|
}
|
|
61
|
-
var easeOutCubic = createEaseOut(easeInCubic);
|
|
62
|
-
var easeInOutCubic = createEaseInOut(easeInCubic);
|
|
54
|
+
var easeOutCubic = (0, import_createEases.createEaseOut)(easeInCubic);
|
|
55
|
+
var easeInOutCubic = (0, import_createEases.createEaseInOut)(easeInCubic);
|
|
63
56
|
function easeInQuart(progress) {
|
|
64
57
|
return progress ** 4;
|
|
65
58
|
}
|
|
66
|
-
var easeOutQuart = createEaseOut(easeInQuart);
|
|
67
|
-
var easeInOutQuart = createEaseInOut(easeInQuart);
|
|
59
|
+
var easeOutQuart = (0, import_createEases.createEaseOut)(easeInQuart);
|
|
60
|
+
var easeInOutQuart = (0, import_createEases.createEaseInOut)(easeInQuart);
|
|
68
61
|
function easeInQuint(progress) {
|
|
69
62
|
return progress ** 5;
|
|
70
63
|
}
|
|
71
|
-
var easeOutQuint = createEaseOut(easeInQuint);
|
|
72
|
-
var easeInOutQuint = createEaseInOut(easeInQuint);
|
|
64
|
+
var easeOutQuint = (0, import_createEases.createEaseOut)(easeInQuint);
|
|
65
|
+
var easeInOutQuint = (0, import_createEases.createEaseInOut)(easeInQuint);
|
|
73
66
|
function easeInSine(progress) {
|
|
74
67
|
return progress === 1 ? 1 : -Math.cos(progress * Math.PI / 2) + 1;
|
|
75
68
|
}
|
|
76
|
-
var easeOutSine = createEaseOut(easeInSine);
|
|
77
|
-
var easeInOutSine = createEaseInOut(easeInSine);
|
|
69
|
+
var easeOutSine = (0, import_createEases.createEaseOut)(easeInSine);
|
|
70
|
+
var easeInOutSine = (0, import_createEases.createEaseInOut)(easeInSine);
|
|
78
71
|
function easeInCirc(progress) {
|
|
79
72
|
return -(Math.sqrt(1 - progress * progress) - 1);
|
|
80
73
|
}
|
|
81
|
-
var easeOutCirc = createEaseOut(easeInCirc);
|
|
82
|
-
var easeInOutCirc = createEaseInOut(easeInCirc);
|
|
74
|
+
var easeOutCirc = (0, import_createEases.createEaseOut)(easeInCirc);
|
|
75
|
+
var easeInOutCirc = (0, import_createEases.createEaseInOut)(easeInCirc);
|
|
83
76
|
function easeInExpo(progress) {
|
|
84
77
|
return 2 ** (10 * (progress - 1));
|
|
85
78
|
}
|
|
86
|
-
var easeOutExpo = createEaseOut(easeInExpo);
|
|
87
|
-
var easeInOutExpo = createEaseInOut(easeInExpo);
|
|
79
|
+
var easeOutExpo = (0, import_createEases.createEaseOut)(easeInExpo);
|
|
80
|
+
var easeInOutExpo = (0, import_createEases.createEaseInOut)(easeInExpo);
|
|
88
81
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/math/ease.d.ts
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Create an out easing function.
|
|
6
|
-
*
|
|
7
|
-
* @param {EasingFunction} easeIn The ease in function.
|
|
8
|
-
* @returns {EasingFunction} The out function.
|
|
9
|
-
*/
|
|
10
|
-
export function createEaseOut(easeIn: EasingFunction): EasingFunction;
|
|
11
|
-
/**
|
|
12
|
-
* Create an in-out easing function.
|
|
13
|
-
*
|
|
14
|
-
* @param {EasingFunction} easeIn The ease in function.
|
|
15
|
-
* @returns {EasingFunction} The in-out function.
|
|
16
|
-
*/
|
|
17
|
-
export function createEaseInOut(easeIn: EasingFunction): EasingFunction;
|
|
18
|
-
/**
|
|
19
|
-
* @type {EasingFunction}
|
|
2
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
3
|
+
* @returns {number} Eased value between 0 and 1.
|
|
20
4
|
*/
|
|
21
5
|
export function easeInQuad(progress: number): number;
|
|
22
6
|
/**
|
|
@@ -61,18 +45,17 @@ export function easeInCirc(progress: number): number;
|
|
|
61
45
|
* @returns {number} Eased value between 0 and 1.
|
|
62
46
|
*/
|
|
63
47
|
export function easeInExpo(progress: number): number;
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
70
|
-
export
|
|
71
|
-
export
|
|
72
|
-
export
|
|
73
|
-
export
|
|
74
|
-
export
|
|
75
|
-
export
|
|
76
|
-
export
|
|
77
|
-
export
|
|
78
|
-
export type EasingFunction = (progress: number) => number;
|
|
48
|
+
export const easeOutQuad: import("./createEases.js").EasingFunction;
|
|
49
|
+
export const easeInOutQuad: import("./createEases.js").EasingFunction;
|
|
50
|
+
export const easeOutCubic: import("./createEases.js").EasingFunction;
|
|
51
|
+
export const easeInOutCubic: import("./createEases.js").EasingFunction;
|
|
52
|
+
export const easeOutQuart: import("./createEases.js").EasingFunction;
|
|
53
|
+
export const easeInOutQuart: import("./createEases.js").EasingFunction;
|
|
54
|
+
export const easeOutQuint: import("./createEases.js").EasingFunction;
|
|
55
|
+
export const easeInOutQuint: import("./createEases.js").EasingFunction;
|
|
56
|
+
export const easeOutSine: import("./createEases.js").EasingFunction;
|
|
57
|
+
export const easeInOutSine: import("./createEases.js").EasingFunction;
|
|
58
|
+
export const easeOutCirc: import("./createEases.js").EasingFunction;
|
|
59
|
+
export const easeInOutCirc: import("./createEases.js").EasingFunction;
|
|
60
|
+
export const easeOutExpo: import("./createEases.js").EasingFunction;
|
|
61
|
+
export const easeInOutExpo: import("./createEases.js").EasingFunction;
|
package/utils/math/ease.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
return (progress) => 1 - easeIn(1 - progress);
|
|
3
|
-
}
|
|
4
|
-
function createEaseInOut(easeIn) {
|
|
5
|
-
return (progress) => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
|
|
6
|
-
}
|
|
1
|
+
import { createEaseOut, createEaseInOut } from "./createEases.js";
|
|
7
2
|
function easeInQuad(progress) {
|
|
8
3
|
return progress ** 2;
|
|
9
4
|
}
|
|
@@ -40,8 +35,6 @@ function easeInExpo(progress) {
|
|
|
40
35
|
const easeOutExpo = createEaseOut(easeInExpo);
|
|
41
36
|
const easeInOutExpo = createEaseInOut(easeInExpo);
|
|
42
37
|
export {
|
|
43
|
-
createEaseInOut,
|
|
44
|
-
createEaseOut,
|
|
45
38
|
easeInCirc,
|
|
46
39
|
easeInCubic,
|
|
47
40
|
easeInExpo,
|
package/utils/math/index.cjs
CHANGED
|
@@ -42,4 +42,5 @@ var import_map = __toESM(require("./map.cjs"), 1);
|
|
|
42
42
|
var import_round = __toESM(require("./round.cjs"), 1);
|
|
43
43
|
__reExport(math_exports, require("./ease.cjs"), module.exports);
|
|
44
44
|
var ease = __toESM(require("./ease.cjs"), 1);
|
|
45
|
+
__reExport(math_exports, require("./createEases.cjs"), module.exports);
|
|
45
46
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/math/index.d.ts
CHANGED
package/utils/math/index.js
CHANGED
package/utils/nextFrame.cjs
CHANGED
|
@@ -19,9 +19,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// packages/js-toolkit/utils/nextFrame.js
|
|
20
20
|
var nextFrame_exports = {};
|
|
21
21
|
__export(nextFrame_exports, {
|
|
22
|
-
default: () => nextFrame,
|
|
23
22
|
getCancelRaf: () => getCancelRaf,
|
|
24
|
-
getRaf: () => getRaf
|
|
23
|
+
getRaf: () => getRaf,
|
|
24
|
+
nextFrame: () => nextFrame
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(nextFrame_exports);
|
|
27
27
|
function getRaf() {
|
package/utils/nextFrame.d.ts
CHANGED
|
@@ -24,4 +24,4 @@ export function getCancelRaf(): (id: number) => void;
|
|
|
24
24
|
* console.log('hello world');
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
export
|
|
27
|
+
export function nextFrame<T extends () => any>(fn?: T): Promise<T extends Function ? ReturnType<T> : undefined>;
|
package/utils/nextFrame.js
CHANGED
package/utils/scheduler.cjs
CHANGED
|
@@ -27,6 +27,7 @@ function getScheduler(steps) {
|
|
|
27
27
|
const stepsFns = {};
|
|
28
28
|
const api = {};
|
|
29
29
|
let isScheduled = false;
|
|
30
|
+
const resolvedPromise = Promise.resolve();
|
|
30
31
|
function run(tasks) {
|
|
31
32
|
let task;
|
|
32
33
|
while (task = tasks.shift()) {
|
|
@@ -47,7 +48,7 @@ function getScheduler(steps) {
|
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
50
|
isScheduled = true;
|
|
50
|
-
|
|
51
|
+
resolvedPromise.then(flush);
|
|
51
52
|
}
|
|
52
53
|
steps.forEach((step) => {
|
|
53
54
|
stepsFns[step] = [];
|
|
@@ -59,7 +60,8 @@ function getScheduler(steps) {
|
|
|
59
60
|
return api;
|
|
60
61
|
}
|
|
61
62
|
var instances = /* @__PURE__ */ new Map();
|
|
62
|
-
|
|
63
|
+
var domSchedulerSteps = ["read", "write", "afterWrite"];
|
|
64
|
+
function useScheduler(steps = domSchedulerSteps) {
|
|
63
65
|
const key = steps.join("-");
|
|
64
66
|
if (instances.has(key)) {
|
|
65
67
|
return instances.get(key);
|
|
@@ -68,5 +70,5 @@ function useScheduler(steps = ["read", "write"]) {
|
|
|
68
70
|
instances.set(key, scheduler);
|
|
69
71
|
return scheduler;
|
|
70
72
|
}
|
|
71
|
-
var domScheduler = useScheduler(
|
|
73
|
+
var domScheduler = useScheduler(domSchedulerSteps);
|
|
72
74
|
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/scheduler.js
CHANGED
|
@@ -2,6 +2,7 @@ function getScheduler(steps) {
|
|
|
2
2
|
const stepsFns = {};
|
|
3
3
|
const api = {};
|
|
4
4
|
let isScheduled = false;
|
|
5
|
+
const resolvedPromise = Promise.resolve();
|
|
5
6
|
function run(tasks) {
|
|
6
7
|
let task;
|
|
7
8
|
while (task = tasks.shift()) {
|
|
@@ -22,7 +23,7 @@ function getScheduler(steps) {
|
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
isScheduled = true;
|
|
25
|
-
|
|
26
|
+
resolvedPromise.then(flush);
|
|
26
27
|
}
|
|
27
28
|
steps.forEach((step) => {
|
|
28
29
|
stepsFns[step] = [];
|
|
@@ -34,7 +35,8 @@ function getScheduler(steps) {
|
|
|
34
35
|
return api;
|
|
35
36
|
}
|
|
36
37
|
const instances = /* @__PURE__ */ new Map();
|
|
37
|
-
|
|
38
|
+
const domSchedulerSteps = ["read", "write", "afterWrite"];
|
|
39
|
+
function useScheduler(steps = domSchedulerSteps) {
|
|
38
40
|
const key = steps.join("-");
|
|
39
41
|
if (instances.has(key)) {
|
|
40
42
|
return instances.get(key);
|
|
@@ -43,7 +45,7 @@ function useScheduler(steps = ["read", "write"]) {
|
|
|
43
45
|
instances.set(key, scheduler);
|
|
44
46
|
return scheduler;
|
|
45
47
|
}
|
|
46
|
-
const domScheduler = useScheduler(
|
|
48
|
+
const domScheduler = useScheduler(domSchedulerSteps);
|
|
47
49
|
export {
|
|
48
50
|
domScheduler,
|
|
49
51
|
useScheduler
|