Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update scalajs-dom to 2.0.0 #377

Merged
merged 5 commits into from
Dec 15, 2021
Merged

update scalajs-dom to 2.0.0 #377

merged 5 commits into from
Dec 15, 2021

Conversation

hugo-vrijswijk
Copy link
Contributor

@hugo-vrijswijk hugo-vrijswijk commented Oct 26, 2021

Update scalajs-dom to 2.0.0. This version is not binary compatible with 1.2.0. I was running into an issue where some of my other dependencies had upgraded, but ST hadn't, resulting in an eviction error from sbt.

I've mostly followed the migration guide:

  1. Change version number
  2. Remove .for3Use2_13
  3. Run script to migrate most imports
  4. Run find-replace on dom.raw, dom.experimental, dom.crypto to replace with dom imports
  5. Test on a local project

Two pre-release versions are used to be able to use scalajs-dom 2 on tests projects:

  • japgolly react 2.0.0-RC4. Find-replace when final version is released
  • slinky 0.6.8+1-b1dd3f4c. Find-replace when final version is released

I realize the changelog for this is massive. But because of the changed imports there's not really a way around it. When someone reviews this, perhaps there's a way to filter out certain diffs (like anything that starts with scalajs.dom.?

@hugo-vrijswijk hugo-vrijswijk marked this pull request as draft October 26, 2021 17:52
CastConversion(stdNames.lib + Name("ChannelSplitterNode"), QualifiedName("org.scalajs.dom.ChannelSplitterNode")),
CastConversion(stdNames.lib + Name("CharacterData"), QualifiedName("org.scalajs.dom.CharacterData")),
CastConversion(stdNames.lib + Name("ClientQueryOptions"), QualifiedName("org.scalajs.dom.ClientQueryOptions")),
CastConversion(stdNames.lib + Name("DOMRect"), QualifiedName("org.scalajs.dom.DOMRect")),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is my biggest concern actually, What you're looking at is a table of named DOM types in typescript and in scalajs-dom used for translation. I generated this at some point.

I'd like to confirm that all the types referenced on the right hand side, for instance org.scalajs.dom.DOMRect actually exist. Do you have any script foo to do that? otherwise I'll get to it eventually :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the auto-generated API reports can be of some use for this? https://github.com/scala-js/scala-js-dom/blob/master/api-reports/2_13.txt

@oyvindberg
Copy link
Collaborator

Thank you, most of the work is done now! :)

Gotta love the scala churn, it never stops. This change is entangled with the scalajs-react major version, which means this PR is entangled with #326 . I rebased that on top of your PR, and all the tests seem to pass, which is good.

That PR is setup to publish snapshots, so we'll publish snapshots of the two PRs combined until both slinky and scalajs-react have stable releases. Hopefully that will be soon.

diffs

The diff is huge because this project uses snapshot tests - all of those files under tests/ are generated, and enforced by CI that they are up to date for each build. just running sbt test will update all of them.

Likewise the huge files underneath import-scalajs-definitions/ are also generated, and can be regenerated with sbt import-scalajs-definitions/run

@oyvindberg
Copy link
Collaborator

Snapshot published as 1.0.0-beta36+27-dc516c4d-SNAPSHOT, it needs this resolver to work:
resolvers += MavenRepository("sonatype-s01-snapshots", "https://s01.oss.sonatype.org/content/repositories/snapshots")

@armanbilge
Copy link
Contributor

Thank you both so much for taking this on, much much appreciated and sincere apologies for the churn :( let me know if there's something I can help with.

@armanbilge
Copy link
Contributor

armanbilge commented Oct 27, 2021

Ok, so I used this regex to extract the scala-js-dom types:

QualifiedName\("org\.scalajs\.dom\.(.*)"\)

which I made into a list of urls which I checked the HTTP status of:

while read LINE; do
  curl -o /dev/null --silent --head --write-out "%{http_code} $LINE\n" "$LINE"
done

giving me this list: https://gist.githubusercontent.com/armanbilge/0637566f9babf52986e9dea6dd67b630/raw/30b4f9eb557fbae5393827423f6c2eedb7b38a63/gistfile1.txt.

There were some 404s in there, but many of those were files moved to scala-2/3 split sources: https://gist.githubusercontent.com/armanbilge/0637566f9babf52986e9dea6dd67b630/raw/943426f38c7249da596d5d261a43467f3141bcca/gistfile2.txt

So in the end, we are left with:

  • ClientRectList
  • ext.Image
  • Collator
  • CollatorOptions
  • DateTimeFormat
  • DateTimeFormatOptions
  • NumberFormat
  • NumberFormatOptions
  • SupportedType

I think these are type aliases or various other things, so I'm going to track them down and make suggestions on the PR if any need fixing.

@oyvindberg
Copy link
Collaborator

Thank you @armanbilge , exactly what I had in mind we would check :)

