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.
Files changed (50) hide show
  1. package/.prettierignore +1 -0
  2. package/.prettierrc.json +9 -0
  3. package/README.md +1 -0
  4. package/package.json +43 -33
  5. package/scripts/generate_docs.js +243 -194
  6. package/tsconfig.json +13 -14
  7. package/types/action.d.ts +358 -279
  8. package/types/animation.d.ts +181 -143
  9. package/types/animation_controller.d.ts +105 -99
  10. package/types/blockbench.d.ts +146 -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 +164 -37
  17. package/types/display_mode.d.ts +13 -6
  18. package/types/file_system.d.ts +159 -0
  19. package/types/format.d.ts +46 -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 -0
  25. package/types/keyframe.d.ts +73 -57
  26. package/types/legacy.d.ts +2 -1
  27. package/types/math_util.d.ts +1 -0
  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 -0
  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 +29 -1
  37. package/types/preview.d.ts +71 -69
  38. package/types/preview_scene.d.ts +11 -12
  39. package/types/project.d.ts +56 -34
  40. package/types/screencam.d.ts +11 -6
  41. package/types/settings.d.ts +87 -85
  42. package/types/shared_actions.d.ts +94 -0
  43. package/types/texture_layers.d.ts +117 -0
  44. package/types/textures.d.ts +381 -176
  45. package/types/timeline.d.ts +60 -60
  46. package/types/undo.d.ts +107 -103
  47. package/types/util.d.ts +165 -33
  48. package/types/uveditor.d.ts +3 -0
  49. package/types/validator.d.ts +3 -2
  50. package/types/vue.d.ts +7 -0
package/types/format.d.ts CHANGED
@@ -1,31 +1,44 @@
1
+ /// <reference path="./blockbench.d.ts"/>
2
+
1
3
  interface FormatPage {
2
4
  component?: Vue.Component
3
- content?: ({
4
- type: 'image' | 'h2' | 'h3' | 'h4' | 'text' | 'label' | 'image' | ''
5
- text?: string
6
- source?: string
7
- width?: number
8
- height?: number
9
- } | string)[]
5
+ content?: (
6
+ | {
7
+ type: 'image' | 'h2' | 'h3' | 'h4' | 'text' | 'label' | 'image' | ''
8
+ text?: string
9
+ source?: string
10
+ width?: number
11
+ height?: number
12
+ }
13
+ | string
14
+ )[]
10
15
  button_text?: string
11
16
  }
