@danielx/civet 0.5.14 → 0.5.15

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.
Files changed (3) hide show
  1. package/dist/browser.js +91 -148
  2. package/dist/main.js +91 -148
  3. package/package.json +1 -1
package/dist/browser.js CHANGED
@@ -5,88 +5,6 @@ var Civet = (() => {
5
5
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6
6
  };
7
7
 
8
- // source/generate.coffee
9
- var require_generate = __commonJS({
10
- "source/generate.coffee"(exports, module) {
11
- "civet coffeeCompat";
12
- var gen;
13
- var prune;
14
- gen = function(node, options) {
15
- var $loc, token;
16
- if (node === null || node === void 0) {
17
- return "";
18
- }
19
- if (typeof node === "string") {
20
- if (options != null) {
21
- if (typeof options.updateSourceMap === "function") {
22
- options.updateSourceMap(node);
23
- }
24
- }
25
- return node;
26
- }
27
- if (Array.isArray(node)) {
28
- return node.map(function(child) {
29
- return gen(child, options);
30
- }).join("");
31
- }
32
- if (typeof node === "object") {
33
- if (options.js && node.ts) {
34
- return "";
35
- }
36
- if (!options.js && node.js) {
37
- return "";
38
- }
39
- if (node.$loc != null) {
40
- ({ token, $loc } = node);
41
- if (options != null) {
42
- if (typeof options.updateSourceMap === "function") {
43
- options.updateSourceMap(token, $loc.pos);
44
- }
45
- }
46
- return token;
47
- }
48
- if (!node.children) {
49
- debugger;
50
- throw new Error("Unknown node", JSON.stringify(node));
51
- }
52
- return gen(node.children, options);
53
- }
54
- debugger;
55
- throw new Error("Unknown node", JSON.stringify(node));
56
- };
57
- module.exports = gen;
58
- prune = function(node) {
59
- var a;
60
- if (node === null || node === void 0) {
61
- return;
62
- }
63
- if (node.length === 0) {
64
- return;
65
- }
66
- if (Array.isArray(node)) {
67
- a = node.map(function(n) {
68
- return prune(n);
69
- }).filter(function(n) {
70
- return !!n;
71
- });
72
- if (a.length > 1) {
73
- return a;
74
- }
75
- if (a.length === 1) {
76
- return a[0];
77
- }
78
- return;
79
- }
80
- if (node.children != null) {
81
- node.children = prune(node.children) || [];
82
- return node;
83
- }
84
- return node;
85
- };
86
- gen.prune = prune;
87
- }
88
- });
89
-
90
8
  // source/parser.hera
91
9
  var require_parser = __commonJS({
92
10
  "source/parser.hera"(exports, module) {
@@ -11002,8 +10920,9 @@ ${input.slice(result.pos)}
11002
10920
  children: children.jsxChildren.length ? [...$0, ["</", open[1], ">"]] : [open.slice(0, -1), " />"]
11003
10921
  };
11004
10922
  });
11005
- var JSXElement$3 = $TS($S(JSXOpeningElement), function($skip, $loc, $0, $1) {
11006
- throw new Error(`could not parse JSX element "${require_generate()($0)}" at pos ${$loc.pos}`);
10923
+ var JSXElement$3 = $TV(JSXOpeningElement, function($skip, $loc, $0, $1) {
10924
+ var elt = $0;
10925
+ throw new Error(`could not parse JSX element "${elt[0]}${elt[1]}${elt[elt.length - 1]}" at pos ${$loc.pos}`);
11007
10926
  });
11008
10927
  function JSXElement(state) {
11009
10928
  if (state.events) {
@@ -11653,7 +11572,7 @@ ${input.slice(result.pos)}
11653
11572
  }
11654
11573
  return $skip;
11655
11574
  });
11656
- var JSXNestedChildren$1 = $TV($Y(EOS), function($skip, $loc, $0, $1) {
11575
+ var JSXNestedChildren$1 = $TV($Y($C(EOS, $EXPECT($L17, fail, 'JSXNestedChildren "}"'))), function($skip, $loc, $0, $1) {
11657
11576
  return { children: [], jsxChildren: [] };
11658
11577
  });
11659
11578
  function JSXNestedChildren(state) {
@@ -14782,6 +14701,88 @@ ${input.slice(result.pos)}
14782
14701
  }
14783
14702
  });
14784
14703
 
14704
+ // source/generate.coffee
14705
+ var require_generate = __commonJS({
14706
+ "source/generate.coffee"(exports, module) {
14707
+ "civet coffeeCompat";
14708
+ var gen;
14709
+ var prune;
14710
+ gen = function(node, options) {
14711
+ var $loc, token;
14712
+ if (node === null || node === void 0) {
14713
+ return "";
14714
+ }
14715
+ if (typeof node === "string") {
14716
+ if (options != null) {
14717
+ if (typeof options.updateSourceMap === "function") {
14718
+ options.updateSourceMap(node);
14719
+ }
14720
+ }
14721
+ return node;
14722
+ }
14723
+ if (Array.isArray(node)) {
14724
+ return node.map(function(child) {
14725
+ return gen(child, options);
14726
+ }).join("");
14727
+ }
14728
+ if (typeof node === "object") {
14729
+ if (options.js && node.ts) {
14730
+ return "";
14731
+ }
14732
+ if (!options.js && node.js) {
14733
+ return "";
14734
+ }
14735
+ if (node.$loc != null) {
14736
+ ({ token, $loc } = node);
14737
+ if (options != null) {
14738
+ if (typeof options.updateSourceMap === "function") {
14739
+ options.updateSourceMap(token, $loc.pos);
14740
+ }
14741
+ }
14742
+ return token;
14743
+ }
14744
+ if (!node.children) {
14745
+ debugger;
14746
+ throw new Error("Unknown node", JSON.stringify(node));
14747
+ }
14748
+ return gen(node.children, options);
14749
+ }
14750
+ debugger;
14751
+ throw new Error("Unknown node", JSON.stringify(node));
14752
+ };
14753
+ module.exports = gen;
14754
+ prune = function(node) {
14755
+ var a;
14756
+ if (node === null || node === void 0) {
14757
+ return;
14758
+ }
14759
+ if (node.length === 0) {
14760
+ return;
14761
+ }
14762
+ if (Array.isArray(node)) {
14763
+ a = node.map(function(n) {
14764
+ return prune(n);
14765
+ }).filter(function(n) {
14766
+ return !!n;
14767
+ });
14768
+ if (a.length > 1) {
14769
+ return a;
14770
+ }
14771
+ if (a.length === 1) {
14772
+ return a[0];
14773
+ }
14774
+ return;
14775
+ }
14776
+ if (node.children != null) {
14777
+ node.children = prune(node.children) || [];
14778
+ return node;
14779
+ }
14780
+ return node;
14781
+ };
14782
+ gen.prune = prune;
14783
+ }
14784
+ });
14785
+
14785
14786
  // source/util.coffee
14786
14787
  var require_util = __commonJS({
14787
14788
  "source/util.coffee"(exports, module) {
@@ -15119,11 +15120,13 @@ ${input.slice(result.pos)}
15119
15120
  var makeCache;
15120
15121
  var parse;
15121
15122
  var prune;
15123
+ var uncacheable;
15122
15124
  var util;
15123
15125
  ({ parse } = require_parser());
15124
15126
  ({ prune } = gen = require_generate());
15125
15127
  ({ SourceMap, base64Encode } = util = require_util());
15126
15128
  defaultOptions = {};
15129
+ uncacheable = /* @__PURE__ */ new Set(["TrackIndented", "Samedent", "IndentedFurther", "PushIndent", "PopIndent", "Nested", "InsertIndent", "Arguments", "ArgumentsWithTrailingCallExpressions", "ApplicationStart", "CallExpression", "CallExpressionRest", "LeftHandSideExpression", "ActualAssignment", "UpdateExpression", "UnaryExpression", "BinaryOpExpression", "BinaryOpRHS", "ConditionalExpression", "ShortCircuitExpression", "ImplicitNestedBlock", "ObjectLiteral", "NestedObject", "NestedImplicitObjectLiteral", "BracedObjectLiteralContent", "NestedPropertyDefinitions", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedBlockStatement", "NestedElement", "NestedElementList", "NestedBindingElement", "NestedBindingElements", "NestedInterfaceProperty", "MemberExpression", "PrimaryExpression", "IndentedApplicationAllowed", "ExpressionWithIndentedApplicationSuppressed", "SuppressIndentedApplication", "AssignmentExpressionTail", "AssignmentExpression", "ExtendedExpression", "Expression", "MemberExpressionRest", "ElseClause", "CoffeeCommentEnabled", "SingleLineComment", "Debugger", "JSXElement", "TypedJSXElement", "JSXFragment", "TypedJSXFragment", "JSXChild", "JSXChildren", "JSXNestedChildren", "JSXMixedChildren"]);
15127
15130
  module.exports = {
15128
15131
  parse,
15129
15132
  compile: function(src, options = defaultOptions) {
@@ -15176,69 +15179,9 @@ ${"//#"} sourceMappingURL=data:application/json;base64,${base64Encode(JSON.strin
15176
15179
  exit: function(ruleName, state, result) {
15177
15180
  var cache;
15178
15181
  cache = caches.get(ruleName);
15179
- if (!cache) {
15180
- switch (ruleName) {
15181
- case "TrackIndented":
15182
- case "Samedent":
15183
- case "IndentedFurther":
15184
- case "PushIndent":
15185
- case "PopIndent":
15186
- case "Nested":
15187
- case "InsertIndent":
15188
- case "Arguments":
15189
- case "ArgumentsWithTrailingCallExpressions":
15190
- case "ApplicationStart":
15191
- case "CallExpression":
15192
- case "CallExpressionRest":
15193
- case "LeftHandSideExpression":
15194
- case "ActualAssignment":
15195
- case "UpdateExpression":
15196
- case "UnaryExpression":
15197
- case "BinaryOpExpression":
15198
- case "BinaryOpRHS":
15199
- case "ConditionalExpression":
15200
- case "ShortCircuitExpression":
15201
- case "ImplicitNestedBlock":
15202
- case "ObjectLiteral":
15203
- case "NestedObject":
15204
- case "NestedImplicitObjectLiteral":
15205
- case "BracedObjectLiteralContent":
15206
- case "NestedPropertyDefinitions":
15207
- case "NestedImplicitPropertyDefinition":
15208
- case "NestedImplicitPropertyDefinitions":
15209
- case "NestedBlockStatement":
15210
- case "NestedElement":
15211
- case "NestedElementList":
15212
- case "NestedBindingElement":
15213
- case "NestedBindingElements":
15214
- case "NestedInterfaceProperty":
15215
- case "MemberExpression":
15216
- case "PrimaryExpression":
15217
- case "IndentedApplicationAllowed":
15218
- case "ExpressionWithIndentedApplicationSuppressed":
15219
- case "SuppressIndentedApplication":
15220
- case "AssignmentExpressionTail":
15221
- case "AssignmentExpression":
15222
- case "ExtendedExpression":
15223
- case "Expression":
15224
- case "MemberExpressionRest":
15225
- case "ElseClause":
15226
- case "CoffeeCommentEnabled":
15227
- case "SingleLineComment":
15228
- case "Debugger":
15229
- case "JSXElement":
15230
- case "TypedJSXElement":
15231
- case "JSXFragment":
15232
- case "TypedJSXFragment":
15233
- case "JSXChild":
15234
- case "JSXChildren":
15235
- case "JSXNestedChildren":
15236
- case "JSXMixedChildren":
15237
- break;
15238
- default:
15239
- cache = /* @__PURE__ */ new Map();
15240
- caches.set(ruleName, cache);
15241
- }
15182
+ if (!cache && !uncacheable.has(ruleName)) {
15183
+ cache = /* @__PURE__ */ new Map();
15184
+ caches.set(ruleName, cache);
15242
15185
  }
15243
15186
  if (cache) {
15244
15187
  if (result) {
package/dist/main.js CHANGED
@@ -4,88 +4,6 @@ var __commonJS = (cb, mod) => function __require() {
4
4
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
5
5
  };
6
6
 
7
- // source/generate.coffee
8
- var require_generate = __commonJS({
9
- "source/generate.coffee"(exports2, module2) {
10
- "civet coffeeCompat";
11
- var gen2;
12
- var prune2;
13
- gen2 = function(node, options) {
14
- var $loc, token;
15
- if (node === null || node === void 0) {
16
- return "";
17
- }
18
- if (typeof node === "string") {
19
- if (options != null) {
20
- if (typeof options.updateSourceMap === "function") {
21
- options.updateSourceMap(node);
22
- }
23
- }
24
- return node;
25
- }
26
- if (Array.isArray(node)) {
27
- return node.map(function(child) {
28
- return gen2(child, options);
29
- }).join("");
30
- }
31
- if (typeof node === "object") {
32
- if (options.js && node.ts) {
33
- return "";
34
- }
35
- if (!options.js && node.js) {
36
- return "";
37
- }
38
- if (node.$loc != null) {
39
- ({ token, $loc } = node);
40
- if (options != null) {
41
- if (typeof options.updateSourceMap === "function") {
42
- options.updateSourceMap(token, $loc.pos);
43
- }
44
- }
45
- return token;
46
- }
47
- if (!node.children) {
48
- debugger;
49
- throw new Error("Unknown node", JSON.stringify(node));
50
- }
51
- return gen2(node.children, options);
52
- }
53
- debugger;
54
- throw new Error("Unknown node", JSON.stringify(node));
55
- };
56
- module2.exports = gen2;
57
- prune2 = function(node) {
58
- var a;
59
- if (node === null || node === void 0) {
60
- return;
61
- }
62
- if (node.length === 0) {
63
- return;
64
- }
65
- if (Array.isArray(node)) {
66
- a = node.map(function(n) {
67
- return prune2(n);
68
- }).filter(function(n) {
69
- return !!n;
70
- });
71
- if (a.length > 1) {
72
- return a;
73
- }
74
- if (a.length === 1) {
75
- return a[0];
76
- }
77
- return;
78
- }
79
- if (node.children != null) {
80
- node.children = prune2(node.children) || [];
81
- return node;
82
- }
83
- return node;
84
- };
85
- gen2.prune = prune2;
86
- }
87
- });
88
-
89
7
  // source/parser.hera
90
8
  var require_parser = __commonJS({
91
9
  "source/parser.hera"(exports2, module2) {
@@ -11001,8 +10919,9 @@ ${input.slice(result.pos)}
11001
10919
  children: children.jsxChildren.length ? [...$0, ["</", open[1], ">"]] : [open.slice(0, -1), " />"]
11002
10920
  };
11003
10921
  });
11004
- var JSXElement$3 = $TS($S(JSXOpeningElement), function($skip, $loc, $0, $1) {
11005
- throw new Error(`could not parse JSX element "${require_generate()($0)}" at pos ${$loc.pos}`);
10922
+ var JSXElement$3 = $TV(JSXOpeningElement, function($skip, $loc, $0, $1) {
10923
+ var elt = $0;
10924
+ throw new Error(`could not parse JSX element "${elt[0]}${elt[1]}${elt[elt.length - 1]}" at pos ${$loc.pos}`);
11006
10925
  });
11007
10926
  function JSXElement(state) {
11008
10927
  if (state.events) {
@@ -11652,7 +11571,7 @@ ${input.slice(result.pos)}
11652
11571
  }
11653
11572
  return $skip;
11654
11573
  });
11655
- var JSXNestedChildren$1 = $TV($Y(EOS), function($skip, $loc, $0, $1) {
11574
+ var JSXNestedChildren$1 = $TV($Y($C(EOS, $EXPECT($L17, fail, 'JSXNestedChildren "}"'))), function($skip, $loc, $0, $1) {
11656
11575
  return { children: [], jsxChildren: [] };
11657
11576
  });
11658
11577
  function JSXNestedChildren(state) {
@@ -14781,6 +14700,88 @@ ${input.slice(result.pos)}
14781
14700
  }
14782
14701
  });
14783
14702
 
14703
+ // source/generate.coffee
14704
+ var require_generate = __commonJS({
14705
+ "source/generate.coffee"(exports2, module2) {
14706
+ "civet coffeeCompat";
14707
+ var gen2;
14708
+ var prune2;
14709
+ gen2 = function(node, options) {
14710
+ var $loc, token;
14711
+ if (node === null || node === void 0) {
14712
+ return "";
14713
+ }
14714
+ if (typeof node === "string") {
14715
+ if (options != null) {
14716
+ if (typeof options.updateSourceMap === "function") {
14717
+ options.updateSourceMap(node);
14718
+ }
14719
+ }
14720
+ return node;
14721
+ }
14722
+ if (Array.isArray(node)) {
14723
+ return node.map(function(child) {
14724
+ return gen2(child, options);
14725
+ }).join("");
14726
+ }
14727
+ if (typeof node === "object") {
14728
+ if (options.js && node.ts) {
14729
+ return "";
14730
+ }
14731
+ if (!options.js && node.js) {
14732
+ return "";
14733
+ }
14734
+ if (node.$loc != null) {
14735
+ ({ token, $loc } = node);
14736
+ if (options != null) {
14737
+ if (typeof options.updateSourceMap === "function") {
14738
+ options.updateSourceMap(token, $loc.pos);
14739
+ }
14740
+ }
14741
+ return token;
14742
+ }
14743
+ if (!node.children) {
14744
+ debugger;
14745
+ throw new Error("Unknown node", JSON.stringify(node));
14746
+ }
14747
+ return gen2(node.children, options);
14748
+ }
14749
+ debugger;
14750
+ throw new Error("Unknown node", JSON.stringify(node));
14751
+ };
14752
+ module2.exports = gen2;
14753
+ prune2 = function(node) {
14754
+ var a;
14755
+ if (node === null || node === void 0) {
14756
+ return;
14757
+ }
14758
+ if (node.length === 0) {
14759
+ return;
14760
+ }
14761
+ if (Array.isArray(node)) {
14762
+ a = node.map(function(n) {
14763
+ return prune2(n);
14764
+ }).filter(function(n) {
14765
+ return !!n;
14766
+ });
14767
+ if (a.length > 1) {
14768
+ return a;
14769
+ }
14770
+ if (a.length === 1) {
14771
+ return a[0];
14772
+ }
14773
+ return;
14774
+ }
14775
+ if (node.children != null) {
14776
+ node.children = prune2(node.children) || [];
14777
+ return node;
14778
+ }
14779
+ return node;
14780
+ };
14781
+ gen2.prune = prune2;
14782
+ }
14783
+ });
14784
+
14784
14785
  // source/util.coffee
14785
14786
  var require_util = __commonJS({
14786
14787
  "source/util.coffee"(exports2, module2) {
@@ -15116,11 +15117,13 @@ var gen;
15116
15117
  var makeCache;
15117
15118
  var parse;
15118
15119
  var prune;
15120
+ var uncacheable;
15119
15121
  var util;
15120
15122
  ({ parse } = require_parser());
15121
15123
  ({ prune } = gen = require_generate());
15122
15124
  ({ SourceMap, base64Encode } = util = require_util());
15123
15125
  defaultOptions = {};
15126
+ uncacheable = /* @__PURE__ */ new Set(["TrackIndented", "Samedent", "IndentedFurther", "PushIndent", "PopIndent", "Nested", "InsertIndent", "Arguments", "ArgumentsWithTrailingCallExpressions", "ApplicationStart", "CallExpression", "CallExpressionRest", "LeftHandSideExpression", "ActualAssignment", "UpdateExpression", "UnaryExpression", "BinaryOpExpression", "BinaryOpRHS", "ConditionalExpression", "ShortCircuitExpression", "ImplicitNestedBlock", "ObjectLiteral", "NestedObject", "NestedImplicitObjectLiteral", "BracedObjectLiteralContent", "NestedPropertyDefinitions", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedBlockStatement", "NestedElement", "NestedElementList", "NestedBindingElement", "NestedBindingElements", "NestedInterfaceProperty", "MemberExpression", "PrimaryExpression", "IndentedApplicationAllowed", "ExpressionWithIndentedApplicationSuppressed", "SuppressIndentedApplication", "AssignmentExpressionTail", "AssignmentExpression", "ExtendedExpression", "Expression", "MemberExpressionRest", "ElseClause", "CoffeeCommentEnabled", "SingleLineComment", "Debugger", "JSXElement", "TypedJSXElement", "JSXFragment", "TypedJSXFragment", "JSXChild", "JSXChildren", "JSXNestedChildren", "JSXMixedChildren"]);
15124
15127
  module.exports = {
15125
15128
  parse,
15126
15129
  compile: function(src, options = defaultOptions) {
@@ -15173,69 +15176,9 @@ makeCache = function() {
15173
15176
  exit: function(ruleName, state, result) {
15174
15177
  var cache;
15175
15178
  cache = caches.get(ruleName);
15176
- if (!cache) {
15177
- switch (ruleName) {
15178
- case "TrackIndented":
15179
- case "Samedent":
15180
- case "IndentedFurther":
15181
- case "PushIndent":
15182
- case "PopIndent":
15183
- case "Nested":
15184
- case "InsertIndent":
15185
- case "Arguments":
15186
- case "ArgumentsWithTrailingCallExpressions":
15187
- case "ApplicationStart":
15188
- case "CallExpression":
15189
- case "CallExpressionRest":
15190
- case "LeftHandSideExpression":
15191
- case "ActualAssignment":
15192
- case "UpdateExpression":
15193
- case "UnaryExpression":
15194
- case "BinaryOpExpression":
15195
- case "BinaryOpRHS":
15196
- case "ConditionalExpression":
15197
- case "ShortCircuitExpression":
15198
- case "ImplicitNestedBlock":
15199
- case "ObjectLiteral":
15200
- case "NestedObject":
15201
- case "NestedImplicitObjectLiteral":
15202
- case "BracedObjectLiteralContent":
15203
- case "NestedPropertyDefinitions":
15204
- case "NestedImplicitPropertyDefinition":
15205
- case "NestedImplicitPropertyDefinitions":
15206
- case "NestedBlockStatement":
15207
- case "NestedElement":
15208
- case "NestedElementList":
15209
- case "NestedBindingElement":
15210
- case "NestedBindingElements":
15211
- case "NestedInterfaceProperty":
15212
- case "MemberExpression":
15213
- case "PrimaryExpression":
15214
- case "IndentedApplicationAllowed":
15215
- case "ExpressionWithIndentedApplicationSuppressed":
15216
- case "SuppressIndentedApplication":
15217
- case "AssignmentExpressionTail":
15218
- case "AssignmentExpression":
15219
- case "ExtendedExpression":
15220
- case "Expression":
15221
- case "MemberExpressionRest":
15222
- case "ElseClause":
15223
- case "CoffeeCommentEnabled":
15224
- case "SingleLineComment":
15225
- case "Debugger":
15226
- case "JSXElement":
15227
- case "TypedJSXElement":
15228
- case "JSXFragment":
15229
- case "TypedJSXFragment":
15230
- case "JSXChild":
15231
- case "JSXChildren":
15232
- case "JSXNestedChildren":
15233
- case "JSXMixedChildren":
15234
- break;
15235
- default:
15236
- cache = /* @__PURE__ */ new Map();
15237
- caches.set(ruleName, cache);
15238
- }
15179
+ if (!cache && !uncacheable.has(ruleName)) {
15180
+ cache = /* @__PURE__ */ new Map();
15181
+ caches.set(ruleName, cache);
15239
15182
  }
15240
15183
  if (cache) {
15241
15184
  if (result) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.5.14",
3
+ "version": "0.5.15",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "exports": {