Browse Source

added math.js

Brandon Wong 4 years ago
parent
commit
bc97d76106

+ 2 - 0
frontend/.gitignore

@@ -15,4 +15,6 @@ pom.xml.asc
 *.log
 /.env
 .rebel_readline_history
+node_modules
+dist/
 *.swp

+ 18 - 0
frontend/package.json

@@ -0,0 +1,18 @@
+{
+  "name": "microtables-frontend",
+  "author": "Brandon Wong <projects@brwong.net> (https://www.brwong.net)",
+  "description": "Frontend of the Microtables project",
+  "version": "1.0.0",
+  "main": "index.js",
+  "dependencies": {
+    "mathjs": "6.2.3",
+    "webpack": "4.41.2",
+    "webpack-cli": "3.3.9"
+  },
+  "devDependencies": {},
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "keywords": [],
+  "license": "ISC"
+}

+ 6 - 3
frontend/project.clj

@@ -33,11 +33,14 @@
                          :output-dir "public/js/out"
                          :asset-path   "js/out"
                          :source-map true
+                         :npm-deps false
                          :optimizations :none
-                         :pretty-print  true}
+                         :pretty-print  true
+                         :foreign-libs [{:file "dist/index.bundle.js"
+                                         :provides ["mathjs"]
+                                         :global-exports {mathjs mathjs}}]}
                         :figwheel
-                        {:on-jsload "microtables-frontend.core/mount-root"
-                         :open-urls ["http://localhost:3449/index.html"]}}
+                        {:on-jsload "microtables-frontend.core/mount-root"}}
                        :release
                        {:source-paths ["src" "env/prod/cljs"]
                         :compiler

+ 5 - 0
frontend/src/js/index.js

@@ -0,0 +1,5 @@
+
+const mathjs = require('mathjs');
+
+window.mathjs = mathjs;
+

+ 5 - 1
frontend/src/microtables_frontend/core.cljs

@@ -1,6 +1,7 @@
 (ns microtables-frontend.core
     (:require
-      [reagent.core :as r]))
+      [reagent.core :as r]
+      ["mathjs" :as mathjs]))
 
 ; to generate random values
 ;for(let i = 0, s = new Set(); i < 10; i++){ let r = Math.floor(Math.random() * 15)+1, c = a[Math.floor(Math.random() * a.length)], k = `${c}${r}`; if(s.has(k)){ i--; continue; } s.add(k); v.push(`{:row ${r} :col "${c}" :value "${Math.floor(Math.random() * 10000)}"}`); }
@@ -76,6 +77,9 @@
 (defn app []
   [:div
    [:h3 "Microtables"]
+   (do
+     (println (.stringify js/JSON (.parse mathjs "3 + 4")))
+     "hi")
    [sheet @data-atom]])
 
 ;; -------------------------

+ 6 - 0
frontend/webpack.config.js

@@ -0,0 +1,6 @@
+module.exports = {
+    entry: './src/js/index.js',
+    output: {
+        filename: 'index.bundle.js',
+    },
+};

File diff suppressed because it is too large
+ 2978 - 0
frontend/yarn.lock