@hyperframes/parsers 0.8.138 → 0.8.139
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/gsapConstants.d.ts +1 -1
- package/dist/gsapConstants.js +3 -2
- package/dist/gsapConstants.js.map +1 -1
- package/dist/gsapParser.d.ts +2 -2
- package/dist/gsapParser.js +3 -2
- package/dist/gsapParser.js.map +1 -1
- package/dist/gsapParserAcorn.d.ts +2 -2
- package/dist/gsapParserAcorn.js.map +1 -1
- package/dist/gsapParserExports.d.ts +1 -1
- package/dist/gsapParserExports.js.map +1 -1
- package/dist/{gsapSerialize-WJrRO8uT.d.ts → gsapSerialize-DPyyDPBC.d.ts} +3 -3
- package/dist/gsapWriterAcorn.d.ts +1 -1
- package/dist/gsapWriterAcorn.js +3 -2
- package/dist/gsapWriterAcorn.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/gsapConstants.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { B as BUILTIN_VAR_KEYS, D as DROPPED_VAR_KEYS, E as EXTRAS_KEYS, u as GSAP_DEFAULT_DURATION, H as HoldScope, f as PROPERTY_GROUPS, g as PropertyGroupName, S as SUPPORTED_EASES, h as SUPPORTED_PROPS, i as classifyPropertyGroup, j as classifyTweenPropertyGroup, x as holdScope, y as isTweenConfigKey, z as isXYPositionWrite, C as keyframeHoldForAnimation } from './gsapSerialize-
|
|
1
|
+
export { B as BUILTIN_VAR_KEYS, D as DROPPED_VAR_KEYS, E as EXTRAS_KEYS, u as GSAP_DEFAULT_DURATION, H as HoldScope, f as PROPERTY_GROUPS, g as PropertyGroupName, S as SUPPORTED_EASES, h as SUPPORTED_PROPS, i as classifyPropertyGroup, j as classifyTweenPropertyGroup, x as holdScope, y as isTweenConfigKey, z as isXYPositionWrite, C as keyframeHoldForAnimation } from './gsapSerialize-DPyyDPBC.js';
|
|
2
2
|
import './types-Ejqndkej.js';
|
package/dist/gsapConstants.js
CHANGED
|
@@ -104,7 +104,7 @@ function holdScope(before, previous) {
|
|
|
104
104
|
held.set(a.targetSelector, props);
|
|
105
105
|
}
|
|
106
106
|
return {
|
|
107
|
-
touched: (a) => previous
|
|
107
|
+
touched: (a) => previous === null || !kept.has(tweenSignature(a)),
|
|
108
108
|
held: (selector) => held.get(selector) ?? /* @__PURE__ */ new Map()
|
|
109
109
|
};
|
|
110
110
|
}
|
|
@@ -122,7 +122,8 @@ function keyframeHoldForAnimation(animation, animations, scope) {
|
|
|
122
122
|
const touched = scope.touched(animation);
|
|
123
123
|
const pinned = scope.held(animation.targetSelector);
|
|
124
124
|
const kept = (property, value) => touched ? pinned.has(property) : pinned.get(property) === value;
|
|
125
|
-
const
|
|
125
|
+
const startsLate = start > 1e-3;
|
|
126
|
+
const pins = (group, property, value) => (group === "position" || group === "size") && ((lone || group === "position" && startsLate) && touched || kept(property, value));
|
|
126
127
|
const hold = {};
|
|
127
128
|
for (const [property, value] of Object.entries(atStart.properties)) {
|
|
128
129
|
if (!pins(classifyPropertyGroup(property), property, value) || typeof value !== "number")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/gsapConstants.ts"],"sourcesContent":["/**\n * GSAP property and ease constants.\n *\n * Extracted into a standalone module so browser code can import them\n * without pulling in gsapParser (which depends on recast / @babel/parser).\n */\n\nimport type { GsapAnimation } from \"./gsapSerialize.js\";\n\nexport const GSAP_DEFAULT_DURATION = 0.5;\n\nexport const SUPPORTED_PROPS = [\n // 2D Transforms\n \"x\",\n \"y\",\n \"scale\",\n \"scaleX\",\n \"scaleY\",\n \"rotation\",\n \"skewX\",\n \"skewY\",\n // 3D Transforms\n \"z\",\n \"rotationX\",\n \"rotationY\",\n \"rotationZ\",\n \"perspective\",\n \"transformPerspective\",\n \"transformOrigin\",\n // Visibility\n \"opacity\",\n \"visibility\",\n \"autoAlpha\",\n // Dimensions\n \"width\",\n \"height\",\n // Colors\n \"color\",\n \"backgroundColor\",\n \"borderColor\",\n // Box model\n \"borderRadius\",\n // Typography\n \"fontSize\",\n \"letterSpacing\",\n // Filter & Clipping\n \"filter\",\n \"clipPath\",\n // DOM content (number counters, text roll-ups)\n \"innerText\",\n];\n\n/** Keys stored on dedicated GsapAnimation fields (not in properties/extras). */\nexport const BUILTIN_VAR_KEYS: ReadonlySet<string> = new Set([\"duration\", \"ease\", \"delay\"]);\nexport const DROPPED_VAR_KEYS: ReadonlySet<string> = new Set([\n \"onComplete\",\n \"onStart\",\n \"onUpdate\",\n \"onRepeat\",\n]);\n/** Keys that go in `extras`: non-editable GSAP config that must survive round-trips. */\nexport const EXTRAS_KEYS: ReadonlySet<string> = new Set([\n \"stagger\",\n \"yoyo\",\n \"repeat\",\n \"repeatDelay\",\n \"snap\",\n \"overwrite\",\n \"immediateRender\",\n]);\n\nexport function isTweenConfigKey(key: string): boolean {\n return BUILTIN_VAR_KEYS.has(key) || DROPPED_VAR_KEYS.has(key) || EXTRAS_KEYS.has(key);\n}\n\n// ── Property Groups ─────────────────────────────────────────────────────────\n// Each group maps to an independent GSAP tween so editing one property\n// (e.g. drag → x/y) never contaminates another (e.g. scale, rotation).\n\nexport type PropertyGroupName = \"position\" | \"scale\" | \"size\" | \"rotation\" | \"visual\" | \"other\";\n\nexport const PROPERTY_GROUPS: Record<PropertyGroupName, ReadonlySet<string>> = {\n position: new Set([\"x\", \"y\", \"xPercent\", \"yPercent\"]),\n scale: new Set([\"scale\", \"scaleX\", \"scaleY\"]),\n size: new Set([\"width\", \"height\"]),\n rotation: new Set([\"rotation\", \"skewX\", \"skewY\"]),\n visual: new Set([\"opacity\", \"autoAlpha\"]),\n other: new Set<string>(),\n};\n\nconst PROP_TO_GROUP = new Map<string, PropertyGroupName>();\nfor (const [group, props] of Object.entries(PROPERTY_GROUPS) as [\n PropertyGroupName,\n ReadonlySet<string>,\n][]) {\n for (const p of props) PROP_TO_GROUP.set(p, group);\n}\n\ntype PositionWrite = Pick<\n GsapAnimation,\n \"propertyGroup\" | \"properties\" | \"fromProperties\" | \"keyframes\"\n>;\n\nfunction writesProperty(animation: PositionWrite, property: string): boolean {\n return (\n property in animation.properties ||\n (!!animation.fromProperties && property in animation.fromProperties) ||\n !!animation.keyframes?.keyframes.some((k) => property in k.properties)\n );\n}\n\n/** A position write that sets x or y. An xPercent/yPercent centring set never duplicates one. */\nexport function isXYPositionWrite(a: PositionWrite): boolean {\n return a.propertyGroup === \"position\" && (writesProperty(a, \"x\") || writesProperty(a, \"y\"));\n}\n\nexport function classifyPropertyGroup(prop: string): PropertyGroupName {\n return PROP_TO_GROUP.get(prop) ?? \"other\";\n}\n\nexport function classifyTweenPropertyGroup(\n properties: Record<string, unknown>,\n): PropertyGroupName | undefined {\n const groups = new Set<PropertyGroupName>();\n for (const key of Object.keys(properties)) {\n // transformOrigin is a modifier; `_auto` is Studio's internal endpoint marker;\n // `data` is GSAP-reserved (carries the Studio hold-set tag). None is an animated\n // property, so none should affect the group.\n if (key === \"transformOrigin\" || key === \"_auto\" || key === \"data\") continue;\n const g = classifyPropertyGroup(key);\n groups.add(g);\n }\n if (groups.size === 1) return groups.values().next().value;\n return undefined;\n}\n\nfunction knownStart(animation: GsapAnimation): number | undefined {\n if (animation.resolvedStart !== undefined) return animation.resolvedStart;\n return typeof animation.position === \"number\" ? animation.position : undefined;\n}\n\nexport interface HoldScope {\n touched: (animation: GsapAnimation) => boolean;\n held: (selector: string) => ReadonlyMap<string, unknown>;\n}\n\nconst tweenSignature = (a: GsapAnimation) =>\n JSON.stringify([a.targetSelector, a.method, a.position, a.duration, a.properties, a.keyframes]);\n\n/** The tweens an edit touched (not in `previous`; none without it), and what the script's holds already pin. */\nexport function holdScope(\n before: readonly GsapAnimation[],\n previous: readonly GsapAnimation[] | null,\n): HoldScope {\n const kept = new Set(previous?.map(tweenSignature));\n const held = new Map<string, Map<string, unknown>>();\n for (const a of before.filter((b) => b.method === \"set\" && b.properties?.data === \"hf-hold\")) {\n const props = held.get(a.targetSelector) ?? new Map<string, unknown>();\n for (const [property, value] of Object.entries(a.properties)) props.set(property, value);\n held.set(a.targetSelector, props);\n }\n return {\n touched: (a) => previous !== null && !kept.has(tweenSignature(a)),\n held: (selector) => held.get(selector) ?? new Map(),\n };\n}\n\n/**\n * What a Studio hold pins from t=0: a keyframed tween's 0% position props before a later start, and the position and\n * size of a lone key (GSAP renders none) only where this edit made it or a hold already pins it, minus earlier tweens.\n */\nexport function keyframeHoldForAnimation(\n animation: GsapAnimation,\n animations: readonly GsapAnimation[],\n scope: HoldScope,\n): Record<string, number> | null {\n if (!animation.keyframes) return null;\n const start = knownStart(animation);\n const lone = animation.keyframes.keyframes.length === 1;\n if (start === undefined || (!(start > 0.001) && !lone)) return null;\n const atStart = animation.keyframes.keyframes.find((keyframe) => keyframe.percentage === 0);\n if (!atStart) return null;\n // A tween whose start the parser could not resolve (a label, say) is not known to come first.\n const earlier = animations.filter((other) => {\n const otherStart = knownStart(other);\n return (\n other !== animation &&\n !other.global &&\n other.targetSelector === animation.targetSelector &&\n otherStart !== undefined &&\n otherStart < start - 0.001\n );\n });\n const touched = scope.touched(animation);\n const pinned = scope.held(animation.targetSelector);\n // An untouched tween keeps only the hold it made: one with its own first value.\n const kept = (property: string, value: unknown) =>\n touched ? pinned.has(property) : pinned.get(property) === value;\n const pins = (group: PropertyGroupName, property: string, value: unknown) =>\n (group === \"position\" && start > 0.001) ||\n ((group === \"position\" || group === \"size\") && ((lone && touched) || kept(property, value)));\n const hold: Record<string, number> = {};\n for (const [property, value] of Object.entries(atStart.properties)) {\n if (!pins(classifyPropertyGroup(property), property, value) || typeof value !== \"number\")\n continue;\n if (earlier.some((other) => writesProperty(other, property))) continue;\n hold[property] = value;\n }\n return Object.keys(hold).length > 0 ? hold : null;\n}\n\nexport const SUPPORTED_EASES = [\n \"none\",\n \"power1.in\",\n \"power1.out\",\n \"power1.inOut\",\n \"power2.in\",\n \"power2.out\",\n \"power2.inOut\",\n \"power3.in\",\n \"power3.out\",\n \"power3.inOut\",\n \"power4.in\",\n \"power4.out\",\n \"power4.inOut\",\n \"back.in\",\n \"back.out\",\n \"back.inOut\",\n \"elastic.in\",\n \"elastic.out\",\n \"elastic.inOut\",\n \"bounce.in\",\n \"bounce.out\",\n \"bounce.inOut\",\n \"circ.inOut\",\n \"expo.in\",\n \"expo.out\",\n \"expo.inOut\",\n \"elastic.out(1,0.3)\",\n \"elastic.inOut(1,0.3)\",\n \"spring-gentle\",\n \"spring-bouncy\",\n \"spring-stiff\",\n \"spring-wobbly\",\n \"spring-heavy\",\n \"hold\",\n \"steps(1)\",\n];\n"],"mappings":";AASO,IAAM,wBAAwB;AAE9B,IAAM,kBAAkB;AAAA;AAAA,EAE7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA;AAAA,EAEA;AACF;AAGO,IAAM,mBAAwC,oBAAI,IAAI,CAAC,YAAY,QAAQ,OAAO,CAAC;AACnF,IAAM,mBAAwC,oBAAI,IAAI;AAAA,EAC3D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,cAAmC,oBAAI,IAAI;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,SAAS,iBAAiB,KAAsB;AACrD,SAAO,iBAAiB,IAAI,GAAG,KAAK,iBAAiB,IAAI,GAAG,KAAK,YAAY,IAAI,GAAG;AACtF;AAQO,IAAM,kBAAkE;AAAA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aAAa,QAAQ;AAAA,EAEzB,CAAC;AACD,QAAM,UAAU,MAAM,QAAQ,SAAS;AACvC,QAAM,SAAS,MAAM,KAAK,UAAU,cAAc;AAElD,QAAM,OAAO,CAAC,UAAkB,UAC9B,UAAU,OAAO,IAAI,QAAQ,IAAI,OAAO,IAAI,QAAQ,MAAM;AAC5D,QAAM,OAAO,CAAC,OAA0B,UAAkB,UACvD,UAAU,cAAc,QAAQ,SAC/B,UAAU,cAAc,UAAU,YAAa,QAAQ,WAAY,KAAK,UAAU,KAAK;AAC3F,QAAM,OAA+B,CAAC;AACtC,aAAW,CAAC,UAAU,KAAK,KAAK,OAAO,QAAQ,QAAQ,UAAU,GAAG;AAClE,QAAI,CAAC,KAAK,sBAAsB,QAAQ,GAAG,UAAU,KAAK,KAAK,OAAO,UAAU;AAC9E;AACF,QAAI,QAAQ,KAAK,CAAC,UAAU,eAAe,OAAO,QAAQ,CAAC,EAAG;AAC9D,SAAK,QAAQ,IAAI;AAAA,EACnB;AACA,SAAO,OAAO,KAAK,IAAI,EAAE,SAAS,IAAI,OAAO;AAC/C;AAEO,IAAM,kBAAkB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/gsapConstants.ts"],"sourcesContent":["/**\n * GSAP property and ease constants.\n *\n * Extracted into a standalone module so browser code can import them\n * without pulling in gsapParser (which depends on recast / @babel/parser).\n */\n\nimport type { GsapAnimation } from \"./gsapSerialize.js\";\n\nexport const GSAP_DEFAULT_DURATION = 0.5;\n\nexport const SUPPORTED_PROPS = [\n // 2D Transforms\n \"x\",\n \"y\",\n \"scale\",\n \"scaleX\",\n \"scaleY\",\n \"rotation\",\n \"skewX\",\n \"skewY\",\n // 3D Transforms\n \"z\",\n \"rotationX\",\n \"rotationY\",\n \"rotationZ\",\n \"perspective\",\n \"transformPerspective\",\n \"transformOrigin\",\n // Visibility\n \"opacity\",\n \"visibility\",\n \"autoAlpha\",\n // Dimensions\n \"width\",\n \"height\",\n // Colors\n \"color\",\n \"backgroundColor\",\n \"borderColor\",\n // Box model\n \"borderRadius\",\n // Typography\n \"fontSize\",\n \"letterSpacing\",\n // Filter & Clipping\n \"filter\",\n \"clipPath\",\n // DOM content (number counters, text roll-ups)\n \"innerText\",\n];\n\n/** Keys stored on dedicated GsapAnimation fields (not in properties/extras). */\nexport const BUILTIN_VAR_KEYS: ReadonlySet<string> = new Set([\"duration\", \"ease\", \"delay\"]);\nexport const DROPPED_VAR_KEYS: ReadonlySet<string> = new Set([\n \"onComplete\",\n \"onStart\",\n \"onUpdate\",\n \"onRepeat\",\n]);\n/** Keys that go in `extras`: non-editable GSAP config that must survive round-trips. */\nexport const EXTRAS_KEYS: ReadonlySet<string> = new Set([\n \"stagger\",\n \"yoyo\",\n \"repeat\",\n \"repeatDelay\",\n \"snap\",\n \"overwrite\",\n \"immediateRender\",\n]);\n\nexport function isTweenConfigKey(key: string): boolean {\n return BUILTIN_VAR_KEYS.has(key) || DROPPED_VAR_KEYS.has(key) || EXTRAS_KEYS.has(key);\n}\n\n// ── Property Groups ─────────────────────────────────────────────────────────\n// Each group maps to an independent GSAP tween so editing one property\n// (e.g. drag → x/y) never contaminates another (e.g. scale, rotation).\n\nexport type PropertyGroupName = \"position\" | \"scale\" | \"size\" | \"rotation\" | \"visual\" | \"other\";\n\nexport const PROPERTY_GROUPS: Record<PropertyGroupName, ReadonlySet<string>> = {\n position: new Set([\"x\", \"y\", \"xPercent\", \"yPercent\"]),\n scale: new Set([\"scale\", \"scaleX\", \"scaleY\"]),\n size: new Set([\"width\", \"height\"]),\n rotation: new Set([\"rotation\", \"skewX\", \"skewY\"]),\n visual: new Set([\"opacity\", \"autoAlpha\"]),\n other: new Set<string>(),\n};\n\nconst PROP_TO_GROUP = new Map<string, PropertyGroupName>();\nfor (const [group, props] of Object.entries(PROPERTY_GROUPS) as [\n PropertyGroupName,\n ReadonlySet<string>,\n][]) {\n for (const p of props) PROP_TO_GROUP.set(p, group);\n}\n\ntype PositionWrite = Pick<\n GsapAnimation,\n \"propertyGroup\" | \"properties\" | \"fromProperties\" | \"keyframes\"\n>;\n\nfunction writesProperty(animation: PositionWrite, property: string): boolean {\n return (\n property in animation.properties ||\n (!!animation.fromProperties && property in animation.fromProperties) ||\n !!animation.keyframes?.keyframes.some((k) => property in k.properties)\n );\n}\n\n/** A position write that sets x or y. An xPercent/yPercent centring set never duplicates one. */\nexport function isXYPositionWrite(a: PositionWrite): boolean {\n return a.propertyGroup === \"position\" && (writesProperty(a, \"x\") || writesProperty(a, \"y\"));\n}\n\nexport function classifyPropertyGroup(prop: string): PropertyGroupName {\n return PROP_TO_GROUP.get(prop) ?? \"other\";\n}\n\nexport function classifyTweenPropertyGroup(\n properties: Record<string, unknown>,\n): PropertyGroupName | undefined {\n const groups = new Set<PropertyGroupName>();\n for (const key of Object.keys(properties)) {\n // transformOrigin is a modifier; `_auto` is Studio's internal endpoint marker;\n // `data` is GSAP-reserved (carries the Studio hold-set tag). None is an animated\n // property, so none should affect the group.\n if (key === \"transformOrigin\" || key === \"_auto\" || key === \"data\") continue;\n const g = classifyPropertyGroup(key);\n groups.add(g);\n }\n if (groups.size === 1) return groups.values().next().value;\n return undefined;\n}\n\nfunction knownStart(animation: GsapAnimation): number | undefined {\n if (animation.resolvedStart !== undefined) return animation.resolvedStart;\n return typeof animation.position === \"number\" ? animation.position : undefined;\n}\n\nexport interface HoldScope {\n touched: (animation: GsapAnimation) => boolean;\n held: (selector: string) => ReadonlyMap<string, unknown>;\n}\n\nconst tweenSignature = (a: GsapAnimation) =>\n JSON.stringify([a.targetSelector, a.method, a.position, a.duration, a.properties, a.keyframes]);\n\n/** The tweens an edit touched (not in `previous`; all without it), and what the script's holds already pin. */\nexport function holdScope(\n before: readonly GsapAnimation[],\n previous: readonly GsapAnimation[] | null,\n): HoldScope {\n const kept = new Set(previous?.map(tweenSignature));\n const held = new Map<string, Map<string, unknown>>();\n for (const a of before.filter((b) => b.method === \"set\" && b.properties?.data === \"hf-hold\")) {\n const props = held.get(a.targetSelector) ?? new Map<string, unknown>();\n for (const [property, value] of Object.entries(a.properties)) props.set(property, value);\n held.set(a.targetSelector, props);\n }\n return {\n touched: (a) => previous === null || !kept.has(tweenSignature(a)),\n held: (selector) => held.get(selector) ?? new Map(),\n };\n}\n\n/**\n * What a Studio hold pins from t=0, only for a tween this edit touched or a hold already pins: the 0% position props\n * before a later start, and the position and size of a lone key (GSAP renders none), minus earlier tweens.\n */\nexport function keyframeHoldForAnimation(\n animation: GsapAnimation,\n animations: readonly GsapAnimation[],\n scope: HoldScope,\n): Record<string, number> | null {\n if (!animation.keyframes) return null;\n const start = knownStart(animation);\n const lone = animation.keyframes.keyframes.length === 1;\n if (start === undefined || (!(start > 0.001) && !lone)) return null;\n const atStart = animation.keyframes.keyframes.find((keyframe) => keyframe.percentage === 0);\n if (!atStart) return null;\n // A tween whose start the parser could not resolve (a label, say) is not known to come first.\n const earlier = animations.filter((other) => {\n const otherStart = knownStart(other);\n return (\n other !== animation &&\n !other.global &&\n other.targetSelector === animation.targetSelector &&\n otherStart !== undefined &&\n otherStart < start - 0.001\n );\n });\n const touched = scope.touched(animation);\n const pinned = scope.held(animation.targetSelector);\n // An untouched tween keeps only the hold it made: one with its own first value.\n const kept = (property: string, value: unknown) =>\n touched ? pinned.has(property) : pinned.get(property) === value;\n const startsLate = start > 0.001;\n const pins = (group: PropertyGroupName, property: string, value: unknown) =>\n (group === \"position\" || group === \"size\") &&\n (((lone || (group === \"position\" && startsLate)) && touched) || kept(property, value));\n const hold: Record<string, number> = {};\n for (const [property, value] of Object.entries(atStart.properties)) {\n if (!pins(classifyPropertyGroup(property), property, value) || typeof value !== \"number\")\n continue;\n if (earlier.some((other) => writesProperty(other, property))) continue;\n hold[property] = value;\n }\n return Object.keys(hold).length > 0 ? hold : null;\n}\n\nexport const SUPPORTED_EASES = [\n \"none\",\n \"power1.in\",\n \"power1.out\",\n \"power1.inOut\",\n \"power2.in\",\n \"power2.out\",\n \"power2.inOut\",\n \"power3.in\",\n \"power3.out\",\n \"power3.inOut\",\n \"power4.in\",\n \"power4.out\",\n \"power4.inOut\",\n \"back.in\",\n \"back.out\",\n \"back.inOut\",\n \"elastic.in\",\n \"elastic.out\",\n \"elastic.inOut\",\n \"bounce.in\",\n \"bounce.out\",\n \"bounce.inOut\",\n \"circ.inOut\",\n \"expo.in\",\n \"expo.out\",\n \"expo.inOut\",\n \"elastic.out(1,0.3)\",\n \"elastic.inOut(1,0.3)\",\n \"spring-gentle\",\n \"spring-bouncy\",\n \"spring-stiff\",\n \"spring-wobbly\",\n \"spring-heavy\",\n \"hold\",\n \"steps(1)\",\n];\n"],"mappings":";AASO,IAAM,wBAAwB;AAE9B,IAAM,kBAAkB;AAAA;AAAA,EAE7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA;AAAA,EAEA;AACF;AAGO,IAAM,mBAAwC,oBAAI,IAAI,CAAC,YAAY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AAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
package/dist/gsapParser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GsapAnimation, P as ParsedGsap, A as ArcPathConfig, a as ArcPathSegment } from './gsapSerialize-
|
|
2
|
-
export { b as GsapKeyframeFormat, c as GsapKeyframesData, d as GsapMethod, e as GsapPercentageKeyframe, f as PROPERTY_GROUPS, g as PropertyGroupName, S as SUPPORTED_EASES, h as SUPPORTED_PROPS, i as classifyPropertyGroup, j as classifyTweenPropertyGroup, k as getAnimationsForElementId, l as gsapAnimationsToKeyframes, m as keyframesToGsapAnimations, s as serializeGsapAnimations, v as validateCompositionGsap } from './gsapSerialize-
|
|
1
|
+
import { G as GsapAnimation, P as ParsedGsap, A as ArcPathConfig, a as ArcPathSegment } from './gsapSerialize-DPyyDPBC.js';
|
|
2
|
+
export { b as GsapKeyframeFormat, c as GsapKeyframesData, d as GsapMethod, e as GsapPercentageKeyframe, f as PROPERTY_GROUPS, g as PropertyGroupName, S as SUPPORTED_EASES, h as SUPPORTED_PROPS, i as classifyPropertyGroup, j as classifyTweenPropertyGroup, k as getAnimationsForElementId, l as gsapAnimationsToKeyframes, m as keyframesToGsapAnimations, s as serializeGsapAnimations, v as validateCompositionGsap } from './gsapSerialize-DPyyDPBC.js';
|
|
3
3
|
export { SPRING_PRESETS, SpringPreset, generateSpringEaseData } from './springEase.js';
|
|
4
4
|
import './types-Ejqndkej.js';
|
|
5
5
|
|
package/dist/gsapParser.js
CHANGED
|
@@ -108,7 +108,7 @@ function holdScope(before, previous) {
|
|
|
108
108
|
held.set(a.targetSelector, props);
|
|
109
109
|
}
|
|
110
110
|
return {
|
|
111
|
-
touched: (a) => previous
|
|
111
|
+
touched: (a) => previous === null || !kept.has(tweenSignature(a)),
|
|
112
112
|
held: (selector) => held.get(selector) ?? /* @__PURE__ */ new Map()
|
|
113
113
|
};
|
|
114
114
|
}
|
|
@@ -126,7 +126,8 @@ function keyframeHoldForAnimation(animation, animations, scope) {
|
|
|
126
126
|
const touched = scope.touched(animation);
|
|
127
127
|
const pinned = scope.held(animation.targetSelector);
|
|
128
128
|
const kept = (property, value) => touched ? pinned.has(property) : pinned.get(property) === value;
|
|
129
|
-
const
|
|
129
|
+
const startsLate = start > 1e-3;
|
|
130
|
+
const pins = (group, property, value) => (group === "position" || group === "size") && ((lone || group === "position" && startsLate) && touched || kept(property, value));
|
|
130
131
|
const hold = {};
|
|
131
132
|
for (const [property, value] of Object.entries(atStart.properties)) {
|
|
132
133
|
if (!pins(classifyPropertyGroup(property), property, value) || typeof value !== "number")
|