blockbench-types 4.9.0 → 4.11.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.
Files changed (50) hide show
  1. package/.prettierignore +1 -0
  2. package/.prettierrc.json +9 -0
  3. package/README.md +3 -2
  4. package/package.json +43 -33
  5. package/scripts/generate_docs.js +243 -196
  6. package/tsconfig.json +13 -14
  7. package/types/action.d.ts +358 -279
  8. package/types/animation.d.ts +181 -147
  9. package/types/animation_controller.d.ts +105 -99
  10. package/types/blockbench.d.ts +136 -76
  11. package/types/canvas.d.ts +239 -228
  12. package/types/canvas_frame.d.ts +2 -2
  13. package/types/codec.d.ts +36 -32
  14. package/types/cube.d.ts +32 -11
  15. package/types/desktop.d.ts +14 -0
  16. package/types/dialog.d.ts +175 -38
  17. package/types/display_mode.d.ts +17 -6
  18. package/types/file_system.d.ts +159 -0
  19. package/types/format.d.ts +55 -12
  20. package/types/global.d.ts +49 -3
  21. package/types/group.d.ts +16 -5
  22. package/types/index.d.ts +1 -0
  23. package/types/interface.d.ts +21 -12
  24. package/types/io.d.ts +2 -2
  25. package/types/keyframe.d.ts +72 -58
  26. package/types/legacy.d.ts +2 -1
  27. package/types/math_util.d.ts +1 -1
  28. package/types/menu.d.ts +93 -78
  29. package/types/mesh.d.ts +89 -64
  30. package/types/misc.d.ts +114 -47
  31. package/types/mode.d.ts +14 -1
  32. package/types/molang.d.ts +17 -0
  33. package/types/outliner.d.ts +42 -23
  34. package/types/painter.d.ts +49 -11
  35. package/types/panel.d.ts +49 -21
  36. package/types/plugin.d.ts +52 -0
  37. package/types/preview.d.ts +71 -69
  38. package/types/preview_scene.d.ts +26 -17
  39. package/types/project.d.ts +54 -37
  40. package/types/screencam.d.ts +11 -6
  41. package/types/settings.d.ts +87 -85
  42. package/types/shared_actions.d.ts +25 -9
  43. package/types/texture_layers.d.ts +104 -105
  44. package/types/textures.d.ts +322 -313
  45. package/types/timeline.d.ts +60 -60
  46. package/types/undo.d.ts +109 -105
  47. package/types/util.d.ts +152 -37
  48. package/types/uveditor.d.ts +3 -0
  49. package/types/validator.d.ts +3 -2
  50. package/types/vue.d.ts +7 -0
@@ -1,13 +1,17 @@
1
+ /// <reference path="./blockbench.d.ts"/>
1
2
  interface ModelProjectOptions {
2
3
  format: ModelFormat
3
4
  }
4
-
5
5
  /**
6
6
  * A project instance. The tab bar can be used to switch between projects.
7
7
  */
8
8
  declare class ModelProject {
9
9
  constructor(options: ModelProjectOptions)
10
10
 
11
+ static properties: {
12
+ [key: string]: Property<any>
13
+ }
14
+
11
15
  box_uv: boolean
12
16
  texture_width: number
13
17
  texture_height: number
@@ -52,10 +56,10 @@ declare class ModelProject {
52
56
  edges: string[]
53
57
  faces: string[]
54
58
  }
55
- };
56
- selected_faces: []
59
+ }
60
+ selected_faces: any[]
57
61
  textures: Texture[]
58
- selected_texture: Texture | null;
62
+ selected_texture: Texture | null
59
63
  outliner: OutlinerNode[]
60
64
  animations: _Animation[]
61
65
  timeline_animators: []
@@ -65,40 +69,53 @@ declare class ModelProject {
65
69
  rotation: [number, number, number]
66
70
  scale: [number, number, number]
67
71
  mirror: [boolean, boolean, boolean]
68
- export(): void;
72
+ export?(...args: any[]): any
69
73
  }
70
- };
71
- ambientocclusion: boolean;
72
- front_gui_light: boolean;
73
- overrides: any;
74
+ }
75
+ overrides?: any
76
+ exploded_view: boolean
77
+ tool: string
78
+ uv_viewport: {
79
+ zoom: number
80
+ offset: [number, number]
81
+ [key: string]: any
82
+ }
83
+ backgrounds: {
84
+ [key: string]: any
85
+ }
86
+ unhandled_root_fields: any
87
+ ambientocclusion: boolean
88
+ front_gui_light: boolean
74
89
 
