jupyterlab-ipyflow 0.0.155 → 0.0.157

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 (2) hide show
  1. package/lib/index.js +39 -21
  2. package/package.json +7 -5
package/lib/index.js CHANGED
@@ -10,7 +10,7 @@ const readyMakingInputClass = 'ready-making-input-cell';
10
10
  const linkedWaitingClass = 'linked-waiting';
11
11
  const linkedReadyMakerClass = 'linked-ready-maker';
12
12
  // ipyflow frontend state
13
- let dirtyCells = new Set();
13
+ const dirtyCells = new Set();
14
14
  let waitingCells = new Set();
15
15
  let readyCells = new Set();
16
16
  let waiterLinks = {};
@@ -23,6 +23,7 @@ let orderIdxById = {};
23
23
  let cellPendingExecution = null;
24
24
  let lastExecutionMode = null;
25
25
  let isReactivelyExecuting = false;
26
+ let isAltModeExecuting = false;
26
27
  let lastExecutionHighlights = null;
27
28
  let executedReactiveReadyCells = new Set();
28
29
  let newReadyCells = new Set();
@@ -42,19 +43,22 @@ const extension = {
42
43
  isVisible: () => true,
43
44
  isToggled: () => false,
44
45
  execute: () => {
45
- if (notebooks.activeCell.model.type === 'code') {
46
+ if (!isAltModeExecuting && notebooks.activeCell.model.type === 'code') {
47
+ isAltModeExecuting = true;
46
48
  const session = notebooks.currentWidget.sessionContext;
47
49
  if (session.isReady && notebooks.activeCell.model.type === 'code') {
48
- session.session.kernel.requestExecute({
50
+ session.session.kernel
51
+ .requestExecute({
49
52
  code: '%flow toggle-reactivity-until-next-reset',
50
53
  silent: true,
51
54
  store_history: false,
52
- }).done.then(() => {
55
+ })
56
+ .done.then(() => {
53
57
  CodeCell.execute(notebooks.activeCell, session);
54
58
  });
55
59
  }
56
60
  }
57
- }
61
+ },
58
62
  });
59
63
  app.commands.addKeyBinding({
60
64
  command: 'alt-mode-execute',
@@ -77,15 +81,20 @@ const extension = {
77
81
  clearCellState(nbPanel.content);
78
82
  activeCell = nbPanel.content.activeCell;
79
83
  activeCellId = nbPanel.content.activeCell.model.id;
80
- let commDisconnectHandler = () => { };
84
+ let commDisconnectHandler = function () {
85
+ // do nothing if not connected.
86
+ };
81
87
  if (session.session.kernel.name === IPYFLOW_KERNEL_NAME) {
82
88
  commDisconnectHandler = connectToComm(session, nbPanel.content);
83
89
  }
84
90
  session.kernelChanged.connect((_, args) => {
85
91
  clearCellState(nbPanel.content);
86
92
  commDisconnectHandler();
87
- commDisconnectHandler = () => { };
88
- if (args.newValue !== null && args.newValue.name === IPYFLOW_KERNEL_NAME) {
93
+ commDisconnectHandler = function () {
94
+ // do nothing if not connected.
95
+ };
96
+ if (args.newValue !== null &&
97
+ args.newValue.name === IPYFLOW_KERNEL_NAME) {
89
98
  commDisconnectHandler = connectToComm(session, nbPanel.content);
90
99
  }
91
100
  });
@@ -99,7 +108,9 @@ const extension = {
99
108
  session.ready.then(() => {
100
109
  clearCellState(nbPanel.content);
101
110
  commDisconnectHandler();
102
- commDisconnectHandler = () => { };
111
+ commDisconnectHandler = function () {
112
+ // do nothing if not connected.
113
+ };
103
114
  if (session.session.kernel.name === IPYFLOW_KERNEL_NAME) {
104
115
  commDisconnectHandler = connectToComm(session, nbPanel.content);
105
116
  }
@@ -108,7 +119,7 @@ const extension = {
108
119
  });
109
120
  });
110
121
  });
111
- }
122
+ },
112
123
  };
