blockbench-types 4.4.0 → 4.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockbench-types",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "description": "Blockbench typescript types",
5
5
  "main": "",
6
6
  "types": "types/index.d.ts",
package/types/codec.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  interface CodecOptions {
2
2
  name: string
3
3
  load?(model: any, file: object, add?: boolean): void
4
- compile?(): void
5
- parse?(): void
4
+ compile?(options?: object): void
5
+ parse?(data: any, path: string): void
6
6
  export?(): void
7
7
  /**
8
8
  * Generate a file name to suggest when exporting
@@ -10,6 +10,7 @@ interface CodecOptions {
10
10
  fileName?(): string
11
11
  startPath?(): string
12
12
  write?(content: any, path: string): void
13
+ overwrite?(content: any, path: string, callback: ((path) => void)): void
13
14
  afterDownload?(path): void
14
15
  afterSave?(path): void
15
16
 
@@ -30,8 +31,8 @@ declare class Codec extends Deletable {
30
31
  constructor(id: string, options: CodecOptions)
31
32
 
32
33
  load?(model: any, file: object, add?: boolean): void
33
- compile?(): any
34
- parse?(model): void
34
+ compile?(options?: object): any
35
+ parse?(data: any, path: string): void
35
36
  export?(): void
36
37
  /**
37
38
  * Generate a file name to suggest when exporting
@@ -39,6 +40,7 @@ declare class Codec extends Deletable {
39
40
  fileName?(): string
40
41
  startPath?(): string
41
42
  write?(content: any, path: string): void
43
+ overwrite?(content: any, path: string, callback: ((path) => void)): void
42
44
  afterDownload?(path): void
43
45
  afterSave?(path): void
44
46
  on(event_name: string, callback: (data: object) => void): void
package/types/dialog.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  interface DialogFormElement {
2
2
  label: string
3
3
  description?: string
4
- type: 'text' | 'number' | 'checkbox' | 'select' | 'radio' | 'textarea' | 'vector' | 'color' | 'file' | 'folder' | 'save' | 'info'
4
+ type: 'text' | 'number' | 'range' | 'checkbox' | 'select' | 'radio' | 'textarea' | 'vector' | 'color' | 'file' | 'folder' | 'save' | 'info'
5
5
  nocolon?: boolean
6
+ full_width?: boolean
6
7
  readonly?: boolean
7
8
  value?: any
8
9
  placeholder?: string
@@ -54,7 +55,7 @@ interface DialogOptions {
54
55
  /**
55
56
  * Array of HTML object strings for each line of content in the dialog.
56
57
  */
57
- lines?: (string|HTMLElement)[]
58
+ lines?: (HTMLElement | {label?: string, widget?: Widget|(() => Widget), nocolon?: boolean} | string)[]
58
59
  /**
59
60
  * Creates a form in the dialog
60
61
  */
@@ -86,6 +87,10 @@ interface DialogOptions {
86
87
  * List of buttons
87
88
  */
88
89
  buttons?: string[]
90
+ /**
91
+ * Unless set to false, clicking on the darkened area outside of the dialog will cancel the dialog.
92
+ */
93
+ cancel_on_click_outside?: boolean
89
94
  }
90
95
 
91
96
  interface DialogSidebarOptions {
@@ -25,6 +25,10 @@ declare namespace Blockbench {
25
25
  * Reads the content from the specified files. Desktop app only.
26
26
  */
27
27
  export function read(files: string[], options?: ReadOptions, callback?: (files: FileResult[]) => void): void
28
+ /**
29
+ * Reads the content from the specified files. Desktop app only.
30
+ */
31
+ export function readFile(files: string[], options?: ReadOptions, callback?: (files: FileResult[]) => void): void
28
32
 
29
33
 
30
34
 
package/types/format.d.ts CHANGED
@@ -46,27 +46,28 @@ interface FormatOptions {
46
46
  onFormatPage?(): void
47
47
  onStart?(): void
48
48
 
49
- box_uv: boolean
50
- optional_box_uv: boolean
51
- single_texture: boolean
52
- model_identifier: boolean
53
- parent_model_id: boolean
54
- vertex_color_ambient_occlusion: boolean
55
- animated_textures: boolean
56
- bone_rig: boolean
57
- centered_grid: boolean
58
- rotate_cubes: boolean
59
- integer_size: boolean
60
- meshes: boolean
61
- texture_meshes: boolean
62
- locators: boolean
63
- rotation_limit: boolean
64
- uv_rotation: boolean
65
- java_face_properties: boolean
66
- select_texture_for_particles: boolean
67
- bone_binding_expression: boolean
68
- animation_files: boolean
69
- texture_folder: boolean
49
+ box_uv?: boolean
50
+ optional_box_uv?: boolean
51
+ single_texture?: boolean
52
+ model_identifier?: boolean
53
+ parent_model_id?: boolean
54
+ vertex_color_ambient_occlusion?: boolean
55
+ animated_textures?: boolean
56
+ bone_rig?: boolean
57
+ centered_grid?: boolean
58
+ rotate_cubes?: boolean
59
+ integer_size?: boolean
60
+ meshes?: boolean
61
+ texture_meshes?: boolean
62
+ locators?: boolean
63
+ rotation_limit?: boolean
64
+ uv_rotation?: boolean
65
+ java_face_properties?: boolean
66
+ select_texture_for_particles?: boolean
67
+ bone_binding_expression?: boolean
68
+ animation_files?: boolean
69
+ texture_folder?: boolean
70
+ image_editor?: boolean
70
71
  edit_mode?: boolean
71
72
  paint_mode?: boolean
72
73
  display_mode?: boolean
@@ -118,11 +119,12 @@ declare class ModelFormat extends Deletable {
118
119
  bone_binding_expression: boolean
119
120
  animation_files: boolean
120
121
  texture_folder: boolean
121
- edit_mode?: boolean
122
- paint_mode?: boolean
123
- display_mode?: boolean
124
- animation_mode?: boolean
125
- pose_mode?: boolean
122
+ image_editor: boolean
123
+ edit_mode: boolean
124
+ paint_mode: boolean
125
+ display_mode: boolean
126
+ animation_mode: boolean
127
+ pose_mode: boolean
126
128
 
127
129
  cube_size_limiter?: CubeSizeLimiter
128
130
  /**
package/types/index.d.ts CHANGED
@@ -40,7 +40,7 @@ type UUID = string
40
40
  declare const isApp: boolean
41
41
 
42
42
  type EventName = 'remove_animation'
43
- | 'display_animation_fram'
43
+ | 'display_animation_frame'
44
44
  | 'before_closing'
45
45
  | 'create_session'
46
46
  | 'join_session'
@@ -215,7 +215,7 @@ declare namespace Blockbench {
215
215
  function addListener(event_names: EventName, callback: (data: object) => void): void
216
216
  function on(event_names: EventName, callback: (data: object) => void): void
217
217
 
218
- function removeEventListener(event_names: EventName): void
218
+ function removeListener(event_names: EventName): void
219
219
  }
220
220
 
221
221
 
package/types/menu.d.ts CHANGED
@@ -22,10 +22,10 @@ interface MenuOptions {
22
22
  keep_open?: boolean
23
23
  searchable?: boolean
24
24
  }
25
- /**
26
- * Creates a new context menu
27
- */
28
25
  declare class Menu extends Deletable {
26
+ /**
27
+ * Creates a new context menu
28
+ */
29
29
  constructor(id: string, template: MenuItem[] | ((context?: any) => MenuItem[]), options?: MenuOptions)
30
30
  constructor(template: MenuItem[] | ((context?: any) => MenuItem[]), options?: MenuOptions)
31
31
 
package/types/undo.d.ts CHANGED
@@ -40,21 +40,70 @@ type UndoEntry = {
40
40
  action: string
41
41
  time: number
42
42
  }
43
+ interface AmendEditForm {
44
+ condition?: Condition
45
+ type?: 'number'
46
+ label: string
47
+ interval_type: 'position' | 'rotation'
48
+ getInterval?: (Event) => number
49
+ value?: number | string,
50
+ min?: number,
51
+ max?: number,
52
+ step?: number,
53
+ }
43
54
 
44
55
  declare class UndoSystem {
45
56
  constructor();
57
+ /**
58
+ * Starts an edit to the current project by saving the state of the provided aspects
59
+ * @param aspects Aspects to save
60
+ */
46
61
  initEdit(aspects: UndoAspects): any;
62
+ /**
63
+ * Finishes an edit by saving the state of the project after it was changed
64
+ * @param action Description of the edit
65
+ */
47
66
  finishEdit(action: string, aspects?: UndoAspects): {
48
67
  before: any;
49
68
  post: any;
50
69
  action: any;
51
70
  time: number;
52
71
  };
72
+ /**
73
+ * Cancels an event before it was finished and reset the project to the state before
74
+ */
53
75
  cancelEdit(): void;
76
+ /**
77
+ * Add keyframes to the current edit that were indirectly removed by moving other keyframes to their position
78
+ * @param keyframes
79
+ */
54
80
  addKeyframeCasualties(keyframes: Keyframe[]): void;
81
+ /**
82
+ * Undoes the latest edit
83
+ */
55
84
  undo(remote?: boolean): void;
85
+ /**
86
+ * Redoes the latest edit
87
+ */
88
+ redo(remote?: boolean): void;
89
+ /**
90
+ * Redoes the latest edit
91
+ */
56
92
  redo(remote?: boolean): void;
57
- remoteEdit(entry: UndoEntry): void;
58
- loadSave(save: UndoSave, reference: UndoSave, mode?: string): void;
93
+ /**
94
+ * Provides a menu to amend the latest edit with slightly changed values
95
+ */
96
+ amendEdit(form: AmendEditForm, callback: (values: {}, form: {}) => void)
97
+
98
+ /**
99
+ * Loads a specific undo save
100
+ * @param save The undo save to load
101
+ * @param reference The current undo save for reference
102
+ * @param mode The load save modes
103
+ */
104
+ loadSave(save: UndoSave, reference: UndoSave, mode?: 'session'): void;
59
105
  }
106
+ /**
107
+ * Blockbench's system to register edits to the project and switch between them
108
+ */
60
109
  declare let Undo: UndoSystem;