75
- get model_3d(): THREE.Object3D;
76
- get materials(): {
90
+ get model_3d(): THREE.Object3D
91
+ get materials(): {
77
92
  [uuid: UUID]: THREE.ShaderMaterial
78
- };
79
- get nodes_3d(): {
93
+ }
94
+ get nodes_3d(): {
80
95
  [uuid: UUID]: THREE.Object3D
81
- };
96
+ }
82
97
 
83
- getDisplayName(): string;
84
- openSettings(): void;
85
- whenNextOpen(callback: () => void): void;
86
- select(): boolean;
87
- unselect(): void;
88
- close(force: any): Promise<boolean>;
98
+ getDisplayName(): string
99
+ openSettings(): void
100
+ whenNextOpen(callback: () => void): void
101
+ select(): boolean
102
+ unselect(): void
103
+ close(force: any): Promise<boolean>
89
104
 
105
+ saveEditorState(): void
106
+ loadEditorState(): void
90
107
  static all: ModelProject[]
91
108
  }
92
109
 
93
110
  /**
94
111
  * Global variable and shortcut to get the currently opened project. If no project is open, or the New Tab is open, this value is falsy.
95
112
  */
96
- declare const Project: ModelProject | 0
113
+ declare let Project: ModelProject | null | undefined
97
114
 
98
- declare function setupProject(format: ModelFormat | string): boolean;
99
- declare function newProject(format: ModelFormat | string): boolean;
100
- declare function setProjectResolution(width: number, height: number, modify_uv?: boolean): void;
101
- declare function updateProjectResolution(): void;
115
+ declare function setupProject(format: ModelFormat | string, uuid?: string): boolean
116
+ declare function newProject(format: ModelFormat | string): boolean
117
+ declare function setProjectResolution(width: number, height: number, modify_uv?: boolean): void
118
+ declare function updateProjectResolution(): void
102
119
 
103
120
  /**
104
121
  * An edit session instance. Edit sessions can be attached to a project to collaborate on it with multiple users via P2P connections.
@@ -116,22 +133,22 @@ declare class EditSession {
116
133
 
117
134
  updateClientCound(): void
118
135
  start(username?: string): void
119
- join(username: string, token: string)
136
+ join(username: string, token: string): void
120
137
  quit(): void
121
138
  setState(active: boolean): void
122
- copyToken(): void;
123
- initNewModel(force?: boolean): void;
124
- initConnection(conn: any): void;
125
- sendAll(type: string, data: any): void;
126
- sendEdit(entry: UndoEntry): void;
127
- receiveData(tag: object): void;
128
- processData(tag: object): void;
129
- catchUp(): void;
139
+ copyToken(): void
140
+ initNewModel(force?: boolean): void
141
+ initConnection(conn: any): void
142
+ sendAll(type: string, data: any): void
143
+ sendEdit(entry: UndoEntry): void
144
+ receiveData(tag: any): void
145
+ processData(tag: any): void
146
+ catchUp(): void
130
147
  /**
131
148
  * Send a chat message
132
149
  * @param text Text to send. If omitted, the current text in the chat panel input is sent
133
150
  */
134
- sendChat(text?: string): void;
135
- addChatMessage(message: any): any;
136
- processChatMessage(data: any): void;
151
+ sendChat(text?: string): void
152
+ addChatMessage(message: any): any
153
+ processChatMessage(data: any): void
137
154
  }
