diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2daa724..1dba0c9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,7 +13,7 @@ dependencies: version: 0.3.1 '@uiw/codemirror-theme-solarized': specifier: ^4.21.25 - version: 4.21.25(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.1) + version: 4.21.25(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.2) pythonia: specifier: ^1.1.3 version: 1.1.3(ws@7.5.9) @@ -32,7 +32,7 @@ packages: regenerator-runtime: 0.14.1 dev: false - /@codemirror/autocomplete@6.15.0(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.1)(@lezer/common@1.2.1): + /@codemirror/autocomplete@6.15.0(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.2)(@lezer/common@1.2.1): resolution: {integrity: sha512-G2Zm0mXznxz97JhaaOdoEG2cVupn4JjPaS4AcNvZzhOsnnG9YVN68VzfoUw6dYTsIxT6a/cmoFEN47KAWhXaOg==} peerDependencies: '@codemirror/language': ^6.0.0 @@ -42,7 +42,7 @@ packages: dependencies: '@codemirror/language': 6.10.1 '@codemirror/state': 6.4.1 - '@codemirror/view': 6.26.1 + '@codemirror/view': 6.26.2 '@lezer/common': 1.2.1 dev: false @@ -51,14 +51,14 @@ packages: dependencies: '@codemirror/language': 6.10.1 '@codemirror/state': 6.4.1 - '@codemirror/view': 6.26.1 + '@codemirror/view': 6.26.2 '@lezer/common': 1.2.1 dev: false - /@codemirror/lang-css@6.2.1(@codemirror/view@6.26.1): + /@codemirror/lang-css@6.2.1(@codemirror/view@6.26.2): resolution: {integrity: sha512-/UNWDNV5Viwi/1lpr/dIXJNWiwDxpw13I4pTUAsNxZdg6E0mI2kTQb0P2iHczg1Tu+H4EBgJR+hYhKiHKko7qg==} dependencies: - '@codemirror/autocomplete': 6.15.0(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.1)(@lezer/common@1.2.1) + '@codemirror/autocomplete': 6.15.0(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.2)(@lezer/common@1.2.1) '@codemirror/language': 6.10.1 '@codemirror/state': 6.4.1 '@lezer/common': 1.2.1 @@ -70,12 +70,12 @@ packages: /@codemirror/lang-html@6.4.8: resolution: {integrity: sha512-tE2YK7wDlb9ZpAH6mpTPiYm6rhfdQKVDa5r9IwIFlwwgvVaKsCfuKKZoJGWsmMZIf3FQAuJ5CHMPLymOtg1hXw==} dependencies: - '@codemirror/autocomplete': 6.15.0(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.1)(@lezer/common@1.2.1) - '@codemirror/lang-css': 6.2.1(@codemirror/view@6.26.1) + '@codemirror/autocomplete': 6.15.0(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.2)(@lezer/common@1.2.1) + '@codemirror/lang-css': 6.2.1(@codemirror/view@6.26.2) '@codemirror/lang-javascript': 6.2.2 '@codemirror/language': 6.10.1 '@codemirror/state': 6.4.1 - '@codemirror/view': 6.26.1 + '@codemirror/view': 6.26.2 '@lezer/common': 1.2.1 '@lezer/css': 1.1.8 '@lezer/html': 1.3.9 @@ -84,11 +84,11 @@ packages: /@codemirror/lang-javascript@6.2.2: resolution: {integrity: sha512-VGQfY+FCc285AhWuwjYxQyUQcYurWlxdKYT4bqwr3Twnd5wP5WSeu52t4tvvuWmljT4EmgEgZCqSieokhtY8hg==} dependencies: - '@codemirror/autocomplete': 6.15.0(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.1)(@lezer/common@1.2.1) + '@codemirror/autocomplete': 6.15.0(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.2)(@lezer/common@1.2.1) '@codemirror/language': 6.10.1 '@codemirror/lint': 6.5.0 '@codemirror/state': 6.4.1 - '@codemirror/view': 6.26.1 + '@codemirror/view': 6.26.2 '@lezer/common': 1.2.1 '@lezer/javascript': 1.4.14 dev: false @@ -99,7 +99,7 @@ packages: '@codemirror/lang-html': 6.4.8 '@codemirror/language': 6.10.1 '@codemirror/state': 6.4.1 - '@codemirror/view': 6.26.1 + '@codemirror/view': 6.26.2 '@lezer/common': 1.2.1 '@lezer/markdown': 1.3.0 dev: false @@ -108,7 +108,7 @@ packages: resolution: {integrity: sha512-5GrXzrhq6k+gL5fjkAwt90nYDmjlzTIJV8THnxNFtNKWotMIlzzN+CpqxqwXOECnUdOndmSeWntVrVcv5axWRQ==} dependencies: '@codemirror/state': 6.4.1 - '@codemirror/view': 6.26.1 + '@codemirror/view': 6.26.2 '@lezer/common': 1.2.1 '@lezer/highlight': 1.2.0 '@lezer/lr': 1.4.0 @@ -119,7 +119,7 @@ packages: resolution: {integrity: sha512-+5YyicIaaAZKU8K43IQi8TBy6mF6giGeWAH7N96Z5LC30Wm5JMjqxOYIE9mxwMG1NbhT2mA3l9hA4uuKUM3E5g==} dependencies: '@codemirror/state': 6.4.1 - '@codemirror/view': 6.26.1 + '@codemirror/view': 6.26.2 crelt: 1.0.6 dev: false @@ -127,7 +127,7 @@ packages: resolution: {integrity: sha512-rpMgcsh7o0GuCDUXKPvww+muLA1pDJaFrpq/CCHtpQJYz8xopu4D1hPcKRoDD0YlF8gZaqTNIRa4VRBWyhyy7Q==} dependencies: '@codemirror/state': 6.4.1 - '@codemirror/view': 6.26.1 + '@codemirror/view': 6.26.2 crelt: 1.0.6 dev: false @@ -135,8 +135,8 @@ packages: resolution: {integrity: sha512-QkEyUiLhsJoZkbumGZlswmAhA7CBU02Wrz7zvH4SrcifbsqwlXShVXg65f3v/ts57W3dqyamEriMhij1Z3Zz4A==} dev: false - /@codemirror/view@6.26.1: - resolution: {integrity: sha512-wLw0t3R9AwOSQThdZ5Onw8QQtem5asE7+bPlnzc57eubPqiuJKIzwjMZ+C42vQett+iva+J8VgFV4RYWDBh5FA==} + /@codemirror/view@6.26.2: + resolution: {integrity: sha512-j6V48PlFC/O7ERAR5vRW5QKDdchzmyyfojDdt+zPsB0YXoWgcjlC1IWjmlYfx08aQZ3HN5BtALcgGgtSKGMe7A==} dependencies: '@codemirror/state': 6.4.1 style-mod: 4.1.2 @@ -201,14 +201,14 @@ packages: /@nextjournal/clojure-mode@0.3.1: resolution: {integrity: sha512-jNPVbIiNsX6xd6+0VTZtccVRS9rqIJmvU5UdU0gUXzP9Jl3z9+ZM44aySgdlLZXXVCZa6/PsQ/iVbAu0PyB2aQ==} dependencies: - '@codemirror/autocomplete': 6.15.0(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.1)(@lezer/common@1.2.1) + '@codemirror/autocomplete': 6.15.0(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.2)(@lezer/common@1.2.1) '@codemirror/commands': 6.3.3 '@codemirror/lang-markdown': 6.0.0 '@codemirror/language': 6.10.1 '@codemirror/lint': 6.5.0 '@codemirror/search': 6.5.6 '@codemirror/state': 6.4.1 - '@codemirror/view': 6.26.1 + '@codemirror/view': 6.26.2 '@lezer/common': 1.2.1 '@lezer/generator': 1.7.0 '@lezer/highlight': 1.2.0 @@ -224,17 +224,17 @@ packages: '@lezer/lr': 1.4.0 dev: false - /@uiw/codemirror-theme-solarized@4.21.25(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.1): + /@uiw/codemirror-theme-solarized@4.21.25(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.2): resolution: {integrity: sha512-tnbhHI58sDLHfU1HrotUlZ2QAZZCDjS15yD61VXxKi3Ga+jqxTIdUGJum13wIbmsXs3O6lO89AZOIaYLujVPBQ==} dependencies: - '@uiw/codemirror-themes': 4.21.25(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.1) + '@uiw/codemirror-themes': 4.21.25(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.2) transitivePeerDependencies: - '@codemirror/language' - '@codemirror/state' - '@codemirror/view' dev: false - /@uiw/codemirror-themes@4.21.25(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.1): + /@uiw/codemirror-themes@4.21.25(@codemirror/language@6.10.1)(@codemirror/state@6.4.1)(@codemirror/view@6.26.2): resolution: {integrity: sha512-C3t/voELxQj0eaVhrlgzaOnSALNf8bOcRbL5xN9r2+RkdsbFOmvNl3VVhlxEB7PSGc1jUZwVO4wQsB2AP178ag==} peerDependencies: '@codemirror/language': '>=6.0.0' @@ -243,7 +243,7 @@ packages: dependencies: '@codemirror/language': 6.10.1 '@codemirror/state': 6.4.1 - '@codemirror/view': 6.26.1 + '@codemirror/view': 6.26.2 dev: false /ansi-styles@4.3.0: diff --git a/shadow-cljs.edn b/shadow-cljs.edn index d4697ff..5119424 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -5,9 +5,9 @@ {:web-editor {:target :esm :output-dir "public/js" - :modules {:l4_web_editor {:init-fn l4-lp.web-editor.main/init!}} - :devtools {:before-load l4-lp.web-editor.main/stop! - :after-load l4-lp.web-editor.main/start!} + :modules {:l4_web_editor {:init-fn l4-lp.web-editor.core/init!}} + :devtools {:before-load l4-lp.web-editor.core/stop! + :after-load l4-lp.web-editor.core/start!} :compiler-options {:output-feature-set :es2021 :externs ["datascript/externs.js"]}} diff --git a/src/l4_lp/core.cljc b/src/l4_lp/core.cljc index 1b4aa21..6e09a94 100644 --- a/src/l4_lp/core.cljc +++ b/src/l4_lp/core.cljc @@ -1,6 +1,5 @@ (ns l4-lp.core - (:require #?(:cljs [applied-science.js-interop :as jsi]) - #?(:cljs [l4-lp.swipl.js.wasm-query :as swipl-wasm-js-query]) + (:require #?(:cljs [l4-lp.swipl.js.wasm-query :as swipl-wasm-js-query]) [l4-lp.syntax.l4-to-prolog :as l4->prolog] #?(:cljs [promesa.core :as prom]))) @@ -12,45 +11,4 @@ ;; #?(:cljs ;; (def query-and-trace -;; swipl-wasm-js-query/query-and-trace)) - -#?(:cljs - (prom/let - [program - ['(DECIDE p of var/xs and var/x and var/z - IF (var/xs IS THE LIST OF ALL var/y SUCH THAT q holds for var/y) - AND (var/ys IS THE LIST OF ALL var/y SUCH THAT r holds for var/y) - AND (r holds for var/z) - AND (var/x IS (SUM var/xs)) - AND (var/y IS (SUM var/ys)) - AND (var/y > 0)) - - '(DECIDE q holds for 0) - '(DECIDE q holds for 1) - - '(DECIDE r holds for var/z - IF (var/z IS 3) - OR (var/z IS 4))] - - goal '(p of var/xs and var/x and 4) - - _ (jsi/call js/console :log "Input L4 program:\n" program) - _ (jsi/call js/console :log "Input L4 goal:\n" goal) - - program' (l4->prolog/l4-program->prolog-program-str program) - goal' (l4->prolog/l4->prolog-str goal) - - _ (jsi/call js/console :log "Transpiled Prolog program:\n" program') - _ (jsi/call js/console :log "Transpiled Prolog goal:\n" goal') - - output (swipl-wasm-js-query/query-and-trace! program' goal')] - (jsi/call js/console :log "Output:\n" output)) - - #_(->> - "[(DECIDE p of var/x IF ((var/x ** 1) IS 0)) - (DECIDE q holds for 1) - (DECIDE q holds for 2)]" - - l4->prolog/l4-program->prolog-program-str - - (jsi/call js/console :log))) \ No newline at end of file +;; swipl-wasm-js-query/query-and-trace)) \ No newline at end of file diff --git a/src/l4_lp/swipl/js/wasm_query.cljs b/src/l4_lp/swipl/js/wasm_query.cljs index 1de67f5..83c7bdf 100644 --- a/src/l4_lp/swipl/js/wasm_query.cljs +++ b/src/l4_lp/swipl/js/wasm_query.cljs @@ -3,12 +3,11 @@ [cljs-bean.core :as bean] [l4-lp.swipl.js.common.swipl-js-to-clj :as swipl-js->clj] [promesa.core :as prom] - [shadow.esm :refer [dynamic-import]])) + ["https://SWI-Prolog.github.io/npm-swipl-wasm/3/7/5/dynamic-import.js" + :as swipl-mod])) (def ^:private swipl-constructor - (prom/let [cdn-url "https://SWI-Prolog.github.io/npm-swipl-wasm/3/7/5/dynamic-import.js" - mod (dynamic-import cdn-url)] - (jsi/get mod :SWIPL))) + (jsi/get swipl-mod :SWIPL)) (def ^:private prelude-qlf-url "resources/swipl/prelude.qlf") diff --git a/src/l4_lp/web_editor/codemirror_editor.cljs b/src/l4_lp/web_editor/codemirror_editor.cljs index 5b99786..b2b7249 100644 --- a/src/l4_lp/web_editor/codemirror_editor.cljs +++ b/src/l4_lp/web_editor/codemirror_editor.cljs @@ -23,8 +23,7 @@ (def ^:private eval-query-extension (jsi/call cm-view/keymap :of - #js [#js {:key "Mod-Enter" - :run eval-query!}])) + #js [#js {:key "Mod-Enter" :run eval-query!}])) (def ^:private theme (jsi/call cm-view/EditorView :theme @@ -48,7 +47,6 @@ (let [editor-elt (jsi/call js/document :getElementById editor-element-id) state (jsi/call cm-state/EditorState :create - #js {:doc code - :extensions extensions})] + #js {:doc code :extensions extensions})] (cm-view/EditorView. #js {:parent editor-elt :state state}))) \ No newline at end of file diff --git a/src/l4_lp/web_editor/main.cljs b/src/l4_lp/web_editor/core.cljs similarity index 98% rename from src/l4_lp/web_editor/main.cljs rename to src/l4_lp/web_editor/core.cljs index 2f00354..d132792 100644 --- a/src/l4_lp/web_editor/main.cljs +++ b/src/l4_lp/web_editor/core.cljs @@ -1,4 +1,4 @@ -(ns l4-lp.web-editor.main +(ns l4-lp.web-editor.core (:require [applied-science.js-interop :as jsi] [hoplon.core :as h] [hoplon.goog] diff --git a/src/l4_lp/web_editor/guifier.cljs b/src/l4_lp/web_editor/guifier.cljs index cd2546a..a80d98f 100644 --- a/src/l4_lp/web_editor/guifier.cljs +++ b/src/l4_lp/web_editor/guifier.cljs @@ -1,17 +1,14 @@ -(ns l4-lp.web-editor.guifier +(ns l4-lp.web-editor.guifier (:require [applied-science.js-interop :as jsi] [l4-lp.swipl.js.wasm-query :as swipl-wasm-query] [l4-lp.syntax.l4-to-prolog :as l4->prolog] [promesa.core :as prom] - [shadow.esm :refer [dynamic-import]])) + ["https://cdn.jsdelivr.net/npm/guifier@1.0.24/dist/Guifier.js" + :as guifier-mod])) (def ^:private guifier {:element-id "guifier" - :constructor - (prom/let - [cdn-url "https://cdn.jsdelivr.net/npm/guifier@1.0.24/dist/Guifier.js" - mod (dynamic-import cdn-url)] - (jsi/get mod :default))}) + :constructor (jsi/get guifier-mod :default)}) (def ^:private query (-> "query" l4->prolog/l4->prolog-str))