jupyterlab-pioneer 1.6.0 → 1.7.3

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 CHANGED
@@ -70,11 +70,13 @@ Check jupyter server [doc](https://jupyter-server.readthedocs.io/en/latest/opera
70
70
  {
71
71
  'name': # string, event name
72
72
  'logWholeNotebook': # boolean, whether to export the entire notebook content when event is triggered
73
+ 'logCellMetadata': # boolean, whether to export cell metadata when a cell related event is triggered
73
74
  }
74
75
  ```
75
76
 
76
77
  The extension would only generate and export data for valid event that has an id associated with the event class, and the event name is included in `activeEvents`.
77
78
  The extension will export the entire notebook content only for valid events when the `logWholeNotebook` flag is True.
79
+ It will export the cell metadata when the `logCellMetadata` flag is True.
78
80
 
79
81
  `exporters`: An array of exporters. Each exporter in the array should have the following structure:
80
82
 
@@ -189,7 +191,7 @@ See [RELEASE](RELEASE.md)
189
191
 
190
192
  ## Contributors ✨
191
193
 
192
- Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
194
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/emoji-key/#natural-language-processing)):
193
195
 
194
196
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
195
197
  <!-- prettier-ignore-start -->
@@ -197,11 +199,12 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
197
199
  <table>
198
200
  <tbody>
199
201
  <tr>
200
- <td align="center" valign="top" width="14.28%"><a href="https://www.wumengyan.com/"><img src="https://avatars.githubusercontent.com/u/85606983?v=4?s=100" width="100px;" alt="mengyanw"/><br /><sub><b>Mengyan Wu</b></sub></a><br /><a href="https://github.com/educational-technology-collective/jupyterlab-pioneer/commits?author=mengyanw" title="Code">💻</a> <a href="#ideas-mengyanw" title="Ideas, Planning, & Feedback">🤔</a> <a href="#maintenance-mengyanw" title="Maintenance">🚧</a> <a href="#projectManagement-mengyanw" title="Project Management">📆</a> <a href="#infra-mengyanw" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/educational-technology-collective/jupyterlab-pioneer/commits?author=mengyanw" title="Tests">⚠️</a> <a href="https://github.com/educational-technology-collective/jupyterlab-pioneer/commits?author=mengyanw" title="Documentation">📖</a></td>
202
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/mengyanw"><img src="https://avatars.githubusercontent.com/u/85606983?v=4?s=100" width="100px;" alt="mengyanw"/><br /><sub><b>Mengyan Wu</b></sub></a><br /><a href="#code-mengyanw" title="Code">💻</a> <a href="#ideas-mengyanw" title="Ideas, Planning, & Feedback">🤔</a> <a href="#maintenance-mengyanw" title="Maintenance">🚧</a> <a href="#projectManagement-mengyanw" title="Project Management">📆</a> <a href="#infra-mengyanw" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#tests-mengyanw" title="Tests">⚠️</a> <a href="#documentation-mengyanw" title="Documentation">📖</a></td>
201
203
  <td align="center" valign="top" width="14.28%"><a href="http://christopherbrooks.ca"><img src="https://avatars.githubusercontent.com/u/1355641?v=4?s=100" width="100px;" alt="Christopher Brooks"/><br /><sub><b>Christopher Brooks</b></sub></a><br /><a href="#ideas-cab938" title="Ideas, Planning, & Feedback">🤔</a> <a href="#projectManagement-cab938" title="Project Management">📆</a> <a href="#infra-cab938" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
202
204
  <td align="center" valign="top" width="14.28%"><a href="http://from.so/Steve_Oney"><img src="https://avatars.githubusercontent.com/u/211262?v=4?s=100" width="100px;" alt="Steve Oney"/><br /><sub><b>Steve Oney</b></sub></a><br /><a href="#ideas-soney" title="Ideas, Planning, & Feedback">🤔</a> <a href="#projectManagement-soney" title="Project Management">📆</a></td>
203
- <td align="center" valign="top" width="14.28%"><a href="https://www.chrisostrouchov.com"><img src="https://avatars.githubusercontent.com/u/1740337?v=4?s=100" width="100px;" alt="Christopher Ostrouchov"/><br /><sub><b>Christopher Ostrouchov</b></sub></a><br /><a href="#ideas-costrouc" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/educational-technology-collective/jupyterlab-pioneer/commits?author=costrouc" title="Code">💻</a></td>
205
+ <td align="center" valign="top" width="14.28%"><a href="https://www.chrisostrouchov.com"><img src="https://avatars.githubusercontent.com/u/1740337?v=4?s=100" width="100px;" alt="Christopher Ostrouchov"/><br /><sub><b>Christopher Ostrouchov</b></sub></a><br /><a href="#ideas-costrouc" title="Ideas, Planning, & Feedback">🤔</a> <a href="#code-costrouc" title="Code">💻</a></td>
204
206
  <td align="center" valign="top" width="14.28%"><a href="https://iamit.in"><img src="https://avatars.githubusercontent.com/u/5647941?v=4?s=100" width="100px;" alt="Amit Kumar"/><br /><sub><b>Amit Kumar</b></sub></a><br /><a href="#infra-aktech" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
207
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/cmarmo"><img src="https://avatars.githubusercontent.com/u/1662261?v=4?s=100" width="100px;" alt="Chiara Marmo"/><br /><sub><b>Chiara Marmo</b></sub></a><br /><a href="#code-cmarmo" title="Code">💻</a> <a href="#infra-cmarmo" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
205
208
  </tr>
206
209
  </tbody>
207
210
  </table>
package/lib/index.d.ts CHANGED
@@ -13,17 +13,18 @@ export interface IJupyterLabPioneer {
13
13
  * Send event data to exporters defined in the configuration file.
14
14
  *
15
15
  * @param {NotebookPanel} notebookPanel The notebook panel the extension currently listens to.
16
- * @param {Object} eventDetail An object containing event details.
16
+ * @param {object} eventDetail An object containing event details.
17
17
  * @param {Exporter} exporter The exporter configuration.
18
18
  * @param {Boolean} logWholeNotebook A boolean indicating whether to log the entire notebook or not.
19
+ * @param {Boolean} logCellMetadata A boolean indicating whether to log the cell metadata or not.
19
20
  */
20
- publishEvent(notebookPanel: NotebookPanel, eventDetail: Object, exporter: Exporter, logWholeNotebook?: Boolean): Promise<void>;
21
+ publishEvent(notebookPanel: NotebookPanel, eventDetail: object, exporter: Exporter, logWholeNotebook?: boolean): Promise<void>;
21
22
  }
22
23
  declare class JupyterLabPioneer implements IJupyterLabPioneer {
23
24
  exporters: Exporter[];
24
25
  constructor();
25
26
  loadExporters(notebookPanel: NotebookPanel): Promise<void>;
26
- publishEvent(notebookPanel: NotebookPanel, eventDetail: Object, exporter: Exporter, logWholeNotebook?: Boolean): Promise<void>;
27
+ publishEvent(notebookPanel: NotebookPanel, eventDetail: object, exporter: Exporter, logWholeNotebook?: boolean): Promise<void>;
27
28
  }
28
29
  declare const plugin: JupyterFrontEndPlugin<JupyterLabPioneer>;
29
30
  export default plugin;
package/lib/producer.js CHANGED
@@ -5,22 +5,24 @@ class ActiveCellChangeEventProducer {
5
5
  listen(notebookPanel, pioneer) {
6
6
  notebookPanel.content.activeCellChanged.connect(async (_, cell) => {
7
7
  if (cell && notebookPanel.content.widgets) {
8
- const activatedCell = {
9
- id: cell === null || cell === void 0 ? void 0 : cell.model.id,
10
- index: notebookPanel.content.widgets.findIndex(value => value === cell),
11
- type: cell === null || cell === void 0 ? void 0 : cell.model.type
12
- };
13
- const event = {
14
- eventName: ActiveCellChangeEventProducer.id,
15
- eventTime: Date.now(),
16
- eventInfo: {
17
- cells: [activatedCell] // activated cell
18
- }
19
- };
20
8
  pioneer.exporters.forEach(async (exporter) => {
21
- var _a, _b, _c;
9
+ var _a, _b, _c, _d, _e;
22
10
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(ActiveCellChangeEventProducer.id)) {
23
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == ActiveCellChangeEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
11
+ const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === ActiveCellChangeEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
12
+ const activatedCell = {
13
+ id: cell === null || cell === void 0 ? void 0 : cell.model.id,
14
+ index: notebookPanel.content.widgets.findIndex(value => value === cell),
15
+ type: cell === null || cell === void 0 ? void 0 : cell.model.type,
16
+ metadata: logCellMetadata ? cell === null || cell === void 0 ? void 0 : cell.model.metadata : null
17
+ };
18
+ const event = {
19
+ eventName: ActiveCellChangeEventProducer.id,
20
+ eventTime: Date.now(),
21
+ eventInfo: {
22
+ cells: [activatedCell] // activated cell
23
+ }
24
+ };
25
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_e = (_d = exporter.activeEvents) === null || _d === void 0 ? void 0 : _d.find(o => o.name === ActiveCellChangeEventProducer.id)) === null || _e === void 0 ? void 0 : _e.logWholeNotebook);
24
26
  }
25
27
  });
26
28
  }
@@ -34,22 +36,24 @@ class CellAddEventProducer {
34
36
  var _a;
35
37
  (_a = notebookPanel.content.model) === null || _a === void 0 ? void 0 : _a.cells.changed.connect(async (_, args) => {
36
38
  if (args.type === 'add') {
37
- const addedCell = {
38
- id: args.newValues[0].id,
39
- index: args.newIndex,
40
- type: args.newValues[0].type
41
- };
42
- const event = {
43
- eventName: CellAddEventProducer.id,
44
- eventTime: Date.now(),
45
- eventInfo: {
46
- cells: [addedCell]
47
- }
48
- };
49
39
  pioneer.exporters.forEach(async (exporter) => {
50
- var _a, _b, _c;
40
+ var _a, _b, _c, _d, _e;
51
41
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(CellAddEventProducer.id)) {
52
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == CellAddEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
42
+ const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === CellAddEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
43
+ const addedCell = {
44
+ id: args.newValues[0].id,
45
+ index: args.newIndex,
46
+ type: args.newValues[0].type,
47
+ metadata: logCellMetadata ? args.newValues[0].metadata : null
48
+ };
49
+ const event = {
50
+ eventName: CellAddEventProducer.id,
51
+ eventTime: Date.now(),
52
+ eventInfo: {
53
+ cells: [addedCell]
54
+ }
55
+ };
56
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_e = (_d = exporter.activeEvents) === null || _d === void 0 ? void 0 : _d.find(o => o.name === CellAddEventProducer.id)) === null || _e === void 0 ? void 0 : _e.logWholeNotebook);
53
57
  }
54
58
  });
55
59
  }
@@ -62,22 +66,23 @@ class CellEditEventProducer {
62
66
  listen(notebookPanel, pioneer) {
63
67
  var _a, _b;
64
68
  const sendDoc = async (_, cell) => {
65
- var _a, _b;
66
69
  await (cell === null || cell === void 0 ? void 0 : cell.ready); // wait until cell is ready, to prevent errors when creating new cells
67
70
  const editor = cell === null || cell === void 0 ? void 0 : cell.editor;
68
- const event = {
69
- eventName: CellEditEventProducer.id,
70
- eventTime: Date.now(),
71
- eventInfo: {
72
- index: notebookPanel.content.widgets.findIndex(value => value === cell),
73
- doc: (_b = (_a = editor === null || editor === void 0 ? void 0 : editor.state) === null || _a === void 0 ? void 0 : _a.doc) === null || _b === void 0 ? void 0 : _b.toJSON(),
74
- type: cell === null || cell === void 0 ? void 0 : cell.model.type
75
- }
76
- };
77
71
  pioneer.exporters.forEach(async (exporter) => {
78
- var _a, _b, _c;
72
+ var _a, _b, _c, _d, _e, _f, _g;
79
73
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(CellEditEventProducer.id)) {
80
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == CellEditEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
74
+ const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === ActiveCellChangeEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
75
+ const event = {
76
+ eventName: CellEditEventProducer.id,
77
+ eventTime: Date.now(),
78
+ eventInfo: {
79
+ index: notebookPanel.content.widgets.findIndex(value => value === cell),
80
+ doc: (_e = (_d = editor === null || editor === void 0 ? void 0 : editor.state) === null || _d === void 0 ? void 0 : _d.doc) === null || _e === void 0 ? void 0 : _e.toJSON(),
81
+ type: cell === null || cell === void 0 ? void 0 : cell.model.type,
82
+ metadata: logCellMetadata ? cell === null || cell === void 0 ? void 0 : cell.model.metadata : null
83
+ }
84
+ };
85
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_g = (_f = exporter.activeEvents) === null || _f === void 0 ? void 0 : _f.find(o => o.name === CellEditEventProducer.id)) === null || _g === void 0 ? void 0 : _g.logWholeNotebook);
81
86
  }
82
87
  });
83
88
  };
@@ -124,24 +129,26 @@ class CellExecuteEventProducer {
124
129
  listen(notebookPanel, pioneer) {
125
130
  NotebookActions.executed.connect(async (_, args) => {
126
131
  if (notebookPanel.content === args.notebook) {
127
- const executedCell = {
128
- id: args.cell.model.id,
129
- index: args.notebook.widgets.findIndex(value => value == args.cell),
130
- type: args.cell.model.type
131
- };
132
- const event = {
133
- eventName: CellExecuteEventProducer.id,
134
- eventTime: Date.now(),
135
- eventInfo: {
136
- cells: [executedCell],
137
- success: args.success,
138
- kernelError: args.success ? null : args.error
139
- }
140
- };
141
132
  pioneer.exporters.forEach(async (exporter) => {
142
- var _a, _b, _c;
133
+ var _a, _b, _c, _d, _e;
143
134
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(CellExecuteEventProducer.id)) {
144
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == CellExecuteEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
135
+ const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === CellExecuteEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
136
+ const executedCell = {
137
+ id: args.cell.model.id,
138
+ index: args.notebook.widgets.findIndex(value => value === args.cell),
139
+ type: args.cell.model.type,
140
+ metadata: logCellMetadata ? args.cell.model.metadata : null
141
+ };
142
+ const event = {
143
+ eventName: CellExecuteEventProducer.id,
144
+ eventTime: Date.now(),
145
+ eventInfo: {
146
+ cells: [executedCell],
147
+ success: args.success,
148
+ kernelError: args.success ? null : args.error
149
+ }
150
+ };
151
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_e = (_d = exporter.activeEvents) === null || _d === void 0 ? void 0 : _d.find(o => o.name === CellExecuteEventProducer.id)) === null || _e === void 0 ? void 0 : _e.logWholeNotebook);
145
152
  }
146
153
  });
147
154
  }
@@ -154,23 +161,26 @@ class CellRemoveEventProducer {
154
161
  listen(notebookPanel, pioneer) {
155
162
  var _a;
156
163
  (_a = notebookPanel.content.model) === null || _a === void 0 ? void 0 : _a.cells.changed.connect(async (_, args) => {
157
- var _a;
158
164
  if (args.type === 'remove') {
159
- const removedCell = {
160
- index: args.oldIndex,
161
- type: (_a = notebookPanel.content.model) === null || _a === void 0 ? void 0 : _a.cells.get(args.oldIndex).type
162
- };
163
- const event = {
164
- eventName: CellRemoveEventProducer.id,
165
- eventTime: Date.now(),
166
- eventInfo: {
167
- cells: [removedCell]
168
- }
169
- };
170
165
  pioneer.exporters.forEach(async (exporter) => {
171
- var _a, _b, _c;
166
+ var _a, _b, _c, _d, _e, _f, _g;
172
167
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(CellRemoveEventProducer.id)) {
173
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == CellRemoveEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
168
+ const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === CellRemoveEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
169
+ const removedCell = {
170
+ index: args.oldIndex,
171
+ type: (_d = notebookPanel.content.model) === null || _d === void 0 ? void 0 : _d.cells.get(args.oldIndex).type,
172
+ metadata: logCellMetadata
173
+ ? (_e = notebookPanel.content.activeCell) === null || _e === void 0 ? void 0 : _e.model.metadata
174
+ : null
175
+ };
176
+ const event = {
177
+ eventName: CellRemoveEventProducer.id,
178
+ eventTime: Date.now(),
179
+ eventInfo: {
180
+ cells: [removedCell]
181
+ }
182
+ };
183
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_g = (_f = exporter.activeEvents) === null || _f === void 0 ? void 0 : _f.find(o => o.name === CellRemoveEventProducer.id)) === null || _g === void 0 ? void 0 : _g.logWholeNotebook);
174
184
  }
175
185
  });
176
186
  }
@@ -182,25 +192,28 @@ export { CellRemoveEventProducer };
182
192
  class ClipboardCopyEventProducer {
183
193
  listen(notebookPanel, pioneer) {
184
194
  notebookPanel.node.addEventListener('copy', async () => {
185
- var _a, _b, _c;
186
- const cell = {
187
- id: (_a = notebookPanel.content.activeCell) === null || _a === void 0 ? void 0 : _a.model.id,
188
- index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
189
- type: (_b = notebookPanel.content.activeCell) === null || _b === void 0 ? void 0 : _b.model.type
190
- };
191
- const text = (_c = document.getSelection()) === null || _c === void 0 ? void 0 : _c.toString();
192
- const event = {
193
- eventName: ClipboardCopyEventProducer.id,
194
- eventTime: Date.now(),
195
- eventInfo: {
196
- cells: [cell],
197
- selection: text
198
- }
199
- };
200
195
  pioneer.exporters.forEach(async (exporter) => {
201
- var _a, _b, _c;
196
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
202
197
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(ClipboardCopyEventProducer.id)) {
203
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == ClipboardCopyEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
198
+ const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === ClipboardCopyEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
199
+ const cell = {
200
+ id: (_d = notebookPanel.content.activeCell) === null || _d === void 0 ? void 0 : _d.model.id,
201
+ index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
202
+ type: (_e = notebookPanel.content.activeCell) === null || _e === void 0 ? void 0 : _e.model.type,
203
+ metadata: logCellMetadata
204
+ ? (_f = notebookPanel.content.activeCell) === null || _f === void 0 ? void 0 : _f.model.metadata
205
+ : null
206
+ };
207
+ const text = (_g = document.getSelection()) === null || _g === void 0 ? void 0 : _g.toString();
208
+ const event = {
209
+ eventName: ClipboardCopyEventProducer.id,
210
+ eventTime: Date.now(),
211
+ eventInfo: {
212
+ cells: [cell],
213
+ selection: text
214
+ }
215
+ };
216
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_j = (_h = exporter.activeEvents) === null || _h === void 0 ? void 0 : _h.find(o => o.name === ClipboardCopyEventProducer.id)) === null || _j === void 0 ? void 0 : _j.logWholeNotebook);
204
217
  }
205
218
  });
206
219
  });
@@ -211,25 +224,28 @@ export { ClipboardCopyEventProducer };
211
224
  class ClipboardCutEventProducer {
212
225
  listen(notebookPanel, pioneer) {
213
226
  notebookPanel.node.addEventListener('cut', async () => {
214
- var _a, _b, _c;
215
- const cell = {
216
- id: (_a = notebookPanel.content.activeCell) === null || _a === void 0 ? void 0 : _a.model.id,
217
- index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
218
- type: (_b = notebookPanel.content.activeCell) === null || _b === void 0 ? void 0 : _b.model.type
219
- };
220
- const text = (_c = document.getSelection()) === null || _c === void 0 ? void 0 : _c.toString();
221
- const event = {
222
- eventName: ClipboardCutEventProducer.id,
223
- eventTime: Date.now(),
224
- eventInfo: {
225
- cells: [cell],
226
- selection: text
227
- }
228
- };
229
227
  pioneer.exporters.forEach(async (exporter) => {
230
- var _a, _b, _c;
228
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
231
229
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(ClipboardCutEventProducer.id)) {
232
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == ClipboardCutEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
230
+ const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === ClipboardCutEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
231
+ const cell = {
232
+ id: (_d = notebookPanel.content.activeCell) === null || _d === void 0 ? void 0 : _d.model.id,
233
+ index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
234
+ type: (_e = notebookPanel.content.activeCell) === null || _e === void 0 ? void 0 : _e.model.type,
235
+ metadata: logCellMetadata
236
+ ? (_f = notebookPanel.content.activeCell) === null || _f === void 0 ? void 0 : _f.model.metadata
237
+ : null
238
+ };
239
+ const text = (_g = document.getSelection()) === null || _g === void 0 ? void 0 : _g.toString();
240
+ const event = {
241
+ eventName: ClipboardCutEventProducer.id,
242
+ eventTime: Date.now(),
243
+ eventInfo: {
244
+ cells: [cell],
245
+ selection: text
246
+ }
247
+ };
248
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_j = (_h = exporter.activeEvents) === null || _h === void 0 ? void 0 : _h.find(o => o.name === ClipboardCutEventProducer.id)) === null || _j === void 0 ? void 0 : _j.logWholeNotebook);
233
249
  }
234
250
  });
235
251
  });
@@ -240,25 +256,28 @@ export { ClipboardCutEventProducer };
240
256
  class ClipboardPasteEventProducer {
241
257
  listen(notebookPanel, pioneer) {
242
258
  notebookPanel.node.addEventListener('paste', async (e) => {
243
- var _a, _b;
244
- const cell = {
245
- id: (_a = notebookPanel.content.activeCell) === null || _a === void 0 ? void 0 : _a.model.id,
246
- index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
247
- type: (_b = notebookPanel.content.activeCell) === null || _b === void 0 ? void 0 : _b.model.type
248
- };
249
- const text = (e.clipboardData || window.clipboardData).getData('text');
250
- const event = {
251
- eventName: ClipboardPasteEventProducer.id,
252
- eventTime: Date.now(),
253
- eventInfo: {
254
- cells: [cell],
255
- selection: text
256
- }
257
- };
258
259
  pioneer.exporters.forEach(async (exporter) => {
259
- var _a, _b, _c;
260
+ var _a, _b, _c, _d, _e, _f, _g, _h;
260
261
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(ClipboardPasteEventProducer.id)) {
261
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == ClipboardPasteEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
262
+ const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === ClipboardPasteEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
263
+ const cell = {
264
+ id: (_d = notebookPanel.content.activeCell) === null || _d === void 0 ? void 0 : _d.model.id,
265
+ index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
266
+ type: (_e = notebookPanel.content.activeCell) === null || _e === void 0 ? void 0 : _e.model.type,
267
+ metadata: logCellMetadata
268
+ ? (_f = notebookPanel.content.activeCell) === null || _f === void 0 ? void 0 : _f.model.metadata
269
+ : null
270
+ };
271
+ const text = (e.clipboardData || window.clipboardData).getData('text');
272
+ const event = {
273
+ eventName: ClipboardPasteEventProducer.id,
274
+ eventTime: Date.now(),
275
+ eventInfo: {
276
+ cells: [cell],
277
+ selection: text
278
+ }
279
+ };
280
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_h = (_g = exporter.activeEvents) === null || _g === void 0 ? void 0 : _g.find(o => o.name === ClipboardPasteEventProducer.id)) === null || _h === void 0 ? void 0 : _h.logWholeNotebook);
262
281
  }
263
282
  });
264
283
  });
@@ -279,7 +298,7 @@ class NotebookHiddenEventProducer {
279
298
  pioneer.exporters.forEach(async (exporter) => {
280
299
  var _a, _b, _c;
281
300
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(NotebookHiddenEventProducer.id)) {
282
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == NotebookHiddenEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
301
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === NotebookHiddenEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
283
302
  }
284
303
  });
285
304
  }
@@ -304,7 +323,7 @@ class NotebookOpenEventProducer {
304
323
  pioneer.exporters.forEach(async (exporter) => {
305
324
  var _a, _b, _c;
306
325
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(NotebookOpenEventProducer.id)) {
307
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == NotebookOpenEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
326
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === NotebookOpenEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
308
327
  this.produced = true;
309
328
  }
310
329
  });
@@ -325,7 +344,7 @@ class NotebookSaveEventProducer {
325
344
  pioneer.exporters.forEach(async (exporter) => {
326
345
  var _a, _b, _c;
327
346
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(NotebookSaveEventProducer.id)) {
328
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == NotebookSaveEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
347
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === NotebookSaveEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
329
348
  }
330
349
  });
331
350
  }
@@ -374,7 +393,7 @@ class NotebookScrollEventProducer {
374
393
  pioneer.exporters.forEach(async (exporter) => {
375
394
  var _a, _b, _c;
376
395
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(NotebookScrollEventProducer.id)) {
377
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == NotebookScrollEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
396
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === NotebookScrollEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
378
397
  }
379
398
  });
380
399
  });
@@ -397,7 +416,7 @@ class NotebookVisibleEventProducer {
397
416
  pioneer.exporters.forEach(async (exporter) => {
398
417
  var _a, _b, _c;
399
418
  if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(NotebookVisibleEventProducer.id)) {
400
- await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name == NotebookVisibleEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
419
+ await pioneer.publishEvent(notebookPanel, event, exporter, (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === NotebookVisibleEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logWholeNotebook);
401
420
  }
402
421
  });
403
422
  }
package/lib/types.d.ts CHANGED
@@ -7,6 +7,10 @@ export interface ActiveEvent {
7
7
  * Whether to log the whole notebook or not when the event is triggered
8
8
  */
9
9
  logWholeNotebook: boolean;
10
+ /**
11
+ * Whether to log the whole notebook or not when the event is triggered
12
+ */
13
+ logCellMetadata: boolean;
10
14
  }
11
15
  export interface ExporterArgs {
12
16
  /**
@@ -24,11 +28,11 @@ export interface ExporterArgs {
24
28
  /**
25
29
  * Additional parameters to pass to the http endpoint (optional for remote exporter)
26
30
  */
27
- params?: Object;
31
+ params?: object;
28
32
  /**
29
33
  * Environment variables to pass to the http endpoint (optional for remote exporter)
30
34
  */
31
- env?: Object[];
35
+ env?: object[];
32
36
  }
33
37
  export interface Exporter {
34
38
  /**
package/lib/utils.js CHANGED
@@ -9,12 +9,27 @@ export const sendInfoNotification = (exporters, isGlobal) => {
9
9
  message = `Telemetry data is being logged to ${exporterMessage} through jupyterlab-pioneer. \n See Help menu -> JupyterLab Pioneer for more details.`;
10
10
  }
11
11
  else if (isGlobal && !exporterMessage) {
12
- message = `Telemetry data is being logged through jupyterlab-pioneer. \n See Help menu -> JupyterLab Pioneer for more details.`;
12
+ message =
13
+ 'Telemetry data is being logged through jupyterlab-pioneer. \n See Help menu -> JupyterLab Pioneer for more details.';
13
14
  }
14
15
  else {
15
16
  message = `Embedded telemetry settings loaded. Telemetry data is being logged to ${exporterMessage} now.`;
16
17
  }
17
- Notification.info(message, { autoClose: 20000 });
18
+ const close = localStorage.getItem('pioneer:autoClose');
19
+ if (close !== null) {
20
+ Notification.info(message, { autoClose: 0 });
21
+ }
22
+ else {
23
+ Notification.info(message, {
24
+ actions: [
25
+ {
26
+ label: "Don't show again",
27
+ callback: () => localStorage.setItem('pioneer:autoClose', '0')
28
+ }
29
+ ],
30
+ autoClose: 10000
31
+ });
32
+ }
18
33
  };
19
34
  export const addInfoToHelpMenu = (app, mainMenu, version) => {
20
35
  // Add extension info to help menu
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jupyterlab-pioneer",
3
- "version": "1.6.0",
3
+ "version": "1.7.3",
4
4
  "description": "A JupyterLab extension.",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -136,11 +136,7 @@
136
136
  "selector": "interface",
137
137
  "format": [
138
138
  "PascalCase"
139
- ],
140
- "custom": {
141
- "regex": "^I[A-Z]",
142
- "match": true
143
- }
139
+ ]
144
140
  }
145
141
  ],
146
142
  "@typescript-eslint/no-unused-vars": [