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