@difizen/libro-kernel 0.0.2-alpha.0

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.
Files changed (188) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/es/basemanager.d.ts +94 -0
  4. package/es/basemanager.d.ts.map +1 -0
  5. package/es/basemanager.js +110 -0
  6. package/es/contents/contents-drive.d.ts +189 -0
  7. package/es/contents/contents-drive.d.ts.map +1 -0
  8. package/es/contents/contents-drive.js +792 -0
  9. package/es/contents/contents-manager.d.ts +229 -0
  10. package/es/contents/contents-manager.d.ts.map +1 -0
  11. package/es/contents/contents-manager.js +551 -0
  12. package/es/contents/contents-module.d.ts +3 -0
  13. package/es/contents/contents-module.d.ts.map +1 -0
  14. package/es/contents/contents-module.js +4 -0
  15. package/es/contents/contents-protocol.d.ts +487 -0
  16. package/es/contents/contents-protocol.d.ts.map +1 -0
  17. package/es/contents/contents-protocol.js +1 -0
  18. package/es/contents/index.d.ts +6 -0
  19. package/es/contents/index.d.ts.map +1 -0
  20. package/es/contents/index.js +5 -0
  21. package/es/contents/validate.d.ts +10 -0
  22. package/es/contents/validate.d.ts.map +1 -0
  23. package/es/contents/validate.js +22 -0
  24. package/es/index.d.ts +10 -0
  25. package/es/index.d.ts.map +1 -0
  26. package/es/index.js +9 -0
  27. package/es/index.less +0 -0
  28. package/es/kernel/comm.d.ts +92 -0
  29. package/es/kernel/comm.d.ts.map +1 -0
  30. package/es/kernel/comm.js +216 -0
  31. package/es/kernel/future.d.ts +178 -0
  32. package/es/kernel/future.d.ts.map +1 -0
  33. package/es/kernel/future.js +587 -0
  34. package/es/kernel/index.d.ts +8 -0
  35. package/es/kernel/index.d.ts.map +1 -0
  36. package/es/kernel/index.js +8 -0
  37. package/es/kernel/kernel-connection.d.ts +550 -0
  38. package/es/kernel/kernel-connection.d.ts.map +1 -0
  39. package/es/kernel/kernel-connection.js +1957 -0
  40. package/es/kernel/kernel-module.d.ts +3 -0
  41. package/es/kernel/kernel-module.d.ts.map +1 -0
  42. package/es/kernel/kernel-module.js +32 -0
  43. package/es/kernel/libro-kernel-manager.d.ts +69 -0
  44. package/es/kernel/libro-kernel-manager.d.ts.map +1 -0
  45. package/es/kernel/libro-kernel-manager.js +349 -0
  46. package/es/kernel/libro-kernel-protocol.d.ts +675 -0
  47. package/es/kernel/libro-kernel-protocol.d.ts.map +1 -0
  48. package/es/kernel/libro-kernel-protocol.js +60 -0
  49. package/es/kernel/libro-kernel-utils.d.ts +95 -0
  50. package/es/kernel/libro-kernel-utils.d.ts.map +1 -0
  51. package/es/kernel/libro-kernel-utils.js +130 -0
  52. package/es/kernel/libro-kernel.d.ts +14 -0
  53. package/es/kernel/libro-kernel.d.ts.map +1 -0
  54. package/es/kernel/libro-kernel.js +54 -0
  55. package/es/kernel/messages.d.ts +845 -0
  56. package/es/kernel/messages.d.ts.map +1 -0
  57. package/es/kernel/messages.js +457 -0
  58. package/es/kernel/restapi.d.ts +78 -0
  59. package/es/kernel/restapi.d.ts.map +1 -0
  60. package/es/kernel/restapi.js +367 -0
  61. package/es/kernel/serialize.d.ts +10 -0
  62. package/es/kernel/serialize.d.ts.map +1 -0
  63. package/es/kernel/serialize.js +214 -0
  64. package/es/kernel/validate.d.ts +15 -0
  65. package/es/kernel/validate.d.ts.map +1 -0
  66. package/es/kernel/validate.js +125 -0
  67. package/es/kernelspec/index.d.ts +5 -0
  68. package/es/kernelspec/index.d.ts.map +1 -0
  69. package/es/kernelspec/index.js +4 -0
  70. package/es/kernelspec/kernelspec-module.d.ts +3 -0
  71. package/es/kernelspec/kernelspec-module.d.ts.map +1 -0
  72. package/es/kernelspec/kernelspec-module.js +4 -0
  73. package/es/kernelspec/kernelspec.d.ts +33 -0
  74. package/es/kernelspec/kernelspec.d.ts.map +1 -0
  75. package/es/kernelspec/kernelspec.js +1 -0
  76. package/es/kernelspec/manager.d.ts +81 -0
  77. package/es/kernelspec/manager.d.ts.map +1 -0
  78. package/es/kernelspec/manager.js +248 -0
  79. package/es/kernelspec/restapi.d.ts +71 -0
  80. package/es/kernelspec/restapi.d.ts.map +1 -0
  81. package/es/kernelspec/restapi.js +107 -0
  82. package/es/kernelspec/validate.d.ts +10 -0
  83. package/es/kernelspec/validate.d.ts.map +1 -0
  84. package/es/kernelspec/validate.js +69 -0
  85. package/es/libro-kernel-connection-manager.d.ts +19 -0
  86. package/es/libro-kernel-connection-manager.d.ts.map +1 -0
  87. package/es/libro-kernel-connection-manager.js +142 -0
  88. package/es/module.d.ts +3 -0
  89. package/es/module.d.ts.map +1 -0
  90. package/es/module.js +9 -0
  91. package/es/page-config.d.ts +36 -0
  92. package/es/page-config.d.ts.map +1 -0
  93. package/es/page-config.js +129 -0
  94. package/es/protocol.d.ts +13 -0
  95. package/es/protocol.d.ts.map +1 -0
  96. package/es/protocol.js +8 -0
  97. package/es/server/connection-error.d.ts +36 -0
  98. package/es/server/connection-error.d.ts.map +1 -0
  99. package/es/server/connection-error.js +109 -0
  100. package/es/server/index.d.ts +6 -0
  101. package/es/server/index.d.ts.map +1 -0
  102. package/es/server/index.js +5 -0
  103. package/es/server/server-connection-protocol.d.ts +49 -0
  104. package/es/server/server-connection-protocol.d.ts.map +1 -0
  105. package/es/server/server-connection-protocol.js +0 -0
  106. package/es/server/server-connection.d.ts +25 -0
  107. package/es/server/server-connection.d.ts.map +1 -0
  108. package/es/server/server-connection.js +159 -0
  109. package/es/server/server-manager.d.ts +22 -0
  110. package/es/server/server-manager.d.ts.map +1 -0
  111. package/es/server/server-manager.js +163 -0
  112. package/es/server/server-module.d.ts +3 -0
  113. package/es/server/server-module.d.ts.map +1 -0
  114. package/es/server/server-module.js +4 -0
  115. package/es/session/index.d.ts +5 -0
  116. package/es/session/index.d.ts.map +1 -0
  117. package/es/session/index.js +4 -0
  118. package/es/session/libro-session-manager.d.ts +71 -0
  119. package/es/session/libro-session-manager.d.ts.map +1 -0
  120. package/es/session/libro-session-manager.js +539 -0
  121. package/es/session/libro-session-protocol.d.ts +50 -0
  122. package/es/session/libro-session-protocol.d.ts.map +1 -0
  123. package/es/session/libro-session-protocol.js +21 -0
  124. package/es/session/libro-session.d.ts +12 -0
  125. package/es/session/libro-session.d.ts.map +1 -0
  126. package/es/session/libro-session.js +19 -0
  127. package/es/session/restapi.d.ts +28 -0
  128. package/es/session/restapi.d.ts.map +1 -0
  129. package/es/session/restapi.js +214 -0
  130. package/es/session/session-module.d.ts +3 -0
  131. package/es/session/session-module.d.ts.map +1 -0
  132. package/es/session/session-module.js +18 -0
  133. package/es/session/validate.d.ts +14 -0
  134. package/es/session/validate.d.ts.map +1 -0
  135. package/es/session/validate.js +37 -0
  136. package/es/utils.d.ts +4 -0
  137. package/es/utils.d.ts.map +1 -0
  138. package/es/utils.js +29 -0
  139. package/es/validate-property.d.ts +2 -0
  140. package/es/validate-property.d.ts.map +1 -0
  141. package/es/validate-property.js +35 -0
  142. package/package.json +62 -0
  143. package/src/basemanager.ts +133 -0
  144. package/src/contents/contents-drive.ts +495 -0
  145. package/src/contents/contents-manager.ts +465 -0
  146. package/src/contents/contents-module.ts +6 -0
  147. package/src/contents/contents-protocol.ts +604 -0
  148. package/src/contents/index.ts +5 -0
  149. package/src/contents/validate.ts +29 -0
  150. package/src/index.tsx +9 -0
  151. package/src/kernel/comm.ts +220 -0
  152. package/src/kernel/future.ts +474 -0
  153. package/src/kernel/index.ts +7 -0
  154. package/src/kernel/kernel-connection.ts +1770 -0
  155. package/src/kernel/kernel-module.ts +50 -0
  156. package/src/kernel/libro-kernel-manager.ts +199 -0
  157. package/src/kernel/libro-kernel-protocol.ts +858 -0
  158. package/src/kernel/libro-kernel-utils.ts +152 -0
  159. package/src/kernel/libro-kernel.ts +39 -0
  160. package/src/kernel/messages.ts +1104 -0
  161. package/src/kernel/restapi.ts +183 -0
  162. package/src/kernel/serialize.ts +262 -0
  163. package/src/kernel/validate.ts +101 -0
  164. package/src/kernelspec/index.ts +5 -0
  165. package/src/kernelspec/kernelspec-module.ts +9 -0
  166. package/src/kernelspec/kernelspec.ts +37 -0
  167. package/src/kernelspec/manager.ts +173 -0
  168. package/src/kernelspec/restapi.ts +104 -0
  169. package/src/kernelspec/validate.ts +80 -0
  170. package/src/libro-kernel-connection-manager.ts +73 -0
  171. package/src/module.ts +19 -0
  172. package/src/page-config.ts +106 -0
  173. package/src/protocol.ts +24 -0
  174. package/src/server/connection-error.ts +60 -0
  175. package/src/server/index.ts +5 -0
  176. package/src/server/server-connection-protocol.ts +57 -0
  177. package/src/server/server-connection.ts +144 -0
  178. package/src/server/server-manager.ts +76 -0
  179. package/src/server/server-module.ts +9 -0
  180. package/src/session/index.ts +4 -0
  181. package/src/session/libro-session-manager.ts +377 -0
  182. package/src/session/libro-session-protocol.ts +61 -0
  183. package/src/session/libro-session.ts +33 -0
  184. package/src/session/restapi.ts +126 -0
  185. package/src/session/session-module.ts +26 -0
  186. package/src/session/validate.ts +39 -0
  187. package/src/utils.ts +28 -0
  188. package/src/validate-property.ts +38 -0