@@ -1,3 +1,4 @@
1
+ /// <reference path="./blockbench.d.ts"/>
1
2
  interface ScreenshotOptions {
2
3
  crop?: boolean
3
4
  width?: number
@@ -41,22 +42,26 @@ declare namespace Screencam {
41
42
  */
42
43
  const recording_timelapse: boolean
43
44
  const gif_options_dialog: Dialog
44
- const gif_crop: {top: number, left: number, right: number, bottom: number}
45
+ const gif_crop: { top: number; left: number; right: number; bottom: number }
45
46
 
46
- function screenshotPreview(preview: Preview, options: ScreenshotOptions, cb: ScreenshotReturn): void
47
+ function screenshotPreview(
48
+ preview: Preview,
49
+ options: ScreenshotOptions,
50
+ cb: ScreenshotReturn
51
+ ): void
47
52
 
48
53
  function fullScreen(options: ScreenshotOptions, cb: ScreenshotReturn): void
49
54
 
50
55
  function screenshot2DEditor(options: ScreenshotOptions, cb: ScreenshotReturn): void
51
56
 
52
- function returnScreenshot(dataUrl, cb: ScreenshotReturn, blob): void
57
+ function returnScreenshot(dataUrl: any, cb: ScreenshotReturn, blob: any): void
53
58
 
54
59
  /**
55
60
  * Runs callback in a clean canvas, where only the model is visible and the control gizmos are hidden
56
- * @param options
57
- * @param cb
61
+ * @param options
62
+ * @param cb
58
63
  */
59
- function cleanCanvas(options, cb: ScreenshotReturn): void
64
+ function cleanCanvas(options: any, cb: ScreenshotReturn): void
60
65
 
61
66
  function createGif(options: RecordGIFOptions, cb: ScreenshotReturn): void
62
67
 
@@ -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
- name: string
3
- type?: 'number' | 'string' | 'boolean' | 'password' | 'select' | 'click'
4
- value: boolean | number | string
5
- condition?: ConditionResolvable
6
- category: string
7
- description?: string
8
- //launch_setting?: boolean
9
- min?: number
10
- max?: number
11
- step?: number
12
- icon?: string
13
- click?(): void
14
- options?: {
15
- [id: string]: string
16
- }
17
- onChange?: (value: any) => void
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
- constructor(id: string, options: SettingOptions);
25
-
26
- id: string
27
- type: string
28
- condition: any
29
- /**
30
- * The master value, not affected by profiles
31
- */
32
- master_value: any
33
- /**
34
- * The active value
35
- */
36
- value: any
37
- /**
38
- * The value that is displayed in the settings dialog
39
- */
40
- ui_value: any
41
- name: string
42
- description: string
43
- category: string
44
- /**
45
- * 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.
46
- */
47
- launch_setting: boolean
48
- min?: number
49
- max?: number
50
- step?: number
51
- icon?: string
52
- options?: {
53
- [id: string]: string
54
- }
55
- hidden?: boolean
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
- const structure: {};
74
- const stored: {};
75
- /**
76
- * Opens the settings dialog
77
- * @param options
78
- */
79
- function open(options?: Partial<{
80
- search: string
81
- tab: 'setting' | 'keybindings' | 'layout_settings' | 'credits'
82
- }>): void;
83
- /**
84
- * Save all settings to the local storage
85
- */
86
- function saveLocalStorages(): void;
87
- /**
88
- * Save the settings and apply changes
89
- */
90
- function save(): void;
91
- /**
92
- * Returns the value of the specified setting
93
- */
94
- function get(setting_id: string): any;
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
- };
@@ -27,7 +27,7 @@
27
27
  *
28
28
  */
29
29
  declare namespace SharedActions {
30
- const checks: {
30
+ const checks: {
31
31
  [id: SharedActionID]: SharedActionHandler
32
32
  }
33
33
 
@@ -52,19 +52,29 @@ declare namespace SharedActions {
52
52
  * @param context Optional context variable
53
53
  * @param force Force the specified handler to run and ignore its condition
54
54
  */
55
- function runSpecific(action_id: SharedActionID, subject: string, event?: Event, context?: any, force?: boolean): boolean
55
+ function runSpecific(
56
+ action_id: SharedActionID,
57
+ subject: string,
58
+ event?: Event,
59
+ context?: any,
60
+ force?: boolean
61
+ ): boolean
56
62
  /**
57
63
  * Check if there is an active and available handler in the current situation for a shared action
58
- * @param action_id
64
+ * @param action_id
59
65
  */
60
66
  function condition(action_id: SharedActionID): boolean
61
67
  /**
62
68
  * Find the active handler in the current situation for a shared action
63
- * @param action_id
64
- * @param event
65
- * @param context
69
+ * @param action_id
70
+ * @param event
71
+ * @param context
66
72
  */
67
- function find(action_id: SharedActionID, event?: Event, context?: any): SharedActionHandler | null
73
+ function find(
74
+ action_id: SharedActionID,
75
+ event?: Event,
76
+ context?: any
77
+ ): SharedActionHandler | null
68
78
  }
69
79
 
70
80
  interface SharedActionHandler {
@@ -74,5 +84,11 @@ interface SharedActionHandler {
74
84
  run: (event?: Event, context?: any) => void
75
85
  }
76
86
 
77
- type SharedActionID = string | 'rename' | 'delete' | 'duplicate' | 'select_all' | 'unselect_all' | 'invert_selection'
78
-
87
+ type SharedActionID =
88
+ | string
89
+ | 'rename'
90
+ | 'delete'
91
+ | 'duplicate'
92
+ | 'select_all'
93
+ | 'unselect_all'
94
+ | 'invert_selection'
@@ -1,118 +1,117 @@
1
1
  /// <reference types="three" />
2
2
 
3
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
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
13
  }
14
14
 
15
15
  /**
16
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
17
  */
18
18
  declare class TextureLayer {
19
- constructor(data: TextureLayerData, texture: Texture, uuid?: string);
19
+ constructor(data: TextureLayerData, texture: Texture, uuid?: string)
20
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'
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
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): 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): 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
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
108
 
109
-
110
- /**
111
- * Get all layers of the active texture
112
- */
113
- static all: TextureLayer[]
114
- /**
115
- * Get the selected layer
116
- */
117
- static selected: TextureLayer
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
118
117
  }