vscode-behavior3 2.2.0 → 2.3.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/README.md +119 -138
- package/build.d.ts +5 -0
- package/dist/build-cli.js +73 -16
- package/dist/extension.js +355 -49
- package/dist/webview/assets/editor-466vlAsX.js +8 -0
- package/dist/webview/assets/editor-CTBBjkkm.css +1 -0
- package/dist/webview/assets/{vendor-BuywoAnb.js → vendor-Ctok02TG.js} +23 -23
- package/dist/webview/index.html +3 -3
- package/dist/webview/locales/en.json +5 -0
- package/dist/webview/locales/zh.json +5 -0
- package/package.json +30 -10
- package/package.nls.json +4 -2
- package/package.nls.zh-cn.json +4 -2
- package/webview/shared/b3build-model.d.ts +22 -2
- package/dist/webview/assets/editor-BxvY-Wyu.css +0 -1
- package/dist/webview/assets/editor-DaW6jFnb.js +0 -7
package/README.md
CHANGED
|
@@ -1,212 +1,185 @@
|
|
|
1
1
|
# Behavior3 Editor
|
|
2
2
|
|
|
3
|
-
VS Code behavior
|
|
3
|
+
VS Code custom editor for Behavior3 JSON behavior trees. It combines a visual graph canvas, an Inspector, project scaffolding, and build/check/batch scripting for game AI workflows.
|
|
4
4
|
|
|
5
5
|
## Related Projects
|
|
6
6
|
|
|
7
|
-
- **[behavior3-ts](https://github.com/codetypess/behavior3-ts)** - TypeScript
|
|
8
|
-
- **[behavior3lua](https://github.com/zhandouxiaojiji/behavior3lua)** - Lua
|
|
7
|
+
- **[behavior3-ts](https://github.com/codetypess/behavior3-ts)** - TypeScript runtime library
|
|
8
|
+
- **[behavior3lua](https://github.com/zhandouxiaojiji/behavior3lua)** - Lua runtime
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Preview
|
|
11
11
|
|
|
12
12
|

|
|
13
13
|
|
|
14
|
-
The editor provides an intuitive visual interface for designing and managing behavior trees. See the screenshot above for the full editing experience with node canvas, inspector panel, and tree organization.
|
|
15
|
-
|
|
16
14
|
## Features
|
|
17
15
|
|
|
18
|
-
- Visual
|
|
19
|
-
-
|
|
16
|
+
- Visual graph editor for Behavior3 trees and reachable subtrees
|
|
17
|
+
- Inspector in `sidebar` or `embedded` mode
|
|
18
|
+
- Explorer `Behavior3` submenu for project, tree, and script scaffolding
|
|
19
|
+
- Build, debug build, checker scripts, and project batch processing
|
|
20
20
|
- Custom node definitions via `.b3-setting`
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- Auto theme adaptation (dark/light)
|
|
21
|
+
- Expression and node-argument validation
|
|
22
|
+
- Theme-aware UI for dark and light VS Code themes
|
|
24
23
|
|
|
25
24
|
## Quick Start
|
|
26
25
|
|
|
27
|
-
### Open a tree
|
|
26
|
+
### Open a tree
|
|
27
|
+
|
|
28
|
+
- Right-click a Behavior3 `.json` file in Explorer
|
|
29
|
+
- Select **Open With** -> **Behavior3 Editor**
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
- Select **Open With** → **Behavior3 Editor**
|
|
31
|
+
### Create project files
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
From a folder's Explorer `Behavior3` submenu you can run:
|
|
33
34
|
|
|
34
|
-
-
|
|
35
|
-
-
|
|
35
|
+
- **Create Project**
|
|
36
|
+
- **Create Behavior Tree File**
|
|
37
|
+
- **Create Build Script**
|
|
38
|
+
- **Create Batch Script**
|
|
39
|
+
- **Create Checker Script**
|
|
40
|
+
- **Run Script as Batch Process**
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
`Run Script as Batch Process` is also available on `.ts`, `.mts`, `.js`, and `.mjs` files. Running it from a folder lets you choose a script first; running it from a script file runs that script directly.
|
|
38
43
|
|
|
39
|
-
|
|
44
|
+
### Configure node definitions
|
|
45
|
+
|
|
46
|
+
Create a `.b3-setting` file in the workspace:
|
|
40
47
|
|
|
41
48
|
```json
|
|
42
49
|
[
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
{
|
|
51
|
+
"name": "MyAction",
|
|
52
|
+
"type": "Action",
|
|
53
|
+
"desc": "Does something useful",
|
|
54
|
+
"args": [{ "name": "duration", "type": "float", "desc": "Duration in seconds" }]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "CheckScore",
|
|
58
|
+
"type": "Condition",
|
|
59
|
+
"desc": "Checks whether the score matches the rule",
|
|
60
|
+
"args": [{ "name": "value", "type": "expr", "desc": "Expression" }]
|
|
61
|
+
}
|
|
55
62
|
]
|
|
56
63
|
```
|
|
57
64
|
|
|
58
|
-
###
|
|
59
|
-
|
|
60
|
-
Click **Build** in the editor title bar.
|
|
65
|
+
### Configure workspace behavior
|
|
61
66
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
The npm package exposes a `behavior3-build` command for CI and project scripts:
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
npm install -D vscode-behavior3
|
|
68
|
-
```
|
|
67
|
+
Use a `.b3-workspace` file to register build and checker scripts:
|
|
69
68
|
|
|
70
69
|
```json
|
|
71
70
|
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
"settings": {
|
|
72
|
+
"checkExpr": true,
|
|
73
|
+
"buildScript": "scripts/build.ts",
|
|
74
|
+
"checkScripts": ["scripts/checkers/**/*.ts"]
|
|
75
|
+
}
|
|
75
76
|
}
|
|
76
77
|
```
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
npm exec -- behavior3-build --project ./workdir/hero.json --output ./dist/behavior3
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Or run it without installing first:
|
|
79
|
+
`buildScript` and `checkScripts` are resolved relative to the `.b3-workspace` file. See [sample/workspace.b3-workspace](sample/workspace.b3-workspace) for a complete sample.
|
|
85
80
|
|
|
86
|
-
|
|
87
|
-
npx --package vscode-behavior3 behavior3-build --project ./workdir/hero.json --output ./dist/behavior3
|
|
88
|
-
```
|
|
81
|
+
## Inspector Modes
|
|
89
82
|
|
|
90
|
-
|
|
83
|
+
Set `behavior3.inspectorMode` to choose the active Inspector presentation:
|
|
91
84
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
npm whoami
|
|
95
|
-
npm version patch
|
|
96
|
-
npm run pack:npm
|
|
97
|
-
npm run publish:npm
|
|
98
|
-
```
|
|
85
|
+
- `sidebar`: show the Inspector in the dedicated Behavior3 side view
|
|
86
|
+
- `embedded`: show the Inspector inside the main editor webview
|
|
99
87
|
|
|
100
|
-
|
|
101
|
-
tarball contents without publishing.
|
|
88
|
+
Both modes share the same document semantics and commands. Only the presentation changes.
|
|
102
89
|
|
|
103
|
-
|
|
90
|
+
## Build, Batch, and Check Scripts
|
|
104
91
|
|
|
105
|
-
|
|
92
|
+
Behavior3 supports ESM JavaScript and TypeScript scripts:
|
|
106
93
|
|
|
107
94
|
- JavaScript: `.js`, `.mjs`
|
|
108
95
|
- TypeScript: `.ts`, `.mts` (runtime transpile, no type-check)
|
|
109
96
|
|
|
110
|
-
|
|
111
|
-
|
|
97
|
+
When importing local TypeScript helpers, use explicit extensions such as `./helper.ts`.
|
|
98
|
+
The `behavior3` decorator namespace is provided by the runtime, so script files only need type imports from `vscode-behavior3/build`.
|
|
112
99
|
|
|
113
|
-
|
|
114
|
-
import { helper } from "./helper.ts";
|
|
115
|
-
```
|
|
100
|
+
All script types can import authoring types from `vscode-behavior3/build`. Example scripts are available in:
|
|
116
101
|
|
|
117
|
-
|
|
118
|
-
|
|
102
|
+
- [sample/scripts/build.ts](sample/scripts/build.ts)
|
|
103
|
+
- [sample/scripts/batch.ts](sample/scripts/batch.ts)
|
|
104
|
+
- [sample/scripts/checkers/positive.ts](sample/scripts/checkers/positive.ts)
|
|
119
105
|
|
|
120
|
-
|
|
121
|
-
BEHAVIOR3_BUILD_DEBUG=1 node --inspect-brk dist/build-cli.js --output /tmp/b3build --project sample/workdir/hero.json
|
|
122
|
-
```
|
|
106
|
+
### Build Scripts
|
|
123
107
|
|
|
124
|
-
|
|
125
|
-
to the build script while the build runs so breakpoints in `build.ts` and
|
|
126
|
-
imported helper files can bind. The runtime files are removed after the build
|
|
127
|
-
completes; if the build script fails to load, they are left in place for
|
|
128
|
-
inspection. Editor debug builds also clean runtime files when the debug session
|
|
129
|
-
terminates.
|
|
130
|
-
Inside the editor, `Ctrl+B`/`Cmd+B` builds normally, while
|
|
131
|
-
`Ctrl+Shift+B`/`Cmd+Shift+B` starts a VS Code Node debug session for the build.
|
|
108
|
+
Build scripts are declared with `@behavior3.build` and can transform build output without rewriting source trees.
|
|
132
109
|
|
|
133
|
-
|
|
110
|
+
```ts
|
|
111
|
+
import type { BuildEnv, BuildScript } from "vscode-behavior3/build";
|
|
134
112
|
|
|
135
|
-
|
|
136
|
-
{
|
|
137
|
-
|
|
138
|
-
"checkExpr": true,
|
|
139
|
-
"buildScript": "scripts/build.ts",
|
|
140
|
-
"checkScripts": ["scripts/checkers/**/*.ts"]
|
|
141
|
-
}
|
|
113
|
+
@behavior3.build
|
|
114
|
+
export class ProjectBuild implements BuildScript {
|
|
115
|
+
constructor(private readonly env: BuildEnv) {}
|
|
142
116
|
}
|
|
143
117
|
```
|
|
144
118
|
|
|
145
|
-
|
|
146
|
-
relative to the `.b3-workspace` directory. Matching scripts are scanned for
|
|
147
|
-
exported `@behavior3.check("name")` classes and are used by both the editor
|
|
148
|
-
Inspector validation and project builds. Generated `.runtime.*.mjs`, `.d.ts`,
|
|
149
|
-
`node_modules`, `dist`, and `build` paths are ignored.
|
|
119
|
+
Supported hooks:
|
|
150
120
|
|
|
151
|
-
|
|
121
|
+
- `onProcessTree(tree, path, errors)`
|
|
122
|
+
- `onProcessNode(node, errors)`
|
|
123
|
+
- `onWriteFile(path, tree)`
|
|
124
|
+
- `onComplete(status)`
|
|
125
|
+
|
|
126
|
+
### Batch Scripts
|
|
152
127
|
|
|
153
|
-
|
|
154
|
-
- `env.path`: full path helper object (all methods exposed)
|
|
155
|
-
- `env.workdir`: resolved workspace directory
|
|
156
|
-
- `env.nodeDefs`: loaded node definitions map
|
|
157
|
-
- `env.logger`: `log/debug/info/warn/error`
|
|
128
|
+
Batch scripts are declared with `@behavior3.batch` and are used by **Run Script as Batch Process** to rewrite source trees in place across the current project.
|
|
158
129
|
|
|
159
|
-
|
|
160
|
-
runtime, so no value import is required. The extension constructs the class once
|
|
161
|
-
with `env`, then calls methods:
|
|
130
|
+
Supported hooks:
|
|
162
131
|
|
|
163
|
-
- `constructor(env)`
|
|
164
132
|
- `shouldUpgradeTree(path, tree)`
|
|
165
133
|
- `onProcessTree(tree, path, errors)`
|
|
166
134
|
- `onProcessNode(node, errors)`
|
|
167
135
|
- `onWriteFile(path, tree)`
|
|
168
136
|
- `onComplete(status)`
|
|
169
137
|
|
|
170
|
-
|
|
171
|
-
import type { BuildEnv, TreeData } from "vscode-behavior3/build";
|
|
138
|
+
### Checker Scripts
|
|
172
139
|
|
|
173
|
-
|
|
174
|
-
export class ProjectBuild {
|
|
175
|
-
constructor(private readonly env: BuildEnv) {}
|
|
140
|
+
Checker scripts register custom argument validators with `@behavior3.check("name")`. They are used by both Inspector validation and project builds.
|
|
176
141
|
|
|
177
|
-
|
|
178
|
-
this.env.logger.info("building", tree.name);
|
|
179
|
-
return tree;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
```
|
|
142
|
+
For compatibility, supported script files may still export classes through named `Hook`, `BuildHook`, `BatchHook`, or `default`, but the decorator-based forms above are the canonical APIs.
|
|
183
143
|
|
|
184
|
-
|
|
185
|
-
`Hook` or `default`.
|
|
144
|
+
## Build and Debug
|
|
186
145
|
|
|
187
|
-
|
|
188
|
-
|
|
146
|
+
- Click **Build** in the editor title bar, or press `Ctrl/Cmd+B`
|
|
147
|
+
- Press `Ctrl/Cmd+Shift+B` to start a debug build session
|
|
189
148
|
|
|
190
|
-
|
|
149
|
+
The npm package also exposes a `behavior3-build` command for CI and project scripts:
|
|
191
150
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
151
|
+
```bash
|
|
152
|
+
npm install -D vscode-behavior3
|
|
153
|
+
```
|
|
195
154
|
|
|
196
|
-
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"scripts": {
|
|
158
|
+
"build:behavior": "behavior3-build --project ./workdir/hero.json --output ./dist/behavior3"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
197
162
|
|
|
198
|
-
|
|
199
|
-
| --------------------- | ------- | -------- | ---------------------------------------------------------------- |
|
|
200
|
-
| `behavior3.checkExpr` | boolean | `true` | Enable expression syntax validation for expression-type args. |
|
|
201
|
-
| `behavior3.language` | string | `"auto"` | Editor UI language. Options:`auto` (follow VS Code), `zh`, `en`. |
|
|
163
|
+
You can also run it directly:
|
|
202
164
|
|
|
203
|
-
|
|
165
|
+
```bash
|
|
166
|
+
npm exec -- behavior3-build --project ./workdir/hero.json --output ./dist/behavior3
|
|
167
|
+
```
|
|
204
168
|
|
|
205
|
-
|
|
169
|
+
Or without installing first:
|
|
206
170
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
171
|
+
```bash
|
|
172
|
+
npx --package vscode-behavior3 behavior3-build --project ./workdir/hero.json --output ./dist/behavior3
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Extension Settings
|
|
176
|
+
|
|
177
|
+
| Setting | Type | Default | Description |
|
|
178
|
+
| --------------------------- | --------- | ----------- | ------------------------------------------------------------------------ |
|
|
179
|
+
| `behavior3.checkExpr` | `boolean` | `true` | Enable expression validation for expression-type args. |
|
|
180
|
+
| `behavior3.language` | `string` | `"auto"` | UI language: `auto`, `zh`, or `en`. |
|
|
181
|
+
| `behavior3.subtreeEditable` | `boolean` | `true` | Allow editing supported subtree content from the current editor context. |
|
|
182
|
+
| `behavior3.inspectorMode` | `string` | `"sidebar"` | Choose whether the Inspector is shown in `sidebar` or `embedded` mode. |
|
|
210
183
|
|
|
211
184
|
## Keyboard Shortcuts
|
|
212
185
|
|
|
@@ -224,14 +197,22 @@ Inspector is available in the dedicated `behavior3` sidebar and supports direct
|
|
|
224
197
|
| `Ctrl/Cmd+B` | Build |
|
|
225
198
|
| `F4` | Toggle Text / Behavior3 editor |
|
|
226
199
|
|
|
200
|
+
## Docs
|
|
201
|
+
|
|
202
|
+
- [docs/README.md](docs/README.md) - documentation entry point
|
|
203
|
+
- [docs/spec-driven-development.md](docs/spec-driven-development.md) - SDD workflow
|
|
204
|
+
- [docs/spec/README.md](docs/spec/README.md) - baseline spec map and work-item index
|
|
205
|
+
- [sample/](sample) - sample workspace, trees, and scripts
|
|
206
|
+
|
|
227
207
|
## Development
|
|
228
208
|
|
|
229
|
-
- Output logs: **View
|
|
209
|
+
- Output logs: **View -> Output** -> **Behavior3**
|
|
230
210
|
- Webview logs are also available in DevTools
|
|
231
211
|
|
|
232
212
|
## Requirements
|
|
233
213
|
|
|
234
|
-
- VS Code 1.
|
|
214
|
+
- VS Code `^1.105.0`
|
|
215
|
+
- Node `>=20.19` for the CLI and TypeScript script runtime
|
|
235
216
|
|
|
236
217
|
## License
|
|
237
218
|
|
package/build.d.ts
CHANGED
|
@@ -2,9 +2,14 @@ import type { BuildRuntime } from "./webview/shared/b3build-model";
|
|
|
2
2
|
export type { NodeDef } from "behavior3";
|
|
3
3
|
export type { NodeData, TreeData } from "./webview/shared/b3type";
|
|
4
4
|
export type {
|
|
5
|
+
BatchDecorator,
|
|
6
|
+
BatchHook,
|
|
7
|
+
BatchHookClass,
|
|
8
|
+
BatchScript,
|
|
5
9
|
BuildEnv,
|
|
6
10
|
CheckDecorator,
|
|
7
11
|
BuildDecorator,
|
|
12
|
+
BuildHook,
|
|
8
13
|
BuildHookClass,
|
|
9
14
|
BuildLogger,
|
|
10
15
|
BuildRuntime,
|
package/dist/build-cli.js
CHANGED
|
@@ -213347,14 +213347,15 @@ var readWorkspaceSettings = (path3) => {
|
|
|
213347
213347
|
const content = getFs().readFileSync(path3, "utf-8");
|
|
213348
213348
|
return parseWorkspaceModelContent(content).settings;
|
|
213349
213349
|
};
|
|
213350
|
-
var
|
|
213350
|
+
var hasBuildHookMethod = (obj) => {
|
|
213351
213351
|
if (!obj || typeof obj !== "object") {
|
|
213352
213352
|
return false;
|
|
213353
213353
|
}
|
|
213354
213354
|
const candidate = obj;
|
|
213355
|
-
return typeof candidate.
|
|
213355
|
+
return typeof candidate.onProcessTree === "function" || typeof candidate.onProcessNode === "function" || typeof candidate.onWriteFile === "function" || typeof candidate.onComplete === "function";
|
|
213356
213356
|
};
|
|
213357
213357
|
var BUILD_HOOK_MARKER = "__behavior3BuildHook";
|
|
213358
|
+
var BATCH_HOOK_MARKER = "__behavior3BatchHook";
|
|
213358
213359
|
var CHECK_HOOK_MARKER = "__behavior3CheckHook";
|
|
213359
213360
|
var CHECK_HOOK_NAME = "__behavior3CheckName";
|
|
213360
213361
|
var markBuildHook = (ctor) => {
|
|
@@ -213364,6 +213365,13 @@ var markBuildHook = (ctor) => {
|
|
|
213364
213365
|
});
|
|
213365
213366
|
return ctor;
|
|
213366
213367
|
};
|
|
213368
|
+
var markBatchHook = (ctor) => {
|
|
213369
|
+
Object.defineProperty(ctor, BATCH_HOOK_MARKER, {
|
|
213370
|
+
value: true,
|
|
213371
|
+
configurable: false
|
|
213372
|
+
});
|
|
213373
|
+
return ctor;
|
|
213374
|
+
};
|
|
213367
213375
|
var markCheckCtor = (ctor, explicitName) => {
|
|
213368
213376
|
const name = explicitName?.trim() || ctor.name;
|
|
213369
213377
|
Object.defineProperty(ctor, CHECK_HOOK_MARKER, {
|
|
@@ -213382,28 +213390,51 @@ var markCheckHook = (nameOrCtor, _context) => {
|
|
|
213382
213390
|
}
|
|
213383
213391
|
return (ctor) => markCheckCtor(ctor, nameOrCtor);
|
|
213384
213392
|
};
|
|
213385
|
-
var
|
|
213393
|
+
var isDecoratedBuildHookCtor = (value) => typeof value === "function" && value[BUILD_HOOK_MARKER] === true;
|
|
213394
|
+
var isDecoratedBatchHookCtor = (value) => typeof value === "function" && value[BATCH_HOOK_MARKER] === true;
|
|
213386
213395
|
var isDecoratedCheckCtor = (value) => typeof value === "function" && value[CHECK_HOOK_MARKER] === true;
|
|
213387
|
-
var
|
|
213388
|
-
const decorated = Array.from(new Set(Object.values(moduleRecord))).filter(
|
|
213396
|
+
var findDecoratedBuildHookCtor = (moduleRecord) => {
|
|
213397
|
+
const decorated = Array.from(new Set(Object.values(moduleRecord))).filter(
|
|
213398
|
+
isDecoratedBuildHookCtor
|
|
213399
|
+
);
|
|
213389
213400
|
if (decorated.length > 1) {
|
|
213390
213401
|
logger.error("build script must decorate exactly one exported class with @behavior3.build");
|
|
213391
213402
|
return void 0;
|
|
213392
213403
|
}
|
|
213393
213404
|
return decorated[0];
|
|
213394
213405
|
};
|
|
213406
|
+
var findDecoratedBatchHookCtor = (moduleRecord) => {
|
|
213407
|
+
const decorated = Array.from(new Set(Object.values(moduleRecord))).filter(
|
|
213408
|
+
isDecoratedBatchHookCtor
|
|
213409
|
+
);
|
|
213410
|
+
if (decorated.length > 1) {
|
|
213411
|
+
logger.error("batch script must decorate exactly one exported class with @behavior3.batch");
|
|
213412
|
+
return void 0;
|
|
213413
|
+
}
|
|
213414
|
+
if (decorated.length === 1) {
|
|
213415
|
+
return decorated[0];
|
|
213416
|
+
}
|
|
213417
|
+
const legacyDecorated = Array.from(new Set(Object.values(moduleRecord))).filter(
|
|
213418
|
+
isDecoratedBuildHookCtor
|
|
213419
|
+
);
|
|
213420
|
+
if (legacyDecorated.length > 1) {
|
|
213421
|
+
logger.error("batch script must decorate exactly one exported class with @behavior3.batch");
|
|
213422
|
+
return void 0;
|
|
213423
|
+
}
|
|
213424
|
+
return legacyDecorated[0];
|
|
213425
|
+
};
|
|
213395
213426
|
var findDecoratedCheckCtors = (moduleRecord) => Array.from(new Set(Object.values(moduleRecord))).filter(isDecoratedCheckCtor);
|
|
213396
|
-
var
|
|
213427
|
+
var createBuildHooks = (moduleExports, env, reportMissing = true) => {
|
|
213397
213428
|
if (!moduleExports || typeof moduleExports !== "object") {
|
|
213398
213429
|
return void 0;
|
|
213399
213430
|
}
|
|
213400
213431
|
const moduleRecord = moduleExports;
|
|
213401
|
-
const defaultExport = isDecoratedCheckCtor(moduleRecord.default) ? void 0 : moduleRecord.default;
|
|
213402
|
-
const ctor = moduleRecord.Hook ??
|
|
213432
|
+
const defaultExport = isDecoratedCheckCtor(moduleRecord.default) || isDecoratedBatchHookCtor(moduleRecord.default) ? void 0 : moduleRecord.default;
|
|
213433
|
+
const ctor = moduleRecord.BuildHook ?? moduleRecord.Hook ?? findDecoratedBuildHookCtor(moduleRecord) ?? defaultExport;
|
|
213403
213434
|
if (typeof ctor === "function") {
|
|
213404
213435
|
try {
|
|
213405
213436
|
const instance = new ctor(env);
|
|
213406
|
-
if (
|
|
213437
|
+
if (hasBuildHookMethod(instance)) {
|
|
213407
213438
|
return instance;
|
|
213408
213439
|
}
|
|
213409
213440
|
logger.error("build hook class instance has no supported hook methods");
|
|
@@ -213413,7 +213444,32 @@ var createBatchHooks = (moduleExports, env, reportMissing = true) => {
|
|
|
213413
213444
|
}
|
|
213414
213445
|
if (reportMissing) {
|
|
213415
213446
|
logger.error(
|
|
213416
|
-
"build script must export a Hook class, default class, or one @behavior3.build-decorated class"
|
|
213447
|
+
"build script must export a BuildHook class, Hook class, default class, or one @behavior3.build-decorated class"
|
|
213448
|
+
);
|
|
213449
|
+
}
|
|
213450
|
+
return void 0;
|
|
213451
|
+
};
|
|
213452
|
+
var createBatchHooks = (moduleExports, env, reportMissing = true) => {
|
|
213453
|
+
if (!moduleExports || typeof moduleExports !== "object") {
|
|
213454
|
+
return void 0;
|
|
213455
|
+
}
|
|
213456
|
+
const moduleRecord = moduleExports;
|
|
213457
|
+
const defaultExport = isDecoratedCheckCtor(moduleRecord.default) || isDecoratedBuildHookCtor(moduleRecord.default) || isDecoratedBatchHookCtor(moduleRecord.default) ? void 0 : moduleRecord.default;
|
|
213458
|
+
const ctor = moduleRecord.BatchHook ?? findDecoratedBatchHookCtor(moduleRecord) ?? moduleRecord.Hook ?? defaultExport;
|
|
213459
|
+
if (typeof ctor === "function") {
|
|
213460
|
+
try {
|
|
213461
|
+
const instance = new ctor(env);
|
|
213462
|
+
if (hasBuildHookMethod(instance) || typeof instance.shouldUpgradeTree === "function") {
|
|
213463
|
+
return instance;
|
|
213464
|
+
}
|
|
213465
|
+
logger.error("batch hook class instance has no supported hook methods");
|
|
213466
|
+
} catch (error) {
|
|
213467
|
+
logger.error("failed to instantiate batch hook class", error);
|
|
213468
|
+
}
|
|
213469
|
+
}
|
|
213470
|
+
if (reportMissing) {
|
|
213471
|
+
logger.error(
|
|
213472
|
+
"batch script must export a BatchHook class, default class, or one @behavior3.batch-decorated class"
|
|
213417
213473
|
);
|
|
213418
213474
|
}
|
|
213419
213475
|
return void 0;
|
|
@@ -213462,13 +213518,13 @@ var createBuildScriptRuntime = (moduleExports, env) => {
|
|
|
213462
213518
|
};
|
|
213463
213519
|
}
|
|
213464
213520
|
const moduleRecord = moduleExports;
|
|
213465
|
-
const hasBuildHookCandidate = typeof moduleRecord.Hook === "function" || Object.values(moduleRecord).some(
|
|
213466
|
-
const buildScript =
|
|
213521
|
+
const hasBuildHookCandidate = typeof moduleRecord.BuildHook === "function" || typeof moduleRecord.Hook === "function" || Object.values(moduleRecord).some(isDecoratedBuildHookCtor) || typeof moduleRecord.default === "function" && !isDecoratedCheckCtor(moduleRecord.default) && !isDecoratedBatchHookCtor(moduleRecord.default);
|
|
213522
|
+
const buildScript = createBuildHooks(moduleExports, env, false);
|
|
213467
213523
|
const checkerResult = createNodeArgCheckers(moduleExports, env);
|
|
213468
213524
|
const hasEntries = Boolean(buildScript) || checkerResult.hasCheckers;
|
|
213469
213525
|
if (!hasEntries) {
|
|
213470
213526
|
logger.error(
|
|
213471
|
-
"build script must export a Hook class, default build class, @behavior3.build class, or @behavior3.check class"
|
|
213527
|
+
"build script must export a BuildHook class, Hook class, default build class, @behavior3.build class, or @behavior3.check class"
|
|
213472
213528
|
);
|
|
213473
213529
|
}
|
|
213474
213530
|
return {
|
|
@@ -213889,6 +213945,7 @@ var applyBehavior3DecoratorGlobal = () => {
|
|
|
213889
213945
|
runtimeGlobal.behavior3 = {
|
|
213890
213946
|
...decoratorGlobalState.previousBehavior3 && typeof decoratorGlobalState.previousBehavior3 === "object" ? decoratorGlobalState.previousBehavior3 : {},
|
|
213891
213947
|
build: markBuildHook,
|
|
213948
|
+
batch: markBatchHook,
|
|
213892
213949
|
check: markCheckHook
|
|
213893
213950
|
};
|
|
213894
213951
|
};
|
|
@@ -213909,7 +213966,7 @@ var restoreBehavior3DecoratorGlobal = () => {
|
|
|
213909
213966
|
decoratorGlobalState.hadBehavior3 = false;
|
|
213910
213967
|
decoratorGlobalState.previousBehavior3 = void 0;
|
|
213911
213968
|
};
|
|
213912
|
-
var
|
|
213969
|
+
var withBehavior3ScriptDecoratorGlobal = async (loader) => {
|
|
213913
213970
|
applyBehavior3DecoratorGlobal();
|
|
213914
213971
|
try {
|
|
213915
213972
|
return await loader();
|
|
@@ -214048,7 +214105,7 @@ var loadRuntimeModule = async (modulePath, options) => {
|
|
|
214048
214105
|
}
|
|
214049
214106
|
}
|
|
214050
214107
|
if (getRuntimeProcess()?.type === "renderer") {
|
|
214051
|
-
return await
|
|
214108
|
+
return await withBehavior3ScriptDecoratorGlobal(
|
|
214052
214109
|
() => import(
|
|
214053
214110
|
/* @vite-ignore */
|
|
214054
214111
|
`${modulePath}?t=${Date.now()}`
|
|
@@ -214076,7 +214133,7 @@ var loadRuntimeModule = async (modulePath, options) => {
|
|
|
214076
214133
|
return null;
|
|
214077
214134
|
}
|
|
214078
214135
|
const normalizedModulePath = b3path_default.posixPath(tempModulePath);
|
|
214079
|
-
const result = await
|
|
214136
|
+
const result = await withBehavior3ScriptDecoratorGlobal(
|
|
214080
214137
|
() => import(
|
|
214081
214138
|
/* @vite-ignore */
|
|
214082
214139
|
`file:///${normalizedModulePath}?t=${Date.now()}`
|