Commit 71d98d91 authored by David Davó's avatar David Davó

Misunderstood the schema

parent 339473ea
...@@ -27,3 +27,4 @@ result ...@@ -27,3 +27,4 @@ result
default.nix default.nix
dist-*/ dist-*/
cabal.project.local cabal.project.local
cabal.config
\ No newline at end of file
...@@ -39,9 +39,12 @@ the kernel. ...@@ -39,9 +39,12 @@ the kernel.
## Displaying widgets ## Displaying widgets
The creation of a widget does not display it. To display a widget, the kernel sends a display The creation of a widget does not display it. To display a widget, the kernel sends a display
message to the frontend on the widget's iopub, with a custom mimetype instead of text/plain. message to the frontend on the widget's iopub, with a custom mimetype instead of text/plain. Since 5.0, all custom json metadata should be encoded as a json object, instead of as a serialized string.
You can also send the ViewModuleVersion in the two fields `version_major` and `verison_minor`.
Only the `model_id` is required. The `version_major` and `version_minor` fields are the version number of the schema of this specific message
(currently in sync with the WMP version). However, only the `model_id` field is required to display the widget.
[Source](https://github.com/jupyter-widgets/ipywidgets/issues/3220)
```json ```json
method = "display_data", method = "display_data",
......
...@@ -110,7 +110,7 @@ library ...@@ -110,7 +110,7 @@ library
-- The singletons package version is locked to the compiler -- The singletons package version is locked to the compiler
-- so let cabal choose the right one. -- so let cabal choose the right one.
, singletons -any , singletons < 3.0.0
-- Directories containing source files. -- Directories containing source files.
hs-source-dirs: src hs-source-dirs: src
......
...@@ -918,16 +918,13 @@ triggerDisplay = triggerEvent DisplayHandler ...@@ -918,16 +918,13 @@ triggerDisplay = triggerEvent DisplayHandler
-- | Every IHaskellWidget widget has the same IHaskellDisplay instance, for this -- | Every IHaskellWidget widget has the same IHaskellDisplay instance, for this
-- reason we need to use FlexibleContexts. The display implementation can still -- reason we need to use FlexibleContexts. The display implementation can still
-- be overriden per widget -- be overriden per widget
instance ('S.ViewModuleVersion WidgetFields w, IHaskellWidget (IPythonWidget w)) => IHaskellDisplay (IPythonWidget w) where instance IHaskellWidget (IPythonWidget w) => IHaskellDisplay (IPythonWidget w) where
display b = do display b = do
widgetSendView b -- Keeping compatibility with classic notebook widgetSendView b -- Keeping compatibility with classic notebook
(version_major,version_minor) <- versionToInteger <$> getField b ViewModuleVersion
return $ Display [ widgetdisplay $ unpack $ decodeUtf8 $ encode $ object [ return $ Display [ widgetdisplay $ unpack $ decodeUtf8 $ encode $ object [
"model_id" .= getCommUUID b, "model_id" .= getCommUUID b,
"version_major" .= version_major, "version_major" .= version_major,
"version_minor" .= version_minor] ] "version_minor" .= version_minor] ]
where where
versionToInteger :: Text -> (Int,Int) version_major = 2 :: Int
versionToInteger str = toTuple (fmap (val.decimal) (splitOn "." str)) version_minor = 0 :: Int
toTuple (x:y:_) = (x,y)
val (Right (v,_)) = v
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment