Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It honks #191

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6da8ac9
[honk] stub out build targets
anp Aug 29, 2020
40f42cc
[honk] boilerplate vscode extension
anp Aug 29, 2020
e2bcd83
[dom][examples] switch to console_error_panic_hook
anp Aug 29, 2020
cf36f39
[ts-bindgen] initial impl bits
anp Aug 30, 2020
29d648a
[ts-bindgen] reorganize crate
anp Aug 30, 2020
37a789d
[ts-bindgen] start of an IR for TS types
anp Sep 4, 2020
12fe94f
[ts-bindgen] begging of ctors and methods, better Debug impls
anp Sep 4, 2020
db3cc4d
[ts-bindgen] unify ctor and function types, improve module debug
anp Sep 4, 2020
2ba1083
[ts-bindgen] handle async/generator functions
anp Sep 4, 2020
3d387b8
[ts-bindgen] modules have functions
anp Sep 4, 2020
5b09cac
[ts-bindgen] start splitting typescript into submodules, starting wit…
anp Sep 4, 2020
2c87f79
[ts-bindgen] finish splitting typescript.rs up
anp Sep 4, 2020
2abba30
[ts-bindgen] start distinguishing between mvp and future work
anp Sep 4, 2020
9e4a163
[ts-bindgen] remove glob imports from ast crate
anp Sep 4, 2020
660b234
[ts-bindgen] finish variables in modules
anp Sep 4, 2020
fbd9393
[ts-bindgen] start adding interfaces in modules
anp Sep 4, 2020
80f2084
[ts-bindgen] move names into modules
anp Sep 4, 2020
89d007a
[ts-bindgen] aliases
anp Sep 4, 2020
13e3795
[ts-bindgen] remove old todo
anp Sep 4, 2020
63abb32
[ts-bindgen] compact module.rs
anp Sep 4, 2020
451a0ef
[ts-bindgen] identify which type variants we need to support for vscode
anp Sep 4, 2020
897868c
[ts-bindgen] start implementing basic Ty's
anp Sep 4, 2020
6fb2de3
[ts-bindgen] fn and ctor types
anp Sep 5, 2020
51c4abf
[ts-bindgen] almost the rest of the parsing owl
anp Sep 5, 2020
554c58c
[ts-bindgen] class properties
anp Sep 5, 2020
c2cd2cc
inline unnecessarily outlined function
anp Sep 5, 2020
95edf7c
[ts-bindgen] classes have type parameters
anp Sep 5, 2020
313cb6f
[ts-bindgen] functions know if they're constructors
anp Sep 5, 2020
f0a31f3
[ts-bindgen] functions have type params
anp Sep 5, 2020
c9fb1ce
[ts-bindge] type params for names
anp Sep 5, 2020
c9c9482
[ts-bindgen] add golden file tests, add rustfmt to codegen
anp Sep 6, 2020
aa2c957
[ts-bindgen] align debug output with source language
anp Sep 6, 2020
883abfc
[ts-bindgen] make sure golden rust files build
anp Sep 6, 2020
38d407b
[ts-bindgen] add first golden test (failing)
anp Sep 6, 2020
50b9c64
[ts-bindgen] initial totokens impls
anp Sep 6, 2020
691cb5f
[ts-bindgen] get modules compiling ok
anp Sep 6, 2020
db7f91c
[project] add list of crates to repo readme
anp Sep 7, 2020
3ef10d0
[honk][vscode] switch the boilerplate to a tree data provider
anp Sep 7, 2020
4b3eb4c
[ts-bindgen] start switching strategies to generating webidl
anp Sep 7, 2020
54babe9
[honk][vscode] initial code-sys crate (doesn't build)
anp Sep 7, 2020
ae4e602
[honk][vscode] add lib.rs (oops)
anp Sep 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ test-dom-drivertest = "wa-test dom/examples/drivertest"
test-dom-hacking = "wa-test dom/examples/hacking"
test-dom-todo = "wa-test dom/examples/todo"
test-dom-todo-e2e = "ofl serve-then-run --cwd dom/examples/todo/e2e -- npx cypress run"
test-ts-bindgen = "test --package ts-bindgen"

# standalones
test-dom = "test --package moxie-dom --package ssr-poc --all-targets"
Expand All @@ -103,6 +104,17 @@ clippy-dom = """clippy
--package todomvc-moxie
"""

####################################################################################################
# honk, the awful replacement for ofl

honk-flow = """
watch --clear
-x test-ts-bindgen
-x build-honk-vscode
"""

build-honk-vscode = "wa-pack-build honk/editors/vscode"

####################################################################################################
# ofl

Expand Down
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/honk/editors/vscode",
]
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/honk/editors/vscode",
"--extensionTestsPath=${workspaceFolder}/honk/editors/vscode/test/suite/index"
]
}
]
}
35 changes: 21 additions & 14 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
"version": "2.0.0",
"tasks": [
{
"label": "core crates",
"label": "core",
"type": "shell",
"presentation": {
"group": "main",
"panel": "dedicated"
},
"runOptions": {
"runOn": "folderOpen"
},
"isBackground": true,
"command": "cargo",
"args": [
Expand All @@ -23,15 +20,12 @@
]
},
{
"label": "dom crates",
"label": "dom",
"type": "shell",
"presentation": {
"group": "main",
"panel": "dedicated"
},
"runOptions": {
"runOn": "folderOpen"
},
"isBackground": true,
"command": "cargo",
"args": [
Expand All @@ -42,7 +36,23 @@
]
},
{
"label": "project website",
"label": "honk",
"type": "shell",
"presentation": {
"group": "main",
"panel": "dedicated"
},
"isBackground": true,
"command": "cargo",
"args": [
"honk-flow"
],
"problemMatcher": [
"$rustc-watch"
]
},
{
"label": "website",
"type": "shell",
"presentation": {
"group": "tools",
Expand All @@ -61,7 +71,7 @@
]
},
{
"label": "project server",
"label": "server",
"type": "shell",
"presentation": {
"group": "tools",
Expand All @@ -78,7 +88,7 @@
"problemMatcher": []
},
{
"label": "ofl crates",
"label": "ofl",
"type": "shell",
"presentation": {
"group": "tools",
Expand Down Expand Up @@ -126,9 +136,6 @@
"group": "tools",
"panel": "dedicated"
},
"runOptions": {
"runOn": "folderOpen"
},
"isBackground": true,
"command": "npx",
"args": [
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,6 @@ Things to update:
* `.cargo/config`
* `.github/workflows/main.yml`
* `index.html`
* `README.md`

(Dependabot discovers the workspace members from the root manifest.)
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ members = [
"dom/examples/todo",
"dom/prettiest",
"dom/raf",
"dom/ts-bindgen",
"dyn-cache",
"honk",
"honk/editors/vscode",
"honk/editors/vscode/sys",
"illicit",
"illicit/macro",
"mox",
Expand Down
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,35 @@

For more information about the moxie project, see the [website](https://moxie.rs).

## Crates in this repository

### moxie-dom and other Web/HTML/JS crates

[`moxie-dom`](./dom) offers APIs for incrementally constructing HTML in the browser and elsewhere.
See [examples](./dom/examples) for demos, live versions of which are available on
[the project's website](https://moxie.rs/#web).

[`augdom`](./dom/augdom) wraps the web's [DOM] API and augments it with non-Web polyfills for e.g.
server-side rendering.

[`prettiest`](./dom/prettiest) is a Rust pretty-printer for JavaScript values.

[`raf`](./dom/raf) is a runloop scheduler built with [`requestAnimationFrame`].

### Platform-agnostic crates

[`moxie`](./src) is an [incremental] runtime offering caching and "reactive" state management.

[`dyn-cache`](./dyn-cache) offers generational caches for arbitrary Rust types, allowing a single
database struct to be used for any number of static or dynamic queries.

[`illicit`](./illicit) offers thread-local type-indexed implicit context singletons.

[`topo`](./topo) creates reproducible identifiers for locations in the runtime callgraph. Used to
generate query scopes for `dyn-cache` storage.

[`mox`](/.mox) implements an XML-like syntax for Rust builders inspired by [JSX].

## Contributing and Code of Conduct

See [CONTRIBUTING.md](CONTRIBUTING.md) for overall contributing info and [CONDUCT.md](CODE_OF_CONDUCT.md)
Expand All @@ -24,3 +53,8 @@ Licensed under either of
* [MIT license](LICENSE-MIT)

at your option.

[DOM]: https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model
[`requestAnimationFrame`]: https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
[incremental]: http://adapton.org/
[JSX]: https://facebook.github.io/jsx/
1 change: 1 addition & 0 deletions dom/examples/hacking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repository = "https://github.com/anp/moxie.git"
crate-type = [ "cdylib" ]

[dependencies]
console_error_panic_hook = "0.1.6"
console_log = "0.2.0"
mox = { path = "../../../mox" }
moxie-dom = { path = "../../" }
Expand Down
4 changes: 1 addition & 3 deletions dom/examples/hacking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use wasm_bindgen::prelude::*;
#[wasm_bindgen(start)]
pub fn begin() {
console_log::init_with_level(tracing::log::Level::Debug).unwrap();
std::panic::set_hook(Box::new(|info| {
tracing::error!("{:#?}", info);
}));
console_error_panic_hook::set_once();

tracing::info!("mounting moxie-dom to root");
moxie_dom::boot(document().body().unwrap(), root);
Expand Down
1 change: 1 addition & 0 deletions dom/examples/todo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repository = "https://github.com/anp/moxie.git"
crate-type = [ "cdylib" ]

[dependencies]
console_error_panic_hook = "0.1.6"
illicit = { path = "../../../illicit" }
mox = { path = "../../../mox" }
moxie-dom = { path = "../../" }
Expand Down
4 changes: 1 addition & 3 deletions dom/examples/todo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ impl Todo {
#[wasm_bindgen(start)]
pub fn setup_tracing() {
tracing_wasm::set_as_global_default();
std::panic::set_hook(Box::new(|info| {
error!(?info, "crashed");
}));
console_error_panic_hook::set_once();
info!("tracing initialized");
}

Expand Down
16 changes: 16 additions & 0 deletions dom/ts-bindgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "ts-bindgen"
version = "0.1.0"
edition = "2018"

[dependencies]
anyhow = "1"
swc_common = { version = "0.10.1", features = [ "tty-emitter" ] }
swc_ecma_ast = "0.30.0"
swc_ecma_parser = "0.36.2"
thiserror = "1.0.20"
wasm-bindgen-webidl = "0.2.67"

[dev-dependencies]
pretty_assertions = "0.6.1"
wasm-bindgen = "0.2.67"
81 changes: 81 additions & 0 deletions dom/ts-bindgen/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
use std::{
fmt::{Debug, Display, Formatter, Result as FmtResult},
io,
};
use swc_ecma_parser::error::Error as SwcError;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum BindingError {
#[error("reading input failed")]
ReadInputFile(io::Error),

#[error("writing output failed")]
WriteOutFile(io::Error),

#[error("processing typescript failed")]
Typescript {
#[from]
source: TypescriptError,
},

#[error("generating wasm bindgen from webidl failed")]
WasmBindgen(#[source] anyhow::Error),
}

#[derive(Debug, Error)]
pub enum TypescriptError {
#[error("parsing failed")]
ParseInputFile { source: ParseError },
}

impl From<SwcError> for TypescriptError {
fn from(e: SwcError) -> Self {
TypescriptError::ParseInputFile { source: e.into() }
}
}

#[derive(Error)]
pub struct ParseError {
e: SwcError,
}

impl ParseError {
fn to_stderr(&self) {
use swc_common::errors::{ColorConfig, EmitterWriter, Handler, HandlerFlags};
let emitter = EmitterWriter::stderr(
ColorConfig::Auto,
None, // source maps
false, // short_message
true, // teach
);
let handler = Handler::with_emitter_and_flags(Box::new(emitter), HandlerFlags {
can_emit_warnings: true,
treat_err_as_bug: true,
dont_buffer_diagnostics: true,
report_delayed_bugs: false,
external_macro_backtrace: false, // lol
});
self.e.clone().into_diagnostic(&handler).emit();
}
}

impl Debug for ParseError {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
self.to_stderr();
write!(f, "ParseError(see stderr)")
}
}

impl Display for ParseError {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
self.to_stderr();
write!(f, "Parsing error (see stderr for details)")
}
}

impl From<SwcError> for ParseError {
fn from(e: SwcError) -> Self {
ParseError { e }
}
}
Loading