@jupyter/docprovider 1.0.0-alpha.3 → 1.0.0-alpha.4
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/ydrive.d.ts +11 -30
- package/lib/ydrive.js +24 -40
- package/package.json +1 -1
package/lib/ydrive.d.ts
CHANGED
|
@@ -16,17 +16,6 @@ export declare class YDrive extends Drive {
|
|
|
16
16
|
* SharedModel factory for the YDrive.
|
|
17
17
|
*/
|
|
18
18
|
readonly sharedModelFactory: SharedModelFactory;
|
|
19
|
-
/**
|
|
20
|
-
* Delete a file.
|
|
21
|
-
*
|
|
22
|
-
* @param localPath - The path to the file.
|
|
23
|
-
*
|
|
24
|
-
* @returns A promise which resolves when the file is deleted.
|
|
25
|
-
*
|
|
26
|
-
* #### Notes
|
|
27
|
-
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/contents).
|
|
28
|
-
*/
|
|
29
|
-
delete(localPath: string): Promise<void>;
|
|
30
19
|
/**
|
|
31
20
|
* Dispose of the resources held by the manager.
|
|
32
21
|
*/
|
|
@@ -43,20 +32,6 @@ export declare class YDrive extends Drive {
|
|
|
43
32
|
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/contents) and validates the response model.
|
|
44
33
|
*/
|
|
45
34
|
get(localPath: string, options?: Contents.IFetchOptions): Promise<Contents.IModel>;
|
|
46
|
-
/**
|
|
47
|
-
* Rename a file or directory.
|
|
48
|
-
*
|
|
49
|
-
* @param oldLocalPath - The original file path.
|
|
50
|
-
*
|
|
51
|
-
* @param newLocalPath - The new file path.
|
|
52
|
-
*
|
|
53
|
-
* @returns A promise which resolves with the new file contents model when
|
|
54
|
-
* the file is renamed.
|
|
55
|
-
*
|
|
56
|
-
* #### Notes
|
|
57
|
-
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/contents) and validates the response model.
|
|
58
|
-
*/
|
|
59
|
-
rename(oldLocalPath: string, newLocalPath: string): Promise<Contents.IModel>;
|
|
60
35
|
/**
|
|
61
36
|
* Save a file.
|
|
62
37
|
*
|
|
@@ -66,11 +41,6 @@ export declare class YDrive extends Drive {
|
|
|
66
41
|
*
|
|
67
42
|
* @returns A promise which resolves with the file content model when the
|
|
68
43
|
* file is saved.
|
|
69
|
-
*
|
|
70
|
-
* #### Notes
|
|
71
|
-
* Ensure that `model.content` is populated for the file.
|
|
72
|
-
*
|
|
73
|
-
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/contents) and validates the response model.
|
|
74
44
|
*/
|
|
75
45
|
save(localPath: string, options?: Partial<Contents.IModel>): Promise<Contents.IModel>;
|
|
76
46
|
private _onCreate;
|
|
@@ -84,11 +54,22 @@ export declare class YDrive extends Drive {
|
|
|
84
54
|
declare class SharedModelFactory implements Contents.ISharedFactory {
|
|
85
55
|
private _onCreate;
|
|
86
56
|
private _documentOptions;
|
|
57
|
+
/**
|
|
58
|
+
* Shared model factory constructor
|
|
59
|
+
*
|
|
60
|
+
* @param _onCreate Callback on new document model creation
|
|
61
|
+
*/
|
|
87
62
|
constructor(_onCreate: (options: Contents.ISharedFactoryOptions, sharedModel: YDocument<DocumentChange>) => void);
|
|
88
63
|
/**
|
|
89
64
|
* Whether the IDrive supports real-time collaboration or not.
|
|
90
65
|
*/
|
|
91
66
|
readonly collaborative = true;
|
|
67
|
+
/**
|
|
68
|
+
* Set shared document model options
|
|
69
|
+
*
|
|
70
|
+
* @param type Document type
|
|
71
|
+
* @param value Document options
|
|
72
|
+
*/
|
|
92
73
|
setDocumentOptions(type: Contents.ContentType, value: Record<string, any>): void;
|
|
93
74
|
/**
|
|
94
75
|
* Create a new `ISharedDocument` instance.
|
package/lib/ydrive.js
CHANGED
|
@@ -55,22 +55,6 @@ export class YDrive extends Drive {
|
|
|
55
55
|
this._providers = new Map();
|
|
56
56
|
this.sharedModelFactory = new SharedModelFactory(this._onCreate);
|
|
57
57
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Delete a file.
|
|
60
|
-
*
|
|
61
|
-
* @param localPath - The path to the file.
|
|
62
|
-
*
|
|
63
|
-
* @returns A promise which resolves when the file is deleted.
|
|
64
|
-
*
|
|
65
|
-
* #### Notes
|
|
66
|
-
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/contents).
|
|
67
|
-
*/
|
|
68
|
-
async delete(localPath) {
|
|
69
|
-
await super.delete(localPath);
|
|
70
|
-
// FIXME
|
|
71
|
-
// We are not removing the path from `sharedPaths` as multiple providers of the same file (with different model) may exist.
|
|
72
|
-
//this._sharedPaths.delete(localPath);
|
|
73
|
-
}
|
|
74
58
|
/**
|
|
75
59
|
* Dispose of the resources held by the manager.
|
|
76
60
|
*/
|
|
@@ -105,22 +89,6 @@ export class YDrive extends Drive {
|
|
|
105
89
|
}
|
|
106
90
|
return super.get(localPath, options);
|
|
107
91
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Rename a file or directory.
|
|
110
|
-
*
|
|
111
|
-
* @param oldLocalPath - The original file path.
|
|
112
|
-
*
|
|
113
|
-
* @param newLocalPath - The new file path.
|
|
114
|
-
*
|
|
115
|
-
* @returns A promise which resolves with the new file contents model when
|
|
116
|
-
* the file is renamed.
|
|
117
|
-
*
|
|
118
|
-
* #### Notes
|
|
119
|
-
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/contents) and validates the response model.
|
|
120
|
-
*/
|
|
121
|
-
async rename(oldLocalPath, newLocalPath) {
|
|
122
|
-
return await super.rename(oldLocalPath, newLocalPath);
|
|
123
|
-
}
|
|
124
92
|
/**
|
|
125
93
|
* Save a file.
|
|
126
94
|
*
|
|
@@ -130,21 +98,29 @@ export class YDrive extends Drive {
|
|
|
130
98
|
*
|
|
131
99
|
* @returns A promise which resolves with the file content model when the
|
|
132
100
|
* file is saved.
|
|
133
|
-
*
|
|
134
|
-
* #### Notes
|
|
135
|
-
* Ensure that `model.content` is populated for the file.
|
|
136
|
-
*
|
|
137
|
-
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/contents) and validates the response model.
|
|
138
101
|
*/
|
|
139
102
|
async save(localPath, options = {}) {
|
|
140
|
-
//
|
|
141
|
-
|
|
103
|
+
// Check that there is a provider - it won't e.g. if the document model is not collaborative.
|
|
104
|
+
if (options.format && options.type) {
|
|
105
|
+
const key = `${options.format}:${options.type}:${localPath}`;
|
|
106
|
+
const provider = this._providers.get(key);
|
|
107
|
+
if (provider) {
|
|
108
|
+
// Save is done from the backend
|
|
109
|
+
return this.get(localPath, { ...options, content: false });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return super.save(localPath, options);
|
|
142
113
|
}
|
|
143
114
|
}
|
|
144
115
|
/**
|
|
145
116
|
* Yjs sharedModel factory for real-time collaboration.
|
|
146
117
|
*/
|
|
147
118
|
class SharedModelFactory {
|
|
119
|
+
/**
|
|
120
|
+
* Shared model factory constructor
|
|
121
|
+
*
|
|
122
|
+
* @param _onCreate Callback on new document model creation
|
|
123
|
+
*/
|
|
148
124
|
constructor(_onCreate) {
|
|
149
125
|
this._onCreate = _onCreate;
|
|
150
126
|
/**
|
|
@@ -156,8 +132,14 @@ class SharedModelFactory {
|
|
|
156
132
|
disableDocumentWideUndoRedo: true
|
|
157
133
|
});
|
|
158
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Set shared document model options
|
|
137
|
+
*
|
|
138
|
+
* @param type Document type
|
|
139
|
+
* @param value Document options
|
|
140
|
+
*/
|
|
159
141
|
setDocumentOptions(type, value) {
|
|
160
|
-
this._documentOptions.set(type, value);
|
|
142
|
+
this._documentOptions.set(type, { ...value });
|
|
161
143
|
}
|
|
162
144
|
/**
|
|
163
145
|
* Create a new `ISharedDocument` instance.
|
|
@@ -170,6 +152,8 @@ class SharedModelFactory {
|
|
|
170
152
|
return;
|
|
171
153
|
}
|
|
172
154
|
if (!options.collaborative) {
|
|
155
|
+
// Bail if the document model does not support collaboration
|
|
156
|
+
// the `sharedModel` will be the default one.
|
|
173
157
|
return;
|
|
174
158
|
}
|
|
175
159
|
let sharedModel;
|