vscode-behavior3 2.3.3 → 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/extension.js CHANGED
@@ -212530,6 +212530,12 @@ var Node = class _Node {
212530
212530
  info(msg) {
212531
212531
  console.info(`${this.cfg.tree.name}->${this.name}#${this.id}: ${msg}`);
212532
212532
  }
212533
+ /**
212534
+ * use console.log to print log message
212535
+ */
212536
+ log(msg) {
212537
+ console.log(`${this.cfg.tree.name}->${this.name}#${this.id}: ${msg}`);
212538
+ }
212533
212539
  _checkOneof(inputIndex, argValue, defaultValue) {
212534
212540
  const inputValue = this.input[inputIndex];
212535
212541
  const inputName = this.cfg.input[inputIndex];
@@ -212768,17 +212774,24 @@ var Context = class {
212768
212774
  return Node.create(this, treeCfg.root);
212769
212775
  }
212770
212776
  };
212771
- var Stack = class {
212777
+ var StackSlice = class {
212772
212778
  _nodes = [];
212773
- _tree;
212774
- constructor(tree) {
212775
- this._tree = tree;
212776
- }
212777
212779
  get length() {
212778
212780
  return this._nodes.length;
212779
212781
  }
212780
- indexOf(node) {
212781
- return this._nodes.indexOf(node);
212782
+ move(dest, start) {
212783
+ const count = this._nodes.length - start;
212784
+ dest._nodes.push(...this._nodes.splice(start, count));
212785
+ }
212786
+ clear() {
212787
+ this._nodes.length = 0;
212788
+ }
212789
+ };
212790
+ var Stack = class extends StackSlice {
212791
+ _tree;
212792
+ constructor(tree) {
212793
+ super();
212794
+ this._tree = tree;
212782
212795
  }
212783
212796
  top() {
212784
212797
  const nodes = this._nodes;
@@ -212799,9 +212812,6 @@ var Stack = class {
212799
212812
  this.pop();
212800
212813
  }
212801
212814
  }
212802
- move(dest, start, count) {
212803
- dest._nodes.push(...this._nodes.splice(start, count));
212804
- }
212805
212815
  clear() {
212806
212816
  this.popTo(0);
212807
212817
  }
@@ -213710,7 +213720,7 @@ var Parallel = class extends (_a17 = Node) {
213710
213720
  if (childStack === void 0) {
213711
213721
  status = children[i].tick(tree);
213712
213722
  } else if (childStack.length > 0) {
213713
- childStack.move(stack, 0, childStack.length);
213723
+ childStack.move(stack, 0);
213714
213724
  while (stack.length > level) {
213715
213725
  status = stack.top().tick(tree);
213716
213726
  if (status === "running") {
@@ -213722,9 +213732,9 @@ var Parallel = class extends (_a17 = Node) {
213722
213732
  }
213723
213733
  if (status === "running") {
213724
213734
  if (childStack === void 0) {
213725
- childStack = new Stack(tree);
213735
+ childStack = new StackSlice();
213726
213736
  }
213727
- stack.move(childStack, level, stack.length - level);
213737
+ stack.move(childStack, level);
213728
213738
  } else {
213729
213739
  count++;
213730
213740
  childStack = EMPTY_STACK$1;
@@ -213770,7 +213780,7 @@ var Race = class extends (_a18 = Node) {
213770
213780
  if (childStack === void 0) {
213771
213781
  status = children[i].tick(tree);
213772
213782
  } else if (childStack.length > 0) {
213773
- childStack.move(stack, 0, childStack.length);
213783
+ childStack.move(stack, 0);
213774
213784
  while (stack.length > level) {
213775
213785
  status = stack.top().tick(tree);
213776
213786
  if (status === "running") {
@@ -213780,9 +213790,9 @@ var Race = class extends (_a18 = Node) {
213780
213790
  }
213781
213791
  if (status === "running") {
213782
213792
  if (childStack === void 0) {
213783
- childStack = new Stack(tree);
213793
+ childStack = new StackSlice();
213784
213794
  }
213785
- stack.move(childStack, level, stack.length - level);
213795
+ stack.move(childStack, level);
213786
213796
  } else if (status === "success") {
213787
213797
  last.forEach((v) => v !== EMPTY_STACK && v.clear());
213788
213798
  return "success";
@@ -214018,7 +214028,7 @@ var Watchdog = class extends (_a23 = Node) {
214018
214028
  } else if (last === void 0) {
214019
214029
  status = this.children[1].tick(tree);
214020
214030
  } else {
214021
- last.move(tree.stack, 0, last.length);
214031
+ last.move(tree.stack, 0);
214022
214032
  while (tree.stack.length > level) {
214023
214033
  const child = tree.stack.top();
214024
214034
  status = child.tick(tree);
@@ -214029,9 +214039,9 @@ var Watchdog = class extends (_a23 = Node) {
214029
214039
  }
214030
214040
  if (status === "running") {
214031
214041
  if (last === void 0) {
214032
- last = new Stack(tree);
214042
+ last = new StackSlice();
214033
214043
  }
214034
- tree.stack.move(last, level, tree.stack.length - level);
214044
+ tree.stack.move(last, level);
214035
214045
  return tree.yield(this, last);
214036
214046
  } else {
214037
214047
  return status;
@@ -214857,7 +214867,7 @@ var Timeout = class extends (_a41 = Node) {
214857
214867
  last.stack.clear();
214858
214868
  return "failure";
214859
214869
  } else {
214860
- last.stack.move(stack, 0, last.stack.length);
214870
+ last.stack.move(stack, 0);
214861
214871
  while (stack.length > level) {
214862
214872
  const child = stack.top();
214863
214873
  status = child.tick(tree);
@@ -214870,11 +214880,11 @@ var Timeout = class extends (_a41 = Node) {
214870
214880
  if (last === void 0) {
214871
214881
  const time = this._checkOneof(0, this.args.time, 0);
214872
214882
  last = {
214873
- stack: new Stack(tree),
214883
+ stack: new StackSlice(),
214874
214884
  expired: context.time + time
214875
214885
  };
214876
214886
  }
214877
- stack.move(last.stack, level, stack.length - level);
214887
+ stack.move(last.stack, level);
214878
214888
  return tree.yield(this, last);
214879
214889
  } else {
214880
214890
  return status;
@@ -214897,6 +214907,7 @@ var Timeout = class extends (_a41 = Node) {
214897
214907
  }
214898
214908
  ],
214899
214909
  doc: `
214910
+ + \u5728\u9650\u5B9A\u65F6\u95F4\u5185\u6267\u884C\u5B50\u8282\u70B9\uFF0C\u8D85\u65F6\u5219\u5931\u8D25
214900
214911
  + \u53EA\u80FD\u6709\u4E00\u4E2A\u5B50\u8282\u70B9\uFF0C\u591A\u4E2A\u4EC5\u6267\u884C\u7B2C\u4E00\u4E2A
214901
214912
  + \u5F53\u5B50\u8282\u70B9\u6267\u884C\u8D85\u65F6\u6216\u8FD4\u56DE \`failure\` \u65F6\uFF0C\u8FD4\u56DE \`failure\`
214902
214913
  + \u5176\u4F59\u60C5\u51B5\u8FD4\u56DE\u5B50\u8282\u70B9\u7684\u6267\u884C\u72B6\u6001
@@ -215392,6 +215403,34 @@ var asStringArray = (value, label) => {
215392
215403
  return entry;
215393
215404
  });
215394
215405
  };
215406
+ var normalizeNodeLabel = (label, record) => {
215407
+ const rawNodeName = record.name;
215408
+ if (typeof rawNodeName !== "string" || !rawNodeName.trim()) {
215409
+ return label;
215410
+ }
215411
+ return `${label}(${rawNodeName.trim()})`;
215412
+ };
215413
+ var normalizeNodeSlotEntry = (value, label) => {
215414
+ if (typeof value === "string") {
215415
+ return asRequiredString(value, label);
215416
+ }
215417
+ const record = expectPlainRecord(value, label);
215418
+ return {
215419
+ name: asRequiredString(record.name, `${label}.name`),
215420
+ checker: asOptionalNonEmptyString(record.checker, `${label}.checker`),
215421
+ visible: asOptionalNonEmptyString(record.visible, `${label}.visible`)
215422
+ };
215423
+ };
215424
+ var normalizeNodeSlots = (value, label) => {
215425
+ if (value === void 0) {
215426
+ return void 0;
215427
+ }
215428
+ if (!Array.isArray(value)) {
215429
+ throw new Error(`${label} must be an array`);
215430
+ }
215431
+ const slots = value.map((entry, index) => normalizeNodeSlotEntry(entry, `${label}[${index}]`));
215432
+ return slots.length > 0 ? slots : void 0;
215433
+ };
215395
215434
  var asWorkdirRelativeJsonPathArray = (value, label) => {
215396
215435
  const entries = asStringArray(value, label);
215397
215436
  return entries.map((entry, index) => {
@@ -215502,44 +215541,43 @@ var normalizeNodeArgs = (value, label) => {
215502
215541
  oneof: asOptionalString(record.oneof),
215503
215542
  default: record.default,
215504
215543
  options: normalizeNodeArgOptions(record.options, `${label}[${index}].options`),
215505
- checker: asOptionalNonEmptyString(record.checker, `${label}[${index}].checker`)
215544
+ checker: asOptionalNonEmptyString(record.checker, `${label}[${index}].checker`),
215545
+ visible: asOptionalNonEmptyString(record.visible, `${label}[${index}].visible`)
215506
215546
  };
215507
215547
  });
215508
215548
  };
215509
215549
  var normalizeNodeDef = (value, label) => {
215510
215550
  const record = expectPlainRecord(value, label);
215511
- const type = asRequiredString(record.type, `${label}.type`);
215551
+ const nodeLabel = normalizeNodeLabel(label, record);
215552
+ const name = asRequiredString(record.name, `${nodeLabel}.name`);
215553
+ const type = asRequiredString(record.type, `${nodeLabel}.type`);
215512
215554
  if (!NODE_DEF_TYPES.has(type)) {
215513
- throw new Error(`${label}.type must be one of ${Array.from(NODE_DEF_TYPES).join(", ")}`);
215555
+ throw new Error(
215556
+ `${nodeLabel}.type must be one of ${Array.from(NODE_DEF_TYPES).join(", ")}`
215557
+ );
215514
215558
  }
215515
215559
  const groupValue = record.group;
215516
215560
  const group = groupValue === void 0 ? void 0 : Array.isArray(groupValue) ? groupValue.map(
215517
- (entry, index) => asRequiredString(entry, `${label}.group[${index}]`)
215518
- ) : [asRequiredString(groupValue, `${label}.group`)];
215561
+ (entry, index) => asRequiredString(entry, `${nodeLabel}.group[${index}]`)
215562
+ ) : [asRequiredString(groupValue, `${nodeLabel}.group`)];
215519
215563
  const childrenValue = record.children;
215520
215564
  if (childrenValue !== void 0 && !CHILDREN_ARITIES.has(childrenValue)) {
215521
- throw new Error(`${label}.children must be one of -1, 0, 1, 2, 3`);
215565
+ throw new Error(`${nodeLabel}.children must be one of -1, 0, 1, 2, 3`);
215522
215566
  }
215523
215567
  const statusValue = record.status;
215524
- const status = statusValue === void 0 ? void 0 : asStringArray(statusValue, `${label}.status`).map((entry) => {
215568
+ const status = statusValue === void 0 ? void 0 : asStringArray(statusValue, `${nodeLabel}.status`).map((entry) => {
215525
215569
  if (!NODE_STATUS_VALUES.has(entry)) {
215526
- throw new Error(`${label}.status contains unsupported value: ${entry}`);
215570
+ throw new Error(`${nodeLabel}.status contains unsupported value: ${entry}`);
215527
215571
  }
215528
215572
  return entry;
215529
215573
  });
215530
215574
  return {
215531
- name: asRequiredString(record.name, `${label}.name`),
215575
+ name,
215532
215576
  type,
215533
215577
  desc: asOptionalString(record.desc) ?? "",
215534
- input: (() => {
215535
- const input = asStringArray(record.input, `${label}.input`);
215536
- return input.length > 0 ? input : void 0;
215537
- })(),
215538
- output: (() => {
215539
- const output = asStringArray(record.output, `${label}.output`);
215540
- return output.length > 0 ? output : void 0;
215541
- })(),
215542
- args: normalizeNodeArgs(record.args, `${label}.args`),
215578
+ input: normalizeNodeSlots(record.input, `${nodeLabel}.input`),
215579
+ output: normalizeNodeSlots(record.output, `${nodeLabel}.output`),
215580
+ args: normalizeNodeArgs(record.args, `${nodeLabel}.args`),
215543
215581
  doc: asOptionalString(record.doc),
215544
215582
  icon: asOptionalString(record.icon),
215545
215583
  color: asOptionalString(record.color),
@@ -216146,16 +216184,22 @@ var findNodeDef = (nodeDefMap, nodeName) => {
216146
216184
  return nodeDefMap.get(nodeName) ?? null;
216147
216185
  };
216148
216186
  var cleanSlotLabel = (value) => value.replace(/\.\.\.$/, "").replace(/\?/g, "");
216187
+ var isStructuredSlotDefinition = (slot) => Boolean(slot && typeof slot === "object" && !Array.isArray(slot));
216149
216188
  var parseSlotDefinition = (slot, slotDefs, index) => {
216150
- const raw = slot ?? "";
216189
+ const raw = typeof slot === "string" ? slot : slot?.name ?? "";
216151
216190
  const hasOptionalMarker = raw.includes("?");
216152
216191
  const hasVariadicMarker = raw.endsWith("...");
216153
216192
  const variadic = hasVariadicMarker && (slotDefs && index !== void 0 ? index === slotDefs.length - 1 : true);
216193
+ const checker = isStructuredSlotDefinition(slot) ? slot.checker?.trim() || void 0 : void 0;
216194
+ const visible = isStructuredSlotDefinition(slot) ? slot.visible?.trim() || void 0 : void 0;
216154
216195
  return {
216155
216196
  raw,
216197
+ name: cleanSlotLabel(raw),
216156
216198
  label: cleanSlotLabel(raw),
216157
216199
  required: !hasOptionalMarker,
216158
- variadic
216200
+ variadic,
216201
+ checker,
216202
+ visible
216159
216203
  };
216160
216204
  };
216161
216205
  var getNodeArgRawType = (arg) => {
@@ -216478,6 +216522,8 @@ var BUILD_HOOK_MARKER = "__behavior3BuildHook";
216478
216522
  var BATCH_HOOK_MARKER = "__behavior3BatchHook";
216479
216523
  var CHECK_HOOK_MARKER = "__behavior3CheckHook";
216480
216524
  var CHECK_HOOK_NAME = "__behavior3CheckName";
216525
+ var VISIBLE_HOOK_MARKER = "__behavior3VisibleHook";
216526
+ var VISIBLE_HOOK_NAME = "__behavior3VisibleName";
216481
216527
  var markBuildHook = (ctor) => {
216482
216528
  Object.defineProperty(ctor, BUILD_HOOK_MARKER, {
216483
216529
  value: true,
@@ -216504,15 +216550,34 @@ var markCheckCtor = (ctor, explicitName) => {
216504
216550
  });
216505
216551
  return ctor;
216506
216552
  };
216553
+ var markVisibleCtor = (ctor, explicitName) => {
216554
+ const name = explicitName?.trim() || ctor.name;
216555
+ Object.defineProperty(ctor, VISIBLE_HOOK_MARKER, {
216556
+ value: true,
216557
+ configurable: false
216558
+ });
216559
+ Object.defineProperty(ctor, VISIBLE_HOOK_NAME, {
216560
+ value: name,
216561
+ configurable: false
216562
+ });
216563
+ return ctor;
216564
+ };
216507
216565
  var markCheckHook = (nameOrCtor, _context) => {
216508
216566
  if (typeof nameOrCtor === "function") {
216509
216567
  return markCheckCtor(nameOrCtor);
216510
216568
  }
216511
216569
  return (ctor) => markCheckCtor(ctor, nameOrCtor);
216512
216570
  };
216571
+ var markVisibleHook = (nameOrCtor, _context) => {
216572
+ if (typeof nameOrCtor === "function") {
216573
+ return markVisibleCtor(nameOrCtor);
216574
+ }
216575
+ return (ctor) => markVisibleCtor(ctor, nameOrCtor);
216576
+ };
216513
216577
  var isDecoratedBuildHookCtor = (value) => typeof value === "function" && value[BUILD_HOOK_MARKER] === true;
216514
216578
  var isDecoratedBatchHookCtor = (value) => typeof value === "function" && value[BATCH_HOOK_MARKER] === true;
216515
216579
  var isDecoratedCheckCtor = (value) => typeof value === "function" && value[CHECK_HOOK_MARKER] === true;
216580
+ var isDecoratedVisibleCtor = (value) => typeof value === "function" && value[VISIBLE_HOOK_MARKER] === true;
216516
216581
  var findDecoratedBuildHookCtor = (moduleRecord) => {
216517
216582
  const decorated = Array.from(new Set(Object.values(moduleRecord))).filter(
216518
216583
  isDecoratedBuildHookCtor
@@ -216544,6 +216609,7 @@ var findDecoratedBatchHookCtor = (moduleRecord) => {
216544
216609
  return legacyDecorated[0];
216545
216610
  };
216546
216611
  var findDecoratedCheckCtors = (moduleRecord) => Array.from(new Set(Object.values(moduleRecord))).filter(isDecoratedCheckCtor);
216612
+ var findDecoratedVisibleCtors = (moduleRecord) => Array.from(new Set(Object.values(moduleRecord))).filter(isDecoratedVisibleCtor);
216547
216613
  var createBuildHooks = (moduleExports, env2, reportMissing = true) => {
216548
216614
  if (!moduleExports || typeof moduleExports !== "object") {
216549
216615
  return void 0;
@@ -216594,7 +216660,7 @@ var createBatchHooks = (moduleExports, env2, reportMissing = true) => {
216594
216660
  }
216595
216661
  return void 0;
216596
216662
  };
216597
- var createNodeArgCheckers = (moduleExports, env2) => {
216663
+ var createNodeFieldCheckers = (moduleExports, env2) => {
216598
216664
  const checkers = /* @__PURE__ */ new Map();
216599
216665
  let hasError = false;
216600
216666
  if (!moduleExports || typeof moduleExports !== "object") {
@@ -216629,10 +216695,70 @@ var createNodeArgCheckers = (moduleExports, env2) => {
216629
216695
  }
216630
216696
  return { checkers, hasError, hasCheckers: decorated.length > 0 };
216631
216697
  };
216698
+ var normalizeNodeFieldVisibleResult = (result) => result !== false;
216699
+ var createNodeFieldVisibles = (moduleExports, env2) => {
216700
+ const visibles = /* @__PURE__ */ new Map();
216701
+ let hasError = false;
216702
+ if (!moduleExports || typeof moduleExports !== "object") {
216703
+ return { visibles, hasError, hasVisibles: false };
216704
+ }
216705
+ const moduleRecord = moduleExports;
216706
+ const decorated = findDecoratedVisibleCtors(moduleRecord);
216707
+ for (const ctor of decorated) {
216708
+ const name = ctor[VISIBLE_HOOK_NAME]?.trim() || ctor.name;
216709
+ if (!name) {
216710
+ logger.error("visible class must have a non-empty @behavior3.visible name");
216711
+ hasError = true;
216712
+ continue;
216713
+ }
216714
+ if (visibles.has(name)) {
216715
+ logger.error(`duplicate @behavior3.visible registration: ${name}`);
216716
+ hasError = true;
216717
+ continue;
216718
+ }
216719
+ try {
216720
+ const instance = new ctor(env2);
216721
+ if (typeof instance.visible !== "function") {
216722
+ logger.error(`visible '${name}' must provide a visible(value, ctx) method`);
216723
+ hasError = true;
216724
+ continue;
216725
+ }
216726
+ visibles.set(name, instance);
216727
+ } catch (error) {
216728
+ logger.error(`failed to instantiate visible '${name}'`, error);
216729
+ hasError = true;
216730
+ }
216731
+ }
216732
+ return { visibles, hasError, hasVisibles: decorated.length > 0 };
216733
+ };
216734
+ var createNodeFieldVisibleRuntimeWithCheckModules = (buildScriptModule, checkScriptModules, env2) => {
216735
+ const nodeFieldVisibles = /* @__PURE__ */ new Map();
216736
+ let hasError = false;
216737
+ const mergeModuleVisibles = (moduleExports) => {
216738
+ const visibleResult = createNodeFieldVisibles(moduleExports, env2);
216739
+ hasError = hasError || visibleResult.hasError;
216740
+ for (const [name, visible] of visibleResult.visibles) {
216741
+ if (nodeFieldVisibles.has(name)) {
216742
+ logger.error(`duplicate @behavior3.visible registration: ${name}`);
216743
+ hasError = true;
216744
+ continue;
216745
+ }
216746
+ nodeFieldVisibles.set(name, visible);
216747
+ }
216748
+ };
216749
+ mergeModuleVisibles(buildScriptModule);
216750
+ for (const checkScript of checkScriptModules) {
216751
+ mergeModuleVisibles(checkScript.moduleExports);
216752
+ }
216753
+ return {
216754
+ nodeFieldVisibles,
216755
+ hasError
216756
+ };
216757
+ };
216632
216758
  var createBuildScriptRuntime = (moduleExports, env2) => {
216633
216759
  if (!moduleExports || typeof moduleExports !== "object") {
216634
216760
  return {
216635
- nodeArgCheckers: /* @__PURE__ */ new Map(),
216761
+ nodeFieldCheckers: /* @__PURE__ */ new Map(),
216636
216762
  hasError: false,
216637
216763
  hasEntries: false
216638
216764
  };
@@ -216640,7 +216766,7 @@ var createBuildScriptRuntime = (moduleExports, env2) => {
216640
216766
  const moduleRecord = moduleExports;
216641
216767
  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);
216642
216768
  const buildScript = createBuildHooks(moduleExports, env2, false);
216643
- const checkerResult = createNodeArgCheckers(moduleExports, env2);
216769
+ const checkerResult = createNodeFieldCheckers(moduleExports, env2);
216644
216770
  const hasEntries = Boolean(buildScript) || checkerResult.hasCheckers;
216645
216771
  if (!hasEntries) {
216646
216772
  logger.error(
@@ -216649,39 +216775,35 @@ var createBuildScriptRuntime = (moduleExports, env2) => {
216649
216775
  }
216650
216776
  return {
216651
216777
  buildScript,
216652
- nodeArgCheckers: checkerResult.checkers,
216778
+ nodeFieldCheckers: checkerResult.checkers,
216653
216779
  hasError: checkerResult.hasError || !hasEntries || hasBuildHookCandidate && !buildScript,
216654
216780
  hasEntries
216655
216781
  };
216656
216782
  };
216657
216783
  var createBuildScriptRuntimeWithCheckModules = (buildScriptModule, checkScriptModules, env2) => {
216658
216784
  const runtime = createBuildScriptRuntime(buildScriptModule, env2);
216659
- const nodeArgCheckers = new Map(runtime.nodeArgCheckers);
216785
+ const nodeFieldCheckers = new Map(runtime.nodeFieldCheckers);
216660
216786
  let hasError = runtime.hasError;
216661
216787
  let hasCheckEntries = false;
216662
216788
  for (const checkScript of checkScriptModules) {
216663
- const checkerResult = createNodeArgCheckers(checkScript.moduleExports, env2);
216789
+ const checkerResult = createNodeFieldCheckers(checkScript.moduleExports, env2);
216664
216790
  if (!checkerResult.hasCheckers) {
216665
- logger.error(
216666
- `check script must export at least one @behavior3.check class: ${checkScript.path}`
216667
- );
216668
- hasError = true;
216669
216791
  continue;
216670
216792
  }
216671
216793
  hasCheckEntries = true;
216672
216794
  hasError = hasError || checkerResult.hasError;
216673
216795
  for (const [name, checker] of checkerResult.checkers) {
216674
- if (nodeArgCheckers.has(name)) {
216796
+ if (nodeFieldCheckers.has(name)) {
216675
216797
  logger.error(`duplicate @behavior3.check registration: ${name}`);
216676
216798
  hasError = true;
216677
216799
  continue;
216678
216800
  }
216679
- nodeArgCheckers.set(name, checker);
216801
+ nodeFieldCheckers.set(name, checker);
216680
216802
  }
216681
216803
  }
216682
216804
  return {
216683
216805
  ...runtime,
216684
- nodeArgCheckers,
216806
+ nodeFieldCheckers,
216685
216807
  hasError,
216686
216808
  hasEntries: runtime.hasEntries || hasCheckEntries
216687
216809
  };
@@ -216827,7 +216949,12 @@ var processBatchTree = (tree, treePath, batch, errors) => {
216827
216949
  }
216828
216950
  return tree;
216829
216951
  };
216830
- var normalizeNodeArgCheckResult = (result) => {
216952
+ var createEmptyNodeFieldVisibilityState = () => ({
216953
+ args: {},
216954
+ input: {},
216955
+ output: {}
216956
+ });
216957
+ var normalizeNodeFieldCheckResult = (result) => {
216831
216958
  if (Array.isArray(result)) {
216832
216959
  return result.filter((entry) => typeof entry === "string" && entry.trim());
216833
216960
  }
@@ -216845,7 +216972,105 @@ var walkTreeNodes = (node, visit) => {
216845
216972
  walkTreeNodes(child, visit);
216846
216973
  }
216847
216974
  };
216848
- var collectNodeArgCheckDiagnostics = (params) => {
216975
+ var buildNodeSlotField = (slot, slotDefs, index) => {
216976
+ const parsed = parseSlotDefinition(slot, slotDefs, index);
216977
+ return {
216978
+ name: parsed.name,
216979
+ label: parsed.label,
216980
+ required: parsed.required,
216981
+ variadic: parsed.variadic,
216982
+ checker: parsed.checker,
216983
+ visible: parsed.visible
216984
+ };
216985
+ };
216986
+ var getSlotValue = (values, slotDefs, index) => {
216987
+ const slotField = parseSlotDefinition(slotDefs?.[index] ?? "", slotDefs, index);
216988
+ return slotField.variadic ? values?.slice(index) ?? [] : values?.[index];
216989
+ };
216990
+ var formatFieldLocator = (node, fieldKind, fieldName, fieldIndex) => {
216991
+ if (fieldKind === "arg") {
216992
+ return `${node.id}|${node.name}.${fieldName}`;
216993
+ }
216994
+ return `${node.id}|${node.name}.${fieldKind}[${fieldIndex ?? 0}:${fieldName}]`;
216995
+ };
216996
+ var getNodeSlotContext = (params) => {
216997
+ if (!isStructuredSlotDefinition(params.slot)) {
216998
+ return null;
216999
+ }
217000
+ return {
217001
+ node: params.node,
217002
+ tree: params.tree,
217003
+ nodeDef: params.nodeDef,
217004
+ fieldKind: params.fieldKind,
217005
+ fieldName: buildNodeSlotField(params.slot, params.slotDefs, params.index).name,
217006
+ fieldIndex: params.index,
217007
+ slot: params.fieldKind === "input" ? params.slot : params.slot,
217008
+ slotField: buildNodeSlotField(params.slot, params.slotDefs, params.index),
217009
+ treePath: params.treePath,
217010
+ env: params.env
217011
+ };
217012
+ };
217013
+ var visitCustomNodeFields = (params) => {
217014
+ for (const arg of params.nodeDef.args ?? []) {
217015
+ const checkerName = arg.checker?.trim() || void 0;
217016
+ const visibleName = arg.visible?.trim() || void 0;
217017
+ if (!(checkerName || visibleName)) {
217018
+ continue;
217019
+ }
217020
+ const ctx = {
217021
+ node: params.node,
217022
+ tree: params.tree,
217023
+ nodeDef: params.nodeDef,
217024
+ fieldKind: "arg",
217025
+ fieldName: arg.name,
217026
+ arg,
217027
+ treePath: params.treePath,
217028
+ env: params.env
217029
+ };
217030
+ params.onArg?.({
217031
+ fieldName: arg.name,
217032
+ checkerName,
217033
+ visibleName,
217034
+ value: params.node.args?.[arg.name],
217035
+ ctx
217036
+ });
217037
+ }
217038
+ for (const [fieldKind, slotDefs, values, visitor] of [
217039
+ ["input", params.nodeDef.input, params.node.input, params.onInput],
217040
+ ["output", params.nodeDef.output, params.node.output, params.onOutput]
217041
+ ]) {
217042
+ for (let index = 0; index < (slotDefs?.length ?? 0); index += 1) {
217043
+ const slot = slotDefs?.[index] ?? "";
217044
+ const slotField = buildNodeSlotField(slot, slotDefs, index);
217045
+ if (!(slotField.checker || slotField.visible)) {
217046
+ continue;
217047
+ }
217048
+ const ctx = getNodeSlotContext({
217049
+ fieldKind,
217050
+ node: params.node,
217051
+ tree: params.tree,
217052
+ nodeDef: params.nodeDef,
217053
+ slotDefs,
217054
+ slot,
217055
+ index,
217056
+ treePath: params.treePath,
217057
+ env: params.env
217058
+ });
217059
+ if (!ctx) {
217060
+ continue;
217061
+ }
217062
+ visitor?.({
217063
+ fieldName: slotField.name,
217064
+ fieldIndex: index,
217065
+ checkerName: slotField.checker,
217066
+ visibleName: slotField.visible,
217067
+ value: getSlotValue(values, slotDefs, index),
217068
+ ctx
217069
+ });
217070
+ }
217071
+ }
217072
+ };
217073
+ var collectNodeFieldCheckDiagnostics = (params) => {
216849
217074
  const diagnostics = [];
216850
217075
  const targets = params.targets ?? [];
216851
217076
  const entries = targets.length ? targets : (() => {
@@ -216859,47 +217084,182 @@ var collectNodeArgCheckDiagnostics = (params) => {
216859
217084
  if (!nodeDef) {
216860
217085
  continue;
216861
217086
  }
216862
- for (const arg of nodeDef.args ?? []) {
216863
- const checkerName = arg.checker?.trim();
216864
- if (!checkerName) {
216865
- continue;
217087
+ visitCustomNodeFields({
217088
+ node,
217089
+ tree: params.tree,
217090
+ nodeDef,
217091
+ treePath: target.treePath ?? params.treePath,
217092
+ env: params.env,
217093
+ onArg: ({ fieldName, checkerName, value, ctx }) => {
217094
+ if (!checkerName) {
217095
+ return;
217096
+ }
217097
+ const pushDiagnostic = (message) => {
217098
+ diagnostics.push({
217099
+ instanceKey: target.instanceKey,
217100
+ nodeId: node.id,
217101
+ nodeName: node.name,
217102
+ fieldKind: "arg",
217103
+ fieldName,
217104
+ checker: checkerName,
217105
+ message
217106
+ });
217107
+ };
217108
+ const checker = params.checkers.get(checkerName);
217109
+ if (!checker) {
217110
+ pushDiagnostic(`checker '${checkerName}' is not registered`);
217111
+ return;
217112
+ }
217113
+ try {
217114
+ const messages = normalizeNodeFieldCheckResult(checker.validate(value, ctx));
217115
+ messages.forEach(pushDiagnostic);
217116
+ } catch (error) {
217117
+ pushDiagnostic(`checker '${checkerName}' failed: ${formatRuntimeError(error)}`);
217118
+ }
217119
+ },
217120
+ onInput: ({ fieldName, fieldIndex, checkerName, value, ctx }) => {
217121
+ if (!checkerName) {
217122
+ return;
217123
+ }
217124
+ const pushDiagnostic = (message) => {
217125
+ diagnostics.push({
217126
+ instanceKey: target.instanceKey,
217127
+ nodeId: node.id,
217128
+ nodeName: node.name,
217129
+ fieldKind: "input",
217130
+ fieldName,
217131
+ fieldIndex,
217132
+ checker: checkerName,
217133
+ message
217134
+ });
217135
+ };
217136
+ const checker = params.checkers.get(checkerName);
217137
+ if (!checker) {
217138
+ pushDiagnostic(`checker '${checkerName}' is not registered`);
217139
+ return;
217140
+ }
217141
+ try {
217142
+ const messages = normalizeNodeFieldCheckResult(checker.validate(value, ctx));
217143
+ messages.forEach(pushDiagnostic);
217144
+ } catch (error) {
217145
+ pushDiagnostic(`checker '${checkerName}' failed: ${formatRuntimeError(error)}`);
217146
+ }
217147
+ },
217148
+ onOutput: ({ fieldName, fieldIndex, checkerName, value, ctx }) => {
217149
+ if (!checkerName) {
217150
+ return;
217151
+ }
217152
+ const pushDiagnostic = (message) => {
217153
+ diagnostics.push({
217154
+ instanceKey: target.instanceKey,
217155
+ nodeId: node.id,
217156
+ nodeName: node.name,
217157
+ fieldKind: "output",
217158
+ fieldName,
217159
+ fieldIndex,
217160
+ checker: checkerName,
217161
+ message
217162
+ });
217163
+ };
217164
+ const checker = params.checkers.get(checkerName);
217165
+ if (!checker) {
217166
+ pushDiagnostic(`checker '${checkerName}' is not registered`);
217167
+ return;
217168
+ }
217169
+ try {
217170
+ const messages = normalizeNodeFieldCheckResult(checker.validate(value, ctx));
217171
+ messages.forEach(pushDiagnostic);
217172
+ } catch (error) {
217173
+ pushDiagnostic(`checker '${checkerName}' failed: ${formatRuntimeError(error)}`);
217174
+ }
216866
217175
  }
216867
- const pushDiagnostic = (message) => {
216868
- diagnostics.push({
216869
- instanceKey: target.instanceKey,
216870
- nodeId: node.id,
216871
- nodeName: node.name,
216872
- argName: arg.name,
216873
- checker: checkerName,
216874
- message
216875
- });
216876
- };
216877
- const checker = params.checkers.get(checkerName);
216878
- if (!checker) {
216879
- pushDiagnostic(`checker '${checkerName}' is not registered`);
216880
- continue;
217176
+ });
217177
+ }
217178
+ return diagnostics;
217179
+ };
217180
+ var resolveNodeFieldVisibility = (params) => {
217181
+ const visibility = createEmptyNodeFieldVisibilityState();
217182
+ const node = params.target;
217183
+ const nodeDef = params.env.nodeDefs.get(node.name);
217184
+ if (!nodeDef) {
217185
+ return visibility;
217186
+ }
217187
+ visitCustomNodeFields({
217188
+ node,
217189
+ tree: params.tree,
217190
+ nodeDef,
217191
+ treePath: params.targetTreePath ?? params.treePath,
217192
+ env: params.env,
217193
+ onArg: ({ fieldName, visibleName, value, ctx }) => {
217194
+ if (!visibleName) {
217195
+ return;
217196
+ }
217197
+ const visible = params.visibles.get(visibleName);
217198
+ if (!visible) {
217199
+ params.env.logger.warn(
217200
+ `visible '${visibleName}' is not registered for ${formatFieldLocator(node, "arg", fieldName)}`
217201
+ );
217202
+ return;
216881
217203
  }
216882
217204
  try {
216883
- const messages = normalizeNodeArgCheckResult(
216884
- checker.validate(node.args?.[arg.name], {
216885
- node,
216886
- tree: params.tree,
216887
- nodeDef,
216888
- arg,
216889
- argName: arg.name,
216890
- treePath: target.treePath ?? params.treePath,
216891
- env: params.env
216892
- })
217205
+ visibility.args[fieldName] = normalizeNodeFieldVisibleResult(
217206
+ visible.visible(value, ctx)
217207
+ );
217208
+ } catch (error) {
217209
+ params.env.logger.warn(
217210
+ `visible '${visibleName}' failed for ${formatFieldLocator(node, "arg", fieldName)}: ${formatRuntimeError(error)}`
217211
+ );
217212
+ visibility.args[fieldName] = true;
217213
+ }
217214
+ },
217215
+ onInput: ({ fieldName, fieldIndex, visibleName, value, ctx }) => {
217216
+ if (!visibleName) {
217217
+ return;
217218
+ }
217219
+ const visible = params.visibles.get(visibleName);
217220
+ if (!visible) {
217221
+ params.env.logger.warn(
217222
+ `visible '${visibleName}' is not registered for ${formatFieldLocator(node, "input", fieldName, fieldIndex)}`
217223
+ );
217224
+ return;
217225
+ }
217226
+ try {
217227
+ visibility.input[fieldIndex] = normalizeNodeFieldVisibleResult(
217228
+ visible.visible(value, ctx)
216893
217229
  );
216894
- messages.forEach(pushDiagnostic);
216895
217230
  } catch (error) {
216896
- pushDiagnostic(`checker '${checkerName}' failed: ${formatRuntimeError(error)}`);
217231
+ params.env.logger.warn(
217232
+ `visible '${visibleName}' failed for ${formatFieldLocator(node, "input", fieldName, fieldIndex)}: ${formatRuntimeError(error)}`
217233
+ );
217234
+ visibility.input[fieldIndex] = true;
217235
+ }
217236
+ },
217237
+ onOutput: ({ fieldName, fieldIndex, visibleName, value, ctx }) => {
217238
+ if (!visibleName) {
217239
+ return;
217240
+ }
217241
+ const visible = params.visibles.get(visibleName);
217242
+ if (!visible) {
217243
+ params.env.logger.warn(
217244
+ `visible '${visibleName}' is not registered for ${formatFieldLocator(node, "output", fieldName, fieldIndex)}`
217245
+ );
217246
+ return;
217247
+ }
217248
+ try {
217249
+ visibility.output[fieldIndex] = normalizeNodeFieldVisibleResult(
217250
+ visible.visible(value, ctx)
217251
+ );
217252
+ } catch (error) {
217253
+ params.env.logger.warn(
217254
+ `visible '${visibleName}' failed for ${formatFieldLocator(node, "output", fieldName, fieldIndex)}: ${formatRuntimeError(error)}`
217255
+ );
217256
+ visibility.output[fieldIndex] = true;
216897
217257
  }
216898
217258
  }
216899
- }
216900
- return diagnostics;
217259
+ });
217260
+ return visibility;
216901
217261
  };
216902
- var formatNodeArgCheckBuildDiagnostic = (diagnostic) => `check ${diagnostic.nodeId}|${diagnostic.nodeName}: ${diagnostic.argName}: ${diagnostic.message}`;
217262
+ 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}`;
216903
217263
  var syncFilesFromDiskWithContext = (files, parsedVarDecl, workdir) => {
216904
217264
  if (!hasFs()) {
216905
217265
  return;
@@ -217066,7 +217426,8 @@ var applyBehavior3DecoratorGlobal = () => {
217066
217426
  ...decoratorGlobalState.previousBehavior3 && typeof decoratorGlobalState.previousBehavior3 === "object" ? decoratorGlobalState.previousBehavior3 : {},
217067
217427
  build: markBuildHook,
217068
217428
  batch: markBatchHook,
217069
- check: markCheckHook
217429
+ check: markCheckHook,
217430
+ visible: markVisibleHook
217070
217431
  };
217071
217432
  };
217072
217433
  var restoreBehavior3DecoratorGlobal = () => {
@@ -217376,16 +217737,16 @@ var buildProjectWithContext = async (project, buildDir, context) => {
217376
217737
  if (!context.checkNodeData(tree.root, (message) => errors.push(message))) {
217377
217738
  hasError = true;
217378
217739
  }
217379
- const checkDiagnostics = collectNodeArgCheckDiagnostics({
217740
+ const checkDiagnostics = collectNodeFieldCheckDiagnostics({
217380
217741
  tree,
217381
217742
  treePath: candidatePath,
217382
217743
  env: scriptEnv,
217383
- checkers: buildRuntime.nodeArgCheckers
217744
+ checkers: buildRuntime.nodeFieldCheckers
217384
217745
  });
217385
217746
  if (checkDiagnostics.length) {
217386
217747
  hasError = true;
217387
217748
  checkDiagnostics.forEach(
217388
- (diagnostic) => errors.push(formatNodeArgCheckBuildDiagnostic(diagnostic))
217749
+ (diagnostic) => errors.push(formatNodeFieldCheckBuildDiagnostic(diagnostic))
217389
217750
  );
217390
217751
  }
217391
217752
  if (errors.length) {
@@ -217918,6 +218279,7 @@ var checkNodeDataWithState = (data, printer, state) => {
217918
218279
  let hasVaridicInput = false;
217919
218280
  if (conf.input) {
217920
218281
  for (let i = 0; i < conf.input.length; i++) {
218282
+ const slotDefinition = parseSlotDefinition(conf.input[i] ?? "", conf.input, i);
217921
218283
  if (!data.input) {
217922
218284
  data.input = [];
217923
218285
  }
@@ -217925,7 +218287,7 @@ var checkNodeDataWithState = (data, printer, state) => {
217925
218287
  data.input[i] = "";
217926
218288
  }
217927
218289
  if (!isValidInputOrOutput(conf.input, data.input, i)) {
217928
- error(`intput field '${conf.input[i]}' is required`);
218290
+ error(`intput field '${slotDefinition.label}' is required`);
217929
218291
  hasError = true;
217930
218292
  }
217931
218293
  if (i === conf.input.length - 1 && isVariadic(conf.input, -1)) {
@@ -217939,6 +218301,7 @@ var checkNodeDataWithState = (data, printer, state) => {
217939
218301
  let hasVaridicOutput = false;
217940
218302
  if (conf.output) {
217941
218303
  for (let i = 0; i < conf.output.length; i++) {
218304
+ const slotDefinition = parseSlotDefinition(conf.output[i] ?? "", conf.output, i);
217942
218305
  if (!data.output) {
217943
218306
  data.output = [];
217944
218307
  }
@@ -217946,7 +218309,7 @@ var checkNodeDataWithState = (data, printer, state) => {
217946
218309
  data.output[i] = "";
217947
218310
  }
217948
218311
  if (!isValidInputOrOutput(conf.output, data.output, i)) {
217949
- error(`output field '${conf.output[i]}' is required`);
218312
+ error(`output field '${slotDefinition.label}' is required`);
217950
218313
  hasError = true;
217951
218314
  }
217952
218315
  if (i === conf.output.length - 1 && isVariadic(conf.output, -1)) {
@@ -220586,6 +220949,37 @@ var computeNodeOverride = (original, edited, def) => {
220586
220949
  }
220587
220950
  return hasDiff ? diff : null;
220588
220951
  };
220952
+ var pruneNodeArgsByDefinition = (args, nodeDef) => {
220953
+ if (!args || !nodeDef) {
220954
+ return args;
220955
+ }
220956
+ const argDefs = nodeDef.args ?? [];
220957
+ if (argDefs.length === 0) {
220958
+ return void 0;
220959
+ }
220960
+ const declaredNames = new Set(argDefs.map((arg) => arg.name));
220961
+ const nextEntries = Object.entries(args).filter(([argName]) => declaredNames.has(argName));
220962
+ if (nextEntries.length === Object.keys(args).length) {
220963
+ return args;
220964
+ }
220965
+ return nextEntries.length > 0 ? Object.fromEntries(nextEntries) : void 0;
220966
+ };
220967
+ var pruneNodeSlotsByDefinition = (slots, slotDefs) => {
220968
+ if (!slots) {
220969
+ return slots;
220970
+ }
220971
+ if (!slotDefs?.length) {
220972
+ return void 0;
220973
+ }
220974
+ const lastIndex = slotDefs.length - 1;
220975
+ const keepVariadicTail = parseSlotDefinition(
220976
+ slotDefs[lastIndex] ?? "",
220977
+ slotDefs,
220978
+ lastIndex
220979
+ ).variadic;
220980
+ const nextSlots = keepVariadicTail ? slots.slice(0) : slots.slice(0, slotDefs.length);
220981
+ return isJsonEqual(nextSlots, slots) ? slots : nextSlots;
220982
+ };
220589
220983
  var matchesSelectedNodeTarget = (selectedNode, payload) => {
220590
220984
  return selectedNode.ref.structuralStableId === payload.target.structuralStableId && selectedNode.ref.sourceStableId === payload.target.sourceStableId && selectedNode.ref.sourceTreePath === payload.target.sourceTreePath;
220591
220985
  };
@@ -220679,9 +221073,9 @@ var reduceUpdateNode = (mutation, context) => {
220679
221073
  }
220680
221074
  const nextDebug = payload.data.debug ? true : void 0;
220681
221075
  const nextDisabled = payload.data.disabled ? true : void 0;
220682
- const nextInput = payload.data.input;
220683
- const nextOutput = payload.data.output;
220684
- const nextArgs = payload.data.args;
221076
+ const nextInput = pruneNodeSlotsByDefinition(payload.data.input, nextNodeDef?.input);
221077
+ const nextOutput = pruneNodeSlotsByDefinition(payload.data.output, nextNodeDef?.output);
221078
+ const nextArgs = pruneNodeArgsByDefinition(payload.data.args, nextNodeDef);
220685
221079
  if (nextName === selectedNode.data.name && nextDesc === selectedNode.data.desc && nextPath === selectedNode.data.path && nextDebug === selectedNode.data.debug && nextDisabled === selectedNode.data.disabled && isJsonEqual(nextInput ?? [], selectedNode.data.input ?? []) && isJsonEqual(nextOutput ?? [], selectedNode.data.output ?? []) && isJsonEqual(nextArgs ?? {}, selectedNode.data.args ?? {})) {
220686
221080
  return { status: "noop" };
220687
221081
  }
@@ -221311,7 +221705,8 @@ function createSessionDispatcher({
221311
221705
  handleSaveDocumentMessage,
221312
221706
  handleRevertDocumentMessage,
221313
221707
  refreshSettings,
221314
- handleValidateNodeChecksMessage,
221708
+ handleValidateNodeFieldsMessage,
221709
+ handleResolveNodeFieldVisibilityMessage,
221315
221710
  fileRequestHandlers
221316
221711
  }) {
221317
221712
  const dispatchEditorMessage = async (msg, reply = postMessage, source = "editor") => {
@@ -221359,8 +221754,11 @@ function createSessionDispatcher({
221359
221754
  case "runInspectorCommand":
221360
221755
  void vscode14.commands.executeCommand(msg.command).then(void 0, logAsyncRuntimeError(`command:${msg.command}`));
221361
221756
  return;
221362
- case "validateNodeChecks":
221363
- await handleValidateNodeChecksMessage(msg, reply);
221757
+ case "validateNodeFields":
221758
+ await handleValidateNodeFieldsMessage(msg, reply);
221759
+ return;
221760
+ case "resolveNodeFieldVisibility":
221761
+ await handleResolveNodeFieldVisibilityMessage(msg, reply);
221364
221762
  return;
221365
221763
  case "webviewLog":
221366
221764
  writeWebviewLogMessage(msg);
@@ -221572,6 +221970,7 @@ async function createSessionNodeCheckRuntime({
221572
221970
  null,
221573
221971
  createSessionBuildScriptEnv(workspaceFolderUri.fsPath, nodeDefs)
221574
221972
  ),
221973
+ nodeFieldVisibleHandlers: /* @__PURE__ */ new Map(),
221575
221974
  treePath: workspaceFolderUri.fsPath
221576
221975
  };
221577
221976
  }
@@ -221608,11 +222007,17 @@ async function createSessionNodeCheckRuntime({
221608
222007
  checkScriptModules,
221609
222008
  env2
221610
222009
  );
222010
+ const visibleRuntime = createNodeFieldVisibleRuntimeWithCheckModules(
222011
+ buildScriptModule,
222012
+ checkScriptModules,
222013
+ env2
222014
+ );
221611
222015
  return {
221612
222016
  buildScriptRuntime: {
221613
222017
  ...buildScriptRuntime,
221614
222018
  hasError: buildScriptRuntime.hasError || hasRuntimeLoadError
221615
222019
  },
222020
+ nodeFieldVisibleHandlers: visibleRuntime.nodeFieldVisibles,
221616
222021
  treePath: workdir
221617
222022
  };
221618
222023
  }
@@ -221629,15 +222034,15 @@ function createSessionNodeChecks(context) {
221629
222034
  readWorkspaceFileContent
221630
222035
  });
221631
222036
  };
221632
- const handleValidateNodeChecksMessage = async (msg, reply = postMessage) => {
222037
+ const handleValidateNodeFieldsMessage = async (msg, reply = postMessage) => {
221633
222038
  try {
221634
222039
  const runtimeResult = await createNodeCheckRuntime();
221635
222040
  const tree = JSON.parse(msg.content);
221636
- const diagnostics = collectNodeArgCheckDiagnostics({
222041
+ const diagnostics = collectNodeFieldCheckDiagnostics({
221637
222042
  tree,
221638
222043
  treePath: msg.treePath || runtimeResult.treePath,
221639
222044
  env: createSessionBuildScriptEnv(runtimeResult.treePath, state.nodeDefs),
221640
- checkers: runtimeResult.buildScriptRuntime.nodeArgCheckers,
222045
+ checkers: runtimeResult.buildScriptRuntime.nodeFieldCheckers,
221641
222046
  targets: msg.nodes.map((entry) => ({
221642
222047
  instanceKey: entry.instanceKey,
221643
222048
  treePath: entry.treePath,
@@ -221645,13 +222050,15 @@ function createSessionNodeChecks(context) {
221645
222050
  }))
221646
222051
  });
221647
222052
  await reply({
221648
- type: "validateNodeChecksResult",
222053
+ type: "validateNodeFieldsResult",
221649
222054
  requestId: msg.requestId,
221650
222055
  diagnostics: diagnostics.filter(
221651
222056
  (diagnostic) => typeof diagnostic.instanceKey === "string"
221652
222057
  ).map((diagnostic) => ({
221653
222058
  instanceKey: diagnostic.instanceKey,
221654
- argName: diagnostic.argName,
222059
+ fieldKind: diagnostic.fieldKind,
222060
+ fieldName: diagnostic.fieldName,
222061
+ fieldIndex: diagnostic.fieldIndex,
221655
222062
  checker: diagnostic.checker,
221656
222063
  message: diagnostic.message
221657
222064
  })),
@@ -221662,15 +222069,42 @@ function createSessionNodeChecks(context) {
221662
222069
  });
221663
222070
  } catch (error) {
221664
222071
  await reply({
221665
- type: "validateNodeChecksResult",
222072
+ type: "validateNodeFieldsResult",
221666
222073
  requestId: msg.requestId,
221667
222074
  diagnostics: [],
221668
222075
  error: String(error)
221669
222076
  });
221670
222077
  }
221671
222078
  };
222079
+ const handleResolveNodeFieldVisibilityMessage = async (msg, reply = postMessage) => {
222080
+ try {
222081
+ const runtimeResult = await createNodeCheckRuntime();
222082
+ const tree = JSON.parse(msg.content);
222083
+ const visibility = resolveNodeFieldVisibility({
222084
+ tree,
222085
+ treePath: msg.treePath || runtimeResult.treePath,
222086
+ env: createSessionBuildScriptEnv(runtimeResult.treePath, state.nodeDefs),
222087
+ visibles: runtimeResult.nodeFieldVisibleHandlers,
222088
+ target: toNodeData(msg.target.node),
222089
+ targetTreePath: msg.target.treePath
222090
+ });
222091
+ await reply({
222092
+ type: "resolveNodeFieldVisibilityResult",
222093
+ requestId: msg.requestId,
222094
+ visibility
222095
+ });
222096
+ } catch (error) {
222097
+ await reply({
222098
+ type: "resolveNodeFieldVisibilityResult",
222099
+ requestId: msg.requestId,
222100
+ visibility: { args: {}, input: {}, output: {} },
222101
+ error: String(error)
222102
+ });
222103
+ }
222104
+ };
221672
222105
  return {
221673
- handleValidateNodeChecksMessage
222106
+ handleValidateNodeFieldsMessage,
222107
+ handleResolveNodeFieldVisibilityMessage
221674
222108
  };
221675
222109
  }
221676
222110
 
@@ -222002,10 +222436,7 @@ async function resolveTreeEditorSession(params) {
222002
222436
  const inspectorSync = createSessionInspectorSync(context);
222003
222437
  const subtreeTracking = createSessionSubtreeTracking(context, inspectorSync);
222004
222438
  const fileVersionGuard = createFileVersionGuard(context);
222005
- const {
222006
- getActiveNewerFileEditMessage,
222007
- getExistingNewerFileEditMessage
222008
- } = fileVersionGuard;
222439
+ const { getActiveNewerFileEditMessage, getExistingNewerFileEditMessage } = fileVersionGuard;
222009
222440
  const { refreshSettings } = createSessionSettingsSync(context, inspectorSync);
222010
222441
  const selectionSync = createSessionSelectionSync(context, inspectorSync);
222011
222442
  const { handleSelectTreeMessage, handleSelectNodeMessage } = selectionSync;
@@ -222021,7 +222452,7 @@ async function resolveTreeEditorSession(params) {
222021
222452
  handleRevertDocumentMessage,
222022
222453
  handleMainDocumentFileChange
222023
222454
  } = createSessionDocumentLifecycle(context, inspectorSync, subtreeTracking, fileVersionGuard);
222024
- const { handleValidateNodeChecksMessage } = createSessionNodeChecks(context);
222455
+ const { handleValidateNodeFieldsMessage, handleResolveNodeFieldVisibilityMessage } = createSessionNodeChecks(context);
222025
222456
  const fileRequestHandlers = createSessionFileRequestHandlers({
222026
222457
  projectRootUri,
222027
222458
  viewType,
@@ -222048,7 +222479,8 @@ async function resolveTreeEditorSession(params) {
222048
222479
  handleSaveDocumentMessage,
222049
222480
  handleRevertDocumentMessage,
222050
222481
  refreshSettings,
222051
- handleValidateNodeChecksMessage,
222482
+ handleValidateNodeFieldsMessage,
222483
+ handleResolveNodeFieldVisibilityMessage,
222052
222484
  fileRequestHandlers
222053
222485
  });
222054
222486
  const activeWebviewEntry = {
@@ -223012,14 +223444,22 @@ var InspectorSidebarCoordinator = class {
223012
223444
  error
223013
223445
  });
223014
223446
  return;
223015
- case "validateNodeChecks":
223447
+ case "validateNodeFields":
223016
223448
  await reply({
223017
- type: "validateNodeChecksResult",
223449
+ type: "validateNodeFieldsResult",
223018
223450
  requestId: message.requestId,
223019
223451
  diagnostics: [],
223020
223452
  error
223021
223453
  });
223022
223454
  return;
223455
+ case "resolveNodeFieldVisibility":
223456
+ await reply({
223457
+ type: "resolveNodeFieldVisibilityResult",
223458
+ requestId: message.requestId,
223459
+ visibility: { args: {}, input: {}, output: {} },
223460
+ error
223461
+ });
223462
+ return;
223023
223463
  case "ready":
223024
223464
  case "undo":
223025
223465
  case "redo":
@@ -223166,19 +223606,19 @@ function createCheckerScriptContent(baseName) {
223166
223606
  const className = ensureSuffix(toPascalIdentifier(baseName), "Checker");
223167
223607
  const checkerName = toCheckerRegistrationName(baseName);
223168
223608
  return [
223169
- 'import type { NodeArgCheckContext } from "vscode-behavior3/build";',
223609
+ 'import type { NodeFieldCheckContext } from "vscode-behavior3/build";',
223170
223610
  "",
223171
223611
  `@behavior3.check("${checkerName}")`,
223172
223612
  `export class ${className} {`,
223173
- " validate(value: unknown, ctx: NodeArgCheckContext) {",
223613
+ " validate(value: unknown, ctx: NodeFieldCheckContext) {",
223174
223614
  ' if (value === undefined || value === null || value === "") {',
223175
223615
  " return;",
223176
223616
  " }",
223177
223617
  ' if (typeof value !== "number") {',
223178
- " return `${ctx.argName} must be a number`;",
223618
+ " return `${ctx.fieldName} must be a number`;",
223179
223619
  " }",
223180
223620
  " if (value <= 0) {",
223181
- " return `${ctx.argName} must be greater than 0`;",
223621
+ " return `${ctx.fieldName} must be greater than 0`;",
223182
223622
  " }",
223183
223623
  " }",
223184
223624
  "}",