@jupyterlite/contents 0.1.0-alpha.18 → 0.1.0-alpha.22
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.d.ts +28 -0
- package/lib/contents.js +31 -8
- package/package.json +4 -4
package/lib/contents.d.ts
CHANGED
|
@@ -4,6 +4,22 @@ import { IContents } from './tokens';
|
|
|
4
4
|
* A class to handle requests to /api/contents
|
|
5
5
|
*/
|
|
6
6
|
export declare class Contents implements IContents {
|
|
7
|
+
/**
|
|
8
|
+
* Construct a new localForage-powered contents provider
|
|
9
|
+
*/
|
|
10
|
+
constructor(options?: Contents.IOptions);
|
|
11
|
+
/**
|
|
12
|
+
* Initialize the default storage for contents.
|
|
13
|
+
*/
|
|
14
|
+
protected createDefaultStorage(): LocalForage;
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the default storage for counting file suffixes.
|
|
17
|
+
*/
|
|
18
|
+
protected createDefaultCounters(): LocalForage;
|
|
19
|
+
/**
|
|
20
|
+
* Create the default checkpoint storage.
|
|
21
|
+
*/
|
|
22
|
+
protected createDefaultCheckpoints(): LocalForage;
|
|
7
23
|
/**
|
|
8
24
|
* Create a new untitled file or directory in the specified directory path.
|
|
9
25
|
*
|
|
@@ -126,7 +142,19 @@ export declare class Contents implements IContents {
|
|
|
126
142
|
*/
|
|
127
143
|
private _incrementCounter;
|
|
128
144
|
private _serverContents;
|
|
145
|
+
private _storageName;
|
|
129
146
|
private _storage;
|
|
130
147
|
private _counters;
|
|
131
148
|
private _checkpoints;
|
|
132
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* A namespace for contents information.
|
|
152
|
+
*/
|
|
153
|
+
export declare namespace Contents {
|
|
154
|
+
interface IOptions {
|
|
155
|
+
/**
|
|
156
|
+
* The name of the storage instance on e.g. IndexedDB, localStorage
|
|
157
|
+
*/
|
|
158
|
+
contentsStorageName: string;
|
|
159
|
+
}
|
|
160
|
+
}
|
package/lib/contents.js
CHANGED
|
@@ -4,7 +4,7 @@ import localforage from 'localforage';
|
|
|
4
4
|
/**
|
|
5
5
|
* The name of the local storage.
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
7
|
+
const DEFAULT_STORAGE_NAME = 'JupyterLite Storage';
|
|
8
8
|
/**
|
|
9
9
|
* The number of checkpoints to save.
|
|
10
10
|
*/
|
|
@@ -24,22 +24,45 @@ const EXTRA_TEXT_MIME_TYPES = new Set([
|
|
|
24
24
|
* A class to handle requests to /api/contents
|
|
25
25
|
*/
|
|
26
26
|
export class Contents {
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Construct a new localForage-powered contents provider
|
|
29
|
+
*/
|
|
30
|
+
constructor(options) {
|
|
28
31
|
this._serverContents = new Map();
|
|
29
|
-
this.
|
|
30
|
-
|
|
32
|
+
this._storageName = DEFAULT_STORAGE_NAME;
|
|
33
|
+
this._storageName = (options || {}).contentsStorageName || DEFAULT_STORAGE_NAME;
|
|
34
|
+
this._storage = this.createDefaultStorage();
|
|
35
|
+
this._counters = this.createDefaultCounters();
|
|
36
|
+
this._checkpoints = this.createDefaultCheckpoints();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Initialize the default storage for contents.
|
|
40
|
+
*/
|
|
41
|
+
createDefaultStorage() {
|
|
42
|
+
return localforage.createInstance({
|
|
43
|
+
name: this._storageName,
|
|
31
44
|
description: 'Offline Storage for Notebooks and Files',
|
|
32
45
|
storeName: 'files',
|
|
33
46
|
version: 1
|
|
34
47
|
});
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Initialize the default storage for counting file suffixes.
|
|
51
|
+
*/
|
|
52
|
+
createDefaultCounters() {
|
|
53
|
+
return localforage.createInstance({
|
|
54
|
+
name: this._storageName,
|
|
37
55
|
description: 'Store the current file suffix counters',
|
|
38
56
|
storeName: 'counters',
|
|
39
57
|
version: 1
|
|
40
58
|
});
|
|
41
|
-
|
|
42
|
-
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create the default checkpoint storage.
|
|
62
|
+
*/
|
|
63
|
+
createDefaultCheckpoints() {
|
|
64
|
+
return localforage.createInstance({
|
|
65
|
+
name: this._storageName,
|
|
43
66
|
description: 'Offline Storage for Checkpoints',
|
|
44
67
|
storeName: 'checkpoints',
|
|
45
68
|
version: 1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlite/contents",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.22",
|
|
4
4
|
"description": "JupyterLite - Contents",
|
|
5
5
|
"homepage": "https://github.com/jupyterlite/jupyterlite",
|
|
6
6
|
"bugs": {
|
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
"watch": "tsc -b --watch"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@jupyterlab/nbformat": "~3.2.
|
|
46
|
-
"@jupyterlab/services": "~6.2.
|
|
45
|
+
"@jupyterlab/nbformat": "~3.2.9",
|
|
46
|
+
"@jupyterlab/services": "~6.2.9",
|
|
47
47
|
"@lumino/coreutils": "^1.8.0",
|
|
48
48
|
"localforage": "^1.9.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@babel/core": "^7.11.6",
|
|
52
52
|
"@babel/preset-env": "^7.12.1",
|
|
53
|
-
"@jupyterlab/testutils": "~3.2.
|
|
53
|
+
"@jupyterlab/testutils": "~3.2.9",
|
|
54
54
|
"@types/jest": "^26.0.10",
|
|
55
55
|
"jest": "^26.4.2",
|
|
56
56
|
"rimraf": "~3.0.0",
|