@danielx/civet 0.5.24 → 0.5.25

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,
@@ -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,
@@ -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;
@@ -6098,7 +6143,7 @@ ${input.slice(result.pos)}
6098
6143
  children: [$1, exps, $3, $4, $5]
6099
6144
  };
6100
6145
  });
6101
- var ElseExpressionBlock$1 = $T($S($N(EOS), ExtendedExpression), function(value) {
6146
+ var ElseExpressionBlock$1 = $T($S($N(EOS), ExpressionWithIndentedApplicationSuppressed), function(value) {
6102
6147
  return value[1];
6103
6148
  });
6104
6149
  function ElseExpressionBlock(state) {
@@ -11792,7 +11837,15 @@ ${input.slice(result.pos)}
11792
11837
  var JSXChild$0 = JSXElement;
11793
11838
  var JSXChild$1 = JSXFragment;
11794
11839
  var JSXChild$2 = JSXComment;
11795
- var JSXChild$3 = $TS($S(OpenBrace, $E(JSXChildExpression), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
11840
+ var JSXChild$3 = $TS($S(OpenBrace, IndentedJSXChildExpression, __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
11841
+ var expression = $2;
11842
+ return {
11843
+ type: "JSXChildExpression",
11844
+ children: $0,
11845
+ expression
11846
+ };
11847
+ });
11848
+ var JSXChild$4 = $TS($S(OpenBrace, $E(JSXChildExpression), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
11796
11849
  var expression = $2;
11797
11850
  return {
11798
11851
  type: "JSXChildExpression",
@@ -11800,7 +11853,7 @@ ${input.slice(result.pos)}
11800
11853
  expression
11801
11854
  };
11802
11855
  });
11803
- var JSXChild$4 = $TS($S(InsertInlineOpenBrace, ArrowFunction, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
11856
+ var JSXChild$5 = $TS($S(InsertInlineOpenBrace, ArrowFunction, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
11804
11857
  var expression = $2;
11805
11858
  return {
11806
11859
  type: "JSXChildExpression",
@@ -11808,7 +11861,7 @@ ${input.slice(result.pos)}
11808
11861
  expression
11809
11862
  };
11810
11863
  });
11811
- var JSXChild$5 = JSXText;
11864
+ var JSXChild$6 = JSXText;
11812
11865
  function JSXChild(state) {
11813
11866
  if (state.events) {
11814
11867
  const result = state.events.enter?.("JSXChild", state);
@@ -11816,12 +11869,12 @@ ${input.slice(result.pos)}
11816
11869
  return result.cache;
11817
11870
  }
11818
11871
  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));
11872
+ 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
11873
  if (state.events)
11821
11874
  state.events.exit?.("JSXChild", state, result);
11822
11875
  return result;
11823
11876
  } else {
11824
- const result = JSXChild$0(state) || JSXChild$1(state) || JSXChild$2(state) || JSXChild$3(state) || JSXChild$4(state) || JSXChild$5(state);
11877
+ const result = JSXChild$0(state) || JSXChild$1(state) || JSXChild$2(state) || JSXChild$3(state) || JSXChild$4(state) || JSXChild$5(state) || JSXChild$6(state);
11825
11878
  if (state.events)
11826
11879
  state.events.exit?.("JSXChild", state, result);
11827
11880
  return result;
@@ -11913,6 +11966,48 @@ ${input.slice(result.pos)}
11913
11966
  return result;
11914
11967
  }
11915
11968
  }
11969
+ var IndentedJSXChildExpression$0 = $TS($S(PushIndent, $E(NestedJSXChildExpression), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
11970
+ if (!$2)
11971
+ return $skip;
11972
+ return $2;
11973
+ });
11974
+ function IndentedJSXChildExpression(state) {
11975
+ if (state.events) {
11976
+ const result = state.events.enter?.("IndentedJSXChildExpression", state);
11977
+ if (result)
11978
+ return result.cache;
11979
+ }
11980
+ if (state.tokenize) {
11981
+ const result = $TOKEN("IndentedJSXChildExpression", state, IndentedJSXChildExpression$0(state));
11982
+ if (state.events)
11983
+ state.events.exit?.("IndentedJSXChildExpression", state, result);
11984
+ return result;
11985
+ } else {
11986
+ const result = IndentedJSXChildExpression$0(state);
11987
+ if (state.events)
11988
+ state.events.exit?.("IndentedJSXChildExpression", state, result);
11989
+ return result;
11990
+ }
11991
+ }
11992
+ var NestedJSXChildExpression$0 = $S(Nested, JSXChildExpression);
11993
+ function NestedJSXChildExpression(state) {
11994
+ if (state.events) {
11995
+ const result = state.events.enter?.("NestedJSXChildExpression", state);
11996
+ if (result)
11997
+ return result.cache;
11998
+ }
11999
+ if (state.tokenize) {
12000
+ const result = $TOKEN("NestedJSXChildExpression", state, NestedJSXChildExpression$0(state));
12001
+ if (state.events)
12002
+ state.events.exit?.("NestedJSXChildExpression", state, result);
12003
+ return result;
12004
+ } else {
12005
+ const result = NestedJSXChildExpression$0(state);
12006
+ if (state.events)
12007
+ state.events.exit?.("NestedJSXChildExpression", state, result);
12008
+ return result;
12009
+ }
12010
+ }
11916
12011
  var TypeDeclaration$0 = $T($S($Q($S(TypeDeclarationModifier, $Q(TrailingComment))), TypeDeclarationRest), function(value) {
11917
12012
  return { "ts": true, "children": value };
11918
12013
  });
@@ -14078,6 +14173,21 @@ ${input.slice(result.pos)}
14078
14173
  return;
14079
14174
  node.splice(1, 0, "return ");
14080
14175
  }
14176
+ module2.makeLeftHandSideExpression = function(exp) {
14177
+ switch (exp.type) {
14178
+ case "Identifier":
14179
+ case "Literal":
14180
+ case "CallExpression":
14181
+ case "MemberExpression":
14182
+ case "ParenthesizedExpression":
14183
+ return exp;
14184
+ default:
14185
+ return {
14186
+ type: "ParenthesizedExpression",
14187
+ children: ["(", exp, ")"]
14188
+ };
14189
+ }
14190
+ };
14081
14191
  module2.isWhitespaceOrEmpty = function(node) {
14082
14192
  if (!node)
14083
14193
  return true;
@@ -14446,31 +14556,29 @@ ${input.slice(result.pos)}
14446
14556
  const lastAssignment = $12[i];
14447
14557
  if (lastAssignment[3].token === "=") {
14448
14558
  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] = ")";
14559
+ if (lhs.type === "MemberExpression") {
14560
+ const members = lhs.children;
14561
+ const lastMember = members[members.length - 1];
14562
+ if (lastMember.type === "SliceExpression") {
14563
+ const { start, end, children: c } = lastMember;
14564
+ c[0].token = ".splice(";
14565
+ c[1] = start;
14566
+ c[2] = ", ";
14567
+ if (end)
14568
+ c[3] = [end, " - ", start];
14569
+ else
14570
+ c[3] = ["1/0"];
14571
+ c[4] = [", ...", $22];
14572
+ c[5] = ")";
14573
+ lastAssignment.pop();
14574
+ if (module2.isWhitespaceOrEmpty(lastAssignment[2]))
14464
14575
  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;
14576
+ if ($12.length > 1) {
14577
+ throw new Error("Not implemented yet! TODO: Handle multiple splice assignments");
14473
14578
  }
14579
+ exp.children = [$12];
14580
+ exp.names = [];
14581
+ return;
14474
14582
  }
14475
14583
  } else if (lhs.type === "ObjectBindingPattern" || lhs.type === "ArrayBindingPattern") {
14476
14584
  processBindingPatternLHS(lhs, tail);
@@ -14961,470 +15069,463 @@ ${input.slice(result.pos)}
14961
15069
  return result;
14962
15070
  }
14963
15071
  }
14964
- exports2.parse = parse2;
14965
- exports2.default = { parse: parse2 };
15072
+ exports.parse = parse2;
15073
+ exports.default = { parse: parse2 };
14966
15074
  }
14967
15075
  });
14968
15076
 
15077
+ // source/main.coffee
15078
+ var main_exports = {};
15079
+ __export(main_exports, {
15080
+ compile: () => compile,
15081
+ default: () => main_default,
15082
+ generate: () => generate_default,
15083
+ parse: () => parse,
15084
+ util: () => util_exports
15085
+ });
15086
+ module.exports = __toCommonJS(main_exports);
15087
+ var import_parser = __toESM(require_parser());
15088
+
14969
15089
  // 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("");
15090
+ "civet coffeeCompat";
15091
+ var gen;
15092
+ var generate_default = gen = function(node, options) {
15093
+ var $loc, token;
15094
+ if (node === null || node === void 0) {
15095
+ return "";
15096
+ }
15097
+ if (typeof node === "string") {
15098
+ if (options != null) {
15099
+ if (typeof options.updateSourceMap === "function") {
15100
+ options.updateSourceMap(node);
14992
15101
  }
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));
15102
+ }
15103
+ return node;
15104
+ }
15105
+ if (Array.isArray(node)) {
15106
+ return node.map(function(child) {
15107
+ return gen(child, options);
15108
+ }).join("");
15109
+ }
15110
+ if (typeof node === "object") {
15111
+ if (options.js && node.ts) {
15112
+ return "";
15113
+ }
15114
+ if (!options.js && node.js) {
15115
+ return "";
15116
+ }
15117
+ if (node.$loc != null) {
15118
+ ({ token, $loc } = node);
15119
+ if (options != null) {
15120
+ if (typeof options.updateSourceMap === "function") {
15121
+ options.updateSourceMap(token, $loc.pos);
15012
15122
  }
15013
- return gen2(node.children, options);
15014
15123
  }
15124
+ return token;
15125
+ }
15126
+ if (!node.children) {
15015
15127
  debugger;
15016
15128
  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;
15129
+ }
15130
+ return gen(node.children, options);
15048
15131
  }
15049
- });
15132
+ debugger;
15133
+ throw new Error("Unknown node", JSON.stringify(node));
15134
+ };
15135
+ var prune = function(node) {
15136
+ var a;
15137
+ if (node === null || node === void 0) {
15138
+ return;
15139
+ }
15140
+ if (node.length === 0) {
15141
+ return;
15142
+ }
15143
+ if (Array.isArray(node)) {
15144
+ a = node.map(function(n) {
15145
+ return prune(n);
15146
+ }).filter(function(n) {
15147
+ return !!n;
15148
+ });
15149
+ if (a.length > 1) {
15150
+ return a;
15151
+ }
15152
+ if (a.length === 1) {
15153
+ return a[0];
15154
+ }
15155
+ return;
15156
+ }
15157
+ if (node.children != null) {
15158
+ node.children = prune(node.children) || [];
15159
+ return node;
15160
+ }
15161
+ return node;
15162
+ };
15050
15163
 
15051
15164
  // 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) {
15165
+ var util_exports = {};
15166
+ __export(util_exports, {
15167
+ SourceMap: () => SourceMap,
15168
+ base64Encode: () => base64Encode,
15169
+ locationTable: () => locationTable,
15170
+ lookupLineColumn: () => lookupLineColumn
15171
+ });
15172
+ "civet coffeeCompat";
15173
+ var BASE64_CHARS;
15174
+ var VLQ_CONTINUATION_BIT;
15175
+ var VLQ_SHIFT;
15176
+ var VLQ_VALUE_MASK;
15177
+ var decodeError;
15178
+ var decodeVLQ;
15179
+ var encodeBase64;
15180
+ var encodeVlq;
15181
+ var prettySourceExcerpt;
15182
+ var remapPosition;
15183
+ var smRegexp;
15184
+ var vlqChars;
15185
+ var vlqTable;
15186
+ var locationTable = function(input) {
15187
+ var line, lines, linesRe, pos, result;
15188
+ linesRe = /([^\r\n]*)(\r\n|\r|\n|$)/y;
15189
+ lines = [];
15190
+ line = 0;
15191
+ pos = 0;
15192
+ while (result = linesRe.exec(input)) {
15193
+ pos += result[0].length;
15194
+ lines[line++] = pos;
15195
+ if (pos === input.length) {
15196
+ break;
15197
+ }
15198
+ }
15199
+ return lines;
15200
+ };
15201
+ var lookupLineColumn = function(table, pos) {
15202
+ var l, prevEnd;
15203
+ l = 0;
15204
+ prevEnd = 0;
15205
+ while (table[l] <= pos) {
15206
+ prevEnd = table[l++];
15207
+ }
15208
+ return [l, pos - prevEnd];
15209
+ };
15210
+ var SourceMap = function(sourceString) {
15211
+ var EOL, sm, srcTable;
15212
+ srcTable = locationTable(sourceString);
15213
+ sm = {
15214
+ lines: [[]],
15215
+ lineNum: 0,
15216
+ colOffset: 0,
15217
+ srcTable
15218
+ };
15219
+ EOL = /\r?\n|\r/;
15220
+ return {
15221
+ data: sm,
15222
+ source: function() {
15223
+ return sourceString;
15224
+ },
15225
+ renderMappings: function() {
15226
+ var lastSourceColumn, lastSourceLine;
15227
+ lastSourceLine = 0;
15228
+ lastSourceColumn = 0;
15229
+ return sm.lines.map(function(line) {
15215
15230
  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;
15231
+ var colDelta, lineDelta, sourceFileIndex, srcCol, srcLine;
15226
15232
  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;
15233
+ [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
15234
+ lineDelta = srcLine - lastSourceLine;
15235
+ colDelta = srcCol - lastSourceColumn;
15236
+ lastSourceLine = srcLine;
15237
+ lastSourceColumn = srcCol;
15238
+ return `${encodeVlq(entry[0])}${encodeVlq(sourceFileIndex)}${encodeVlq(lineDelta)}${encodeVlq(colDelta)}`;
15239
+ } else {
15240
+ return encodeVlq(entry[0]);
15330
15241
  }
15242
+ }).join(",");
15243
+ }).join(";");
15244
+ },
15245
+ json: function(srcFileName, outFileName) {
15246
+ return {
15247
+ version: 3,
15248
+ file: outFileName,
15249
+ sources: [srcFileName],
15250
+ mappings: this.renderMappings(),
15251
+ names: [],
15252
+ sourcesContent: [sourceString]
15253
+ };
15254
+ },
15255
+ updateSourceMap: function(outputStr, inputPos) {
15256
+ var outLines, srcCol, srcLine;
15257
+ outLines = outputStr.split(EOL);
15258
+ if (inputPos != null) {
15259
+ [srcLine, srcCol] = lookupLineColumn(srcTable, inputPos);
15260
+ }
15261
+ outLines.forEach(function(line, i) {
15262
+ var l;
15263
+ if (i > 0) {
15264
+ sm.lineNum++;
15265
+ sm.colOffset = 0;
15266
+ sm.lines[sm.lineNum] = [];
15267
+ srcCol = 0;
15331
15268
  }
15332
- if (vlq & 1) {
15333
- v = -(vlq >> 1);
15334
- } else {
15335
- v = vlq >> 1;
15269
+ l = sm.colOffset;
15270
+ sm.colOffset = line.length;
15271
+ if (inputPos != null) {
15272
+ return sm.lines[sm.lineNum].push([l, 0, srcLine + i, srcCol]);
15273
+ } else if (l !== 0) {
15274
+ return sm.lines[sm.lineNum].push([l]);
15336
15275
  }
15337
- result.push(v);
15276
+ });
15277
+ }
15278
+ };
15279
+ };
15280
+ SourceMap.parseWithLines = function(base64encodedJSONstr) {
15281
+ var json, lines, sourceColumn, sourceLine;
15282
+ json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
15283
+ sourceLine = 0;
15284
+ sourceColumn = 0;
15285
+ lines = json.mappings.split(";").map(function(line) {
15286
+ if (line.length === 0) {
15287
+ return [];
15288
+ }
15289
+ return line.split(",").map(function(entry) {
15290
+ var result;
15291
+ result = decodeVLQ(entry);
15292
+ switch (result.length) {
15293
+ case 1:
15294
+ return [result[0]];
15295
+ case 4:
15296
+ return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3]];
15297
+ case 5:
15298
+ return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3], result[4]];
15299
+ default:
15300
+ throw new Error("Unknown source map entry", result);
15338
15301
  }
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++;
15302
+ });
15303
+ });
15304
+ json.lines = lines;
15305
+ return json;
15306
+ };
15307
+ smRegexp = /\n\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,([+a-zA-Z0-9\/]*=?=?)$/;
15308
+ SourceMap.remap = function(codeWithSourceMap, upstreamMap, sourcePath, targetPath) {
15309
+ var codeWithoutSourceMap, composedLines, newSourceMap, parsed, remappedCodeWithSourceMap, remappedSourceMapJSON, sourceMapText;
15310
+ sourceMapText = codeWithSourceMap.match(smRegexp);
15311
+ if (sourceMapText) {
15312
+ parsed = SourceMap.parseWithLines(sourceMapText[1]);
15313
+ } else {
15314
+ console.warn("No source map found in code");
15315
+ return codeWithSourceMap;
15316
+ }
15317
+ composedLines = SourceMap.composeLines(upstreamMap.data.lines, parsed.lines);
15318
+ upstreamMap.data.lines = composedLines;
15319
+ remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
15320
+ codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, "");
15321
+ newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode(JSON.stringify(remappedSourceMapJSON))}`;
15322
+ remappedCodeWithSourceMap = `${codeWithoutSourceMap}
15323
+ //# ${newSourceMap}`;
15324
+ return remappedCodeWithSourceMap;
15325
+ };
15326
+ SourceMap.composeLines = function(upstreamMapping, lines) {
15327
+ return lines.map(function(line, l) {
15328
+ return line.map(function(entry) {
15329
+ var colDelta, sourceFileIndex, srcCol, srcLine, srcPos, upstreamCol, upstreamLine;
15330
+ if (entry.length === 1) {
15331
+ return entry;
15364
15332
  }
15365
- if (character - lastMappingPosition !== 0) {
15366
- return void 0;
15333
+ [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
15334
+ srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
15335
+ if (!srcPos) {
15336
+ return [entry[0]];
15367
15337
  }
15368
- if (lastMapping) {
15369
- return [lastMapping[2], lastMapping[3]];
15370
- } else {
15371
- return void 0;
15338
+ [upstreamLine, upstreamCol] = srcPos;
15339
+ if (entry.length === 4) {
15340
+ return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
15372
15341
  }
15373
- };
15342
+ return [colDelta, sourceFileIndex, upstreamLine, upstreamCol, entry[4]];
15343
+ });
15344
+ });
15345
+ };
15346
+ prettySourceExcerpt = function(source, location, length) {
15347
+ var colNum, i, j, line, lineNum, lineNumStr, lines, ref, ref1;
15348
+ lines = source.split(/\r?\n|\r/);
15349
+ lineNum = location.line;
15350
+ colNum = location.column;
15351
+ for (i = j = ref = lineNum - 2, ref1 = lineNum + 2; ref <= ref1 ? j <= ref1 : j >= ref1; i = ref <= ref1 ? ++j : --j) {
15352
+ if (i < 0 || i >= lines.length) {
15353
+ continue;
15354
+ }
15355
+ line = lines[i];
15356
+ lineNumStr = (i + 1).toString();
15357
+ while (lineNumStr.length < 4) {
15358
+ lineNumStr = " " + lineNumStr;
15359
+ }
15360
+ if (i === lineNum) {
15361
+ console.log(`${lineNumStr}: ${line}`);
15362
+ console.log(" ".repeat(lineNumStr.length + 2 + colNum) + "^".repeat(length));
15363
+ } else {
15364
+ console.log(`${lineNumStr}: ${line}`);
15365
+ }
15374
15366
  }
15375
- });
15367
+ };
15368
+ VLQ_SHIFT = 5;
15369
+ VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
15370
+ VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
15371
+ encodeVlq = function(value) {
15372
+ var answer, nextChunk, signBit, valueToEncode;
15373
+ answer = "";
15374
+ signBit = value < 0 ? 1 : 0;
15375
+ valueToEncode = (Math.abs(value) << 1) + signBit;
15376
+ while (valueToEncode || !answer) {
15377
+ nextChunk = valueToEncode & VLQ_VALUE_MASK;
15378
+ valueToEncode = valueToEncode >> VLQ_SHIFT;
15379
+ if (valueToEncode) {
15380
+ nextChunk |= VLQ_CONTINUATION_BIT;
15381
+ }
15382
+ answer += encodeBase64(nextChunk);
15383
+ }
15384
+ return answer;
15385
+ };
15386
+ BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
15387
+ encodeBase64 = function(value) {
15388
+ return BASE64_CHARS[value] || function() {
15389
+ throw new Error(`Cannot Base64 encode value: ${value}`);
15390
+ }();
15391
+ };
15392
+ var base64Encode = function(src) {
15393
+ return Buffer.from(src).toString("base64");
15394
+ };
15395
+ vlqTable = new Uint8Array(128);
15396
+ vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
15397
+ (function() {
15398
+ var i, l, results;
15399
+ i = 0;
15400
+ l = vlqTable.length;
15401
+ while (i < l) {
15402
+ vlqTable[i] = 255;
15403
+ i++;
15404
+ }
15405
+ i = 0;
15406
+ l = vlqChars.length;
15407
+ results = [];
15408
+ while (i < l) {
15409
+ vlqTable[vlqChars.charCodeAt(i)] = i;
15410
+ results.push(i++);
15411
+ }
15412
+ return results;
15413
+ })();
15414
+ decodeError = function(message) {
15415
+ throw new Error(message);
15416
+ };
15417
+ decodeVLQ = function(mapping) {
15418
+ var c, i, index, l, result, shift, v, vlq;
15419
+ i = 0;
15420
+ l = mapping.length;
15421
+ result = [];
15422
+ while (i < l) {
15423
+ shift = 0;
15424
+ vlq = 0;
15425
+ while (true) {
15426
+ if (i >= l) {
15427
+ decodeError("Unexpected early end of mapping data");
15428
+ }
15429
+ c = mapping.charCodeAt(i);
15430
+ if ((c & 127) !== c) {
15431
+ decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
15432
+ }
15433
+ index = vlqTable[c & 127];
15434
+ if (index === 255) {
15435
+ decodeError(`Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}`);
15436
+ }
15437
+ i++;
15438
+ vlq |= (index & 31) << shift;
15439
+ shift += 5;
15440
+ if ((index & 32) === 0) {
15441
+ break;
15442
+ }
15443
+ }
15444
+ if (vlq & 1) {
15445
+ v = -(vlq >> 1);
15446
+ } else {
15447
+ v = vlq >> 1;
15448
+ }
15449
+ result.push(v);
15450
+ }
15451
+ return result;
15452
+ };
15453
+ remapPosition = function(position, sourcemapLines) {
15454
+ var character, i, l, lastMapping, lastMappingPosition, line, mapping, p, textLine;
15455
+ [line, character] = position;
15456
+ textLine = sourcemapLines[line];
15457
+ if (!(textLine != null ? textLine.length : void 0)) {
15458
+ return void 0;
15459
+ }
15460
+ i = 0;
15461
+ p = 0;
15462
+ l = textLine.length;
15463
+ lastMapping = void 0;
15464
+ lastMappingPosition = 0;
15465
+ while (i < l) {
15466
+ mapping = textLine[i];
15467
+ p += mapping[0];
15468
+ if (mapping.length === 4) {
15469
+ lastMapping = mapping;
15470
+ lastMappingPosition = p;
15471
+ }
15472
+ if (p >= character) {
15473
+ break;
15474
+ }
15475
+ i++;
15476
+ }
15477
+ if (character - lastMappingPosition !== 0) {
15478
+ return void 0;
15479
+ }
15480
+ if (lastMapping) {
15481
+ return [lastMapping[2], lastMapping[3]];
15482
+ } else {
15483
+ return void 0;
15484
+ }
15485
+ };
15376
15486
 
