blockbench-types 4.5.0 → 4.6.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/package.json +10 -3
- package/scripts/generate_docs.js +368 -0
- package/tsconfig.json +16 -0
- package/types/action.d.ts +75 -11
- package/types/animation.d.ts +53 -22
- package/types/animation_controller.d.ts +112 -0
- package/types/blockbench.d.ts +406 -0
- package/types/canvas.d.ts +90 -54
- package/types/codec.d.ts +62 -1
- package/types/cube.d.ts +132 -0
- package/types/dialog.d.ts +109 -32
- package/types/display_mode.d.ts +37 -0
- package/types/format.d.ts +4 -4
- package/types/group.d.ts +74 -0
- package/types/interface.d.ts +4 -4
- package/types/keyframe.d.ts +18 -11
- package/types/menu.d.ts +2 -5
- package/types/mesh.d.ts +138 -0
- package/types/misc.d.ts +172 -0
- package/types/mode.d.ts +34 -0
- package/types/outliner.d.ts +61 -123
- package/types/painter.d.ts +29 -0
- package/types/panel.d.ts +4 -4
- package/types/plugin.d.ts +4 -0
- package/types/preview_scene.d.ts +3 -3
- package/types/project.d.ts +7 -3
- package/types/screencam.d.ts +63 -0
- package/types/settings.d.ts +10 -10
- package/types/textures.d.ts +4 -2
- package/types/timeline.d.ts +4 -1
- package/types/undo.d.ts +29 -9
- package/types/util.d.ts +35 -4
- package/types/validator.d.ts +3 -3
- package/types/file_system.d.ts +0 -145
- package/types/index.d.ts +0 -312
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blockbench-types",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.1",
|
|
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,18 @@
|
|
|
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",
|
|
22
25
|
"@types/tinycolor2": "^1.4.3",
|
|
23
26
|
"three": "^0.129.0",
|
|
27
|
+
"typescript": "^4.9.5",
|
|
24
28
|
"vue": "^2.6.14",
|
|
25
|
-
"wintersky": "^1.1
|
|
29
|
+
"wintersky": "^1.2.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"typedoc": "^0.23.24"
|
|
26
33
|
}
|
|
27
34
|
}
|
|
@@ -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
|
+
'THREE.Vector3': '[THREE.Vector3](https://threejs.org/docs/index.html#api/en/math/Vector3)',
|
|
72
|
+
'THREE.Euler': '[THREE.Euler](https://threejs.org/docs/index.html#api/en/math/Euler)',
|
|
73
|
+
'THREE.Quaternion': '[THREE.Quaternion](https://threejs.org/docs/index.html#api/en/math/Quaternion)',
|
|
74
|
+
'THREE.Object3D': '[THREE.Object3D](https://threejs.org/docs/index.html#api/en/core/Object3D)',
|
|
75
|
+
'THREE.PerspectiveCamera': '[THREE.PerspectiveCamera](https://threejs.org/docs/index.html#api/en/cameras/PerspectiveCamera)',
|
|
76
|
+
'THREE.OrthographicCamera': '[THREE.OrthographicCamera](https://threejs.org/docs/index.html#api/en/cameras/OrthographicCamera)',
|
|
77
|
+
'THREE.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
|
}
|
|
@@ -29,22 +35,45 @@ interface BarItemOptions extends KeybindItemOptions {
|
|
|
29
35
|
name?: string
|
|
30
36
|
description?: string
|
|
31
37
|
icon: string
|
|
32
|
-
condition?:
|
|
38
|
+
condition?: ConditionResolvable
|
|
33
39
|
category?: string
|
|
34
40
|
keybind?: Keybind
|
|
35
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Anything that can go into a toolbar, including actions, tools, toggles, widgets etc.
|
|
44
|
+
*/
|
|
36
45
|
declare class BarItem extends KeybindItem {
|
|
37
46
|
constructor(id: string, options: BarItemOptions);
|
|
38
47
|
conditionMet(): boolean;
|
|
39
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Adds a label to the HTML element of the bar item
|
|
50
|
+
* @param in_bar Set to true to generate an in-bar label, as opposed to a regular on-hover label
|
|
51
|
+
* @param action Provide the action to generate the label. This defaults to self and is only needed in special cases
|
|
52
|
+
*/
|
|
53
|
+
addLabel(in_bar?: boolean, action?: any): void;
|
|
54
|
+
/**
|
|
55
|
+
* Gets a copy of the elements HTML node that is not yet in use.
|
|
56
|
+
*/
|
|
40
57
|
getNode(): HTMLElement;
|
|
58
|
+
/**
|
|
59
|
+
* Appends the bar item to a HTML element
|
|
60
|
+
*/
|
|
41
61
|
toElement(destination: HTMLElement): this;
|
|
42
62
|
pushToolbar(bar: any): void;
|
|
43
63
|
}
|
|
44
64
|
|
|
45
65
|
interface ActionOptions extends BarItemOptions {
|
|
66
|
+
/**
|
|
67
|
+
* Function to run when user uses the action successfully
|
|
68
|
+
*/
|
|
46
69
|
click(event: Event): void
|
|
70
|
+
/**
|
|
71
|
+
* Icon color. Can be a CSS color string, or an axis letter to use an axis color.
|
|
72
|
+
*/
|
|
47
73
|
color?: string
|
|
74
|
+
/**
|
|
75
|
+
* ID of a setting that the action is slinked to
|
|
76
|
+
*/
|
|
48
77
|
linked_setting?: string
|
|
49
78
|
children?: object[]
|
|
50
79
|
/**
|
|
@@ -52,6 +81,9 @@ interface ActionOptions extends BarItemOptions {
|
|
|
52
81
|
*/
|
|
53
82
|
label?: boolean
|
|
54
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Actions can be triggered to run something, they can be added to menus, toolbars, assigned a keybinding, or run via Action Control
|
|
86
|
+
*/
|
|
55
87
|
declare class Action extends BarItem {
|
|
56
88
|
constructor(id: string, options: ActionOptions);
|
|
57
89
|
/**
|
|
@@ -68,6 +100,26 @@ declare class Action extends BarItem {
|
|
|
68
100
|
*/
|
|
69
101
|
side_menu?: Menu
|
|
70
102
|
}
|
|
103
|
+
interface ToggleOptions extends ActionOptions {
|
|
104
|
+
/**
|
|
105
|
+
* Default value of the toggle
|
|
106
|
+
*/
|
|
107
|
+
default?: boolean
|
|
108
|
+
/**
|
|
109
|
+
* Method that gets called when the user changes the value of the toggle
|
|
110
|
+
*/
|
|
111
|
+
onChange?(value: boolean): void
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A toggle is a type of action that can be on or off. The state is not persistent between restarts by default.
|
|
115
|
+
*/
|
|
116
|
+
declare class Toggle extends Action {
|
|
117
|
+
constructor(id: string, options: ToggleOptions);
|
|
118
|
+
/**
|
|
119
|
+
* Updates the state of the toggle in the UI
|
|
120
|
+
*/
|
|
121
|
+
updateEnabledState(): void
|
|
122
|
+
}
|
|
71
123
|
|
|
72
124
|
type RGBAColor = {r: number, g: number, b: number, a: number}
|
|
73
125
|
type ViewMode = 'textured' | 'solid' | 'wireframe' | 'uv' | 'normal'
|
|
@@ -177,6 +229,9 @@ interface ToolOptions extends ActionOptions {
|
|
|
177
229
|
paintTool?: boolean
|
|
178
230
|
brush?: BrushOptions
|
|
179
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* A tool, such as mvoe tool, vertex snap tool, or paint brush
|
|
234
|
+
*/
|
|
180
235
|
declare class Tool extends Action {
|
|
181
236
|
constructor(id: string, options: ToolOptions);
|
|
182
237
|
select(): this | undefined;
|
|
@@ -189,7 +244,7 @@ declare class NumSlider extends Widget {
|
|
|
189
244
|
constructor(id: string, options: object);
|
|
190
245
|
startInput(event: Event): void;
|
|
191
246
|
setWidth(width: any): this;
|
|
192
|
-
getInterval(event: Event):
|
|
247
|
+
getInterval(event: Event): number;
|
|
193
248
|
slide(clientX: any, event: Event): void;
|
|
194
249
|
input(): void;
|
|
195
250
|
stopInput(): void;
|
|
@@ -197,23 +252,23 @@ declare class NumSlider extends Widget {
|
|
|
197
252
|
trigger(event: Event): boolean;
|
|
198
253
|
setValue(value: number, trim: any): this;
|
|
199
254
|
change(modify: any): void;
|
|
200
|
-
get():
|
|
255
|
+
get(): number;
|
|
201
256
|
update(): void;
|
|
202
257
|
}
|
|
203
258
|
declare class BarSlider extends Widget {
|
|
204
259
|
constructor(id: string, options: object);
|
|
205
260
|
change(event: Event): void;
|
|
206
|
-
set(value:
|
|
207
|
-
get():
|
|
261
|
+
set(value: number): void;
|
|
262
|
+
get(): number;
|
|
208
263
|
}
|
|
209
264
|
declare class BarSelect extends Widget {
|
|
210
265
|
constructor(id: string, options: object);
|
|
211
266
|
open(event: Event): void;
|
|
212
267
|
trigger(event: Event): boolean | undefined;
|
|
213
268
|
change(event: Event): this;
|
|
214
|
-
getNameFor(key:
|
|
215
|
-
set(key:
|
|
216
|
-
get():
|
|
269
|
+
getNameFor(key: string): string;
|
|
270
|
+
set(key: string): this;
|
|
271
|
+
get(): string;
|
|
217
272
|
}
|
|
218
273
|
declare class BarText extends Widget {
|
|
219
274
|
constructor(id: string, options: object);
|
|
@@ -245,7 +300,6 @@ declare namespace BARS {
|
|
|
245
300
|
const stored: {};
|
|
246
301
|
const editing_bar: undefined | Toolbar;
|
|
247
302
|
const action_definers: (() => void)[];
|
|
248
|
-
const condition: any;
|
|
249
303
|
function defineActions(definer: any): void;
|
|
250
304
|
function setupActions(): void;
|
|
251
305
|
function setupToolbars(): void;
|
|
@@ -253,6 +307,9 @@ declare namespace BARS {
|
|
|
253
307
|
function updateConditions(): void;
|
|
254
308
|
function updateToolToolbar(): void;
|
|
255
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* A dialog-based interface to search and trigger actions and other things
|
|
312
|
+
*/
|
|
256
313
|
declare namespace ActionControl {
|
|
257
314
|
const open: boolean;
|
|
258
315
|
const type: string;
|
|
@@ -265,6 +322,9 @@ declare namespace ActionControl {
|
|
|
265
322
|
function click(action: any, event: Event): void;
|
|
266
323
|
function handleKeys(event: Event): boolean;
|
|
267
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Stores and handles keybinds
|
|
327
|
+
*/
|
|
268
328
|
declare namespace Keybinds {
|
|
269
329
|
const actions: BarItem[];
|
|
270
330
|
const stored: {};
|
|
@@ -272,4 +332,8 @@ declare namespace Keybinds {
|
|
|
272
332
|
const structure: {};
|
|
273
333
|
function save (): void;
|
|
274
334
|
function reset (): void;
|
|
275
|
-
}
|
|
335
|
+
}
|
|
336
|
+
declare class _ToolToolbar extends Toolbar {
|
|
337
|
+
selected: Tool
|
|
338
|
+
}
|
|
339
|
+
declare const Toolbox: _ToolToolbar;
|