webpipe-js 2.0.12 → 2.0.14

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
@@ -493,10 +493,40 @@ var Parser = class {
493
493
  this.expect(":");
494
494
  this.skipInlineSpaces();
495
495
  const { config, configType } = this.parseStepConfig();
496
- const tags = this.parseTags();
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, tags, parsedJoinTargets };
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
+ const ch = this.cur();
513
+ if (ch !== "@" && ch !== "(") {
514
+ return void 0;
515
+ }
516
+ let expr = this.parseTagExpr();
517
+ while (true) {
518
+ this.skipInlineSpaces();
519
+ const ch2 = this.cur();
520
+ if (ch2 === "\n" || ch2 === "\r" || ch2 === "#" || this.text.startsWith("//", this.pos)) {
521
+ break;
522
+ }
523
+ if (ch2 !== "@") {
524
+ break;
525
+ }
526
+ const nextTag = this.parseTag();
527
+ expr = { kind: "And", left: expr, right: { kind: "Tag", tag: nextTag } };
528
+ }
529
+ return expr;
500
530
  }
501
531
  /**
502
532
  * Pre-parse join config into task names at parse time.
@@ -1195,8 +1225,8 @@ function formatConfigValue(value) {
1195
1225
  function formatPipelineStep(step, indent = " ") {
1196
1226
  if (step.kind === "Regular") {
1197
1227
  const configPart = formatStepConfig(step.config, step.configType);
1198
- const tagsPart = step.tags.length > 0 ? " " + formatTags(step.tags) : "";
1199
- return `${indent}|> ${step.name}: ${configPart}${tagsPart}`;
1228
+ const conditionPart = step.condition ? " " + formatTagExpr(step.condition) : "";
1229
+ return `${indent}|> ${step.name}: ${configPart}${conditionPart}`;
1200
1230
  } else if (step.kind === "Result") {
1201
1231
  const lines = [`${indent}|> result`];
1202
1232
  step.branches.forEach((branch) => {
package/dist/index.d.cts CHANGED
@@ -111,7 +111,7 @@ type PipelineStep = {
111
111
  name: string;
112
112
  config: string;
113
113
  configType: ConfigType;
114
- tags: Tag[];
114
+ condition?: TagExpr;
115
115
  parsedJoinTargets?: string[];
116
116
  } | {
117
117
  kind: 'Result';
package/dist/index.d.ts CHANGED
@@ -111,7 +111,7 @@ type PipelineStep = {
111
111
  name: string;
112
112
  config: string;
113
113
  configType: ConfigType;
114
- tags: Tag[];
114
+ condition?: TagExpr;
115
115
  parsedJoinTargets?: string[];
116
116
  } | {
117
117
  kind: 'Result';
package/dist/index.mjs CHANGED
@@ -443,10 +443,40 @@ var Parser = class {
443
443
  this.expect(":");
444
444
  this.skipInlineSpaces();
445
445
  const { config, configType } = this.parseStepConfig();
446
- const tags = this.parseTags();
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, tags, parsedJoinTargets };
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
+ const ch = this.cur();
463
+ if (ch !== "@" && ch !== "(") {
464
+ return void 0;
465
+ }
466
+ let expr = this.parseTagExpr();
467
+ while (true) {
468
+ this.skipInlineSpaces();
469
+ const ch2 = this.cur();
470
+ if (ch2 === "\n" || ch2 === "\r" || ch2 === "#" || this.text.startsWith("//", this.pos)) {
471
+ break;
472
+ }
473
+ if (ch2 !== "@") {
474
+ break;
475
+ }
476
+ const nextTag = this.parseTag();
477
+ expr = { kind: "And", left: expr, right: { kind: "Tag", tag: nextTag } };
478
+ }
479
+ return expr;
450
480
  }
451
481
  /**
452
482
  * Pre-parse join config into task names at parse time.
@@ -1145,8 +1175,8 @@ function formatConfigValue(value) {
1145
1175
  function formatPipelineStep(step, indent = " ") {
1146
1176
  if (step.kind === "Regular") {
1147
1177
  const configPart = formatStepConfig(step.config, step.configType);
1148
- const tagsPart = step.tags.length > 0 ? " " + formatTags(step.tags) : "";
1149
- return `${indent}|> ${step.name}: ${configPart}${tagsPart}`;
1178
+ const conditionPart = step.condition ? " " + formatTagExpr(step.condition) : "";
1179
+ return `${indent}|> ${step.name}: ${configPart}${conditionPart}`;
1150
1180
  } else if (step.kind === "Result") {
1151
1181
  const lines = [`${indent}|> result`];
1152
1182
  step.branches.forEach((branch) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",