@danielx/civet 0.6.15 → 0.6.16

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/browser.js CHANGED
@@ -745,12 +745,15 @@ var Civet = (() => {
745
745
  }
746
746
  }
747
747
  function findAncestor(node, predicate, stopPredicate) {
748
- node = node.parent;
749
- while (node && !stopPredicate?.(node)) {
750
- if (predicate(node))
751
- return node;
752
- node = node.parent;
748
+ let { parent } = node;
749
+ while (parent && !stopPredicate?.(parent, node)) {
750
+ if (predicate(parent, node)) {
751
+ return { ancestor: parent, child: node };
752
+ }
753
+ node = parent;
754
+ parent = node.parent;
753
755
  }
756
+ return { ancestor: void 0, child: node };
754
757
  }
755
758
  function gatherNodes(node, predicate) {
756
759
  if (node == null)
@@ -823,14 +826,11 @@ var Civet = (() => {
823
826
  }
824
827
  function hoistRefDecs(statements) {
825
828
  gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
826
- let { hoistDec, parent } = node;
829
+ let { hoistDec } = node;
827
830
  node.hoistDec = null;
828
- while (parent?.type !== "BlockStatement" || parent.bare && !parent.root) {
829
- node = parent;
830
- parent = node.parent;
831
- }
832
- if (parent) {
833
- insertHoistDec(parent, node, hoistDec);
831
+ const { ancestor, child } = findAncestor(node, (ancestor2) => ancestor2.type === "BlockStatement" && (!ancestor2.bare || ancestor2.root));
832
+ if (ancestor) {
833
+ insertHoistDec(ancestor, child, hoistDec);
834
834
  } else {
835
835
  throw new Error("Couldn't find block to hoist declaration into.");
836
836
  }
@@ -1370,6 +1370,8 @@ var Civet = (() => {
1370
1370
  if (f.abstract || f.block || f.signature?.optional)
1371
1371
  return;
1372
1372
  const { name, parent } = f;
1373
+ if (parent?.type === "ExportDeclaration")
1374
+ return;
1373
1375
  const expressions = parent?.expressions ?? parent?.elements;
1374
1376
  const currentIndex = expressions?.findIndex(([, def]) => def === f);
1375
1377
  const following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
@@ -2227,7 +2229,7 @@ var Civet = (() => {
2227
2229
  let declared;
2228
2230
  values.forEach((value) => {
2229
2231
  value.children = [ref];
2230
- const ancestor = findAncestor(
2232
+ const { ancestor } = findAncestor(
2231
2233
  value,
2232
2234
  ({ type }) => type === "Declaration",
2233
2235
  isFunction
@@ -14732,14 +14734,15 @@ ${input.slice(result.pos)}
14732
14734
  }
14733
14735
  }
14734
14736
  var ExportDeclaration$0 = $TS($S($E(Decorators), Export, __, Default, __, $C(HoistableDeclaration, ClassDeclaration, ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
14735
- return { type: "ExportDeclaration", children: $0 };
14737
+ var declaration = $6;
14738
+ return { type: "ExportDeclaration", declaration, children: $0 };
14736
14739
  });
14737
14740
  var ExportDeclaration$1 = $TS($S(Export, __, ExportFromClause, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
14738
14741
  return { type: "ExportDeclaration", ts: $3.ts, children: $0 };
14739
14742
  });
14740
14743
  var ExportDeclaration$2 = $TS($S($E(Decorators), Export, __, $C(Declaration, VariableStatement, TypeAndNamedExports, ExportVarDec)), function($skip, $loc, $0, $1, $2, $3, $4) {
14741
- var decl = $4;
14742
- return { type: "ExportDeclaration", ts: decl.ts, children: $0 };
14744
+ var declaration = $4;
14745
+ return { type: "ExportDeclaration", declaration, ts: declaration.ts, children: $0 };
14743
14746
  });
14744
14747
  function ExportDeclaration(state) {
14745
14748
  let eventData;
package/dist/main.js CHANGED
@@ -744,12 +744,15 @@ var require_lib = __commonJS({
744
744
  }
745
745
  }
746
746
  function findAncestor(node, predicate, stopPredicate) {
747
- node = node.parent;
748
- while (node && !stopPredicate?.(node)) {
749
- if (predicate(node))
750
- return node;
751
- node = node.parent;
747
+ let { parent } = node;
748
+ while (parent && !stopPredicate?.(parent, node)) {
749
+ if (predicate(parent, node)) {
750
+ return { ancestor: parent, child: node };
751
+ }
752
+ node = parent;
753
+ parent = node.parent;
752
754
  }
755
+ return { ancestor: void 0, child: node };
753
756
  }
754
757
  function gatherNodes(node, predicate) {
755
758
  if (node == null)
@@ -822,14 +825,11 @@ var require_lib = __commonJS({
822
825
  }
823
826
  function hoistRefDecs(statements) {
824
827
  gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
825
- let { hoistDec, parent } = node;
828
+ let { hoistDec } = node;
826
829
  node.hoistDec = null;
827
- while (parent?.type !== "BlockStatement" || parent.bare && !parent.root) {
828
- node = parent;
829
- parent = node.parent;
830
- }
831
- if (parent) {
832
- insertHoistDec(parent, node, hoistDec);
830
+ const { ancestor, child } = findAncestor(node, (ancestor2) => ancestor2.type === "BlockStatement" && (!ancestor2.bare || ancestor2.root));
831
+ if (ancestor) {
832
+ insertHoistDec(ancestor, child, hoistDec);
833
833
  } else {
834
834
  throw new Error("Couldn't find block to hoist declaration into.");
835
835
  }
@@ -1369,6 +1369,8 @@ var require_lib = __commonJS({
1369
1369
  if (f.abstract || f.block || f.signature?.optional)
1370
1370
  return;
1371
1371
  const { name, parent } = f;
1372
+ if (parent?.type === "ExportDeclaration")
1373
+ return;
1372
1374
  const expressions = parent?.expressions ?? parent?.elements;
1373
1375
  const currentIndex = expressions?.findIndex(([, def]) => def === f);
1374
1376
  const following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
@@ -2226,7 +2228,7 @@ var require_lib = __commonJS({
2226
2228
  let declared;
2227
2229
  values.forEach((value) => {
2228
2230
  value.children = [ref];
2229
- const ancestor = findAncestor(
2231
+ const { ancestor } = findAncestor(
2230
2232
  value,
2231
2233
  ({ type }) => type === "Declaration",
2232
2234
  isFunction
@@ -14731,14 +14733,15 @@ ${input.slice(result.pos)}
14731
14733
  }
14732
14734
  }
14733
14735
  var ExportDeclaration$0 = $TS($S($E(Decorators), Export, __, Default, __, $C(HoistableDeclaration, ClassDeclaration, ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
14734
- return { type: "ExportDeclaration", children: $0 };
14736
+ var declaration = $6;
14737
+ return { type: "ExportDeclaration", declaration, children: $0 };
14735
14738
  });
14736
14739
  var ExportDeclaration$1 = $TS($S(Export, __, ExportFromClause, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
14737
14740
  return { type: "ExportDeclaration", ts: $3.ts, children: $0 };
14738
14741
  });
14739
14742
  var ExportDeclaration$2 = $TS($S($E(Decorators), Export, __, $C(Declaration, VariableStatement, TypeAndNamedExports, ExportVarDec)), function($skip, $loc, $0, $1, $2, $3, $4) {
14740
- var decl = $4;
14741
- return { type: "ExportDeclaration", ts: decl.ts, children: $0 };
14743
+ var declaration = $4;
14744
+ return { type: "ExportDeclaration", declaration, ts: declaration.ts, children: $0 };
14742
14745
  });
14743
14746
  function ExportDeclaration(state) {
14744
14747
  let eventData;
package/dist/main.mjs CHANGED
@@ -742,12 +742,15 @@ var require_lib = __commonJS({
742
742
  }
743
743
  }
744
744
  function findAncestor(node, predicate, stopPredicate) {
745
- node = node.parent;
746
- while (node && !stopPredicate?.(node)) {
747
- if (predicate(node))
748
- return node;
749
- node = node.parent;
745
+ let { parent } = node;
746
+ while (parent && !stopPredicate?.(parent, node)) {
747
+ if (predicate(parent, node)) {
748
+ return { ancestor: parent, child: node };
749
+ }
750
+ node = parent;
751
+ parent = node.parent;
750
752
  }
753
+ return { ancestor: void 0, child: node };
751
754
  }
752
755
  function gatherNodes(node, predicate) {
753
756
  if (node == null)
@@ -820,14 +823,11 @@ var require_lib = __commonJS({
820
823
  }
821
824
  function hoistRefDecs(statements) {
822
825
  gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
823
- let { hoistDec, parent } = node;
826
+ let { hoistDec } = node;
824
827
  node.hoistDec = null;
825
- while (parent?.type !== "BlockStatement" || parent.bare && !parent.root) {
826
- node = parent;
827
- parent = node.parent;
828
- }
829
- if (parent) {
830
- insertHoistDec(parent, node, hoistDec);
828
+ const { ancestor, child } = findAncestor(node, (ancestor2) => ancestor2.type === "BlockStatement" && (!ancestor2.bare || ancestor2.root));
829
+ if (ancestor) {
830
+ insertHoistDec(ancestor, child, hoistDec);
831
831
  } else {
832
832
  throw new Error("Couldn't find block to hoist declaration into.");
833
833
  }
@@ -1367,6 +1367,8 @@ var require_lib = __commonJS({
1367
1367
  if (f.abstract || f.block || f.signature?.optional)
1368
1368
  return;
1369
1369
  const { name, parent } = f;
1370
+ if (parent?.type === "ExportDeclaration")
1371
+ return;
1370
1372
  const expressions = parent?.expressions ?? parent?.elements;
1371
1373
  const currentIndex = expressions?.findIndex(([, def]) => def === f);
1372
1374
  const following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
@@ -2224,7 +2226,7 @@ var require_lib = __commonJS({
2224
2226
  let declared;
2225
2227
  values.forEach((value) => {
2226
2228
  value.children = [ref];
2227
- const ancestor = findAncestor(
2229
+ const { ancestor } = findAncestor(
2228
2230
  value,
2229
2231
  ({ type }) => type === "Declaration",
2230
2232
  isFunction
@@ -14729,14 +14731,15 @@ ${input.slice(result.pos)}
14729
14731
  }
14730
14732
  }
14731
14733
  var ExportDeclaration$0 = $TS($S($E(Decorators), Export, __, Default, __, $C(HoistableDeclaration, ClassDeclaration, ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
14732
- return { type: "ExportDeclaration", children: $0 };
14734
+ var declaration = $6;
14735
+ return { type: "ExportDeclaration", declaration, children: $0 };
14733
14736
  });
14734
14737
  var ExportDeclaration$1 = $TS($S(Export, __, ExportFromClause, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
14735
14738
  return { type: "ExportDeclaration", ts: $3.ts, children: $0 };
14736
14739
  });
14737
14740
  var ExportDeclaration$2 = $TS($S($E(Decorators), Export, __, $C(Declaration, VariableStatement, TypeAndNamedExports, ExportVarDec)), function($skip, $loc, $0, $1, $2, $3, $4) {
14738
- var decl = $4;
14739
- return { type: "ExportDeclaration", ts: decl.ts, children: $0 };
14741
+ var declaration = $4;
14742
+ return { type: "ExportDeclaration", declaration, ts: declaration.ts, children: $0 };
14740
14743
  });
14741
14744
  function ExportDeclaration(state) {
14742
14745
  let eventData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.6.15",
3
+ "version": "0.6.16",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.mjs",