-
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-js): implement commonjs module loading support feat(graalvm-js): implement esm module loading support feat(graalvm-ts): move js realm patcher to `graalvm-js` module feat(graalvm-ts): use new delegated module facilities feat(graalvm): initialize javascript when plugin is added feat(graalvm): enable `node:assert` for injection feat(graalvm): enable `node:path` for injection feat(graalvm): enable `node:zlib` for injection feat(graalvm): enable `node:os` for injection chore: reintroduce graalvm/graaljs modules and pins chore: mark js realm patcher as deprecated test: add test scripts for node paths Signed-off-by: Sam Gammon <sam@elide.dev>
- Loading branch information
Showing
55 changed files
with
2,017 additions
and
310 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
55 changes: 0 additions & 55 deletions
55
packages/engine/src/main/java/elide/runtime/plugins/api/NativePlugin.java
This file was deleted.
Oops, something went wrong.
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
62 changes: 62 additions & 0 deletions
62
packages/engine/src/main/kotlin/elide/runtime/gvm/loader/ModuleInfo.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,62 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package elide.runtime.gvm.loader | ||
|
||
import java.util.concurrent.ConcurrentSkipListMap | ||
|
||
/** | ||
* Assigned string name/ID for a code module. | ||
*/ | ||
public typealias ModuleId = String | ||
|
||
/** | ||
* ## Module Info | ||
* | ||
* Describes information about a code module of some kind; the module is addressed by a simple [name]. | ||
* | ||
* @property name The name of the module. | ||
* @property dependencies The list of module names that this module depends on. | ||
*/ | ||
@ConsistentCopyVisibility | ||
@JvmRecord public data class ModuleInfo private constructor ( | ||
public val name: ModuleId, | ||
public val dependencies: List<ModuleId> = emptyList(), | ||
) : Comparable<ModuleInfo> { | ||
override fun compareTo(other: ModuleInfo): Int = name.compareTo(other.name) | ||
|
||
public companion object { | ||
public val allModuleInfos: MutableMap<ModuleId, ModuleInfo> = ConcurrentSkipListMap<ModuleId, ModuleInfo>() | ||
|
||
// Register a module info record. | ||
@JvmStatic private fun register(name: String, vararg deps: String): ModuleInfo { | ||
assert(name !in allModuleInfos) { "Module $name already registered" } | ||
return ModuleInfo( | ||
name = name, | ||
dependencies = deps.toList(), | ||
).also { | ||
allModuleInfos[name] = it | ||
} | ||
} | ||
|
||
// Obtain a module info record, registering if needed. | ||
@JvmStatic public fun of(name: String, vararg deps: String): ModuleInfo = allModuleInfos.computeIfAbsent(name) { | ||
register( | ||
name = name, | ||
deps = deps, | ||
) | ||
} | ||
|
||
// Obtain a module info record, or return `null` if not found. | ||
@JvmStatic public fun find(name: String): ModuleInfo? = allModuleInfos[name] | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
packages/engine/src/main/kotlin/elide/runtime/gvm/loader/ModuleRegistrar.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,34 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package elide.runtime.gvm.loader | ||
|
||
/** | ||
* ## Module Registry | ||
*/ | ||
public interface ModuleRegistrar { | ||
/** | ||
* Register a module with the module registry. | ||
* | ||
* @param module The module to register. | ||
* @param impl An instance of the registered module. | ||
*/ | ||
public fun register(module: ModuleInfo, impl: Any) | ||
|
||
/** | ||
* Register a module with the module registry. | ||
* | ||
* @param module The module to register. | ||
* @param producer The factory to create the module. | ||
*/ | ||
public fun deferred(module: ModuleInfo, producer: ModuleFactory) | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/engine/src/main/kotlin/elide/runtime/gvm/loader/ModuleRegistry.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,44 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package elide.runtime.gvm.loader | ||
|
||
/** | ||
* ## Module Registry | ||
*/ | ||
public object ModuleRegistry : ModuleRegistrar, ModuleResolver { | ||
private val registered = sortedMapOf<ModuleInfo, Any>() | ||
private val factories = sortedMapOf<ModuleInfo, ModuleFactory>() | ||
|
||
override fun register(module: ModuleInfo, impl: Any) { | ||
assert(module !in registered) { "Module already registered: $module" } | ||
assert(module !in factories) { "Module already registered as factory: $module" } | ||
factories[module] = ModuleFactory { _ -> impl } | ||
} | ||
|
||
override fun deferred(module: ModuleInfo, producer: ModuleFactory) { | ||
factories[module] = producer | ||
} | ||
|
||
override operator fun contains(mod: ModuleInfo): Boolean = mod in factories | ||
|
||
override fun load(info: ModuleInfo): Any = when (info) { | ||
in registered -> registered[info]!! | ||
in factories -> factories[info]!!.let { fac -> | ||
fac.load(info).also { | ||
registered[info] = it | ||
} | ||
} | ||
else -> error("Module not registered: $info") | ||
} | ||
} |
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
Oops, something went wrong.