@jupytergis/jupytergis-core 0.1.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/LICENSE +29 -0
- package/README.md +1 -0
- package/lib/externalcommand.d.ts +7 -0
- package/lib/externalcommand.js +11 -0
- package/lib/factory.d.ts +37 -0
- package/lib/factory.js +57 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +10 -0
- package/lib/jgisplugin/modelfactory.d.ts +54 -0
- package/lib/jgisplugin/modelfactory.js +72 -0
- package/lib/jgisplugin/plugins.d.ts +3 -0
- package/lib/jgisplugin/plugins.js +183 -0
- package/lib/layerBrowserRegistry.d.ts +32 -0
- package/lib/layerBrowserRegistry.js +40 -0
- package/lib/plugin.d.ts +6 -0
- package/lib/plugin.js +53 -0
- package/lib/schemaregistry.d.ts +8 -0
- package/lib/schemaregistry.js +20 -0
- package/package.json +122 -0
- package/style/base.css +5 -0
- package/style/index.css +1 -0
- package/style/index.js +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, JupyterGIS contributors
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# JupyterGIS Core package
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IJGISExternalCommand, IJGISExternalCommandRegistry } from '@jupytergis/schema';
|
|
2
|
+
export declare class JupyterGISExternalCommandRegistry implements IJGISExternalCommandRegistry {
|
|
3
|
+
constructor();
|
|
4
|
+
registerCommand(cmd: IJGISExternalCommand): void;
|
|
5
|
+
getCommands(): IJGISExternalCommand[];
|
|
6
|
+
private _registry;
|
|
7
|
+
}
|
package/lib/factory.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console';
|
|
2
|
+
import { ICollaborativeDrive } from '@jupyter/docprovider';
|
|
3
|
+
import { JupyterGISModel, IJupyterGISTracker, IJGISExternalCommandRegistry } from '@jupytergis/schema';
|
|
4
|
+
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
5
|
+
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
|
|
6
|
+
import { ABCWidgetFactory, DocumentRegistry } from '@jupyterlab/docregistry';
|
|
7
|
+
import { CommandRegistry } from '@lumino/commands';
|
|
8
|
+
import { JupyterGISWidget } from '@jupytergis/base';
|
|
9
|
+
import { ServiceManager } from '@jupyterlab/services';
|
|
10
|
+
interface IOptions extends DocumentRegistry.IWidgetFactoryOptions {
|
|
11
|
+
tracker: IJupyterGISTracker;
|
|
12
|
+
commands: CommandRegistry;
|
|
13
|
+
externalCommandRegistry: IJGISExternalCommandRegistry;
|
|
14
|
+
manager?: ServiceManager.IManager;
|
|
15
|
+
contentFactory?: ConsolePanel.IContentFactory;
|
|
16
|
+
mimeTypeService?: IEditorMimeTypeService;
|
|
17
|
+
rendermime?: IRenderMimeRegistry;
|
|
18
|
+
consoleTracker?: IConsoleTracker;
|
|
19
|
+
backendCheck?: () => boolean;
|
|
20
|
+
drive?: ICollaborativeDrive | null;
|
|
21
|
+
}
|
|
22
|
+
export declare class JupyterGISWidgetFactory extends ABCWidgetFactory<JupyterGISWidget, JupyterGISModel> {
|
|
23
|
+
private options;
|
|
24
|
+
constructor(options: IOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Create a new widget given a context.
|
|
27
|
+
*
|
|
28
|
+
* @param context Contains the information of the file
|
|
29
|
+
* @returns The widget
|
|
30
|
+
*/
|
|
31
|
+
protected createNewWidget(context: DocumentRegistry.IContext<JupyterGISModel>): JupyterGISWidget;
|
|
32
|
+
private _commands;
|
|
33
|
+
private _externalCommandRegistry;
|
|
34
|
+
private _backendCheck?;
|
|
35
|
+
private _drive?;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
package/lib/factory.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { ABCWidgetFactory } from '@jupyterlab/docregistry';
|
|
13
|
+
import { JupyterGISPanel, JupyterGISWidget, ToolbarWidget } from '@jupytergis/base';
|
|
14
|
+
export class JupyterGISWidgetFactory extends ABCWidgetFactory {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
const { backendCheck, externalCommandRegistry } = options, rest = __rest(options, ["backendCheck", "externalCommandRegistry"]);
|
|
17
|
+
super(rest);
|
|
18
|
+
this.options = options;
|
|
19
|
+
this._backendCheck = backendCheck;
|
|
20
|
+
this._commands = options.commands;
|
|
21
|
+
this._externalCommandRegistry = externalCommandRegistry;
|
|
22
|
+
this._drive = options.drive;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a new widget given a context.
|
|
26
|
+
*
|
|
27
|
+
* @param context Contains the information of the file
|
|
28
|
+
* @returns The widget
|
|
29
|
+
*/
|
|
30
|
+
createNewWidget(context) {
|
|
31
|
+
if (this._backendCheck) {
|
|
32
|
+
const checked = this._backendCheck();
|
|
33
|
+
if (!checked) {
|
|
34
|
+
throw new Error('Requested backend is not installed');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const { model } = context;
|
|
38
|
+
if (this._drive) {
|
|
39
|
+
model.setDrive(this._drive, context.path);
|
|
40
|
+
}
|
|
41
|
+
const content = new JupyterGISPanel({
|
|
42
|
+
model,
|
|
43
|
+
manager: this.options.manager,
|
|
44
|
+
contentFactory: this.options.contentFactory,
|
|
45
|
+
mimeTypeService: this.options.mimeTypeService,
|
|
46
|
+
rendermime: this.options.rendermime,
|
|
47
|
+
consoleTracker: this.options.consoleTracker,
|
|
48
|
+
commandRegistry: this.options.commands
|
|
49
|
+
});
|
|
50
|
+
const toolbar = new ToolbarWidget({
|
|
51
|
+
commands: this._commands,
|
|
52
|
+
model,
|
|
53
|
+
externalCommands: this._externalCommandRegistry.getCommands()
|
|
54
|
+
});
|
|
55
|
+
return new JupyterGISWidget({ context, content, toolbar });
|
|
56
|
+
}
|
|
57
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
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>)[];
|
|
3
|
+
export default _default;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import jgisPlugin from './jgisplugin/plugins';
|
|
2
|
+
import { externalCommandRegistryPlugin, formSchemaRegistryPlugin, layerBrowserRegistryPlugin, trackerPlugin } from './plugin';
|
|
3
|
+
export * from './factory';
|
|
4
|
+
export default [
|
|
5
|
+
trackerPlugin,
|
|
6
|
+
jgisPlugin,
|
|
7
|
+
formSchemaRegistryPlugin,
|
|
8
|
+
externalCommandRegistryPlugin,
|
|
9
|
+
layerBrowserRegistryPlugin
|
|
10
|
+
];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { IJupyterGISDoc, JupyterGISModel } from '@jupytergis/schema';
|
|
2
|
+
import { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
3
|
+
import { Contents } from '@jupyterlab/services';
|
|
4
|
+
/**
|
|
5
|
+
* A Model factory to create new instances of JupyterGISModel.
|
|
6
|
+
*/
|
|
7
|
+
export declare class JupyterGISModelFactory implements DocumentRegistry.IModelFactory<JupyterGISModel> {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the model is collaborative or not.
|
|
10
|
+
*/
|
|
11
|
+
readonly collaborative = true;
|
|
12
|
+
/**
|
|
13
|
+
* The name of the model.
|
|
14
|
+
*
|
|
15
|
+
* @returns The name
|
|
16
|
+
*/
|
|
17
|
+
get name(): string;
|
|
18
|
+
/**
|
|
19
|
+
* The content type of the file.
|
|
20
|
+
*
|
|
21
|
+
* @returns The content type
|
|
22
|
+
*/
|
|
23
|
+
get contentType(): Contents.ContentType;
|
|
24
|
+
/**
|
|
25
|
+
* The format of the file.
|
|
26
|
+
*
|
|
27
|
+
* @returns the file format
|
|
28
|
+
*/
|
|
29
|
+
get fileFormat(): Contents.FileFormat;
|
|
30
|
+
/**
|
|
31
|
+
* Get whether the model factory has been disposed.
|
|
32
|
+
*
|
|
33
|
+
* @returns disposed status
|
|
34
|
+
*/
|
|
35
|
+
get isDisposed(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Dispose the model factory.
|
|
38
|
+
*/
|
|
39
|
+
dispose(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Get the preferred language given the path on the file.
|
|
42
|
+
*
|
|
43
|
+
* @param path path of the file represented by this document model
|
|
44
|
+
* @returns The preferred language
|
|
45
|
+
*/
|
|
46
|
+
preferredLanguage(path: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Create a new instance of JupyterGISModel.
|
|
49
|
+
*
|
|
50
|
+
* @returns The model
|
|
51
|
+
*/
|
|
52
|
+
createNew(options: DocumentRegistry.IModelOptions<IJupyterGISDoc>): JupyterGISModel;
|
|
53
|
+
private _disposed;
|
|
54
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { JupyterGISModel } from '@jupytergis/schema';
|
|
2
|
+
/**
|
|
3
|
+
* A Model factory to create new instances of JupyterGISModel.
|
|
4
|
+
*/
|
|
5
|
+
export class JupyterGISModelFactory {
|
|
6
|
+
constructor() {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the model is collaborative or not.
|
|
9
|
+
*/
|
|
10
|
+
this.collaborative = true;
|
|
11
|
+
this._disposed = false;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The name of the model.
|
|
15
|
+
*
|
|
16
|
+
* @returns The name
|
|
17
|
+
*/
|
|
18
|
+
get name() {
|
|
19
|
+
return 'jupytergis-jgismodel';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The content type of the file.
|
|
23
|
+
*
|
|
24
|
+
* @returns The content type
|
|
25
|
+
*/
|
|
26
|
+
get contentType() {
|
|
27
|
+
return 'jgis';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The format of the file.
|
|
31
|
+
*
|
|
32
|
+
* @returns the file format
|
|
33
|
+
*/
|
|
34
|
+
get fileFormat() {
|
|
35
|
+
return 'text';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get whether the model factory has been disposed.
|
|
39
|
+
*
|
|
40
|
+
* @returns disposed status
|
|
41
|
+
*/
|
|
42
|
+
get isDisposed() {
|
|
43
|
+
return this._disposed;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Dispose the model factory.
|
|
47
|
+
*/
|
|
48
|
+
dispose() {
|
|
49
|
+
this._disposed = true;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the preferred language given the path on the file.
|
|
53
|
+
*
|
|
54
|
+
* @param path path of the file represented by this document model
|
|
55
|
+
* @returns The preferred language
|
|
56
|
+
*/
|
|
57
|
+
preferredLanguage(path) {
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a new instance of JupyterGISModel.
|
|
62
|
+
*
|
|
63
|
+
* @returns The model
|
|
64
|
+
*/
|
|
65
|
+
createNew(options) {
|
|
66
|
+
const model = new JupyterGISModel({
|
|
67
|
+
sharedModel: options.sharedModel,
|
|
68
|
+
languagePreference: options.languagePreference
|
|
69
|
+
});
|
|
70
|
+
return model;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { ICollaborativeDrive } from '@jupyter/docprovider';
|
|
2
|
+
import { IJGISExternalCommandRegistryToken, IJupyterGISDocTracker, JupyterGISDoc } from '@jupytergis/schema';
|
|
3
|
+
import { ICommandPalette, IThemeManager } from '@jupyterlab/apputils';
|
|
4
|
+
import { IEditorServices } from '@jupyterlab/codeeditor';
|
|
5
|
+
import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console';
|
|
6
|
+
import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
|
|
7
|
+
import { ILauncher } from '@jupyterlab/launcher';
|
|
8
|
+
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
9
|
+
import { fileIcon } from '@jupyterlab/ui-components';
|
|
10
|
+
import { CommandIDs } from '@jupytergis/base';
|
|
11
|
+
import { JupyterGISWidgetFactory } from '../factory';
|
|
12
|
+
import { JupyterGISModelFactory } from './modelfactory';
|
|
13
|
+
const FACTORY = 'JupyterGIS .jgis Viewer';
|
|
14
|
+
const PALETTE_CATEGORY = 'JupyterGIS';
|
|
15
|
+
const activate = (app, tracker, themeManager, browserFactory, externalCommandRegistry, contentFactory, editorServices, rendermime, consoleTracker, launcher, palette, drive) => {
|
|
16
|
+
const widgetFactory = new JupyterGISWidgetFactory({
|
|
17
|
+
name: FACTORY,
|
|
18
|
+
modelName: 'jupytergis-jgismodel',
|
|
19
|
+
fileTypes: ['jgis'],
|
|
20
|
+
defaultFor: ['jgis'],
|
|
21
|
+
tracker,
|
|
22
|
+
commands: app.commands,
|
|
23
|
+
externalCommandRegistry,
|
|
24
|
+
drive,
|
|
25
|
+
manager: app.serviceManager,
|
|
26
|
+
contentFactory,
|
|
27
|
+
rendermime,
|
|
28
|
+
mimeTypeService: editorServices.mimeTypeService,
|
|
29
|
+
consoleTracker
|
|
30
|
+
});
|
|
31
|
+
// Registering the widget factory
|
|
32
|
+
app.docRegistry.addWidgetFactory(widgetFactory);
|
|
33
|
+
// Creating and registering the model factory for our custom DocumentModel
|
|
34
|
+
const modelFactory = new JupyterGISModelFactory();
|
|
35
|
+
app.docRegistry.addModelFactory(modelFactory);
|
|
36
|
+
// register the filetype
|
|
37
|
+
app.docRegistry.addFileType({
|
|
38
|
+
name: 'jgis',
|
|
39
|
+
displayName: 'JGIS',
|
|
40
|
+
mimeTypes: ['text/json'],
|
|
41
|
+
extensions: ['.jgis', '.JGIS'],
|
|
42
|
+
fileFormat: 'text',
|
|
43
|
+
contentType: 'jgis'
|
|
44
|
+
});
|
|
45
|
+
const jGISSharedModelFactory = () => {
|
|
46
|
+
return new JupyterGISDoc();
|
|
47
|
+
};
|
|
48
|
+
if (drive) {
|
|
49
|
+
drive.sharedModelFactory.registerDocumentFactory('jgis', jGISSharedModelFactory);
|
|
50
|
+
}
|
|
51
|
+
widgetFactory.widgetCreated.connect((sender, widget) => {
|
|
52
|
+
widget.context.pathChanged.connect(() => {
|
|
53
|
+
tracker.save(widget);
|
|
54
|
+
});
|
|
55
|
+
themeManager.themeChanged.connect((_, changes) => widget.context.model.themeChanged.emit(changes));
|
|
56
|
+
tracker.add(widget);
|
|
57
|
+
app.shell.activateById('jupytergis::leftControlPanel');
|
|
58
|
+
app.shell.activateById('jupytergis::rightControlPanel');
|
|
59
|
+
});
|
|
60
|
+
app.commands.addCommand(CommandIDs.createNew, {
|
|
61
|
+
label: args => 'New JGIS File',
|
|
62
|
+
caption: 'Create a new JGIS Editor',
|
|
63
|
+
icon: args => (args['isPalette'] ? undefined : fileIcon),
|
|
64
|
+
execute: async (args) => {
|
|
65
|
+
var _a;
|
|
66
|
+
// Get the directory in which the JGIS file must be created;
|
|
67
|
+
// otherwise take the current filebrowser directory
|
|
68
|
+
const cwd = (args['cwd'] ||
|
|
69
|
+
((_a = browserFactory.tracker.currentWidget) === null || _a === void 0 ? void 0 : _a.model.path));
|
|
70
|
+
// Create a new untitled GIS file
|
|
71
|
+
let model = await app.serviceManager.contents.newUntitled({
|
|
72
|
+
path: cwd,
|
|
73
|
+
type: 'file',
|
|
74
|
+
ext: '.jGIS'
|
|
75
|
+
});
|
|
76
|
+
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"terrain": {"source": "", "exaggeration": 0}\n}' }));
|
|
77
|
+
// Open the newly created file with the 'Editor'
|
|
78
|
+
return app.commands.execute('docmanager:open', {
|
|
79
|
+
path: model.path,
|
|
80
|
+
factory: FACTORY
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
// Add the command to the launcher
|
|
85
|
+
if (launcher) {
|
|
86
|
+
launcher.add({
|
|
87
|
+
command: CommandIDs.createNew,
|
|
88
|
+
category: 'Other',
|
|
89
|
+
rank: 1
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
// Add the command to the palette
|
|
93
|
+
if (palette) {
|
|
94
|
+
palette.addItem({
|
|
95
|
+
command: CommandIDs.createNew,
|
|
96
|
+
args: { isPalette: true },
|
|
97
|
+
category: PALETTE_CATEGORY
|
|
98
|
+
});
|
|
99
|
+
palette.addItem({
|
|
100
|
+
command: CommandIDs.openLayerBrowser,
|
|
101
|
+
category: 'JupyterGIS'
|
|
102
|
+
});
|
|
103
|
+
// Layers and Sources
|
|
104
|
+
palette.addItem({
|
|
105
|
+
command: CommandIDs.newRasterEntry,
|
|
106
|
+
category: 'JupyterGIS'
|
|
107
|
+
});
|
|
108
|
+
palette.addItem({
|
|
109
|
+
command: CommandIDs.newVectorTileEntry,
|
|
110
|
+
category: 'JupyterGIS'
|
|
111
|
+
});
|
|
112
|
+
palette.addItem({
|
|
113
|
+
command: CommandIDs.newGeoJSONEntry,
|
|
114
|
+
category: 'JupyterGIS'
|
|
115
|
+
});
|
|
116
|
+
palette.addItem({
|
|
117
|
+
command: CommandIDs.newHillshadeEntry,
|
|
118
|
+
category: 'JupyterGIS'
|
|
119
|
+
});
|
|
120
|
+
// Source only
|
|
121
|
+
palette.addItem({
|
|
122
|
+
command: CommandIDs.newRasterSource,
|
|
123
|
+
category: 'JupyterGIS'
|
|
124
|
+
});
|
|
125
|
+
palette.addItem({
|
|
126
|
+
command: CommandIDs.newRasterDemSource,
|
|
127
|
+
category: 'JupyterGIS'
|
|
128
|
+
});
|
|
129
|
+
palette.addItem({
|
|
130
|
+
command: CommandIDs.newVectorSource,
|
|
131
|
+
category: 'JupyterGIS'
|
|
132
|
+
});
|
|
133
|
+
palette.addItem({
|
|
134
|
+
command: CommandIDs.newGeoJSONSource,
|
|
135
|
+
category: 'JupyterGIS'
|
|
136
|
+
});
|
|
137
|
+
// Layers only
|
|
138
|
+
palette.addItem({
|
|
139
|
+
command: CommandIDs.newRasterLayer,
|
|
140
|
+
category: 'JupyterGIS'
|
|
141
|
+
});
|
|
142
|
+
palette.addItem({
|
|
143
|
+
command: CommandIDs.newVectorLayer,
|
|
144
|
+
category: 'JupyterGIS'
|
|
145
|
+
});
|
|
146
|
+
palette.addItem({
|
|
147
|
+
command: CommandIDs.newHillshadeLayer,
|
|
148
|
+
category: 'JupyterGIS'
|
|
149
|
+
});
|
|
150
|
+
// Layer and group actions
|
|
151
|
+
palette.addItem({
|
|
152
|
+
command: CommandIDs.moveLayerToNewGroup,
|
|
153
|
+
category: 'JupyterGIS'
|
|
154
|
+
});
|
|
155
|
+
// Source actions
|
|
156
|
+
// Terrain
|
|
157
|
+
palette.addItem({
|
|
158
|
+
command: CommandIDs.newTerrain,
|
|
159
|
+
category: 'JupyterGIS'
|
|
160
|
+
});
|
|
161
|
+
palette.addItem({
|
|
162
|
+
command: CommandIDs.removeTerrain,
|
|
163
|
+
category: 'JupyterGIS'
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const jGISPlugin = {
|
|
168
|
+
id: 'jupyterGIS:jGISplugin',
|
|
169
|
+
requires: [
|
|
170
|
+
IJupyterGISDocTracker,
|
|
171
|
+
IThemeManager,
|
|
172
|
+
IFileBrowserFactory,
|
|
173
|
+
IJGISExternalCommandRegistryToken,
|
|
174
|
+
ConsolePanel.IContentFactory,
|
|
175
|
+
IEditorServices,
|
|
176
|
+
IRenderMimeRegistry,
|
|
177
|
+
IConsoleTracker
|
|
178
|
+
],
|
|
179
|
+
optional: [ILauncher, ICommandPalette, ICollaborativeDrive],
|
|
180
|
+
autoStart: true,
|
|
181
|
+
activate
|
|
182
|
+
};
|
|
183
|
+
export default jGISPlugin;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IJGISLayerBrowserRegistry, IRasterLayerGalleryEntry } from '@jupytergis/schema';
|
|
2
|
+
/**
|
|
3
|
+
* Manages a registry of raster layer gallery entries for a Jupyter GIS Layer Browser.
|
|
4
|
+
* Implements the {@link IJGISLayerBrowserRegistry} interface, allowing for the addition, removal, and retrieval of raster layer entries.
|
|
5
|
+
*
|
|
6
|
+
* @class JupyterGISLayerBrowserRegistry
|
|
7
|
+
* @implements IJGISLayerBrowserRegistry
|
|
8
|
+
*/
|
|
9
|
+
export declare class JupyterGISLayerBrowserRegistry implements IJGISLayerBrowserRegistry {
|
|
10
|
+
private _registry;
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the current state of the registry layers.
|
|
14
|
+
* Returns a copy of the internal registry array to prevent external modifications.
|
|
15
|
+
* @returns The current state of the registry layers.
|
|
16
|
+
*/
|
|
17
|
+
getRegistryLayers(): IRasterLayerGalleryEntry[];
|
|
18
|
+
/**
|
|
19
|
+
* Adds a new raster layer gallery entry to the registry.
|
|
20
|
+
* @param data - The raster layer gallery entry to add.
|
|
21
|
+
*/
|
|
22
|
+
addRegistryLayer(data: IRasterLayerGalleryEntry): void;
|
|
23
|
+
/**
|
|
24
|
+
* Removes a raster layer gallery entry from the registry by its name.
|
|
25
|
+
* @param name - The name of the raster layer gallery entry to remove.
|
|
26
|
+
*/
|
|
27
|
+
removeRegistryLayer(name: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Clears the entire registry of raster layer gallery entries.
|
|
30
|
+
*/
|
|
31
|
+
clearRegistry(): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages a registry of raster layer gallery entries for a Jupyter GIS Layer Browser.
|
|
3
|
+
* Implements the {@link IJGISLayerBrowserRegistry} interface, allowing for the addition, removal, and retrieval of raster layer entries.
|
|
4
|
+
*
|
|
5
|
+
* @class JupyterGISLayerBrowserRegistry
|
|
6
|
+
* @implements IJGISLayerBrowserRegistry
|
|
7
|
+
*/
|
|
8
|
+
export class JupyterGISLayerBrowserRegistry {
|
|
9
|
+
constructor() {
|
|
10
|
+
this._registry = [];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the current state of the registry layers.
|
|
14
|
+
* Returns a copy of the internal registry array to prevent external modifications.
|
|
15
|
+
* @returns The current state of the registry layers.
|
|
16
|
+
*/
|
|
17
|
+
getRegistryLayers() {
|
|
18
|
+
return [...this._registry];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Adds a new raster layer gallery entry to the registry.
|
|
22
|
+
* @param data - The raster layer gallery entry to add.
|
|
23
|
+
*/
|
|
24
|
+
addRegistryLayer(data) {
|
|
25
|
+
this._registry.push(data);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Removes a raster layer gallery entry from the registry by its name.
|
|
29
|
+
* @param name - The name of the raster layer gallery entry to remove.
|
|
30
|
+
*/
|
|
31
|
+
removeRegistryLayer(name) {
|
|
32
|
+
this._registry = this._registry.filter(item => item.name !== name);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Clears the entire registry of raster layer gallery entries.
|
|
36
|
+
*/
|
|
37
|
+
clearRegistry() {
|
|
38
|
+
this._registry = [];
|
|
39
|
+
}
|
|
40
|
+
}
|
package/lib/plugin.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IJGISExternalCommandRegistry, IJGISFormSchemaRegistry, IJGISLayerBrowserRegistry, IJupyterGISTracker } from '@jupytergis/schema';
|
|
2
|
+
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
3
|
+
export declare const trackerPlugin: JupyterFrontEndPlugin<IJupyterGISTracker>;
|
|
4
|
+
export declare const formSchemaRegistryPlugin: JupyterFrontEndPlugin<IJGISFormSchemaRegistry>;
|
|
5
|
+
export declare const externalCommandRegistryPlugin: JupyterFrontEndPlugin<IJGISExternalCommandRegistry>;
|
|
6
|
+
export declare const layerBrowserRegistryPlugin: JupyterFrontEndPlugin<IJGISLayerBrowserRegistry>;
|
package/lib/plugin.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IJGISExternalCommandRegistryToken, IJGISFormSchemaRegistryToken, IJGISLayerBrowserRegistryToken, IJupyterGISDocTracker } from '@jupytergis/schema';
|
|
2
|
+
import { WidgetTracker } from '@jupyterlab/apputils';
|
|
3
|
+
import { IMainMenu } from '@jupyterlab/mainmenu';
|
|
4
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
5
|
+
import { JupyterGISExternalCommandRegistry } from './externalcommand';
|
|
6
|
+
import { JupyterGISLayerBrowserRegistry } from './layerBrowserRegistry';
|
|
7
|
+
import { JupyterGISFormSchemaRegistry } from './schemaregistry';
|
|
8
|
+
const NAME_SPACE = 'jupytergis';
|
|
9
|
+
export const trackerPlugin = {
|
|
10
|
+
id: 'jupytergis:core:tracker',
|
|
11
|
+
autoStart: true,
|
|
12
|
+
requires: [ITranslator],
|
|
13
|
+
optional: [IMainMenu],
|
|
14
|
+
provides: IJupyterGISDocTracker,
|
|
15
|
+
activate: (app, translator, mainMenu) => {
|
|
16
|
+
const tracker = new WidgetTracker({
|
|
17
|
+
namespace: NAME_SPACE
|
|
18
|
+
});
|
|
19
|
+
console.log('jupytergis:core:tracker is activated!');
|
|
20
|
+
return tracker;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export const formSchemaRegistryPlugin = {
|
|
24
|
+
id: 'jupytergis:core:form-schema-registry',
|
|
25
|
+
autoStart: true,
|
|
26
|
+
requires: [],
|
|
27
|
+
provides: IJGISFormSchemaRegistryToken,
|
|
28
|
+
activate: (app) => {
|
|
29
|
+
const registry = new JupyterGISFormSchemaRegistry();
|
|
30
|
+
return registry;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export const externalCommandRegistryPlugin = {
|
|
34
|
+
id: 'jupytergis:core:external-command-registry',
|
|
35
|
+
autoStart: true,
|
|
36
|
+
requires: [],
|
|
37
|
+
provides: IJGISExternalCommandRegistryToken,
|
|
38
|
+
activate: (app) => {
|
|
39
|
+
const registry = new JupyterGISExternalCommandRegistry();
|
|
40
|
+
return registry;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export const layerBrowserRegistryPlugin = {
|
|
44
|
+
id: 'jupytergis:core:layer-browser-registry',
|
|
45
|
+
autoStart: true,
|
|
46
|
+
requires: [],
|
|
47
|
+
provides: IJGISLayerBrowserRegistryToken,
|
|
48
|
+
activate: (app) => {
|
|
49
|
+
console.log('jupytergis:core:layer-browser-registry is activated');
|
|
50
|
+
const registry = new JupyterGISLayerBrowserRegistry();
|
|
51
|
+
return registry;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IDict, IJGISFormSchemaRegistry } from '@jupytergis/schema';
|
|
2
|
+
export declare class JupyterGISFormSchemaRegistry implements IJGISFormSchemaRegistry {
|
|
3
|
+
constructor();
|
|
4
|
+
registerSchema(name: string, schema: IDict): void;
|
|
5
|
+
has(name: string): boolean;
|
|
6
|
+
getSchemas(): Map<string, IDict>;
|
|
7
|
+
private _registry;
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import formSchema from '@jupytergis/schema/lib/_interface/forms.json';
|
|
2
|
+
export class JupyterGISFormSchemaRegistry {
|
|
3
|
+
constructor() {
|
|
4
|
+
this._registry = new Map(Object.entries(formSchema));
|
|
5
|
+
}
|
|
6
|
+
registerSchema(name, schema) {
|
|
7
|
+
if (!this._registry.has(name)) {
|
|
8
|
+
this._registry.set(name, schema);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
console.error('Worker is already registered!');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
has(name) {
|
|
15
|
+
return this._registry.has(name);
|
|
16
|
+
}
|
|
17
|
+
getSchemas() {
|
|
18
|
+
return this._registry;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jupytergis/jupytergis-core",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "JupyterGIS core extension",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"jupyter",
|
|
7
|
+
"jupyterlab",
|
|
8
|
+
"jupyterlab-extension"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/geojupyter/jupytergis",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/geojupyter/jupytergis/issues"
|
|
13
|
+
},
|
|
14
|
+
"license": "BSD-3-Clause",
|
|
15
|
+
"author": "JupyterGIS contributors",
|
|
16
|
+
"files": [
|
|
17
|
+
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
|
|
18
|
+
"style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
|
|
19
|
+
],
|
|
20
|
+
"main": "lib/index.js",
|
|
21
|
+
"types": "lib/index.d.ts",
|
|
22
|
+
"style": "style/index.css",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/geojupyter/jupytergis.git"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "jlpm build:lib && jlpm build:labextension:dev",
|
|
29
|
+
"build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension",
|
|
30
|
+
"build:labextension": "jupyter labextension build .",
|
|
31
|
+
"build:labextension:dev": "jupyter labextension build --development True .",
|
|
32
|
+
"build:lib": "tsc --sourceMap",
|
|
33
|
+
"build:lib:prod": "tsc",
|
|
34
|
+
"build:dev": "jlpm run build",
|
|
35
|
+
"clean": "jlpm clean:lib",
|
|
36
|
+
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
|
|
37
|
+
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
|
|
38
|
+
"clean:labextension": "rimraf jupytergis_core/labextension jupytergis_core/_version.py",
|
|
39
|
+
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
|
|
40
|
+
"eslint": "jlpm eslint:check --fix",
|
|
41
|
+
"eslint:check": "eslint . --cache --ext .ts,.tsx",
|
|
42
|
+
"install:extension": "jlpm build",
|
|
43
|
+
"lint": "jlpm stylelint && jlpm prettier && jlpm eslint",
|
|
44
|
+
"lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check",
|
|
45
|
+
"prettier": "jlpm prettier:base --write",
|
|
46
|
+
"prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
|
|
47
|
+
"prettier:check": "jlpm prettier:base --check",
|
|
48
|
+
"stylelint": "jlpm stylelint:check --fix",
|
|
49
|
+
"stylelint:check": "stylelint --cache \"style/**/*.css\"",
|
|
50
|
+
"watch": "run-p watch:src watch:labextension",
|
|
51
|
+
"watch:src": "tsc -w --sourceMap",
|
|
52
|
+
"watch:labextension": "jupyter labextension watch ."
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@jupyter/docprovider": "^2.0.0",
|
|
56
|
+
"@jupytergis/base": "^0.1.1",
|
|
57
|
+
"@jupytergis/schema": "^0.1.1",
|
|
58
|
+
"@jupyterlab/application": "^4.0.0",
|
|
59
|
+
"@jupyterlab/apputils": "^4.0.0",
|
|
60
|
+
"@jupyterlab/docregistry": "^4.0.0",
|
|
61
|
+
"@jupyterlab/filebrowser": "^4.0.0",
|
|
62
|
+
"@jupyterlab/launcher": "^4.0.0",
|
|
63
|
+
"@jupyterlab/mainmenu": "^4.0.0",
|
|
64
|
+
"@jupyterlab/services": "^7.0.0",
|
|
65
|
+
"@jupyterlab/translation": "^4.0.0",
|
|
66
|
+
"@jupyterlab/ui-components": "^4.0.0",
|
|
67
|
+
"@lumino/commands": "^2.0.0",
|
|
68
|
+
"util": "^0.12.5"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@jupyterlab/builder": "^4.0.0",
|
|
72
|
+
"@types/json-schema": "^7.0.11",
|
|
73
|
+
"@types/react": "^18.0.26",
|
|
74
|
+
"@types/react-addons-linked-state-mixin": "^0.14.22",
|
|
75
|
+
"copy-webpack-plugin": "^10.0.0",
|
|
76
|
+
"css-loader": "^6.7.1",
|
|
77
|
+
"mkdirp": "^1.0.3",
|
|
78
|
+
"npm-run-all": "^4.1.5",
|
|
79
|
+
"rimraf": "^3.0.2",
|
|
80
|
+
"style-loader": "^3.3.1",
|
|
81
|
+
"typescript": "^5",
|
|
82
|
+
"webpack": "^5.76.3",
|
|
83
|
+
"yjs": "^13.5.0"
|
|
84
|
+
},
|
|
85
|
+
"sideEffects": [
|
|
86
|
+
"style/*.css",
|
|
87
|
+
"style/index.js"
|
|
88
|
+
],
|
|
89
|
+
"styleModule": "style/index.js",
|
|
90
|
+
"publishConfig": {
|
|
91
|
+
"access": "public"
|
|
92
|
+
},
|
|
93
|
+
"jupyterlab": {
|
|
94
|
+
"discovery": {
|
|
95
|
+
"server": {
|
|
96
|
+
"managers": [
|
|
97
|
+
"pip"
|
|
98
|
+
],
|
|
99
|
+
"base": {
|
|
100
|
+
"name": "jupytergis_core"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"extension": true,
|
|
105
|
+
"outputDir": "jupytergis_core/labextension",
|
|
106
|
+
"webpackConfig": "./extension.webpack.config.js",
|
|
107
|
+
"sharedPackages": {
|
|
108
|
+
"@jupytergis/base": {
|
|
109
|
+
"singleton": true,
|
|
110
|
+
"bundled": true
|
|
111
|
+
},
|
|
112
|
+
"@jupytergis/schema": {
|
|
113
|
+
"singleton": true,
|
|
114
|
+
"bundled": true
|
|
115
|
+
},
|
|
116
|
+
"@jupyter/docprovider": {
|
|
117
|
+
"singleton": true,
|
|
118
|
+
"bundled": false
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
package/style/base.css
ADDED
package/style/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import url('base.css');
|
package/style/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./base.css";
|