@fails-components/jupyter-interceptor 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -74,29 +74,3 @@ pip uninstall fails_components_jupyter_interceptor
74
74
  In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
75
75
  command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
76
76
  folder is located. Then you can remove the symlink named `@fails-components/jupyter-applet-view` within that folder.
77
-
78
- ### Testing the extension
79
-
80
- #### Frontend tests
81
-
82
- This extension is using [Jest](https://jestjs.io/) for JavaScript code testing.
83
-
84
- To execute them, execute:
85
-
86
- ```sh
87
- jlpm
88
- jlpm test
89
- ```
90
-
91
- <!--
92
- #### Integration tests
93
-
94
- This extension uses [Playwright](https://playwright.dev/docs/intro) for the integration tests (aka user level tests).
95
- More precisely, the JupyterLab helper [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) is used to handle testing the extension in JupyterLab.
96
-
97
- More information are provided within the [ui-tests](./ui-tests/README.md) README.
98
-
99
- ### Packaging the extension
100
-
101
- See [RELEASE](RELEASE.md)
102
- -->
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
- import { WidgetModel } from '@jupyter-widgets/base';
3
- import { IFailsInterceptorUpdateMessage, IAppletWidgetRegistry, IFailsLauncherInfo } from '@fails-components/jupyter-launcher';
1
+ import type { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ import type { WidgetModel } from '@jupyter-widgets/base';
3
+ import type { IFailsInterceptorUpdateMessage, IAppletWidgetRegistry } from '@fails-components/jupyter-launcher';
4
+ import { IFailsLauncherInfo } from '@fails-components/jupyter-launcher';
4
5
  export * from './tokens';
5
6
  export declare class AppletWidgetRegistry implements IAppletWidgetRegistry {
6
7
  constructor(launcher: IFailsLauncherInfo);
package/lib/index.js CHANGED
@@ -138,19 +138,19 @@ function activateWidgetInterceptor(app, notebookTracker, rendermimeRegistry, lau
138
138
  mimetypes.forEach(mime => {
139
139
  const factory = rmRegistry.getFactory(mime);
140
140
  if (!factory) {
141
- console.log('Plotly seems to be not installed! So I can not add an interceptor');
141
+ console.warn('Plotly seems to be not installed! So I can not add an interceptor');
142
142
  return;
143
143
  }
144
144
  // ok, lets add an interceptor
145
145
  const createRendererOld = factory.createRenderer;
146
146
  factory.createRenderer = function (options) {
147
147
  const renderer = createRendererOld(options);
148
- console.log('intercepted renderer', mime, renderer, renderer.node);
148
+ // console.log('intercepted renderer', mime, renderer, renderer.node);
149
149
  // we have also the replace renderModel
150
150
  const renderModelOld = renderer.renderModel.bind(renderer);
151
151
  renderer.renderModel = async (model) => {
152
152
  let result = await renderModelOld(model);
153
- console.log('intercepted renderer model', model);
153
+ // console.log('intercepted renderer model', model);
154
154
  if (!renderer.hasGraphElement()) {
155
155
  result = await renderer.createGraph(renderer === null || renderer === void 0 ? void 0 : renderer._model);
156
156
  }
@@ -165,7 +165,7 @@ function activateWidgetInterceptor(app, notebookTracker, rendermimeRegistry, lau
165
165
  ];
166
166
  messages.forEach(mess => {
167
167
  renderer.node.on('plotly_' + mess, (data) => {
168
- var _a, _b;
168
+ var _a;
169
169
  const path = (_a = model.metadata) === null || _a === void 0 ? void 0 : _a.appPath;
170
170
  if (path) {
171
171
  wRegistry.dispatchMessage({
@@ -174,22 +174,20 @@ function activateWidgetInterceptor(app, notebookTracker, rendermimeRegistry, lau
174
174
  state: data
175
175
  });
176
176
  }
177
- console.log('plotly', mess, data, (_b = model.metadata) === null || _b === void 0 ? void 0 : _b.appPath, path);
177
+ /*
178
+ console.log(
179
+ 'plotly',
180
+ mess,
181
+ data,
182
+ model.metadata?.appPath,
183
+ path
184
+ ); */
178
185
  });
179
186
  });
180
187
  }
181
- console.log('renderer layout rM',
182
- // @ts-expect-error plotly
183
- renderer.node.layout,
184
- // @ts-expect-error plotly
185
- !!renderer.node.on, renderer);
186
- //@ts-expect-error result is different from void
187
- console.log('renderer result', result, !!(result === null || result === void 0 ? void 0 : result.on));
188
188
  return result;
189
189
  };
190
190
  // special code for plotly
191
- // @ts-expect-error plotly
192
- console.log('renderer layout', renderer.node.layout);
193
191
  /* if (!(renderer as any).hasGraphElement()) {
194
192
  (renderer as any).createGraph((renderer as any)['_model]']);
195
193
  } */
@@ -332,9 +330,6 @@ function activateWidgetInterceptor(app, notebookTracker, rendermimeRegistry, lau
332
330
  // eslint-disable-next-line no-constant-condition
333
331
  mimebundle['application/vnd.plotly.v1+json'] &&
334
332
  false) {
335
- const bundle = mimebundle['application/vnd.plotly.v1+json'];
336
- console.log('Plotly bundle', bundle);
337
- console.log('plotly cell', cell);
338
333
  if (result.metadata.appPath !== appPath) {
339
334
  result.metadata.appPath = appPath;
340
335
  addPath = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fails-components/jupyter-interceptor",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "A collections of plugins intercepting kernel messages and other message, to steer outputs remotely",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -34,8 +34,8 @@
34
34
  "scripts": {
35
35
  "build": "jlpm build:lib && jlpm build:labextension:dev",
36
36
  "build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension",
37
- "build:labextension": "jupyter labextension build .",
38
- "build:labextension:dev": "jupyter labextension build --development True .",
37
+ "build:labextension": "jupyter-builder build .",
38
+ "build:labextension:dev": "jupyter-builder build --development True .",
39
39
  "build:lib": "tsc --sourceMap",
40
40
  "build:lib:prod": "tsc",
41
41
  "clean": "jlpm clean:lib",
@@ -60,33 +60,34 @@
60
60
  "watch:labextension": "jupyter labextension watch ."
61
61
  },
62
62
  "dependencies": {
63
- "@fails-components/jupyter-launcher": "^0.0.5",
63
+ "@fails-components/jupyter-launcher": "^0.0.6",
64
64
  "@jupyter-widgets/base": "^6.0.11",
65
65
  "@jupyter-widgets/jupyterlab-manager": "^5.0.15",
66
- "@jupyter/ydoc": "^3.1.0",
67
- "@jupyterlab/application": "^4.5.1",
68
- "@jupyterlab/cells": "^4.5.1",
69
- "@jupyterlab/nbformat": "^4.5.1",
70
- "@jupyterlab/notebook": "^4.5.1",
71
- "@jupyterlab/rendermime": "^4.5.1",
72
- "@jupyterlab/services": "^7.5.1",
73
- "@jupyterlite/application-extension": "^0.7.1",
66
+ "@jupyter/ydoc": "^4.0.0",
67
+ "@jupyterlab/application": "~4.6.0",
68
+ "@jupyterlab/cells": "~4.6.0",
69
+ "@jupyterlab/nbformat": "~4.6.0",
70
+ "@jupyterlab/notebook": "~4.6.0",
71
+ "@jupyterlab/rendermime": "~4.6.0",
72
+ "@jupyterlab/services": "^7.6.0",
73
+ "@jupyterlite/application-extension": "^0.8.1",
74
74
  "@lumino/coreutils": "^2.2.2",
75
75
  "@lumino/signaling": "^2.1.5"
76
76
  },
77
77
  "devDependencies": {
78
- "@jupyterlab/builder": "^4.5.1",
79
- "@jupyterlab/testutils": "^4.5.1",
78
+ "@jupyter/builder": "~1.0.0",
79
+ "@jupyter/eslint-plugin": "0.0.5",
80
+ "@jupyterlab/testutils": "~4.6.0",
81
+ "@stylistic/eslint-plugin": "^5.10.0",
80
82
  "@types/jest": "^29.2.0",
81
83
  "@types/json-schema": "^7.0.11",
82
84
  "@types/react": "^18.0.26",
83
85
  "@types/react-addons-linked-state-mixin": "^0.14.22",
84
- "@typescript-eslint/eslint-plugin": "^6.1.0",
85
- "@typescript-eslint/parser": "^6.1.0",
86
86
  "css-loader": "^6.7.1",
87
- "eslint": "^8.36.0",
88
- "eslint-config-prettier": "^8.8.0",
89
- "eslint-plugin-prettier": "^5.0.0",
87
+ "eslint": "^9.39.2",
88
+ "eslint-config-prettier": "^9.1.0",
89
+ "eslint-plugin-prettier": "^5.1.3",
90
+ "eslint-plugin-react": "^7.37.0",
90
91
  "jest": "^29.2.0",
91
92
  "npm-run-all": "^4.1.5",
92
93
  "prettier": "^3.0.0",
@@ -98,7 +99,8 @@
98
99
  "stylelint-config-standard": "^34.0.0",
99
100
  "stylelint-csstree-validator": "^3.0.0",
100
101
  "stylelint-prettier": "^4.0.0",
101
- "typescript": "~5.0.2",
102
+ "typescript": "~5.9.3",
103
+ "typescript-eslint": "^8.0.0",
102
104
  "yjs": "^13.5.0"
103
105
  },
104
106
  "sideEffects": [
@@ -127,8 +129,7 @@
127
129
  "coverage",
128
130
  "**/*.d.ts",
129
131
  "tests",
130
- "**/__tests__",
131
- "ui-tests"
132
+ "**/__tests__"
132
133
  ],
133
134
  "eslintConfig": {
134
135
  "extends": [
package/src/index.ts CHANGED
@@ -1,32 +1,26 @@
1
- import {
2
- INotebookTracker,
3
- NotebookPanel,
4
- INotebookModel
5
- } from '@jupyterlab/notebook';
6
- import {
1
+ import type { NotebookPanel, INotebookModel } from '@jupyterlab/notebook';
2
+ import { INotebookTracker } from '@jupyterlab/notebook';
3
+ import type {
7
4
  JupyterFrontEnd,
8
5
  JupyterFrontEndPlugin
9
6
  } from '@jupyterlab/application';
10
- import { IWidgetManager, WidgetModel } from '@jupyter-widgets/base';
11
- import {
7
+ import type { IWidgetManager, WidgetModel } from '@jupyter-widgets/base';
8
+ import type {
12
9
  IExecuteResult,
13
10
  IDisplayData,
14
11
  IDisplayUpdate
15
12
  } from '@jupyterlab/nbformat';
16
- import {
17
- IRenderMime,
18
- IRenderMimeRegistry,
19
- RenderMimeRegistry
20
- } from '@jupyterlab/rendermime';
21
- import { ICellModel } from '@jupyterlab/cells';
22
- import { ISharedCodeCell } from '@jupyter/ydoc';
23
- import { JSONObject, PromiseDelegate } from '@lumino/coreutils';
24
- import { Kernel /*, KernelMessage */ } from '@jupyterlab/services';
25
- import {
13
+ import type { IRenderMime, RenderMimeRegistry } from '@jupyterlab/rendermime';
14
+ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
15
+ import type { ICellModel } from '@jupyterlab/cells';
16
+ import type { ISharedCodeCell } from '@jupyter/ydoc';
17
+ import type { JSONObject, PromiseDelegate } from '@lumino/coreutils';
18
+ import type { Kernel /*, KernelMessage */ } from '@jupyterlab/services';
19
+ import type {
26
20
  IFailsInterceptorUpdateMessage,
27
- IAppletWidgetRegistry,
28
- IFailsLauncherInfo
21
+ IAppletWidgetRegistry
29
22
  } from '@fails-components/jupyter-launcher';
23
+ import { IFailsLauncherInfo } from '@fails-components/jupyter-launcher';
30
24
  import { Signal } from '@lumino/signaling';
31
25
  import { IFailsInterceptor } from './tokens';
32
26
 
@@ -200,7 +194,7 @@ function activateWidgetInterceptor(
200
194
  mime
201
195
  ) as IRenderMime.IRendererFactory;
202
196
  if (!factory) {
203
- console.log(
197
+ console.warn(
204
198
  'Plotly seems to be not installed! So I can not add an interceptor'
205
199
  );
206
200
  return;
@@ -211,12 +205,12 @@ function activateWidgetInterceptor(
211
205
  options: IRenderMime.IRendererOptions
212
206
  ) {
213
207
  const renderer = createRendererOld(options);
214
- console.log('intercepted renderer', mime, renderer, renderer.node);
208
+ // console.log('intercepted renderer', mime, renderer, renderer.node);
215
209
  // we have also the replace renderModel
216
210
  const renderModelOld = renderer.renderModel.bind(renderer);
217
211
  renderer.renderModel = async (model: IRenderMime.IMimeModel) => {
218
212
  let result = await renderModelOld(model);
219
- console.log('intercepted renderer model', model);
213
+ // console.log('intercepted renderer model', model);
220
214
  if (!(<any>renderer).hasGraphElement()) {
221
215
  result = await (renderer as any).createGraph(
222
216
  (renderer as any)?._model
@@ -241,32 +235,21 @@ function activateWidgetInterceptor(
241
235
  state: data
242
236
  });
243
237
  }
238
+ /*
244
239
  console.log(
245
240
  'plotly',
246
241
  mess,
247
242
  data,
248
243
  model.metadata?.appPath,
249
244
  path
250
- );
245
+ ); */
251
246
  });
252
247
  });
253
248
  }
254
- console.log(
255
- 'renderer layout rM',
256
- // @ts-expect-error plotly
257
- renderer.node.layout,
258
- // @ts-expect-error plotly
259
- !!renderer.node.on,
260
- renderer
261
- );
262
- //@ts-expect-error result is different from void
263
- console.log('renderer result', result, !!result?.on);
264
249
 
265
250
  return result;
266
251
  };
267
252
  // special code for plotly
268
- // @ts-expect-error plotly
269
- console.log('renderer layout', renderer.node.layout);
270
253
  /* if (!(renderer as any).hasGraphElement()) {
271
254
  (renderer as any).createGraph((renderer as any)['_model]']);
272
255
  } */
@@ -412,9 +395,7 @@ function activateWidgetInterceptor(
412
395
  case 'execute_result':
413
396
  {
414
397
  const result = output as
415
- | IExecuteResult
416
- | IDisplayUpdate
417
- | IDisplayData;
398
+ IExecuteResult | IDisplayUpdate | IDisplayData;
418
399
 
419
400
  // console.log('Mimebundle', result.data); // to do parse this also
420
401
  // console.log('Metadata', result.metadata);
@@ -433,10 +414,6 @@ function activateWidgetInterceptor(
433
414
  mimebundle['application/vnd.plotly.v1+json'] &&
434
415
  false
435
416
  ) {
436
- const bundle =
437
- mimebundle['application/vnd.plotly.v1+json'];
438
- console.log('Plotly bundle', bundle);
439
- console.log('plotly cell', cell);
440
417
  if ((<any>result.metadata).appPath !== appPath) {
441
418
  (<any>result.metadata).appPath = appPath;
442
419
  addPath = true;