12
17
  interface CubeSizeLimiter {
13
18
  /**
14
19
  * Test whether the cube with the optionally provided values violates the size restrictions
15
20
  */
16
- test: (cube: Cube, values?: {from: ArrayVector3, to: ArrayVector3, inflate: number}) => boolean
21
+ test: (
22
+ cube: Cube,
23
+ values?: { from: ArrayVector3; to: ArrayVector3; inflate: number }
24
+ ) => boolean
17
25
  /**
18
26
  * Move the cube back into the restructions
19
27
  */
20
- move: (cube: Cube, values?: {from: ArrayVector3, to: ArrayVector3, inflate: number}) => void
28
+ move(cube: Cube, values?: { from: ArrayVector3; to: ArrayVector3; inflate: number }): void
21
29
  /**
22
30
  * Clamp the cube to fit into the restrictions. When an axis and direction is provided, clamp the element on that side to prevent wandering.
23
31
  */
24
- clamp: (cube: Cube, values?: {from: ArrayVector3, to: ArrayVector3, inflate: number}, axis?: number, direction?: boolean | null) => void
32
+ clamp: (
33
+ cube: Cube,
34
+ values?: { from: ArrayVector3; to: ArrayVector3; inflate: number },
35
+ axis?: number,
36
+ direction?: boolean | null
37
+ ) => void
25
38
  /**
26
39
  * Set to true to tell Blockbench to check and adjust the cube limit after rotating a cube
27
40
  */
28
- rotation_affected?: boolean,
41
+ rotation_affected?: boolean
29
42
  /**
30
43
  * Optionally set the coordinate limits of cubes in local space
31
44
  */
@@ -45,11 +58,17 @@ interface FormatOptions {
45
58
  format_page?: FormatPage
46
59
  onFormatPage?(): void
47
60
  onStart?(): void
61
+ onSetup?(project: ModelProject, newModel?: boolean): void
62
+ convertTo?(): void
48
63
 
49
64
  box_uv?: boolean
50
65
  optional_box_uv?: boolean
51
66
  single_texture?: boolean
67
+ single_texture_default?: boolean
68
+ per_group_texture?: boolean
69
+ per_texture_uv_size?: boolean
52
70
  model_identifier?: boolean
71
+ legacy_editable_file_name?: boolean
53
72
  parent_model_id?: boolean
54
73
  vertex_color_ambient_occlusion?: boolean
55
74
  animated_textures?: boolean
@@ -62,9 +81,11 @@ interface FormatOptions {
62
81
  texture_meshes?: boolean
63
82
  locators?: boolean
64
83
  rotation_limit?: boolean
84
+ rotation_snap?: boolean
65
85
  uv_rotation?: boolean
66
86
  java_face_properties?: boolean
67
87
  select_texture_for_particles?: boolean
88
+ texture_mcmeta?: boolean
68
89
  bone_binding_expression?: boolean
69
90
  animation_files?: boolean
70
91
  texture_folder?: boolean
@@ -74,6 +95,8 @@ interface FormatOptions {
74
95
  display_mode?: boolean
75
96
  animation_mode?: boolean
76
97
  pose_mode?: boolean
98
+ animation_controllers?: boolean
99
+ render_sides?: 'front'
77
100
 
78
101
  cube_size_limiter?: CubeSizeLimiter
79
102
 
@@ -98,11 +121,16 @@ declare class ModelFormat extends Deletable {
98
121
  format_page?: FormatPage
99
122
  onFormatPage?(): void
100
123
  onStart?(): void
124
+ onSetup?(): void
101
125
 
102
126
  box_uv: boolean
103
127
  optional_box_uv: boolean
104
128
  single_texture: boolean
129
+ single_texture_default?: boolean
130
+ per_group_texture?: boolean
131
+ per_texture_uv_size?: boolean
105
132
  model_identifier: boolean
133
+ legacy_editable_file_name?: boolean
106
134
  parent_model_id: boolean
107
135
  vertex_color_ambient_occlusion: boolean
108
136
  animated_textures: boolean
@@ -115,9 +143,11 @@ declare class ModelFormat extends Deletable {
115
143
  texture_meshes: boolean
116
144
  locators: boolean
117
145
  rotation_limit: boolean
146
+ rotation_snap: boolean
118
147
  uv_rotation: boolean
119
148
  java_face_properties: boolean
120
149
  select_texture_for_particles: boolean
150
+ texture_mcmeta: boolean
121
151
  bone_binding_expression: boolean
122
152
  animation_files: boolean
123
153
  texture_folder: boolean
@@ -128,6 +158,8 @@ declare class ModelFormat extends Deletable {
128
158
  animation_mode: boolean
129
159
  pose_mode: boolean
130
160
 
161
+ codec?: Codec
162
+
131
163
  cube_size_limiter?: CubeSizeLimiter
132
164
  /**
133
165
  * Selects the format
@@ -147,7 +179,9 @@ declare class ModelFormat extends Deletable {
147
179
  * The current format
148
180
  */
149
181
  declare const Format: ModelFormat
150
-
182
+ declare const Formats: {
183
+ [id: string]: ModelFormat
184
+ }
151
185
 
152
186
  interface ModelLoaderOptions {
153
187
  id?: string
package/types/global.d.ts CHANGED
@@ -1,9 +1,50 @@
1
+ /// <reference path="./blockbench.d.ts"/>
2
+
1
3
  declare global {
4
+ const THREE: typeof import('three')
5
+
6
+ const Prism: typeof import('prismjs')
7
+ const scene: THREE.Scene
8
+ const Transformer: any
9
+ const DOMPurify: typeof import('dompurify')
10
+ const electron: typeof import('electron')
11
+ const { clipboard, shell, nativeImage, ipcRenderer, dialog }: typeof electron
12
+
13
+ const main_preview: Preview
14
+ let open_interface: Dialog | undefined
15
+
16
+ function confirm(message: string, title: string): boolean
17
+
18
+ const PathModule: typeof import('path')
19
+ const fs: typeof import('fs')
20
+
21
+ const tinycolor: typeof import('tinycolor2')
22
+
23
+ let selected: OutlinerElement[]
24
+ const Toolbars: Record<string, Toolbar>
25
+
26
+ function rotateOnAxis(modify: OutlinerNode, axis: number, slider?: boolean): void
27
+ function afterRotateOnAxis(): void
28
+
29
+ // const Transformer: THREE.TransformControls
30
+ interface HTMLImageElement {
31
+ src: string
32
+ tex: THREE.Texture & {
33
+ magFilter: THREE.TextureFilter
34
+ minFilter: THREE.TextureFilter
35
+ }
36
+ }
2
37
  interface Date {
3
38
  /**
4
39
  * Returns a timestamp in the format 16:30
5
40
  */
6
41
  getTimestamp(): string
42
+ getDateArray(): number[]
43
+ getDateString(): string
44
+ dayOfYear(): number
45
+ }
46
+ interface Number {
47
+ toDigitString(digits: number): string
7
48
  }
8
49
  interface Event {
9
50
  readonly ctrlOrCmd: boolean
@@ -70,13 +111,18 @@ declare global {
70
111
  */
71
112
  safePush(...items: any): boolean
72
113
  equals(array: Array<any>): boolean
114
+ replace(items: T[]): boolean
115
+ allAre(callback: (item: T, index: number) => boolean): boolean
116
+ findInArray(key: string, value: any): number
117
+ positiveItems(): number
73
118
  /**
74
119
  * Empties the array
75
120
  */
76
121
  empty(): this
77
- last(): any
78
- allEqual(item: any): boolean
122
+ last(): T
123
+ allEqual(item: T): boolean
79
124
  random(): T
125
+ toggle(item: T, state?: boolean): boolean
80
126
  /**
81
127
  * Same as forEach, but in reverse order
82
128
  */
@@ -100,4 +146,4 @@ declare global {
100
146
  }
101
147
  }
102
148
 
103
- export {}
149
+ export {}
package/types/group.d.ts CHANGED
@@ -20,9 +20,10 @@ interface GroupOptions {
20
20
  }
21
21
 
22
22
  declare class Group extends OutlinerNode {
23
- constructor (options: Partial<GroupOptions>)
23
+ constructor(options: Partial<GroupOptions>)
24
24
  static selected: Group
25
25
  static all: Group[]
26
+ static animator: BoneAnimator
26
27
  /**Check if any groups are in the project */
27
28
  static hasAny: () => boolean
28
29
 
@@ -38,11 +39,21 @@ declare class Group extends OutlinerNode {
38
39
  isOpen: boolean
39
40
  ik_enabled: boolean
40
41
  ik_chain_length: number
42
+ texture?: string
43
+ skin_original_origin?: ArrayVector3
44
+ bedrock_binding?: string
45
+ cem_animations?: any[]
46
+ cem_attach?: boolean
47
+ cem_scale?: number
48
+ mesh: THREE.Mesh
49
+
50
+ static preview_controller: NodePreviewController
41
51
 
42
52
  extend(options: Partial<GroupOptions>): this
43
53
  selectChildren(event: Event): this
44
54
  selectLow(highlight: boolean): this
45
- unselect(): this
55
+ select(event?: any, isOutlinerClick?: boolean): this | void
56
+ unselect(): this | void
46
57
  matchesSelection(): boolean
47
58
  /**
48
59
  * Opens the group and all of its ancestor groups.
@@ -69,8 +80,8 @@ declare class Group extends OutlinerNode {
69
80
  * Duplicate the group
70
81
  */
71
82
  duplicate(): Group
72
- getSaveCopy(): object
83
+ getSaveCopy(): any
73
84
  getChildlessCopy(): Group
74
- compile(undo: boolean): object
75
- forEachChild(callback: (object: OutlinerNode) => void, type?: any, for_self?: boolean)
85
+ compile(undo: boolean): any
86
+ forEachChild(callback: (any: OutlinerNode) => void, type?: any, for_self?: boolean): void
76
87
  }
@@ -0,0 +1 @@
1
+ /// <reference path="./blockbench.d.ts"/>
@@ -1,3 +1,5 @@
1
+ /// <reference path="./blockbench.d.ts"/>
2
+
1
3
  interface ResizeLineOptions {
2
4
  condition?: ConditionResolvable
3
5
  horizontal?: boolean
@@ -16,11 +18,15 @@ declare class ResizeLine {
16
18
  set(): void
17
19
  node: HTMLElement
18
20
  update(): void
19
- setPosition(data: {top?: number, bottom?: number, left?: number, right?: number}): void
21
+ setPosition(data: { top?: number; bottom?: number; left?: number; right?: number }): void
20
22
  }
21
23
 
22
24
  declare namespace Interface {
23
- function createElement(type: keyof HTMLElementTagNameMap, attributes?: {}, content?: string | HTMLElement | HTMLElement[]): HTMLElement
25
+ function createElement(
26
+ type: keyof HTMLElementTagNameMap,
27
+ attributes?: {},
28
+ content?: string | HTMLElement | HTMLElement[]
29
+ ): HTMLElement
24
30
 
25
31
  const data: {
26
32
  left_bar_width: number
@@ -50,12 +56,12 @@ declare namespace Interface {
50
56
  }
51
57
  const status_bar: {
52
58
  menu: Menu
53
- vue: Vue
59
+ vue: Vue.Component
54
60
  }
55
61
  const Panels: {
56
- (key: string): Panel
62
+ [key: string]: Panel
57
63
  }
58
- function toggleSidebar(side, status): void
64
+ function toggleSidebar(side: any, status: any): void
59
65
 
60
66
  const text_edit_menu: Menu
61
67
 
@@ -70,12 +76,15 @@ declare namespace Interface {
70
76
  const left_bar: HTMLElement
71
77
 
72
78
  namespace CustomElements {
73
- function SelectInput(id: string, options: {
74
- value?: string
75
- default?: string
76
- options: {key: string, value: string}
77
- onChange?(): void
78
- }): HTMLElement
79
- const ResizeLine;
79
+ function SelectInput(
80
+ id: string,
81
+ options: {
82
+ value?: string
83
+ default?: string
84
+ options: { [key: string]: string }
85
+ onChange?(): void
86
+ }
87
+ ): HTMLElement
88
+ const ResizeLine: any
80
89
  }
81
90
  }
package/types/io.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare function autoParseJSON(data: string, feedback?: boolean): any
2
+ declare function autoStringifyJSON(data: any): string
@@ -1,68 +1,84 @@
1
+ /// <reference path="./blockbench.d.ts"/>
2
+
1
3
  interface KeyframeDataPointData {
2
- [key: string]: any
4
+ [key: string]: any
3
5
  }
4
- declare class KeyframeDataPoint {
5
- constructor(keyframe: _Keyframe);
6
- extend(data: KeyframeDataPointData): void;
7
- getUndoCopy(): {
8
- [key: string]: any
9
- };
6
+ declare class KeyframeDataPoint extends Object {
7
+ static properties: Record<string, Property<any>>
8
+ constructor(keyframe: _Keyframe)
9
+ extend(data: KeyframeDataPointData): void
10
+ getUndoCopy(): {
11
+ [key: string]: any
12
+ }
13
+ [key: string]: any
10
14
  }
11
15
 
12
16
  interface KeyframeOptions {
13
- channel?: string
14
- data_points: {}[]
15
- time: number
16
- color: number
17
- uniform: boolean
18
- interpolation: 'linear' | 'catmullrom' | 'bezier' | 'step' | string
19
- bezier_linked: boolean
20
- bezier_left_time: ArrayVector3
21
- bezier_left_value: ArrayVector3
22
- bezier_right_time: ArrayVector3
23
- bezier_right_value: ArrayVector3
17
+ channel?: string
18
+ data_points: {}[]
19
+ time: number
20
+ color?: number
21
+ uniform?: boolean
22
+ interpolation?: 'linear' | 'catmullrom' | 'bezier' | 'step' | string
23
+ bezier_linked?: boolean
24
+ bezier_left_time?: ArrayVector3
25
+ bezier_left_value?: ArrayVector3
26
+ bezier_right_time?: ArrayVector3
27
+ bezier_right_value?: ArrayVector3
24
28
  }
25
29
  type axisLetter = 'x' | 'y' | 'z'
26
30
 
27
31
  declare class _Keyframe {
28
- constructor(options: KeyframeOptions, uuid: any);
29
-
30
- animator: GeneralAnimator;
31
-
32
- channel: string
33
- data_points: KeyframeDataPoint[]
34
- time: number
35
- color: number
36
- uniform: boolean
37
- interpolation: 'linear' | 'catmullrom' | 'bezier' | 'step' | string
38
- bezier_linked: boolean
39
- bezier_left_time: ArrayVector3;
40
- bezier_right_time: ArrayVector3;
41
- bezier_left_value: ArrayVector3;
42
- bezier_right_value: ArrayVector3;
32
+ constructor(options: KeyframeOptions, uuid: any)
33
+ static selected: _Keyframe[]
34
+ data_points: KeyframeDataPoint[]
35
+ animator: GeneralAnimator
36
+ channel: string
37
+ time: number
38
+ uuid: string
39
+ color: number
40
+ uniform: boolean
41
+ interpolation: 'linear' | 'catmullrom' | 'bezier' | 'step'
42
+ cooldown?: boolean
43
+ bezier_linked: boolean
44
+ bezier_left_time: ArrayVector3
45
+ bezier_right_time: ArrayVector3
46
+ bezier_left_value: ArrayVector3
47
+ bezier_right_value: ArrayVector3
43
48
 
49
+ extend(data: KeyframeOptions): this
50
+ get(axis: axisLetter, data_point?: number): number | string
51
+ calc(axis: axisLetter, data_point?: number): number
52
+ set(axis: axisLetter, value: any, data_point?: number): this
53
+ offset(axis: axisLetter, amount: any, data_point?: number): void
54
+ flip(axis: axisLetter): this
55
+ getLerp(other: any, axis: axisLetter, amount: any, allow_expression?: boolean): number
56
+ getCatmullromLerp(
57
+ before_plus: _Keyframe,
58
+ before: _Keyframe,
59
+ after: _Keyframe,
60
+ after_plus: _Keyframe,
61
+ axis: axisLetter,
62
+ alpha: number
63
+ ): number
64
+ getArray(data_point?: number): (number | string)[]
65
+ getFixed(
66
+ data_point?: number,
67
+ get_quaternion?: boolean
68
+ ): THREE.Vector3 | THREE.Euler | THREE.Quaternion
69
+ getTimecodeString(): string
70
+ compileBedrockKeyframe(): any
71
+ replaceOthers(save: any): void
72
+ select(event?: any): this
73
+ callPlayhead(): this
74
+ showContextMenu(event: Event): this
75
+ remove(): void
76
+ forSelected(callback: (keyframe: _Keyframe) => void, undo_tag: any): this[]
77
+ getUndoCopy(save: any): {
78
+ animator: any
79
+ channel?: string | null
80
+ data_points: KeyframeDataPoint[]
81
+ }
82
+ }
44
83
 
45
- extend(data: KeyframeOptions): this;
46
- get(axis: axisLetter, data_point?: number): number | string;
47
- calc(axis: axisLetter, data_point?: number): number;
48
- set(axis: axisLetter, value: any, data_point?: number): this;
49
- offset(axis: axisLetter, amount: any, data_point?: number): void;
50
- flip(axis: axisLetter): this;
51
- getLerp(other: any, axis: axisLetter, amount: any, allow_expression?: boolean): number;
52
- getCatmullromLerp(before_plus: _Keyframe, before: _Keyframe, after: _Keyframe, after_plus: _Keyframe, axis: axisLetter, alpha: number): number;
53
- getArray(data_point?: number): (number | string)[];
54
- getFixed(data_point?: number, get_quaternion?: boolean): THREE.Vector3 | THREE.Euler | THREE.Quaternion;
55
- getTimecodeString(): string;
56
- compileBedrockKeyframe(): object;
57
- replaceOthers(save: any): void;
58
- select(event: any): this;
59
- callPlayhead(): this;
60
- showContextMenu(event: Event): this;
61
- remove(): void;
62
- forSelected(callback: (keyframe: _Keyframe) => void, undo_tag: any): this[];
63
- getUndoCopy(save: any): {
64
- animator: any;
65
- channel?: string | null;
66
- data_points: object[];
67
- };
68
- }
84
+ declare function updateKeyframeSelection(): void
package/types/legacy.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ /// <reference path="./blockbench.d.ts"/>
1
2
  /**
2
3
  * Assign plugin information
3
4
  * @deprecated This way of defining plugins is deprecated and will not be supported in the future
4
5
  */
5
- declare var plugin_data: object
6
+ declare var plugin_data: any
@@ -0,0 +1 @@
1
+ declare function guid(): string
package/types/menu.d.ts CHANGED
@@ -1,96 +1,111 @@
1
+ /// <reference path="./blockbench.d.ts"/>
1
2
  interface CustomMenuItem {
2
- name: string
3
- id: string
4
- icon: IconString
5
- color?: string
6
- description?: string
7
- /**
8
- * Keybind or string to display in the menu, won't work as an actual keybinding by default
9
- */
10
- keybind?: Keybind | string
11
- /**
12
- * Adds a search bar to the menu or submenu
13
- */
14
- searchable?: boolean
15
- children?: MenuItem[] | (() => MenuItem[])
16
- click?: (context?: any, event?: Event) => void
3
+ name: string
4
+ id: string
5
+ icon: IconString
6
+ color?: string
7
+ description?: string
8
+ /**
9
+ * Keybind or string to display in the menu, won't work as an actual keybinding by default
10
+ */
11
+ keybind?: Keybind | string
12
+ /**
13
+ * Adds a search bar to the menu or submenu
14
+ */
15
+ searchable?: boolean
16
+ children?: MenuItem[] | (() => MenuItem[])
17
+ click?(context?: any, event?: Event): void
17
18
  }
18
- type MenuItem = CustomMenuItem | Action | BarSelect | string;
19
+ type MenuItem = CustomMenuItem | Action | BarSelect | MenuSeparator | string
19
20
  interface MenuOptions {
20
- onOpen?: (position: MouseEvent | HTMLElement, context?: any) => void
21
- onClose?(): void
22
- keep_open?: boolean
23
- searchable?: boolean
21
+ onOpen?(position: MouseEvent | HTMLElement, context?: any): void
22
+ onClose?(): void
23
+ keep_open?: boolean
24
+ searchable?: boolean
25
+ class?: string
24
26
  }
25
27
  /**
26
28
  * Use the Menu class to create a context menu. Menus can contain custom entries and hierarchy, or existing actions and tools.
27
29
  */
28
30
  declare class Menu extends Deletable {
29
- constructor(id: string, template: MenuItem[] | ((context?: any) => MenuItem[]), options?: MenuOptions)
30
- constructor(template: MenuItem[] | ((context?: any) => MenuItem[]), options?: MenuOptions)
31
+ /**
32
+ * Creates a new context menu
33
+ */
34
+ constructor(
35
+ id: string,
36
+ template: MenuItem[] | ((context?: any) => MenuItem[]),
37
+ options?: MenuOptions
38
+ )
39
+ constructor(template: MenuItem[] | ((context?: any) => MenuItem[]), options?: MenuOptions)
31
40
 
32
- /**
33
- * Opens the menu somewhere
34
- * @param position Position where to open the menu. Can be a mouse event, or a node that the menu is spawned below.
35
- * @param context Context for the click events inside the menu
36
- */
37
- open(position: MouseEvent | HTMLElement, context?: any): this
38
- /**
39
- * Closes the menu if it's open
40
- */
41
- hide(): this
42
- /**
43
- * Adds an action to the menu structure
44
- * @param action Action to add
45
- * @param path Path pointing to the location. Use the ID of each level of the menu, or index within a level, separated by a point. For example, `export.0` places the action at the top position of the Export submenu.
46
- */
47
- addAction(action: Action, path?: string): void
48
- /**
49
- *
50
- * @param path Path pointing to the location. Use the ID of each level of the menu, or index within a level, or item ID, separated by a point. For example, `export.export_special_format` removes the action "Export Special Format" from the Export submenu.
51
- */
52
- removeAction(path: string): void
41
+ /**
42
+ * Opens the menu somewhere
43
+ * @param position Position where to open the menu. Can be a mouse event, or a node that the menu is spawned below.
44
+ * @param context Context for the click events inside the menu
45
+ */
46
+ open(position: MouseEvent | HTMLElement, context?: any): this
47
+ /**
48
+ * Closes the menu if it's open
49
+ */
50
+ hide(): this
51
+ /**
52
+ * Adds an action to the menu structure
53
+ * @param action Action to add
54
+ * @param path Path pointing to the location. Use the ID of each level of the menu, or index within a level, separated by a point. For example, `export.0` places the action at the top position of the Export submenu.
55
+ */
56
+ addAction(action: Action, path?: string | number): void
57
+ /**
58
+ *
59
+ * @param path Path pointing to the location. Use the ID of each level of the menu, or index within a level, or item ID, separated by a point. For example, `export.export_special_format` removes the action "Export Special Format" from the Export submenu.
60
+ */
61
+ removeAction(path: string): void
62
+ structure: MenuItem[]
53
63
  }
54
64
 
55
65
  /**
56
66
  * Creates a new menu in the menu bar
57
67
  */
58
68
  declare class BarMenu extends Menu {
59
- constructor(id: string, structure: MenuItem[], condition?: ConditionResolvable)
60
- /**
61
- * Visually highlights an action within the menu, until the user opens the menu
62
- */
63
- highlight(action: Action): void
69
+ constructor(id: string, structure: MenuItem[], condition?: ConditionResolvable)
70
+ type: 'bar_menu'
71
+ id: string
72
+ condition?: ConditionResolvable
73
+ name: string
74
+ structure: MenuItem[]
75
+ /**
76
+ * Visually highlights an action within the menu, until the user opens the menu
77
+ */
78
+ highlight(action: Action): void
64
79
  }
65
80
 
66
81
  declare namespace MenuBar {
67
- const menus: {
68
- file: Menu
69
- edit: Menu
70
- transform: Menu
71
- uv: Menu
72
- texture: Menu
73
- animation: Menu
74
- keyframe: Menu
75
- display: Menu
76
- tools: Menu
77
- view: Menu
78
- help: Menu
79
- [id: string]: Menu
80
- }
81
- /**
82
- * Adds an action to the menu structure
83
- * @param action Action to add
84
- * @param path Path pointing to the location. Use the ID of each level of the menu, or index or group within a level, separated by a point. For example, `file.export.0` places the action at the top position of the Export submenu in the File menu.
85
- */
86
- function addAction(action: Action, path?: string): void
87
- /**
88
- *
89
- * @param path Path pointing to the location. Use the ID of each level of the menu, or index or group within a level, or item ID, separated by a point. For example, `export.export_special_format` removes the action "Export Special Format" from the Export submenu.
90
- */
91
- function removeAction(path: string)
92
- /**
93
- * Update the menu bar
94
- */
95
- function update(): void
96
- }
82
+ const menus: {
83
+ file: Menu
84
+ edit: Menu
85
+ transform: Menu
86
+ uv: Menu
87
+ texture: Menu
88
+ animation: Menu
89
+ keyframe: Menu
90
+ display: Menu
91
+ tools: Menu
92
+ view: Menu
93
+ help: Menu
94
+ [id: string]: Menu
95
+ }
96
+ /**
97
+ * Adds an action to the menu structure
98
+ * @param action Action to add
99
+ * @param path Path pointing to the location. Use the ID of each level of the menu, or index or group within a level, separated by a point. For example, `file.export.0` places the action at the top position of the Export submenu in the File menu.
100
+ */
101
+ function addAction(action: Action, path?: string): void
102
+ /**
103
+ *
104
+ * @param path Path pointing to the location. Use the ID of each level of the menu, or index or group within a level, or item ID, separated by a point. For example, `export.export_special_format` removes the action "Export Special Format" from the Export submenu.
105
+ */
106
+ function removeAction(path: string): void
107
+ /**
108
+ * Update the menu bar
109
+ */
110
+ function update(): void
111
+ }