vscode-behavior3 2.1.2 → 2.1.3
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/README.md +1 -0
- package/dist/build-cli.js +11 -60
- package/dist/extension.js +11 -60
- package/dist/webview/icons/icon.svg +1 -1
- package/media/icons/icon.svg +1 -1
- package/package.json +1 -1
- package/webview/shared/b3build-model.d.ts +2 -0
package/README.md
CHANGED
|
@@ -161,6 +161,7 @@ runtime, so no value import is required. The extension constructs the class once
|
|
|
161
161
|
with `env`, then calls methods:
|
|
162
162
|
|
|
163
163
|
- `constructor(env)`
|
|
164
|
+
- `shouldUpgradeTree(path, tree)`
|
|
164
165
|
- `onProcessTree(tree, path, errors)`
|
|
165
166
|
- `onProcessNode(node, errors)`
|
|
166
167
|
- `onWriteFile(path, tree)`
|
package/dist/build-cli.js
CHANGED
|
@@ -215619,7 +215619,7 @@ var hasBatchHookMethod = (obj) => {
|
|
|
215619
215619
|
return false;
|
|
215620
215620
|
}
|
|
215621
215621
|
const candidate = obj;
|
|
215622
|
-
return typeof candidate.onProcessTree === "function" || typeof candidate.onProcessNode === "function" || typeof candidate.onWriteFile === "function" || typeof candidate.onComplete === "function";
|
|
215622
|
+
return typeof candidate.shouldUpgradeTree === "function" || typeof candidate.onProcessTree === "function" || typeof candidate.onProcessNode === "function" || typeof candidate.onWriteFile === "function" || typeof candidate.onComplete === "function";
|
|
215623
215623
|
};
|
|
215624
215624
|
var BUILD_HOOK_MARKER = "__behavior3BuildHook";
|
|
215625
215625
|
var CHECK_HOOK_MARKER = "__behavior3CheckHook";
|
|
@@ -216501,11 +216501,8 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
216501
216501
|
let skippedFiles = 0;
|
|
216502
216502
|
let failedFiles = 0;
|
|
216503
216503
|
let writtenFiles = 0;
|
|
216504
|
-
const settings = readWorkspaceSettings(project);
|
|
216505
|
-
const checkScriptSetting = settings.checkScripts ?? [];
|
|
216506
216504
|
const allErrors = [];
|
|
216507
216505
|
const stagedWrites = [];
|
|
216508
|
-
context.setCheckExpr(context.checkExprOverride ?? settings.checkExpr ?? true);
|
|
216509
216506
|
let buildScriptModule;
|
|
216510
216507
|
try {
|
|
216511
216508
|
buildScriptModule = await loadRuntimeModule(scriptPath, {
|
|
@@ -216514,23 +216511,6 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
216514
216511
|
} catch {
|
|
216515
216512
|
logger.error(`'${scriptPath}' is not a valid batch script`);
|
|
216516
216513
|
}
|
|
216517
|
-
const checkScriptModules = [];
|
|
216518
|
-
const checkScriptPaths = resolveCheckScriptPaths(context.workdir, checkScriptSetting);
|
|
216519
|
-
for (const pattern of checkScriptPaths.missingPatterns) {
|
|
216520
|
-
logger.error(`checkScripts pattern matched no files: ${pattern}`);
|
|
216521
|
-
hasError = true;
|
|
216522
|
-
}
|
|
216523
|
-
for (const checkScriptPath of checkScriptPaths.paths) {
|
|
216524
|
-
const moduleExports = await loadRuntimeModule(checkScriptPath, {
|
|
216525
|
-
debug: context.buildScriptDebug
|
|
216526
|
-
});
|
|
216527
|
-
if (!moduleExports) {
|
|
216528
|
-
logger.error(`'${checkScriptPath}' is not a valid check script`);
|
|
216529
|
-
hasError = true;
|
|
216530
|
-
continue;
|
|
216531
|
-
}
|
|
216532
|
-
checkScriptModules.push({ path: checkScriptPath, moduleExports });
|
|
216533
|
-
}
|
|
216534
216514
|
const scriptEnv = {
|
|
216535
216515
|
fs: getFs(),
|
|
216536
216516
|
path: b3path_default,
|
|
@@ -216538,28 +216518,25 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
216538
216518
|
nodeDefs: context.nodeDefs,
|
|
216539
216519
|
logger
|
|
216540
216520
|
};
|
|
216541
|
-
const
|
|
216542
|
-
|
|
216543
|
-
checkScriptModules,
|
|
216544
|
-
scriptEnv
|
|
216545
|
-
);
|
|
216546
|
-
if (!buildScriptModule || buildRuntime.hasError || !buildRuntime.buildScript) {
|
|
216521
|
+
const buildScript = createBatchHooks(buildScriptModule, scriptEnv);
|
|
216522
|
+
if (!buildScriptModule || !buildScript) {
|
|
216547
216523
|
hasError = true;
|
|
216548
216524
|
}
|
|
216549
216525
|
try {
|
|
216550
|
-
if (!hasError ||
|
|
216526
|
+
if (!hasError || buildScript) {
|
|
216551
216527
|
for (const candidatePath of b3path_default.lsdir(b3path_default.dirname(project), true)) {
|
|
216552
216528
|
if (!isBehaviorTreeJsonPath(candidatePath)) {
|
|
216553
216529
|
continue;
|
|
216554
216530
|
}
|
|
216555
216531
|
totalFiles += 1;
|
|
216556
216532
|
const treeName = b3path_default.basenameWithoutExt(candidatePath);
|
|
216533
|
+
const originalDiskContent = getFs().readFileSync(candidatePath, "utf-8");
|
|
216557
216534
|
const originalTree = readTreeFromFile(candidatePath);
|
|
216558
216535
|
const originalContent = writeTree(originalTree, treeName);
|
|
216559
216536
|
const errors = [];
|
|
216560
216537
|
let tree = originalTree;
|
|
216561
216538
|
try {
|
|
216562
|
-
tree = processBatchTree(tree, candidatePath,
|
|
216539
|
+
tree = processBatchTree(tree, candidatePath, buildScript, errors);
|
|
216563
216540
|
} catch (error) {
|
|
216564
216541
|
errors.push(`batch script failed: ${formatRuntimeError(error)}`);
|
|
216565
216542
|
}
|
|
@@ -216568,34 +216545,6 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
216568
216545
|
skippedFiles += 1;
|
|
216569
216546
|
continue;
|
|
216570
216547
|
}
|
|
216571
|
-
const declare = {
|
|
216572
|
-
import: tree.variables.imports.map((importPath) => ({
|
|
216573
|
-
path: importPath,
|
|
216574
|
-
vars: [],
|
|
216575
|
-
depends: []
|
|
216576
|
-
})),
|
|
216577
|
-
vars: tree.variables.locals.map((variable) => ({
|
|
216578
|
-
name: variable.name,
|
|
216579
|
-
desc: variable.desc
|
|
216580
|
-
})),
|
|
216581
|
-
subtree: []
|
|
216582
|
-
};
|
|
216583
|
-
context.refreshVarDecl(tree.root, tree.group, declare);
|
|
216584
|
-
if (!context.checkNodeData(tree.root, (message) => errors.push(message))) {
|
|
216585
|
-
hasError = true;
|
|
216586
|
-
}
|
|
216587
|
-
const checkDiagnostics = collectNodeArgCheckDiagnostics({
|
|
216588
|
-
tree,
|
|
216589
|
-
treePath: candidatePath,
|
|
216590
|
-
env: scriptEnv,
|
|
216591
|
-
checkers: buildRuntime.nodeArgCheckers
|
|
216592
|
-
});
|
|
216593
|
-
if (checkDiagnostics.length) {
|
|
216594
|
-
hasError = true;
|
|
216595
|
-
checkDiagnostics.forEach(
|
|
216596
|
-
(diagnostic) => errors.push(formatNodeArgCheckBuildDiagnostic(diagnostic))
|
|
216597
|
-
);
|
|
216598
|
-
}
|
|
216599
216548
|
if (errors.length) {
|
|
216600
216549
|
hasError = true;
|
|
216601
216550
|
failedFiles += 1;
|
|
@@ -216604,7 +216553,9 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
216604
216553
|
continue;
|
|
216605
216554
|
}
|
|
216606
216555
|
const nextContent = writeTree(tree, treeName);
|
|
216607
|
-
|
|
216556
|
+
const changedByScript = nextContent !== originalContent;
|
|
216557
|
+
const changedByInputUpgrade = buildScript?.shouldUpgradeTree?.(candidatePath, tree) === true && nextContent !== originalDiskContent;
|
|
216558
|
+
if (!changedByScript && !changedByInputUpgrade) {
|
|
216608
216559
|
unchangedFiles += 1;
|
|
216609
216560
|
continue;
|
|
216610
216561
|
}
|
|
@@ -216618,7 +216569,7 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
216618
216569
|
if (!hasError) {
|
|
216619
216570
|
for (const staged of stagedWrites) {
|
|
216620
216571
|
try {
|
|
216621
|
-
|
|
216572
|
+
buildScript?.onWriteFile?.(staged.path, staged.tree);
|
|
216622
216573
|
} catch (error) {
|
|
216623
216574
|
hasError = true;
|
|
216624
216575
|
failedFiles += 1;
|
|
@@ -216638,7 +216589,7 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
216638
216589
|
} finally {
|
|
216639
216590
|
allErrors.forEach((message) => logger.error(message));
|
|
216640
216591
|
try {
|
|
216641
|
-
|
|
216592
|
+
buildScript?.onComplete?.(hasError ? "failure" : "success");
|
|
216642
216593
|
} catch (error) {
|
|
216643
216594
|
logger.error("batch script onComplete failed", error);
|
|
216644
216595
|
}
|
package/dist/extension.js
CHANGED
|
@@ -218736,7 +218736,7 @@ var hasBatchHookMethod = (obj) => {
|
|
|
218736
218736
|
return false;
|
|
218737
218737
|
}
|
|
218738
218738
|
const candidate = obj;
|
|
218739
|
-
return typeof candidate.onProcessTree === "function" || typeof candidate.onProcessNode === "function" || typeof candidate.onWriteFile === "function" || typeof candidate.onComplete === "function";
|
|
218739
|
+
return typeof candidate.shouldUpgradeTree === "function" || typeof candidate.onProcessTree === "function" || typeof candidate.onProcessNode === "function" || typeof candidate.onWriteFile === "function" || typeof candidate.onComplete === "function";
|
|
218740
218740
|
};
|
|
218741
218741
|
var BUILD_HOOK_MARKER = "__behavior3BuildHook";
|
|
218742
218742
|
var CHECK_HOOK_MARKER = "__behavior3CheckHook";
|
|
@@ -219618,11 +219618,8 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
219618
219618
|
let skippedFiles = 0;
|
|
219619
219619
|
let failedFiles = 0;
|
|
219620
219620
|
let writtenFiles = 0;
|
|
219621
|
-
const settings = readWorkspaceSettings(project);
|
|
219622
|
-
const checkScriptSetting = settings.checkScripts ?? [];
|
|
219623
219621
|
const allErrors = [];
|
|
219624
219622
|
const stagedWrites = [];
|
|
219625
|
-
context.setCheckExpr(context.checkExprOverride ?? settings.checkExpr ?? true);
|
|
219626
219623
|
let buildScriptModule;
|
|
219627
219624
|
try {
|
|
219628
219625
|
buildScriptModule = await loadRuntimeModule(scriptPath, {
|
|
@@ -219631,23 +219628,6 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
219631
219628
|
} catch {
|
|
219632
219629
|
logger.error(`'${scriptPath}' is not a valid batch script`);
|
|
219633
219630
|
}
|
|
219634
|
-
const checkScriptModules = [];
|
|
219635
|
-
const checkScriptPaths = resolveCheckScriptPaths(context.workdir, checkScriptSetting);
|
|
219636
|
-
for (const pattern of checkScriptPaths.missingPatterns) {
|
|
219637
|
-
logger.error(`checkScripts pattern matched no files: ${pattern}`);
|
|
219638
|
-
hasError = true;
|
|
219639
|
-
}
|
|
219640
|
-
for (const checkScriptPath of checkScriptPaths.paths) {
|
|
219641
|
-
const moduleExports = await loadRuntimeModule(checkScriptPath, {
|
|
219642
|
-
debug: context.buildScriptDebug
|
|
219643
|
-
});
|
|
219644
|
-
if (!moduleExports) {
|
|
219645
|
-
logger.error(`'${checkScriptPath}' is not a valid check script`);
|
|
219646
|
-
hasError = true;
|
|
219647
|
-
continue;
|
|
219648
|
-
}
|
|
219649
|
-
checkScriptModules.push({ path: checkScriptPath, moduleExports });
|
|
219650
|
-
}
|
|
219651
219631
|
const scriptEnv = {
|
|
219652
219632
|
fs: getFs(),
|
|
219653
219633
|
path: b3path_default,
|
|
@@ -219655,28 +219635,25 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
219655
219635
|
nodeDefs: context.nodeDefs,
|
|
219656
219636
|
logger
|
|
219657
219637
|
};
|
|
219658
|
-
const
|
|
219659
|
-
|
|
219660
|
-
checkScriptModules,
|
|
219661
|
-
scriptEnv
|
|
219662
|
-
);
|
|
219663
|
-
if (!buildScriptModule || buildRuntime.hasError || !buildRuntime.buildScript) {
|
|
219638
|
+
const buildScript = createBatchHooks(buildScriptModule, scriptEnv);
|
|
219639
|
+
if (!buildScriptModule || !buildScript) {
|
|
219664
219640
|
hasError = true;
|
|
219665
219641
|
}
|
|
219666
219642
|
try {
|
|
219667
|
-
if (!hasError ||
|
|
219643
|
+
if (!hasError || buildScript) {
|
|
219668
219644
|
for (const candidatePath of b3path_default.lsdir(b3path_default.dirname(project), true)) {
|
|
219669
219645
|
if (!isBehaviorTreeJsonPath(candidatePath)) {
|
|
219670
219646
|
continue;
|
|
219671
219647
|
}
|
|
219672
219648
|
totalFiles += 1;
|
|
219673
219649
|
const treeName = b3path_default.basenameWithoutExt(candidatePath);
|
|
219650
|
+
const originalDiskContent = getFs().readFileSync(candidatePath, "utf-8");
|
|
219674
219651
|
const originalTree = readTreeFromFile(candidatePath);
|
|
219675
219652
|
const originalContent = writeTree(originalTree, treeName);
|
|
219676
219653
|
const errors = [];
|
|
219677
219654
|
let tree = originalTree;
|
|
219678
219655
|
try {
|
|
219679
|
-
tree = processBatchTree(tree, candidatePath,
|
|
219656
|
+
tree = processBatchTree(tree, candidatePath, buildScript, errors);
|
|
219680
219657
|
} catch (error) {
|
|
219681
219658
|
errors.push(`batch script failed: ${formatRuntimeError(error)}`);
|
|
219682
219659
|
}
|
|
@@ -219685,34 +219662,6 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
219685
219662
|
skippedFiles += 1;
|
|
219686
219663
|
continue;
|
|
219687
219664
|
}
|
|
219688
|
-
const declare = {
|
|
219689
|
-
import: tree.variables.imports.map((importPath) => ({
|
|
219690
|
-
path: importPath,
|
|
219691
|
-
vars: [],
|
|
219692
|
-
depends: []
|
|
219693
|
-
})),
|
|
219694
|
-
vars: tree.variables.locals.map((variable) => ({
|
|
219695
|
-
name: variable.name,
|
|
219696
|
-
desc: variable.desc
|
|
219697
|
-
})),
|
|
219698
|
-
subtree: []
|
|
219699
|
-
};
|
|
219700
|
-
context.refreshVarDecl(tree.root, tree.group, declare);
|
|
219701
|
-
if (!context.checkNodeData(tree.root, (message) => errors.push(message))) {
|
|
219702
|
-
hasError = true;
|
|
219703
|
-
}
|
|
219704
|
-
const checkDiagnostics = collectNodeArgCheckDiagnostics({
|
|
219705
|
-
tree,
|
|
219706
|
-
treePath: candidatePath,
|
|
219707
|
-
env: scriptEnv,
|
|
219708
|
-
checkers: buildRuntime.nodeArgCheckers
|
|
219709
|
-
});
|
|
219710
|
-
if (checkDiagnostics.length) {
|
|
219711
|
-
hasError = true;
|
|
219712
|
-
checkDiagnostics.forEach(
|
|
219713
|
-
(diagnostic) => errors.push(formatNodeArgCheckBuildDiagnostic(diagnostic))
|
|
219714
|
-
);
|
|
219715
|
-
}
|
|
219716
219665
|
if (errors.length) {
|
|
219717
219666
|
hasError = true;
|
|
219718
219667
|
failedFiles += 1;
|
|
@@ -219721,7 +219670,9 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
219721
219670
|
continue;
|
|
219722
219671
|
}
|
|
219723
219672
|
const nextContent = writeTree(tree, treeName);
|
|
219724
|
-
|
|
219673
|
+
const changedByScript = nextContent !== originalContent;
|
|
219674
|
+
const changedByInputUpgrade = buildScript?.shouldUpgradeTree?.(candidatePath, tree) === true && nextContent !== originalDiskContent;
|
|
219675
|
+
if (!changedByScript && !changedByInputUpgrade) {
|
|
219725
219676
|
unchangedFiles += 1;
|
|
219726
219677
|
continue;
|
|
219727
219678
|
}
|
|
@@ -219735,7 +219686,7 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
219735
219686
|
if (!hasError) {
|
|
219736
219687
|
for (const staged of stagedWrites) {
|
|
219737
219688
|
try {
|
|
219738
|
-
|
|
219689
|
+
buildScript?.onWriteFile?.(staged.path, staged.tree);
|
|
219739
219690
|
} catch (error) {
|
|
219740
219691
|
hasError = true;
|
|
219741
219692
|
failedFiles += 1;
|
|
@@ -219755,7 +219706,7 @@ var batchProcessProjectWithContext = async (project, scriptPath, context) => {
|
|
|
219755
219706
|
} finally {
|
|
219756
219707
|
allErrors.forEach((message) => logger.error(message));
|
|
219757
219708
|
try {
|
|
219758
|
-
|
|
219709
|
+
buildScript?.onComplete?.(hasError ? "failure" : "success");
|
|
219759
219710
|
} catch (error) {
|
|
219760
219711
|
logger.error("batch script onComplete failed", error);
|
|
219761
219712
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 256 256" height="200px" width="200px" xmlns="http://www.w3.org/2000/svg"><path d="M160,
|
|
1
|
+
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 256 256" height="200px" width="200px" xmlns="http://www.w3.org/2000/svg"><path d="M160,112h48a16,16,0,0,0,16-16V48a16,16,0,0,0-16-16H160a16,16,0,0,0-16,16V64H128a24,24,0,0,0-24,24v32H72v-8A16,16,0,0,0,56,96H24A16,16,0,0,0,8,112v32a16,16,0,0,0,16,16H56a16,16,0,0,0,16-16v-8h32v32a24,24,0,0,0,24,24h16v16a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V160a16,16,0,0,0-16-16H160a16,16,0,0,0-16,16v16H128a8,8,0,0,1-8-8V88a8,8,0,0,1,8-8h16V96A16,16,0,0,0,160,112ZM56,144H24V112H56v32Zm104,16h48v48H160Zm0-112h48V96H160Z"></path></svg>
|
package/media/icons/icon.svg
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 256 256" height="200px" width="200px" xmlns="http://www.w3.org/2000/svg"><path d="M160,
|
|
1
|
+
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 256 256" height="200px" width="200px" xmlns="http://www.w3.org/2000/svg"><path d="M160,112h48a16,16,0,0,0,16-16V48a16,16,0,0,0-16-16H160a16,16,0,0,0-16,16V64H128a24,24,0,0,0-24,24v32H72v-8A16,16,0,0,0,56,96H24A16,16,0,0,0,8,112v32a16,16,0,0,0,16,16H56a16,16,0,0,0,16-16v-8h32v32a24,24,0,0,0,24,24h16v16a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V160a16,16,0,0,0-16-16H160a16,16,0,0,0-16,16v16H128a8,8,0,0,1-8-8V88a8,8,0,0,1,8-8h16V96A16,16,0,0,0,160,112ZM56,144H24V112H56v32Zm104,16h48v48H160Zm0-112h48V96H160Z"></path></svg>
|
package/package.json
CHANGED
|
@@ -62,6 +62,7 @@ export interface NodeArgChecker {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export type BuildScript = {
|
|
65
|
+
shouldUpgradeTree?: (path: string, tree: TreeData) => boolean;
|
|
65
66
|
onProcessTree?: (tree: TreeData, path: string, errors: string[]) => TreeData | null;
|
|
66
67
|
onProcessNode?: (node: NodeData, errors: string[]) => NodeData | null;
|
|
67
68
|
onWriteFile?: (path: string, tree: TreeData) => void;
|
|
@@ -91,6 +92,7 @@ export type BuildRuntime = {
|
|
|
91
92
|
|
|
92
93
|
export declare class Hook implements BuildScript {
|
|
93
94
|
constructor(env: BuildEnv);
|
|
95
|
+
shouldUpgradeTree?(path: string, tree: TreeData): boolean;
|
|
94
96
|
onProcessTree?(tree: TreeData, path: string, errors: string[]): TreeData | null;
|
|
95
97
|
onProcessNode?(node: NodeData, errors: string[]): NodeData | null;
|
|
96
98
|
onWriteFile?(path: string, tree: TreeData): void;
|