vscode-behavior3 2.1.1
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/LICENSE +21 -0
- package/README.md +237 -0
- package/build.d.ts +24 -0
- package/dist/build-cli.js +220367 -0
- package/dist/extension.js +225724 -0
- package/dist/webview/assets/editor-Ko79XsIi.css +1 -0
- package/dist/webview/assets/editor-RJ_NkY97.js +534 -0
- package/dist/webview/assets/worker-B9qc9nkC.js +13 -0
- package/dist/webview/codicons/LICENSE +399 -0
- package/dist/webview/codicons/LICENSE-CODE +21 -0
- package/dist/webview/codicons/codicon.css +712 -0
- package/dist/webview/codicons/codicon.ttf +0 -0
- package/dist/webview/icons/Action.svg +1 -0
- package/dist/webview/icons/Composite.svg +1 -0
- package/dist/webview/icons/Condition.svg +1 -0
- package/dist/webview/icons/Debug.svg +1 -0
- package/dist/webview/icons/Decorator.svg +1 -0
- package/dist/webview/icons/Disabled.svg +1 -0
- package/dist/webview/icons/Error.svg +1 -0
- package/dist/webview/icons/Other.svg +1 -0
- package/dist/webview/icons/icon.svg +1 -0
- package/dist/webview/icons/status000.svg +40 -0
- package/dist/webview/icons/status001.svg +50 -0
- package/dist/webview/icons/status010.svg +50 -0
- package/dist/webview/icons/status011.svg +60 -0
- package/dist/webview/icons/status100.svg +50 -0
- package/dist/webview/icons/status101.svg +60 -0
- package/dist/webview/icons/status110.svg +60 -0
- package/dist/webview/icons/status111.svg +70 -0
- package/dist/webview/images/pic.png +0 -0
- package/dist/webview/index.html +14 -0
- package/dist/webview/locales/en.json +212 -0
- package/dist/webview/locales/zh.json +211 -0
- package/icon.png +0 -0
- package/media/icons/icon.svg +1 -0
- package/package.json +313 -0
- package/package.nls.json +28 -0
- package/package.nls.zh-cn.json +28 -0
- package/webview/shared/b3build-model.d.ts +98 -0
- package/webview/shared/b3type.ts +112 -0
package/package.json
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vscode-behavior3",
|
|
3
|
+
"displayName": "%extension.displayName%",
|
|
4
|
+
"description": "%extension.description%",
|
|
5
|
+
"version": "2.1.1",
|
|
6
|
+
"publisher": "codetypess",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/codetypess/vscode-behavior3"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"behavior3",
|
|
13
|
+
"behavior-tree",
|
|
14
|
+
"vscode",
|
|
15
|
+
"cli",
|
|
16
|
+
"game-ai"
|
|
17
|
+
],
|
|
18
|
+
"bin": {
|
|
19
|
+
"behavior3-build": "./dist/build-cli.js"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
"./build": {
|
|
23
|
+
"types": "./build.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"typesVersions": {
|
|
27
|
+
"*": {
|
|
28
|
+
"build": [
|
|
29
|
+
"build.d.ts"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"build.d.ts",
|
|
35
|
+
"dist/build-cli.js",
|
|
36
|
+
"dist/extension.js",
|
|
37
|
+
"dist/webview/",
|
|
38
|
+
"icon.png",
|
|
39
|
+
"media/icons/icon.svg",
|
|
40
|
+
"package.nls.json",
|
|
41
|
+
"package.nls.zh-cn.json",
|
|
42
|
+
"webview/shared/b3build-model.d.ts",
|
|
43
|
+
"webview/shared/b3type.ts"
|
|
44
|
+
],
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public",
|
|
47
|
+
"registry": "https://registry.npmjs.org/"
|
|
48
|
+
},
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=18",
|
|
52
|
+
"vscode": "^1.85.0"
|
|
53
|
+
},
|
|
54
|
+
"categories": [
|
|
55
|
+
"Other"
|
|
56
|
+
],
|
|
57
|
+
"icon": "icon.png",
|
|
58
|
+
"activationEvents": [
|
|
59
|
+
"onLanguage:json"
|
|
60
|
+
],
|
|
61
|
+
"main": "./dist/extension.js",
|
|
62
|
+
"contributes": {
|
|
63
|
+
"customEditors": [
|
|
64
|
+
{
|
|
65
|
+
"viewType": "behavior3.treeEditor",
|
|
66
|
+
"displayName": "%extension.editor.displayName%",
|
|
67
|
+
"selector": [
|
|
68
|
+
{
|
|
69
|
+
"filenamePattern": "*.json"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"priority": "option"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
"viewsContainers": {
|
|
76
|
+
"activitybar": [
|
|
77
|
+
{
|
|
78
|
+
"id": "behavior3InspectorContainer",
|
|
79
|
+
"title": "%viewContainer.inspector.title%",
|
|
80
|
+
"icon": "media/icons/icon.svg"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"views": {
|
|
85
|
+
"behavior3InspectorContainer": [
|
|
86
|
+
{
|
|
87
|
+
"id": "behavior3.inspectorView",
|
|
88
|
+
"name": "%view.inspector.title%",
|
|
89
|
+
"icon": "media/icons/icon.svg",
|
|
90
|
+
"type": "webview",
|
|
91
|
+
"visibility": "visible"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"submenus": [
|
|
96
|
+
{
|
|
97
|
+
"id": "behavior3.explorer",
|
|
98
|
+
"label": "%submenu.explorer.label%"
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"commands": [
|
|
102
|
+
{
|
|
103
|
+
"command": "behavior3.build",
|
|
104
|
+
"title": "%command.build.title%",
|
|
105
|
+
"category": "%command.category%",
|
|
106
|
+
"icon": "$(build)"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"command": "behavior3.buildDebug",
|
|
110
|
+
"title": "%command.buildDebug.title%",
|
|
111
|
+
"category": "%command.category%",
|
|
112
|
+
"icon": "$(debug-alt)"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"command": "behavior3.batchProcess",
|
|
116
|
+
"title": "%command.batchProcess.title%",
|
|
117
|
+
"category": "%command.category%"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"command": "behavior3.runBatchProcessScript",
|
|
121
|
+
"title": "%command.runBatchProcessScript.title%",
|
|
122
|
+
"category": "%command.category%"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"command": "behavior3.createProject",
|
|
126
|
+
"title": "%command.createProject.title%",
|
|
127
|
+
"category": "%command.category%"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"command": "behavior3.createTree",
|
|
131
|
+
"title": "%command.createTree.title%",
|
|
132
|
+
"category": "%command.category%"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"command": "behavior3.openSettings",
|
|
136
|
+
"title": "%command.openSettings.title%",
|
|
137
|
+
"category": "%command.category%"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"command": "behavior3.openWithEditor",
|
|
141
|
+
"title": "%command.openWithEditor.title%",
|
|
142
|
+
"category": "%command.category%"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"command": "behavior3.toggleEditorMode",
|
|
146
|
+
"title": "%command.toggleEditorMode.title%",
|
|
147
|
+
"category": "%command.category%",
|
|
148
|
+
"icon": "$(edit-code)"
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
"keybindings": [
|
|
152
|
+
{
|
|
153
|
+
"command": "behavior3.build",
|
|
154
|
+
"key": "ctrl+b",
|
|
155
|
+
"mac": "cmd+b",
|
|
156
|
+
"when": "activeCustomEditorId == 'behavior3.treeEditor'"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"command": "behavior3.buildDebug",
|
|
160
|
+
"key": "ctrl+shift+b",
|
|
161
|
+
"mac": "cmd+shift+b",
|
|
162
|
+
"when": "activeCustomEditorId == 'behavior3.treeEditor'"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"command": "behavior3.toggleEditorMode",
|
|
166
|
+
"key": "f4",
|
|
167
|
+
"when": "activeCustomEditorId == 'behavior3.treeEditor' || resourceExtname == .json"
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
"menus": {
|
|
171
|
+
"editor/title": [
|
|
172
|
+
{
|
|
173
|
+
"command": "behavior3.toggleEditorMode",
|
|
174
|
+
"when": "activeCustomEditorId == 'behavior3.treeEditor' || resourceExtname == .json",
|
|
175
|
+
"group": "navigation@0"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"command": "behavior3.build",
|
|
179
|
+
"when": "activeCustomEditorId == 'behavior3.treeEditor'",
|
|
180
|
+
"group": "navigation@1",
|
|
181
|
+
"alt": "behavior3.buildDebug"
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
"explorer/context": [
|
|
185
|
+
{
|
|
186
|
+
"submenu": "behavior3.explorer",
|
|
187
|
+
"when": "explorerResourceIsFolder || resourceExtname == .json || resourceExtname == .ts || resourceExtname == .mts || resourceExtname == .js || resourceExtname == .mjs",
|
|
188
|
+
"group": "navigation@45"
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"behavior3.explorer": [
|
|
192
|
+
{
|
|
193
|
+
"command": "behavior3.createProject",
|
|
194
|
+
"when": "explorerResourceIsFolder",
|
|
195
|
+
"group": "1_create@1"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"command": "behavior3.batchProcess",
|
|
199
|
+
"when": "explorerResourceIsFolder",
|
|
200
|
+
"group": "1_create@2"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"command": "behavior3.createTree",
|
|
204
|
+
"when": "explorerResourceIsFolder",
|
|
205
|
+
"group": "1_create@3"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"command": "behavior3.runBatchProcessScript",
|
|
209
|
+
"when": "(resourceExtname == .ts || resourceExtname == .mts || resourceExtname == .js || resourceExtname == .mjs) && !explorerResourceIsFolder",
|
|
210
|
+
"group": "2_run@1"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"command": "behavior3.openWithEditor",
|
|
214
|
+
"when": "resourceExtname == .json && !explorerResourceIsFolder",
|
|
215
|
+
"group": "3_open@1"
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
"configuration": {
|
|
220
|
+
"title": "%configuration.title%",
|
|
221
|
+
"properties": {
|
|
222
|
+
"behavior3.checkExpr": {
|
|
223
|
+
"type": "boolean",
|
|
224
|
+
"default": true,
|
|
225
|
+
"description": "%configuration.checkExpr.description%"
|
|
226
|
+
},
|
|
227
|
+
"behavior3.language": {
|
|
228
|
+
"type": "string",
|
|
229
|
+
"default": "auto",
|
|
230
|
+
"enum": [
|
|
231
|
+
"auto",
|
|
232
|
+
"zh",
|
|
233
|
+
"en"
|
|
234
|
+
],
|
|
235
|
+
"enumDescriptions": [
|
|
236
|
+
"%configuration.language.auto%",
|
|
237
|
+
"%configuration.language.zh%",
|
|
238
|
+
"%configuration.language.en%"
|
|
239
|
+
],
|
|
240
|
+
"description": "%configuration.language.description%"
|
|
241
|
+
},
|
|
242
|
+
"behavior3.subtreeEditable": {
|
|
243
|
+
"type": "boolean",
|
|
244
|
+
"default": true,
|
|
245
|
+
"description": "%configuration.subtreeEditable.description%"
|
|
246
|
+
},
|
|
247
|
+
"behavior3.inspectorMode": {
|
|
248
|
+
"type": "string",
|
|
249
|
+
"default": "sidebar",
|
|
250
|
+
"enum": [
|
|
251
|
+
"sidebar",
|
|
252
|
+
"embedded"
|
|
253
|
+
],
|
|
254
|
+
"enumDescriptions": [
|
|
255
|
+
"%configuration.inspectorMode.sidebar%",
|
|
256
|
+
"%configuration.inspectorMode.embedded%"
|
|
257
|
+
],
|
|
258
|
+
"description": "%configuration.inspectorMode.description%"
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
"scripts": {
|
|
264
|
+
"vscode:prepublish": "npm run build",
|
|
265
|
+
"build": "node esbuild.js && vite build",
|
|
266
|
+
"build:cli": "node esbuild.js --cli",
|
|
267
|
+
"build:dev": "node esbuild.js --dev && vite build --mode development",
|
|
268
|
+
"watch:ext": "node esbuild.js --watch",
|
|
269
|
+
"watch:webview": "vite build --watch --mode development",
|
|
270
|
+
"dev": "npm run watch:webview",
|
|
271
|
+
"package": "vsce package",
|
|
272
|
+
"pack:npm": "npm pack --dry-run",
|
|
273
|
+
"prepack": "npm run check && npm run test:shared && npm run build",
|
|
274
|
+
"publish:npm": "npm publish --access public",
|
|
275
|
+
"check": "tsc --noEmit && tsc --project tsconfig.webview.json --noEmit",
|
|
276
|
+
"test:shared": "node test/run-tests.js",
|
|
277
|
+
"format:check": "prettier --check package.json \"test/**/*.js\" \"test/**/*.ts\"",
|
|
278
|
+
"format": "prettier --write package.json \"test/**/*.js\" \"test/**/*.ts\""
|
|
279
|
+
},
|
|
280
|
+
"dependencies": {
|
|
281
|
+
"behavior3": "^1.1.0"
|
|
282
|
+
},
|
|
283
|
+
"devDependencies": {
|
|
284
|
+
"@ant-design/icons": "^6.1.1",
|
|
285
|
+
"@antv/g6": "^5.0.51",
|
|
286
|
+
"@types/node": "^20.19.37",
|
|
287
|
+
"@types/react": "^18.3.12",
|
|
288
|
+
"@types/react-dom": "^18.3.1",
|
|
289
|
+
"@types/vscode": "^1.85.0",
|
|
290
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
291
|
+
"@vscode/vsce": "^3.7.1",
|
|
292
|
+
"ahooks": "^3.8.0",
|
|
293
|
+
"antd": "^6.3.4",
|
|
294
|
+
"autoprefixer": "^10.4.20",
|
|
295
|
+
"esbuild": "^0.24.0",
|
|
296
|
+
"i18next": "^23.12.2",
|
|
297
|
+
"nanoid": "^5.1.6",
|
|
298
|
+
"postcss": "^8.4.49",
|
|
299
|
+
"prettier": "^3.8.3",
|
|
300
|
+
"react": "^18.3.1",
|
|
301
|
+
"react-dom": "^18.3.1",
|
|
302
|
+
"react-i18next": "^14.1.3",
|
|
303
|
+
"react-icons": "^5.2.1",
|
|
304
|
+
"react-markdown": "^9.0.1",
|
|
305
|
+
"sass": "^1.77.8",
|
|
306
|
+
"tailwindcss": "^3.4.15",
|
|
307
|
+
"ts-key-enum": "^2.0.12",
|
|
308
|
+
"typescript": "^5.8.2",
|
|
309
|
+
"usehooks-ts": "^3.1.0",
|
|
310
|
+
"vite": "^6.3.5",
|
|
311
|
+
"zustand": "^5.0.3"
|
|
312
|
+
}
|
|
313
|
+
}
|
package/package.nls.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extension.displayName": "Behavior3 Editor",
|
|
3
|
+
"extension.description": "Visual Behavior3 Editor for game development",
|
|
4
|
+
"extension.editor.displayName": "Behavior3 Editor",
|
|
5
|
+
"viewContainer.inspector.title": "Behavior3",
|
|
6
|
+
"view.inspector.title": "Behavior3",
|
|
7
|
+
"submenu.explorer.label": "Behavior3",
|
|
8
|
+
"command.category": "Behavior Tree",
|
|
9
|
+
"command.build.title": "Build Behavior Tree",
|
|
10
|
+
"command.buildDebug.title": "Debug Build Behavior Tree",
|
|
11
|
+
"command.batchProcess.title": "Batch Process Behavior Trees",
|
|
12
|
+
"command.runBatchProcessScript.title": "Run as Batch Process",
|
|
13
|
+
"command.createProject.title": "Create Project",
|
|
14
|
+
"command.openSettings.title": "Open Node Config (.b3-setting)",
|
|
15
|
+
"command.createTree.title": "Create Behavior3 File",
|
|
16
|
+
"command.openWithEditor.title": "Open with Behavior3",
|
|
17
|
+
"command.toggleEditorMode.title": "Toggle Text / Behavior3",
|
|
18
|
+
"configuration.title": "Behavior3 Editor",
|
|
19
|
+
"configuration.checkExpr.description": "Enable expression validation.",
|
|
20
|
+
"configuration.language.description": "Editor UI language. The default follows the VS Code display language; you can also force a language.",
|
|
21
|
+
"configuration.language.auto": "Follow VS Code display language",
|
|
22
|
+
"configuration.language.zh": "Force Chinese",
|
|
23
|
+
"configuration.language.en": "Force English",
|
|
24
|
+
"configuration.subtreeEditable.description": "Allow editing subtree node properties in the Inspector, including input, output, and arguments. When enabled, $override can override node properties inside subtrees. When disabled, subtree internal nodes are read-only.",
|
|
25
|
+
"configuration.inspectorMode.description": "Choose where the Inspector is shown.",
|
|
26
|
+
"configuration.inspectorMode.sidebar": "Show the Inspector in the dedicated VS Code sidebar.",
|
|
27
|
+
"configuration.inspectorMode.embedded": "Show the Inspector inside the Behavior3 editor."
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extension.displayName": "Behavior3 编辑器",
|
|
3
|
+
"extension.description": "面向游戏开发的可视化 Behavior3 编辑器",
|
|
4
|
+
"extension.editor.displayName": "Behavior3 编辑器",
|
|
5
|
+
"viewContainer.inspector.title": "Behavior3",
|
|
6
|
+
"view.inspector.title": "Behavior3",
|
|
7
|
+
"submenu.explorer.label": "Behavior3",
|
|
8
|
+
"command.category": "行为树",
|
|
9
|
+
"command.build.title": "构建行为树",
|
|
10
|
+
"command.buildDebug.title": "调试构建行为树",
|
|
11
|
+
"command.batchProcess.title": "批量处理行为树",
|
|
12
|
+
"command.runBatchProcessScript.title": "作为批处理运行",
|
|
13
|
+
"command.createProject.title": "创建项目",
|
|
14
|
+
"command.openSettings.title": "打开节点配置 (.b3-setting)",
|
|
15
|
+
"command.createTree.title": "创建 Behavior3 文件",
|
|
16
|
+
"command.openWithEditor.title": "使用 Behavior3 打开",
|
|
17
|
+
"command.toggleEditorMode.title": "切换文本 / Behavior3",
|
|
18
|
+
"configuration.title": "Behavior3 编辑器",
|
|
19
|
+
"configuration.checkExpr.description": "启用表达式校验。",
|
|
20
|
+
"configuration.language.description": "编辑器界面语言。默认跟随 VS Code 显示语言,也可手动指定。",
|
|
21
|
+
"configuration.language.auto": "跟随 VS Code 显示语言",
|
|
22
|
+
"configuration.language.zh": "强制中文",
|
|
23
|
+
"configuration.language.en": "强制英文",
|
|
24
|
+
"configuration.subtreeEditable.description": "允许在 Inspector 中编辑子树节点的属性,包括输入、输出和参数。启用时可通过 $override 覆盖子树中的节点属性;禁用时子树内部节点为只读。",
|
|
25
|
+
"configuration.inspectorMode.description": "选择 Inspector 的显示位置。",
|
|
26
|
+
"configuration.inspectorMode.sidebar": "在独立的 VS Code 侧栏中显示 Inspector。",
|
|
27
|
+
"configuration.inspectorMode.embedded": "在 Behavior3 编辑器内部显示 Inspector。"
|
|
28
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { NodeDef } from "behavior3";
|
|
2
|
+
import type { NodeData, TreeData } from "./b3type";
|
|
3
|
+
|
|
4
|
+
export type NodeArg = Exclude<NodeDef["args"], undefined>[number];
|
|
5
|
+
|
|
6
|
+
export type BuildLogger = {
|
|
7
|
+
log: (...args: unknown[]) => void;
|
|
8
|
+
debug: (...args: unknown[]) => void;
|
|
9
|
+
info: (...args: unknown[]) => void;
|
|
10
|
+
warn: (...args: unknown[]) => void;
|
|
11
|
+
error: (...args: unknown[]) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type FsLike = {
|
|
15
|
+
readFileSync(path: string, encoding: "utf8" | "utf-8"): string;
|
|
16
|
+
writeFileSync(path: string, data: string, encoding?: "utf8" | "utf-8"): void;
|
|
17
|
+
readdirSync(path: string): string[];
|
|
18
|
+
readdirSync(path: string, options: { encoding: "utf8" | "utf-8"; recursive?: boolean }): string[];
|
|
19
|
+
statSync(path: string): { mtimeMs: number; isFile(): boolean };
|
|
20
|
+
mkdirSync(path: string, options?: { recursive?: boolean }): unknown;
|
|
21
|
+
copyFileSync(source: string, destination: string): void;
|
|
22
|
+
unlinkSync(path: string): void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type PathLike = {
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
basename(path: string, suffix?: string): string;
|
|
28
|
+
basenameWithoutExt(path: string): string;
|
|
29
|
+
dirname(path: string): string;
|
|
30
|
+
extname(path: string): string;
|
|
31
|
+
isAbsolute(path: string): boolean;
|
|
32
|
+
join(...paths: string[]): string;
|
|
33
|
+
lsdir(path: string, recursive?: boolean): string[];
|
|
34
|
+
normalize(path: string): string;
|
|
35
|
+
posixPath(path: string): string;
|
|
36
|
+
relative(from: string, to: string): string;
|
|
37
|
+
resolve(...paths: string[]): string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type BuildEnv = {
|
|
41
|
+
fs: FsLike;
|
|
42
|
+
path: PathLike;
|
|
43
|
+
workdir: string;
|
|
44
|
+
nodeDefs: ReadonlyMap<string, NodeDef>;
|
|
45
|
+
logger: BuildLogger;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type NodeArgCheckResult = string | string[] | null | undefined;
|
|
49
|
+
|
|
50
|
+
export type NodeArgCheckContext = {
|
|
51
|
+
node: NodeData;
|
|
52
|
+
tree: TreeData;
|
|
53
|
+
nodeDef: NodeDef;
|
|
54
|
+
arg: NodeArg;
|
|
55
|
+
argName: string;
|
|
56
|
+
treePath: string;
|
|
57
|
+
env: BuildEnv;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export interface NodeArgChecker {
|
|
61
|
+
validate(value: unknown, ctx: NodeArgCheckContext): NodeArgCheckResult;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type BuildScript = {
|
|
65
|
+
onProcessTree?: (tree: TreeData, path: string, errors: string[]) => TreeData | null;
|
|
66
|
+
onProcessNode?: (node: NodeData, errors: string[]) => NodeData | null;
|
|
67
|
+
onWriteFile?: (path: string, tree: TreeData) => void;
|
|
68
|
+
onComplete?: (status: "success" | "failure") => void;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type BuildHookClass<T extends BuildScript = BuildScript> = new (...args: any[]) => T;
|
|
72
|
+
export type NodeArgCheckerClass<T extends NodeArgChecker = NodeArgChecker> = new (
|
|
73
|
+
...args: any[]
|
|
74
|
+
) => T;
|
|
75
|
+
|
|
76
|
+
export type BuildDecorator = {
|
|
77
|
+
<T extends BuildHookClass>(target: T): T | void;
|
|
78
|
+
<T extends BuildHookClass>(target: T, context: ClassDecoratorContext<T>): T | void;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type CheckDecorator = {
|
|
82
|
+
<T extends NodeArgCheckerClass>(target: T): T | void;
|
|
83
|
+
<T extends NodeArgCheckerClass>(target: T, context: ClassDecoratorContext<T>): T | void;
|
|
84
|
+
(name?: string): <T extends NodeArgCheckerClass>(target: T) => T | void;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type BuildRuntime = {
|
|
88
|
+
build: BuildDecorator;
|
|
89
|
+
check: CheckDecorator;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export declare class Hook implements BuildScript {
|
|
93
|
+
constructor(env: BuildEnv);
|
|
94
|
+
onProcessTree?(tree: TreeData, path: string, errors: string[]): TreeData | null;
|
|
95
|
+
onProcessNode?(node: NodeData, errors: string[]): NodeData | null;
|
|
96
|
+
onWriteFile?(path: string, tree: TreeData): void;
|
|
97
|
+
onComplete?(status: "success" | "failure"): void;
|
|
98
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { NodeDef } from "behavior3";
|
|
2
|
+
|
|
3
|
+
export type { NodeDef };
|
|
4
|
+
export type NodeType = NodeDef["type"] | "Other" | "Error";
|
|
5
|
+
export type NodeArg = Exclude<NodeDef["args"], undefined>[number];
|
|
6
|
+
|
|
7
|
+
export const DOCUMENT_VERSION = "2.1.0";
|
|
8
|
+
export const VERSION = DOCUMENT_VERSION;
|
|
9
|
+
|
|
10
|
+
export interface NodeData {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
desc?: string;
|
|
14
|
+
args?: { [key: string]: unknown };
|
|
15
|
+
input?: string[];
|
|
16
|
+
output?: string[];
|
|
17
|
+
children?: NodeData[];
|
|
18
|
+
debug?: boolean;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
path?: string;
|
|
21
|
+
|
|
22
|
+
// Stable node identity, for overrides
|
|
23
|
+
uuid: string;
|
|
24
|
+
|
|
25
|
+
// for runtime
|
|
26
|
+
$mtime?: number;
|
|
27
|
+
$size?: number[];
|
|
28
|
+
$status?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface VarDecl {
|
|
32
|
+
name: string;
|
|
33
|
+
desc: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface TreeVariables {
|
|
37
|
+
imports: string[];
|
|
38
|
+
locals: VarDecl[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface GroupDecl {
|
|
42
|
+
name: string;
|
|
43
|
+
value: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ImportDecl {
|
|
47
|
+
path: string;
|
|
48
|
+
modified?: number;
|
|
49
|
+
vars: VarDecl[];
|
|
50
|
+
depends: {
|
|
51
|
+
path: string;
|
|
52
|
+
modified: number;
|
|
53
|
+
}[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface FileVarDecl {
|
|
57
|
+
import: ImportDecl[];
|
|
58
|
+
subtree: ImportDecl[];
|
|
59
|
+
vars: VarDecl[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface TreeData {
|
|
63
|
+
version: string;
|
|
64
|
+
name: string;
|
|
65
|
+
prefix: string;
|
|
66
|
+
desc?: string;
|
|
67
|
+
export?: boolean;
|
|
68
|
+
group: string[];
|
|
69
|
+
variables: TreeVariables;
|
|
70
|
+
custom: Record<string, string | number | boolean | object>;
|
|
71
|
+
root: NodeData;
|
|
72
|
+
|
|
73
|
+
overrides: {
|
|
74
|
+
[key: string]: Pick<NodeData, "desc" | "input" | "output" | "args" | "debug" | "disabled">;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const keyWords = ["true", "false", "null", "undefined", "NaN", "Infinity"];
|
|
79
|
+
|
|
80
|
+
export const isIntType = (type: string) => type.startsWith("int");
|
|
81
|
+
export const isFloatType = (type: string) => type.startsWith("float");
|
|
82
|
+
export const isStringType = (type: string) => type.startsWith("string");
|
|
83
|
+
export const isBoolType = (type: string) => type.startsWith("bool");
|
|
84
|
+
export const isExprType = (type: string) => type.startsWith("expr");
|
|
85
|
+
export const isJsonType = (type: string) => type.startsWith("json");
|
|
86
|
+
export const hasArgOptions = (arg: NodeArg) => arg.options !== undefined;
|
|
87
|
+
|
|
88
|
+
/** `.b3-workspace` file shape. Extension build only reads `settings`; `files` is optional (desktop may still use it). */
|
|
89
|
+
export interface WorkspaceModel {
|
|
90
|
+
settings: {
|
|
91
|
+
checkExpr?: boolean;
|
|
92
|
+
buildScript?: string;
|
|
93
|
+
checkScripts?: string[];
|
|
94
|
+
/** Override default node-type colors. Keys: "Composite" | "Decorator" | "Condition" | "Action" | "Other" | "Error" */
|
|
95
|
+
nodeColors?: Record<string, string>;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const getNodeType = (def: NodeDef): NodeType => {
|
|
100
|
+
const type = def.type.toLocaleLowerCase().toString();
|
|
101
|
+
if (type.startsWith("action")) {
|
|
102
|
+
return "Action";
|
|
103
|
+
} else if (type.startsWith("composite")) {
|
|
104
|
+
return "Composite";
|
|
105
|
+
} else if (type.startsWith("decorator")) {
|
|
106
|
+
return "Decorator";
|
|
107
|
+
} else if (type.startsWith("condition")) {
|
|
108
|
+
return "Condition";
|
|
109
|
+
} else {
|
|
110
|
+
return "Other";
|
|
111
|
+
}
|
|
112
|
+
};
|