@jupytergis/jupytergis-core 0.4.5 → 0.6.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 CHANGED
@@ -1,12 +1,12 @@
1
- import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console';
2
1
  import { ICollaborativeDrive } from '@jupyter/collaborative-drive';
2
+ import { JupyterGISDocumentWidget } from '@jupytergis/base';
3
3
  import { JupyterGISModel, IJupyterGISTracker, IJGISExternalCommandRegistry } from '@jupytergis/schema';
4
- import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
5
4
  import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
5
+ import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console';
6
6
  import { ABCWidgetFactory, DocumentRegistry } from '@jupyterlab/docregistry';
7
- import { CommandRegistry } from '@lumino/commands';
8
- import { JupyterGISDocumentWidget } from '@jupytergis/base';
7
+ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
9
8
  import { ServiceManager } from '@jupyterlab/services';
9
+ import { CommandRegistry } from '@lumino/commands';
10
10
  interface IOptions extends DocumentRegistry.IWidgetFactoryOptions {
11
11
  tracker: IJupyterGISTracker;
12
12
  commands: CommandRegistry;
package/lib/factory.js CHANGED
@@ -9,8 +9,8 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
+ import { JupyterGISPanel, JupyterGISDocumentWidget, ToolbarWidget, } from '@jupytergis/base';
12
13
  import { ABCWidgetFactory } from '@jupyterlab/docregistry';
13
- import { JupyterGISPanel, JupyterGISDocumentWidget, ToolbarWidget } from '@jupytergis/base';
14
14
  export class JupyterGISDocumentWidgetFactory extends ABCWidgetFactory {
15
15
  constructor(options) {
16
16
  var _a;
@@ -37,6 +37,9 @@ export class JupyterGISDocumentWidgetFactory extends ABCWidgetFactory {
37
37
  }
38
38
  const { model } = context;
39
39
  model.filePath = context.localPath;
40
+ context.pathChanged.connect(() => {
41
+ model.filePath = context.localPath;
42
+ });
40
43
  if (this._contentsManager) {
41
44
  model.contentsManager = this._contentsManager;
42
45
  }
@@ -47,12 +50,12 @@ export class JupyterGISDocumentWidgetFactory extends ABCWidgetFactory {
47
50
  mimeTypeService: this.options.mimeTypeService,
48
51
  rendermime: this.options.rendermime,
49
52
  consoleTracker: this.options.consoleTracker,
50
- commandRegistry: this.options.commands
53
+ commandRegistry: this.options.commands,
51
54
  });
52
55
  const toolbar = new ToolbarWidget({
53
56
  commands: this._commands,
54
57
  model,
55
- externalCommands: this._externalCommandRegistry.getCommands()
58
+ externalCommands: this._externalCommandRegistry.getCommands(),
56
59
  });
57
60
  return new JupyterGISDocumentWidget({ context, content, toolbar });
58
61
  }
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import jgisPlugin from './jgisplugin/plugins';
2
- import { externalCommandRegistryPlugin, formSchemaRegistryPlugin, layerBrowserRegistryPlugin, trackerPlugin, annotationPlugin } from './plugin';
2
+ import { externalCommandRegistryPlugin, formSchemaRegistryPlugin, layerBrowserRegistryPlugin, trackerPlugin, annotationPlugin, } from './plugin';
3
3
  export * from './factory';
4
4
  export default [
5
5
  trackerPlugin,
@@ -7,5 +7,5 @@ export default [
7
7
  formSchemaRegistryPlugin,
8
8
  externalCommandRegistryPlugin,
9
9
  layerBrowserRegistryPlugin,
10
- annotationPlugin
10
+ annotationPlugin,
11
11
  ];
@@ -1,6 +1,7 @@
1
1
  import { IAnnotationModel, IJupyterGISDoc, JupyterGISModel } from '@jupytergis/schema';
2
2
  import { DocumentRegistry } from '@jupyterlab/docregistry';
3
3
  import { Contents } from '@jupyterlab/services';
4
+ import { ISettingRegistry } from '@jupyterlab/settingregistry';
4
5
  /**
5
6
  * A Model factory to create new instances of JupyterGISModel.
6
7
  */
@@ -52,10 +53,12 @@ export declare class JupyterGISModelFactory implements DocumentRegistry.IModelFa
52
53
  */
53
54
  createNew(options: DocumentRegistry.IModelOptions<IJupyterGISDoc>): JupyterGISModel;
54
55
  private _annotationModel;
56
+ private _settingRegistry;
55
57
  private _disposed;
56
58
  }
57
59
  export declare namespace JupyterGISModelFactory {
58
60
  interface IOptions {
59
61
  annotationModel: IAnnotationModel;
62
+ settingRegistry: ISettingRegistry;
60
63
  }
61
64
  }
@@ -1,4 +1,4 @@
1
- import { JupyterGISModel } from '@jupytergis/schema';
1
+ import { JupyterGISModel, } from '@jupytergis/schema';
2
2
  /**
3
3
  * A Model factory to create new instances of JupyterGISModel.
4
4
  */
@@ -10,6 +10,7 @@ export class JupyterGISModelFactory {
10
10
  this.collaborative = true;
11
11
  this._disposed = false;
12
12
  this._annotationModel = options.annotationModel;
13
+ this._settingRegistry = options.settingRegistry;
13
14
  }
14
15
  /**
15
16
  * The name of the model.
@@ -67,8 +68,10 @@ export class JupyterGISModelFactory {
67
68
  const model = new JupyterGISModel({
68
69
  sharedModel: options.sharedModel,
69
70
  languagePreference: options.languagePreference,
70
- annotationModel: this._annotationModel
71
+ annotationModel: this._annotationModel,
72
+ settingRegistry: this._settingRegistry,
71
73
  });
74
+ model.initSettings();
72
75
  return model;
73
76
  }
74
77
  }
@@ -1,24 +1,34 @@
1
- import { ICollaborativeDrive } from '@jupyter/collaborative-drive';
2
- import { IAnnotationToken, IJGISExternalCommandRegistryToken, IJupyterGISDocTracker, JupyterGISDoc } from '@jupytergis/schema';
3
- import { ICommandPalette, IThemeManager } from '@jupyterlab/apputils';
1
+ import { ICollaborativeDrive, } from '@jupyter/collaborative-drive';
2
+ import { CommandIDs, logoIcon, logoMiniIcon } from '@jupytergis/base';
3
+ import { IAnnotationToken, IJGISExternalCommandRegistryToken, IJupyterGISDocTracker, JupyterGISDoc, SCHEMA_VERSION, ProcessingMerge, } from '@jupytergis/schema';
4
+ import { ICommandPalette, IThemeManager, } from '@jupyterlab/apputils';
4
5
  import { IEditorServices } from '@jupyterlab/codeeditor';
5
6
  import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console';
6
7
  import { PageConfig } from '@jupyterlab/coreutils';
8
+ import { MimeDocumentFactory } from '@jupyterlab/docregistry';
7
9
  import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
8
10
  import { ILauncher } from '@jupyterlab/launcher';
9
11
  import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
10
- import { CommandIDs, logoIcon, logoMiniIcon } from '@jupytergis/base';
12
+ import { ISettingRegistry } from '@jupyterlab/settingregistry';
11
13
  import { JupyterGISDocumentWidgetFactory } from '../factory';
12
14
  import { JupyterGISModelFactory } from './modelfactory';
13
- import { MimeDocumentFactory } from '@jupyterlab/docregistry';
14
15
  const FACTORY = 'JupyterGIS .jgis Viewer';
15
16
  const CONTENT_TYPE = 'jgis';
16
17
  const PALETTE_CATEGORY = 'JupyterGIS';
17
18
  const MODEL_NAME = 'jupytergis-jgismodel';
18
- const activate = (app, tracker, themeManager, browserFactory, externalCommandRegistry, contentFactory, editorServices, rendermime, consoleTracker, annotationModel, launcher, palette, drive) => {
19
+ const SETTINGS_ID = '@jupytergis/jupytergis-core:jupytergis-settings';
20
+ const activate = async (app, tracker, themeManager, browserFactory, externalCommandRegistry, contentFactory, editorServices, rendermime, consoleTracker, annotationModel, settingRegistry, launcher, palette, drive) => {
19
21
  if (PageConfig.getOption('jgis_expose_maps')) {
20
22
  window.jupytergisMaps = {};
21
23
  }
24
+ let settings = null;
25
+ try {
26
+ settings = await settingRegistry.load(SETTINGS_ID);
27
+ console.log(`Loaded settings for ${SETTINGS_ID}`, settings);
28
+ }
29
+ catch (error) {
30
+ console.warn(`Failed to load settings for ${SETTINGS_ID}`, error);
31
+ }
22
32
  const widgetFactory = new JupyterGISDocumentWidgetFactory({
23
33
  name: FACTORY,
24
34
  modelName: MODEL_NAME,
@@ -31,7 +41,7 @@ const activate = (app, tracker, themeManager, browserFactory, externalCommandReg
31
41
  contentFactory,
32
42
  rendermime,
33
43
  mimeTypeService: editorServices.mimeTypeService,
34
- consoleTracker
44
+ consoleTracker,
35
45
  });
36
46
  // Registering the widget factory
37
47
  app.docRegistry.addWidgetFactory(widgetFactory);
@@ -41,11 +51,14 @@ const activate = (app, tracker, themeManager, browserFactory, externalCommandReg
41
51
  modelName: MODEL_NAME,
42
52
  name: 'JSON Editor',
43
53
  primaryFileType: app.docRegistry.getFileType('json'),
44
- fileTypes: [CONTENT_TYPE]
54
+ fileTypes: [CONTENT_TYPE],
45
55
  });
46
56
  app.docRegistry.addWidgetFactory(mimeDocumentFactory);
47
57
  // Creating and registering the model factory for our custom DocumentModel
48
- const modelFactory = new JupyterGISModelFactory({ annotationModel });
58
+ const modelFactory = new JupyterGISModelFactory({
59
+ annotationModel,
60
+ settingRegistry,
61
+ });
49
62
  app.docRegistry.addModelFactory(modelFactory);
50
63
  // register the filetype
51
64
  app.docRegistry.addFileType({
@@ -55,7 +68,7 @@ const activate = (app, tracker, themeManager, browserFactory, externalCommandReg
55
68
  extensions: ['.jgis', '.JGIS'],
56
69
  fileFormat: 'text',
57
70
  contentType: CONTENT_TYPE,
58
- icon: logoMiniIcon
71
+ icon: logoMiniIcon,
59
72
  });
60
73
  const jGISSharedModelFactory = () => {
61
74
  return new JupyterGISDoc();
@@ -98,22 +111,22 @@ const activate = (app, tracker, themeManager, browserFactory, externalCommandReg
98
111
  let model = await app.serviceManager.contents.newUntitled({
99
112
  path: cwd,
100
113
  type: 'file',
101
- ext: '.jGIS'
114
+ ext: '.jGIS',
102
115
  });
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}' }));
116
+ model = await app.serviceManager.contents.save(model.path, Object.assign(Object.assign({}, model), { format: 'text', size: undefined, content: `{\n\t"schemaVersion": "${SCHEMA_VERSION}",\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}` }));
104
117
  // Open the newly created file with the 'Editor'
105
118
  return app.commands.execute('docmanager:open', {
106
119
  path: model.path,
107
- factory: FACTORY
120
+ factory: FACTORY,
108
121
  });
109
- }
122
+ },
110
123
  });
111
124
  // Add the command to the launcher
112
125
  if (launcher) {
113
126
  launcher.add({
114
127
  command: CommandIDs.createNew,
115
128
  category: 'Other',
116
- rank: 1
129
+ rank: 1,
117
130
  });
118
131
  }
119
132
  // Add the command to the palette
@@ -121,68 +134,40 @@ const activate = (app, tracker, themeManager, browserFactory, externalCommandReg
121
134
  palette.addItem({
122
135
  command: CommandIDs.createNew,
123
136
  args: { isPalette: true },
124
- category: PALETTE_CATEGORY
137
+ category: PALETTE_CATEGORY,
125
138
  });
126
139
  palette.addItem({
127
140
  command: CommandIDs.openLayerBrowser,
128
- category: 'JupyterGIS'
141
+ category: 'JupyterGIS',
129
142
  });
130
143
  // Layers and Sources
131
144
  palette.addItem({
132
145
  command: CommandIDs.newRasterEntry,
133
- category: 'JupyterGIS'
146
+ category: 'JupyterGIS',
134
147
  });
135
148
  palette.addItem({
136
149
  command: CommandIDs.newVectorTileEntry,
137
- category: 'JupyterGIS'
150
+ category: 'JupyterGIS',
138
151
  });
139
152
  palette.addItem({
140
153
  command: CommandIDs.newGeoJSONEntry,
141
- category: 'JupyterGIS'
154
+ category: 'JupyterGIS',
142
155
  });
143
156
  palette.addItem({
144
157
  command: CommandIDs.newHillshadeEntry,
145
- category: 'JupyterGIS'
146
- });
147
- // Source only
148
- palette.addItem({
149
- command: CommandIDs.newRasterSource,
150
- category: 'JupyterGIS'
151
- });
152
- palette.addItem({
153
- command: CommandIDs.newRasterDemSource,
154
- category: 'JupyterGIS'
155
- });
156
- palette.addItem({
157
- command: CommandIDs.newVectorSource,
158
- category: 'JupyterGIS'
159
- });
160
- palette.addItem({
161
- command: CommandIDs.newGeoJSONSource,
162
- category: 'JupyterGIS'
163
- });
164
- // Layers only
165
- palette.addItem({
166
- command: CommandIDs.newRasterLayer,
167
- category: 'JupyterGIS'
168
- });
169
- palette.addItem({
170
- command: CommandIDs.newVectorLayer,
171
- category: 'JupyterGIS'
172
- });
173
- palette.addItem({
174
- command: CommandIDs.newHillshadeLayer,
175
- category: 'JupyterGIS'
158
+ category: 'JupyterGIS',
176
159
  });
177
160
  // Layer and group actions
178
161
  palette.addItem({
179
162
  command: CommandIDs.moveLayerToNewGroup,
180
- category: 'JupyterGIS'
181
- });
182
- palette.addItem({
183
- command: CommandIDs.buffer,
184
- category: 'JupyterGIS'
163
+ category: 'JupyterGIS',
185
164
  });
165
+ for (const processingElement of ProcessingMerge) {
166
+ palette.addItem({
167
+ command: processingElement.name,
168
+ category: 'JupyterGIS',
169
+ });
170
+ }
186
171
  }
187
172
  };
188
173
  const jGISPlugin = {
@@ -196,10 +181,11 @@ const jGISPlugin = {
196
181
  IEditorServices,
197
182
  IRenderMimeRegistry,
198
183
  IConsoleTracker,
199
- IAnnotationToken
184
+ IAnnotationToken,
185
+ ISettingRegistry,
200
186
  ],
201
187
  optional: [ILauncher, ICommandPalette, ICollaborativeDrive],
202
188
  autoStart: true,
203
- activate
189
+ activate,
204
190
  };
205
191
  export default jGISPlugin;
package/lib/plugin.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { AnnotationModel } from '@jupytergis/base';
2
- import { IAnnotationToken, IJGISExternalCommandRegistryToken, IJGISFormSchemaRegistryToken, IJGISLayerBrowserRegistryToken, IJupyterGISDocTracker } from '@jupytergis/schema';
2
+ import { IAnnotationToken, IJGISExternalCommandRegistryToken, IJGISFormSchemaRegistryToken, IJGISLayerBrowserRegistryToken, IJupyterGISDocTracker, } from '@jupytergis/schema';
3
3
  import { WidgetTracker } from '@jupyterlab/apputils';
4
+ import { IDocumentManager } from '@jupyterlab/docmanager';
4
5
  import { IMainMenu } from '@jupyterlab/mainmenu';
5
6
  import { ITranslator } from '@jupyterlab/translation';
6
- import { IDocumentManager } from '@jupyterlab/docmanager';
7
7
  import { JupyterGISExternalCommandRegistry } from './externalcommand';
8
8
  import { JupyterGISLayerBrowserRegistry } from './layerBrowserRegistry';
9
9
  import { JupyterGISFormSchemaRegistry } from './schemaregistry';
@@ -16,11 +16,11 @@ export const trackerPlugin = {
16
16
  provides: IJupyterGISDocTracker,
17
17
  activate: (app, translator, mainMenu) => {
18
18
  const tracker = new WidgetTracker({
19
- namespace: NAME_SPACE
19
+ namespace: NAME_SPACE,
20
20
  });
21
21
  console.log('jupytergis:core:tracker is activated!');
22
22
  return tracker;
23
- }
23
+ },
24
24
  };
25
25
  export const formSchemaRegistryPlugin = {
26
26
  id: 'jupytergis:core:form-schema-registry',
@@ -30,7 +30,7 @@ export const formSchemaRegistryPlugin = {
30
30
  activate: (app, docmanager) => {
31
31
  const registry = new JupyterGISFormSchemaRegistry(docmanager);
32
32
  return registry;
33
- }
33
+ },
34
34
  };
35
35
  export const externalCommandRegistryPlugin = {
36
36
  id: 'jupytergis:core:external-command-registry',
@@ -40,7 +40,7 @@ export const externalCommandRegistryPlugin = {
40
40
  activate: (app) => {
41
41
  const registry = new JupyterGISExternalCommandRegistry();
42
42
  return registry;
43
- }
43
+ },
44
44
  };
45
45
  export const layerBrowserRegistryPlugin = {
46
46
  id: 'jupytergis:core:layer-browser-registry',
@@ -51,7 +51,7 @@ export const layerBrowserRegistryPlugin = {
51
51
  console.log('jupytergis:core:layer-browser-registry is activated');
52
52
  const registry = new JupyterGISLayerBrowserRegistry();
53
53
  return registry;
54
- }
54
+ },
55
55
  };
56
56
  export const annotationPlugin = {
57
57
  id: 'jupytergis:core:annotation',
@@ -61,11 +61,11 @@ export const annotationPlugin = {
61
61
  activate: (app, tracker) => {
62
62
  var _a;
63
63
  const annotationModel = new AnnotationModel({
64
- model: (_a = tracker.currentWidget) === null || _a === void 0 ? void 0 : _a.model
64
+ model: (_a = tracker.currentWidget) === null || _a === void 0 ? void 0 : _a.model,
65
65
  });
66
66
  tracker.currentChanged.connect((_, changed) => {
67
67
  annotationModel.model = (changed === null || changed === void 0 ? void 0 : changed.model) || undefined;
68
68
  });
69
69
  return annotationModel;
70
- }
70
+ },
71
71
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupytergis/jupytergis-core",
3
- "version": "0.4.5",
3
+ "version": "0.6.0",
4
4
  "description": "JupyterGIS core extension",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -15,7 +15,8 @@
15
15
  "author": "JupyterGIS contributors",
16
16
  "files": [
17
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}"
18
+ "style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
19
+ "schema/**/*.{json,js,ts}"
19
20
  ],
