diff --git a/plugin/src/main/java/io/deephaven/plugin/js/JsPlugin.java b/plugin/src/main/java/io/deephaven/plugin/js/JsPlugin.java index 929de4071eb..64f6f2c8ca0 100644 --- a/plugin/src/main/java/io/deephaven/plugin/js/JsPlugin.java +++ b/plugin/src/main/java/io/deephaven/plugin/js/JsPlugin.java @@ -43,7 +43,7 @@ public static Builder builder() { public abstract String version(); /** - * The main JS file path, specified relative to {@link #rootPath()}. The main JS file must exist + * The main JS file path, specified relative to {@link #path()}. The main JS file must exist * ({@code Files.isRegularFile(root().resolve(main()))}) and must be included in {@link #paths()}. Will be included * as the "main" field for the manifest entry in "js-plugins/manifest.json". * @@ -53,15 +53,15 @@ public static Builder builder() { public abstract Path main(); /** - * The root directory path of the resources to serve. The root must exist ({@code Files.isDirectory(root())}). + * The directory path of the resources to serve. The path must exist ({@code Files.isDirectory(path())}). * - * @return the root + * @return the path */ - public abstract Path rootPath(); + public abstract Path path(); /** - * The paths to serve, specified relative to {@link #rootPath()}. The resources will be served via the URL path - * "js-plugins/{name}/{pathRelativeToRoot}". By default, is {@link Paths#all()}. + * The paths to serve, specified relative to {@link #path()}. The resources will be served via the URL path + * "js-plugins/{name}/{relativePath}". By default, is {@link Paths#all()}. * * @return the paths */ @@ -76,15 +76,15 @@ public final > T walk(V visitor) { } @Check - final void checkRootPath() { - if (!Files.isDirectory(rootPath())) { - throw new IllegalArgumentException(String.format("rootPath ('%s') must exist and be a directory", rootPath())); + final void checkPath() { + if (!Files.isDirectory(path())) { + throw new IllegalArgumentException(String.format("path ('%s') must exist and be a directory", path())); } } @Check final void checkMain() { - final Path mainPath = rootPath().resolve(main()); + final Path mainPath = path().resolve(main()); if (!Files.isRegularFile(mainPath)) { throw new IllegalArgumentException(String.format("main ('%s') must exist and be a regular file", mainPath)); } @@ -95,7 +95,7 @@ final void checkPaths() { if (!(paths() instanceof PathsInternal)) { throw new IllegalArgumentException("Must construct one of the approved Paths"); } - final Path relativeMain = rootPath().relativize(rootPath().resolve(main())); + final Path relativeMain = path().relativize(path().resolve(main())); if (!((PathsInternal) paths()).matches(relativeMain)) { throw new IllegalArgumentException(String.format("main ('%s') is not in paths", relativeMain)); } @@ -108,7 +108,7 @@ public interface Builder { Builder main(Path main); - Builder rootPath(Path rootPath); + Builder path(Path path); Builder paths(Paths paths); diff --git a/py/server/deephaven_internal/plugin/js/__init__.py b/py/server/deephaven_internal/plugin/js/__init__.py index dea9822f7cf..2ce5fca3d81 100644 --- a/py/server/deephaven_internal/plugin/js/__init__.py +++ b/py/server/deephaven_internal/plugin/js/__init__.py @@ -10,11 +10,8 @@ def to_j_js_plugin(js_plugin: JsPlugin) -> jpy.JType: - with js_plugin.path() as tmp_path: - path = tmp_path - if not path.exists(): - raise NotImplementedError(f"The Deephaven JsPlugin server-side currently only supports normal filesystem resources. {js_plugin}") - main_path = root_path.relativize(root_path.resolve(js_plugin.main)) + j_path = _JPath.of(str(js_plugin.path)) + main_path = j_path.relativize(j_path.resolve(js_plugin.main)) builder = _JJsPlugin.builder() builder.name(js_plugin.name) builder.version(js_plugin.version) diff --git a/py/server/setup.py b/py/server/setup.py index df83ea7e498..4161000e0d4 100644 --- a/py/server/setup.py +++ b/py/server/setup.py @@ -56,7 +56,7 @@ def _compute_version(): python_requires='>=3.8', install_requires=[ 'jpy>=0.14.0', - 'deephaven-plugin==0.5.0', + 'deephaven-plugin>=0.6.0', 'numpy', 'pandas>=1.5.0', 'pyarrow', diff --git a/server/jetty/src/main/java/io/deephaven/server/jetty/JsPluginsZipFilesystem.java b/server/jetty/src/main/java/io/deephaven/server/jetty/JsPluginsZipFilesystem.java index 602d9c930d0..7250a8e71b0 100644 --- a/server/jetty/src/main/java/io/deephaven/server/jetty/JsPluginsZipFilesystem.java +++ b/server/jetty/src/main/java/io/deephaven/server/jetty/JsPluginsZipFilesystem.java @@ -69,7 +69,7 @@ public synchronized void add(JsPlugin plugin) throws IOException { // If listing and traversing the contents of development directories (and skipping the copy) becomes // too expensive, we can add logic here wrt PathsInternal/PathsPrefix to specify a dirMatcher. Or, // properly route directly from the filesystem via Jetty. - CopyHelper.copyRecursive(plugin.rootPath(), dstPath, pathMatcher); + CopyHelper.copyRecursive(plugin.path(), dstPath, pathMatcher); plugins.add(plugin); writeManifest(fs); } diff --git a/server/jetty/src/test/java/io/deephaven/server/jetty/js/Example123Registration.java b/server/jetty/src/test/java/io/deephaven/server/jetty/js/Example123Registration.java index d681c106e19..8574d22442a 100644 --- a/server/jetty/src/test/java/io/deephaven/server/jetty/js/Example123Registration.java +++ b/server/jetty/src/test/java/io/deephaven/server/jetty/js/Example123Registration.java @@ -32,36 +32,36 @@ public void registerInto(Callback callback) { } private static JsPlugin example1() throws URISyntaxException { - final Path resourceRoot = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example1").toURI()); - final Path main = resourceRoot.relativize(resourceRoot.resolve("dist/index.js")); + final Path resourcePath = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example1").toURI()); + final Path main = resourcePath.relativize(resourcePath.resolve("dist/index.js")); return JsPlugin.builder() .name("@deephaven_test/example1") .version("0.1.0") .main(main) - .rootPath(resourceRoot) + .path(resourcePath) .build(); } private static JsPlugin example2() throws URISyntaxException { - final Path resourceRoot = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example2").toURI()); - final Path main = resourceRoot.relativize(resourceRoot.resolve("dist/index.js")); + final Path resourcePath = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example2").toURI()); + final Path main = resourcePath.relativize(resourcePath.resolve("dist/index.js")); return JsPlugin.builder() .name("@deephaven_test/example2") .version("0.2.0") .main(main) - .rootPath(resourceRoot) + .path(resourcePath) .paths(Paths.ofPrefixes(main)) .build(); } private static JsPlugin example3() throws URISyntaxException { - final Path resourceRoot = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example3").toURI()); - final Path main = resourceRoot.relativize(resourceRoot.resolve("index.js")); + final Path resourcePath = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example3").toURI()); + final Path main = resourcePath.relativize(resourcePath.resolve("index.js")); return JsPlugin.builder() .name("@deephaven_test/example3") .version("0.3.0") .main(main) - .rootPath(resourceRoot) + .path(resourcePath) .build(); } } diff --git a/server/src/main/java/io/deephaven/server/plugin/js/JsPluginFromNpmPackage.java b/server/src/main/java/io/deephaven/server/plugin/js/JsPluginFromNpmPackage.java index 5c1b87af061..98f8e29bee5 100644 --- a/server/src/main/java/io/deephaven/server/plugin/js/JsPluginFromNpmPackage.java +++ b/server/src/main/java/io/deephaven/server/plugin/js/JsPluginFromNpmPackage.java @@ -63,7 +63,7 @@ static JsPlugin of(Path packageRoot) throws IOException { .name(packageJson.name()) .version(packageJson.version()) .main(main) - .rootPath(packageRoot) + .path(packageRoot) .paths(paths); return builder.build(); } diff --git a/server/src/main/java/io/deephaven/server/plugin/js/JsPluginNpmPackageRegistration.java b/server/src/main/java/io/deephaven/server/plugin/js/JsPluginNpmPackageRegistration.java index c1eb43ec1d9..0acf62337ce 100644 --- a/server/src/main/java/io/deephaven/server/plugin/js/JsPluginNpmPackageRegistration.java +++ b/server/src/main/java/io/deephaven/server/plugin/js/JsPluginNpmPackageRegistration.java @@ -31,7 +31,7 @@ * configuration is meant for development-oriented use-cases and is done on a "best-effort" basis. * *

- * The configuration value of the above property corresponds to the {@link JsPlugin#rootPath()} directory. A + * The configuration value of the above property corresponds to the {@link JsPlugin#path()} directory. A * {@value PACKAGE_JSON} must exist in this directory (as specified via * package-json). The {@value NAME} json value * corresponds to {@link JsPlugin#name()}, the {@value VERSION} json value corresponds to {@link JsPlugin#version()}, diff --git a/server/src/main/java/io/deephaven/server/plugin/js/JsPluginsFromManifest.java b/server/src/main/java/io/deephaven/server/plugin/js/JsPluginsFromManifest.java index cb4d85c855b..c07540d27db 100644 --- a/server/src/main/java/io/deephaven/server/plugin/js/JsPluginsFromManifest.java +++ b/server/src/main/java/io/deephaven/server/plugin/js/JsPluginsFromManifest.java @@ -16,13 +16,13 @@ static List of(Path manifestRoot) throws IOException { final JsPluginManifest manifest = JsPluginManifest.read(manifestRoot.resolve(JsPluginManifest.MANIFEST_JSON)); final List plugins = new ArrayList<>(manifest.plugins().size()); for (JsPluginManifestEntry entry : manifest.plugins()) { - final Path pluginRoot = manifestRoot.resolve(entry.name()); - final Path pluginMain = pluginRoot.relativize(pluginRoot.resolve(entry.main())); + final Path pluginPath = manifestRoot.resolve(entry.name()); + final Path pluginMain = pluginPath.relativize(pluginPath.resolve(entry.main())); final JsPlugin plugin = JsPlugin.builder() .name(entry.name()) .version(entry.version()) .main(pluginMain) - .rootPath(pluginRoot) + .path(pluginPath) .build(); // We expect manifests to be "production" use cases - they should already be packed as appropriate. // Additionally, there is no strict requirement that they have package.json anyways.