webpipe-js 2.0.12 → 2.0.13
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 +33 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +33 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -493,10 +493,39 @@ var Parser = class {
|
|
|
493
493
|
this.expect(":");
|
|
494
494
|
this.skipInlineSpaces();
|
|
495
495
|
const { config, configType } = this.parseStepConfig();
|
|
496
|
-
const
|
|
496
|
+
const condition = this.parseStepCondition();
|
|
497
497
|
const parsedJoinTargets = name === "join" ? this.parseJoinTaskNames(config) : void 0;
|
|
498
498
|
this.skipWhitespaceOnly();
|
|
499
|
-
return { kind: "Regular", name, config, configType,
|
|
499
|
+
return { kind: "Regular", name, config, configType, condition, parsedJoinTargets };
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Parse optional step condition (tag expression after the config)
|
|
503
|
+
* Supports:
|
|
504
|
+
* - @tag (single tag)
|
|
505
|
+
* - @tag @tag2 (implicit AND for backwards compatibility)
|
|
506
|
+
* - @tag and @tag2 (explicit AND)
|
|
507
|
+
* - @tag or @tag2 (explicit OR)
|
|
508
|
+
* - (@tag or @tag2) and @tag3 (grouping)
|
|
509
|
+
*/
|
|
510
|
+
parseStepCondition() {
|
|
511
|
+
this.skipInlineSpaces();
|
|
512
|
+
if (this.cur() !== "@") {
|
|
513
|
+
return void 0;
|
|
514
|
+
}
|
|
515
|
+
let expr = this.parseTagExpr();
|
|
516
|
+
while (true) {
|
|
517
|
+
this.skipInlineSpaces();
|
|
518
|
+
const ch = this.cur();
|
|
519
|
+
if (ch === "\n" || ch === "\r" || ch === "#" || this.text.startsWith("//", this.pos)) {
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
if (ch !== "@") {
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
const nextTag = this.parseTag();
|
|
526
|
+
expr = { kind: "And", left: expr, right: { kind: "Tag", tag: nextTag } };
|
|
527
|
+
}
|
|
528
|
+
return expr;
|
|
500
529
|
}
|
|
501
530
|
/**
|
|
502
531
|
* Pre-parse join config into task names at parse time.
|
|
@@ -1195,8 +1224,8 @@ function formatConfigValue(value) {
|
|
|
1195
1224
|
function formatPipelineStep(step, indent = " ") {
|
|
1196
1225
|
if (step.kind === "Regular") {
|
|
1197
1226
|
const configPart = formatStepConfig(step.config, step.configType);
|
|
1198
|
-
const
|
|
1199
|
-
return `${indent}|> ${step.name}: ${configPart}${
|
|
1227
|
+
const conditionPart = step.condition ? " " + formatTagExpr(step.condition) : "";
|
|
1228
|
+
return `${indent}|> ${step.name}: ${configPart}${conditionPart}`;
|
|
1200
1229
|
} else if (step.kind === "Result") {
|
|
1201
1230
|
const lines = [`${indent}|> result`];
|
|
1202
1231
|
step.branches.forEach((branch) => {
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -443,10 +443,39 @@ var Parser = class {
|
|
|
443
443
|
this.expect(":");
|
|
444
444
|
this.skipInlineSpaces();
|
|
445
445
|
const { config, configType } = this.parseStepConfig();
|
|
446
|
-
const
|
|
446
|
+
const condition = this.parseStepCondition();
|
|
447
447
|
const parsedJoinTargets = name === "join" ? this.parseJoinTaskNames(config) : void 0;
|
|
448
448
|
this.skipWhitespaceOnly();
|
|
449
|
-
return { kind: "Regular", name, config, configType,
|
|
449
|
+
return { kind: "Regular", name, config, configType, condition, parsedJoinTargets };
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Parse optional step condition (tag expression after the config)
|
|
453
|
+
* Supports:
|
|
454
|
+
* - @tag (single tag)
|
|
455
|
+
* - @tag @tag2 (implicit AND for backwards compatibility)
|
|
456
|
+
* - @tag and @tag2 (explicit AND)
|
|
457
|
+
* - @tag or @tag2 (explicit OR)
|
|
458
|
+
* - (@tag or @tag2) and @tag3 (grouping)
|
|
459
|
+
*/
|
|
460
|
+
parseStepCondition() {
|
|
461
|
+
this.skipInlineSpaces();
|
|
462
|
+
if (this.cur() !== "@") {
|
|
463
|
+
return void 0;
|
|
464
|
+
}
|
|
465
|
+
let expr = this.parseTagExpr();
|
|
466
|
+
while (true) {
|
|
467
|
+
this.skipInlineSpaces();
|
|
468
|
+
const ch = this.cur();
|
|
469
|
+
if (ch === "\n" || ch === "\r" || ch === "#" || this.text.startsWith("//", this.pos)) {
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
if (ch !== "@") {
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
const nextTag = this.parseTag();
|
|
476
|
+
expr = { kind: "And", left: expr, right: { kind: "Tag", tag: nextTag } };
|
|
477
|
+
}
|
|
478
|
+
return expr;
|
|
450
479
|
}
|
|
451
480
|
/**
|
|
452
481
|
* Pre-parse join config into task names at parse time.
|
|
@@ -1145,8 +1174,8 @@ function formatConfigValue(value) {
|
|
|
1145
1174
|
function formatPipelineStep(step, indent = " ") {
|
|
1146
1175
|
if (step.kind === "Regular") {
|
|
1147
1176
|
const configPart = formatStepConfig(step.config, step.configType);
|
|
1148
|
-
const
|
|
1149
|
-
return `${indent}|> ${step.name}: ${configPart}${
|
|
1177
|
+
const conditionPart = step.condition ? " " + formatTagExpr(step.condition) : "";
|
|
1178
|
+
return `${indent}|> ${step.name}: ${configPart}${conditionPart}`;
|
|
1150
1179
|
} else if (step.kind === "Result") {
|
|
1151
1180
|
const lines = [`${indent}|> result`];
|
|
1152
1181
|
step.branches.forEach((branch) => {
|