@rpiaggio
Copy link

Snapshot published as 1.0.0-beta36+27-dc516c4d-SNAPSHOT, it needs this resolver to work: resolvers += MavenRepository("sonatype-s01-snapshots", "https://s01.oss.sonatype.org/content/repositories/snapshots")

Would it be straightforward to release a snapshot depending on scalajs-react 2.0.0-RC5 ?

My deepest thanks to everyone involved.

@rpiaggio
Copy link

Hmm. I realize we would need a snapshot that also integrates this PR in order to be able to migrate to scalajs-dom 2.

@armanbilge
Copy link
Contributor

@rpiaggio #326 is based on this PR, so the snapshot published from there against scalajs-react 2.0.0-RC4 works with sjs-dom v2. In fact, I would have expected it to work for RC5 unless there are breaking changes?

@rpiaggio
Copy link

Thank you for the quick response!

@rpiaggio #326 is based on this PR, so the snapshot published from there against scalajs-react 2.0.0-RC4 works with sjs-dom v2. In fact, I would have expected it to work for RC5 unless there are breaking changes?

I'm doing ThisBuild / libraryDependencySchemes += "com.github.japgolly.scalajs-react" %% "core_sjs1" % "always" to avoid the version conflict error betweekn RC4 and RC5; but then I get an error when compiling this ST generated class:

std/ParentNode.scala:305:17: class HTMLCollection takes type parameters
  val children: HTMLCollection = js.native

HTMLCollection is org.scalajs.dom.HTMLCollection.

We have stUseScalaJsDom := true, but setting it to false makes no difference.

@armanbilge
Copy link
Contributor

armanbilge commented Oct 30, 2021

Thanks for reporting, that's because of the changes in scala-js/scala-js-dom#593. It looks like the generator in ST will have to be adjusted to accommodate for that.

I am surprised that setting stUseScalaJsDom := false doesn't work doesn't at least generate a different error, though.

Edit: ah, it's probably to due with the flavour setting. The ST docs say that

Also note that if you use a flavour which translates types to scala-js-dom types, only types found in the chosen stdlib will be translated.

@oyvindberg
Copy link
Collaborator

oyvindberg commented Oct 30, 2021

I wrote a test to enforce that all right hand sides in that conversion tables exist, and that the number of type parameters matches. Then I fixed the few things which showed up. The biggest surprise was probably that IDBRequest has a type parameter which TS doesn't.

For reference, here is a list of types in scala-js-dom which ST will not translate to currently. I don't intend to add any of those to the conversion list now, but anyone can certainly feel free:

somewhat long list
org.scalajs.dom.AppendMode
org.scalajs.dom.BigInteger
org.scalajs.dom.BufferSource
org.scalajs.dom.CanvasProxy
org.scalajs.dom.Chunk
org.scalajs.dom.Client
org.scalajs.dom.ClientRect
org.scalajs.dom.ClientRectList
org.scalajs.dom.ClientType
org.scalajs.dom.Clients
org.scalajs.dom.Clipboard
org.scalajs.dom.CompositionEventInit
org.scalajs.dom.ConvertToBlobOptions
org.scalajs.dom.CreateImageBitmapOptions
org.scalajs.dom.CustomEventInit
org.scalajs.dom.DOMList
org.scalajs.dom.DedicatedWorkerGlobalScope
org.scalajs.dom.DocumentReadyState
org.scalajs.dom.EndOfStreamError
org.scalajs.dom.EventException
org.scalajs.dom.EventInit
org.scalajs.dom.ExtendableEvent
org.scalajs.dom.ExtendableEventInit
org.scalajs.dom.ExtendableMessageEvent
org.scalajs.dom.ExtendableMessageEventInit
org.scalajs.dom.FetchEvent
org.scalajs.dom.FetchEventInit
org.scalajs.dom.FileReaderSync
org.scalajs.dom.FocusEventInit
org.scalajs.dom.FrameType
org.scalajs.dom.FullscreenOptions
org.scalajs.dom.GetSVGDocument
org.scalajs.dom.HTMLFormControlsCollection
org.scalajs.dom.HTMLOptionsCollection
org.scalajs.dom.HTMLTableAlignment
org.scalajs.dom.HashAlgorithm
org.scalajs.dom.HeadersInit
org.scalajs.dom.HttpMethod
org.scalajs.dom.IDBCreateIndexOptions
org.scalajs.dom.IDBCreateObjectStoreOptions
org.scalajs.dom.IDBCursorDirection
org.scalajs.dom.IDBCursorReadOnly
org.scalajs.dom.IDBDatabaseInfo
org.scalajs.dom.IDBEvent
org.scalajs.dom.IDBEventTarget
org.scalajs.dom.IDBRequestReadyState
org.scalajs.dom.IDBStoreLike
org.scalajs.dom.IDBTransactionDurability
org.scalajs.dom.IDBTransactionMode
org.scalajs.dom.IDBTransactionOptions
org.scalajs.dom.IDBVersionChangeEventInit
org.scalajs.dom.ImageBitmap
org.scalajs.dom.ImageCapture
org.scalajs.dom.MediaQueryListListener
org.scalajs.dom.MediaSource
org.scalajs.dom.MediaSourceReadyState
org.scalajs.dom.MediaStreamEventInit
org.scalajs.dom.MessageEventInit
org.scalajs.dom.ModifierKeyEvent
org.scalajs.dom.ModifierKeyEventInit
org.scalajs.dom.MouseEventInit
org.scalajs.dom.NavigatorGeolocation
org.scalajs.dom.NavigatorStorageUtils
org.scalajs.dom.NavigatorVibration
org.scalajs.dom.NodeListOf
org.scalajs.dom.NodeSelector
org.scalajs.dom.OffscreenCanvas
org.scalajs.dom.OpenEndedDictionary
org.scalajs.dom.PageTransitionEvent
org.scalajs.dom.PageVisibility
org.scalajs.dom.PermissionDescriptor
org.scalajs.dom.PermissionName
org.scalajs.dom.PermissionState
org.scalajs.dom.PermissionStatus
org.scalajs.dom.Permissions
org.scalajs.dom.PushEvent
org.scalajs.dom.PushMessageData
org.scalajs.dom.PushPermissionDescriptor
org.scalajs.dom.RadioNodeList
org.scalajs.dom.ReadableStreamController
org.scalajs.dom.RequestType
org.scalajs.dom.SVGAnimatedPathData
org.scalajs.dom.SVGException
org.scalajs.dom.SVGExternalResourcesRequired
org.scalajs.dom.SVGLangSpace
org.scalajs.dom.SVGLocatable
org.scalajs.dom.SVGStylable
org.scalajs.dom.SVGTransformable
org.scalajs.dom.SVGZoomEventInit
org.scalajs.dom.Sequence
org.scalajs.dom.ServiceWorkerGlobalScope
org.scalajs.dom.SharedWorker
org.scalajs.dom.SharedWorkerGlobalScope
org.scalajs.dom.SourceBuffer
org.scalajs.dom.SourceBufferList
org.scalajs.dom.StorageEstimate
org.scalajs.dom.StorageEventInit
org.scalajs.dom.StorageManager
org.scalajs.dom.TextEventInit
org.scalajs.dom.TextTrackMode
org.scalajs.dom.TouchEventInit
org.scalajs.dom.Transferable
org.scalajs.dom.TwoDContextAttributes
org.scalajs.dom.UIEventInit
org.scalajs.dom.URLSearchParams
org.scalajs.dom.VideoTrack
org.scalajs.dom.VideoTrackList
org.scalajs.dom.WheelEventInit
org.scalajs.dom.WindowClient
org.scalajs.dom.WindowOrWorkerGlobalScope
org.scalajs.dom.WorkerGlobalScope
org.scalajs.dom.WorkerLocation
org.scalajs.dom.WorkerNavigator
org.scalajs.dom.WriteableState
org.scalajs.dom.WriteableStream
org.scalajs.dom.XPathNSResolver
org.scalajs.dom.webgl.ActiveInfo
org.scalajs.dom.webgl.Buffer
org.scalajs.dom.webgl.ContextAttributes
org.scalajs.dom.webgl.Framebuffer
org.scalajs.dom.webgl.Program
org.scalajs.dom.webgl.Renderbuffer
org.scalajs.dom.webgl.RenderingContext
org.scalajs.dom.webgl.Shader
org.scalajs.dom.webgl.ShaderPrecisionFormat
org.scalajs.dom.webgl.Texture
org.scalajs.dom.webgl.UniformLocation
org.scalajs.dom.webgl.extensions.ANGLEInstancedArrays
org.scalajs.dom.webgl.extensions.EXTBlendMinmax
org.scalajs.dom.webgl.extensions.EXTColorBufferHalfFloat
org.scalajs.dom.webgl.extensions.EXTDisjointTimerQuery
org.scalajs.dom.webgl.extensions.EXTFragDepth
org.scalajs.dom.webgl.extensions.EXTShaderTextureLOD
org.scalajs.dom.webgl.extensions.EXTTextureFilterAnisotropic
org.scalajs.dom.webgl.extensions.EXTsRGB
org.scalajs.dom.webgl.extensions.OESElementIndexUint
org.scalajs.dom.webgl.extensions.OESStandardDerivatives
org.scalajs.dom.webgl.extensions.OESTextureFloat
org.scalajs.dom.webgl.extensions.OESTextureFloatLinear
org.scalajs.dom.webgl.extensions.OESTextureHalfFloat
org.scalajs.dom.webgl.extensions.OESTextureHalfFloatLinear
org.scalajs.dom.webgl.extensions.OESVertexArrayObject
org.scalajs.dom.webgl.extensions.WEBGLColorBufferFloat
org.scalajs.dom.webgl.extensions.WEBGLCompressedTextureETC1
org.scalajs.dom.webgl.extensions.WEBGLDrawBuffers
org.scalajs.dom.webgl.extensions.WebGLCompressedTextureATC
org.scalajs.dom.webgl.extensions.WebGLCompressedTexturePVRTC
org.scalajs.dom.webgl.extensions.WebGLCompressedTextureS3TC
org.scalajs.dom.webgl.extensions.WebGLDebugRendererInfo
org.scalajs.dom.webgl.extensions.WebGLDebugShaders
org.scalajs.dom.webgl.extensions.WebGLDepthTexture
org.scalajs.dom.webgl.extensions.WebGLLoseContext
org.scalajs.dom.webgl.extensions.WebGLTimerQueryEXT
org.scalajs.dom.webgl.extensions.WebGLVertexArrayObjectOES
org.scalajs.dom.webworkers.AbstractWorker
org.scalajs.dom.webworkers.DedicatedWorkerGlobalScope
org.scalajs.dom.webworkers.Worker
org.scalajs.dom.webworkers.WorkerGlobalScope
org.scalajs.dom.webworkers.WorkerLocation
org.scalajs.dom.webworkers.WorkerNavigator