15377
15487
  // source/main.coffee
15378
15488
  "civet coffeeCompat";
15379
- var SourceMap;
15380
- var base64Encode;
15489
+ var SourceMap2;
15490
+ var base64Encode2;
15381
15491
  var defaultOptions;
15382
- var gen;
15383
15492
  var makeCache;
15384
15493
  var parse;
15385
- var prune;
15386
15494
  var uncacheable;
15387
- var util;
15388
- ({ parse } = require_parser());
15389
- ({ prune } = gen = require_generate());
15390
- ({ SourceMap, base64Encode } = util = require_util());
15495
+ ({ parse } = import_parser.default);
15496
+ ({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
15391
15497
  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))}
15498
+ 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", "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", "JSXElement", "TypedJSXElement", "JSXFragment", "TypedJSXFragment", "JSXChild", "JSXChildren", "JSXNestedChildren", "JSXMixedChildren"]);
15499
+ var compile = function(src, options = defaultOptions) {
15500
+ var ast, code, events, filename, sm, srcMapJSON;
15501
+ filename = options.filename || "unknown";
15502
+ if (filename.endsWith(".coffee") && !/^(#![^\r\n]*(\r\n|\n|\r))?\s*['"]civet/.test(src)) {
15503
+ src = `"civet coffeeCompat"; ${src}`;
15504
+ }
15505
+ if (!options.noCache) {
15506
+ events = makeCache();
15507
+ }
15508
+ ast = prune(parse(src, { filename, events }));
15509
+ if (options.ast) {
15510
+ return ast;
15511
+ }
15512
+ if (options.sourceMap || options.inlineMap) {
15513
+ sm = SourceMap2(src);
15514
+ options.updateSourceMap = sm.updateSourceMap;
15515
+ code = generate_default(ast, options);
15516
+ if (options.inlineMap) {
15517
+ srcMapJSON = sm.json(filename, "");
15518
+ return `${code}
15519
+ ${"//#"} sourceMappingURL=data:application/json;base64,${base64Encode2(JSON.stringify(srcMapJSON))}
15416
15520
  `;
15417
- } else {
15418
- return {
15419
- code,
15420
- sourceMap: sm
15421
- };
15422
- }
15521
+ } else {
15522
+ return {
15523
+ code,
15524
+ sourceMap: sm
15525
+ };
15423
15526
  }
15424
- return gen(ast, options);
15425
- },
15426
- generate: gen,
15427
- util
15527
+ }
15528
+ return generate_default(ast, options);
15428
15529
  };
15429
15530
  makeCache = function() {
15430
15531
  var caches, events;
@@ -15463,3 +15564,11 @@ makeCache = function() {
15463
15564
  };
15464
15565
  return events;
15465
15566
  };
15567
+ var main_default = { parse, generate: generate_default, util: util_exports, compile };
15568
+ // Annotate the CommonJS export names for ESM import in node:
15569
+ 0 && (module.exports = {
15570
+ compile,
15571
+ generate,
15572
+ parse,
15573
+ util
15574
+ });