mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-06 15:15:58 +00:00
Serving scalajs artifacts and provide errors to js
This commit is contained in:
parent
71985244f1
commit
d4006461f6
17
build.sbt
17
build.sbt
@ -86,7 +86,7 @@ val stylesSettings = Seq(
|
|||||||
Compile / resourceGenerators += stylesBuild.taskValue
|
Compile / resourceGenerators += stylesBuild.taskValue
|
||||||
)
|
)
|
||||||
|
|
||||||
val webjarSettings = Seq(
|
def webjarSettings(queryJS: Project) = Seq(
|
||||||
Compile / resourceGenerators += Def.task {
|
Compile / resourceGenerators += Def.task {
|
||||||
copyWebjarResources(
|
copyWebjarResources(
|
||||||
Seq((sourceDirectory in Compile).value / "webjar"),
|
Seq((sourceDirectory in Compile).value / "webjar"),
|
||||||
@ -96,6 +96,18 @@ val webjarSettings = Seq(
|
|||||||
streams.value.log
|
streams.value.log
|
||||||
)
|
)
|
||||||
}.taskValue,
|
}.taskValue,
|
||||||
|
Compile / resourceGenerators += Def.task {
|
||||||
|
val logger = streams.value.log
|
||||||
|
val out = (queryJS/Compile/fullOptJS).value
|
||||||
|
logger.info(s"Produced query js file: ${out.data}")
|
||||||
|
copyWebjarResources(
|
||||||
|
Seq(out.data),
|
||||||
|
(Compile/resourceManaged).value,
|
||||||
|
name.value,
|
||||||
|
version.value,
|
||||||
|
logger
|
||||||
|
)
|
||||||
|
}.taskValue,
|
||||||
watchSources += Watched.WatchSource(
|
watchSources += Watched.WatchSource(
|
||||||
(Compile / sourceDirectory).value / "webjar",
|
(Compile / sourceDirectory).value / "webjar",
|
||||||
FileFilter.globFilter("*.js") || FileFilter.globFilter("*.css"),
|
FileFilter.globFilter("*.js") || FileFilter.globFilter("*.css"),
|
||||||
@ -273,7 +285,6 @@ ${lines.map(_._1).mkString(",\n")}
|
|||||||
val query =
|
val query =
|
||||||
crossProject(JSPlatform, JVMPlatform)
|
crossProject(JSPlatform, JVMPlatform)
|
||||||
.withoutSuffixFor(JVMPlatform)
|
.withoutSuffixFor(JVMPlatform)
|
||||||
.crossType(CrossType.Pure)
|
|
||||||
.in(file("modules/query"))
|
.in(file("modules/query"))
|
||||||
.disablePlugins(RevolverPlugin)
|
.disablePlugins(RevolverPlugin)
|
||||||
.settings(sharedSettings)
|
.settings(sharedSettings)
|
||||||
@ -446,7 +457,7 @@ val webapp = project
|
|||||||
.settings(sharedSettings)
|
.settings(sharedSettings)
|
||||||
.settings(elmSettings)
|
.settings(elmSettings)
|
||||||
.settings(stylesSettings)
|
.settings(stylesSettings)
|
||||||
.settings(webjarSettings)
|
.settings(webjarSettings(query.js))
|
||||||
.settings(
|
.settings(
|
||||||
name := "docspell-webapp",
|
name := "docspell-webapp",
|
||||||
openapiTargetLanguage := Language.Elm,
|
openapiTargetLanguage := Language.Elm,
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package docspell.query.js
|
||||||
|
|
||||||
|
import scala.scalajs.js
|
||||||
|
import scala.scalajs.js.annotation._
|
||||||
|
|
||||||
|
import docspell.query.ItemQueryParser
|
||||||
|
|
||||||
|
@JSExportTopLevel("DsItemQueryParser")
|
||||||
|
object JSItemQueryParser {
|
||||||
|
|
||||||
|
@JSExport
|
||||||
|
def parseToFailure(input: String): Failure =
|
||||||
|
ItemQueryParser
|
||||||
|
.parse(input)
|
||||||
|
.swap
|
||||||
|
.toOption
|
||||||
|
.map(fr =>
|
||||||
|
new Failure(
|
||||||
|
fr.input,
|
||||||
|
fr.failedAt,
|
||||||
|
js.Array(fr.messages.toList.toSeq.map(_.msg): _*)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.orNull
|
||||||
|
|
||||||
|
@JSExportAll
|
||||||
|
case class Failure(input: String, failedAt: Int, messages: js.Array[String])
|
||||||
|
|
||||||
|
}
|
@ -1,14 +1,10 @@
|
|||||||
package docspell.query
|
package docspell.query
|
||||||
|
|
||||||
import scala.scalajs.js.annotation._
|
|
||||||
|
|
||||||
import docspell.query.internal.ExprParser
|
import docspell.query.internal.ExprParser
|
||||||
import docspell.query.internal.ExprUtil
|
import docspell.query.internal.ExprUtil
|
||||||
|
|
||||||
@JSExportTopLevel("DsItemQueryParser")
|
|
||||||
object ItemQueryParser {
|
object ItemQueryParser {
|
||||||
|
|
||||||
@JSExport
|
|
||||||
def parse(input: String): Either[ParseFailure, ItemQuery] =
|
def parse(input: String): Either[ParseFailure, ItemQuery] =
|
||||||
if (input.isEmpty) Right(ItemQuery.all)
|
if (input.isEmpty) Right(ItemQuery.all)
|
||||||
else {
|
else {
|
||||||
@ -22,5 +18,4 @@ object ItemQueryParser {
|
|||||||
|
|
||||||
def parseUnsafe(input: String): ItemQuery =
|
def parseUnsafe(input: String): ItemQuery =
|
||||||
parse(input).fold(m => sys.error(m.render), identity)
|
parse(input).fold(m => sys.error(m.render), identity)
|
||||||
|
|
||||||
}
|
}
|
@ -170,7 +170,8 @@ object TemplateRoutes {
|
|||||||
chooseUi(uiVersion),
|
chooseUi(uiVersion),
|
||||||
Seq(
|
Seq(
|
||||||
"/app/assets" + Webjars.clipboardjs + "/clipboard.min.js",
|
"/app/assets" + Webjars.clipboardjs + "/clipboard.min.js",
|
||||||
s"/app/assets/docspell-webapp/${BuildInfo.version}/docspell-app.js"
|
s"/app/assets/docspell-webapp/${BuildInfo.version}/docspell-app.js",
|
||||||
|
s"/app/assets/docspell-webapp/${BuildInfo.version}/docspell-query-opt.js"
|
||||||
),
|
),
|
||||||
s"/app/assets/docspell-webapp/${BuildInfo.version}/favicon",
|
s"/app/assets/docspell-webapp/${BuildInfo.version}/favicon",
|
||||||
s"/app/assets/docspell-webapp/${BuildInfo.version}/docspell.js",
|
s"/app/assets/docspell-webapp/${BuildInfo.version}/docspell.js",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user