I also bumped #326 to use 2.0.0-M5, a snapshot if hopefully on the way

@armanbilge
Copy link
Contributor

The biggest surprise was probably that IDBRequest has a type parameter which TS doesn't.

Yes, I think that was done in scala-js/scala-js-dom#569. Hope it didn't cause too much trouble 😅

Quite a list there!

@oyvindberg
Copy link
Collaborator

oyvindberg commented Oct 30, 2021

No, not a problem at all @armanbilge :)

snapshot published with version 1.0.0-beta36+29-f3b7dd30-SNAPSHOT edit: use 1.0.0-beta36+41-906a0cad-SNAPSHOT

@hugo-vrijswijk
Copy link
Contributor Author

Thanks for the extensive review and comments. I might have bitten off more than I can chew with this PR, as my SJS and ST experience are limited, and this PR grew a lot. I see the build is still red, but I'm not sure what the exact reason for it is and what still needs to be done for this PR to be merged 😅

@armanbilge
Copy link
Contributor

@hugo-vrijswijk as previously mentioned this PR is entangled with #326 which IIUC means they need to be merged at the same time (this one cannot standalone). Given that #326 is rebased against this, the fact that it is green there is a good sign :)

@rpiaggio
Copy link

snapshot published with version 1.0.0-beta36+29-f3b7dd30-SNAPSHOT

Awesome, our library compiles with this version. Thank you very much!

@hugo-vrijswijk hugo-vrijswijk marked this pull request as ready for review November 2, 2021 08:51
@ngbinh
Copy link

ngbinh commented Nov 7, 2021

scala.js react 2.0.0 final has been released with not much changes https://github.com/japgolly/scalajs-react/blob/master/doc/changelog/2.0.0-RCs.md#changes-in-between-rc5-and-200-final

@oyvindberg
Copy link
Collaborator

Now we only need a stable version of slinky :)

@oyvindberg
Copy link
Collaborator

Ok, tired of being blocked. This is going in anyway, and I'll release when possible. with a slinky snapshot version if necessary

@oyvindberg oyvindberg merged commit b3efa41 into ScalablyTyped:master Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants