@fails-components/jupyter-interceptor 0.0.1-alpha.9 → 0.0.3

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/index.d.ts CHANGED
@@ -1,19 +1,15 @@
1
1
  import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
2
  import { WidgetModel } from '@jupyter-widgets/base';
3
- import { Token } from '@lumino/coreutils';
4
3
  import { IFailsInterceptorUpdateMessage, IAppletWidgetRegistry, IFailsLauncherInfo } from '@fails-components/jupyter-launcher';
5
- export interface IFailsInterceptor {
6
- isMimeTypeSupported: (mimeType: string) => boolean;
7
- }
8
- export declare const IFailsInterceptor: Token<IFailsInterceptor>;
4
+ export * from './tokens';
9
5
  export declare class AppletWidgetRegistry implements IAppletWidgetRegistry {
10
6
  constructor(launcher: IFailsLauncherInfo);
11
7
  registerModel(path: string, modelId: string, model: WidgetModel): void;
12
8
  unregisterPath(path: string): void;
13
9
  unregisterModel(modelId: string): void;
14
- getModelId(path: string): string;
15
- getModel(path: string): WidgetModel;
16
- getPath(modelId: string): string;
10
+ getModelId(path: string): string | undefined;
11
+ getModel(path: string): WidgetModel | undefined;
12
+ getPath(modelId: string): string | undefined;
17
13
  dispatchMessage(message: IFailsInterceptorUpdateMessage): void;
18
14
  private _modelIdToPath;
19
15
  private _pathToModelId;
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { INotebookTracker } from '@jupyterlab/notebook';
2
2
  import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
3
- import { Token } from '@lumino/coreutils';
4
3
  import { IFailsLauncherInfo } from '@fails-components/jupyter-launcher';
5
4
  import { Signal } from '@lumino/signaling';
6
- export const IFailsInterceptor = new Token('@fails-components/jupyter-fails:IFailsInterceptor', 'A service to talk with FAILS interceptor.');
5
+ import { IFailsInterceptor } from './tokens';
6
+ export * from './tokens';
7
7
  // List of static Mimetypes, where intercepting is not necessary
8
8
  const staticMimeTypes = new Set([
9
9
  'text/html',
@@ -116,6 +116,10 @@ function activateWidgetInterceptor(app, notebookTracker, rendermimeRegistry, lau
116
116
  launcher.remoteUpdateMessageArrived.connect(async (slot, args) => {
117
117
  // const modelId = wRegistry.getModelId(args.path);
118
118
  const model = wRegistry.getModel(args.path);
119
+ if (!model) {
120
+ // just skip
121
+ return;
122
+ }
119
123
  const state = await model.constructor._deserialize_state(args.state, model.widget_manager);
120
124
  // console.log('got an remote interceptor message', args, state);
121
125
  for (const [key, value] of Object.entries(state)) {
@@ -0,0 +1,5 @@
1
+ import { Token } from '@lumino/coreutils';
2
+ export interface IFailsInterceptor {
3
+ isMimeTypeSupported: (mimeType: string) => boolean;
4
+ }
5
+ export declare const IFailsInterceptor: Token<IFailsInterceptor>;
package/lib/tokens.js ADDED
@@ -0,0 +1,2 @@
1
+ import { Token } from '@lumino/coreutils';
2
+ export const IFailsInterceptor = new Token('@fails-components/jupyter-fails:IFailsInterceptor', 'A service to talk with FAILS interceptor.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fails-components/jupyter-interceptor",
3
- "version": "0.0.1-alpha.9",
3
+ "version": "0.0.3",
4
4
  "description": "A collections of plugins intercepting kernel messages and other message, to steer outputs remotely",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -60,22 +60,19 @@
60
60
  "watch:labextension": "jupyter labextension watch ."
61
61
  },
62
62
  "dependencies": {
63
- "@fails-components/jupyter-launcher": "^0.0.1-alpha.9",
64
- "@jupyter-widgets/base": "^6.0.8",
65
- "@jupyter-widgets/jupyterlab-manager": "^5.0.11",
66
- "@jupyter/ydoc": "^3.0.0",
67
- "@jupyterlab/application": "^4.3.4",
68
- "@jupyterlab/cells": "^4.3.4",
69
- "@jupyterlab/nbformat": "^4.3.4",
70
- "@jupyterlab/notebook": "^4.3.4",
71
- "@jupyterlab/rendermime": "^4.3.4",
72
- "@jupyterlab/services": "^7.3.4",
73
- "@jupyterlite/application-extension": "^0.5.0",
74
- "@jupyterlite/contents": "^0.5.0",
75
- "@jupyterlite/server": "^0.5.0",
76
- "@jupyterlite/settings": "^0.5.0",
77
- "@lumino/coreutils": "^2.2.0",
78
- "json5": "^2.2.3"
63
+ "@fails-components/jupyter-launcher": "^0.0.3",
64
+ "@jupyter-widgets/base": "^6.0.11",
65
+ "@jupyter-widgets/jupyterlab-manager": "^5.0.15",
66
+ "@jupyter/ydoc": "^3.0.4",
67
+ "@jupyterlab/application": "^4.4.3",
68
+ "@jupyterlab/cells": "^4.4.3",
69
+ "@jupyterlab/nbformat": "^4.4.3",
70
+ "@jupyterlab/notebook": "^4.4.3",
71
+ "@jupyterlab/rendermime": "^4.4.3",
72
+ "@jupyterlab/services": "^7.4.3",
73
+ "@jupyterlite/application-extension": "^0.6.1",
74
+ "@lumino/coreutils": "^2.2.1",
75
+ "@lumino/signaling": "^2.1.4"
79
76
  },
80
77
  "devDependencies": {
81
78
  "@jupyterlab/builder": "^4.0.0",
@@ -115,7 +112,14 @@
115
112
  "jupyterlab": {
116
113
  "extension": true,
117
114
  "outputDir": "fails_components_jupyter_interceptor/labextension",
118
- "schemaDir": "schema"
115
+ "schemaDir": "schema",
116
+ "sharedPackages": {
117
+ "@fails-components/jupyter-launcher": {
118
+ "singleton": true,
119
+ "requiredVersion": "^0.0.1-alpha.18",
120
+ "import": false
121
+ }
122
+ }
119
123
  },
120
124
  "eslintIgnore": [
121
125
  "node_modules",
package/src/index.ts CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  } from '@jupyterlab/rendermime';
21
21
  import { ICellModel } from '@jupyterlab/cells';
22
22
  import { ISharedCodeCell } from '@jupyter/ydoc';
23
- import { JSONObject, PromiseDelegate, Token } from '@lumino/coreutils';
23
+ import { JSONObject, PromiseDelegate } from '@lumino/coreutils';
24
24
  import { Kernel /*, KernelMessage */ } from '@jupyterlab/services';
25
25
  import {
26
26
  IFailsInterceptorUpdateMessage,
@@ -28,15 +28,9 @@ import {
28
28
  IFailsLauncherInfo
29
29
  } from '@fails-components/jupyter-launcher';
30
30
  import { Signal } from '@lumino/signaling';
31
+ import { IFailsInterceptor } from './tokens';
31
32
 
32
- export interface IFailsInterceptor {
33
- isMimeTypeSupported: (mimeType: string) => boolean;
34
- }
35
-
36
- export const IFailsInterceptor = new Token<IFailsInterceptor>(
37
- '@fails-components/jupyter-fails:IFailsInterceptor',
38
- 'A service to talk with FAILS interceptor.'
39
- );
33
+ export * from './tokens';
40
34
 
41
35
  // List of static Mimetypes, where intercepting is not necessary
42
36
  const staticMimeTypes = new Set([
@@ -89,15 +83,15 @@ export class AppletWidgetRegistry implements IAppletWidgetRegistry {
89
83
  }
90
84
  }
91
85
 
92
- getModelId(path: string) {
86
+ getModelId(path: string): string | undefined {
93
87
  return this._pathToModelId[path];
94
88
  }
95
89
 
96
- getModel(path: string) {
90
+ getModel(path: string): WidgetModel | undefined {
97
91
  return this._pathToModel[path];
98
92
  }
99
93
 
100
- getPath(modelId: string) {
94
+ getPath(modelId: string): string | undefined {
101
95
  return this._modelIdToPath[modelId];
102
96
  }
103
97
 
@@ -175,6 +169,10 @@ function activateWidgetInterceptor(
175
169
  ) => {
176
170
  // const modelId = wRegistry.getModelId(args.path);
177
171
  const model = wRegistry.getModel(args.path);
172
+ if (!model) {
173
+ // just skip
174
+ return;
175
+ }
178
176
  const state = await (
179
177
  model.constructor as typeof WidgetModel
180
178
  )._deserialize_state(args.state, model.widget_manager);
package/src/tokens.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { Token } from '@lumino/coreutils';
2
+
3
+ export interface IFailsInterceptor {
4
+ isMimeTypeSupported: (mimeType: string) => boolean;
5
+ }
6
+
7
+ export const IFailsInterceptor = new Token<IFailsInterceptor>(
8
+ '@fails-components/jupyter-fails:IFailsInterceptor',
9
+ 'A service to talk with FAILS interceptor.'
10
+ );