From a579f10acd510e5c1d4dca0a703fbf5e76529893 Mon Sep 17 00:00:00 2001 From: Julian Date: Sat, 16 Sep 2023 14:49:35 +0200 Subject: [PATCH] update js dependencies and fix zip.js --- build.sbt | 16 ++++++++-------- index.html | 2 +- index_fast.html | 2 +- src/main/scala/databackend.scala | 17 +++++++++++------ yarn.lock | 2 +- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/build.sbt b/build.sbt index 280b55c..92aa8fd 100644 --- a/build.sbt +++ b/build.sbt @@ -34,17 +34,17 @@ libraryDependencies += "com.lihaoyi" %%% "scalatags" % "0.12.0" // js/ts dependencies webpack / version := "5.76.2" -Compile / npmDependencies += "@zip.js/zip.js" -> "^2.6.62" +Compile / npmDependencies += "@zip.js/zip.js" -> "^2.7.29" Compile / npmDependencies += "idb-keyval" -> "^6.2.1" Compile / npmDevDependencies += "compression-webpack-plugin" -> "10.0.0" // dependabot alerts -Compile / additionalNpmConfig ++= Map( - "resolutions" -> obj( - "ansi-html" -> str("^0.0.8"), - "glob-parent" -> str("^5.1.2"), - "node-forge" -> str("^1.3.0") - ) -) +// Compile / additionalNpmConfig ++= Map( +// "resolutions" -> obj( +// "ansi-html" -> str("^0.0.8"), +// "glob-parent" -> str("^5.1.2"), +// "node-forge" -> str("^1.3.0") +// ) +// ) // disable sourcemaps Compile / fastOptJS / scalaJSLinkerConfig ~= { _.withSourceMap(false) } Compile / fullOptJS / scalaJSLinkerConfig ~= { _.withSourceMap(false) } diff --git a/index.html b/index.html index 5eaea60..7fc986f 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@ --> - + \ No newline at end of file diff --git a/index_fast.html b/index_fast.html index de46ef9..8f87330 100644 --- a/index_fast.html +++ b/index_fast.html @@ -18,7 +18,7 @@ + src="./target/scala-3.3.1/scalajs-bundler/main/miniscribe-fastopt-bundle.js"> \ No newline at end of file diff --git a/src/main/scala/databackend.scala b/src/main/scala/databackend.scala index bd13911..320c21f 100644 --- a/src/main/scala/databackend.scala +++ b/src/main/scala/databackend.scala @@ -4,10 +4,11 @@ import cats.syntax.all._ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future import scala.scalajs.js +import scala.scalajs.js.Promise import scala.scalajs.js.typedarray.Uint8Array import scala.scalajs.js.JSConverters._ import org.scalajs.dom.Blob -import typings.zipJsZipJs.mod.{BlobReader, TextWriter, ZipReader} +import typings.zipJsZipJs.mod.{BlobReader, Entry, TextWriter, ZipReader} import sttp.client3._ import fs2.{Fallible, Stream} import fs2.data.xml._ @@ -20,8 +21,8 @@ object DataBackend: // urls private val fetchBackend = FetchBackend() private val corsProxy = - // uri"https://miniscribe-cors.fly.dev" - uri"http://localhost:8080" + uri"https://miniscribe-cors.fly.dev" + // uri"http://localhost:8080" // see https://gallery.bsdata.net/?repo=middle-earth and https://github.com/BSData/gallery for better alternative private val mesbgRoot = uri"$corsProxy/https://github.com/BSData/middle-earth/releases/latest/download/" @@ -32,11 +33,15 @@ object DataBackend: val zipFileBlob = new Blob(js.Array(zipFileJs)) val zipFileReader = new BlobReader(zipFileBlob) val zipReader = new ZipReader(zipFileReader) - val helloWorldWriter = new TextWriter() + val textWriter = new TextWriter() for entries <- zipReader.getEntries().toFuture - firstEntry = entries.shift() - result <- firstEntry.getData_MEntry(helloWorldWriter).toFuture + firstEntry = entries.shift().asInstanceOf[Entry] + // result <- firstEntry.getData_MEntry(helloWorldWriter).toFuture + result <- firstEntry.getData + // necessary fix because scalablytyped could not infer type + .asInstanceOf[js.Function1[TextWriter, Promise[String]]](textWriter) + .toFuture _ <- zipReader.close().toFuture yield result diff --git a/yarn.lock b/yarn.lock index 6fb455d..e034419 100644 --- a/yarn.lock +++ b/yarn.lock @@ -244,7 +244,7 @@ resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== -"@zip.js/zip.js@^2.6.62": +"@zip.js/zip.js@^2.7.29": version "2.7.29" resolved "https://registry.yarnpkg.com/@zip.js/zip.js/-/zip.js-2.7.29.tgz#852dddcaa9f0c9dffbef932d424c4d79a731f088" integrity sha512-KtOa3HY7Vi77ctZAVhx2nsKweDTCP4DVBghZkvg5qyIX6T/Z54QlU6f0q2hFhxu5j+LgUDeMMhiv2xj4ZF6snA==