blockbench-types 4.8.0 → 4.10.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/.prettierignore +1 -0
- package/.prettierrc.json +9 -0
- package/README.md +1 -0
- package/package.json +43 -33
- package/scripts/generate_docs.js +243 -194
- package/tsconfig.json +13 -14
- package/types/action.d.ts +358 -279
- package/types/animation.d.ts +181 -143
- package/types/animation_controller.d.ts +105 -99
- package/types/blockbench.d.ts +146 -76
- package/types/canvas.d.ts +239 -228
- package/types/canvas_frame.d.ts +2 -2
- package/types/codec.d.ts +36 -32
- package/types/cube.d.ts +32 -11
- package/types/desktop.d.ts +14 -0
- package/types/dialog.d.ts +164 -37
- package/types/display_mode.d.ts +13 -6
- package/types/file_system.d.ts +159 -0
- package/types/format.d.ts +46 -12
- package/types/global.d.ts +49 -3
- package/types/group.d.ts +16 -5
- package/types/index.d.ts +1 -0
- package/types/interface.d.ts +21 -12
- package/types/io.d.ts +2 -0
- package/types/keyframe.d.ts +73 -57
- package/types/legacy.d.ts +2 -1
- package/types/math_util.d.ts +1 -0
- package/types/menu.d.ts +93 -78
- package/types/mesh.d.ts +89 -64
- package/types/misc.d.ts +114 -47
- package/types/mode.d.ts +14 -0
- package/types/molang.d.ts +17 -0
- package/types/outliner.d.ts +42 -23
- package/types/painter.d.ts +49 -11
- package/types/panel.d.ts +49 -21
- package/types/plugin.d.ts +29 -1
- package/types/preview.d.ts +71 -69
- package/types/preview_scene.d.ts +11 -12
- package/types/project.d.ts +56 -34
- package/types/screencam.d.ts +11 -6
- package/types/settings.d.ts +87 -85
- package/types/shared_actions.d.ts +94 -0
- package/types/texture_layers.d.ts +117 -0
- package/types/textures.d.ts +381 -176
- package/types/timeline.d.ts +60 -60
- package/types/undo.d.ts +107 -103
- package/types/util.d.ts +165 -33
- package/types/uveditor.d.ts +3 -0
- package/types/validator.d.ts +3 -2
- package/types/vue.d.ts +7 -0
package/types/settings.d.ts
CHANGED
|
@@ -1,99 +1,101 @@
|
|
|
1
|
+
/// <reference path="./blockbench.d.ts"/>
|
|
2
|
+
declare const settings: {
|
|
3
|
+
[id: string]: Setting
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
interface SettingOptions {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
name: string
|
|
8
|
+
type?: 'number' | 'string' | 'boolean' | 'password' | 'select' | 'click'
|
|
9
|
+
value: boolean | number | string
|
|
10
|
+
condition?: ConditionResolvable
|
|
11
|
+
category: string
|
|
12
|
+
description?: string
|
|
13
|
+
//launch_setting?: boolean
|
|
14
|
+
min?: number
|
|
15
|
+
max?: number
|
|
16
|
+
step?: number
|
|
17
|
+
icon?: string
|
|
18
|
+
click?(): void
|
|
19
|
+
options?: {
|
|
20
|
+
[id: string]: string
|
|
21
|
+
}
|
|
22
|
+
onChange?(value: any): void
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
/**
|
|
21
26
|
* Settings can be used to add global configuration options to Blockbench. All settings are listed under File > Preferences > Settings.
|
|
22
27
|
*/
|
|
23
28
|
declare class Setting extends Deletable {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
onChange?: () => {}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Sets the value of the setting, while triggering the onChange function if available, and saving the change.
|
|
60
|
-
*/
|
|
61
|
-
set(value): void
|
|
62
|
-
/**
|
|
63
|
-
* Triggers the setting, as if selected in action control. This toggles boolean settings, opens a dialog for string or numeric settings, etc.
|
|
64
|
-
*/
|
|
65
|
-
trigger(event?: Event): void
|
|
66
|
-
|
|
29
|
+
constructor(id: string, options: SettingOptions)
|
|
30
|
+
id: string
|
|
31
|
+
type: string
|
|
32
|
+
condition: any
|
|
33
|
+
/**
|
|
34
|
+
* The master value, not affected by profiles
|
|
35
|
+
*/
|
|
36
|
+
master_value: any
|
|
37
|
+
/**
|
|
38
|
+
* The active value
|
|
39
|
+
*/
|
|
40
|
+
value: any
|
|
41
|
+
/**
|
|
42
|
+
* The value that is displayed in the settings dialog
|
|
43
|
+
*/
|
|
44
|
+
ui_value: any
|
|
45
|
+
name: string
|
|
46
|
+
description: string
|
|
47
|
+
category: string
|
|
48
|
+
/**
|
|
49
|
+
* If true, the setting can be used by the main process before initializing the Blockbench window. This is not available to custom settings created by plugins.
|
|
50
|
+
*/
|
|
51
|
+
launch_setting: boolean
|
|
52
|
+
min?: number
|
|
53
|
+
max?: number
|
|
54
|
+
step?: number
|
|
55
|
+
icon?: string
|
|
56
|
+
options?: {
|
|
57
|
+
[id: string]: string
|
|
58
|
+
}
|
|
59
|
+
hidden?: boolean
|
|
60
|
+
onChange?: () => {}
|
|
67
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Sets the value of the setting, while triggering the onChange function if available, and saving the change.
|
|
64
|
+
*/
|
|
65
|
+
set(value: any): void
|
|
66
|
+
/**
|
|
67
|
+
* Triggers the setting, as if selected in action control. This toggles boolean settings, opens a dialog for string or numeric settings, etc.
|
|
68
|
+
*/
|
|
69
|
+
trigger(event?: Event): void
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
70
72
|
* Global namespace handling data and functionality related to settings.
|
|
71
73
|
*/
|
|
74
|
+
declare type SettingItems = Record<string, { name: string; open: boolean; items: SettingItems }>
|
|
75
|
+
|
|
72
76
|
declare namespace Settings {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
77
|
+
const structure: Record<string, SettingItems>
|
|
78
|
+
const stored: Record<string, Setting>
|
|
79
|
+
/**
|
|
80
|
+
* Opens the settings dialog
|
|
81
|
+
* @param options
|
|
82
|
+
*/
|
|
83
|
+
function open(
|
|
84
|
+
options?: Partial<{
|
|
85
|
+
search: string
|
|
86
|
+
tab: 'setting' | 'keybindings' | 'layout_settings' | 'credits'
|
|
87
|
+
}>
|
|
88
|
+
): void
|
|
89
|
+
/**
|
|
90
|
+
* Save all settings to the local storage
|
|
91
|
+
*/
|
|
92
|
+
function saveLocalStorages(): void
|
|
93
|
+
/**
|
|
94
|
+
* Save the settings and apply changes
|
|
95
|
+
*/
|
|
96
|
+
function save(): void
|
|
97
|
+
/**
|
|
98
|
+
* Returns the value of the specified setting
|
|
99
|
+
*/
|
|
100
|
+
function get(setting_id: string): any
|
|
95
101
|
}
|
|
96
|
-
|
|
97
|
-
declare const settings: {
|
|
98
|
-
[id: string]: Setting
|
|
99
|
-
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Actions is a system in Blockbench to allow actions (including in toolbars, menus, via action control, or keybinding) to run different code in different cases, such as in different modes or different panels.
|
|
3
|
+
* As an example, the "Duplicate" action runs code to duplicate elements when used in the outliner, and duplicates textures when used in the textures panel.
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* Handlers can be added for existing actions like this:
|
|
7
|
+
|
|
8
|
+
### Example:
|
|
9
|
+
|
|
10
|
+
```javascript
|
|
11
|
+
// Duplicate layers when using "Duplicate" in the layers panel
|
|
12
|
+
SharedActions.add('duplicate', {
|
|
13
|
+
subject: 'layer',
|
|
14
|
+
condition: () => Prop.active_panel == 'layers' && TextureLayer.selected,
|
|
15
|
+
run() {
|
|
16
|
+
let texture = Texture.selected;
|
|
17
|
+
let original = texture.getActiveLayer();
|
|
18
|
+
let copy = original.getUndoCopy(true);
|
|
19
|
+
copy.name += '-copy';
|
|
20
|
+
Undo.initEdit({textures: [texture]});
|
|
21
|
+
let layer = new TextureLayer(copy, texture);
|
|
22
|
+
layer.addForEditing();
|
|
23
|
+
Undo.finishEdit('Duplicate layer');
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
declare namespace SharedActions {
|
|
30
|
+
const checks: {
|
|
31
|
+
[id: SharedActionID]: SharedActionHandler
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Add a new handler to a shared action
|
|
36
|
+
* @param action_id Action ID
|
|
37
|
+
* @param handler Handler options
|
|
38
|
+
*/
|
|
39
|
+
function add(action_id: SharedActionID, handler: SharedActionHandler): Deletable
|
|
40
|
+
/**
|
|
41
|
+
* Run the active handler for a specific subject manually
|
|
42
|
+
* @param action_id Action ID
|
|
43
|
+
* @param event Event that triggered the interaction
|
|
44
|
+
* @param context Optional context variable
|
|
45
|
+
*/
|
|
46
|
+
function run(action_id: SharedActionID, event?: Event, context?: any): boolean
|
|
47
|
+
/**
|
|
48
|
+
* Run a specific handler manually
|
|
49
|
+
* @param action_id Action ID
|
|
50
|
+
* @param subject Subject to run on
|
|
51
|
+
* @param event Event that triggered the interaction
|
|
52
|
+
* @param context Optional context variable
|
|
53
|
+
* @param force Force the specified handler to run and ignore its condition
|
|
54
|
+
*/
|
|
55
|
+
function runSpecific(
|
|
56
|
+
action_id: SharedActionID,
|
|
57
|
+
subject: string,
|
|
58
|
+
event?: Event,
|
|
59
|
+
context?: any,
|
|
60
|
+
force?: boolean
|
|
61
|
+
): boolean
|
|
62
|
+
/**
|
|
63
|
+
* Check if there is an active and available handler in the current situation for a shared action
|
|
64
|
+
* @param action_id
|
|
65
|
+
*/
|
|
66
|
+
function condition(action_id: SharedActionID): boolean
|
|
67
|
+
/**
|
|
68
|
+
* Find the active handler in the current situation for a shared action
|
|
69
|
+
* @param action_id
|
|
70
|
+
* @param event
|
|
71
|
+
* @param context
|
|
72
|
+
*/
|
|
73
|
+
function find(
|
|
74
|
+
action_id: SharedActionID,
|
|
75
|
+
event?: Event,
|
|
76
|
+
context?: any
|
|
77
|
+
): SharedActionHandler | null
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface SharedActionHandler {
|
|
81
|
+
priority: number
|
|
82
|
+
subject: string
|
|
83
|
+
condition: ConditionResolvable
|
|
84
|
+
run: (event?: Event, context?: any) => void
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type SharedActionID =
|
|
88
|
+
| string
|
|
89
|
+
| 'rename'
|
|
90
|
+
| 'delete'
|
|
91
|
+
| 'duplicate'
|
|
92
|
+
| 'select_all'
|
|
93
|
+
| 'unselect_all'
|
|
94
|
+
| 'invert_selection'
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/// <reference types="three" />
|
|
2
|
+
|
|
3
|
+
interface TextureLayerData {
|
|
4
|
+
name?: string
|
|
5
|
+
in_limbo?: boolean
|
|
6
|
+
offset?: ArrayVector2
|
|
7
|
+
scale?: ArrayVector2
|
|
8
|
+
opacity?: number
|
|
9
|
+
visible?: boolean
|
|
10
|
+
blend_mode?: 'default' | 'set_opacity' | 'color' | 'multiply' | 'add' | 'screen' | 'difference'
|
|
11
|
+
image_data?: ImageData
|
|
12
|
+
data_url?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Texture layers always belong to a texture and represent the layers of the texture. Each layer has its own HTML canvas and canvas context
|
|
17
|
+
*/
|
|
18
|
+
declare class TextureLayer {
|
|
19
|
+
constructor(data: TextureLayerData, texture: Texture, uuid?: string)
|
|
20
|
+
|
|
21
|
+
name: string
|
|
22
|
+
uuid: UUID
|
|
23
|
+
texture: Texture
|
|
24
|
+
canvas: HTMLCanvasElement
|
|
25
|
+
ctx: CanvasRenderingContext2D
|
|
26
|
+
in_limbo: boolean
|
|
27
|
+
img: HTMLImageElement
|
|
28
|
+
/**
|
|
29
|
+
* Layer offset from the top left corner of the texture to the top left corner of the layer
|
|
30
|
+
*/
|
|
31
|
+
offset: ArrayVector2
|
|
32
|
+
/**
|
|
33
|
+
* Layer scale. This is only used by the layer transform tool and should be applied and reset to 1x1 before doing further changes
|
|
34
|
+
*/
|
|
35
|
+
scale: ArrayVector2
|
|
36
|
+
opacity: number
|
|
37
|
+
visible: boolean
|
|
38
|
+
blend_mode: 'default' | 'set_opacity' | 'color' | 'multiply' | 'add' | 'screen' | 'difference'
|
|
39
|
+
|
|
40
|
+
extend(data: TextureLayerData): void
|
|
41
|
+
/**
|
|
42
|
+
* Selects the layer
|
|
43
|
+
*/
|
|
44
|
+
select(): void
|
|
45
|
+
showContextMenu(event: Event): void
|
|
46
|
+
/**
|
|
47
|
+
* Remove the layer
|
|
48
|
+
* @param undo Create an undo point and update the texture
|
|
49
|
+
*/
|
|
50
|
+
remove(undo: boolean): void
|
|
51
|
+
getUndoCopy(image_data: boolean): object
|
|
52
|
+
getSaveCopy(): object
|
|
53
|
+
/**
|
|
54
|
+
* Set the layer into a limbo state, where clicking Place or clicking next to the layer will place it on the layer below
|
|
55
|
+
*/
|
|
56
|
+
setLimbo(): void
|
|
57
|
+
/**
|
|
58
|
+
* Resolves the limbo state by turning the limbo layer into a full layer, or merging it into the layer below
|
|
59
|
+
* @param keep_separate If true, the layer is kept as a separate layer
|
|
60
|
+
*/
|
|
61
|
+
resolveLimbo(keep_separate: boolean): void
|
|
62
|
+
/**
|
|
63
|
+
* Set the layer size. This resizes the canvas, which discards the layer content
|
|
64
|
+
*/
|
|
65
|
+
setSize(width: number, height: number): void
|
|
66
|
+
/**
|
|
67
|
+
* Toggle layer visibility. This creates an undo point
|
|
68
|
+
*/
|
|
69
|
+
toggleVisibility(): void
|
|
70
|
+
/**
|
|
71
|
+
* Scroll the layer panel list to
|
|
72
|
+
*/
|
|
73
|
+
scrollTo(): void
|
|
74
|
+
/**
|
|
75
|
+
* Add the layer to the associated texture above the previously selected layer, select this layer, and scroll the layer panel list to it
|
|
76
|
+
*/
|
|
77
|
+
addForEditing(): void
|
|
78
|
+
/**
|
|
79
|
+
* Merge this texture onto the texture below
|
|
80
|
+
* @param undo Create an undo entry
|
|
81
|
+
*/
|
|
82
|
+
mergeDown(undo: boolean): void
|
|
83
|
+
/**
|
|
84
|
+
* Expand the layer to include the listed pixels
|
|
85
|
+
* @param points
|
|
86
|
+
*/
|
|
87
|
+
expandTo(...points: ArrayVector2): void
|
|
88
|
+
/**
|
|
89
|
+
* Flip the texture along an axis
|
|
90
|
+
* @param axis Flip axis, where 0 is X and 1 is Y
|
|
91
|
+
* @param undo Create an undo entry
|
|
92
|
+
*/
|
|
93
|
+
flip(axis: number, undo: boolean): void
|
|
94
|
+
/**
|
|
95
|
+
* Rotate the layer around itself in 90 degree steps
|
|
96
|
+
* @param angle Angle in degrees
|
|
97
|
+
* @param undo Create an undo entry
|
|
98
|
+
*/
|
|
99
|
+
rotate(angle: number, undo: boolean): void
|
|
100
|
+
/**
|
|
101
|
+
* Centers the layer on the texture
|
|
102
|
+
*/
|
|
103
|
+
center(): void
|
|
104
|
+
/**
|
|
105
|
+
* Open the properties dialog
|
|
106
|
+
*/
|
|
107
|
+
propertiesDialog(): void
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Get all layers of the active texture
|
|
111
|
+
*/
|
|
112
|
+
static all: TextureLayer[]
|
|
113
|
+
/**
|
|
114
|
+
* Get the selected layer
|
|
115
|
+
*/
|
|
116
|
+
static selected: TextureLayer
|
|
117
|
+
}
|