@hyperframes/parsers 0.8.134 → 0.8.135
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/gsapParser.d.ts +2 -2
- package/dist/gsapParser.js +21 -14
- package/dist/gsapParser.js.map +1 -1
- package/dist/gsapParserAcorn.d.ts +9 -3
- package/dist/gsapParserAcorn.js +35 -9
- package/dist/gsapParserAcorn.js.map +1 -1
- package/dist/gsapParserExports.d.ts +1 -1
- package/dist/gsapParserExports.js +0 -3
- package/dist/gsapParserExports.js.map +1 -1
- package/dist/{gsapSerialize-_tuK-qvB.d.ts → gsapSerialize-WJrRO8uT.d.ts} +1 -1
- package/dist/gsapWriterAcorn.d.ts +1 -1
- package/dist/gsapWriterAcorn.js +22 -9
- package/dist/gsapWriterAcorn.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { P as ParsedGsap,
|
|
2
|
-
export { A as ArcPathConfig,
|
|
1
|
+
import { P as ParsedGsap, d as GsapMethod, G as GsapAnimation } from './gsapSerialize-WJrRO8uT.js';
|
|
2
|
+
export { A as ArcPathConfig, a as ArcPathSegment, n as GsapProvenance, o as GsapProvenanceKind, K as KeyframeEditability, M as MotionPathShape, p as buildArcPath, q as editabilityForProvenance } from './gsapSerialize-WJrRO8uT.js';
|
|
3
3
|
import './types-Ejqndkej.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A script's syntax tree as one string, or null when it does not parse. Comments, layout, quote
|
|
7
|
+
* style, parentheses and semicolons drop out; `maskNumbers` also hides every number literal.
|
|
8
|
+
*/
|
|
9
|
+
declare function scriptShape(code: string, maskNumbers?: boolean): string | null;
|
|
10
|
+
|
|
5
11
|
interface TweenCallInfo {
|
|
6
12
|
node: any;
|
|
7
13
|
/** acorn-walk ancestor array at the call site (root→call, call is last). */
|
|
@@ -57,4 +63,4 @@ interface GsapLabelEntry {
|
|
|
57
63
|
*/
|
|
58
64
|
declare function extractGsapLabels(script: string): GsapLabelEntry[];
|
|
59
65
|
|
|
60
|
-
export { type GsapLabelEntry, type ParsedGsapAcornForWrite, type TweenCallInfo, extractGsapLabels, findTimelineScript, gsapScriptMotionPathFirstUseIndex, gsapScriptUsesMotionPath, parseGsapScriptAcorn, parseGsapScriptAcornForWrite };
|
|
66
|
+
export { type GsapLabelEntry, type ParsedGsapAcornForWrite, type TweenCallInfo, extractGsapLabels, findTimelineScript, gsapScriptMotionPathFirstUseIndex, gsapScriptUsesMotionPath, parseGsapScriptAcorn, parseGsapScriptAcornForWrite, scriptShape };
|
package/dist/gsapParserAcorn.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/gsapParserAcorn.ts
|
|
2
|
-
import * as
|
|
2
|
+
import * as acorn2 from "acorn";
|
|
3
3
|
import * as acornWalk from "acorn-walk";
|
|
4
4
|
|
|
5
5
|
// src/gsapConstants.ts
|
|
@@ -623,6 +623,34 @@ function getObjectArrayKeyframeTiming(durations) {
|
|
|
623
623
|
};
|
|
624
624
|
}
|
|
625
625
|
|
|
626
|
+
// src/scriptShape.ts
|
|
627
|
+
import * as acorn from "acorn";
|
|
628
|
+
var isTaggedTemplate = (value) => value?.type === "TaggedTemplateExpression";
|
|
629
|
+
var printOnly = (tagged) => /* @__PURE__ */ new Map([
|
|
630
|
+
["start", () => true],
|
|
631
|
+
["end", () => true],
|
|
632
|
+
["raw", (holder) => !tagged.has(holder)],
|
|
633
|
+
["shorthand", (holder) => holder.key?.name !== "__proto__"]
|
|
634
|
+
]);
|
|
635
|
+
var isNumberLiteral = (holder, key, value) => key === "value" && typeof value === "number" && holder.type === "Literal";
|
|
636
|
+
function scriptShape(code, maskNumbers = false) {
|
|
637
|
+
let tree;
|
|
638
|
+
try {
|
|
639
|
+
tree = acorn.parse(code, { ecmaVersion: "latest", allowHashBang: true });
|
|
640
|
+
} catch {
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
643
|
+
const tagged = /* @__PURE__ */ new WeakSet();
|
|
644
|
+
const dropped = printOnly(tagged);
|
|
645
|
+
return JSON.stringify(tree, function(key, value) {
|
|
646
|
+
if (dropped.get(key)?.(this)) return void 0;
|
|
647
|
+
if (isTaggedTemplate(value)) for (const quasi of value.quasi.quasis) tagged.add(quasi.value);
|
|
648
|
+
if (typeof value === "bigint") return `${value}n`;
|
|
649
|
+
if (maskNumbers && isNumberLiteral(this, key, value)) return "num";
|
|
650
|
+
return value;
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
|
|
626
654
|
// src/gsapParserAcorn.ts
|
|
627
655
|
var GSAP_METHODS2 = /* @__PURE__ */ new Set(["set", "to", "from", "fromTo"]);
|
|
628
656
|
var QUERY_METHODS = /* @__PURE__ */ new Set(["querySelector", "querySelectorAll"]);
|
|
@@ -636,13 +664,13 @@ var SCOPE_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
|
636
664
|
]);
|
|
637
665
|
function parseProgram(script) {
|
|
638
666
|
try {
|
|
639
|
-
return
|
|
667
|
+
return acorn2.parse(script, {
|
|
640
668
|
ecmaVersion: "latest",
|
|
641
669
|
sourceType: "script",
|
|
642
670
|
locations: true
|
|
643
671
|
});
|
|
644
672
|
} catch {
|
|
645
|
-
return
|
|
673
|
+
return acorn2.parse(script, {
|
|
646
674
|
ecmaVersion: "latest",
|
|
647
675
|
sourceType: "module",
|
|
648
676
|
locations: true
|
|
@@ -1433,9 +1461,6 @@ function tweenCallToAnimation(call, scope, source, identifierBindings) {
|
|
|
1433
1461
|
properties[key] = val;
|
|
1434
1462
|
}
|
|
1435
1463
|
}
|
|
1436
|
-
if (keyframesData && typeof vars.easeEach === "string") {
|
|
1437
|
-
keyframesData.easeEach = vars.easeEach;
|
|
1438
|
-
}
|
|
1439
1464
|
if (motionPathResult) {
|
|
1440
1465
|
const { waypoints } = motionPathResult;
|
|
1441
1466
|
if (!keyframesData) {
|
|
@@ -1787,7 +1812,7 @@ function assignStableIds(anims) {
|
|
|
1787
1812
|
}
|
|
1788
1813
|
function parseGsapScriptAcornForWrite(script) {
|
|
1789
1814
|
try {
|
|
1790
|
-
const ast =
|
|
1815
|
+
const ast = acorn2.parse(script, {
|
|
1791
1816
|
ecmaVersion: "latest",
|
|
1792
1817
|
sourceType: "script",
|
|
1793
1818
|
locations: true
|
|
@@ -1944,7 +1969,7 @@ function gsapScriptUsesMotionPath(script) {
|
|
|
1944
1969
|
}
|
|
1945
1970
|
function extractGsapLabels(script) {
|
|
1946
1971
|
try {
|
|
1947
|
-
const ast =
|
|
1972
|
+
const ast = acorn2.parse(script, {
|
|
1948
1973
|
ecmaVersion: "latest",
|
|
1949
1974
|
sourceType: "script",
|
|
1950
1975
|
locations: true
|
|
@@ -1985,6 +2010,7 @@ export {
|
|
|
1985
2010
|
gsapScriptMotionPathFirstUseIndex,
|
|
1986
2011
|
gsapScriptUsesMotionPath,
|
|
1987
2012
|
parseGsapScriptAcorn,
|
|
1988
|
-
parseGsapScriptAcornForWrite
|
|
2013
|
+
parseGsapScriptAcornForWrite,
|
|
2014
|
+
scriptShape
|
|
1989
2015
|
};
|
|
1990
2016
|
//# sourceMappingURL=gsapParserAcorn.js.map
|