blockbench-types 4.6.0 → 4.8.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/package.json +11 -3
- package/scripts/generate_docs.js +368 -0
- package/tsconfig.json +16 -0
- package/types/action.d.ts +94 -11
- package/types/animation.d.ts +39 -23
- package/types/animation_controller.d.ts +28 -22
- package/types/{index.d.ts → blockbench.d.ts} +208 -28
- package/types/canvas.d.ts +78 -65
- package/types/canvas_frame.d.ts +21 -0
- package/types/codec.d.ts +93 -1
- package/types/cube.d.ts +93 -67
- package/types/dialog.d.ts +39 -36
- package/types/display_mode.d.ts +8 -5
- package/types/format.d.ts +2 -0
- package/types/global.d.ts +28 -0
- package/types/group.d.ts +76 -0
- package/types/interface.d.ts +2 -2
- package/types/keyframe.d.ts +36 -14
- package/types/menu.d.ts +7 -7
- package/types/mesh.d.ts +70 -64
- package/types/misc.d.ts +29 -8
- package/types/mode.d.ts +5 -5
- package/types/outliner.d.ts +29 -89
- package/types/painter.d.ts +6 -4
- package/types/panel.d.ts +21 -6
- package/types/plugin.d.ts +8 -0
- package/types/preview.d.ts +3 -0
- package/types/project.d.ts +10 -1
- package/types/screencam.d.ts +8 -0
- package/types/settings.d.ts +61 -13
- package/types/textures.d.ts +51 -2
- package/types/timeline.d.ts +4 -1
- package/types/undo.d.ts +30 -10
- package/types/util.d.ts +16 -3
- package/types/validator.d.ts +37 -2
- package/types/file_system.d.ts +0 -145
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blockbench-types",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"description": "Blockbench typescript types",
|
|
5
5
|
"main": "",
|
|
6
|
-
"types": "types/
|
|
6
|
+
"types": "types/blockbench.d.ts",
|
|
7
7
|
"typeScriptVersion": "3.2",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -17,11 +17,19 @@
|
|
|
17
17
|
"url": "https://github.com/JannisX11/blockbench-types/issues"
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/JannisX11/blockbench-types#readme",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"generate": "node ./scripts/generate_docs.js"
|
|
22
|
+
},
|
|
20
23
|
"dependencies": {
|
|
21
24
|
"@types/jquery": "^3.5.4",
|
|
25
|
+
"@types/three": "^0.155.0",
|
|
22
26
|
"@types/tinycolor2": "^1.4.3",
|
|
23
27
|
"three": "^0.129.0",
|
|
28
|
+
"typescript": "^4.9.5",
|
|
24
29
|
"vue": "^2.6.14",
|
|
25
|
-
"wintersky": "^1.2.
|
|
30
|
+
"wintersky": "^1.2.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"typedoc": "^0.23.24"
|
|
26
34
|
}
|
|
27
35
|
}
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
const TypeDoc = require("typedoc");
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const PathModule = require('path');
|
|
4
|
+
|
|
5
|
+
//const out_path = '../docs/';
|
|
6
|
+
const out_path = '../../blockbench.net/content/api/';
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
const app = new TypeDoc.Application();
|
|
10
|
+
|
|
11
|
+
// If you want TypeDoc to load tsconfig.json / typedoc.json files
|
|
12
|
+
app.options.addReader(new TypeDoc.TSConfigReader());
|
|
13
|
+
app.options.addReader(new TypeDoc.TypeDocReader());
|
|
14
|
+
|
|
15
|
+
app.bootstrap({
|
|
16
|
+
entryPoints: [
|
|
17
|
+
"./types/blockbench.d.ts",
|
|
18
|
+
"./types/textures.d.ts",
|
|
19
|
+
"./types/action.d.ts",
|
|
20
|
+
"./types/animation.d.ts",
|
|
21
|
+
"./types/animation_controller.d.ts",
|
|
22
|
+
"./types/canvas.d.ts",
|
|
23
|
+
"./types/codec.d.ts",
|
|
24
|
+
"./types/format.d.ts",
|
|
25
|
+
"./types/global.d.ts",
|
|
26
|
+
"./types/interface.d.ts",
|
|
27
|
+
"./types/dialog.d.ts",
|
|
28
|
+
"./types/panel.d.ts",
|
|
29
|
+
"./types/keyframe.d.ts",
|
|
30
|
+
"./types/legacy.d.ts",
|
|
31
|
+
"./types/menu.d.ts",
|
|
32
|
+
"./types/outliner.d.ts",
|
|
33
|
+
"./types/group.d.ts",
|
|
34
|
+
"./types/cube.d.ts",
|
|
35
|
+
"./types/mesh.d.ts",
|
|
36
|
+
"./types/plugin.d.ts",
|
|
37
|
+
"./types/preview.d.ts",
|
|
38
|
+
"./types/project.d.ts",
|
|
39
|
+
"./types/mode.d.ts",
|
|
40
|
+
"./types/settings.d.ts",
|
|
41
|
+
"./types/timeline.d.ts",
|
|
42
|
+
"./types/undo.d.ts",
|
|
43
|
+
"./types/painter.d.ts",
|
|
44
|
+
"./types/screencam.d.ts",
|
|
45
|
+
"./types/validator.d.ts",
|
|
46
|
+
"./types/display_mode.d.ts",
|
|
47
|
+
"./types/misc.d.ts",
|
|
48
|
+
"./types/util.d.ts"
|
|
49
|
+
],
|
|
50
|
+
sort: ['source-order'],
|
|
51
|
+
commentStyle: "all"
|
|
52
|
+
//json: "./json/test.json",
|
|
53
|
+
//pretty: true
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
let skip_files = ['global', 'legacy'];
|
|
57
|
+
|
|
58
|
+
console.log('Scanning...');
|
|
59
|
+
|
|
60
|
+
const project = app.convert();
|
|
61
|
+
|
|
62
|
+
if (!project) return; // Failed to parse types
|
|
63
|
+
|
|
64
|
+
console.log('Scanned types');
|
|
65
|
+
|
|
66
|
+
const external = {
|
|
67
|
+
'ConditionResolvable': '[ConditionResolvable](https://github.com/JannisX11/blockbench-types/blob/main/types/util.d.ts#L1)',
|
|
68
|
+
|
|
69
|
+
'Vue.Component': '[Vue.Component](https://v2.vuejs.org/v2/guide/components.html)',
|
|
70
|
+
|
|
71
|
+
'Vector3': '[THREE.Vector3](https://threejs.org/docs/index.html#api/en/math/Vector3)',
|
|
72
|
+
'Euler': '[THREE.Euler](https://threejs.org/docs/index.html#api/en/math/Euler)',
|
|
73
|
+
'Quaternion': '[THREE.Quaternion](https://threejs.org/docs/index.html#api/en/math/Quaternion)',
|
|
74
|
+
'Object3D': '[THREE.Object3D](https://threejs.org/docs/index.html#api/en/core/Object3D)',
|
|
75
|
+
'PerspectiveCamera': '[THREE.PerspectiveCamera](https://threejs.org/docs/index.html#api/en/cameras/PerspectiveCamera)',
|
|
76
|
+
'OrthographicCamera': '[THREE.OrthographicCamera](https://threejs.org/docs/index.html#api/en/cameras/OrthographicCamera)',
|
|
77
|
+
'WebGLRenderer': '[THREE.WebGLRenderer](https://threejs.org/docs/index.html#api/en/renderers/WebGLRenderer)',
|
|
78
|
+
|
|
79
|
+
'HTMLElement': '[HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)',
|
|
80
|
+
'HTMLCanvasElement': '[HTMLCanvasElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement)',
|
|
81
|
+
'HTMLAudioElement': '[HTMLAudioElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement)',
|
|
82
|
+
'CanvasRenderingContext2D': '[CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)',
|
|
83
|
+
'Date': '[Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)',
|
|
84
|
+
'Event': '[Event](https://developer.mozilla.org/en-US/docs/Web/API/Event)',
|
|
85
|
+
'PointerEvent': '[PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent)',
|
|
86
|
+
}
|
|
87
|
+
let top_level_references = {};
|
|
88
|
+
let top_level_hidden_references = {};
|
|
89
|
+
for (let file of project.children) {
|
|
90
|
+
let file_name = file.name.replace(/[^\w]/gi, '');
|
|
91
|
+
for (let concept of file.children) {
|
|
92
|
+
anchor_name = concept.name.replace(/[^\w]/gi, '').replace(/^_/, '').toLowerCase();
|
|
93
|
+
if (anchor_name == file_name) anchor_name += '-1';
|
|
94
|
+
|
|
95
|
+
if (concept.kindString == 'Interface' || concept.kindString == 'Type alias') {
|
|
96
|
+
top_level_hidden_references[concept.name] = `[${concept.name}](${concept.sources?.[0]?.url || ''})`;
|
|
97
|
+
} else {
|
|
98
|
+
top_level_references[concept.name] = file_name + '#' + anchor_name;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getReferenceLink(reference) {
|
|
104
|
+
if (reference.qualifiedName && (external[reference.qualifiedName] || external[reference.name])) {
|
|
105
|
+
return (external[reference.qualifiedName] || external[reference.name]);
|
|
106
|
+
}
|
|
107
|
+
if (top_level_hidden_references[reference.name]) {
|
|
108
|
+
return top_level_hidden_references[reference.name];
|
|
109
|
+
}
|
|
110
|
+
let link = '#' + reference.name;
|
|
111
|
+
if (top_level_references[reference.name]) {
|
|
112
|
+
link = top_level_references[reference.name];
|
|
113
|
+
}
|
|
114
|
+
return `[${reference.name}](${link})`
|
|
115
|
+
}
|
|
116
|
+
function getType(type) {
|
|
117
|
+
if (!type) return 'Function'
|
|
118
|
+
|
|
119
|
+
switch (type.type) {
|
|
120
|
+
case 'reflection': return `[See types](${type.declaration?.sources?.[0]?.url || ''})`;
|
|
121
|
+
|
|
122
|
+
case 'intrinsic': return '*' + type.name + '*';
|
|
123
|
+
|
|
124
|
+
case 'tuple': return 'Array';
|
|
125
|
+
|
|
126
|
+
case 'literal': return typeof type.value == 'string' ? ('`"' + type.value + '"`') : ('`' + type.value + '`');
|
|
127
|
+
|
|
128
|
+
case 'reference': {
|
|
129
|
+
if (type.name == 'Partial' && type.typeArguments?.[0]) {
|
|
130
|
+
return getType(type.typeArguments?.[0])
|
|
131
|
+
}
|
|
132
|
+
return getReferenceLink(type)
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
case 'array': return 'Array of ' + getType(type.elementType);
|
|
136
|
+
|
|
137
|
+
case 'union': return type.types.map(t => getType(t)).join(' or ');
|
|
138
|
+
|
|
139
|
+
default: return '';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function addComments(object, lines, default_value) {
|
|
143
|
+
if (object.comment?.summary) {
|
|
144
|
+
for (let comment of object.comment.summary) {
|
|
145
|
+
lines.push(comment.text, '');
|
|
146
|
+
}
|
|
147
|
+
} else if (default_value) {
|
|
148
|
+
lines.push(default_value, '');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function addArgumentTree(arguments, lines) {
|
|
152
|
+
if (arguments?.length) lines.push('##### Arguments:');
|
|
153
|
+
function generateArgumentList(list, depth) {
|
|
154
|
+
list.forEach((object) => {
|
|
155
|
+
let line = '';
|
|
156
|
+
let is_nested = (object.type?.type == 'reference' && object.type.reflection && object.type.reflection.children && object.type.reflection.kindString == 'Interface');
|
|
157
|
+
for (let i = 0; i < depth; i++) {
|
|
158
|
+
line += '\t';
|
|
159
|
+
}
|
|
160
|
+
line += '* `' + object.name + '`: ' + (is_nested ? object.type?.name : getType(object.type));
|
|
161
|
+
if (object.flags.isOptional) line += ' (Optional)';
|
|
162
|
+
if (object.comment?.summary) {
|
|
163
|
+
line += ' -';
|
|
164
|
+
for (let comment of object.comment.summary) {
|
|
165
|
+
line += ' ' + comment.text;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
lines.push(line);
|
|
169
|
+
|
|
170
|
+
if (is_nested) {
|
|
171
|
+
generateArgumentList(object.type.reflection.children, depth + 1);
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
generateArgumentList(arguments, 0);
|
|
176
|
+
lines.push('');
|
|
177
|
+
}
|
|
178
|
+
function generateArgumentSuffix(arguments) {
|
|
179
|
+
if (arguments && arguments.length) {
|
|
180
|
+
let args = '';
|
|
181
|
+
let required_args = arguments.filter(p => !p.flags.isOptional).map(p => p.name).join(', ');
|
|
182
|
+
let optional_args = arguments.filter(p => p.flags.isOptional).map(p => p.name).join(', ');
|
|
183
|
+
if (required_args && optional_args) {
|
|
184
|
+
args = required_args + '[, ' + optional_args + ']';
|
|
185
|
+
} else if (required_args) {
|
|
186
|
+
args = required_args
|
|
187
|
+
} else if (optional_args) {
|
|
188
|
+
args = '['+optional_args+']';
|
|
189
|
+
}
|
|
190
|
+
return `( ${args} )`;
|
|
191
|
+
} else {
|
|
192
|
+
return '()';
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function toTitleCase(input) {
|
|
196
|
+
return input.split(/[ _.-]/).map(word => word[0].toUpperCase() + word.substring(1)).join(' ');
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
let num_files = 0;
|
|
203
|
+
for (let file of project.children) {
|
|
204
|
+
if (skip_files.includes(file.name)) continue;
|
|
205
|
+
|
|
206
|
+
let file_name = file.name.replace(/[^\w]/gi, '');
|
|
207
|
+
let display_name = toTitleCase(file.name);
|
|
208
|
+
let markdown_lines = [
|
|
209
|
+
'---', `title: ${display_name}`, '---',
|
|
210
|
+
'',
|
|
211
|
+
`# ${display_name}`
|
|
212
|
+
];
|
|
213
|
+
let addLine = (s, empty_after) => {
|
|
214
|
+
markdown_lines.push(s || '');
|
|
215
|
+
if (empty_after && s) markdown_lines.push('');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
for (let concept of file.children) {
|
|
220
|
+
if (concept.kindString == 'Interface') continue;
|
|
221
|
+
if (concept.kindString == 'Type alias') continue;
|
|
222
|
+
|
|
223
|
+
if (concept.name.startsWith('_')) concept.name = concept.name.substring(1);
|
|
224
|
+
|
|
225
|
+
if (concept.kindString == 'Function') {
|
|
226
|
+
for (let signature of concept.signatures) {
|
|
227
|
+
let suffix = generateArgumentSuffix(signature.parameters);
|
|
228
|
+
addLine(`## ${signature.name.replace(/^_/, '')}${suffix}`);
|
|
229
|
+
addLine(`#### Global Function`, true);
|
|
230
|
+
|
|
231
|
+
addComments(signature, markdown_lines);
|
|
232
|
+
|
|
233
|
+
if (signature.parameters) {
|
|
234
|
+
addArgumentTree(signature.parameters, markdown_lines);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (signature.type && signature.type.name !== 'void') {
|
|
238
|
+
addLine(`Returns: ${getType(signature.type)}`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
addLine();
|
|
242
|
+
} else {
|
|
243
|
+
addLine(`## ${concept.name}`);
|
|
244
|
+
}
|
|
245
|
+
if (concept.kindString != 'Class' && concept.kindString != 'Function') {
|
|
246
|
+
let kind = concept.kindString;
|
|
247
|
+
if (kind != 'Interface' && kind != 'Type alias' && kind != 'Namespace') {
|
|
248
|
+
kind = 'Global ' + kind;
|
|
249
|
+
}
|
|
250
|
+
addLine(`#### ${kind}`, true);
|
|
251
|
+
}
|
|
252
|
+
if (concept.kindString == 'Variable') {
|
|
253
|
+
addLine(`Type: ${getType(concept.type)}`, true);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Extend
|
|
257
|
+
if (concept.extendedTypes) {
|
|
258
|
+
let parents = concept.extendedTypes.map(type => {
|
|
259
|
+
return getReferenceLink(type);
|
|
260
|
+
});
|
|
261
|
+
addLine('Extends: ' + parents.join(', '), true);
|
|
262
|
+
}
|
|
263
|
+
if (concept.extendedBy) {
|
|
264
|
+
let parents = concept.extendedBy.map(type => {
|
|
265
|
+
return getReferenceLink(type);
|
|
266
|
+
});
|
|
267
|
+
addLine('Extended by: ' + parents.join(', '), true);
|
|
268
|
+
}
|
|
269
|
+
// Comment
|
|
270
|
+
addComments(concept, markdown_lines);
|
|
271
|
+
|
|
272
|
+
// Children
|
|
273
|
+
if (concept.children) {
|
|
274
|
+
if (concept.children[0]) {}
|
|
275
|
+
|
|
276
|
+
let handled = [];
|
|
277
|
+
// Constructor
|
|
278
|
+
for (let child of concept.children) {
|
|
279
|
+
if (child.kindString != 'Constructor') continue;
|
|
280
|
+
let sig_i = 0;
|
|
281
|
+
for (let signature of child.signatures) {
|
|
282
|
+
let suffix = generateArgumentSuffix(signature.parameters);
|
|
283
|
+
addLine(`### ${signature.name}${suffix}`);
|
|
284
|
+
|
|
285
|
+
if (sig_i) {
|
|
286
|
+
addLine(`*Alternative constructor signature*`, true);
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
addComments(signature, markdown_lines, `Creates a new ${concept.name}`);
|
|
290
|
+
|
|
291
|
+
if (signature.parameters) {
|
|
292
|
+
addArgumentTree(signature.parameters, markdown_lines);
|
|
293
|
+
}
|
|
294
|
+
sig_i++;
|
|
295
|
+
//break; // Only use first signature in types for simplicity
|
|
296
|
+
}
|
|
297
|
+
addLine();
|
|
298
|
+
handled.push(child.id);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Properties
|
|
302
|
+
let properties = concept.children.filter(child => (child.kindString == 'Property' || child.kindString == 'Variable') && !child.type?.name?.startsWith('BlockbenchType') && !child.flags.isStatic);
|
|
303
|
+
if (properties.length) {
|
|
304
|
+
addLine('| Property | Type | Description |');
|
|
305
|
+
addLine('| -------- | ---- | ----------- |');
|
|
306
|
+
}
|
|
307
|
+
for (let child of properties) {
|
|
308
|
+
addLine(`| ${child.name} | ${getType(child.type)} | ${child.comment?.summary?.[0]?.text || ''} |`);
|
|
309
|
+
handled.push(child.id);
|
|
310
|
+
}
|
|
311
|
+
if (properties.length) {
|
|
312
|
+
addLine();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Methods
|
|
316
|
+
for (let child of concept.children) {
|
|
317
|
+
if (child.kindString != 'Method' && child.kindString != 'Function') continue;
|
|
318
|
+
for (let signature of child.signatures) {
|
|
319
|
+
let prefix = child.flags.isStatic ? (concept.name + '.') : '';
|
|
320
|
+
let suffix = generateArgumentSuffix(signature.parameters);
|
|
321
|
+
addLine(`### ${prefix}${signature.name.replace(/^_/, '')}${suffix}`);
|
|
322
|
+
addComments(signature, markdown_lines);
|
|
323
|
+
|
|
324
|
+
if (signature.parameters) {
|
|
325
|
+
addArgumentTree(signature.parameters, markdown_lines);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (signature.type && signature.type.name !== 'void') {
|
|
329
|
+
addLine(`Returns: ${getType(signature.type)}`);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
addLine();
|
|
333
|
+
handled.push(child.id);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Misc
|
|
337
|
+
for (let child of concept.children) {
|
|
338
|
+
if (handled.includes(child.id)) continue;
|
|
339
|
+
addLine(`### ${child.name}`);
|
|
340
|
+
let kind = child.kindString;
|
|
341
|
+
if (child.flags.isStatic) {
|
|
342
|
+
kind = 'Static ' + kind;
|
|
343
|
+
}
|
|
344
|
+
addLine(kind, true);
|
|
345
|
+
if (child.kindString == 'Property') {
|
|
346
|
+
addLine(`Type: ${getType(child.type)}`, true);
|
|
347
|
+
}
|
|
348
|
+
addComments(child, markdown_lines);
|
|
349
|
+
addLine();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
addLine();
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
fs.writeFileSync(PathModule.resolve(__dirname, out_path, `${file_name}.md`), markdown_lines.join('\r\n'), "utf-8");
|
|
360
|
+
num_files++;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
console.log(`Generated ${num_files} api doc files`);
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
main().catch(console.error);
|
package/tsconfig.json
ADDED
package/types/action.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of all toolbar items, such as actions, tools, etc.
|
|
3
|
+
*/
|
|
1
4
|
declare const BarItems: {
|
|
2
5
|
[id: string]: BarItem
|
|
3
6
|
}
|
|
@@ -12,6 +15,9 @@ declare interface KeybindKeys {
|
|
|
12
15
|
alt?: boolean | null
|
|
13
16
|
meta?: boolean | null
|
|
14
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* A customizable keybind
|
|
20
|
+
*/
|
|
15
21
|
declare class Keybind {
|
|
16
22
|
constructor(keys: KeybindKeys)
|
|
17
23
|
}
|
|
@@ -25,26 +31,70 @@ declare class KeybindItem extends Deletable {
|
|
|
25
31
|
declare class MenuSeparator {
|
|
26
32
|
constructor();
|
|
27
33
|
}
|
|
34
|
+
type ActionEventName = 'delete' | 'use' | 'used' | 'trigger' | 'get_node' | 'select' | 'change' | 'changed' | 'update' | 'open'
|
|
28
35
|
interface BarItemOptions extends KeybindItemOptions {
|
|
29
36
|
name?: string
|
|
30
37
|
description?: string
|
|
31
38
|
icon: string
|
|
32
|
-
condition?:
|
|
39
|
+
condition?: ConditionResolvable
|
|
33
40
|
category?: string
|
|
34
41
|
keybind?: Keybind
|
|
35
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Anything that can go into a toolbar, including actions, tools, toggles, widgets etc.
|
|
45
|
+
*/
|
|
36
46
|
declare class BarItem extends KeybindItem {
|
|
37
47
|
constructor(id: string, options: BarItemOptions);
|
|
38
48
|
conditionMet(): boolean;
|
|
39
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Adds a label to the HTML element of the bar item
|
|
51
|
+
* @param in_bar Set to true to generate an in-bar label, as opposed to a regular on-hover label
|
|
52
|
+
* @param action Provide the action to generate the label. This defaults to self and is only needed in special cases
|
|
53
|
+
*/
|
|
54
|
+
addLabel(in_bar?: boolean, action?: any): void;
|
|
55
|
+
/**
|
|
56
|
+
* Gets a copy of the elements HTML node that is not yet in use.
|
|
57
|
+
*/
|
|
40
58
|
getNode(): HTMLElement;
|
|
59
|
+
/**
|
|
60
|
+
* Appends the bar item to a HTML element
|
|
61
|
+
*/
|
|
41
62
|
toElement(destination: HTMLElement): this;
|
|
42
63
|
pushToolbar(bar: any): void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Adds an event listener to the item
|
|
67
|
+
* @param event_name The event type to listen for
|
|
68
|
+
* @param callback
|
|
69
|
+
*/
|
|
70
|
+
on(event_name: ActionEventName, callback: (data: object) => void): void
|
|
71
|
+
/**
|
|
72
|
+
* Adds a single-use event listener to the item
|
|
73
|
+
* @param event_name The event type to listen for
|
|
74
|
+
* @param callback
|
|
75
|
+
*/
|
|
76
|
+
once(event_name: ActionEventName, callback: (data: object) => void): void
|
|
77
|
+
/**
|
|
78
|
+
* Removes an event listener from the item
|
|
79
|
+
* @param event_name
|
|
80
|
+
* @param callback
|
|
81
|
+
*/
|
|
82
|
+
removeListener(event_name: ActionEventName, callback: (data: object) => void): void
|
|
83
|
+
dispatchEvent(data: object): void
|
|
43
84
|
}
|
|
44
85
|
|
|
45
86
|
interface ActionOptions extends BarItemOptions {
|
|
87
|
+
/**
|
|
88
|
+
* Function to run when user uses the action successfully
|
|
89
|
+
*/
|
|
46
90
|
click(event: Event): void
|
|
91
|
+
/**
|
|
92
|
+
* Icon color. Can be a CSS color string, or an axis letter to use an axis color.
|
|
93
|
+
*/
|
|
47
94
|
color?: string
|
|
95
|
+
/**
|
|
96
|
+
* ID of a setting that the action is slinked to
|
|
97
|
+
*/
|
|
48
98
|
linked_setting?: string
|
|
49
99
|
children?: object[]
|
|
50
100
|
/**
|
|
@@ -52,6 +102,9 @@ interface ActionOptions extends BarItemOptions {
|
|
|
52
102
|
*/
|
|
53
103
|
label?: boolean
|
|
54
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Actions can be triggered to run something, they can be added to menus, toolbars, assigned a keybinding, or run via Action Control
|
|
107
|
+
*/
|
|
55
108
|
declare class Action extends BarItem {
|
|
56
109
|
constructor(id: string, options: ActionOptions);
|
|
57
110
|
/**
|
|
@@ -78,6 +131,9 @@ interface ToggleOptions extends ActionOptions {
|
|
|
78
131
|
*/
|
|
79
132
|
onChange?(value: boolean): void
|
|
80
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* A toggle is a type of action that can be on or off. The state is not persistent between restarts by default.
|
|
136
|
+
*/
|
|
81
137
|
declare class Toggle extends Action {
|
|
82
138
|
constructor(id: string, options: ToggleOptions);
|
|
83
139
|
/**
|
|
@@ -194,6 +250,9 @@ interface ToolOptions extends ActionOptions {
|
|
|
194
250
|
paintTool?: boolean
|
|
195
251
|
brush?: BrushOptions
|
|
196
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* A tool, such as move tool, vertex snap tool, or paint brush
|
|
255
|
+
*/
|
|
197
256
|
declare class Tool extends Action {
|
|
198
257
|
constructor(id: string, options: ToolOptions);
|
|
199
258
|
select(): this | undefined;
|
|
@@ -206,7 +265,7 @@ declare class NumSlider extends Widget {
|
|
|
206
265
|
constructor(id: string, options: object);
|
|
207
266
|
startInput(event: Event): void;
|
|
208
267
|
setWidth(width: any): this;
|
|
209
|
-
getInterval(event: Event):
|
|
268
|
+
getInterval(event: Event): number;
|
|
210
269
|
slide(clientX: any, event: Event): void;
|
|
211
270
|
input(): void;
|
|
212
271
|
stopInput(): void;
|
|
@@ -214,23 +273,23 @@ declare class NumSlider extends Widget {
|
|
|
214
273
|
trigger(event: Event): boolean;
|
|
215
274
|
setValue(value: number, trim: any): this;
|
|
216
275
|
change(modify: any): void;
|
|
217
|
-
get():
|
|
276
|
+
get(): number;
|
|
218
277
|
update(): void;
|
|
219
278
|
}
|
|
220
279
|
declare class BarSlider extends Widget {
|
|
221
280
|
constructor(id: string, options: object);
|
|
222
281
|
change(event: Event): void;
|
|
223
|
-
set(value:
|
|
224
|
-
get():
|
|
282
|
+
set(value: number): void;
|
|
283
|
+
get(): number;
|
|
225
284
|
}
|
|
226
285
|
declare class BarSelect extends Widget {
|
|
227
286
|
constructor(id: string, options: object);
|
|
228
287
|
open(event: Event): void;
|
|
229
288
|
trigger(event: Event): boolean | undefined;
|
|
230
289
|
change(event: Event): this;
|
|
231
|
-
getNameFor(key:
|
|
232
|
-
set(key:
|
|
233
|
-
get():
|
|
290
|
+
getNameFor(key: string): string;
|
|
291
|
+
set(key: string): this;
|
|
292
|
+
get(): string;
|
|
234
293
|
}
|
|
235
294
|
declare class BarText extends Widget {
|
|
236
295
|
constructor(id: string, options: object);
|
|
@@ -246,8 +305,27 @@ declare class ColorPicker extends Widget {
|
|
|
246
305
|
set(color: any): this;
|
|
247
306
|
get(): any;
|
|
248
307
|
}
|
|
308
|
+
interface ToolbarOptions {
|
|
309
|
+
id: string
|
|
310
|
+
name?: string
|
|
311
|
+
/**
|
|
312
|
+
* If true, the toolbar will display a label abovee
|
|
313
|
+
*/
|
|
314
|
+
label?: boolean
|
|
315
|
+
condition?: ConditionResolvable
|
|
316
|
+
/**
|
|
317
|
+
* If true, the toolbar will only take as much width as needed
|
|
318
|
+
*/
|
|
319
|
+
narrow?: boolean
|
|
320
|
+
vertical?: boolean
|
|
321
|
+
/**
|
|
322
|
+
* Default content of the toolbar. Separators are available, where _ = separator, + = spaces, # = line break
|
|
323
|
+
*/
|
|
324
|
+
children: ('_' | '+' | '#' | string | BarItem)[]
|
|
325
|
+
}
|
|
249
326
|
declare class Toolbar {
|
|
250
|
-
constructor(data:
|
|
327
|
+
constructor(id: string, data: ToolbarOptions);
|
|
328
|
+
constructor(data: ToolbarOptions);
|
|
251
329
|
build(data: any, force: any): this;
|
|
252
330
|
contextmenu(event: Event): void;
|
|
253
331
|
editMenu(): this;
|
|
@@ -262,7 +340,6 @@ declare namespace BARS {
|
|
|
262
340
|
const stored: {};
|
|
263
341
|
const editing_bar: undefined | Toolbar;
|
|
264
342
|
const action_definers: (() => void)[];
|
|
265
|
-
const condition: any;
|
|
266
343
|
function defineActions(definer: any): void;
|
|
267
344
|
function setupActions(): void;
|
|
268
345
|
function setupToolbars(): void;
|
|
@@ -270,6 +347,9 @@ declare namespace BARS {
|
|
|
270
347
|
function updateConditions(): void;
|
|
271
348
|
function updateToolToolbar(): void;
|
|
272
349
|
}
|
|
350
|
+
/**
|
|
351
|
+
* A dialog-based interface to search and trigger actions and other things
|
|
352
|
+
*/
|
|
273
353
|
declare namespace ActionControl {
|
|
274
354
|
const open: boolean;
|
|
275
355
|
const type: string;
|
|
@@ -282,6 +362,9 @@ declare namespace ActionControl {
|
|
|
282
362
|
function click(action: any, event: Event): void;
|
|
283
363
|
function handleKeys(event: Event): boolean;
|
|
284
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* Stores and handles keybinds
|
|
367
|
+
*/
|
|
285
368
|
declare namespace Keybinds {
|
|
286
369
|
const actions: BarItem[];
|
|
287
370
|
const stored: {};
|