vscode-behavior3 2.3.0 → 2.5.0

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/build-cli.js CHANGED
@@ -212364,16 +212364,22 @@ var hasArgOptions = (arg) => arg.options !== void 0;
212364
212364
  // webview/shared/node-utils.ts
212365
212365
  var createNodeDefMap = (nodeDefs) => new Map(nodeDefs.map((nodeDef) => [nodeDef.name, nodeDef]));
212366
212366
  var cleanSlotLabel = (value) => value.replace(/\.\.\.$/, "").replace(/\?/g, "");
212367
+ var isStructuredSlotDefinition = (slot) => Boolean(slot && typeof slot === "object" && !Array.isArray(slot));
212367
212368
  var parseSlotDefinition = (slot, slotDefs, index) => {
212368
- const raw = slot ?? "";
212369
+ const raw = typeof slot === "string" ? slot : slot?.name ?? "";
212369
212370
  const hasOptionalMarker = raw.includes("?");
212370
212371
  const hasVariadicMarker = raw.endsWith("...");
212371
212372
  const variadic = hasVariadicMarker && (slotDefs && index !== void 0 ? index === slotDefs.length - 1 : true);
212373
+ const checker = isStructuredSlotDefinition(slot) ? slot.checker?.trim() || void 0 : void 0;
212374
+ const visible = isStructuredSlotDefinition(slot) ? slot.visible?.trim() || void 0 : void 0;
212372
212375
  return {
212373
212376
  raw,
212377
+ name: cleanSlotLabel(raw),
212374
212378
  label: cleanSlotLabel(raw),
212375
212379
  required: !hasOptionalMarker,
212376
- variadic
212380
+ variadic,
212381
+ checker,
212382
+ visible
212377
212383
  };
212378
212384
  };
