(ns vimsical.frontend.code-editor.config
  (:require [vimsical.frontend.util.dom :as util.dom]))

(defn configure-editor []
  ;; js config
  (doto js/monaco.languages.typescript.javascriptDefaults
    ;; validation
    (.setDiagnosticsOptions
     #js {:noSemanticValidation true
          :noSyntaxValidation   false})
    ;; compiler opts
    ;; -editor/blob/3d17695d9322cb89dd2c9cee997807a6aadd7295/monaco.d.ts#L4948
  -options.html
    (.setCompilerOptions
     #js {:allowJs              true
          :target               js/monaco.languages.typescript.ScriptTarget.ES5
:  ; " React " , " Preserve " , " None " ; default : preserve
: jsxFactory ; default " React.createElement "
          :allowNonTsExtensions true})))


  Code using monaco 's typescript compiler webworker to compile js es6 to es5
#_(let [model-uri (-> (js/monaco.editor.getModels) last .-uri)]
    (-> (js/monaco.languages.typescript.getJavaScriptWorker)
        (.then
         (fn [w]
           (-> (w model-uri)
               (.then
                (fn [client]
                  (-> (.getEmitOutput client (str model-uri))
                      (.then
                       (fn [r]
                         (-> r
                             .-outputFiles
                             first
                             .-text)))))))))))

 js config
 validation
 compiler opts
 -editor/blob/3d17695d9322cb89dd2c9cee997807a6aadd7295/monaco.d.ts#L4948
 " React " , " Preserve " , " None " ; default : preserve
 default " React.createElement "
(ns vimsical.frontend.code-editor.config
  (:require [vimsical.frontend.util.dom :as util.dom]))

(defn configure-editor []
  (doto js/monaco.languages.typescript.javascriptDefaults
    (.setDiagnosticsOptions
     #js {:noSemanticValidation true
          :noSyntaxValidation   false})
  -options.html
    (.setCompilerOptions
     #js {:allowJs              true
          :target               js/monaco.languages.typescript.ScriptTarget.ES5
          :allowNonTsExtensions true})))


  Code using monaco 's typescript compiler webworker to compile js es6 to es5
#_(let [model-uri (-> (js/monaco.editor.getModels) last .-uri)]
    (-> (js/monaco.languages.typescript.getJavaScriptWorker)
        (.then
         (fn [w]
           (-> (w model-uri)
               (.then
                (fn [client]
                  (-> (.getEmitOutput client (str model-uri))
                      (.then
                       (fn [r]
                         (-> r
                             .-outputFiles
                             first
                             .-text)))))))))))
