Skip to content

Commit

Permalink
update js dependencies and fix zip.js
Browse files Browse the repository at this point in the history
  • Loading branch information
haaase committed Sep 16, 2023
1 parent c300640 commit a579f10
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
16 changes: 8 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</ul> -->
<!-- Include Scala.js compiled code -->
<!-- <script type="text/javascript" src="./src/main/js/ziptest.js"></script> -->
<script type="text/javascript" src="./target/scala-3.2.1/scalajs-bundler/main/miniscribe-opt-bundle.js"></script>
<script type="text/javascript" src="./target/scala-3.3.1/scalajs-bundler/main/miniscribe-opt-bundle.js"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion index_fast.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<!-- Include Scala.js compiled code -->
<!-- <script type="text/javascript" src="./src/main/js/ziptest.js"></script> -->
<script type="text/javascript"
src="./target/scala-3.2.1/scalajs-bundler/main/miniscribe-fastopt-bundle.js"></script>
src="./target/scala-3.3.1/scalajs-bundler/main/miniscribe-fastopt-bundle.js"></script>
</body>

</html>
17 changes: 11 additions & 6 deletions src/main/scala/databackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand All @@ -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/"
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down

0 comments on commit a579f10

Please sign in to comment.