jupyter-chat-example 0.8.1 → 0.10.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.
package/lib/index.js CHANGED
@@ -2,14 +2,19 @@
2
2
  * Copyright (c) Jupyter Development Team.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
- import { ActiveCellManager, AttachmentOpenerRegistry, buildChatSidebar, ChatModel, SelectionWatcher } from '@jupyter/chat';
5
+ import { ActiveCellManager, AttachmentOpenerRegistry, buildChatSidebar, AbstractChatModel, SelectionWatcher, AbstractChatContext } from '@jupyter/chat';
6
6
  import { IThemeManager } from '@jupyterlab/apputils';
7
7
  import { IDefaultFileBrowser } from '@jupyterlab/filebrowser';
8
8
  import { INotebookTracker } from '@jupyterlab/notebook';
9
9
  import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
10
10
  import { ISettingRegistry } from '@jupyterlab/settingregistry';
11
11
  import { UUID } from '@lumino/coreutils';
12
- class MyChatModel extends ChatModel {
12
+ class ChatContext extends AbstractChatContext {
13
+ get users() {
14
+ return [];
15
+ }
16
+ }
17
+ class MyChatModel extends AbstractChatModel {
13
18
  sendMessage(newMessage) {
14
19
  var _a;
15
20
  const message = {
@@ -23,6 +28,9 @@ class MyChatModel extends ChatModel {
23
28
  this.messageAdded(message);
24
29
  this.input.clearAttachments();
25
30
  }
31
+ createChatContext() {
32
+ return new ChatContext({ model: this });
33
+ }
26
34
  }
27
35
  /*
28
36
  * Extension providing a chat panel.
@@ -51,7 +59,11 @@ const plugin = {
51
59
  const selectionWatcher = new SelectionWatcher({
52
60
  shell: app.shell
53
61
  });
54
- const model = new MyChatModel({ activeCellManager, selectionWatcher });
62
+ const model = new MyChatModel({
63
+ activeCellManager,
64
+ selectionWatcher,
65
+ documentManager: filebrowser === null || filebrowser === void 0 ? void 0 : filebrowser.model.manager
66
+ });
55
67
  // Update the settings when they change.
56
68
  function loadSetting(setting) {
57
69
  model.config = {
@@ -89,7 +101,6 @@ const plugin = {
89
101
  model,
90
102
  rmRegistry,
91
103
  themeManager,
92
- documentManager: filebrowser === null || filebrowser === void 0 ? void 0 : filebrowser.model.manager,
93
104
  attachmentOpenerRegistry
94
105
  });
95
106
  app.shell.add(panel, 'left');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jupyter-chat-example",
3
- "version": "0.8.1",
3
+ "version": "0.10.0",
4
4
  "description": "A chat extension providing a chat as example",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -44,7 +44,7 @@
44
44
  "install:extension": "jlpm build"
45
45
  },
46
46
  "dependencies": {
47
- "@jupyter/chat": "^0.8.1",
47
+ "@jupyter/chat": "^0.10.0",
48
48
  "@jupyterlab/application": "^4.2.0",
49
49
  "@jupyterlab/apputils": "^4.3.0",
50
50
  "@jupyterlab/notebook": "^4.2.0",
package/src/index.ts CHANGED
@@ -7,11 +7,13 @@ import {
7
7
  ActiveCellManager,
8
8
  AttachmentOpenerRegistry,
9
9
  buildChatSidebar,
10
- ChatModel,
10
+ AbstractChatModel,
11
11
  IAttachment,
12
12
  IChatMessage,
13
13
  INewMessage,
14
- SelectionWatcher
14
+ SelectionWatcher,
15
+ IChatContext,
16
+ AbstractChatContext
15
17
  } from '@jupyter/chat';
16
18
  import {
17
19
  JupyterFrontEnd,
@@ -24,7 +26,13 @@ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
24
26
  import { ISettingRegistry } from '@jupyterlab/settingregistry';
25
27
  import { UUID } from '@lumino/coreutils';
26
28
 
27
- class MyChatModel extends ChatModel {
29
+ class ChatContext extends AbstractChatContext {
30
+ get users() {
31
+ return [];
32
+ }
33
+ }
34
+
35
+ class MyChatModel extends AbstractChatModel {
28
36
  sendMessage(
29
37
  newMessage: INewMessage
30
38
  ): Promise<boolean | void> | boolean | void {
@@ -39,6 +47,10 @@ class MyChatModel extends ChatModel {
39
47
  this.messageAdded(message);
40
48
  this.input.clearAttachments();
41
49
  }
50
+
51
+ createChatContext(): IChatContext {
52
+ return new ChatContext({ model: this });
53
+ }
42
54
  }
43
55
 
44
56
  /*
@@ -77,7 +89,11 @@ const plugin: JupyterFrontEndPlugin<void> = {
77
89
  shell: app.shell
78
90
  });
79
91
 
80
- const model = new MyChatModel({ activeCellManager, selectionWatcher });
92
+ const model = new MyChatModel({
93
+ activeCellManager,
94
+ selectionWatcher,
95
+ documentManager: filebrowser?.model.manager
96
+ });
81
97
 
82
98
  // Update the settings when they change.
83
99
  function loadSetting(setting: ISettingRegistry.ISettings): void {
@@ -122,7 +138,6 @@ const plugin: JupyterFrontEndPlugin<void> = {
122
138
  model,
123
139
  rmRegistry,
124
140
  themeManager,
125
- documentManager: filebrowser?.model.manager,
126
141
  attachmentOpenerRegistry
127
142
  });
128
143
  app.shell.add(panel, 'left');