@hyperframes/parsers 0.7.68 → 0.7.70

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/index.js CHANGED
@@ -874,6 +874,21 @@ var SCOPE_NODE_TYPES = /* @__PURE__ */ new Set([
874
874
  "FunctionExpression",
875
875
  "ArrowFunctionExpression"
876
876
  ]);
877
+ function parseProgram(script) {
878
+ try {
879
+ return acorn.parse(script, {
880
+ ecmaVersion: "latest",
881
+ sourceType: "script",
882
+ locations: true
883
+ });
884
+ } catch {
885
+ return acorn.parse(script, {
886
+ ecmaVersion: "latest",
887
+ sourceType: "module",
888
+ locations: true
889
+ });
890
+ }
891
+ }
877
892
  var CONST_NODES = /* @__PURE__ */ Symbol("hf.constNodes");
878
893
  function constNodesOf(scope) {
879
894
  return scope[CONST_NODES];
@@ -2019,11 +2034,7 @@ function parseGsapScriptAcornForWrite(script) {
2019
2034
  }
2020
2035
  function parseGsapScriptAcorn(script) {
2021
2036
  try {
2022
- const ast = acorn.parse(script, {
2023
- ecmaVersion: "latest",
2024
- sourceType: "script",
2025
- locations: true
2026
- });
2037
+ const ast = parseProgram(script);
2027
2038
  const scope = collectScopeBindings(ast);
2028
2039
  const detection = findTimelineVar(ast, scope);
2029
2040
  const ref = detection.ref ?? { kind: "identifier", name: "tl" };