Skip to content

Commit

Permalink
run fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistonight committed Sep 30, 2023
1 parent 3a6ac17 commit ad9df1a
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 69 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion compiler-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ wasm-bindgen-futures = { version = "0.4.37", optional = true }
js-sys = { version = "0.3.64", optional = true }
web-sys = { version = "0.3.64", optional = true }
instant = "0.1.12"
http = "0.2.9"
log = "0.4.20"

[features]
Expand Down
1 change: 0 additions & 1 deletion compiler-core/src/pack/resource/loader_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,3 @@ async fn load_image_url_internal(loader: &ArcLoader, path: &str) -> PackerResult
async fn load_structured_internal(loader: &ArcLoader, path: &str) -> PackerResult<Value> {
loader.load_structured(path).await
}

30 changes: 0 additions & 30 deletions compiler-core/src/pack/resource/loader_url.rs

This file was deleted.

12 changes: 2 additions & 10 deletions compiler-core/src/pack/resource/resource_github.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! GitHub resource resolver and loader impl
use std::{sync::Arc, borrow::Cow};
use std::sync::Arc;

use crate::util::Path;
use cached::proc_macro::cached;

use super::{ArcLoader, EmptyLoader, Resource, ResourcePath, ResourceResolver};
use crate::pack::{PackerError, PackerResult, ValidUse};
Expand Down Expand Up @@ -128,14 +127,7 @@ async fn get_github_url(
reference: Option<&str>,
) -> PackerResult<String> {
let path = path.as_ref();
let branch = match reference {
Some(reference) => {
reference
}
None => {
"main"
}
};
let branch = reference.unwrap_or("main");
let url = format!("https://raw.githubusercontent.com/{owner}/{repo}/{branch}/{path}");
Ok(url)
}
5 changes: 3 additions & 2 deletions compiler-core/src/util/async_macro_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn set_cancelled(value: bool) {
///
/// Shared code for server and WASM should use the [`yield_now`] macro instead of calling this directly.
pub async fn set_timeout_yield() -> Result<(), WasmError> {
if BUDGET.with(|budget| unsafe {
let has_budget = BUDGET.with(|budget| unsafe {
let b_ref = budget.get();
if *b_ref == 0 {
*b_ref = BUDGET_MAX;
Expand All @@ -44,7 +44,8 @@ pub async fn set_timeout_yield() -> Result<(), WasmError> {
*b_ref -= 1;
true
}
}) {
});
if has_budget {
return Ok(());
}
let promise = WINDOW.with(|window| {
Expand Down
10 changes: 4 additions & 6 deletions compiler-wasm/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
use std::cell::{RefCell, UnsafeCell};
use std::cell::RefCell;
use std::sync::Arc;

use celerc::api::{CompilerMetadata, CompilerOutput, Setting};
use celerc::pack::{
GlobalCacheLoader, LocalResourceResolver, Resource, ResourcePath,
};
use celerc::pack::{LocalResourceResolver, Resource, ResourcePath};
use celerc::util::Path;
use celerctypes::ExecDoc;
use js_sys::Function;
use log::{info, LevelFilter};
use wasm_bindgen::JsValue;
use web_sys::console;

use crate::logger::{self, Logger};
use crate::loader_file::FileLoader;
use crate::loader_url::UrlLoader;
use crate::logger::{self, Logger};

const LOGGER: Logger = Logger;

Expand Down Expand Up @@ -65,7 +63,7 @@ pub fn init(logger: JsValue, load_file: Function, fetch: Function) {
pub async fn compile_document() -> Option<ExecDoc> {
// create root resource
let fs_loader = FILE_LOADER.with(|x| x.clone());
let url_loader = URL_LOADER.with(|x| x.clone());
let url_loader = URL_LOADER.with(|x| x.clone());
let root_path = Path::new();
let resolver = Arc::new(LocalResourceResolver(root_path.clone()));
let resource = Resource::new(
Expand Down
2 changes: 1 addition & 1 deletion compiler-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ mod api;
mod wasm;
use wasm::*;

mod logger;
mod loader_file;
mod loader_url;
mod logger;

// WASM output types
import! {
Expand Down
10 changes: 5 additions & 5 deletions compiler-wasm/src/loader_url.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::cell::RefCell;

use celerc::{yield_now, pack::ResourceLoader};
use celerc::pack::{PackerResult, PackerError};
use js_sys::{Uint8Array, Function};
use wasm_bindgen::{JsValue, JsCast};
use celerc::pack::{PackerError, PackerResult};
use celerc::{pack::ResourceLoader, yield_now};
use js_sys::{Function, Uint8Array};
use wasm_bindgen::{JsCast, JsValue};

use crate::wasm::{stub_function, into_future};
use crate::wasm::{into_future, stub_function};

/// Loader for loading a URL using a provided JS function
pub struct UrlLoader {
Expand Down
2 changes: 1 addition & 1 deletion compiler-wasm/src/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Utils for gluing WASM and JS

use js_sys::{Function, Promise, Boolean};
use js_sys::{Boolean, Function, Promise};
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::JsFuture;

Expand Down
5 changes: 4 additions & 1 deletion web-client/src/core/kernel/editor/CompMgr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export class CompMgr {
this.compiling = false;
}

public async init(loadFile: RequestFileFunction, loadUrl: RequestFileFunction) {
public async init(
loadFile: RequestFileFunction,
loadUrl: RequestFileFunction,
) {
initCompiler(CompilerLog, loadFile, (url: string) => {
CompilerLog.info(`loading ${url}`);
return loadUrl(url);
Expand Down
7 changes: 5 additions & 2 deletions web-client/src/core/kernel/editor/EditorKernelImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import {
import { FileSys, FsResult } from "low/fs";
import { isInDarkMode } from "low/utils";

import { fetchAsBytes } from "low/fetch";
import { EditorKernel } from "./EditorKernel";
import { EditorLog, toFsPath } from "./utils";
import { IdleMgr } from "./IdleMgr";
import { FileMgr } from "./FileMgr";
import { CompMgr } from "./CompMgr";
import { fetchAsBytes } from "low/fetch";

export class EditorKernelImpl implements EditorKernel {
private store: AppStore;
Expand Down Expand Up @@ -82,7 +82,10 @@ export class EditorKernelImpl implements EditorKernel {
}

public async init(): Promise<void> {
await this.compMgr.init(this.fileMgr.getFileAsBytes.bind(this.fileMgr), fetchAsBytes);
await this.compMgr.init(
this.fileMgr.getFileAsBytes.bind(this.fileMgr),
fetchAsBytes,
);
}

/// Reset the editor with a new file system. Unsaved changes will be lost
Expand Down
2 changes: 1 addition & 1 deletion web-client/src/low/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export const fetchAsBytes = async (url: string): Promise<Uint8Array> => {
throw error;
}
throw new Error("unknown error");
}
};
1 change: 0 additions & 1 deletion web-client/src/low/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ export const isInDarkMode = () =>
/// Example: await sleep(1000);
export const sleep = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms));

2 changes: 1 addition & 1 deletion web-client/src/low/utils/yielder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export const createYielder = (budget: number) => {
}
currentBudget--;
return Promise.resolve();
}
};
};
14 changes: 12 additions & 2 deletions web-client/src/ui/doc/DocLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,25 @@ export const DocLine: React.FC<DocLineProps> = ({
</div>
)}
<div className="docline-text-container">
<div className={clsx("docline-primary-text", iconUrl && "docline-icon-text")}>
<div
className={clsx(
"docline-primary-text",
iconUrl && "docline-icon-text",
)}
>
{removeTags(text).trim().length === 0 ? (
<span>&nbsp;</span>
) : (
<Rich size={500} content={text} />
)}
</div>
{secondaryText.length > 0 && (
<div className={clsx("docline-secondary-text", iconUrl && "docline-icon-text")}>
<div
className={clsx(
"docline-secondary-text",
iconUrl && "docline-icon-text",
)}
>
<Rich size={400} content={secondaryText} />
</div>
)}
Expand Down
8 changes: 7 additions & 1 deletion web-client/src/ui/doc/Poor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ type PoorBlockProps = DocPoorText & {
const PoorBlock: React.FC<PoorBlockProps> = ({ type, data, textProps }) => {
return (
<Text as="span" {...textProps}>
{type === "link" ? <a href={data} target="_blank">{data}</a> : data}
{type === "link" ? (
<a href={data} target="_blank">
{data}
</a>
) : (
data
)}
</Text>
);
};
2 changes: 1 addition & 1 deletion web-themes/src/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
.docline-diagnostic-body.docline-diagnostic-error {
background-color: #ff6666;
}
.docline-diagnostic-body.docline-diagnostic-error a{
.docline-diagnostic-body.docline-diagnostic-error a {
color: #0000ff;
}
/* Warning */
Expand Down
2 changes: 1 addition & 1 deletion web-themes/src/granatus.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
.docline-diagnostic-body.docline-diagnostic-error {
background-color: #ff6666;
}
.docline-diagnostic-body.docline-diagnostic-error a{
.docline-diagnostic-body.docline-diagnostic-error a {
color: #0000ff;
}
/* Warning */
Expand Down

0 comments on commit ad9df1a

Please sign in to comment.