@danielx/civet 0.5.15 → 0.5.17

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/README.md CHANGED
@@ -217,6 +217,11 @@ Things Added that CoffeeScript didn't
217
217
  (assuming they are not preceded by text); this is unambiguous because
218
218
  `>` isn't valid JSX text. For example, `<For> (item) => ...`
219
219
  (where function body can be indented).
220
+ - `#foo` shorthand for `id="foo"`;
221
+ also `#"foo bar"`, `` #`foo ${bar}` ``, `#{expr}`
222
+ - `.foo` shorthand for `class="foo"` (but must be at least one space after
223
+ tag name); also `.foo.bar`, `."foo bar"`, `` .`foo ${bar}` ``, `.{expr}`
224
+ - `"civet react"` flag uses `className` instead of `class`
220
225
  - Any braced object literal can be used as an attribute:
221
226
  `{foo}` → `foo={foo}`, `{foo: bar}` → `foo={bar}`,
222
227
  `{...foo}` remains as is; methods and getters/setters work too.
package/dist/browser.js CHANGED
@@ -780,6 +780,7 @@ ${input.slice(result.pos)}
780
780
  JSXIdentifierName,
781
781
  JSXAttributes,
782
782
  JSXAttribute,
783
+ JSXShorthandString,
783
784
  JSXAttributeName,
784
785
  JSXAttributeInitializer,
785
786
  JSXAttributeValue,
@@ -1099,14 +1100,15 @@ ${input.slice(result.pos)}
1099
1100
  var $R43 = $R(new RegExp("(?!\\p{ID_Continue})", "suy"));
1100
1101
  var $R44 = $R(new RegExp("\\s", "suy"));
1101
1102
  var $R45 = $R(new RegExp("(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$-])*", "suy"));
1102
- var $R46 = $R(new RegExp("[^{}<>\\r\\n]+", "suy"));
1103
- var $R47 = $R(new RegExp("[+-]?", "suy"));
1104
- var $R48 = $R(new RegExp("#![^\\r\\n]*", "suy"));
1105
- var $R49 = $R(new RegExp("[\\t ]*", "suy"));
1106
- var $R50 = $R(new RegExp("[\\s]*", "suy"));
1107
- var $R51 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
1108
- var $R52 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
1109
- var $R53 = $R(new RegExp("[ \\t]*", "suy"));
1103
+ var $R46 = $R(new RegExp("(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+", "suy"));
1104
+ var $R47 = $R(new RegExp("[^{}<>\\r\\n]+", "suy"));
1105
+ var $R48 = $R(new RegExp("[+-]?", "suy"));
1106
+ var $R49 = $R(new RegExp("#![^\\r\\n]*", "suy"));
1107
+ var $R50 = $R(new RegExp("[\\t ]*", "suy"));
1108
+ var $R51 = $R(new RegExp("[\\s]*", "suy"));
1109
+ var $R52 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
1110
+ var $R53 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
1111
+ var $R54 = $R(new RegExp("[ \\t]*", "suy"));
1110
1112
  var Program$0 = $TS($S(Reset, Init, __, $Q(TopLevelStatement), __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
1111
1113
  var statements = $4;
1112
1114
  module.processProgram(statements);
@@ -4968,7 +4970,7 @@ ${input.slice(result.pos)}
4968
4970
  return result;
4969
4971
  }
4970
4972
  }
