gennaker-tools 0.1.3 → 0.1.5

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/index.js CHANGED
@@ -3,8 +3,11 @@ import { ICommandPalette } from '@jupyterlab/apputils';
3
3
  import { ITranslator, nullTranslator } from '@jupyterlab/translation';
4
4
  import { IEditorExtensionRegistry, EditorExtensionRegistry } from '@jupyterlab/codemirror';
5
5
  import { snippetCompletion, autocompletion, completeFromList } from '@codemirror/autocomplete';
6
- const RESTART_RUN_STATELESS = 'gennaker-tools:restart-run-stateless';
7
- const RESET_JUPYTERLAB = 'gennaker-tools:reset-jupyterlab';
6
+ var CommandIDs;
7
+ (function (CommandIDs) {
8
+ CommandIDs.restartRunStateless = 'gennaker-tools:restart-run-stateless';
9
+ CommandIDs.resetJupyterLab = 'gennaker-tools:reset-jupyterlab';
10
+ })(CommandIDs || (CommandIDs = {}));
8
11
  /**
9
12
  * Initialization data for the gennaker-tools extension.
10
13
  */
@@ -17,20 +20,19 @@ export const statelessRunPlugin = {
17
20
  activate: (app, palette, tracker, translator) => {
18
21
  const trans = (translator !== null && translator !== void 0 ? translator : nullTranslator).load('jupyterlab');
19
22
  const { commands, shell } = app;
20
- console.log('JupyterLab extension gennaker-tools is activated!');
23
+ console.log('JupyterLab plugin gennaker-tools:stateless-run is activated!');
21
24
  // Add a command
22
25
  const isEnabled = () => {
23
- console.log('enabed', { tracker, shell });
24
26
  return (tracker.currentWidget !== null &&
25
27
  tracker.currentWidget === shell.currentWidget);
26
28
  };
27
- commands.addCommand(RESTART_RUN_STATELESS, {
29
+ commands.addCommand(CommandIDs.restartRunStateless, {
28
30
  label: 'Restart Kernel, Clear Outputs, and Run All Above Selected Cell',
29
31
  caption: 'Clear all outputs, restart kernel, and run all cells above the selected cell',
30
32
  isEnabled,
31
33
  execute: async (args) => {
32
34
  const orig = args['origin'];
33
- console.log(`${RESTART_RUN_STATELESS} has been called from... ${orig}.`);
35
+ console.log(`${CommandIDs.restartRunStateless} has been called from... ${orig}.`);
34
36
  if (orig !== 'init') {
35
37
  // Clear all outputs
36
38
  await commands.execute('apputils:run-all-enabled', {
@@ -45,7 +47,7 @@ export const statelessRunPlugin = {
45
47
  // Add the command to the command palette
46
48
  const category = trans.__('Notebook Operations');
47
49
  palette.addItem({
48
- command: RESTART_RUN_STATELESS,
50
+ command: CommandIDs.restartRunStateless,
49
51
  category,
50
52
  args: { origin: 'from palette' }
51
53
  });
@@ -61,9 +63,10 @@ export const reloadPlugin = {
61
63
  requires: [ICommandPalette],
62
64
  optional: [ITranslator],
63
65
  activate: (app, palette, translator) => {
66
+ console.log('JupyterLab plugin gennaker-tools:reload is activated!');
64
67
  const { commands } = app;
65
68
  const trans = (translator !== null && translator !== void 0 ? translator : nullTranslator).load('jupyterlab');
66
- commands.addCommand(RESET_JUPYTERLAB, {
69
+ commands.addCommand(CommandIDs.resetJupyterLab, {
67
70
  label: 'Reset JupyterLab',
68
71
  caption: 'Reset JupyterLab',
69
72
  isEnabled: () => true,
@@ -77,7 +80,7 @@ export const reloadPlugin = {
77
80
  // Add the command to the command palette
78
81
  const category = trans.__('Reset');
79
82
  palette.addItem({
80
- command: RESET_JUPYTERLAB,
83
+ command: CommandIDs.resetJupyterLab,
81
84
  category,
82
85
  args: { origin: 'from palette' }
83
86
  });
@@ -127,6 +130,7 @@ export const snippetsPlugin = {
127
130
  requires: [IEditorExtensionRegistry],
128
131
  optional: [],
129
132
  activate: (app, registry) => {
133
+ console.log('JupyterLab plugin gennaker-tools:snippets is activated!');
130
134
  registry.addExtension(Object.freeze({
131
135
  name: 'gennaker-tools:snippets',
132
136
  factory: () => EditorExtensionRegistry.createConfigurableExtension((config) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gennaker-tools",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "A JupyterLab extension to provide a restart-and-run-to-selected command variant that clears non-executed cell outputs.",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -7,11 +7,13 @@
7
7
  "id": "jp-mainmenu-run",
8
8
  "items": [
9
9
  {
10
- "command": "stateless:clear-restart-run-to-selected",
10
+ "command": "gennaker-tools:restart-run-stateless",
11
11
  "rank": 80
12
12
  }
13
13
  ]
14
14
  }
15
15
  ]
16
- }
16
+ },
17
+ "additionalProperties": false,
18
+ "type": "object"
17
19
  }
package/src/index.ts CHANGED
@@ -16,8 +16,10 @@ import {
16
16
  } from '@codemirror/autocomplete';
17
17
  import type { Completion } from '@codemirror/autocomplete';
18
18
 
19
- const RESTART_RUN_STATELESS = 'gennaker-tools:restart-run-stateless';
20
- const RESET_JUPYTERLAB = 'gennaker-tools:reset-jupyterlab';
19
+ namespace CommandIDs {
20
+ export const restartRunStateless = 'gennaker-tools:restart-run-stateless';
21
+ export const resetJupyterLab = 'gennaker-tools:reset-jupyterlab';
22
+ }
21
23
 
22
24
  /**
23
25
  * Initialization data for the gennaker-tools extension.
@@ -37,18 +39,17 @@ export const statelessRunPlugin: JupyterFrontEndPlugin<void> = {
37
39
  const trans = (translator ?? nullTranslator).load('jupyterlab');
38
40
  const { commands, shell } = app;
39
41
 
40
- console.log('JupyterLab extension gennaker-tools is activated!');
42
+ console.log('JupyterLab plugin gennaker-tools:stateless-run is activated!');
41
43
  // Add a command
42
44
 
43
45
  const isEnabled = () => {
44
- console.log('enabed', { tracker, shell });
45
46
  return (
46
47
  tracker.currentWidget !== null &&
47
48
  tracker.currentWidget === shell.currentWidget
48
49
  );
49
50
  };
50
51
 
51
- commands.addCommand(RESTART_RUN_STATELESS, {
52
+ commands.addCommand(CommandIDs.restartRunStateless, {
52
53
  label: 'Restart Kernel, Clear Outputs, and Run All Above Selected Cell',
53
54
  caption:
54
55
  'Clear all outputs, restart kernel, and run all cells above the selected cell',
@@ -56,7 +57,7 @@ export const statelessRunPlugin: JupyterFrontEndPlugin<void> = {
56
57
  execute: async (args: any) => {
57
58
  const orig = args['origin'];
58
59
  console.log(
59
- `${RESTART_RUN_STATELESS} has been called from... ${orig}.`
60
+ `${CommandIDs.restartRunStateless} has been called from... ${orig}.`
60
61
  );
61
62
  if (orig !== 'init') {
62
63
  // Clear all outputs
@@ -73,7 +74,7 @@ export const statelessRunPlugin: JupyterFrontEndPlugin<void> = {
73
74
  // Add the command to the command palette
74
75
  const category = trans.__('Notebook Operations');
75
76
  palette.addItem({
76
- command: RESTART_RUN_STATELESS,
77
+ command: CommandIDs.restartRunStateless,
77
78
  category,
78
79
  args: { origin: 'from palette' }
79
80
  });
@@ -94,10 +95,12 @@ export const reloadPlugin: JupyterFrontEndPlugin<void> = {
94
95
  palette: ICommandPalette,
95
96
  translator: ITranslator | null
96
97
  ) => {
98
+ console.log('JupyterLab plugin gennaker-tools:reload is activated!');
99
+
97
100
  const { commands } = app;
98
101
  const trans = (translator ?? nullTranslator).load('jupyterlab');
99
102
 
100
- commands.addCommand(RESET_JUPYTERLAB, {
103
+ commands.addCommand(CommandIDs.resetJupyterLab, {
101
104
  label: 'Reset JupyterLab',
102
105
  caption: 'Reset JupyterLab',
103
106
  isEnabled: () => true,
@@ -112,7 +115,7 @@ export const reloadPlugin: JupyterFrontEndPlugin<void> = {
112
115
  // Add the command to the command palette
113
116
  const category = trans.__('Reset');
114
117
  palette.addItem({
115
- command: RESET_JUPYTERLAB,
118
+ command: CommandIDs.resetJupyterLab,
116
119
  category,
117
120
  args: { origin: 'from palette' }
118
121
  });
@@ -171,6 +174,7 @@ export const snippetsPlugin: JupyterFrontEndPlugin<void> = {
171
174
  requires: [IEditorExtensionRegistry],
172
175
  optional: [],
173
176
  activate: (app: JupyterFrontEnd, registry: IEditorExtensionRegistry) => {
177
+ console.log('JupyterLab plugin gennaker-tools:snippets is activated!');
174
178
  registry.addExtension(
175
179
  Object.freeze({
176
180
  name: 'gennaker-tools:snippets',