mirror of
https://github.com/enso-org/enso.git
synced 2024-11-22 03:32:23 +03:00
refactor: ydoc
This commit is contained in:
parent
6b758a0938
commit
aa42f76cde
57
build.sbt
57
build.sbt
@ -385,6 +385,7 @@ lazy val enso = (project in file("."))
|
||||
`test-utils`,
|
||||
`text-buffer`,
|
||||
`version-output`,
|
||||
ydoc,
|
||||
`ydoc-server`,
|
||||
`zio-wrapper`
|
||||
)
|
||||
@ -1885,8 +1886,8 @@ lazy val searcher = project
|
||||
.dependsOn(testkit % Test)
|
||||
.dependsOn(`polyglot-api`)
|
||||
|
||||
lazy val `ydoc-server` = project
|
||||
.in(file("lib/java/ydoc-server"))
|
||||
lazy val ydoc = project
|
||||
.in(file("lib/java/ydoc"))
|
||||
.enablePlugins(JPMSPlugin)
|
||||
.configs(Test)
|
||||
.settings(
|
||||
@ -1897,14 +1898,50 @@ lazy val `ydoc-server` = project
|
||||
autoScalaLibrary := false,
|
||||
Test / fork := true,
|
||||
commands += WithDebugCommand.withDebug,
|
||||
Compile / moduleDependencies ++= {
|
||||
GraalVM.modules ++ GraalVM.jsPkgs ++ GraalVM.chromeInspectorPkgs ++ helidon ++ Seq(
|
||||
"org.slf4j" % "slf4j-api" % slf4jVersion
|
||||
)
|
||||
},
|
||||
Compile / internalModuleDependencies := Seq(
|
||||
(`syntax-rust-definition` / Compile / exportedModule).value
|
||||
),
|
||||
libraryDependencies ++= Seq(
|
||||
"org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided",
|
||||
"org.graalvm.polyglot" % "inspect-community" % graalMavenPackagesVersion % "runtime",
|
||||
"org.graalvm.polyglot" % "js-community" % graalMavenPackagesVersion % "runtime",
|
||||
"org.slf4j" % "slf4j-api" % slf4jVersion,
|
||||
"io.helidon.webclient" % "helidon-webclient-websocket" % helidonVersion,
|
||||
"io.helidon.webserver" % "helidon-webserver-websocket" % helidonVersion,
|
||||
"junit" % "junit" % junitVersion % Test,
|
||||
"com.github.sbt" % "junit-interface" % junitIfVersion % Test
|
||||
),
|
||||
libraryDependencies ++= {
|
||||
GraalVM.modules ++ GraalVM.jsPkgs ++ GraalVM.chromeInspectorPkgs ++ helidon
|
||||
}
|
||||
)
|
||||
.dependsOn(`syntax-rust-definition`)
|
||||
|
||||
lazy val `ydoc-server` = project
|
||||
.in(file("lib/java/ydoc-server"))
|
||||
.enablePlugins(JPMSPlugin)
|
||||
.configs(Test)
|
||||
.settings(
|
||||
customFrgaalJavaCompilerSettings("21"),
|
||||
javaModuleName := "org.enso.ydoc.server",
|
||||
Compile / exportJars := true,
|
||||
crossPaths := false,
|
||||
autoScalaLibrary := false,
|
||||
Test / fork := true,
|
||||
commands += WithDebugCommand.withDebug,
|
||||
Compile / moduleDependencies ++= {
|
||||
GraalVM.modules ++ GraalVM.jsPkgs ++ GraalVM.chromeInspectorPkgs ++ helidon ++ logbackPkg ++ Seq(
|
||||
"org.slf4j" % "slf4j-api" % slf4jVersion
|
||||
)
|
||||
},
|
||||
Compile / internalModuleDependencies := Seq(
|
||||
(`syntax-rust-definition` / Compile / exportedModule).value,
|
||||
(`profiling-utils` / Compile / exportedModule).value
|
||||
(ydoc / Compile / exportedModule).value,
|
||||
(`syntax-rust-definition` / Compile / exportedModule).value
|
||||
),
|
||||
libraryDependencies ++= Seq(
|
||||
"org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided",
|
||||
@ -1912,8 +1949,9 @@ lazy val `ydoc-server` = project
|
||||
"org.graalvm.polyglot" % "inspect-community" % graalMavenPackagesVersion % "runtime",
|
||||
"org.graalvm.polyglot" % "js-community" % graalMavenPackagesVersion % "runtime",
|
||||
"org.slf4j" % "slf4j-api" % slf4jVersion,
|
||||
"io.helidon.webclient" % "helidon-webclient-websocket" % helidonVersion,
|
||||
"io.helidon.webserver" % "helidon-webserver-websocket" % helidonVersion,
|
||||
"io.helidon.common" % "helidon-common" % helidonVersion,
|
||||
"io.helidon.webclient" % "helidon-webclient-websocket" % helidonVersion % Test,
|
||||
"io.helidon.webserver" % "helidon-webserver-websocket" % helidonVersion % Test,
|
||||
"junit" % "junit" % junitVersion % Test,
|
||||
"com.github.sbt" % "junit-interface" % junitIfVersion % Test,
|
||||
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonVersion % Test
|
||||
@ -1936,8 +1974,7 @@ lazy val `ydoc-server` = project
|
||||
// would result in an sbt caught in an infinite recursion.
|
||||
//
|
||||
Compile / run / javaOptions ++= {
|
||||
val mp =
|
||||
(Compile / modulePath).value ++ (`profiling-utils` / Compile / modulePath).value
|
||||
val mp = (Compile / modulePath).value
|
||||
val jar = (Compile / exportedProductJars).value.head
|
||||
val modName = javaModuleName.value
|
||||
val allMp = mp ++ Seq(jar.data.absolutePath)
|
||||
@ -1969,7 +2006,7 @@ lazy val `ydoc-server` = project
|
||||
.buildNativeImage(
|
||||
"ydoc",
|
||||
staticOnLinux = false,
|
||||
mainClass = Some("org.enso.ydoc.Main")
|
||||
mainClass = Some("org.enso.ydoc.server.Main")
|
||||
)
|
||||
.value,
|
||||
buildNativeImage := NativeImage
|
||||
@ -1979,7 +2016,7 @@ lazy val `ydoc-server` = project
|
||||
)
|
||||
.value
|
||||
)
|
||||
.dependsOn(`syntax-rust-definition`)
|
||||
.dependsOn(ydoc)
|
||||
.dependsOn(`logging-service-logback`)
|
||||
|
||||
lazy val `persistance` = (project in file("lib/java/persistance"))
|
||||
|
@ -1,14 +1,9 @@
|
||||
module org.enso.ydoc {
|
||||
requires io.helidon.webclient;
|
||||
requires io.helidon.webclient.websocket;
|
||||
requires io.helidon.webserver;
|
||||
requires io.helidon.webserver.websocket;
|
||||
requires org.enso.syntax;
|
||||
module org.enso.ydoc.server {
|
||||
requires io.helidon.common;
|
||||
requires org.enso.ydoc;
|
||||
requires org.graalvm.polyglot;
|
||||
requires org.slf4j;
|
||||
requires static org.graalvm.nativeimage;
|
||||
|
||||
opens org.enso.ydoc.polyfill.web;
|
||||
|
||||
exports org.enso.ydoc;
|
||||
exports org.enso.ydoc.server;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.enso.ydoc;
|
||||
package org.enso.ydoc.server;
|
||||
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.enso.ydoc;
|
||||
package org.enso.ydoc.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CompletableFuture;
|
@ -1,4 +1,4 @@
|
||||
package org.enso.ydoc.polyfill.web;
|
||||
package org.enso.ydoc.server.nativeimage;
|
||||
|
||||
import com.oracle.svm.core.annotate.Substitute;
|
||||
import com.oracle.svm.core.annotate.TargetClass;
|
@ -1,4 +1,4 @@
|
||||
package org.enso.ydoc.polyfill.web;
|
||||
package org.enso.ydoc.server.nativeimage;
|
||||
|
||||
import com.oracle.svm.core.annotate.Alias;
|
||||
import com.oracle.svm.core.annotate.RecomputeFieldValue;
|
@ -1,6 +0,0 @@
|
||||
package org.enso.ydoc.jsonrpc.model.result;
|
||||
|
||||
import java.util.List;
|
||||
import org.enso.ydoc.jsonrpc.model.FileSystemObject;
|
||||
|
||||
public record FileListResult(List<FileSystemObject> paths) implements Result {}
|
@ -1,3 +0,0 @@
|
||||
package org.enso.ydoc.jsonrpc.model.result;
|
||||
|
||||
public interface Result {}
|
@ -1,4 +1,4 @@
|
||||
package org.enso.ydoc;
|
||||
package org.enso.ydoc.server;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@ -18,15 +18,15 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.enso.ydoc.jsonrpc.JsonRpcRequest;
|
||||
import org.enso.ydoc.jsonrpc.JsonRpcResponse;
|
||||
import org.enso.ydoc.jsonrpc.model.ContentRoot;
|
||||
import org.enso.ydoc.jsonrpc.model.FilePath;
|
||||
import org.enso.ydoc.jsonrpc.model.FileSystemObject;
|
||||
import org.enso.ydoc.jsonrpc.model.WriteCapability;
|
||||
import org.enso.ydoc.jsonrpc.model.result.FileListResult;
|
||||
import org.enso.ydoc.jsonrpc.model.result.InitProtocolConnectionResult;
|
||||
import org.enso.ydoc.jsonrpc.model.result.TextOpenFileResult;
|
||||
import org.enso.ydoc.server.jsonrpc.JsonRpcRequest;
|
||||
import org.enso.ydoc.server.jsonrpc.JsonRpcResponse;
|
||||
import org.enso.ydoc.server.jsonrpc.model.ContentRoot;
|
||||
import org.enso.ydoc.server.jsonrpc.model.FilePath;
|
||||
import org.enso.ydoc.server.jsonrpc.model.FileSystemObject;
|
||||
import org.enso.ydoc.server.jsonrpc.model.WriteCapability;
|
||||
import org.enso.ydoc.server.jsonrpc.model.result.FileListResult;
|
||||
import org.enso.ydoc.server.jsonrpc.model.result.InitProtocolConnectionResult;
|
||||
import org.enso.ydoc.server.jsonrpc.model.result.TextOpenFileResult;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
@ -1,4 +1,4 @@
|
||||
package org.enso.ydoc.jsonrpc;
|
||||
package org.enso.ydoc.server.jsonrpc;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.enso.ydoc.jsonrpc;
|
||||
package org.enso.ydoc.server.jsonrpc;
|
||||
|
||||
import org.enso.ydoc.jsonrpc.model.result.Result;
|
||||
import org.enso.ydoc.server.jsonrpc.model.result.Result;
|
||||
|
||||
public record JsonRpcResponse(String jsonrpc, String id, Result result) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.enso.ydoc.jsonrpc.model;
|
||||
package org.enso.ydoc.server.jsonrpc.model;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.enso.ydoc.jsonrpc.model;
|
||||
package org.enso.ydoc.server.jsonrpc.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
@ -1,4 +1,4 @@
|
||||
package org.enso.ydoc.jsonrpc.model;
|
||||
package org.enso.ydoc.server.jsonrpc.model;
|
||||
|
||||
public record FileSystemObject(String type, String name, FilePath path) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.enso.ydoc.jsonrpc.model;
|
||||
package org.enso.ydoc.server.jsonrpc.model;
|
||||
|
||||
public record WriteCapability(String method, Options registerOptions) {
|
||||
|
@ -0,0 +1,6 @@
|
||||
package org.enso.ydoc.server.jsonrpc.model.result;
|
||||
|
||||
import java.util.List;
|
||||
import org.enso.ydoc.server.jsonrpc.model.FileSystemObject;
|
||||
|
||||
public record FileListResult(List<FileSystemObject> paths) implements Result {}
|
@ -1,7 +1,7 @@
|
||||
package org.enso.ydoc.jsonrpc.model.result;
|
||||
package org.enso.ydoc.server.jsonrpc.model.result;
|
||||
|
||||
import java.util.List;
|
||||
import org.enso.ydoc.jsonrpc.model.ContentRoot;
|
||||
import org.enso.ydoc.server.jsonrpc.model.ContentRoot;
|
||||
|
||||
public record InitProtocolConnectionResult(
|
||||
String ensoVersion, String currentEdition, List<ContentRoot> contentRoots) implements Result {}
|
@ -0,0 +1,3 @@
|
||||
package org.enso.ydoc.server.jsonrpc.model.result;
|
||||
|
||||
public interface Result {}
|
@ -1,6 +1,6 @@
|
||||
package org.enso.ydoc.jsonrpc.model.result;
|
||||
package org.enso.ydoc.server.jsonrpc.model.result;
|
||||
|
||||
import org.enso.ydoc.jsonrpc.model.WriteCapability;
|
||||
import org.enso.ydoc.server.jsonrpc.model.WriteCapability;
|
||||
|
||||
public record TextOpenFileResult(
|
||||
WriteCapability writeCapability, String content, String currentVersion) implements Result {}
|
14
lib/java/ydoc/src/main/java/module-info.java
Normal file
14
lib/java/ydoc/src/main/java/module-info.java
Normal file
@ -0,0 +1,14 @@
|
||||
module org.enso.ydoc {
|
||||
requires io.helidon.webclient;
|
||||
requires io.helidon.webclient.websocket;
|
||||
requires io.helidon.webserver;
|
||||
requires io.helidon.webserver.websocket;
|
||||
requires org.enso.syntax;
|
||||
requires org.graalvm.polyglot;
|
||||
requires org.slf4j;
|
||||
|
||||
opens org.enso.ydoc.polyfill.web;
|
||||
|
||||
exports org.enso.ydoc.polyfill;
|
||||
exports org.enso.ydoc.polyfill.web;
|
||||
}
|
17
lib/java/ydoc/src/test/resources/logback-test.xml
Normal file
17
lib/java/ydoc/src/test/resources/logback-test.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration>
|
||||
|
||||
<configuration>
|
||||
<import class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"/>
|
||||
<import class="ch.qos.logback.core.ConsoleAppender"/>
|
||||
|
||||
<appender name="STDOUT" class="ConsoleAppender">
|
||||
<encoder class="PatternLayoutEncoder">
|
||||
<pattern>%d{HH:mm:ss.SSS} [%-15thread] %-5level %logger{36} %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="error">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</configuration>
|
@ -50,7 +50,7 @@ object Ydoc {
|
||||
val generator = Tracked.inputChanged[Seq[File], Seq[File]](store) {
|
||||
case (changed, _) =>
|
||||
val resourceYdocServerJs =
|
||||
ydocServerResourceManaged / "org" / "enso" / "ydoc" / "ydoc.cjs"
|
||||
ydocServerResourceManaged / "org" / "enso" / "ydoc" / "server" / "ydoc.cjs"
|
||||
|
||||
if (changed) {
|
||||
val command = s"$pnpmCommand -r compile"
|
||||
|
Loading…
Reference in New Issue
Block a user