-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathFileAPI.res
More file actions
225 lines (184 loc) · 8.13 KB
/
Copy pathFileAPI.res
File metadata and controls
225 lines (184 loc) · 8.13 KB
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
@@warning("-30")
open Prelude
open EventAPI
type endingType =
| @as("native") Native
| @as("transparent") Transparent
type readableStreamReaderMode = | @as("byob") Byob
type fileSystemHandleKind =
| @as("directory") Directory
| @as("file") File
type writeCommandType =
| @as("seek") Seek
| @as("truncate") Truncate
| @as("write") Write
/**
A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.
[See Blob on MDN](https://developer.mozilla.org/docs/Web/API/Blob)
*/
@editor.completeFrom(Blob)
type blob = {
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/size)
*/
size: int,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/type)
*/
@as("type")
type_: string,
}
/**
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.
[See ReadableStream on MDN](https://developer.mozilla.org/docs/Web/API/ReadableStream)
*/
type readableStream<'r> = {
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked)
*/
locked: bool,
}
/**
This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing.
[See WritableStream on MDN](https://developer.mozilla.org/docs/Web/API/WritableStream)
*/
type writableStream<'w> = {
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/WritableStream/locked)
*/
locked: bool,
}
/**
This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate.
[See WritableStreamDefaultController on MDN](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
*/
@editor.completeFrom(WritableStreamDefaultController)
type writableStreamDefaultController = {
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal)
*/
signal: abortSignal,
}
/**
Provides information about files and allows JavaScript in a web page to access their content.
[See File on MDN](https://developer.mozilla.org/docs/Web/API/File)
*/
@editor.completeFrom(File)
type file = {
...blob,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/File/name)
*/
name: string,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/File/lastModified)
*/
lastModified: int,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/File/webkitRelativePath)
*/
webkitRelativePath: string,
}
/**
[See FileSystemHandle on MDN](https://developer.mozilla.org/docs/Web/API/FileSystemHandle)
*/
@editor.completeFrom(FileSystemHandle)
type fileSystemHandle = {
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/kind)
*/
kind: fileSystemHandleKind,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/name)
*/
name: string,
}
/**
[See FileSystemDirectoryHandle on MDN](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle)
*/
@editor.completeFrom(FileSystemDirectoryHandle)
type fileSystemDirectoryHandle = {
...fileSystemHandle,
}
/**
[See FileSystemFileHandle on MDN](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle)
*/
@editor.completeFrom(FileSystemFileHandle)
type fileSystemFileHandle = {
...fileSystemHandle,
}
/**
[See FileSystemWritableFileStream on MDN](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream)
*/
@editor.completeFrom(FileSystemWritableFileStream)
type fileSystemWritableFileStream = {
...writableStream<any>,
}
@unboxed
type blobPart =
| String(string)
| Blob(blob)
// | ArrayBuffer(ArrayBuffer.t)
// | TypedArray(TypedArray.t<int>)
type queuingStrategy<'t> = any
type underlyingSink<'t> = any
type readableStreamReader<'t> = any
type writableStreamDefaultWriter<'t> = any
type fileSystemWriteChunkType = any
type underlyingSourceCancelCallback = JSON.t => promise<unit>
type blobPropertyBag = {
@as("type") mutable type_?: string,
mutable endings?: endingType,
}
type underlyingByteSource = {
@as("type") mutable type_: unknown,
mutable autoAllocateChunkSize?: int,
mutable start?: unknown,
mutable pull?: unknown,
mutable cancel?: underlyingSourceCancelCallback,
}
type readableStreamGetReaderOptions = {
/**
Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.
*/
mutable mode?: readableStreamReaderMode,
}
type readableWritablePair<'r, 'w> = {
mutable readable: readableStream<'r>,
/**
Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.
Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
*/
mutable writable: writableStream<'w>,
}
type streamPipeOptions = {
/**
Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
Errors and closures of the source and destination streams propagate as follows:
An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination.
An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source.
When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error.
If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source.
The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.
*/
mutable preventClose?: bool,
mutable preventAbort?: bool,
mutable preventCancel?: bool,
mutable signal?: abortSignal,
}
type filePropertyBag = {
...blobPropertyBag,
mutable lastModified?: int,
}
type fileSystemGetFileOptions = {mutable create?: bool}
type fileSystemGetDirectoryOptions = {mutable create?: bool}
type fileSystemRemoveOptions = {mutable recursive?: bool}
type fileSystemCreateWritableOptions = {mutable keepExistingData?: bool}
type writeParams = {
@as("type") mutable type_: writeCommandType,
mutable size?: Null.t<int>,
mutable position?: Null.t<int>,
mutable data?: Null.t<unknown>,
}