@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/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,
@@ -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,
@@ -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;
@@ -6099,7 +6144,7 @@ ${input.slice(result.pos)}
6099
6144
  children: [$1, exps, $3, $4, $5]
6100
6145
  };
6101
6146
  });
6102
- var ElseExpressionBlock$1 = $T($S($N(EOS), ExtendedExpression), function(value) {
6147
+ var ElseExpressionBlock$1 = $T($S($N(EOS), ExpressionWithIndentedApplicationSuppressed), function(value) {
6103
6148
  return value[1];
6104
6149
  });
6105
6150
  function ElseExpressionBlock(state) {
@@ -11793,7 +11838,15 @@ ${input.slice(result.pos)}
11793
11838
  var JSXChild$0 = JSXElement;
11794
11839
  var JSXChild$1 = JSXFragment;
11795
11840
  var JSXChild$2 = JSXComment;
11796
- var JSXChild$3 = $TS($S(OpenBrace, $E(JSXChildExpression), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
11841
+ var JSXChild$3 = $TS($S(OpenBrace, IndentedJSXChildExpression, __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
11842
+ var expression = $2;
11843
+ return {
11844
+ type: "JSXChildExpression",
11845
+ children: $0,
11846
+ expression
11847
+ };
11848
+ });
11849
+ var JSXChild$4 = $TS($S(OpenBrace, $E(JSXChildExpression), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4) {
11797
11850
  var expression = $2;
11798
11851
  return {
11799
11852
  type: "JSXChildExpression",
@@ -11801,7 +11854,7 @@ ${input.slice(result.pos)}
11801
11854
  expression
11802
11855
  };
11803
11856
  });
11804
- var JSXChild$4 = $TS($S(InsertInlineOpenBrace, ArrowFunction, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
11857
+ var JSXChild$5 = $TS($S(InsertInlineOpenBrace, ArrowFunction, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
11805
11858
  var expression = $2;
11806
11859
  return {
11807
11860
  type: "JSXChildExpression",
@@ -11809,7 +11862,7 @@ ${input.slice(result.pos)}
11809
11862
  expression
11810
11863
  };
11811
11864
  });
11812
- var JSXChild$5 = JSXText;
11865
+ var JSXChild$6 = JSXText;
11813
11866
  function JSXChild(state) {
11814
11867
  if (state.events) {
11815
11868
  const result = state.events.enter?.("JSXChild", state);
@@ -11817,12 +11870,12 @@ ${input.slice(result.pos)}
11817
11870
  return result.cache;
11818
11871
  }
11819
11872
  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));
11873
+ 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
11874
  if (state.events)
11822
11875
  state.events.exit?.("JSXChild", state, result);
11823
11876
  return result;
11824
11877
  } else {
11825
- const result = JSXChild$0(state) || JSXChild$1(state) || JSXChild$2(state) || JSXChild$3(state) || JSXChild$4(state) || JSXChild$5(state);
11878
+ const result = JSXChild$0(state) || JSXChild$1(state) || JSXChild$2(state) || JSXChild$3(state) || JSXChild$4(state) || JSXChild$5(state) || JSXChild$6(state);
11826
11879
  if (state.events)
11827
11880
  state.events.exit?.("JSXChild", state, result);
11828
11881
  return result;
@@ -11914,6 +11967,48 @@ ${input.slice(result.pos)}
11914
11967
  return result;
11915
11968
  }
11916
11969
  }
11970
+ var IndentedJSXChildExpression$0 = $TS($S(PushIndent, $E(NestedJSXChildExpression), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
11971
+ if (!$2)
11972
+ return $skip;
11973
+ return $2;
11974
+ });
11975
+ function IndentedJSXChildExpression(state) {
11976
+ if (state.events) {
11977
+ const result = state.events.enter?.("IndentedJSXChildExpression", state);
11978
+ if (result)
11979
+ return result.cache;
11980
+ }
11981
+ if (state.tokenize) {
11982
+ const result = $TOKEN("IndentedJSXChildExpression", state, IndentedJSXChildExpression$0(state));
11983
+ if (state.events)
11984
+ state.events.exit?.("IndentedJSXChildExpression", state, result);
11985
+ return result;
11986
+ } else {
11987
+ const result = IndentedJSXChildExpression$0(state);
11988
+ if (state.events)
11989
+ state.events.exit?.("IndentedJSXChildExpression", state, result);
11990
+ return result;
11991
+ }
11992
+ }
11993
+ var NestedJSXChildExpression$0 = $S(Nested, JSXChildExpression);
11994
+ function NestedJSXChildExpression(state) {
11995
+ if (state.events) {
11996
+ const result = state.events.enter?.("NestedJSXChildExpression", state);
11997
+ if (result)
11998
+ return result.cache;
11999
+ }
12000
+ if (state.tokenize) {
12001
+ const result = $TOKEN("NestedJSXChildExpression", state, NestedJSXChildExpression$0(state));
12002
+ if (state.events)
12003
+ state.events.exit?.("NestedJSXChildExpression", state, result);
12004
+ return result;
12005
+ } else {
12006
+ const result = NestedJSXChildExpression$0(state);
12007
+ if (state.events)
12008
+ state.events.exit?.("NestedJSXChildExpression", state, result);
12009
+ return result;
12010
+ }
12011
+ }
11917
12012
  var TypeDeclaration$0 = $T($S($Q($S(TypeDeclarationModifier, $Q(TrailingComment))), TypeDeclarationRest), function(value) {
11918
12013
  return { "ts": true, "children": value };
11919
12014
  });
@@ -13592,7 +13687,7 @@ ${input.slice(result.pos)}
13592
13687
  }
13593
13688
  });
13594
13689
  }
13595
- module.config = parse.config = {
13690
+ module.config = parse2.config = {
13596
13691
  autoVar: false,
13597
13692
  autoLet: false,
13598
13693
  coffeeBinaryExistential: false,
@@ -14079,6 +14174,21 @@ ${input.slice(result.pos)}
14079
14174
  return;
14080
14175
  node.splice(1, 0, "return ");
14081
14176
  }
14177
+ module.makeLeftHandSideExpression = function(exp) {
14178
+ switch (exp.type) {
14179
+ case "Identifier":
14180
+ case "Literal":
14181
+ case "CallExpression":
14182
+ case "MemberExpression":
14183
+ case "ParenthesizedExpression":
14184
+ return exp;
14185
+ default:
14186
+ return {
14187
+ type: "ParenthesizedExpression",
14188
+ children: ["(", exp, ")"]
14189
+ };
14190
+ }
14191
+ };
14082
14192
  module.isWhitespaceOrEmpty = function(node) {
14083
14193
  if (!node)
14084
14194
  return true;
@@ -14447,31 +14557,29 @@ ${input.slice(result.pos)}
14447
14557
  const lastAssignment = $12[i];
14448
14558
  if (lastAssignment[3].token === "=") {
14449
14559
  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] = ")";
14560
+ if (lhs.type === "MemberExpression") {
14561
+ const members = lhs.children;
14562
+ const lastMember = members[members.length - 1];
14563
+ if (lastMember.type === "SliceExpression") {
14564
+ const { start, end, children: c } = lastMember;
14565
+ c[0].token = ".splice(";
14566
+ c[1] = start;
14567
+ c[2] = ", ";
14568
+ if (end)
14569
+ c[3] = [end, " - ", start];
14570
+ else
14571
+ c[3] = ["1/0"];
14572
+ c[4] = [", ...", $22];
14573
+ c[5] = ")";
14574
+ lastAssignment.pop();
14575
+ if (module.isWhitespaceOrEmpty(lastAssignment[2]))
14465
14576
  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;
14577
+ if ($12.length > 1) {
14578
+ throw new Error("Not implemented yet! TODO: Handle multiple splice assignments");
14474
14579
  }
14580
+ exp.children = [$12];
14581
+ exp.names = [];
14582
+ return;
14475
14583
  }
14476
14584
  } else if (lhs.type === "ObjectBindingPattern" || lhs.type === "ArrayBindingPattern") {
14477
14585
  processBindingPatternLHS(lhs, tail);
@@ -14962,511 +15070,500 @@ ${input.slice(result.pos)}
14962
15070
  return result;
14963
15071
  }
14964
15072
  }
14965
- exports.parse = parse;
14966
- exports.default = { parse };
15073
+ exports.parse = parse2;
15074
+ exports.default = { parse: parse2 };
14967
15075
  }
14968
15076
  });
14969
15077
 
