@jupytergis/jupytergis-qgis 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 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_qgis
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@jupyterlab/application").JupyterFrontEndPlugin<void>[];
2
+ export default _default;
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { qgisplugin } from './plugins';
2
+ export default [qgisplugin];
@@ -0,0 +1,82 @@
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 JupyterGISModelFactoryBase 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
+ }
55
+ export declare class QGZModelFactory extends JupyterGISModelFactoryBase {
56
+ /**
57
+ * The name of the model.
58
+ *
59
+ * @returns The name
60
+ */
61
+ get name(): string;
62
+ /**
63
+ * The content type of the file.
64
+ *
65
+ * @returns The content type
66
+ */
67
+ get contentType(): Contents.ContentType;
68
+ }
69
+ export declare class QGSModelFactory extends JupyterGISModelFactoryBase {
70
+ /**
71
+ * The name of the model.
72
+ *
73
+ * @returns The name
74
+ */
75
+ get name(): string;
76
+ /**
77
+ * The content type of the file.
78
+ *
79
+ * @returns The content type
80
+ */
81
+ get contentType(): Contents.ContentType;
82
+ }
@@ -0,0 +1,108 @@
1
+ import { JupyterGISModel } from '@jupytergis/schema';
2
+ /**
3
+ * A Model factory to create new instances of JupyterGISModel.
4
+ */
5
+ export class JupyterGISModelFactoryBase {
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
+ throw 'Not implemented';
20
+ }
21
+ /**
22
+ * The content type of the file.
23
+ *
24
+ * @returns The content type
25
+ */
26
+ get contentType() {
27
+ throw 'Not implemented';
28
+ }
29
+ /**
30
+ * The format of the file.
31
+ *
32
+ * @returns the file format
33
+ */
34
+ get fileFormat() {
35
+ return 'base64';
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
+ }
73
+ export class QGZModelFactory extends JupyterGISModelFactoryBase {
74
+ /**
75
+ * The name of the model.
76
+ *
77
+ * @returns The name
78
+ */
79
+ get name() {
80
+ return 'jupytergis-qgzmodel';
81
+ }
82
+ /**
83
+ * The content type of the file.
84
+ *
85
+ * @returns The content type
86
+ */
87
+ get contentType() {
88
+ return 'QGZ';
89
+ }
90
+ }
91
+ export class QGSModelFactory extends JupyterGISModelFactoryBase {
92
+ /**
93
+ * The name of the model.
94
+ *
95
+ * @returns The name
96
+ */
97
+ get name() {
98
+ return 'jupytergis-qgsmodel';
99
+ }
100
+ /**
101
+ * The content type of the file.
102
+ *
103
+ * @returns The content type
104
+ */
105
+ get contentType() {
106
+ return 'QGS';
107
+ }
108
+ }
@@ -0,0 +1,2 @@
1
+ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ export declare const qgisplugin: JupyterFrontEndPlugin<void>;
package/lib/plugins.js ADDED
@@ -0,0 +1,109 @@
1
+ import { ICollaborativeDrive } from '@jupyter/docprovider';
2
+ import { JupyterGISDoc, IJGISExternalCommandRegistryToken } from '@jupytergis/schema';
3
+ import { IThemeManager, showErrorMessage } from '@jupyterlab/apputils';
4
+ import { IEditorServices } from '@jupyterlab/codeeditor';
5
+ import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console';
6
+ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
7
+ import { JupyterGISWidgetFactory } from '@jupytergis/jupytergis-core';
8
+ import { IJupyterGISDocTracker } from '@jupytergis/schema';
9
+ import { requestAPI } from '@jupytergis/base';
10
+ import { QGSModelFactory, QGZModelFactory } from './modelfactory';
11
+ const activate = async (app, tracker, themeManager, drive, externalCommandRegistry, contentFactory, editorServices, rendermime, consoleTracker) => {
12
+ const fcCheck = await requestAPI('jupytergis_qgis/backend-check', {
13
+ method: 'POST',
14
+ body: JSON.stringify({})
15
+ });
16
+ const { installed } = fcCheck;
17
+ const backendCheck = () => {
18
+ if (!installed) {
19
+ showErrorMessage('QGIS is not installed', 'QGIS is required to open QGIS files');
20
+ }
21
+ return installed;
22
+ };
23
+ const QGSWidgetFactory = new JupyterGISWidgetFactory({
24
+ name: 'JupyterGIS QGS Factory',
25
+ modelName: 'jupytergis-qgsmodel',
26
+ fileTypes: ['QGS'],
27
+ defaultFor: ['QGS'],
28
+ tracker,
29
+ commands: app.commands,
30
+ externalCommandRegistry,
31
+ backendCheck,
32
+ manager: app.serviceManager,
33
+ contentFactory,
34
+ rendermime,
35
+ mimeTypeService: editorServices.mimeTypeService,
36
+ consoleTracker
37
+ });
38
+ const QGZWidgetFactory = new JupyterGISWidgetFactory({
39
+ name: 'JupyterGIS QGZ Factory',
40
+ modelName: 'jupytergis-qgzmodel',
41
+ fileTypes: ['QGZ'],
42
+ defaultFor: ['QGZ'],
43
+ tracker,
44
+ commands: app.commands,
45
+ externalCommandRegistry,
46
+ backendCheck,
47
+ manager: app.serviceManager,
48
+ contentFactory,
49
+ rendermime,
50
+ mimeTypeService: editorServices.mimeTypeService,
51
+ consoleTracker
52
+ });
53
+ // Registering the widget factory
54
+ app.docRegistry.addWidgetFactory(QGSWidgetFactory);
55
+ app.docRegistry.addWidgetFactory(QGZWidgetFactory);
56
+ // Creating and registering the model factory for our custom DocumentModel
57
+ app.docRegistry.addModelFactory(new QGSModelFactory());
58
+ app.docRegistry.addModelFactory(new QGZModelFactory());
59
+ // register the filetype
60
+ app.docRegistry.addFileType({
61
+ name: 'QGS',
62
+ displayName: 'QGS',
63
+ mimeTypes: ['application/octet-stream'],
64
+ extensions: ['.qgs', '.QGS'],
65
+ fileFormat: 'base64',
66
+ contentType: 'QGS'
67
+ });
68
+ app.docRegistry.addFileType({
69
+ name: 'QGZ',
70
+ displayName: 'QGZ',
71
+ mimeTypes: ['application/octet-stream'],
72
+ extensions: ['.qgz', '.QGZ'],
73
+ fileFormat: 'base64',
74
+ contentType: 'QGZ'
75
+ });
76
+ const QGISSharedModelFactory = () => {
77
+ return new JupyterGISDoc();
78
+ };
79
+ drive.sharedModelFactory.registerDocumentFactory('QGS', QGISSharedModelFactory);
80
+ drive.sharedModelFactory.registerDocumentFactory('QGZ', QGISSharedModelFactory);
81
+ const widgetCreatedCallback = (sender, widget) => {
82
+ // Notify the instance tracker if restore data needs to update.
83
+ widget.context.pathChanged.connect(() => {
84
+ tracker.save(widget);
85
+ });
86
+ themeManager.themeChanged.connect((_, changes) => widget.context.model.themeChanged.emit(changes));
87
+ tracker.add(widget);
88
+ app.shell.activateById('jupytergis::leftControlPanel');
89
+ app.shell.activateById('jupytergis::rightControlPanel');
90
+ };
91
+ QGSWidgetFactory.widgetCreated.connect(widgetCreatedCallback);
92
+ QGZWidgetFactory.widgetCreated.connect(widgetCreatedCallback);
93
+ console.log('jupytergis:qgisplugin is activated!');
94
+ };
95
+ export const qgisplugin = {
96
+ id: 'jupytergis:qgisplugin',
97
+ requires: [
98
+ IJupyterGISDocTracker,
99
+ IThemeManager,
100
+ ICollaborativeDrive,
101
+ IJGISExternalCommandRegistryToken,
102
+ ConsolePanel.IContentFactory,
103
+ IEditorServices,
104
+ IRenderMimeRegistry,
105
+ IConsoleTracker
106
+ ],
107
+ autoStart: true,
108
+ activate
109
+ };
package/package.json ADDED
@@ -0,0 +1,122 @@
1
+ {
2
+ "name": "@jupytergis/jupytergis-qgis",
3
+ "version": "0.1.1",
4
+ "description": "JupyterGIS QGIS 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_qgis/labextension jupytergis_qgis/_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/jupytergis-core": "^0.1.1",
58
+ "@jupytergis/schema": "^0.1.1",
59
+ "@jupyterlab/application": "^4.0.0",
60
+ "@jupyterlab/apputils": "^4.0.0",
61
+ "@jupyterlab/coreutils": "^6.0.0",
62
+ "@jupyterlab/docregistry": "^4.0.0",
63
+ "@jupyterlab/filebrowser": "^4.0.0",
64
+ "@jupyterlab/launcher": "^4.0.0",
65
+ "@jupyterlab/mainmenu": "^4.0.0",
66
+ "@jupyterlab/services": "^7.0.0",
67
+ "@jupyterlab/translation": "^4.0.0",
68
+ "@jupyterlab/ui-components": "^4.0.0",
69
+ "@lumino/messaging": "^2.0.0",
70
+ "@lumino/widgets": "^2.0.0",
71
+ "react": "^18.0.1"
72
+ },
73
+ "devDependencies": {
74
+ "@jupyterlab/builder": "^4.0.0",
75
+ "css-loader": "^6.7.1",
76
+ "mkdirp": "^1.0.3",
77
+ "npm-run-all": "^4.1.5",
78
+ "rimraf": "^3.0.2",
79
+ "typescript": "^5",
80
+ "yjs": "^13.5.0"
81
+ },
82
+ "sideEffects": [
83
+ "style/*.css",
84
+ "style/index.js"
85
+ ],
86
+ "styleModule": "style/index.js",
87
+ "publishConfig": {
88
+ "access": "public"
89
+ },
90
+ "jupyterlab": {
91
+ "discovery": {
92
+ "server": {
93
+ "managers": [
94
+ "pip"
95
+ ],
96
+ "base": {
97
+ "name": "jupytergis_qgis"
98
+ }
99
+ }
100
+ },
101
+ "extension": true,
102
+ "outputDir": "jupytergis_qgis/labextension",
103
+ "sharedPackages": {
104
+ "@jupytergis/base": {
105
+ "singleton": true,
106
+ "bundled": false
107
+ },
108
+ "@jupytergis/schema": {
109
+ "singleton": true,
110
+ "bundled": false
111
+ },
112
+ "@jupytergis/jupytergis-core": {
113
+ "singleton": true,
114
+ "bundled": false
115
+ },
116
+ "@jupyter/docprovider": {
117
+ "singleton": true,
118
+ "bundled": false
119
+ }
120
+ }
121
+ }
122
+ }
package/style/base.css ADDED
File without changes
@@ -0,0 +1 @@
1
+ @import url('base.css');
package/style/index.js ADDED
@@ -0,0 +1 @@
1
+ import "./base.css";