forked from denoland/deno_lint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c531029
commit 7bb82c2
Showing
11 changed files
with
526 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"lock": false, | ||
"tasks": { | ||
"wasmbuild": "deno run -A jsr:@deno/[email protected] --features wasm --out www/static", | ||
"update-docs": "cargo run --features=docs --example dlint rules --json > www/static/docs.json" | ||
}, | ||
"exclude": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
// @deno-types="../static/deno_lint.d.ts" | ||
import init, { run } from "../static/deno_lint.js"; | ||
import { instantiate, run } from "../static/deno_lint.generated.js"; | ||
import { useEffect, useMemo } from "preact/hooks"; | ||
import { type Signal, useComputed, useSignal } from "@preact/signals"; | ||
import Convert from "https://esm.sh/v130/[email protected]"; | ||
|
@@ -22,7 +21,10 @@ export default function Linter(props: Props) { | |
const initialized = useSignal(false); | ||
|
||
useEffect(() => { | ||
init(fetch("/deno_lint_bg.wasm")).then(() => { | ||
const origin = new URL(location.href).origin; | ||
instantiate({ | ||
url: new URL("deno_lint_bg.wasm", origin), | ||
}).then(() => { | ||
initialized.value = true; | ||
}); | ||
}, []); | ||
|
@@ -55,7 +57,7 @@ export default function Linter(props: Props) { | |
<div class="h-full"> | ||
<div class="border border-gray-300 dark:border-gray-700 dark:bg-[#1e1e1e] p-4 overflow-x-auto h-full"> | ||
{display.value.kind === "Loading" | ||
? <p>Loading...</p> | ||
? <p>wasm is being loaded...</p> | ||
: display.value.kind === "LintError" | ||
? ( | ||
<> | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// deno-lint-ignore-file | ||
// deno-fmt-ignore-file | ||
|
||
export interface InstantiateResult { | ||
instance: WebAssembly.Instance; | ||
exports: { | ||
run: typeof run | ||
}; | ||
} | ||
|
||
/** Gets if the Wasm module has been instantiated. */ | ||
export function isInstantiated(): boolean; | ||
|
||
/** Options for instantiating a Wasm instance. */ | ||
export interface InstantiateOptions { | ||
/** Optional url to the Wasm file to instantiate. */ | ||
url?: URL; | ||
/** Callback to decompress the raw Wasm file bytes before instantiating. */ | ||
decompress?: (bytes: Uint8Array) => Uint8Array; | ||
} | ||
|
||
/** Instantiates an instance of the Wasm module returning its functions. | ||
* @remarks It is safe to call this multiple times and once successfully | ||
* loaded it will always return a reference to the same object. */ | ||
export function instantiate(opts?: InstantiateOptions): Promise<InstantiateResult["exports"]>; | ||
|
||
/** Instantiates an instance of the Wasm module along with its exports. | ||
* @remarks It is safe to call this multiple times and once successfully | ||
* loaded it will always return a reference to the same object. */ | ||
export function instantiateWithInstance(opts?: InstantiateOptions): Promise<InstantiateResult>; | ||
|
||
/** | ||
* @param {string} filename | ||
* @param {string} source_code | ||
* @returns {string} | ||
*/ | ||
export function run(filename: string, source_code: string): string; |
Oops, something went wrong.