@jupytergis/jupytergis-core 0.1.6 → 0.2.0
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/factory.d.ts +2 -2
- package/lib/factory.js +4 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -2
- package/lib/jgisplugin/modelfactory.d.ts +9 -2
- package/lib/jgisplugin/modelfactory.js +5 -3
- package/lib/jgisplugin/plugins.js +41 -14
- package/lib/plugin.d.ts +2 -1
- package/lib/plugin.js +18 -1
- package/package.json +14 -14
package/lib/factory.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console';
|
|
2
|
-
import { ICollaborativeDrive } from '@jupyter/
|
|
2
|
+
import { ICollaborativeDrive } from '@jupyter/collaborative-drive';
|
|
3
3
|
import { JupyterGISModel, IJupyterGISTracker, IJGISExternalCommandRegistry } from '@jupytergis/schema';
|
|
4
4
|
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
5
5
|
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
|
|
@@ -32,6 +32,6 @@ export declare class JupyterGISWidgetFactory extends ABCWidgetFactory<JupyterGIS
|
|
|
32
32
|
private _commands;
|
|
33
33
|
private _externalCommandRegistry;
|
|
34
34
|
private _backendCheck?;
|
|
35
|
-
private
|
|
35
|
+
private _contentsManager?;
|
|
36
36
|
}
|
|
37
37
|
export {};
|
package/lib/factory.js
CHANGED
|
@@ -13,13 +13,14 @@ import { ABCWidgetFactory } from '@jupyterlab/docregistry';
|
|
|
13
13
|
import { JupyterGISPanel, JupyterGISWidget, ToolbarWidget } from '@jupytergis/base';
|
|
14
14
|
export class JupyterGISWidgetFactory extends ABCWidgetFactory {
|
|
15
15
|
constructor(options) {
|
|
16
|
+
var _a;
|
|
16
17
|
const { backendCheck, externalCommandRegistry } = options, rest = __rest(options, ["backendCheck", "externalCommandRegistry"]);
|
|
17
18
|
super(rest);
|
|
18
19
|
this.options = options;
|
|
19
20
|
this._backendCheck = backendCheck;
|
|
20
21
|
this._commands = options.commands;
|
|
21
22
|
this._externalCommandRegistry = externalCommandRegistry;
|
|
22
|
-
this.
|
|
23
|
+
this._contentsManager = (_a = options.manager) === null || _a === void 0 ? void 0 : _a.contents;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Create a new widget given a context.
|
|
@@ -35,8 +36,8 @@ export class JupyterGISWidgetFactory extends ABCWidgetFactory {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
const { model } = context;
|
|
38
|
-
if (this.
|
|
39
|
-
model.
|
|
39
|
+
if (this._contentsManager) {
|
|
40
|
+
model.setContentsManager(this._contentsManager, context.path);
|
|
40
41
|
}
|
|
41
42
|
const content = new JupyterGISPanel({
|
|
42
43
|
model,
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './factory';
|
|
2
|
-
declare const _default: (import("@jupyterlab/application").JupyterFrontEndPlugin<void> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupytergis/schema").IJupyterGISTracker> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupytergis/schema").IJGISFormSchemaRegistry> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupytergis/schema").IJGISExternalCommandRegistry> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupytergis/schema").IJGISLayerBrowserRegistry>)[];
|
|
2
|
+
declare const _default: (import("@jupyterlab/application").JupyterFrontEndPlugin<void> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupytergis/schema").IJupyterGISTracker> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupytergis/schema").IJGISFormSchemaRegistry> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupytergis/schema").IJGISExternalCommandRegistry> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupytergis/schema").IJGISLayerBrowserRegistry> | import("@jupyterlab/application").JupyterFrontEndPlugin<import("@jupytergis/schema").IAnnotationModel>)[];
|
|
3
3
|
export default _default;
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import jgisPlugin from './jgisplugin/plugins';
|
|
2
|
-
import { externalCommandRegistryPlugin, formSchemaRegistryPlugin, layerBrowserRegistryPlugin, trackerPlugin } from './plugin';
|
|
2
|
+
import { externalCommandRegistryPlugin, formSchemaRegistryPlugin, layerBrowserRegistryPlugin, trackerPlugin, annotationPlugin } from './plugin';
|
|
3
3
|
export * from './factory';
|
|
4
4
|
export default [
|
|
5
5
|
trackerPlugin,
|
|
6
6
|
jgisPlugin,
|
|
7
7
|
formSchemaRegistryPlugin,
|
|
8
8
|
externalCommandRegistryPlugin,
|
|
9
|
-
layerBrowserRegistryPlugin
|
|
9
|
+
layerBrowserRegistryPlugin,
|
|
10
|
+
annotationPlugin
|
|
10
11
|
];
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { IJupyterGISDoc, JupyterGISModel } from '@jupytergis/schema';
|
|
1
|
+
import { IAnnotationModel, IJupyterGISDoc, JupyterGISModel } from '@jupytergis/schema';
|
|
2
2
|
import { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
3
3
|
import { Contents } from '@jupyterlab/services';
|
|
4
4
|
/**
|
|
5
5
|
* A Model factory to create new instances of JupyterGISModel.
|
|
6
6
|
*/
|
|
7
7
|
export declare class JupyterGISModelFactory implements DocumentRegistry.IModelFactory<JupyterGISModel> {
|
|
8
|
+
constructor(options: JupyterGISModelFactory.IOptions);
|
|
8
9
|
/**
|
|
9
10
|
* Whether the model is collaborative or not.
|
|
10
11
|
*/
|
|
11
|
-
readonly collaborative
|
|
12
|
+
readonly collaborative: boolean;
|
|
12
13
|
/**
|
|
13
14
|
* The name of the model.
|
|
14
15
|
*
|
|
@@ -50,5 +51,11 @@ export declare class JupyterGISModelFactory implements DocumentRegistry.IModelFa
|
|
|
50
51
|
* @returns The model
|
|
51
52
|
*/
|
|
52
53
|
createNew(options: DocumentRegistry.IModelOptions<IJupyterGISDoc>): JupyterGISModel;
|
|
54
|
+
private _annotationModel;
|
|
53
55
|
private _disposed;
|
|
54
56
|
}
|
|
57
|
+
export declare namespace JupyterGISModelFactory {
|
|
58
|
+
interface IOptions {
|
|
59
|
+
annotationModel: IAnnotationModel;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -3,12 +3,13 @@ import { JupyterGISModel } from '@jupytergis/schema';
|
|
|
3
3
|
* A Model factory to create new instances of JupyterGISModel.
|
|
4
4
|
*/
|
|
5
5
|
export class JupyterGISModelFactory {
|
|
6
|
-
constructor() {
|
|
6
|
+
constructor(options) {
|
|
7
7
|
/**
|
|
8
8
|
* Whether the model is collaborative or not.
|
|
9
9
|
*/
|
|
10
|
-
this.collaborative =
|
|
10
|
+
this.collaborative = document.querySelectorAll('[data-jupyter-lite-root]')[0] === undefined;
|
|
11
11
|
this._disposed = false;
|
|
12
|
+
this._annotationModel = options.annotationModel;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* The name of the model.
|
|
@@ -65,7 +66,8 @@ export class JupyterGISModelFactory {
|
|
|
65
66
|
createNew(options) {
|
|
66
67
|
const model = new JupyterGISModel({
|
|
67
68
|
sharedModel: options.sharedModel,
|
|
68
|
-
languagePreference: options.languagePreference
|
|
69
|
+
languagePreference: options.languagePreference,
|
|
70
|
+
annotationModel: this._annotationModel
|
|
69
71
|
});
|
|
70
72
|
return model;
|
|
71
73
|
}
|
|
@@ -1,26 +1,32 @@
|
|
|
1
|
-
import { ICollaborativeDrive } from '@jupyter/
|
|
2
|
-
import { IJGISExternalCommandRegistryToken, IJupyterGISDocTracker, JupyterGISDoc } from '@jupytergis/schema';
|
|
1
|
+
import { ICollaborativeDrive } from '@jupyter/collaborative-drive';
|
|
2
|
+
import { IAnnotationToken, IJGISExternalCommandRegistryToken, IJupyterGISDocTracker, JupyterGISDoc } from '@jupytergis/schema';
|
|
3
3
|
import { ICommandPalette, IThemeManager } from '@jupyterlab/apputils';
|
|
4
4
|
import { IEditorServices } from '@jupyterlab/codeeditor';
|
|
5
5
|
import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console';
|
|
6
|
+
import { PageConfig } from '@jupyterlab/coreutils';
|
|
6
7
|
import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
|
|
7
8
|
import { ILauncher } from '@jupyterlab/launcher';
|
|
8
9
|
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
9
10
|
import { CommandIDs, logoIcon, logoMiniIcon } from '@jupytergis/base';
|
|
10
11
|
import { JupyterGISWidgetFactory } from '../factory';
|
|
11
12
|
import { JupyterGISModelFactory } from './modelfactory';
|
|
13
|
+
import { MimeDocumentFactory } from '@jupyterlab/docregistry';
|
|
12
14
|
const FACTORY = 'JupyterGIS .jgis Viewer';
|
|
15
|
+
const CONTENT_TYPE = 'jgis';
|
|
13
16
|
const PALETTE_CATEGORY = 'JupyterGIS';
|
|
14
|
-
const
|
|
17
|
+
const MODEL_NAME = 'jupytergis-jgismodel';
|
|
18
|
+
const activate = (app, tracker, themeManager, browserFactory, externalCommandRegistry, contentFactory, editorServices, rendermime, consoleTracker, annotationModel, launcher, palette, drive) => {
|
|
19
|
+
if (PageConfig.getOption('jgis_expose_maps')) {
|
|
20
|
+
window.jupytergisMaps = {};
|
|
21
|
+
}
|
|
15
22
|
const widgetFactory = new JupyterGISWidgetFactory({
|
|
16
23
|
name: FACTORY,
|
|
17
|
-
modelName:
|
|
18
|
-
fileTypes: [
|
|
19
|
-
defaultFor: [
|
|
24
|
+
modelName: MODEL_NAME,
|
|
25
|
+
fileTypes: [CONTENT_TYPE],
|
|
26
|
+
defaultFor: [CONTENT_TYPE],
|
|
20
27
|
tracker,
|
|
21
28
|
commands: app.commands,
|
|
22
29
|
externalCommandRegistry,
|
|
23
|
-
drive,
|
|
24
30
|
manager: app.serviceManager,
|
|
25
31
|
contentFactory,
|
|
26
32
|
rendermime,
|
|
@@ -29,24 +35,33 @@ const activate = (app, tracker, themeManager, browserFactory, externalCommandReg
|
|
|
29
35
|
});
|
|
30
36
|
// Registering the widget factory
|
|
31
37
|
app.docRegistry.addWidgetFactory(widgetFactory);
|
|
38
|
+
const mimeDocumentFactory = new MimeDocumentFactory({
|
|
39
|
+
dataType: 'json',
|
|
40
|
+
rendermime,
|
|
41
|
+
modelName: MODEL_NAME,
|
|
42
|
+
name: 'JSON Editor',
|
|
43
|
+
primaryFileType: app.docRegistry.getFileType('json'),
|
|
44
|
+
fileTypes: [CONTENT_TYPE]
|
|
45
|
+
});
|
|
46
|
+
app.docRegistry.addWidgetFactory(mimeDocumentFactory);
|
|
32
47
|
// Creating and registering the model factory for our custom DocumentModel
|
|
33
|
-
const modelFactory = new JupyterGISModelFactory();
|
|
48
|
+
const modelFactory = new JupyterGISModelFactory({ annotationModel });
|
|
34
49
|
app.docRegistry.addModelFactory(modelFactory);
|
|
35
50
|
// register the filetype
|
|
36
51
|
app.docRegistry.addFileType({
|
|
37
|
-
name:
|
|
52
|
+
name: CONTENT_TYPE,
|
|
38
53
|
displayName: 'JGIS',
|
|
39
54
|
mimeTypes: ['text/json'],
|
|
40
55
|
extensions: ['.jgis', '.JGIS'],
|
|
41
56
|
fileFormat: 'text',
|
|
42
|
-
contentType:
|
|
57
|
+
contentType: CONTENT_TYPE,
|
|
43
58
|
icon: logoMiniIcon
|
|
44
59
|
});
|
|
45
60
|
const jGISSharedModelFactory = () => {
|
|
46
61
|
return new JupyterGISDoc();
|
|
47
62
|
};
|
|
48
63
|
if (drive) {
|
|
49
|
-
drive.sharedModelFactory.registerDocumentFactory(
|
|
64
|
+
drive.sharedModelFactory.registerDocumentFactory(CONTENT_TYPE, jGISSharedModelFactory);
|
|
50
65
|
}
|
|
51
66
|
widgetFactory.widgetCreated.connect((sender, widget) => {
|
|
52
67
|
widget.title.icon = logoIcon;
|
|
@@ -54,9 +69,20 @@ const activate = (app, tracker, themeManager, browserFactory, externalCommandReg
|
|
|
54
69
|
tracker.save(widget);
|
|
55
70
|
});
|
|
56
71
|
themeManager.themeChanged.connect((_, changes) => widget.context.model.themeChanged.emit(changes));
|
|
57
|
-
tracker.add(widget);
|
|
58
72
|
app.shell.activateById('jupytergis::leftControlPanel');
|
|
59
73
|
app.shell.activateById('jupytergis::rightControlPanel');
|
|
74
|
+
tracker
|
|
75
|
+
.add(widget)
|
|
76
|
+
.then(() => {
|
|
77
|
+
Object.values(CommandIDs).forEach(id => {
|
|
78
|
+
if (app.commands.hasCommand(id)) {
|
|
79
|
+
app.commands.notifyCommandChanged(id);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
})
|
|
83
|
+
.catch(e => {
|
|
84
|
+
console.error('Cannot update JupyterGIS commands', e);
|
|
85
|
+
});
|
|
60
86
|
});
|
|
61
87
|
app.commands.addCommand(CommandIDs.createNew, {
|
|
62
88
|
label: args => 'GIS File',
|
|
@@ -74,7 +100,7 @@ const activate = (app, tracker, themeManager, browserFactory, externalCommandReg
|
|
|
74
100
|
type: 'file',
|
|
75
101
|
ext: '.jGIS'
|
|
76
102
|
});
|
|
77
|
-
model = await app.serviceManager.contents.save(model.path, Object.assign(Object.assign({}, model), { format: 'text', size: undefined, content: '{\n\t"layers": {},\n\t"sources": {},\n\t"options": {"latitude": 0, "longitude": 0, "zoom": 0, "bearing": 0, "pitch": 0, "projection": "EPSG:3857"},\n\t"layerTree": []\n}' }));
|
|
103
|
+
model = await app.serviceManager.contents.save(model.path, Object.assign(Object.assign({}, model), { format: 'text', size: undefined, content: '{\n\t"layers": {},\n\t"sources": {},\n\t"options": {"latitude": 0, "longitude": 0, "zoom": 0, "bearing": 0, "pitch": 0, "projection": "EPSG:3857"},\n\t"layerTree": [],\n\t"metadata": {}\n}' }));
|
|
78
104
|
// Open the newly created file with the 'Editor'
|
|
79
105
|
return app.commands.execute('docmanager:open', {
|
|
80
106
|
path: model.path,
|
|
@@ -165,7 +191,8 @@ const jGISPlugin = {
|
|
|
165
191
|
ConsolePanel.IContentFactory,
|
|
166
192
|
IEditorServices,
|
|
167
193
|
IRenderMimeRegistry,
|
|
168
|
-
IConsoleTracker
|
|
194
|
+
IConsoleTracker,
|
|
195
|
+
IAnnotationToken
|
|
169
196
|
],
|
|
170
197
|
optional: [ILauncher, ICommandPalette, ICollaborativeDrive],
|
|
171
198
|
autoStart: true,
|
package/lib/plugin.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IJGISExternalCommandRegistry, IJGISFormSchemaRegistry, IJGISLayerBrowserRegistry, IJupyterGISTracker } from '@jupytergis/schema';
|
|
1
|
+
import { IAnnotationModel, IJGISExternalCommandRegistry, IJGISFormSchemaRegistry, IJGISLayerBrowserRegistry, IJupyterGISTracker } from '@jupytergis/schema';
|
|
2
2
|
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
3
3
|
export declare const trackerPlugin: JupyterFrontEndPlugin<IJupyterGISTracker>;
|
|
4
4
|
export declare const formSchemaRegistryPlugin: JupyterFrontEndPlugin<IJGISFormSchemaRegistry>;
|
|
5
5
|
export declare const externalCommandRegistryPlugin: JupyterFrontEndPlugin<IJGISExternalCommandRegistry>;
|
|
6
6
|
export declare const layerBrowserRegistryPlugin: JupyterFrontEndPlugin<IJGISLayerBrowserRegistry>;
|
|
7
|
+
export declare const annotationPlugin: JupyterFrontEndPlugin<IAnnotationModel>;
|
package/lib/plugin.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnnotationModel } from '@jupytergis/base';
|
|
2
|
+
import { IAnnotationToken, IJGISExternalCommandRegistryToken, IJGISFormSchemaRegistryToken, IJGISLayerBrowserRegistryToken, IJupyterGISDocTracker } from '@jupytergis/schema';
|
|
2
3
|
import { WidgetTracker } from '@jupyterlab/apputils';
|
|
3
4
|
import { IMainMenu } from '@jupyterlab/mainmenu';
|
|
4
5
|
import { ITranslator } from '@jupyterlab/translation';
|
|
@@ -51,3 +52,19 @@ export const layerBrowserRegistryPlugin = {
|
|
|
51
52
|
return registry;
|
|
52
53
|
}
|
|
53
54
|
};
|
|
55
|
+
export const annotationPlugin = {
|
|
56
|
+
id: 'jupytergis:core:annotation',
|
|
57
|
+
autoStart: true,
|
|
58
|
+
requires: [IJupyterGISDocTracker],
|
|
59
|
+
provides: IAnnotationToken,
|
|
60
|
+
activate: (app, tracker) => {
|
|
61
|
+
var _a;
|
|
62
|
+
const annotationModel = new AnnotationModel({
|
|
63
|
+
context: (_a = tracker.currentWidget) === null || _a === void 0 ? void 0 : _a.context
|
|
64
|
+
});
|
|
65
|
+
tracker.currentChanged.connect((_, changed) => {
|
|
66
|
+
annotationModel.context = (changed === null || changed === void 0 ? void 0 : changed.context) || undefined;
|
|
67
|
+
});
|
|
68
|
+
return annotationModel;
|
|
69
|
+
}
|
|
70
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupytergis/jupytergis-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "JupyterGIS core extension",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jupyter",
|
|
@@ -52,23 +52,23 @@
|
|
|
52
52
|
"watch:labextension": "jupyter labextension watch ."
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@jupyter/
|
|
56
|
-
"@jupytergis/base": "^0.
|
|
57
|
-
"@jupytergis/schema": "^0.
|
|
58
|
-
"@jupyterlab/application": "^4.
|
|
59
|
-
"@jupyterlab/apputils": "^4.
|
|
60
|
-
"@jupyterlab/docregistry": "^4.
|
|
61
|
-
"@jupyterlab/filebrowser": "^4.
|
|
62
|
-
"@jupyterlab/launcher": "^4.
|
|
63
|
-
"@jupyterlab/mainmenu": "^4.
|
|
64
|
-
"@jupyterlab/services": "^7.
|
|
65
|
-
"@jupyterlab/translation": "^4.
|
|
66
|
-
"@jupyterlab/ui-components": "^4.
|
|
55
|
+
"@jupyter/collaborative-drive": "^3.0.0",
|
|
56
|
+
"@jupytergis/base": "^0.2.0",
|
|
57
|
+
"@jupytergis/schema": "^0.2.0",
|
|
58
|
+
"@jupyterlab/application": "^4.3.0",
|
|
59
|
+
"@jupyterlab/apputils": "^4.3.0",
|
|
60
|
+
"@jupyterlab/docregistry": "^4.3.0",
|
|
61
|
+
"@jupyterlab/filebrowser": "^4.3.0",
|
|
62
|
+
"@jupyterlab/launcher": "^4.3.0",
|
|
63
|
+
"@jupyterlab/mainmenu": "^4.3.0",
|
|
64
|
+
"@jupyterlab/services": "^7.3.0",
|
|
65
|
+
"@jupyterlab/translation": "^4.3.0",
|
|
66
|
+
"@jupyterlab/ui-components": "^4.3.0",
|
|
67
67
|
"@lumino/commands": "^2.0.0",
|
|
68
68
|
"util": "^0.12.5"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@jupyterlab/builder": "^4.
|
|
71
|
+
"@jupyterlab/builder": "^4.3.0",
|
|
72
72
|
"@types/json-schema": "^7.0.11",
|
|
73
73
|
"@types/react": "^18.0.26",
|
|
74
74
|
"@types/react-addons-linked-state-mixin": "^0.14.22",
|