webpipe-js 2.0.56 → 2.0.58

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/index.cjs CHANGED
@@ -892,11 +892,20 @@ var Parser = class {
892
892
  const comments = [];
893
893
  while (true) {
894
894
  const save = this.pos;
895
- this.skipSpaces();
895
+ this.skipWhitespaceOnly();
896
+ const commentPos = this.pos;
896
897
  const comment = this.tryParse(() => this.parseStandaloneComment());
897
898
  if (comment) {
898
- comments.push(comment);
899
- continue;
899
+ if (this.cur() === "\n") this.pos++;
900
+ this.skipWhitespaceOnly();
901
+ const hasFollowingStep = this.text.startsWith("|>", this.pos);
902
+ if (hasFollowingStep || steps.length === 0) {
903
+ comments.push(comment);
904
+ continue;
905
+ } else {
906
+ this.pos = commentPos;
907
+ break;
908
+ }
900
909
  }
901
910
  for (const keyword of stopKeywords) {
902
911
  if (this.text.startsWith(keyword, this.pos)) {
@@ -920,15 +929,22 @@ var Parser = class {
920
929
  const steps = [];
921
930
  const comments = [];
922
931
  while (true) {
923
- const save = this.pos;
924
- this.skipSpaces();
932
+ this.skipWhitespaceOnly();
933
+ const commentPos = this.pos;
925
934
  const comment = this.tryParse(() => this.parseStandaloneComment());
926
935
  if (comment) {
927
- comments.push(comment);
928
- continue;
936
+ if (this.cur() === "\n") this.pos++;
937
+ this.skipWhitespaceOnly();
938
+ const hasFollowingStep = this.text.startsWith("|>", this.pos);
939
+ if (hasFollowingStep || steps.length === 0) {
940
+ comments.push(comment);
941
+ continue;
942
+ } else {
943
+ this.pos = commentPos;
944
+ break;
945
+ }
929
946
  }
930
947
  if (!this.text.startsWith("|>", this.pos)) {
931
- this.pos = save;
932
948
  break;
933
949
  }
934
950
  const step = this.parsePipelineStep();
@@ -1060,7 +1076,7 @@ var Parser = class {
1060
1076
  this.skipInlineSpaces();
1061
1077
  const path = this.consumeWhile((c) => c !== " " && c !== "\n" && c !== "#");
1062
1078
  const inlineComment = this.parseInlineComment();
1063
- this.skipSpaces();
1079
+ this.skipWhitespaceOnly();
1064
1080
  const pipeline = this.parsePipelineRef();
1065
1081
  const end = this.pos;
1066
1082
  this.skipWhitespaceOnly();
@@ -1265,7 +1281,6 @@ var Parser = class {
1265
1281
  return { conditionType: ct, field, headerName: headerName ?? void 0, jqExpr: jqExpr ?? void 0, comparison, value, start, end };
1266
1282
  }
1267
1283
  parseMockHead(prefixWord) {
1268
- this.skipSpaces();
1269
1284
  const start = this.pos;
1270
1285
  this.expect(prefixWord);
1271
1286
  this.skipInlineSpaces();
@@ -1285,7 +1300,6 @@ var Parser = class {
1285
1300
  this.expect("returning");
1286
1301
  this.skipInlineSpaces();
1287
1302
  const returnValue = this.parseBacktickString();
1288
- this.skipSpaces();
1289
1303
  const end = this.pos;
1290
1304
  return { target, targetStart, returnValue, lineNumber: this.getLineNumber(start), start, end };
1291
1305
  }
@@ -1501,11 +1515,20 @@ var Parser = class {
1501
1515
  const tests = [];
1502
1516
  const comments = [];
1503
1517
  while (true) {
1504
- this.skipSpaces();
1518
+ this.skipWhitespaceOnly();
1519
+ const commentPos = this.pos;
1505
1520
  const comment = this.tryParse(() => this.parseStandaloneComment());
1506
1521
  if (comment) {
1507
- comments.push(comment);
1508
- continue;
1522
+ if (this.cur() === "\n") this.pos++;
1523
+ this.skipWhitespaceOnly();
1524
+ const hasFollowingItem = this.text.startsWith("let ", this.pos) || this.text.startsWith("with mock", this.pos) || this.text.startsWith("and mock", this.pos) || this.text.startsWith("it ", this.pos) || this.text.startsWith('it"', this.pos);
1525
+ if (hasFollowingItem || variables.length === 0 && mocks.length === 0 && tests.length === 0) {
1526
+ comments.push(comment);
1527
+ continue;
1528
+ } else {
1529
+ this.pos = commentPos;
1530
+ break;
1531
+ }
1509
1532
  }
1510
1533
  const letBinding = this.tryParse(() => this.parseLetBinding());
1511
1534
  if (letBinding) {
package/dist/index.mjs CHANGED
@@ -839,11 +839,20 @@ var Parser = class {
839
839
  const comments = [];
840
840
  while (true) {
841
841
  const save = this.pos;
842
- this.skipSpaces();
842
+ this.skipWhitespaceOnly();
843
+ const commentPos = this.pos;
843
844
  const comment = this.tryParse(() => this.parseStandaloneComment());
844
845
  if (comment) {
845
- comments.push(comment);
846
- continue;
846
+ if (this.cur() === "\n") this.pos++;
847
+ this.skipWhitespaceOnly();
848
+ const hasFollowingStep = this.text.startsWith("|>", this.pos);
849
+ if (hasFollowingStep || steps.length === 0) {
850
+ comments.push(comment);
851
+ continue;
852
+ } else {
853
+ this.pos = commentPos;
854
+ break;
855
+ }
847
856
  }
848
857
  for (const keyword of stopKeywords) {
849
858
  if (this.text.startsWith(keyword, this.pos)) {
@@ -867,15 +876,22 @@ var Parser = class {
867
876
  const steps = [];
868
877
  const comments = [];
869
878
  while (true) {
870
- const save = this.pos;
871
- this.skipSpaces();
879
+ this.skipWhitespaceOnly();
880
+ const commentPos = this.pos;
872
881
  const comment = this.tryParse(() => this.parseStandaloneComment());
873
882
  if (comment) {
874
- comments.push(comment);
875
- continue;
883
+ if (this.cur() === "\n") this.pos++;
884
+ this.skipWhitespaceOnly();
885
+ const hasFollowingStep = this.text.startsWith("|>", this.pos);
886
+ if (hasFollowingStep || steps.length === 0) {
887
+ comments.push(comment);
888
+ continue;
889
+ } else {
890
+ this.pos = commentPos;
891
+ break;
892
+ }
876
893
  }
877
894
  if (!this.text.startsWith("|>", this.pos)) {
878
- this.pos = save;
879
895
  break;
880
896
  }
881
897
  const step = this.parsePipelineStep();
@@ -1007,7 +1023,7 @@ var Parser = class {
1007
1023
  this.skipInlineSpaces();
1008
1024
  const path = this.consumeWhile((c) => c !== " " && c !== "\n" && c !== "#");
1009
1025
  const inlineComment = this.parseInlineComment();
1010
- this.skipSpaces();
1026
+ this.skipWhitespaceOnly();
1011
1027
  const pipeline = this.parsePipelineRef();
1012
1028
  const end = this.pos;
1013
1029
  this.skipWhitespaceOnly();
@@ -1212,7 +1228,6 @@ var Parser = class {
1212
1228
  return { conditionType: ct, field, headerName: headerName ?? void 0, jqExpr: jqExpr ?? void 0, comparison, value, start, end };
1213
1229
  }
1214
1230
  parseMockHead(prefixWord) {
1215
- this.skipSpaces();
1216
1231
  const start = this.pos;
1217
1232
  this.expect(prefixWord);
1218
1233
  this.skipInlineSpaces();
@@ -1232,7 +1247,6 @@ var Parser = class {
1232
1247
  this.expect("returning");
1233
1248
  this.skipInlineSpaces();
1234
1249
  const returnValue = this.parseBacktickString();
1235
- this.skipSpaces();
1236
1250
  const end = this.pos;
1237
1251
  return { target, targetStart, returnValue, lineNumber: this.getLineNumber(start), start, end };
1238
1252
  }
@@ -1448,11 +1462,20 @@ var Parser = class {
1448
1462
  const tests = [];
1449
1463
  const comments = [];
1450
1464
  while (true) {
1451
- this.skipSpaces();
1465
+ this.skipWhitespaceOnly();
1466
+ const commentPos = this.pos;
1452
1467
  const comment = this.tryParse(() => this.parseStandaloneComment());
1453
1468
  if (comment) {
1454
- comments.push(comment);
1455
- continue;
1469
+ if (this.cur() === "\n") this.pos++;
1470
+ this.skipWhitespaceOnly();
1471
+ const hasFollowingItem = this.text.startsWith("let ", this.pos) || this.text.startsWith("with mock", this.pos) || this.text.startsWith("and mock", this.pos) || this.text.startsWith("it ", this.pos) || this.text.startsWith('it"', this.pos);
1472
+ if (hasFollowingItem || variables.length === 0 && mocks.length === 0 && tests.length === 0) {
1473
+ comments.push(comment);
1474
+ continue;
1475
+ } else {
1476
+ this.pos = commentPos;
1477
+ break;
1478
+ }
1456
1479
  }
1457
1480
  const letBinding = this.tryParse(() => this.parseLetBinding());
1458
1481
  if (letBinding) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "2.0.56",
3
+ "version": "2.0.58",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",