@jupyterlite/kernel 0.1.0-beta.10 → 0.1.0-beta.11

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.
@@ -8,6 +8,10 @@ export declare class KernelSpecs implements IKernelSpecs {
8
8
  * Get the kernel specs.
9
9
  */
10
10
  get specs(): KernelSpec.ISpecModels | null;
11
+ /**
12
+ * Get the default kernel name.
13
+ */
14
+ get defaultKernelName(): string;
11
15
  /**
12
16
  * Get the kernel factories for the current kernels.
13
17
  */
@@ -1,3 +1,5 @@
1
+ import { PageConfig } from '@jupyterlab/coreutils';
2
+ import { FALLBACK_KERNEL } from './tokens';
1
3
  /**
2
4
  * A class to handle requests to /api/kernelspecs
3
5
  */
@@ -14,10 +16,22 @@ export class KernelSpecs {
14
16
  return null;
15
17
  }
16
18
  return {
17
- default: 'python',
19
+ default: this.defaultKernelName,
18
20
  kernelspecs: Object.fromEntries(this._specs),
19
21
  };
20
22
  }
23
+ /**
24
+ * Get the default kernel name.
25
+ */
26
+ get defaultKernelName() {
27
+ let defaultKernelName = PageConfig.getOption('defaultKernelName');
28
+ if (!defaultKernelName && this._specs.size) {
29
+ const keys = Array.from(this._specs.keys());
30
+ keys.sort();
31
+ defaultKernelName = keys[0];
32
+ }
33
+ return defaultKernelName || FALLBACK_KERNEL;
34
+ }
21
35
  /**
22
36
  * Get the kernel factories for the current kernels.
23
37
  */
package/lib/tokens.d.ts CHANGED
@@ -8,6 +8,10 @@ import { KernelSpecs } from './kernelspecs';
8
8
  * The token for the kernels service.
9
9
  */
10
10
  export declare const IKernels: Token<IKernels>;
11
+ /**
12
+ * The kernel name of last resort.
13
+ */
14
+ export declare const FALLBACK_KERNEL = "javascript";
11
15
  /**
12
16
  * An interface for the Kernels service.
13
17
  */
@@ -100,6 +104,10 @@ export interface IKernelSpecs {
100
104
  * Get the kernel specs.
101
105
  */
102
106
  readonly specs: KernelSpec.ISpecModels | null;
107
+ /**
108
+ * Get the default kernel name.
109
+ */
110
+ readonly defaultKernelName: string;
103
111
  /**
104
112
  * Get the kernel factories for the current kernels.
105
113
  */
package/lib/tokens.js CHANGED
@@ -5,6 +5,10 @@ import { Token } from '@lumino/coreutils';
5
5
  * The token for the kernels service.
6
6
  */
7
7
  export const IKernels = new Token('@jupyterlite/kernel:IKernels');
8
+ /**
9
+ * The kernel name of last resort.
10
+ */
11
+ export const FALLBACK_KERNEL = 'javascript';
8
12
  /**
9
13
  * The token for the kernel spec service.
10
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlite/kernel",
3
- "version": "0.1.0-beta.10",
3
+ "version": "0.1.0-beta.11",
4
4
  "description": "JupyterLite - Kernel",
5
5
  "homepage": "https://github.com/jupyterlite/jupyterlite",
6
6
  "bugs": {
@@ -42,6 +42,7 @@
42
42
  "watch": "tsc -b --watch"
43
43
  },
44
44
  "dependencies": {
45
+ "@jupyterlab/coreutils": "~5.4.3",
45
46
  "@jupyterlab/observables": "~4.4.3",
46
47
  "@jupyterlab/services": "~6.4.3",
47
48
  "@lumino/coreutils": "^1.12.0",