mirror of
https://github.com/ziex-dev/ziex.git
synced 2026-07-20 02:29:36 -06:00
docs: re-enable zls 0.16 in pg
This commit is contained in:
parent
1048cc90b6
commit
cf90ffb36a
@ -225,7 +225,7 @@ async function multilineSmartBackspace() {
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Copy from multiline string ────────────────────────────────────────
|
||||
// Copy from multiline string
|
||||
// Strips \\ prefixes from copied text so it pastes cleanly outside
|
||||
// multiline string blocks. Falls through to built-in copy otherwise.
|
||||
async function copyFromMultilineString() {
|
||||
@ -276,7 +276,7 @@ async function copyFromMultilineString() {
|
||||
await vscode.env.clipboard.writeText(stripped);
|
||||
}
|
||||
|
||||
// ─── Paste inside multiline string ─────────────────────────────────────
|
||||
// Paste inside multiline string
|
||||
// Reads clipboard, prefixes each line with \\, then inserts.
|
||||
// Only activates when the cursor is on a \\ line; otherwise falls through
|
||||
// to the built-in paste.
|
||||
|
||||
@ -270,7 +270,6 @@ export class ZxBridge extends ZxBridgeCore {
|
||||
_wsClose: (wsId: bigint, code: number, reasonPtr: number, reasonLen: number) => {
|
||||
bridgeRef.current?.wsClose(wsId, code, reasonPtr, reasonLen);
|
||||
},
|
||||
// ── Direct DOM externs ──────────────────────────────────────────────────
|
||||
_ce: (id: number, vnodeId: bigint): bigint => {
|
||||
const tagName = TAG_NAMES[id] as string;
|
||||
const el = id >= SVG_TAG_START_INDEX
|
||||
|
||||
@ -19,7 +19,7 @@ import { javascript } from "@codemirror/lang-javascript";
|
||||
import { createPlaygroundShareUrl, decodeFilesFromQuery } from "../../../scripts/playground_share";
|
||||
|
||||
// TODO: zls is not available for Zig 0.17 yet.
|
||||
// let client = createZlsClient(workerTransport(new Worker('/assets/playground/workers/zls.js')));
|
||||
let client = createZlsClient(workerTransport(new Worker('/assets/playground/workers/zls.js')));
|
||||
const PLAYGROUND_NOTICE_STORAGE_KEY = "playground_feature_notice_dismissed_v1";
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ function createEditorState(filename: string, content: string) {
|
||||
|
||||
if (filename.endsWith('.zig') || filename.endsWith('.zx') || filename.endsWith('.zon')) {
|
||||
// TODO: zls is not available for Zig 0.17 yet.
|
||||
// extensions.push(client.plugin(`file:///${filename}`, "zig"));
|
||||
extensions.push(client.plugin(`file:///${filename}`, "zig"));
|
||||
}
|
||||
|
||||
if (filename.endsWith(".zx") || filename.endsWith(".html")) {
|
||||
@ -390,7 +390,7 @@ function setupFeatureNotice() {
|
||||
window.addEventListener("DOMContentLoaded", async () => {
|
||||
setupFeatureNotice();
|
||||
// TODO: zls is not available for Zig 0.17 yet.
|
||||
// await client.initializing;
|
||||
await client.initializing;
|
||||
let code = null;
|
||||
if (location.hash.startsWith("#data=")) {
|
||||
code = location.hash.slice(6);
|
||||
@ -510,7 +510,7 @@ function updatePreviewStatus(emoji: string, label: string, stepId: string) {
|
||||
if (textEl) textEl.textContent = label;
|
||||
}
|
||||
|
||||
// ─── Content hash (fast djb2 variant) ───────────────────────────────────────
|
||||
// Content hash (fast djb2 variant)
|
||||
function hashFiles(map: { [name: string]: string }): string {
|
||||
const s = JSON.stringify(Object.entries(map).sort(([a], [b]) => a.localeCompare(b)));
|
||||
let h = 5381;
|
||||
@ -518,7 +518,7 @@ function hashFiles(map: { [name: string]: string }): string {
|
||||
return (h >>> 0).toString(36);
|
||||
}
|
||||
|
||||
// ─── In-memory LRU caches (max 8 entries each) ──────────────────────────────
|
||||
// In-memory LRU caches (max 8 entries each)
|
||||
const MAX_CACHE = 8;
|
||||
function cachePut<V>(cache: Map<string, V>, key: string, value: V) {
|
||||
if (cache.size >= MAX_CACHE) cache.delete(cache.keys().next().value!);
|
||||
@ -534,7 +534,7 @@ interface CacheEntry<V> {
|
||||
const transpileCache = new Map<string, CacheEntry<{ [name: string]: string }>>();
|
||||
const buildCache = new Map<string, CacheEntry<unknown>>();
|
||||
|
||||
// ─── Promisified transpile ───────────────────────────────────────────────────
|
||||
// Promisified transpile
|
||||
let transpile_start_time: number | null = null;
|
||||
function transpileZxFileAsync(zxName: string, zxContent: string): Promise<{ [filename: string]: string }> {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -557,7 +557,7 @@ function transpileZxFileAsync(zxName: string, zxContent: string): Promise<{ [fil
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Promisified build ───────────────────────────────────────────────────────
|
||||
// Promisified build
|
||||
let build_start_time = performance.now();
|
||||
function buildFilesAsync(filesMap: { [name: string]: string }): Promise<unknown> {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -575,7 +575,7 @@ function buildFilesAsync(filesMap: { [name: string]: string }): Promise<unknown>
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Run compiled binary ─────────────────────────────────────────────────────
|
||||
// Run compiled binary
|
||||
function runCompiled(compiled: unknown) {
|
||||
appendStatusStep('run', 'Running\u2026');
|
||||
updatePreviewStatus('', 'Running\u2026', 'run');
|
||||
@ -616,7 +616,7 @@ function runCompiled(compiled: unknown) {
|
||||
};
|
||||
}
|
||||
|
||||
// ─── getCurrentFilesMap ──────────────────────────────────────────────────────
|
||||
// getCurrentFilesMap
|
||||
function getCurrentFilesMap(): { [filename: string]: string } {
|
||||
if (activeFileIndex !== -1 && editorView) {
|
||||
fileManager.updateContent(files[activeFileIndex].name, editorView.state.doc.toString());
|
||||
@ -628,14 +628,14 @@ function getCurrentFilesMap(): { [filename: string]: string } {
|
||||
return map;
|
||||
}
|
||||
|
||||
// ─── Core pipeline (shared by Run click + silent prefetch) ───────────────────
|
||||
// Core pipeline (shared by Run click + silent prefetch)
|
||||
async function runTranspileAndBuild(visible: boolean): Promise<unknown | null> {
|
||||
let filesMap = getCurrentFilesMap();
|
||||
if (!filesMap['main.zig']) filesMap['main.zig'] = zigMainSource;
|
||||
|
||||
const zxEntries = Object.entries(filesMap).filter(([n]) => n.endsWith('.zx'));
|
||||
|
||||
// ── Transpile ────────────────────────────────────────────────────────────
|
||||
// Transpile
|
||||
const zxHash = hashFiles(Object.fromEntries(zxEntries));
|
||||
let transpiledFiles: { [name: string]: string } = {};
|
||||
|
||||
@ -710,7 +710,7 @@ async function runTranspileAndBuild(visible: boolean): Promise<unknown | null> {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Build ─────────────────────────────────────────────────────────────────
|
||||
// Build
|
||||
const buildKey = hashFiles(filesMap);
|
||||
const buildHit = buildCache.get(buildKey);
|
||||
if (buildHit) {
|
||||
@ -787,7 +787,7 @@ outputsRun.addEventListener('click', async () => {
|
||||
runCompiled(compiled);
|
||||
});
|
||||
|
||||
// ─── Background building on editor mouseleave ────────────────────────────────
|
||||
// Background building on editor mouseleave
|
||||
document.getElementById('pg-editor')?.addEventListener('mouseleave', () => {
|
||||
if (prefetchPromise) return; // already prefetching
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ onmessage = (event) => {
|
||||
|
||||
(async () => {
|
||||
// TODO: zls is not available for Zig 0.17 yet.
|
||||
return;
|
||||
// return;
|
||||
let libDirectory = await getLatestZigArchive();
|
||||
|
||||
let args = ["zls.wasm"];
|
||||
@ -58,7 +58,7 @@ onmessage = (event) => {
|
||||
];
|
||||
let wasii = new WASI(args, env, fds, { debug: false });
|
||||
|
||||
const response = await fetchWithCache("/assets/playground/zls.wasm");
|
||||
const response = await fetchWithCache("https://playground.zigtools.org/assets/zls-Cv7Q1mLZ.wasm");
|
||||
const { instance: localInstance } = await WebAssembly.instantiateStreaming(response, {
|
||||
"wasi_snapshot_preview1": wasii.wasiImport,
|
||||
});
|
||||
|
||||
@ -21,6 +21,7 @@ pub fn build(b: *std.Build) !void {
|
||||
// const playground_dep = b.dependency("playground", .{});
|
||||
// const zls_dep = playground_dep.builder.dependency("zls", .{ .target = wasm_target, .optimize = wasm_optimize });
|
||||
const zx_wasm_dep = b.dependency("ziex", .{ .target = wasm_target, .optimize = wasm_optimize });
|
||||
const zls_wasm_url = "https://playground.zigtools.org/assets/zls-Cv7Q1mLZ.wasm";
|
||||
const zig_dep = b.dependency("zig", .{
|
||||
.target = wasm_target,
|
||||
.optimize = wasm_optimize,
|
||||
@ -69,11 +70,16 @@ pub fn build(b: *std.Build) !void {
|
||||
run_zx_tar.has_side_effects = true;
|
||||
const zx_tar_gz = run_zx_tar.addOutputFileArg("zx.tar.gz");
|
||||
run_zx_tar.addArgs(&.{
|
||||
"--exclude", "src/cli",
|
||||
"--exclude", "src/lsp",
|
||||
"--exclude", "src/tui",
|
||||
"--exclude", "src/build",
|
||||
"--exclude", "src/main.zig",
|
||||
"--exclude",
|
||||
"src/cli",
|
||||
"--exclude",
|
||||
"src/lsp",
|
||||
"--exclude",
|
||||
"src/tui",
|
||||
"--exclude",
|
||||
"src/build",
|
||||
"--exclude",
|
||||
"src/main.zig",
|
||||
});
|
||||
run_zx_tar.addArg("-C");
|
||||
run_zx_tar.addDirectoryArg(zx_wasm_dep.path("."));
|
||||
@ -81,6 +87,9 @@ pub fn build(b: *std.Build) !void {
|
||||
|
||||
const playground_assets = b.addNamedWriteFiles("playground_assets");
|
||||
// _ = playground_assets.addCopyFile(zls_exe.getEmittedBin(), "zls.wasm");
|
||||
const pg_get_zls = b.addSystemCommand(&.{ "curl", "-LSsf", zls_wasm_url, "-o" });
|
||||
pg_get_zls.expectExitCode(0);
|
||||
_ = playground_assets.addCopyFile(pg_get_zls.addOutputFileArg("zls.wasm"), "zls.wasm");
|
||||
_ = playground_assets.addCopyFile(zig_exe.getEmittedBin(), b.fmt("zig-{s}.wasm", .{ziex.info.minimum_zig_version}));
|
||||
_ = playground_assets.addCopyFile(zx_exe.getEmittedBin(), b.fmt("zx-{s}.wasm", .{ziex.info.version}));
|
||||
_ = playground_assets.addCopyFile(lib_compiler_rt.getEmittedBin(), "libcompiler_rt.a");
|
||||
@ -98,6 +107,7 @@ pub fn build(b: *std.Build) !void {
|
||||
// -- Steps: pg - installs playground assets --- //
|
||||
const pg_step = b.step("pg", "Install playground assets");
|
||||
pg_step.dependOn(&install_pg.step);
|
||||
pg_step.dependOn(&pg_get_zls.step);
|
||||
|
||||
// --- ZX App Executable --- //
|
||||
const app_exe = b.addExecutable(.{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user