15078
+ // source/main.coffee
15079
+ var main_exports = {};
15080
+ __export(main_exports, {
15081
+ compile: () => compile,
15082
+ default: () => main_default,
15083
+ generate: () => generate_default,
15084
+ parse: () => parse,
15085
+ util: () => util_exports
15086
+ });
15087
+ var import_parser = __toESM(require_parser());
15088
+
14970
15089
  // 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("");
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);
14993
15101
  }
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));
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);
15013
15122
  }
15014
- return gen(node.children, options);
15015
15123
  }
15124
+ return token;
15125
+ }
15126
+ if (!node.children) {
15016
15127
  debugger;
15017
15128
  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;
15129
+ }
15130
+ return gen(node.children, options);
15049
15131
  }
15050
- });
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
+ };
15051
15163
 
15052
15164
  // 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) {
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) {
15216
15230
  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;
15231
+ var colDelta, lineDelta, sourceFileIndex, srcCol, srcLine;
15227
15232
  if (entry.length === 4) {
15228
- return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
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]);
15229
15241
  }
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;
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;
15247
15268
  }
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}`);
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]);
15253
15275
  }
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);
15254
15301
  }
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;
15331
- }
15332
- }
15333
- if (vlq & 1) {
15334
- v = -(vlq >> 1);
15335
- } else {
15336
- v = vlq >> 1;
15337
- }
15338
- result.push(v);
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;
15339
15332
  }
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++;
15333
+ [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
15334
+ srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
15335
+ if (!srcPos) {
15336
+ return [entry[0]];
15365
15337
  }
15366
- if (character - lastMappingPosition !== 0) {
15367
- return void 0;
15338
+ [upstreamLine, upstreamCol] = srcPos;
15339
+ if (entry.length === 4) {
15340
+ return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
15368
15341
  }
15369
- if (lastMapping) {
15370
- return [lastMapping[2], lastMapping[3]];
15371
- } else {
15372
- return void 0;
15373
- }
15374
- };
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
+ }
15375
15366
  }
15376
- });
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
+ };
15377
15486
 
15378
15487
  // 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))}
15488
+ "civet coffeeCompat";
15489
+ var SourceMap2;
15490
+ var base64Encode2;
15491
+ var defaultOptions;
15492
+ var makeCache;
15493
+ var parse;
15494
+ var uncacheable;
15495
+ ({ parse } = import_parser.default);
15496
+ ({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
15497
+ defaultOptions = {};
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))}
15419
15520
  `;
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
- }
15521
+ } else {
15522
+ return {
15523
+ code,
15524
+ sourceMap: sm
15466
15525
  };
15467
- return events;
15468
- };
15526
+ }
15469
15527
  }
15470
- });
15471
- return require_main();
15528
+ return generate_default(ast, options);
15529
+ };
15530
+ makeCache = function() {
15531
+ var caches, events;
15532
+ caches = /* @__PURE__ */ new Map();
15533
+ events = {
15534
+ enter: function(ruleName, state) {
15535
+ var cache, result;
15536
+ cache = caches.get(ruleName);
15537
+ if (cache) {
15538
+ if (cache.has(state.pos)) {
15539
+ result = cache.get(state.pos);
15540
+ return {
15541
+ cache: result ? { ...result } : void 0
15542
+ };
15543
+ }
15544
+ }
15545
+ },
15546
+ exit: function(ruleName, state, result) {
15547
+ var cache;
15548
+ cache = caches.get(ruleName);
15549
+ if (!cache && !uncacheable.has(ruleName)) {
15550
+ cache = /* @__PURE__ */ new Map();
15551
+ caches.set(ruleName, cache);
15552
+ }
15553
+ if (cache) {
15554
+ if (result) {
15555
+ cache.set(state.pos, { ...result });
15556
+ } else {
15557
+ cache.set(state.pos, result);
15558
+ }
15559
+ }
15560
+ if (parse.config.verbose && result) {
15561
+ console.log(`Parsed ${JSON.stringify(state.input.slice(state.pos, result.pos))} [pos ${state.pos}-${result.pos}] as ${ruleName}`);
15562
+ }
15563
+ }
15564
+ };
15565
+ return events;
15566
+ };
15567
+ var main_default = { parse, generate: generate_default, util: util_exports, compile };
15568
+ return __toCommonJS(main_exports);
15472
15569
  })();