@danielx/civet 0.5.24 → 0.5.26

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/main.js CHANGED
@@ -1,18 +1,40 @@
1
1
  "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
2
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
3
8
  var __commonJS = (cb, mod) => function __require() {
4
9
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
5
10
  };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
6
28
 
7
29
  // source/parser.hera
8
30
  var require_parser = __commonJS({
9
- "source/parser.hera"(exports2, module2) {
31
+ "source/parser.hera"(exports, module2) {
10
32
  "use strict";
11
- Object.defineProperty(exports2, "__esModule", { value: true });
12
- exports2.parserState = exports2.$R$0 = exports2.$TV = exports2.$TS = exports2.$TR = exports2.$T = exports2.$Y = exports2.$N = exports2.$TOKEN = exports2.$TEXT = exports2.$P = exports2.$Q = exports2.$E = exports2.$S = exports2.$C = exports2.$R = exports2.$L = exports2.$EXPECT = void 0;
13
- function $EXPECT(parser, fail2, expectation) {
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.parserState = exports.$R$0 = exports.$TV = exports.$TS = exports.$TR = exports.$T = exports.$Y = exports.$N = exports.$TOKEN = exports.$TEXT = exports.$P = exports.$Q = exports.$E = exports.$S = exports.$C = exports.$R = exports.$L = exports.$EXPECT = void 0;
35
+ function $EXPECT(parser2, fail2, expectation) {
14
36
  return function(state) {
15
- const result = parser(state);
37
+ const result = parser2(state);
16
38
  if (result)
17
39
  return result;
18
40
  const { pos } = state;
@@ -20,7 +42,7 @@ var require_parser = __commonJS({
20
42
  return;
21
43
  };
22
44
  }
23
- exports2.$EXPECT = $EXPECT;
45
+ exports.$EXPECT = $EXPECT;
24
46
  function $L(str) {
25
47
  return function(state) {
26
48
  const { input, pos } = state;
@@ -38,7 +60,7 @@ var require_parser = __commonJS({
38
60
  return;
39
61
  };
40
62
  }
41
- exports2.$L = $L;
63
+ exports.$L = $L;
42
64
  function $R(regExp) {
43
65
  return function(state) {
44
66
  const { input, pos } = state;
@@ -59,7 +81,7 @@ var require_parser = __commonJS({
59
81
  return;
60
82
  };
61
83
  }
62
- exports2.$R = $R;
84
+ exports.$R = $R;
63
85
  function $C(...terms) {
64
86
  return (state) => {
65
87
  let i = 0;
@@ -72,7 +94,7 @@ var require_parser = __commonJS({
72
94
  return;
73
95
  };
74
96
  }
75
- exports2.$C = $C;
97
+ exports.$C = $C;
76
98
  function $S(...terms) {
77
99
  return (state) => {
78
100
  let { input, pos, tokenize, events } = state, i = 0, value;
@@ -95,7 +117,7 @@ var require_parser = __commonJS({
95
117
  };
96
118
  };
97
119
  }
98
- exports2.$S = $S;
120
+ exports.$S = $S;
99
121
  function $E(fn) {
100
122
  return (state) => {
101
123
  const r = fn(state);
@@ -112,7 +134,7 @@ var require_parser = __commonJS({
112
134
  };
113
135
  };
114
136
  }
115
- exports2.$E = $E;
137
+ exports.$E = $E;
116
138
  function $Q(fn) {
117
139
  return (state) => {
118
140
  let { input, pos, tokenize, events } = state;
@@ -140,7 +162,7 @@ var require_parser = __commonJS({
140
162
  };
141
163
  };
142
164
  }
143
- exports2.$Q = $Q;
165
+ exports.$Q = $Q;
144
166
  function $P(fn) {
145
167
  return (state) => {
146
168
  const { input, pos: s, tokenize, events } = state;
@@ -170,7 +192,7 @@ var require_parser = __commonJS({
170
192
  };
171
193
  };
172
194
  }
173
- exports2.$P = $P;
195
+ exports.$P = $P;
174
196
  function $TEXT(fn) {
175
197
  return (state) => {
176
198
  const newState = fn(state);
@@ -180,7 +202,7 @@ var require_parser = __commonJS({
180
202
  return newState;
181
203
  };
182
204
  }
183
- exports2.$TEXT = $TEXT;
205
+ exports.$TEXT = $TEXT;
184
206
  function $TOKEN(name, state, newState) {
185
207
  if (!newState)
186
208
  return;
@@ -192,7 +214,7 @@ var require_parser = __commonJS({
192
214
  };
193
215
  return newState;
194
216
  }
195
- exports2.$TOKEN = $TOKEN;
217
+ exports.$TOKEN = $TOKEN;
196
218
  function $N(fn) {
197
219
  return (state) => {
198
220
  const newState = fn(state);
@@ -208,7 +230,7 @@ var require_parser = __commonJS({
208
230
  };
209
231
  };
210
232
  }
211
- exports2.$N = $N;
233
+ exports.$N = $N;
212
234
  function $Y(fn) {
213
235
  return (state) => {
214
236
  const newState = fn(state);
@@ -224,10 +246,10 @@ var require_parser = __commonJS({
224
246
  };
225
247
  };
226
248
  }
227
- exports2.$Y = $Y;
228
- function $T(parser, fn) {
249
+ exports.$Y = $Y;
250
+ function $T(parser2, fn) {
229
251
  return function(state) {
230
- const result = parser(state);
252
+ const result = parser2(state);
231
253
  if (!result)
232
254
  return;
233
255
  if (state.tokenize)
@@ -238,10 +260,10 @@ var require_parser = __commonJS({
238
260
  return result;
239
261
  };
240
262
  }
241
- exports2.$T = $T;
242
- function $TR(parser, fn) {
263
+ exports.$T = $T;
264
+ function $TR(parser2, fn) {
243
265
  return function(state) {
244
- const result = parser(state);
266
+ const result = parser2(state);
245
267
  if (!result)
246
268
  return;
247
269
  if (state.tokenize)
@@ -255,10 +277,10 @@ var require_parser = __commonJS({
255
277
  return result;
256
278
  };
257
279
  }
258
- exports2.$TR = $TR;
259
- function $TS(parser, fn) {
280
+ exports.$TR = $TR;
281
+ function $TS(parser2, fn) {
260
282
  return function(state) {
261
- const result = parser(state);
283
+ const result = parser2(state);
262
284
  if (!result)
263
285
  return;
264
286
  if (state.tokenize)
@@ -272,10 +294,10 @@ var require_parser = __commonJS({
272
294
  return result;
273
295
  };
274
296
  }
275
- exports2.$TS = $TS;
276
- function $TV(parser, fn) {
297
+ exports.$TS = $TS;
298
+ function $TV(parser2, fn) {
277
299
  return function(state) {
278
- const result = parser(state);
300
+ const result = parser2(state);
279
301
  if (!result)
280
302
  return;
281
303
  if (state.tokenize)
@@ -289,10 +311,10 @@ var require_parser = __commonJS({
289
311
  return result;
290
312
  };
291
313
  }
292
- exports2.$TV = $TV;
293
- function $R$0(parser) {
314
+ exports.$TV = $TV;
315
+ function $R$0(parser2) {
294
316
  return function(state) {
295
- const result = parser(state);
317
+ const result = parser2(state);
296
318
  if (!result)
297
319
  return;
298
320
  const value = result.value[0];
@@ -300,7 +322,7 @@ var require_parser = __commonJS({
300
322
  return result;
301
323
  };
302
324
  }
303
- exports2.$R$0 = $R$0;
325
+ exports.$R$0 = $R$0;
304
326
  var SKIP = {};
305
327
  var failHintRegex = /\S+|\s+|$/y;
306
328
  var failExpected = Array(16);
@@ -373,14 +395,14 @@ ${input.slice(result.pos)}
373
395
  parse: (input, options = {}) => {
374
396
  if (typeof input !== "string")
375
397
  throw new Error("Input must be a string");
376
- const parser = options.startRule != null ? grammar[options.startRule] : Object.values(grammar)[0];
377
- if (!parser)
398
+ const parser2 = options.startRule != null ? grammar[options.startRule] : Object.values(grammar)[0];
399
+ if (!parser2)
378
400
  throw new Error("Could not find rule with name '#{opts.startRule}'");
379
401
  const filename = options.filename || "<anonymous>";
380
402
  failIndex = 0;
381
403
  maxFailPos = 0;
382
404
  failExpected.length = 0;
383
- return validate(input, parser({
405
+ return validate(input, parser2({
384
406
  input,
385
407
  pos: 0,
386
408
  tokenize: options.tokenize || false,
@@ -391,7 +413,7 @@ ${input.slice(result.pos)}
391
413
  }
392
414
  };
393
415
  }
394
- exports2.parserState = parserState;
416
+ exports.parserState = parserState;
395
417
  var { parse: parse2 } = parserState({
396
418
  Program,
397
419
  TopLevelStatement,
@@ -770,12 +792,12 @@ ${input.slice(result.pos)}
770
792
  When,
771
793
  While,
772
794
  Yield,
773
- TypedJSXElement,
795
+ JSXImplicitFragment,
796
+ JSXTag,
774
797
  JSXElement,
775
798
  JSXSelfClosingElement,
776
799
  JSXOpeningElement,
777
800
  JSXClosingElement,
778
- TypedJSXFragment,
779
801
  JSXFragment,
780
802
  JSXElementName,
781
803
  JSXIdentifierName,
@@ -804,6 +826,8 @@ ${input.slice(result.pos)}
804
826
  JSXCommentContent,
805
827
  JSXText,
806
828
  JSXChildExpression,
829
+ IndentedJSXChildExpression,
830
+ NestedJSXChildExpression,
807
831
  TypeDeclaration,
808
832
  TypeDeclarationModifier,
809
833
  TypeDeclarationRest,
@@ -1064,7 +1088,7 @@ ${input.slice(result.pos)}
1064
1088
  var $R1 = $R(new RegExp("[&]", "suy"));
1065
1089
  var $R2 = $R(new RegExp("[!~+-]+", "suy"));
1066
1090
  var $R3 = $R(new RegExp("(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$])*", "suy"));
1067
- var $R4 = $R(new RegExp("[+-]", "suy"));
1091
+ var $R4 = $R(new RegExp("[!+-]", "suy"));
1068
1092
  var $R5 = $R(new RegExp("<(?!\\p{ID_Start}|[_$])", "suy"));
1069
1093
  var $R6 = $R(new RegExp("[!~+-](?!\\s|[!~+-]*&)", "suy"));
1070
1094
  var $R7 = $R(new RegExp("(?=[\\s\\)])", "suy"));
@@ -1111,12 +1135,13 @@ ${input.slice(result.pos)}
1111
1135
  var $R48 = $R(new RegExp("(?:-[^-]|[^-]*)*", "suy"));
1112
1136
  var $R49 = $R(new RegExp("[^{}<>\\r\\n]+", "suy"));
1113
1137
  var $R50 = $R(new RegExp("[+-]?", "suy"));
1114
- var $R51 = $R(new RegExp("#![^\\r\\n]*", "suy"));
1115
- var $R52 = $R(new RegExp("[\\t ]*", "suy"));
1116
- var $R53 = $R(new RegExp("[\\s]*", "suy"));
1117
- var $R54 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
1118
- var $R55 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
1119
- var $R56 = $R(new RegExp("[ \\t]*", "suy"));
1138
+ var $R51 = $R(new RegExp("[+-]", "suy"));
1139
+ var $R52 = $R(new RegExp("#![^\\r\\n]*", "suy"));
1140
+ var $R53 = $R(new RegExp("[\\t ]*", "suy"));
1141
+ var $R54 = $R(new RegExp("[\\s]*", "suy"));
1142
+ var $R55 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
1143
+ var $R56 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
1144
+ var $R57 = $R(new RegExp("[ \\t]*", "suy"));
1120
1145
  var Program$0 = $TS($S(Reset, Init, __, $Q(TopLevelStatement), __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
1121
1146
  var statements = $4;
1122
1147
  module2.processProgram(statements);
@@ -2137,8 +2162,7 @@ ${input.slice(result.pos)}
2137
2162
  var PrimaryExpression$7 = RegularExpressionLiteral;
2138
2163
  var PrimaryExpression$8 = TemplateLiteral;
2139
2164
  var PrimaryExpression$9 = ParenthesizedExpression;
2140
- var PrimaryExpression$10 = TypedJSXElement;
2141
- var PrimaryExpression$11 = TypedJSXFragment;
2165
+ var PrimaryExpression$10 = JSXImplicitFragment;
2142
2166
  function PrimaryExpression(state) {
2143
2167
  if (state.events) {
2144
2168
  const result = state.events.enter?.("PrimaryExpression", state);
@@ -2146,12 +2170,12 @@ ${input.slice(result.pos)}
2146
2170
  return result.cache;
2147
2171
  }
2148
2172
  if (state.tokenize) {
2149
- const result = $TOKEN("PrimaryExpression", state, PrimaryExpression$0(state) || PrimaryExpression$1(state) || PrimaryExpression$2(state) || PrimaryExpression$3(state) || PrimaryExpression$4(state) || PrimaryExpression$5(state) || PrimaryExpression$6(state) || PrimaryExpression$7(state) || PrimaryExpression$8(state) || PrimaryExpression$9(state) || PrimaryExpression$10(state) || PrimaryExpression$11(state));
2173
+ const result = $TOKEN("PrimaryExpression", state, PrimaryExpression$0(state) || PrimaryExpression$1(state) || PrimaryExpression$2(state) || PrimaryExpression$3(state) || PrimaryExpression$4(state) || PrimaryExpression$5(state) || PrimaryExpression$6(state) || PrimaryExpression$7(state) || PrimaryExpression$8(state) || PrimaryExpression$9(state) || PrimaryExpression$10(state));
2150
2174
  if (state.events)
2151
2175
  state.events.exit?.("PrimaryExpression", state, result);
2152
2176
  return result;
2153
2177
  } else {
2154
- const result = PrimaryExpression$0(state) || PrimaryExpression$1(state) || PrimaryExpression$2(state) || PrimaryExpression$3(state) || PrimaryExpression$4(state) || PrimaryExpression$5(state) || PrimaryExpression$6(state) || PrimaryExpression$7(state) || PrimaryExpression$8(state) || PrimaryExpression$9(state) || PrimaryExpression$10(state) || PrimaryExpression$11(state);
2178
+ const result = PrimaryExpression$0(state) || PrimaryExpression$1(state) || PrimaryExpression$2(state) || PrimaryExpression$3(state) || PrimaryExpression$4(state) || PrimaryExpression$5(state) || PrimaryExpression$6(state) || PrimaryExpression$7(state) || PrimaryExpression$8(state) || PrimaryExpression$9(state) || PrimaryExpression$10(state);
2155
2179
  if (state.events)
2156
2180
  state.events.exit?.("PrimaryExpression", state, result);
2157
2181
  return result;
@@ -2311,7 +2335,14 @@ ${input.slice(result.pos)}
2311
2335
  return result;
2312
2336
  }
2313
2337
  }
2314
- var ExtendsTarget$0 = $S(LeftHandSideExpression, $E(TypeArguments));
2338
+ var ExtendsTarget$0 = $TS($S(ExpressionWithIndentedApplicationSuppressed, $E(TypeArguments)), function($skip, $loc, $0, $1, $2) {
2339
+ var exp = $1;
2340
+ var ta = $2;
2341
+ exp = module2.makeLeftHandSideExpression(exp);
2342
+ if (ta)
2343
+ return [exp, ta];
2344
+ return exp;
2345
+ });
2315
2346
  function ExtendsTarget(state) {
2316
2347
  if (state.events) {
2317
2348
  const result = state.events.enter?.("ExtendsTarget", state);
@@ -2618,10 +2649,19 @@ ${input.slice(result.pos)}
2618
2649
  }
2619
2650
  }
2620
2651
  var CallExpression$0 = $S($EXPECT($L10, fail, 'CallExpression "super"'), ArgumentsWithTrailingCallExpressions, $Q(CallExpressionRest));
2621
- var CallExpression$1 = $S($EXPECT($L11, fail, 'CallExpression "import"'), ArgumentsWithTrailingCallExpressions, $Q(CallExpressionRest));
2652
+ var CallExpression$1 = $TS($S($EXPECT($L11, fail, 'CallExpression "import"'), ArgumentsWithTrailingCallExpressions, $Q(CallExpressionRest)), function($skip, $loc, $0, $1, $2, $3) {
2653
+ return {
2654
+ type: "CallExpression",
2655
+ children: $0
2656
+ };
2657
+ });
2622
2658
  var CallExpression$2 = $TS($S(MemberExpression, $Q(CallExpressionRest)), function($skip, $loc, $0, $1, $2) {
2623
- if ($2.length)
2624
- return $0;
2659
+ if ($2.length) {
2660
+ return {
2661
+ type: "CallExpression",
2662
+ children: [$1].concat($2)
2663
+ };
2664
+ }
2625
2665
  return $1;
2626
2666
  });
2627
2667
  function CallExpression(state) {
@@ -2724,8 +2764,13 @@ ${input.slice(result.pos)}
2724
2764
  }
2725
2765
  }
2726
2766
  var MemberExpression$0 = $TS($S(PrimaryExpression, $Q(MemberExpressionRest)), function($skip, $loc, $0, $1, $2) {
2727
- if ($2.length)
2728
- return $0;
2767
+ var rest = $2;
2768
+ if (rest.length) {
2769
+ return {
2770
+ type: "MemberExpression",
2771
+ children: [$1].concat(rest)
2772
+ };
2773
+ }
2729
2774
  return $1;
2730
2775
  });
2731
2776
  var MemberExpression$1 = SuperProperty;
@@ -4734,7 +4779,8 @@ ${input.slice(result.pos)}
4734
4779
  return result;
4735
4780
  }
4736
4781
  }
4737
- var ArrayElementExpression$0 = $TS($S($E(ExtendedExpression), __, DotDotDot, $Y(ArrayElementDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
4782
+ var ArrayElementExpression$0 = JSXTag;
4783
+ var ArrayElementExpression$1 = $TS($S($E(ExtendedExpression), __, DotDotDot, $Y(ArrayElementDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
4738
4784
  var exp = $1;
4739
4785
  var ws = $2;
4740
4786
  var dots = $3;
@@ -4752,7 +4798,7 @@ ${input.slice(result.pos)}
4752
4798
  names: exp.names
4753
4799
  };
4754
4800
  });
4755
- var ArrayElementExpression$1 = $TS($S($E($S($E($S(__, DotDotDot, __)), ExtendedExpression)), $Y(ArrayElementDelimiter)), function($skip, $loc, $0, $1, $2) {
4801
+ var ArrayElementExpression$2 = $TS($S($E($S($E($S(__, DotDotDot, __)), ExtendedExpression)), $Y(ArrayElementDelimiter)), function($skip, $loc, $0, $1, $2) {
4756
4802
  var expMaybeSpread = $1;
4757
4803
  if (expMaybeSpread) {
4758
4804
  const [spread, exp] = expMaybeSpread;
@@ -4782,12 +4828,12 @@ ${input.slice(result.pos)}
4782
4828
  return result.cache;
4783
4829
  }
4784
4830
  if (state.tokenize) {
4785
- const result = $TOKEN("ArrayElementExpression", state, ArrayElementExpression$0(state) || ArrayElementExpression$1(state));
4831
+ const result = $TOKEN("ArrayElementExpression", state, ArrayElementExpression$0(state) || ArrayElementExpression$1(state) || ArrayElementExpression$2(state));
4786
4832
  if (state.events)
4787
4833
  state.events.exit?.("ArrayElementExpression", state, result);
4788
4834
  return result;
4789
4835
  } else {
4790
- const result = ArrayElementExpression$0(state) || ArrayElementExpression$1(state);
4836
+ const result = ArrayElementExpression$0(state) || ArrayElementExpression$1(state) || ArrayElementExpression$2(state);
4791
4837
  if (state.events)
4792
4838
  state.events.exit?.("ArrayElementExpression", state, result);
4793
4839
  return result;
@@ -5113,7 +5159,7 @@ ${input.slice(result.pos)}
5113
5159
  value
5114
5160
  };
5115
5161
  });
5116
- var PropertyDefinition$1 = $TS($S(__, $TEXT($EXPECT($R4, fail, "PropertyDefinition /[+-]/")), IdentifierName), function($skip, $loc, $0, $1, $2, $3) {
5162
+ var PropertyDefinition$1 = $TS($S(__, $TEXT($EXPECT($R4, fail, "PropertyDefinition /[!+-]/")), IdentifierName), function($skip, $loc, $0, $1, $2, $3) {
5117
5163
  var ws = $1;
5118
5164
  var toggle = $2;
5119
5165
  var id = $3;
@@ -6098,7 +6144,7 @@ ${input.slice(result.pos)}
6098
6144
  children: [$1, exps, $3, $4, $5]
6099
6145
  };
6100
6146
  });
6101
- var ElseExpressionBlock$1 = $T($S($N(EOS), ExtendedExpression), function(value) {
6147
+ var ElseExpressionBlock$1 = $T($S($N(EOS), ExpressionWithIndentedApplicationSuppressed), function(value) {
6102
6148
  return value[1];
6103
6149
  });
6104
6150
  function ElseExpressionBlock(state) {
@@ -10958,29 +11004,62 @@ ${input.slice(result.pos)}
10958
11004
  return result;
10959
11005
  }
10960
11006
  }
10961
- var TypedJSXElement$0 = $TS($S(JSXElement), function($skip, $loc, $0, $1) {
10962
- const type = module2.typeOfJSXElement($1);
11007
+ var JSXImplicitFragment$0 = $TS($S(JSXTag, $Q($S(Samedent, JSXTag))), function($skip, $loc, $0, $1, $2) {
11008
+ const jsx = $2.length === 0 ? $1 : {
11009
+ type: "JSXFragment",
11010
+ children: [
11011
+ "<>\n",
11012
+ module2.currentIndent.token,
11013
+ ...$0,
11014
+ "\n",
11015
+ module2.currentIndent.token,
11016
+ "</>"
11017
+ ],
11018
+ jsxChildren: [$1].concat($2.map(([, tag]) => tag))
11019
+ };
11020
+ const type = module2.typeOfJSX(jsx);
10963
11021
  return type ? [
10964
11022
  { ts: true, children: ["("] },
10965
- $1,
11023
+ jsx,
10966
11024
  { ts: true, children: [" as any as ", type, ")"] }
10967
- ] : $1;
11025
+ ] : jsx;
10968
11026
  });
10969
- function TypedJSXElement(state) {
11027
+ function JSXImplicitFragment(state) {
10970
11028
  if (state.events) {
10971
- const result = state.events.enter?.("TypedJSXElement", state);
11029
+ const result = state.events.enter?.("JSXImplicitFragment", state);
10972
11030
  if (result)
10973
11031
  return result.cache;
10974
11032
  }
10975
11033
  if (state.tokenize) {
10976
- const result = $TOKEN("TypedJSXElement", state, TypedJSXElement$0(state));
11034
+ const result = $TOKEN("JSXImplicitFragment", state, JSXImplicitFragment$0(state));
10977
11035
  if (state.events)
10978
- state.events.exit?.("TypedJSXElement", state, result);
11036
+ state.events.exit?.("JSXImplicitFragment", state, result);
10979
11037
  return result;
10980
11038
  } else {
10981
- const result = TypedJSXElement$0(state);
11039
+ const result = JSXImplicitFragment$0(state);
10982
11040
  if (state.events)
10983
- state.events.exit?.("TypedJSXElement", state, result);
11041
+ state.events.exit?.("JSXImplicitFragment", state, result);
11042
+ return result;
11043
+ }
11044
+ }
11045
+ var JSXTag$0 = JSXElement;
11046
+ var JSXTag$1 = JSXFragment;
11047
+ var JSXTag$2 = JSXComment;
11048
+ function JSXTag(state) {
11049
+ if (state.events) {
11050
+ const result = state.events.enter?.("JSXTag", state);
11051
+ if (result)
11052
+ return result.cache;
11053
+ }
11054
+ if (state.tokenize) {
11055
+ const result = $TOKEN("JSXTag", state, JSXTag$0(state) || JSXTag$1(state) || JSXTag$2(state));
11056
+ if (state.events)
11057
+ state.events.exit?.("JSXTag", state, result);
11058
+ return result;
11059
+ } else {
11060
+ const result = JSXTag$0(state) || JSXTag$1(state) || JSXTag$2(state);
11061
+ if (state.events)
11062
+ state.events.exit?.("JSXTag", state, result);
10984
11063
  return result;
10985
11064
  }
10986
11065
  }
@@ -11079,32 +11158,6 @@ ${input.slice(result.pos)}
11079
11158
  return result;
11080
11159
  }
11081
11160
  }
11082
- var TypedJSXFragment$0 = $TS($S(JSXFragment), function($skip, $loc, $0, $1) {
11083
- const type = module2.typeOfJSXFragment($1);
11084
- return type ? [
11085
- { ts: true, children: ["("] },
11086
- $1,
11087
- { ts: true, children: [" as any as ", type, ")"] }
11088
- ] : $1;
11089
- });
11090
- function TypedJSXFragment(state) {
11091
- if (state.events) {
11092
- const result = state.events.enter?.("TypedJSXFragment", state);
11093
- if (result)
11094
- return result.cache;
11095
- }
11096
- if (state.tokenize) {
11097
- const result = $TOKEN("TypedJSXFragment", state, TypedJSXFragment$0(state));
11098
- if (state.events)
11099
- state.events.exit?.("TypedJSXFragment", state, result);
11100
- return result;
11101
- } else {
11102
- const result = TypedJSXFragment$0(state);
11103
- if (state.events)
11104
- state.events.exit?.("TypedJSXFragment", state, result);
11105
- return result;
11106
- }
11107
- }
11108
11161
  var JSXFragment$0 = $TS($S($EXPECT($L156, fail, 'JSXFragment "<>"'), $E(JSXChildren), $E(Whitespace), $EXPECT($L157, fail, 'JSXFragment "</>"')), function($skip, $loc, $0, $1, $2, $3, $4) {
11109
11162
  if ($2) {
11110
11163
  return { type: "JSXFragment", children: $0, jsxChildren: $2.jsxChildren };
@@ -11332,6 +11385,12 @@ ${input.slice(result.pos)}
11332
11385
  class: $2
11333
11386
  };
11334
11387
  });
11388
+ var JSXAttribute$5 = $TS($S($TEXT($EXPECT($R4, fail, "JSXAttribute /[!+-]/")), JSXAttributeName), function($skip, $loc, $0, $1, $2) {
11389
+ var toggle = $1;
11390
+ var id = $2;
11391
+ const value = toggle === "+" ? "true" : "false";
11392
+ return [" ", id, "={", value, "}"];
11393
+ });
11335
11394
  function JSXAttribute(state) {
11336
11395
  if (state.events) {
11337
11396
  const result = state.events.enter?.("JSXAttribute", state);
@@ -11339,12 +11398,12 @@ ${input.slice(result.pos)}
11339
11398
  return result.cache;
11340
11399
  }
11341
11400
  if (state.tokenize) {
11342
- const result = $TOKEN("JSXAttribute", state, JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state) || JSXAttribute$3(state) || JSXAttribute$4(state));
11401
+ const result = $TOKEN("JSXAttribute", state, JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state) || JSXAttribute$3(state) || JSXAttribute$4(state) || JSXAttribute$5(state));
11343
11402
  if (state.events)
11344
11403
  state.events.exit?.("JSXAttribute", state, result);
11345
11404
  return result;
11346
11405
  } else {
11347
- const result = JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state) || JSXAttribute$3(state) || JSXAttribute$4(state);
11406
+ const result = JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state) || JSXAttribute$3(state) || JSXAttribute$4(state) || JSXAttribute$5(state);
11348
11407
  if (state.events)
11349
11408
  state.events.exit?.("JSXAttribute", state, result);
11350
11409
  return result;
@@ -11792,7 +11851,15 @@ ${input.slice(result.pos)}
11792
11851
  var JSXChild$0 = JSXElement;
11793
11852
  var JSXChild$1 = JSXFragment;
11794
11853
  var JSXChild$2 = JSXComment;
11795
- var JSXChild$3 = $TS($S(OpenBrace, $E(JSXChildExpression), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
11854
+ var JSXChild$3 = $TS($S(OpenBrace, IndentedJSXChildExpression, __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
11855
+ var expression = $2;
11856
+ return {
11857
+ type: "JSXChildExpression",
11858
+ children: $0,
11859
+ expression
11860
+ };
11861
+ });
11862
+ var JSXChild$4 = $TS($S(OpenBrace, $E(JSXChildExpression), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
11796
11863
  var expression = $2;
11797
11864
  return {
11798
11865
  type: "JSXChildExpression",
@@ -11800,7 +11867,7 @@ ${input.slice(result.pos)}
11800
11867
  expression
11801
11868
  };
11802
11869
  });
11803
- var JSXChild$4 = $TS($S(InsertInlineOpenBrace, ArrowFunction, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
11870
+ var JSXChild$5 = $TS($S(InsertInlineOpenBrace, ArrowFunction, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
11804
11871
  var expression = $2;
11805
11872
  return {
11806
11873
  type: "JSXChildExpression",
@@ -11808,7 +11875,7 @@ ${input.slice(result.pos)}
11808
11875
  expression
11809
11876
  };
11810
11877
  });
11811
- var JSXChild$5 = JSXText;
11878
+ var JSXChild$6 = JSXText;
11812
11879
  function JSXChild(state) {
11813
11880
  if (state.events) {
11814
11881
  const result = state.events.enter?.("JSXChild", state);
@@ -11816,12 +11883,12 @@ ${input.slice(result.pos)}
11816
11883
  return result.cache;
11817
11884
  }
11818
11885
  if (state.tokenize) {
11819
- const result = $TOKEN("JSXChild", state, JSXChild$0(state) || JSXChild$1(state) || JSXChild$2(state) || JSXChild$3(state) || JSXChild$4(state) || JSXChild$5(state));
11886
+ const result = $TOKEN("JSXChild", state, JSXChild$0(state) || JSXChild$1(state) || JSXChild$2(state) || JSXChild$3(state) || JSXChild$4(state) || JSXChild$5(state) || JSXChild$6(state));
11820
11887
  if (state.events)
11821
11888
  state.events.exit?.("JSXChild", state, result);
11822
11889
  return result;
11823
11890
  } else {
11824
- const result = JSXChild$0(state) || JSXChild$1(state) || JSXChild$2(state) || JSXChild$3(state) || JSXChild$4(state) || JSXChild$5(state);
11891
+ const result = JSXChild$0(state) || JSXChild$1(state) || JSXChild$2(state) || JSXChild$3(state) || JSXChild$4(state) || JSXChild$5(state) || JSXChild$6(state);
11825
11892
  if (state.events)
11826
11893
  state.events.exit?.("JSXChild", state, result);
11827
11894
  return result;
@@ -11913,6 +11980,48 @@ ${input.slice(result.pos)}
11913
11980
  return result;
11914
11981
  }
11915
11982
  }
11983
+ var IndentedJSXChildExpression$0 = $TS($S(PushIndent, $E(NestedJSXChildExpression), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
11984
+ if (!$2)
11985
+ return $skip;
11986
+ return $2;
11987
+ });
11988
+ function IndentedJSXChildExpression(state) {
11989
+ if (state.events) {
11990
+ const result = state.events.enter?.("IndentedJSXChildExpression", state);
11991
+ if (result)
11992
+ return result.cache;
11993
+ }
11994
+ if (state.tokenize) {
11995
+ const result = $TOKEN("IndentedJSXChildExpression", state, IndentedJSXChildExpression$0(state));
11996
+ if (state.events)
11997
+ state.events.exit?.("IndentedJSXChildExpression", state, result);
11998
+ return result;
11999
+ } else {
12000
+ const result = IndentedJSXChildExpression$0(state);
12001
+ if (state.events)
12002
+ state.events.exit?.("IndentedJSXChildExpression", state, result);
12003
+ return result;
12004
+ }
12005
+ }
12006
+ var NestedJSXChildExpression$0 = $S(Nested, JSXChildExpression);
12007
+ function NestedJSXChildExpression(state) {
12008
+ if (state.events) {
12009
+ const result = state.events.enter?.("NestedJSXChildExpression", state);
12010
+ if (result)
12011
+ return result.cache;
12012
+ }
12013
+ if (state.tokenize) {
12014
+ const result = $TOKEN("NestedJSXChildExpression", state, NestedJSXChildExpression$0(state));
12015
+ if (state.events)
12016
+ state.events.exit?.("NestedJSXChildExpression", state, result);
12017
+ return result;
12018
+ } else {
12019
+ const result = NestedJSXChildExpression$0(state);
12020
+ if (state.events)
12021
+ state.events.exit?.("NestedJSXChildExpression", state, result);
12022
+ return result;
12023
+ }
12024
+ }
11916
12025
  var TypeDeclaration$0 = $T($S($Q($S(TypeDeclarationModifier, $Q(TrailingComment))), TypeDeclarationRest), function(value) {
11917
12026
  return { "ts": true, "children": value };
11918
12027
  });
@@ -12203,7 +12312,7 @@ ${input.slice(result.pos)}
12203
12312
  return result;
12204
12313
  }
12205
12314
  }
12206
- var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R50, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L130, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R4, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
12315
+ var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R50, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L130, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R51, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
12207
12316
  function TypeIndexSignature(state) {
12208
12317
  if (state.events) {
12209
12318
  const result = state.events.enter?.("TypeIndexSignature", state);
@@ -12805,7 +12914,7 @@ ${input.slice(result.pos)}
12805
12914
  return result;
12806
12915
  }
12807
12916
  }
12808
- var Shebang$0 = $S($R$0($EXPECT($R51, fail, "Shebang /#![^\\r\\n]*/")), EOL);
12917
+ var Shebang$0 = $S($R$0($EXPECT($R52, fail, "Shebang /#![^\\r\\n]*/")), EOL);
12809
12918
  function Shebang(state) {
12810
12919
  if (state.events) {
12811
12920
  const result = state.events.enter?.("Shebang", state);
@@ -12824,11 +12933,11 @@ ${input.slice(result.pos)}
12824
12933
  return result;
12825
12934
  }
12826
12935
  }
12827
- var CivetPrologue$0 = $T($S($EXPECT($R52, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(StatementDelimiter), $E(EOS)), function(value) {
12936
+ var CivetPrologue$0 = $T($S($EXPECT($R53, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(StatementDelimiter), $E(EOS)), function(value) {
12828
12937
  var content = value[2];
12829
12938
  return content;
12830
12939
  });
12831
- var CivetPrologue$1 = $T($S($EXPECT($R52, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(StatementDelimiter), $E(EOS)), function(value) {
12940
+ var CivetPrologue$1 = $T($S($EXPECT($R53, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(StatementDelimiter), $E(EOS)), function(value) {
12832
12941
  var content = value[2];
12833
12942
  return content;
12834
12943
  });
@@ -12850,7 +12959,7 @@ ${input.slice(result.pos)}
12850
12959
  return result;
12851
12960
  }
12852
12961
  }
12853
- var CivetPrologueContent$0 = $TS($S($EXPECT($L168, fail, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R53, fail, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12962
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L168, fail, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R54, fail, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12854
12963
  var options = $3;
12855
12964
  return {
12856
12965
  type: "CivetPrologue",
@@ -12876,7 +12985,7 @@ ${input.slice(result.pos)}
12876
12985
  return result;
12877
12986
  }
12878
12987
  }
12879
- var CivetOption$0 = $TR($EXPECT($R54, fail, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12988
+ var CivetOption$0 = $TR($EXPECT($R55, fail, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12880
12989
  const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
12881
12990
  if (l)
12882
12991
  return l.toUpperCase();
@@ -12908,7 +13017,7 @@ ${input.slice(result.pos)}
12908
13017
  return result;
12909
13018
  }
12910
13019
  }
12911
- var UnknownPrologue$0 = $S($R$0($EXPECT($R52, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(StatementDelimiter), EOS);
13020
+ var UnknownPrologue$0 = $S($R$0($EXPECT($R53, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(StatementDelimiter), EOS);
12912
13021
  function UnknownPrologue(state) {
12913
13022
  if (state.events) {
12914
13023
  const result = state.events.enter?.("UnknownPrologue", state);
@@ -12966,7 +13075,7 @@ ${input.slice(result.pos)}
12966
13075
  return result;
12967
13076
  }
12968
13077
  }
12969
- var EOL$0 = $TR($EXPECT($R55, fail, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
13078
+ var EOL$0 = $TR($EXPECT($R56, fail, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12970
13079
  return { $loc, token: $0 };
12971
13080
  });
12972
13081
  function EOL(state) {
@@ -13683,12 +13792,20 @@ ${input.slice(result.pos)}
13683
13792
  declareRef[base](ref);
13684
13793
  return refs[base] = ref;
13685
13794
  };
13686
- module2.typeOfJSXElement = function($12) {
13795
+ module2.typeOfJSX = function(node) {
13796
+ switch (node.type) {
13797
+ case "JSXElement":
13798
+ return module2.typeOfJSXElement(node);
13799
+ case "JSXFragment":
13800
+ return module2.typeOfJSXFragment(node);
13801
+ }
13802
+ };
13803
+ module2.typeOfJSXElement = function(node) {
13687
13804
  if (module2.config.solid) {
13688
13805
  if (module2.config.server && !module2.config.client) {
13689
13806
  return ["string"];
13690
13807
  }
13691
- let open = $12.children;
13808
+ let open = node.children;
13692
13809
  while (Array.isArray(open[0]))
13693
13810
  open = open[0];
13694
13811
  open = open[1];
@@ -13700,11 +13817,11 @@ ${input.slice(result.pos)}
13700
13817
  }
13701
13818
  }
13702
13819
  };
13703
- module2.typeOfJSXFragment = function($12) {
13820
+ module2.typeOfJSXFragment = function(node) {
13704
13821
  if (module2.config.solid) {
13705
13822
  let type = [];
13706
13823
  let lastType;
13707
- for (let child of $12.jsxChildren) {
13824
+ for (let child of node.jsxChildren) {
13708
13825
  switch (child.type) {
13709
13826
  case "JSXText":
13710
13827
  if (lastType !== "JSXText") {
@@ -14078,6 +14195,21 @@ ${input.slice(result.pos)}
14078
14195
  return;
14079
14196
  node.splice(1, 0, "return ");
14080
14197
  }
14198
+ module2.makeLeftHandSideExpression = function(exp) {
14199
+ switch (exp.type) {
14200
+ case "Identifier":
14201
+ case "Literal":
14202
+ case "CallExpression":
14203
+ case "MemberExpression":
14204
+ case "ParenthesizedExpression":
14205
+ return exp;
14206
+ default:
14207
+ return {
14208
+ type: "ParenthesizedExpression",
14209
+ children: ["(", exp, ")"]
14210
+ };
14211
+ }
14212
+ };
14081
14213
  module2.isWhitespaceOrEmpty = function(node) {
14082
14214
  if (!node)
14083
14215
  return true;
@@ -14446,31 +14578,29 @@ ${input.slice(result.pos)}
14446
14578
  const lastAssignment = $12[i];
14447
14579
  if (lastAssignment[3].token === "=") {
14448
14580
  const lhs = lastAssignment[1];
14449
- if (Array.isArray(lhs) && lhs.length > 1) {
14450
- const props = lhs[lhs.length - 1];
14451
- if (Array.isArray(props)) {
14452
- const lastProp = props[props.length - 1];
14453
- if (lastProp.type === "SliceExpression") {
14454
- const { start, end, children: c } = lastProp;
14455
- c[0].token = ".splice(";
14456
- c[1] = start;
14457
- c[2] = ", ";
14458
- if (end)
14459
- c[3] = [end, " - ", start];
14460
- else
14461
- c[3] = ["1/0"];
14462
- c[4] = [", ...", $22];
14463
- c[5] = ")";
14581
+ if (lhs.type === "MemberExpression") {
14582
+ const members = lhs.children;
14583
+ const lastMember = members[members.length - 1];
14584
+ if (lastMember.type === "SliceExpression") {
14585
+ const { start, end, children: c } = lastMember;
14586
+ c[0].token = ".splice(";
14587
+ c[1] = start;
14588
+ c[2] = ", ";
14589
+ if (end)
14590
+ c[3] = [end, " - ", start];
14591
+ else
14592
+ c[3] = ["1/0"];
14593
+ c[4] = [", ...", $22];
14594
+ c[5] = ")";
14595
+ lastAssignment.pop();
14596
+ if (module2.isWhitespaceOrEmpty(lastAssignment[2]))
14464
14597
  lastAssignment.pop();
14465
- if (module2.isWhitespaceOrEmpty(lastAssignment[2]))
14466
- lastAssignment.pop();
14467
- if ($12.length > 1) {
14468
- throw new Error("Not implemented yet! TODO: Handle multiple splice assignments");
14469
- }
14470
- exp.children = [$12];
14471
- exp.names = [];
14472
- return;
14598
+ if ($12.length > 1) {
14599
+ throw new Error("Not implemented yet! TODO: Handle multiple splice assignments");
14473
14600
  }
14601
+ exp.children = [$12];
14602
+ exp.names = [];
14603
+ return;
14474
14604
  }
14475
14605
  } else if (lhs.type === "ObjectBindingPattern" || lhs.type === "ArrayBindingPattern") {
14476
14606
  processBindingPatternLHS(lhs, tail);
@@ -14768,7 +14898,7 @@ ${input.slice(result.pos)}
14768
14898
  return result;
14769
14899
  }
14770
14900
  }
14771
- var Indent$0 = $TR($EXPECT($R56, fail, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
14901
+ var Indent$0 = $TR($EXPECT($R57, fail, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
14772
14902
  let level;
14773
14903
  if (module2.config.tab) {
14774
14904
  const tabs = $0.match(/\t/g);
@@ -14961,470 +15091,463 @@ ${input.slice(result.pos)}
14961
15091
  return result;
14962
15092
  }
14963
15093
  }
14964
- exports2.parse = parse2;
14965
- exports2.default = { parse: parse2 };
15094
+ exports.parse = parse2;
15095
+ exports.default = { parse: parse2 };
14966
15096
  }
14967
15097
  });
14968
15098
 
15099
+ // source/main.coffee
15100
+ var main_exports = {};
15101
+ __export(main_exports, {
15102
+ compile: () => compile,
15103
+ default: () => main_default,
15104
+ generate: () => generate_default,
15105
+ parse: () => parse,
15106
+ util: () => util_exports
15107
+ });
15108
+ module.exports = __toCommonJS(main_exports);
15109
+ var import_parser = __toESM(require_parser());
15110
+
14969
15111
  // source/generate.coffee
14970
- var require_generate = __commonJS({
14971
- "source/generate.coffee"(exports2, module2) {
14972
- "civet coffeeCompat";
14973
- var gen2;
14974
- var prune2;
14975
- gen2 = function(node, options) {
14976
- var $loc, token;
14977
- if (node === null || node === void 0) {
14978
- return "";
14979
- }
14980
- if (typeof node === "string") {
14981
- if (options != null) {
14982
- if (typeof options.updateSourceMap === "function") {
14983
- options.updateSourceMap(node);
14984
- }
14985
- }
14986
- return node;
14987
- }
14988
- if (Array.isArray(node)) {
14989
- return node.map(function(child) {
14990
- return gen2(child, options);
14991
- }).join("");
15112
+ "civet coffeeCompat";
15113
+ var gen;
15114
+ var generate_default = gen = function(node, options) {
15115
+ var $loc, token;
15116
+ if (node === null || node === void 0) {
15117
+ return "";
15118
+ }
15119
+ if (typeof node === "string") {
15120
+ if (options != null) {
15121
+ if (typeof options.updateSourceMap === "function") {
15122
+ options.updateSourceMap(node);
14992
15123
  }
14993
- if (typeof node === "object") {
14994
- if (options.js && node.ts) {
14995
- return "";
14996
- }
14997
- if (!options.js && node.js) {
14998
- return "";
14999
- }
15000
- if (node.$loc != null) {
15001
- ({ token, $loc } = node);
15002
- if (options != null) {
15003
- if (typeof options.updateSourceMap === "function") {
15004
- options.updateSourceMap(token, $loc.pos);
15005
- }
15006
- }
15007
- return token;
15008
- }
15009
- if (!node.children) {
15010
- debugger;
15011
- throw new Error("Unknown node", JSON.stringify(node));
15124
+ }
15125
+ return node;
15126
+ }
15127
+ if (Array.isArray(node)) {
15128
+ return node.map(function(child) {
15129
+ return gen(child, options);
15130
+ }).join("");
15131
+ }
15132
+ if (typeof node === "object") {
15133
+ if (options.js && node.ts) {
15134
+ return "";
15135
+ }
15136
+ if (!options.js && node.js) {
15137
+ return "";
15138
+ }
15139
+ if (node.$loc != null) {
15140
+ ({ token, $loc } = node);
15141
+ if (options != null) {
15142
+ if (typeof options.updateSourceMap === "function") {
15143
+ options.updateSourceMap(token, $loc.pos);
15012
15144
  }
15013
- return gen2(node.children, options);
15014
15145
  }
15146
+ return token;
15147
+ }
15148
+ if (!node.children) {
15015
15149
  debugger;
15016
15150
  throw new Error("Unknown node", JSON.stringify(node));
15017
- };
15018
- module2.exports = gen2;
15019
- prune2 = function(node) {
15020
- var a;
15021
- if (node === null || node === void 0) {
15022
- return;
15023
- }
15024
- if (node.length === 0) {
15025
- return;
15026
- }
15027
- if (Array.isArray(node)) {
15028
- a = node.map(function(n) {
15029
- return prune2(n);
15030
- }).filter(function(n) {
15031
- return !!n;
15032
- });
15033
- if (a.length > 1) {
15034
- return a;
15035
- }
15036
- if (a.length === 1) {
15037
- return a[0];
15038
- }
15039
- return;
15040
- }
15041
- if (node.children != null) {
15042
- node.children = prune2(node.children) || [];
15043
- return node;
15044
- }
15045
- return node;
15046
- };
15047
- gen2.prune = prune2;
15151
+ }
15152
+ return gen(node.children, options);
15048
15153
  }
15049
- });
15154
+ debugger;
15155
+ throw new Error("Unknown node", JSON.stringify(node));
15156
+ };
15157
+ var prune = function(node) {
15158
+ var a;
15159
+ if (node === null || node === void 0) {
15160
+ return;
15161
+ }
15162
+ if (node.length === 0) {
15163
+ return;
15164
+ }
15165
+ if (Array.isArray(node)) {
15166
+ a = node.map(function(n) {
15167
+ return prune(n);
15168
+ }).filter(function(n) {
15169
+ return !!n;
15170
+ });
15171
+ if (a.length > 1) {
15172
+ return a;
15173
+ }
15174
+ if (a.length === 1) {
15175
+ return a[0];
15176
+ }
15177
+ return;
15178
+ }
15179
+ if (node.children != null) {
15180
+ node.children = prune(node.children) || [];
15181
+ return node;
15182
+ }
15183
+ return node;
15184
+ };
15050
15185
 
15051
15186
  // source/util.coffee
15052
- var require_util = __commonJS({
15053
- "source/util.coffee"(exports2, module2) {
15054
- "use strict";
15055
- "civet coffeeCompat";
15056
- var BASE64_CHARS;
15057
- var SourceMap2;
15058
- var VLQ_CONTINUATION_BIT;
15059
- var VLQ_SHIFT;
15060
- var VLQ_VALUE_MASK;
15061
- var base64Encode2;
15062
- var decodeError;
15063
- var decodeVLQ;
15064
- var encodeBase64;
15065
- var encodeVlq;
15066
- var locationTable;
15067
- var lookupLineColumn;
15068
- var prettySourceExcerpt;
15069
- var remapPosition;
15070
- var smRegexp;
15071
- var vlqChars;
15072
- var vlqTable;
15073
- locationTable = function(input) {
15074
- var line, lines, linesRe, pos, result;
15075
- linesRe = /([^\r\n]*)(\r\n|\r|\n|$)/y;
15076
- lines = [];
15077
- line = 0;
15078
- pos = 0;
15079
- while (result = linesRe.exec(input)) {
15080
- pos += result[0].length;
15081
- lines[line++] = pos;
15082
- if (pos === input.length) {
15083
- break;
15084
- }
15085
- }
15086
- return lines;
15087
- };
15088
- lookupLineColumn = function(table, pos) {
15089
- var l, prevEnd;
15090
- l = 0;
15091
- prevEnd = 0;
15092
- while (table[l] <= pos) {
15093
- prevEnd = table[l++];
15094
- }
15095
- return [l, pos - prevEnd];
15096
- };
15097
- SourceMap2 = function(sourceString) {
15098
- var EOL, sm, srcTable;
15099
- srcTable = locationTable(sourceString);
15100
- sm = {
15101
- lines: [[]],
15102
- lineNum: 0,
15103
- colOffset: 0,
15104
- srcTable
15105
- };
15106
- EOL = /\r?\n|\r/;
15107
- return {
15108
- data: sm,
15109
- source: function() {
15110
- return sourceString;
15111
- },
15112
- renderMappings: function() {
15113
- var lastSourceColumn, lastSourceLine;
15114
- lastSourceLine = 0;
15115
- lastSourceColumn = 0;
15116
- return sm.lines.map(function(line) {
15117
- return line.map(function(entry) {
15118
- var colDelta, lineDelta, sourceFileIndex, srcCol, srcLine;
15119
- if (entry.length === 4) {
15120
- [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
15121
- lineDelta = srcLine - lastSourceLine;
15122
- colDelta = srcCol - lastSourceColumn;
15123
- lastSourceLine = srcLine;
15124
- lastSourceColumn = srcCol;
15125
- return `${encodeVlq(entry[0])}${encodeVlq(sourceFileIndex)}${encodeVlq(lineDelta)}${encodeVlq(colDelta)}`;
15126
- } else {
15127
- return encodeVlq(entry[0]);
15128
- }
15129
- }).join(",");
15130
- }).join(";");
15131
- },
15132
- json: function(srcFileName, outFileName) {
15133
- return {
15134
- version: 3,
15135
- file: outFileName,
15136
- sources: [srcFileName],
15137
- mappings: this.renderMappings(),
15138
- names: [],
15139
- sourcesContent: [sourceString]
15140
- };
15141
- },
15142
- updateSourceMap: function(outputStr, inputPos) {
15143
- var outLines, srcCol, srcLine;
15144
- outLines = outputStr.split(EOL);
15145
- if (inputPos != null) {
15146
- [srcLine, srcCol] = lookupLineColumn(srcTable, inputPos);
15147
- }
15148
- outLines.forEach(function(line, i) {
15149
- var l;
15150
- if (i > 0) {
15151
- sm.lineNum++;
15152
- sm.colOffset = 0;
15153
- sm.lines[sm.lineNum] = [];
15154
- srcCol = 0;
15155
- }
15156
- l = sm.colOffset;
15157
- sm.colOffset = line.length;
15158
- if (inputPos != null) {
15159
- return sm.lines[sm.lineNum].push([l, 0, srcLine + i, srcCol]);
15160
- } else if (l !== 0) {
15161
- return sm.lines[sm.lineNum].push([l]);
15162
- }
15163
- });
15164
- }
15165
- };
15166
- };
15167
- SourceMap2.parseWithLines = function(base64encodedJSONstr) {
15168
- var json, lines, sourceColumn, sourceLine;
15169
- json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
15170
- sourceLine = 0;
15171
- sourceColumn = 0;
15172
- lines = json.mappings.split(";").map(function(line) {
15173
- if (line.length === 0) {
15174
- return [];
15175
- }
15176
- return line.split(",").map(function(entry) {
15177
- var result;
15178
- result = decodeVLQ(entry);
15179
- switch (result.length) {
15180
- case 1:
15181
- return [result[0]];
15182
- case 4:
15183
- return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3]];
15184
- case 5:
15185
- return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3], result[4]];
15186
- default:
15187
- throw new Error("Unknown source map entry", result);
15188
- }
15189
- });
15190
- });
15191
- json.lines = lines;
15192
- return json;
15193
- };
15194
- smRegexp = /\n\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,([+a-zA-Z0-9\/]*=?=?)$/;
15195
- SourceMap2.remap = function(codeWithSourceMap, upstreamMap, sourcePath, targetPath) {
15196
- var codeWithoutSourceMap, composedLines, newSourceMap, parsed, remappedCodeWithSourceMap, remappedSourceMapJSON, sourceMapText;
15197
- sourceMapText = codeWithSourceMap.match(smRegexp);
15198
- if (sourceMapText) {
15199
- parsed = SourceMap2.parseWithLines(sourceMapText[1]);
15200
- } else {
15201
- console.warn("No source map found in code");
15202
- return codeWithSourceMap;
15203
- }
15204
- composedLines = SourceMap2.composeLines(upstreamMap.data.lines, parsed.lines);
15205
- upstreamMap.data.lines = composedLines;
15206
- remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
15207
- codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, "");
15208
- newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode2(JSON.stringify(remappedSourceMapJSON))}`;
15209
- remappedCodeWithSourceMap = `${codeWithoutSourceMap}
15210
- //# ${newSourceMap}`;
15211
- return remappedCodeWithSourceMap;
15212
- };
15213
- SourceMap2.composeLines = function(upstreamMapping, lines) {
15214
- return lines.map(function(line, l) {
15187
+ var util_exports = {};
15188
+ __export(util_exports, {
15189
+ SourceMap: () => SourceMap,
15190
+ base64Encode: () => base64Encode,
15191
+ locationTable: () => locationTable,
15192
+ lookupLineColumn: () => lookupLineColumn
15193
+ });
15194
+ "civet coffeeCompat";
15195
+ var BASE64_CHARS;
15196
+ var VLQ_CONTINUATION_BIT;
15197
+ var VLQ_SHIFT;
15198
+ var VLQ_VALUE_MASK;
15199
+ var decodeError;
15200
+ var decodeVLQ;
15201
+ var encodeBase64;
15202
+ var encodeVlq;
15203
+ var prettySourceExcerpt;
15204
+ var remapPosition;
15205
+ var smRegexp;
15206
+ var vlqChars;
15207
+ var vlqTable;
15208
+ var locationTable = function(input) {
15209
+ var line, lines, linesRe, pos, result;
15210
+ linesRe = /([^\r\n]*)(\r\n|\r|\n|$)/y;
15211
+ lines = [];
15212
+ line = 0;
15213
+ pos = 0;
15214
+ while (result = linesRe.exec(input)) {
15215
+ pos += result[0].length;
15216
+ lines[line++] = pos;
15217
+ if (pos === input.length) {
15218
+ break;
15219
+ }
15220
+ }
15221
+ return lines;
15222
+ };
15223
+ var lookupLineColumn = function(table, pos) {
15224
+ var l, prevEnd;
15225
+ l = 0;
15226
+ prevEnd = 0;
15227
+ while (table[l] <= pos) {
15228
+ prevEnd = table[l++];
15229
+ }
15230
+ return [l, pos - prevEnd];
15231
+ };
15232
+ var SourceMap = function(sourceString) {
15233
+ var EOL, sm, srcTable;
15234
+ srcTable = locationTable(sourceString);
15235
+ sm = {
15236
+ lines: [[]],
15237
+ lineNum: 0,
15238
+ colOffset: 0,
15239
+ srcTable
15240
+ };
15241
+ EOL = /\r?\n|\r/;
15242
+ return {
15243
+ data: sm,
15244
+ source: function() {
15245
+ return sourceString;
15246
+ },
15247
+ renderMappings: function() {
15248
+ var lastSourceColumn, lastSourceLine;
15249
+ lastSourceLine = 0;
15250
+ lastSourceColumn = 0;
15251
+ return sm.lines.map(function(line) {
15215
15252
  return line.map(function(entry) {
15216
- var colDelta, sourceFileIndex, srcCol, srcLine, srcPos, upstreamCol, upstreamLine;
15217
- if (entry.length === 1) {
15218
- return entry;
15219
- }
15220
- [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
15221
- srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
15222
- if (!srcPos) {
15223
- return [entry[0]];
15224
- }
15225
- [upstreamLine, upstreamCol] = srcPos;
15253
+ var colDelta, lineDelta, sourceFileIndex, srcCol, srcLine;
15226
15254
  if (entry.length === 4) {
15227
- return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
15228
- }
15229
- return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
15230
- });
15231
- });
15232
- };
15233
- prettySourceExcerpt = function(source, location, length) {
15234
- var colNum, i, j, line, lineNum, lineNumStr, lines, ref, ref1;
15235
- lines = source.split(/\r?\n|\r/);
15236
- lineNum = location.line;
15237
- colNum = location.column;
15238
- for (i = j = ref = lineNum - 2, ref1 = lineNum + 2; ref <= ref1 ? j <= ref1 : j >= ref1; i = ref <= ref1 ? ++j : --j) {
15239
- if (i < 0 || i >= lines.length) {
15240
- continue;
15241
- }
15242
- line = lines[i];
15243
- lineNumStr = (i + 1).toString();
15244
- while (lineNumStr.length < 4) {
15245
- lineNumStr = " " + lineNumStr;
15246
- }
15247
- if (i === lineNum) {
15248
- console.log(`${lineNumStr}: ${line}`);
15249
- console.log(" ".repeat(lineNumStr.length + 2 + colNum) + "^".repeat(length));
15250
- } else {
15251
- console.log(`${lineNumStr}: ${line}`);
15252
- }
15253
- }
15254
- };
15255
- VLQ_SHIFT = 5;
15256
- VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
15257
- VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
15258
- encodeVlq = function(value) {
15259
- var answer, nextChunk, signBit, valueToEncode;
15260
- answer = "";
15261
- signBit = value < 0 ? 1 : 0;
15262
- valueToEncode = (Math.abs(value) << 1) + signBit;
15263
- while (valueToEncode || !answer) {
15264
- nextChunk = valueToEncode & VLQ_VALUE_MASK;
15265
- valueToEncode = valueToEncode >> VLQ_SHIFT;
15266
- if (valueToEncode) {
15267
- nextChunk |= VLQ_CONTINUATION_BIT;
15268
- }
15269
- answer += encodeBase64(nextChunk);
15270
- }
15271
- return answer;
15272
- };
15273
- BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
15274
- encodeBase64 = function(value) {
15275
- return BASE64_CHARS[value] || function() {
15276
- throw new Error(`Cannot Base64 encode value: ${value}`);
15277
- }();
15278
- };
15279
- base64Encode2 = function(src) {
15280
- return Buffer.from(src).toString("base64");
15281
- };
15282
- module2.exports = { base64Encode: base64Encode2, locationTable, lookupLineColumn, SourceMap: SourceMap2 };
15283
- vlqTable = new Uint8Array(128);
15284
- vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
15285
- (function() {
15286
- var i, l, results;
15287
- i = 0;
15288
- l = vlqTable.length;
15289
- while (i < l) {
15290
- vlqTable[i] = 255;
15291
- i++;
15292
- }
15293
- i = 0;
15294
- l = vlqChars.length;
15295
- results = [];
15296
- while (i < l) {
15297
- vlqTable[vlqChars.charCodeAt(i)] = i;
15298
- results.push(i++);
15299
- }
15300
- return results;
15301
- })();
15302
- decodeError = function(message) {
15303
- throw new Error(message);
15304
- };
15305
- decodeVLQ = function(mapping) {
15306
- var c, i, index, l, result, shift, v, vlq;
15307
- i = 0;
15308
- l = mapping.length;
15309
- result = [];
15310
- while (i < l) {
15311
- shift = 0;
15312
- vlq = 0;
15313
- while (true) {
15314
- if (i >= l) {
15315
- decodeError("Unexpected early end of mapping data");
15316
- }
15317
- c = mapping.charCodeAt(i);
15318
- if ((c & 127) !== c) {
15319
- decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
15320
- }
15321
- index = vlqTable[c & 127];
15322
- if (index === 255) {
15323
- decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
15324
- }
15325
- i++;
15326
- vlq |= (index & 31) << shift;
15327
- shift += 5;
15328
- if ((index & 32) === 0) {
15329
- break;
15255
+ [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
15256
+ lineDelta = srcLine - lastSourceLine;
15257
+ colDelta = srcCol - lastSourceColumn;
15258
+ lastSourceLine = srcLine;
15259
+ lastSourceColumn = srcCol;
15260
+ return `${encodeVlq(entry[0])}${encodeVlq(sourceFileIndex)}${encodeVlq(lineDelta)}${encodeVlq(colDelta)}`;
15261
+ } else {
15262
+ return encodeVlq(entry[0]);
15330
15263
  }
15264
+ }).join(",");
15265
+ }).join(";");
15266
+ },
15267
+ json: function(srcFileName, outFileName) {
15268
+ return {
15269
+ version: 3,
15270
+ file: outFileName,
15271
+ sources: [srcFileName],
15272
+ mappings: this.renderMappings(),
15273
+ names: [],
15274
+ sourcesContent: [sourceString]
15275
+ };
15276
+ },
15277
+ updateSourceMap: function(outputStr, inputPos) {
15278
+ var outLines, srcCol, srcLine;
15279
+ outLines = outputStr.split(EOL);
15280
+ if (inputPos != null) {
15281
+ [srcLine, srcCol] = lookupLineColumn(srcTable, inputPos);
15282
+ }
15283
+ outLines.forEach(function(line, i) {
15284
+ var l;
15285
+ if (i > 0) {
15286
+ sm.lineNum++;
15287
+ sm.colOffset = 0;
15288
+ sm.lines[sm.lineNum] = [];
15289
+ srcCol = 0;
15331
15290
  }
15332
- if (vlq & 1) {
15333
- v = -(vlq >> 1);
15334
- } else {
15335
- v = vlq >> 1;
15291
+ l = sm.colOffset;
15292
+ sm.colOffset = line.length;
15293
+ if (inputPos != null) {
15294
+ return sm.lines[sm.lineNum].push([l, 0, srcLine + i, srcCol]);
15295
+ } else if (l !== 0) {
15296
+ return sm.lines[sm.lineNum].push([l]);
15336
15297
  }
15337
- result.push(v);
15298
+ });
15299
+ }
15300
+ };
15301
+ };
15302
+ SourceMap.parseWithLines = function(base64encodedJSONstr) {
15303
+ var json, lines, sourceColumn, sourceLine;
15304
+ json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
15305
+ sourceLine = 0;
15306
+ sourceColumn = 0;
15307
+ lines = json.mappings.split(";").map(function(line) {
15308
+ if (line.length === 0) {
15309
+ return [];
15310
+ }
15311
+ return line.split(",").map(function(entry) {
15312
+ var result;
15313
+ result = decodeVLQ(entry);
15314
+ switch (result.length) {
15315
+ case 1:
15316
+ return [result[0]];
15317
+ case 4:
15318
+ return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3]];
15319
+ case 5:
15320
+ return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3], result[4]];
15321
+ default:
15322
+ throw new Error("Unknown source map entry", result);
15338
15323
  }
15339
- return result;
15340
- };
15341
- remapPosition = function(position, sourcemapLines) {
15342
- var character, i, l, lastMapping, lastMappingPosition, line, mapping, p, textLine;
15343
- [line, character] = position;
15344
- textLine = sourcemapLines[line];
15345
- if (!(textLine != null ? textLine.length : void 0)) {
15346
- return void 0;
15347
- }
15348
- i = 0;
15349
- p = 0;
15350
- l = textLine.length;
15351
- lastMapping = void 0;
15352
- lastMappingPosition = 0;
15353
- while (i < l) {
15354
- mapping = textLine[i];
15355
- p += mapping[0];
15356
- if (mapping.length === 4) {
15357
- lastMapping = mapping;
15358
- lastMappingPosition = p;
15359
- }
15360
- if (p >= character) {
15361
- break;
15362
- }
15363
- i++;
15324
+ });
15325
+ });
15326
+ json.lines = lines;
15327
+ return json;
15328
+ };
15329
+ smRegexp = /\n\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,([+a-zA-Z0-9\/]*=?=?)$/;
15330
+ SourceMap.remap = function(codeWithSourceMap, upstreamMap, sourcePath, targetPath) {
15331
+ var codeWithoutSourceMap, composedLines, newSourceMap, parsed, remappedCodeWithSourceMap, remappedSourceMapJSON, sourceMapText;
15332
+ sourceMapText = codeWithSourceMap.match(smRegexp);
15333
+ if (sourceMapText) {
15334
+ parsed = SourceMap.parseWithLines(sourceMapText[1]);
15335
+ } else {
15336
+ console.warn("No source map found in code");
15337
+ return codeWithSourceMap;
15338
+ }
15339
+ composedLines = SourceMap.composeLines(upstreamMap.data.lines, parsed.lines);
15340
+ upstreamMap.data.lines = composedLines;
15341
+ remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
15342
+ codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, "");
15343
+ newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode(JSON.stringify(remappedSourceMapJSON))}`;
15344
+ remappedCodeWithSourceMap = `${codeWithoutSourceMap}
15345
+ //# ${newSourceMap}`;
15346
+ return remappedCodeWithSourceMap;
15347
+ };
15348
+ SourceMap.composeLines = function(upstreamMapping, lines) {
15349
+ return lines.map(function(line, l) {
15350
+ return line.map(function(entry) {
15351
+ var colDelta, sourceFileIndex, srcCol, srcLine, srcPos, upstreamCol, upstreamLine;
15352
+ if (entry.length === 1) {
15353
+ return entry;
15364
15354
  }
15365
- if (character - lastMappingPosition !== 0) {
15366
- return void 0;
15355
+ [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
15356
+ srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
15357
+ if (!srcPos) {
15358
+ return [entry[0]];
15367
15359
  }
15368
- if (lastMapping) {
15369
- return [lastMapping[2], lastMapping[3]];
15370
- } else {
15371
- return void 0;
15360
+ [upstreamLine, upstreamCol] = srcPos;
15361
+ if (entry.length === 4) {
15362
+ return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
15372
15363
  }
15373
- };
15364
+ return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
15365
+ });
15366
+ });
15367
+ };
15368
+ prettySourceExcerpt = function(source, location, length) {
15369
+ var colNum, i, j, line, lineNum, lineNumStr, lines, ref, ref1;
15370
+ lines = source.split(/\r?\n|\r/);
15371
+ lineNum = location.line;
15372
+ colNum = location.column;
15373
+ for (i = j = ref = lineNum - 2, ref1 = lineNum + 2; ref <= ref1 ? j <= ref1 : j >= ref1; i = ref <= ref1 ? ++j : --j) {
15374
+ if (i < 0 || i >= lines.length) {
15375
+ continue;
15376
+ }
15377
+ line = lines[i];
15378
+ lineNumStr = (i + 1).toString();
15379
+ while (lineNumStr.length < 4) {
15380
+ lineNumStr = " " + lineNumStr;
15381
+ }
15382
+ if (i === lineNum) {
15383
+ console.log(`${lineNumStr}: ${line}`);
15384
+ console.log(" ".repeat(lineNumStr.length + 2 + colNum) + "^".repeat(length));
15385
+ } else {
15386
+ console.log(`${lineNumStr}: ${line}`);
15387
+ }
15374
15388
  }
15375
- });
15389
+ };
15390
+ VLQ_SHIFT = 5;
15391
+ VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
15392
+ VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
15393
+ encodeVlq = function(value) {
15394
+ var answer, nextChunk, signBit, valueToEncode;
15395
+ answer = "";
15396
+ signBit = value < 0 ? 1 : 0;
15397
+ valueToEncode = (Math.abs(value) << 1) + signBit;
15398
+ while (valueToEncode || !answer) {
15399
+ nextChunk = valueToEncode & VLQ_VALUE_MASK;
15400
+ valueToEncode = valueToEncode >> VLQ_SHIFT;
15401
+ if (valueToEncode) {
15402
+ nextChunk |= VLQ_CONTINUATION_BIT;
15403
+ }
15404
+ answer += encodeBase64(nextChunk);
15405
+ }
15406
+ return answer;
15407
+ };
15408
+ BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
15409
+ encodeBase64 = function(value) {
15410
+ return BASE64_CHARS[value] || function() {
15411
+ throw new Error(`Cannot Base64 encode value: ${value}`);
15412
+ }();
15413
+ };
15414
+ var base64Encode = function(src) {
15415
+ return Buffer.from(src).toString("base64");
15416
+ };
15417
+ vlqTable = new Uint8Array(128);
15418
+ vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
15419
+ (function() {
15420
+ var i, l, results;
15421
+ i = 0;
15422
+ l = vlqTable.length;
15423
+ while (i < l) {
15424
+ vlqTable[i] = 255;
15425
+ i++;
15426
+ }
15427
+ i = 0;
15428
+ l = vlqChars.length;
15429
+ results = [];
15430
+ while (i < l) {
15431
+ vlqTable[vlqChars.charCodeAt(i)] = i;
15432
+ results.push(i++);
15433
+ }
15434
+ return results;
15435
+ })();
15436
+ decodeError = function(message) {
15437
+ throw new Error(message);
15438
+ };
15439
+ decodeVLQ = function(mapping) {
15440
+ var c, i, index, l, result, shift, v, vlq;
15441
+ i = 0;
15442
+ l = mapping.length;
15443
+ result = [];
15444
+ while (i < l) {
15445
+ shift = 0;
15446
+ vlq = 0;
15447
+ while (true) {
15448
+ if (i >= l) {
15449
+ decodeError("Unexpected early end of mapping data");
15450
+ }
15451
+ c = mapping.charCodeAt(i);
15452
+ if ((c & 127) !== c) {
15453
+ decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
15454
+ }
15455
+ index = vlqTable[c & 127];
15456
+ if (index === 255) {
15457
+ decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
15458
+ }
15459
+ i++;
15460
+ vlq |= (index & 31) << shift;
15461
+ shift += 5;
15462
+ if ((index & 32) === 0) {
15463
+ break;
15464
+ }
15465
+ }
15466
+ if (vlq & 1) {
15467
+ v = -(vlq >> 1);
15468
+ } else {
15469
+ v = vlq >> 1;
15470
+ }
15471
+ result.push(v);
15472
+ }
15473
+ return result;
15474
+ };
15475
+ remapPosition = function(position, sourcemapLines) {
15476
+ var character, i, l, lastMapping, lastMappingPosition, line, mapping, p, textLine;
15477
+ [line, character] = position;
15478
+ textLine = sourcemapLines[line];
15479
+ if (!(textLine != null ? textLine.length : void 0)) {
15480
+ return void 0;
15481
+ }
15482
+ i = 0;
15483
+ p = 0;
15484
+ l = textLine.length;
15485
+ lastMapping = void 0;
15486
+ lastMappingPosition = 0;
15487
+ while (i < l) {
15488
+ mapping = textLine[i];
15489
+ p += mapping[0];
15490
+ if (mapping.length === 4) {
15491
+ lastMapping = mapping;
15492
+ lastMappingPosition = p;
15493
+ }
15494
+ if (p >= character) {
15495
+ break;
15496
+ }
15497
+ i++;
15498
+ }
15499
+ if (character - lastMappingPosition !== 0) {
15500
+ return void 0;
15501
+ }
15502
+ if (lastMapping) {
15503
+ return [lastMapping[2], lastMapping[3]];
15504
+ } else {
15505
+ return void 0;
15506
+ }
15507
+ };
15376
15508
 
15377
15509
  // source/main.coffee
15378
15510
  "civet coffeeCompat";
15379
- var SourceMap;
15380
- var base64Encode;
15511
+ var SourceMap2;
15512
+ var base64Encode2;
15381
15513
  var defaultOptions;
15382
- var gen;
15383
15514
  var makeCache;
15384
15515
  var parse;
15385
- var prune;
15386
15516
  var uncacheable;
15387
- var util;
15388
- ({ parse } = require_parser());
15389
- ({ prune } = gen = require_generate());
15390
- ({ SourceMap, base64Encode } = util = require_util());
15517
+ ({ parse } = import_parser.default);
15518
+ ({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
15391
15519
  defaultOptions = {};
15392
- uncacheable = /* @__PURE__ */ new Set(["TrackIndented", "Samedent", "IndentedFurther", "PushIndent", "PopIndent", "Nested", "InsertIndent", "Arguments", "ArgumentsWithTrailingCallExpressions", "ApplicationStart", "CallExpression", "CallExpressionRest", "LeftHandSideExpression", "ActualAssignment", "UpdateExpression", "UnaryExpression", "BinaryOpExpression", "BinaryOpRHS", "ConditionalExpression", "ShortCircuitExpression", "InlineObjectLiteral", "ImplicitInlineObjectPropertyDelimiter", "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"]);
15393
- module.exports = {
15394
- parse,
15395
- compile: function(src, options = defaultOptions) {
15396
- var ast, code, events, filename, sm, srcMapJSON;
15397
- filename = options.filename || "unknown";
15398
- if (filename.endsWith(".coffee") && !/^(#![^\r\n]*(\r\n|\n|\r))?\s*['"]civet/.test(src)) {
15399
- src = `"civet coffeeCompat"; ${src}`;
15400
- }
15401
- if (!options.noCache) {
15402
- events = makeCache();
15403
- }
15404
- ast = prune(parse(src, { filename, events }));
15405
- if (options.ast) {
15406
- return ast;
15407
- }
15408
- if (options.sourceMap || options.inlineMap) {
15409
- sm = SourceMap(src);
15410
- options.updateSourceMap = sm.updateSourceMap;
15411
- code = gen(ast, options);
15412
- if (options.inlineMap) {
15413
- srcMapJSON = sm.json(filename, "");
15414
- return `${code}
15415
- ${"//#"} sourceMappingURL=data:application/json;base64,${base64Encode(JSON.stringify(srcMapJSON))}
15520
+ uncacheable = /* @__PURE__ */ new Set(["TrackIndented", "Samedent", "IndentedFurther", "PushIndent", "PopIndent", "Nested", "InsertIndent", "Arguments", "ArgumentsWithTrailingCallExpressions", "ApplicationStart", "CallExpression", "CallExpressionRest", "LeftHandSideExpression", "ActualAssignment", "UpdateExpression", "UnaryExpression", "BinaryOpExpression", "BinaryOpRHS", "ConditionalExpression", "ShortCircuitExpression", "InlineObjectLiteral", "ImplicitInlineObjectPropertyDelimiter", "FatArrowBody", "ThinArrowFunction", "ArrowFunctionTail", "ArrowFunction", "ImplicitNestedBlock", "BracedBlock", "BracedOrEmptyBlock", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatements", "SingleLineStatements", "ExpressionStatement", "Statement", "IndentedJSXChildExpression", "NestedJSXChildExpression", "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", "JSXImplicitFragment", "JSXTag", "JSXElement", "TypedJSXElement", "JSXFragment", "TypedJSXFragment", "JSXChild", "JSXChildren", "JSXNestedChildren", "JSXMixedChildren"]);
15521
+ var compile = function(src, options = defaultOptions) {
15522
+ var ast, code, events, filename, sm, srcMapJSON;
15523
+ filename = options.filename || "unknown";
15524
+ if (filename.endsWith(".coffee") && !/^(#![^\r\n]*(\r\n|\n|\r))?\s*['"]civet/.test(src)) {
15525
+ src = `"civet coffeeCompat"; ${src}`;
15526
+ }
15527
+ if (!options.noCache) {
15528
+ events = makeCache();
15529
+ }
15530
+ ast = prune(parse(src, { filename, events }));
15531
+ if (options.ast) {
15532
+ return ast;
15533
+ }
15534
+ if (options.sourceMap || options.inlineMap) {
15535
+ sm = SourceMap2(src);
15536
+ options.updateSourceMap = sm.updateSourceMap;
15537
+ code = generate_default(ast, options);
15538
+ if (options.inlineMap) {
15539
+ srcMapJSON = sm.json(filename, "");
15540
+ return `${code}
15541
+ ${"//#"} sourceMappingURL=data:application/json;base64,${base64Encode2(JSON.stringify(srcMapJSON))}
15416
15542
  `;
15417
- } else {
15418
- return {
15419
- code,
15420
- sourceMap: sm
15421
- };
15422
- }
15543
+ } else {
15544
+ return {
15545
+ code,
15546
+ sourceMap: sm
15547
+ };
15423
15548
  }
15424
- return gen(ast, options);
15425
- },
15426
- generate: gen,
15427
- util
15549
+ }
15550
+ return generate_default(ast, options);
15428
15551
  };
15429
15552
  makeCache = function() {
15430
15553
  var caches, events;
@@ -15463,3 +15586,11 @@ makeCache = function() {
15463
15586
  };
15464
15587
  return events;
15465
15588
  };
15589
+ var main_default = { parse, generate: generate_default, util: util_exports, compile };
15590
+ // Annotate the CommonJS export names for ESM import in node:
15591
+ 0 && (module.exports = {
15592
+ compile,
15593
+ generate,
15594
+ parse,
15595
+ util
15596
+ });