-
Notifications
You must be signed in to change notification settings - Fork 8
/
file_system.d.ts
159 lines (152 loc) · 3.79 KB
/
file_system.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
/// <reference path="./blockbench.d.ts"/>
declare namespace Blockbench {
/**
* The resource identifier group, used to allow the file dialog (open and save) to remember where it was last used
*/
type ResourceID =
| string
| 'texture'
| 'minecraft_skin'
| 'dev_plugin'
| 'animation'
| 'animation_particle'
| 'animation_audio'
| 'theme'
| 'model'
| 'gltf'
| 'obj'
| 'preview_background'
| 'screenshot'
| 'palette'
interface FileResult {
name: string
path: string
content: string | ArrayBuffer
}
type ReadType = 'buffer' | 'binary' | 'text' | 'image'
interface ReadOptions {
readtype?: ReadType | ((file: string) => ReadType)
errorbox?: boolean
}
/**
* Reads the content from the specified files. Desktop app only.
*/
export function read(
files: string[],
options?: ReadOptions,
callback?: (files: FileResult[]) => void
): void
/**
* Reads the content from the specified files. Desktop app only.
*/
export function readFile(
files: string[],
options?: ReadOptions,
callback?: (files: FileResult[]) => void
): void
type WriteType = 'buffer' | 'text' | 'zip' | 'image'
interface WriteOptions {
content?: string | ArrayBuffer
savetype?: WriteType | ((file: string) => WriteType)
custom_writer?: (content: string | ArrayBuffer, file_path: string) => void
}
/**
* Writes a file to the file system. Desktop app only.
*/
export function writeFile(
file_path: string,
options: WriteOptions,
callback?: (file_path: string) => void
): void
interface PickDirOptions {
/**Location where the file dialog starts off
*/
startpath?: string
/** The resource identifier group, used to allow the file dialog (open and save) to remember where it was last used
*/
resource_id?: ResourceID
/** Window title for the file picker
*/
title?: string
}
/**
* Pick a directory. Desktop app only.
*/
export function pickDirectory(options: PickDirOptions): string | undefined
interface ImportOptions extends ReadOptions {
/** Name of the file type
*/
type: string
/** File Extensions
*/
extensions: string[]
/** Allow selection of multiple elements
*/
multiple?: boolean
/** File picker start path
*/
startpath?: string
/** The resource identifier group, used to allow the file dialog (open and save) to remember where it was last used
*/
resource_id?: ResourceID
/** Title of the file picker window
*/
title?: string
/**
*/
}
// @ts-ignore
function _import(options: ImportOptions, callback?: (files: FileResult[]) => void): any
export { _import as import }
interface ExportOptions extends WriteOptions {
/**
* Name of the file type
*/
type: string
/**
* File extensions
*/
extensions: string[]
/**
* Suggested file name
*/
name?: string
/**
* Location where the file dialog starts
*/
startpath?: string
/**
* The resource identifier group, used to allow the file dialog (open and save) to remember where it was last used
*/
resource_id?: string
}
function _export(options: ExportOptions, callback?: (file_path: string) => void): any
export { _export as export }
/**
* Adds a drag handler that handles dragging and dropping files into Blockbench
*/
interface DragHandlerOptions extends ReadOptions {
/**
* Allowed file extensions
*/
extensions: string[] | (() => string[])
/**
* Whether or not to enable the drag handler
*/
condition?: ConditionResolvable
/**
* Drop target element
*/
element?: string | HTMLElement | (() => string | HTMLElement)
/**
* If true, the drop will work on all child elements of the specified element
*/
propagate?: boolean
}
export function addDragHandler(
id: string,
options: DragHandlerOptions,
callback?: () => void
): Deletable
export function removeDragHandler(id: string): void
}