@hyperframes/core 0.7.78 → 0.7.80
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/dist/generated/runtime-inline.js +1 -1
- package/dist/generated/runtime-inline.js.map +1 -1
- package/dist/hyperframe.runtime.iife.js +23 -23
- package/dist/runtime/customEase.d.ts +9 -0
- package/dist/runtime/customEase.d.ts.map +1 -0
- package/dist/runtime/customEase.js +128 -0
- package/dist/runtime/customEase.js.map +1 -0
- package/package.json +8 -4
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type RuntimeEase = (progress: number) => number;
|
|
2
|
+
type GsapEaseApi = {
|
|
3
|
+
parseEase?: (ease: string | RuntimeEase, ...args: unknown[]) => RuntimeEase | null;
|
|
4
|
+
registerEase?: (name: string, ease: RuntimeEase) => void;
|
|
5
|
+
__hfCustomEaseInstalled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function installStudioCustomEase(gsap: GsapEaseApi): boolean;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=customEase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customEase.d.ts","sourceRoot":"","sources":["../../src/runtime/customEase.ts"],"names":[],"mappings":"AAIA,KAAK,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;AAIhD,KAAK,WAAW,GAAG;IACjB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,WAAW,GAAG,IAAI,CAAC;IACnF,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACzD,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC;AA8EF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CA8DlE"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { evaluateSpringEase, parseSpringBounce } from "../parsers/springEase.js";
|
|
2
|
+
import { emitAnalyticsEvent } from "./analytics.js";
|
|
3
|
+
import { resolveWiggleEase } from "./wiggleEase.js";
|
|
4
|
+
const BISECTION_STEPS = 24;
|
|
5
|
+
const HOLD_EASE = (progress) => (progress >= 1 ? 1 : 0);
|
|
6
|
+
const IDENTITY_EASE = (progress) => progress;
|
|
7
|
+
const NUMBER_SOURCE = String.raw `([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)`;
|
|
8
|
+
// Studio authors one cubic-bezier segment with fixed (0,0) and (1,1)
|
|
9
|
+
// endpoints. Anticipation/overshoot is represented by Y controls outside
|
|
10
|
+
// [0,1]; X controls stay in [0,1] so progress remains a function of time.
|
|
11
|
+
const CUSTOM_CUBIC_PATH = new RegExp(String.raw `^\s*M\s*0\s*,\s*0\s+C\s*${NUMBER_SOURCE}\s*,\s*${NUMBER_SOURCE}\s+${NUMBER_SOURCE}\s*,\s*${NUMBER_SOURCE}\s+1\s*,\s*1\s*$`, "i");
|
|
12
|
+
function cubicCoordinate(t, point1, point2) {
|
|
13
|
+
const inverse = 1 - t;
|
|
14
|
+
return 3 * inverse * inverse * t * point1 + 3 * inverse * t * t * point2 + t * t * t;
|
|
15
|
+
}
|
|
16
|
+
function evaluateCubicBezier(progress, x1, y1, x2, y2) {
|
|
17
|
+
if (!Number.isFinite(progress))
|
|
18
|
+
return progress;
|
|
19
|
+
if (progress <= 0)
|
|
20
|
+
return 0;
|
|
21
|
+
if (progress >= 1)
|
|
22
|
+
return 1;
|
|
23
|
+
let low = 0;
|
|
24
|
+
let high = 1;
|
|
25
|
+
for (let step = 0; step < BISECTION_STEPS; step += 1) {
|
|
26
|
+
const t = (low + high) / 2;
|
|
27
|
+
if (cubicCoordinate(t, x1, x2) < progress)
|
|
28
|
+
low = t;
|
|
29
|
+
else
|
|
30
|
+
high = t;
|
|
31
|
+
}
|
|
32
|
+
return cubicCoordinate((low + high) / 2, y1, y2);
|
|
33
|
+
}
|
|
34
|
+
function createCubicBezierEase(path) {
|
|
35
|
+
const match = CUSTOM_CUBIC_PATH.exec(path);
|
|
36
|
+
if (!match)
|
|
37
|
+
return null;
|
|
38
|
+
const x1 = Number(match[1]);
|
|
39
|
+
const y1 = Number(match[2]);
|
|
40
|
+
const x2 = Number(match[3]);
|
|
41
|
+
const y2 = Number(match[4]);
|
|
42
|
+
if (Math.min(x1, x2) < 0 || Math.max(x1, x2) > 1)
|
|
43
|
+
return null;
|
|
44
|
+
return (progress) => evaluateCubicBezier(progress, x1, y1, x2, y2);
|
|
45
|
+
}
|
|
46
|
+
function resolveSpringEase(ease, springEaseCache) {
|
|
47
|
+
if (!ease.startsWith("spring("))
|
|
48
|
+
return null;
|
|
49
|
+
const bounce = parseSpringBounce(ease);
|
|
50
|
+
if (bounce === null)
|
|
51
|
+
return null;
|
|
52
|
+
const cached = springEaseCache.get(bounce);
|
|
53
|
+
if (cached)
|
|
54
|
+
return cached;
|
|
55
|
+
const springEase = (progress) => evaluateSpringEase(progress, bounce);
|
|
56
|
+
springEaseCache.set(bounce, springEase);
|
|
57
|
+
return springEase;
|
|
58
|
+
}
|
|
59
|
+
function resolveCustomEase(ease, customEaseCache) {
|
|
60
|
+
if (!ease.startsWith("custom(") || !ease.endsWith(")"))
|
|
61
|
+
return null;
|
|
62
|
+
const path = ease.slice(7, -1);
|
|
63
|
+
const cached = customEaseCache.get(path);
|
|
64
|
+
if (cached)
|
|
65
|
+
return cached;
|
|
66
|
+
const customEase = createCubicBezierEase(path);
|
|
67
|
+
if (customEase)
|
|
68
|
+
customEaseCache.set(path, customEase);
|
|
69
|
+
return customEase;
|
|
70
|
+
}
|
|
71
|
+
export function installStudioCustomEase(gsap) {
|
|
72
|
+
if (gsap.__hfCustomEaseInstalled)
|
|
73
|
+
return true;
|
|
74
|
+
const originalParseEase = gsap.parseEase;
|
|
75
|
+
if (!originalParseEase)
|
|
76
|
+
return false;
|
|
77
|
+
const customEaseCache = new Map();
|
|
78
|
+
const springEaseCache = new Map();
|
|
79
|
+
const wiggleEaseCache = new Map();
|
|
80
|
+
// Single source of truth for "hyperframes ease string -> function". Both the
|
|
81
|
+
// public parseEase override and the internal registerEase configs below route
|
|
82
|
+
// through this, so the resolution rules live in exactly one place.
|
|
83
|
+
const resolveHyperframesEase = (ease) => {
|
|
84
|
+
if (typeof ease !== "string")
|
|
85
|
+
return null;
|
|
86
|
+
if (ease === "hold")
|
|
87
|
+
return HOLD_EASE;
|
|
88
|
+
return (resolveWiggleEase(ease, wiggleEaseCache) ??
|
|
89
|
+
resolveSpringEase(ease, springEaseCache) ??
|
|
90
|
+
resolveCustomEase(ease, customEaseCache));
|
|
91
|
+
};
|
|
92
|
+
const parseEaseWithFallback = (ease, context, args = []) => {
|
|
93
|
+
const resolved = resolveHyperframesEase(ease);
|
|
94
|
+
if (resolved)
|
|
95
|
+
return resolved;
|
|
96
|
+
if (typeof ease === "string" && /^(?:hold|spring|wiggle|custom)(?:\(|$)/.test(ease.trim())) {
|
|
97
|
+
emitAnalyticsEvent("custom_ease_parse_failed", { ease });
|
|
98
|
+
}
|
|
99
|
+
return originalParseEase.call(context, ease, ...args) ?? IDENTITY_EASE;
|
|
100
|
+
};
|
|
101
|
+
// Public parseEase: direct callers (studio ease UI, adapters) resolve
|
|
102
|
+
// synchronously; anything else falls through to GSAP's own parser.
|
|
103
|
+
gsap.parseEase = function parseHyperframesEase(ease, ...args) {
|
|
104
|
+
return parseEaseWithFallback(ease, this, args);
|
|
105
|
+
};
|
|
106
|
+
// GSAP resolves a keyframe SEGMENT's ease through its INTERNAL _parseEase /
|
|
107
|
+
// _easeMap, never the public parseEase above — so a custom ease used inside
|
|
108
|
+
// `keyframes:{...}` resolves to undefined and throws "_ease is not a function"
|
|
109
|
+
// on the first render. Register the eases in the internal map too. GSAP calls
|
|
110
|
+
// a configurable ease's `.config(...params)` with the parenthesized string
|
|
111
|
+
// comma-split, so `params.join(",")` losslessly reconstructs the original
|
|
112
|
+
// (including custom() bezier paths, whose commas survive the round-trip).
|
|
113
|
+
const registerEase = gsap.registerEase;
|
|
114
|
+
if (typeof registerEase === "function") {
|
|
115
|
+
registerEase("hold", HOLD_EASE);
|
|
116
|
+
const registerConfigurable = (name) => {
|
|
117
|
+
const base = (progress) => progress;
|
|
118
|
+
base.config = (...params) => parseEaseWithFallback(`${name}(${params.join(",")})`, gsap);
|
|
119
|
+
registerEase(name, base);
|
|
120
|
+
};
|
|
121
|
+
registerConfigurable("spring");
|
|
122
|
+
registerConfigurable("wiggle");
|
|
123
|
+
registerConfigurable("custom");
|
|
124
|
+
}
|
|
125
|
+
gsap.__hfCustomEaseInstalled = true;
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=customEase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customEase.js","sourceRoot":"","sources":["../../src/runtime/customEase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAYjD,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,SAAS,GAAgB,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrE,MAAM,aAAa,GAAgB,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC;AAC1D,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA,8CAA8C,CAAC;AAC/E,qEAAqE;AACrE,yEAAyE;AACzE,0EAA0E;AAC1E,MAAM,iBAAiB,GAAG,IAAI,MAAM,CAClC,MAAM,CAAC,GAAG,CAAA,2BAA2B,aAAa,UAAU,aA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IAAI,EAAE,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC;QACF,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAC/B,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAC/B,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC;IACpC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.80",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -87,6 +87,10 @@
|
|
|
87
87
|
"import": "./dist/runtime/clipTree.js",
|
|
88
88
|
"types": "./dist/runtime/clipTree.d.ts"
|
|
89
89
|
},
|
|
90
|
+
"./runtime/custom-ease": {
|
|
91
|
+
"import": "./dist/runtime/customEase.js",
|
|
92
|
+
"types": "./dist/runtime/customEase.d.ts"
|
|
93
|
+
},
|
|
90
94
|
"./runtime/start-expression": {
|
|
91
95
|
"import": "./dist/runtime/startExpression.js",
|
|
92
96
|
"types": "./dist/runtime/startExpression.d.ts"
|
|
@@ -206,9 +210,9 @@
|
|
|
206
210
|
"bpm-detective": "^2.0.5",
|
|
207
211
|
"linkedom": "^0.18.12",
|
|
208
212
|
"postcss": "^8.5.8",
|
|
209
|
-
"@hyperframes/lint": "0.7.
|
|
210
|
-
"@hyperframes/
|
|
211
|
-
"@hyperframes/
|
|
213
|
+
"@hyperframes/lint": "0.7.80",
|
|
214
|
+
"@hyperframes/studio-server": "0.7.80",
|
|
215
|
+
"@hyperframes/parsers": "0.7.80"
|
|
212
216
|
},
|
|
213
217
|
"devDependencies": {
|
|
214
218
|
"@types/jsdom": "^28.0.0",
|