@runtimed/node 0.5.4 → 0.5.6-nightly.36505591006
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 +148 -5
- package/package.json +24 -11
- package/src/binding.cjs +53 -52
- package/src/binding.d.ts +39 -2
- package/src/execution-store.cjs +397 -0
- package/src/execution-store.d.cts +66 -0
- package/src/index.d.ts +52 -43
- package/src/relay.d.ts +10 -1
- package/src/session.cjs +8 -68
package/src/session.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const { createNotebookExecutionStore } = require("./execution-store.cjs");
|
|
3
4
|
const { Subject } = require("rxjs");
|
|
4
5
|
const { parseJsonEvent } = require("./napi-observables.cjs");
|
|
5
6
|
|
|
@@ -7,7 +8,7 @@ class Session {
|
|
|
7
8
|
constructor(nativeSession) {
|
|
8
9
|
this._native = nativeSession;
|
|
9
10
|
this._subscriptions = [];
|
|
10
|
-
this.
|
|
11
|
+
this.executions = createNotebookExecutionStore();
|
|
11
12
|
this._runtimeStateSubject = new Subject();
|
|
12
13
|
this._executionTransitionsSubject = new Subject();
|
|
13
14
|
this._executionViewChangesSubject = new Subject();
|
|
@@ -56,7 +57,7 @@ class Session {
|
|
|
56
57
|
this._subscriptions.push(
|
|
57
58
|
nativeSession.onExecutionViewChange((json) => {
|
|
58
59
|
const changeset = parseJsonEvent(json);
|
|
59
|
-
|
|
60
|
+
this.executions.applyChangeset(changeset);
|
|
60
61
|
this._executionViewChangesSubject.next(changeset);
|
|
61
62
|
}),
|
|
62
63
|
);
|
|
@@ -202,7 +203,11 @@ class Session {
|
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
getExecutionView() {
|
|
205
|
-
return
|
|
206
|
+
return this.executions.getSnapshot();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
confirmNotebookSync() {
|
|
210
|
+
return this._native.confirmNotebookSync();
|
|
206
211
|
}
|
|
207
212
|
|
|
208
213
|
close() {
|
|
@@ -233,71 +238,6 @@ function normalizeDependencyOptions(options) {
|
|
|
233
238
|
return { packageManager: options.packageManager };
|
|
234
239
|
}
|
|
235
240
|
|
|
236
|
-
function emptyExecutionView() {
|
|
237
|
-
return {
|
|
238
|
-
cell_execution_ids: {},
|
|
239
|
-
executions: {},
|
|
240
|
-
queue: null,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function applyExecutionViewChangeset(view, changeset) {
|
|
245
|
-
for (const [cellId, executionId] of changeset?.cell_pointer_changes ?? []) {
|
|
246
|
-
if (executionId == null) {
|
|
247
|
-
delete view.cell_execution_ids[cellId];
|
|
248
|
-
} else {
|
|
249
|
-
view.cell_execution_ids[cellId] = executionId;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
for (const [executionId, snapshot] of changeset?.execution_upserts ?? []) {
|
|
254
|
-
view.executions[executionId] = cloneExecutionSnapshot(snapshot);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
for (const executionId of changeset?.removed_execution_ids ?? []) {
|
|
258
|
-
delete view.executions[executionId];
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (Object.hasOwn(changeset ?? {}, "queue")) {
|
|
262
|
-
view.queue = cloneQueueProjection(changeset.queue ?? null);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function cloneExecutionView(view) {
|
|
267
|
-
return {
|
|
268
|
-
cell_execution_ids: { ...view.cell_execution_ids },
|
|
269
|
-
executions: Object.fromEntries(
|
|
270
|
-
Object.entries(view.executions).map(([executionId, snapshot]) => [
|
|
271
|
-
executionId,
|
|
272
|
-
cloneExecutionSnapshot(snapshot),
|
|
273
|
-
]),
|
|
274
|
-
),
|
|
275
|
-
queue: cloneQueueProjection(view.queue),
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function cloneExecutionSnapshot(snapshot) {
|
|
280
|
-
return {
|
|
281
|
-
...snapshot,
|
|
282
|
-
output_ids: Array.from(snapshot?.output_ids ?? []),
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function cloneQueueProjection(queue) {
|
|
287
|
-
if (queue == null) return null;
|
|
288
|
-
return {
|
|
289
|
-
executing_execution_id: queue.executing_execution_id ?? null,
|
|
290
|
-
queued_execution_ids: Array.from(queue.queued_execution_ids ?? []),
|
|
291
|
-
notebook:
|
|
292
|
-
queue.notebook == null
|
|
293
|
-
? queue.notebook
|
|
294
|
-
: {
|
|
295
|
-
executing_cell_id: queue.notebook.executing_cell_id ?? null,
|
|
296
|
-
queued_cell_ids: Array.from(queue.notebook.queued_cell_ids ?? []),
|
|
297
|
-
},
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
|
|
301
241
|
module.exports = {
|
|
302
242
|
Session,
|
|
303
243
|
};
|