@danielx/civet 0.5.45 → 0.5.47

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
@@ -517,13 +517,13 @@ ${input.slice(result.pos)}
517
517
  BindingPattern,
518
518
  ObjectBindingPattern,
519
519
  ObjectBindingPatternContent,
520
+ BindingPropertyList,
520
521
  ArrayBindingPattern,
521
522
  ArrayBindingPatternContent,
522
523
  Elision,
523
524
  NestedBindingProperties,
524
- NestedBindingProperty,
525
+ NestedBindingPropertyList,
525
526
  BindingProperty,
526
- NestedBindingRestProperty,
527
527
  BindingRestProperty,
528
528
  NestedBindingElements,
529
529
  NestedBindingElement,
@@ -3817,21 +3817,11 @@ ${input.slice(result.pos)}
3817
3817
  }
3818
3818
  }
3819
3819
  var ObjectBindingPatternContent$0 = NestedBindingProperties;
3820
- var ObjectBindingPatternContent$1 = $TS($S($Q(BindingProperty), $E(BindingRestProperty), $Q(BindingProperty)), function($skip, $loc, $0, $1, $2, $3) {
3821
- var props = $1;
3822
- var rest = $2;
3823
- var after = $3;
3824
- const names = props.flatMap((p) => p.names);
3825
- const children = [...props];
3826
- if (rest) {
3827
- [rest, after] = module.reorderBindingRestProperty(rest, after);
3828
- children.push(...after, rest);
3829
- names.push(...after.flatMap((p) => p.names), ...rest.names);
3830
- }
3831
- return {
3832
- names,
3833
- children
3834
- };
3820
+ var ObjectBindingPatternContent$1 = $TV($E(BindingPropertyList), function($skip, $loc, $0, $1) {
3821
+ var props = $0;
3822
+ if (!props)
3823
+ return { children: [], names: [] };
3824
+ return module.reorderBindingRestProperty(props);
3835
3825
  });
3836
3826
  function ObjectBindingPatternContent(state) {
3837
3827
  let eventData;
@@ -3855,6 +3845,37 @@ ${input.slice(result.pos)}
3855
3845
  return result;
3856
3846
  }
3857
3847
  }
3848
+ var BindingPropertyList$0 = $TV($P($S(BindingProperty, ObjectPropertyDelimiter)), function($skip, $loc, $0, $1) {
3849
+ var props = $0;
3850
+ return props.map(([prop, delim]) => {
3851
+ return {
3852
+ ...prop,
3853
+ children: [...prop.children, delim]
3854
+ };
3855
+ });
3856
+ });
3857
+ function BindingPropertyList(state) {
3858
+ let eventData;
3859
+ if (state.events) {
3860
+ const result = state.events.enter?.("BindingPropertyList", state);
3861
+ if (result) {
3862
+ if (result.cache)
3863
+ return result.cache;
3864
+ eventData = result.data;
3865
+ }
3866
+ }
3867
+ if (state.tokenize) {
3868
+ const result = $TOKEN("BindingPropertyList", state, BindingPropertyList$0(state));
3869
+ if (state.events)
3870
+ state.events.exit?.("BindingPropertyList", state, result, eventData);
3871
+ return result;
3872
+ } else {
3873
+ const result = BindingPropertyList$0(state);
3874
+ if (state.events)
3875
+ state.events.exit?.("BindingPropertyList", state, result, eventData);
3876
+ return result;
3877
+ }
3878
+ }
3858
3879
  var ArrayBindingPattern$0 = $TS($S(OpenBracket, ArrayBindingPatternContent, __, CloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
3859
3880
  var c = $2;
3860
3881
  return {
@@ -3962,23 +3983,12 @@ ${input.slice(result.pos)}
3962
3983
  return result;
3963
3984
  }
3964
3985
  }
3965
- var NestedBindingProperties$0 = $TS($S(PushIndent, $Q(NestedBindingProperty), $E(NestedBindingRestProperty), $Q(NestedBindingProperty), PopIndent), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
3986
+ var NestedBindingProperties$0 = $TS($S(PushIndent, $Q(NestedBindingPropertyList), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
3966
3987
  var props = $2;
3967
- var rest = $3;
3968
- var after = $4;
3969
- if (!(props.length || rest))
3988
+ if (!props.length)
3970
3989
  return $skip;
3971
- const names = props.flatMap((p) => p.names);
3972
- const children = [...props];
3973
- if (rest) {
3974
- [rest, after] = module.reorderBindingRestProperty(rest, after);
3975
- children.push(...after, rest);
3976
- names.push(...after.flatMap((p) => p.names), ...rest.names);
3977
- }
3978
- return {
3979
- children,
3980
- names
3981
- };
3990
+ props = props.flat();
3991
+ return module.reorderBindingRestProperty(props);
3982
3992
  });
3983
3993
  function NestedBindingProperties(state) {
3984
3994
  let eventData;
@@ -4002,18 +4012,22 @@ ${input.slice(result.pos)}
4002
4012
  return result;
4003
4013
  }
4004
4014
  }
4005
- var NestedBindingProperty$0 = $TS($S(Nested, BindingProperty), function($skip, $loc, $0, $1, $2) {
4006
- var indent = $1;
4007
- var prop = $2;
4008
- return {
4009
- ...prop,
4010
- children: [...indent, ...prop.children]
4011
- };
4015
+ var NestedBindingPropertyList$0 = $TS($S(Nested, BindingPropertyList), function($skip, $loc, $0, $1, $2) {
4016
+ var ws = $1;
4017
+ var props = $2;
4018
+ return props.map((prop, i) => {
4019
+ if (i > 0)
4020
+ return prop;
4021
+ return {
4022
+ ...prop,
4023
+ children: [ws, ...prop.children]
4024
+ };
4025
+ });
4012
4026
  });
4013
- function NestedBindingProperty(state) {
4027
+ function NestedBindingPropertyList(state) {
4014
4028
  let eventData;
4015
4029
  if (state.events) {
4016
- const result = state.events.enter?.("NestedBindingProperty", state);
4030
+ const result = state.events.enter?.("NestedBindingPropertyList", state);
4017
4031
  if (result) {
4018
4032
  if (result.cache)
4019
4033
  return result.cache;
@@ -4021,25 +4035,26 @@ ${input.slice(result.pos)}
4021
4035
  }
4022
4036
  }
4023
4037
  if (state.tokenize) {
4024
- const result = $TOKEN("NestedBindingProperty", state, NestedBindingProperty$0(state));
4038
+ const result = $TOKEN("NestedBindingPropertyList", state, NestedBindingPropertyList$0(state));
4025
4039
  if (state.events)
4026
- state.events.exit?.("NestedBindingProperty", state, result, eventData);
4040
+ state.events.exit?.("NestedBindingPropertyList", state, result, eventData);
4027
4041
  return result;
4028
4042
  } else {
4029
- const result = NestedBindingProperty$0(state);
4043
+ const result = NestedBindingPropertyList$0(state);
4030
4044
  if (state.events)
4031
- state.events.exit?.("NestedBindingProperty", state, result, eventData);
4045
+ state.events.exit?.("NestedBindingPropertyList", state, result, eventData);
4032
4046
  return result;
4033
4047
  }
4034
4048
  }
4035
- var BindingProperty$0 = $TS($S(__, PropertyName, __, Colon, $C(BindingIdentifier, BindingPattern), $E(Initializer), ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
4049
+ var BindingProperty$0 = BindingRestProperty;
4050
+ var BindingProperty$1 = $TS($S($E(_), PropertyName, __, Colon, $C(BindingIdentifier, BindingPattern), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
4036
4051
  var b = $5;
4037
4052
  return {
4038
4053
  names: b.names,
4039
4054
  children: $0
4040
4055
  };
4041
4056
  });
4042
- var BindingProperty$1 = $TS($S(BindingIdentifier, $E(Initializer), ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3) {
4057
+ var BindingProperty$2 = $TS($S(BindingIdentifier, $E(Initializer)), function($skip, $loc, $0, $1, $2) {
4043
4058
  var b = $1;
4044
4059
  if (b.type === "AtBinding") {
4045
4060
  return {
@@ -4065,65 +4080,35 @@ ${input.slice(result.pos)}
4065
4080
  }
4066
4081
  }
4067
4082
  if (state.tokenize) {
4068
- const result = $TOKEN("BindingProperty", state, BindingProperty$0(state) || BindingProperty$1(state));
4083
+ const result = $TOKEN("BindingProperty", state, BindingProperty$0(state) || BindingProperty$1(state) || BindingProperty$2(state));
4069
4084
  if (state.events)
4070
4085
  state.events.exit?.("BindingProperty", state, result, eventData);
4071
4086
  return result;
4072
4087
  } else {
4073
- const result = BindingProperty$0(state) || BindingProperty$1(state);
4088
+ const result = BindingProperty$0(state) || BindingProperty$1(state) || BindingProperty$2(state);
4074
4089
  if (state.events)
4075
4090
  state.events.exit?.("BindingProperty", state, result, eventData);
4076
4091
  return result;
4077
4092
  }
4078
4093
  }
4079
- var NestedBindingRestProperty$0 = $TS($S(Nested, BindingRestProperty), function($skip, $loc, $0, $1, $2) {
4080
- var indent = $1;
4081
- var prop = $2;
4082
- return {
4083
- ...prop,
4084
- children: [indent, ...prop.children]
4085
- };
4086
- });
4087
- function NestedBindingRestProperty(state) {
4088
- let eventData;
4089
- if (state.events) {
4090
- const result = state.events.enter?.("NestedBindingRestProperty", state);
4091
- if (result) {
4092
- if (result.cache)
4093
- return result.cache;
4094
- eventData = result.data;
4095
- }
4096
- }
4097
- if (state.tokenize) {
4098
- const result = $TOKEN("NestedBindingRestProperty", state, NestedBindingRestProperty$0(state));
4099
- if (state.events)
4100
- state.events.exit?.("NestedBindingRestProperty", state, result, eventData);
4101
- return result;
4102
- } else {
4103
- const result = NestedBindingRestProperty$0(state);
4104
- if (state.events)
4105
- state.events.exit?.("NestedBindingRestProperty", state, result, eventData);
4106
- return result;
4107
- }
4108
- }
4109
- var BindingRestProperty$0 = $TS($S(__, DotDotDot, BindingIdentifier, ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
4094
+ var BindingRestProperty$0 = $TS($S($E(_), DotDotDot, BindingIdentifier), function($skip, $loc, $0, $1, $2, $3) {
4110
4095
  var ws = $1;
4111
4096
  var dots = $2;
4112
4097
  var id = $3;
4113
- var delimiter = $4;
4114
4098
  return {
4115
4099
  ...id,
4116
- children: [...ws, dots, ...id.children, delimiter]
4100
+ type: "BindingRestProperty",
4101
+ children: [...ws || [], dots, ...id.children]
4117
4102
  };
4118
4103
  });
4119
- var BindingRestProperty$1 = $TS($S(__, BindingIdentifier, DotDotDot, ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
4104
+ var BindingRestProperty$1 = $TS($S($E(_), BindingIdentifier, DotDotDot), function($skip, $loc, $0, $1, $2, $3) {
4120
4105
  var ws = $1;
4121
4106
  var id = $2;
4122
4107
  var dots = $3;
4123
- var delimiter = $4;
4124
4108
  return {
4125
4109
  ...id,
4126
- children: [...ws, dots, ...id.children, delimiter]
4110
+ type: "BindingRestProperty",
4111
+ children: [...ws || [], dots, ...id.children]
4127
4112
  };
4128
4113
  });
4129
4114
  function BindingRestProperty(state) {
@@ -17320,13 +17305,39 @@ ${input.slice(result.pos)}
17320
17305
  token: str
17321
17306
  };
17322
17307
  };
17323
- module.reorderBindingRestProperty = function(rest, after) {
17324
- if (after.length) {
17325
- const [restDelim] = rest.children.slice(-1), lastAfterProp = after[after.length - 1], lastAfterChildren = lastAfterProp.children, [lastDelim] = lastAfterChildren.slice(-1);
17326
- rest = { ...rest, children: [...rest.children.slice(0, -1), lastDelim] };
17327
- after = [...after.slice(0, -1), { ...lastAfterProp, children: [...lastAfterChildren.slice(0, -1), restDelim] }];
17308
+ module.reorderBindingRestProperty = function(props) {
17309
+ const names = props.flatMap((p) => p.names);
17310
+ let restIndex = -1;
17311
+ let restCount = 0;
17312
+ props.forEach(({ type }, i) => {
17313
+ if (type === "BindingRestProperty") {
17314
+ if (restIndex < 0)
17315
+ restIndex = i;
17316
+ restCount++;
17317
+ }
17318
+ });
17319
+ if (restCount === 0) {
17320
+ const children = [...props];
17321
+ return {
17322
+ children,
17323
+ names
17324
+ };
17325
+ } else if (restCount === 1) {
17326
+ let after = props.slice(restIndex + 1);
17327
+ let rest = props[restIndex];
17328
+ props = props.slice(0, restIndex);
17329
+ if (after.length) {
17330
+ const [restDelim] = rest.children.slice(-1), lastAfterProp = after[after.length - 1], lastAfterChildren = lastAfterProp.children, [lastDelim] = lastAfterChildren.slice(-1);
17331
+ rest = { ...rest, children: [...rest.children.slice(0, -1), lastDelim] };
17332
+ after = [...after.slice(0, -1), { ...lastAfterProp, children: [...lastAfterChildren.slice(0, -1), restDelim] }];
17333
+ }
17334
+ const children = [...props, ...after, rest];
17335
+ return {
17336
+ children,
17337
+ names
17338
+ };
17328
17339
  }
17329
- return [rest, after];
17340
+ throw new Error("Multiple rest properties in object pattern");
17330
17341
  };
17331
17342
  function gatherNodes(node, predicate) {
17332
17343
  if (node == null)
@@ -0,0 +1,22 @@
1
+ import {
2
+ plugin
3
+ } from "bun";
4
+ await plugin({
5
+ name: "Civet loader",
6
+ setup: async function(builder) {
7
+ var compile, readFileSync;
8
+ ({ compile } = await import("./main.mjs"));
9
+ ({ readFileSync } = await import("fs"));
10
+ return builder.onLoad({
11
+ filter: /\.civet$/
12
+ }, function({ path }) {
13
+ var contents, source;
14
+ source = readFileSync(path, "utf8");
15
+ contents = compile(source);
16
+ return {
17
+ contents,
18
+ loader: "js"
19
+ };
20
+ });
21
+ }
22
+ });
package/dist/civet CHANGED
@@ -65,7 +65,7 @@ parseArgs = function(args = process.argv.slice(2)) {
65
65
  }
66
66
  if (options.run) {
67
67
  filenames.push(args[j]);
68
- return scriptArgs = args.slice(j);
68
+ return scriptArgs = args.slice(j + 1);
69
69
  } else {
70
70
  return filenames.push(...args.slice(j));
71
71
  }
package/dist/main.js CHANGED
@@ -516,13 +516,13 @@ ${input.slice(result.pos)}
516
516
  BindingPattern,
517
517
  ObjectBindingPattern,
518
518
  ObjectBindingPatternContent,
519
+ BindingPropertyList,
519
520
  ArrayBindingPattern,
520
521
  ArrayBindingPatternContent,
521
522
  Elision,
522
523
  NestedBindingProperties,
523
- NestedBindingProperty,
524
+ NestedBindingPropertyList,
524
525
  BindingProperty,
525
- NestedBindingRestProperty,
526
526
  BindingRestProperty,
527
527
  NestedBindingElements,
528
528
  NestedBindingElement,
@@ -3816,21 +3816,11 @@ ${input.slice(result.pos)}
3816
3816
  }
3817
3817
  }
3818
3818
  var ObjectBindingPatternContent$0 = NestedBindingProperties;
3819
- var ObjectBindingPatternContent$1 = $TS($S($Q(BindingProperty), $E(BindingRestProperty), $Q(BindingProperty)), function($skip, $loc, $0, $1, $2, $3) {
3820
- var props = $1;
3821
- var rest = $2;
3822
- var after = $3;
3823
- const names = props.flatMap((p) => p.names);
3824
- const children = [...props];
3825
- if (rest) {
3826
- [rest, after] = module2.reorderBindingRestProperty(rest, after);
3827
- children.push(...after, rest);
3828
- names.push(...after.flatMap((p) => p.names), ...rest.names);
3829
- }
3830
- return {
3831
- names,
3832
- children
3833
- };
3819
+ var ObjectBindingPatternContent$1 = $TV($E(BindingPropertyList), function($skip, $loc, $0, $1) {
3820
+ var props = $0;
3821
+ if (!props)
3822
+ return { children: [], names: [] };
3823
+ return module2.reorderBindingRestProperty(props);
3834
3824
  });
3835
3825
  function ObjectBindingPatternContent(state) {
3836
3826
  let eventData;
@@ -3854,6 +3844,37 @@ ${input.slice(result.pos)}
3854
3844
  return result;
3855
3845
  }
3856
3846
  }
3847
+ var BindingPropertyList$0 = $TV($P($S(BindingProperty, ObjectPropertyDelimiter)), function($skip, $loc, $0, $1) {
3848
+ var props = $0;
3849
+ return props.map(([prop, delim]) => {
3850
+ return {
3851
+ ...prop,
3852
+ children: [...prop.children, delim]
3853
+ };
3854
+ });
3855
+ });
3856
+ function BindingPropertyList(state) {
3857
+ let eventData;
3858
+ if (state.events) {
3859
+ const result = state.events.enter?.("BindingPropertyList", state);
3860
+ if (result) {
3861
+ if (result.cache)
3862
+ return result.cache;
3863
+ eventData = result.data;
3864
+ }
3865
+ }
3866
+ if (state.tokenize) {
3867
+ const result = $TOKEN("BindingPropertyList", state, BindingPropertyList$0(state));
3868
+ if (state.events)
3869
+ state.events.exit?.("BindingPropertyList", state, result, eventData);
3870
+ return result;
3871
+ } else {
3872
+ const result = BindingPropertyList$0(state);
3873
+ if (state.events)
3874
+ state.events.exit?.("BindingPropertyList", state, result, eventData);
3875
+ return result;
3876
+ }
3877
+ }
3857
3878
  var ArrayBindingPattern$0 = $TS($S(OpenBracket, ArrayBindingPatternContent, __, CloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
3858
3879
  var c = $2;
3859
3880
  return {
@@ -3961,23 +3982,12 @@ ${input.slice(result.pos)}
3961
3982
  return result;
3962
3983
  }
3963
3984
  }
3964
- var NestedBindingProperties$0 = $TS($S(PushIndent, $Q(NestedBindingProperty), $E(NestedBindingRestProperty), $Q(NestedBindingProperty), PopIndent), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
3985
+ var NestedBindingProperties$0 = $TS($S(PushIndent, $Q(NestedBindingPropertyList), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
3965
3986
  var props = $2;
3966
- var rest = $3;
3967
- var after = $4;
3968
- if (!(props.length || rest))
3987
+ if (!props.length)
3969
3988
  return $skip;
3970
- const names = props.flatMap((p) => p.names);
3971
- const children = [...props];
3972
- if (rest) {
3973
- [rest, after] = module2.reorderBindingRestProperty(rest, after);
3974
- children.push(...after, rest);
3975
- names.push(...after.flatMap((p) => p.names), ...rest.names);
3976
- }
3977
- return {
3978
- children,
3979
- names
3980
- };
3989
+ props = props.flat();
3990
+ return module2.reorderBindingRestProperty(props);
3981
3991
  });
3982
3992
  function NestedBindingProperties(state) {
3983
3993
  let eventData;
@@ -4001,18 +4011,22 @@ ${input.slice(result.pos)}
4001
4011
  return result;
4002
4012
  }
4003
4013
  }
4004
- var NestedBindingProperty$0 = $TS($S(Nested, BindingProperty), function($skip, $loc, $0, $1, $2) {
4005
- var indent = $1;
4006
- var prop = $2;
4007
- return {
4008
- ...prop,
4009
- children: [...indent, ...prop.children]
4010
- };
4014
+ var NestedBindingPropertyList$0 = $TS($S(Nested, BindingPropertyList), function($skip, $loc, $0, $1, $2) {
4015
+ var ws = $1;
4016
+ var props = $2;
4017
+ return props.map((prop, i) => {
4018
+ if (i > 0)
4019
+ return prop;
4020
+ return {
4021
+ ...prop,
4022
+ children: [ws, ...prop.children]
4023
+ };
4024
+ });
4011
4025
  });
4012
- function NestedBindingProperty(state) {
4026
+ function NestedBindingPropertyList(state) {
4013
4027
  let eventData;
4014
4028
  if (state.events) {
4015
- const result = state.events.enter?.("NestedBindingProperty", state);
4029
+ const result = state.events.enter?.("NestedBindingPropertyList", state);
4016
4030
  if (result) {
4017
4031
  if (result.cache)
4018
4032
  return result.cache;
@@ -4020,25 +4034,26 @@ ${input.slice(result.pos)}
4020
4034
  }
4021
4035
  }
4022
4036
  if (state.tokenize) {
4023
- const result = $TOKEN("NestedBindingProperty", state, NestedBindingProperty$0(state));
4037
+ const result = $TOKEN("NestedBindingPropertyList", state, NestedBindingPropertyList$0(state));
4024
4038
  if (state.events)
4025
- state.events.exit?.("NestedBindingProperty", state, result, eventData);
4039
+ state.events.exit?.("NestedBindingPropertyList", state, result, eventData);
4026
4040
  return result;
4027
4041
  } else {
4028
- const result = NestedBindingProperty$0(state);
4042
+ const result = NestedBindingPropertyList$0(state);
4029
4043
  if (state.events)
4030
- state.events.exit?.("NestedBindingProperty", state, result, eventData);
4044
+ state.events.exit?.("NestedBindingPropertyList", state, result, eventData);
4031
4045
  return result;
4032
4046
  }
4033
4047
  }
4034
- var BindingProperty$0 = $TS($S(__, PropertyName, __, Colon, $C(BindingIdentifier, BindingPattern), $E(Initializer), ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
4048
+ var BindingProperty$0 = BindingRestProperty;
4049
+ var BindingProperty$1 = $TS($S($E(_), PropertyName, __, Colon, $C(BindingIdentifier, BindingPattern), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
4035
4050
  var b = $5;
4036
4051
  return {
4037
4052
  names: b.names,
4038
4053
  children: $0
4039
4054
  };
4040
4055
  });
4041
- var BindingProperty$1 = $TS($S(BindingIdentifier, $E(Initializer), ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3) {
4056
+ var BindingProperty$2 = $TS($S(BindingIdentifier, $E(Initializer)), function($skip, $loc, $0, $1, $2) {
4042
4057
  var b = $1;
4043
4058
  if (b.type === "AtBinding") {
4044
4059
  return {
@@ -4064,65 +4079,35 @@ ${input.slice(result.pos)}
4064
4079
  }
4065
4080
  }
4066
4081
  if (state.tokenize) {
4067
- const result = $TOKEN("BindingProperty", state, BindingProperty$0(state) || BindingProperty$1(state));
4082
+ const result = $TOKEN("BindingProperty", state, BindingProperty$0(state) || BindingProperty$1(state) || BindingProperty$2(state));
4068
4083
  if (state.events)
4069
4084
  state.events.exit?.("BindingProperty", state, result, eventData);
4070
4085
  return result;
4071
4086
  } else {
4072
- const result = BindingProperty$0(state) || BindingProperty$1(state);
4087
+ const result = BindingProperty$0(state) || BindingProperty$1(state) || BindingProperty$2(state);
4073
4088
  if (state.events)
4074
4089
  state.events.exit?.("BindingProperty", state, result, eventData);
4075
4090
  return result;
4076
4091
  }
4077
4092
  }
4078
- var NestedBindingRestProperty$0 = $TS($S(Nested, BindingRestProperty), function($skip, $loc, $0, $1, $2) {
4079
- var indent = $1;
4080
- var prop = $2;
4081
- return {
4082
- ...prop,
4083
- children: [indent, ...prop.children]
4084
- };
4085
- });
4086
- function NestedBindingRestProperty(state) {
4087
- let eventData;
4088
- if (state.events) {
4089
- const result = state.events.enter?.("NestedBindingRestProperty", state);
4090
- if (result) {
4091
- if (result.cache)
4092
- return result.cache;
4093
- eventData = result.data;
4094
- }
4095
- }
4096
- if (state.tokenize) {
4097
- const result = $TOKEN("NestedBindingRestProperty", state, NestedBindingRestProperty$0(state));
4098
- if (state.events)
4099
- state.events.exit?.("NestedBindingRestProperty", state, result, eventData);
4100
- return result;
4101
- } else {
4102
- const result = NestedBindingRestProperty$0(state);
4103
- if (state.events)
4104
- state.events.exit?.("NestedBindingRestProperty", state, result, eventData);
4105
- return result;
4106
- }
4107
- }
4108
- var BindingRestProperty$0 = $TS($S(__, DotDotDot, BindingIdentifier, ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
4093
+ var BindingRestProperty$0 = $TS($S($E(_), DotDotDot, BindingIdentifier), function($skip, $loc, $0, $1, $2, $3) {
4109
4094
  var ws = $1;
4110
4095
  var dots = $2;
4111
4096
  var id = $3;
4112
- var delimiter = $4;
4113
4097
  return {
4114
4098
  ...id,
4115
- children: [...ws, dots, ...id.children, delimiter]
4099
+ type: "BindingRestProperty",
4100
+ children: [...ws || [], dots, ...id.children]
4116
4101
  };
4117
4102
  });
4118
- var BindingRestProperty$1 = $TS($S(__, BindingIdentifier, DotDotDot, ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
4103
+ var BindingRestProperty$1 = $TS($S($E(_), BindingIdentifier, DotDotDot), function($skip, $loc, $0, $1, $2, $3) {
4119
4104
  var ws = $1;
4120
4105
  var id = $2;
4121
4106
  var dots = $3;
4122
- var delimiter = $4;
4123
4107
  return {
4124
4108
  ...id,
4125
- children: [...ws, dots, ...id.children, delimiter]
4109
+ type: "BindingRestProperty",
4110
+ children: [...ws || [], dots, ...id.children]
4126
4111
  };
4127
4112
  });
4128
4113
  function BindingRestProperty(state) {
@@ -17319,13 +17304,39 @@ ${input.slice(result.pos)}
17319
17304
  token: str
17320
17305
  };
17321
17306
  };
17322
- module2.reorderBindingRestProperty = function(rest, after) {
17323
- if (after.length) {
17324
- const [restDelim] = rest.children.slice(-1), lastAfterProp = after[after.length - 1], lastAfterChildren = lastAfterProp.children, [lastDelim] = lastAfterChildren.slice(-1);
17325
- rest = { ...rest, children: [...rest.children.slice(0, -1), lastDelim] };
17326
- after = [...after.slice(0, -1), { ...lastAfterProp, children: [...lastAfterChildren.slice(0, -1), restDelim] }];
17307
+ module2.reorderBindingRestProperty = function(props) {
17308
+ const names = props.flatMap((p) => p.names);
17309
+ let restIndex = -1;
17310
+ let restCount = 0;
17311
+ props.forEach(({ type }, i) => {
17312
+ if (type === "BindingRestProperty") {
17313
+ if (restIndex < 0)
17314
+ restIndex = i;
17315
+ restCount++;
17316
+ }
17317
+ });
17318
+ if (restCount === 0) {
17319
+ const children = [...props];
17320
+ return {
17321
+ children,
17322
+ names
17323
+ };
17324
+ } else if (restCount === 1) {
17325
+ let after = props.slice(restIndex + 1);
17326
+ let rest = props[restIndex];
17327
+ props = props.slice(0, restIndex);
17328
+ if (after.length) {
17329
+ const [restDelim] = rest.children.slice(-1), lastAfterProp = after[after.length - 1], lastAfterChildren = lastAfterProp.children, [lastDelim] = lastAfterChildren.slice(-1);
17330
+ rest = { ...rest, children: [...rest.children.slice(0, -1), lastDelim] };
17331
+ after = [...after.slice(0, -1), { ...lastAfterProp, children: [...lastAfterChildren.slice(0, -1), restDelim] }];
17332
+ }
17333
+ const children = [...props, ...after, rest];
17334
+ return {
17335
+ children,
17336
+ names
17337
+ };
17327
17338
  }
17328
- return [rest, after];
17339
+ throw new Error("Multiple rest properties in object pattern");
17329
17340
  };
17330
17341
  function gatherNodes(node, predicate) {
17331
17342
  if (node == null)
package/dist/main.mjs CHANGED
@@ -514,13 +514,13 @@ ${input.slice(result.pos)}
514
514
  BindingPattern,
515
515
  ObjectBindingPattern,
516
516
  ObjectBindingPatternContent,
517
+ BindingPropertyList,
517
518
  ArrayBindingPattern,
518
519
  ArrayBindingPatternContent,
519
520
  Elision,
520
521
  NestedBindingProperties,
521
- NestedBindingProperty,
522
+ NestedBindingPropertyList,
522
523
  BindingProperty,
523
- NestedBindingRestProperty,
524
524
  BindingRestProperty,
525
525
  NestedBindingElements,
526
526
  NestedBindingElement,
@@ -3814,21 +3814,11 @@ ${input.slice(result.pos)}
3814
3814
  }
3815
3815
  }
3816
3816
  var ObjectBindingPatternContent$0 = NestedBindingProperties;
3817
- var ObjectBindingPatternContent$1 = $TS($S($Q(BindingProperty), $E(BindingRestProperty), $Q(BindingProperty)), function($skip, $loc, $0, $1, $2, $3) {
3818
- var props = $1;
3819
- var rest = $2;
3820
- var after = $3;
3821
- const names = props.flatMap((p) => p.names);
3822
- const children = [...props];
3823
- if (rest) {
3824
- [rest, after] = module.reorderBindingRestProperty(rest, after);
3825
- children.push(...after, rest);
3826
- names.push(...after.flatMap((p) => p.names), ...rest.names);
3827
- }
3828
- return {
3829
- names,
3830
- children
3831
- };
3817
+ var ObjectBindingPatternContent$1 = $TV($E(BindingPropertyList), function($skip, $loc, $0, $1) {
3818
+ var props = $0;
3819
+ if (!props)
3820
+ return { children: [], names: [] };
3821
+ return module.reorderBindingRestProperty(props);
3832
3822
  });
3833
3823
  function ObjectBindingPatternContent(state) {
3834
3824
  let eventData;
@@ -3852,6 +3842,37 @@ ${input.slice(result.pos)}
3852
3842
  return result;
3853
3843
  }
3854
3844
  }
3845
+ var BindingPropertyList$0 = $TV($P($S(BindingProperty, ObjectPropertyDelimiter)), function($skip, $loc, $0, $1) {
3846
+ var props = $0;
3847
+ return props.map(([prop, delim]) => {
3848
+ return {
3849
+ ...prop,
3850
+ children: [...prop.children, delim]
3851
+ };
3852
+ });
3853
+ });
3854
+ function BindingPropertyList(state) {
3855
+ let eventData;
3856
+ if (state.events) {
3857
+ const result = state.events.enter?.("BindingPropertyList", state);
3858
+ if (result) {
3859
+ if (result.cache)
3860
+ return result.cache;
3861
+ eventData = result.data;
3862
+ }
3863
+ }
3864
+ if (state.tokenize) {
3865
+ const result = $TOKEN("BindingPropertyList", state, BindingPropertyList$0(state));
3866
+ if (state.events)
3867
+ state.events.exit?.("BindingPropertyList", state, result, eventData);
3868
+ return result;
3869
+ } else {
3870
+ const result = BindingPropertyList$0(state);
3871
+ if (state.events)
3872
+ state.events.exit?.("BindingPropertyList", state, result, eventData);
3873
+ return result;
3874
+ }
3875
+ }
3855
3876
  var ArrayBindingPattern$0 = $TS($S(OpenBracket, ArrayBindingPatternContent, __, CloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
3856
3877
  var c = $2;
3857
3878
  return {
@@ -3959,23 +3980,12 @@ ${input.slice(result.pos)}
3959
3980
  return result;
3960
3981
  }
3961
3982
  }
3962
- var NestedBindingProperties$0 = $TS($S(PushIndent, $Q(NestedBindingProperty), $E(NestedBindingRestProperty), $Q(NestedBindingProperty), PopIndent), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
3983
+ var NestedBindingProperties$0 = $TS($S(PushIndent, $Q(NestedBindingPropertyList), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
3963
3984
  var props = $2;
3964
- var rest = $3;
3965
- var after = $4;
3966
- if (!(props.length || rest))
3985
+ if (!props.length)
3967
3986
  return $skip;
3968
- const names = props.flatMap((p) => p.names);
3969
- const children = [...props];
3970
- if (rest) {
3971
- [rest, after] = module.reorderBindingRestProperty(rest, after);
3972
- children.push(...after, rest);
3973
- names.push(...after.flatMap((p) => p.names), ...rest.names);
3974
- }
3975
- return {
3976
- children,
3977
- names
3978
- };
3987
+ props = props.flat();
3988
+ return module.reorderBindingRestProperty(props);
3979
3989
  });
3980
3990
  function NestedBindingProperties(state) {
3981
3991
  let eventData;
@@ -3999,18 +4009,22 @@ ${input.slice(result.pos)}
3999
4009
  return result;
4000
4010
  }
4001
4011
  }
4002
- var NestedBindingProperty$0 = $TS($S(Nested, BindingProperty), function($skip, $loc, $0, $1, $2) {
4003
- var indent = $1;
4004
- var prop = $2;
4005
- return {
4006
- ...prop,
4007
- children: [...indent, ...prop.children]
4008
- };
4012
+ var NestedBindingPropertyList$0 = $TS($S(Nested, BindingPropertyList), function($skip, $loc, $0, $1, $2) {
4013
+ var ws = $1;
4014
+ var props = $2;
4015
+ return props.map((prop, i) => {
4016
+ if (i > 0)
4017
+ return prop;
4018
+ return {
4019
+ ...prop,
4020
+ children: [ws, ...prop.children]
4021
+ };
4022
+ });
4009
4023
  });
4010
- function NestedBindingProperty(state) {
4024
+ function NestedBindingPropertyList(state) {
4011
4025
  let eventData;
4012
4026
  if (state.events) {
4013
- const result = state.events.enter?.("NestedBindingProperty", state);
4027
+ const result = state.events.enter?.("NestedBindingPropertyList", state);
4014
4028
  if (result) {
4015
4029
  if (result.cache)
4016
4030
  return result.cache;
@@ -4018,25 +4032,26 @@ ${input.slice(result.pos)}
4018
4032
  }
4019
4033
  }
4020
4034
  if (state.tokenize) {
4021
- const result = $TOKEN("NestedBindingProperty", state, NestedBindingProperty$0(state));
4035
+ const result = $TOKEN("NestedBindingPropertyList", state, NestedBindingPropertyList$0(state));
4022
4036
  if (state.events)
4023
- state.events.exit?.("NestedBindingProperty", state, result, eventData);
4037
+ state.events.exit?.("NestedBindingPropertyList", state, result, eventData);
4024
4038
  return result;
4025
4039
  } else {
4026
- const result = NestedBindingProperty$0(state);
4040
+ const result = NestedBindingPropertyList$0(state);
4027
4041
  if (state.events)
4028
- state.events.exit?.("NestedBindingProperty", state, result, eventData);
4042
+ state.events.exit?.("NestedBindingPropertyList", state, result, eventData);
4029
4043
  return result;
4030
4044
  }
4031
4045
  }
4032
- var BindingProperty$0 = $TS($S(__, PropertyName, __, Colon, $C(BindingIdentifier, BindingPattern), $E(Initializer), ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
4046
+ var BindingProperty$0 = BindingRestProperty;
4047
+ var BindingProperty$1 = $TS($S($E(_), PropertyName, __, Colon, $C(BindingIdentifier, BindingPattern), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
4033
4048
  var b = $5;
4034
4049
  return {
4035
4050
  names: b.names,
4036
4051
  children: $0
4037
4052
  };
4038
4053
  });
4039
- var BindingProperty$1 = $TS($S(BindingIdentifier, $E(Initializer), ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3) {
4054
+ var BindingProperty$2 = $TS($S(BindingIdentifier, $E(Initializer)), function($skip, $loc, $0, $1, $2) {
4040
4055
  var b = $1;
4041
4056
  if (b.type === "AtBinding") {
4042
4057
  return {
@@ -4062,65 +4077,35 @@ ${input.slice(result.pos)}
4062
4077
  }
4063
4078
  }
4064
4079
  if (state.tokenize) {
4065
- const result = $TOKEN("BindingProperty", state, BindingProperty$0(state) || BindingProperty$1(state));
4080
+ const result = $TOKEN("BindingProperty", state, BindingProperty$0(state) || BindingProperty$1(state) || BindingProperty$2(state));
4066
4081
  if (state.events)
4067
4082
  state.events.exit?.("BindingProperty", state, result, eventData);
4068
4083
  return result;
4069
4084
  } else {
4070
- const result = BindingProperty$0(state) || BindingProperty$1(state);
4085
+ const result = BindingProperty$0(state) || BindingProperty$1(state) || BindingProperty$2(state);
4071
4086
  if (state.events)
4072
4087
  state.events.exit?.("BindingProperty", state, result, eventData);
4073
4088
  return result;
4074
4089
  }
4075
4090
  }
4076
- var NestedBindingRestProperty$0 = $TS($S(Nested, BindingRestProperty), function($skip, $loc, $0, $1, $2) {
4077
- var indent = $1;
4078
- var prop = $2;
4079
- return {
4080
- ...prop,
4081
- children: [indent, ...prop.children]
4082
- };
4083
- });
4084
- function NestedBindingRestProperty(state) {
4085
- let eventData;
4086
- if (state.events) {
4087
- const result = state.events.enter?.("NestedBindingRestProperty", state);
4088
- if (result) {
4089
- if (result.cache)
4090
- return result.cache;
4091
- eventData = result.data;
4092
- }
4093
- }
4094
- if (state.tokenize) {
4095
- const result = $TOKEN("NestedBindingRestProperty", state, NestedBindingRestProperty$0(state));
4096
- if (state.events)
4097
- state.events.exit?.("NestedBindingRestProperty", state, result, eventData);
4098
- return result;
4099
- } else {
4100
- const result = NestedBindingRestProperty$0(state);
4101
- if (state.events)
4102
- state.events.exit?.("NestedBindingRestProperty", state, result, eventData);
4103
- return result;
4104
- }
4105
- }
4106
- var BindingRestProperty$0 = $TS($S(__, DotDotDot, BindingIdentifier, ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
4091
+ var BindingRestProperty$0 = $TS($S($E(_), DotDotDot, BindingIdentifier), function($skip, $loc, $0, $1, $2, $3) {
4107
4092
  var ws = $1;
4108
4093
  var dots = $2;
4109
4094
  var id = $3;
4110
- var delimiter = $4;
4111
4095
  return {
4112
4096
  ...id,
4113
- children: [...ws, dots, ...id.children, delimiter]
4097
+ type: "BindingRestProperty",
4098
+ children: [...ws || [], dots, ...id.children]
4114
4099
  };
4115
4100
  });
4116
- var BindingRestProperty$1 = $TS($S(__, BindingIdentifier, DotDotDot, ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
4101
+ var BindingRestProperty$1 = $TS($S($E(_), BindingIdentifier, DotDotDot), function($skip, $loc, $0, $1, $2, $3) {
4117
4102
  var ws = $1;
4118
4103
  var id = $2;
4119
4104
  var dots = $3;
4120
- var delimiter = $4;
4121
4105
  return {
4122
4106
  ...id,
4123
- children: [...ws, dots, ...id.children, delimiter]
4107
+ type: "BindingRestProperty",
4108
+ children: [...ws || [], dots, ...id.children]
4124
4109
  };
4125
4110
  });
4126
4111
  function BindingRestProperty(state) {
@@ -17317,13 +17302,39 @@ ${input.slice(result.pos)}
17317
17302
  token: str
17318
17303
  };
17319
17304
  };
17320
- module.reorderBindingRestProperty = function(rest, after) {
17321
- if (after.length) {
17322
- const [restDelim] = rest.children.slice(-1), lastAfterProp = after[after.length - 1], lastAfterChildren = lastAfterProp.children, [lastDelim] = lastAfterChildren.slice(-1);
17323
- rest = { ...rest, children: [...rest.children.slice(0, -1), lastDelim] };
17324
- after = [...after.slice(0, -1), { ...lastAfterProp, children: [...lastAfterChildren.slice(0, -1), restDelim] }];
17305
+ module.reorderBindingRestProperty = function(props) {
17306
+ const names = props.flatMap((p) => p.names);
17307
+ let restIndex = -1;
17308
+ let restCount = 0;
17309
+ props.forEach(({ type }, i) => {
17310
+ if (type === "BindingRestProperty") {
17311
+ if (restIndex < 0)
17312
+ restIndex = i;
17313
+ restCount++;
17314
+ }
17315
+ });
17316
+ if (restCount === 0) {
17317
+ const children = [...props];
17318
+ return {
17319
+ children,
17320
+ names
17321
+ };
17322
+ } else if (restCount === 1) {
17323
+ let after = props.slice(restIndex + 1);
17324
+ let rest = props[restIndex];
17325
+ props = props.slice(0, restIndex);
17326
+ if (after.length) {
17327
+ const [restDelim] = rest.children.slice(-1), lastAfterProp = after[after.length - 1], lastAfterChildren = lastAfterProp.children, [lastDelim] = lastAfterChildren.slice(-1);
17328
+ rest = { ...rest, children: [...rest.children.slice(0, -1), lastDelim] };
17329
+ after = [...after.slice(0, -1), { ...lastAfterProp, children: [...lastAfterChildren.slice(0, -1), restDelim] }];
17330
+ }
17331
+ const children = [...props, ...after, rest];
17332
+ return {
17333
+ children,
17334
+ names
17335
+ };
17325
17336
  }
17326
- return [rest, after];
17337
+ throw new Error("Multiple rest properties in object pattern");
17327
17338
  };
17328
17339
  function gatherNodes(node, predicate) {
17329
17340
  if (node == null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.5.45",
3
+ "version": "0.5.47",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.mjs",
@@ -11,6 +11,7 @@
11
11
  },
12
12
  "./esm": "./dist/esm.mjs",
13
13
  "./esbuild-plugin": "./dist/esbuild-plugin.js",
14
+ "./bun-civet": "./dist/bun-civet.mjs",
14
15
  "./register": "./register.js",
15
16
  "./*": "./*",
16
17
  "./dist/*": "./dist/*"