@@ -0,0 +1,125 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
+ import { validateProperty } from "../validate-property.js";
8
+ /**
9
+ * Required fields for `IKernelHeader`.
10
+ */
11
+ var HEADER_FIELDS = ['username', 'version', 'session', 'msg_id', 'msg_type'];
12
+
13
+ /**
14
+ * Required fields and types for contents of various types of `kernel.IMessage`
15
+ * messages on the iopub channel.
16
+ */
17
+ var IOPUB_CONTENT_FIELDS = {
18
+ stream: {
19
+ name: 'string',
20
+ text: 'string'
21
+ },
22
+ display_data: {
23
+ data: 'object',
24
+ metadata: 'object'
25
+ },
26
+ execute_input: {
27
+ code: 'string',
28
+ execution_count: 'number'
29
+ },
30
+ execute_result: {
31
+ execution_count: 'number',
32
+ data: 'object',
33
+ metadata: 'object'
34
+ },
35
+ error: {
36
+ ename: 'string',
37
+ evalue: 'string',
38
+ traceback: 'object'
39
+ },
40
+ status: {
41
+ execution_state: ['string', ['starting', 'idle', 'busy', 'restarting', 'dead']]
42
+ },
43
+ clear_output: {
44
+ wait: 'boolean'
45
+ },
46
+ comm_open: {
47
+ comm_id: 'string',
48
+ target_name: 'string',
49
+ data: 'object'
50
+ },
51
+ comm_msg: {
52
+ comm_id: 'string',
53
+ data: 'object'
54
+ },
55
+ comm_close: {
56
+ comm_id: 'string'
57
+ },
58
+ shutdown_reply: {
59
+ restart: 'boolean'
60
+ } // Emitted by the IPython kernel.
61
+ };
62
+
63
+ /**
64
+ * Validate the header of a kernel message.
65
+ */
66
+ function validateHeader(header) {
67
+ for (var i = 0; i < HEADER_FIELDS.length; i++) {
68
+ validateProperty(header, HEADER_FIELDS[i], 'string');
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Validate a kernel message object.
74
+ */
75
+ export function validateMessage(msg) {
76
+ validateProperty(msg, 'metadata', 'object');
77
+ validateProperty(msg, 'content', 'object');
78
+ validateProperty(msg, 'channel', 'string');
79
+ validateHeader(msg.header);
80
+ if (msg.channel === 'iopub') {
81
+ validateIOPubContent(msg);
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Validate content an kernel message on the iopub channel.
87
+ */
88
+ function validateIOPubContent(msg) {
89
+ if (msg.channel === 'iopub') {
90
+ var fields = IOPUB_CONTENT_FIELDS[msg.header.msg_type];
91
+ // Check for unknown message type.
92
+ if (fields === undefined) {
93
+ return;
94
+ }
95
+ var names = Object.keys(fields);
96
+ var content = msg.content;
97
+ for (var i = 0; i < names.length; i++) {
98
+ var args = fields[names[i]];
99
+ if (!Array.isArray(args)) {
100
+ args = [args];
101
+ }
102
+ validateProperty.apply(void 0, [content, names[i]].concat(_toConsumableArray(args)));
103
+ }
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Validate a `Kernel.KernelMeta` object.
109
+ */
110
+ export function validateModel(model) {
111
+ validateProperty(model, 'name', 'string');
112
+ validateProperty(model, 'id', 'string');
113
+ }
114
+
115
+ /**
116
+ * Validate an array of `KernelMeta` objects.
117
+ */
118
+ export function validateModels(models) {
119
+ if (!Array.isArray(models)) {
120
+ throw new Error('Invalid kernel list');
121
+ }
122
+ models.forEach(function (d) {
123
+ return validateModel(d);
124
+ });
125
+ }
@@ -0,0 +1,5 @@
1
+ export * from './kernelspec.js';
2
+ export * from './restapi.js';
3
+ export * from './manager.js';
4
+ export * from './kernelspec-module.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kernelspec/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAE7B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./kernelspec.js";
2
+ export * from "./restapi.js";
3
+ export * from "./manager.js";
4
+ export * from "./kernelspec-module.js";
@@ -0,0 +1,3 @@
1
+ import { ManaModule } from '@difizen/mana-app';
2
+ export declare const LibroKernelSpecModule: ManaModule;
3
+ //# sourceMappingURL=kernelspec-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernelspec-module.d.ts","sourceRoot":"","sources":["../../src/kernelspec/kernelspec-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,eAAO,MAAM,qBAAqB,YAGjC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ManaModule } from '@difizen/mana-app';
2
+ import { KernelSpecManager } from "./manager.js";
3
+ import { KernelSpecRestAPI } from "./restapi.js";
4
+ export var LibroKernelSpecModule = ManaModule.create().register(KernelSpecManager, KernelSpecRestAPI);
@@ -0,0 +1,33 @@
1
+ import type { Event as ManaEvent } from '@difizen/mana-app';
2
+ import type { IManager as IBaseManager } from '../basemanager.js';
3
+ import type { ISpecModels } from './restapi.js';
4
+ /**
5
+ * Object which manages kernel instances for a given base url.
6
+ *
7
+ * #### Notes
8
+ * The manager is responsible for maintaining the state of kernel specs.
9
+ */
10
+ export interface IManager extends IBaseManager {
11
+ /**
12
+ * A signal emitted when the kernel specs change.
13
+ */
14
+ specsChanged: ManaEvent<ISpecModels>;
15
+ /**
16
+ * The kernel spec models.
17
+ *
18
+ * #### Notes
19
+ * The value will be null until the manager is ready.
20
+ */
21
+ readonly specs: ISpecModels | null;
22
+ /**
23
+ * Force a refresh of the specs from the server.
24
+ *
25
+ * @returns A promise that resolves when the specs are fetched.
26
+ *
27
+ * #### Notes
28
+ * This is intended to be called only in response to a user action,
29
+ * since the manager maintains its internal state.
30
+ */
31
+ refreshSpecs: () => Promise<void>;
32
+ }
33
+ //# sourceMappingURL=kernelspec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernelspec.d.ts","sourceRoot":"","sources":["../../src/kernelspec/kernelspec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,WAAW,QAAS,SAAQ,YAAY;IAC5C;;OAEG;IACH,YAAY,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAErC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAEnC;;;;;;;;OAQG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,81 @@
1
+ import { Poll } from '@difizen/libro-common';
2
+ import type { Event as ManaEvent } from '@difizen/mana-app';
3
+ import { Emitter, Deferred } from '@difizen/mana-app';
4
+ import { BaseManager } from '../basemanager.js';
5
+ import { ServerManager } from '../server/server-manager.js';
6
+ import type * as KernelSpec from './kernelspec.js';
7
+ import type { ISpecModels } from './restapi.js';
8
+ import { KernelSpecRestAPI } from './restapi.js';
9
+ /**
10
+ * An implementation of a kernel spec manager.
11
+ */
12
+ export declare class KernelSpecManager extends BaseManager implements KernelSpec.IManager {
13
+ protected serverManager: ServerManager;
14
+ protected kernelSpecRestAPI: KernelSpecRestAPI;
15
+ /**
16
+ * Construct a new kernel spec manager.
17
+ *
18
+ * @param options - The default options for kernel.
19
+ */
20
+ constructor();
21
+ /**
22
+ * The server settings for the manager.
23
+ */
24
+ /**
25
+ * Test whether the manager is ready.
26
+ */
27
+ /**
28
+ * A promise that fulfills when the manager is ready.
29
+ */
30
+ get specsReady(): Promise<ISpecModels>;
31
+ /**
32
+ * Get the most recently fetched kernel specs.
33
+ */
34
+ get specs(): ISpecModels | null;
35
+ /**
36
+ * A signal emitted when the specs change.
37
+ */
38
+ get specsChanged(): ManaEvent<ISpecModels>;
39
+ /**
40
+ * A signal emitted when there is a connection failure.
41
+ */
42
+ get connectionFailure(): ManaEvent<Error>;
43
+ /**
44
+ * Dispose of the resources used by the manager.
45
+ */
46
+ dispose(): void;
47
+ /**
48
+ * Force a refresh of the specs from the server.
49
+ *
50
+ * @returns A promise that resolves when the specs are fetched.
51
+ *
52
+ * #### Notes
53
+ * This is intended to be called only in response to a user action,
54
+ * since the manager maintains its internal state.
55
+ */
56
+ refreshSpecs(): Promise<void>;
57
+ /**
58
+ * Execute a request to the server to poll specs and update state.
59
+ */
60
+ protected requestSpecs(): Promise<void>;
61
+ protected connectionFailureEmitter: Emitter<Error>;
62
+ protected _pollSpecs: Poll;
63
+ protected _specs: ISpecModels | null;
64
+ protected specsChangedEmitter: Emitter<ISpecModels>;
65
+ protected specsDeferred: Deferred<ISpecModels>;
66
+ }
67
+ /**
68
+ * The namespace for `KernelManager` class statics.
69
+ */
70
+ export declare namespace KernelSpecManager {
71
+ /**
72
+ * The options used to initialize a KernelManager.
73
+ */
74
+ interface IOptions extends BaseManager.IOptions {
75
+ /**
76
+ * When the manager stops polling the API. Defaults to `when-hidden`.
77
+ */
78
+ standby?: Poll.Standby | (() => boolean | Poll.Standby);
79
+ }
80
+ }
81
+ //# sourceMappingURL=manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/kernelspec/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAItD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,KAAK,KAAK,UAAU,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;GAEG;AACH,qBACa,iBAAkB,SAAQ,WAAY,YAAW,UAAU,CAAC,QAAQ;IAE/E,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IAEvC,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAE/C;;;;OAIG;;IAoCH;;OAEG;IAGH;;OAEG;IAKH;;OAEG;IAKH,IAAI,UAAU,yBAEb;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,WAAW,GAAG,IAAI,CAE9B;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,SAAS,CAAC,WAAW,CAAC,CAEzC;IAED;;OAEG;IACH,IAAa,iBAAiB,IAAI,SAAS,CAAC,KAAK,CAAC,CAEjD;IAED;;OAEG;IACM,OAAO,IAAI,IAAI;IAKxB;;;;;;;;OAQG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAKnC;;OAEG;cACa,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB7C,UAAmB,wBAAwB,iBAAwB;IAEnE,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC;IAI3B,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAQ;IAC5C,SAAS,CAAC,mBAAmB,uBAA8B;IAC3D,SAAS,CAAC,aAAa,wBAA+B;CACvD;AAED;;GAEG;AACH,yBAAiB,iBAAiB,CAAC;IACjC;;OAEG;IACH,UAAiB,QAAS,SAAQ,WAAW,CAAC,QAAQ;QACpD;;WAEG;QACH,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;KACzD;CACF"}
@@ -0,0 +1,248 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3;
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
5
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6
+ function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
13
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
14
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
22
+ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
23
+ import { deepEqual, Poll } from '@difizen/libro-common';
24
+ import { Emitter, Deferred } from '@difizen/mana-app';
25
+ import { inject, singleton } from '@difizen/mana-app';
26
+ import { prop } from '@difizen/mana-app';
27
+ import { BaseManager } from "../basemanager.js";
28
+ import { ServerManager } from "../server/server-manager.js";
29
+ import { KernelSpecRestAPI } from "./restapi.js";
30
+
31
+ /**
32
+ * An implementation of a kernel spec manager.
33
+ */
34
+ export var KernelSpecManager = (_dec = singleton(), _dec2 = inject(ServerManager), _dec3 = inject(KernelSpecRestAPI), _dec4 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function (_BaseManager) {
35
+ _inherits(KernelSpecManager, _BaseManager);
36
+ var _super = _createSuper(KernelSpecManager);
37
+ /**
38
+ * Construct a new kernel spec manager.
39
+ *
40
+ * @param options - The default options for kernel.
41
+ */
42
+ function KernelSpecManager() {
43
+ var _this;
44
+ _classCallCheck(this, KernelSpecManager);
45
+ _this = _super.call(this);
46
+
47
+ // Initialize internal data.
48
+ _initializerDefineProperty(_this, "serverManager", _descriptor, _assertThisInitialized(_this));
49
+ _initializerDefineProperty(_this, "kernelSpecRestAPI", _descriptor2, _assertThisInitialized(_this));
50
+ // protected _isReady = false;
51
+ _this.connectionFailureEmitter = new Emitter();
52
+ // protected _ready: Promise<void>;
53
+ _initializerDefineProperty(_this, "_specs", _descriptor3, _assertThisInitialized(_this));
54
+ _this.specsChangedEmitter = new Emitter();
55
+ _this.specsDeferred = new Deferred();
56
+ _this._ready = Promise.all([_this.requestSpecs()])
57
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
58
+ .then(function (_) {
59
+ return undefined;
60
+ })
61
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
62
+ .catch(function (_) {
63
+ return undefined;
64
+ }).then(function () {
65
+ if (_this.isDisposed) {
66
+ return;
67
+ }
68
+ _this._isReady = true;
69
+ return;
70
+ });
71
+ _this._pollSpecs = new Poll({
72
+ auto: false,
73
+ factory: function factory() {
74
+ return _this.requestSpecs();
75
+ },
76
+ frequency: {
77
+ interval: 61 * 1000,
78
+ backoff: true,
79
+ max: 300 * 1000
80
+ },
81
+ name: "@jupyterlab/services:KernelSpecManager#specs",
82
+ standby: 'when-hidden'
83
+ // standby: options.standby ?? 'when-hidden',
84
+ });
85
+
86
+ void _this.ready.then(function () {
87
+ void _this._pollSpecs.start();
88
+ return;
89
+ });
90
+ return _this;
91
+ }
92
+
93
+ /**
94
+ * The server settings for the manager.
95
+ */
96
+ // readonly serverSettings: ServerConnection.ISettings;
97
+
98
+ /**
99
+ * Test whether the manager is ready.
100
+ */
101
+ // get isReady(): boolean {
102
+ // return this._isReady;
103
+ // }
104
+
105
+ /**
106
+ * A promise that fulfills when the manager is ready.
107
+ */
108
+ // get ready(): Promise<void> {
109
+ // return this._ready;
110
+ // }
111
+ _createClass(KernelSpecManager, [{
112
+ key: "specsReady",
113
+ get: function get() {
114
+ return this.specsDeferred.promise;
115
+ }
116
+
117
+ /**
118
+ * Get the most recently fetched kernel specs.
119
+ */
120
+ }, {
121
+ key: "specs",
122
+ get: function get() {
123
+ return this._specs;
124
+ }
125
+
126
+ /**
127
+ * A signal emitted when the specs change.
128
+ */
129
+ }, {
130
+ key: "specsChanged",
131
+ get: function get() {
132
+ return this.specsChangedEmitter.event;
133
+ }
134
+
135
+ /**
136
+ * A signal emitted when there is a connection failure.
137
+ */
138
+ }, {
139
+ key: "connectionFailure",
140
+ get: function get() {
141
+ return this.connectionFailureEmitter.event;
142
+ }
143
+
144
+ /**
145
+ * Dispose of the resources used by the manager.
146
+ */
147
+ }, {
148
+ key: "dispose",
149
+ value: function dispose() {
150
+ this._pollSpecs.dispose();
151
+ _get(_getPrototypeOf(KernelSpecManager.prototype), "dispose", this).call(this);
152
+ }
153
+
154
+ /**
155
+ * Force a refresh of the specs from the server.
156
+ *
157
+ * @returns A promise that resolves when the specs are fetched.
158
+ *
159
+ * #### Notes
160
+ * This is intended to be called only in response to a user action,
161
+ * since the manager maintains its internal state.
162
+ */
163
+ }, {
164
+ key: "refreshSpecs",
165
+ value: function () {
166
+ var _refreshSpecs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
167
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
168
+ while (1) switch (_context.prev = _context.next) {
169
+ case 0:
170
+ _context.next = 2;
171
+ return this._pollSpecs.refresh();
172
+ case 2:
173
+ _context.next = 4;
174
+ return this._pollSpecs.tick;
175
+ case 4:
176
+ case "end":
177
+ return _context.stop();
178
+ }
179
+ }, _callee, this);
180
+ }));
181
+ function refreshSpecs() {
182
+ return _refreshSpecs.apply(this, arguments);
183
+ }
184
+ return refreshSpecs;
185
+ }()
186
+ /**
187
+ * Execute a request to the server to poll specs and update state.
188
+ */
189
+ }, {
190
+ key: "requestSpecs",
191
+ value: function () {
192
+ var _requestSpecs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
193
+ var specs;
194
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
195
+ while (1) switch (_context2.prev = _context2.next) {
196
+ case 0:
197
+ _context2.next = 2;
198
+ return this.kernelSpecRestAPI.getSpecs(this.serverSettings);
199
+ case 2:
200
+ specs = _context2.sent;
201
+ if (specs) {
202
+ this.specsDeferred.resolve(specs);
203
+ }
204
+ if (!this.isDisposed) {
205
+ _context2.next = 6;
206
+ break;
207
+ }
208
+ return _context2.abrupt("return");
209
+ case 6:
210
+ if (!this._specs || !deepEqual(specs, this._specs)) {
211
+ this._specs = specs;
212
+ this.specsChangedEmitter.fire(specs);
213
+ }
214
+ case 7:
215
+ case "end":
216
+ return _context2.stop();
217
+ }
218
+ }, _callee2, this);
219
+ }));
220
+ function requestSpecs() {
221
+ return _requestSpecs.apply(this, arguments);
222
+ }
223
+ return requestSpecs;
224
+ }()
225
+ }]);
226
+ return KernelSpecManager;
227
+ }(BaseManager), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "serverManager", [_dec2], {
228
+ configurable: true,
229
+ enumerable: true,
230
+ writable: true,
231
+ initializer: null
232
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "kernelSpecRestAPI", [_dec3], {
233
+ configurable: true,
234
+ enumerable: true,
235
+ writable: true,
236
+ initializer: null
237
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_specs", [_dec4], {
238
+ configurable: true,
239
+ enumerable: true,
240
+ writable: true,
241
+ initializer: function initializer() {
242
+ return null;
243
+ }
244
+ })), _class2)) || _class);
245
+
246
+ /**
247
+ * The namespace for `KernelManager` class statics.
248
+ */
@@ -0,0 +1,71 @@
1
+ import type { PartialJSONObject } from '@difizen/libro-common';
2
+ import type { ISettings } from '../server/server-connection-protocol.js';
3
+ import { ServerConnection } from '../server/server-connection.js';
4
+ export declare class KernelSpecRestAPI {
5
+ serverConnection: ServerConnection;
6
+ /**
7
+ * Fetch all of the kernel specs.
8
+ *
9
+ * @param settings - The optional server settings.
10
+ * @param useCache - Whether to use the cache. If false, always request.
11
+ *
12
+ * @returns A promise that resolves with the kernel specs.
13
+ *
14
+ * #### Notes
15
+ * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernelspecs).
16
+ */
17
+ getSpecs(serverSettings?: Partial<ISettings>): Promise<ISpecModels>;
18
+ }
19
+ /**
20
+ * Kernel Spec interface.
21
+ *
22
+ * #### Notes
23
+ * See [Kernel specs](https://jupyter-client.readthedocs.io/en/latest/kernels.html#kernelspecs).
24
+ */
25
+ export interface ISpecModel extends PartialJSONObject {
26
+ /**
27
+ * The name of the kernel spec.
28
+ */
29
+ readonly name: string;
30
+ /**
31
+ * The name of the language of the kernel.
32
+ */
33
+ readonly language: string;
34
+ /**
35
+ * A list of command line arguments used to start the kernel.
36
+ */
37
+ readonly argv: string[];
38
+ /**
39
+ * The kernel’s name as it should be displayed in the UI.
40
+ */
41
+ readonly display_name: string;
42
+ /**
43
+ * A dictionary of environment variables to set for the kernel.
44
+ */
45
+ readonly env?: PartialJSONObject;
46
+ /**
47
+ * A mapping of resource file name to download path.
48
+ */
49
+ readonly resources: Record<string, string>;
50
+ /**
51
+ * A dictionary of additional attributes about this kernel; used by clients to aid in kernel selection.
52
+ */
53
+ readonly metadata?: PartialJSONObject;
54
+ }
55
+ /**
56
+ * The available kernelSpec models.
57
+ *
58
+ * #### Notes
59
+ * See the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernelspecs).
60
+ */
61
+ export interface ISpecModels extends PartialJSONObject {
62
+ /**
63
+ * The name of the default kernel spec.
64
+ */
65
+ default: string;
66
+ /**
67
+ * A mapping of kernel spec name to spec.
68
+ */
69
+ readonly kernelspecs: Record<string, ISpecModel | undefined>;
70
+ }
71
+ //# sourceMappingURL=restapi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restapi.d.ts","sourceRoot":"","sources":["../../src/kernelspec/restapi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAQlE,qBACa,iBAAiB;IACF,gBAAgB,EAAE,gBAAgB,CAAC;IAC7D;;;;;;;;;;OAUG;IACG,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;CAc1E;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAW,SAAQ,iBAAiB;IACnD;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,iBAAiB,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAY,SAAQ,iBAAiB;IACpD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC;CAC9D"}