212379
212385
  var getNodeArgRawType = (arg) => {
@@ -212496,10 +212502,7 @@ function customAlphabet(alphabet, size = 21) {
212496
212502
 
212497
212503
  // webview/shared/stable-id.ts
212498
212504
  var UUID_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
212499
- var generateUuid = customAlphabet(
212500
- UUID_ALPHABET,
212501
- 10
212502
- );
212505
+ var generateUuid = customAlphabet(UUID_ALPHABET, 10);
212503
212506
  var hashString = (value) => {
212504
212507
  let hash = 2166136261;
212505
212508
  for (let index = 0; index < value.length; index += 1) {
@@ -212513,7 +212516,7 @@ var generateDeterministicUuid = (seed) => {
212513
212516
  let result = "";
212514
212517
  for (let index = 0; index < 10; index += 1) {
212515
212518
  state = Math.imul(state ^ state >>> 16, 2246822519) >>> 0;
212516
- state ^= hashString(`${seed}:${index}`);
212519
+ state = (state ^ hashString(`${seed}:${index}`)) >>> 0;
212517
212520
  result += UUID_ALPHABET[state % UUID_ALPHABET.length];
212518
212521
  }
212519
212522
  return result;
@@ -212559,6 +212562,12 @@ var asRequiredString = (value, label) => {
212559
212562
  }
212560
212563
  return value;
212561
212564
  };
212565
+ var normalizeTreeVersion = (value) => {
212566
+ if (value === void 0) {
212567
+ return DOCUMENT_VERSION;
212568
+ }
212569
+ return asRequiredString(value, "tree file version");
212570
+ };
212562
212571
  var asStringArray = (value, label) => {
212563
212572
  if (value === void 0) {
212564
212573
  return [];
@@ -212573,6 +212582,34 @@ var asStringArray = (value, label) => {
212573
212582
  return entry;
212574
212583
  });
212575
212584
  };
212585
+ var normalizeNodeLabel = (label, record) => {
212586
+ const rawNodeName = record.name;
212587
+ if (typeof rawNodeName !== "string" || !rawNodeName.trim()) {
212588
+ return label;
212589
+ }
212590
+ return `${label}(${rawNodeName.trim()})`;
212591
+ };
212592
+ var normalizeNodeSlotEntry = (value, label) => {
212593
+ if (typeof value === "string") {
212594
+ return asRequiredString(value, label);
212595
+ }
212596
+ const record = expectPlainRecord(value, label);
212597
+ return {
212598
+ name: asRequiredString(record.name, `${label}.name`),
212599
+ checker: asOptionalNonEmptyString(record.checker, `${label}.checker`),
212600
+ visible: asOptionalNonEmptyString(record.visible, `${label}.visible`)
212601
+ };
212602
+ };
212603
+ var normalizeNodeSlots = (value, label) => {
212604
+ if (value === void 0) {
212605
+ return void 0;
212606
+ }
212607
+ if (!Array.isArray(value)) {
212608
+ throw new Error(`${label} must be an array`);
212609
+ }
212610
+ const slots = value.map((entry, index) => normalizeNodeSlotEntry(entry, `${label}[${index}]`));
212611
+ return slots.length > 0 ? slots : void 0;
212612
+ };
212576
212613
  var asWorkdirRelativeJsonPathArray = (value, label) => {
212577
212614
  const entries = asStringArray(value, label);
212578
212615
  return entries.map((entry, index) => {
@@ -212683,44 +212720,43 @@ var normalizeNodeArgs = (value, label) => {
212683
212720
  oneof: asOptionalString(record.oneof),
212684
212721
  default: record.default,
212685
212722
  options: normalizeNodeArgOptions(record.options, `${label}[${index}].options`),
212686
- checker: asOptionalNonEmptyString(record.checker, `${label}[${index}].checker`)
212723
+ checker: asOptionalNonEmptyString(record.checker, `${label}[${index}].checker`),
212724
+ visible: asOptionalNonEmptyString(record.visible, `${label}[${index}].visible`)
212687
212725
  };
212688
212726
  });
212689
212727
  };
212690
212728
  var normalizeNodeDef = (value, label) => {
212691
212729
  const record = expectPlainRecord(value, label);
212692
- const type = asRequiredString(record.type, `${label}.type`);
212730
+ const nodeLabel = normalizeNodeLabel(label, record);
212731
+ const name = asRequiredString(record.name, `${nodeLabel}.name`);
212732
+ const type = asRequiredString(record.type, `${nodeLabel}.type`);
212693
212733
  if (!NODE_DEF_TYPES.has(type)) {
212694
- throw new Error(`${label}.type must be one of ${Array.from(NODE_DEF_TYPES).join(", ")}`);
212734
+ throw new Error(
212735
+ `${nodeLabel}.type must be one of ${Array.from(NODE_DEF_TYPES).join(", ")}`
212736
+ );
212695
212737
  }
212696
212738
  const groupValue = record.group;
212697
212739
  const group = groupValue === void 0 ? void 0 : Array.isArray(groupValue) ? groupValue.map(
212698
- (entry, index) => asRequiredString(entry, `${label}.group[${index}]`)
212699
- ) : [asRequiredString(groupValue, `${label}.group`)];
212740
+ (entry, index) => asRequiredString(entry, `${nodeLabel}.group[${index}]`)
212741
+ ) : [asRequiredString(groupValue, `${nodeLabel}.group`)];
212700
212742
  const childrenValue = record.children;
212701
212743
  if (childrenValue !== void 0 && !CHILDREN_ARITIES.has(childrenValue)) {
212702
- throw new Error(`${label}.children must be one of -1, 0, 1, 2, 3`);
212744
+ throw new Error(`${nodeLabel}.children must be one of -1, 0, 1, 2, 3`);
212703
212745
  }
212704
212746
  const statusValue = record.status;
212705
- const status = statusValue === void 0 ? void 0 : asStringArray(statusValue, `${label}.status`).map((entry) => {
212747
+ const status = statusValue === void 0 ? void 0 : asStringArray(statusValue, `${nodeLabel}.status`).map((entry) => {
212706
212748
  if (!NODE_STATUS_VALUES.has(entry)) {
212707
- throw new Error(`${label}.status contains unsupported value: ${entry}`);
212749
+ throw new Error(`${nodeLabel}.status contains unsupported value: ${entry}`);
212708
212750
  }
212709
212751
  return entry;
212710
212752
  });
212711
212753
  return {
212712
- name: asRequiredString(record.name, `${label}.name`),
212754
+ name,
212713
212755
  type,
212714
212756
  desc: asOptionalString(record.desc) ?? "",
212715
- input: (() => {
212716
- const input = asStringArray(record.input, `${label}.input`);
212717
- return input.length > 0 ? input : void 0;
212718
- })(),
212719
- output: (() => {
212720
- const output = asStringArray(record.output, `${label}.output`);
212721
- return output.length > 0 ? output : void 0;
212722
- })(),
212723
- args: normalizeNodeArgs(record.args, `${label}.args`),
212757
+ input: normalizeNodeSlots(record.input, `${nodeLabel}.input`),
212758
+ output: normalizeNodeSlots(record.output, `${nodeLabel}.output`),
212759
+ args: normalizeNodeArgs(record.args, `${nodeLabel}.args`),
212724
212760
  doc: asOptionalString(record.doc),
212725
212761
  icon: asOptionalString(record.icon),
212726
212762
  color: asOptionalString(record.color),
@@ -212874,7 +212910,7 @@ var normalizeTreeData = (value, opts) => {
212874
212910
  const variablesValue = record.variables;
212875
212911
  const variablesRecord = variablesValue === void 0 ? void 0 : expectPlainRecord(variablesValue, "tree file variables");
212876
212912
  return {
212877
- version: asRequiredString(record.version, "tree file version"),
212913
+ version: normalizeTreeVersion(record.version),
212878
212914
  name: asRequiredString(record.name, "tree file name"),
212879
212915
  prefix: asOptionalString(record.prefix) ?? "",
212880
212916
  desc: asOptionalString(record.desc),
@@ -213034,10 +213070,10 @@ var collectReachableSubtreePaths = (root) => {
213034
213070
  });
213035
213071
  return Array.from(paths);
213036
213072
  };
213037
- var hasMissingStableIds = (content) => {
213073
+ var needsLegacyTreeWriteback = (content) => {
213038
213074
  try {
213039
213075
  const parsed = JSON.parse(content);
213040
- return subtreeNeedsMissingIds(parsed.root) || parsed.$override !== void 0 || parsed.import !== void 0 || parsed.vars !== void 0;
213076
+ return parsed.version === void 0 || subtreeNeedsMissingIds(parsed.root) || parsed.$override !== void 0 || parsed.import !== void 0 || parsed.vars !== void 0;
213041
213077
  } catch {
213042
213078
  return false;
213043
213079
  }
@@ -213060,7 +213096,7 @@ var loadSubtreeSourceCache = async (params) => {
213060
213096
  return;
213061
213097
  }
213062
213098
  try {
213063
- const needsWriteback = hasMissingStableIds(content);
213099
+ const needsWriteback = needsLegacyTreeWriteback(content);
213064
213100
  const tree = parsePersistedTreeContent(content, normalizedPath);
213065
213101
  cache[normalizedPath] = tree;
213066
213102
  await params.onTreeLoaded?.({
@@ -213358,6 +213394,8 @@ var BUILD_HOOK_MARKER = "__behavior3BuildHook";
213358
213394
  var BATCH_HOOK_MARKER = "__behavior3BatchHook";
213359
213395
  var CHECK_HOOK_MARKER = "__behavior3CheckHook";
213360
213396
  var CHECK_HOOK_NAME = "__behavior3CheckName";
213397
+ var VISIBLE_HOOK_MARKER = "__behavior3VisibleHook";
213398
+ var VISIBLE_HOOK_NAME = "__behavior3VisibleName";
213361
213399
  var markBuildHook = (ctor) => {
213362
213400
  Object.defineProperty(ctor, BUILD_HOOK_MARKER, {
213363
213401
  value: true,
@@ -213384,12 +213422,30 @@ var markCheckCtor = (ctor, explicitName) => {
213384
213422
  });
213385
213423
  return ctor;
213386
213424
  };
213425
+ var markVisibleCtor = (ctor, explicitName) => {
213426
+ const name = explicitName?.trim() || ctor.name;
213427
+ Object.defineProperty(ctor, VISIBLE_HOOK_MARKER, {
213428
+ value: true,
213429
+ configurable: false
213430
+ });
213431
+ Object.defineProperty(ctor, VISIBLE_HOOK_NAME, {
213432
+ value: name,
213433
+ configurable: false
213434
+ });
213435
+ return ctor;
213436
+ };
213387
213437
  var markCheckHook = (nameOrCtor, _context) => {
213388
213438
  if (typeof nameOrCtor === "function") {
213389
213439
  return markCheckCtor(nameOrCtor);
213390
213440
  }
213391
213441
  return (ctor) => markCheckCtor(ctor, nameOrCtor);
213392
213442
  };
213443
+ var markVisibleHook = (nameOrCtor, _context) => {
213444
+ if (typeof nameOrCtor === "function") {
213445
+ return markVisibleCtor(nameOrCtor);
213446
+ }
213447
+ return (ctor) => markVisibleCtor(ctor, nameOrCtor);
213448
+ };
213393
213449
  var isDecoratedBuildHookCtor = (value) => typeof value === "function" && value[BUILD_HOOK_MARKER] === true;
213394
213450
  var isDecoratedBatchHookCtor = (value) => typeof value === "function" && value[BATCH_HOOK_MARKER] === true;
213395
213451
  var isDecoratedCheckCtor = (value) => typeof value === "function" && value[CHECK_HOOK_MARKER] === true;
@@ -213474,7 +213530,7 @@ var createBatchHooks = (moduleExports, env, reportMissing = true) => {
213474
213530
  }
213475
213531
  return void 0;
213476
213532
  };
213477
- var createNodeArgCheckers = (moduleExports, env) => {
213533
+ var createNodeFieldCheckers = (moduleExports, env) => {
213478
213534
  const checkers = /* @__PURE__ */ new Map();
213479
213535
  let hasError = false;
213480
213536
  if (!moduleExports || typeof moduleExports !== "object") {
@@ -213512,7 +213568,7 @@ var createNodeArgCheckers = (moduleExports, env) => {
213512
213568
  var createBuildScriptRuntime = (moduleExports, env) => {
213513
213569
  if (!moduleExports || typeof moduleExports !== "object") {
213514
213570
  return {
213515
- nodeArgCheckers: /* @__PURE__ */ new Map(),
213571
+ nodeFieldCheckers: /* @__PURE__ */ new Map(),
213516
213572
  hasError: false,
213517
213573
  hasEntries: false
213518
213574
  };
@@ -213520,7 +213576,7 @@ var createBuildScriptRuntime = (moduleExports, env) => {
213520
213576
  const moduleRecord = moduleExports;
213521
213577
  const hasBuildHookCandidate = typeof moduleRecord.BuildHook === "function" || typeof moduleRecord.Hook === "function" || Object.values(moduleRecord).some(isDecoratedBuildHookCtor) || typeof moduleRecord.default === "function" && !isDecoratedCheckCtor(moduleRecord.default) && !isDecoratedBatchHookCtor(moduleRecord.default);
213522
213578
  const buildScript = createBuildHooks(moduleExports, env, false);
213523
- const checkerResult = createNodeArgCheckers(moduleExports, env);
213579
+ const checkerResult = createNodeFieldCheckers(moduleExports, env);
213524
213580
  const hasEntries = Boolean(buildScript) || checkerResult.hasCheckers;
213525
213581
  if (!hasEntries) {
213526
213582
  logger.error(
@@ -213529,39 +213585,35 @@ var createBuildScriptRuntime = (moduleExports, env) => {
213529
213585
  }
213530
213586
  return {
213531
213587
  buildScript,
213532
- nodeArgCheckers: checkerResult.checkers,
213588
+ nodeFieldCheckers: checkerResult.checkers,
213533
213589
  hasError: checkerResult.hasError || !hasEntries || hasBuildHookCandidate && !buildScript,
213534
213590
  hasEntries
213535
213591
  };
213536
213592
  };
213537
213593
  var createBuildScriptRuntimeWithCheckModules = (buildScriptModule, checkScriptModules, env) => {
213538
213594
  const runtime = createBuildScriptRuntime(buildScriptModule, env);
213539
- const nodeArgCheckers = new Map(runtime.nodeArgCheckers);
213595
+ const nodeFieldCheckers = new Map(runtime.nodeFieldCheckers);
213540
213596
  let hasError = runtime.hasError;
213541
213597
  let hasCheckEntries = false;
213542
213598
  for (const checkScript of checkScriptModules) {
213543
- const checkerResult = createNodeArgCheckers(checkScript.moduleExports, env);
213599
+ const checkerResult = createNodeFieldCheckers(checkScript.moduleExports, env);
213544
213600
  if (!checkerResult.hasCheckers) {
213545
- logger.error(
213546
- `check script must export at least one @behavior3.check class: ${checkScript.path}`
213547
- );
213548
- hasError = true;
213549
213601
  continue;
213550
213602
  }
213551
213603
  hasCheckEntries = true;
213552
213604
  hasError = hasError || checkerResult.hasError;
213553
213605
  for (const [name, checker] of checkerResult.checkers) {
213554
- if (nodeArgCheckers.has(name)) {
213606
+ if (nodeFieldCheckers.has(name)) {
213555
213607
  logger.error(`duplicate @behavior3.check registration: ${name}`);
213556
213608
  hasError = true;
213557
213609
  continue;
213558
213610
  }
213559
- nodeArgCheckers.set(name, checker);
213611
+ nodeFieldCheckers.set(name, checker);
213560
213612
  }
213561
213613
  }
213562
213614
  return {
213563
213615
  ...runtime,
213564
- nodeArgCheckers,
213616
+ nodeFieldCheckers,
213565
213617
  hasError,
213566
213618
  hasEntries: runtime.hasEntries || hasCheckEntries
213567
213619
  };
@@ -213707,7 +213759,7 @@ var processBatchTree = (tree, treePath, batch, errors) => {
213707
213759
  }
213708
213760
  return tree;
213709
213761
  };
213710
- var normalizeNodeArgCheckResult = (result) => {
213762
+ var normalizeNodeFieldCheckResult = (result) => {
213711
213763
  if (Array.isArray(result)) {
213712
213764
  return result.filter((entry) => typeof entry === "string" && entry.trim());
213713
213765
  }
@@ -213725,7 +213777,99 @@ var walkTreeNodes = (node, visit) => {
213725
213777
  walkTreeNodes(child, visit);
213726
213778
  }
213727
213779
  };
213728
- var collectNodeArgCheckDiagnostics = (params) => {
213780
+ var buildNodeSlotField = (slot, slotDefs, index) => {
213781
+ const parsed = parseSlotDefinition(slot, slotDefs, index);
213782
+ return {
213783
+ name: parsed.name,
213784
+ label: parsed.label,
213785
+ required: parsed.required,
213786
+ variadic: parsed.variadic,
213787
+ checker: parsed.checker,
213788
+ visible: parsed.visible
213789
+ };
213790
+ };
213791
+ var getSlotValue = (values, slotDefs, index) => {
213792
+ const slotField = parseSlotDefinition(slotDefs?.[index] ?? "", slotDefs, index);
213793
+ return slotField.variadic ? values?.slice(index) ?? [] : values?.[index];
213794
+ };
213795
+ var getNodeSlotContext = (params) => {
213796
+ if (!isStructuredSlotDefinition(params.slot)) {
213797
+ return null;
213798
+ }
213799
+ return {
213800
+ node: params.node,
213801
+ tree: params.tree,
213802
+ nodeDef: params.nodeDef,
213803
+ fieldKind: params.fieldKind,
213804
+ fieldName: buildNodeSlotField(params.slot, params.slotDefs, params.index).name,
213805
+ fieldIndex: params.index,
213806
+ slot: params.fieldKind === "input" ? params.slot : params.slot,
213807
+ slotField: buildNodeSlotField(params.slot, params.slotDefs, params.index),
213808
+ treePath: params.treePath,
213809
+ env: params.env
213810
+ };
213811
+ };
213812
+ var visitCustomNodeFields = (params) => {
213813
+ for (const arg of params.nodeDef.args ?? []) {
213814
+ const checkerName = arg.checker?.trim() || void 0;
213815
+ const visibleName = arg.visible?.trim() || void 0;
213816
+ if (!(checkerName || visibleName)) {
213817
+ continue;
213818
+ }
213819
+ const ctx = {
213820
+ node: params.node,
213821
+ tree: params.tree,
213822
+ nodeDef: params.nodeDef,
213823
+ fieldKind: "arg",
213824
+ fieldName: arg.name,
213825
+ arg,
213826
+ treePath: params.treePath,
213827
+ env: params.env
213828
+ };
213829
+ params.onArg?.({
213830
+ fieldName: arg.name,
213831
+ checkerName,
213832
+ visibleName,
213833
+ value: params.node.args?.[arg.name],
213834
+ ctx
213835
+ });
213836
+ }
213837
+ for (const [fieldKind, slotDefs, values, visitor] of [
213838
+ ["input", params.nodeDef.input, params.node.input, params.onInput],
213839
+ ["output", params.nodeDef.output, params.node.output, params.onOutput]
213840
+ ]) {
213841
+ for (let index = 0; index < (slotDefs?.length ?? 0); index += 1) {
213842
+ const slot = slotDefs?.[index] ?? "";
213843
+ const slotField = buildNodeSlotField(slot, slotDefs, index);
213844
+ if (!(slotField.checker || slotField.visible)) {
213845
+ continue;
213846
+ }
213847
+ const ctx = getNodeSlotContext({
213848
+ fieldKind,
213849
+ node: params.node,
213850
+ tree: params.tree,
213851
+ nodeDef: params.nodeDef,
213852
+ slotDefs,
213853
+ slot,
213854
+ index,
213855
+ treePath: params.treePath,
213856
+ env: params.env
213857
+ });
213858
+ if (!ctx) {
213859
+ continue;
213860
+ }
213861
+ visitor?.({
213862
+ fieldName: slotField.name,
213863
+ fieldIndex: index,
213864
+ checkerName: slotField.checker,
213865
+ visibleName: slotField.visible,
213866
+ value: getSlotValue(values, slotDefs, index),
213867
+ ctx
213868
+ });
213869
+ }
213870
+ }
213871
+ };
213872
+ var collectNodeFieldCheckDiagnostics = (params) => {
213729
213873
  const diagnostics = [];
213730
213874
  const targets = params.targets ?? [];
213731
213875
  const entries = targets.length ? targets : (() => {
@@ -213739,47 +213883,100 @@ var collectNodeArgCheckDiagnostics = (params) => {
213739
213883
  if (!nodeDef) {
213740
213884
  continue;
213741
213885
  }
213742
- for (const arg of nodeDef.args ?? []) {
213743
- const checkerName = arg.checker?.trim();
213744
- if (!checkerName) {
213745
- continue;
213746
- }
213747
- const pushDiagnostic = (message) => {
213748
- diagnostics.push({
213749
- instanceKey: target.instanceKey,
213750
- nodeId: node.id,
213751
- nodeName: node.name,
213752
- argName: arg.name,
213753
- checker: checkerName,
213754
- message
213755
- });
213756
- };
213757
- const checker = params.checkers.get(checkerName);
213758
- if (!checker) {
213759
- pushDiagnostic(`checker '${checkerName}' is not registered`);
213760
- continue;
213761
- }
213762
- try {
213763
- const messages = normalizeNodeArgCheckResult(
213764
- checker.validate(node.args?.[arg.name], {
213765
- node,
213766
- tree: params.tree,
213767
- nodeDef,
213768
- arg,
213769
- argName: arg.name,
213770
- treePath: target.treePath ?? params.treePath,
213771
- env: params.env
213772
- })
213773
- );
213774
- messages.forEach(pushDiagnostic);
213775
- } catch (error) {
213776
- pushDiagnostic(`checker '${checkerName}' failed: ${formatRuntimeError(error)}`);
213886
+ visitCustomNodeFields({
213887
+ node,
213888
+ tree: params.tree,
213889
+ nodeDef,
213890
+ treePath: target.treePath ?? params.treePath,
213891
+ env: params.env,
213892
+ onArg: ({ fieldName, checkerName, value, ctx }) => {
213893
+ if (!checkerName) {
213894
+ return;
213895
+ }
213896
+ const pushDiagnostic = (message) => {
213897
+ diagnostics.push({
213898
+ instanceKey: target.instanceKey,
213899
+ nodeId: node.id,
213900
+ nodeName: node.name,
213901
+ fieldKind: "arg",
213902
+ fieldName,
213903
+ checker: checkerName,
213904
+ message
213905
+ });
213906
+ };
213907
+ const checker = params.checkers.get(checkerName);
213908
+ if (!checker) {
213909
+ pushDiagnostic(`checker '${checkerName}' is not registered`);
213910
+ return;
213911
+ }
213912
+ try {
213913
+ const messages = normalizeNodeFieldCheckResult(checker.validate(value, ctx));
213914
+ messages.forEach(pushDiagnostic);
213915
+ } catch (error) {
213916
+ pushDiagnostic(`checker '${checkerName}' failed: ${formatRuntimeError(error)}`);
213917
+ }
213918
+ },
213919
+ onInput: ({ fieldName, fieldIndex, checkerName, value, ctx }) => {
213920
+ if (!checkerName) {
213921
+ return;
213922
+ }
213923
+ const pushDiagnostic = (message) => {
213924
+ diagnostics.push({
213925
+ instanceKey: target.instanceKey,
213926
+ nodeId: node.id,
213927
+ nodeName: node.name,
213928
+ fieldKind: "input",
213929
+ fieldName,
213930
+ fieldIndex,
213931
+ checker: checkerName,
213932
+ message
213933
+ });
213934
+ };
213935
+ const checker = params.checkers.get(checkerName);
213936
+ if (!checker) {
213937
+ pushDiagnostic(`checker '${checkerName}' is not registered`);
213938
+ return;
213939
+ }
213940
+ try {
213941
+ const messages = normalizeNodeFieldCheckResult(checker.validate(value, ctx));
213942
+ messages.forEach(pushDiagnostic);
213943
+ } catch (error) {
213944
+ pushDiagnostic(`checker '${checkerName}' failed: ${formatRuntimeError(error)}`);
213945
+ }
213946
+ },
213947
+ onOutput: ({ fieldName, fieldIndex, checkerName, value, ctx }) => {
213948
+ if (!checkerName) {
213949
+ return;
213950
+ }
213951
+ const pushDiagnostic = (message) => {
213952
+ diagnostics.push({
213953
+ instanceKey: target.instanceKey,
213954
+ nodeId: node.id,
213955
+ nodeName: node.name,
213956
+ fieldKind: "output",
213957
+ fieldName,
213958
+ fieldIndex,
213959
+ checker: checkerName,
213960
+ message
213961
+ });
213962
+ };
213963
+ const checker = params.checkers.get(checkerName);
213964
+ if (!checker) {
213965
+ pushDiagnostic(`checker '${checkerName}' is not registered`);
213966
+ return;
213967
+ }
213968
+ try {
213969
+ const messages = normalizeNodeFieldCheckResult(checker.validate(value, ctx));
213970
+ messages.forEach(pushDiagnostic);
213971
+ } catch (error) {
213972
+ pushDiagnostic(`checker '${checkerName}' failed: ${formatRuntimeError(error)}`);
213973
+ }
213777
213974
  }
213778
- }
213975
+ });
213779
213976
  }
213780
213977
  return diagnostics;
213781
213978
  };
213782
- var formatNodeArgCheckBuildDiagnostic = (diagnostic) => `check ${diagnostic.nodeId}|${diagnostic.nodeName}: ${diagnostic.argName}: ${diagnostic.message}`;
213979
+ var formatNodeFieldCheckBuildDiagnostic = (diagnostic) => diagnostic.fieldKind === "arg" ? `check ${diagnostic.nodeId}|${diagnostic.nodeName}: ${diagnostic.fieldName}: ${diagnostic.message}` : `check ${diagnostic.nodeId}|${diagnostic.nodeName}: ${diagnostic.fieldKind}[${diagnostic.fieldIndex ?? 0}:${diagnostic.fieldName}]: ${diagnostic.message}`;
213783
213980
  var syncFilesFromDiskWithContext = (files, parsedVarDecl, workdir) => {
213784
213981
  if (!hasFs()) {
213785
213982
  return;
@@ -213946,7 +214143,8 @@ var applyBehavior3DecoratorGlobal = () => {
213946
214143
  ...decoratorGlobalState.previousBehavior3 && typeof decoratorGlobalState.previousBehavior3 === "object" ? decoratorGlobalState.previousBehavior3 : {},
213947
214144
  build: markBuildHook,
213948
214145
  batch: markBatchHook,
213949
- check: markCheckHook
214146
+ check: markCheckHook,
214147
+ visible: markVisibleHook
213950
214148
  };
213951
214149
  };
213952
214150
  var restoreBehavior3DecoratorGlobal = () => {
@@ -214256,16 +214454,16 @@ var buildProjectWithContext = async (project, buildDir, context) => {
214256
214454
  if (!context.checkNodeData(tree.root, (message) => errors.push(message))) {
214257
214455
  hasError = true;
214258
214456
  }
214259
- const checkDiagnostics = collectNodeArgCheckDiagnostics({
214457
+ const checkDiagnostics = collectNodeFieldCheckDiagnostics({
214260
214458
  tree,
214261
214459
  treePath: candidatePath,
214262
214460
  env: scriptEnv,
214263
- checkers: buildRuntime.nodeArgCheckers
214461
+ checkers: buildRuntime.nodeFieldCheckers
214264
214462
  });
214265
214463
  if (checkDiagnostics.length) {
214266
214464
  hasError = true;
214267
214465
  checkDiagnostics.forEach(
214268
- (diagnostic) => errors.push(formatNodeArgCheckBuildDiagnostic(diagnostic))
214466
+ (diagnostic) => errors.push(formatNodeFieldCheckBuildDiagnostic(diagnostic))
214269
214467
  );
214270
214468
  }
214271
214469
  if (errors.length) {
@@ -214988,6 +215186,12 @@ var Node = class _Node {
214988
215186
  info(msg) {
214989
215187
  console.info(`${this.cfg.tree.name}->${this.name}#${this.id}: ${msg}`);
214990
215188
  }
215189
+ /**
215190
+ * use console.log to print log message
215191
+ */
215192
+ log(msg) {
215193
+ console.log(`${this.cfg.tree.name}->${this.name}#${this.id}: ${msg}`);
215194
+ }
214991
215195
  _checkOneof(inputIndex, argValue, defaultValue) {
214992
215196
  const inputValue = this.input[inputIndex];
214993
215197
  const inputName = this.cfg.input[inputIndex];
@@ -215048,17 +215252,24 @@ function registerNode(cls) {
215048
215252
  descriptor
215049
215253
  });
215050
215254
  }
215051
- var Stack = class {
215255
+ var StackSlice = class {
215052
215256
  _nodes = [];
215053
- _tree;
215054
- constructor(tree) {
215055
- this._tree = tree;
215056
- }
215057
215257
  get length() {
215058
215258
  return this._nodes.length;
215059
215259
  }
215060
- indexOf(node) {
215061
- return this._nodes.indexOf(node);
215260
+ move(dest, start) {
215261
+ const count = this._nodes.length - start;
215262
+ dest._nodes.push(...this._nodes.splice(start, count));
215263
+ }
215264
+ clear() {
215265
+ this._nodes.length = 0;
215266
+ }
215267
+ };
215268
+ var Stack = class extends StackSlice {
215269
+ _tree;
215270
+ constructor(tree) {
215271
+ super();
215272
+ this._tree = tree;
215062
215273
  }
215063
215274
  top() {
215064
215275
  const nodes = this._nodes;
@@ -215079,9 +215290,6 @@ var Stack = class {
215079
215290
  this.pop();
215080
215291
  }
215081
215292
  }
215082
- move(dest, start, count) {
215083
- dest._nodes.push(...this._nodes.splice(start, count));
215084
- }
215085
215293
  clear() {
215086
215294
  this.popTo(0);
215087
215295
  }
@@ -215990,7 +216198,7 @@ var Parallel = class extends (_a17 = Node) {
215990
216198
  if (childStack === void 0) {
215991
216199
  status = children[i].tick(tree);
215992
216200
  } else if (childStack.length > 0) {
215993
- childStack.move(stack, 0, childStack.length);
216201
+ childStack.move(stack, 0);
215994
216202
  while (stack.length > level) {
215995
216203
  status = stack.top().tick(tree);
215996
216204
  if (status === "running") {
@@ -216002,9 +216210,9 @@ var Parallel = class extends (_a17 = Node) {
216002
216210
  }
216003
216211
  if (status === "running") {
216004
216212
  if (childStack === void 0) {
216005
- childStack = new Stack(tree);
216213
+ childStack = new StackSlice();
216006
216214
  }
216007
- stack.move(childStack, level, stack.length - level);
216215
+ stack.move(childStack, level);
216008
216216
  } else {
216009
216217
  count++;
216010
216218
  childStack = EMPTY_STACK$1;
@@ -216050,7 +216258,7 @@ var Race = class extends (_a18 = Node) {
216050
216258
  if (childStack === void 0) {
216051
216259
  status = children[i].tick(tree);
216052
216260
  } else if (childStack.length > 0) {
216053
- childStack.move(stack, 0, childStack.length);
216261
+ childStack.move(stack, 0);
216054
216262
  while (stack.length > level) {
216055
216263
  status = stack.top().tick(tree);
216056
216264
  if (status === "running") {
@@ -216060,9 +216268,9 @@ var Race = class extends (_a18 = Node) {
216060
216268
  }
216061
216269
  if (status === "running") {
216062
216270
  if (childStack === void 0) {
216063
- childStack = new Stack(tree);
216271
+ childStack = new StackSlice();
216064
216272
  }
216065
- stack.move(childStack, level, stack.length - level);
216273
+ stack.move(childStack, level);
216066
216274
  } else if (status === "success") {
216067
216275
  last.forEach((v) => v !== EMPTY_STACK && v.clear());
216068
216276
  return "success";
@@ -216298,7 +216506,7 @@ var Watchdog = class extends (_a23 = Node) {
216298
216506
  } else if (last === void 0) {
216299
216507
  status = this.children[1].tick(tree);
216300
216508
  } else {
216301
- last.move(tree.stack, 0, last.length);
216509
+ last.move(tree.stack, 0);
216302
216510
  while (tree.stack.length > level) {
216303
216511
  const child = tree.stack.top();
216304
216512
  status = child.tick(tree);
@@ -216309,9 +216517,9 @@ var Watchdog = class extends (_a23 = Node) {
216309
216517
  }
216310
216518
  if (status === "running") {
216311
216519
  if (last === void 0) {
216312
- last = new Stack(tree);
216520
+ last = new StackSlice();
216313
216521
  }
216314
- tree.stack.move(last, level, tree.stack.length - level);
216522
+ tree.stack.move(last, level);
216315
216523
  return tree.yield(this, last);
216316
216524
  } else {
216317
216525
  return status;
@@ -217137,7 +217345,7 @@ var Timeout = class extends (_a41 = Node) {
217137
217345
  last.stack.clear();
217138
217346
  return "failure";
217139
217347
  } else {
217140
- last.stack.move(stack, 0, last.stack.length);
217348
+ last.stack.move(stack, 0);
217141
217349
  while (stack.length > level) {
217142
217350
  const child = stack.top();
217143
217351
  status = child.tick(tree);
@@ -217150,11 +217358,11 @@ var Timeout = class extends (_a41 = Node) {
217150
217358
  if (last === void 0) {
217151
217359
  const time = this._checkOneof(0, this.args.time, 0);
217152
217360
  last = {
217153
- stack: new Stack(tree),
217361
+ stack: new StackSlice(),
217154
217362
  expired: context.time + time
217155
217363
  };
217156
217364
  }
217157
- stack.move(last.stack, level, stack.length - level);
217365
+ stack.move(last.stack, level);
217158
217366
  return tree.yield(this, last);
217159
217367
  } else {
217160
217368
  return status;
@@ -217177,6 +217385,7 @@ var Timeout = class extends (_a41 = Node) {
217177
217385
  }
217178
217386
  ],
217179
217387
  doc: `
217388
+ + \u5728\u9650\u5B9A\u65F6\u95F4\u5185\u6267\u884C\u5B50\u8282\u70B9\uFF0C\u8D85\u65F6\u5219\u5931\u8D25
217180
217389
  + \u53EA\u80FD\u6709\u4E00\u4E2A\u5B50\u8282\u70B9\uFF0C\u591A\u4E2A\u4EC5\u6267\u884C\u7B2C\u4E00\u4E2A
217181
217390
  + \u5F53\u5B50\u8282\u70B9\u6267\u884C\u8D85\u65F6\u6216\u8FD4\u56DE \`failure\` \u65F6\uFF0C\u8FD4\u56DE \`failure\`
217182
217391
  + \u5176\u4F59\u60C5\u51B5\u8FD4\u56DE\u5B50\u8282\u70B9\u7684\u6267\u884C\u72B6\u6001
@@ -217235,6 +217444,14 @@ var validateExpressionEntries = (entries, usingVars, checkExpr) => {
217235
217444
  return null;
217236
217445
  };
217237
217446
  var getArgLabel = (arg) => arg.desc || arg.name;
217447
+ var findNodeArgOneofInputIndex = (arg, inputDefs) => {
217448
+ if (!arg.oneof || !inputDefs?.length) {
217449
+ return -1;
217450
+ }
217451
+ return inputDefs.findIndex(
217452
+ (input, index) => parseSlotDefinition(input, inputDefs, index).label === arg.oneof
217453
+ );
217454
+ };
217238
217455
  var isRequiredNodeArgValueMissing = (arg, value) => {
217239
217456
  if (isNodeArgOptional(arg)) {
217240
217457
  return false;
@@ -217349,6 +217566,28 @@ var validateNodeArgValue = (params) => {
217349
217566
  }
217350
217567
  return validateNodeArgScalarValue(arg, value, args, validateOptions);
217351
217568
  };
217569
+ var validateNodeArgOneof = (params) => {
217570
+ const { arg, argValue, inputValues, inputDefs } = params;
217571
+ if (!arg.oneof) {
217572
+ return null;
217573
+ }
217574
+ const relatedInputIndex = findNodeArgOneofInputIndex(arg, inputDefs);
217575
+ if (relatedInputIndex < 0) {
217576
+ return {
217577
+ code: "missing-oneof-input",
217578
+ argName: arg.name,
217579
+ inputLabel: arg.oneof
217580
+ };
217581
+ }
217582
+ if (checkOneof(arg, argValue, inputValues?.[relatedInputIndex])) {
217583
+ return null;
217584
+ }
217585
+ return {
217586
+ code: "oneof-conflict",
217587
+ argName: arg.name,
217588
+ inputLabel: arg.oneof
217589
+ };
217590
+ };
217352
217591
 
217353
217592
  // webview/shared/b3build-context.ts
217354
217593
  var unknownNodeDef = {
@@ -217432,6 +217671,10 @@ var formatBuildDiagnostic = (diagnostic) => {
217432
217671
  return `intput field '${diagnostic.label}' is required`;
217433
217672
  case "required-output":
217434
217673
  return `output field '${diagnostic.label}' is required`;
217674
+ case "missing-oneof-input":
217675
+ return `missing oneof input slot '${diagnostic.inputLabel}' for arg '${diagnostic.argName}'`;
217676
+ case "oneof-conflict":
217677
+ return `only one of arg '${diagnostic.argName}' and input '${diagnostic.inputLabel}' can be set`;
217435
217678
  case "invalid-arg-value": {
217436
217679
  const value = JSON.stringify(diagnostic.value);
217437
217680
  switch (diagnostic.expected) {
@@ -217472,14 +217715,15 @@ var checkNodeArg = (data, conf, i, printer) => {
217472
217715
  const diagnostics = validateNodeArgValue({ arg, value, args: data.args ?? {} });
217473
217716
  let hasError = diagnostics.length > 0;
217474
217717
  diagnostics.forEach((diagnostic) => error(formatBuildDiagnostic(diagnostic)));
217475
- if (arg.oneof !== void 0) {
217476
- const idx = conf.input?.findIndex((v) => v.startsWith(arg.oneof)) ?? -1;
217477
- if (!checkOneof(arg, data.args?.[arg.name], data.input?.[idx])) {
217478
- error(
217479
- `only one is allowed for between argument '${arg.name}' and input '${data.input?.[idx]}'`
217480
- );
217481
- hasError = true;
217482
- }
217718
+ const oneofDiagnostic = validateNodeArgOneof({
217719
+ arg,
217720
+ argValue: value,
217721
+ inputValues: data.input,
217722
+ inputDefs: conf.input
217723
+ });
217724
+ if (oneofDiagnostic) {
217725
+ error(formatBuildDiagnostic(oneofDiagnostic));
217726
+ hasError = true;
217483
217727
  }
217484
217728
  return !hasError;
217485
217729
  };
@@ -217551,6 +217795,7 @@ var checkNodeDataWithState = (data, printer, state) => {
217551
217795
  let hasVaridicInput = false;
217552
217796
  if (conf.input) {
217553
217797
  for (let i = 0; i < conf.input.length; i++) {
217798
+ const slotDefinition = parseSlotDefinition(conf.input[i] ?? "", conf.input, i);
217554
217799
  if (!data.input) {
217555
217800
  data.input = [];
217556
217801
  }
@@ -217558,7 +217803,7 @@ var checkNodeDataWithState = (data, printer, state) => {
217558
217803
  data.input[i] = "";
217559
217804
  }
217560
217805
  if (!isValidInputOrOutput(conf.input, data.input, i)) {
217561
- error(`intput field '${conf.input[i]}' is required`);
217806
+ error(`intput field '${slotDefinition.label}' is required`);
217562
217807
  hasError = true;
217563
217808
  }
217564
217809
  if (i === conf.input.length - 1 && isVariadic(conf.input, -1)) {
@@ -217572,6 +217817,7 @@ var checkNodeDataWithState = (data, printer, state) => {
217572
217817
  let hasVaridicOutput = false;
217573
217818
  if (conf.output) {
217574
217819
  for (let i = 0; i < conf.output.length; i++) {
217820
+ const slotDefinition = parseSlotDefinition(conf.output[i] ?? "", conf.output, i);
217575
217821
  if (!data.output) {
217576
217822
  data.output = [];
217577
217823
  }
@@ -217579,7 +217825,7 @@ var checkNodeDataWithState = (data, printer, state) => {
217579
217825
  data.output[i] = "";
217580
217826
  }
217581
217827
  if (!isValidInputOrOutput(conf.output, data.output, i)) {
217582
- error(`output field '${conf.output[i]}' is required`);
217828
+ error(`output field '${slotDefinition.label}' is required`);
217583
217829
  hasError = true;
217584
217830
  }
217585
217831
  if (i === conf.output.length - 1 && isVariadic(conf.output, -1)) {