File tree 7 files changed +67
-14
lines changed
7 files changed +67
-14
lines changed Original file line number Diff line number Diff line change 125
125
"electron-window-state" : " 5.0.3" ,
126
126
"font-scanner" : " 0.2.1" ,
127
127
"mdn-data" : " 2.8.0" ,
128
- "opentype.js" : " 1.3.4"
128
+ "opentype.js" : " 1.3.4" ,
129
+ "pyodide" : " 0.26.1"
129
130
}
130
131
}
Original file line number Diff line number Diff line change 7
7
[" mdn-data" :as mdn] ; ; deprecating in favor of w3c/webref
8
8
[" opentype.js" :as opentype]
9
9
[" os" :as os]
10
+ [" pyodide" :refer [loadPyodide]]
10
11
[config]))
11
12
13
+ (def pyodide (atom nil ))
14
+
12
15
(defn text->path
13
16
" https://github.com/opentypejs/opentype.js#loading-a-font-synchronously-nodejs"
14
17
[text {:keys [font-url x y font-size]}]
21
24
:receive (fn [channel f]
22
25
; ; Strip event (_) as it includes `sender`
23
26
(.on ipcRenderer channel (fn [_ args] (f args))))
27
+ :runPython #(.runPython ^js @pyodide %)
24
28
:mdn mdn
25
29
:webrefCss css
26
30
:platform (.platform os)
33
37
(defn ^:export init []
34
38
; ; https://docs.sentry.io/platforms/javascript/guides/electron/#configuring-the-client
35
39
#_ (.init Sentry (clj->js config/sentry-options))
36
- ; ; Expose protected methods that allow the renderer process to use the
40
+ (.then (loadPyodide ) #(reset! pyodide %))
41
+ ; ; Expose protected methods that allow the renderer process to use the
37
42
; ; ipcRenderer without exposing the entire object
38
43
; ; https://www.electronjs.org/docs/api/context-bridge
39
44
(.exposeInMainWorld contextBridge " api" (clj->js api)))
Original file line number Diff line number Diff line change 8
8
[" codemirror/addon/runmode/runmode.js" ]
9
9
[" codemirror/mode/clojure/clojure.js" ]
10
10
[" codemirror/mode/javascript/javascript.js" ]
11
+ [" codemirror/mode/python/python.js" ]
11
12
[" react" :as react]
12
13
[clojure.string :as str]
13
14
[reagent.core :as r]))
Original file line number Diff line number Diff line change 3
3
[" react-resizable-panels" :refer [Panel PanelResizeHandle]]
4
4
[cljs.reader]
5
5
[cljs.tools.reader]
6
+ [platform]
6
7
[re-frame.core :as rf]
7
8
[reagent.core :as ra]
8
9
[renderer.components :as comp]
91
92
cm-opts)]
92
93
[:div.self-start.h-full.flex.items-center
93
94
(repl-mode-button :cljs )
94
- (repl-mode-button :js )]
95
+ (repl-mode-button :js )
96
+ (when platform/electron? (repl-mode-button :py ))]
95
97
[comp/toggle-icon-button
96
98
{:active? repl-history?
97
99
:active-icon " chevron-down"
Original file line number Diff line number Diff line change @@ -237,10 +237,10 @@ cljs.js/*load-fn*
237
237
(js-attrs proto))))))
238
238
239
239
(defn js-completion
240
- [text]
240
+ [mode text]
241
241
(let [parts (vec (.split text " ." ))
242
242
completing (or (last parts) " " )
243
- prefix #(str " js/" (str/join " ." (conj (vec (butlast parts)) %)))
243
+ prefix #(str ( when ( = mode :cljs ) " js/" ) (str/join " ." (conj (vec (butlast parts)) %)))
244
244
possibles (js-attrs (reduce aget js/window (butlast parts)))]
245
245
(->> possibles
246
246
(filter #(not= -1 (.indexOf % completing)))
@@ -289,10 +289,13 @@ cljs.js/*load-fn*
289
289
(filter matches? names))))))
290
290
291
291
(defn process-apropos
292
- [text]
293
- (if (zero? (.indexOf text " js/" ))
294
- (js-completion (.slice text 3 ))
295
- (cljs-completion text)))
292
+ [mode text]
293
+ (case mode
294
+ :js (js-completion mode text)
295
+ :cljs (if (zero? (.indexOf text " js/" ))
296
+ (js-completion mode (.slice text 3 ))
297
+ (cljs-completion text))
298
+ :py []))
296
299
297
300
(defn get-forms
298
301
[m]
Original file line number Diff line number Diff line change 21
21
(defn root
22
22
[]
23
23
[reepl/repl
24
- :execute #(replumb/run-repl (if (= @(rf/subscribe [:repl-mode ]) :cljs ) %1 (str " (js/eval \" " %1 " \" )" )) {:warning-as-error true } %2 )
25
- :complete-word replumb/process-apropos
26
- :get-docs replumb/process-doc
24
+ :execute #(replumb/run-repl (case @(rf/subscribe [:repl-mode ])
25
+ :cljs %1
26
+ :js (str " (js/eval \" " %1 " \" )" )
27
+ :py (str " (js/window.api.runPython \" " %1 " \" )" ))
28
+ {:warning-as-error true } %2 )
29
+ :complete-word (fn [text] (replumb/process-apropos @(rf/subscribe [:repl-mode ]) text))
30
+ :get-docs (if (= @(rf/subscribe [:repl-mode ]) :cljs ) replumb/process-doc #())
27
31
:state repl-state
28
32
:show-value-opts
29
33
{:showers [show-devtools/show-devtools
30
34
(partial show-function/show-fn-with-docs maybe-fn-docs)]}
31
- :js-cm-opts {:mode (if (= @(rf/subscribe [:repl-mode ]) :cljs ) " clojure" " javascript" )
35
+ :js-cm-opts {:mode (case
36
+ :cljs " clojure"
37
+ :js " javascript"
38
+ :py " python" )
32
39
:keyMap " default"
33
40
:showCursorWhenSelecting true }])
You can’t perform that action at this time.
0 commit comments