Skip to content

Commit

Permalink
very slow app implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
CrowdHailer committed Oct 5, 2023
1 parent 230b9f3 commit a685c5b
Show file tree
Hide file tree
Showing 19 changed files with 96 additions and 24 deletions.
3 changes: 2 additions & 1 deletion eyg/gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ gleam_bitwise = "~> 1.2"
lustre = "~> 3.0.0"
gleam_json = "~> 0.5"
gleam_fetch = "~> 0.1"
plinth = "~> 0.1.3"
# plinth = "~> 0.1.3"
plinth = {path= "/opt/plinth"}
simplifile = "~> 0.1"

[dev-dependencies]
Expand Down
8 changes: 4 additions & 4 deletions eyg/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

packages = [
{ name = "gleam_bitwise", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_bitwise", source = "hex", outer_checksum = "6064699EFBABB1CA392DCB193D0E8B402FB042B4B46857B01E6875E643B57F54" },
{ name = "gleam_fetch", version = "0.2.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript"], otp_app = "gleam_fetch", source = "hex", outer_checksum = "D0C9E9CAE8D6EFCCC3A9FF817DCA9ED327097222086D91DE4F6CA8FBAB02D79F" },
{ name = "gleam_fetch", version = "0.2.0", build_tools = ["gleam"], requirements = ["gleam_javascript", "gleam_http"], otp_app = "gleam_fetch", source = "hex", outer_checksum = "D0C9E9CAE8D6EFCCC3A9FF817DCA9ED327097222086D91DE4F6CA8FBAB02D79F" },
{ name = "gleam_http", version = "3.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "FAE9AE3EB1CA90C2194615D20FFFD1E28B630E84DACA670B28D959B37BCBB02C" },
{ name = "gleam_javascript", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "EC5C683E144B407B3DC948197FD22D2D8E8D92D32E57332F8041A178E2D73710" },
{ name = "gleam_json", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "C6CC5BEECA525117E97D0905013AB3F8836537455645DDDD10FE31A511B195EF" },
{ name = "gleam_json", version = "0.6.0", build_tools = ["gleam"], requirements = ["thoas", "gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "C6CC5BEECA525117E97D0905013AB3F8836537455645DDDD10FE31A511B195EF" },
{ name = "gleam_stdlib", version = "0.30.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "704258528887F95075FFED7AAE1CCF836A9B88E3AADA2F69F9DA15815F94A4F9" },
{ name = "gleeunit", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "1397E5C4AC4108769EE979939AC39BF7870659C5AFB714630DEEEE16B8272AD5" },
{ name = "lustre", version = "3.0.3", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "3FE126D993DC4B5E779E75AA1D8C80A9F5EC5C5E5A4F859D5B3BAAD61CAE5557" },
{ name = "plinth", version = "0.1.3", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_javascript"], otp_app = "plinth", source = "hex", outer_checksum = "E81BA6A6CEAFFADBCB85B04DC817A4CDC43AFA7BB6AE56CE0B7C7E66D1C9ADD1" },
{ name = "plinth", version = "0.1.3", build_tools = ["gleam"], requirements = ["gleam_javascript", "gleam_stdlib"], source = "local", path = "/opt/plinth" },
{ name = "simplifile", version = "0.1.14", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "10EA0207796F20488A3A166C50A189C9385333F3C9FAC187729DE7B9CE4ADDBC" },
{ name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" },
]
Expand All @@ -23,5 +23,5 @@ gleam_json = { version = "~> 0.5" }
gleam_stdlib = { version = "~> 0.20" }
gleeunit = { version = "~> 0.6" }
lustre = { version = "~> 3.0.0" }
plinth = { version = "~> 0.1.3" }
plinth = { path = "/opt/plinth" }
simplifile = { version = "~> 0.1" }
3 changes: 2 additions & 1 deletion eyg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"prebuild:atelier": "gleam build",
"build:atelier": "npx rollup -f iife -i ./build/dev/javascript/eyg/atelier.js -o build/bundle/atelier.js",
"build:run": "npx rollup -c rollup.config.js -f iife -i ./build/dev/javascript/eyg/run.js -o build/bundle/run.js",
"build:easel": "npx rollup -c rollup.config.js -f iife -i ./build/dev/javascript/eyg/easel.js -o build/bundle/easel.js"
"build:easel": "npx rollup -c rollup.config.js -f iife -i ./build/dev/javascript/eyg/easel.js -o build/bundle/easel.js",
"build:resume": "npx rollup -f iife -i ./build/dev/javascript/eyg/resume.js -o build/bundle/resume.js"
},
"dependencies": {
"adm-zip": "^0.5.10",
Expand Down
2 changes: 1 addition & 1 deletion eyg/saved/saved.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions eyg/src/easel/embed.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import atelier/view/type_
import gleam/javascript
import gleam/javascript/array
import gleam/javascript/promise
import plinth/browser/window
import plinth/browser/document
import old_plinth/browser/window
import old_plinth/browser/document
import platforms/browser

// TODO remove last run information when moving cursor
Expand Down
2 changes: 1 addition & 1 deletion eyg/src/easel/loader.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import gleam/option.{None}
import gleam/string
import gleam/javascript/array
import gleam/javascript
import plinth/browser/document
import old_plinth/browser/document
import easel/embed
import eygir/decode
import harness/ffi/cast
Expand Down
4 changes: 2 additions & 2 deletions eyg/src/harness/effect.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import gleam/javascript/array.{Array}
import gleam/javascript/promise.{try_await}
import simplifile
import eyg/analysis/typ as t
import plinth/browser/window
import plinth/javascript/promisex
import old_plinth/browser/window
import old_plinth/javascript/promisex
import eyg/runtime/interpreter as r
import harness/ffi/cast
import harness/ffi/env
Expand Down
2 changes: 1 addition & 1 deletion eyg/src/harness/ffi/core.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import harness/env.{extend, init}
import harness/ffi/integer
import harness/ffi/linked_list
import harness/ffi/string
import plinth/browser/window
import old_plinth/browser/window

pub fn equal() {
let type_ =
Expand Down
4 changes: 2 additions & 2 deletions eyg/src/observable.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import gleam/option.{None, Option, Some}
import gleam/javascript
import gleam/javascript/array
import gleam/javascript/promise
import plinth/browser/document
import plinth/javascript/promisex
import old_plinth/browser/document
import old_plinth/javascript/promisex

// I think these are observable not signals because subscription rather than get in a call

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions eyg/src/platforms/browser.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import gleam/list
import gleam/map
import gleam/option.{None, Some}
import eygir/decode
import plinth/browser/window
import plinth/browser/document
import old_plinth/browser/window
import old_plinth/browser/document
import eyg/runtime/interpreter as r
import eyg/analysis/typ as t
import harness/effect
import harness/stdlib
import gleam/javascript/array
import gleam/javascript/promise
import plinth/javascript/promisex
import old_plinth/javascript/promisex
import harness/ffi/cast
import harness/ffi/env
import eygir/expression as e
Expand Down
65 changes: 65 additions & 0 deletions eyg/src/platforms/resume.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import gleam/map
import gleam/option.{None, Some}
import gleam/string
import plinth/browser/document
import plinth/browser/element
import plinth/browser/event
import plinth/javascript/console
import eygir/decode
import eyg/runtime/interpreter as r
import harness/stdlib

pub fn run() {
// console.log(document.document())
document.add_event_listener(
"click",
fn(event) {
case element.closest(event.target(event), "*[on\\:click]") {
Ok(target) ->
case element.closest(target, "[r\\:container]") {
Ok(container) -> {
// console.log(#("clicked", target))

case
document.query_selector(
"script[type=\"application/eygir.json\"]",
)
{
Ok(script) -> {
// console.log(script)
let assert Ok(source) =
decode.from_json(string.replace(
element.inner_text(script),
"\\/",
"/",
))
// console.log(source)
// env needs builtins
let env = stdlib.env()
let rev = []
let k = Some(r.Kont(r.CallWith(r.Binary("0"), [], env), None))
let answer = r.eval(source, env, k)
// console.log(answer)
let assert r.Value(term) = answer
// console.log(r.to_string(term))
case term {
r.Tagged("Ok", r.Binary(content)) ->
element.set_inner_html(container, content)
_ -> {
console.log("bad stuff")
Nil
}
}
Nil
}
Error(_) -> Nil
}
}

Error(Nil) -> Nil
}
Error(Nil) -> Nil
}
},
)
}
3 changes: 3 additions & 0 deletions eyg/src/resume.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { run } from "./platforms/resume.mjs";

run();
4 changes: 2 additions & 2 deletions eyg/src/signal.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import gleam/javascript
import gleam/javascript/array
import gleam/javascript/promise
import plinth/javascript/console
import plinth/browser/document
import plinth/javascript/promisex
import old_plinth/browser/document
import old_plinth/javascript/promisex
import eygir/expression as e
import eygir/decode

Expand Down
4 changes: 3 additions & 1 deletion tmp.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ let data (^Await (receive 5000 try_receive))
let stop (serve 5000 (static (projects.website.build "")))
let stop (serve 5000 (multi_tenent [{key "localhost:5000" value projects.laura}]))


let stop (serve 5000 ctrl.serve)

## DB AST

let s (^Read_Source "./saved/saved.json")
Expand All @@ -20,7 +23,6 @@ let db (cozo.ast s)
(^Await (^LoadDB (cozo.ast (std.capture file))))
(^Await (^QueryDB "?[id, attr] := *eav[id, 'label', attr], *eav[id, 'expression', 'Lambda'],"))

(let stop (serve 8080 (fn _ (browser.continue (fn _ (^Log "hey"))))))

## Netlify
let client (facilities.netlify.auth {})
Expand Down
2 changes: 1 addition & 1 deletion zircon/src/plinth/browser/document.gleam
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gleam/javascript/array.{Array}
import plinth/browser/element.{Element}
import old_plinth/browser/element.{Element}

@external(javascript, "../../document_ffi.mjs", "querySelector")
pub fn query_selector(selector: String) -> Result(Element, Nil)
Expand Down
4 changes: 2 additions & 2 deletions zircon/src/stringly_example.gleam
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import plinth/browser/document
import plinth/browser/element
import old_plinth/browser/document
import old_plinth/browser/element
import stringly as h

fn page(x) {
Expand Down

0 comments on commit a685c5b

Please sign in to comment.