From 2773efb312aa415b7df9afa537fbfb08603c6fc7 Mon Sep 17 00:00:00 2001 From: Wei Ouyang Date: Wed, 10 Apr 2024 20:22:14 -0700 Subject: [PATCH 1/2] imagej chatbot support --- src/chat.html | 291 +++++++++++++++++++++ src/imagej-js-chatbot-extension.imjoy.html | 99 +++++++ src/imjoyApp.js | 8 + src/index.html | 43 +++ src/index.js | 58 +--- webpack.config.js | 8 + 6 files changed, 461 insertions(+), 46 deletions(-) create mode 100644 src/chat.html create mode 100644 src/imagej-js-chatbot-extension.imjoy.html diff --git a/src/chat.html b/src/chat.html new file mode 100644 index 0000000..b5161af --- /dev/null +++ b/src/chat.html @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + ImageJ.JS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Drop file here to open +
+ +
+ +
+
+
+
+
+
+
+
+ + + +

Open File

+ +

+ You can either select a file from your local file system or cached + files in the browser. +

+ +
+ + + +
+
+
+ + + + + + + + + diff --git a/src/imagej-js-chatbot-extension.imjoy.html b/src/imagej-js-chatbot-extension.imjoy.html new file mode 100644 index 0000000..b8630b6 --- /dev/null +++ b/src/imagej-js-chatbot-extension.imjoy.html @@ -0,0 +1,99 @@ + + +[TODO: write documentation for this plugin.] + + + +{ + "name": "ImageJ.JS Chatbot Extension", + "type": "web-worker", + "tags": [], + "ui": "", + "version": "0.1.0", + "cover": "", + "description": "Run ImageJ.JS macro in the chatbot", + "icon": "extension", + "inputs": null, + "outputs": null, + "api_version": "0.1.8", + "env": "", + "permissions": [], + "requirements": [], + "dependencies": [] +} + + + diff --git a/src/imjoyApp.js b/src/imjoyApp.js index 37df155..bc71dd5 100644 --- a/src/imjoyApp.js +++ b/src/imjoyApp.js @@ -8,8 +8,11 @@ const builtinPlugins = [ "https://gist.githubusercontent.com/oeway/16d189e53d23cb2e26c3618ed6e40be6/raw/ImJoyModelRunner.imjoy.html", "https://bioimage-io.github.io/bioengine-web-client/", ]; + + async function startImJoy(app, imjoy) { await imjoy.start(); + window.imjoy = imjoy; imjoy.event_bus.on("show_message", (msg) => { Snackbar.show({ text: msg, @@ -333,6 +336,10 @@ function promisify_functions(obj, bind) { return ret; } +window.imjoyReady = new Promise((resolve) => { + window.resolveImJoyReady = resolve; +}); + export async function setupImJoyApp(setAPI) { const vue = await import("vue/dist/vue.common"); const vuejsmodal = await import("vue-js-modal"); @@ -411,6 +418,7 @@ export async function setupImJoyApp(setAPI) { }); this.imjoy = imjoy; startImJoy(this, this.imjoy).then(() => { + if (window.resolveImJoyReady) window.resolveImJoyReady(this.imjoy); imjoy.pm .reloadPluginRecursively({ uri: diff --git a/src/index.html b/src/index.html index 4c392d5..9a09561 100644 --- a/src/index.html +++ b/src/index.html @@ -220,6 +220,49 @@

Open File

integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous" /> +