@jupyterlite/session 0.1.0-beta.11 → 0.1.0-beta.12

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/sessions.d.ts CHANGED
@@ -24,7 +24,9 @@ export declare class Sessions implements ISessions {
24
24
  /**
25
25
  * Path an existing session.
26
26
  * This can be used to rename a session.
27
- * TODO: read path and name
27
+ *
28
+ * - path updates session to track renamed paths
29
+ * - kernel.name starts a new kernel with a given kernelspec
28
30
  *
29
31
  * @param options The options to patch the session.
30
32
  */
package/lib/sessions.js CHANGED
@@ -36,12 +36,14 @@ export class Sessions {
36
36
  /**
37
37
  * Path an existing session.
38
38
  * This can be used to rename a session.
39
- * TODO: read path and name
39
+ *
40
+ * - path updates session to track renamed paths
41
+ * - kernel.name starts a new kernel with a given kernelspec
40
42
  *
41
43
  * @param options The options to patch the session.
42
44
  */
43
45
  async patch(options) {
44
- const { id, path, name } = options;
46
+ const { id, path, name, kernel } = options;
45
47
  const index = this._sessions.findIndex((s) => s.id === id);
46
48
  const session = this._sessions[index];
47
49
  if (!session) {
@@ -52,6 +54,25 @@ export class Sessions {
52
54
  path: path !== null && path !== void 0 ? path : session.path,
53
55
  name: name !== null && name !== void 0 ? name : session.name,
54
56
  };
57
+ if (kernel) {
58
+ // Kernel id takes precedence over name.
59
+ if (kernel.id) {
60
+ const session = this._sessions.find((session) => { var _a; return ((_a = session.kernel) === null || _a === void 0 ? void 0 : _a.id) === (kernel === null || kernel === void 0 ? void 0 : kernel.id); });
61
+ if (session) {
62
+ patched.kernel = session.kernel;
63
+ }
64
+ }
65
+ else if (kernel.name) {
66
+ const newKernel = await this._kernels.startNew({
67
+ id: UUID.uuid4(),
68
+ name: kernel.name,
69
+ location: PathExt.dirname(patched.path),
70
+ });
71
+ if (newKernel) {
72
+ patched.kernel = newKernel;
73
+ }
74
+ }
75
+ }
55
76
  this._sessions[index] = patched;
56
77
  return patched;
57
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlite/session",
3
- "version": "0.1.0-beta.11",
3
+ "version": "0.1.0-beta.12",
4
4
  "description": "JupyterLite - Session",
5
5
  "homepage": "https://github.com/jupyterlite/jupyterlite",
6
6
  "bugs": {
@@ -42,16 +42,16 @@
42
42
  "watch": "tsc -b --watch"
43
43
  },
44
44
  "dependencies": {
45
- "@jupyterlab/coreutils": "^5.4.2",
46
- "@jupyterlab/services": "~6.4.3",
47
- "@jupyterlite/kernel": "^0.1.0-beta.11",
45
+ "@jupyterlab/coreutils": "~5.4.5",
46
+ "@jupyterlab/services": "~6.4.5",
47
+ "@jupyterlite/kernel": "^0.1.0-beta.12",
48
48
  "@lumino/algorithm": "^1.9.1",
49
49
  "@lumino/coreutils": "^1.12.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@babel/core": "^7.11.6",
53
53
  "@babel/preset-env": "^7.12.1",
54
- "@jupyterlab/testutils": "~3.4.3",
54
+ "@jupyterlab/testutils": "~3.4.5",
55
55
  "@types/jest": "^26.0.10",
56
56
  "jest": "^26.4.2",
57
57
  "rimraf": "~3.0.0",