You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/migration_guides.md
+32-6Lines changed: 32 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,12 +53,12 @@ You can also apply the following diff if you only want to support ipywidgets==8
53
53
54
54
```diff
55
55
- "@jupyter-widgets/base": "^2 || ^3 || ^4",
56
-
+ "@jupyter-widgets/base": "^5 || ^6",
56
+
+ "@jupyter-widgets/base": "^6",
57
57
```
58
58
59
-
Note that "@jupyter-widgets/base" version 5 is for ipywidgets 8 support in the front-end, "@jupyter-widgets/base" version 6 is for ipywidgets 8 **and JupyterLab 4** support in the front-end.
59
+
Note that "@jupyter-widgets/base" version 5 is reserved for **ipywidgets 7 support on JupyterLab 4**, "@jupyter-widgets/base" version 6 is the version released with ipywidgets 8.
60
60
61
-
The ``ManagerBase`` class has been moved from the ``@jupyter-widgets/base`` packageto the new ``@jupyter-widgets/base-manager`` package. So if you used to depend on that ``ManagerBase`` class, you need to add the new dependency in your ``package.json`` as following, and update your imports accordingly.
61
+
The ``ManagerBase`` class has been split into an interface type `IWidgetManager` which remains in the ``@jupyter-widgets/base`` package, and its implementation which has moved to the new ``@jupyter-widgets/base-manager`` package. So if you subclass the ``ManagerBase`` class, you will need to add a new dependency in your ``package.json`` as following, and update your imports accordingly.
62
62
63
63
```diff
64
64
+ "@jupyter-widgets/base-manager": "^1",
@@ -115,18 +115,41 @@ The ``DOMWidgetView.processPhosphorMessage`` method has been renamed ``DOMWidget
115
115
116
116
I you're dropping ipywidgets 7.x support, you can simply rename the `processPhosphorMessage` method into `processLuminoMessage`.
117
117
118
-
#### ManagerBase import
118
+
#### Widget manager import
119
119
120
-
As mentionned before, if you depend on the ``ManagerBase`` class, you will need to update the import:
120
+
As mentioned before, if you depend on the ``ManagerBase`` class, you will**either** need to update the import:
121
121
122
122
```diff
123
123
- import { ManagerBase } from '@jupyter-widgets/base';
124
124
+ import { ManagerBase } from '@jupyter-widgets/base-manager';
125
125
```
126
126
127
+
**or**, siwtch to using the new `IWidgetManager` interface in the `base` package:
128
+
129
+
```diff
130
+
- import { ManagerBase } from '@jupyter-widgets/base';
131
+
+ import { IWidgetManager } from '@jupyter-widgets/base';
132
+
```
133
+
134
+
Which one to pick depends on how you use it. If you are using it as the base class for your own implementation of a widget manager, and want to subclass it in order to reuse the methods/logic in that implementation, you should depend on the `base-manager` package. If you are only interested in the TypeScript type for a widget manager, e.g. for use in the arguments of a deserializer function, you should use the `IWidgetManager` interface type.
135
+
136
+
Typescript trick:
137
+
If you need to support a deserializer function against both ipywidgets 7 and older and the new version 8, you can change your deserializer function to have the following signature:
138
+
139
+
```diff
140
+
- import { ManagerBase } from '@jupyter-widgets/base';
141
+
+ import { unpack_models } from '@jupyter-widgets/base';
142
+
143
+
export async function myDeserializer(
144
+
obj: MyObjectType,
145
+
- manager?: ManagerBase
146
+
+ manager?: Parameters<typeof unpack_models>[1]
147
+
): Promise<JSONValue> {
148
+
```
149
+
127
150
#### Backbone extend
128
151
129
-
If you were extending the base widget model with `var CustomWidgetModel = Widget.extend({ ... });` you will need to update the class definition using the ES6 notation:
152
+
The version of backbone that ipywidgets depend on has changed from 1.2.3 to 1.4.0. If you were extending the base widget model with `var CustomWidgetModel = Widget.extend({ ... });` you will need to update the class definition using the ES6 notation:
130
153
131
154
```diff
132
155
- var CustomWidgetModel = Widget.extend({
@@ -137,6 +160,9 @@ If you were extending the base widget model with `var CustomWidgetModel = Widget
137
160
+ }
138
161
```
139
162
163
+
Note: If you were relying on setting certain instance attributes via the `extend` method, you might now need override the `preinitialize` method in order for their values to be set in time.
0 commit comments