113
124
  const getJpInputCollapser = (elem) => {
114
125
  if (elem === null || elem === undefined) {
@@ -262,7 +273,7 @@ const connectToComm = (session, notebook) => {
262
273
  const payload = {
263
274
  type: 'change_active_cell',
264
275
  active_cell_id: newActiveCell.id,
265
- active_cell_order_idx: newActiveCellOrderIdx
276
+ active_cell_order_idx: newActiveCellOrderIdx,
266
277
  };
267
278
  comm.send(payload);
268
279
  };
@@ -286,7 +297,9 @@ const connectToComm = (session, notebook) => {
286
297
  }
287
298
  activeCell = cell;
288
299
  activeCellId = cell.model.id;
289
- if (activeCell === null || activeCell.model === null || activeCell.model.type !== "code") {
300
+ if (activeCell === null ||
301
+ activeCell.model === null ||
302
+ activeCell.model.type !== 'code') {
290
303
  return;
291
304
  }
292
305
  activeCell.model.stateChanged.connect(onExecution);
@@ -305,10 +318,11 @@ const connectToComm = (session, notebook) => {
305
318
  {
306
319
  action: 'mouseover',
307
320
  update: 'add',
308
- }, {
321
+ },
322
+ {
309
323
  action: 'mouseout',
310
324
  update: 'remove',
311
- }
325
+ },
312
326
  ];
313
327
  const updateOneCellUI = (id) => {
314
328
  const model = cellModelsById[id];
@@ -334,13 +348,13 @@ const connectToComm = (session, notebook) => {
334
348
  if (lastExecutionMode === 'reactive') {
335
349
  return;
336
350
  }
337
- if (waiterLinks.hasOwnProperty(id)) {
351
+ if (Object.prototype.hasOwnProperty.call(waiterLinks, id)) {
338
352
  actionUpdatePairs.forEach(({ action, update }) => {
339
353
  addUnsafeCellInteraction(getJpInputCollapser(elem), waiterLinks[id], cellsById, getJpInputCollapser, action, update, waitingCells);
340
354
  addUnsafeCellInteraction(getJpOutputCollapser(elem), waiterLinks[id], cellsById, getJpInputCollapser, action, update, waitingCells);
341
355
  });
342
356
  }
343
- if (readyMakerLinks.hasOwnProperty(id)) {
357
+ if (Object.prototype.hasOwnProperty.call(readyMakerLinks, id)) {
344
358
  if (!waitingCells.has(id)) {
345
359
  elem.classList.add(readyMakingClass);
346
360
  elem.classList.add(readyClass);
@@ -388,7 +402,7 @@ const connectToComm = (session, notebook) => {
388
402
  readyMakerLinks = payload.ready_maker_links;
389
403
  cellPendingExecution = null;
390
404
  const exec_mode = payload.exec_mode;
391
- isReactivelyExecuting = isReactivelyExecuting || (exec_mode === 'reactive');
405
+ isReactivelyExecuting = isReactivelyExecuting || exec_mode === 'reactive';
392
406
  const flow_order = payload.flow_order;
393
407
  const exec_schedule = payload.exec_schedule;
394
408
  lastExecutionMode = exec_mode;
@@ -400,18 +414,20 @@ const connectToComm = (session, notebook) => {
400
414
  let lastExecutedCellIdSeen = false;
401
415
  for (const cell of notebook.widgets) {
402
416
  if (!lastExecutedCellIdSeen) {
403
- lastExecutedCellIdSeen = (cell.model.id == lastExecutedCellId);
417
+ lastExecutedCellIdSeen = cell.model.id === lastExecutedCellId;
404
418
  if (flow_order === 'in_order' || exec_schedule === 'strict') {
405
419
  continue;
406
420
  }
407
421
  }
408
- if (cell.model.type !== 'code' || executedReactiveReadyCells.has(cell.model.id)) {
422
+ if (cell.model.type !== 'code' ||
423
+ executedReactiveReadyCells.has(cell.model.id)) {
409
424
  continue;
410
425
  }
411
426
  if (!newReadyCells.has(cell.model.id)) {
412
427
  continue;
413
428
  }
414
- if (!forcedReactiveCells.has(cell.model.id) && exec_mode !== 'reactive') {
429
+ if (!forcedReactiveCells.has(cell.model.id) &&
430
+ exec_mode !== 'reactive') {
415
431
  continue;
416
432
  }
417
433
  const codeCell = cell;
@@ -425,7 +441,8 @@ const connectToComm = (session, notebook) => {
425
441
  else if (codeCell.model.executionCount == null) {
426
442
  // pass
427
443
  }
428
- else if (codeCell.model.executionCount < cellPendingExecution.model.executionCount) {
444
+ else if (codeCell.model.executionCount <
445
+ cellPendingExecution.model.executionCount) {
429
446
  // otherwise, execute in order of earliest execution counter
430
447
  cellPendingExecution = codeCell;
431
448
  }
@@ -445,6 +462,7 @@ const connectToComm = (session, notebook) => {
445
462
  executedReactiveReadyCells = new Set();
446
463
  updateUI(notebook);
447
464
  isReactivelyExecuting = false;
465
+ isAltModeExecuting = false;
448
466
  }
449
467
  else {
450
468
  isReactivelyExecuting = true;
package/package.json CHANGED
@@ -24,17 +24,19 @@
24
24
  "url": "https://github.com/ipyflow/ipyflow.git"
25
25
  },
26
26
  "scripts": {
27
- "build": "jlpm run build:lib && jlpm run build:labextension:dev",
28
- "build:prod": "jlpm run build:lib && jlpm run build:labextension",
27
+ "build": "npm run build:lib && npm run build:labextension",
28
+ "build:dev": "npm run build:lib && npm run build:labextension:dev",
29
29
  "build:labextension": "jupyter labextension build .",
30
30
  "build:labextension:dev": "jupyter labextension build --development True .",
31
31
  "build:lib": "tsc",
32
- "clean": "jlpm run clean:lib",
32
+ "clean": "npm run clean:lib",
33
33
  "clean:lib": "rimraf lib tsconfig.tsbuildinfo",
34
34
  "eslint": "eslint . --ext .ts,.tsx --fix",
35
35
  "eslint:check": "eslint . --ext .ts,.tsx",
36
+ "format": "prettier --write 'src/*.ts'",
37
+ "lint": "prettier --check 'src/*.ts'",
36
38
  "install:extension": "jupyter labextension develop --overwrite .",
37
- "prepare": "jlpm run clean && jlpm run build:prod",
39
+ "prepare": "npm run clean && npm run build",
38
40
  "watch": "run-p watch:src watch:labextension",
39
41
  "watch:src": "tsc -w",
40
42
  "watch:labextension": "jupyter labextension watch ."
@@ -64,5 +66,5 @@
64
66
  "extension": true,
65
67
  "outputDir": "../../core/ipyflow/resources/labextension/"
66
68
  },
67
- "version": "0.0.155"
69
+ "version": "0.0.157"
68
70
  }