@jupyterlite/services 0.1.0 → 0.7.0-rc.1
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/lib/contents/drive.d.ts +278 -0
- package/lib/contents/drive.js +888 -0
- package/lib/contents/drive.js.map +1 -0
- package/lib/contents/drivecontents.d.ts +92 -0
- package/lib/contents/drivecontents.js +132 -0
- package/lib/contents/drivecontents.js.map +1 -0
- package/lib/contents/drivefs.d.ts +245 -0
- package/lib/contents/drivefs.js +481 -0
- package/lib/contents/drivefs.js.map +1 -0
- package/lib/contents/emscripten.d.ts +96 -0
- package/lib/contents/emscripten.js +10 -0
- package/lib/contents/emscripten.js.map +1 -0
- package/lib/contents/index.d.ts +5 -0
- package/lib/contents/index.js +8 -0
- package/lib/contents/index.js.map +1 -0
- package/lib/contents/tokens.d.ts +21 -0
- package/lib/contents/tokens.js +55 -0
- package/lib/contents/tokens.js.map +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/lib/kernel/base.d.ts +245 -0
- package/lib/kernel/base.js +457 -0
- package/lib/kernel/base.js.map +1 -0
- package/lib/kernel/client.d.ts +115 -0
- package/lib/kernel/client.js +375 -0
- package/lib/kernel/client.js.map +1 -0
- package/lib/kernel/index.d.ts +5 -0
- package/lib/kernel/index.js +8 -0
- package/lib/kernel/index.js.map +1 -0
- package/lib/kernel/kernelspecclient.d.ts +40 -0
- package/lib/kernel/kernelspecclient.js +37 -0
- package/lib/kernel/kernelspecclient.js.map +1 -0
- package/lib/kernel/kernelspecs.d.ts +59 -0
- package/lib/kernel/kernelspecs.js +62 -0
- package/lib/kernel/kernelspecs.js.map +1 -0
- package/lib/kernel/tokens.d.ts +163 -0
- package/lib/kernel/tokens.js +20 -0
- package/lib/kernel/tokens.js.map +1 -0
- package/lib/nbconvert/exporters.d.ts +80 -0
- package/lib/nbconvert/exporters.js +154 -0
- package/lib/nbconvert/exporters.js.map +1 -0
- package/lib/nbconvert/index.d.ts +3 -0
- package/lib/nbconvert/index.js +6 -0
- package/lib/nbconvert/index.js.map +1 -0
- package/lib/nbconvert/manager.d.ts +67 -0
- package/lib/nbconvert/manager.js +77 -0
- package/lib/nbconvert/manager.js.map +1 -0
- package/lib/nbconvert/tokens.d.ts +49 -0
- package/lib/nbconvert/tokens.js +8 -0
- package/lib/nbconvert/tokens.js.map +1 -0
- package/lib/session/client.d.ts +86 -0
- package/lib/session/client.js +200 -0
- package/lib/session/client.js.map +1 -0
- package/lib/session/index.d.ts +1 -0
- package/lib/session/index.js +4 -0
- package/lib/session/index.js.map +1 -0
- package/lib/settings/index.d.ts +1 -0
- package/lib/settings/index.js +4 -0
- package/lib/settings/index.js.map +1 -0
- package/lib/settings/settings.d.ts +92 -0
- package/lib/settings/settings.js +185 -0
- package/lib/settings/settings.js.map +1 -0
- package/package.json +67 -8
- package/src/contents/drive.ts +1032 -0
- package/src/contents/drivecontents.ts +254 -0
- package/src/contents/drivefs.ts +821 -0
- package/src/contents/emscripten.ts +148 -0
- package/src/contents/index.ts +8 -0
- package/src/contents/tokens.ts +61 -0
- package/src/index.ts +13 -0
- package/src/kernel/base.ts +638 -0
- package/src/kernel/client.ts +483 -0
- package/src/kernel/index.ts +8 -0
- package/src/kernel/kernelspecclient.ts +65 -0
- package/src/kernel/kernelspecs.ts +105 -0
- package/src/kernel/tokens.ts +222 -0
- package/src/nbconvert/exporters.ts +177 -0
- package/src/nbconvert/index.ts +6 -0
- package/src/nbconvert/manager.ts +106 -0
- package/src/nbconvert/tokens.ts +60 -0
- package/src/session/client.ts +252 -0
- package/src/session/index.ts +4 -0
- package/src/settings/index.ts +4 -0
- package/src/settings/settings.ts +237 -0
- package/style/index.css +6 -0
- package/style/index.js +6 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import type { Contents, Drive } from '@jupyterlab/services';
|
|
2
|
+
import { ServerConnection } from '@jupyterlab/services';
|
|
3
|
+
import type { ISignal } from '@lumino/signaling';
|
|
4
|
+
import type localforage from 'localforage';
|
|
5
|
+
type IModel = Contents.IModel;
|
|
6
|
+
/**
|
|
7
|
+
* The name of the drive.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DRIVE_NAME = "BrowserStorage";
|
|
10
|
+
/**
|
|
11
|
+
* A custom drive to store files in the browser storage.
|
|
12
|
+
*/
|
|
13
|
+
export declare class BrowserStorageDrive implements Contents.IDrive {
|
|
14
|
+
/**
|
|
15
|
+
* Construct a new localForage-powered contents provider
|
|
16
|
+
*/
|
|
17
|
+
constructor(options: BrowserStorageDrive.IOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Dispose the drive.
|
|
20
|
+
*/
|
|
21
|
+
dispose(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the drive is disposed.
|
|
24
|
+
*/
|
|
25
|
+
get isDisposed(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The name of the drive.
|
|
28
|
+
*/
|
|
29
|
+
get name(): string;
|
|
30
|
+
/**
|
|
31
|
+
* The server settings of the drive.
|
|
32
|
+
*/
|
|
33
|
+
get serverSettings(): ServerConnection.ISettings;
|
|
34
|
+
/**
|
|
35
|
+
* Signal emitted when a file operation takes place.
|
|
36
|
+
*/
|
|
37
|
+
get fileChanged(): ISignal<Contents.IDrive, Contents.IChangedArgs>;
|
|
38
|
+
/**
|
|
39
|
+
* Get the download URL
|
|
40
|
+
*/
|
|
41
|
+
getDownloadUrl(path: string): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Finish any initialization after server has started and all extensions are applied.
|
|
44
|
+
*
|
|
45
|
+
* TODO: keep private?
|
|
46
|
+
*/
|
|
47
|
+
initialize(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Initialize all storage instances
|
|
50
|
+
*/
|
|
51
|
+
protected initStorage(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* A promise that resolves once all storage is fully initialized.
|
|
54
|
+
*/
|
|
55
|
+
get ready(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* A lazy reference to the underlying storage.
|
|
58
|
+
*/
|
|
59
|
+
protected get storage(): Promise<LocalForage>;
|
|
60
|
+
/**
|
|
61
|
+
* A lazy reference to the underlying counters.
|
|
62
|
+
*/
|
|
63
|
+
protected get counters(): Promise<LocalForage>;
|
|
64
|
+
/**
|
|
65
|
+
* A lazy reference to the underlying checkpoints.
|
|
66
|
+
*/
|
|
67
|
+
protected get checkpoints(): Promise<LocalForage>;
|
|
68
|
+
/**
|
|
69
|
+
* Get default options for localForage instances
|
|
70
|
+
*/
|
|
71
|
+
protected get defaultStorageOptions(): LocalForageOptions;
|
|
72
|
+
/**
|
|
73
|
+
* Initialize the default storage for contents.
|
|
74
|
+
*/
|
|
75
|
+
protected createDefaultStorage(): LocalForage;
|
|
76
|
+
/**
|
|
77
|
+
* Initialize the default storage for counting file suffixes.
|
|
78
|
+
*/
|
|
79
|
+
protected createDefaultCounters(): LocalForage;
|
|
80
|
+
/**
|
|
81
|
+
* Create the default checkpoint storage.
|
|
82
|
+
*/
|
|
83
|
+
protected createDefaultCheckpoints(): LocalForage;
|
|
84
|
+
/**
|
|
85
|
+
* Clear all storage (files, counters, and checkpoints).
|
|
86
|
+
*
|
|
87
|
+
* @returns A promise which resolves when all storage is cleared.
|
|
88
|
+
*/
|
|
89
|
+
clearStorage(): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Create a new untitled file or directory in the specified directory path.
|
|
92
|
+
*
|
|
93
|
+
* @param options: The options used to create the file.
|
|
94
|
+
*
|
|
95
|
+
* @returns A promise which resolves with the created file content when the file is created.
|
|
96
|
+
*/
|
|
97
|
+
newUntitled(options?: Contents.ICreateOptions): Promise<IModel>;
|
|
98
|
+
/**
|
|
99
|
+
* Copy a file into a given directory.
|
|
100
|
+
*
|
|
101
|
+
* @param path - The original file path.
|
|
102
|
+
* @param toDir - The destination directory path.
|
|
103
|
+
*
|
|
104
|
+
* @returns A promise which resolves with the new contents model when the
|
|
105
|
+
* file is copied.
|
|
106
|
+
*
|
|
107
|
+
* #### Notes
|
|
108
|
+
* The server will select the name of the copied file.
|
|
109
|
+
*/
|
|
110
|
+
copy(path: string, toDir: string): Promise<IModel>;
|
|
111
|
+
/**
|
|
112
|
+
* Get a file or directory.
|
|
113
|
+
*
|
|
114
|
+
* @param path: The path to the file.
|
|
115
|
+
* @param options: The options used to fetch the file.
|
|
116
|
+
*
|
|
117
|
+
* @returns A promise which resolves with the file content.
|
|
118
|
+
*/
|
|
119
|
+
get(path: string, options?: Contents.IFetchOptions): Promise<IModel>;
|
|
120
|
+
/**
|
|
121
|
+
* Rename a file or directory.
|
|
122
|
+
*
|
|
123
|
+
* @param oldLocalPath - The original file path.
|
|
124
|
+
* @param newLocalPath - The new file path.
|
|
125
|
+
*
|
|
126
|
+
* @returns A promise which resolves with the new file content model when the file is renamed.
|
|
127
|
+
*/
|
|
128
|
+
rename(oldLocalPath: string, newLocalPath: string): Promise<IModel>;
|
|
129
|
+
/**
|
|
130
|
+
* Save a file.
|
|
131
|
+
*
|
|
132
|
+
* @param path - The desired file path.
|
|
133
|
+
* @param options - Optional overrides to the model.
|
|
134
|
+
*
|
|
135
|
+
* @returns A promise which resolves with the file content model when the file is saved.
|
|
136
|
+
*/
|
|
137
|
+
save(path: string, options?: Partial<IModel>): Promise<IModel>;
|
|
138
|
+
/**
|
|
139
|
+
* Delete a file from browser storage.
|
|
140
|
+
*
|
|
141
|
+
* Has no effect on server-backed files, which will re-appear with their
|
|
142
|
+
* original timestamp.
|
|
143
|
+
*
|
|
144
|
+
* @param path - The path to the file.
|
|
145
|
+
*/
|
|
146
|
+
delete(path: string): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Remove the localForage and checkpoints for a path.
|
|
149
|
+
*
|
|
150
|
+
* @param path - The path to the file
|
|
151
|
+
*/
|
|
152
|
+
protected forgetPath(path: string): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Create a checkpoint for a file.
|
|
155
|
+
*
|
|
156
|
+
* @param path - The path of the file.
|
|
157
|
+
*
|
|
158
|
+
* @returns A promise which resolves with the new checkpoint model when the
|
|
159
|
+
* checkpoint is created.
|
|
160
|
+
*/
|
|
161
|
+
createCheckpoint(path: string): Promise<Contents.ICheckpointModel>;
|
|
162
|
+
/**
|
|
163
|
+
* List available checkpoints for a file.
|
|
164
|
+
*
|
|
165
|
+
* @param path - The path of the file.
|
|
166
|
+
*
|
|
167
|
+
* @returns A promise which resolves with a list of checkpoint models for
|
|
168
|
+
* the file.
|
|
169
|
+
*/
|
|
170
|
+
listCheckpoints(path: string): Promise<Contents.ICheckpointModel[]>;
|
|
171
|
+
protected normalizeCheckpoint(model: IModel, id: number): Contents.ICheckpointModel;
|
|
172
|
+
/**
|
|
173
|
+
* Restore a file to a known checkpoint state.
|
|
174
|
+
*
|
|
175
|
+
* @param path - The path of the file.
|
|
176
|
+
* @param checkpointID - The id of the checkpoint to restore.
|
|
177
|
+
*
|
|
178
|
+
* @returns A promise which resolves when the checkpoint is restored.
|
|
179
|
+
*/
|
|
180
|
+
restoreCheckpoint(path: string, checkpointID: string): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Delete a checkpoint for a file.
|
|
183
|
+
*
|
|
184
|
+
* @param path - The path of the file.
|
|
185
|
+
* @param checkpointID - The id of the checkpoint to delete.
|
|
186
|
+
*
|
|
187
|
+
* @returns A promise which resolves when the checkpoint is deleted.
|
|
188
|
+
*/
|
|
189
|
+
deleteCheckpoint(path: string, checkpointID: string): Promise<void>;
|
|
190
|
+
/**
|
|
191
|
+
* Handle an upload chunk for a file.
|
|
192
|
+
* each chunk is base64 encoded, so we need to decode it and append it to the
|
|
193
|
+
* original content.
|
|
194
|
+
* @param newContent the new content to process, base64 encoded
|
|
195
|
+
* @param originalContent the original content, must be null or a binary string if chunked is true
|
|
196
|
+
* @param appendChunk whether the chunk should be appended to the originalContent
|
|
197
|
+
*
|
|
198
|
+
*
|
|
199
|
+
* @returns the decoded binary string, appended to the original content if requested
|
|
200
|
+
* /
|
|
201
|
+
*/
|
|
202
|
+
private _handleUploadChunk;
|
|
203
|
+
/**
|
|
204
|
+
* Convert a binary string to an Uint8Array
|
|
205
|
+
* @param binaryString the binary string
|
|
206
|
+
* @returns the bytes of the binary string
|
|
207
|
+
*/
|
|
208
|
+
private _binaryStringToBytes;
|
|
209
|
+
/**
|
|
210
|
+
* retrieve the contents for this path from the union of local storage and
|
|
211
|
+
* `api/contents/{path}/all.json`.
|
|
212
|
+
*
|
|
213
|
+
* @param path - The contents path to retrieve
|
|
214
|
+
*
|
|
215
|
+
* @returns A promise which resolves with a Map of contents, keyed by local file name
|
|
216
|
+
*/
|
|
217
|
+
private _getFolder;
|
|
218
|
+
/**
|
|
219
|
+
* Attempt to recover the model from `{:path}/__all__.json` file, fall back to
|
|
220
|
+
* deriving the model (including content) off the file in `/files/`. Otherwise
|
|
221
|
+
* return `null`.
|
|
222
|
+
*/
|
|
223
|
+
private _getServerContents;
|
|
224
|
+
/**
|
|
225
|
+
* A reducer for turning arbitrary binary into a string
|
|
226
|
+
*/
|
|
227
|
+
protected reduceBytesToString: (data: string, byte: number) => string;
|
|
228
|
+
/**
|
|
229
|
+
* retrieve the contents for this path from `__index__.json` in the appropriate
|
|
230
|
+
* folder.
|
|
231
|
+
*
|
|
232
|
+
* @param newLocalPath - The new file path.
|
|
233
|
+
*
|
|
234
|
+
* @returns A promise which resolves with a Map of contents, keyed by local file name
|
|
235
|
+
*/
|
|
236
|
+
private _getServerDirectory;
|
|
237
|
+
/**
|
|
238
|
+
* Increment the counter for a given file type.
|
|
239
|
+
* Used to avoid collisions when creating new untitled files.
|
|
240
|
+
*
|
|
241
|
+
* @param type The file type to increment the counter for.
|
|
242
|
+
*/
|
|
243
|
+
private _incrementCounter;
|
|
244
|
+
private _serverContents;
|
|
245
|
+
private _isDisposed;
|
|
246
|
+
private _fileChanged;
|
|
247
|
+
private _storageName;
|
|
248
|
+
private _storageDrivers;
|
|
249
|
+
private _ready;
|
|
250
|
+
private _storage;
|
|
251
|
+
private _counters;
|
|
252
|
+
private _checkpoints;
|
|
253
|
+
private _localforage;
|
|
254
|
+
private _serverSettings;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* A namespace for contents information.
|
|
258
|
+
*/
|
|
259
|
+
export declare namespace BrowserStorageDrive {
|
|
260
|
+
/**
|
|
261
|
+
* The options used to create a BrowserStorageDrive.
|
|
262
|
+
*/
|
|
263
|
+
interface IOptions extends Drive.IOptions {
|
|
264
|
+
/**
|
|
265
|
+
* The name of the storage instance on e.g. IndexedDB, localStorage
|
|
266
|
+
*/
|
|
267
|
+
storageName?: string | null;
|
|
268
|
+
/**
|
|
269
|
+
* The drivers to use for storage.
|
|
270
|
+
*/
|
|
271
|
+
storageDrivers?: string[] | null;
|
|
272
|
+
/**
|
|
273
|
+
* The localForage instance to use.
|
|
274
|
+
*/
|
|
275
|
+
localforage: typeof localforage;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
export {};
|