Skip to content

Commit dc64e61

Browse files
authored
Merge pull request #3458 from jupyter-widgets/update-migration-guide
Update migration guide to 8.0
2 parents 6ce6130 + 142d704 commit dc64e61

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

docs/source/migration_guides.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ You can also apply the following diff if you only want to support ipywidgets==8
5353

5454
```diff
5555
- "@jupyter-widgets/base": "^2 || ^3 || ^4",
56-
+ "@jupyter-widgets/base": "^5 || ^6",
56+
+ "@jupyter-widgets/base": "^6",
5757
```
5858

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.
6060

61-
The ``ManagerBase`` class has been moved from the ``@jupyter-widgets/base`` package to 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.
6262

6363
```diff
6464
+ "@jupyter-widgets/base-manager": "^1",
@@ -115,18 +115,41 @@ The ``DOMWidgetView.processPhosphorMessage`` method has been renamed ``DOMWidget
115115

116116
I you're dropping ipywidgets 7.x support, you can simply rename the `processPhosphorMessage` method into `processLuminoMessage`.
117117

118-
#### ManagerBase import
118+
#### Widget manager import
119119

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:
121121

122122
```diff
123123
- import { ManagerBase } from '@jupyter-widgets/base';
124124
+ import { ManagerBase } from '@jupyter-widgets/base-manager';
125125
```
126126

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+
127150
#### Backbone extend
128151

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:
130153

131154
```diff
132155
- var CustomWidgetModel = Widget.extend({
@@ -137,6 +160,9 @@ If you were extending the base widget model with `var CustomWidgetModel = Widget
137160
+ }
138161
```
139162

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.
164+
165+
140166
Migrating from 6.0 to 7.0
141167
-------------------------
142168

0 commit comments

Comments
 (0)