jupyterpack 0.2.0 → 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.
@@ -19,9 +19,12 @@ export class CommManager {
19
19
  }
20
20
  const params = url.searchParams.toString();
21
21
  const pathAfterExtensionName = urlPath.split('/jupyterpack/static')[1];
22
- const pathList = pathAfterExtensionName.split('/').filter(Boolean);
23
- const instanceId = pathList[0];
24
- const kernelClientId = pathList[2];
22
+ const pathList = pathAfterExtensionName === null || pathAfterExtensionName === void 0 ? void 0 : pathAfterExtensionName.split('/').filter(Boolean);
23
+ const instanceId = pathList === null || pathList === void 0 ? void 0 : pathList[0];
24
+ const kernelClientId = pathList === null || pathList === void 0 ? void 0 : pathList[2];
25
+ if (!instanceId || !kernelClientId) {
26
+ return await fetch(url, { method });
27
+ }
25
28
  const comm = this._commIds.get(instanceId);
26
29
  if (!comm) {
27
30
  throw new Error('Missing comm');
@@ -32,7 +32,10 @@ async function onFetch(event) {
32
32
  if (url.endsWith('__jupyterpack__/ping.html')) {
33
33
  return;
34
34
  }
35
- event.respondWith(COMM_MANAGER.generateResponse(event.request));
35
+ if (url.includes('extensions/jupyterpack/static')) {
36
+ return event.respondWith(COMM_MANAGER.generateResponse(event.request));
37
+ }
38
+ return;
36
39
  }
37
40
  function onMessage(msg) {
38
41
  const { type, data } = msg.data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jupyterpack",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A JupyterLab extension for serving web app.",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -19,11 +19,15 @@ export class CommManager {
19
19
  }
20
20
  }
21
21
  const params = url.searchParams.toString();
22
- const pathAfterExtensionName = urlPath.split('/jupyterpack/static')[1];
23
- const pathList = pathAfterExtensionName.split('/').filter(Boolean);
24
- const instanceId = pathList[0];
25
- const kernelClientId = pathList[2];
26
-
22
+ const pathAfterExtensionName: string | undefined = urlPath.split(
23
+ '/jupyterpack/static'
24
+ )[1];
25
+ const pathList = pathAfterExtensionName?.split('/').filter(Boolean);
26
+ const instanceId = pathList?.[0];
27
+ const kernelClientId = pathList?.[2];
28
+ if (!instanceId || !kernelClientId) {
29
+ return await fetch(url, { method });
30
+ }
27
31
  const comm = this._commIds.get(instanceId);
28
32
  if (!comm) {
29
33
  throw new Error('Missing comm');
@@ -36,7 +36,10 @@ async function onFetch(event: FetchEvent): Promise<void> {
36
36
  if (url.endsWith('__jupyterpack__/ping.html')) {
37
37
  return;
38
38
  }
39
- event.respondWith(COMM_MANAGER.generateResponse(event.request));
39
+ if (url.includes('extensions/jupyterpack/static')) {
40
+ return event.respondWith(COMM_MANAGER.generateResponse(event.request));
41
+ }
42
+ return;
40
43
  }
41
44
 
42
45
  function onMessage(