4971
- var InlineObjectLiteral$0 = $TS($S(InsertInlineOpenBrace, SnugNamedProperty, ImplicitInlineObjectPropertyDelimiter, $Q($S(NamedProperty, ImplicitInlineObjectPropertyDelimiter)), InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4973
+ var InlineObjectLiteral$0 = $TS($S(InsertInlineOpenBrace, SnugNamedProperty, ImplicitInlineObjectPropertyDelimiter, $Q($S($C(Samedent, $Q(_)), NamedProperty, ImplicitInlineObjectPropertyDelimiter)), InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4972
4974
  var open = $1;
4973
4975
  var close = $5;
4974
4976
  return [open, $2, $3, ...$4, close];
@@ -4992,7 +4994,7 @@ ${input.slice(result.pos)}
4992
4994
  }
4993
4995
  }
4994
4996
  var ImplicitInlineObjectPropertyDelimiter$0 = $S($Q(TrailingComment), Comma);
4995
- var ImplicitInlineObjectPropertyDelimiter$1 = $T($S($Y($S(EOS, NamedProperty)), InsertComma), function(value) {
4997
+ var ImplicitInlineObjectPropertyDelimiter$1 = $T($S($Y($S($C(Samedent, $Q(_)), NamedProperty)), InsertComma), function(value) {
4996
4998
  return value[1];
4997
4999
  });
4998
5000
  var ImplicitInlineObjectPropertyDelimiter$2 = $T($Y($S(__, $C($EXPECT($L29, fail, 'ImplicitInlineObjectPropertyDelimiter ":"'), $EXPECT($L15, fail, 'ImplicitInlineObjectPropertyDelimiter ")"'), $EXPECT($L28, fail, 'ImplicitInlineObjectPropertyDelimiter "]"'), $EXPECT($L17, fail, 'ImplicitInlineObjectPropertyDelimiter "}"'), ReservedWord))), function(value) {
@@ -5094,7 +5096,14 @@ ${input.slice(result.pos)}
5094
5096
  value
5095
5097
  };
5096
5098
  });
5097
- var PropertyDefinition$2 = NamedProperty;
5099
+ var PropertyDefinition$2 = $TS($S(__, NamedProperty), function($skip, $loc, $0, $1, $2) {
5100
+ var ws = $1;
5101
+ var prop = $2;
5102
+ return {
5103
+ ...prop,
5104
+ children: [...ws, ...prop.children]
5105
+ };
5106
+ });
5098
5107
  var PropertyDefinition$3 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
5099
5108
  var ws = $1;
5100
5109
  var def = $2;
@@ -5137,9 +5146,9 @@ ${input.slice(result.pos)}
5137
5146
  return result;
5138
5147
  }
5139
5148
  }
5140
- var NamedProperty$0 = $TS($S(__, PropertyName, __, Colon, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5141
- var name = $2;
5142
- var exp = $5;
5149
+ var NamedProperty$0 = $TS($S(PropertyName, __, Colon, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4) {
5150
+ var name = $1;
5151
+ var exp = $4;
5143
5152
  return {
5144
5153
  type: "Property",
5145
5154
  children: $0,
@@ -5478,7 +5487,9 @@ ${input.slice(result.pos)}
5478
5487
  var AssignmentOpSymbol$15 = $T($EXPECT($L45, fail, 'AssignmentOpSymbol "?="'), function(value) {
5479
5488
  return "??=";
5480
5489
  });
5481
- var AssignmentOpSymbol$16 = $EXPECT($L26, fail, 'AssignmentOpSymbol "="');
5490
+ var AssignmentOpSymbol$16 = $T($S($EXPECT($L26, fail, 'AssignmentOpSymbol "="'), $N($EXPECT($L26, fail, 'AssignmentOpSymbol "="'))), function(value) {
5491
+ return value[0];
5492
+ });
5482
5493
  var AssignmentOpSymbol$17 = $T($S(CoffeeWordAssignmentOp), function(value) {
5483
5494
  return value[0];
5484
5495
  });
@@ -5844,9 +5855,7 @@ ${input.slice(result.pos)}
5844
5855
  return result;
5845
5856
  }
5846
5857
  }
5847
- var ElseClause$0 = $T($S($Y(EOS), Samedent, Else, Block), function(value) {
5848
- return [value[1], value[2], value[3]];
5849
- });
5858
+ var ElseClause$0 = $S(Samedent, Else, Block);
5850
5859
  var ElseClause$1 = $S($Q(TrailingComment), Else, Block);
5851
5860
  function ElseClause(state) {
5852
5861
  if (state.events) {
@@ -10907,7 +10916,7 @@ ${input.slice(result.pos)}
10907
10916
  }
10908
10917
  }
10909
10918
  var JSXElement$0 = JSXSelfClosingElement;
10910
- var JSXElement$1 = $TS($S(JSXOpeningElement, $E(JSXChildren), __, JSXClosingElement), function($skip, $loc, $0, $1, $2, $3, $4) {
10919
+ var JSXElement$1 = $TS($S(JSXOpeningElement, $E(JSXChildren), $E(Whitespace), JSXClosingElement), function($skip, $loc, $0, $1, $2, $3, $4) {
10911
10920
  if ($1[1] !== $4[2])
10912
10921
  return $skip;
10913
10922
  return { type: "JSXElement", children: $0 };
@@ -10942,7 +10951,7 @@ ${input.slice(result.pos)}
10942
10951
  return result;
10943
10952
  }
10944
10953
  }
10945
- var JSXSelfClosingElement$0 = $TS($S($EXPECT($L5, fail, 'JSXSelfClosingElement "<"'), $TEXT(JSXElementName), $E(CompactTypeArguments), $E(JSXAttributes), __, $EXPECT($L153, fail, 'JSXSelfClosingElement "/>"')), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10954
+ var JSXSelfClosingElement$0 = $TS($S($EXPECT($L5, fail, 'JSXSelfClosingElement "<"'), $TEXT(JSXElementName), $E(CompactTypeArguments), $E(JSXAttributes), $E(Whitespace), $EXPECT($L153, fail, 'JSXSelfClosingElement "/>"')), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10946
10955
  return { type: "JSXElement", children: $0 };
10947
10956
  });
10948
10957
  function JSXSelfClosingElement(state) {
@@ -10963,7 +10972,7 @@ ${input.slice(result.pos)}
10963
10972
  return result;
10964
10973
  }
10965
10974
  }
10966
- var JSXOpeningElement$0 = $S($EXPECT($L5, fail, 'JSXOpeningElement "<"'), $TEXT(JSXElementName), $E(CompactTypeArguments), $E(JSXAttributes), __, $EXPECT($L27, fail, 'JSXOpeningElement ">"'));
10975
+ var JSXOpeningElement$0 = $S($EXPECT($L5, fail, 'JSXOpeningElement "<"'), $TEXT(JSXElementName), $E(CompactTypeArguments), $E(JSXAttributes), $E(Whitespace), $EXPECT($L27, fail, 'JSXOpeningElement ">"'));
10967
10976
  function JSXOpeningElement(state) {
10968
10977
  if (state.events) {
10969
10978
  const result = state.events.enter?.("JSXOpeningElement", state);
@@ -10982,7 +10991,7 @@ ${input.slice(result.pos)}
10982
10991
  return result;
10983
10992
  }
10984
10993
  }
10985
- var JSXClosingElement$0 = $S($EXPECT($L154, fail, 'JSXClosingElement "</"'), __, $TEXT(JSXElementName), __, $EXPECT($L27, fail, 'JSXClosingElement ">"'));
10994
+ var JSXClosingElement$0 = $S($EXPECT($L154, fail, 'JSXClosingElement "</"'), $E(Whitespace), $TEXT(JSXElementName), $E(Whitespace), $EXPECT($L27, fail, 'JSXClosingElement ">"'));
10986
10995
  function JSXClosingElement(state) {
10987
10996
  if (state.events) {
10988
10997
  const result = state.events.enter?.("JSXClosingElement", state);
@@ -11027,7 +11036,7 @@ ${input.slice(result.pos)}
11027
11036
  return result;
11028
11037
  }
11029
11038
  }
11030
- var JSXFragment$0 = $TS($S($EXPECT($L155, fail, 'JSXFragment "<>"'), $E(JSXChildren), __, $EXPECT($L156, fail, 'JSXFragment "</>"')), function($skip, $loc, $0, $1, $2, $3, $4) {
11039
+ var JSXFragment$0 = $TS($S($EXPECT($L155, fail, 'JSXFragment "<>"'), $E(JSXChildren), $E(Whitespace), $EXPECT($L156, fail, 'JSXFragment "</>"')), function($skip, $loc, $0, $1, $2, $3, $4) {
11031
11040
  if ($2) {
11032
11041
  return { type: "JSXFragment", children: $0, jsxChildren: $2.jsxChildren };
11033
11042
  } else {
@@ -11093,7 +11102,62 @@ ${input.slice(result.pos)}
11093
11102
  return result;
11094
11103
  }
11095
11104
  }
11096
- var JSXAttributes$0 = $Q($S(__, JSXAttribute));
11105
+ var JSXAttributes$0 = $TV($Q($S($E(Whitespace), JSXAttribute)), function($skip, $loc, $0, $1) {
11106
+ const classes = [];
11107
+ let attrs = $0.filter((pair) => {
11108
+ const [, attr] = pair;
11109
+ if (attr.type === "JSXClass") {
11110
+ classes.push(attr.class);
11111
+ return false;
11112
+ }
11113
+ return true;
11114
+ });
11115
+ if (classes.length) {
11116
+ let braced = function(c) {
11117
+ return c[0] === "{" || c[0]?.token === "{";
11118
+ }, parseClass = function(c) {
11119
+ c = c.token || c;
11120
+ if (c.startsWith("'")) {
11121
+ c = '"' + c.slice(1, -1).replace(/\\*"/g, (m) => m.length % 2 == 0 ? m : "\\" + m) + '"';
11122
+ }
11123
+ return JSON.parse(c);
11124
+ };
11125
+ let className = module.config.react ? "className" : "class";
11126
+ attrs = attrs.filter((pair) => {
11127
+ const [, attr] = pair;
11128
+ if ((attr[0][0] === "class" || attr[0][0] === "className") && !attr[0][1]) {
11129
+ className = attr[0][0];
11130
+ classes.push(attr[1][attr[1].length - 1]);
11131
+ return false;
11132
+ }
11133
+ return true;
11134
+ });
11135
+ let classValue;
11136
+ if (classes.some(braced)) {
11137
+ classValue = ["{`"];
11138
+ classes.forEach((c, i) => {
11139
+ if (i > 0)
11140
+ classValue.push(" ");
11141
+ if (braced(c)) {
11142
+ classValue.push("$", c);
11143
+ } else {
11144
+ classValue.push(parseClass(c));
11145
+ }
11146
+ });
11147
+ classValue.push("`}");
11148
+ } else {
11149
+ classValue = JSON.stringify(classes.map(parseClass).join(" "));
11150
+ }
11151
+ attrs.splice(0, 0, [" ", [className, ["=", classValue]]]);
11152
+ }
11153
+ return attrs.map((pair) => {
11154
+ const [space, attr] = pair;
11155
+ if (space && attr[0] === " ") {
11156
+ pair = [space, attr.slice(1)];
11157
+ }
11158
+ return pair;
11159
+ });
11160
+ });
11097
11161
  function JSXAttributes(state) {
11098
11162
  if (state.events) {
11099
11163
  const result = state.events.enter?.("JSXAttributes", state);
@@ -11168,6 +11232,15 @@ ${input.slice(result.pos)}
11168
11232
  }
11169
11233
  });
11170
11234
  var JSXAttribute$2 = $S(InsertInlineOpenBrace, DotDotDot, InlineJSXAttributeValue, InsertCloseBrace);
11235
+ var JSXAttribute$3 = $TS($S($EXPECT($L8, fail, 'JSXAttribute "#"'), JSXShorthandString), function($skip, $loc, $0, $1, $2) {
11236
+ return [" ", "id=", $2];
11237
+ });
11238
+ var JSXAttribute$4 = $TS($S(Dot, JSXShorthandString), function($skip, $loc, $0, $1, $2) {
11239
+ return {
11240
+ type: "JSXClass",
11241
+ class: $2
11242
+ };
11243
+ });
11171
11244
  function JSXAttribute(state) {
11172
11245
  if (state.events) {
11173
11246
  const result = state.events.enter?.("JSXAttribute", state);
@@ -11175,17 +11248,49 @@ ${input.slice(result.pos)}
11175
11248
  return result.cache;
11176
11249
  }
11177
11250
  if (state.tokenize) {
11178
- const result = $TOKEN("JSXAttribute", state, JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state));
11251
+ const result = $TOKEN("JSXAttribute", state, JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state) || JSXAttribute$3(state) || JSXAttribute$4(state));
11179
11252
  if (state.events)
11180
11253
  state.events.exit?.("JSXAttribute", state, result);
11181
11254
  return result;
11182
11255
  } else {
11183
- const result = JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state);
11256
+ const result = JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state) || JSXAttribute$3(state) || JSXAttribute$4(state);
11184
11257
  if (state.events)
11185
11258
  state.events.exit?.("JSXAttribute", state, result);
11186
11259
  return result;
11187
11260
  }
11188
11261
  }
11262
+ var JSXShorthandString$0 = $TR($EXPECT($R46, fail, "JSXShorthandString /(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11263
+ return module.quoteString($0);
11264
+ });
11265
+ var JSXShorthandString$1 = $TS($S(StringLiteral), function($skip, $loc, $0, $1) {
11266
+ if (module.isTemplateLiteral($1)) {
11267
+ return ["{", $1, "}"];
11268
+ } else {
11269
+ return $1;
11270
+ }
11271
+ });
11272
+ var JSXShorthandString$2 = $TS($S(TemplateLiteral), function($skip, $loc, $0, $1) {
11273
+ return ["{", $1, "}"];
11274
+ });
11275
+ var JSXShorthandString$3 = $S(OpenBrace, ExtendedExpression, $E(Whitespace), CloseBrace);
11276
+ function JSXShorthandString(state) {
11277
+ if (state.events) {
11278
+ const result = state.events.enter?.("JSXShorthandString", state);
11279
+ if (result)
11280
+ return result.cache;
11281
+ }
11282
+ if (state.tokenize) {
11283
+ const result = $TOKEN("JSXShorthandString", state, JSXShorthandString$0(state) || JSXShorthandString$1(state) || JSXShorthandString$2(state) || JSXShorthandString$3(state));
11284
+ if (state.events)
11285
+ state.events.exit?.("JSXShorthandString", state, result);
11286
+ return result;
11287
+ } else {
11288
+ const result = JSXShorthandString$0(state) || JSXShorthandString$1(state) || JSXShorthandString$2(state) || JSXShorthandString$3(state);
11289
+ if (state.events)
11290
+ state.events.exit?.("JSXShorthandString", state, result);
11291
+ return result;
11292
+ }
11293
+ }
11189
11294
  var JSXAttributeName$0 = $S(JSXIdentifierName, $E($S(Colon, JSXIdentifierName)));
11190
11295
  var JSXAttributeName$1 = ComputedPropertyName;
11191
11296
  function JSXAttributeName(state) {
@@ -11206,7 +11311,7 @@ ${input.slice(result.pos)}
11206
11311
  return result;
11207
11312
  }
11208
11313
  }
11209
- var JSXAttributeInitializer$0 = $S(__, Equals, __, JSXAttributeValue);
11314
+ var JSXAttributeInitializer$0 = $S($E(Whitespace), Equals, $E(Whitespace), JSXAttributeValue);
11210
11315
  function JSXAttributeInitializer(state) {
11211
11316
  if (state.events) {
11212
11317
  const result = state.events.enter?.("JSXAttributeInitializer", state);
@@ -11230,7 +11335,7 @@ ${input.slice(result.pos)}
11230
11335
  return $skip;
11231
11336
  return $1;
11232
11337
  });
11233
- var JSXAttributeValue$1 = $S(OpenBrace, ExtendedExpression, __, CloseBrace);
11338
+ var JSXAttributeValue$1 = $S(OpenBrace, ExtendedExpression, $E(Whitespace), CloseBrace);
11234
11339
  var JSXAttributeValue$2 = JSXElement;
11235
11340
  var JSXAttributeValue$3 = JSXFragment;
11236
11341
  var JSXAttributeValue$4 = $S(InsertInlineOpenBrace, InlineJSXAttributeValue, InsertCloseBrace);
@@ -11630,7 +11735,7 @@ ${input.slice(result.pos)}
11630
11735
  return result;
11631
11736
  }
11632
11737
  }
11633
- var JSXText$0 = $TR($EXPECT($R46, fail, "JSXText /[^{}<>\\r\\n]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11738
+ var JSXText$0 = $TR($EXPECT($R47, fail, "JSXText /[^{}<>\\r\\n]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11634
11739
  return {
11635
11740
  type: "JSXText",
11636
11741
  token: $0,
@@ -11655,7 +11760,7 @@ ${input.slice(result.pos)}
11655
11760
  return result;
11656
11761
  }
11657
11762
  }
11658
- var JSXChildExpression$0 = $S(__, $E($S(DotDotDot, __)), ExtendedExpression);
11763
+ var JSXChildExpression$0 = $S($E(Whitespace), $E($S(DotDotDot, $E(Whitespace))), ExtendedExpression);
11659
11764
  function JSXChildExpression(state) {
11660
11765
  if (state.events) {
11661
11766
  const result = state.events.enter?.("JSXChildExpression", state);
@@ -11964,7 +12069,7 @@ ${input.slice(result.pos)}
11964
12069
  return result;
11965
12070
  }
11966
12071
  }
11967
- var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R47, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L129, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R4, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
12072
+ var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R48, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L129, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R4, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
11968
12073
  function TypeIndexSignature(state) {
11969
12074
  if (state.events) {
11970
12075
  const result = state.events.enter?.("TypeIndexSignature", state);
@@ -12566,7 +12671,7 @@ ${input.slice(result.pos)}
12566
12671
  return result;
12567
12672
  }
12568
12673
  }
12569
- var Shebang$0 = $S($R$0($EXPECT($R48, fail, "Shebang /#![^\\r\\n]*/")), EOL);
12674
+ var Shebang$0 = $S($R$0($EXPECT($R49, fail, "Shebang /#![^\\r\\n]*/")), EOL);
12570
12675
  function Shebang(state) {
12571
12676
  if (state.events) {
12572
12677
  const result = state.events.enter?.("Shebang", state);
@@ -12585,11 +12690,11 @@ ${input.slice(result.pos)}
12585
12690
  return result;
12586
12691
  }
12587
12692
  }
12588
- var CivetPrologue$0 = $T($S($EXPECT($R49, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
12693
+ var CivetPrologue$0 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
12589
12694
  var content = value[2];
12590
12695
  return content;
12591
12696
  });
12592
- var CivetPrologue$1 = $T($S($EXPECT($R49, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
12697
+ var CivetPrologue$1 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
12593
12698
  var content = value[2];
12594
12699
  return content;
12595
12700
  });
@@ -12611,7 +12716,7 @@ ${input.slice(result.pos)}
12611
12716
  return result;
12612
12717
  }
12613
12718
  }
12614
- var CivetPrologueContent$0 = $TS($S($EXPECT($L165, fail, 'CivetPrologueContent "civet"'), $Q(CivetOption), $EXPECT($R50, fail, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3) {
12719
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L165, fail, 'CivetPrologueContent "civet"'), $Q(CivetOption), $EXPECT($R51, fail, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3) {
12615
12720
  var options = $2;
12616
12721
  return {
12617
12722
  type: "CivetPrologue",
@@ -12637,7 +12742,7 @@ ${input.slice(result.pos)}
12637
12742
  return result;
12638
12743
  }
12639
12744
  }
12640
- var CivetOption$0 = $TR($EXPECT($R51, fail, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12745
+ var CivetOption$0 = $TR($EXPECT($R52, fail, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12641
12746
  const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
12642
12747
  if (l)
12643
12748
  return l.toUpperCase();
@@ -12669,7 +12774,7 @@ ${input.slice(result.pos)}
12669
12774
  return result;
12670
12775
  }
12671
12776
  }
12672
- var UnknownPrologue$0 = $S($R$0($EXPECT($R49, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(StatementDelimiter), EOS);
12777
+ var UnknownPrologue$0 = $S($R$0($EXPECT($R50, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(StatementDelimiter), EOS);
12673
12778
  function UnknownPrologue(state) {
12674
12779
  if (state.events) {
12675
12780
  const result = state.events.enter?.("UnknownPrologue", state);
@@ -12727,7 +12832,7 @@ ${input.slice(result.pos)}
12727
12832
  return result;
12728
12833
  }
12729
12834
  }
12730
- var EOL$0 = $TR($EXPECT($R52, fail, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12835
+ var EOL$0 = $TR($EXPECT($R53, fail, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12731
12836
  return { $loc, token: $0 };
12732
12837
  });
12733
12838
  function EOL(state) {
@@ -13368,6 +13473,7 @@ ${input.slice(result.pos)}
13368
13473
  coffeeNot: false,
13369
13474
  coffeeOf: false,
13370
13475
  implicitReturns: true,
13476
+ react: false,
13371
13477
  solid: false,
13372
13478
  client: false,
13373
13479
  server: false,
@@ -13525,6 +13631,14 @@ ${input.slice(result.pos)}
13525
13631
  module.modifyString = function(str) {
13526
13632
  return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
13527
13633
  };
13634
+ module.quoteString = function(str) {
13635
+ str = str.replace(/\\/g, "\\\\");
13636
+ if (str.includes('"') && !str.includes("'")) {
13637
+ return "'" + str.replace(/'/g, "\\'") + "'";
13638
+ } else {
13639
+ return '"' + str.replace(/"/g, '\\"') + '"';
13640
+ }
13641
+ };
13528
13642
  });
13529
13643
  function Reset(state) {
13530
13644
  if (state.events) {
@@ -14503,7 +14617,7 @@ ${input.slice(result.pos)}
14503
14617
  return result;
14504
14618
  }
14505
14619
  }
14506
- var Indent$0 = $TR($EXPECT($R53, fail, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
14620
+ var Indent$0 = $TR($EXPECT($R54, fail, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
14507
14621
  let level;
14508
14622
  if (module.config.tab) {
14509
14623
  const tabs = $0.match(/\t/g);
@@ -15126,7 +15240,7 @@ ${input.slice(result.pos)}
15126
15240
  ({ prune } = gen = require_generate());
15127
15241
  ({ SourceMap, base64Encode } = util = require_util());
15128
15242
  defaultOptions = {};
15129
- uncacheable = /* @__PURE__ */ new Set(["TrackIndented", "Samedent", "IndentedFurther", "PushIndent", "PopIndent", "Nested", "InsertIndent", "Arguments", "ArgumentsWithTrailingCallExpressions", "ApplicationStart", "CallExpression", "CallExpressionRest", "LeftHandSideExpression", "ActualAssignment", "UpdateExpression", "UnaryExpression", "BinaryOpExpression", "BinaryOpRHS", "ConditionalExpression", "ShortCircuitExpression", "ImplicitNestedBlock", "ObjectLiteral", "NestedObject", "NestedImplicitObjectLiteral", "BracedObjectLiteralContent", "NestedPropertyDefinitions", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedBlockStatement", "NestedElement", "NestedElementList", "NestedBindingElement", "NestedBindingElements", "NestedInterfaceProperty", "MemberExpression", "PrimaryExpression", "IndentedApplicationAllowed", "ExpressionWithIndentedApplicationSuppressed", "SuppressIndentedApplication", "AssignmentExpressionTail", "AssignmentExpression", "ExtendedExpression", "Expression", "MemberExpressionRest", "ElseClause", "CoffeeCommentEnabled", "SingleLineComment", "Debugger", "JSXElement", "TypedJSXElement", "JSXFragment", "TypedJSXFragment", "JSXChild", "JSXChildren", "JSXNestedChildren", "JSXMixedChildren"]);
15243
+ 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"]);
15130
15244
  module.exports = {
15131
15245
  parse,
15132
15246
  compile: function(src, options = defaultOptions) {
package/dist/civet CHANGED
@@ -6,7 +6,7 @@ if (process.argv.includes("--version")) {
6
6
  process.exit(0);
7
7
  }
8
8
  if (process.argv.includes("--help")) {
9
- process.stdout.write(` \u2584\u2584\xB7 \u25AA \u258C \u2590\xB7\u2584\u2584\u2584 .\u2584\u2584\u2584\u2584\u2584
9
+ process.stderr.write(` \u2584\u2584\xB7 \u25AA \u258C \u2590\xB7\u2584\u2584\u2584 .\u2584\u2584\u2584\u2584\u2584
10
10
  \u2590\u2588 \u258C\u25AA\u2588\u2588 \u25AA\u2588\xB7\u2588\u258C\u2580\u2584.\u2580\xB7\u2022\u2588\u2588 _._ _,-'""\`-._
11
11
  \u2588\u2588 \u2584\u2584\u2590\u2588\xB7\u2590\u2588\u2590\u2588\u2022\u2590\u2580\u2580\u25AA\u2584 \u2590\u2588.\u25AA (,-.\`._,'( |\\\`-/|
12
12
  \u2590\u2588\u2588\u2588\u258C\u2590\u2588\u258C \u2588\u2588\u2588 \u2590\u2588\u2584\u2584\u258C \u2590\u2588\u258C\xB7 \`-.-' \\ )-\`( , o o)
@@ -47,15 +47,14 @@ readLines = function(rl) {
47
47
  return parts.push(buffer + "\n");
48
48
  });
49
49
  rl.on("SIGINT", function() {
50
- rl.write("^C\n");
51
- return reject();
50
+ return reject("^C");
52
51
  });
53
52
  return rl.on("close", function() {
54
53
  return resolve(parts.join(""));
55
54
  });
56
55
  });
57
56
  };
58
- readLines(readline.createInterface(process.stdin)).then(function(input) {
57
+ readLines(readline.createInterface(process.stdin, process.stdout)).then(function(input) {
59
58
  var ast, filename, inlineMap, js, noCache, output;
60
59
  ast = process.argv.includes("--ast");
61
60
  noCache = process.argv.includes("--no-cache");
package/dist/main.js CHANGED
@@ -779,6 +779,7 @@ ${input.slice(result.pos)}
779
779
  JSXIdentifierName,
780
780
  JSXAttributes,
781
781
  JSXAttribute,
782
+ JSXShorthandString,
782
783
  JSXAttributeName,
783
784
  JSXAttributeInitializer,
784
785
  JSXAttributeValue,
@@ -1098,14 +1099,15 @@ ${input.slice(result.pos)}
1098
1099
  var $R43 = $R(new RegExp("(?!\\p{ID_Continue})", "suy"));
1099
1100
  var $R44 = $R(new RegExp("\\s", "suy"));
1100
1101
  var $R45 = $R(new RegExp("(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$-])*", "suy"));
1101
- var $R46 = $R(new RegExp("[^{}<>\\r\\n]+", "suy"));
1102
- var $R47 = $R(new RegExp("[+-]?", "suy"));
1103
- var $R48 = $R(new RegExp("#![^\\r\\n]*", "suy"));
1104
- var $R49 = $R(new RegExp("[\\t ]*", "suy"));
1105
- var $R50 = $R(new RegExp("[\\s]*", "suy"));
1106
- var $R51 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
1107
- var $R52 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
1108
- var $R53 = $R(new RegExp("[ \\t]*", "suy"));
1102
+ var $R46 = $R(new RegExp("(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+", "suy"));
1103
+ var $R47 = $R(new RegExp("[^{}<>\\r\\n]+", "suy"));
1104
+ var $R48 = $R(new RegExp("[+-]?", "suy"));
1105
+ var $R49 = $R(new RegExp("#![^\\r\\n]*", "suy"));
1106
+ var $R50 = $R(new RegExp("[\\t ]*", "suy"));
1107
+ var $R51 = $R(new RegExp("[\\s]*", "suy"));
1108
+ var $R52 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
1109
+ var $R53 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
1110
+ var $R54 = $R(new RegExp("[ \\t]*", "suy"));
1109
1111
  var Program$0 = $TS($S(Reset, Init, __, $Q(TopLevelStatement), __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
1110
1112
  var statements = $4;
1111
1113
  module2.processProgram(statements);
@@ -4967,7 +4969,7 @@ ${input.slice(result.pos)}
4967
4969
  return result;
4968
4970
  }
4969
4971
  }
4970
- var InlineObjectLiteral$0 = $TS($S(InsertInlineOpenBrace, SnugNamedProperty, ImplicitInlineObjectPropertyDelimiter, $Q($S(NamedProperty, ImplicitInlineObjectPropertyDelimiter)), InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4972
+ var InlineObjectLiteral$0 = $TS($S(InsertInlineOpenBrace, SnugNamedProperty, ImplicitInlineObjectPropertyDelimiter, $Q($S($C(Samedent, $Q(_)), NamedProperty, ImplicitInlineObjectPropertyDelimiter)), InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4971
4973
  var open = $1;
4972
4974
  var close = $5;
4973
4975
  return [open, $2, $3, ...$4, close];
@@ -4991,7 +4993,7 @@ ${input.slice(result.pos)}
4991
4993
  }
4992
4994
  }
4993
4995
  var ImplicitInlineObjectPropertyDelimiter$0 = $S($Q(TrailingComment), Comma);
4994
- var ImplicitInlineObjectPropertyDelimiter$1 = $T($S($Y($S(EOS, NamedProperty)), InsertComma), function(value) {
4996
+ var ImplicitInlineObjectPropertyDelimiter$1 = $T($S($Y($S($C(Samedent, $Q(_)), NamedProperty)), InsertComma), function(value) {
4995
4997
  return value[1];
4996
4998
  });
4997
4999
  var ImplicitInlineObjectPropertyDelimiter$2 = $T($Y($S(__, $C($EXPECT($L29, fail, 'ImplicitInlineObjectPropertyDelimiter ":"'), $EXPECT($L15, fail, 'ImplicitInlineObjectPropertyDelimiter ")"'), $EXPECT($L28, fail, 'ImplicitInlineObjectPropertyDelimiter "]"'), $EXPECT($L17, fail, 'ImplicitInlineObjectPropertyDelimiter "}"'), ReservedWord))), function(value) {
@@ -5093,7 +5095,14 @@ ${input.slice(result.pos)}
5093
5095
  value
5094
5096
  };
5095
5097
  });
5096
- var PropertyDefinition$2 = NamedProperty;
5098
+ var PropertyDefinition$2 = $TS($S(__, NamedProperty), function($skip, $loc, $0, $1, $2) {
5099
+ var ws = $1;
5100
+ var prop = $2;
5101
+ return {
5102
+ ...prop,
5103
+ children: [...ws, ...prop.children]
5104
+ };
5105
+ });
5097
5106
  var PropertyDefinition$3 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
5098
5107
  var ws = $1;
5099
5108
  var def = $2;
@@ -5136,9 +5145,9 @@ ${input.slice(result.pos)}
5136
5145
  return result;
5137
5146
  }
5138
5147
  }
5139
- var NamedProperty$0 = $TS($S(__, PropertyName, __, Colon, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5140
- var name = $2;
5141
- var exp = $5;
5148
+ var NamedProperty$0 = $TS($S(PropertyName, __, Colon, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4) {
5149
+ var name = $1;
5150
+ var exp = $4;
5142
5151
  return {
5143
5152
  type: "Property",
5144
5153
  children: $0,
@@ -5477,7 +5486,9 @@ ${input.slice(result.pos)}
5477
5486
  var AssignmentOpSymbol$15 = $T($EXPECT($L45, fail, 'AssignmentOpSymbol "?="'), function(value) {
5478
5487
  return "??=";
5479
5488
  });
5480
- var AssignmentOpSymbol$16 = $EXPECT($L26, fail, 'AssignmentOpSymbol "="');
5489
+ var AssignmentOpSymbol$16 = $T($S($EXPECT($L26, fail, 'AssignmentOpSymbol "="'), $N($EXPECT($L26, fail, 'AssignmentOpSymbol "="'))), function(value) {
5490
+ return value[0];
5491
+ });
5481
5492
  var AssignmentOpSymbol$17 = $T($S(CoffeeWordAssignmentOp), function(value) {
5482
5493
  return value[0];
5483
5494
  });
@@ -5843,9 +5854,7 @@ ${input.slice(result.pos)}
5843
5854
  return result;
5844
5855
  }
5845
5856
  }
5846
- var ElseClause$0 = $T($S($Y(EOS), Samedent, Else, Block), function(value) {
5847
- return [value[1], value[2], value[3]];
5848
- });
5857
+ var ElseClause$0 = $S(Samedent, Else, Block);
5849
5858
  var ElseClause$1 = $S($Q(TrailingComment), Else, Block);
5850
5859
  function ElseClause(state) {
5851
5860
  if (state.events) {
@@ -10906,7 +10915,7 @@ ${input.slice(result.pos)}
10906
10915
  }
10907
10916
  }
10908
10917
  var JSXElement$0 = JSXSelfClosingElement;
10909
- var JSXElement$1 = $TS($S(JSXOpeningElement, $E(JSXChildren), __, JSXClosingElement), function($skip, $loc, $0, $1, $2, $3, $4) {
10918
+ var JSXElement$1 = $TS($S(JSXOpeningElement, $E(JSXChildren), $E(Whitespace), JSXClosingElement), function($skip, $loc, $0, $1, $2, $3, $4) {
10910
10919
  if ($1[1] !== $4[2])
10911
10920
  return $skip;
10912
10921
  return { type: "JSXElement", children: $0 };
@@ -10941,7 +10950,7 @@ ${input.slice(result.pos)}
10941
10950
  return result;
10942
10951
  }
10943
10952
  }
10944
- var JSXSelfClosingElement$0 = $TS($S($EXPECT($L5, fail, 'JSXSelfClosingElement "<"'), $TEXT(JSXElementName), $E(CompactTypeArguments), $E(JSXAttributes), __, $EXPECT($L153, fail, 'JSXSelfClosingElement "/>"')), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10953
+ var JSXSelfClosingElement$0 = $TS($S($EXPECT($L5, fail, 'JSXSelfClosingElement "<"'), $TEXT(JSXElementName), $E(CompactTypeArguments), $E(JSXAttributes), $E(Whitespace), $EXPECT($L153, fail, 'JSXSelfClosingElement "/>"')), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10945
10954
  return { type: "JSXElement", children: $0 };
10946
10955
  });
10947
10956
  function JSXSelfClosingElement(state) {
@@ -10962,7 +10971,7 @@ ${input.slice(result.pos)}
10962
10971
  return result;
10963
10972
  }
10964
10973
  }
10965
- var JSXOpeningElement$0 = $S($EXPECT($L5, fail, 'JSXOpeningElement "<"'), $TEXT(JSXElementName), $E(CompactTypeArguments), $E(JSXAttributes), __, $EXPECT($L27, fail, 'JSXOpeningElement ">"'));
10974
+ var JSXOpeningElement$0 = $S($EXPECT($L5, fail, 'JSXOpeningElement "<"'), $TEXT(JSXElementName), $E(CompactTypeArguments), $E(JSXAttributes), $E(Whitespace), $EXPECT($L27, fail, 'JSXOpeningElement ">"'));
10966
10975
  function JSXOpeningElement(state) {
10967
10976
  if (state.events) {
10968
10977
  const result = state.events.enter?.("JSXOpeningElement", state);
@@ -10981,7 +10990,7 @@ ${input.slice(result.pos)}
10981
10990
  return result;
10982
10991
  }
10983
10992
  }
10984
- var JSXClosingElement$0 = $S($EXPECT($L154, fail, 'JSXClosingElement "</"'), __, $TEXT(JSXElementName), __, $EXPECT($L27, fail, 'JSXClosingElement ">"'));
10993
+ var JSXClosingElement$0 = $S($EXPECT($L154, fail, 'JSXClosingElement "</"'), $E(Whitespace), $TEXT(JSXElementName), $E(Whitespace), $EXPECT($L27, fail, 'JSXClosingElement ">"'));
10985
10994
  function JSXClosingElement(state) {
10986
10995
  if (state.events) {
10987
10996
  const result = state.events.enter?.("JSXClosingElement", state);
@@ -11026,7 +11035,7 @@ ${input.slice(result.pos)}
11026
11035
  return result;
11027
11036
  }
11028
11037
  }
11029
- var JSXFragment$0 = $TS($S($EXPECT($L155, fail, 'JSXFragment "<>"'), $E(JSXChildren), __, $EXPECT($L156, fail, 'JSXFragment "</>"')), function($skip, $loc, $0, $1, $2, $3, $4) {
11038
+ var JSXFragment$0 = $TS($S($EXPECT($L155, fail, 'JSXFragment "<>"'), $E(JSXChildren), $E(Whitespace), $EXPECT($L156, fail, 'JSXFragment "</>"')), function($skip, $loc, $0, $1, $2, $3, $4) {
11030
11039
  if ($2) {
11031
11040
  return { type: "JSXFragment", children: $0, jsxChildren: $2.jsxChildren };
11032
11041
  } else {
@@ -11092,7 +11101,62 @@ ${input.slice(result.pos)}
11092
11101
  return result;
11093
11102
  }
11094
11103
  }
11095
- var JSXAttributes$0 = $Q($S(__, JSXAttribute));
11104
+ var JSXAttributes$0 = $TV($Q($S($E(Whitespace), JSXAttribute)), function($skip, $loc, $0, $1) {
11105
+ const classes = [];
11106
+ let attrs = $0.filter((pair) => {
11107
+ const [, attr] = pair;
11108
+ if (attr.type === "JSXClass") {
11109
+ classes.push(attr.class);
11110
+ return false;
11111
+ }
11112
+ return true;
11113
+ });
11114
+ if (classes.length) {
11115
+ let braced = function(c) {
11116
+ return c[0] === "{" || c[0]?.token === "{";
11117
+ }, parseClass = function(c) {
11118
+ c = c.token || c;
11119
+ if (c.startsWith("'")) {
11120
+ c = '"' + c.slice(1, -1).replace(/\\*"/g, (m) => m.length % 2 == 0 ? m : "\\" + m) + '"';
11121
+ }
11122
+ return JSON.parse(c);
11123
+ };
11124
+ let className = module2.config.react ? "className" : "class";
11125
+ attrs = attrs.filter((pair) => {
11126
+ const [, attr] = pair;
11127
+ if ((attr[0][0] === "class" || attr[0][0] === "className") && !attr[0][1]) {
11128
+ className = attr[0][0];
11129
+ classes.push(attr[1][attr[1].length - 1]);
11130
+ return false;
11131
+ }
11132
+ return true;
11133
+ });
11134
+ let classValue;
11135
+ if (classes.some(braced)) {
11136
+ classValue = ["{`"];
11137
+ classes.forEach((c, i) => {
11138
+ if (i > 0)
11139
+ classValue.push(" ");
11140
+ if (braced(c)) {
11141
+ classValue.push("$", c);
11142
+ } else {
11143
+ classValue.push(parseClass(c));
11144
+ }
11145
+ });
11146
+ classValue.push("`}");
11147
+ } else {
11148
+ classValue = JSON.stringify(classes.map(parseClass).join(" "));
11149
+ }
11150
+ attrs.splice(0, 0, [" ", [className, ["=", classValue]]]);
11151
+ }
11152
+ return attrs.map((pair) => {
11153
+ const [space, attr] = pair;
11154
+ if (space && attr[0] === " ") {
11155
+ pair = [space, attr.slice(1)];
11156
+ }
11157
+ return pair;
11158
+ });
11159
+ });
11096
11160
  function JSXAttributes(state) {
11097
11161
  if (state.events) {
11098
11162
  const result = state.events.enter?.("JSXAttributes", state);
@@ -11167,6 +11231,15 @@ ${input.slice(result.pos)}
11167
11231
  }
11168
11232
  });
11169
11233
  var JSXAttribute$2 = $S(InsertInlineOpenBrace, DotDotDot, InlineJSXAttributeValue, InsertCloseBrace);
11234
+ var JSXAttribute$3 = $TS($S($EXPECT($L8, fail, 'JSXAttribute "#"'), JSXShorthandString), function($skip, $loc, $0, $1, $2) {
11235
+ return [" ", "id=", $2];
11236
+ });
11237
+ var JSXAttribute$4 = $TS($S(Dot, JSXShorthandString), function($skip, $loc, $0, $1, $2) {
11238
+ return {
11239
+ type: "JSXClass",
11240
+ class: $2
11241
+ };
11242
+ });
11170
11243
  function JSXAttribute(state) {
11171
11244
  if (state.events) {
11172
11245
  const result = state.events.enter?.("JSXAttribute", state);
@@ -11174,17 +11247,49 @@ ${input.slice(result.pos)}
11174
11247
  return result.cache;
11175
11248
  }
11176
11249
  if (state.tokenize) {
11177
- const result = $TOKEN("JSXAttribute", state, JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state));
11250
+ const result = $TOKEN("JSXAttribute", state, JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state) || JSXAttribute$3(state) || JSXAttribute$4(state));
11178
11251
  if (state.events)
11179
11252
  state.events.exit?.("JSXAttribute", state, result);
11180
11253
  return result;
11181
11254
  } else {
11182
- const result = JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state);
11255
+ const result = JSXAttribute$0(state) || JSXAttribute$1(state) || JSXAttribute$2(state) || JSXAttribute$3(state) || JSXAttribute$4(state);
11183
11256
  if (state.events)
11184
11257
  state.events.exit?.("JSXAttribute", state, result);
11185
11258
  return result;
11186
11259
  }
11187
11260
  }
11261
+ var JSXShorthandString$0 = $TR($EXPECT($R46, fail, "JSXShorthandString /(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11262
+ return module2.quoteString($0);
11263
+ });
11264
+ var JSXShorthandString$1 = $TS($S(StringLiteral), function($skip, $loc, $0, $1) {
11265
+ if (module2.isTemplateLiteral($1)) {
11266
+ return ["{", $1, "}"];
11267
+ } else {
11268
+ return $1;
11269
+ }
11270
+ });
11271
+ var JSXShorthandString$2 = $TS($S(TemplateLiteral), function($skip, $loc, $0, $1) {
11272
+ return ["{", $1, "}"];
11273
+ });
11274
+ var JSXShorthandString$3 = $S(OpenBrace, ExtendedExpression, $E(Whitespace), CloseBrace);
11275
+ function JSXShorthandString(state) {
11276
+ if (state.events) {
11277
+ const result = state.events.enter?.("JSXShorthandString", state);
11278
+ if (result)
11279
+ return result.cache;
11280
+ }
11281
+ if (state.tokenize) {
11282
+ const result = $TOKEN("JSXShorthandString", state, JSXShorthandString$0(state) || JSXShorthandString$1(state) || JSXShorthandString$2(state) || JSXShorthandString$3(state));
11283
+ if (state.events)
11284
+ state.events.exit?.("JSXShorthandString", state, result);
11285
+ return result;
11286
+ } else {
11287
+ const result = JSXShorthandString$0(state) || JSXShorthandString$1(state) || JSXShorthandString$2(state) || JSXShorthandString$3(state);
11288
+ if (state.events)
11289
+ state.events.exit?.("JSXShorthandString", state, result);
11290
+ return result;
11291
+ }
11292
+ }
11188
11293
  var JSXAttributeName$0 = $S(JSXIdentifierName, $E($S(Colon, JSXIdentifierName)));
11189
11294
  var JSXAttributeName$1 = ComputedPropertyName;
11190
11295
  function JSXAttributeName(state) {
@@ -11205,7 +11310,7 @@ ${input.slice(result.pos)}
11205
11310
  return result;
11206
11311
  }
11207
11312
  }
11208
- var JSXAttributeInitializer$0 = $S(__, Equals, __, JSXAttributeValue);
11313
+ var JSXAttributeInitializer$0 = $S($E(Whitespace), Equals, $E(Whitespace), JSXAttributeValue);
11209
11314
  function JSXAttributeInitializer(state) {
11210
11315
  if (state.events) {
11211
11316
  const result = state.events.enter?.("JSXAttributeInitializer", state);
@@ -11229,7 +11334,7 @@ ${input.slice(result.pos)}
11229
11334
  return $skip;
11230
11335
  return $1;
11231
11336
  });
11232
- var JSXAttributeValue$1 = $S(OpenBrace, ExtendedExpression, __, CloseBrace);
11337
+ var JSXAttributeValue$1 = $S(OpenBrace, ExtendedExpression, $E(Whitespace), CloseBrace);
11233
11338
  var JSXAttributeValue$2 = JSXElement;
11234
11339
  var JSXAttributeValue$3 = JSXFragment;
11235
11340
  var JSXAttributeValue$4 = $S(InsertInlineOpenBrace, InlineJSXAttributeValue, InsertCloseBrace);
@@ -11629,7 +11734,7 @@ ${input.slice(result.pos)}
11629
11734
  return result;
11630
11735
  }
11631
11736
  }
11632
- var JSXText$0 = $TR($EXPECT($R46, fail, "JSXText /[^{}<>\\r\\n]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11737
+ var JSXText$0 = $TR($EXPECT($R47, fail, "JSXText /[^{}<>\\r\\n]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11633
11738
  return {
11634
11739
  type: "JSXText",
11635
11740
  token: $0,
@@ -11654,7 +11759,7 @@ ${input.slice(result.pos)}
11654
11759
  return result;
11655
11760
  }
11656
11761
  }
11657
- var JSXChildExpression$0 = $S(__, $E($S(DotDotDot, __)), ExtendedExpression);
11762
+ var JSXChildExpression$0 = $S($E(Whitespace), $E($S(DotDotDot, $E(Whitespace))), ExtendedExpression);
11658
11763
  function JSXChildExpression(state) {
11659
11764
  if (state.events) {
11660
11765
  const result = state.events.enter?.("JSXChildExpression", state);
@@ -11963,7 +12068,7 @@ ${input.slice(result.pos)}
11963
12068
  return result;
11964
12069
  }
11965
12070
  }
11966
- var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R47, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L129, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R4, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
12071
+ var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R48, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L129, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R4, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
11967
12072
  function TypeIndexSignature(state) {
11968
12073
  if (state.events) {
11969
12074
  const result = state.events.enter?.("TypeIndexSignature", state);
@@ -12565,7 +12670,7 @@ ${input.slice(result.pos)}
12565
12670
  return result;
12566
12671
  }
12567
12672
  }
12568
- var Shebang$0 = $S($R$0($EXPECT($R48, fail, "Shebang /#![^\\r\\n]*/")), EOL);
12673
+ var Shebang$0 = $S($R$0($EXPECT($R49, fail, "Shebang /#![^\\r\\n]*/")), EOL);
12569
12674
  function Shebang(state) {
12570
12675
  if (state.events) {
12571
12676
  const result = state.events.enter?.("Shebang", state);
@@ -12584,11 +12689,11 @@ ${input.slice(result.pos)}
12584
12689
  return result;
12585
12690
  }
12586
12691
  }
12587
- var CivetPrologue$0 = $T($S($EXPECT($R49, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
12692
+ var CivetPrologue$0 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
12588
12693
  var content = value[2];
12589
12694
  return content;
12590
12695
  });
12591
- var CivetPrologue$1 = $T($S($EXPECT($R49, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
12696
+ var CivetPrologue$1 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
12592
12697
  var content = value[2];
12593
12698
  return content;
12594
12699
  });
@@ -12610,7 +12715,7 @@ ${input.slice(result.pos)}
12610
12715
  return result;
12611
12716
  }
12612
12717
  }
12613
- var CivetPrologueContent$0 = $TS($S($EXPECT($L165, fail, 'CivetPrologueContent "civet"'), $Q(CivetOption), $EXPECT($R50, fail, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3) {
12718
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L165, fail, 'CivetPrologueContent "civet"'), $Q(CivetOption), $EXPECT($R51, fail, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3) {
12614
12719
  var options = $2;
12615
12720
  return {
12616
12721
  type: "CivetPrologue",
@@ -12636,7 +12741,7 @@ ${input.slice(result.pos)}
12636
12741
  return result;
12637
12742
  }
12638
12743
  }
12639
- var CivetOption$0 = $TR($EXPECT($R51, fail, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12744
+ var CivetOption$0 = $TR($EXPECT($R52, fail, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12640
12745
  const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
12641
12746
  if (l)
12642
12747
  return l.toUpperCase();
@@ -12668,7 +12773,7 @@ ${input.slice(result.pos)}
12668
12773
  return result;
12669
12774
  }
12670
12775
  }
12671
- var UnknownPrologue$0 = $S($R$0($EXPECT($R49, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(StatementDelimiter), EOS);
12776
+ var UnknownPrologue$0 = $S($R$0($EXPECT($R50, fail, "UnknownPrologue /[\\t ]*/")), BasicStringLiteral, $TEXT(StatementDelimiter), EOS);
12672
12777
  function UnknownPrologue(state) {
12673
12778
  if (state.events) {
12674
12779
  const result = state.events.enter?.("UnknownPrologue", state);
@@ -12726,7 +12831,7 @@ ${input.slice(result.pos)}
12726
12831
  return result;
12727
12832
  }
12728
12833
  }
12729
- var EOL$0 = $TR($EXPECT($R52, fail, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12834
+ var EOL$0 = $TR($EXPECT($R53, fail, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12730
12835
  return { $loc, token: $0 };
12731
12836
  });
12732
12837
  function EOL(state) {
@@ -13367,6 +13472,7 @@ ${input.slice(result.pos)}
13367
13472
  coffeeNot: false,
13368
13473
  coffeeOf: false,
13369
13474
  implicitReturns: true,
13475
+ react: false,
13370
13476
  solid: false,
13371
13477
  client: false,
13372
13478
  server: false,
@@ -13524,6 +13630,14 @@ ${input.slice(result.pos)}
13524
13630
  module2.modifyString = function(str) {
13525
13631
  return str.replace(/(^.?|[^\\]{2})(\\\\)*\n/g, "$1$2\\n");
13526
13632
  };
13633
+ module2.quoteString = function(str) {
13634
+ str = str.replace(/\\/g, "\\\\");
13635
+ if (str.includes('"') && !str.includes("'")) {
13636
+ return "'" + str.replace(/'/g, "\\'") + "'";
13637
+ } else {
13638
+ return '"' + str.replace(/"/g, '\\"') + '"';
13639
+ }
13640
+ };
13527
13641
  });
13528
13642
  function Reset(state) {
13529
13643
  if (state.events) {
@@ -14502,7 +14616,7 @@ ${input.slice(result.pos)}
14502
14616
  return result;
14503
14617
  }
14504
14618
  }
14505
- var Indent$0 = $TR($EXPECT($R53, fail, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
14619
+ var Indent$0 = $TR($EXPECT($R54, fail, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
14506
14620
  let level;
14507
14621
  if (module2.config.tab) {
14508
14622
  const tabs = $0.match(/\t/g);
@@ -15123,7 +15237,7 @@ var util;
15123
15237
  ({ prune } = gen = require_generate());
15124
15238
  ({ SourceMap, base64Encode } = util = require_util());
15125
15239
  defaultOptions = {};
15126
- uncacheable = /* @__PURE__ */ new Set(["TrackIndented", "Samedent", "IndentedFurther", "PushIndent", "PopIndent", "Nested", "InsertIndent", "Arguments", "ArgumentsWithTrailingCallExpressions", "ApplicationStart", "CallExpression", "CallExpressionRest", "LeftHandSideExpression", "ActualAssignment", "UpdateExpression", "UnaryExpression", "BinaryOpExpression", "BinaryOpRHS", "ConditionalExpression", "ShortCircuitExpression", "ImplicitNestedBlock", "ObjectLiteral", "NestedObject", "NestedImplicitObjectLiteral", "BracedObjectLiteralContent", "NestedPropertyDefinitions", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedBlockStatement", "NestedElement", "NestedElementList", "NestedBindingElement", "NestedBindingElements", "NestedInterfaceProperty", "MemberExpression", "PrimaryExpression", "IndentedApplicationAllowed", "ExpressionWithIndentedApplicationSuppressed", "SuppressIndentedApplication", "AssignmentExpressionTail", "AssignmentExpression", "ExtendedExpression", "Expression", "MemberExpressionRest", "ElseClause", "CoffeeCommentEnabled", "SingleLineComment", "Debugger", "JSXElement", "TypedJSXElement", "JSXFragment", "TypedJSXFragment", "JSXChild", "JSXChildren", "JSXNestedChildren", "JSXMixedChildren"]);
15240
+ 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"]);
15127
15241
  module.exports = {
15128
15242
  parse,
15129
15243
  compile: function(src, options = defaultOptions) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.5.15",
3
+ "version": "0.5.17",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "exports": {