20
21
  "main": "lib/index.js",
21
22
  "types": "lib/index.d.ts",
@@ -53,8 +54,8 @@
53
54
  },
54
55
  "dependencies": {
55
56
  "@jupyter/collaborative-drive": "^3.0.0",
56
- "@jupytergis/base": "^0.4.5",
57
- "@jupytergis/schema": "^0.4.5",
57
+ "@jupytergis/base": "^0.6.0",
58
+ "@jupytergis/schema": "^0.6.0",
58
59
  "@jupyterlab/application": "^4.3.0",
59
60
  "@jupyterlab/apputils": "^4.3.0",
60
61
  "@jupyterlab/docregistry": "^4.3.0",
@@ -91,6 +92,7 @@
91
92
  "access": "public"
92
93
  },
93
94
  "jupyterlab": {
95
+ "schemaDir": "schema",
94
96
  "discovery": {
95
97
  "server": {
96
98
  "managers": [
@@ -0,0 +1,13 @@
1
+ {
2
+ "title": "JupyterGIS Settings",
3
+ "description": "Settings for the JupyterGIS extension.",
4
+ "type": "object",
5
+ "properties": {
6
+ "proxyUrl": {
7
+ "type": "string",
8
+ "title": "Proxy URL",
9
+ "description": "The proxy URL to use for external requests.",
10
+ "default": "https://corsproxy.io"
11
+ }
12
+ }
13
+ }