diff --git a/.eslintignore b/.eslintignore index c42749513..1c96db0f4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,3 +7,4 @@ /.clj-kondo /site /test-data +/repl-output-ui diff --git a/.gitignore b/.gitignore index 6f835751f..2a5f80680 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ jspm_packages lib/ cljs-out/ test-out/ +repl-output-ui/ # This and that .nrepl-port diff --git a/.prettierignore b/.prettierignore index 0c9ccac56..a2d094dc5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -9,3 +9,4 @@ **/.shadow-cljs/ **/out/ clojure.tmLanguage.json +/repl-output-ui diff --git a/deps-clj-version b/deps-clj-version index 58f1900bb..dabab0a6b 100644 --- a/deps-clj-version +++ b/deps-clj-version @@ -1 +1 @@ -v1.11.2.1446 \ No newline at end of file +v1.11.3.1463 \ No newline at end of file diff --git a/deps.clj.jar b/deps.clj.jar index a86fbd28b..94e9f9f79 100644 Binary files a/deps.clj.jar and b/deps.clj.jar differ diff --git a/deps.edn b/deps.edn index 2e8928ff9..84a968955 100644 --- a/deps.edn +++ b/deps.edn @@ -4,6 +4,10 @@ org.clojars.liverm0r/dartclojure {:mvn/version "0.2.22-SNAPSHOT"} vvvvalvalval/supdate {:mvn/version "0.2.3"} camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"} + no.cjohansen/replicant {:git/url "https://github.com/cjohansen/replicant.git" + :git/sha "ef2fecbe301cafa8449b74a1e2cbe4fc3ddc18ac"} + org.clojars.abhinav/snitch {:mvn/version "0.1.14"} #_#_org.clojars.liverm0r/dartclojure {:local/root "../DartClojure"}} + :aliases {:dev {:extra-deps {org.clojars.abhinav/snitch {:mvn/version "0.1.14"}}}} :paths ["src/cljs-lib/src" - "src/cljs-lib/test"]} \ No newline at end of file + "src/cljs-lib/test"]} diff --git a/package-lock.json b/package-lock.json index 51334bc43..7e8728e1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "open": "^6.3.0", "parinfer": "^3.12.0", "posthtml-parser": "^0.11.0", + "react-dom": "^18.2.0", "semver": "^7.3.7", "tree-kill": "^1.2.2", "uuidv4": "6.2.12", @@ -6776,8 +6777,7 @@ "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "node_modules/js-yaml": { "version": "4.1.0", @@ -7073,6 +7073,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -8845,6 +8856,30 @@ "node": ">=0.10.0" } }, + "node_modules/react": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", + "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", + "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -9082,6 +9117,14 @@ "node": ">=10" } }, + "node_modules/scheduler": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", + "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", + "dependencies": { + "loose-envify": "^1.1.0" + } + }, "node_modules/semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", @@ -16169,8 +16212,7 @@ "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "js-yaml": { "version": "4.1.0", @@ -16405,6 +16447,14 @@ "is-unicode-supported": "^0.1.0" } }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -17817,6 +17867,24 @@ } } }, + "react": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", + "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "peer": true, + "requires": { + "loose-envify": "^1.1.0" + } + }, + "react-dom": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", + "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", + "requires": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.0" + } + }, "react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -17993,6 +18061,14 @@ "xmlchars": "^2.2.0" } }, + "scheduler": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", + "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", + "requires": { + "loose-envify": "^1.1.0" + } + }, "semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", diff --git a/package.json b/package.json index d0fb9aeb2..6d443dcbc 100644 --- a/package.json +++ b/package.json @@ -3311,7 +3311,7 @@ "compile-ts": "npx tsc --project ./tsconfig.json", "compile": "npm run compile-cljs && npm run compile-ts", "watch-ts": "npx tsc --watch --project ./tsconfig.json", - "watch-cljs": "npx shadow-cljs -d cider/cider-nrepl:0.28.5 watch :calva-lib :test", + "watch-cljs": "npx shadow-cljs -d cider/cider-nrepl:0.28.5 watch :calva-lib :test :repl-output-ui", "watch-ts-with-strict-nulls": "npx tsc --watch --project ./tsconfig.json --strictNullChecks", "release-cljs": "npx shadow-cljs release :calva-lib :test", "release": "webpack --mode production", diff --git a/shadow-cljs.edn b/shadow-cljs.edn index e977707a9..63a5df038 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -22,10 +22,20 @@ :js2cljs calva.js2cljs.converter/convert-bridge :dart2clj calva.dartclojure/convert-bridge :readConfigEdn calva.read-config/config-edn->js-bridge - :html2hiccup calva.html2hiccup/html->hiccup-convert-bridge} + :html2hiccup calva.html2hiccup/html->hiccup-convert-bridge + :initializeCljs calva.util/initialize-cljs + :showReplOutputWebviewPanel calva.repl.webview.core/show-repl-output-webview-panel} :output-to "out/cljs-lib/cljs-lib.js"} :test {:target :node-test :output-to "out/cljs-lib/test/cljs-lib-tests.js" :ns-regexp "-test$" - :autorun true}}} + :autorun true} + :repl-output-ui + {:target :browser + ;; TODO: Do the asset-path and output-dir values make sense? + :asset-path "js" + :output-dir "repl-output-ui/js" + :modules {:main {:init-fn calva.repl.webview.ui/main}} + :devtools {:loader-mode :eval + :devtools-url "http://localhost:9630"}}}} diff --git a/src/cljs-lib/src/calva/repl/webview/core.cljs b/src/cljs-lib/src/calva/repl/webview/core.cljs new file mode 100644 index 000000000..64079ab06 --- /dev/null +++ b/src/cljs-lib/src/calva/repl/webview/core.cljs @@ -0,0 +1,105 @@ +(ns calva.repl.webview.core + (:require + [calva.util :as util])) + +(defonce repl-output-webview-panel (atom nil)) + +(defn dispose-repl-output-webview-panel [] + (println "Disposing repl-output-webview-panel") + (reset! repl-output-webview-panel nil)) + +;; TODO: See if there's a way to not have to use ^js in so many places without shadow-cljs warnings +(defn create-or-get-repl-output-webview-panel [] + (or @repl-output-webview-panel + (let [webview-panel (.. ^js @util/vscode -window + (createWebviewPanel "calva:repl-output" + "REPL Output" + (.. ^js @util/vscode -ViewColumn -Two) + #js {:enableScripts true}))] + (.. ^js webview-panel (onDidDispose dispose-repl-output-webview-panel)) + (reset! repl-output-webview-panel webview-panel)))) + +(defn get-webview-html + [js-src] + (str " + + +
+ + + + + + + +