@jupytergis/jupytergis-core 0.1.7 → 0.2.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/lib/factory.d.ts CHANGED
@@ -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 _drive?;
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._drive = options.drive;
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._drive) {
39
- model.setDrive(this._drive, context.path);
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,10 +1,11 @@
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
  */
@@ -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
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,5 +1,5 @@
1
1
  import { ICollaborativeDrive } from '@jupyter/collaborative-drive';
2
- import { IJGISExternalCommandRegistryToken, IJupyterGISDocTracker, JupyterGISDoc } from '@jupytergis/schema';
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';
@@ -15,7 +15,7 @@ const FACTORY = 'JupyterGIS .jgis Viewer';
15
15
  const CONTENT_TYPE = 'jgis';
16
16
  const PALETTE_CATEGORY = 'JupyterGIS';
17
17
  const MODEL_NAME = 'jupytergis-jgismodel';
18
- const activate = (app, tracker, themeManager, browserFactory, externalCommandRegistry, contentFactory, editorServices, rendermime, consoleTracker, launcher, palette, drive) => {
18
+ const activate = (app, tracker, themeManager, browserFactory, externalCommandRegistry, contentFactory, editorServices, rendermime, consoleTracker, annotationModel, launcher, palette, drive) => {
19
19
  if (PageConfig.getOption('jgis_expose_maps')) {
20
20
  window.jupytergisMaps = {};
21
21
  }
@@ -27,7 +27,6 @@ const activate = (app, tracker, themeManager, browserFactory, externalCommandReg
27
27
  tracker,
28
28
  commands: app.commands,
29
29
  externalCommandRegistry,
30
- drive,
31
30
  manager: app.serviceManager,
32
31
  contentFactory,
33
32
  rendermime,
@@ -46,7 +45,7 @@ const activate = (app, tracker, themeManager, browserFactory, externalCommandReg
46
45
  });
47
46
  app.docRegistry.addWidgetFactory(mimeDocumentFactory);
48
47
  // Creating and registering the model factory for our custom DocumentModel
49
- const modelFactory = new JupyterGISModelFactory();
48
+ const modelFactory = new JupyterGISModelFactory({ annotationModel });
50
49
  app.docRegistry.addModelFactory(modelFactory);
51
50
  // register the filetype
52
51
  app.docRegistry.addFileType({
@@ -101,7 +100,7 @@ const activate = (app, tracker, themeManager, browserFactory, externalCommandReg
101
100
  type: 'file',
102
101
  ext: '.jGIS'
103
102
  });
104
- 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}' }));
105
104
  // Open the newly created file with the 'Editor'
106
105
  return app.commands.execute('docmanager:open', {
107
106
  path: model.path,
@@ -192,7 +191,8 @@ const jGISPlugin = {
192
191
  ConsolePanel.IContentFactory,
193
192
  IEditorServices,
194
193
  IRenderMimeRegistry,
195
- IConsoleTracker
194
+ IConsoleTracker,
195
+ IAnnotationToken
196
196
  ],
197
197
  optional: [ILauncher, ICommandPalette, ICollaborativeDrive],
198
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 { IJGISExternalCommandRegistryToken, IJGISFormSchemaRegistryToken, IJGISLayerBrowserRegistryToken, IJupyterGISDocTracker } from '@jupytergis/schema';
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.1.7",
3
+ "version": "0.2.1",
4
4
  "description": "JupyterGIS core extension",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -53,8 +53,8 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@jupyter/collaborative-drive": "^3.0.0",
56
- "@jupytergis/base": "^0.1.7",
57
- "@jupytergis/schema": "^0.1.7",
56
+ "@jupytergis/base": "^0.2.1",
57
+ "@jupytergis/schema": "^0.2.1",
58
58
  "@jupyterlab/application": "^4.3.0",
59
59
  "@jupyterlab/apputils": "^4.3.0",
60
60
  "@jupyterlab/docregistry": "^4.3.0",