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

Playground improvements #169

Merged
merged 7 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
14 changes: 8 additions & 6 deletions src/playground/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { parser as jsParser } from "@lezer/javascript";
import { tags } from "@lezer/highlight";
import { HighlightStyle, syntaxHighlighting, LanguageSupport, LRLanguage } from "@codemirror/language";
import { init as init_ezno, check_with_options, get_version } from "ezno";
// import lz from "lz-string";

const diagnosticsEntry = document.querySelector(".diagnostics");
const editorParent = document.querySelector("#editor");
Expand Down Expand Up @@ -40,12 +39,12 @@ const theme = EditorView.theme({

const STORE = "https://kaleidawave-savednamedplaygrounds.web.val.run"


let text = "const x: 2 = 3;";
let initialText = text;

const { searchParams } = new URL(location);
const id = searchParams.get("id");
const raw = searchParams.get("raw-example");

if (id) {
fetch(STORE + `?id=${id}`, { method: "GET" }).then(res => res.json()).then((result) => {
Expand All @@ -57,6 +56,9 @@ if (id) {
}
})
} else {
if (raw) {
initialText = raw;
}
setup()
}

Expand All @@ -69,7 +71,7 @@ async function setup() {

function getLinter() {
return linter((args) => {
text = args.state.doc.text.toString();
text = args.state.doc.text.join("\n");
try {
const start = performance.now();
currentState = check_with_options(ROOT_PATH, (_) => text, { lsp_mode: true, store_type_mappings: true });
Expand All @@ -96,15 +98,15 @@ async function setup() {
}

function getHover() {
const cursor = hoverTooltip((view, pos, side) => {
const cursor = hoverTooltip((_view, pos, _side) => {
if (currentState) {
const type = currentState.get_type_at_position(ROOT_PATH, pos);
if (typeof type !== "undefined") {
return {
pos,
end: pos,
above: true,
create(view) {
create(_view) {
let dom = document.createElement("div")
dom.textContent = type
// TODO!
Expand Down Expand Up @@ -139,7 +141,7 @@ async function setup() {
return [cursor, cursorTooltipBaseTheme]
}

let editor = new EditorView({
const _editor = new EditorView({
state: EditorState.create({
doc: Text.of([text]),
extensions: [
Expand Down
17 changes: 4 additions & 13 deletions src/playground/package-lock.json

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

4 changes: 2 additions & 2 deletions src/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"@codemirror/view": "^6.23.0",
"@lezer/highlight": "^1.2.0",
"@lezer/javascript": "^1.4.13",
"ezno": "=0.0.21"
"ezno": "^0.0.22"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'd be great if the playground mentioned the version it's using 👀

Copy link
Owner Author

@kaleidawave kaleidawave Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check main.js:162 😄

}
}
}