chore: clean up warnings in starmelon
This commit is contained in:
parent
376a14480b
commit
f8191db391
6 changed files with 31 additions and 70 deletions
|
|
@ -5,7 +5,6 @@ use deno_core::{v8, Extension, OpState};
|
||||||
use elm_project_utils::{setup_generator_project, ElmPostProcessor, ElmResult};
|
use elm_project_utils::{setup_generator_project, ElmPostProcessor, ElmResult};
|
||||||
use os_pipe::dup_stderr;
|
use os_pipe::dup_stderr;
|
||||||
use sqlx::sqlite::SqlitePool;
|
use sqlx::sqlite::SqlitePool;
|
||||||
use sqlx::Row;
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,11 @@
|
||||||
use crate::exec::{fixtures, runtime};
|
use crate::exec::{fixtures, runtime};
|
||||||
use crate::reporting::{CompilerError, InterpreterError, Problem};
|
use crate::reporting::{CompilerError, InterpreterError, Problem};
|
||||||
use deno_core::{v8, Extension, OpState};
|
use deno_core::{Extension, OpState};
|
||||||
use elm_project_utils::{setup_generator_project, ElmPostProcessor, ElmResult};
|
use elm_project_utils::{setup_generator_project, ElmPostProcessor};
|
||||||
use os_pipe::dup_stderr;
|
use os_pipe::dup_stderr;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Deserialize;
|
||||||
use sqlx::sqlite::SqlitePool;
|
|
||||||
use sqlx::Row;
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::convert::TryFrom;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
@ -140,8 +136,6 @@ pub(crate) fn run(
|
||||||
// lookups using the rust v8 API.
|
// lookups using the rust v8 API.
|
||||||
buffer.push_str(
|
buffer.push_str(
|
||||||
r#"
|
r#"
|
||||||
globalThis.runOnInput = function(route) {};
|
|
||||||
|
|
||||||
if (worker.ports.onFilesOutput) {
|
if (worker.ports.onFilesOutput) {
|
||||||
worker.ports.onFilesOutput.subscribe(function(result){
|
worker.ports.onFilesOutput.subscribe(function(result){
|
||||||
Deno.core.opSync('op_starmelon_elm_css_files_output', result)
|
Deno.core.opSync('op_starmelon_elm_css_files_output', result)
|
||||||
|
|
@ -159,42 +153,8 @@ pub(crate) fn run(
|
||||||
.map_err(|io_err| CompilerError::WriteOutputFailed(io_err, buffer_file.clone()))?;
|
.map_err(|io_err| CompilerError::WriteOutputFailed(io_err, buffer_file.clone()))?;
|
||||||
drop(timing_guard);
|
drop(timing_guard);
|
||||||
|
|
||||||
let desired_route = entrypoint.0.module.clone().to_string();
|
let _desired_route = entrypoint.0.module.clone().to_string();
|
||||||
let foo = move |mut scope: deno_core::v8::HandleScope| -> Result<(), InterpreterError> {
|
let foo = move |_scope: deno_core::v8::HandleScope| -> Result<(), InterpreterError> { Ok(()) };
|
||||||
Ok(())
|
|
||||||
// I don't think we have to provide any input to kick the process off
|
|
||||||
|
|
||||||
//let scope = &mut scope;
|
|
||||||
//let ctx = scope.get_current_context();
|
|
||||||
//let global = ctx.global(scope);
|
|
||||||
|
|
||||||
//let entrypoint = {
|
|
||||||
// let x =
|
|
||||||
// v8::String::new(scope, "runOnInput").ok_or(InterpreterError::AllocationFailed)?;
|
|
||||||
// v8::Local::new(scope, x).into()
|
|
||||||
//};
|
|
||||||
//let v8_value = global
|
|
||||||
// .get(scope, entrypoint)
|
|
||||||
// .ok_or(InterpreterError::ReferenceError)?;
|
|
||||||
|
|
||||||
//// step 12 invoke the function
|
|
||||||
//let function = v8::Local::<v8::Function>::try_from(v8_value)?;
|
|
||||||
|
|
||||||
//let this = v8::undefined(scope).into();
|
|
||||||
|
|
||||||
//let span = info_span!("dispatch v8 call");
|
|
||||||
//let timing_guard = span.enter();
|
|
||||||
//let arg1 = {
|
|
||||||
// let x =
|
|
||||||
// v8::String::new(scope, &desired_route).ok_or(InterpreterError::AllocationFailed)?;
|
|
||||||
// v8::Local::new(scope, x).into()
|
|
||||||
//};
|
|
||||||
|
|
||||||
//function.call(scope, this, &[arg1]);
|
|
||||||
//drop(timing_guard);
|
|
||||||
|
|
||||||
//Ok(())
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create a tokio runtime before registering ops so we can block on futures inside sync ops
|
// Create a tokio runtime before registering ops so we can block on futures inside sync ops
|
||||||
let span = info_span!("create tokio runtime");
|
let span = info_span!("create tokio runtime");
|
||||||
|
|
@ -214,7 +174,7 @@ pub(crate) fn run(
|
||||||
let mailbox: Arc<RefCell<Option<Vec<FileDefinition>>>> = Arc::new(RefCell::new(None));
|
let mailbox: Arc<RefCell<Option<Vec<FileDefinition>>>> = Arc::new(RefCell::new(None));
|
||||||
let mailbox_clone = Arc::clone(&mailbox);
|
let mailbox_clone = Arc::clone(&mailbox);
|
||||||
|
|
||||||
let mut extensions = vec![Extension::builder()
|
let extensions = vec![Extension::builder()
|
||||||
.ops(vec![op_starmelon_elm_css_files_output::decl()])
|
.ops(vec![op_starmelon_elm_css_files_output::decl()])
|
||||||
.state(move |state| {
|
.state(move |state| {
|
||||||
state.put(Arc::clone(&mailbox_clone));
|
state.put(Arc::clone(&mailbox_clone));
|
||||||
|
|
@ -245,23 +205,27 @@ pub(crate) fn run(
|
||||||
match mailbox.replace(None) {
|
match mailbox.replace(None) {
|
||||||
Some(files) => {
|
Some(files) => {
|
||||||
let base = match output {
|
let base = match output {
|
||||||
None => {
|
None => std::env::current_dir().unwrap(),
|
||||||
std::env::current_dir().unwrap()
|
|
||||||
}
|
|
||||||
Some(base) => base,
|
Some(base) => base,
|
||||||
};
|
};
|
||||||
for FileDefinition { filename, content, success } in files.iter() {
|
for FileDefinition {
|
||||||
|
filename,
|
||||||
|
content,
|
||||||
|
success,
|
||||||
|
} in files.iter()
|
||||||
|
{
|
||||||
if *success {
|
if *success {
|
||||||
let outfile = base.join(&filename);
|
let outfile = base.join(&filename);
|
||||||
let mut f = fs::File::create(&outfile)
|
let mut f = fs::File::create(&outfile).map_err(|io_err| {
|
||||||
.map_err(|io_err| CompilerError::WriteOutputFailed(io_err, outfile.clone()))?;
|
CompilerError::WriteOutputFailed(io_err, outfile.clone())
|
||||||
|
})?;
|
||||||
f.write_all(content.as_bytes())
|
f.write_all(content.as_bytes())
|
||||||
.map_err(|io_err| CompilerError::WriteOutputFailed(io_err, outfile))?;
|
.map_err(|io_err| CompilerError::WriteOutputFailed(io_err, outfile))?;
|
||||||
} else {
|
} else {
|
||||||
eprintln!("{} failed\n{}", filename, content)
|
eprintln!("{} failed\n{}", filename, content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => eprintln!("nothing in the mailbox"),
|
None => eprintln!("nothing in the mailbox"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
use crate::exec::astrid_pages::OutputType;
|
|
||||||
use elm_quote::Tokens;
|
use elm_quote::Tokens;
|
||||||
use genco::tokens::quoted;
|
|
||||||
|
|
||||||
pub(crate) fn generate(source_checksum: u64, entrypoint: &elmi::Global) -> (String, String) {
|
pub(crate) fn generate(source_checksum: u64, entrypoint: &elmi::Global) -> (String, String) {
|
||||||
let tokens: Tokens = genco::quote! {
|
let tokens: Tokens = genco::quote! {
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,8 @@ use deno_core::futures::StreamExt;
|
||||||
use deno_core::{Extension, OpState};
|
use deno_core::{Extension, OpState};
|
||||||
use elm_project_utils::ElmResult;
|
use elm_project_utils::ElmResult;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::value::Number;
|
use serde_json::{value::Map, value::Number, Value};
|
||||||
use serde_json::Value;
|
use sqlx::{sqlite::SqlitePool, Column, Row, TypeInfo, ValueRef};
|
||||||
use sqlx::sqlite::SqlitePool;
|
|
||||||
use sqlx::Row;
|
|
||||||
use sqlx::{Column, TypeInfo, ValueRef};
|
|
||||||
use std::thread::JoinHandle;
|
use std::thread::JoinHandle;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use tokio;
|
use tokio;
|
||||||
|
|
@ -163,10 +160,6 @@ enum AstridQueryError {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_marshal(row: &sqlx::sqlite::SqliteRow) -> Result<serde_json::Value, sqlx::Error> {
|
fn try_marshal(row: &sqlx::sqlite::SqliteRow) -> Result<serde_json::Value, sqlx::Error> {
|
||||||
use serde_json::value::Map;
|
|
||||||
use serde_json::Value;
|
|
||||||
use sqlx::{Column, TypeInfo};
|
|
||||||
|
|
||||||
let mut object = Map::new();
|
let mut object = Map::new();
|
||||||
for i in 0..row.len() {
|
for i in 0..row.len() {
|
||||||
let value = try_decode_column(row, i)?;
|
let value = try_decode_column(row, i)?;
|
||||||
|
|
|
||||||
|
|
@ -135,16 +135,25 @@ fn is_css_in_elm_stylesheet(tipe: &elmi::Type) -> bool {
|
||||||
elmi::Type::TTuple(a, b, None) => {
|
elmi::Type::TTuple(a, b, None) => {
|
||||||
match &**a {
|
match &**a {
|
||||||
elmi::Type::TType(module_name, name, _)
|
elmi::Type::TType(module_name, name, _)
|
||||||
if module_name == "elm/core/String" && name == "String" => (),
|
if module_name == "elm/core/String" && name == "String" =>
|
||||||
|
{
|
||||||
|
()
|
||||||
|
}
|
||||||
_ => return false,
|
_ => return false,
|
||||||
}
|
}
|
||||||
match &**b {
|
match &**b {
|
||||||
elmi::Type::TType(module_name, name, args)
|
elmi::Type::TType(module_name, name, args)
|
||||||
if module_name == "elm/core/List" && name == "List" && args.len() == 1 =>
|
if module_name == "elm/core/List"
|
||||||
|
&& name == "List"
|
||||||
|
&& args.len() == 1 =>
|
||||||
{
|
{
|
||||||
match &args[0] {
|
match &args[0] {
|
||||||
elmi::Type::TAlias(module_name, name, _, _)
|
elmi::Type::TAlias(module_name, name, _, _)
|
||||||
if module_name == "ThinkAlexandria/css-in-elm/Css" && name == "Stylesheet" => return true,
|
if module_name == "ThinkAlexandria/css-in-elm/Css"
|
||||||
|
&& name == "Stylesheet" =>
|
||||||
|
{
|
||||||
|
return true
|
||||||
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -154,7 +163,6 @@ fn is_css_in_elm_stylesheet(tipe: &elmi::Type) -> bool {
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ use deno_core::{Extension, OpState};
|
||||||
use elm_project_utils::{setup_generator_project, ElmResult};
|
use elm_project_utils::{setup_generator_project, ElmResult};
|
||||||
use os_pipe::dup_stderr;
|
use os_pipe::dup_stderr;
|
||||||
use sqlx::sqlite::SqlitePool;
|
use sqlx::sqlite::SqlitePool;
|
||||||
use sqlx::Row;
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue