-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(graalvm-js): add new `graalvm-js` module for graaljs integration feat(graalvm-js): initial structure and api for elide's import router feat(graalvm-ts): move js realm patcher to `graalvm-js` module feat(graalvm): initialize javascript when plugin is added chore: reintroduce graalvm/graaljs modules and pins Signed-off-by: Sam Gammon <sam@elide.dev>
- Loading branch information
Showing
17 changed files
with
182 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class elide/runtime/lang/javascript/JSRealmPatcher { | ||
public fun <init> ()V | ||
public static fun setModuleLoader (Lcom/oracle/truffle/js/runtime/JSRealm;Lcom/oracle/truffle/js/runtime/objects/JSModuleLoader;)V | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) 2024 Elide Technologies, Inc. | ||
* | ||
* Licensed under the MIT license (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/license/mit/ | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
import elide.internal.conventions.kotlin.KotlinTarget | ||
import elide.internal.conventions.publishing.publish | ||
|
||
plugins { | ||
alias(libs.plugins.micronaut.graalvm) | ||
|
||
kotlin("jvm") | ||
kotlin("kapt") | ||
kotlin("plugin.allopen") | ||
|
||
alias(libs.plugins.elide.conventions) | ||
} | ||
|
||
elide { | ||
publishing { | ||
id = "graalvm-js" | ||
name = "Elide JS integration package for GraalVM" | ||
description = "Integration package with GraalVM, Elide, and JS." | ||
|
||
publish("jvm") { | ||
from(components["kotlin"]) | ||
} | ||
} | ||
|
||
kotlin { | ||
target = KotlinTarget.JVM | ||
explicitApi = true | ||
} | ||
} | ||
|
||
val gvmJarsRoot = rootProject.layout.projectDirectory.dir("third_party/oracle") | ||
|
||
val patchedLibs = files( | ||
gvmJarsRoot.file("graaljs.jar"), | ||
) | ||
|
||
val patchedDependencies: Configuration by configurations.creating { | ||
isCanBeResolved = true | ||
} | ||
|
||
dependencies { | ||
api(projects.packages.engine) | ||
api(patchedLibs) | ||
patchedDependencies(patchedLibs) | ||
} | ||
|
||
configurations.all { | ||
libs.graalvm.js.language.get().let { | ||
exclude(group = it.group, module = it.name) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/graalvm-js/src/main/kotlin/elide/runtime/lang/javascript/ElideJsModuleRouter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package elide.runtime.lang.javascript | ||
|
||
import com.oracle.truffle.js.runtime.JSEngine | ||
import com.oracle.truffle.js.runtime.JSModuleLoaderFactory | ||
import com.oracle.truffle.js.runtime.JSRealm | ||
import com.oracle.truffle.js.runtime.objects.JSModuleLoader | ||
import java.util.* | ||
import kotlinx.atomicfu.atomic | ||
|
||
/** | ||
* ## Elide JavaScript Module Router | ||
*/ | ||
public object ElideJsModuleRouter : JSModuleLoaderFactory { | ||
private val initialized = atomic(false) | ||
|
||
@JvmStatic public fun install() { | ||
if (!initialized.getAndSet(true)) { | ||
JSEngine.setModuleLoaderFactory(this) | ||
} | ||
} | ||
|
||
override fun createLoader(realm: JSRealm, defaultFactory: JSModuleLoaderFactory): Optional<JSModuleLoader> = | ||
defaultFactory.createLoader( | ||
realm, | ||
defaultFactory | ||
) | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/graalvm-js/src/main/kotlin/elide/runtime/lang/javascript/JavaScriptLang.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package elide.runtime.lang.javascript | ||
|
||
import kotlinx.atomicfu.atomic | ||
|
||
/** | ||
* ## JavaScript Language Utilities | ||
* | ||
* Static utilities for internal engine use. | ||
*/ | ||
public object JavaScriptLang { | ||
private val initialized = atomic(false) | ||
|
||
public fun initialize() { | ||
if (initialized.compareAndSet(expect = false, update = true)) { | ||
ElideJsModuleRouter.install() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.