vscode-behavior3 2.5.0 → 2.6.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
@@ -215705,6 +215705,7 @@ var normalizeWorkspaceModel = (value) => {
215705
215705
  }
215706
215706
  return {
215707
215707
  settings: {
215708
+ allowNewFunction: typeof settingsRecord.allowNewFunction === "boolean" ? settingsRecord.allowNewFunction : void 0,
215708
215709
  checkExpr: typeof settingsRecord.checkExpr === "boolean" ? settingsRecord.checkExpr : void 0,
215709
215710
  buildScript: asOptionalString(settingsRecord.buildScript),
215710
215711
  checkScripts: settingsRecord.checkScripts === void 0 ? void 0 : Array.isArray(settingsRecord.checkScripts) ? settingsRecord.checkScripts.map(
@@ -216248,82 +216249,549 @@ var checkOneof = (arg, argValue, inputValue) => {
216248
216249
  return normalizedArgValue !== "" && normalizedInputValue === "" || normalizedArgValue === "" && normalizedInputValue !== "";
216249
216250
  };
216250
216251
 
216251
- // webview/shared/tree-materializer.ts
216252
- var applyPatchIfAny = (node, patch) => {
216253
- if (!patch) {
216254
- return;
216255
- }
216256
- if (patch.desc !== void 0) {
216257
- node.desc = patch.desc;
216258
- }
216259
- if (patch.input !== void 0) {
216260
- node.input = patch.input;
216261
- }
216262
- if (patch.output !== void 0) {
216263
- node.output = patch.output;
216264
- }
216265
- if (patch.args !== void 0) {
216266
- node.args = { ...node.args ?? {}, ...patch.args };
216267
- }
216268
- if (patch.debug !== void 0) {
216269
- node.debug = patch.debug;
216270
- }
216271
- if (patch.disabled !== void 0) {
216272
- node.disabled = patch.disabled;
216273
- }
216274
- };
216275
- var applyArgDefaults = (node, def) => {
216276
- if (!def?.args?.length) {
216277
- return;
216278
- }
216279
- node.args ||= {};
216280
- for (const arg of def.args) {
216281
- if (node.args[arg.name] === void 0 && arg.default !== void 0) {
216282
- node.args[arg.name] = arg.default;
216283
- }
216284
- }
216285
- };
216286
- var buildResolvedExternalNode = (sourceNode, overrideChain, rootOverride) => {
216287
- const value = clonePersistedNode(sourceNode);
216288
- for (const tree of [...overrideChain].reverse()) {
216289
- applyPatchIfAny(value, tree.overrides[sourceNode.uuid]);
216290
- }
216291
- const subtreeOriginal = clonePersistedNode(value);
216292
- applyPatchIfAny(value, rootOverride[sourceNode.uuid]);
216293
- return { value, subtreeOriginal };
216294
- };
216295
- var isInvalidSubtreeSource = (value) => {
216296
- return Boolean(value && typeof value === "object" && "error" in value);
216252
+ // media/locales/en.json
216253
+ var en_default = {
216254
+ about: "About Behavior3",
216255
+ actuaSize: "Actual Size",
216256
+ actualSize: "Actual Size",
216257
+ add: "Add",
216258
+ alertNewVersion: "This file is created by a newer version of Behavior3({{version}}), please upgrade to the latest version.",
216259
+ batch: "Batch Script",
216260
+ batchCompleted: "Batch completed",
216261
+ batchFailed: "Batch failed, more information can be found in the console.",
216262
+ build: "Build",
216263
+ buildCompleted: "Build completed",
216264
+ buildFailed: "Build failed, more information can be found in the console.",
216265
+ cancel: "Cancel",
216266
+ compact: "Compact",
216267
+ console: "Console",
216268
+ copy: "Copy",
216269
+ createProject: "Create Project",
216270
+ checkExpr: "Check expression",
216271
+ cut: "Cut",
216272
+ delete: "Delete",
216273
+ deleteNode: "Delete Node",
216274
+ devTools: "Toggle Developer Tools",
216275
+ donotSave: "Don't Save",
216276
+ duplicate: "Duplicate",
216277
+ editSubtree: "Edit Subtree",
216278
+ fieldRequired: "Field '{{field}}' is required",
216279
+ forceReload: "Force Reload",
216280
+ fullscreen: "Toggle Full Screen",
216281
+ hide: "Hide Behavior3",
216282
+ hideOthers: "Hide Others",
216283
+ insertNode: "Insert Node",
216284
+ jumpNode: "Jump Node",
216285
+ language: "Language",
216286
+ moveToTrash: "Move to Trash",
216287
+ newFile: "New File...",
216288
+ newFolder: "New Folder...",
216289
+ newWindow: "New Window",
216290
+ nodeDefinition: "NODES",
216291
+ normal: "Normal",
216292
+ open: "Open...",
216293
+ openProject: "Open Project",
216294
+ paste: "Paste",
216295
+ quit: "Quit Behavior3",
216296
+ recent: "Recent",
216297
+ redo: "Redo",
216298
+ reload: "Reload",
216299
+ reset: "Reset",
216300
+ "reset.confirm": "Reset to original value?",
216301
+ "reset.defaultConfirm": "Reset to default value?",
216302
+ rename: "Rename...",
216303
+ replace: "Replace",
216304
+ reportIssue: "Report Issue",
216305
+ revealFileOnMac: "Reveal in Finder",
216306
+ revealFileOnWindows: "Reveal in File Explorer",
216307
+ save: "Save",
216308
+ saveAll: "Save All",
216309
+ saveAs: "Save As...",
216310
+ saveAsSubtree: "Save As Subtree",
216311
+ searchFile: "Search File",
216312
+ searchNode: "Search Node",
216313
+ selectAll: "Select All",
216314
+ services: "Services",
216315
+ setupBuildScript: "Setup Build Script",
216316
+ start: "Start",
216317
+ undo: "Undo",
216318
+ unhide: "Show All",
216319
+ zoomIn: "Zoom In",
216320
+ zoomOut: "Zoom Out",
216321
+ "menu.edit": "Edit",
216322
+ "menu.file": "File",
216323
+ "menu.view": "View",
216324
+ "menu.window": "Window",
216325
+ "menu.help": "Help",
216326
+ "workspace.saveAllOnClose": "Do you want to save the changes to the following {{count}} files?",
216327
+ "workspace.saveOnClose": "Do you want to save the changes you made to '{{name}}'?",
216328
+ "workspace.reloadFile": "'{{name}}' has changed, do you want to reload now?",
216329
+ "explorer.deleteFile": "Are you sure you want delete '{{name}}'?",
216330
+ "explorer.deleteFolder": "Are you sure you want delete '{{name}}' and its contents?",
216331
+ "explorer.replaceFile": "Are you sure you want replace '{{name}}'?",
216332
+ "explorer.restoreFileInfo": "You can restore this file from the Trash.",
216333
+ "explorer.title": "Explorer",
216334
+ "tree.overview": "Overview",
216335
+ "tree.name": "Tree name",
216336
+ "tree.desc": "Tree desc",
216337
+ "tree.export": "Export",
216338
+ "tree.prefix": "ID prefix",
216339
+ "tree.group": "Enable Node Grouping",
216340
+ "tree.group.placeholder": "Select node groups",
216341
+ "tree.vars": "Define Variables",
216342
+ "tree.vars.local": "Local Variables",
216343
+ "tree.vars.add": "Add Variable",
216344
+ "tree.vars.name": "name",
216345
+ "tree.vars.invalidName": "Invalid variable name",
216346
+ "tree.vars.desc": "description",
216347
+ "tree.vars.imports": "Import Variables",
216348
+ "tree.vars.subtree": "Subtree Variables",
216349
+ "tree.import.add": "Add Import",
216350
+ "tree.custom": "Custom Data",
216351
+ "tree.custom.add": "Add Entry",
216352
+ "tree.custom.key": "key",
216353
+ "tree.custom.value": "value",
216354
+ "tree.custom.type.string": "String value",
216355
+ "tree.custom.type.number": "Number value",
216356
+ "tree.custom.type.boolean": "Boolean value",
216357
+ "tree.custom.type.invalid": "Invalid custom value",
216358
+ "regnode.input": "Input: ",
216359
+ "regnode.output": "Output: ",
216360
+ "regnode.args": "Args: ",
216361
+ "regnode.mark": "Mark: ",
216362
+ "regnode.subtree": "Subtree: ",
216363
+ "node.args": "Const arguments",
216364
+ "node.children.unlimited": "Unlimited",
216365
+ "node.children": "Num children",
216366
+ "node.debug": "Debug",
216367
+ "node.deleteRootNodeDenied": "Unable to delete the root node",
216368
+ "node.dropDenied": "This node position is denied to drop the node",
216369
+ "node.desc": "Node desc",
216370
+ "node.disabled": "Disabled",
216371
+ "node.editSubtreeDenied": "Unable to edit the subtree node",
216372
+ "node.editFailed": "Node '{{name}}' edit failed",
216373
+ "node.group": "Node group",
216374
+ "node.groupNotEnabled": "One of '{{group}}' node group is not enabled in current file",
216375
+ "node.id": "Node id",
216376
+ "node.inputVariable": "Input variables",
216377
+ "node.invalidChildren": "Invalid number of children",
216378
+ "node.invalidExpression": "Invalid expression",
216379
+ "node.invalidValue": "Invalid value",
216380
+ "node.invalidVariableName": "Invalid variable name, should start with a letter or underscore",
216381
+ "node.name": "Node name",
216382
+ "node.noNodeSelected": "No node selected",
216383
+ "node.notFound": "Node '{{name}}' not found",
216384
+ "node.oneof.error": "Only one is allowed between input '{{input}}' and argument '{{desc}}({{arg}})'",
216385
+ "node.oneof.inputNotfound": "Input '{{input}}' not found",
216386
+ "node.outputVariable": "Output variables",
216387
+ "node.pasteDataError": "Paste data error",
216388
+ "node.rootNodeAsSubtree": "Root node cann't be save as subtree",
216389
+ "node.subtree": "Subtree",
216390
+ "node.subtreeMissing": "Subtree file is missing: {{path}}",
216391
+ "node.subtreeInvalid": "Subtree file is invalid: {{path}}",
216392
+ "node.subtreeCyclic": "Subtree reference is cyclic: {{path}}",
216393
+ "node.subtreeOpenFailed": "Failed to open subtree: file not found or unreadable ({{path}})",
216394
+ "node.subtreePathError": "You should save the subtree inside the current workspace",
216395
+ "node.subtreeSaveRootError": "Root node cann't be save as subtree",
216396
+ "node.subtreeSaveSuccess": "Saved and converted to subtree node: {{path}}",
216397
+ "node.moveSubtreeDenied": "Cannot move nodes inside a subtree",
216398
+ "node.dropSubtreeInternalDenied": "Cannot drop onto a subtree internal node",
216399
+ "node.moveRootDenied": "Cannot move the root node",
216400
+ "node.dropAroundRootDenied": "Cannot place a node before or after the root",
216401
+ "node.addChildToSubtreeRefDenied": "Cannot add child nodes to a subtree reference",
216402
+ "node.moveIntoDescendantDenied": "Cannot move a node into its own descendant",
216403
+ "node.type": "Node type",
216404
+ "node.undefinedVariable": "Variable '{{variable}}' is not defined",
216405
+ "node.jsonData": "JSON Data",
216406
+ "node.unknown.title": "Unknown Node",
216407
+ "node.unknownType": "Unknown",
216408
+ "node.resolutionError": "Resolution Error",
216409
+ "node.unknown.desc": "New node",
216410
+ "build.success": "Build completed.",
216411
+ "build.failed": "Build failed.",
216412
+ "editor.loading": "Loading editor...",
216413
+ "editor.externalChangeConflict": "External file change detected while the document has unsaved edits.",
216414
+ "editor.reloadFromDisk": "Reload",
216415
+ "editor.dismissConflict": "Dismiss",
216416
+ "editor.newerVersionEditDenied": "This file is created by a newer version of Behavior3({{version}}). Please upgrade to the latest version.",
216417
+ "inspector.noActiveDocument": "Open a Behavior3 editor to inspect and edit the active tree.",
216418
+ "inspector.embeddedModeNotice": "Inspector is configured to appear inside the Behavior3 editor.",
216419
+ "inspector.embeddedToolbar.build": "Build Behavior Tree",
216420
+ "inspector.embeddedToolbar.toggleEditorMode": "Toggle Editor Mode",
216421
+ "inspector.embeddedToolbar.toggleInspectorNodeJson": "Toggle Raw Node JSON",
216422
+ "inspector.embeddedToolbar.createProject": "Create Project",
216423
+ "inspector.embeddedToolbar.createTree": "Create Behavior Tree",
216424
+ "mutation.invalidJsonPath": "Invalid JSON path: {{path}}",
216425
+ "mutation.missingSelectedNode": "No selected node is available for this mutation.",
216426
+ "mutation.selectedNodeMismatch": "The selected node changed before the mutation was applied.",
216427
+ "mutation.missingTargetNode": "The target node could not be found.",
216428
+ "mutation.missingSourceNode": "The source node could not be found.",
216429
+ "mutation.missingSubtreeOriginal": "Missing subtree original snapshot for this mutation.",
216430
+ "mutation.missingDetachedSubtreeRoot": "Missing detached subtree snapshot for this mutation.",
216431
+ "mutation.moveRootDenied": "Cannot move the root node.",
216432
+ "mutation.dropAroundRootDenied": "Cannot drop before or after the root node.",
216433
+ "mutation.addChildToSubtreeRefDenied": "Cannot add a child directly to a subtree reference.",
216434
+ "mutation.moveIntoDescendantDenied": "Cannot move a node into its own descendant.",
216435
+ "mutation.deleteRootNodeDenied": "Cannot delete the root node.",
216436
+ "mutation.editSubtreeDenied": "Cannot edit structure on a subtree reference.",
216437
+ "mutation.saveSelectedAsSubtreeRootDenied": "The root node cannot be saved as a subtree.",
216438
+ "mutation.saveSelectedAsSubtreeMissingTarget": "The target node could not be saved as a subtree.",
216439
+ "mutation.saveSelectedAsSubtreePostSaveMissingTarget": "The target node could not be found after saving the subtree.",
216440
+ "runtime.nodeCheckRuntimeHasErrors": "Checker runtime has errors.",
216441
+ "runtime.invalidSavedSubtreePath": "Host returned an invalid saved subtree path.",
216442
+ "runtime.unsupportedDocumentMutation": "Unsupported document mutation.",
216443
+ "runtime.visibleHookNotRegistered": "Visible '{{name}}' is not registered.",
216444
+ "runtime.visibleHookFailed": "Visible '{{name}}' failed: {{error}}",
216445
+ "runtime.visibleExpressionDisabled": "Visible expression is disabled; enable settings.allowNewFunction.",
216446
+ "runtime.visibleExpressionCompileFailed": "Visible expression failed to compile: {{error}}",
216447
+ "runtime.visibleExpressionFailed": "Visible expression failed: {{error}}",
216448
+ "runtime.visibleExpressionUnknownArg": "Visible expression referenced args.{{property}}, but '{{property}}' is not in the defined arg scope (defined args: {{definedArgs}}).",
216449
+ "runtime.visibleExpressionNoArgs": "Visible expression referenced args.{{property}}, but this node defines no args.",
216450
+ "runtime.visibleExpressionUnknownSlotIndex": "Visible expression referenced {{fieldKind}}[{{index}}], but {{definedScope}}.",
216451
+ "runtime.visibleExpressionInvalidSlotProperty": "Visible expression referenced {{fieldKind}}.{{property}}, but {{fieldKind}} only supports defined numeric slot indices.",
216452
+ "runtime.visibleSlotScopeNone": "this node defines no {{fieldKind}} slots",
216453
+ "runtime.visibleSlotScopeIndex": "the defined {{fieldKind}} index is {{start}}",
216454
+ "runtime.visibleSlotScopeRange": "the defined {{fieldKind}} indices are {{start}}..{{end}}",
216455
+ "runtime.visibleSlotScopeRangeVariadic": "the defined {{fieldKind}} indices are {{start}}..{{end}}+",
216456
+ "override.resetTitle": "Reset this override?",
216457
+ "form.enterJsonArray": "Enter JSON array",
216458
+ "form.enterJsonValue": "Enter JSON value",
216459
+ "form.unset": "Unset",
216460
+ "form.true": "True",
216461
+ "form.false": "False",
216462
+ "validation.jsonArray": "{{name}} must be a JSON array",
216463
+ "validation.integer": "{{field}} must be an integer",
216464
+ "validation.number": "{{field}} must be a number",
216465
+ "validation.missingOneofInput": "Missing input slot for oneof '{{input}}'",
216466
+ "validation.oneof": "Only one of '{{left}}' and '{{right}}' can be set",
216467
+ "validation.invalidJsonPath": "Path must be a workdir-relative .json file: {{path}}",
216468
+ "validation.variableDescriptionRequired": "Variable description is required",
216469
+ "validation.customKeyRequired": "Custom key is required",
216470
+ "validation.customKeyDuplicate": "Custom key '{{key}}' is duplicated",
216471
+ "validation.customValueInvalid": "Custom value must be a string, number, or boolean"
216297
216472
  };
216298
- var toStatusFlag = (nodeName, defsByName) => {
216299
- let status = 0;
216300
- const def = defsByName.get(nodeName);
216301
- def?.status?.forEach((entry) => {
216302
- switch (entry) {
216303
- case "success":
216304
- status |= 1 << 2 /* SUCCESS */;
216305
- break;
216306
- case "failure":
216307
- status |= 1 << 1 /* FAILURE */;
216308
- break;
216309
- case "running":
216310
- status |= 1 << 0 /* RUNNING */;
216311
- break;
216312
- }
216473
+
216474
+ // media/locales/zh.json
216475
+ var zh_default = {
216476
+ about: "\u5173\u4E8E Behavior3",
216477
+ actualSize: "\u5B9E\u9645\u5927\u5C0F",
216478
+ add: "\u6DFB\u52A0",
216479
+ alertNewVersion: "\u6B64\u6587\u4EF6\u7531\u65B0\u7248\u672C Behavior3({{version}}) \u521B\u5EFA\uFF0C\u8BF7\u5347\u7EA7\u5230\u6700\u65B0\u7248\u672C\u3002",
216480
+ batch: "\u6279\u5904\u7406\u811A\u672C",
216481
+ batchCompleted: "\u6279\u5904\u7406\u5B8C\u6210",
216482
+ batchFailed: "\u6279\u5904\u7406\u51FA\u73B0\u9519\u8BEF\uFF0C\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A7\u5236\u53F0\uFF01",
216483
+ build: "\u6784\u5EFA",
216484
+ buildCompleted: "\u6784\u5EFA\u5B8C\u6210",
216485
+ buildFailed: "\u6784\u5EFA\u51FA\u73B0\u9519\u8BEF\uFF0C\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A7\u5236\u53F0\uFF01",
216486
+ cancel: "\u53D6\u6D88",
216487
+ compact: "\u7D27\u51D1",
216488
+ console: "\u63A7\u5236\u53F0",
216489
+ checkExpr: "\u68C0\u67E5\u8868\u8FBE\u5F0F",
216490
+ copy: "\u590D\u5236",
216491
+ createProject: "\u65B0\u5EFA\u9879\u76EE",
216492
+ cut: "\u526A\u5207",
216493
+ delete: "\u5220\u9664",
216494
+ deleteNode: "\u5220\u9664\u8282\u70B9",
216495
+ devTools: "\u5207\u6362\u5F00\u53D1\u8005\u5DE5\u5177",
216496
+ donotSave: "\u4E0D\u4FDD\u5B58",
216497
+ duplicate: "\u751F\u6210\u526F\u672C",
216498
+ editSubtree: "\u7F16\u8F91\u5B50\u6811",
216499
+ fieldRequired: "\u5B57\u6BB5\u201C{{field}}\u201D\u5FC5\u586B",
216500
+ forceReload: "\u5F3A\u5236\u91CD\u65B0\u52A0\u8F7D",
216501
+ fullscreen: "\u5207\u6362\u5168\u5C4F",
216502
+ hide: "\u9690\u85CF Behavior3",
216503
+ hideOthers: "\u9690\u85CF\u5176\u5B83",
216504
+ insertNode: "\u63D2\u5165\u8282\u70B9",
216505
+ jumpNode: "\u8DF3\u8F6C\u8282\u70B9",
216506
+ language: "\u8BED\u8A00",
216507
+ moveToTrash: "\u79FB\u81F3\u56DE\u6536\u7AD9",
216508
+ newFile: "\u65B0\u5EFA\u884C\u4E3A\u6811...",
216509
+ newFolder: "\u65B0\u5EFA\u76EE\u5F55...",
216510
+ newWindow: "\u65B0\u5EFA\u7A97\u53E3",
216511
+ nodeDefinition: "\u8282\u70B9\u5B9A\u4E49",
216512
+ normal: "\u6B63\u5E38",
216513
+ open: "\u6253\u5F00...",
216514
+ openProject: "\u6253\u5F00\u9879\u76EE",
216515
+ paste: "\u7C98\u8D34",
216516
+ quit: "\u9000\u51FA Behavior3",
216517
+ recent: "\u6700\u8FD1\u6253\u5F00",
216518
+ redo: "\u91CD\u505A",
216519
+ reload: "\u91CD\u65B0\u52A0\u8F7D",
216520
+ reset: "\u91CD\u7F6E",
216521
+ "reset.confirm": "\u91CD\u7F6E\u4E3A\u539F\u59CB\u503C\uFF1F",
216522
+ "reset.defaultConfirm": "\u91CD\u7F6E\u4E3A\u9ED8\u8BA4\u503C\uFF1F",
216523
+ rename: "\u91CD\u547D\u540D...",
216524
+ replace: "\u66FF\u6362",
216525
+ reportIssue: "\u95EE\u9898\u53CD\u9988",
216526
+ revealFileOnMac: "\u5728 Finder \u4E2D\u663E\u793A",
216527
+ revealFileOnWindows: "\u5728\u6587\u4EF6\u7BA1\u7406\u5668\u4E2D\u6253\u5F00",
216528
+ save: "\u4FDD\u5B58",
216529
+ saveAll: "\u4FDD\u5B58\u5168\u90E8",
216530
+ saveAs: "\u53E6\u5B58\u4E3A...",
216531
+ saveAsSubtree: "\u53E6\u5B58\u4E3A\u5B50\u6811",
216532
+ searchFile: "\u641C\u7D22\u6587\u4EF6",
216533
+ searchNode: "\u641C\u7D22\u8282\u70B9",
216534
+ selectAll: "\u5168\u9009",
216535
+ services: "\u670D\u52A1",
216536
+ setupBuildScript: "\u8BBE\u7F6E\u6784\u5EFA\u811A\u672C",
216537
+ start: "\u5F00\u59CB",
216538
+ undo: "\u64A4\u9500",
216539
+ unhide: "\u663E\u793A\u6240\u6709",
216540
+ zoomIn: "\u653E\u5927",
216541
+ zoomOut: "\u7F29\u5C0F",
216542
+ "menu.file": "\u6587\u4EF6",
216543
+ "menu.edit": "\u7F16\u8F91",
216544
+ "menu.view": "\u89C6\u56FE",
216545
+ "menu.window": "\u7A97\u53E3",
216546
+ "menu.help": "\u5E2E\u52A9",
216547
+ "workspace.saveAllOnClose": "\u4F60\u9700\u8981\u4FDD\u5B58\u5BF9\u4EE5\u4E0B {{count}} \u4E2A\u6587\u4EF6\u7684\u4FEE\u6539\u5417\uFF1F",
216548
+ "workspace.saveOnClose": "\u4F60\u9700\u8981\u4FDD\u5B58\u5BF9\u6587\u4EF6 {{name}} \u7684\u4FEE\u6539\u5417\uFF1F",
216549
+ "workspace.reloadFile": "\u6587\u4EF6 {{name}} \u53D1\u751F\u6539\u53D8\uFF0C\u4F60\u9700\u8981\u91CD\u65B0\u52A0\u8F7D\u5417\uFF1F",
216550
+ "explorer.deleteFile": "\u4F60\u786E\u5B9A\u8981\u5220\u9664\u6587\u4EF6 '{{name}}'\uFF1F",
216551
+ "explorer.deleteFolder": "\u4F60\u786E\u5B9A\u8981\u5220\u9664\u76EE\u5F55 '{{name}}'\uFF1F",
216552
+ "explorer.replaceFile": "\u4F60\u786E\u5B9A\u8981\u66FF\u6362\u6587\u4EF6 '{{name}}'\uFF1F",
216553
+ "explorer.restoreFileInfo": "\u4F60\u53EF\u4EE5\u4ECE\u56DE\u6536\u7AD9\u6062\u590D\u6B64\u6587\u4EF6\u3002",
216554
+ "explorer.title": "\u8D44\u6E90\u6D4F\u89C8",
216555
+ "tree.overview": "\u6982\u51B5",
216556
+ "tree.name": "\u884C\u4E3A\u6811",
216557
+ "tree.desc": "\u8BF4\u660E",
216558
+ "tree.export": "\u5BFC\u51FA",
216559
+ "tree.prefix": "\u6807\u8BC6\u524D\u7F00",
216560
+ "tree.group": "\u542F\u7528\u8282\u70B9\u5206\u7EC4",
216561
+ "tree.group.placeholder": "\u9009\u62E9\u8282\u70B9\u5206\u7EC4",
216562
+ "tree.vars": "\u5B9A\u4E49\u53D8\u91CF",
216563
+ "tree.vars.local": "\u672C\u5730\u53D8\u91CF",
216564
+ "tree.vars.add": "\u6DFB\u52A0\u53D8\u91CF",
216565
+ "tree.vars.name": "\u53D8\u91CF\u540D",
216566
+ "tree.vars.invalidName": "\u53D8\u91CF\u540D\u4E0D\u5408\u6CD5",
216567
+ "tree.vars.desc": "\u53D8\u91CF\u8BF4\u660E",
216568
+ "tree.vars.imports": "\u5BFC\u5165\u53D8\u91CF",
216569
+ "tree.vars.subtree": "\u5B50\u6811\u53D8\u91CF",
216570
+ "tree.import.add": "\u6DFB\u52A0\u5BFC\u5165",
216571
+ "tree.custom": "\u81EA\u5B9A\u4E49\u6570\u636E",
216572
+ "tree.custom.add": "\u6DFB\u52A0\u6761\u76EE",
216573
+ "tree.custom.key": "\u952E",
216574
+ "tree.custom.value": "\u503C",
216575
+ "tree.custom.type.string": "\u5B57\u7B26\u4E32\u503C",
216576
+ "tree.custom.type.number": "\u6570\u5B57\u503C",
216577
+ "tree.custom.type.boolean": "\u5E03\u5C14\u503C",
216578
+ "tree.custom.type.invalid": "\u975E\u6CD5\u7684\u81EA\u5B9A\u4E49\u503C",
216579
+ "regnode.input": "\u8F93\u5165\uFF1A",
216580
+ "regnode.output": "\u8F93\u51FA\uFF1A",
216581
+ "regnode.args": "\u53C2\u6570\uFF1A",
216582
+ "regnode.mark": "\u5907\u6CE8\uFF1A",
216583
+ "regnode.subtree": "\u5B50\u6811\uFF1A",
216584
+ "node.args": "\u5E38\u91CF\u53C2\u6570",
216585
+ "node.children.unlimited": "\u65E0\u9650\u5236",
216586
+ "node.children": "\u5B50\u8282\u70B9\u6570\u91CF",
216587
+ "node.debug": "\u8C03\u8BD5",
216588
+ "node.deleteRootNodeDenied": "\u4E0D\u80FD\u5220\u9664\u6839\u8282\u70B9",
216589
+ "node.dropDenied": "\u6B64\u8282\u70B9\u4F4D\u7F6E\u4E0D\u5141\u8BB8\u653E\u7F6E\u62D6\u62FD\u7684\u8282\u70B9",
216590
+ "node.desc": "\u8282\u70B9\u8BF4\u660E",
216591
+ "node.disabled": "\u7981\u7528",
216592
+ "node.editSubtreeDenied": "\u4E0D\u80FD\u7F16\u8F91\u5B50\u6811\u8282\u70B9",
216593
+ "node.editFailed": "\u8282\u70B9 {{name}} \u7F16\u8F91\u5931\u8D25",
216594
+ "node.group": "\u8282\u70B9\u5206\u7EC4",
216595
+ "node.groupNotEnabled": "\u8282\u70B9\u5206\u7EC4 \u201C{{group}}\u201D \u4EFB\u610F\u4E00\u4E2A\u672A\u5728\u5F53\u524D\u6587\u4EF6\u4E2D\u542F\u7528",
216596
+ "node.id": "\u8282\u70B9\u6807\u8BC6",
216597
+ "node.inputVariable": "\u8F93\u5165\u53D8\u91CF",
216598
+ "node.invalidChildren": "\u5B50\u8282\u70B9\u6570\u91CF\u4E0D\u5408\u6CD5",
216599
+ "node.invalidExpression": "\u8868\u8FBE\u5F0F\u4E0D\u5408\u6CD5",
216600
+ "node.invalidValue": "\u65E0\u6548\u7684\u503C",
216601
+ "node.invalidVariableName": "\u53D8\u91CF\u540D\u5FC5\u987B\u4EE5\u5B57\u6BCD\u6216\u4E0B\u5212\u7EBF\u5F00\u5934",
216602
+ "node.name": "\u8282\u70B9\u540D\u79F0",
216603
+ "node.noNodeSelected": "\u672A\u9009\u62E9\u4EFB\u52A1\u8282\u70B9",
216604
+ "node.notFound": "\u8282\u70B9 \u201C{{name}}\u201D \u4E0D\u5B58\u5728",
216605
+ "node.oneof.error": "\u8F93\u5165\u9879 \u201C{{input}}\u201D \u548C\u53C2\u6570 \u201C{{desc}}({{arg}})\u201D \u4E4B\u4E2D\uFF0C\u53EA\u80FD\u9009\u62E9\u8BBE\u7F6E\u5176\u4E2D\u4E4B\u4E00",
216606
+ "node.oneof.inputNotfound": "\u8F93\u5165\u9879\u201C{{input}}\u201D\u4E0D\u5B58\u5728",
216607
+ "node.outputVariable": "\u8F93\u51FA\u53D8\u91CF",
216608
+ "node.pasteDataError": "\u7C98\u8D34\u6570\u636E\u51FA\u9519",
216609
+ "node.rootNodeAsSubtree": "\u6839\u8282\u70B9\u4E0D\u80FD\u4FDD\u5B58\u4E3A\u5B50\u6811",
216610
+ "node.subtree": "\u5B50\u6811",
216611
+ "node.subtreeMissing": "\u5B50\u6811\u6587\u4EF6\u7F3A\u5931\uFF1A{{path}}",
216612
+ "node.subtreeInvalid": "\u5B50\u6811\u6587\u4EF6\u65E0\u6548\uFF1A{{path}}",
216613
+ "node.subtreeCyclic": "\u5B50\u6811\u5F15\u7528\u51FA\u73B0\u5FAA\u73AF\uFF1A{{path}}",
216614
+ "node.subtreeOpenFailed": "\u6253\u5F00\u5B50\u6811\u5931\u8D25\uFF1A\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u8BFB\uFF08{{path}}\uFF09",
216615
+ "node.subtreePathError": "\u5B50\u6811\u5FC5\u987B\u4FDD\u5B58\u5728\u5F53\u524D\u5DE5\u4F5C\u533A\u7684\u76EE\u5F55\u5185",
216616
+ "node.subtreeSaveRootError": "\u6839\u8282\u70B9\u4E0D\u80FD\u4FDD\u5B58\u4E3A\u5B50\u6811",
216617
+ "node.subtreeSaveSuccess": "\u5DF2\u4FDD\u5B58\u5E76\u8F6C\u6362\u4E3A\u5B50\u6811\u8282\u70B9\uFF1A{{path}}",
216618
+ "node.moveSubtreeDenied": "\u4E0D\u80FD\u79FB\u52A8\u5B50\u6811\u5185\u90E8\u8282\u70B9",
216619
+ "node.dropSubtreeInternalDenied": "\u4E0D\u80FD\u62D6\u653E\u5230\u5B50\u6811\u5185\u90E8\u8282\u70B9",
216620
+ "node.moveRootDenied": "\u4E0D\u80FD\u79FB\u52A8\u6839\u8282\u70B9",
216621
+ "node.dropAroundRootDenied": "\u4E0D\u80FD\u5C06\u8282\u70B9\u653E\u5230\u6839\u8282\u70B9\u4E4B\u524D\u6216\u4E4B\u540E",
216622
+ "node.addChildToSubtreeRefDenied": "\u4E0D\u80FD\u5411\u5B50\u6811\u5F15\u7528\u6DFB\u52A0\u5B50\u8282\u70B9",
216623
+ "node.moveIntoDescendantDenied": "\u4E0D\u80FD\u5C06\u8282\u70B9\u79FB\u52A8\u5230\u81EA\u5DF1\u7684\u540E\u4EE3\u8282\u70B9\u4E2D",
216624
+ "node.type": "\u8282\u70B9\u7C7B\u578B",
216625
+ "node.undefinedVariable": "\u53D8\u91CF \u201C{{variable}}\u201D \u672A\u5B9A\u4E49",
216626
+ "node.jsonData": "JSON \u6570\u636E",
216627
+ "node.unknown.title": "\u672A\u77E5\u8282\u70B9",
216628
+ "node.unknownType": "\u672A\u77E5",
216629
+ "node.resolutionError": "\u89E3\u6790\u9519\u8BEF",
216630
+ "node.unknown.desc": "\u65B0\u5EFA\u8282\u70B9",
216631
+ "build.success": "\u6784\u5EFA\u5B8C\u6210\u3002",
216632
+ "build.failed": "\u6784\u5EFA\u5931\u8D25\u3002",
216633
+ "editor.loading": "\u6B63\u5728\u52A0\u8F7D\u7F16\u8F91\u5668...",
216634
+ "editor.externalChangeConflict": "\u68C0\u6D4B\u5230\u5916\u90E8\u6587\u4EF6\u53D8\u66F4\uFF0C\u5F53\u524D\u6587\u6863\u8FD8\u6709\u672A\u4FDD\u5B58\u4FEE\u6539\u3002",
216635
+ "editor.reloadFromDisk": "\u91CD\u65B0\u8F7D\u5165",
216636
+ "editor.dismissConflict": "\u5FFD\u7565",
216637
+ "editor.newerVersionEditDenied": "\u6B64\u6587\u4EF6\u7531\u65B0\u7248\u672C Behavior3({{version}}) \u521B\u5EFA\uFF0C\u8BF7\u5347\u7EA7\u5230\u6700\u65B0\u7248\u672C\u540E\u518D\u7F16\u8F91\u3002",
216638
+ "inspector.noActiveDocument": "\u6253\u5F00\u4E00\u4E2A Behavior3 \u7F16\u8F91\u5668\u540E\uFF0C\u8FD9\u91CC\u4F1A\u663E\u793A\u5F53\u524D\u884C\u4E3A\u6811\u7684 Inspector\uFF0C\u5E76\u652F\u6301\u76F4\u63A5\u7F16\u8F91\u3002",
216639
+ "inspector.embeddedModeNotice": "Inspector \u5F53\u524D\u914D\u7F6E\u4E3A\u5728 Behavior3 \u7F16\u8F91\u5668\u5185\u90E8\u663E\u793A\u3002",
216640
+ "inspector.embeddedToolbar.build": "\u6784\u5EFA\u884C\u4E3A\u6811",
216641
+ "inspector.embeddedToolbar.toggleEditorMode": "\u5207\u6362\u7F16\u8F91\u5668\u6A21\u5F0F",
216642
+ "inspector.embeddedToolbar.toggleInspectorNodeJson": "\u5207\u6362\u539F\u59CB\u8282\u70B9 JSON",
216643
+ "inspector.embeddedToolbar.createProject": "\u65B0\u5EFA\u9879\u76EE",
216644
+ "inspector.embeddedToolbar.createTree": "\u65B0\u5EFA\u884C\u4E3A\u6811",
216645
+ "mutation.invalidJsonPath": "\u65E0\u6548\u7684 JSON \u8DEF\u5F84: {{path}}",
216646
+ "mutation.missingSelectedNode": "\u5F53\u524D\u6CA1\u6709\u53EF\u7528\u4E8E\u63D0\u4EA4\u6B64\u4FEE\u6539\u7684\u9009\u4E2D\u8282\u70B9\u3002",
216647
+ "mutation.selectedNodeMismatch": "\u5F53\u524D\u9009\u4E2D\u8282\u70B9\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u8BD5\u3002",
216648
+ "mutation.missingTargetNode": "\u672A\u627E\u5230\u76EE\u6807\u8282\u70B9\uFF0C\u8BF7\u91CD\u8BD5\u3002",
216649
+ "mutation.missingSourceNode": "\u672A\u627E\u5230\u6E90\u8282\u70B9\uFF0C\u8BF7\u91CD\u8BD5\u3002",
216650
+ "mutation.missingSubtreeOriginal": "\u7F3A\u5C11 subtree \u539F\u59CB\u8282\u70B9\u5FEB\u7167\uFF0C\u8BF7\u91CD\u8BD5\u3002",
216651
+ "mutation.missingDetachedSubtreeRoot": "\u7F3A\u5C11\u7528\u4E8E\u89E3\u7ED1 subtree \u5F15\u7528\u7684\u5FEB\u7167\uFF0C\u8BF7\u91CD\u8BD5\u3002",
216652
+ "mutation.moveRootDenied": "\u4E0D\u80FD\u79FB\u52A8\u6839\u8282\u70B9\u3002",
216653
+ "mutation.dropAroundRootDenied": "\u4E0D\u80FD\u56F4\u7ED5\u6839\u8282\u70B9\u63D2\u5165\u3002",
216654
+ "mutation.addChildToSubtreeRefDenied": "\u4E0D\u80FD\u76F4\u63A5\u5411 subtree \u5F15\u7528\u6DFB\u52A0\u5B50\u8282\u70B9\u3002",
216655
+ "mutation.moveIntoDescendantDenied": "\u4E0D\u80FD\u79FB\u52A8\u5230\u81EA\u5DF1\u7684\u540E\u4EE3\u4E0B\u3002",
216656
+ "mutation.deleteRootNodeDenied": "\u4E0D\u80FD\u5220\u9664\u6839\u8282\u70B9\u3002",
216657
+ "mutation.editSubtreeDenied": "\u4E0D\u80FD\u5728 subtree \u5F15\u7528\u4E0A\u76F4\u63A5\u4FEE\u6539\u7ED3\u6784\u3002",
216658
+ "mutation.saveSelectedAsSubtreeRootDenied": "\u6839\u8282\u70B9\u4E0D\u80FD\u53E6\u5B58\u4E3A subtree\u3002",
216659
+ "mutation.saveSelectedAsSubtreeMissingTarget": "\u672A\u627E\u5230\u53EF\u53E6\u5B58\u4E3A subtree \u7684\u76EE\u6807\u8282\u70B9\u3002",
216660
+ "mutation.saveSelectedAsSubtreePostSaveMissingTarget": "\u63D0\u4EA4 subtree \u4FDD\u5B58\u7ED3\u679C\u65F6\u672A\u627E\u5230\u76EE\u6807\u8282\u70B9\u3002",
216661
+ "runtime.nodeCheckRuntimeHasErrors": "checker \u8FD0\u884C\u65F6\u5B58\u5728\u9519\u8BEF\u3002",
216662
+ "runtime.invalidSavedSubtreePath": "\u5BBF\u4E3B\u8FD4\u56DE\u4E86\u65E0\u6548\u7684 subtree \u4FDD\u5B58\u8DEF\u5F84\u3002",
216663
+ "runtime.unsupportedDocumentMutation": "\u4E0D\u652F\u6301\u6B64\u6587\u6863\u4FEE\u6539\u3002",
216664
+ "runtime.visibleHookNotRegistered": "visible \u201C{{name}}\u201D \u672A\u6CE8\u518C\u3002",
216665
+ "runtime.visibleHookFailed": "visible \u201C{{name}}\u201D \u6267\u884C\u5931\u8D25\uFF1A{{error}}",
216666
+ "runtime.visibleExpressionDisabled": "visible \u8868\u8FBE\u5F0F\u5DF2\u7981\u7528\uFF1B\u8BF7\u542F\u7528 settings.allowNewFunction\u3002",
216667
+ "runtime.visibleExpressionCompileFailed": "visible \u8868\u8FBE\u5F0F\u7F16\u8BD1\u5931\u8D25\uFF1A{{error}}",
216668
+ "runtime.visibleExpressionFailed": "visible \u8868\u8FBE\u5F0F\u6267\u884C\u5931\u8D25\uFF1A{{error}}",
216669
+ "runtime.visibleExpressionUnknownArg": "visible \u8868\u8FBE\u5F0F\u5F15\u7528\u4E86 args.{{property}}\uFF0C\u4F46 \u201C{{property}}\u201D \u4E0D\u5728\u5DF2\u5B9A\u4E49\u7684\u53C2\u6570\u8303\u56F4\u5185\uFF08\u5DF2\u5B9A\u4E49\u53C2\u6570\uFF1A{{definedArgs}}\uFF09\u3002",
216670
+ "runtime.visibleExpressionNoArgs": "visible \u8868\u8FBE\u5F0F\u5F15\u7528\u4E86 args.{{property}}\uFF0C\u4F46\u5F53\u524D\u8282\u70B9\u672A\u5B9A\u4E49\u53C2\u6570\u3002",
216671
+ "runtime.visibleExpressionUnknownSlotIndex": "visible \u8868\u8FBE\u5F0F\u5F15\u7528\u4E86 {{fieldKind}}[{{index}}]\uFF0C\u4F46{{definedScope}}\u3002",
216672
+ "runtime.visibleExpressionInvalidSlotProperty": "visible \u8868\u8FBE\u5F0F\u5F15\u7528\u4E86 {{fieldKind}}.{{property}}\uFF0C\u4F46 {{fieldKind}} \u4EC5\u652F\u6301\u5DF2\u5B9A\u4E49\u7684\u6570\u5B57\u69FD\u4F4D\u7D22\u5F15\u3002",
216673
+ "runtime.visibleSlotScopeNone": "\u5F53\u524D\u8282\u70B9\u672A\u5B9A\u4E49{{fieldKind}}\u69FD\u4F4D",
216674
+ "runtime.visibleSlotScopeIndex": "\u5DF2\u5B9A\u4E49\u7684{{fieldKind}}\u69FD\u4F4D\u7D22\u5F15\u53EA\u6709 {{start}}",
216675
+ "runtime.visibleSlotScopeRange": "\u5DF2\u5B9A\u4E49\u7684{{fieldKind}}\u69FD\u4F4D\u7D22\u5F15\u8303\u56F4\u662F {{start}}..{{end}}",
216676
+ "runtime.visibleSlotScopeRangeVariadic": "\u5DF2\u5B9A\u4E49\u7684{{fieldKind}}\u69FD\u4F4D\u7D22\u5F15\u8303\u56F4\u662F {{start}}..{{end}}+",
216677
+ "override.resetTitle": "\u91CD\u7F6E\u6B64\u8986\u76D6\uFF1F",
216678
+ "form.enterJsonArray": "\u8F93\u5165 JSON \u6570\u7EC4",
216679
+ "form.enterJsonValue": "\u8F93\u5165 JSON \u503C",
216680
+ "form.unset": "\u672A\u8BBE\u7F6E",
216681
+ "form.true": "\u662F",
216682
+ "form.false": "\u5426",
216683
+ "validation.jsonArray": "{{name}} \u5FC5\u987B\u662F JSON \u6570\u7EC4",
216684
+ "validation.integer": "{{field}} \u5FC5\u987B\u662F\u6574\u6570",
216685
+ "validation.number": "{{field}} \u5FC5\u987B\u662F\u6570\u5B57",
216686
+ "validation.missingOneofInput": "\u7F3A\u5C11 oneof \u8F93\u5165\u9879 \u201C{{input}}\u201D",
216687
+ "validation.oneof": "\u201C{{left}}\u201D \u548C \u201C{{right}}\u201D \u53EA\u80FD\u8BBE\u7F6E\u5176\u4E2D\u4E4B\u4E00",
216688
+ "validation.invalidJsonPath": "\u8DEF\u5F84\u5FC5\u987B\u662F\u5DE5\u4F5C\u76EE\u5F55\u5185\u7684\u76F8\u5BF9 .json \u6587\u4EF6\uFF1A{{path}}",
216689
+ "validation.variableDescriptionRequired": "\u53D8\u91CF\u8BF4\u660E\u5FC5\u586B",
216690
+ "validation.customKeyRequired": "\u81EA\u5B9A\u4E49 key \u5FC5\u586B",
216691
+ "validation.customKeyDuplicate": "\u81EA\u5B9A\u4E49 key \u201C{{key}}\u201D \u91CD\u590D\u4E86",
216692
+ "validation.customValueInvalid": "\u81EA\u5B9A\u4E49\u503C\u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u3001\u6570\u5B57\u6216\u5E03\u5C14\u503C"
216693
+ };
216694
+
216695
+ // webview/shared/runtime-i18n.ts
216696
+ var runtimeTranslations = {
216697
+ en: en_default,
216698
+ zh: zh_default
216699
+ };
216700
+ var INTERPOLATION_PATTERN = /\{\{\s*([^{}\s]+)\s*\}\}/g;
216701
+ var normalizeI18nLanguage = (language) => {
216702
+ const value = (language ?? "").toLowerCase();
216703
+ return value.startsWith("zh") ? "zh" : "en";
216704
+ };
216705
+ var interpolateRuntimeMessage = (template, params) => {
216706
+ if (!params) {
216707
+ return template;
216708
+ }
216709
+ return template.replace(INTERPOLATION_PATTERN, (match, key) => {
216710
+ const value = params[key];
216711
+ return value === void 0 || value === null ? match : String(value);
216313
216712
  });
216314
- return status;
216315
216713
  };
216316
- var appendStatusFlag = (status, childStatus) => {
216317
- const childSuccess = childStatus >> 2 /* SUCCESS */ & 1;
216318
- const childFailure = childStatus >> 1 /* FAILURE */ & 1;
216319
- if (childSuccess === 0) {
216320
- status |= 1 << 5 /* SUCCESS_ZERO */;
216714
+ var translateRuntimeMessage = (language, key, params) => {
216715
+ const template = runtimeTranslations[language][key] ?? runtimeTranslations.en[key] ?? key;
216716
+ return interpolateRuntimeMessage(template, params);
216717
+ };
216718
+
216719
+ // webview/shared/tree-materializer.ts
216720
+ var applyPatchIfAny = (node, patch) => {
216721
+ if (!patch) {
216722
+ return;
216321
216723
  }
216322
- if (childFailure === 0) {
216323
- status |= 1 << 4 /* FAILURE_ZERO */;
216724
+ if (patch.desc !== void 0) {
216725
+ node.desc = patch.desc;
216324
216726
  }
216325
- status |= childStatus;
216326
- return status;
216727
+ if (patch.input !== void 0) {
216728
+ node.input = patch.input;
216729
+ }
216730
+ if (patch.output !== void 0) {
216731
+ node.output = patch.output;
216732
+ }
216733
+ if (patch.args !== void 0) {
216734
+ node.args = { ...node.args ?? {}, ...patch.args };
216735
+ }
216736
+ if (patch.debug !== void 0) {
216737
+ node.debug = patch.debug;
216738
+ }
216739
+ if (patch.disabled !== void 0) {
216740
+ node.disabled = patch.disabled;
216741
+ }
216742
+ };
216743
+ var applyArgDefaults = (node, def) => {
216744
+ if (!def?.args?.length) {
216745
+ return;
216746
+ }
216747
+ node.args ||= {};
216748
+ for (const arg of def.args) {
216749
+ if (node.args[arg.name] === void 0 && arg.default !== void 0) {
216750
+ node.args[arg.name] = arg.default;
216751
+ }
216752
+ }
216753
+ };
216754
+ var buildResolvedExternalNode = (sourceNode, overrideChain, rootOverride) => {
216755
+ const value = clonePersistedNode(sourceNode);
216756
+ for (const tree of [...overrideChain].reverse()) {
216757
+ applyPatchIfAny(value, tree.overrides[sourceNode.uuid]);
216758
+ }
216759
+ const subtreeOriginal = clonePersistedNode(value);
216760
+ applyPatchIfAny(value, rootOverride[sourceNode.uuid]);
216761
+ return { value, subtreeOriginal };
216762
+ };
216763
+ var isInvalidSubtreeSource = (value) => {
216764
+ return Boolean(value && typeof value === "object" && "error" in value);
216765
+ };
216766
+ var toStatusFlag = (nodeName, defsByName) => {
216767
+ let status = 0;
216768
+ const def = defsByName.get(nodeName);
216769
+ def?.status?.forEach((entry) => {
216770
+ switch (entry) {
216771
+ case "success":
216772
+ status |= 1 << 2 /* SUCCESS */;
216773
+ break;
216774
+ case "failure":
216775
+ status |= 1 << 1 /* FAILURE */;
216776
+ break;
216777
+ case "running":
216778
+ status |= 1 << 0 /* RUNNING */;
216779
+ break;
216780
+ }
216781
+ });
216782
+ return status;
216783
+ };
216784
+ var appendStatusFlag = (status, childStatus) => {
216785
+ const childSuccess = childStatus >> 2 /* SUCCESS */ & 1;
216786
+ const childFailure = childStatus >> 1 /* FAILURE */ & 1;
216787
+ if (childSuccess === 0) {
216788
+ status |= 1 << 5 /* SUCCESS_ZERO */;
216789
+ }
216790
+ if (childFailure === 0) {
216791
+ status |= 1 << 4 /* FAILURE_ZERO */;
216792
+ }
216793
+ status |= childStatus;
216794
+ return status;
216327
216795
  };
216328
216796
  var buildStatusFlag = (status, nodeName, childStatus, defsByName) => {
216329
216797
  const def = defsByName.get(nodeName);
@@ -216696,6 +217164,282 @@ var createNodeFieldCheckers = (moduleExports, env2) => {
216696
217164
  return { checkers, hasError, hasCheckers: decorated.length > 0 };
216697
217165
  };
216698
217166
  var normalizeNodeFieldVisibleResult = (result) => result !== false;
217167
+ var VISIBLE_HANDLER_NAME_PATTERN = /^\w+$/;
217168
+ var VISIBLE_EXPRESSION_TOKEN_PATTERN = /[\s()[\].!=<>|&+*\/?:'"]/;
217169
+ var VISIBLE_ARRAY_INDEX_PATTERN = /^(0|[1-9]\d*)$/;
217170
+ var visibleExpressionCache = /* @__PURE__ */ new Map();
217171
+ var getBuildEnvLanguage = (env2) => normalizeI18nLanguage(env2.language);
217172
+ var translateVisibleRuntimeMessage = (env2, key, params) => translateRuntimeMessage(getBuildEnvLanguage(env2), key, params);
217173
+ var formatVisibleArgScope = (env2, definedArgNames) => getBuildEnvLanguage(env2) === "zh" ? definedArgNames.join("\u3001") : definedArgNames.join(", ");
217174
+ var getVisibleFieldKindLabel = (env2, fieldKind) => {
217175
+ if (getBuildEnvLanguage(env2) === "zh") {
217176
+ return fieldKind === "input" ? "\u8F93\u5165" : "\u8F93\u51FA";
217177
+ }
217178
+ return fieldKind;
217179
+ };
217180
+ var parseVisibleArrayIndex = (property) => {
217181
+ if (typeof property === "number") {
217182
+ return Number.isInteger(property) && property >= 0 ? property : null;
217183
+ }
217184
+ if (typeof property === "string" && VISIBLE_ARRAY_INDEX_PATTERN.test(property)) {
217185
+ return Number(property);
217186
+ }
217187
+ return null;
217188
+ };
217189
+ var isVisibleSlotIndexDefined = (slotDefs, index) => {
217190
+ if (index < 0) {
217191
+ return false;
217192
+ }
217193
+ const slotCount = slotDefs?.length ?? 0;
217194
+ if (slotCount === 0) {
217195
+ return false;
217196
+ }
217197
+ if (index < slotCount) {
217198
+ return true;
217199
+ }
217200
+ const normalizedSlotDefs = slotDefs ?? [];
217201
+ return parseSlotDefinition(
217202
+ normalizedSlotDefs[slotCount - 1] ?? "",
217203
+ normalizedSlotDefs,
217204
+ slotCount - 1
217205
+ ).variadic;
217206
+ };
217207
+ var formatVisibleSlotScope = (env2, fieldKind, slotDefs) => {
217208
+ const slotCount = slotDefs?.length ?? 0;
217209
+ const fieldKindLabel = getVisibleFieldKindLabel(env2, fieldKind);
217210
+ if (slotCount === 0) {
217211
+ return translateVisibleRuntimeMessage(env2, "runtime.visibleSlotScopeNone", {
217212
+ fieldKind: fieldKindLabel
217213
+ });
217214
+ }
217215
+ if (parseSlotDefinition(slotDefs?.[slotCount - 1] ?? "", slotDefs, slotCount - 1).variadic) {
217216
+ return translateVisibleRuntimeMessage(env2, "runtime.visibleSlotScopeRangeVariadic", {
217217
+ fieldKind: fieldKindLabel,
217218
+ start: 0,
217219
+ end: slotCount - 1
217220
+ });
217221
+ }
217222
+ return slotCount === 1 ? translateVisibleRuntimeMessage(env2, "runtime.visibleSlotScopeIndex", {
217223
+ fieldKind: fieldKindLabel,
217224
+ start: 0
217225
+ }) : translateVisibleRuntimeMessage(env2, "runtime.visibleSlotScopeRange", {
217226
+ fieldKind: fieldKindLabel,
217227
+ start: 0,
217228
+ end: slotCount - 1
217229
+ });
217230
+ };
217231
+ var createVisibleArgScope = (ctx) => {
217232
+ const definedArgNames = (ctx.nodeDef.args ?? []).map((arg) => arg.name);
217233
+ const definedArgNameSet = new Set(definedArgNames);
217234
+ const target = Object.assign(
217235
+ /* @__PURE__ */ Object.create(null),
217236
+ ctx.node.args ?? {}
217237
+ );
217238
+ return new Proxy(target, {
217239
+ get(currentTarget, property) {
217240
+ if (typeof property === "symbol") {
217241
+ return Reflect.get(currentTarget, property);
217242
+ }
217243
+ if (definedArgNameSet.has(property)) {
217244
+ return currentTarget[property];
217245
+ }
217246
+ throw new Error(
217247
+ definedArgNames.length ? translateVisibleRuntimeMessage(
217248
+ ctx.env,
217249
+ "runtime.visibleExpressionUnknownArg",
217250
+ {
217251
+ property,
217252
+ definedArgs: formatVisibleArgScope(ctx.env, definedArgNames)
217253
+ }
217254
+ ) : translateVisibleRuntimeMessage(ctx.env, "runtime.visibleExpressionNoArgs", {
217255
+ property
217256
+ })
217257
+ );
217258
+ },
217259
+ has(_currentTarget, property) {
217260
+ if (typeof property === "symbol") {
217261
+ return false;
217262
+ }
217263
+ return definedArgNameSet.has(property);
217264
+ }
217265
+ });
217266
+ };
217267
+ var createVisibleSlotScope = (fieldKind, values, slotDefs, env2) => {
217268
+ const target = values ?? [];
217269
+ return new Proxy(target, {
217270
+ get(currentTarget, property, receiver) {
217271
+ if (typeof property === "symbol") {
217272
+ return Reflect.get(currentTarget, property, receiver);
217273
+ }
217274
+ const index = parseVisibleArrayIndex(property);
217275
+ if (index !== null) {
217276
+ if (!isVisibleSlotIndexDefined(slotDefs, index)) {
217277
+ throw new Error(
217278
+ translateVisibleRuntimeMessage(
217279
+ env2,
217280
+ "runtime.visibleExpressionUnknownSlotIndex",
217281
+ {
217282
+ fieldKind: getVisibleFieldKindLabel(env2, fieldKind),
217283
+ index,
217284
+ definedScope: formatVisibleSlotScope(env2, fieldKind, slotDefs)
217285
+ }
217286
+ )
217287
+ );
217288
+ }
217289
+ return Reflect.get(currentTarget, property, receiver);
217290
+ }
217291
+ if (property in currentTarget || property in Array.prototype) {
217292
+ return Reflect.get(currentTarget, property, receiver);
217293
+ }
217294
+ throw new Error(
217295
+ translateVisibleRuntimeMessage(
217296
+ env2,
217297
+ "runtime.visibleExpressionInvalidSlotProperty",
217298
+ {
217299
+ fieldKind: getVisibleFieldKindLabel(env2, fieldKind),
217300
+ property: String(property)
217301
+ }
217302
+ )
217303
+ );
217304
+ },
217305
+ has(currentTarget, property) {
217306
+ if (typeof property === "symbol") {
217307
+ return property in currentTarget;
217308
+ }
217309
+ const index = parseVisibleArrayIndex(property);
217310
+ if (index !== null) {
217311
+ return isVisibleSlotIndexDefined(slotDefs, index);
217312
+ }
217313
+ return property in currentTarget || property in Array.prototype;
217314
+ }
217315
+ });
217316
+ };
217317
+ var isNamedNodeFieldVisible = (visibleName) => VISIBLE_HANDLER_NAME_PATTERN.test(visibleName);
217318
+ var isInlineNodeFieldVisibleExpression = (visibleName, visibles) => {
217319
+ if (visibles.has(visibleName)) {
217320
+ return false;
217321
+ }
217322
+ if (isNamedNodeFieldVisible(visibleName)) {
217323
+ return false;
217324
+ }
217325
+ return VISIBLE_EXPRESSION_TOKEN_PATTERN.test(visibleName);
217326
+ };
217327
+ var getVisibleExpressionEvaluator = (expression) => {
217328
+ const cached = visibleExpressionCache.get(expression);
217329
+ if (cached) {
217330
+ return cached;
217331
+ }
217332
+ const evaluator = new Function(
217333
+ "args",
217334
+ "input",
217335
+ "output",
217336
+ "value",
217337
+ `"use strict"; return (${expression});`
217338
+ );
217339
+ visibleExpressionCache.set(expression, evaluator);
217340
+ return evaluator;
217341
+ };
217342
+ var resolveNodeFieldVisible = (params) => {
217343
+ if (!isInlineNodeFieldVisibleExpression(params.visibleName, params.visibles)) {
217344
+ const visible = params.visibles.get(params.visibleName);
217345
+ if (!visible) {
217346
+ return {
217347
+ diagnostic: {
217348
+ source: params.visibleName,
217349
+ message: translateVisibleRuntimeMessage(
217350
+ params.ctx.env,
217351
+ "runtime.visibleHookNotRegistered",
217352
+ {
217353
+ name: params.visibleName
217354
+ }
217355
+ )
217356
+ }
217357
+ };
217358
+ }
217359
+ try {
217360
+ return {
217361
+ visible: normalizeNodeFieldVisibleResult(visible.visible(params.value, params.ctx))
217362
+ };
217363
+ } catch (error) {
217364
+ return {
217365
+ diagnostic: {
217366
+ source: params.visibleName,
217367
+ message: translateVisibleRuntimeMessage(
217368
+ params.ctx.env,
217369
+ "runtime.visibleHookFailed",
217370
+ {
217371
+ name: params.visibleName,
217372
+ error: formatRuntimeError(error)
217373
+ }
217374
+ )
217375
+ }
217376
+ };
217377
+ }
217378
+ }
217379
+ if (!params.ctx.env.allowNewFunction) {
217380
+ return {
217381
+ diagnostic: {
217382
+ source: params.visibleName,
217383
+ message: translateVisibleRuntimeMessage(
217384
+ params.ctx.env,
217385
+ "runtime.visibleExpressionDisabled"
217386
+ )
217387
+ }
217388
+ };
217389
+ }
217390
+ let evaluator;
217391
+ try {
217392
+ evaluator = getVisibleExpressionEvaluator(params.visibleName);
217393
+ } catch (error) {
217394
+ return {
217395
+ diagnostic: {
217396
+ source: params.visibleName,
217397
+ message: translateVisibleRuntimeMessage(
217398
+ params.ctx.env,
217399
+ "runtime.visibleExpressionCompileFailed",
217400
+ {
217401
+ error: formatRuntimeError(error)
217402
+ }
217403
+ )
217404
+ }
217405
+ };
217406
+ }
217407
+ try {
217408
+ return {
217409
+ visible: normalizeNodeFieldVisibleResult(
217410
+ evaluator(
217411
+ createVisibleArgScope(params.ctx),
217412
+ createVisibleSlotScope(
217413
+ "input",
217414
+ params.ctx.node.input ?? [],
217415
+ params.ctx.nodeDef.input,
217416
+ params.ctx.env
217417
+ ),
217418
+ createVisibleSlotScope(
217419
+ "output",
217420
+ params.ctx.node.output ?? [],
217421
+ params.ctx.nodeDef.output,
217422
+ params.ctx.env
217423
+ ),
217424
+ params.value
217425
+ )
217426
+ )
217427
+ };
217428
+ } catch (error) {
217429
+ return {
217430
+ diagnostic: {
217431
+ source: params.visibleName,
217432
+ message: translateVisibleRuntimeMessage(
217433
+ params.ctx.env,
217434
+ "runtime.visibleExpressionFailed",
217435
+ {
217436
+ error: formatRuntimeError(error)
217437
+ }
217438
+ )
217439
+ }
217440
+ };
217441
+ }
217442
+ };
216699
217443
  var createNodeFieldVisibles = (moduleExports, env2) => {
216700
217444
  const visibles = /* @__PURE__ */ new Map();
216701
217445
  let hasError = false;
@@ -217090,38 +217834,49 @@ var collectNodeFieldCheckDiagnostics = (params) => {
217090
217834
  nodeDef,
217091
217835
  treePath: target.treePath ?? params.treePath,
217092
217836
  env: params.env,
217093
- onArg: ({ fieldName, checkerName, value, ctx }) => {
217094
- if (!checkerName) {
217095
- return;
217096
- }
217097
- const pushDiagnostic = (message) => {
217837
+ onArg: ({ fieldName, checkerName, visibleName, value, ctx }) => {
217838
+ const pushDiagnostic = (source, message) => {
217098
217839
  diagnostics.push({
217099
217840
  instanceKey: target.instanceKey,
217100
217841
  nodeId: node.id,
217101
217842
  nodeName: node.name,
217102
217843
  fieldKind: "arg",
217103
217844
  fieldName,
217104
- checker: checkerName,
217845
+ checker: source,
217105
217846
  message
217106
217847
  });
217107
217848
  };
217849
+ if (visibleName) {
217850
+ const resolution = resolveNodeFieldVisible({
217851
+ visibleName,
217852
+ value,
217853
+ ctx,
217854
+ visibles: params.visibles ?? /* @__PURE__ */ new Map()
217855
+ });
217856
+ if (resolution.diagnostic) {
217857
+ pushDiagnostic(resolution.diagnostic.source, resolution.diagnostic.message);
217858
+ }
217859
+ }
217860
+ if (!checkerName) {
217861
+ return;
217862
+ }
217108
217863
  const checker = params.checkers.get(checkerName);
217109
217864
  if (!checker) {
217110
- pushDiagnostic(`checker '${checkerName}' is not registered`);
217865
+ pushDiagnostic(checkerName, `checker '${checkerName}' is not registered`);
217111
217866
  return;
217112
217867
  }
217113
217868
  try {
217114
217869
  const messages = normalizeNodeFieldCheckResult(checker.validate(value, ctx));
217115
- messages.forEach(pushDiagnostic);
217870
+ messages.forEach((message) => pushDiagnostic(checkerName, message));
217116
217871
  } catch (error) {
217117
- pushDiagnostic(`checker '${checkerName}' failed: ${formatRuntimeError(error)}`);
217872
+ pushDiagnostic(
217873
+ checkerName,
217874
+ `checker '${checkerName}' failed: ${formatRuntimeError(error)}`
217875
+ );
217118
217876
  }
217119
217877
  },
217120
- onInput: ({ fieldName, fieldIndex, checkerName, value, ctx }) => {
217121
- if (!checkerName) {
217122
- return;
217123
- }
217124
- const pushDiagnostic = (message) => {
217878
+ onInput: ({ fieldName, fieldIndex, checkerName, visibleName, value, ctx }) => {
217879
+ const pushDiagnostic = (source, message) => {
217125
217880
  diagnostics.push({
217126
217881
  instanceKey: target.instanceKey,
217127
217882
  nodeId: node.id,
@@ -217129,27 +217884,41 @@ var collectNodeFieldCheckDiagnostics = (params) => {
217129
217884
  fieldKind: "input",
217130
217885
  fieldName,
217131
217886
  fieldIndex,
217132
- checker: checkerName,
217887
+ checker: source,
217133
217888
  message
217134
217889
  });
217135
217890
  };
217891
+ if (visibleName) {
217892
+ const resolution = resolveNodeFieldVisible({
217893
+ visibleName,
217894
+ value,
217895
+ ctx,
217896
+ visibles: params.visibles ?? /* @__PURE__ */ new Map()
217897
+ });
217898
+ if (resolution.diagnostic) {
217899
+ pushDiagnostic(resolution.diagnostic.source, resolution.diagnostic.message);
217900
+ }
217901
+ }
217902
+ if (!checkerName) {
217903
+ return;
217904
+ }
217136
217905
  const checker = params.checkers.get(checkerName);
217137
217906
  if (!checker) {
217138
- pushDiagnostic(`checker '${checkerName}' is not registered`);
217907
+ pushDiagnostic(checkerName, `checker '${checkerName}' is not registered`);
217139
217908
  return;
217140
217909
  }
217141
217910
  try {
217142
217911
  const messages = normalizeNodeFieldCheckResult(checker.validate(value, ctx));
217143
- messages.forEach(pushDiagnostic);
217912
+ messages.forEach((message) => pushDiagnostic(checkerName, message));
217144
217913
  } catch (error) {
217145
- pushDiagnostic(`checker '${checkerName}' failed: ${formatRuntimeError(error)}`);
217914
+ pushDiagnostic(
217915
+ checkerName,
217916
+ `checker '${checkerName}' failed: ${formatRuntimeError(error)}`
217917
+ );
217146
217918
  }
217147
217919
  },
217148
- onOutput: ({ fieldName, fieldIndex, checkerName, value, ctx }) => {
217149
- if (!checkerName) {
217150
- return;
217151
- }
217152
- const pushDiagnostic = (message) => {
217920
+ onOutput: ({ fieldName, fieldIndex, checkerName, visibleName, value, ctx }) => {
217921
+ const pushDiagnostic = (source, message) => {
217153
217922
  diagnostics.push({
217154
217923
  instanceKey: target.instanceKey,
217155
217924
  nodeId: node.id,
@@ -217157,20 +217926,37 @@ var collectNodeFieldCheckDiagnostics = (params) => {
217157
217926
  fieldKind: "output",
217158
217927
  fieldName,
217159
217928
  fieldIndex,
217160
- checker: checkerName,
217929
+ checker: source,
217161
217930
  message
217162
217931
  });
217163
217932
  };
217933
+ if (visibleName) {
217934
+ const resolution = resolveNodeFieldVisible({
217935
+ visibleName,
217936
+ value,
217937
+ ctx,
217938
+ visibles: params.visibles ?? /* @__PURE__ */ new Map()
217939
+ });
217940
+ if (resolution.diagnostic) {
217941
+ pushDiagnostic(resolution.diagnostic.source, resolution.diagnostic.message);
217942
+ }
217943
+ }
217944
+ if (!checkerName) {
217945
+ return;
217946
+ }
217164
217947
  const checker = params.checkers.get(checkerName);
217165
217948
  if (!checker) {
217166
- pushDiagnostic(`checker '${checkerName}' is not registered`);
217949
+ pushDiagnostic(checkerName, `checker '${checkerName}' is not registered`);
217167
217950
  return;
217168
217951
  }
217169
217952
  try {
217170
217953
  const messages = normalizeNodeFieldCheckResult(checker.validate(value, ctx));
217171
- messages.forEach(pushDiagnostic);
217954
+ messages.forEach((message) => pushDiagnostic(checkerName, message));
217172
217955
  } catch (error) {
217173
- pushDiagnostic(`checker '${checkerName}' failed: ${formatRuntimeError(error)}`);
217956
+ pushDiagnostic(
217957
+ checkerName,
217958
+ `checker '${checkerName}' failed: ${formatRuntimeError(error)}`
217959
+ );
217174
217960
  }
217175
217961
  }
217176
217962
  });
@@ -217194,66 +217980,60 @@ var resolveNodeFieldVisibility = (params) => {
217194
217980
  if (!visibleName) {
217195
217981
  return;
217196
217982
  }
217197
- const visible = params.visibles.get(visibleName);
217198
- if (!visible) {
217983
+ const resolution = resolveNodeFieldVisible({
217984
+ visibleName,
217985
+ value,
217986
+ ctx,
217987
+ visibles: params.visibles
217988
+ });
217989
+ if (resolution.diagnostic) {
217199
217990
  params.env.logger.warn(
217200
- `visible '${visibleName}' is not registered for ${formatFieldLocator(node, "arg", fieldName)}`
217991
+ `${resolution.diagnostic.message} for ${formatFieldLocator(node, "arg", fieldName)}`
217201
217992
  );
217202
217993
  return;
217203
217994
  }
217204
- try {
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;
217995
+ if (typeof resolution.visible === "boolean") {
217996
+ visibility.args[fieldName] = resolution.visible;
217213
217997
  }
217214
217998
  },
217215
217999
  onInput: ({ fieldName, fieldIndex, visibleName, value, ctx }) => {
217216
218000
  if (!visibleName) {
217217
218001
  return;
217218
218002
  }
217219
- const visible = params.visibles.get(visibleName);
217220
- if (!visible) {
218003
+ const resolution = resolveNodeFieldVisible({
218004
+ visibleName,
218005
+ value,
218006
+ ctx,
218007
+ visibles: params.visibles
218008
+ });
218009
+ if (resolution.diagnostic) {
217221
218010
  params.env.logger.warn(
217222
- `visible '${visibleName}' is not registered for ${formatFieldLocator(node, "input", fieldName, fieldIndex)}`
218011
+ `${resolution.diagnostic.message} for ${formatFieldLocator(node, "input", fieldName, fieldIndex)}`
217223
218012
  );
217224
218013
  return;
217225
218014
  }
217226
- try {
217227
- visibility.input[fieldIndex] = normalizeNodeFieldVisibleResult(
217228
- visible.visible(value, ctx)
217229
- );
217230
- } catch (error) {
217231
- params.env.logger.warn(
217232
- `visible '${visibleName}' failed for ${formatFieldLocator(node, "input", fieldName, fieldIndex)}: ${formatRuntimeError(error)}`
217233
- );
217234
- visibility.input[fieldIndex] = true;
218015
+ if (typeof resolution.visible === "boolean") {
218016
+ visibility.input[fieldIndex] = resolution.visible;
217235
218017
  }
217236
218018
  },
217237
218019
  onOutput: ({ fieldName, fieldIndex, visibleName, value, ctx }) => {
217238
218020
  if (!visibleName) {
217239
218021
  return;
217240
218022
  }
217241
- const visible = params.visibles.get(visibleName);
217242
- if (!visible) {
218023
+ const resolution = resolveNodeFieldVisible({
218024
+ visibleName,
218025
+ value,
218026
+ ctx,
218027
+ visibles: params.visibles
218028
+ });
218029
+ if (resolution.diagnostic) {
217243
218030
  params.env.logger.warn(
217244
- `visible '${visibleName}' is not registered for ${formatFieldLocator(node, "output", fieldName, fieldIndex)}`
218031
+ `${resolution.diagnostic.message} for ${formatFieldLocator(node, "output", fieldName, fieldIndex)}`
217245
218032
  );
217246
218033
  return;
217247
218034
  }
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;
218035
+ if (typeof resolution.visible === "boolean") {
218036
+ visibility.output[fieldIndex] = resolution.visible;
217257
218037
  }
217258
218038
  }
217259
218039
  });
@@ -217689,13 +218469,19 @@ var buildProjectWithContext = async (project, buildDir, context) => {
217689
218469
  path: b3path_default,
217690
218470
  workdir: context.workdir,
217691
218471
  nodeDefs: context.nodeDefs,
217692
- logger
218472
+ logger,
218473
+ allowNewFunction: settings.allowNewFunction ?? false
217693
218474
  };
217694
218475
  const buildRuntime = createBuildScriptRuntimeWithCheckModules(
217695
218476
  buildScriptModule,
217696
218477
  checkScriptModules,
217697
218478
  scriptEnv
217698
218479
  );
218480
+ const visibleRuntime = createNodeFieldVisibleRuntimeWithCheckModules(
218481
+ buildScriptModule,
218482
+ checkScriptModules,
218483
+ scriptEnv
218484
+ );
217699
218485
  if (buildSetting && (!buildScriptModule || buildRuntime.hasError)) {
217700
218486
  hasError = true;
217701
218487
  }
@@ -217741,7 +218527,8 @@ var buildProjectWithContext = async (project, buildDir, context) => {
217741
218527
  tree,
217742
218528
  treePath: candidatePath,
217743
218529
  env: scriptEnv,
217744
- checkers: buildRuntime.nodeFieldCheckers
218530
+ checkers: buildRuntime.nodeFieldCheckers,
218531
+ visibles: visibleRuntime.nodeFieldVisibles
217745
218532
  });
217746
218533
  if (checkDiagnostics.length) {
217747
218534
  hasError = true;
@@ -217774,6 +218561,7 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
217774
218561
  let writtenFiles = 0;
217775
218562
  const allErrors = [];
217776
218563
  const stagedWrites = [];
218564
+ const settings = readWorkspaceSettings(project);
217777
218565
  let buildScriptModule;
217778
218566
  try {
217779
218567
  buildScriptModule = await loadRuntimeModule(scriptPath, {
@@ -217787,7 +218575,8 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
217787
218575
  path: b3path_default,
217788
218576
  workdir: context.workdir,
217789
218577
  nodeDefs: context.nodeDefs,
217790
- logger
218578
+ logger,
218579
+ allowNewFunction: settings.allowNewFunction ?? false
217791
218580
  };
217792
218581
  const buildScript = createBatchHooks(buildScriptModule, scriptEnv);
217793
218582
  if (!buildScriptModule || !buildScript) {
@@ -218536,6 +219325,13 @@ var isValidInputOrOutput = (def, data, index) => {
218536
219325
  // src/project-path-discovery.ts
218537
219326
  var fs = __toESM(require("fs"));
218538
219327
  var path = __toESM(require("path"));
219328
+ var resolveExistingPath = (inputPath) => {
219329
+ const resolved = path.resolve(inputPath);
219330
+ if (!fs.existsSync(resolved)) {
219331
+ return resolved;
219332
+ }
219333
+ return fs.realpathSync.native(resolved);
219334
+ };
218539
219335
  var isWithinRoot = (rootDir, candidateDir) => {
218540
219336
  const relative7 = path.relative(rootDir, candidateDir);
218541
219337
  return relative7 === "" || !relative7.startsWith("..") && !path.isAbsolute(relative7);
@@ -218545,12 +219341,13 @@ var toSearchDirectory = (inputPath) => {
218545
219341
  if (!fs.existsSync(resolved)) {
218546
219342
  return path.extname(resolved) ? path.dirname(resolved) : resolved;
218547
219343
  }
218548
- const stat = fs.statSync(resolved);
218549
- return stat.isDirectory() ? resolved : path.dirname(resolved);
219344
+ const canonical = resolveExistingPath(resolved);
219345
+ const stat = fs.statSync(canonical);
219346
+ return stat.isDirectory() ? canonical : path.dirname(canonical);
218550
219347
  };
218551
219348
  var findNearestFileUpward = (searchFrom, suffix, rootDir) => {
218552
- let dir = path.resolve(searchFrom);
218553
- const boundary = rootDir ? path.resolve(rootDir) : void 0;
219349
+ let dir = resolveExistingPath(searchFrom);
219350
+ const boundary = rootDir ? resolveExistingPath(rootDir) : void 0;
218554
219351
  while (true) {
218555
219352
  if (boundary && !isWithinRoot(boundary, dir)) {
218556
219353
  break;
@@ -218559,7 +219356,7 @@ var findNearestFileUpward = (searchFrom, suffix, rootDir) => {
218559
219356
  const names = fs.readdirSync(dir);
218560
219357
  const hit = names.filter((name) => name.endsWith(suffix)).sort()[0];
218561
219358
  if (hit) {
218562
- return path.join(dir, hit);
219359
+ return resolveExistingPath(path.join(dir, hit));
218563
219360
  }
218564
219361
  } catch {
218565
219362
  }
@@ -218577,14 +219374,14 @@ var findNearestFileUpward = (searchFrom, suffix, rootDir) => {
218577
219374
  var findBehaviorWorkspaceFileSync = (searchPath, opts) => {
218578
219375
  const resolved = path.resolve(searchPath);
218579
219376
  if (resolved.endsWith(".b3-workspace") && fs.existsSync(resolved)) {
218580
- return resolved;
219377
+ return resolveExistingPath(resolved);
218581
219378
  }
218582
219379
  return findNearestFileUpward(toSearchDirectory(resolved), ".b3-workspace", opts?.rootDir);
218583
219380
  };
218584
219381
  var findBehaviorSettingFileSync = (searchPath, opts) => {
218585
219382
  const resolved = path.resolve(searchPath);
218586
219383
  if (resolved.endsWith(".b3-setting") && fs.existsSync(resolved)) {
218587
- return resolved;
219384
+ return resolveExistingPath(resolved);
218588
219385
  }
218589
219386
  return findNearestFileUpward(toSearchDirectory(resolved), ".b3-setting", opts?.rootDir);
218590
219387
  };
@@ -218592,6 +219389,25 @@ var findBehaviorSettingFileSync = (searchPath, opts) => {
218592
219389
  // src/build/build-cli.ts
218593
219390
  setFs(fs2);
218594
219391
  var normalizePosixPath = (filePath) => filePath.replace(/\\/g, "/");
219392
+ var resolveExistingPath2 = (filePath) => {
219393
+ const resolved = path2.resolve(filePath);
219394
+ if (!fs2.existsSync(resolved)) {
219395
+ return resolved;
219396
+ }
219397
+ return fs2.realpathSync.native(resolved);
219398
+ };
219399
+ async function withProcessCwd(cwd, run) {
219400
+ const previousCwd = process.cwd();
219401
+ if (previousCwd === cwd) {
219402
+ return run();
219403
+ }
219404
+ process.chdir(cwd);
219405
+ try {
219406
+ return await run();
219407
+ } finally {
219408
+ process.chdir(previousCwd);
219409
+ }
219410
+ }
218595
219411
  var ensureExistingFile = (filePath, suffix, label) => {
218596
219412
  const resolved = path2.resolve(filePath);
218597
219413
  if (!resolved.endsWith(suffix)) {
@@ -218600,7 +219416,7 @@ var ensureExistingFile = (filePath, suffix, label) => {
218600
219416
  if (!fs2.existsSync(resolved) || !fs2.statSync(resolved).isFile()) {
218601
219417
  throw new Error(`${label} does not exist: ${resolved}`);
218602
219418
  }
218603
- return resolved;
219419
+ return resolveExistingPath2(resolved);
218604
219420
  };
218605
219421
  var ensureExistingScriptFile = (filePath, label) => {
218606
219422
  const resolved = path2.resolve(filePath);
@@ -218611,7 +219427,7 @@ var ensureExistingScriptFile = (filePath, label) => {
218611
219427
  if (!fs2.existsSync(resolved) || !fs2.statSync(resolved).isFile()) {
218612
219428
  throw new Error(`${label} does not exist: ${resolved}`);
218613
219429
  }
218614
- return resolved;
219430
+ return resolveExistingPath2(resolved);
218615
219431
  };
218616
219432
  var resolveBehaviorProjectPaths = (options) => {
218617
219433
  const projectPath = path2.resolve(options.projectPath ?? process.cwd());
@@ -218659,10 +219475,13 @@ var buildBehaviorProject = async (options) => {
218659
219475
  alertError: () => {
218660
219476
  }
218661
219477
  });
218662
- const hasError = await buildProjectWithContext(
218663
- normalizePosixPath(paths.workspaceFile),
218664
- normalizePosixPath(paths.outputDir),
218665
- buildContext
219478
+ const hasError = await withProcessCwd(
219479
+ paths.workdir,
219480
+ async () => buildProjectWithContext(
219481
+ normalizePosixPath(paths.workspaceFile),
219482
+ normalizePosixPath(paths.outputDir),
219483
+ buildContext
219484
+ )
218666
219485
  );
218667
219486
  return {
218668
219487
  hasError,
@@ -219710,11 +220529,34 @@ async function resolveB3SettingFilePath(workspaceFolder, documentUri) {
219710
220529
  }
219711
220530
  return void 0;
219712
220531
  }
219713
- async function resolveNodeDefs(workspaceFolder, documentUri) {
219714
- const filePath = await resolveB3SettingFilePath(workspaceFolder, documentUri);
219715
- if (!filePath) {
219716
- return [];
219717
- }
220532
+ async function resolveB3WorkspaceFilePath(workspaceFolder, documentUri) {
220533
+ if (documentUri) {
220534
+ const wf = vscode7.workspace.getWorkspaceFolder(documentUri);
220535
+ const foundFs = findB3WorkspacePath(documentUri, wf?.uri ?? workspaceFolder);
220536
+ if (foundFs) {
220537
+ try {
220538
+ await vscode7.workspace.fs.stat(vscode7.Uri.file(foundFs));
220539
+ return foundFs;
220540
+ } catch {
220541
+ }
220542
+ }
220543
+ }
220544
+ const pattern = new vscode7.RelativePattern(workspaceFolder.fsPath, "*.b3-workspace");
220545
+ const found = await vscode7.workspace.findFiles(pattern, null, 1);
220546
+ if (found.length > 0) {
220547
+ try {
220548
+ await vscode7.workspace.fs.stat(found[0]);
220549
+ return found[0].fsPath;
220550
+ } catch {
220551
+ }
220552
+ }
220553
+ return void 0;
220554
+ }
220555
+ async function resolveNodeDefs(workspaceFolder, documentUri) {
220556
+ const filePath = await resolveB3SettingFilePath(workspaceFolder, documentUri);
220557
+ if (!filePath) {
220558
+ return [];
220559
+ }
219718
220560
  try {
219719
220561
  const raw = await vscode7.workspace.fs.readFile(vscode7.Uri.file(filePath));
219720
220562
  const text = Buffer.from(raw).toString("utf-8");
@@ -219724,23 +220566,19 @@ async function resolveNodeDefs(workspaceFolder, documentUri) {
219724
220566
  return [];
219725
220567
  }
219726
220568
  }
219727
- async function resolveWorkspaceNodeColors(workspaceFolder, documentUri) {
219728
- let wfPath;
219729
- if (documentUri) {
219730
- const wf = vscode7.workspace.getWorkspaceFolder(documentUri);
219731
- wfPath = findB3WorkspacePath(documentUri, wf?.uri ?? workspaceFolder);
219732
- }
220569
+ async function resolveWorkspaceFileSettings(workspaceFolder, documentUri) {
220570
+ const wfPath = await resolveB3WorkspaceFilePath(workspaceFolder, documentUri);
219733
220571
  if (!wfPath) {
219734
- const pattern = new vscode7.RelativePattern(workspaceFolder.fsPath, "*.b3-workspace");
219735
- const found = await vscode7.workspace.findFiles(pattern, null, 1);
219736
- if (found.length > 0) wfPath = found[0].fsPath;
220572
+ return void 0;
219737
220573
  }
219738
- if (!wfPath) return void 0;
219739
220574
  try {
219740
220575
  const raw = await vscode7.workspace.fs.readFile(vscode7.Uri.file(wfPath));
219741
220576
  const data = parseWorkspaceModelContent(Buffer.from(raw).toString("utf-8"));
219742
- const nc = data.settings.nodeColors;
219743
- return nc && Object.keys(nc).length > 0 ? nc : void 0;
220577
+ const nodeColors = data.settings.nodeColors;
220578
+ return {
220579
+ allowNewFunction: data.settings.allowNewFunction,
220580
+ nodeColors: nodeColors && Object.keys(nodeColors).length > 0 ? nodeColors : void 0
220581
+ };
219744
220582
  } catch {
219745
220583
  return void 0;
219746
220584
  }
@@ -219894,941 +220732,510 @@ var ProjectIndex = class {
219894
220732
  return void 0;
219895
220733
  }
219896
220734
  const relativePath = path7.relative(this.workdir.fsPath, uri.fsPath).replace(/\\/g, "/");
219897
- if (relativePath.startsWith("..") || path7.isAbsolute(relativePath)) {
219898
- return void 0;
219899
- }
219900
- return parseWorkdirRelativeJsonPath(relativePath) ?? void 0;
219901
- }
219902
- async readWorkspaceFileContent(fileUri) {
219903
- const openDocument = vscode8.workspace.textDocuments.find(
219904
- (document) => isSameUri(document.uri, fileUri)
219905
- );
219906
- if (openDocument) {
219907
- return openDocument.getText();
219908
- }
219909
- const raw = await vscode8.workspace.fs.readFile(fileUri);
219910
- return Buffer.from(raw).toString("utf-8");
219911
- }
219912
- async readTreeFile(relativePath) {
219913
- const normalizedPath = parseWorkdirRelativeJsonPath(relativePath);
219914
- if (!normalizedPath) {
219915
- return null;
219916
- }
219917
- const fileUri = vscode8.Uri.joinPath(this.workdir, normalizedPath);
219918
- const content = await this.readWorkspaceFileContent(fileUri).catch(() => null);
219919
- if (content === null) {
219920
- this.treeCache.set(normalizedPath, {
219921
- content: "",
219922
- tree: null
219923
- });
219924
- return null;
219925
- }
219926
- const cached = this.treeCache.get(normalizedPath);
219927
- if (cached && cached.content === content) {
219928
- return cached.tree;
219929
- }
219930
- try {
219931
- const tree = parsePersistedTreeContent(content, normalizedPath);
219932
- this.treeCache.set(normalizedPath, {
219933
- content,
219934
- tree
219935
- });
219936
- return tree;
219937
- } catch {
219938
- this.treeCache.set(normalizedPath, {
219939
- content,
219940
- tree: null
219941
- });
219942
- return null;
219943
- }
219944
- }
219945
- getLocalVarsFromTree(relativePath) {
219946
- const normalizedPath = parseWorkdirRelativeJsonPath(relativePath);
219947
- if (!normalizedPath) {
219948
- return [];
219949
- }
219950
- const tree = this.treeCache.get(normalizedPath)?.tree;
219951
- if (!tree) {
219952
- return [];
219953
- }
219954
- return tree.variables.locals.filter((entry) => entry.name).map((entry) => ({ name: entry.name, desc: entry.desc ?? "" }));
219955
- }
219956
- async readVarsFromFile(relativePath, visitedForGlobal, globalVars) {
219957
- const localVars = [];
219958
- const parsedPath = parseWorkdirRelativeJsonPath(relativePath);
219959
- if (!parsedPath) {
219960
- return localVars;
219961
- }
219962
- const normalizedPath = parsedPath;
219963
- if (visitedForGlobal.has(normalizedPath)) {
219964
- return localVars;
219965
- }
219966
- visitedForGlobal.add(normalizedPath);
219967
- const tree = await this.readTreeFile(normalizedPath);
219968
- if (!tree) {
219969
- return localVars;
219970
- }
219971
- for (const entry of tree.variables.locals) {
219972
- if (!entry.name) {
219973
- continue;
219974
- }
219975
- const variable = { name: entry.name, desc: entry.desc ?? "" };
219976
- localVars.push(variable);
219977
- if (!globalVars[entry.name]) {
219978
- globalVars[entry.name] = variable;
219979
- }
219980
- }
219981
- for (const importPath of tree.variables.imports) {
219982
- await this.readVarsFromFile(importPath, visitedForGlobal, globalVars);
219983
- }
219984
- for (const subtreePath of collectSubtreePaths2(tree.root)) {
219985
- await this.readVarsFromFile(subtreePath, visitedForGlobal, globalVars);
219986
- }
219987
- return localVars;
219988
- }
219989
- async collectOrderedTransitiveImportPaths(seedImports) {
219990
- return collectTransitivePaths(normalizePathList(seedImports), async (relativePath) => {
219991
- const tree = await this.readTreeFile(relativePath);
219992
- return normalizePathList(tree?.variables.imports ?? []);
219993
- });
219994
- }
219995
- async collectOrderedTransitiveSubtreePaths(root) {
219996
- return collectTransitivePaths(
219997
- normalizePathList(collectSubtreePaths2(root)),
219998
- async (relativePath) => {
219999
- const tree = await this.readTreeFile(relativePath);
220000
- return tree?.root ? normalizePathList(collectSubtreePaths2(tree.root)) : [];
220001
- }
220002
- );
220003
- }
220004
- };
220005
-
220006
- // src/editor-session/settings/live-settings.ts
220007
- var vscode10 = __toESM(require("vscode"));
220008
-
220009
- // src/editor-session/settings/editor-settings.ts
220010
- var vscode9 = __toESM(require("vscode"));
220011
- function getEditorLanguage(setting) {
220012
- if (setting === "zh" || setting === "en") {
220013
- return setting;
220014
- }
220015
- const envLanguage = vscode9.env.language.toLowerCase();
220016
- return envLanguage.startsWith("zh") ? "zh" : "en";
220017
- }
220018
- function getVSCodeTheme() {
220019
- const kind = vscode9.window.activeColorTheme.kind;
220020
- return kind === vscode9.ColorThemeKind.Light || kind === vscode9.ColorThemeKind.HighContrastLight ? "light" : "dark";
220021
- }
220022
-
220023
- // src/editor-session/settings/live-settings.ts
220024
- function createLiveSettingsResolver(workspaceFolderUri, documentUri) {
220025
- return async () => {
220026
- const config = vscode10.workspace.getConfiguration("behavior3");
220027
- return {
220028
- checkExpr: config.get("checkExpr", true),
220029
- subtreeEditable: config.get("subtreeEditable", true),
220030
- language: getEditorLanguage(config.get("language", "auto")),
220031
- inspectorMode: config.get("inspectorMode", "sidebar"),
220032
- nodeColors: await resolveWorkspaceNodeColors(workspaceFolderUri, documentUri)
220033
- };
220034
- };
220035
- }
220036
-
220037
- // src/editor-session/session/context.ts
220038
- async function createTreeEditorSessionContext(params) {
220039
- const workspaceFolderUri = getWorkdir(params.document.uri);
220040
- const projectRootUri = vscode11.Uri.file(
220041
- getBehaviorProjectRootFsPath(params.document.uri, workspaceFolderUri)
220042
- );
220043
- const projectIndex = new ProjectIndex(projectRootUri);
220044
- const resolveLiveSettings = createLiveSettingsResolver(
220045
- workspaceFolderUri,
220046
- params.document.uri
220047
- );
220048
- const [nodeDefs, settingDir, currentSettings] = await Promise.all([
220049
- resolveNodeDefs(workspaceFolderUri, params.document.uri),
220050
- getResolvedB3SettingDir(workspaceFolderUri, params.document.uri),
220051
- resolveLiveSettings()
220052
- ]);
220053
- const state = {
220054
- nodeDefs,
220055
- settingDir,
220056
- currentSettings,
220057
- fileVersionIsNewer: false,
220058
- newerFileVersion: null,
220059
- cachedSubtreeRefs: null,
220060
- latestAllFiles: [],
220061
- latestVarDecls: {
220062
- usingVars: {},
220063
- importDecls: [],
220064
- subtreeDecls: []
220065
- },
220066
- sharedSelection: normalizeHostSelectionState(params.initialSelection),
220067
- selectionRevision: 0,
220068
- inspectorContentSyncKind: "reload"
220069
- };
220070
- const documentSession = params.document.sessionState;
220071
- const buildDocumentSessionMessage = () => documentSession.getSnapshot();
220072
- params.configureWebview(params.webviewPanel.webview, workspaceFolderUri);
220073
- const postMessage = (message) => params.webviewPanel.webview.postMessage(message);
220074
- const mapDefsForWebview = (defs = state.nodeDefs) => mapNodeDefsIconsForWebview(
220075
- params.webviewPanel.webview,
220076
- workspaceFolderUri,
220077
- state.settingDir,
220078
- defs
220079
- );
220080
- return {
220081
- ...params,
220082
- workspaceFolderUri,
220083
- projectRootUri,
220084
- projectIndex,
220085
- state,
220086
- documentSession,
220087
- resolveLiveSettings,
220088
- postMessage,
220089
- mapDefsForWebview,
220090
- buildDocumentSessionMessage,
220091
- enqueueMainDocumentOperation: createSerialOperationQueue()
220092
- };
220093
- }
220094
-
220095
- // src/editor-session/session/document-lifecycle.ts
220096
- var vscode12 = __toESM(require("vscode"));
220097
- function createSessionDocumentLifecycle(context, inspectorSync, subtreeTracking, fileVersionGuard) {
220098
- const {
220099
- document,
220100
- revertDocument,
220101
- onDidChangeDocument,
220102
- state,
220103
- documentSession,
220104
- postMessage,
220105
- buildDocumentSessionMessage,
220106
- enqueueMainDocumentOperation
220107
- } = context;
220108
- const { fanoutDocumentSnapshot } = inspectorSync;
220109
- const { invalidateSubtreeRefs, refreshTrackedSubtreeRefs } = subtreeTracking;
220110
- const { updateFileVersionState, blockEditingForNewerFile } = fileVersionGuard;
220111
- const applySessionHistorySnapshot = async (snapshot) => {
220112
- const sessionSnapshot = buildDocumentSessionMessage();
220113
- const changed = document.syncContentState(snapshot, sessionSnapshot.dirty);
220114
- if (!changed) {
220115
- return false;
220116
- }
220117
- state.inspectorContentSyncKind = "update";
220118
- invalidateSubtreeRefs();
220119
- void refreshTrackedSubtreeRefs();
220120
- updateFileVersionState(snapshot);
220121
- onDidChangeDocument(document);
220122
- await fanoutDocumentSnapshot({
220123
- syncKind: "update"
220124
- });
220125
- return true;
220126
- };
220127
- const handleSaveDocumentMessage = async (msg, reply = postMessage) => {
220128
- await enqueueMainDocumentOperation(async () => {
220129
- const editBlockedMessage = blockEditingForNewerFile();
220130
- if (editBlockedMessage) {
220131
- await reply({
220132
- type: "saveDocumentResult",
220133
- requestId: msg.requestId,
220134
- success: false,
220135
- error: editBlockedMessage
220136
- });
220137
- return;
220138
- }
220139
- try {
220140
- if (document.isDirty) {
220141
- await vscode12.workspace.save(document.uri);
220142
- }
220143
- const success = !document.isDirty;
220144
- if (!success) {
220145
- getBehavior3OutputChannel().warn(
220146
- `[saveDocument] save failed for ${document.uri.fsPath}; isDirty=${document.isDirty}`
220147
- );
220148
- }
220149
- await reply({
220150
- type: "saveDocumentResult",
220151
- requestId: msg.requestId,
220152
- success,
220153
- error: success ? void 0 : "Failed to save document"
220154
- });
220155
- if (success) {
220156
- state.inspectorContentSyncKind = "reload";
220157
- }
220158
- } catch (error) {
220159
- getBehavior3OutputChannel().error(
220160
- `[saveDocument] exception for ${document.uri.fsPath}: ${String(error)}`
220161
- );
220162
- await reply({
220163
- type: "saveDocumentResult",
220164
- requestId: msg.requestId,
220165
- success: false,
220166
- error: String(error)
220167
- });
220168
- }
220169
- });
220170
- };
220171
- const handleHistoryNavigationMessage = async (direction) => {
220172
- await enqueueMainDocumentOperation(async () => {
220173
- const editBlockedMessage = blockEditingForNewerFile();
220174
- if (editBlockedMessage) {
220175
- return;
220176
- }
220177
- const snapshot = direction === "undo" ? documentSession.undo() : documentSession.redo();
220178
- if (!snapshot) {
220179
- return;
220180
- }
220181
- await applySessionHistorySnapshot(snapshot);
220182
- });
220183
- };
220184
- const handleRevertDocumentMessage = async (msg, reply = postMessage) => {
220185
- await enqueueMainDocumentOperation(async () => {
220186
- const cancellation = new vscode12.CancellationTokenSource();
220187
- try {
220188
- await revertDocument(document, cancellation.token);
220189
- state.inspectorContentSyncKind = "reload";
220190
- await reply({
220191
- type: "revertDocumentResult",
220192
- requestId: msg.requestId,
220193
- success: true
220194
- });
220195
- } catch (error) {
220196
- await reply({
220197
- type: "revertDocumentResult",
220198
- requestId: msg.requestId,
220199
- success: false,
220200
- error: String(error)
220201
- });
220202
- } finally {
220203
- cancellation.dispose();
220204
- }
220205
- });
220206
- };
220207
- const handleMainDocumentFileChange = async () => {
220208
- await enqueueMainDocumentOperation(async () => {
220209
- let content;
220210
- try {
220211
- content = await readFileContentFromDisk(document.uri);
220212
- } catch {
220213
- return;
220214
- }
220215
- invalidateSubtreeRefs();
220216
- if (document.consumeOwnWrite(content)) {
220217
- return;
220218
- }
220219
- if (document.content === content) {
220220
- return;
220221
- }
220222
- if (!document.isDirty) {
220223
- document.updateContent(content, { markSaved: true, markDirty: false });
220224
- documentSession.replaceFromDisk(content);
220225
- state.inspectorContentSyncKind = "reload";
220226
- void refreshTrackedSubtreeRefs();
220227
- updateFileVersionState(content, { showWarning: true });
220228
- await fanoutDocumentSnapshot({
220229
- syncKind: "reload"
220230
- });
220231
- return;
220232
- }
220233
- documentSession.showReloadConflict(content);
220234
- await fanoutDocumentSnapshot({
220235
- syncKind: "update",
220236
- refreshVars: false
220237
- });
220238
- });
220239
- };
220240
- return {
220241
- handleSaveDocumentMessage,
220242
- handleHistoryNavigationMessage,
220243
- handleRevertDocumentMessage,
220244
- handleMainDocumentFileChange
220245
- };
220246
- }
220247
-
220248
- // src/editor-session/document/subtree-overrides.ts
220249
- var path8 = __toESM(require("path"));
220250
- var vscode13 = __toESM(require("vscode"));
220251
- function branchContainsSubtreeLink(node) {
220252
- if (!node) {
220253
- return false;
220254
- }
220255
- let found = false;
220256
- walkPersistedNodes(node, (entry) => {
220257
- if (entry.path) {
220258
- found = true;
220259
- }
220260
- });
220261
- return found;
220262
- }
220263
- async function normalizeReachableSubtreeOverrides(params) {
220264
- if (Object.keys(params.tree.overrides).length === 0) {
220265
- return;
220266
- }
220267
- const subtreeSources = await loadSubtreeSourceCache({
220268
- root: params.tree.root,
220269
- readContent: async (relativePath) => {
220270
- const subtreeUri = vscode13.Uri.file(path8.join(params.projectRootFsPath, relativePath));
220271
- try {
220272
- return await params.readWorkspaceFileContent(subtreeUri);
220273
- } catch {
220274
- return null;
220275
- }
220276
- }
220277
- });
220278
- pruneStaleSubtreeOverrides({
220279
- tree: params.tree,
220280
- subtreeSources
220281
- });
220282
- }
220283
- function mutationMayAffectSubtreeOverrideReachability(mutation, currentTree) {
220284
- switch (mutation.type) {
220285
- case "updateNode": {
220286
- if (mutation.payload.currentNodeSnapshot?.subtreeNode) {
220287
- return false;
220288
- }
220289
- const currentNode = findPersistedNodeByStableId(
220290
- currentTree.root,
220291
- mutation.payload.target.structuralStableId
220292
- ) ?? mutation.payload.currentNodeSnapshot?.data;
220293
- if (!currentNode) {
220294
- return false;
220295
- }
220296
- const currentPath = currentNode.path;
220297
- const nextPath = mutation.payload.data.path?.trim() || void 0;
220298
- return currentPath !== nextPath;
220299
- }
220300
- case "replaceNode": {
220301
- const currentNode = findPersistedNodeByStableId(
220302
- currentTree.root,
220303
- mutation.payload.target.structuralStableId
220304
- );
220305
- return branchContainsSubtreeLink(currentNode) || branchContainsSubtreeLink(mutation.payload.snapshot);
220306
- }
220307
- case "deleteNode": {
220308
- const currentNode = findPersistedNodeByStableId(
220309
- currentTree.root,
220310
- mutation.payload.target.structuralStableId
220311
- );
220312
- return branchContainsSubtreeLink(currentNode);
220313
- }
220314
- default:
220315
- return false;
220316
- }
220317
- }
220318
-
220319
- // src/editor-session/session/selection-state.ts
220320
- var buildPendingSelectionRef = (structuralStableId) => ({
220321
- instanceKey: structuralStableId,
220322
- displayId: "",
220323
- structuralStableId,
220324
- sourceStableId: structuralStableId,
220325
- sourceTreePath: null,
220326
- subtreeStack: []
220327
- });
220328
- var applySharedSelectionState = (currentSelection, nextSelection, opts) => {
220329
- const normalized = normalizeHostSelectionState(nextSelection);
220330
- if (isJsonEqual(currentSelection, normalized)) {
220331
- return {
220332
- selection: currentSelection,
220333
- result: opts?.reassertIfEqual ? "reasserted" : "noop"
220334
- };
220335
- }
220336
- return {
220337
- selection: normalized,
220338
- result: "changed"
220339
- };
220340
- };
220341
-
220342
- // src/editor-session/session/messages.ts
220343
- function buildVarDeclLoadedMessage(result, allFiles) {
220344
- return {
220345
- type: "varDeclLoaded",
220346
- usingVars: Object.values(result.usingVars),
220347
- allFiles,
220348
- importDecls: result.importDecls,
220349
- subtreeDecls: result.subtreeDecls
220350
- };
220351
- }
220352
- function buildDocumentSnapshotChangedMessage(params) {
220353
- return {
220354
- type: "documentSnapshotChanged",
220355
- snapshot: {
220356
- content: params.content,
220357
- documentSession: params.documentSession,
220358
- selection: params.selection,
220359
- syncKind: params.syncKind
220360
- }
220361
- };
220362
- }
220363
- function buildHostSelectionFromMutationSelection(selection) {
220364
- return selection.kind === "tree" ? { kind: "tree" } : {
220365
- kind: "node",
220366
- ref: buildPendingSelectionRef(selection.structuralStableId)
220367
- };
220368
- }
220369
- function buildInitMessage(params) {
220370
- return {
220371
- type: "init",
220372
- content: params.content,
220373
- filePath: params.filePath,
220374
- workdir: params.workdir,
220375
- nodeDefs: params.nodeDefs,
220376
- checkExpr: params.settings.checkExpr,
220377
- subtreeEditable: params.settings.subtreeEditable,
220378
- language: params.settings.language,
220379
- theme: params.theme,
220380
- inspectorMode: params.settings.inspectorMode,
220381
- allFiles: params.allFiles,
220382
- nodeColors: params.settings.nodeColors,
220383
- documentSession: params.documentSession,
220384
- selection: params.selection
220385
- };
220386
- }
220387
-
220388
- // webview/shared/node-overrides.ts
220389
- var hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
220390
- var getNodeArgOverrideCompareValue = (args, arg) => {
220391
- if (args && hasOwn(args, arg.name)) {
220392
- return args[arg.name];
220393
- }
220394
- return arg.default;
220395
- };
220396
-
220397
- // media/locales/en.json
220398
- var en_default = {
220399
- about: "About Behavior3",
220400
- actuaSize: "Actual Size",
220401
- actualSize: "Actual Size",
220402
- add: "Add",
220403
- alertNewVersion: "This file is created by a newer version of Behavior3({{version}}), please upgrade to the latest version.",
220404
- batch: "Batch Script",
220405
- batchCompleted: "Batch completed",
220406
- batchFailed: "Batch failed, more information can be found in the console.",
220407
- build: "Build",
220408
- buildCompleted: "Build completed",
220409
- buildFailed: "Build failed, more information can be found in the console.",
220410
- cancel: "Cancel",
220411
- compact: "Compact",
220412
- console: "Console",
220413
- copy: "Copy",
220414
- createProject: "Create Project",
220415
- checkExpr: "Check expression",
220416
- cut: "Cut",
220417
- delete: "Delete",
220418
- deleteNode: "Delete Node",
220419
- devTools: "Toggle Developer Tools",
220420
- donotSave: "Don't Save",
220421
- duplicate: "Duplicate",
220422
- editSubtree: "Edit Subtree",
220423
- fieldRequired: "Field '{{field}}' is required",
220424
- forceReload: "Force Reload",
220425
- fullscreen: "Toggle Full Screen",
220426
- hide: "Hide Behavior3",
220427
- hideOthers: "Hide Others",
220428
- insertNode: "Insert Node",
220429
- jumpNode: "Jump Node",
220430
- language: "Language",
220431
- moveToTrash: "Move to Trash",
220432
- newFile: "New File...",
220433
- newFolder: "New Folder...",
220434
- newWindow: "New Window",
220435
- nodeDefinition: "NODES",
220436
- normal: "Normal",
220437
- open: "Open...",
220438
- openProject: "Open Project",
220439
- paste: "Paste",
220440
- quit: "Quit Behavior3",
220441
- recent: "Recent",
220442
- redo: "Redo",
220443
- reload: "Reload",
220444
- reset: "Reset",
220445
- "reset.confirm": "Reset to original value?",
220446
- "reset.defaultConfirm": "Reset to default value?",
220447
- rename: "Rename...",
220448
- replace: "Replace",
220449
- reportIssue: "Report Issue",
220450
- revealFileOnMac: "Reveal in Finder",
220451
- revealFileOnWindows: "Reveal in File Explorer",
220452
- save: "Save",
220453
- saveAll: "Save All",
220454
- saveAs: "Save As...",
220455
- saveAsSubtree: "Save As Subtree",
220456
- searchFile: "Search File",
220457
- searchNode: "Search Node",
220458
- selectAll: "Select All",
220459
- services: "Services",
220460
- setupBuildScript: "Setup Build Script",
220461
- start: "Start",
220462
- undo: "Undo",
220463
- unhide: "Show All",
220464
- zoomIn: "Zoom In",
220465
- zoomOut: "Zoom Out",
220466
- "menu.edit": "Edit",
220467
- "menu.file": "File",
220468
- "menu.view": "View",
220469
- "menu.window": "Window",
220470
- "menu.help": "Help",
220471
- "workspace.saveAllOnClose": "Do you want to save the changes to the following {{count}} files?",
220472
- "workspace.saveOnClose": "Do you want to save the changes you made to '{{name}}'?",
220473
- "workspace.reloadFile": "'{{name}}' has changed, do you want to reload now?",
220474
- "explorer.deleteFile": "Are you sure you want delete '{{name}}'?",
220475
- "explorer.deleteFolder": "Are you sure you want delete '{{name}}' and its contents?",
220476
- "explorer.replaceFile": "Are you sure you want replace '{{name}}'?",
220477
- "explorer.restoreFileInfo": "You can restore this file from the Trash.",
220478
- "explorer.title": "Explorer",
220479
- "tree.overview": "Overview",
220480
- "tree.name": "Tree name",
220481
- "tree.desc": "Tree desc",
220482
- "tree.export": "Export",
220483
- "tree.prefix": "ID prefix",
220484
- "tree.group": "Enable Node Grouping",
220485
- "tree.group.placeholder": "Select node groups",
220486
- "tree.vars": "Define Variables",
220487
- "tree.vars.local": "Local Variables",
220488
- "tree.vars.add": "Add Variable",
220489
- "tree.vars.name": "name",
220490
- "tree.vars.invalidName": "Invalid variable name",
220491
- "tree.vars.desc": "description",
220492
- "tree.vars.imports": "Import Variables",
220493
- "tree.vars.subtree": "Subtree Variables",
220494
- "tree.import.add": "Add Import",
220495
- "tree.custom": "Custom Data",
220496
- "tree.custom.add": "Add Entry",
220497
- "tree.custom.key": "key",
220498
- "tree.custom.value": "value",
220499
- "tree.custom.type.string": "String value",
220500
- "tree.custom.type.number": "Number value",
220501
- "tree.custom.type.boolean": "Boolean value",
220502
- "tree.custom.type.invalid": "Invalid custom value",
220503
- "regnode.input": "Input: ",
220504
- "regnode.output": "Output: ",
220505
- "regnode.args": "Args: ",
220506
- "regnode.mark": "Mark: ",
220507
- "regnode.subtree": "Subtree: ",
220508
- "node.args": "Const arguments",
220509
- "node.children.unlimited": "Unlimited",
220510
- "node.children": "Num children",
220511
- "node.debug": "Debug",
220512
- "node.deleteRootNodeDenied": "Unable to delete the root node",
220513
- "node.dropDenied": "This node position is denied to drop the node",
220514
- "node.desc": "Node desc",
220515
- "node.disabled": "Disabled",
220516
- "node.editSubtreeDenied": "Unable to edit the subtree node",
220517
- "node.editFailed": "Node '{{name}}' edit failed",
220518
- "node.group": "Node group",
220519
- "node.groupNotEnabled": "One of '{{group}}' node group is not enabled in current file",
220520
- "node.id": "Node id",
220521
- "node.inputVariable": "Input variables",
220522
- "node.invalidChildren": "Invalid number of children",
220523
- "node.invalidExpression": "Invalid expression",
220524
- "node.invalidValue": "Invalid value",
220525
- "node.invalidVariableName": "Invalid variable name, should start with a letter or underscore",
220526
- "node.name": "Node name",
220527
- "node.noNodeSelected": "No node selected",
220528
- "node.notFound": "Node '{{name}}' not found",
220529
- "node.oneof.error": "Only one is allowed between input '{{input}}' and argument '{{desc}}({{arg}})'",
220530
- "node.oneof.inputNotfound": "Input '{{input}}' not found",
220531
- "node.outputVariable": "Output variables",
220532
- "node.pasteDataError": "Paste data error",
220533
- "node.rootNodeAsSubtree": "Root node cann't be save as subtree",
220534
- "node.subtree": "Subtree",
220535
- "node.subtreeMissing": "Subtree file is missing: {{path}}",
220536
- "node.subtreeInvalid": "Subtree file is invalid: {{path}}",
220537
- "node.subtreeCyclic": "Subtree reference is cyclic: {{path}}",
220538
- "node.subtreeOpenFailed": "Failed to open subtree: file not found or unreadable ({{path}})",
220539
- "node.subtreePathError": "You should save the subtree inside the current workspace",
220540
- "node.subtreeSaveRootError": "Root node cann't be save as subtree",
220541
- "node.subtreeSaveSuccess": "Saved and converted to subtree node: {{path}}",
220542
- "node.moveSubtreeDenied": "Cannot move nodes inside a subtree",
220543
- "node.dropSubtreeInternalDenied": "Cannot drop onto a subtree internal node",
220544
- "node.moveRootDenied": "Cannot move the root node",
220545
- "node.dropAroundRootDenied": "Cannot place a node before or after the root",
220546
- "node.addChildToSubtreeRefDenied": "Cannot add child nodes to a subtree reference",
220547
- "node.moveIntoDescendantDenied": "Cannot move a node into its own descendant",
220548
- "node.type": "Node type",
220549
- "node.undefinedVariable": "Variable '{{variable}}' is not defined",
220550
- "node.jsonData": "JSON Data",
220551
- "node.unknown.title": "Unknown Node",
220552
- "node.unknownType": "Unknown",
220553
- "node.resolutionError": "Resolution Error",
220554
- "node.unknown.desc": "New node",
220555
- "build.success": "Build completed.",
220556
- "build.failed": "Build failed.",
220557
- "editor.loading": "Loading editor...",
220558
- "editor.externalChangeConflict": "External file change detected while the document has unsaved edits.",
220559
- "editor.reloadFromDisk": "Reload",
220560
- "editor.dismissConflict": "Dismiss",
220561
- "editor.newerVersionEditDenied": "This file is created by a newer version of Behavior3({{version}}). Please upgrade to the latest version.",
220562
- "inspector.noActiveDocument": "Open a Behavior3 editor to inspect and edit the active tree.",
220563
- "inspector.embeddedModeNotice": "Inspector is configured to appear inside the Behavior3 editor.",
220564
- "inspector.embeddedToolbar.build": "Build Behavior Tree",
220565
- "inspector.embeddedToolbar.toggleEditorMode": "Toggle Editor Mode",
220566
- "inspector.embeddedToolbar.toggleInspectorNodeJson": "Toggle Raw Node JSON",
220567
- "inspector.embeddedToolbar.createProject": "Create Project",
220568
- "inspector.embeddedToolbar.createTree": "Create Behavior Tree",
220569
- "mutation.invalidJsonPath": "Invalid JSON path: {{path}}",
220570
- "mutation.missingSelectedNode": "No selected node is available for this mutation.",
220571
- "mutation.selectedNodeMismatch": "The selected node changed before the mutation was applied.",
220572
- "mutation.missingTargetNode": "The target node could not be found.",
220573
- "mutation.missingSourceNode": "The source node could not be found.",
220574
- "mutation.missingSubtreeOriginal": "Missing subtree original snapshot for this mutation.",
220575
- "mutation.missingDetachedSubtreeRoot": "Missing detached subtree snapshot for this mutation.",
220576
- "mutation.moveRootDenied": "Cannot move the root node.",
220577
- "mutation.dropAroundRootDenied": "Cannot drop before or after the root node.",
220578
- "mutation.addChildToSubtreeRefDenied": "Cannot add a child directly to a subtree reference.",
220579
- "mutation.moveIntoDescendantDenied": "Cannot move a node into its own descendant.",
220580
- "mutation.deleteRootNodeDenied": "Cannot delete the root node.",
220581
- "mutation.editSubtreeDenied": "Cannot edit structure on a subtree reference.",
220582
- "mutation.saveSelectedAsSubtreeRootDenied": "The root node cannot be saved as a subtree.",
220583
- "mutation.saveSelectedAsSubtreeMissingTarget": "The target node could not be saved as a subtree.",
220584
- "mutation.saveSelectedAsSubtreePostSaveMissingTarget": "The target node could not be found after saving the subtree.",
220585
- "runtime.nodeCheckRuntimeHasErrors": "Checker runtime has errors.",
220586
- "runtime.invalidSavedSubtreePath": "Host returned an invalid saved subtree path.",
220587
- "runtime.unsupportedDocumentMutation": "Unsupported document mutation.",
220588
- "override.resetTitle": "Reset this override?",
220589
- "form.enterJsonArray": "Enter JSON array",
220590
- "form.enterJsonValue": "Enter JSON value",
220591
- "form.unset": "Unset",
220592
- "form.true": "True",
220593
- "form.false": "False",
220594
- "validation.jsonArray": "{{name}} must be a JSON array",
220595
- "validation.integer": "{{field}} must be an integer",
220596
- "validation.number": "{{field}} must be a number",
220597
- "validation.missingOneofInput": "Missing input slot for oneof '{{input}}'",
220598
- "validation.oneof": "Only one of '{{left}}' and '{{right}}' can be set",
220599
- "validation.invalidJsonPath": "Path must be a workdir-relative .json file: {{path}}",
220600
- "validation.variableDescriptionRequired": "Variable description is required",
220601
- "validation.customKeyRequired": "Custom key is required",
220602
- "validation.customKeyDuplicate": "Custom key '{{key}}' is duplicated",
220603
- "validation.customValueInvalid": "Custom value must be a string, number, or boolean"
220604
- };
220605
-
220606
- // media/locales/zh.json
220607
- var zh_default = {
220608
- about: "\u5173\u4E8E Behavior3",
220609
- actualSize: "\u5B9E\u9645\u5927\u5C0F",
220610
- add: "\u6DFB\u52A0",
220611
- alertNewVersion: "\u6B64\u6587\u4EF6\u7531\u65B0\u7248\u672C Behavior3({{version}}) \u521B\u5EFA\uFF0C\u8BF7\u5347\u7EA7\u5230\u6700\u65B0\u7248\u672C\u3002",
220612
- batch: "\u6279\u5904\u7406\u811A\u672C",
220613
- batchCompleted: "\u6279\u5904\u7406\u5B8C\u6210",
220614
- batchFailed: "\u6279\u5904\u7406\u51FA\u73B0\u9519\u8BEF\uFF0C\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A7\u5236\u53F0\uFF01",
220615
- build: "\u6784\u5EFA",
220616
- buildCompleted: "\u6784\u5EFA\u5B8C\u6210",
220617
- buildFailed: "\u6784\u5EFA\u51FA\u73B0\u9519\u8BEF\uFF0C\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A7\u5236\u53F0\uFF01",
220618
- cancel: "\u53D6\u6D88",
220619
- compact: "\u7D27\u51D1",
220620
- console: "\u63A7\u5236\u53F0",
220621
- checkExpr: "\u68C0\u67E5\u8868\u8FBE\u5F0F",
220622
- copy: "\u590D\u5236",
220623
- createProject: "\u65B0\u5EFA\u9879\u76EE",
220624
- cut: "\u526A\u5207",
220625
- delete: "\u5220\u9664",
220626
- deleteNode: "\u5220\u9664\u8282\u70B9",
220627
- devTools: "\u5207\u6362\u5F00\u53D1\u8005\u5DE5\u5177",
220628
- donotSave: "\u4E0D\u4FDD\u5B58",
220629
- duplicate: "\u751F\u6210\u526F\u672C",
220630
- editSubtree: "\u7F16\u8F91\u5B50\u6811",
220631
- fieldRequired: "\u5B57\u6BB5\u201C{{field}}\u201D\u5FC5\u586B",
220632
- forceReload: "\u5F3A\u5236\u91CD\u65B0\u52A0\u8F7D",
220633
- fullscreen: "\u5207\u6362\u5168\u5C4F",
220634
- hide: "\u9690\u85CF Behavior3",
220635
- hideOthers: "\u9690\u85CF\u5176\u5B83",
220636
- insertNode: "\u63D2\u5165\u8282\u70B9",
220637
- jumpNode: "\u8DF3\u8F6C\u8282\u70B9",
220638
- language: "\u8BED\u8A00",
220639
- moveToTrash: "\u79FB\u81F3\u56DE\u6536\u7AD9",
220640
- newFile: "\u65B0\u5EFA\u884C\u4E3A\u6811...",
220641
- newFolder: "\u65B0\u5EFA\u76EE\u5F55...",
220642
- newWindow: "\u65B0\u5EFA\u7A97\u53E3",
220643
- nodeDefinition: "\u8282\u70B9\u5B9A\u4E49",
220644
- normal: "\u6B63\u5E38",
220645
- open: "\u6253\u5F00...",
220646
- openProject: "\u6253\u5F00\u9879\u76EE",
220647
- paste: "\u7C98\u8D34",
220648
- quit: "\u9000\u51FA Behavior3",
220649
- recent: "\u6700\u8FD1\u6253\u5F00",
220650
- redo: "\u91CD\u505A",
220651
- reload: "\u91CD\u65B0\u52A0\u8F7D",
220652
- reset: "\u91CD\u7F6E",
220653
- "reset.confirm": "\u91CD\u7F6E\u4E3A\u539F\u59CB\u503C\uFF1F",
220654
- "reset.defaultConfirm": "\u91CD\u7F6E\u4E3A\u9ED8\u8BA4\u503C\uFF1F",
220655
- rename: "\u91CD\u547D\u540D...",
220656
- replace: "\u66FF\u6362",
220657
- reportIssue: "\u95EE\u9898\u53CD\u9988",
220658
- revealFileOnMac: "\u5728 Finder \u4E2D\u663E\u793A",
220659
- revealFileOnWindows: "\u5728\u6587\u4EF6\u7BA1\u7406\u5668\u4E2D\u6253\u5F00",
220660
- save: "\u4FDD\u5B58",
220661
- saveAll: "\u4FDD\u5B58\u5168\u90E8",
220662
- saveAs: "\u53E6\u5B58\u4E3A...",
220663
- saveAsSubtree: "\u53E6\u5B58\u4E3A\u5B50\u6811",
220664
- searchFile: "\u641C\u7D22\u6587\u4EF6",
220665
- searchNode: "\u641C\u7D22\u8282\u70B9",
220666
- selectAll: "\u5168\u9009",
220667
- services: "\u670D\u52A1",
220668
- setupBuildScript: "\u8BBE\u7F6E\u6784\u5EFA\u811A\u672C",
220669
- start: "\u5F00\u59CB",
220670
- undo: "\u64A4\u9500",
220671
- unhide: "\u663E\u793A\u6240\u6709",
220672
- zoomIn: "\u653E\u5927",
220673
- zoomOut: "\u7F29\u5C0F",
220674
- "menu.file": "\u6587\u4EF6",
220675
- "menu.edit": "\u7F16\u8F91",
220676
- "menu.view": "\u89C6\u56FE",
220677
- "menu.window": "\u7A97\u53E3",
220678
- "menu.help": "\u5E2E\u52A9",
220679
- "workspace.saveAllOnClose": "\u4F60\u9700\u8981\u4FDD\u5B58\u5BF9\u4EE5\u4E0B {{count}} \u4E2A\u6587\u4EF6\u7684\u4FEE\u6539\u5417\uFF1F",
220680
- "workspace.saveOnClose": "\u4F60\u9700\u8981\u4FDD\u5B58\u5BF9\u6587\u4EF6 {{name}} \u7684\u4FEE\u6539\u5417\uFF1F",
220681
- "workspace.reloadFile": "\u6587\u4EF6 {{name}} \u53D1\u751F\u6539\u53D8\uFF0C\u4F60\u9700\u8981\u91CD\u65B0\u52A0\u8F7D\u5417\uFF1F",
220682
- "explorer.deleteFile": "\u4F60\u786E\u5B9A\u8981\u5220\u9664\u6587\u4EF6 '{{name}}'\uFF1F",
220683
- "explorer.deleteFolder": "\u4F60\u786E\u5B9A\u8981\u5220\u9664\u76EE\u5F55 '{{name}}'\uFF1F",
220684
- "explorer.replaceFile": "\u4F60\u786E\u5B9A\u8981\u66FF\u6362\u6587\u4EF6 '{{name}}'\uFF1F",
220685
- "explorer.restoreFileInfo": "\u4F60\u53EF\u4EE5\u4ECE\u56DE\u6536\u7AD9\u6062\u590D\u6B64\u6587\u4EF6\u3002",
220686
- "explorer.title": "\u8D44\u6E90\u6D4F\u89C8",
220687
- "tree.overview": "\u6982\u51B5",
220688
- "tree.name": "\u884C\u4E3A\u6811",
220689
- "tree.desc": "\u8BF4\u660E",
220690
- "tree.export": "\u5BFC\u51FA",
220691
- "tree.prefix": "\u6807\u8BC6\u524D\u7F00",
220692
- "tree.group": "\u542F\u7528\u8282\u70B9\u5206\u7EC4",
220693
- "tree.group.placeholder": "\u9009\u62E9\u8282\u70B9\u5206\u7EC4",
220694
- "tree.vars": "\u5B9A\u4E49\u53D8\u91CF",
220695
- "tree.vars.local": "\u672C\u5730\u53D8\u91CF",
220696
- "tree.vars.add": "\u6DFB\u52A0\u53D8\u91CF",
220697
- "tree.vars.name": "\u53D8\u91CF\u540D",
220698
- "tree.vars.invalidName": "\u53D8\u91CF\u540D\u4E0D\u5408\u6CD5",
220699
- "tree.vars.desc": "\u53D8\u91CF\u8BF4\u660E",
220700
- "tree.vars.imports": "\u5BFC\u5165\u53D8\u91CF",
220701
- "tree.vars.subtree": "\u5B50\u6811\u53D8\u91CF",
220702
- "tree.import.add": "\u6DFB\u52A0\u5BFC\u5165",
220703
- "tree.custom": "\u81EA\u5B9A\u4E49\u6570\u636E",
220704
- "tree.custom.add": "\u6DFB\u52A0\u6761\u76EE",
220705
- "tree.custom.key": "\u952E",
220706
- "tree.custom.value": "\u503C",
220707
- "tree.custom.type.string": "\u5B57\u7B26\u4E32\u503C",
220708
- "tree.custom.type.number": "\u6570\u5B57\u503C",
220709
- "tree.custom.type.boolean": "\u5E03\u5C14\u503C",
220710
- "tree.custom.type.invalid": "\u975E\u6CD5\u7684\u81EA\u5B9A\u4E49\u503C",
220711
- "regnode.input": "\u8F93\u5165\uFF1A",
220712
- "regnode.output": "\u8F93\u51FA\uFF1A",
220713
- "regnode.args": "\u53C2\u6570\uFF1A",
220714
- "regnode.mark": "\u5907\u6CE8\uFF1A",
220715
- "regnode.subtree": "\u5B50\u6811\uFF1A",
220716
- "node.args": "\u5E38\u91CF\u53C2\u6570",
220717
- "node.children.unlimited": "\u65E0\u9650\u5236",
220718
- "node.children": "\u5B50\u8282\u70B9\u6570\u91CF",
220719
- "node.debug": "\u8C03\u8BD5",
220720
- "node.deleteRootNodeDenied": "\u4E0D\u80FD\u5220\u9664\u6839\u8282\u70B9",
220721
- "node.dropDenied": "\u6B64\u8282\u70B9\u4F4D\u7F6E\u4E0D\u5141\u8BB8\u653E\u7F6E\u62D6\u62FD\u7684\u8282\u70B9",
220722
- "node.desc": "\u8282\u70B9\u8BF4\u660E",
220723
- "node.disabled": "\u7981\u7528",
220724
- "node.editSubtreeDenied": "\u4E0D\u80FD\u7F16\u8F91\u5B50\u6811\u8282\u70B9",
220725
- "node.editFailed": "\u8282\u70B9 {{name}} \u7F16\u8F91\u5931\u8D25",
220726
- "node.group": "\u8282\u70B9\u5206\u7EC4",
220727
- "node.groupNotEnabled": "\u8282\u70B9\u5206\u7EC4 \u201C{{group}}\u201D \u4EFB\u610F\u4E00\u4E2A\u672A\u5728\u5F53\u524D\u6587\u4EF6\u4E2D\u542F\u7528",
220728
- "node.id": "\u8282\u70B9\u6807\u8BC6",
220729
- "node.inputVariable": "\u8F93\u5165\u53D8\u91CF",
220730
- "node.invalidChildren": "\u5B50\u8282\u70B9\u6570\u91CF\u4E0D\u5408\u6CD5",
220731
- "node.invalidExpression": "\u8868\u8FBE\u5F0F\u4E0D\u5408\u6CD5",
220732
- "node.invalidValue": "\u65E0\u6548\u7684\u503C",
220733
- "node.invalidVariableName": "\u53D8\u91CF\u540D\u5FC5\u987B\u4EE5\u5B57\u6BCD\u6216\u4E0B\u5212\u7EBF\u5F00\u5934",
220734
- "node.name": "\u8282\u70B9\u540D\u79F0",
220735
- "node.noNodeSelected": "\u672A\u9009\u62E9\u4EFB\u52A1\u8282\u70B9",
220736
- "node.notFound": "\u8282\u70B9 \u201C{{name}}\u201D \u4E0D\u5B58\u5728",
220737
- "node.oneof.error": "\u8F93\u5165\u9879 \u201C{{input}}\u201D \u548C\u53C2\u6570 \u201C{{desc}}({{arg}})\u201D \u4E4B\u4E2D\uFF0C\u53EA\u80FD\u9009\u62E9\u8BBE\u7F6E\u5176\u4E2D\u4E4B\u4E00",
220738
- "node.oneof.inputNotfound": "\u8F93\u5165\u9879\u201C{{input}}\u201D\u4E0D\u5B58\u5728",
220739
- "node.outputVariable": "\u8F93\u51FA\u53D8\u91CF",
220740
- "node.pasteDataError": "\u7C98\u8D34\u6570\u636E\u51FA\u9519",
220741
- "node.rootNodeAsSubtree": "\u6839\u8282\u70B9\u4E0D\u80FD\u4FDD\u5B58\u4E3A\u5B50\u6811",
220742
- "node.subtree": "\u5B50\u6811",
220743
- "node.subtreeMissing": "\u5B50\u6811\u6587\u4EF6\u7F3A\u5931\uFF1A{{path}}",
220744
- "node.subtreeInvalid": "\u5B50\u6811\u6587\u4EF6\u65E0\u6548\uFF1A{{path}}",
220745
- "node.subtreeCyclic": "\u5B50\u6811\u5F15\u7528\u51FA\u73B0\u5FAA\u73AF\uFF1A{{path}}",
220746
- "node.subtreeOpenFailed": "\u6253\u5F00\u5B50\u6811\u5931\u8D25\uFF1A\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u8BFB\uFF08{{path}}\uFF09",
220747
- "node.subtreePathError": "\u5B50\u6811\u5FC5\u987B\u4FDD\u5B58\u5728\u5F53\u524D\u5DE5\u4F5C\u533A\u7684\u76EE\u5F55\u5185",
220748
- "node.subtreeSaveRootError": "\u6839\u8282\u70B9\u4E0D\u80FD\u4FDD\u5B58\u4E3A\u5B50\u6811",
220749
- "node.subtreeSaveSuccess": "\u5DF2\u4FDD\u5B58\u5E76\u8F6C\u6362\u4E3A\u5B50\u6811\u8282\u70B9\uFF1A{{path}}",
220750
- "node.moveSubtreeDenied": "\u4E0D\u80FD\u79FB\u52A8\u5B50\u6811\u5185\u90E8\u8282\u70B9",
220751
- "node.dropSubtreeInternalDenied": "\u4E0D\u80FD\u62D6\u653E\u5230\u5B50\u6811\u5185\u90E8\u8282\u70B9",
220752
- "node.moveRootDenied": "\u4E0D\u80FD\u79FB\u52A8\u6839\u8282\u70B9",
220753
- "node.dropAroundRootDenied": "\u4E0D\u80FD\u5C06\u8282\u70B9\u653E\u5230\u6839\u8282\u70B9\u4E4B\u524D\u6216\u4E4B\u540E",
220754
- "node.addChildToSubtreeRefDenied": "\u4E0D\u80FD\u5411\u5B50\u6811\u5F15\u7528\u6DFB\u52A0\u5B50\u8282\u70B9",
220755
- "node.moveIntoDescendantDenied": "\u4E0D\u80FD\u5C06\u8282\u70B9\u79FB\u52A8\u5230\u81EA\u5DF1\u7684\u540E\u4EE3\u8282\u70B9\u4E2D",
220756
- "node.type": "\u8282\u70B9\u7C7B\u578B",
220757
- "node.undefinedVariable": "\u53D8\u91CF \u201C{{variable}}\u201D \u672A\u5B9A\u4E49",
220758
- "node.jsonData": "JSON \u6570\u636E",
220759
- "node.unknown.title": "\u672A\u77E5\u8282\u70B9",
220760
- "node.unknownType": "\u672A\u77E5",
220761
- "node.resolutionError": "\u89E3\u6790\u9519\u8BEF",
220762
- "node.unknown.desc": "\u65B0\u5EFA\u8282\u70B9",
220763
- "build.success": "\u6784\u5EFA\u5B8C\u6210\u3002",
220764
- "build.failed": "\u6784\u5EFA\u5931\u8D25\u3002",
220765
- "editor.loading": "\u6B63\u5728\u52A0\u8F7D\u7F16\u8F91\u5668...",
220766
- "editor.externalChangeConflict": "\u68C0\u6D4B\u5230\u5916\u90E8\u6587\u4EF6\u53D8\u66F4\uFF0C\u5F53\u524D\u6587\u6863\u8FD8\u6709\u672A\u4FDD\u5B58\u4FEE\u6539\u3002",
220767
- "editor.reloadFromDisk": "\u91CD\u65B0\u8F7D\u5165",
220768
- "editor.dismissConflict": "\u5FFD\u7565",
220769
- "editor.newerVersionEditDenied": "\u6B64\u6587\u4EF6\u7531\u65B0\u7248\u672C Behavior3({{version}}) \u521B\u5EFA\uFF0C\u8BF7\u5347\u7EA7\u5230\u6700\u65B0\u7248\u672C\u540E\u518D\u7F16\u8F91\u3002",
220770
- "inspector.noActiveDocument": "\u6253\u5F00\u4E00\u4E2A Behavior3 \u7F16\u8F91\u5668\u540E\uFF0C\u8FD9\u91CC\u4F1A\u663E\u793A\u5F53\u524D\u884C\u4E3A\u6811\u7684 Inspector\uFF0C\u5E76\u652F\u6301\u76F4\u63A5\u7F16\u8F91\u3002",
220771
- "inspector.embeddedModeNotice": "Inspector \u5F53\u524D\u914D\u7F6E\u4E3A\u5728 Behavior3 \u7F16\u8F91\u5668\u5185\u90E8\u663E\u793A\u3002",
220772
- "inspector.embeddedToolbar.build": "\u6784\u5EFA\u884C\u4E3A\u6811",
220773
- "inspector.embeddedToolbar.toggleEditorMode": "\u5207\u6362\u7F16\u8F91\u5668\u6A21\u5F0F",
220774
- "inspector.embeddedToolbar.toggleInspectorNodeJson": "\u5207\u6362\u539F\u59CB\u8282\u70B9 JSON",
220775
- "inspector.embeddedToolbar.createProject": "\u65B0\u5EFA\u9879\u76EE",
220776
- "inspector.embeddedToolbar.createTree": "\u65B0\u5EFA\u884C\u4E3A\u6811",
220777
- "mutation.invalidJsonPath": "\u65E0\u6548\u7684 JSON \u8DEF\u5F84: {{path}}",
220778
- "mutation.missingSelectedNode": "\u5F53\u524D\u6CA1\u6709\u53EF\u7528\u4E8E\u63D0\u4EA4\u6B64\u4FEE\u6539\u7684\u9009\u4E2D\u8282\u70B9\u3002",
220779
- "mutation.selectedNodeMismatch": "\u5F53\u524D\u9009\u4E2D\u8282\u70B9\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u8BD5\u3002",
220780
- "mutation.missingTargetNode": "\u672A\u627E\u5230\u76EE\u6807\u8282\u70B9\uFF0C\u8BF7\u91CD\u8BD5\u3002",
220781
- "mutation.missingSourceNode": "\u672A\u627E\u5230\u6E90\u8282\u70B9\uFF0C\u8BF7\u91CD\u8BD5\u3002",
220782
- "mutation.missingSubtreeOriginal": "\u7F3A\u5C11 subtree \u539F\u59CB\u8282\u70B9\u5FEB\u7167\uFF0C\u8BF7\u91CD\u8BD5\u3002",
220783
- "mutation.missingDetachedSubtreeRoot": "\u7F3A\u5C11\u7528\u4E8E\u89E3\u7ED1 subtree \u5F15\u7528\u7684\u5FEB\u7167\uFF0C\u8BF7\u91CD\u8BD5\u3002",
220784
- "mutation.moveRootDenied": "\u4E0D\u80FD\u79FB\u52A8\u6839\u8282\u70B9\u3002",
220785
- "mutation.dropAroundRootDenied": "\u4E0D\u80FD\u56F4\u7ED5\u6839\u8282\u70B9\u63D2\u5165\u3002",
220786
- "mutation.addChildToSubtreeRefDenied": "\u4E0D\u80FD\u76F4\u63A5\u5411 subtree \u5F15\u7528\u6DFB\u52A0\u5B50\u8282\u70B9\u3002",
220787
- "mutation.moveIntoDescendantDenied": "\u4E0D\u80FD\u79FB\u52A8\u5230\u81EA\u5DF1\u7684\u540E\u4EE3\u4E0B\u3002",
220788
- "mutation.deleteRootNodeDenied": "\u4E0D\u80FD\u5220\u9664\u6839\u8282\u70B9\u3002",
220789
- "mutation.editSubtreeDenied": "\u4E0D\u80FD\u5728 subtree \u5F15\u7528\u4E0A\u76F4\u63A5\u4FEE\u6539\u7ED3\u6784\u3002",
220790
- "mutation.saveSelectedAsSubtreeRootDenied": "\u6839\u8282\u70B9\u4E0D\u80FD\u53E6\u5B58\u4E3A subtree\u3002",
220791
- "mutation.saveSelectedAsSubtreeMissingTarget": "\u672A\u627E\u5230\u53EF\u53E6\u5B58\u4E3A subtree \u7684\u76EE\u6807\u8282\u70B9\u3002",
220792
- "mutation.saveSelectedAsSubtreePostSaveMissingTarget": "\u63D0\u4EA4 subtree \u4FDD\u5B58\u7ED3\u679C\u65F6\u672A\u627E\u5230\u76EE\u6807\u8282\u70B9\u3002",
220793
- "runtime.nodeCheckRuntimeHasErrors": "checker \u8FD0\u884C\u65F6\u5B58\u5728\u9519\u8BEF\u3002",
220794
- "runtime.invalidSavedSubtreePath": "\u5BBF\u4E3B\u8FD4\u56DE\u4E86\u65E0\u6548\u7684 subtree \u4FDD\u5B58\u8DEF\u5F84\u3002",
220795
- "runtime.unsupportedDocumentMutation": "\u4E0D\u652F\u6301\u6B64\u6587\u6863\u4FEE\u6539\u3002",
220796
- "override.resetTitle": "\u91CD\u7F6E\u6B64\u8986\u76D6\uFF1F",
220797
- "form.enterJsonArray": "\u8F93\u5165 JSON \u6570\u7EC4",
220798
- "form.enterJsonValue": "\u8F93\u5165 JSON \u503C",
220799
- "form.unset": "\u672A\u8BBE\u7F6E",
220800
- "form.true": "\u662F",
220801
- "form.false": "\u5426",
220802
- "validation.jsonArray": "{{name}} \u5FC5\u987B\u662F JSON \u6570\u7EC4",
220803
- "validation.integer": "{{field}} \u5FC5\u987B\u662F\u6574\u6570",
220804
- "validation.number": "{{field}} \u5FC5\u987B\u662F\u6570\u5B57",
220805
- "validation.missingOneofInput": "\u7F3A\u5C11 oneof \u8F93\u5165\u9879 \u201C{{input}}\u201D",
220806
- "validation.oneof": "\u201C{{left}}\u201D \u548C \u201C{{right}}\u201D \u53EA\u80FD\u8BBE\u7F6E\u5176\u4E2D\u4E4B\u4E00",
220807
- "validation.invalidJsonPath": "\u8DEF\u5F84\u5FC5\u987B\u662F\u5DE5\u4F5C\u76EE\u5F55\u5185\u7684\u76F8\u5BF9 .json \u6587\u4EF6\uFF1A{{path}}",
220808
- "validation.variableDescriptionRequired": "\u53D8\u91CF\u8BF4\u660E\u5FC5\u586B",
220809
- "validation.customKeyRequired": "\u81EA\u5B9A\u4E49 key \u5FC5\u586B",
220810
- "validation.customKeyDuplicate": "\u81EA\u5B9A\u4E49 key \u201C{{key}}\u201D \u91CD\u590D\u4E86",
220811
- "validation.customValueInvalid": "\u81EA\u5B9A\u4E49\u503C\u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u3001\u6570\u5B57\u6216\u5E03\u5C14\u503C"
220735
+ if (relativePath.startsWith("..") || path7.isAbsolute(relativePath)) {
220736
+ return void 0;
220737
+ }
220738
+ return parseWorkdirRelativeJsonPath(relativePath) ?? void 0;
220739
+ }
220740
+ async readWorkspaceFileContent(fileUri) {
220741
+ const openDocument = vscode8.workspace.textDocuments.find(
220742
+ (document) => isSameUri(document.uri, fileUri)
220743
+ );
220744
+ if (openDocument) {
220745
+ return openDocument.getText();
220746
+ }
220747
+ const raw = await vscode8.workspace.fs.readFile(fileUri);
220748
+ return Buffer.from(raw).toString("utf-8");
220749
+ }
220750
+ async readTreeFile(relativePath) {
220751
+ const normalizedPath = parseWorkdirRelativeJsonPath(relativePath);
220752
+ if (!normalizedPath) {
220753
+ return null;
220754
+ }
220755
+ const fileUri = vscode8.Uri.joinPath(this.workdir, normalizedPath);
220756
+ const content = await this.readWorkspaceFileContent(fileUri).catch(() => null);
220757
+ if (content === null) {
220758
+ this.treeCache.set(normalizedPath, {
220759
+ content: "",
220760
+ tree: null
220761
+ });
220762
+ return null;
220763
+ }
220764
+ const cached = this.treeCache.get(normalizedPath);
220765
+ if (cached && cached.content === content) {
220766
+ return cached.tree;
220767
+ }
220768
+ try {
220769
+ const tree = parsePersistedTreeContent(content, normalizedPath);
220770
+ this.treeCache.set(normalizedPath, {
220771
+ content,
220772
+ tree
220773
+ });
220774
+ return tree;
220775
+ } catch {
220776
+ this.treeCache.set(normalizedPath, {
220777
+ content,
220778
+ tree: null
220779
+ });
220780
+ return null;
220781
+ }
220782
+ }
220783
+ getLocalVarsFromTree(relativePath) {
220784
+ const normalizedPath = parseWorkdirRelativeJsonPath(relativePath);
220785
+ if (!normalizedPath) {
220786
+ return [];
220787
+ }
220788
+ const tree = this.treeCache.get(normalizedPath)?.tree;
220789
+ if (!tree) {
220790
+ return [];
220791
+ }
220792
+ return tree.variables.locals.filter((entry) => entry.name).map((entry) => ({ name: entry.name, desc: entry.desc ?? "" }));
220793
+ }
220794
+ async readVarsFromFile(relativePath, visitedForGlobal, globalVars) {
220795
+ const localVars = [];
220796
+ const parsedPath = parseWorkdirRelativeJsonPath(relativePath);
220797
+ if (!parsedPath) {
220798
+ return localVars;
220799
+ }
220800
+ const normalizedPath = parsedPath;
220801
+ if (visitedForGlobal.has(normalizedPath)) {
220802
+ return localVars;
220803
+ }
220804
+ visitedForGlobal.add(normalizedPath);
220805
+ const tree = await this.readTreeFile(normalizedPath);
220806
+ if (!tree) {
220807
+ return localVars;
220808
+ }
220809
+ for (const entry of tree.variables.locals) {
220810
+ if (!entry.name) {
220811
+ continue;
220812
+ }
220813
+ const variable = { name: entry.name, desc: entry.desc ?? "" };
220814
+ localVars.push(variable);
220815
+ if (!globalVars[entry.name]) {
220816
+ globalVars[entry.name] = variable;
220817
+ }
220818
+ }
220819
+ for (const importPath of tree.variables.imports) {
220820
+ await this.readVarsFromFile(importPath, visitedForGlobal, globalVars);
220821
+ }
220822
+ for (const subtreePath of collectSubtreePaths2(tree.root)) {
220823
+ await this.readVarsFromFile(subtreePath, visitedForGlobal, globalVars);
220824
+ }
220825
+ return localVars;
220826
+ }
220827
+ async collectOrderedTransitiveImportPaths(seedImports) {
220828
+ return collectTransitivePaths(normalizePathList(seedImports), async (relativePath) => {
220829
+ const tree = await this.readTreeFile(relativePath);
220830
+ return normalizePathList(tree?.variables.imports ?? []);
220831
+ });
220832
+ }
220833
+ async collectOrderedTransitiveSubtreePaths(root) {
220834
+ return collectTransitivePaths(
220835
+ normalizePathList(collectSubtreePaths2(root)),
220836
+ async (relativePath) => {
220837
+ const tree = await this.readTreeFile(relativePath);
220838
+ return tree?.root ? normalizePathList(collectSubtreePaths2(tree.root)) : [];
220839
+ }
220840
+ );
220841
+ }
220812
220842
  };
220813
220843
 
220814
- // webview/shared/runtime-i18n.ts
220815
- var runtimeTranslations = {
220816
- en: en_default,
220817
- zh: zh_default
220818
- };
220819
- var INTERPOLATION_PATTERN = /\{\{\s*([^{}\s]+)\s*\}\}/g;
220820
- var interpolateRuntimeMessage = (template, params) => {
220821
- if (!params) {
220822
- return template;
220844
+ // src/editor-session/settings/live-settings.ts
220845
+ var vscode10 = __toESM(require("vscode"));
220846
+
220847
+ // src/editor-session/settings/editor-settings.ts
220848
+ var vscode9 = __toESM(require("vscode"));
220849
+ function getEditorLanguage(setting) {
220850
+ if (setting === "zh" || setting === "en") {
220851
+ return setting;
220852
+ }
220853
+ const envLanguage = vscode9.env.language.toLowerCase();
220854
+ return envLanguage.startsWith("zh") ? "zh" : "en";
220855
+ }
220856
+ function getVSCodeTheme() {
220857
+ const kind = vscode9.window.activeColorTheme.kind;
220858
+ return kind === vscode9.ColorThemeKind.Light || kind === vscode9.ColorThemeKind.HighContrastLight ? "light" : "dark";
220859
+ }
220860
+
220861
+ // src/editor-session/settings/live-settings.ts
220862
+ function createLiveSettingsResolver(workspaceFolderUri, documentUri) {
220863
+ return async () => {
220864
+ const config = vscode10.workspace.getConfiguration("behavior3");
220865
+ const workspaceSettings = await resolveWorkspaceFileSettings(
220866
+ workspaceFolderUri,
220867
+ documentUri
220868
+ );
220869
+ return {
220870
+ allowNewFunction: workspaceSettings?.allowNewFunction ?? false,
220871
+ checkExpr: config.get("checkExpr", true),
220872
+ subtreeEditable: config.get("subtreeEditable", true),
220873
+ language: getEditorLanguage(config.get("language", "auto")),
220874
+ inspectorMode: config.get("inspectorMode", "sidebar"),
220875
+ nodeColors: workspaceSettings?.nodeColors
220876
+ };
220877
+ };
220878
+ }
220879
+
220880
+ // src/editor-session/session/context.ts
220881
+ async function createTreeEditorSessionContext(params) {
220882
+ const workspaceFolderUri = getWorkdir(params.document.uri);
220883
+ const projectRootUri = vscode11.Uri.file(
220884
+ getBehaviorProjectRootFsPath(params.document.uri, workspaceFolderUri)
220885
+ );
220886
+ const projectIndex = new ProjectIndex(projectRootUri);
220887
+ const resolveLiveSettings = createLiveSettingsResolver(
220888
+ workspaceFolderUri,
220889
+ params.document.uri
220890
+ );
220891
+ const [nodeDefs, settingDir, currentSettings] = await Promise.all([
220892
+ resolveNodeDefs(workspaceFolderUri, params.document.uri),
220893
+ getResolvedB3SettingDir(workspaceFolderUri, params.document.uri),
220894
+ resolveLiveSettings()
220895
+ ]);
220896
+ const state = {
220897
+ nodeDefs,
220898
+ settingDir,
220899
+ currentSettings,
220900
+ fileVersionIsNewer: false,
220901
+ newerFileVersion: null,
220902
+ cachedSubtreeRefs: null,
220903
+ latestAllFiles: [],
220904
+ latestVarDecls: {
220905
+ usingVars: {},
220906
+ importDecls: [],
220907
+ subtreeDecls: []
220908
+ },
220909
+ sharedSelection: normalizeHostSelectionState(params.initialSelection),
220910
+ selectionRevision: 0,
220911
+ inspectorContentSyncKind: "reload"
220912
+ };
220913
+ const documentSession = params.document.sessionState;
220914
+ const buildDocumentSessionMessage = () => documentSession.getSnapshot();
220915
+ params.configureWebview(params.webviewPanel.webview, workspaceFolderUri);
220916
+ const postMessage = (message) => params.webviewPanel.webview.postMessage(message);
220917
+ const mapDefsForWebview = (defs = state.nodeDefs) => mapNodeDefsIconsForWebview(
220918
+ params.webviewPanel.webview,
220919
+ workspaceFolderUri,
220920
+ state.settingDir,
220921
+ defs
220922
+ );
220923
+ return {
220924
+ ...params,
220925
+ workspaceFolderUri,
220926
+ projectRootUri,
220927
+ projectIndex,
220928
+ state,
220929
+ documentSession,
220930
+ resolveLiveSettings,
220931
+ postMessage,
220932
+ mapDefsForWebview,
220933
+ buildDocumentSessionMessage,
220934
+ enqueueMainDocumentOperation: createSerialOperationQueue()
220935
+ };
220936
+ }
220937
+
220938
+ // src/editor-session/session/document-lifecycle.ts
220939
+ var vscode12 = __toESM(require("vscode"));
220940
+ function createSessionDocumentLifecycle(context, inspectorSync, subtreeTracking, fileVersionGuard) {
220941
+ const {
220942
+ document,
220943
+ revertDocument,
220944
+ onDidChangeDocument,
220945
+ state,
220946
+ documentSession,
220947
+ postMessage,
220948
+ buildDocumentSessionMessage,
220949
+ enqueueMainDocumentOperation
220950
+ } = context;
220951
+ const { fanoutDocumentSnapshot } = inspectorSync;
220952
+ const { invalidateSubtreeRefs, refreshTrackedSubtreeRefs } = subtreeTracking;
220953
+ const { updateFileVersionState, blockEditingForNewerFile } = fileVersionGuard;
220954
+ const applySessionHistorySnapshot = async (snapshot) => {
220955
+ const sessionSnapshot = buildDocumentSessionMessage();
220956
+ const changed = document.syncContentState(snapshot, sessionSnapshot.dirty);
220957
+ if (!changed) {
220958
+ return false;
220959
+ }
220960
+ state.inspectorContentSyncKind = "update";
220961
+ invalidateSubtreeRefs();
220962
+ void refreshTrackedSubtreeRefs();
220963
+ updateFileVersionState(snapshot);
220964
+ onDidChangeDocument(document);
220965
+ await fanoutDocumentSnapshot({
220966
+ syncKind: "update"
220967
+ });
220968
+ return true;
220969
+ };
220970
+ const handleSaveDocumentMessage = async (msg, reply = postMessage) => {
220971
+ await enqueueMainDocumentOperation(async () => {
220972
+ const editBlockedMessage = blockEditingForNewerFile();
220973
+ if (editBlockedMessage) {
220974
+ await reply({
220975
+ type: "saveDocumentResult",
220976
+ requestId: msg.requestId,
220977
+ success: false,
220978
+ error: editBlockedMessage
220979
+ });
220980
+ return;
220981
+ }
220982
+ try {
220983
+ if (document.isDirty) {
220984
+ await vscode12.workspace.save(document.uri);
220985
+ }
220986
+ const success = !document.isDirty;
220987
+ if (!success) {
220988
+ getBehavior3OutputChannel().warn(
220989
+ `[saveDocument] save failed for ${document.uri.fsPath}; isDirty=${document.isDirty}`
220990
+ );
220991
+ }
220992
+ await reply({
220993
+ type: "saveDocumentResult",
220994
+ requestId: msg.requestId,
220995
+ success,
220996
+ error: success ? void 0 : "Failed to save document"
220997
+ });
220998
+ if (success) {
220999
+ state.inspectorContentSyncKind = "reload";
221000
+ }
221001
+ } catch (error) {
221002
+ getBehavior3OutputChannel().error(
221003
+ `[saveDocument] exception for ${document.uri.fsPath}: ${String(error)}`
221004
+ );
221005
+ await reply({
221006
+ type: "saveDocumentResult",
221007
+ requestId: msg.requestId,
221008
+ success: false,
221009
+ error: String(error)
221010
+ });
221011
+ }
221012
+ });
221013
+ };
221014
+ const handleHistoryNavigationMessage = async (direction) => {
221015
+ await enqueueMainDocumentOperation(async () => {
221016
+ const editBlockedMessage = blockEditingForNewerFile();
221017
+ if (editBlockedMessage) {
221018
+ return;
221019
+ }
221020
+ const snapshot = direction === "undo" ? documentSession.undo() : documentSession.redo();
221021
+ if (!snapshot) {
221022
+ return;
221023
+ }
221024
+ await applySessionHistorySnapshot(snapshot);
221025
+ });
221026
+ };
221027
+ const handleRevertDocumentMessage = async (msg, reply = postMessage) => {
221028
+ await enqueueMainDocumentOperation(async () => {
221029
+ const cancellation = new vscode12.CancellationTokenSource();
221030
+ try {
221031
+ await revertDocument(document, cancellation.token);
221032
+ state.inspectorContentSyncKind = "reload";
221033
+ await reply({
221034
+ type: "revertDocumentResult",
221035
+ requestId: msg.requestId,
221036
+ success: true
221037
+ });
221038
+ } catch (error) {
221039
+ await reply({
221040
+ type: "revertDocumentResult",
221041
+ requestId: msg.requestId,
221042
+ success: false,
221043
+ error: String(error)
221044
+ });
221045
+ } finally {
221046
+ cancellation.dispose();
221047
+ }
221048
+ });
221049
+ };
221050
+ const handleMainDocumentFileChange = async () => {
221051
+ await enqueueMainDocumentOperation(async () => {
221052
+ let content;
221053
+ try {
221054
+ content = await readFileContentFromDisk(document.uri);
221055
+ } catch {
221056
+ return;
221057
+ }
221058
+ invalidateSubtreeRefs();
221059
+ if (document.consumeOwnWrite(content)) {
221060
+ return;
221061
+ }
221062
+ if (document.content === content) {
221063
+ return;
221064
+ }
221065
+ if (!document.isDirty) {
221066
+ document.updateContent(content, { markSaved: true, markDirty: false });
221067
+ documentSession.replaceFromDisk(content);
221068
+ state.inspectorContentSyncKind = "reload";
221069
+ void refreshTrackedSubtreeRefs();
221070
+ updateFileVersionState(content, { showWarning: true });
221071
+ await fanoutDocumentSnapshot({
221072
+ syncKind: "reload"
221073
+ });
221074
+ return;
221075
+ }
221076
+ documentSession.showReloadConflict(content);
221077
+ await fanoutDocumentSnapshot({
221078
+ syncKind: "update",
221079
+ refreshVars: false
221080
+ });
221081
+ });
221082
+ };
221083
+ return {
221084
+ handleSaveDocumentMessage,
221085
+ handleHistoryNavigationMessage,
221086
+ handleRevertDocumentMessage,
221087
+ handleMainDocumentFileChange
221088
+ };
221089
+ }
221090
+
221091
+ // src/editor-session/document/subtree-overrides.ts
221092
+ var path8 = __toESM(require("path"));
221093
+ var vscode13 = __toESM(require("vscode"));
221094
+ function branchContainsSubtreeLink(node) {
221095
+ if (!node) {
221096
+ return false;
220823
221097
  }
220824
- return template.replace(INTERPOLATION_PATTERN, (match, key) => {
220825
- const value = params[key];
220826
- return value === void 0 || value === null ? match : String(value);
221098
+ let found = false;
221099
+ walkPersistedNodes(node, (entry) => {
221100
+ if (entry.path) {
221101
+ found = true;
221102
+ }
221103
+ });
221104
+ return found;
221105
+ }
221106
+ async function normalizeReachableSubtreeOverrides(params) {
221107
+ if (Object.keys(params.tree.overrides).length === 0) {
221108
+ return;
221109
+ }
221110
+ const subtreeSources = await loadSubtreeSourceCache({
221111
+ root: params.tree.root,
221112
+ readContent: async (relativePath) => {
221113
+ const subtreeUri = vscode13.Uri.file(path8.join(params.projectRootFsPath, relativePath));
221114
+ try {
221115
+ return await params.readWorkspaceFileContent(subtreeUri);
221116
+ } catch {
221117
+ return null;
221118
+ }
221119
+ }
221120
+ });
221121
+ pruneStaleSubtreeOverrides({
221122
+ tree: params.tree,
221123
+ subtreeSources
220827
221124
  });
221125
+ }
221126
+ function mutationMayAffectSubtreeOverrideReachability(mutation, currentTree) {
221127
+ switch (mutation.type) {
221128
+ case "updateNode": {
221129
+ if (mutation.payload.currentNodeSnapshot?.subtreeNode) {
221130
+ return false;
221131
+ }
221132
+ const currentNode = findPersistedNodeByStableId(
221133
+ currentTree.root,
221134
+ mutation.payload.target.structuralStableId
221135
+ ) ?? mutation.payload.currentNodeSnapshot?.data;
221136
+ if (!currentNode) {
221137
+ return false;
221138
+ }
221139
+ const currentPath = currentNode.path;
221140
+ const nextPath = mutation.payload.data.path?.trim() || void 0;
221141
+ return currentPath !== nextPath;
221142
+ }
221143
+ case "replaceNode": {
221144
+ const currentNode = findPersistedNodeByStableId(
221145
+ currentTree.root,
221146
+ mutation.payload.target.structuralStableId
221147
+ );
221148
+ return branchContainsSubtreeLink(currentNode) || branchContainsSubtreeLink(mutation.payload.snapshot);
221149
+ }
221150
+ case "deleteNode": {
221151
+ const currentNode = findPersistedNodeByStableId(
221152
+ currentTree.root,
221153
+ mutation.payload.target.structuralStableId
221154
+ );
221155
+ return branchContainsSubtreeLink(currentNode);
221156
+ }
221157
+ default:
221158
+ return false;
221159
+ }
221160
+ }
221161
+
221162
+ // src/editor-session/session/selection-state.ts
221163
+ var buildPendingSelectionRef = (structuralStableId) => ({
221164
+ instanceKey: structuralStableId,
221165
+ displayId: "",
221166
+ structuralStableId,
221167
+ sourceStableId: structuralStableId,
221168
+ sourceTreePath: null,
221169
+ subtreeStack: []
221170
+ });
221171
+ var applySharedSelectionState = (currentSelection, nextSelection, opts) => {
221172
+ const normalized = normalizeHostSelectionState(nextSelection);
221173
+ if (isJsonEqual(currentSelection, normalized)) {
221174
+ return {
221175
+ selection: currentSelection,
221176
+ result: opts?.reassertIfEqual ? "reasserted" : "noop"
221177
+ };
221178
+ }
221179
+ return {
221180
+ selection: normalized,
221181
+ result: "changed"
221182
+ };
220828
221183
  };
220829
- var translateRuntimeMessage = (language, key, params) => {
220830
- const template = runtimeTranslations[language][key] ?? runtimeTranslations.en[key] ?? key;
220831
- return interpolateRuntimeMessage(template, params);
221184
+
221185
+ // src/editor-session/session/messages.ts
221186
+ function buildVarDeclLoadedMessage(result, allFiles) {
221187
+ return {
221188
+ type: "varDeclLoaded",
221189
+ usingVars: Object.values(result.usingVars),
221190
+ allFiles,
221191
+ importDecls: result.importDecls,
221192
+ subtreeDecls: result.subtreeDecls
221193
+ };
221194
+ }
221195
+ function buildDocumentSnapshotChangedMessage(params) {
221196
+ return {
221197
+ type: "documentSnapshotChanged",
221198
+ snapshot: {
221199
+ content: params.content,
221200
+ documentSession: params.documentSession,
221201
+ selection: params.selection,
221202
+ syncKind: params.syncKind
221203
+ }
221204
+ };
221205
+ }
221206
+ function buildHostSelectionFromMutationSelection(selection) {
221207
+ return selection.kind === "tree" ? { kind: "tree" } : {
221208
+ kind: "node",
221209
+ ref: buildPendingSelectionRef(selection.structuralStableId)
221210
+ };
221211
+ }
221212
+ function buildInitMessage(params) {
221213
+ return {
221214
+ type: "init",
221215
+ content: params.content,
221216
+ filePath: params.filePath,
221217
+ workdir: params.workdir,
221218
+ nodeDefs: params.nodeDefs,
221219
+ allowNewFunction: params.settings.allowNewFunction,
221220
+ checkExpr: params.settings.checkExpr,
221221
+ subtreeEditable: params.settings.subtreeEditable,
221222
+ language: params.settings.language,
221223
+ theme: params.theme,
221224
+ inspectorMode: params.settings.inspectorMode,
221225
+ allFiles: params.allFiles,
221226
+ nodeColors: params.settings.nodeColors,
221227
+ documentSession: params.documentSession,
221228
+ selection: params.selection
221229
+ };
221230
+ }
221231
+
221232
+ // webview/shared/node-overrides.ts
221233
+ var hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
221234
+ var getNodeArgOverrideCompareValue = (args, arg) => {
221235
+ if (args && hasOwn(args, arg.name)) {
221236
+ return args[arg.name];
221237
+ }
221238
+ return arg.default;
220832
221239
  };
220833
221240
 
220834
221241
  // webview/shared/document.ts
@@ -221948,19 +222355,22 @@ function createSessionInspectorSync(context) {
221948
222355
  var fs4 = __toESM(require("fs"));
221949
222356
  var path9 = __toESM(require("path"));
221950
222357
  var vscode16 = __toESM(require("vscode"));
221951
- function createSessionBuildScriptEnv(workdir, nodeDefs) {
222358
+ function createSessionBuildScriptEnv(workdir, nodeDefs, allowNewFunction = false, language) {
221952
222359
  return {
221953
222360
  fs: fs4,
221954
222361
  path: b3path_default,
221955
222362
  workdir,
221956
222363
  nodeDefs: createNodeDefMap(nodeDefs),
221957
- logger: createBuildScriptLogger()
222364
+ logger: createBuildScriptLogger(),
222365
+ allowNewFunction,
222366
+ language
221958
222367
  };
221959
222368
  }
221960
222369
  async function createSessionNodeCheckRuntime({
221961
222370
  documentUri,
221962
222371
  workspaceFolderUri,
221963
222372
  nodeDefs,
222373
+ language,
221964
222374
  readWorkspaceFileContent: readWorkspaceFileContent2
221965
222375
  }) {
221966
222376
  const workspaceFile = findB3WorkspacePath(documentUri, workspaceFolderUri);
@@ -221968,18 +222378,20 @@ async function createSessionNodeCheckRuntime({
221968
222378
  return {
221969
222379
  buildScriptRuntime: createBuildScriptRuntime(
221970
222380
  null,
221971
- createSessionBuildScriptEnv(workspaceFolderUri.fsPath, nodeDefs)
222381
+ createSessionBuildScriptEnv(workspaceFolderUri.fsPath, nodeDefs, false, language)
221972
222382
  ),
221973
222383
  nodeFieldVisibleHandlers: /* @__PURE__ */ new Map(),
221974
- treePath: workspaceFolderUri.fsPath
222384
+ treePath: workspaceFolderUri.fsPath,
222385
+ allowNewFunction: false
221975
222386
  };
221976
222387
  }
221977
222388
  const workspaceText = await readWorkspaceFileContent2(vscode16.Uri.file(workspaceFile));
221978
222389
  const workspaceModel = parseWorkspaceModelContent(workspaceText);
221979
222390
  const buildScript = workspaceModel.settings.buildScript;
221980
222391
  const checkScripts = workspaceModel.settings.checkScripts ?? [];
222392
+ const allowNewFunction = workspaceModel.settings.allowNewFunction ?? false;
221981
222393
  const workdir = path9.dirname(workspaceFile).replace(/\\/g, "/");
221982
- const env2 = createSessionBuildScriptEnv(workdir, nodeDefs);
222394
+ const env2 = createSessionBuildScriptEnv(workdir, nodeDefs, allowNewFunction, language);
221983
222395
  let buildScriptModule = null;
221984
222396
  let hasRuntimeLoadError = false;
221985
222397
  if (buildScript) {
@@ -222018,7 +222430,8 @@ async function createSessionNodeCheckRuntime({
222018
222430
  hasError: buildScriptRuntime.hasError || hasRuntimeLoadError
222019
222431
  },
222020
222432
  nodeFieldVisibleHandlers: visibleRuntime.nodeFieldVisibles,
222021
- treePath: workdir
222433
+ treePath: workdir,
222434
+ allowNewFunction
222022
222435
  };
222023
222436
  }
222024
222437
 
@@ -222031,6 +222444,7 @@ function createSessionNodeChecks(context) {
222031
222444
  documentUri: document.uri,
222032
222445
  workspaceFolderUri,
222033
222446
  nodeDefs: state.nodeDefs,
222447
+ language: state.currentSettings.language,
222034
222448
  readWorkspaceFileContent
222035
222449
  });
222036
222450
  };
@@ -222041,8 +222455,14 @@ function createSessionNodeChecks(context) {
222041
222455
  const diagnostics = collectNodeFieldCheckDiagnostics({
222042
222456
  tree,
222043
222457
  treePath: msg.treePath || runtimeResult.treePath,
222044
- env: createSessionBuildScriptEnv(runtimeResult.treePath, state.nodeDefs),
222458
+ env: createSessionBuildScriptEnv(
222459
+ runtimeResult.treePath,
222460
+ state.nodeDefs,
222461
+ runtimeResult.allowNewFunction,
222462
+ state.currentSettings.language
222463
+ ),
222045
222464
  checkers: runtimeResult.buildScriptRuntime.nodeFieldCheckers,
222465
+ visibles: runtimeResult.nodeFieldVisibleHandlers,
222046
222466
  targets: msg.nodes.map((entry) => ({
222047
222467
  instanceKey: entry.instanceKey,
222048
222468
  treePath: entry.treePath,
@@ -222083,7 +222503,12 @@ function createSessionNodeChecks(context) {
222083
222503
  const visibility = resolveNodeFieldVisibility({
222084
222504
  tree,
222085
222505
  treePath: msg.treePath || runtimeResult.treePath,
222086
- env: createSessionBuildScriptEnv(runtimeResult.treePath, state.nodeDefs),
222506
+ env: createSessionBuildScriptEnv(
222507
+ runtimeResult.treePath,
222508
+ state.nodeDefs,
222509
+ runtimeResult.allowNewFunction,
222510
+ state.currentSettings.language
222511
+ ),
222087
222512
  visibles: runtimeResult.nodeFieldVisibleHandlers,
222088
222513
  target: toNodeData(msg.target.node),
222089
222514
  targetTreePath: msg.target.treePath
@@ -222899,7 +223324,7 @@ async function startBuildScriptDebugSession(params) {
222899
223324
  request: "launch",
222900
223325
  name: "Debug Behavior3 Build Script",
222901
223326
  program,
222902
- cwd: params.folder.uri.fsPath,
223327
+ cwd: params.projectDir,
222903
223328
  console: "integratedTerminal",
222904
223329
  sourceMaps: true,
222905
223330
  smartStep: true,
@@ -223036,6 +223461,7 @@ async function runBuild(context, options = {}) {
223036
223461
  }
223037
223462
  const outputDirFs = picked[0].fsPath;
223038
223463
  const outputDirPosix = outputDirFs.replace(/\\/g, "/");
223464
+ const projectDir = path12.dirname(workspaceFile);
223039
223465
  await saveLastBuildOutput(context, folder.uri, outputDirFs);
223040
223466
  const config = vscode20.workspace.getConfiguration("behavior3");
223041
223467
  const checkExpr = config.get("checkExpr", true);
@@ -223048,6 +223474,7 @@ async function runBuild(context, options = {}) {
223048
223474
  const started = await startBuildScriptDebugSession({
223049
223475
  context,
223050
223476
  folder,
223477
+ projectDir,
223051
223478
  projectPath: treeUri?.fsPath ?? workspaceFile,
223052
223479
  workspaceFile,
223053
223480
  settingPath,
@@ -223167,6 +223594,7 @@ var buildEmbeddedModeSettingsMessage = (snapshot) => ({
223167
223594
  type: "settingLoaded",
223168
223595
  nodeDefs: snapshot?.initMessage.nodeDefs ?? [],
223169
223596
  settings: {
223597
+ allowNewFunction: snapshot?.initMessage.allowNewFunction,
223170
223598
  checkExpr: snapshot?.initMessage.checkExpr,
223171
223599
  subtreeEditable: snapshot?.initMessage.subtreeEditable,
223172
223600
  language: snapshot?.initMessage.language,