webpipe-js 2.0.10 → 2.0.11
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 +29 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +29 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -461,8 +461,29 @@ var Parser = class {
|
|
|
461
461
|
if (ifStep) return ifStep;
|
|
462
462
|
const dispatchStep = this.tryParse(() => this.parseDispatchStep());
|
|
463
463
|
if (dispatchStep) return dispatchStep;
|
|
464
|
+
const foreachStep = this.tryParse(() => this.parseForeachStep());
|
|
465
|
+
if (foreachStep) return foreachStep;
|
|
464
466
|
return this.parseRegularStep();
|
|
465
467
|
}
|
|
468
|
+
parseForeachStep() {
|
|
469
|
+
this.skipWhitespaceOnly();
|
|
470
|
+
this.expect("|>");
|
|
471
|
+
this.skipInlineSpaces();
|
|
472
|
+
this.expect("foreach");
|
|
473
|
+
if (this.cur() !== " " && this.cur() !== " ") {
|
|
474
|
+
throw new ParseFailure("space after foreach", this.pos);
|
|
475
|
+
}
|
|
476
|
+
this.skipInlineSpaces();
|
|
477
|
+
const selector = this.consumeWhile((c) => c !== "\n" && c !== "#").trim();
|
|
478
|
+
if (selector.length === 0) {
|
|
479
|
+
throw new ParseFailure("foreach selector", this.pos);
|
|
480
|
+
}
|
|
481
|
+
this.skipSpaces();
|
|
482
|
+
const pipeline = this.parseIfPipeline("end");
|
|
483
|
+
this.skipSpaces();
|
|
484
|
+
this.expect("end");
|
|
485
|
+
return { kind: "Foreach", selector, pipeline };
|
|
486
|
+
}
|
|
466
487
|
parseRegularStep() {
|
|
467
488
|
this.skipWhitespaceOnly();
|
|
468
489
|
this.expect("|>");
|
|
@@ -1143,7 +1164,7 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1143
1164
|
});
|
|
1144
1165
|
}
|
|
1145
1166
|
return lines.join("\n");
|
|
1146
|
-
} else {
|
|
1167
|
+
} else if (step.kind === "Dispatch") {
|
|
1147
1168
|
const lines = [`${indent}|> dispatch`];
|
|
1148
1169
|
step.branches.forEach((branch) => {
|
|
1149
1170
|
lines.push(`${indent} case ${formatTag(branch.tag)}:`);
|
|
@@ -1158,6 +1179,13 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1158
1179
|
});
|
|
1159
1180
|
}
|
|
1160
1181
|
return lines.join("\n");
|
|
1182
|
+
} else {
|
|
1183
|
+
const lines = [`${indent}|> foreach ${step.selector}`];
|
|
1184
|
+
step.pipeline.steps.forEach((innerStep) => {
|
|
1185
|
+
lines.push(formatPipelineStep(innerStep, indent + " "));
|
|
1186
|
+
});
|
|
1187
|
+
lines.push(`${indent}end`);
|
|
1188
|
+
return lines.join("\n");
|
|
1161
1189
|
}
|
|
1162
1190
|
}
|
|
1163
1191
|
function formatStepConfig(config, configType) {
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -412,8 +412,29 @@ var Parser = class {
|
|
|
412
412
|
if (ifStep) return ifStep;
|
|
413
413
|
const dispatchStep = this.tryParse(() => this.parseDispatchStep());
|
|
414
414
|
if (dispatchStep) return dispatchStep;
|
|
415
|
+
const foreachStep = this.tryParse(() => this.parseForeachStep());
|
|
416
|
+
if (foreachStep) return foreachStep;
|
|
415
417
|
return this.parseRegularStep();
|
|
416
418
|
}
|
|
419
|
+
parseForeachStep() {
|
|
420
|
+
this.skipWhitespaceOnly();
|
|
421
|
+
this.expect("|>");
|
|
422
|
+
this.skipInlineSpaces();
|
|
423
|
+
this.expect("foreach");
|
|
424
|
+
if (this.cur() !== " " && this.cur() !== " ") {
|
|
425
|
+
throw new ParseFailure("space after foreach", this.pos);
|
|
426
|
+
}
|
|
427
|
+
this.skipInlineSpaces();
|
|
428
|
+
const selector = this.consumeWhile((c) => c !== "\n" && c !== "#").trim();
|
|
429
|
+
if (selector.length === 0) {
|
|
430
|
+
throw new ParseFailure("foreach selector", this.pos);
|
|
431
|
+
}
|
|
432
|
+
this.skipSpaces();
|
|
433
|
+
const pipeline = this.parseIfPipeline("end");
|
|
434
|
+
this.skipSpaces();
|
|
435
|
+
this.expect("end");
|
|
436
|
+
return { kind: "Foreach", selector, pipeline };
|
|
437
|
+
}
|
|
417
438
|
parseRegularStep() {
|
|
418
439
|
this.skipWhitespaceOnly();
|
|
419
440
|
this.expect("|>");
|
|
@@ -1094,7 +1115,7 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1094
1115
|
});
|
|
1095
1116
|
}
|
|
1096
1117
|
return lines.join("\n");
|
|
1097
|
-
} else {
|
|
1118
|
+
} else if (step.kind === "Dispatch") {
|
|
1098
1119
|
const lines = [`${indent}|> dispatch`];
|
|
1099
1120
|
step.branches.forEach((branch) => {
|
|
1100
1121
|
lines.push(`${indent} case ${formatTag(branch.tag)}:`);
|
|
@@ -1109,6 +1130,13 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1109
1130
|
});
|
|
1110
1131
|
}
|
|
1111
1132
|
return lines.join("\n");
|
|
1133
|
+
} else {
|
|
1134
|
+
const lines = [`${indent}|> foreach ${step.selector}`];
|
|
1135
|
+
step.pipeline.steps.forEach((innerStep) => {
|
|
1136
|
+
lines.push(formatPipelineStep(innerStep, indent + " "));
|
|
1137
|
+
});
|
|
1138
|
+
lines.push(`${indent}end`);
|
|
1139
|
+
return lines.join("\n");
|
|
1112
1140
|
}
|
|
1113
1141
|
}
|
|
1114
1142
|
function formatStepConfig(config, configType) {
|