forked from BabylonJS/Editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babylonjs-editor.d.ts
3037 lines (2986 loc) · 119 KB
/
babylonjs-editor.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Generated by dts-bundle v0.7.3
// Dependencies for this module:
// ../../babylonjs
// ../../typescript
// ../../monaco-editor
// ../../dat-gui
// ../../golden-layout
// ../../babylonjs-editor-code-editor
// ../../babylonjs-gui
// ../../babylonjs-materials
declare module 'babylonjs-editor' {
import Editor from 'babylonjs-editor/editor/editor';
import Tools from 'babylonjs-editor/editor/tools/tools';
import Request from 'babylonjs-editor/editor/tools/request';
import UndoRedo from 'babylonjs-editor/editor/tools/undo-redo';
import ThemeSwitcher, { ThemeType } from 'babylonjs-editor/editor/tools/theme';
import GraphicsTools from 'babylonjs-editor/editor/tools/graphics-tools';
import { ConsoleLevel } from 'babylonjs-editor/editor/components/console';
import Layout from 'babylonjs-editor/editor/gui/layout';
import Toolbar from 'babylonjs-editor/editor/gui/toolbar';
import List from 'babylonjs-editor/editor/gui/list';
import Grid, { GridRow } from 'babylonjs-editor/editor/gui/grid';
import Picker from 'babylonjs-editor/editor/gui/picker';
import Graph, { GraphNode } from 'babylonjs-editor/editor/gui/graph';
import Window from 'babylonjs-editor/editor/gui/window';
import CodeEditor, { TranspilationOutput } from 'babylonjs-editor/editor/gui/code';
import Form from 'babylonjs-editor/editor/gui/form';
import Edition from 'babylonjs-editor/editor/gui/edition';
import Tree, { TreeContextMenuItem, TreeNode } from 'babylonjs-editor/editor/gui/tree';
import Dialog from 'babylonjs-editor/editor/gui/dialog';
import ContextMenu, { ContextMenuItem } from 'babylonjs-editor/editor/gui/context-menu';
import ResizableLayout, { ComponentConfig, ItemConfigType } from 'babylonjs-editor/editor/gui/resizable-layout';
import AbstractEditionTool, { IEditionTool } from 'babylonjs-editor/editor/edition-tools/edition-tool';
import { IStringDictionary, IDisposable, INumberDictionary } from 'babylonjs-editor/editor/typings/typings';
import { EditorPlugin } from 'babylonjs-editor/editor/typings/plugin';
import { ProjectRoot } from 'babylonjs-editor/editor/typings/project';
import CodeProjectEditorFactory from 'babylonjs-editor/editor/project/project-code-editor';
import SceneManager from 'babylonjs-editor/editor/scene/scene-manager';
import SceneFactory from 'babylonjs-editor/editor/scene/scene-factory';
import ScenePreview from 'babylonjs-editor/editor/scene/scene-preview';
import ScenePicker from 'babylonjs-editor/editor/scene/scene-picker';
import PrefabAssetComponent from 'babylonjs-editor/editor/prefabs/asset-component';
import { Prefab, PrefabNodeType } from 'babylonjs-editor/editor/prefabs/prefab';
import ParticlesCreatorExtension, { ParticlesCreatorMetadata } from 'babylonjs-editor/editor/particles/asset-component';
import Storage from 'babylonjs-editor/editor/storage/storage';
import VSCodeSocket from 'babylonjs-editor/editor/extensions/vscode-socket';
export default Editor;
export { Editor, Tools, Request, UndoRedo, ThemeSwitcher, ThemeType, GraphicsTools, ConsoleLevel, IStringDictionary, INumberDictionary, IDisposable, EditorPlugin, Layout, Toolbar, List, Grid, GridRow, Picker, Graph, GraphNode, Window, CodeEditor, TranspilationOutput, Form, Edition, Tree, TreeContextMenuItem, TreeNode, Dialog, ContextMenu, ContextMenuItem, ResizableLayout, ComponentConfig, ItemConfigType, AbstractEditionTool, IEditionTool, ProjectRoot, CodeProjectEditorFactory, SceneManager, SceneFactory, ScenePreview, ScenePicker, PrefabAssetComponent, Prefab, PrefabNodeType, ParticlesCreatorExtension, ParticlesCreatorMetadata, Storage, VSCodeSocket };
}
declare module 'babylonjs-editor/editor/editor' {
import { Scene, FreeCamera, Camera, FilesInput, ArcRotateCamera } from 'babylonjs';
import { IStringDictionary } from 'babylonjs-editor/editor/typings/typings';
import { IEditorPlugin } from 'babylonjs-editor/editor/typings/plugin';
import Core, { IUpdatable } from 'babylonjs-editor/editor/core';
import Layout from 'babylonjs-editor/editor/gui/layout';
import ResizableLayout from 'babylonjs-editor/editor/gui/resizable-layout';
import EditorToolbar from 'babylonjs-editor/editor/components/toolbar';
import EditorGraph from 'babylonjs-editor/editor/components/graph';
import EditorPreview from 'babylonjs-editor/editor/components/preview';
import EditorInspector from 'babylonjs-editor/editor/components/inspector';
import EditorEditPanel from 'babylonjs-editor/editor/components/edit-panel';
import EditorStats from 'babylonjs-editor/editor/components/stats';
import EditorAssets from 'babylonjs-editor/editor/components/assets';
import EditorFiles from 'babylonjs-editor/editor/components/files';
import EditorConsole from 'babylonjs-editor/editor/components/console';
import ScenePicker from 'babylonjs-editor/editor/scene/scene-picker';
import SceneIcons from 'babylonjs-editor/editor/scene/scene-icons';
export default class Editor implements IUpdatable {
core: Core;
camera: FreeCamera | ArcRotateCamera;
playCamera: Camera;
layout: Layout;
resizableLayout: ResizableLayout;
toolbar: EditorToolbar;
graph: EditorGraph;
preview: EditorPreview;
inspector: EditorInspector;
editPanel: EditorEditPanel;
stats: EditorStats;
assets: EditorAssets;
files: EditorFiles;
console: EditorConsole;
plugins: IStringDictionary<IEditorPlugin>;
scenePicker: ScenePicker;
sceneIcons: SceneIcons;
filesInput: FilesInput;
sceneFile: File;
guiFiles: File[];
projectFile: File;
projectFileName: string;
_showReloadDialog: boolean;
static LayoutVersion: string;
static EditorVersion: string;
/**
* Constructor
* @param scene: a scene to edit. If undefined, a default scene will be created
*/
constructor(scene?: Scene);
/**
* Runs the editor and Babylon.js engine
*/
run(): void;
/**
* Resizes elements
*/
resize(): Promise<void>;
/**
* On after render the scene
*/
onPostUpdate(): void;
/**
* Returns the extension instance identified by the given name
* @param name the name of the extension
*/
getExtension<T>(name: string): T;
/**
* Adds an "edit panel" plugin
* @param url the URL of the plugin
* @param restart: if to restart the plugin
* @param name: the name of the plugin to show
* @param params: the params to give to the plugin's constructor
*/
addEditPanelPlugin(url: string, restart?: boolean, name?: string, ...params: any[]): Promise<IEditorPlugin>;
/**
* Removes the given plugin
* @param plugin: the plugin to remove
*/
removePlugin(plugin: IEditorPlugin, removePanel?: boolean): Promise<void>;
/**
* Restarts the plugins already loaded
*/
restartPlugins(removePanels?: boolean): Promise<void>;
/**
* Notifies a message at the bottom of the editor
* @param message the message to show in notification
* @param spinner if the notification should have a spinner
* @param timeout time in ms to wait before hidding the message
*/
notifyMessage(message: string, spinner?: boolean, timeout?: number): void;
/**
* Checks if the user opened a file
* @param fullLoad sets if the loader should load newly added files in the scene folder
*/
checkOpenedFile(): Promise<void>;
/**
* Returns the project file looking from the files input store
*/
getProjectFileFromFilesInputStore(): File;
/**
* Creates the scene picker
*/
createScenePicker(): void;
/**
* Creates the default scene
* @param showNewSceneDialog if to show a dialog to confirm creating default scene
* @param emptyScene sets wether or not the default scene would be empty or not
*/
createDefaultScene(showNewSceneDialog?: boolean, emptyScene?: boolean): Promise<void>;
/**
* Creates the editor camera
*/
createEditorCamera(type?: 'arc' | 'free' | any): Camera;
/**
* Resets the editor's state
*/
resetEditorState(): Promise<void>;
}
}
declare module 'babylonjs-editor/editor/tools/tools' {
import { Scene, BaseTexture } from 'babylonjs';
import { IStringDictionary } from 'babylonjs-editor/editor/typings/typings';
export default class Tools {
static PendingFilesToLoad: number;
static IsStandalone: boolean;
static Version: string;
static Epsilon: number;
/**
* Creates a div element
* @param style: the div's style
*/
static CreateElement<T extends HTMLElement>(type: string, id: string, style?: IStringDictionary<string>): T;
/**
* Returns if the given element is a child (recursively) of the given parent
* @param element the element being possibily a child of the given parent
* @param parent the parent to check
*/
static IsElementChildOf(element: HTMLElement, parent: HTMLElement): boolean;
/**
* Returns if the focused element in the DOM is an input
*/
static IsFocusingInputElement(): boolean;
/**
* Returns the constructor name of the given object
* @param obj the object
*/
static GetConstructorName(obj: any): string;
/**
* Returns if the browser is running in Electron
*/
static IsElectron(): boolean;
/**
* Returns the file type for the given extension
*/
static GetFileType(extension: string): string;
/**
* Returns the extension attached to the given mime type.
*/
static GetExtensionFromMimeType(mimeType: string): string;
/**
* Creates a window popup
* @param url the URL of the popup
* @param name: the name of the popup
* @param width the width of the popup
* @param height the height of the popup
*/
static OpenPopup(url: string, name: string, width: number, height: number): Window;
/**
* Set window's title
* @param title the title of the window
*/
static SetWindowTitle(title: string): void;
/**
* Returns the file extension
* @param filename: the file's name
*/
static GetFileExtension(filename: string): string;
/**
* Returns the filename without extension
* @param filename: the filename (path)
* @param withPath: if the return value should contain all path
*/
static GetFilenameWithoutExtension(filename: string, withPath?: boolean): string;
/**
* Returns the filename
* @param filename: the complete filename with path
*/
static GetFilename(filename: string): string;
/**
* Returns the first texture found wich has the given name
* @param scene the scene containing the textures
* @param name the name of the texture to find
*/
static GetTextureByName(scene: Scene, name: string): BaseTexture;
/**
* Returns the first texture found which has the given url.
* @param scene the scene containing the textures.
* @param url the url of the texture to find.
*/
static GetTextureByUrl(scene: Scene, url: string): BaseTexture;
/**
* Returns the first texture found according to the given serialized values (search by uniqueId, name and Url).
* @param scene the scene containing the textures.
* @param serializedValues the serialized values containing the uniqueId, name and url.
*/
static GetTextureFromSerializedValues(scene: Scene, serializedValues: any): BaseTexture;
/**
* Returns the first texture found which as the given unique Id.
* @param scene the scene containing the textures.
* @param uniqueId the id of the texture to find.
*/
static GetTextureByUniqueId(scene: Scene, uniqueId: number): BaseTexture;
/**
* Creates an open file dialog
* @param callback called once the user selects files
*/
static OpenFileDialog(callback?: (files: File[]) => void): Promise<File[]>;
/**
* Returns the base url of the window
*/
static GetBaseURL(): string;
/**
* Sorts the given string array alphabetically
* @param arr: the array to sort
* @param property: the property to take
*/
static SortAlphabetically(arr: any[], property?: string): void;
/**
* Creates a new File (blob today to fix Edge compatibility)
* @param buffer the file's buffer
* @param filename the file's name
*/
static CreateFile(buffer: Uint8Array, filename: string): File;
/**
* Loads a file using HTTP request
* @param url the url of the file
* @param arrayBuffer if should load file as arraybuffer
*/
static LoadFile<T extends string | ArrayBuffer>(url: string, arrayBuffer?: boolean, onProgress?: (data?: any) => void): Promise<T>;
/**
* Loads a file and creates a new File added to the FilesToLoad
* @param url: the URLof the file
*/
static CreateFileFromURL(url: string): Promise<File>;
/**
* Loads a file and creates a new File
* @param url the URLof the file
*/
static GetFile(url: string): Promise<File>;
/**
* Returns the given file path (for electron)
* @param file the file to get its path
*/
static GetFilePath(file: File): string;
/**
* Converts a string to an UInt8Array
* @param str: the string to convert
*/
static ConvertStringToUInt8Array(str: string): Uint8Array;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param sources One or more source objects from which to copy properties
*/
static Assign<T>(target: Object, ...sources: Object[]): T;
/**
* Deep clones the given object. Take care of cycling objects!
* @param data the data of the object to clone
*/
static Clone<T>(data: T): T;
/**
* Calls the garbage collector manually.
* Take care of performances while using this method.
*/
static GarbageCollect(): void;
/**
* Reads the given file
* @param file the file to read
* @param arrayBuffer if should read as array buffer
*/
static ReadFile<T extends string | ArrayBuffer>(file: File, arrayBuffer: boolean): Promise<T>;
/**
* Reads a file as base 64
* @param file the file to read
*/
static ReadFileAsBase64(file: File): Promise<string>;
/**
* Reads a file as text
* @param file the file to read
*/
static ReadFileAsText(file: File): Promise<string>;
/**
* Reads a file as array buffer
* @param file the file to read
*/
static ReadFileAsArrayBuffer(file: File): Promise<ArrayBuffer>;
/**
* Imports a new script returning its exported object
* @param url the URL / NAME of the script
*/
static ImportScript<T>(url: string): Promise<T>;
/**
* According to the navigator, returns if the file API
* is fully supported
*/
static isFileApiSupported(showAlert?: boolean): boolean;
}
}
declare module 'babylonjs-editor/editor/tools/request' {
import { IStringDictionary } from 'babylonjs-editor/editor/typings/typings';
export default class Request {
/**
* Sends a GET request
* @param url: url of the request
* @param headers: the request headers
*/
static Get<T>(url: string, headers?: IStringDictionary<any>): Promise<T>;
/**
* Sends a PUT request
* @param url the url of the request
* @param content the content to put
* @param headers the request headers
*/
static Put<T>(url: string, content: any, headers?: IStringDictionary<any>): Promise<T>;
/**
* Sends a POST request
* @param url the url of the request
* @param content the content to post
* @param headers the request headers
*/
static Post<T>(url: string, content: any, headers?: IStringDictionary<any>): Promise<T>;
}
}
declare module 'babylonjs-editor/editor/tools/undo-redo' {
export interface StackElement {
scope?: string;
baseObject?: any;
property?: string;
to?: any;
from?: any;
object?: any;
fn?: (type?: 'from' | 'to') => void;
undo?: () => void;
redo?: () => void;
}
export default class UndoRedo {
static Stack: StackElement[];
static CurrentIndex: number;
static StackSize: number;
static onUndo: (element: StackElement) => void;
static onRedo: (element: StackElement) => void;
/**
* Pushes a new element in the stack
* @param element the element to push in the stack
*/
static Push(element: StackElement): void;
/**
* Pops an element from the undo/redo stack
*/
static Pop(): void;
/**
* Clears the given scope. For example when an extension has been closed
* @param scope the scope name
*/
static ClearScope(scope: string): void;
/**
* Clears the undo / redo stack
*/
static Clear(): void;
/**
* Undo an action
*/
static Undo(): StackElement;
/**
* Redo an action
*/
static Redo(): StackElement;
}
}
declare module 'babylonjs-editor/editor/tools/theme' {
export type ThemeType = 'Light' | 'Dark';
export default class ThemeSwitcher {
static LightThemeUrls: string[];
static DarkThemeUrls: string[];
/**
* Returns the theme's name
*/
static ThemeName: ThemeType;
/**
* Applies the theme dynamically
* @param url the url of the theme
*/
static Apply(urls: string[]): Promise<void>;
}
}
declare module 'babylonjs-editor/editor/tools/graphics-tools' {
import { BaseTexture } from 'babylonjs';
export default class GraphicsTools {
/**
* Configures the given texture to retrieve its pixels and create a new file (blob)
* @param tex the texture to transform to a blob
*/
static TextureToFile(tex: BaseTexture): Promise<Blob>;
/**
* Converts the given canvas data to blob
* @param canvas the canvas to take its data and convert to a blob
*/
static CanvasToBlob(canvas: HTMLCanvasElement): Promise<Blob>;
}
}
declare module 'babylonjs-editor/editor/components/console' {
import Editor from 'babylonjs-editor/editor/editor';
import CodeEditor from 'babylonjs-editor/editor/gui/code';
import Layout from 'babylonjs-editor/editor/gui/layout';
import Toolbar from 'babylonjs-editor/editor/gui/toolbar';
export enum ConsoleLevel {
/**
* Just log an info.
*/
INFO = 0,
/**
* Just log a warning.
*/
WARN = 1,
/**
* Just log an error.
*/
ERROR = 2
}
export default class EditorConsole {
protected editor: Editor;
/**
* The layout used to draw toolbar etc.
*/
layout: Layout;
/**
* The toolbar reference.
*/
toolbar: Toolbar;
/**
* The code editor reference used to draw the logs.
*/
code: CodeEditor;
/**
* Defines the maximum number of logs available in the console.
*/
static MaxLogsCount: number;
/**
* Constructor.
* @param editor the editor reference.
*/
constructor(editor: Editor);
/**
* Logs a new message in the console.
* @param message the message to log.
* @param level the level of the given logged message.
*/
log(message: string, level: ConsoleLevel): void;
/**
* Clears the console.
*/
clear(): void;
}
}
declare module 'babylonjs-editor/editor/gui/layout' {
export default class Layout {
element: W2UI.W2Layout;
name: string;
panels: W2UI.W2Panel[];
/**
* Constructor
* @param name the layout name
*/
constructor(name: string);
/**
* Returns the size of the given panel
* @param type the panel type (left, top, etc.)
*/
getPanelSize(type: string): {
width: number;
height: number;
};
/**
* Sets the panel size
* @param type the panel type (left, top, etc.)
* @param size the new panel size
*/
setPanelSize(type: string, size: number): void;
/**
* Hides the given panel
* @param type the panel type (left, top, etc.)
*/
hidePanel(type: string): void;
/**
* Shows the given panel
* @param type the panel type (left, top, etc.)
*/
showPanel(type: string): void;
/**
* Locks the given panel type
* @param type the panel type
* @param message the message to show
* @param showSpinner if to show a spinner
*/
lockPanel(type: string, message?: string, showSpinner?: boolean): void;
/**
* Unlocks the given panel
* @param type the panel type
*/
unlockPanel(type: string): void;
/**
* Returns the panel from the given type
* @param type the panel type
*/
getPanelFromType(type: string): W2UI.W2Panel;
/**
* Builds the layout
* @param parentId the parent id
*/
build(parentId: string): void;
}
}
declare module 'babylonjs-editor/editor/gui/toolbar' {
export interface W2Item extends W2UI.W2Item {
html?: string;
selected?: string[];
hidden?: boolean;
}
export default class Toolbar {
name: string;
items: W2Item[];
right: string;
helpUrl: string;
element: W2UI.W2Toolbar;
onClick: (target: string) => void;
/**
* Constructor
* @param name the graph name
*/
constructor(name: string);
/**
* Returns if the given item is checked
* @param id the id of the element (menu, item, etc.)
*/
isChecked(id: string, justClicked?: boolean): boolean;
/**
* Sets an item checked or unchecked
* @param id the id of the item
* @param checked if the item is checked or not
*/
setChecked(id: string, checked: boolean): void;
/**
* Sets an item enabled or disabled
* @param id the id of the item
* @param enabled if the item is enabled or not
*/
enable(id: string, enabled: boolean): void;
/**
* Updates the given item
* @param id the id of the item to update
* @param data the new item
*/
updateItem(id: string, data: W2Item): void;
/**
* Notifies the given message on the right
* @param message the message to notify
*/
notifyMessage(message: string): void;
/**
* Builds the graph
* @param parentId the parent id
*/
build(parentId: string): void;
}
}
declare module 'babylonjs-editor/editor/gui/list' {
export default class List {
name: string;
element: JQuery;
input: JQuery;
items: string[];
onChange: (selected: string) => void;
/**
* Constructor
* @param name the name of the list
*/
constructor(name: any);
/**
* Sets the new items
* @param items the new items
*/
setItems(items: string[]): void;
/**
* Sets the selected item
* @param text: the item's text
*/
setSelected(text: string): void;
/**
* Returns the selected value of the list
*/
getSelected(): string;
/**
* Builds the element
* The parent HTML element
*/
build(parent: HTMLElement, style?: string): void;
}
}
declare module 'babylonjs-editor/editor/gui/grid' {
export interface GridRow {
recid?: number;
w2ui?: {
style?: string;
};
}
export interface GridColumn {
field: string;
caption: string;
size: string;
editable?: {
type: string;
};
}
export interface GridOptions {
toolbar?: boolean;
footer?: boolean;
toolbarEdit?: boolean;
toolbarDelete?: boolean;
toolbarAdd?: boolean;
toolbarSearch?: boolean;
toolbarColumns?: boolean;
toolbarReload?: boolean;
header?: string;
columnsHeaders?: boolean;
multiSelect?: boolean;
}
export interface GridContextMenuItem {
id: number;
text: string;
icon?: string;
}
export default class Grid<T extends GridRow> {
name: string;
element: W2UI.W2Grid;
options: GridOptions;
columns: GridColumn[];
contextMenuItems: GridContextMenuItem[];
onClick: (selected: number[]) => void;
onAdd: () => void;
onDelete: (ids: number[]) => void;
onChange: (recid: number, value: string) => void;
onEdit: (recid: number) => void;
onContextMenu: (id: number, recid: number) => void;
/**
* Constructor
* @param name the name of the grid
*/
constructor(name: string, options?: GridOptions);
/**
* Sets the options of the grid
* @param options options of the grid
*/
setOptions(options: GridOptions): void;
/**
* Adds a new row to the grid and refreshes itself
* @param record the row record to add
*/
addRow(record: T): void;
/**
* Adds a new record to the grid but does not refreshes itself
* @param record the record to add
*/
addRecord(record: T): void;
/**
* Returns the row at the given index
* @param selected the row index
*/
getRow(selected: number): T;
/**
* Sets the selected items
* @param selected the selected items
*/
select(selected: number[]): void;
/**
* Unselects all selected items
*/
selectNone(): void;
/**
* Returns the selected rows
*/
getSelected(): number[];
/**
* Builds the grid
* @param parentId the parent id
*/
build(parentId: string): void;
}
}
declare module 'babylonjs-editor/editor/gui/picker' {
import Window from 'babylonjs-editor/editor/gui/window';
import Grid, { GridRow } from 'babylonjs-editor/editor/gui/grid';
export interface PickerItem {
name?: string | null;
id?: string | null;
}
export interface Row extends GridRow {
name: string;
}
export default class Picker {
items: string[];
selected: string[];
window: Window;
grid: Grid<Row>;
title: string;
search: boolean;
showClose: boolean;
/**
* Constructor
*/
constructor(title: string);
/**
* Adds the given items to pick
* @param items: items to add
*/
addItems(items: PickerItem[]): void;
/**
* Clears the current items
*/
clear(): void;
/**
* Adds the given items as selected
* @param items: items to add
*/
addSelected(items: PickerItem[]): void;
/**
* Closes the picker
*/
close(): void;
/**
* Builds the object picker
* @param callback: called when user clicks the button "ok"
*/
open(callback: (items: {
id: number;
name: string;
}[], selected?: number[]) => void): Promise<void>;
/**
* Adds current items to the grid
*/
refreshGrid(): void;
}
}
declare module 'babylonjs-editor/editor/gui/graph' {
export interface GraphNode {
id: string;
text: string;
group?: boolean;
img?: string;
data?: any;
count?: string;
}
export interface GraphMenu {
id: string;
text: string;
img: string;
}
export default class Graph {
name: string;
element: W2UI.W2Sidebar;
topContent: string;
bottomContent: string;
onClick: <T>(id: string, data: T) => void;
onDbleClick: <T>(id: string, data: T) => void;
onMenuClick: <T>(id: string, node: GraphNode) => void;
/**
* Constructor
* @param name the graph name
*/
constructor(name: string);
/**
* Clear the graph
*/
clear(): void;
/**
* Adds the given node to the graph
* @param node: the node to add into the graph
* @param parent: the optional parent of the node
*/
add(node: GraphNode, parent?: string): void;
/**
* Adds a context menu item to the graph when the user
* right clicks on the node
* @param menu the menu to add
*/
addMenu(menu: GraphMenu): void;
/**
* Selects the node which has the given id
* @param id the id of the node to select
*/
setSelected(id: string): void;
/**
* Returns the selected item
*/
getSelected(): GraphNode;
/**
* Builds the graph
* @param parent the parent id
*/
build(parent: HTMLDivElement | string): void;
}
}
declare module 'babylonjs-editor/editor/gui/window' {
export default class Window {
name: string;
element: W2UI.W2Popup;
title: string;
body: string;
buttons: string[];
width: number;
height: number;
showMax: boolean;
showClose: boolean;
onButtonClick: (id: string) => void;
onClose: () => void;
onMax: () => void;
onMin: () => void;
onToggle: () => void;
/**
* Constructor
* @param name: the name of the window
*/
constructor(name: string);
/**
* Closes the window
*/
close(): void;
/**
* Locks the window
* @param message: the message to draw
*/
lock(message: string): void;
/**
* Unlocks the window
*/
unlock(): void;
/**
* Opens the window
*/
open(): Promise<void>;
/**
* Opens a window alert
* @param message: the message to show
* @param title: the title of the window alert
*/
static CreateAlert(message: string, title?: string): void;
}
}
declare module 'babylonjs-editor/editor/gui/code' {
import { IDisposable, IStringDictionary } from 'babylonjs-editor/editor/typings/typings';
import * as typescript from 'typescript';
import { editor } from 'monaco-editor';
export interface Typings {
name: string;
id: string;
content: string;
}
export interface TranspilationErrorOutput {
line: number;
column: number;
message: string;
}
export interface TranspilationOutput {
compiledCode: string;
errors: TranspilationErrorOutput[];
}
export default class CodeEditor {
editor: editor.ICodeEditor;
onChange: (value: string) => void;
theme: string;
readonly: boolean;
static Typescript: typeof typescript;
static ExternalLibraries: string;
static ExtraLibs: {
lib: IDisposable;
caller: Window;
}[];
static CustomLibs: IStringDictionary<IDisposable>;
static Instances: editor.ICodeEditor[];
static Libs: string[];
/**
* Remove extra lib from the registered callers
* @param caller the caller reference (Window)
*/
static RemoveExtraLib(caller: Window): void;
/**
* Returns if at least one code editor is focused
*/
static HasOneFocused(): boolean;
/**
* Constructor.
* @param language the language of the code editor.
* @param value the default value to draw in the code editor.
* @param theme the theme to use for the code editor.
*/
constructor(language?: string, value?: string);
/**
* Returns the editor's value
*/
getValue(): string;
/**
* Sets the value of the editor
* @param value the value to set
*/
setValue(value: string): void;
/**
* Focus the editor
*/
focus(): void;
/**
* Disposes the editor
*/
dispose(): void;
/**
* Builds the code editor
* @param parentId the parent id of the editor
*/
build(parentId: string | HTMLElement, caller?: Window): Promise<void>;
/**
* Transpiles the current TS source to JS source.
*/
transpileTypeScript(): Promise<TranspilationOutput>;
/**
* Formats the transpilations errors to output an understandable output.
* @param errors the errors coming from the typescript transpilation function. @see .transpileTypeScript