diff --git a/.github/workflows/edge.yml b/.github/workflows/edge.yml index e02737ea..e4063cf7 100644 --- a/.github/workflows/edge.yml +++ b/.github/workflows/edge.yml @@ -10,18 +10,20 @@ jobs: steps: - name: Setup repo uses: actions/checkout@v3 - - name: Setup Deno - uses: denoland/setup-deno@v2 + - name: Setup Node.js + uses: actions/setup-node@v4 with: - deno-version: v2.6.8 + node-version: '20' - name: Setup Go uses: actions/setup-go@v4 with: go-version: "1.25.1" - - name: Compile frontend and plug-compile with Deno + - name: Install dependencies + run: npm ci + - name: Compile frontend and plug-compile run: | - deno task build-production - deno task build-plug-compile + npm run build + npm run build:plug-compile - name: Build Go binaries for multiple platforms run: | # Linux ARM64 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 96268293..c732c4bc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,16 +16,21 @@ jobs: with: fetch-depth: 0 fetch-tags: true - - name: Setup Deno - uses: denoland/setup-deno@v2 + - name: Setup Node.js + uses: actions/setup-node@v4 with: - deno-version: v2.6.8 + node-version: '20' + registry-url: 'https://registry.npmjs.org' + - name: Install dependencies + run: npm ci - name: Run build run: | - deno task build-production - deno task build-plug-compile - - name: Publish to JSR - run: deno publish --allow-dirty + npm run build + npm run build:plug-compile + - name: Publish to npm + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Release uses: softprops/action-gh-release@v1 env: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c2a03c85..f38b23a1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,16 +20,21 @@ jobs: fetch-depth: 0 fetch-tags: true - - name: Setup Deno - uses: denoland/setup-deno@v2 + - name: Setup Node.js + uses: actions/setup-node@v4 with: - deno-version: v2.6.8 + node-version: '20' + + - name: Install dependencies + run: npm ci - name: Run build - run: deno task build + run: npm run build - name: Run checks - run: deno task checks + run: | + npm run check + npm test test-go: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index dc78cd5a..ce3a9975 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ tmp_playground website/_plug tmp .idea +.opencode AGENTS.md diff --git a/.node-version b/.node-version new file mode 100644 index 00000000..a45fd52c --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +24 diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..a45fd52c --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +24 diff --git a/Dockerfile b/Dockerfile index e19fc73f..0b9a00f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ # Stage 1: Build the silverbullet binary -# Use the Debian version of Deno as a base image -FROM denoland/deno:debian-2.6.8 AS builder +FROM node:20-bookworm AS builder RUN apt update && apt install -y git wget make ARG TARGETARCH @@ -15,6 +14,9 @@ ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH WORKDIR /app ADD . /app +# Install npm dependencies +RUN npm ci + # Build the `silverbullet` self-contained binary in /app/silverbullet RUN make build diff --git a/Makefile b/Makefile index cb029597..a6d1290a 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ build: # Build client - deno task build + npm run build # Build plug-compile - deno task build-plug-compile + npm run build:plug-compile # Build server go build @@ -19,32 +19,28 @@ clean: check: # Frontend type check - deno task check - # Frontend lint - deno task lint + npm run check # Backend lint go vet fmt: - # Reformat frontend - deno task fmt # Reformat backend go fmt test: # Run frontend tests - deno task test + npx vitest run # Run backend tests go test ./server/... .PHONY: bench bench: - # Run frontend tests - deno task bench + # Run frontend benchmarks + npm run bench generate: # Regenerate the Lua parser from the the grammar - deno run -A npm:@lezer/generator@1.5.1 client/space_lua/lua.grammar -o client/space_lua/parse-lua.js + npx @lezer/generator@1.5.1 client/space_lua/lua.grammar -o client/space_lua/parse-lua.js .PHONY: website website: build diff --git a/README.md b/README.md index 7e4c6059..e0f9728d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ And if you are comfortable **programming** a little bit — now we’re really t Check out the [instructions](https://silverbullet.md/Install). ## Developing SilverBullet -SilverBullet's frontend is written in [TypeScript](https://www.typescriptlang.org/) and built on top of the excellent [CodeMirror 6](https://codemirror.net/) editor component. Additional UI is built using [Preact](https://preactjs.com). [ESBuild](https://esbuild.github.io)) running through Deno is used to build both the front-end. +SilverBullet's frontend is written in [TypeScript](https://www.typescriptlang.org/) and built on top of the excellent [CodeMirror 6](https://codemirror.net/) editor component. Additional UI is built using [Preact](https://preactjs.com). [ESBuild](https://esbuild.github.io) is used to build the frontend. The server backend is written in Go. @@ -43,9 +43,15 @@ If you're considering contributing changes, be aware of the [LLM use policy](htt * `website/`: silverbullet.md website content ### Requirements -* [Deno](https://deno.com/): Used to build the frontend and plugs +* [Node.js](https://nodejs.org/) 24+ and npm 10+: Used to build the frontend and plugs * [Go](https://go.dev/): Used to build the backend +The project includes `.nvmrc` and `.node-version` files. If you use [nvm](https://github.com/nvm-sh/nvm) or another Node version manager, it will automatically use the correct Node.js version: + +```shell +nvm use # If using nvm +``` + It's convenient to also install [air](https://github.com/air-verse/air) for development, this will automatically rebuild both the frontend and backend when changes are made: ```shell @@ -53,6 +59,12 @@ go install github.com/air-verse/air@latest ``` Make sure your `$GOPATH/bin` is in your $PATH. +First, install dependencies: + +```shell +npm install +``` + To build everything and run the server: ```shell @@ -62,7 +74,9 @@ air Alternatively, to build: ```shell -make +make build +# or +npm run build ``` To run the resulting server: @@ -85,7 +99,7 @@ make test ``` ### Build a docker container -Note, you do not need Deno nor Go locally installed for this to work: +Note, you do not need Node.js nor Go locally installed for this to work: ```shell docker build -t silverbullet . diff --git a/STYLE.md b/STYLE.md index ccde0d40..5af6bb33 100644 --- a/STYLE.md +++ b/STYLE.md @@ -44,11 +44,13 @@ import { sleep } from "@silverbulletmd/silverbullet/lib/async"; ### Testing Patterns -TypeScript tests run with Deno. +TypeScript tests run with Vitest (Node.js). **Test structure:** ```typescript -Deno.test("Test description in plain English", async () => { +import { expect, test } from "vitest"; + +test("Test description in plain English", async () => { // Setup const kv = new MemoryKvPrimitives(); const space = new Space(new DataStoreSpacePrimitives(kv), eventHook); @@ -57,26 +59,25 @@ Deno.test("Test description in plain English", async () => { await space.writePage("test", testPage); // Assert - assertEquals(await space.readPage("test"), testPage); + expect(await space.readPage("test")).toEqual(testPage); }); ``` **Assertions:** ```typescript -import { assertEquals, assertNotEquals } from "@std/assert"; +import { expect } from "vitest"; -assertEquals(actual, expected); -assertNotEquals(actual, notExpected); +expect(actual).toEqual(expected); +expect(actual).not.toEqual(notExpected); +expect(value).toBeTruthy(); +expect(value).toBeInstanceOf(ClassName); ``` -**Test configuration:** -```typescript -Deno.test("Test with options", { - sanitizeResources: false, - sanitizeOps: false, -}, async () => { - // test code -}); +**Running tests:** +```bash +npx vitest run # Run all tests once +npx vitest # Run in watch mode +npx vitest run # Run specific test file ``` ### Comments & Documentation diff --git a/bench/lua.bench.ts b/bench/lua.bench.ts index 0820f56b..3f40c23e 100644 --- a/bench/lua.bench.ts +++ b/bench/lua.bench.ts @@ -1,3 +1,8 @@ +use strict; +use warnings; +use File::Copy; +import { bench } from "vitest"; +import { readFile } from "node:fs/promises"; import { parse } from "../client/space_lua/parse.ts"; import { luaBuildStandardEnv } from "../client/space_lua/stdlib.ts"; import { @@ -6,72 +11,71 @@ import { LuaStackFrame, } from "../client/space_lua/runtime.ts"; import { evalStatement } from "../client/space_lua/eval.ts"; -import { assert } from "@std/assert/assert"; import { fileURLToPath } from "node:url"; -Deno.bench("[Lua] Core language", async () => { +bench("[Lua] Core language", async () => { await runLuaTest("../client/space_lua/language_core_test.lua"); }); -Deno.bench("[Lua] Core language (length)", async () => { +bench("[Lua] Core language (length)", async () => { await runLuaTest("../client/space_lua/len_test.lua"); }); -Deno.bench("[Lua] Core language (truthiness)", async () => { +bench("[Lua] Core language (truthiness)", async () => { await runLuaTest("../client/space_lua/truthiness_test.lua"); }); -Deno.bench("[Lua] Core language (arithmetic)", async () => { +bench("[Lua] Core language (arithmetic)", async () => { await runLuaTest("../client/space_lua/arithmetic_test.lua"); }); -Deno.bench("[Lua] Load tests", async () => { +bench("[Lua] Load tests", async () => { await runLuaTest("../client/space_lua/stdlib/load_test.lua"); }); -Deno.bench("[Lua] Table tests", async () => { +bench("[Lua] Table tests", async () => { await runLuaTest("../client/space_lua/stdlib/table_test.lua"); }); -Deno.bench("[Lua] String to number tests", async () => { +bench("[Lua] String to number tests", async () => { await runLuaTest("../client/space_lua/tonumber_test.lua"); }); -Deno.bench("[Lua] String tests", async () => { +bench("[Lua] String tests", async () => { await runLuaTest("../client/space_lua/stdlib/string_test.lua"); // await runLuaTest("../client/space_lua/stdlib/string_test2.lua"); }); -Deno.bench("[Lua] Space Lua tests", async () => { +bench("[Lua] Space Lua tests", async () => { await runLuaTest("../client/space_lua/stdlib/space_lua_test.lua"); }); -Deno.bench("[Lua] OS tests", async () => { +bench("[Lua] OS tests", async () => { await runLuaTest("../client/space_lua/stdlib/os_test.lua"); }); -Deno.bench("[Lua] Math tests", async () => { +bench("[Lua] Math tests", async () => { await runLuaTest("../client/space_lua/stdlib/math_test.lua"); }); -Deno.bench("[Lua] JS tests", async () => { +bench("[Lua] JS tests", async () => { await runLuaTest("../client/space_lua/stdlib/js_test.lua"); }); -Deno.bench("[Lua] Global functions tests", async () => { +bench("[Lua] Global functions tests", async () => { await runLuaTest("../client/space_lua/stdlib/global_test.lua"); }); -Deno.bench("[Lua] Encoding functions tests", async () => { +bench("[Lua] Encoding functions tests", async () => { await runLuaTest("../client/space_lua/stdlib/encoding_test.lua"); }); -Deno.bench("[Lua] Lume functions tests", async () => { +bench("[Lua] Lume functions tests", async () => { await runLuaTest("../client/space_lua/lume_test.lua"); }); async function runLuaTest(luaPath: string) { - const luaFile = await Deno.readTextFile( + const luaFile = await readFile( fileURLToPath(new URL(luaPath, import.meta.url)), ); const chunk = parse(luaFile, {}); @@ -86,6 +90,6 @@ async function runLuaTest(luaPath: string) { } else { console.error(`Error evaluating script:`, e); } - assert(false); + expect(false).toBeTruthy(); } } diff --git a/bin/plug-compile.ts b/bin/plug-compile.ts index fca99b29..dd03887e 100755 --- a/bin/plug-compile.ts +++ b/bin/plug-compile.ts @@ -1,32 +1,34 @@ -import.meta.main = false; -import { Command } from "@cliffy/command"; +import { Command } from "commander"; import { version } from "../version.ts"; import { plugCompileCommand } from "../client/plugos/plug_compile.ts"; -await new Command() +const program = new Command(); + +program .name("plug-compile") .description("Bundle (compile) one or more plug manifests") .version(version) - .helpOption(false) - .usage(" | (see below)") - .arguments("<...name.plug.yaml:string>") - .option("--debug", "Do not minifiy code", { default: false }) - .option("--info", "Print out size info per function", { - default: false, - }) - .option("--watch, -w [type:boolean]", "Watch for changes and rebuild", { - default: false, - }) - .option( - "--dist ", - "Folder to put the resulting .plug.json file into", - { default: "." }, - ) - .option("-c, --config ", "Path to deno.json file to use") - .option("--runtimeUrl ", "URL to worker_runtime.ts to use") - .action(plugCompileCommand) - .parse(Deno.args); + .usage(" ") + .argument("", "One or more .plug.yaml manifest files") + .option("--debug", "Do not minify code", false) + .option("--info", "Print out size info per function", false) + .option("-w, --watch", "Watch for changes and rebuild", false) + .option("--dist ", "Folder to put the resulting .plug.json file into", ".") + .option("-c, --config ", "Path to deno.json file to use") + .option("--runtimeUrl ", "URL to worker_runtime.ts to use") + .action(async (manifestPaths: string[], options: any) => { + await plugCompileCommand( + { + dist: options.dist, + debug: options.debug, + info: options.info, + config: options.config, + runtimeUrl: options.runtimeUrl, + }, + ...manifestPaths, + ); + }); -Deno.exit(0); +program.parse(process.argv); diff --git a/build_client.ts b/build_client.ts index e30e0326..a7ca819b 100644 --- a/build_client.ts +++ b/build_client.ts @@ -1,10 +1,14 @@ -import { copy } from "@std/fs"; +import { cp, mkdir, readFile, writeFile } from "node:fs/promises"; import { fileURLToPath } from "node:url"; +import { dirname, resolve } from "node:path"; +import * as sass from "sass"; -import sass from "denosass"; +import * as esbuild from "esbuild"; import { patchDenoLibJS } from "./client/plugos/plug_compile.ts"; -import { denoPlugin, esbuild } from "./build_deps.ts"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); // This builds the client and puts it into client_bundle/client @@ -13,44 +17,30 @@ export async function bundleAll(): Promise { } export async function copyAssets(dist: string) { - await Deno.mkdir(dist, { recursive: true }); - await copy("client/fonts", `${dist}`, { overwrite: true }); - await copy("client/html/index.html", `${dist}/index.html`, { - overwrite: true, - }); - await copy("client/html/auth.html", `${dist}/auth.html`, { - overwrite: true, - }); - await copy("client/images/favicon.png", `${dist}/favicon.png`, { - overwrite: true, - }); - await copy("client/images/logo.png", `${dist}/logo.png`, { - overwrite: true, - }); - await copy("client/images/logo-dock.png", `${dist}/logo-dock.png`, { - overwrite: true, - }); + await mkdir(dist, { recursive: true }); + await cp("client/fonts", `${dist}`, { recursive: true }); + await cp("client/html/index.html", `${dist}/index.html`); + await cp("client/html/auth.html", `${dist}/auth.html`); + await cp("client/images/favicon.png", `${dist}/favicon.png`); + await cp("client/images/logo.png", `${dist}/logo.png`); + await cp("client/images/logo-dock.png", `${dist}/logo-dock.png`); - const compiler = sass( - Deno.readTextFileSync("client/styles/main.scss"), - { - load_paths: ["client/styles"], - }, - ); - await Deno.writeTextFile( - `${dist}/main.css`, - compiler.to_string("expanded") as string, - ); + const scssContent = await readFile("client/styles/main.scss", "utf-8"); + const result = sass.compileString(scssContent, { + loadPaths: ["client/styles"], + style: "expanded", + }); + await writeFile(`${dist}/main.css`, result.css, "utf-8"); // HACK: Patch the JS by removing an invalid regex - let bundleJs = await Deno.readTextFile(`${dist}/client.js`); + let bundleJs = await readFile(`${dist}/client.js`, "utf-8"); bundleJs = patchDenoLibJS(bundleJs); - await Deno.writeTextFile(`${dist}/client.js`, bundleJs); + await writeFile(`${dist}/client.js`, bundleJs, "utf-8"); } async function buildCopyBundleAssets() { - await Deno.mkdir("client_bundle/client", { recursive: true }); - await Deno.mkdir("client_bundle/base_fs", { recursive: true }); + await mkdir("client_bundle/client", { recursive: true }); + await mkdir("client_bundle/base_fs", { recursive: true }); console.log("Now ESBuilding the client and service workers..."); @@ -66,7 +56,7 @@ async function buildCopyBundleAssets() { }, ], outdir: "client_bundle/client", - absWorkingDir: Deno.cwd(), + absWorkingDir: process.cwd(), bundle: true, treeShaking: true, sourcemap: "linked", @@ -75,10 +65,7 @@ async function buildCopyBundleAssets() { // metafile: true, jsx: "automatic", jsxFragment: "Fragment", - jsxImportSource: "npm:preact@10.23.1", - plugins: [denoPlugin({ - configPath: fileURLToPath(new URL("./deno.json", import.meta.url)), - })], + jsxImportSource: "preact", }); if (result.metafile) { @@ -87,18 +74,20 @@ async function buildCopyBundleAssets() { } // Patch the service_worker {{CACHE_NAME}} - let swCode = await Deno.readTextFile( + let swCode = await readFile( "client_bundle/client/service_worker.js", + "utf-8", ); swCode = swCode.replaceAll("{{CACHE_NAME}}", `cache-${Date.now()}`); - await Deno.writeTextFile("client_bundle/client/service_worker.js", swCode); + await writeFile("client_bundle/client/service_worker.js", swCode, "utf-8"); await copyAssets("client_bundle/client/.client"); console.log("Built!"); } -if (import.meta.main) { +const isMain = process.argv[1] === fileURLToPath(import.meta.url); +if (isMain) { await bundleAll(); esbuild.stop(); } diff --git a/build_deps.ts b/build_deps.ts deleted file mode 100644 index 95d65f08..00000000 --- a/build_deps.ts +++ /dev/null @@ -1,9 +0,0 @@ -// deno-lint-ignore-file no-import-prefix - -// To avoid having to create import maps for plug-compile, we're centralizing the build dependencies here instead of putting them in deno.json - -import * as esbuild from "npm:esbuild@^0.27.3"; -import { denoPlugin } from "jsr:@deno/esbuild-plugin@^1.2.1"; - -export { esbuild }; -export { denoPlugin }; diff --git a/build_plug_compile.ts b/build_plug_compile.ts index 3c5cda5f..a7cf1c9a 100644 --- a/build_plug_compile.ts +++ b/build_plug_compile.ts @@ -1,38 +1,41 @@ -import { denoPlugin, esbuild } from "./build_deps.ts"; +import { mkdir } from "node:fs/promises"; +import * as esbuild from "esbuild"; -await Deno.mkdir("dist", { recursive: true }); +await mkdir("dist", { recursive: true }); const result = await esbuild.build({ - entryPoints: { - "plug-compile": "./bin/plug-compile.ts", - }, - outdir: "dist", + entryPoints: ["./bin/plug-compile.ts"], + outfile: "dist/plug-compile.js", format: "esm", - absWorkingDir: Deno.cwd(), + banner: { + js: "#!/usr/bin/env node", + }, + platform: "node", + absWorkingDir: process.cwd(), bundle: true, metafile: false, treeShaking: true, logLevel: "error", - minify: true, + minify: false, // Don't minify for better debugging + // Mark all npm packages as external - they'll be installed by npm external: [ - // Exclude weird yarn detection modules - "pnpapi", - // Exclude some larger dependencies that can be downloaded on the fly - "npm:esbuild*", - "jsr:@deno/esbuild-plugin*", + "esbuild", + "commander", + "js-yaml", + "picomatch", + "sass", + "fast-glob", ], - plugins: [denoPlugin({ - configPath: new URL("./deno.json", import.meta.url).pathname, - })], }); if (result.metafile) { const text = await esbuild.analyzeMetafile(result.metafile!); console.log("Bundle info", text); } -// const plugBundleJS = await Deno.readTextFile("dist/plug-compile.js"); +// const plugBundleJS = await readFile("dist/plug-compile.js", "utf-8"); // Patch output JS with import.meta.main override to avoid ESBuild CLI handling -// await Deno.writeTextFile( +// await writeFile( // "dist/plug-compile.js", // "import.meta.main = false;\n" + plugBundleJS, +// "utf-8", // ); console.log("Output in dist"); esbuild.stop(); diff --git a/build_plugs_libraries.ts b/build_plugs_libraries.ts index ef6283b9..cb5fcf54 100644 --- a/build_plugs_libraries.ts +++ b/build_plugs_libraries.ts @@ -1,19 +1,29 @@ -import * as path from "@std/path"; -import { esbuild } from "./build_deps.ts"; +import { join } from "node:path"; +import { mkdirSync } from "node:fs"; +import { cp, writeFile } from "node:fs/promises"; +import { parseArgs } from "node:util"; +import { fileURLToPath } from "node:url"; +import { spawn } from "node:child_process"; +import * as esbuild from "esbuild"; + import { compileManifests } from "./client/plugos/plug_compile.ts"; import { builtinPlugNames } from "./plugs/builtin_plugs.ts"; -import { parseArgs } from "@std/cli/parse-args"; -import { fileURLToPath } from "node:url"; -import { copy } from "@std/fs"; import { version } from "./version.ts"; // This builds all built-in plugs and libraries and puts them into client_bundle/base_fs -if (import.meta.main) { +const isMain = process.argv[1] === fileURLToPath(import.meta.url); +if (isMain) { await updateVersionFile(); - const args = parseArgs(Deno.args, { - boolean: ["debug", "reload", "info"], - alias: { w: "watch" }, + const { values: args } = parseArgs({ + args: process.argv.slice(2), + options: { + debug: { type: "boolean" }, + reload: { type: "boolean" }, + info: { type: "boolean" }, + watch: { type: "boolean", short: "w" }, + }, + strict: false, }); const manifests = builtinPlugNames.map((name) => @@ -21,16 +31,16 @@ if (import.meta.main) { ); const plugBundlePath = "client_bundle/base_fs"; - const targetDir = path.join(plugBundlePath, "Library", "Std", "Plugs"); - Deno.mkdirSync(targetDir, { recursive: true }); - Deno.mkdirSync("dist", { recursive: true }); + const targetDir = join(plugBundlePath, "Library", "Std", "Plugs"); + mkdirSync(targetDir, { recursive: true }); + mkdirSync("dist", { recursive: true }); // Copy Library files - await copy("libraries/Library", `${plugBundlePath}/Library`, { - overwrite: true, + await cp("libraries/Library", `${plugBundlePath}/Library`, { + recursive: true, }); - await copy("libraries/Repositories", `${plugBundlePath}/Repositories`, { - overwrite: true, + await cp("libraries/Repositories", `${plugBundlePath}/Repositories`, { + recursive: true, }); // Build the plugs @@ -38,8 +48,8 @@ if (import.meta.main) { manifests, targetDir, { - debug: args.debug, - info: args.info, + debug: args.debug as boolean | undefined, + info: args.info as boolean | undefined, configPath: fileURLToPath(new URL("deno.json", import.meta.url)), }, ); @@ -47,25 +57,44 @@ if (import.meta.main) { } export async function updateVersionFile() { - const command = new Deno.Command("git", { - args: ["describe", "--tags", "--long"], - stdout: "piped", - stderr: "piped", + return new Promise((resolve, reject) => { + const gitProcess = spawn("git", ["describe", "--tags", "--long"], { + stdio: ["ignore", "pipe", "pipe"], + }); + + let stdout = ""; + let stderr = ""; + + gitProcess.stdout?.on("data", (data) => { + stdout += data.toString(); + }); + + gitProcess.stderr?.on("data", (data) => { + stderr += data.toString(); + }); + + gitProcess.on("close", async (code) => { + let commitVersion = stdout.trim(); + + if (!commitVersion || code !== 0) { + // Probably no valid .git repo, fallback to GITHUB_SHA env var (used in CI) + commitVersion = `${version}-${process.env.GITHUB_SHA || "unknown"}`; + } + + const versionFilePath = "./public_version.ts"; + // Write version to file with date in YYYY-MM-DDTHH-MM-SSZ format attached to the version + const versionContent = `export const publicVersion = "${commitVersion}-${ + new Date().toISOString().split(".")[0].replaceAll(":", "-").concat("Z") + }";`; + + try { + await writeFile(versionFilePath, versionContent, "utf-8"); + resolve(); + } catch (err) { + reject(err); + } + }); + + gitProcess.on("error", reject); }); - - const { stdout } = await command.output(); - let commitVersion = new TextDecoder().decode(stdout).trim(); - - if (!commitVersion) { - // Probably no valid .git repo, fallback to GITHUB_SHA env var (used in CI) - commitVersion = `${version}-${Deno.env.get("GITHUB_SHA") || "unknown"}`; - } - - const versionFilePath = "./public_version.ts"; - // Write version to file with date in YYYY-MM-DDTHH-MM-SSZ format attached to the version - const versionContent = `export const publicVersion = "${commitVersion}-${ - new Date().toISOString().split(".")[0].replaceAll(":", "-").concat("Z") - }";`; - - await Deno.writeTextFile(versionFilePath, versionContent); } diff --git a/build_worker_runtime.ts b/build_worker_runtime.ts new file mode 100644 index 00000000..e41ecaf6 --- /dev/null +++ b/build_worker_runtime.ts @@ -0,0 +1,15 @@ +import * as esbuild from "esbuild"; +import { fileURLToPath } from "node:url"; + +// Build worker_runtime.ts into a standalone JS file +await esbuild.build({ + entryPoints: [fileURLToPath(new URL("./client/plugos/worker_runtime.ts", import.meta.url))], + bundle: true, + format: "esm", + platform: "browser", + outfile: "dist/worker_runtime_bundle.js", + minify: false, + treeShaking: true, +}); + +console.log("Built worker_runtime_bundle.js"); diff --git a/client/asset_bundle/builder.ts b/client/asset_bundle/builder.ts index 54729119..553378a2 100644 --- a/client/asset_bundle/builder.ts +++ b/client/asset_bundle/builder.ts @@ -1,8 +1,21 @@ -// import { globToRegExp, mime, path, walk } from "../deps_server.ts"; -import { globToRegExp } from "@std/path"; +import picomatch from "picomatch"; +import { readFile, readdir } from "node:fs/promises"; +import { join } from "node:path"; +import mime from "mime"; + import { AssetBundle } from "./bundle.ts"; -import { walk } from "@std/fs"; -import { mime } from "mimetypes"; + +async function* walk(dir: string): AsyncGenerator<{ path: string }> { + const entries = await readdir(dir, { withFileTypes: true }); + for (const entry of entries) { + const fullPath = join(dir, entry.name); + if (entry.isDirectory()) { + yield* walk(fullPath); + } else if (entry.isFile()) { + yield { path: fullPath }; + } + } +} export async function bundleAssets( rootPath: string, @@ -12,24 +25,17 @@ export async function bundleAssets( if (patterns.length === 0) { return bundle; } - const matchRegexes = patterns.map((pat) => globToRegExp(pat)); + const isMatch = picomatch(patterns); for await ( const file of walk(rootPath) ) { const cleanPath = file.path.substring(rootPath.length + 1); - let match = false; // console.log("Considering", rootPath, file.path, cleanPath); - for (const matchRegex of matchRegexes) { - if (matchRegex.test(cleanPath)) { - match = true; - break; - } - } - if (match) { + if (isMatch(cleanPath)) { bundle.writeFileSync( cleanPath, mime.getType(cleanPath) || "application/octet-stream", - await Deno.readFile(file.path), + await readFile(file.path), ); } } diff --git a/client/asset_bundle/bundle.test.ts b/client/asset_bundle/bundle.test.ts index da00aaca..2096a56b 100644 --- a/client/asset_bundle/bundle.test.ts +++ b/client/asset_bundle/bundle.test.ts @@ -1,16 +1,16 @@ +import { expect, test } from "vitest"; import { AssetBundle } from "./bundle.ts"; -import { assertEquals } from "@std/assert"; -Deno.test("Asset bundle", () => { +test("Asset bundle", () => { const assetBundle = new AssetBundle(); assetBundle.writeTextFileSync("test.txt", "text/plain", "Sup yo"); - assertEquals("text/plain", assetBundle.getMimeType("test.txt")); - assertEquals("Sup yo", assetBundle.readTextFileSync("test.txt")); + expect("text/plain").toEqual(assetBundle.getMimeType("test.txt")); + expect("Sup yo").toEqual(assetBundle.readTextFileSync("test.txt")); const buf = new Uint8Array(3); buf[0] = 1; buf[1] = 2; buf[2] = 3; assetBundle.writeFileSync("test.bin", "application/octet-stream", buf); - assertEquals("application/octet-stream", assetBundle.getMimeType("test.bin")); - assertEquals(buf, assetBundle.readFileSync("test.bin")); + expect("application/octet-stream").toEqual(assetBundle.getMimeType("test.bin")); + expect(buf).toEqual(assetBundle.readFileSync("test.bin")); }); diff --git a/client/boot_config.test.ts b/client/boot_config.test.ts index 5ebfae7f..de4b2617 100644 --- a/client/boot_config.test.ts +++ b/client/boot_config.test.ts @@ -1,30 +1,27 @@ -import { assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { extractSpaceLuaFromPageText, loadConfig } from "./boot_config.ts"; -Deno.test("Test boot config", () => { +test("Test boot config", () => { // One block present - assertEquals( + expect( extractSpaceLuaFromPageText("Hello\n\n```space-lua\ntest()\n```\nMore"), - "test()", - ); + ).toEqual("test()"); // Two blocks present - assertEquals( + expect( extractSpaceLuaFromPageText( "Hello\n\n```space-lua\ntest()\n```\nMore\n\n```space-lua\ntest2()\n```", ), - "test()\ntest2()", - ); + ).toEqual("test()\ntest2()"); // No lua present - assertEquals( + expect( extractSpaceLuaFromPageText("Hello\n\n```lua\ntest()\n```\nMore"), - "", - ); + ).toEqual(""); }); -Deno.test("Test CONFIG lua eval", async () => { +test("Test CONFIG lua eval", async () => { // Test base case: no config code let config = await loadConfig("", {}); - assertEquals(config.values, {}); + expect(config.values).toEqual({}); // Check a few config sets config = await loadConfig( @@ -36,7 +33,7 @@ Deno.test("Test CONFIG lua eval", async () => { `, {}, ); - assertEquals(config.values, { + expect(config.values).toEqual({ option1: "pete", optionObj: { nested: 5, @@ -57,7 +54,7 @@ Deno.test("Test CONFIG lua eval", async () => { `, {}, ); - assertEquals(config.values, { + expect(config.values).toEqual({ option1: "pete", optionObj: { nested: 5, diff --git a/client/codemirror/change.test.ts b/client/codemirror/change.test.ts index d842f0c1..9bfe56c0 100644 --- a/client/codemirror/change.test.ts +++ b/client/codemirror/change.test.ts @@ -1,26 +1,14 @@ +import { expect, test } from "vitest"; import { rangeLength, rangesOverlap } from "./change.ts"; -import { assertEquals } from "@std/assert"; -Deno.test("rangeLength", () => { - assertEquals(rangeLength({ from: 4, to: 11 }), 7); +test("rangeLength", () => { + expect(rangeLength({ from: 4, to: 11 })).toEqual(7); }); -Deno.test("rangesOverlap", () => { - assertEquals( - rangesOverlap({ from: 0, to: 5 }, { from: 3, to: 8 }), - true, - ); - assertEquals( - rangesOverlap({ from: 0, to: 5 }, { from: 6, to: 8 }), - false, - ); +test("rangesOverlap", () => { + expect(rangesOverlap({ from: 0, to: 5 }, { from: 3, to: 8 })).toEqual(true); + expect(rangesOverlap({ from: 0, to: 5 }, { from: 6, to: 8 })).toEqual(false); // `to` is exclusive - assertEquals( - rangesOverlap({ from: 0, to: 6 }, { from: 6, to: 8 }), - false, - ); - assertEquals( - rangesOverlap({ from: 3, to: 6 }, { from: 0, to: 4 }), - true, - ); + expect(rangesOverlap({ from: 0, to: 6 }, { from: 6, to: 8 })).toEqual(false); + expect(rangesOverlap({ from: 3, to: 6 }, { from: 0, to: 4 })).toEqual(true); }); diff --git a/client/codemirror/editor_paste.ts b/client/codemirror/editor_paste.ts index a71fe55e..fc216f02 100644 --- a/client/codemirror/editor_paste.ts +++ b/client/codemirror/editor_paste.ts @@ -6,7 +6,7 @@ import type { Client } from "../client.ts"; import TurndownService from "turndown"; // With tables and task notation as well -import { tables, taskListItems } from "turndown-plugin-gfm"; +import { tables, taskListItems } from "@joplin/turndown-plugin-gfm"; import { lezerToParseTree } from "../markdown_parser/parse_tree.ts"; import { addParentPointers, diff --git a/client/config.test.ts b/client/config.test.ts index 7a91d1ae..8aef3bdf 100644 --- a/client/config.test.ts +++ b/client/config.test.ts @@ -1,27 +1,27 @@ -import { assert, assertEquals, assertThrows } from "@std/assert"; +import { expect, test } from "vitest"; import { Config } from "./config.ts"; -Deno.test("Config - basic functionality", () => { +test("Config - basic functionality", () => { const config = new Config(); // Test set and get config.set("testKey", "testValue"); - assertEquals(config.get(["testKey"], null), "testValue"); + expect(config.get(["testKey"], null)).toEqual("testValue"); // Test insert config.insert("plugs", "plug1"); config.insert("plugs", "plug1"); - assertEquals(config.get("plugs", null), ["plug1", "plug1"]); + expect(config.get("plugs", null)).toEqual(["plug1", "plug1"]); // Test default value - assertEquals(config.get("nonExistentKey", "default"), "default"); + expect(config.get("nonExistentKey", "default")).toEqual("default"); // Test has - assert(config.has("testKey")); - assert(!config.has("nonExistentKey")); + expect(config.has("testKey")).toBeTruthy(); + expect(!config.has("nonExistentKey")).toBeTruthy(); }); -Deno.test("Config - object-based setting", () => { +test("Config - object-based setting", () => { const config = new Config(); // Test setting multiple values at once @@ -31,12 +31,12 @@ Deno.test("Config - object-based setting", () => { key3: 123, }); - assertEquals(config.get("key1", null), "value1"); - assertEquals(config.get("key2", null), "value2"); - assertEquals(config.get("key3", 0), 123); + expect(config.get("key1", null)).toEqual("value1"); + expect(config.get("key2", null)).toEqual("value2"); + expect(config.get("key3", 0)).toEqual(123); }); -Deno.test("Config - paths", () => { +test("Config - paths", () => { const config = new Config(); // Test setting with dot notation @@ -44,26 +44,26 @@ Deno.test("Config - paths", () => { config.set("user.profile.age", 30); // Test getting with dot notation - assertEquals(config.get("user.name", null), "John"); - assertEquals(config.get("user.profile.age", 0), 30); + expect(config.get("user.name", null)).toEqual("John"); + expect(config.get("user.profile.age", 0)).toEqual(30); config.set(["user", "name"], "Pete"); config.set(["user", "profile", "age"], 20); - assertEquals(config.get(["user", "name"], null), "Pete"); - assertEquals(config.get(["user", "profile", "age"], 0), 20); + expect(config.get(["user", "name"], null)).toEqual("Pete"); + expect(config.get(["user", "profile", "age"], 0)).toEqual(20); // Test has with dot notation - assert(config.has("user.name")); - assert(config.has("user.profile")); - assert(config.has("user.profile.age")); - assert(!config.has("user.profile.nonExistent")); + expect(config.has("user.name")).toBeTruthy(); + expect(config.has("user.profile")).toBeTruthy(); + expect(config.has("user.profile.age")).toBeTruthy(); + expect(!config.has("user.profile.nonExistent")).toBeTruthy(); // Test with path notation - assert(config.has(["user", "name"])); - assert(config.has(["user", "profile", "age"])); + expect(config.has(["user", "name"])).toBeTruthy(); + expect(config.has(["user", "profile", "age"])).toBeTruthy(); // Test getting the entire object - assertEquals(config.get("user", {}), { + expect(config.get("user", {})).toEqual({ name: "Pete", profile: { age: 20, @@ -71,39 +71,39 @@ Deno.test("Config - paths", () => { }); }); -Deno.test("Config - edge cases", () => { +test("Config - edge cases", () => { const config = new Config(); // Test setting a value on a non-existent path config.set("a.b.c", "value"); - assertEquals(config.get("a.b.c", null), "value"); + expect(config.get("a.b.c", null)).toEqual("value"); // Test overwriting a primitive with an object config.set("x", "primitive"); - assertEquals(config.get("x", null), "primitive"); + expect(config.get("x", null)).toEqual("primitive"); config.set("x.y", "nested"); - assertEquals(config.get("x.y", null), "nested"); + expect(config.get("x.y", null)).toEqual("nested"); // Test setting a value on a path where part of the path is a primitive config.set("p", "primitive"); config.set("p.q.r", "nested"); - assertEquals(config.get("p.q.r", null), "nested"); + expect(config.get("p.q.r", null)).toEqual("nested"); // Test deep nesting config.set("deep.nesting.test.value", 42); - assertEquals(config.get("deep.nesting.test.value", 0), 42); + expect(config.get("deep.nesting.test.value", 0)).toEqual(42); // Test with empty string key config.set("", "empty"); - assertEquals(config.get("", null), "empty"); + expect(config.get("", null)).toEqual("empty"); // Test with special characters in key config.set("special!@#", "chars"); - assertEquals(config.get("special!@#", null), "chars"); + expect(config.get("special!@#", null)).toEqual("chars"); }); -Deno.test("Config - object setting with dot notation in keys", () => { +test("Config - object setting with dot notation in keys", () => { const config = new Config(); // Test setting an object with dot notation in keys @@ -112,11 +112,11 @@ Deno.test("Config - object setting with dot notation in keys", () => { "user.profile.age": 30, }); - assertEquals(config.get("user.name", null), "John"); - assertEquals(config.get("user.profile.age", 0), 30); + expect(config.get("user.name", null)).toEqual("John"); + expect(config.get("user.profile.age", 0)).toEqual(30); }); -Deno.test("Config - constructor with initial values", () => { +test("Config - constructor with initial values", () => { const config = new Config({ simple: "value", nested: { @@ -124,11 +124,11 @@ Deno.test("Config - constructor with initial values", () => { }, }); - assertEquals(config.get("simple", null), "value"); - assertEquals(config.get("nested.key", null), "nestedValue"); + expect(config.get("simple", null)).toEqual("value"); + expect(config.get("nested.key", null)).toEqual("nestedValue"); }); -Deno.test("Config - schema validation", () => { +test("Config - schema validation", () => { const config = new Config(); // Define a schema for a key @@ -154,61 +154,41 @@ Deno.test("Config - schema validation", () => { config.set("user.name", "John"); // Missing required field should throw - assertThrows( - () => { - config.set("user", { - name: "John", - }); - }, - Error, - "Validation error for user", - ); + expect(() => { + config.set("user", { + name: "John", + }); + }).toThrow("Validation error for user"); // Wrong type should throw - assertThrows( - () => { - config.set("user", { - name: "John", - age: "thirty", // Should be a number - }); - }, - Error, - "Validation error for user", - ); + expect(() => { + config.set("user", { + name: "John", + age: "thirty", // Should be a number + }); + }).toThrow("Validation error for user"); // Wrong type should throw with path - assertThrows( - () => { - config.set(["user", "name"], 22); - }, - Error, - "Validation error for user", - ); + expect(() => { + config.set(["user", "name"], 22); + }).toThrow("Validation error for user"); // Invalid format should throw - assertThrows( - () => { - config.set("user", { - name: "John", - age: 30, - email: "not-an-email", - }); - }, - Error, - "Validation error for user", - ); + expect(() => { + config.set("user", { + name: "John", + age: 30, + email: "not-an-email", + }); + }).toThrow("Validation error for user"); // Value below minimum should throw - assertThrows( - () => { - config.set("user", { - name: "John", - age: -1, // Should be >= 0 - }); - }, - Error, - "Validation error for user", - ); + expect(() => { + config.set("user", { + name: "John", + age: -1, // Should be >= 0 + }); + }).toThrow("Validation error for user"); // Check nested keys config.define("a.b.user", userSchema); @@ -216,16 +196,12 @@ Deno.test("Config - schema validation", () => { console.log(config.schemas); config.set("a.b.user.name", "Hank"); - assertThrows( - () => { - config.set("a.b.user.name", 22); - }, - Error, - "Validation error for a.b.user", - ); + expect(() => { + config.set("a.b.user.name", 22); + }).toThrow("Validation error for a.b.user"); }); -Deno.test("Config - nested schema definitions with arrays", () => { +test("Config - nested schema definitions with arrays", () => { const config = new Config(); // Define schema for nested path using array syntax @@ -246,33 +222,25 @@ Deno.test("Config - nested schema definitions with arrays", () => { maxItems: 10, }); - assertEquals(config.get("app.ui.settings.theme", null), "dark"); - assertEquals(config.get("app.ui.settings.maxItems", 0), 10); + expect(config.get("app.ui.settings.theme", null)).toEqual("dark"); + expect(config.get("app.ui.settings.maxItems", 0)).toEqual(10); // Setting individual nested properties should work config.set("app.ui.settings.theme", "light"); - assertEquals(config.get("app.ui.settings.theme", null), "light"); + expect(config.get("app.ui.settings.theme", null)).toEqual("light"); // Invalid type should throw - assertThrows( - () => { - config.set("app.ui.settings.theme", 123); - }, - Error, - "Validation error for app.ui.settings", - ); + expect(() => { + config.set("app.ui.settings.theme", 123); + }).toThrow("Validation error for app.ui.settings"); // Invalid value should throw - assertThrows( - () => { - config.set("app.ui.settings.maxItems", -1); - }, - Error, - "Validation error for app.ui.settings", - ); + expect(() => { + config.set("app.ui.settings.maxItems", -1); + }).toThrow("Validation error for app.ui.settings"); }); -Deno.test("Config - multiple nested schemas", () => { +test("Config - multiple nested schemas", () => { const config = new Config(); // Define multiple schemas at different nesting levels @@ -302,39 +270,27 @@ Deno.test("Config - multiple nested schemas", () => { config.set("system.config.version", "1.0.0"); config.set("system.config.enabled", true); - assertEquals(config.get("user.name", null), "Alice"); - assertEquals(config.get("system.config.version", null), "1.0.0"); - assertEquals(config.get("system.config.enabled", false), true); + expect(config.get("user.name", null)).toEqual("Alice"); + expect(config.get("system.config.version", null)).toEqual("1.0.0"); + expect(config.get("system.config.enabled", false)).toEqual(true); // Validation should work for both - assertThrows( - () => { - config.set("user.name", 123); - }, - Error, - "Validation error for user", - ); + expect(() => { + config.set("user.name", 123); + }).toThrow("Validation error for user"); - assertThrows( - () => { - config.set("system.config.enabled", "not-boolean"); - }, - Error, - "Validation error for system.config", - ); + expect(() => { + config.set("system.config.enabled", "not-boolean"); + }).toThrow("Validation error for system.config"); }); -Deno.test("Config - invalid schema definition", () => { +test("Config - invalid schema definition", () => { const config = new Config(); // Invalid schema should throw when defined - assertThrows( - () => { - config.define("test", { - type: "invalid-type", // Invalid type - }); - }, - Error, - "Invalid schema for key test", - ); + expect(() => { + config.define("test", { + type: "invalid-type", // Invalid type + }); + }).toThrow("Invalid schema for key test"); }); diff --git a/client/data/data_augmenter.test.ts b/client/data/data_augmenter.test.ts index 0f19ea7f..7f6e867a 100644 --- a/client/data/data_augmenter.test.ts +++ b/client/data/data_augmenter.test.ts @@ -1,9 +1,9 @@ -import { assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { Augmenter } from "./data_augmenter.ts"; import { DataStore } from "./datastore.ts"; import { MemoryKvPrimitives } from "./memory_kv_primitives.ts"; -Deno.test("Test data augmentation", async () => { +test("Test data augmentation", async () => { const ds = new DataStore(new MemoryKvPrimitives()); const john: any = { ref: "john", @@ -28,6 +28,6 @@ Deno.test("Test data augmentation", async () => { // Fetch them back const objs = [john, mary]; await augm.augmentObjectArray(objs, "ref"); - assertEquals(objs[0].augmented, true); - assertEquals(objs[1].augmented, undefined); + expect(objs[0].augmented).toEqual(true); + expect(objs[1].augmented).toEqual(undefined); }); diff --git a/client/data/datastore.test.ts b/client/data/datastore.test.ts index 902966a2..3dabaf73 100644 --- a/client/data/datastore.test.ts +++ b/client/data/datastore.test.ts @@ -1,13 +1,13 @@ +import { expect, test } from "vitest"; import "fake-indexeddb/auto"; import { IndexedDBKvPrimitives } from "./indexeddb_kv_primitives.ts"; import { MemoryKvPrimitives } from "./memory_kv_primitives.ts"; import type { KvPrimitives } from "./kv_primitives.ts"; -import { assertEquals } from "@std/assert"; import { DataStore } from "./datastore.ts"; import { LuaEnv, LuaStackFrame } from "../space_lua/runtime.ts"; import { parseExpressionString } from "../space_lua/parse.ts"; -async function test(db: KvPrimitives) { +async function runDataStoreTest(db: KvPrimitives) { const datastore = new DataStore(db); await datastore.set(["user", "peter"], { name: "Peter" }); await datastore.set(["user", "hank"], { name: "Hank" }); @@ -24,21 +24,18 @@ async function test(db: KvPrimitives) { env, sf, ); - assertEquals(results, [{ name: "Peter" }]); + expect(results).toEqual([{ name: "Peter" }]); } -Deno.test("Test Memory KV DataStore", async () => { +test("Test Memory KV DataStore", async () => { const db = new MemoryKvPrimitives(); // In-memory only, no persistence - await test(db); + await runDataStoreTest(db); await db.close(); }); -Deno.test("Test IndexDB DataStore", { - sanitizeResources: false, - sanitizeOps: false, -}, async () => { +test("Test IndexDB DataStore", async () => { const db = new IndexedDBKvPrimitives("test"); await db.init(); - await test(db); + await runDataStoreTest(db); db.close(); }); diff --git a/client/data/encrypted_kv_primitives.test.ts b/client/data/encrypted_kv_primitives.test.ts index b3ae7326..d7f9f4d6 100644 --- a/client/data/encrypted_kv_primitives.test.ts +++ b/client/data/encrypted_kv_primitives.test.ts @@ -1,9 +1,9 @@ -import { assert, assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { EncryptedKvPrimitives } from "./encrypted_kv_primitives.ts"; import { MemoryKvPrimitives } from "./memory_kv_primitives.ts"; import { deriveCTRKeyFromPassword } from "@silverbulletmd/silverbullet/lib/crypto"; -Deno.test("Test Encrypted KV Primitives", async () => { +test("Test Encrypted KV Primitives", async () => { const memoryKv = new MemoryKvPrimitives(); const salt = new Uint8Array(32); const key = await deriveCTRKeyFromPassword("test", salt); @@ -13,13 +13,13 @@ Deno.test("Test Encrypted KV Primitives", async () => { // Store a basic key await kv.batchSet([{ key: ["key"], value: 10 }]); const [value] = await kv.batchGet([["key"]]); - assertEquals(value, 10); + expect(value).toEqual(10); // Store a binary blob const blob = new Uint8Array([1, 2, 3, 4, 5]); await kv.batchSet([{ key: ["blob"], value: blob }]); const [blobValue] = await kv.batchGet([["blob"]]); - assertEquals(blobValue, blob); + expect(blobValue).toEqual(blob); // Store a nested JSON and blob structure const nested = { @@ -28,7 +28,7 @@ Deno.test("Test Encrypted KV Primitives", async () => { }; await kv.batchSet([{ key: ["nested"], value: nested }]); const [nestedValue] = await kv.batchGet([["nested"]]); - assertEquals(nestedValue, nested); + expect(nestedValue).toEqual(nested); // Put a few objects with a person prefix await kv.batchSet([ @@ -39,18 +39,18 @@ Deno.test("Test Encrypted KV Primitives", async () => { // Then query based on the prefix let counter = 0; for await (const { key, value } of kv.query({ prefix: ["person"] })) { - assertEquals(key[0], "person"); - assert(key[1] === "alice" || key[1] === "bob"); - assert(value.age); + expect(key[0]).toEqual("person"); + expect(key[1] === "alice" || key[1] === "bob").toBeTruthy(); + expect(value.age).toBeTruthy(); counter++; } - assertEquals(counter, 2); + expect(counter).toEqual(2); // Delete something await kv.batchDelete([["person", "alice"]]); // Check it's gone const [deletedValue] = await kv.batchGet([["person", "alice"]]); - assertEquals(deletedValue, undefined); + expect(deletedValue).toEqual(undefined); console.log(memoryKv); @@ -60,5 +60,5 @@ Deno.test("Test Encrypted KV Primitives", async () => { for await (const _ of kv.query({ prefix: ["person"] })) { counter++; } - assertEquals(counter, 0); + expect(counter).toEqual(0); }); diff --git a/client/data/indexeddb_kv_primitives.test.ts b/client/data/indexeddb_kv_primitives.test.ts index fe64ce79..af61e54e 100644 --- a/client/data/indexeddb_kv_primitives.test.ts +++ b/client/data/indexeddb_kv_primitives.test.ts @@ -1,11 +1,9 @@ +import { expect, test } from "vitest"; import "fake-indexeddb/auto"; import { IndexedDBKvPrimitives } from "./indexeddb_kv_primitives.ts"; import { allTests } from "./kv_primitives.test.ts"; -Deno.test("Test IDB key primitives", { - sanitizeResources: false, - sanitizeOps: false, -}, async () => { +test("Test IDB key primitives", async () => { const db = new IndexedDBKvPrimitives("test"); await db.init(); await allTests(db); diff --git a/client/data/kv_primitives.test.ts b/client/data/kv_primitives.test.ts index 5dfb317c..260739d9 100644 --- a/client/data/kv_primitives.test.ts +++ b/client/data/kv_primitives.test.ts @@ -1,5 +1,5 @@ +import { expect } from "vitest"; import type { KvPrimitives } from "./kv_primitives.ts"; -import { assertEquals } from "@std/assert"; import type { KV } from "../../plug-api/types/datastore.ts"; @@ -13,16 +13,16 @@ export async function allTests(db: KvPrimitives) { "kv", "test3", ]]); - assertEquals(result.length, 3); - assertEquals(result[0], "Hello1"); - assertEquals(result[1], "Hello2"); - assertEquals(result[2], undefined); + expect(result.length).toEqual(3); + expect(result[0]).toEqual("Hello1"); + expect(result[1]).toEqual("Hello2"); + expect(result[2]).toEqual(undefined); let counter = 0; // Query all for await (const _entry of db.query({})) { counter++; } - assertEquals(counter, 3); + expect(counter).toEqual(3); counter = 0; // Query prefix @@ -30,7 +30,7 @@ export async function allTests(db: KvPrimitives) { counter++; console.log(_entry); } - assertEquals(counter, 2); + expect(counter).toEqual(2); // Delete a few keys await db.batchDelete([["kv", "test1"], ["other", "random"]]); @@ -38,15 +38,15 @@ export async function allTests(db: KvPrimitives) { "other", "random", ]]); - assertEquals(result2.length, 3); - assertEquals(result2[0], undefined); - assertEquals(result2[1], "Hello2"); - assertEquals(result2[2], undefined); + expect(result2.length).toEqual(3); + expect(result2[0]).toEqual(undefined); + expect(result2[1]).toEqual("Hello2"); + expect(result2[2]).toEqual(undefined); // Update a key await db.batchSet([{ key: ["kv", "test2"], value: "Hello2.1" }]); const [val] = await db.batchGet([["kv", "test2"]]); - assertEquals(val, "Hello2.1"); + expect(val).toEqual("Hello2.1"); // Set a large batch const largeBatch: KV[] = []; @@ -58,7 +58,7 @@ export async function allTests(db: KvPrimitives) { for await (const entry of db.query({ prefix: ["test"] })) { largeBatchResult.push(entry); } - assertEquals(largeBatchResult.length, 50); + expect(largeBatchResult.length).toEqual(50); // Delete the large batch await db.batchDelete(largeBatch.map((e) => e.key)); diff --git a/client/data/memory_kv_primitives.test.ts b/client/data/memory_kv_primitives.test.ts index 313ca6ae..4af57078 100644 --- a/client/data/memory_kv_primitives.test.ts +++ b/client/data/memory_kv_primitives.test.ts @@ -1,22 +1,25 @@ -import { assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; +import { mkdtemp, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; import { MemoryKvPrimitives } from "./memory_kv_primitives.ts"; import { allTests } from "./kv_primitives.test.ts"; import type { KV } from "../../plug-api/types/datastore.ts"; -Deno.test("MemoryKvPrimitives loads from non-existent file without error", async () => { - const tempPath = await Deno.makeTempFile() + "_nonexistent"; +test("MemoryKvPrimitives loads from non-existent file without error", async () => { + const tempPath = join(tmpdir(), `test-${Date.now()}-${Math.random().toString(36)}.json`) + "_nonexistent"; // Disable throttling for tests const store = new MemoryKvPrimitives(tempPath, { throttleMs: 0 }); await store.init(); // Should create an empty store const result = await store.batchGet([["test"]]); - assertEquals(result, [undefined]); + expect(result).toEqual([undefined]); }); -Deno.test("MemoryKvPrimitives passes all KvPrimitives tests", async () => { - const tempPath = await Deno.makeTempFile(); +test("MemoryKvPrimitives passes all KvPrimitives tests", async () => { + const tempPath = join(tmpdir(), `test-${Date.now()}-${Math.random().toString(36)}.json`); try { const store = new MemoryKvPrimitives(tempPath, { throttleMs: 0 }); @@ -26,15 +29,15 @@ Deno.test("MemoryKvPrimitives passes all KvPrimitives tests", async () => { } finally { // Clean up try { - await Deno.remove(tempPath); + await rm(tempPath, { force: true }); } catch (_) { // Ignore errors during cleanup } } }); -Deno.test("MemoryKvPrimitives persists and loads data", async () => { - const tempPath = await Deno.makeTempFile(); +test("MemoryKvPrimitives persists and loads data", async () => { + const tempPath = join(tmpdir(), `test-${Date.now()}-${Math.random().toString(36)}.json`); try { // Create and populate first instance @@ -54,19 +57,19 @@ Deno.test("MemoryKvPrimitives persists and loads data", async () => { // Check if data was loaded correctly const results = await store2.batchGet([["test", "key1"], ["test", "key2"]]); - assertEquals(results, ["value1", "value2"]); + expect(results).toEqual(["value1", "value2"]); } finally { // Clean up try { - await Deno.remove(tempPath); + await rm(tempPath, { force: true }); } catch (_) { // Ignore errors during cleanup } } }); -Deno.test("MemoryKvPrimitives mutations trigger persistence", async () => { - const tempPath = await Deno.makeTempFile(); +test("MemoryKvPrimitives mutations trigger persistence", async () => { + const tempPath = join(tmpdir(), `test-${Date.now()}-${Math.random().toString(36)}.json`); try { // Create and populate first instance @@ -82,19 +85,19 @@ Deno.test("MemoryKvPrimitives mutations trigger persistence", async () => { // Check if data was persisted const results = await store2.batchGet([["test", "key"]]); - assertEquals(results, ["value"]); + expect(results).toEqual(["value"]); } finally { // Clean up try { - await Deno.remove(tempPath); + await rm(tempPath, { force: true }); } catch (_) { // Ignore errors during cleanup } } }); -Deno.test("MemoryKvPrimitives persists delete operations", async () => { - const tempPath = await Deno.makeTempFile(); +test("MemoryKvPrimitives persists delete operations", async () => { + const tempPath = join(tmpdir(), `test-${Date.now()}-${Math.random().toString(36)}.json`); try { // Create and populate store @@ -116,26 +119,26 @@ Deno.test("MemoryKvPrimitives persists delete operations", async () => { // Check if delete was persisted const results = await store2.batchGet([["test", "key1"], ["test", "key2"]]); - assertEquals(results, [undefined, "value2"]); + expect(results).toEqual([undefined, "value2"]); } finally { // Clean up try { - await Deno.remove(tempPath); + await rm(tempPath, { force: true }); } catch (_) { // Ignore errors during cleanup } } }); -Deno.test("MemoryKvPrimitives.fromFile creates and initializes store", async () => { - const tempPath = await Deno.makeTempFile(); +test("MemoryKvPrimitives.fromFile creates and initializes store", async () => { + const tempPath = join(tmpdir(), `test-${Date.now()}-${Math.random().toString(36)}.json`); try { // Create JSON file with initial data const initialData = { "test\0key": "value", }; - await Deno.writeTextFile(tempPath, JSON.stringify(initialData)); + await writeFile(tempPath, JSON.stringify(initialData), "utf-8"); // Use factory method with throttling disabled const store = await MemoryKvPrimitives.fromFile(tempPath, { @@ -144,19 +147,19 @@ Deno.test("MemoryKvPrimitives.fromFile creates and initializes store", async () // Check if data was loaded const result = await store.batchGet([["test", "key"]]); - assertEquals(result, ["value"]); + expect(result).toEqual(["value"]); } finally { // Clean up try { - await Deno.remove(tempPath); + await rm(tempPath, { force: true }); } catch (_) { // Ignore errors during cleanup } } }); -Deno.test("MemoryKvPrimitives query works with persisted data", async () => { - const tempPath = await Deno.makeTempFile(); +test("MemoryKvPrimitives query works with persisted data", async () => { + const tempPath = join(tmpdir(), `test-${Date.now()}-${Math.random().toString(36)}.json`); try { // Create and populate store @@ -182,15 +185,15 @@ Deno.test("MemoryKvPrimitives query works with persisted data", async () => { results.push(item); } - assertEquals(results.length, 2); - assertEquals(results[0].key, ["test", "key1"]); - assertEquals(results[0].value, "value1"); - assertEquals(results[1].key, ["test", "key2"]); - assertEquals(results[1].value, "value2"); + expect(results.length).toEqual(2); + expect(results[0].key).toEqual(["test", "key1"]); + expect(results[0].value).toEqual("value1"); + expect(results[1].key).toEqual(["test", "key2"]); + expect(results[1].value).toEqual("value2"); } finally { // Clean up try { - await Deno.remove(tempPath); + await rm(tempPath, { force: true }); } catch (_) { // Ignore errors during cleanup } diff --git a/client/data/memory_kv_primitives.ts b/client/data/memory_kv_primitives.ts index 04cbcc26..b3c307ed 100644 --- a/client/data/memory_kv_primitives.ts +++ b/client/data/memory_kv_primitives.ts @@ -1,3 +1,4 @@ +import { readFile, writeFile } from "node:fs/promises"; import type { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts"; import { throttle } from "@silverbulletmd/silverbullet/lib/async"; @@ -62,7 +63,7 @@ export class MemoryKvPrimitives implements KvPrimitives { if (!this.filePath) return; try { - const text = await Deno.readTextFile(this.filePath); + const text = await readFile(this.filePath, "utf-8"); // Handle empty files gracefully to prevent "SyntaxError: Unexpected end of JSON input" if (text.trim() === "") { return; @@ -74,7 +75,7 @@ export class MemoryKvPrimitives implements KvPrimitives { } } catch (error) { // Handle specific errors more gracefully - if (error instanceof Deno.errors.NotFound) { + if ((error as any).code === "ENOENT") { // File doesn't exist yet, nothing to load return; } @@ -167,9 +168,10 @@ export class MemoryKvPrimitives implements KvPrimitives { try { const jsonData = this.toJSON(); - await Deno.writeTextFile( + await writeFile( this.filePath, JSON.stringify(jsonData, null, 2), + "utf-8", ); } catch (error) { console.error(`Failed to persist KV store to ${this.filePath}:`, error); diff --git a/client/data/mq.datastore.test.ts b/client/data/mq.datastore.test.ts index 8c0ea9a6..248c8e60 100644 --- a/client/data/mq.datastore.test.ts +++ b/client/data/mq.datastore.test.ts @@ -1,16 +1,15 @@ +import { expect, test, vi } from "vitest"; import { DataStoreMQ } from "./mq.datastore.ts"; -import { assertEquals } from "@std/assert"; import { MemoryKvPrimitives } from "./memory_kv_primitives.ts"; import { DataStore } from "./datastore.ts"; -import { FakeTime } from "@std/testing/time"; import type { MQMessage } from "../../plug-api/types/datastore.ts"; import { EventHook } from "../plugos/hooks/event.ts"; import { System } from "../plugos/system.ts"; import type { EventHookT } from "@silverbulletmd/silverbullet/type/manifest"; -Deno.test("DataStore MQ", async () => { - const time = new FakeTime(); +test("DataStore MQ", async () => { + vi.useFakeTimers(); const db = new MemoryKvPrimitives(); // In-memory only, no persistence const eventHook = new EventHook(); const system = new System(); @@ -27,62 +26,62 @@ Deno.test("DataStore MQ", async () => { // Send and ack await mq.send("test", "Hello World"); messages = await mq.poll("test", 10); - assertEquals(messages.length, 1); + expect(messages.length).toEqual(1); await mq.ack("test", messages[0].id); - assertEquals([], await mq.poll("test", 10)); + expect([]).toEqual(await mq.poll("test", 10)); // Timeout await mq.send("test", "Hello World"); messages = await mq.poll("test", 10); - assertEquals(messages.length, 1); - assertEquals([], await mq.poll("test", 10)); - await time.tickAsync(20); + expect(messages.length).toEqual(1); + expect([]).toEqual(await mq.poll("test", 10)); + await vi.advanceTimersByTimeAsync(20); await mq.requeueTimeouts(10); messages = await mq.poll("test", 10); const stats = await mq.getQueueStats(); - assertEquals(stats.processing, 1); - assertEquals(messages.length, 1); - assertEquals(messages[0].retries, 1); + expect(stats.processing).toEqual(1); + expect(messages.length).toEqual(1); + expect(messages[0].retries).toEqual(1); // Max retries - await time.tickAsync(20); + await vi.advanceTimersByTimeAsync(20); await mq.requeueTimeouts(10, 1); - assertEquals((await mq.fetchDLQMessages()).length, 1); + expect((await mq.fetchDLQMessages()).length).toEqual(1); // Batch send and ack await mq.batchSend("test", ["Hello", "World"]); const messageBatch1 = await mq.poll("test", 1); - assertEquals(messageBatch1.length, 1); - assertEquals(messageBatch1[0].body, "Hello"); + expect(messageBatch1.length).toEqual(1); + expect(messageBatch1[0].body).toEqual("Hello"); const messageBatch2 = await mq.poll("test", 1); - assertEquals(messageBatch2.length, 1); - assertEquals(messageBatch2[0].body, "World"); + expect(messageBatch2.length).toEqual(1); + expect(messageBatch2[0].body).toEqual("World"); await mq.batchAck("test", [messageBatch1[0].id, messageBatch2[0].id]); - assertEquals(await mq.fetchProcessingMessages(), []); + expect(await mq.fetchProcessingMessages()).toEqual([]); // Subscribe let receivedMessage = false; const worker = mq.subscribe("test123", {}, async (messages) => { - assertEquals(messages.length, 1); + expect(messages.length).toEqual(1); receivedMessage = true; await mq.ack("test123", messages[0].id); }); await mq.send("test123", "Hello World"); // Wait for message to be processed by checking queue stats while ((await mq.getQueueStats("test123")).queued > 0) { - await time.tickAsync(100); + await vi.advanceTimersByTimeAsync(100); } - assertEquals(receivedMessage, true); + expect(receivedMessage).toEqual(true); worker.stop(); - assertEquals(mq.queueWaiters.size, 0); + expect(mq.queueWaiters.size).toEqual(0); } finally { await db.close(); - time.restore(); + vi.useRealTimers(); } }); -Deno.test("DataStore MQ - Scale test with multiple subscribers", async () => { - const time = new FakeTime(); +test("DataStore MQ - Scale test with multiple subscribers", async () => { + vi.useFakeTimers(); const db = new MemoryKvPrimitives(); const eventHook = new EventHook(); const system = new System(); @@ -116,11 +115,7 @@ Deno.test("DataStore MQ - Scale test with multiple subscribers", async () => { queueName, { batchSize }, async (messages) => { - assertEquals( - messages.length <= batchSize, - true, - `Batch size should not exceed ${batchSize}`, - ); + expect(messages.length <= batchSize).toBe(true); console.log( `[Subscriber ${subscriberId}] Processing batch of ${messages.length} messages`, @@ -179,7 +174,7 @@ Deno.test("DataStore MQ - Scale test with multiple subscribers", async () => { const chunk = messageBodies.slice(i, i + chunkSize); await mq.batchSend(queueName, chunk); // Give a small delay to allow processing - await time.tickAsync(10); + await vi.advanceTimersByTimeAsync(10); } // Wait for all messages to be processed @@ -187,24 +182,20 @@ Deno.test("DataStore MQ - Scale test with multiple subscribers", async () => { let waitTime = 0; while (processedMessages.size < totalMessages && waitTime < maxWaitTime) { - await time.tickAsync(100); + await vi.advanceTimersByTimeAsync(100); waitTime += 100; } // Verify all messages were processed - assertEquals( - processedMessages.size, - totalMessages, - `Expected ${totalMessages} messages processed, got ${processedMessages.size}`, - ); + expect(processedMessages.size).toEqual(totalMessages); // Wait a bit more to ensure all acks are processed - await time.tickAsync(100); + await vi.advanceTimersByTimeAsync(100); // Verify queue is empty const stats = await mq.getQueueStats(queueName); - assertEquals(stats.queued, 0, "Queue should be empty"); - assertEquals(stats.processing, 0, "No messages should be processing"); + expect(stats.queued).toEqual(0); + expect(stats.processing).toEqual(0); // Verify work distribution among subscribers let totalProcessedAcrossSubscribers = 0; @@ -212,28 +203,20 @@ Deno.test("DataStore MQ - Scale test with multiple subscribers", async () => { totalProcessedAcrossSubscribers += count; console.log(`Subscriber ${subscriberId} processed ${count} messages`); } - assertEquals( - totalProcessedAcrossSubscribers, - totalMessages, - "Total processed should match sent messages", - ); + expect(totalProcessedAcrossSubscribers).toEqual(totalMessages); // Verify at least one subscriber processed messages (relaxed requirement since MQ may favor one worker) const activeSubscribers = Array.from(subscriberStats.values()).filter((count) => count > 0).length; - assertEquals( - activeSubscribers >= 1, - true, - "At least one subscriber should have processed messages", - ); + expect(activeSubscribers >= 1).toBe(true); // Stop all workers workers.forEach((worker) => worker.stop()); // Verify no queue waiters remain - assertEquals(mq.queueWaiters.size, 0); + expect(mq.queueWaiters.size).toEqual(0); } finally { await db.close(); - time.restore(); + vi.useRealTimers(); } }); diff --git a/client/lib/box_proxy.test.ts b/client/lib/box_proxy.test.ts index cd611d0d..661d6858 100644 --- a/client/lib/box_proxy.test.ts +++ b/client/lib/box_proxy.test.ts @@ -1,59 +1,59 @@ -import { assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { BoxProxy } from "./box_proxy.ts"; -Deno.test("Test LateBinder - basic get functionality", () => { +test("Test LateBinder - basic get functionality", () => { const binder = new BoxProxy({ returnNumber: () => 1, }); const p = binder.buildProxy(); - assertEquals(p.returnNumber(), 1); + expect(p.returnNumber()).toEqual(1); // Now swap out target binder.setTarget({ returnNumber: () => 3, }); - assertEquals(p.returnNumber(), 3); + expect(p.returnNumber()).toEqual(3); }); -Deno.test("Test LateBinder - property setting", () => { +test("Test LateBinder - property setting", () => { const target: any = { count: 0 }; const proxy = new BoxProxy(target).buildProxy(); proxy.count = 5; - assertEquals(target.count, 5); - assertEquals(proxy.count, 5); + expect(target.count).toEqual(5); + expect(proxy.count).toEqual(5); proxy.newProp = "test"; - assertEquals(target.newProp, "test"); - assertEquals(proxy.newProp, "test"); + expect(target.newProp).toEqual("test"); + expect(proxy.newProp).toEqual("test"); }); -Deno.test("Test LateBinder - has operator", () => { +test("Test LateBinder - has operator", () => { const proxy = new BoxProxy({ existing: true, nested: { prop: "value" }, }).buildProxy(); - assertEquals("existing" in proxy, true); - assertEquals("nested" in proxy, true); - assertEquals("nonexistent" in proxy, false); + expect("existing" in proxy).toEqual(true); + expect("nested" in proxy).toEqual(true); + expect("nonexistent" in proxy).toEqual(false); }); -Deno.test("Test LateBinder - delete property", () => { +test("Test LateBinder - delete property", () => { const target: any = { prop1: "value1", prop2: "value2", }; const proxy = new BoxProxy(target).buildProxy(); - assertEquals("prop1" in proxy, true); + expect("prop1" in proxy).toEqual(true); delete proxy.prop1; - assertEquals("prop1" in proxy, false); - assertEquals("prop1" in target, false); + expect("prop1" in proxy).toEqual(false); + expect("prop1" in target).toEqual(false); - assertEquals("prop2" in proxy, true); + expect("prop2" in proxy).toEqual(true); }); -Deno.test("Test LateBinder - ownKeys", () => { +test("Test LateBinder - ownKeys", () => { const target = { prop1: "value1", prop2: "value2", @@ -63,10 +63,10 @@ Deno.test("Test LateBinder - ownKeys", () => { const keys = Object.keys(proxy); const expectedKeys = Object.keys(target); - assertEquals(keys.sort(), expectedKeys.sort()); + expect(keys.sort()).toEqual(expectedKeys.sort()); }); -Deno.test("Test LateBinder - with functions and methods", () => { +test("Test LateBinder - with functions and methods", () => { const target: any = { multiplier: 2, multiply: function (x: number) { @@ -77,12 +77,12 @@ Deno.test("Test LateBinder - with functions and methods", () => { const proxy = new BoxProxy(target).buildProxy(); - assertEquals(proxy.multiply(5), 10); - assertEquals(proxy.arrow(4), 12); - assertEquals(proxy.multiplier, 2); + expect(proxy.multiply(5)).toEqual(10); + expect(proxy.arrow(4)).toEqual(12); + expect(proxy.multiplier).toEqual(2); }); -Deno.test("Test LateBinder - complex object interactions", () => { +test("Test LateBinder - complex object interactions", () => { const target: any = { data: { nested: { value: 42 } }, getValue: function () { @@ -92,14 +92,14 @@ Deno.test("Test LateBinder - complex object interactions", () => { const proxy = new BoxProxy(target).buildProxy(); - assertEquals(proxy.getValue(), 42); + expect(proxy.getValue()).toEqual(42); proxy.data.nested.value = 100; - assertEquals(proxy.getValue(), 100); - assertEquals(target.data.nested.value, 100); + expect(proxy.getValue()).toEqual(100); + expect(target.data.nested.value).toEqual(100); }); -Deno.test("Test LateBinder - target switching with different interfaces", () => { +test("Test LateBinder - target switching with different interfaces", () => { interface Calculator { add(a: number, b: number): number; } @@ -115,19 +115,19 @@ Deno.test("Test LateBinder - target switching with different interfaces", () => const binder = new BoxProxy(calc1); const proxy = binder.buildProxy(); - assertEquals(proxy.add(2, 3), 5); + expect(proxy.add(2, 3)).toEqual(5); binder.setTarget(calc2); - assertEquals(proxy.add(2, 3), 6); + expect(proxy.add(2, 3)).toEqual(6); }); -Deno.test("Test LateBinder - empty target", () => { +test("Test LateBinder - empty target", () => { const proxy = new BoxProxy({}).buildProxy(); - assertEquals(Object.keys(proxy).length, 0); - assertEquals("anything" in proxy, false); + expect(Object.keys(proxy).length).toEqual(0); + expect("anything" in proxy).toEqual(false); (proxy as any).newProp = "added"; - assertEquals((proxy as any).newProp, "added"); - assertEquals("newProp" in proxy, true); + expect((proxy as any).newProp).toEqual("added"); + expect("newProp" in proxy).toEqual(true); }); diff --git a/client/lib/fuse_search.test.ts b/client/lib/fuse_search.test.ts index 00b3ed6a..02713706 100644 --- a/client/lib/fuse_search.test.ts +++ b/client/lib/fuse_search.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import type { FilterOption } from "@silverbulletmd/silverbullet/type/client"; -import { assertEquals } from "@std/assert"; import { fuzzySearchAndSort } from "./fuse_search.ts"; -Deno.test("testFuzzyFilter", () => { +test("testFuzzyFilter", () => { const array: FilterOption[] = [ { name: "My Company/Hank", orderId: 2 }, { name: "My Company/Hane", orderId: 1 }, @@ -13,18 +13,18 @@ Deno.test("testFuzzyFilter", () => { // Prioritize match in last path part let results = fuzzySearchAndSort(array, ""); - assertEquals(results.length, array.length); + expect(results.length).toEqual(array.length); results = fuzzySearchAndSort(array, "Steve"); - assertEquals(results.length, 3); + expect(results.length).toEqual(3); results = fuzzySearchAndSort(array, "Co"); // Match in last path part - assertEquals(results[0].name, "My Company/Steve Co"); + expect(results[0].name).toEqual("My Company/Steve Co"); // Due to orderId - assertEquals(results[1].name, "My Company/Hane"); - assertEquals(results[2].name, "My Company/Hank"); + expect(results[1].name).toEqual("My Company/Hane"); + expect(results[2].name).toEqual("My Company/Hank"); }); -Deno.test("Fuzzy search edge case testing", () => { +test("Fuzzy search edge case testing", () => { // Test edge case where aspiring pages (Infinity orderId) sort last without NaN const array: FilterOption[] = [ { name: "Existing", orderId: 1 }, @@ -32,9 +32,9 @@ Deno.test("Fuzzy search edge case testing", () => { { name: "Aspiring B", orderId: Infinity }, ]; const results = fuzzySearchAndSort(array, ""); - assertEquals(results.length, 3); - assertEquals(results[0].name, "Existing"); + expect(results.length).toEqual(3); + expect(results[0].name).toEqual("Existing"); // Both aspiring pages last; relative order between them is stable (no NaN) - assertEquals(results[1].name, "Aspiring A"); - assertEquals(results[2].name, "Aspiring B"); + expect(results[1].name).toEqual("Aspiring A"); + expect(results[2].name).toEqual("Aspiring B"); }); diff --git a/client/lib/logger.test.ts b/client/lib/logger.test.ts index 670d9256..15e94479 100644 --- a/client/lib/logger.test.ts +++ b/client/lib/logger.test.ts @@ -1,7 +1,7 @@ -import { assert, assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { initLogger, Logger } from "./logger.ts"; -Deno.test("Logger prefix functionality", () => { +test("Logger prefix functionality", () => { // Store original console methods const originalLog = console.log; const originalInfo = console.info; @@ -32,10 +32,10 @@ Deno.test("Logger prefix functionality", () => { console.warn("Warning message"); console.error("Error message"); - assertEquals(capturedOutput[0], "[TEST] Hello world"); - assertEquals(capturedOutput[1], "[TEST] Info message"); - assertEquals(capturedOutput[2], "[TEST] Warning message"); - assertEquals(capturedOutput[3], "[TEST] Error message"); + expect(capturedOutput[0]).toEqual("[TEST] Hello world"); + expect(capturedOutput[1]).toEqual("[TEST] Info message"); + expect(capturedOutput[2]).toEqual("[TEST] Warning message"); + expect(capturedOutput[3]).toEqual("[TEST] Error message"); } finally { // Restore original console methods console.log = originalLog; @@ -45,7 +45,7 @@ Deno.test("Logger prefix functionality", () => { } }); -Deno.test("Logger without prefix", () => { +test("Logger without prefix", () => { const originalLog = console.log; const capturedOutput: string[] = []; @@ -58,13 +58,13 @@ Deno.test("Logger without prefix", () => { console.log("Hello", "world"); - assertEquals(capturedOutput[0], "Hello world"); + expect(capturedOutput[0]).toEqual("Hello world"); } finally { console.log = originalLog; } }); -Deno.test("Logger log capture", () => { +test("Logger log capture", () => { const logger = new Logger("[CAPTURE]"); console.log("First message"); @@ -74,28 +74,28 @@ Deno.test("Logger log capture", () => { const capturedLogs = logger.logBuffer; - assertEquals(capturedLogs.length, 4); + expect(capturedLogs.length).toEqual(4); - assertEquals(capturedLogs[0].level, "log"); - assertEquals(capturedLogs[0].message, "First message"); + expect(capturedLogs[0].level).toEqual("log"); + expect(capturedLogs[0].message).toEqual("First message"); - assertEquals(capturedLogs[1].level, "info"); - assertEquals(capturedLogs[1].message, 'Second message {"key":"value"}'); + expect(capturedLogs[1].level).toEqual("info"); + expect(capturedLogs[1].message).toEqual('Second message {"key":"value"}'); - assertEquals(capturedLogs[2].level, "warn"); - assertEquals(capturedLogs[2].message, "Third message 123"); + expect(capturedLogs[2].level).toEqual("warn"); + expect(capturedLogs[2].message).toEqual("Third message 123"); - assertEquals(capturedLogs[3].level, "error"); - assertEquals(capturedLogs[3].message, "Fourth message"); + expect(capturedLogs[3].level).toEqual("error"); + expect(capturedLogs[3].message).toEqual("Fourth message"); // Check that all entries have timestamps capturedLogs.forEach((entry) => { - assert(typeof entry.timestamp === "number"); - assert(entry.timestamp > 0); + expect(typeof entry.timestamp === "number").toBeTruthy(); + expect(entry.timestamp > 0).toBeTruthy(); }); }); -Deno.test("Logger max capture size", () => { +test("Logger max capture size", () => { const logger = new Logger("[SIZE]", 3); // Add more logs than the max size @@ -108,13 +108,13 @@ Deno.test("Logger max capture size", () => { const capturedLogs = logger.logBuffer; // Should only keep the last 3 messages - assertEquals(capturedLogs.length, 3); - assertEquals(capturedLogs[0].message, "Message 3"); - assertEquals(capturedLogs[1].message, "Message 4"); - assertEquals(capturedLogs[2].message, "Message 5"); + expect(capturedLogs.length).toEqual(3); + expect(capturedLogs[0].message).toEqual("Message 3"); + expect(capturedLogs[1].message).toEqual("Message 4"); + expect(capturedLogs[2].message).toEqual("Message 5"); }); -Deno.test("Global logger initialization", () => { +test("Global logger initialization", () => { const originalLog = console.log; const capturedOutput: string[] = []; @@ -127,14 +127,14 @@ Deno.test("Global logger initialization", () => { console.log("Global test"); - assertEquals(capturedOutput[0], "[GLOBAL] Global test"); - assert(logger instanceof Logger); + expect(capturedOutput[0]).toEqual("[GLOBAL] Global test"); + expect(logger instanceof Logger).toBeTruthy(); } finally { console.log = originalLog; } }); -Deno.test("Logger handles complex objects", () => { +test("Logger handles complex objects", () => { const logger = new Logger("[COMPLEX]"); const complexObject = { @@ -151,14 +151,12 @@ Deno.test("Logger handles complex objects", () => { const capturedLogs = logger.logBuffer; - assertEquals(capturedLogs.length, 2); + expect(capturedLogs.length).toEqual(2); // First log should handle complex object properly - assertEquals( - capturedLogs[0].message, - `Complex object: {"name":"test","nested":{"value":42},"array":[1,2,3]}`, + expect(capturedLogs[0].message).toEqual(`Complex object: {"name":"test","nested":{"value":42},"array":[1,2,3]}`, ); // Second log should handle circular reference gracefully - assertEquals(capturedLogs[1].message, `Circular object: [object Object]`); + expect(capturedLogs[1].message).toEqual(`Circular object: [object Object]`); }); diff --git a/client/lib/url_prefix.test.ts b/client/lib/url_prefix.test.ts index 373be168..9110b5ca 100644 --- a/client/lib/url_prefix.test.ts +++ b/client/lib/url_prefix.test.ts @@ -1,204 +1,148 @@ -import { assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { applyUrlPrefix, removeUrlPrefix } from "./url_prefix.ts"; -Deno.test("url_prefix - removeUrlPrefix - with value", async (t) => { - await t.step("Absolute URL, present, should be removed", () => { - assertEquals( - removeUrlPrefix("http://myserver/sb/relevant", "/sb"), - "http://myserver/relevant", - ); - assertEquals( - removeUrlPrefix("https://myserver/sb/relevant", "/sb"), - "https://myserver/relevant", - ); - }); +test("url_prefix - removeUrlPrefix - with value", async () => { + // Absolute URL, present, should be removed + expect( + removeUrlPrefix("http://myserver/sb/relevant", "/sb"), + ).toEqual("http://myserver/relevant"); + expect( + removeUrlPrefix("https://myserver/sb/relevant", "/sb"), + ).toEqual("https://myserver/relevant"); - await t.step("Absolute URL, present, should only remove leading", () => { - assertEquals( - removeUrlPrefix("http://myserver/sb/sb/relevant/sb", "/sb"), - "http://myserver/sb/relevant/sb", - ); - assertEquals( - removeUrlPrefix("http://myserver/relevant/sb", "/sb"), - "http://myserver/relevant/sb", - ); - }); + // Absolute URL, present, should only remove leading + expect( + removeUrlPrefix("http://myserver/sb/sb/relevant/sb", "/sb"), + ).toEqual("http://myserver/sb/relevant/sb"); + expect( + removeUrlPrefix("http://myserver/relevant/sb", "/sb"), + ).toEqual("http://myserver/relevant/sb"); - await t.step("Absolute URL, absent, should be untouched", () => { - assertEquals( - removeUrlPrefix("http://myserver/other/relevant", "/sb"), - "http://myserver/other/relevant", - ); - assertEquals( - removeUrlPrefix("https://myserver/other/relevant", "/sb"), - "https://myserver/other/relevant", - ); - }); + // Absolute URL, absent, should be untouched + expect( + removeUrlPrefix("http://myserver/other/relevant", "/sb"), + ).toEqual("http://myserver/other/relevant"); + expect( + removeUrlPrefix("https://myserver/other/relevant", "/sb"), + ).toEqual("https://myserver/other/relevant"); - await t.step("Absolute URL, queryString, should be preserved", () => { - assertEquals( - removeUrlPrefix("http://myserver/sb/sb/relevant/sb?param=arg", "/sb"), - "http://myserver/sb/relevant/sb?param=arg", - ); - }); + // Absolute URL, queryString, should be preserved + expect( + removeUrlPrefix("http://myserver/sb/sb/relevant/sb?param=arg", "/sb"), + ).toEqual("http://myserver/sb/relevant/sb?param=arg"); - await t.step("Absolute URL, unsupported, should be untouched", () => { - assertEquals( - removeUrlPrefix("ftp://myserver/sb/relevant", "/sb"), - "ftp://myserver/sb/relevant", - ); - }); + // Absolute URL, unsupported, should be untouched + expect( + removeUrlPrefix("ftp://myserver/sb/relevant", "/sb"), + ).toEqual("ftp://myserver/sb/relevant"); - await t.step("Host-Relative URL, present, should be removed", () => { - assertEquals(removeUrlPrefix("/sb/relevant", "/sb"), "/relevant"); - }); + // Host-Relative URL, present, should be removed + expect(removeUrlPrefix("/sb/relevant", "/sb")).toEqual("/relevant"); - await t.step("Host-Relative URL, present, should only remove leading", () => { - assertEquals( - removeUrlPrefix("/sb/sb/relevant/sb", "/sb"), - "/sb/relevant/sb", - ); - assertEquals(removeUrlPrefix("/relevant/sb", "/sb"), "/relevant/sb"); - }); + // Host-Relative URL, present, should only remove leading + expect( + removeUrlPrefix("/sb/sb/relevant/sb", "/sb"), + ).toEqual("/sb/relevant/sb"); + expect(removeUrlPrefix("/relevant/sb", "/sb")).toEqual("/relevant/sb"); - await t.step("Host-Relative URL, queryString, should be preserved", () => { - assertEquals( - removeUrlPrefix("/sb/sb/relevant/sb?param=arg", "/sb"), - "/sb/relevant/sb?param=arg", - ); - assertEquals( - removeUrlPrefix("/relevant/sb?param=arg", "/sb"), - "/relevant/sb?param=arg", - ); - }); + // Host-Relative URL, queryString, should be preserved + expect( + removeUrlPrefix("/sb/sb/relevant/sb?param=arg", "/sb"), + ).toEqual("/sb/relevant/sb?param=arg"); + expect( + removeUrlPrefix("/relevant/sb?param=arg", "/sb"), + ).toEqual("/relevant/sb?param=arg"); - await t.step("Host-Relative URL, absent, should be untouched", () => { - assertEquals(removeUrlPrefix("/other/relevant", "/sb"), "/other/relevant"); - }); + // Host-Relative URL, absent, should be untouched + expect(removeUrlPrefix("/other/relevant", "/sb")).toEqual("/other/relevant"); - await t.step("Page-Relative URL, should be untouched", () => { - assertEquals(removeUrlPrefix("sb/relevant", "/sb"), "sb/relevant"); - }); + // Page-Relative URL, should be untouched + expect(removeUrlPrefix("sb/relevant", "/sb")).toEqual("sb/relevant"); }); -Deno.test("url_prefix - removeUrlPrefix - no value", async (t) => { - await t.step("Absolute URL, should be untouched", () => { - assertEquals( - removeUrlPrefix("http://myserver/sb/relevant", ""), - "http://myserver/sb/relevant", - ); - assertEquals( - removeUrlPrefix("https://myserver/sb/relevant"), - "https://myserver/sb/relevant", - ); - }); +test("url_prefix - removeUrlPrefix - no value", async () => { + // Absolute URL, should be untouched + expect( + removeUrlPrefix("http://myserver/sb/relevant", ""), + ).toEqual("http://myserver/sb/relevant"); + expect( + removeUrlPrefix("https://myserver/sb/relevant"), + ).toEqual("https://myserver/sb/relevant"); - await t.step("Host-Relative URL, should be untouched", () => { - assertEquals(removeUrlPrefix("/sb/relevant", ""), "/sb/relevant"); - assertEquals(removeUrlPrefix("/sb/relevant"), "/sb/relevant"); - }); + // Host-Relative URL, should be untouched + expect(removeUrlPrefix("/sb/relevant", "")).toEqual("/sb/relevant"); + expect(removeUrlPrefix("/sb/relevant")).toEqual("/sb/relevant"); - await t.step("Page-Relative URL, should be untouched", () => { - assertEquals(removeUrlPrefix("sb/relevant", ""), "sb/relevant"); - assertEquals(removeUrlPrefix("sb/relevant"), "sb/relevant"); - }); + // Page-Relative URL, should be untouched + expect(removeUrlPrefix("sb/relevant", "")).toEqual("sb/relevant"); + expect(removeUrlPrefix("sb/relevant")).toEqual("sb/relevant"); }); -Deno.test("url_prefix - applyUrlPrefix - with value", async (t) => { - await t.step("string, Absolute URL, should be prefixed", () => { - assertEquals( - applyUrlPrefix("http://myserver/relevant", "/sb"), - "http://myserver/sb/relevant", - ); - assertEquals( - applyUrlPrefix("https://myserver/relevant", "/sb"), - "https://myserver/sb/relevant", - ); - }); +test("url_prefix - applyUrlPrefix - with value", async () => { + // string, Absolute URL, should be prefixed + expect( + applyUrlPrefix("http://myserver/relevant", "/sb"), + ).toEqual("http://myserver/sb/relevant"); + expect( + applyUrlPrefix("https://myserver/relevant", "/sb"), + ).toEqual("https://myserver/sb/relevant"); - await t.step("string, Absolute URL, should not care about dups", () => { - assertEquals( - applyUrlPrefix("http://myserver/sb/relevant/sb", "/sb"), - "http://myserver/sb/sb/relevant/sb", - ); - }); + // string, Absolute URL, should not care about dups + expect( + applyUrlPrefix("http://myserver/sb/relevant/sb", "/sb"), + ).toEqual("http://myserver/sb/sb/relevant/sb"); - await t.step("string, Absolute URL, queryString should be preserved", () => { - assertEquals( - applyUrlPrefix("http://myserver/sb/relevant/sb?param=arg", "/sb"), - "http://myserver/sb/sb/relevant/sb?param=arg", - ); - }); + // string, Absolute URL, queryString should be preserved + expect( + applyUrlPrefix("http://myserver/sb/relevant/sb?param=arg", "/sb"), + ).toEqual("http://myserver/sb/sb/relevant/sb?param=arg"); - await t.step("string, Absolute URL, unsupported, should be untouched", () => { - assertEquals( - applyUrlPrefix("ftp://myserver/relevant", "/sb"), - "ftp://myserver/relevant", - ); - }); + // string, Absolute URL, unsupported, should be untouched + expect( + applyUrlPrefix("ftp://myserver/relevant", "/sb"), + ).toEqual("ftp://myserver/relevant"); - await t.step("string, Host-Relative URL, should be prefixed", () => { - assertEquals(applyUrlPrefix("/relevant", "/sb"), "/sb/relevant"); - }); + // string, Host-Relative URL, should be prefixed + expect(applyUrlPrefix("/relevant", "/sb")).toEqual("/sb/relevant"); - await t.step("string, Host-Relative URL, should not care about dups", () => { - assertEquals( - applyUrlPrefix("/sb/relevant/sb", "/sb"), - "/sb/sb/relevant/sb", - ); - }); + // string, Host-Relative URL, should not care about dups + expect( + applyUrlPrefix("/sb/relevant/sb", "/sb"), + ).toEqual("/sb/sb/relevant/sb"); - await t.step( - "string, Host-Relative URL, queryString should be preserved", - () => { - assertEquals( - applyUrlPrefix("/sb/relevant/sb?param=arg", "/sb"), - "/sb/sb/relevant/sb?param=arg", - ); - }, - ); + // string, Host-Relative URL, queryString should be preserved + expect( + applyUrlPrefix("/sb/relevant/sb?param=arg", "/sb"), + ).toEqual("/sb/sb/relevant/sb?param=arg"); - await t.step("string, Page-Relative URL, should be untouched", () => { - assertEquals(applyUrlPrefix("relevant", "/sb"), "relevant"); - }); + // string, Page-Relative URL, should be untouched + expect(applyUrlPrefix("relevant", "/sb")).toEqual("relevant"); - await t.step("URL object, Absolute URL, should be prefixed", () => { - assertEquals( - applyUrlPrefix(new URL("http://myserver/relevant"), "/sb"), - new URL("http://myserver/sb/relevant"), - ); - }); + // URL object, Absolute URL, should be prefixed + expect( + applyUrlPrefix(new URL("http://myserver/relevant"), "/sb"), + ).toEqual(new URL("http://myserver/sb/relevant")); - await t.step( - "URL object, Absolute URL, queryString should be preserved", - () => { - assertEquals( - applyUrlPrefix(new URL("http://myserver/relevant?param=arg"), "/sb"), - new URL("http://myserver/sb/relevant?param=arg"), - ); - }, - ); + // URL object, Absolute URL, queryString should be preserved + expect( + applyUrlPrefix(new URL("http://myserver/relevant?param=arg"), "/sb"), + ).toEqual(new URL("http://myserver/sb/relevant?param=arg")); }); -Deno.test("url_prefix - applyUrlPrefix - no value", async (t) => { - await t.step("Absolute URL, should be untouched", () => { - assertEquals( - applyUrlPrefix("http://myserver/relevant", ""), - "http://myserver/relevant", - ); - assertEquals( - applyUrlPrefix("https://myserver/relevant"), - "https://myserver/relevant", - ); - }); +test("url_prefix - applyUrlPrefix - no value", async () => { + // Absolute URL, should be untouched + expect( + applyUrlPrefix("http://myserver/relevant", ""), + ).toEqual("http://myserver/relevant"); + expect( + applyUrlPrefix("https://myserver/relevant"), + ).toEqual("https://myserver/relevant"); - await t.step("Host-Relative URL, should be untouched", () => { - assertEquals(applyUrlPrefix("/relevant", ""), "/relevant"); - assertEquals(applyUrlPrefix("/relevant"), "/relevant"); - }); + // Host-Relative URL, should be untouched + expect(applyUrlPrefix("/relevant", "")).toEqual("/relevant"); + expect(applyUrlPrefix("/relevant")).toEqual("/relevant"); - await t.step("Page-Relative URL, should be untouched", () => { - assertEquals(applyUrlPrefix("relevant", ""), "relevant"); - assertEquals(applyUrlPrefix("relevant"), "relevant"); - }); + // Page-Relative URL, should be untouched + expect(applyUrlPrefix("relevant", "")).toEqual("relevant"); + expect(applyUrlPrefix("relevant")).toEqual("relevant"); }); diff --git a/client/markdown_parser/parser.test.ts b/client/markdown_parser/parser.test.ts index 17a2b582..568e4524 100644 --- a/client/markdown_parser/parser.test.ts +++ b/client/markdown_parser/parser.test.ts @@ -1,9 +1,9 @@ +import { expect, test } from "vitest"; import { collectNodesOfType, findNodeOfType, renderToText, } from "@silverbulletmd/silverbullet/lib/tree"; -import { assertEquals, assertNotEquals } from "@std/assert"; import { parseMarkdown } from "./parser.ts"; import { extractHashtag } from "../../plug-api/lib/tags.ts"; import { renderHashtag } from "../../plugs/index/tags.ts"; @@ -26,34 +26,34 @@ name: Zef Supper`; -Deno.test("Test parser", () => { +test("Test parser", () => { let tree = parseMarkdown(sample1); // console.log("tree", JSON.stringify(tree, null, 2)); // Check if rendering back to text works - assertEquals(renderToText(tree), sample1); + expect(renderToText(tree)).toEqual(sample1); const tree2 = parseMarkdown(sample1, 3); // console.log("tree", JSON.stringify(tree, null, 2)); // Check if rendering back to text works - assertEquals(renderToText(tree2), sample1); + expect(renderToText(tree2)).toEqual(sample1); // Find wiki link and wiki link alias const links = collectNodesOfType(tree, "WikiLink"); - assertEquals(links.length, 2); + expect(links.length).toEqual(2); const nameNode = findNodeOfType(links[0], "WikiLinkPage"); - assertEquals(nameNode!.children![0].text, "wiki link"); + expect(nameNode!.children![0].text).toEqual("wiki link"); // Check if alias is parsed properly const aliasNode = findNodeOfType(links[1], "WikiLinkAlias"); - assertEquals(aliasNode!.children![0].text, "alias"); + expect(aliasNode!.children![0].text).toEqual("alias"); // Find frontmatter let node = findNodeOfType(tree, "FrontMatter"); - assertNotEquals(node, undefined); + expect(node).not.toEqual(undefined); tree = parseMarkdown(sampleInvalid1); node = findNodeOfType(tree, "FrontMatter"); // console.log("Invalid node", node); - assertEquals(node, undefined); + expect(node).toEqual(undefined); }); const inlineAttributeSample = ` @@ -66,24 +66,24 @@ Here's a more [ambiguous: case](http://zef.plus) And one with nested brackets: [array: [1, 2, 3]] `; -Deno.test("Test inline attribute syntax", () => { +test("Test inline attribute syntax", () => { const tree = parseMarkdown(inlineAttributeSample); // console.log("Attribute parsed", JSON.stringify(tree, null, 2)); const attributes = collectNodesOfType(tree, "Attribute"); let nameNode = findNodeOfType(attributes[0], "AttributeName"); - assertEquals(nameNode!.children![0].text, "age"); + expect(nameNode!.children![0].text).toEqual("age"); let valueNode = findNodeOfType(attributes[0], "AttributeValue"); - assertEquals(valueNode!.children![0].text, "100"); + expect(valueNode!.children![0].text).toEqual("100"); nameNode = findNodeOfType(attributes[1], "AttributeName"); - assertEquals(nameNode!.children![0].text, "age"); + expect(nameNode!.children![0].text).toEqual("age"); valueNode = findNodeOfType(attributes[1], "AttributeValue"); - assertEquals(valueNode!.children![0].text, "200"); + expect(valueNode!.children![0].text).toEqual("200"); nameNode = findNodeOfType(attributes[2], "AttributeName"); - assertEquals(nameNode!.children![0].text, "array"); + expect(nameNode!.children![0].text).toEqual("array"); valueNode = findNodeOfType(attributes[2], "AttributeValue"); - assertEquals(valueNode!.children![0].text, "[1, 2, 3]"); + expect(valueNode!.children![0].text).toEqual("[1, 2, 3]"); }); const multiStatusTaskExample = ` @@ -92,18 +92,18 @@ const multiStatusTaskExample = ` * [TODO] Task 3 `; -Deno.test("Test multi-status tasks", () => { +test("Test multi-status tasks", () => { const tree = parseMarkdown(multiStatusTaskExample); // console.log("Tasks parsed", JSON.stringify(tree, null, 2)); const tasks = collectNodesOfType(tree, "Task"); - assertEquals(tasks.length, 3); + expect(tasks.length).toEqual(3); // Check " " checkbox state parsing - assertEquals(tasks[0].children![0].children![1].text, " "); - assertEquals(tasks[1].children![0].children![1].text, "x"); - assertEquals(tasks[2].children![0].children![1].text, "TODO"); + expect(tasks[0].children![0].children![1].text).toEqual(" "); + expect(tasks[1].children![0].children![1].text).toEqual("x"); + expect(tasks[2].children![0].children![1].text).toEqual("TODO"); }); -Deno.test("Test lua directive parser", () => { +test("Test lua directive parser", () => { const simpleExample = `Simple \${query_coll("something")}`; console.log(JSON.stringify(parseMarkdown(simpleExample), null, 2)); }); @@ -122,43 +122,41 @@ But magazine issue #1 or #123 are not hashtags. Should support other languages, like #żółć or #井号 `; -Deno.test("Test hashtag parser", () => { +test("Test hashtag parser", () => { const tree = parseMarkdown(hashtagSample); const hashtags = collectNodesOfType(tree, "Hashtag"); - assertEquals(hashtags.length, 14); + expect(hashtags.length).toEqual(14); - assertEquals(hashtags[0].children![0].text, "#mytag"); - assertEquals(hashtags[1].children![0].text, "#level/beginner"); - assertEquals(hashtags[2].children![0].text, "#Mike's-idea"); - assertEquals(hashtags[3].children![0].text, "#a"); - assertEquals(hashtags[4].children![0].text, "#interpunction"); - assertEquals(hashtags[5].children![0].text, "#exclamation"); - assertEquals(hashtags[6].children![0].text, "#question"); - assertEquals(hashtags[7].children![0].text, "#"); + expect(hashtags[0].children![0].text).toEqual("#mytag"); + expect(hashtags[1].children![0].text).toEqual("#level/beginner"); + expect(hashtags[2].children![0].text).toEqual("#Mike's-idea"); + expect(hashtags[3].children![0].text).toEqual("#a"); + expect(hashtags[4].children![0].text).toEqual("#interpunction"); + expect(hashtags[5].children![0].text).toEqual("#exclamation"); + expect(hashtags[6].children![0].text).toEqual("#question"); + expect(hashtags[7].children![0].text).toEqual("#"); // multiple lines not allowed - assertEquals(hashtags[8].children![0].text, "#no"); - assertEquals(hashtags[9].children![0].text, "#spacing"); - assertEquals(hashtags[10].children![0].text, "#3dprint"); - assertEquals(hashtags[11].children![0].text, "#15-52_Trip-to-NYC"); - assertEquals(hashtags[12].children![0].text, "#żółć"); - assertEquals(hashtags[13].children![0].text, "#井号"); + expect(hashtags[8].children![0].text).toEqual("#no"); + expect(hashtags[9].children![0].text).toEqual("#spacing"); + expect(hashtags[10].children![0].text).toEqual("#3dprint"); + expect(hashtags[11].children![0].text).toEqual("#15-52_Trip-to-NYC"); + expect(hashtags[12].children![0].text).toEqual("#żółć"); + expect(hashtags[13].children![0].text).toEqual("#井号"); }); -Deno.test("Test hashtag helper functions", () => { - assertEquals(extractHashtag("#name"), "name"); - assertEquals(extractHashtag("#123-content"), "123-content"); - assertEquals(extractHashtag("#"), "escaped tag"); - assertEquals( - extractHashtag("#"), - "allow < and # inside", +test("Test hashtag helper functions", () => { + expect(extractHashtag("#name")).toEqual("name"); + expect(extractHashtag("#123-content")).toEqual("123-content"); + expect(extractHashtag("#")).toEqual("escaped tag"); + expect(extractHashtag("#")).toEqual("allow < and # inside", ); - assertEquals(renderHashtag("simple"), "#simple"); - assertEquals(renderHashtag("123-content"), "#123-content"); - assertEquals(renderHashtag("with spaces"), "#"); - assertEquals(renderHashtag("single'quote"), "#single'quote"); + expect(renderHashtag("simple")).toEqual("#simple"); + expect(renderHashtag("123-content")).toEqual("#123-content"); + expect(renderHashtag("with spaces")).toEqual("#"); + expect(renderHashtag("single'quote")).toEqual("#single'quote"); // should behave like this for all characters in tagRegex - assertEquals(renderHashtag("exclamation!"), "#"); + expect(renderHashtag("exclamation!")).toEqual("#"); }); const nakedURLSample = ` @@ -170,11 +168,11 @@ http://abc.com?e=2.71,pi=3.14 is a URL too. http://abc.com?e=2.71. That is a URL, which ends with 1 (and not '.'). `; -Deno.test("Test NakedURL parser", () => { +test("Test NakedURL parser", () => { const tree = parseMarkdown(nakedURLSample); const urls = collectNodesOfType(tree, "NakedURL"); - assertEquals(urls.map((x) => x.children![0].text), [ + expect(urls.map((x) => x.children![0].text)).toEqual([ "http://abc.com", "http://no-trailing-period.com", "http://no-trailing-comma.com", @@ -191,11 +189,11 @@ const tableSample = ` | 2A | 2B | `; -Deno.test("Test table parser", () => { +test("Test table parser", () => { const tree = parseMarkdown(tableSample); const cells = collectNodesOfType(tree, "TableCell"); - assertEquals(cells.map((x) => x.children![0].text), [ + expect(cells.map((x) => x.children![0].text)).toEqual([ "Header A", "Header B", undefined, @@ -205,9 +203,9 @@ Deno.test("Test table parser", () => { ]); // Check the Wiki Link - Make sure no backslash has been added (issue 943) - assertEquals(cells[2].children![0].type, "WikiLink"); + expect(cells[2].children![0].type).toEqual("WikiLink"); const wikiName = findNodeOfType(cells[2], "WikiLinkPage"); const wikiAlias = findNodeOfType(cells[2], "WikiLinkAlias"); - assertEquals(wikiName!.children![0].text, "Wiki"); - assertEquals(wikiAlias!.children![0].text, "Alias"); + expect(wikiName!.children![0].text).toEqual("Wiki"); + expect(wikiAlias!.children![0].text).toEqual("Alias"); }); diff --git a/client/markdown_renderer/html_render.test.ts b/client/markdown_renderer/html_render.test.ts index b624b0bc..a254ec7b 100644 --- a/client/markdown_renderer/html_render.test.ts +++ b/client/markdown_renderer/html_render.test.ts @@ -1,29 +1,20 @@ -import { assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { renderHtml } from "./html_render.ts"; -Deno.test("HTML Render", () => { - assertEquals( - renderHtml({ - name: "b", - body: "hello", - }), - `hello`, - ); - assertEquals( - renderHtml({ - name: "a", - attrs: { - href: "https://example.com", - }, - body: "hello", - }), - `hello`, - ); - assertEquals( - renderHtml({ - name: "span", - body: "<>", - }), - `<>`, - ); +test("HTML Render", () => { + expect(renderHtml({ + name: "b", + body: "hello", + })).toEqual(`hello`); + expect(renderHtml({ + name: "a", + attrs: { + href: "https://example.com", + }, + body: "hello", + })).toEqual(`hello`); + expect(renderHtml({ + name: "span", + body: "<>", + })).toEqual(`<>`); }); diff --git a/client/markdown_renderer/inline.ts b/client/markdown_renderer/inline.ts index ea6c6e64..b3e22771 100644 --- a/client/markdown_renderer/inline.ts +++ b/client/markdown_renderer/inline.ts @@ -11,7 +11,7 @@ import { parseToRef, } from "@silverbulletmd/silverbullet/lib/ref"; import { isLocalURL } from "@silverbulletmd/silverbullet/lib/resolve"; -import { mime } from "mimetypes"; +import mime from "mime"; import { LuaStackFrame, LuaTable } from "../space_lua/runtime.ts"; import { parseMarkdown } from "../markdown_parser/parser.ts"; import { renderExpressionResult } from "./result_render.ts"; diff --git a/client/markdown_renderer/markdown_render.test.ts b/client/markdown_renderer/markdown_render.test.ts index 4b4118be..f4005a55 100644 --- a/client/markdown_renderer/markdown_render.test.ts +++ b/client/markdown_renderer/markdown_render.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import { parse } from "../markdown_parser/parse_tree.ts"; import { renderMarkdownToHtml } from "./markdown_render.ts"; import { extendedMarkdownLanguage } from "../markdown_parser/parser.ts"; -import { assertEquals } from "@std/assert"; const sampleMarkdown = `--- name: Sup @@ -67,14 +67,14 @@ Here is something A new thing. `; -Deno.test("Markdown render", () => { +test("Markdown render", () => { const tree = parse(extendedMarkdownLanguage, sampleMarkdown); renderMarkdownToHtml(tree, { failOnUnknown: true, }); }); -Deno.test("Smart hard break test", () => { +test("Smart hard break test", () => { const example = `**Hello** *world!*`; const tree = parse(extendedMarkdownLanguage, example); @@ -82,9 +82,7 @@ Deno.test("Smart hard break test", () => { failOnUnknown: true, smartHardBreak: true, }); - assertEquals( - html, - `Hello
world!
`, + expect(html).toEqual(`Hello
world!
`, ); const example2 = `This is going to be a text. With a new line. diff --git a/client/plugos/event.test.ts b/client/plugos/event.test.ts index 83de21a0..c5c96471 100644 --- a/client/plugos/event.test.ts +++ b/client/plugos/event.test.ts @@ -1,4 +1,4 @@ -import { assert, assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { EventEmitter } from "./event.ts"; // Test event handler interfaces @@ -16,7 +16,7 @@ class TestEventEmitter extends EventEmitter { // Just a concrete implementation for testing } -Deno.test("EventEmitter - basic on/emit functionality", async () => { +test("EventEmitter - basic on/emit functionality", async () => { const emitter = new TestEventEmitter(); let received = ""; let count = 0; @@ -31,13 +31,13 @@ Deno.test("EventEmitter - basic on/emit functionality", async () => { }); await emitter.emit("message", "hello world"); - assertEquals(received, "hello world"); + expect(received).toEqual("hello world"); await emitter.emit("count", 42); - assertEquals(count, 42); + expect(count).toEqual(42); }); -Deno.test("EventEmitter - multiple handlers for same event", async () => { +test("EventEmitter - multiple handlers for same event", async () => { const emitter = new TestEventEmitter(); const results: string[] = []; @@ -55,12 +55,12 @@ Deno.test("EventEmitter - multiple handlers for same event", async () => { await emitter.emit("message", "test"); - assertEquals(results.length, 2); - assertEquals(results[0], "handler1: test"); - assertEquals(results[1], "handler2: test"); + expect(results.length).toEqual(2); + expect(results[0]).toEqual("handler1: test"); + expect(results[1]).toEqual("handler2: test"); }); -Deno.test("EventEmitter - multiple events in single handler", async () => { +test("EventEmitter - multiple events in single handler", async () => { const emitter = new TestEventEmitter(); let messageReceived = ""; let countReceived = 0; @@ -77,11 +77,11 @@ Deno.test("EventEmitter - multiple events in single handler", async () => { await emitter.emit("message", "multi-handler"); await emitter.emit("count", 123); - assertEquals(messageReceived, "multi-handler"); - assertEquals(countReceived, 123); + expect(messageReceived).toEqual("multi-handler"); + expect(countReceived).toEqual(123); }); -Deno.test("EventEmitter - emit with multiple arguments", async () => { +test("EventEmitter - emit with multiple arguments", async () => { const emitter = new TestEventEmitter(); let receivedA = ""; let receivedB = 0; @@ -97,12 +97,12 @@ Deno.test("EventEmitter - emit with multiple arguments", async () => { await emitter.emit("multi", "test", 456, true); - assertEquals(receivedA, "test"); - assertEquals(receivedB, 456); - assertEquals(receivedC, true); + expect(receivedA).toEqual("test"); + expect(receivedB).toEqual(456); + expect(receivedC).toEqual(true); }); -Deno.test("EventEmitter - off removes specific handler object with multiple events", async () => { +test("EventEmitter - off removes specific handler object with multiple events", async () => { const emitter = new TestEventEmitter(); let messageCount = 0; let numberCount = 0; @@ -131,9 +131,9 @@ Deno.test("EventEmitter - off removes specific handler object with multiple even // Test that both handlers work initially await emitter.emit("message", "test1"); await emitter.emit("count", 42); - assertEquals(messageCount, 1); - assertEquals(numberCount, 1); - assertEquals(remainingMessageCount, 1); + expect(messageCount).toEqual(1); + expect(numberCount).toEqual(1); + expect(remainingMessageCount).toEqual(1); // Remove the first handler object emitter.off(handlersToRemove); @@ -141,12 +141,12 @@ Deno.test("EventEmitter - off removes specific handler object with multiple even // Test that only the remaining message handler works await emitter.emit("message", "test2"); await emitter.emit("count", 43); - assertEquals(messageCount, 1); // Should not have incremented - assertEquals(numberCount, 1); // Should not have incremented - assertEquals(remainingMessageCount, 2); // Should have incremented + expect(messageCount).toEqual(1); // Should not have incremented + expect(numberCount).toEqual(1); // Should not have incremented + expect(remainingMessageCount).toEqual(2); // Should have incremented }); -Deno.test("EventEmitter - off removes only the specified handler object", async () => { +test("EventEmitter - off removes only the specified handler object", async () => { const emitter = new TestEventEmitter(); let handler1MessageCount = 0; let handler1CountValue = 0; @@ -177,10 +177,10 @@ Deno.test("EventEmitter - off removes only the specified handler object", async // Test both handlers work initially await emitter.emit("message", "test1"); await emitter.emit("count", 100); - assertEquals(handler1MessageCount, 1); - assertEquals(handler1CountValue, 100); - assertEquals(handler2MessageCount, 1); - assertEquals(handler2CountValue, 100); + expect(handler1MessageCount).toEqual(1); + expect(handler1CountValue).toEqual(100); + expect(handler2MessageCount).toEqual(1); + expect(handler2CountValue).toEqual(100); // Remove only handlers1 emitter.off(handlers1); @@ -188,13 +188,13 @@ Deno.test("EventEmitter - off removes only the specified handler object", async // Test that only handlers2 continues to work await emitter.emit("message", "test2"); await emitter.emit("count", 200); - assertEquals(handler1MessageCount, 1); // Should not have incremented - assertEquals(handler1CountValue, 100); // Should not have changed - assertEquals(handler2MessageCount, 2); // Should have incremented - assertEquals(handler2CountValue, 200); // Should have changed + expect(handler1MessageCount).toEqual(1); // Should not have incremented + expect(handler1CountValue).toEqual(100); // Should not have changed + expect(handler2MessageCount).toEqual(2); // Should have incremented + expect(handler2CountValue).toEqual(200); // Should have changed }); -Deno.test("EventEmitter - no handlers for event", async () => { +test("EventEmitter - no handlers for event", async () => { const emitter = new TestEventEmitter(); // Should not throw when emitting to non-existent handlers @@ -202,5 +202,5 @@ Deno.test("EventEmitter - no handlers for event", async () => { await emitter.emit("count", 42); // Test passes if no exception is thrown - assert(true); + expect(true).toBeTruthy(); }); diff --git a/client/plugos/plug_compile.ts b/client/plugos/plug_compile.ts index 58aa1e9d..658ec6f4 100644 --- a/client/plugos/plug_compile.ts +++ b/client/plugos/plug_compile.ts @@ -1,16 +1,29 @@ -import * as path from "@std/path"; -import * as YAML from "@std/yaml"; -import { denoPlugin, esbuild } from "../../build_deps.ts"; +import * as path from "node:path"; +import { readFile, writeFile, mkdtemp, rm, mkdir } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import * as YAML from "js-yaml"; + +import * as esbuild from "esbuild"; import { bundleAssets } from "../asset_bundle/builder.ts"; import type { Manifest } from "./types.ts"; import { version } from "../../version.ts"; -// const workerRuntimeUrl = new URL( -// "../lib/plugos/worker_runtime.ts", -// import.meta.url, -// ); -const workerRuntimeUrl = - `https://deno.land/x/silverbullet@${version}/client/plugos/worker_runtime.ts`; +import { fileURLToPath } from "node:url"; +import { readFileSync, existsSync } from "node:fs"; +import { dirname } from "node:path"; + +// Read the pre-built worker_runtime bundle +// When running from source: ../../dist/worker_runtime_bundle.js (from client/plugos/) +// When bundled: ./worker_runtime_bundle.js (from dist/) +const currentDir = dirname(fileURLToPath(import.meta.url)); +const bundledPath = path.join(currentDir, "worker_runtime_bundle.js"); +const sourcePath = path.join(currentDir, "../../dist/worker_runtime_bundle.js"); + +const workerRuntimeBundlePath = existsSync(bundledPath) ? bundledPath : sourcePath; +const workerRuntimeBundle = readFileSync(workerRuntimeBundlePath, "utf-8"); + +// Create a data URL so esbuild can inline it +const workerRuntimeUrl = `data:text/javascript;charset=utf-8,${encodeURIComponent(workerRuntimeBundle)}`; export type CompileOptions = { debug?: boolean; @@ -27,9 +40,8 @@ export async function compileManifest( options: CompileOptions = {}, ): Promise { const rootPath = path.dirname(manifestPath); - const manifest = YAML.parse( - await Deno.readTextFile(manifestPath), - ) as Manifest; + const manifestContent = await readFile(manifestPath, "utf-8"); + const manifest = YAML.load(manifestContent) as Manifest; if (!manifest.name) { throw new Error(`Missing 'name' in ${manifestPath}`); @@ -93,9 +105,10 @@ setupMessageListener(functionMapping, manifest, self.postMessage); // console.log("Code:", jsFile); - const inFile = await Deno.makeTempFile({ suffix: ".js" }); + const tempDir = await mkdtemp(path.join(tmpdir(), "plug-compile-")); + const inFile = path.join(tempDir, "input.js"); const outFile = `${destPath}/${manifest.name}.plug.js`; - await Deno.writeTextFile(inFile, jsFile); + await writeFile(inFile, jsFile, "utf-8"); const result = await esbuild.build({ entryPoints: [inFile], @@ -109,10 +122,16 @@ setupMessageListener(functionMapping, manifest, self.postMessage); metafile: options.info, treeShaking: true, plugins: [ - denoPlugin({ - configPath: options.configPath && - path.resolve(Deno.cwd(), options.configPath), - }), + // Simple plugin to handle file:// URLs + { + name: "file-url-resolver", + setup(build: esbuild.PluginBuild) { + build.onResolve({ filter: /^file:\/\// }, (args: esbuild.OnResolveArgs) => { + const filePath = args.path.replace(/^file:\/\//, ""); + return { path: filePath }; + }); + }, + }, ], }); @@ -121,9 +140,13 @@ setupMessageListener(functionMapping, manifest, self.postMessage); console.log("Bundle info for", manifestPath, text); } - let jsCode = await Deno.readTextFile(outFile); + let jsCode = await readFile(outFile, "utf-8"); jsCode = patchDenoLibJS(jsCode); - await Deno.writeTextFile(outFile, jsCode); + await writeFile(outFile, jsCode, "utf-8"); + + // Clean up temp directory + await rm(tempDir, { recursive: true, force: true }); + console.log(`Plug ${manifest.name} written to ${outFile}.`); return outFile; } @@ -142,7 +165,7 @@ export async function compileManifests( } console.log("Building", manifestFiles); building = true; - Deno.mkdirSync(dist, { recursive: true }); + await mkdir(dist, { recursive: true }); const startTime = Date.now(); // Build all plugs in parallel await Promise.all(manifestFiles.map(async (plugManifestPath) => { @@ -191,5 +214,5 @@ export async function plugCompileCommand( }, ); esbuild.stop(); - Deno.exit(0); + process.exit(0); } diff --git a/client/plugos/worker_runtime.ts b/client/plugos/worker_runtime.ts index 30ddaac2..7d003a08 100644 --- a/client/plugos/worker_runtime.ts +++ b/client/plugos/worker_runtime.ts @@ -27,6 +27,7 @@ const runningAsWebWorker = typeof window === "undefined" && // @ts-ignore: globalThis typeof globalThis.WebSocketPair === "undefined"; +// @ts-ignore: Check if Deno is defined if (typeof Deno === "undefined") { // @ts-ignore: Deno hack self.Deno = { diff --git a/client/service_registry.test.ts b/client/service_registry.test.ts index 0ab4b7ea..d9157224 100644 --- a/client/service_registry.test.ts +++ b/client/service_registry.test.ts @@ -1,11 +1,11 @@ +import { expect, test } from "vitest"; import type { EventHookT } from "@silverbulletmd/silverbullet/type/manifest"; import { EventHook } from "./plugos/hooks/event.ts"; import { System } from "./plugos/system.ts"; import { ServiceRegistry } from "./service_registry.ts"; -import { assertEquals } from "@std/assert"; import { Config } from "./config.ts"; -Deno.test("Test services", async () => { +test("Test services", async () => { const system = new System(); const config = new Config(); const eventHook = new EventHook(config); @@ -56,23 +56,17 @@ Deno.test("Test services", async () => { }); const matches = await registry.discover("greeter", {}); - assertEquals(matches.length, 1); - assertEquals(matches[0].priority, 1); + expect(matches.length).toEqual(1); + expect(matches[0].priority).toEqual(1); const matchesMulti = await registry.discover("greeter-multi", {}); - assertEquals(matchesMulti.length, 2); + expect(matchesMulti.length).toEqual(2); // higher prio should come first - assertEquals(matchesMulti[0].priority, 2); - assertEquals(matchesMulti[1].priority, 1); + expect(matchesMulti[0].priority).toEqual(2); + expect(matchesMulti[1].priority).toEqual(1); - assertEquals(await registry.invoke(matches[0], "Pete"), "Hello Pete!"); - assertEquals( - await registry.invokeBestMatch("greeter", "Pete"), - "Hello Pete!", - ); + expect(await registry.invoke(matches[0], "Pete")).toEqual("Hello Pete!"); + expect(await registry.invokeBestMatch("greeter", "Pete")).toEqual("Hello Pete!"); - assertEquals( - await registry.invokeBestMatch("greeter-multi", "Pete"), - "Hello 2 Pete!", - ); + expect(await registry.invokeBestMatch("greeter-multi", "Pete")).toEqual("Hello 2 Pete!"); }); diff --git a/client/service_registry.ts b/client/service_registry.ts index 402e58a0..21a33601 100644 --- a/client/service_registry.ts +++ b/client/service_registry.ts @@ -19,7 +19,7 @@ export class ServiceRegistry { } public define(spec: ServiceSpec): void { - const id = crypto.randomUUID(); + const id = globalThis.crypto.randomUUID(); // Register with discover:* event this.config.insert([ "eventListeners", diff --git a/client/space.test.ts b/client/space.test.ts index 3c2ffe81..671edbf9 100644 --- a/client/space.test.ts +++ b/client/space.test.ts @@ -1,9 +1,9 @@ +import { expect, test } from "vitest"; import { sleep } from "@silverbulletmd/silverbullet/lib/async"; import { MemoryKvPrimitives } from "./data/memory_kv_primitives.ts"; import { EventHook } from "./plugos/hooks/event.ts"; import { Space } from "./space.ts"; import { DataStoreSpacePrimitives } from "./spaces/datastore_space_primitives.ts"; -import { assertEquals } from "@std/assert"; import { parseToRef } from "@silverbulletmd/silverbullet/lib/ref"; const testPage = ` @@ -19,7 +19,7 @@ Some text * Sub-sub item `.trim(); -Deno.test("readRef checks", async () => { +test("readRef checks", async () => { const kv = new MemoryKvPrimitives(); const eventHook = new EventHook(); const space = new Space(new DataStoreSpacePrimitives(kv), eventHook); @@ -27,34 +27,30 @@ Deno.test("readRef checks", async () => { await space.writePage("test", testPage); // Reference to page - assertEquals(await space.readRef(parseToRef("test")!), { + expect(await space.readRef(parseToRef("test")!)).toEqual({ text: testPage, offset: 0, }); // Pointer to a paragraph - assertEquals(await space.readRef(parseToRef("test@0")!), { + expect(await space.readRef(parseToRef("test@0")!)).toEqual({ text: "Some paragraph", offset: 0, }); // With a linecolumn ref - assertEquals(await space.readRef(parseToRef("test@l1c1")!), { + expect(await space.readRef(parseToRef("test@l1c1")!)).toEqual({ text: "Some paragraph", offset: 0, }); // Reference to a header - assertEquals( - await space.readRef(parseToRef("test#Header 1")!), - { + expect(await space.readRef(parseToRef("test#Header 1")!)).toEqual({ text: "# Header 1\nSome text\n\n", offset: testPage.indexOf("# Header 1"), }, ); - assertEquals( - await space.readRef(parseToRef("test#Header 2")!), - { + expect(await space.readRef(parseToRef("test#Header 2")!)).toEqual({ text: "# Header 2\n* Item 1\n * Sub item\n* [ ] Task 1\n * Sub item 2\n * Sub-sub item", offset: testPage.indexOf("# Header 2"), @@ -63,16 +59,12 @@ Deno.test("readRef checks", async () => { // Reference to an item should get item and children const itemPos = testPage.indexOf("* Item 1"); - assertEquals( - await space.readRef(parseToRef(`test@${itemPos}`)!), - { text: "* Item 1\n * Sub item", offset: itemPos }, + expect(await space.readRef(parseToRef(`test@${itemPos}`)!)).toEqual({ text: "* Item 1\n * Sub item", offset: itemPos }, ); // Reference to a task should get item and children const taskPos = testPage.indexOf("* [ ] Task 1"); - assertEquals( - await space.readRef(parseToRef(`test@${taskPos}`)!), - { + expect(await space.readRef(parseToRef(`test@${taskPos}`)!)).toEqual({ text: "* [ ] Task 1\n * Sub item 2\n * Sub-sub item", offset: taskPos, }, @@ -80,8 +72,6 @@ Deno.test("readRef checks", async () => { // Check left shift in case of jumping into nested item const subItemPos = testPage.indexOf("* Sub item 2"); - assertEquals( - await space.readRef(parseToRef(`test@${subItemPos}`)!), - { text: "* Sub item 2\n * Sub-sub item", offset: subItemPos }, + expect(await space.readRef(parseToRef(`test@${subItemPos}`)!)).toEqual({ text: "* Sub item 2\n * Sub-sub item", offset: subItemPos }, ); }); diff --git a/client/space_lua/break_async.test.ts b/client/space_lua/break_async.test.ts index 7d42936c..ce706c88 100644 --- a/client/space_lua/break_async.test.ts +++ b/client/space_lua/break_async.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "@std/assert/equals"; +import { expect, test } from "vitest"; import { parse } from "./parse.ts"; import { evalStatement } from "./eval.ts"; import { LuaEnv, LuaNativeJSFunction, LuaStackFrame } from "./runtime.ts"; @@ -15,7 +15,7 @@ async function evalBlock(code: string, env?: LuaEnv) { return base; } -Deno.test("For loops: inner break", async () => { +test("For loops: inner break", async () => { const env = new LuaEnv(luaBuildStandardEnv()); await evalBlock( ` @@ -30,10 +30,10 @@ Deno.test("For loops: inner break", async () => { `, env, ); - assertEquals(env.get("found"), 1); + expect(env.get("found")).toEqual(1); }); -Deno.test("Nested for loops: inner break (sync body)", async () => { +test("Nested for loops: inner break (sync body)", async () => { const env = new LuaEnv(luaBuildStandardEnv()); await evalBlock( ` @@ -49,10 +49,10 @@ Deno.test("Nested for loops: inner break (sync body)", async () => { `, env, ); - assertEquals(env.get("found"), 2); + expect(env.get("found")).toEqual(2); }); -Deno.test("Nested for loops: inner break with async call in body (Promise path)", async () => { +test("Nested for loops: inner break with async call in body (Promise path)", async () => { const env = new LuaEnv(luaBuildStandardEnv()); env.set( "asyncOne", @@ -73,10 +73,10 @@ Deno.test("Nested for loops: inner break with async call in body (Promise path)" `, env, ); - assertEquals(env.get("found"), 2); + expect(env.get("found")).toEqual(2); }); -Deno.test("While: Promise condition, break inside body", async () => { +test("While: Promise condition, break inside body", async () => { const env = new LuaEnv(luaBuildStandardEnv()); // asyncTrue returns a truthy value via Promise to trigger Promise-based while path env.set( @@ -102,10 +102,10 @@ Deno.test("While: Promise condition, break inside body", async () => { `, env, ); - assertEquals(env.get("cnt"), 1); + expect(env.get("cnt")).toEqual(1); }); -Deno.test("Repeat-until: body goes Promise once, break handled locally", async () => { +test("Repeat-until: body goes Promise once, break handled locally", async () => { const env = new LuaEnv(luaBuildStandardEnv()); env.set( "asyncOne", @@ -123,10 +123,10 @@ Deno.test("Repeat-until: body goes Promise once, break handled locally", async ( `, env, ); - assertEquals(env.get("n"), 1); + expect(env.get("n")).toEqual(1); }); -Deno.test("For-in: custom iterator, Promise in body before break", async () => { +test("For-in: custom iterator, Promise in body before break", async () => { const env = new LuaEnv(luaBuildStandardEnv()); env.set( "asyncOne", @@ -152,10 +152,10 @@ Deno.test("For-in: custom iterator, Promise in body before break", async () => { `, env, ); - assertEquals(env.get("hits"), 1); + expect(env.get("hits")).toEqual(1); }); -Deno.test("Jaro-like inner-window matching: inner break with occasional Promise", async () => { +test("Jaro-like inner-window matching: inner break with occasional Promise", async () => { const env = new LuaEnv(luaBuildStandardEnv()); env.set( "tick", @@ -193,5 +193,5 @@ Deno.test("Jaro-like inner-window matching: inner break with occasional Promise" `, env, ); - assertEquals(env.get("ok"), true); + expect(env.get("ok")).toEqual(true); }); diff --git a/client/space_lua/close_attribute.test.ts b/client/space_lua/close_attribute.test.ts index fa062040..3c3f7020 100644 --- a/client/space_lua/close_attribute.test.ts +++ b/client/space_lua/close_attribute.test.ts @@ -1,8 +1,4 @@ -import { - assertEquals, - assertInstanceOf, - assertStringIncludes, -} from "@std/assert"; +import { expect, test } from "vitest"; import { isPromise } from "./rp.ts"; import { parse } from "./parse.ts"; import { evalStatement } from "./eval.ts"; @@ -60,7 +56,7 @@ async function runAndCatchEnv(code: string, ref = "close_attribute.lua") { // 1. parsing and static validation -Deno.test("close: parse ok", () => { +test("close: parse ok", () => { parse( ` local x = {} @@ -69,7 +65,7 @@ Deno.test("close: parse ok", () => { ); }); -Deno.test("close: parse ok without init", () => { +test("close: parse ok without init", () => { parse( ` do @@ -80,7 +76,7 @@ Deno.test("close: parse ok without init", () => { ); }); -Deno.test("close: local list only one", () => { +test("close: local list only one", () => { try { parse( ` @@ -92,12 +88,12 @@ Deno.test("close: local list only one", () => { ); throw new Error("Expected parse error"); } catch (e) { - assertStringIncludes(String((e as any)?.message ?? e), ""); - assertStringIncludes(String((e as any)?.message ?? e), "local list"); + expect(String((e as any)?.message ?? e)).toContain(""); + expect(String((e as any)?.message ?? e)).toContain("local list"); } }); -Deno.test("close: parse ok", () => { +test("close: parse ok", () => { parse( ` do @@ -108,7 +104,7 @@ Deno.test("close: parse ok", () => { ); }); -Deno.test("close: and parse ok", () => { +test("close: and parse ok", () => { parse( ` do @@ -123,7 +119,7 @@ Deno.test("close: and parse ok", () => { ); }); -Deno.test("close: invalid goto into scope", () => { +test("close: invalid goto into scope", () => { try { parse( ` @@ -140,13 +136,13 @@ Deno.test("close: invalid goto into scope", () => { ); throw new Error("Expected parse error"); } catch (e) { - assertStringIncludes(String((e as any)?.message ?? e), "goto"); + expect(String((e as any)?.message ?? e)).toContain("goto"); } }); // 2. basic scope exit -Deno.test("close: nil ignored; false is non-closable", async () => { +test("close: nil ignored; false is non-closable", async () => { const { e, ref, code } = await runAndCatch( ` do @@ -157,14 +153,14 @@ Deno.test("close: nil ignored; false is non-closable", async () => { "close_nil_false.lua", ); - assertStringIncludes(ref, "close_nil_false.lua"); - assertStringIncludes(code, "local y = false"); + expect(ref).toContain("close_nil_false.lua"); + expect(code).toContain("local y = false"); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: normal close gets nil error", async () => { +test("close: normal close gets nil error", async () => { const env = await evalBlock(` t = {} @@ -181,10 +177,10 @@ Deno.test("close: normal close gets nil error", async () => { end `); - assertEquals((env.get("t") as any).get(1), "nil"); + expect((env.get("t") as any).get(1)).toEqual("nil"); }); -Deno.test("close: close order", async () => { +test("close: close order", async () => { const env = await evalBlock(` t = {} @@ -203,11 +199,11 @@ Deno.test("close: close order", async () => { end `); - assertEquals((env.get("t") as any).get(1), 2); - assertEquals((env.get("t") as any).get(2), 1); + expect((env.get("t") as any).get(1)).toEqual(2); + expect((env.get("t") as any).get(2)).toEqual(1); }); -Deno.test("close: shadowed variables close independently", async () => { +test("close: shadowed variables close independently", async () => { const env = await evalBlock(` t = {} @@ -231,14 +227,14 @@ Deno.test("close: shadowed variables close independently", async () => { const t = env.get("t") as any; - assertEquals(t.get(1), "inner-end"); - assertEquals(t.get(2), "close-INNER"); - assertEquals(t.get(3), "middle"); - assertEquals(t.get(4), "close-OUTER"); - assertEquals(t.get(5), "outer-end"); + expect(t.get(1)).toEqual("inner-end"); + expect(t.get(2)).toEqual("close-INNER"); + expect(t.get(3)).toEqual("middle"); + expect(t.get(4)).toEqual("close-OUTER"); + expect(t.get(5)).toEqual("outer-end"); }); -Deno.test("close: metatable swap after mark closes with new __close", async () => { +test("close: metatable swap after mark closes with new __close", async () => { const env = await evalBlock(` t = {} @@ -263,10 +259,10 @@ Deno.test("close: metatable swap after mark closes with new __close", async () = // Lua uses the metamethod at close time; this verifies close-time // lookup - assertEquals(t.get(1), "close-2"); + expect(t.get(1)).toEqual("close-2"); }); -Deno.test("close: replacing __close function affects close-time behavior", async () => { +test("close: replacing __close function affects close-time behavior", async () => { const env = await evalBlock(` t = {} @@ -286,24 +282,24 @@ Deno.test("close: replacing __close function affects close-time behavior", async `); const t = env.get("t") as any; - assertEquals(t.length, 1); - assertEquals(t.get(1), "close-2"); + expect(t.length).toEqual(1); + expect(t.get(1)).toEqual("close-2"); }); // 3. errors and unwinding -Deno.test("close: non-closable init", async () => { +test("close: non-closable init", async () => { const { e } = await runAndCatch(` do local x = {} end `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: reassign after implicit nil errors", async () => { +test("close: reassign after implicit nil errors", async () => { const { e } = await runAndCatch( ` do @@ -314,14 +310,11 @@ Deno.test("close: reassign after implicit nil errors", async () => { "close_reassign_after_implicit_nil.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 'a'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 'a'",); }); -Deno.test("close: reassign after explicit nil errors", async () => { +test("close: reassign after explicit nil errors", async () => { const { e } = await runAndCatch( ` do @@ -332,14 +325,11 @@ Deno.test("close: reassign after explicit nil errors", async () => { "close_reassign_after_explicit_nil.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 'a'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 'a'",); }); -Deno.test("close: reassign after false is non-closable", async () => { +test("close: reassign after false is non-closable", async () => { const { e } = await runAndCatch( ` do @@ -350,11 +340,11 @@ Deno.test("close: reassign after false is non-closable", async () => { "close_reassign_after_false.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: reassign after closable value errors", async () => { +test("close: reassign after closable value errors", async () => { const { e } = await runAndCatch( ` do @@ -368,14 +358,11 @@ Deno.test("close: reassign after closable value errors", async () => { "close_reassign_after_closable.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 'a'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 'a'",); }); -Deno.test("close: reassignment through closure is non-closable", async () => { +test("close: reassignment through closure is non-closable", async () => { const { e } = await runAndCatch( ` do @@ -391,11 +378,11 @@ Deno.test("close: reassignment through closure is non-closable", async () => { "close_reassign_through_closure.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: initializer true is non-closable", async () => { +test("close: initializer true is non-closable", async () => { const { e } = await runAndCatch( ` do @@ -405,11 +392,11 @@ Deno.test("close: initializer true is non-closable", async () => { "close_init_true.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: initializer integer is non-closable", async () => { +test("close: initializer integer is non-closable", async () => { const { e } = await runAndCatch( ` do @@ -419,11 +406,11 @@ Deno.test("close: initializer integer is non-closable", async () => { "close_init_int.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: initializer float is non-closable", async () => { +test("close: initializer float is non-closable", async () => { const { e } = await runAndCatch( ` do @@ -433,11 +420,11 @@ Deno.test("close: initializer float is non-closable", async () => { "close_init_float.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: initializer string is non-closable", async () => { +test("close: initializer string is non-closable", async () => { const { e } = await runAndCatch( ` do @@ -447,11 +434,11 @@ Deno.test("close: initializer string is non-closable", async () => { "close_init_string.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: initializer function is non-closable", async () => { +test("close: initializer function is non-closable", async () => { const { e } = await runAndCatch( ` do @@ -461,11 +448,11 @@ Deno.test("close: initializer function is non-closable", async () => { "close_init_function.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: __close called exactly once on normal exit", async () => { +test("close: __close called exactly once on normal exit", async () => { const env = await evalBlock(` t = {} @@ -482,11 +469,11 @@ Deno.test("close: __close called exactly once on normal exit", async () => { const t = env.get("t") as any; - assertEquals(t.length, 1); - assertEquals(t.get(1), 1); + expect(t.length).toEqual(1); + expect(t.get(1)).toEqual(1); }); -Deno.test("close: async __close awaited on normal exit", async () => { +test("close: async __close awaited on normal exit", async () => { const G = luaBuildStandardEnv(); const env = new LuaEnv(G); @@ -513,11 +500,11 @@ Deno.test("close: async __close awaited on normal exit", async () => { ); const t = env.get("t") as any; - assertEquals(t.length, 1); - assertEquals(t.get(1), "closed"); + expect(t.length).toEqual(1); + expect(t.get(1)).toEqual("closed"); }); -Deno.test("close: __close called exactly once on error unwind", async () => { +test("close: __close called exactly once on error unwind", async () => { const { err: e, env } = await runAndCatchEnv( ` t = {} @@ -536,15 +523,15 @@ Deno.test("close: __close called exactly once on error unwind", async () => { "close_once_on_error.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "boom"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("boom"); const t = env.get("t") as any; - assertEquals(t.length, 1); - assertEquals(t.get(1), 1); + expect(t.length).toEqual(1); + expect(t.get(1)).toEqual(1); }); -Deno.test("close: async __close awaited on error unwind", async () => { +test("close: async __close awaited on error unwind", async () => { const code = ` t = {} @@ -579,15 +566,15 @@ Deno.test("close: async __close awaited on error unwind", async () => { e = err; } - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "boom"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("boom"); const t = env.get("t") as any; - assertEquals(t.length, 1); - assertEquals(t.get(1), "close-X-boom"); + expect(t.length).toEqual(1); + expect(t.get(1)).toEqual("close-X-boom"); }); -Deno.test("close: error in __close inside vararg function", async () => { +test("close: error in __close inside vararg function", async () => { const { e } = await runAndCatch( ` local function mk() @@ -608,11 +595,11 @@ Deno.test("close: error in __close inside vararg function", async () => { "close_vararg_close_error.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "closefail"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("closefail"); }); -Deno.test("close: __close not callable", async () => { +test("close: __close not callable", async () => { const { e } = await runAndCatch( ` do @@ -624,11 +611,11 @@ Deno.test("close: __close not callable", async () => { "close_not_callable.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: __close not found via __index", async () => { +test("close: __close not found via __index", async () => { const { e } = await runAndCatch( ` do @@ -645,11 +632,11 @@ Deno.test("close: __close not found via __index", async () => { "close_index_metaclose.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: mutate __close", async () => { +test("close: mutate __close", async () => { const { e } = await runAndCatch( ` do @@ -664,11 +651,11 @@ Deno.test("close: mutate __close", async () => { "close_mutate.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "not callable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("not callable"); }); -Deno.test("close: remove __close after mark errors at close time", async () => { +test("close: remove __close after mark errors at close time", async () => { const { err: e } = await runAndCatchEnv( ` do @@ -684,11 +671,11 @@ Deno.test("close: remove __close after mark errors at close time", async () => { "close_remove_metaclose.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "not callable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("not callable"); }); -Deno.test("close: __close callable via __call", async () => { +test("close: __close callable via __call", async () => { const { e } = await runAndCatch( ` do @@ -706,11 +693,11 @@ Deno.test("close: __close callable via __call", async () => { "close_callable_via_call.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: error after close var init still closes", async () => { +test("close: error after close var init still closes", async () => { const { e } = await runAndCatch( ` t = {} @@ -731,11 +718,11 @@ Deno.test("close: error after close var init still closes", async () => { "close_error_after_init_closes.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "boom"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("boom"); }); -Deno.test("close: close gets error", async () => { +test("close: close gets error", async () => { const { e } = await runAndCatch(` t = {} @@ -753,11 +740,11 @@ Deno.test("close: close gets error", async () => { end `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "boom"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("boom"); }); -Deno.test("close: close error", async () => { +test("close: close error", async () => { const { e } = await runAndCatch( ` do @@ -771,11 +758,11 @@ Deno.test("close: close error", async () => { "close_error.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "closefail"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("closefail"); }); -Deno.test("close: close error on error", async () => { +test("close: close error on error", async () => { const { e } = await runAndCatch( ` do @@ -791,11 +778,11 @@ Deno.test("close: close error on error", async () => { "close_error_on_error.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "closefail"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("closefail"); }); -Deno.test("close: close errors stop", async () => { +test("close: close errors stop", async () => { const { err: e, env } = await runAndCatchEnv( ` t = {} @@ -819,18 +806,18 @@ Deno.test("close: close errors stop", async () => { "close_errors_stop.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "c2"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("c2"); // verify that both closes were attempted (Lua 5.4), but the first // close error (from B, closed first) is the reported error const t = env.get("t") as any; - assertEquals(t.length, 2); - assertEquals(t.get(1), "close-B"); - assertEquals(t.get(2), "close-A"); + expect(t.length).toEqual(2); + expect(t.get(1)).toEqual("close-B"); + expect(t.get(2)).toEqual("close-A"); }); -Deno.test("close: multiple closers unwind on error", async () => { +test("close: multiple closers unwind on error", async () => { const { err: e, env } = await runAndCatchEnv( ` t = {} @@ -852,17 +839,17 @@ Deno.test("close: multiple closers unwind on error", async () => { "close_multi_unwind.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "boom"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("boom"); // verify both were closed in reverse order with the error object const t = env.get("t") as any; - assertEquals(t.length, 2); - assertEquals(t.get(1), "close-B-boom"); - assertEquals(t.get(2), "close-A-boom"); + expect(t.length).toEqual(2); + expect(t.get(1)).toEqual("close-B-boom"); + expect(t.get(2)).toEqual("close-A-boom"); }); -Deno.test("close: close errors stop during unwind", async () => { +test("close: close errors stop during unwind", async () => { const { err: e, env } = await runAndCatchEnv( ` t = {} @@ -887,18 +874,18 @@ Deno.test("close: close errors stop during unwind", async () => { "close_unwind_close_error.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "closefail-B"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("closefail-B"); // verify both closes were attempted (Lua 5.4), but the first close // error (from B, closed first) is the reported error const t = env.get("t") as any; - assertEquals(t.length, 2); - assertEquals(t.get(1), "close-B-boom"); - assertEquals(t.get(2), "close-A-boom"); + expect(t.length).toEqual(2); + expect(t.get(1)).toEqual("close-B-boom"); + expect(t.get(2)).toEqual("close-A-boom"); }); -Deno.test("close: complex assignment error closes prior", async () => { +test("close: complex assignment error closes prior", async () => { const { err: e, env } = await runAndCatchEnv( ` t = {} @@ -923,15 +910,15 @@ Deno.test("close: complex assignment error closes prior", async () => { "complex_assign_error.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "assign_error"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("assign_error"); // verify 'a' was closed despite 'b' failing to assign const t = env.get("t") as any; - assertEquals(t.get(1), "a_closed"); + expect(t.get(1)).toEqual("a_closed"); }); -Deno.test("close: multi-init closes prior when later init errors", async () => { +test("close: multi-init closes prior when later init errors", async () => { const { err: e, env } = await runAndCatchEnv( ` t = {} @@ -955,14 +942,14 @@ Deno.test("close: multi-init closes prior when later init errors", async () => { "close_multi_init_later_error.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "boom"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("boom"); const t = env.get("t") as any; - assertEquals(t.get(1), "a_closed"); + expect(t.get(1)).toEqual("a_closed"); }); -Deno.test("close: async close error reported; later closers still run", async () => { +test("close: async close error reported; later closers still run", async () => { const G = luaBuildStandardEnv(); const env = new LuaEnv(G); @@ -1005,19 +992,19 @@ Deno.test("close: async close error reported; later closers still run", async () return { err }; })(); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "b-closefail"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("b-closefail"); const t = env.get("t") as any; // B closes first and errors, but A must still be closed in Lua 5.4 intent - assertEquals(t.length, 2); - assertEquals(t.get(1), "close-B"); - assertEquals(t.get(2), "close-A"); + expect(t.length).toEqual(2); + expect(t.get(1)).toEqual("close-B"); + expect(t.get(2)).toEqual("close-A"); }); // 4. control flow exits -Deno.test("close: return closes", async () => { +test("close: return closes", async () => { const env = await evalBlock(` t = {} @@ -1035,11 +1022,11 @@ Deno.test("close: return closes", async () => { table.insert(t, f()) `); - assertEquals((env.get("t") as any).get(1), "close-X"); - assertEquals((env.get("t") as any).get(2), 1); + expect((env.get("t") as any).get(1)).toEqual("close-X"); + expect((env.get("t") as any).get(2)).toEqual(1); }); -Deno.test("close: return in if closes", async () => { +test("close: return in if closes", async () => { const env = await evalBlock(` t = {} @@ -1060,11 +1047,11 @@ Deno.test("close: return in if closes", async () => { table.insert(t, f()) `); - assertEquals((env.get("t") as any).get(1), "close-X"); - assertEquals((env.get("t") as any).get(2), 2); + expect((env.get("t") as any).get(1)).toEqual("close-X"); + expect((env.get("t") as any).get(2)).toEqual(2); }); -Deno.test("close: goto closes", async () => { +test("close: goto closes", async () => { const env = await evalBlock(` t = {} @@ -1084,10 +1071,10 @@ Deno.test("close: goto closes", async () => { end `); - assertEquals((env.get("t") as any).get(1), "close-X"); + expect((env.get("t") as any).get(1)).toEqual("close-X"); }); -Deno.test("close: goto nested", async () => { +test("close: goto nested", async () => { const env = await evalBlock(` t = {} @@ -1111,11 +1098,11 @@ Deno.test("close: goto nested", async () => { end `); - assertEquals((env.get("t") as any).get(1), "close-B"); - assertEquals((env.get("t") as any).get(2), "close-A"); + expect((env.get("t") as any).get(1)).toEqual("close-B"); + expect((env.get("t") as any).get(2)).toEqual("close-A"); }); -Deno.test("close: return to-be-closed variable", async () => { +test("close: return to-be-closed variable", async () => { const env = await evalBlock(` t = {} @@ -1133,13 +1120,13 @@ Deno.test("close: return to-be-closed variable", async () => { `); const t = env.get("t") as any; - assertEquals(t.get(1), "closed"); - assertEquals(t.get(2), "table"); + expect(t.get(1)).toEqual("closed"); + expect(t.get(2)).toEqual("table"); }); // 5. generic-for loop-scoped closing -Deno.test("close: for-in no close", async () => { +test("close: for-in no close", async () => { const env = await evalBlock(` t = {} @@ -1159,11 +1146,11 @@ Deno.test("close: for-in no close", async () => { end `); - assertEquals((env.get("t") as any).get(1), "body"); - assertEquals((env.get("t") as any).length, 1); + expect((env.get("t") as any).get(1)).toEqual("body"); + expect((env.get("t") as any).length).toEqual(1); }); -Deno.test("close: for-in false close is non-closable", async () => { +test("close: for-in false close is non-closable", async () => { const { e } = await runAndCatch( ` local function iter(state, ctrl) @@ -1183,11 +1170,11 @@ Deno.test("close: for-in false close is non-closable", async () => { "for_in_false_close.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: for-in bad close", async () => { +test("close: for-in bad close", async () => { const { e } = await runAndCatch( ` local function iter(state, ctrl) @@ -1207,11 +1194,11 @@ Deno.test("close: for-in bad close", async () => { "for_in_bad_close.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "non-closable"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("non-closable"); }); -Deno.test("close: for-in updates control", async () => { +test("close: for-in updates control", async () => { const env = await evalBlock(` t = {} local calls = 0 @@ -1241,12 +1228,12 @@ Deno.test("close: for-in updates control", async () => { table.insert(t, calls) `); - assertEquals((env.get("t") as any).get(1), "body"); - assertEquals((env.get("t") as any).get(2), "close-C"); - assertEquals((env.get("t") as any).get(3), 2); + expect((env.get("t") as any).get(1)).toEqual("body"); + expect((env.get("t") as any).get(2)).toEqual("close-C"); + expect((env.get("t") as any).get(3)).toEqual(2); }); -Deno.test("close: for-in closes", async () => { +test("close: for-in closes", async () => { const env = await evalBlock(` t = {} @@ -1272,11 +1259,11 @@ Deno.test("close: for-in closes", async () => { end `); - assertEquals((env.get("t") as any).get(1), "body"); - assertEquals((env.get("t") as any).get(2), "close-C"); + expect((env.get("t") as any).get(1)).toEqual("body"); + expect((env.get("t") as any).get(2)).toEqual("close-C"); }); -Deno.test("close: for-in async iterator and async closing are awaited", async () => { +test("close: for-in async iterator and async closing are awaited", async () => { const G = luaBuildStandardEnv(); const env = new LuaEnv(G); @@ -1319,12 +1306,12 @@ Deno.test("close: for-in async iterator and async closing are awaited", async () ); const t = env.get("t") as any; - assertEquals(t.get(1), "body"); - assertEquals(t.get(2), "close-C-nil"); - assertEquals(t.get(3), 2); + expect(t.get(1)).toEqual("body"); + expect(t.get(2)).toEqual("close-C-nil"); + expect(t.get(3)).toEqual(2); }); -Deno.test("close: loop scope", async () => { +test("close: loop scope", async () => { const env = await evalBlock(` t = {} @@ -1351,12 +1338,12 @@ Deno.test("close: loop scope", async () => { table.insert(t, "after") `); - assertEquals((env.get("t") as any).get(1), "body"); - assertEquals((env.get("t") as any).get(2), "close-C"); - assertEquals((env.get("t") as any).get(3), "after"); + expect((env.get("t") as any).get(1)).toEqual("body"); + expect((env.get("t") as any).get(2)).toEqual("close-C"); + expect((env.get("t") as any).get(3)).toEqual("after"); }); -Deno.test("close: for-in closing closes before outer block closers", async () => { +test("close: for-in closing closes before outer block closers", async () => { const env = await evalBlock(` t = {} @@ -1401,14 +1388,14 @@ Deno.test("close: for-in closing closes before outer block closers", async () => // after-loop runs // outer closes when leaving do-block // after-block runs - assertEquals(t.get(1), "body"); - assertEquals(t.get(2), "close-L"); - assertEquals(t.get(3), "after-loop"); - assertEquals(t.get(4), "close-O"); - assertEquals(t.get(5), "after-block"); + expect(t.get(1)).toEqual("body"); + expect(t.get(2)).toEqual("close-L"); + expect(t.get(3)).toEqual("after-loop"); + expect(t.get(4)).toEqual("close-O"); + expect(t.get(5)).toEqual("after-block"); }); -Deno.test("close: for-in closes on break", async () => { +test("close: for-in closes on break", async () => { const env = await evalBlock(` t = {} @@ -1435,11 +1422,11 @@ Deno.test("close: for-in closes on break", async () => { end `); - assertEquals((env.get("t") as any).get(1), "body"); - assertEquals((env.get("t") as any).get(2), "close-C"); + expect((env.get("t") as any).get(1)).toEqual("body"); + expect((env.get("t") as any).get(2)).toEqual("close-C"); }); -Deno.test("close: for-in closes on error", async () => { +test("close: for-in closes on error", async () => { const { err: e, env } = await runAndCatchEnv(` t = {} @@ -1465,15 +1452,15 @@ Deno.test("close: for-in closes on error", async () => { end `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "boom"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("boom"); // verify closer received error const t = env.get("t") as any; - assertEquals(t.get(1), "close-C-boom"); + expect(t.get(1)).toEqual("close-C-boom"); }); -Deno.test("close: for-in closes if iterator errors", async () => { +test("close: for-in closes if iterator errors", async () => { const { err: e, env } = await runAndCatchEnv( ` t = {} @@ -1498,15 +1485,15 @@ Deno.test("close: for-in closes if iterator errors", async () => { "for_in_iterator_error.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "iterboom"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("iterboom"); // verify closer received error const t = env.get("t") as any; - assertEquals(t.get(1), "close-C-iterboom"); + expect(t.get(1)).toEqual("close-C-iterboom"); }); -Deno.test("close: return inside for-in body closes loop closing value", async () => { +test("close: return inside for-in body closes loop closing value", async () => { const env = await evalBlock(` t = {} @@ -1537,11 +1524,11 @@ Deno.test("close: return inside for-in body closes loop closing value", async () `); const t = env.get("t") as any; - assertEquals(t.get(1), "close-C-nil"); - assertEquals(t.get(2), 1); + expect(t.get(1)).toEqual("close-C-nil"); + expect(t.get(2)).toEqual(1); }); -Deno.test("close: error inside for-in body closes loop closing value with error", async () => { +test("close: error inside for-in body closes loop closing value with error", async () => { const { err: e, env } = await runAndCatchEnv( ` t = {} @@ -1569,16 +1556,16 @@ Deno.test("close: error inside for-in body closes loop closing value with error" "for_in_body_error_close_value.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "boom"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("boom"); const t = env.get("t") as any; - assertEquals(t.get(1), "close-C-boom"); + expect(t.get(1)).toEqual("close-C-boom"); }); // 6. pairs integration -Deno.test("close: pairs closes", async () => { +test("close: pairs closes", async () => { const env = await evalBlock(` t = {} local closed = false @@ -1613,14 +1600,14 @@ Deno.test("close: pairs closes", async () => { end `); - assertEquals((env.get("t") as any).get(1), "body"); - assertEquals((env.get("t") as any).get(2), "close-P"); - assertEquals((env.get("t") as any).get(3), "closed"); + expect((env.get("t") as any).get(1)).toEqual("body"); + expect((env.get("t") as any).get(2)).toEqual("close-P"); + expect((env.get("t") as any).get(3)).toEqual("closed"); }); // 7. protected calls -Deno.test("close: pcall closes on success", async () => { +test("close: pcall closes on success", async () => { const env = await evalBlock(` t = {} @@ -1639,11 +1626,11 @@ Deno.test("close: pcall closes on success", async () => { end `); - assertEquals((env.get("t") as any).get(1), "close-X-nil"); - assertEquals((env.get("t") as any).get(2), 1); + expect((env.get("t") as any).get(1)).toEqual("close-X-nil"); + expect((env.get("t") as any).get(2)).toEqual(1); }); -Deno.test("close: multi-return expansion binds and closes", async () => { +test("close: multi-return expansion binds and closes", async () => { const env = await evalBlock(` t = {} @@ -1663,11 +1650,11 @@ Deno.test("close: multi-return expansion binds and closes", async () => { `); const t = env.get("t") as any; - assertEquals(t.get(1), 99); - assertEquals(t.get(2), "close-A-nil"); + expect(t.get(1)).toEqual(99); + expect(t.get(2)).toEqual("close-A-nil"); }); -Deno.test("close: pcall return closes with nil error", async () => { +test("close: pcall return closes with nil error", async () => { const env = await evalBlock(` t = {} @@ -1692,12 +1679,12 @@ Deno.test("close: pcall return closes with nil error", async () => { `); const t = env.get("t") as any; - assertEquals(t.get(1), "close-R-nil"); - assertEquals(t.get(2), true); - assertEquals(t.get(3), 7); + expect(t.get(1)).toEqual("close-R-nil"); + expect(t.get(2)).toEqual(true); + expect(t.get(3)).toEqual(7); }); -Deno.test("close: pcall break closes with nil error", async () => { +test("close: pcall break closes with nil error", async () => { const env = await evalBlock(` t = {} @@ -1725,12 +1712,12 @@ Deno.test("close: pcall break closes with nil error", async () => { `); const t = env.get("t") as any; - assertEquals(t.get(1), "close-B-nil"); - assertEquals(t.get(2), true); - assertEquals(t.get(3), 1); + expect(t.get(1)).toEqual("close-B-nil"); + expect(t.get(2)).toEqual(true); + expect(t.get(3)).toEqual(1); }); -Deno.test("close: pcall goto closes with nil error", async () => { +test("close: pcall goto closes with nil error", async () => { const env = await evalBlock(` t = {} @@ -1758,12 +1745,12 @@ Deno.test("close: pcall goto closes with nil error", async () => { `); const t = env.get("t") as any; - assertEquals(t.get(1), "close-G-nil"); - assertEquals(t.get(2), true); - assertEquals(t.get(3), 2); + expect(t.get(1)).toEqual("close-G-nil"); + expect(t.get(2)).toEqual(true); + expect(t.get(3)).toEqual(2); }); -Deno.test("close: pcall closes on error", async () => { +test("close: pcall closes on error", async () => { const env = await evalBlock(` t = {} @@ -1782,11 +1769,11 @@ Deno.test("close: pcall closes on error", async () => { end `); - assertEquals((env.get("t") as any).get(1), "close-X-boom"); - assertEquals((env.get("t") as any).get(2), "boom"); + expect((env.get("t") as any).get(1)).toEqual("close-X-boom"); + expect((env.get("t") as any).get(2)).toEqual("boom"); }); -Deno.test("close: pcall close error overrides original and skips remaining closers", async () => { +test("close: pcall close error overrides original and skips remaining closers", async () => { const env = await evalBlock(` t = {} @@ -1818,15 +1805,15 @@ Deno.test("close: pcall close error overrides original and skips remaining close const t = env.get("t") as any; // C closes first, then B closes and errors; A is still closed in Lua 5.4 - assertEquals(t.get(1), "close-C-boom"); - assertEquals(t.get(2), "close-B-boom"); - assertEquals(t.get(3), "close-A-boom"); - assertEquals(t.get(4), false); - assertEquals(t.get(5), "closefail-B"); - assertEquals(t.length, 5); + expect(t.get(1)).toEqual("close-C-boom"); + expect(t.get(2)).toEqual("close-B-boom"); + expect(t.get(3)).toEqual("close-A-boom"); + expect(t.get(4)).toEqual(false); + expect(t.get(5)).toEqual("closefail-B"); + expect(t.length).toEqual(5); }); -Deno.test("close: xpcall closes on error", async () => { +test("close: xpcall closes on error", async () => { const env = await evalBlock(` t = {} @@ -1849,11 +1836,11 @@ Deno.test("close: xpcall closes on error", async () => { end `); - assertEquals((env.get("t") as any).get(1), "close-X-boom"); - assertEquals((env.get("t") as any).get(2), "handled-boom"); + expect((env.get("t") as any).get(1)).toEqual("close-X-boom"); + expect((env.get("t") as any).get(2)).toEqual("handled-boom"); }); -Deno.test("close: xpcall boundary contains __close errors", async () => { +test("close: xpcall boundary contains __close errors", async () => { const env = await evalBlock(` t = {} @@ -1882,18 +1869,18 @@ Deno.test("close: xpcall boundary contains __close errors", async () => { const t = env.get("t") as any; // close runs during unwind and sees original error - assertEquals(t.get(1), "close-err-boom"); + expect(t.get(1)).toEqual("close-err-boom"); // the close error overrides the original for `xpcall`, so the // handler sees "closefail" - assertEquals(t.get(2), "handler-closefail"); + expect(t.get(2)).toEqual("handler-closefail"); - assertEquals(t.get(3), false); - assertEquals(t.get(4), "handled-closefail"); - assertEquals(t.length, 4); + expect(t.get(3)).toEqual(false); + expect(t.get(4)).toEqual("handled-closefail"); + expect(t.length).toEqual(4); }); -Deno.test("close: nested to-be-closed created inside __close", async () => { +test("close: nested to-be-closed created inside __close", async () => { const env = await evalBlock(` t = {} @@ -1927,14 +1914,14 @@ Deno.test("close: nested to-be-closed created inside __close", async () => { // - outer close begins // - inner scope ends, so inner closes (during exec of outer __close) // - outer close ends - assertEquals(t.get(1), "body-end"); - assertEquals(t.get(2), "outer-close-start-nil"); - assertEquals(t.get(3), "inner-scope-end"); - assertEquals(t.get(4), "close-INNER-nil"); - assertEquals(t.get(5), "outer-close-end"); + expect(t.get(1)).toEqual("body-end"); + expect(t.get(2)).toEqual("outer-close-start-nil"); + expect(t.get(3)).toEqual("inner-scope-end"); + expect(t.get(4)).toEqual("close-INNER-nil"); + expect(t.get(5)).toEqual("outer-close-end"); }); -Deno.test("close: pcall boundary does not close closers created in pcall args", async () => { +test("close: pcall boundary does not close closers created in pcall args", async () => { const env = await evalBlock(` t = {} @@ -1966,14 +1953,14 @@ Deno.test("close: pcall boundary does not close closers created in pcall args", // if `pcall` boundary is correct, ARG is closed at end of its own // scope and `pcall` does not close it - assertEquals(t.get(1), "arg"); - assertEquals(t.get(2), "close-ARG"); - assertEquals(t.get(3), "in-f"); - assertEquals(t.get(4), true); - assertEquals(t.get(5), 1); + expect(t.get(1)).toEqual("arg"); + expect(t.get(2)).toEqual("close-ARG"); + expect(t.get(3)).toEqual("in-f"); + expect(t.get(4)).toEqual(true); + expect(t.get(5)).toEqual(1); }); -Deno.test("close: nested pcall boundaries", async () => { +test("close: nested pcall boundaries", async () => { const env = await evalBlock(` t = {} @@ -2007,10 +1994,10 @@ Deno.test("close: nested pcall boundaries", async () => { // inner closes with "inner" outer continues, then outer closes with // nil on success of outer itself - assertEquals(t.get(1), "close-B-inner"); - assertEquals(t.get(2), false); - assertEquals(t.get(3), "inner"); - assertEquals(t.get(4), "close-A-nil"); - assertEquals(t.get(5), true); - assertEquals(t.get(6), 1); + expect(t.get(1)).toEqual("close-B-inner"); + expect(t.get(2)).toEqual(false); + expect(t.get(3)).toEqual("inner"); + expect(t.get(4)).toEqual("close-A-nil"); + expect(t.get(5)).toEqual(true); + expect(t.get(6)).toEqual(1); }); diff --git a/client/space_lua/const_attribute.test.ts b/client/space_lua/const_attribute.test.ts index 12c8c3c7..069c79d5 100644 --- a/client/space_lua/const_attribute.test.ts +++ b/client/space_lua/const_attribute.test.ts @@ -1,8 +1,4 @@ -import { - assertEquals, - assertInstanceOf, - assertStringIncludes, -} from "@std/assert"; +import { expect, test } from "vitest"; import { parse } from "./parse.ts"; import { evalStatement } from "./eval.ts"; import { LuaEnv, LuaRuntimeError, LuaStackFrame } from "./runtime.ts"; @@ -38,114 +34,102 @@ async function runAndCatch(code: string, ref = "const_attribute.lua") { } } -Deno.test("const: Unknown attribute (parse-time)", () => { +test("const: Unknown attribute (parse-time)", () => { let threw = false; try { parse(`local x = 1`, { ref: "unknown_attribute.lua" }); } catch (e: any) { threw = true; - assertStringIncludes(String(e?.message ?? e), "unknown attribute 'nope'"); + expect(String(e?.message ?? e)).toContain("unknown attribute 'nope'"); } if (!threw) { throw new Error("Expected parse error for unknown attribute"); } }); -Deno.test("const: Case-sensitive attribute (parse-time)", () => { +test("const: Case-sensitive attribute (parse-time)", () => { let threw = false; try { parse(`local x = 1`, { ref: "unknown_attribute.lua" }); } catch (e: any) { threw = true; - assertStringIncludes(String(e?.message ?? e), "unknown attribute 'Const'"); + expect(String(e?.message ?? e)).toContain("unknown attribute 'Const'"); } if (!threw) { throw new Error("Expected parse error for unknown attribute"); } }); -Deno.test("const: Requires initializer", async () => { +test("const: Requires initializer", async () => { const { e } = await runAndCatch(` local x `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "must be initialized"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("must be initialized"); }); -Deno.test("const: Initialization ok, reassignment error", async () => { +test("const: Initialization ok, reassignment error", async () => { const env = await evalBlock(` local x = 1 y = x `); - assertEquals(env.get("y"), 1); + expect(env.get("y")).toEqual(1); const { e } = await runAndCatch(` local x = 1 x = 2 `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 'x'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 'x'",); }); -Deno.test("const: Initialization to nil ok, reassignment error", async () => { +test("const: Initialization to nil ok, reassignment error", async () => { const { e } = await runAndCatch(` local x = nil x = 2 `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 'x'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 'x'",); }); -Deno.test("const: Multi-declaration and missing RHS", async () => { +test("const: Multi-declaration and missing RHS", async () => { { const env = await evalBlock(` local a , b = 1 y1 = a y2 = b `); - assertEquals(env.get("y1"), 1); - assertEquals(env.get("y2"), null); + expect(env.get("y1")).toEqual(1); + expect(env.get("y2")).toEqual(null); } { const { e } = await runAndCatch(` local a, b ; -- missing assignment `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes((e as LuaRuntimeError).message, "must be initialized"); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("must be initialized"); } }); -Deno.test("const: Multi-assignment after declaration fails", async () => { +test("const: Multi-assignment after declaration fails", async () => { const { e } = await runAndCatch(` local a, b = 1, 2 a, b = 3, 4 `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 'a'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 'a'",); }); -Deno.test("const: Second position", async () => { +test("const: Second position", async () => { const { e } = await runAndCatch(` local a, b = 1, 2 b = 3 `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 'b'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 'b'",); }); -Deno.test("const: Initialization from function returns", async () => { +test("const: Initialization from function returns", async () => { const env = await evalBlock(` local function f() return 7 @@ -155,8 +139,8 @@ Deno.test("const: Initialization from function returns", async () => { y1, y2 = a, b `); - assertEquals(env.get("y1"), 7); - assertEquals(env.get("y2"), null); + expect(env.get("y1")).toEqual(7); + expect(env.get("y2")).toEqual(null); const { e } = await runAndCatch(` local function f() @@ -167,14 +151,11 @@ Deno.test("const: Initialization from function returns", async () => { a = 2 `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 'a'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 'a'",); }); -Deno.test("const: Shadowing", async () => { +test("const: Shadowing", async () => { { const { e } = await runAndCatch(` local a = 1 @@ -184,11 +165,8 @@ Deno.test("const: Shadowing", async () => { a = 3 end `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 'a'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 'a'",); } { @@ -202,11 +180,11 @@ Deno.test("const: Shadowing", async () => { y = a `); - assertEquals(env.get("y"), 1); + expect(env.get("y")).toEqual(1); } }); -Deno.test("const: Globals and fields not affected", async () => { +test("const: Globals and fields not affected", async () => { const env = await evalBlock(` local a = 1 G = a @@ -216,11 +194,11 @@ Deno.test("const: Globals and fields not affected", async () => { y1, y2 = G, T.x `); - assertEquals(env.get("y1"), 1); - assertEquals(env.get("y2"), 1); + expect(env.get("y1")).toEqual(1); + expect(env.get("y2")).toEqual(1); }); -Deno.test("const: Table binding vs table contents", async () => { +test("const: Table binding vs table contents", async () => { const env = await evalBlock(` local t = { a = 1, 2, 3 } @@ -229,12 +207,12 @@ Deno.test("const: Table binding vs table contents", async () => { y1, y2, y3 = t.a, t[2], #t `); - assertEquals(env.get("y1"), 10); - assertEquals(env.get("y2"), 20); - assertEquals(env.get("y3"), 2); + expect(env.get("y1")).toEqual(10); + expect(env.get("y2")).toEqual(20); + expect(env.get("y3")).toEqual(2); }); -Deno.test("const: Rebinding table fails", async () => { +test("const: Rebinding table fails", async () => { const { e } = await runAndCatch( ` local t = { @@ -247,28 +225,22 @@ Deno.test("const: Rebinding table fails", async () => { `, "const_table_rebind.lua", ); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 't'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 't'",); }); -Deno.test("const: Inner block reassignment", async () => { +test("const: Inner block reassignment", async () => { const { e } = await runAndCatch(` local a = 1 do a = 2 -- must fail end `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 'a'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 'a'",); }); -Deno.test("const: Closure reassignment", async () => { +test("const: Closure reassignment", async () => { const { e } = await runAndCatch(` local a = 1 @@ -278,14 +250,11 @@ Deno.test("const: Closure reassignment", async () => { f() `); - assertInstanceOf(e, LuaRuntimeError); - assertStringIncludes( - (e as LuaRuntimeError).message, - "attempt to assign to const variable 'a'", - ); + expect(e).toBeInstanceOf(LuaRuntimeError); + expect((e as LuaRuntimeError).message).toContain("attempt to assign to const variable 'a'",); }); -Deno.test("const: Closure mutates table", async () => { +test("const: Closure mutates table", async () => { const env = await evalBlock(` local t = { x = 1 } @@ -297,5 +266,5 @@ Deno.test("const: Closure mutates table", async () => { y = t.x `); - assertEquals(env.get("y"), 2); + expect(env.get("y")).toEqual(2); }); diff --git a/client/space_lua/context_errors.test.ts b/client/space_lua/context_errors.test.ts index 5c421fb9..b33e9dce 100644 --- a/client/space_lua/context_errors.test.ts +++ b/client/space_lua/context_errors.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import { parse } from "./parse.ts"; import { evalStatement } from "./eval.ts"; import { LuaEnv, LuaRuntimeError, LuaStackFrame } from "./runtime.ts"; import { luaBuildStandardEnv } from "./stdlib.ts"; -import { assertInstanceOf, assertStringIncludes } from "@std/assert"; async function runAndCatch(code: string, ref = "ctx_test.lua") { const ast = parse(code, { ref }); @@ -24,17 +24,17 @@ function assertCtxErrorContains( ref: string, msgIncludes: string, ) { - assertInstanceOf(e, LuaRuntimeError); + expect(e).toBeInstanceOf(LuaRuntimeError); const err = e as LuaRuntimeError; - assertStringIncludes(err.message, msgIncludes); + expect(err.message).toContain(msgIncludes); const pretty = err.toPrettyString(code); - assertStringIncludes(pretty, msgIncludes); - assertStringIncludes(pretty, ref); + expect(pretty).toContain(msgIncludes); + expect(pretty).toContain(ref); // caret presence sanity check - assertStringIncludes(pretty, "^"); + expect(pretty).toContain("^"); } -Deno.test("Context error: indexing nil value includes message and ref", async () => { +test("Context error: indexing nil value includes message and ref", async () => { const { e, code, ref } = await runAndCatch( ` local t = nil @@ -45,7 +45,7 @@ Deno.test("Context error: indexing nil value includes message and ref", async () assertCtxErrorContains(e, code, ref, "attempt to index a nil value"); }); -Deno.test("Context error: indexing with nil key includes message and ref", async () => { +test("Context error: indexing with nil key includes message and ref", async () => { const { e, code, ref } = await runAndCatch( ` local t = {} @@ -57,7 +57,7 @@ Deno.test("Context error: indexing with nil key includes message and ref", async assertCtxErrorContains(e, code, ref, "attempt to index with a nil key"); }); -Deno.test("Context error: calling nil includes message and ref", async () => { +test("Context error: calling nil includes message and ref", async () => { const { e, code, ref } = await runAndCatch( ` local f = nil @@ -68,7 +68,7 @@ Deno.test("Context error: calling nil includes message and ref", async () => { assertCtxErrorContains(e, code, ref, "attempt to call a nil value"); }); -Deno.test("Context error: modulo by zero includes message and ref", async () => { +test("Context error: modulo by zero includes message and ref", async () => { const { e, code, ref } = await runAndCatch( ` local a = 1 @@ -80,7 +80,7 @@ Deno.test("Context error: modulo by zero includes message and ref", async () => assertCtxErrorContains(e, code, ref, "attempt to perform 'n%0'"); }); -Deno.test("Context error: type mismatch in comparison includes message and ref", async () => { +test("Context error: type mismatch in comparison includes message and ref", async () => { const { e, code, ref } = await runAndCatch( ` local x = "a" < 1 @@ -96,7 +96,7 @@ Deno.test("Context error: type mismatch in comparison includes message and ref", * - __call metamethod wrong type (non-callable) * - length operator on unsupported type */ -Deno.test("Context error: __index metamethod must be function or table", async () => { +test("Context error: __index metamethod must be function or table", async () => { const { e, code, ref } = await runAndCatch( ` local t = {} @@ -113,7 +113,7 @@ Deno.test("Context error: __index metamethod must be function or table", async ( ); }); -Deno.test("Context error: __call metamethod must be a function", async () => { +test("Context error: __call metamethod must be a function", async () => { const { e, code, ref } = await runAndCatch( ` local t = {} @@ -130,7 +130,7 @@ Deno.test("Context error: __call metamethod must be a function", async () => { ); }); -Deno.test("Context error: length operator wrong type (number)", async () => { +test("Context error: length operator wrong type (number)", async () => { const { e, code, ref } = await runAndCatch( ` local x = #1 diff --git a/client/space_lua/eval.test.ts b/client/space_lua/eval.test.ts index fc0eb2b5..e989122c 100644 --- a/client/space_lua/eval.test.ts +++ b/client/space_lua/eval.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "@std/assert/equals"; +import { expect, test } from "vitest"; import { LuaEnv, LuaNativeJSFunction, @@ -30,87 +30,83 @@ async function evalBlock(s: string, e = new LuaEnv()): Promise { await evalStatement(node, e, sf); } -Deno.test("Evaluator test", async () => { +test("Evaluator test", async () => { const env = new LuaEnv(); env.set("test", new LuaNativeJSFunction((n) => n)); env.set("asyncTest", new LuaNativeJSFunction((n) => Promise.resolve(n))); // Basic arithmetic - assertEquals(evalExpr(`1 + 2 + 3 - 3`), 3); - assertEquals(evalExpr(`4 // 3`), 1); - assertEquals(evalExpr(`4 % 3`), 1); + expect(evalExpr(`1 + 2 + 3 - 3`)).toEqual(3); + expect(evalExpr(`4 // 3`)).toEqual(1); + expect(evalExpr(`4 % 3`)).toEqual(1); // Bitwise arithmetic - assertEquals(evalExpr(`~171`), -172); // signed two's complement - assertEquals(evalExpr(`5 & 3`), 1); // 101 & 011 = 001 - assertEquals(evalExpr(`5 | 3`), 7); // 101 | 011 = 111 - assertEquals(evalExpr(`5 ~ 3`), 6); // 101 ^ 011 = 110 - assertEquals(evalExpr(`5 << 3`), 40); // 101 << 3 = 101000 - assertEquals(evalExpr(`5 >> 2`), 1); // 101 >> 2 = 1 + expect(evalExpr(`~171`)).toEqual(-172); // signed two's complement + expect(evalExpr(`5 & 3`)).toEqual(1); // 101 & 011 = 001 + expect(evalExpr(`5 | 3`)).toEqual(7); // 101 | 011 = 111 + expect(evalExpr(`5 ~ 3`)).toEqual(6); // 101 ^ 011 = 110 + expect(evalExpr(`5 << 3`)).toEqual(40); // 101 << 3 = 101000 + expect(evalExpr(`5 >> 2`)).toEqual(1); // 101 >> 2 = 1 // Strings - assertEquals(evalExpr(`"a" .. "b"`), "ab"); + expect(evalExpr(`"a" .. "b"`)).toEqual("ab"); // Logic - assertEquals(evalExpr(`true and false`), false); - assertEquals(evalExpr(`true or false`), true); - assertEquals(evalExpr(`not true`), false); + expect(evalExpr(`true and false`)).toEqual(false); + expect(evalExpr(`true or false`)).toEqual(true); + expect(evalExpr(`not true`)).toEqual(false); // Test eager evaluation of left operand - assertEquals( + expect( evalExpr( `true or (function() error("this should not be evaluated") end)()`, ), - true, - ); + ).toEqual(true); // Tables const tbl = await evalExpr(`{3, 1, 2}`); - assertEquals(tbl.get(1), 3); - assertEquals(tbl.get(2), 1); - assertEquals(tbl.get(3), 2); - assertEquals(luaValueToJS(tbl, sf), [3, 1, 2]); + expect(tbl.get(1)).toEqual(3); + expect(tbl.get(2)).toEqual(1); + expect(tbl.get(3)).toEqual(2); + expect(luaValueToJS(tbl, sf)).toEqual([3, 1, 2]); - assertEquals( + expect( luaValueToJS(await evalExpr(`{name=test("Zef"), age=100}`, env), sf), - { - name: "Zef", - age: 100, - }, - ); + ).toEqual({ + name: "Zef", + age: 100, + }); - assertEquals( + expect( luaValueToJS(await evalExpr(`{name="Zef", age=asyncTest(100)}`, env), sf), - { - name: "Zef", - age: 100, - }, - ); + ).toEqual({ + name: "Zef", + age: 100, + }); const result = await evalExpr(`{[3+2]=1, ["a".."b"]=2}`); - assertEquals(result.get(5), 1); - assertEquals(result.get("ab"), 2); + expect(result.get(5)).toEqual(1); + expect(result.get("ab")).toEqual(2); - assertEquals(await evalExpr(`#{}`), 0); - assertEquals(await evalExpr(`#{1, 2, 3}`), 3); + expect(await evalExpr(`#{}`)).toEqual(0); + expect(await evalExpr(`#{1, 2, 3}`)).toEqual(3); // Unary operators - assertEquals(await evalExpr(`-asyncTest(3)`, env), -3); + expect(await evalExpr(`-asyncTest(3)`, env)).toEqual(-3); // Function calls - assertEquals(singleResult(evalExpr(`test(3)`, env)), 3); - assertEquals(singleResult(await evalExpr(`asyncTest(3) + 1`, env)), 4); + expect(singleResult(evalExpr(`test(3)`, env))).toEqual(3); + expect(singleResult(await evalExpr(`asyncTest(3) + 1`, env))).toEqual(4); // Function expressions and table access - assertEquals( + expect( await evalExpr(`(function() return {name="John"} end)().name`), - "John", - ); + ).toEqual("John"); // Function definitions const fn = evalExpr(`function(a, b) return a + b end`); - assertEquals(fn.body.parameters, ["a", "b"]); + expect(fn.body.parameters).toEqual(["a", "b"]); }); -Deno.test("Parser rejects unary plus - parenthesized", () => { +test("Parser rejects unary plus - parenthesized", () => { for ( const src of [ "return +(1)", @@ -125,16 +121,14 @@ Deno.test("Parser rejects unary plus - parenthesized", () => { } catch (e: any) { err = e; } - assertEquals(err !== null, true, `expected parse error for: ${src}`); - assertEquals( + expect(err !== null).toEqual(true); + expect( String(err?.message ?? err).includes("unexpected symbol near '+'"), - true, - `expected unary-plus message for: ${src}`, - ); + ).toEqual(true); } }); -Deno.test("Parser rejects unary plus - variables and calls", () => { +test("Parser rejects unary plus - variables and calls", () => { for ( const src of [ "return +(a)", @@ -150,16 +144,14 @@ Deno.test("Parser rejects unary plus - variables and calls", () => { } catch (e: any) { err = e; } - assertEquals(err !== null, true, `expected parse error for: ${src}`); - assertEquals( + expect(err !== null).toEqual(true); + expect( String(err?.message ?? err).includes("unexpected symbol near '+'"), - true, - `expected unary-plus message for: ${src}`, - ); + ).toEqual(true); } }); -Deno.test("Parser rejects unary plus - whitespace/newlines", () => { +test("Parser rejects unary plus - whitespace/newlines", () => { for ( const src of [ "return + 1", @@ -174,16 +166,14 @@ Deno.test("Parser rejects unary plus - whitespace/newlines", () => { } catch (e: any) { err = e; } - assertEquals(err !== null, true, `expected parse error for: ${src}`); - assertEquals( + expect(err !== null).toEqual(true); + expect( String(err?.message ?? err).includes("unexpected symbol near '+'"), - true, - `expected unary-plus message for: ${src}`, - ); + ).toEqual(true); } }); -Deno.test("Comparison metamethods: __lt", async () => { +test("Comparison metamethods: __lt", async () => { const env = new LuaEnv(luaBuildStandardEnv()); await evalBlock( @@ -198,10 +188,10 @@ Deno.test("Comparison metamethods: __lt", async () => { env, ); - assertEquals(env.get("res"), true); + expect(env.get("res")).toEqual(true); }); -Deno.test("Comparison metamethods: __le does not fallback to __lt", async () => { +test("Comparison metamethods: __le does not fallback to __lt", async () => { const env = new LuaEnv(luaBuildStandardEnv()); let threw = false; @@ -225,10 +215,10 @@ Deno.test("Comparison metamethods: __le does not fallback to __lt", async () => } } - assertEquals(threw, true); + expect(threw).toEqual(true); }); -Deno.test("Equality metamethod: __eq requires same function", async () => { +test("Equality metamethod: __eq requires same function", async () => { const env = new LuaEnv(luaBuildStandardEnv()); await evalBlock( @@ -245,38 +235,38 @@ Deno.test("Equality metamethod: __eq requires same function", async () => { ); // Lua calls __eq even when the functions differ - assertEquals(env.get("res"), true); + expect(env.get("res")).toEqual(true); }); -Deno.test("Statement evaluation", async () => { +test("Statement evaluation", async () => { const env = new LuaEnv(); env.set("test", new LuaNativeJSFunction((n) => n)); env.set("asyncTest", new LuaNativeJSFunction((n) => Promise.resolve(n))); - assertEquals(undefined, await evalBlock(`a = 3`, env)); - assertEquals(env.get("a"), 3); - assertEquals(undefined, await evalBlock(`b = test(3)`, env)); - assertEquals(env.get("b"), 3); + expect(await evalBlock(`a = 3`, env)).toEqual(undefined); + expect(env.get("a")).toEqual(3); + expect(await evalBlock(`b = test(3)`, env)).toEqual(undefined); + expect(env.get("b")).toEqual(3); await evalBlock(`c = asyncTest(3)`, env); - assertEquals(env.get("c"), 3); + expect(env.get("c")).toEqual(3); // Multiple assignments const env2 = new LuaEnv(); - assertEquals(undefined, await evalBlock(`a, b = 1, 2`, env2)); - assertEquals(env2.get("a"), 1); - assertEquals(env2.get("b"), 2); + expect(await evalBlock(`a, b = 1, 2`, env2)).toEqual(undefined); + expect(env2.get("a")).toEqual(1); + expect(env2.get("b")).toEqual(2); // Other lvalues const env3 = new LuaEnv(); await evalBlock(`tbl = {1, 2, 3}`, env3); await evalBlock(`tbl[1] = 3`, env3); - assertEquals(luaValueToJS(env3.get("tbl"), sf), [3, 2, 3]); + expect(luaValueToJS(env3.get("tbl"), sf)).toEqual([3, 2, 3]); await evalBlock("tbl.name = 'Zef'", env3); - assertEquals(env3.get("tbl").get("name"), "Zef"); + expect(env3.get("tbl").get("name")).toEqual("Zef"); await evalBlock(`tbl[2] = {age=10}`, env3); await evalBlock(`tbl[2].age = 20`, env3); - assertEquals(env3.get("tbl").get(2).get("age"), 20); + expect(env3.get("tbl").get(2).get("age")).toEqual(20); // Blocks and scopes const env4 = new LuaEnv(); @@ -291,7 +281,7 @@ Deno.test("Statement evaluation", async () => { end`, env4, ); - assertEquals(env4.get("a"), 3); + expect(env4.get("a")).toEqual(3); const env5 = new LuaEnv(); env5.set("print", new LuaNativeJSFunction(console.log)); @@ -306,7 +296,7 @@ Deno.test("Statement evaluation", async () => { end`, env5, ); - assertEquals(env5.get("a"), 3); + expect(env5.get("a")).toEqual(3); await evalBlock( ` @@ -319,7 +309,7 @@ Deno.test("Statement evaluation", async () => { end`, env5, ); - assertEquals(env5.get("a"), 1); + expect(env5.get("a")).toEqual(1); await evalBlock( ` @@ -330,7 +320,7 @@ Deno.test("Statement evaluation", async () => { end`, env5, ); - assertEquals(env5.get("var"), 1); + expect(env5.get("var")).toEqual(1); // While loop const env6 = new LuaEnv(); @@ -346,7 +336,7 @@ Deno.test("Statement evaluation", async () => { `, env6, ); - assertEquals(env6.get("c"), 3); + expect(env6.get("c")).toEqual(3); // Repeat loop const env7 = new LuaEnv(); @@ -362,7 +352,7 @@ Deno.test("Statement evaluation", async () => { `, env7, ); - assertEquals(env7.get("c"), 3); + expect(env7.get("c")).toEqual(3); // Function definition and calling const env8 = new LuaEnv(); @@ -401,7 +391,7 @@ Deno.test("Statement evaluation", async () => { `, env10, ); - assertEquals(env10.get("c"), 6); + expect(env10.get("c")).toEqual(6); // For loop over iterator const env11 = new LuaEnv(luaBuildStandardEnv()); @@ -443,16 +433,15 @@ Deno.test("Statement evaluation", async () => { return fn("Lua"); }), ); - assertEquals( - "Hello from Lua", + expect( await evalExpr( `runMe(function(name) return "Hello from " .. name end)`, env12, ), - ); + ).toEqual("Hello from Lua"); }); -Deno.test("Thread local _CTX", async () => { +test("Thread local _CTX", async () => { const env = new LuaEnv(); const threadLocal = new LuaEnv(); threadLocal.setLocal("threadValue", "test123"); @@ -469,10 +458,10 @@ Deno.test("Thread local _CTX", async () => { ); const result = await evalExpr("test()", env, sf); - assertEquals(singleResult(result), "test123"); + expect(singleResult(result)).toEqual("test123"); }); -Deno.test("Thread local _CTX - advanced cases", async () => { +test("Thread local _CTX - advanced cases", async () => { // Create environment with standard library const env = new LuaEnv(luaBuildStandardEnv()); const threadLocal = new LuaEnv(); @@ -502,7 +491,7 @@ Deno.test("Thread local _CTX - advanced cases", async () => { `, env, ); - assertEquals(await evalExpr("outer()", env, sf), "alice"); + expect(await evalExpr("outer()", env, sf)).toEqual("alice"); // Test 2: Table access and modification await evalBlock( @@ -518,9 +507,9 @@ Deno.test("Thread local _CTX - advanced cases", async () => { `, env, ); - assertEquals(await evalExpr("checkAdmin()", env, sf), true); - assertEquals(await evalExpr("revokeAdmin()", env, sf), false); - assertEquals(threadLocal.get("permissions").get("admin"), false); + expect(await evalExpr("checkAdmin()", env, sf)).toEqual(true); + expect(await evalExpr("revokeAdmin()", env, sf)).toEqual(false); + expect(threadLocal.get("permissions").get("admin")).toEqual(false); // Test 3: Complex data structures await evalBlock( @@ -536,8 +525,8 @@ Deno.test("Thread local _CTX - advanced cases", async () => { `, env, ); - assertEquals(await evalExpr("getNestedData()", env, sf), "dark"); - assertEquals(await evalExpr("updateTheme('light')", env, sf), "light"); + expect(await evalExpr("getNestedData()", env, sf)).toEqual("dark"); + expect(await evalExpr("updateTheme('light')", env, sf)).toEqual("light"); // Test 4: Multiple thread locals const threadLocal2 = new LuaEnv(); @@ -554,8 +543,8 @@ Deno.test("Thread local _CTX - advanced cases", async () => { ); // Same function, different thread contexts - assertEquals(await evalExpr("getUser()", env, sf), "alice"); - assertEquals(await evalExpr("getUser()", env, sf2), "bob"); + expect(await evalExpr("getUser()", env, sf)).toEqual("alice"); + expect(await evalExpr("getUser()", env, sf2)).toEqual("bob"); // Test 5: Async operations with _CTX env.set( @@ -578,8 +567,8 @@ Deno.test("Thread local _CTX - advanced cases", async () => { env, ); - assertEquals(await evalExpr("asyncTest()", env, sf), "completed"); - assertEquals(threadLocal.get("status"), "completed"); + expect(await evalExpr("asyncTest()", env, sf)).toEqual("completed"); + expect(threadLocal.get("status")).toEqual("completed"); // Test 6: Error handling with _CTX await evalBlock( @@ -596,32 +585,30 @@ Deno.test("Thread local _CTX - advanced cases", async () => { env, ); - assertEquals(await evalExpr("errorTest()", env, sf), "caught"); - assertEquals(threadLocal.get("error"), "caught"); + expect(await evalExpr("errorTest()", env, sf)).toEqual("caught"); + expect(threadLocal.get("error")).toEqual("caught"); // Test string interpolation sf.threadLocal.setLocal("_GLOBAL", env); - assertEquals( + expect( await evalExpr( "spacelua.interpolate('Hello, ${globalEnv} and ${loc}!', {loc='local'})", env, sf, ), - "Hello, GLOBAL and local!", - ); + ).toEqual("Hello, GLOBAL and local!"); // Some more complex string interpolation with more complex lua expressions, with nested {} - assertEquals( + expect( await evalExpr( `spacelua.interpolate('Some JSON \${js.stringify(js.tojs({name="Pete"}))}!')`, env, sf, ), - `Some JSON {"name":"Pete"}!`, - ); + ).toEqual(`Some JSON {"name":"Pete"}!`); }); -Deno.test("Length: rawlen ignores __len", async () => { +test("Length: rawlen ignores __len", async () => { const env = new LuaEnv(luaBuildStandardEnv()); await evalBlock( @@ -634,6 +621,6 @@ Deno.test("Length: rawlen ignores __len", async () => { env, ); - assertEquals(env.get("a"), 99); - assertEquals(env.get("b"), 3); + expect(env.get("a")).toEqual(99); + expect(env.get("b")).toEqual(3); }); diff --git a/client/space_lua/lua.test.ts b/client/space_lua/lua.test.ts index 4f4ca82b..d178a68a 100644 --- a/client/space_lua/lua.test.ts +++ b/client/space_lua/lua.test.ts @@ -1,90 +1,92 @@ +import { expect, test } from "vitest"; import { parse } from "./parse.ts"; import { luaBuildStandardEnv } from "./stdlib.ts"; import { LuaEnv, LuaRuntimeError, LuaStackFrame } from "./runtime.ts"; import { evalStatement } from "./eval.ts"; -import { assert } from "@std/assert/assert"; +import { readFile } from "node:fs/promises"; import { fileURLToPath } from "node:url"; -Deno.test("[Lua] Core language", async () => { +test("[Lua] Core language", async () => { await runLuaTest("./language_core_test.lua"); }); -Deno.test("[Lua] Core language (labels and goto)", async () => { +test("[Lua] Core language (labels and goto)", async () => { await runLuaTest("./goto_test.lua"); }); -Deno.test("[Lua] Core language (length)", async () => { +test("[Lua] Core language (length)", async () => { await runLuaTest("./len_test.lua"); }); -Deno.test("[Lua] Core language (truthiness)", async () => { +test("[Lua] Core language (truthiness)", async () => { await runLuaTest("./truthiness_test.lua"); }); -Deno.test("[Lua] Core language (arithmetic)", async () => { +test("[Lua] Core language (arithmetic)", async () => { await runLuaTest("./arithmetic_test.lua"); }); -Deno.test("[Lua] Core language (metamethods)", async () => { +test("[Lua] Core language (metamethods)", async () => { await runLuaTest("./metamethods_test.lua"); }); -Deno.test("[Lua] Load tests", async () => { +test("[Lua] Load tests", async () => { await runLuaTest("./stdlib/load_test.lua"); }); -Deno.test("[Lua] Core language (length)", async () => { +test("[Lua] Core language (length)", async () => { await runLuaTest("./len_test.lua"); }); -Deno.test("[Lua] Format tests", async () => { +test("[Lua] Format tests", async () => { await runLuaTest("./stdlib/format_test.lua"); }); -Deno.test("[Lua] String to number tests", async () => { +test("[Lua] String to number tests", async () => { await runLuaTest("./tonumber_test.lua"); }); -Deno.test("[Lua] String tests", async () => { +test("[Lua] String tests", async () => { await runLuaTest("./stdlib/string_test.lua"); // await runLuaTest("./stdlib/string_test2.lua"); }); -Deno.test("[Lua] Space Lua tests", async () => { +test("[Lua] Space Lua tests", async () => { await runLuaTest("./stdlib/space_lua_test.lua"); }); -Deno.test("[Lua] OS tests", async () => { +test("[Lua] OS tests", async () => { await runLuaTest("./stdlib/os_test.lua"); }); -Deno.test("[Lua] Math tests", async () => { +test("[Lua] Math tests", async () => { await runLuaTest("./stdlib/math_test.lua"); }); -Deno.test("[Lua] JS tests", async () => { +test("[Lua] JS tests", async () => { await runLuaTest("./stdlib/js_test.lua"); }); -Deno.test("[Lua] Global functions tests", async () => { +test("[Lua] Global functions tests", async () => { await runLuaTest("./stdlib/global_test.lua"); }); -Deno.test("[Lua] Encoding functions tests", async () => { +test("[Lua] Encoding functions tests", async () => { await runLuaTest("./stdlib/encoding_test.lua"); }); -Deno.test("[Lua] Crypto functions tests", async () => { +test("[Lua] Crypto functions tests", async () => { await runLuaTest("./stdlib/crypto_test.lua"); }); -Deno.test("[Lua] Lume functions tests", async () => { +test("[Lua] Lume functions tests", async () => { await runLuaTest("./lume_test.lua"); }); async function runLuaTest(luaPath: string) { - const luaFile = await Deno.readTextFile( + const luaFile = await readFile( fileURLToPath(new URL(luaPath, import.meta.url)), + "utf-8" ); const chunk = parse(luaFile, {}); const env = new LuaEnv(luaBuildStandardEnv()); @@ -98,6 +100,6 @@ async function runLuaTest(luaPath: string) { } else { console.error(`Error evaluating script:`, e); } - assert(false); + expect(false).toBeTruthy(); } } diff --git a/client/space_lua/parse.test.ts b/client/space_lua/parse.test.ts index bd4ba299..d86ef465 100644 --- a/client/space_lua/parse.test.ts +++ b/client/space_lua/parse.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import { parse, parseExpressionString, stripLuaComments } from "./parse.ts"; import type { LuaNumberLiteral } from "./ast.ts"; -import { assertEquals } from "@std/assert/equals"; -Deno.test("Test Lua parser", () => { +test("Test Lua parser", () => { // Basic block test parse(` print("Hello, World!") @@ -109,7 +109,7 @@ Deno.test("Test Lua parser", () => { parse(`return 1, 2, 3`); }); -Deno.test("Test comment handling", () => { +test("Test comment handling", () => { const code = ` -- Single line comment --[[ Multi @@ -120,14 +120,14 @@ hello -- yo ]])`; const code2 = stripLuaComments(code); - assertEquals(code2.length, code.length); + expect(code2.length).toEqual(code.length); console.log(code2); console.log(stripLuaComments(`e([==[ --- Hello ]==])`)); }); -Deno.test("Test query parsing", () => { +test("Test query parsing", () => { parse( `_(query[[from p = index.tag("page") where p.name == "John" limit 10, 3]])`, ); @@ -138,30 +138,20 @@ Deno.test("Test query parsing", () => { parse(`_(query[[from p = index.tag("page") order by p.lastModified]])`); }); -Deno.test("Test numeric constant parsing", () => { +test("Test numeric constant parsing", () => { // Examples from Lua 5.4 Reference Manual, except hexadecimal constants with fractional part - assertEquals((parseExpressionString(`3`) as LuaNumberLiteral).value, 3); - assertEquals((parseExpressionString(`345`) as LuaNumberLiteral).value, 345); - assertEquals((parseExpressionString(`0xff`) as LuaNumberLiteral).value, 0xff); - assertEquals( - (parseExpressionString(`0xBEBADA`) as LuaNumberLiteral).value, - 0xBEBADA, + expect((parseExpressionString(`3`) as LuaNumberLiteral).value).toEqual(3); + expect((parseExpressionString(`345`) as LuaNumberLiteral).value).toEqual(345); + expect((parseExpressionString(`0xff`) as LuaNumberLiteral).value).toEqual(0xff); + expect((parseExpressionString(`0xBEBADA`) as LuaNumberLiteral).value).toEqual(0xBEBADA, ); - assertEquals((parseExpressionString(`3.0`) as LuaNumberLiteral).value, 3.0); - assertEquals( - (parseExpressionString(`3.1416`) as LuaNumberLiteral).value, - 3.1416, + expect((parseExpressionString(`3.0`) as LuaNumberLiteral).value).toEqual(3.0); + expect((parseExpressionString(`3.1416`) as LuaNumberLiteral).value).toEqual(3.1416, ); - assertEquals( - (parseExpressionString(`314.16e-2`) as LuaNumberLiteral).value, - 314.16e-2, + expect((parseExpressionString(`314.16e-2`) as LuaNumberLiteral).value).toEqual(314.16e-2, ); - assertEquals( - (parseExpressionString(`0.31416E1`) as LuaNumberLiteral).value, - 0.31416E1, + expect((parseExpressionString(`0.31416E1`) as LuaNumberLiteral).value).toEqual(0.31416E1, ); - assertEquals( - (parseExpressionString(`34e1`) as LuaNumberLiteral).value, - 34e1, + expect((parseExpressionString(`34e1`) as LuaNumberLiteral).value).toEqual(34e1, ); }); diff --git a/client/space_lua/query_collection.test.ts b/client/space_lua/query_collection.test.ts index 098b2db6..f1887ce3 100644 --- a/client/space_lua/query_collection.test.ts +++ b/client/space_lua/query_collection.test.ts @@ -1,9 +1,9 @@ +import { expect, test } from "vitest"; import { parseExpressionString } from "./parse.ts"; import { ArrayQueryCollection } from "./query_collection.ts"; import { LuaEnv, LuaNativeJSFunction, LuaStackFrame } from "./runtime.ts"; -import { assert, assertEquals } from "@std/assert"; -Deno.test("ArrayQueryCollection", async () => { +test("ArrayQueryCollection", async () => { const rootEnv = new LuaEnv(); rootEnv.setLocal( "build_name", @@ -26,7 +26,7 @@ Deno.test("ArrayQueryCollection", async () => { {}, // Default collation configuration, since the config API is unavailable ); // console.log(result); - assert(result.length === 2); + expect(result.length === 2).toBeTruthy(); // Test limit const result2 = await collection.query( @@ -37,8 +37,8 @@ Deno.test("ArrayQueryCollection", async () => { rootEnv, LuaStackFrame.lostFrame, ); - assert(result2.length === 1); - assert(result2[0].x === 1); + expect(result2.length === 1).toBeTruthy(); + expect(result2[0].x === 1).toBeTruthy(); // Test offset const result3 = await collection.query( @@ -50,8 +50,8 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, {}, ); - assert(result3.length === 2); - assert(result3[0].x === 2); + expect(result3.length === 2).toBeTruthy(); + expect(result3[0].x === 2).toBeTruthy(); // Test order by const result4 = await collection.query( @@ -63,10 +63,10 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, {}, ); - assert(result4.length === 3); - assert(result4[0].x === 1); - assert(result4[1].x === 2); - assert(result4[2].x === 3); + expect(result4.length === 3).toBeTruthy(); + expect(result4[0].x === 1).toBeTruthy(); + expect(result4[1].x === 2).toBeTruthy(); + expect(result4[2].x === 3).toBeTruthy(); // Test order by desc const result5 = await collection.query( @@ -78,10 +78,10 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, {}, ); - assert(result5.length === 3); - assert(result5[0].x === 3); - assert(result5[1].x === 2); - assert(result5[2].x === 1); + expect(result5.length === 3).toBeTruthy(); + expect(result5[0].x === 3).toBeTruthy(); + expect(result5[1].x === 2).toBeTruthy(); + expect(result5[2].x === 1).toBeTruthy(); // Test order by multiple fields const collection2 = new ArrayQueryCollection([ @@ -102,14 +102,14 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, {}, ); - assertEquals(result6[0].firstName, "John"); - assertEquals(result6[0].lastName, "Doe"); - assertEquals(result6[1].firstName, "Jane"); - assertEquals(result6[1].lastName, "Doe"); - assertEquals(result6[2].firstName, "Bob"); - assertEquals(result6[2].lastName, "Johnson"); - assertEquals(result6[3].firstName, "Alice"); - assertEquals(result6[3].lastName, "Johnson"); + expect(result6[0].firstName).toEqual("John"); + expect(result6[0].lastName).toEqual("Doe"); + expect(result6[1].firstName).toEqual("Jane"); + expect(result6[1].lastName).toEqual("Doe"); + expect(result6[2].firstName).toEqual("Bob"); + expect(result6[2].lastName).toEqual("Johnson"); + expect(result6[3].firstName).toEqual("Alice"); + expect(result6[3].lastName).toEqual("Johnson"); // Test select with expression const result8 = await collection2.query( @@ -121,10 +121,10 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, {}, ); - assertEquals(result8[0], "John Doe"); - assertEquals(result8[1], "Alice Johnson"); - assertEquals(result8[2], "Jane Doe"); - assertEquals(result8[3], "Bob Johnson"); + expect(result8[0]).toEqual("John Doe"); + expect(result8[1]).toEqual("Alice Johnson"); + expect(result8[2]).toEqual("Jane Doe"); + expect(result8[3]).toEqual("Bob Johnson"); // Test select with native function and implicit object variable const result9 = await collection2.query( @@ -135,10 +135,10 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, {}, ); - assertEquals(result9[0], "John Doe"); - assertEquals(result9[1], "Alice Johnson"); - assertEquals(result9[2], "Jane Doe"); - assertEquals(result9[3], "Bob Johnson"); + expect(result9[0]).toEqual("John Doe"); + expect(result9[1]).toEqual("Alice Johnson"); + expect(result9[2]).toEqual("Jane Doe"); + expect(result9[3]).toEqual("Bob Johnson"); // Test distinct const collectionWithDuplicates = new ArrayQueryCollection([ @@ -161,9 +161,9 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, {}, ); - assertEquals(distinctResult.length, 2); - assertEquals(distinctResult.includes("fruit"), true); - assertEquals(distinctResult.includes("vegetable"), true); + expect(distinctResult.length).toEqual(2); + expect(distinctResult.includes("fruit")).toEqual(true); + expect(distinctResult.includes("vegetable")).toEqual(true); // Test distinct with objects const distinctObjectsResult = await collectionWithDuplicates.query( @@ -178,7 +178,7 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, {}, ); - assertEquals(distinctObjectsResult.length, 4); + expect(distinctObjectsResult.length).toEqual(4); // Test string sorting (collation) with example from MDN const letterCollection = new ArrayQueryCollection([ @@ -198,10 +198,10 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, { enabled: false }, ); - assertEquals(resultCodepoint[0].letter, "Z"); - assertEquals(resultCodepoint[1].letter, "a"); - assertEquals(resultCodepoint[2].letter, "z"); - assertEquals(resultCodepoint[3].letter, "ä"); + expect(resultCodepoint[0].letter).toEqual("Z"); + expect(resultCodepoint[1].letter).toEqual("a"); + expect(resultCodepoint[2].letter).toEqual("z"); + expect(resultCodepoint[3].letter).toEqual("ä"); // Defaults for German const resultGerman = await letterCollection.query( @@ -213,10 +213,10 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, { enabled: true, locale: "de" }, ); - assertEquals(resultGerman[0].letter, "a"); - assertEquals(resultGerman[1].letter, "ä"); - assertEquals(resultGerman[2].letter, "z"); - assertEquals(resultGerman[3].letter, "Z"); + expect(resultGerman[0].letter).toEqual("a"); + expect(resultGerman[1].letter).toEqual("ä"); + expect(resultGerman[2].letter).toEqual("z"); + expect(resultGerman[3].letter).toEqual("Z"); // Defaults for Swedish const resultSwedish = await letterCollection.query( @@ -228,10 +228,10 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, { enabled: true, locale: "sv" }, ); - assertEquals(resultSwedish[0].letter, "a"); - assertEquals(resultSwedish[1].letter, "z"); - assertEquals(resultSwedish[2].letter, "Z"); - assertEquals(resultSwedish[3].letter, "ä"); + expect(resultSwedish[0].letter).toEqual("a"); + expect(resultSwedish[1].letter).toEqual("z"); + expect(resultSwedish[2].letter).toEqual("Z"); + expect(resultSwedish[3].letter).toEqual("ä"); // Uppercase first const resultUpper = await letterCollection.query( @@ -243,8 +243,8 @@ Deno.test("ArrayQueryCollection", async () => { LuaStackFrame.lostFrame, { enabled: true, locale: "de", options: { caseFirst: "upper" } }, ); - assertEquals(resultUpper[0].letter, "a"); - assertEquals(resultUpper[1].letter, "ä"); - assertEquals(resultUpper[2].letter, "Z"); - assertEquals(resultUpper[3].letter, "z"); + expect(resultUpper[0].letter).toEqual("a"); + expect(resultUpper[1].letter).toEqual("ä"); + expect(resultUpper[2].letter).toEqual("Z"); + expect(resultUpper[3].letter).toEqual("z"); }); diff --git a/client/space_lua/rp.bench.ts b/client/space_lua/rp.bench.ts index f254a77d..4bc2d6aa 100644 --- a/client/space_lua/rp.bench.ts +++ b/client/space_lua/rp.bench.ts @@ -1,3 +1,5 @@ +import { bench } from "vitest"; +import { readFile } from "node:fs/promises"; // Benchmark suite for Space Lua RP (Result-or-Promise) optimizations // that exercises hot synchronous paths (binary ops, loops, function // calls, argument lists, table get/set, concatenation). @@ -176,7 +178,7 @@ const luaTableDotMissRead = ` // The truthiness_test.lua uses the `string.format`. const truthinessPath = new URL("./truthiness_test.lua", import.meta.url).pathname; -const truthinessCode = await Deno.readTextFile(truthinessPath); +const truthinessCode = await readFile(truthinessPath, "utf-8"); const astWhileSync = parseLua(luaWhileSync); const astForNumeric = parseLua(luaForNumeric); @@ -191,78 +193,78 @@ const astTableDeepDotGetSet = parseLua(luaTableDeepDotGetSet); const astTableDotMissRead = parseLua(luaTableDotMissRead); const astTruthiness = parseLua(truthinessCode); -Deno.bench( +bench( { name: "RP: while (sync cond) numeric sum", group: "space-lua" }, async () => { await run(astWhileSync); }, ); -Deno.bench({ name: "RP: for (numeric) sum", group: "space-lua" }, async () => { +bench("RP: for (numeric) sum", async () => { await run(astForNumeric); }); -Deno.bench({ +bench({ name: "RP: while (function cond -> truthy then nil)", group: "space-lua", }, async () => { await run(astWhileFuncCondTruthy); }); -Deno.bench( +bench( { name: "RP: function calls + arg eval", group: "space-lua" }, async () => { await run(astFuncCallArgs); }, ); -Deno.bench({ name: "RP: table dot get/set", group: "space-lua" }, async () => { +bench("RP: table dot get/set", async () => { await run(astTableGetSet); }); -Deno.bench( +bench( { name: "RP: table numeric index get/set", group: "space-lua" }, async () => { await run(astTableIndexNumeric); }, ); -Deno.bench( +bench( { name: "RP: table deep dot get/set (3 levels)", group: "space-lua" }, async () => { await run(astTableDeepDotGetSet); }, ); -Deno.bench( +bench( { name: "RP: table dot miss (nil reads, no metatable)", group: "space-lua" }, async () => { await run(astTableDotMissRead); }, ); -Deno.bench( +bench( { name: "RP: string concatenation (..)", group: "space-lua" }, async () => { await run(astConcatStrings); }, ); -Deno.bench( +bench( { name: "RP: arithmetic (binary ops)", group: "space-lua" }, async () => { await run(astArithmeticBinary); }, ); -Deno.bench({ +bench({ name: "RP: while truthiness mix (0,'' ,{},...)", group: "space-lua", }, async () => { await run(astWhileTruthinessMix); }); -Deno.bench( +bench( { name: "RP: truthiness_test.lua (end-to-end)", group: "space-lua" }, async () => { await run(astTruthiness); diff --git a/client/space_lua/runtime.test.ts b/client/space_lua/runtime.test.ts index 9a857301..ac7c3f34 100644 --- a/client/space_lua/runtime.test.ts +++ b/client/space_lua/runtime.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "@std/assert/equals"; +import { expect, test } from "vitest"; import { jsToLuaValue, luaLen, @@ -7,51 +7,48 @@ import { luaToString, } from "./runtime.ts"; -Deno.test("Test Lua Rutime", async () => { +test("Test Lua Rutime", async () => { // Test LuaMultires - assertEquals(new LuaMultiRes([]).flatten().values, []); - assertEquals(new LuaMultiRes([1, 2, 3]).flatten().values, [1, 2, 3]); - assertEquals( - new LuaMultiRes([1, new LuaMultiRes([2, 3])]).flatten().values, - [ - 1, - 2, - 3, - ], - ); + expect(new LuaMultiRes([]).flatten().values).toEqual([]); + expect(new LuaMultiRes([1, 2, 3]).flatten().values).toEqual([1, 2, 3]); + expect(new LuaMultiRes([1, new LuaMultiRes([2, 3])]).flatten().values).toEqual([ + 1, + 2, + 3, + ]); // Test JavaScript to Lua conversion - assertEquals(jsToLuaValue(1), 1); - assertEquals(jsToLuaValue("hello"), "hello"); + expect(jsToLuaValue(1)).toEqual(1); + expect(jsToLuaValue("hello")).toEqual("hello"); // Arrays let luaVal = jsToLuaValue([1, 2, 3]); - assertEquals(luaLen(luaVal), 3); - assertEquals(luaVal.get(1), 1); + expect(luaLen(luaVal)).toEqual(3); + expect(luaVal.get(1)).toEqual(1); // Objects luaVal = jsToLuaValue({ name: "Pete", age: 10 }); - assertEquals(luaVal.get("name"), "Pete"); - assertEquals(luaVal.get("age"), 10); + expect(luaVal.get("name")).toEqual("Pete"); + expect(luaVal.get("age")).toEqual(10); // Nested objects luaVal = jsToLuaValue({ name: "Pete", list: [1, 2, 3] }); - assertEquals(luaVal.get("name"), "Pete"); - assertEquals(luaLen(luaVal.get("list")), 3); - assertEquals(luaVal.get("list").get(2), 2); + expect(luaVal.get("name")).toEqual("Pete"); + expect(luaLen(luaVal.get("list"))).toEqual(3); + expect(luaVal.get("list").get(2)).toEqual(2); luaVal = jsToLuaValue([{ name: "Pete" }, { name: "John" }]); - assertEquals(luaLen(luaVal), 2); - assertEquals(luaVal.get(1).get("name"), "Pete"); - assertEquals(luaVal.get(2).get("name"), "John"); + expect(luaLen(luaVal)).toEqual(2); + expect(luaVal.get(1).get("name")).toEqual("Pete"); + expect(luaVal.get(2).get("name")).toEqual("John"); // Functions in objects luaVal = jsToLuaValue({ name: "Pete", first: (l: any[]) => l[0] }); - assertEquals(luaVal.get("first").call(LuaStackFrame.lostFrame, [1, 2, 3]), 1); + expect(luaVal.get("first").call(LuaStackFrame.lostFrame, [1, 2, 3])).toEqual(1); // Test luaToString - assertEquals(await luaToString(new Promise((resolve) => resolve(1))), "1"); - assertEquals(await luaToString({ a: 1 }), "{a = 1}"); - assertEquals(await luaToString([{ a: 1 }]), "{{a = 1}}"); + expect(await luaToString(new Promise((resolve) => resolve(1)))).toEqual("1"); + expect(await luaToString({ a: 1 })).toEqual("{a = 1}"); + expect(await luaToString([{ a: 1 }])).toEqual("{{a = 1}}"); // Ensure simple cases are not returning promises - assertEquals(luaToString(10), "10"); + expect(luaToString(10)).toEqual("10"); // Test circular references const circular: any = {}; circular.self = circular; - assertEquals(await luaToString(circular), "{self = }"); + expect(await luaToString(circular)).toEqual("{self = }"); }); diff --git a/client/space_lua/util.test.ts b/client/space_lua/util.test.ts index a210e0ff..5a401d57 100644 --- a/client/space_lua/util.test.ts +++ b/client/space_lua/util.test.ts @@ -1,11 +1,10 @@ +import { expect, test } from "vitest"; import { evalPromiseValues } from "./util.ts"; -import { assertEquals } from "@std/assert/equals"; -import { assert } from "@std/assert"; -Deno.test("Test promise helpers", async () => { +test("Test promise helpers", async () => { const r = evalPromiseValues([1, 2, 3]); // should return the same array not as a promise - assertEquals(r, [1, 2, 3]); + expect(r).toEqual([1, 2, 3]); const asyncR = evalPromiseValues([ new Promise((resolve) => { setTimeout(() => { @@ -16,6 +15,6 @@ Deno.test("Test promise helpers", async () => { 3, ]); // should return a promise - assert(asyncR instanceof Promise); - assertEquals(await asyncR, [1, 2, 3]); + expect(asyncR instanceof Promise).toBeTruthy(); + expect(await asyncR).toEqual([1, 2, 3]); }); diff --git a/client/spaces/datastore_space_primitives.test.ts b/client/spaces/datastore_space_primitives.test.ts index 190ac2d6..41706d37 100644 --- a/client/spaces/datastore_space_primitives.test.ts +++ b/client/spaces/datastore_space_primitives.test.ts @@ -1,12 +1,10 @@ +import { expect, test } from "vitest"; import "fake-indexeddb/auto"; import { IndexedDBKvPrimitives } from "../data/indexeddb_kv_primitives.ts"; import { DataStoreSpacePrimitives } from "./datastore_space_primitives.ts"; import { testSpacePrimitives } from "./space_primitives.test.ts"; -Deno.test("DataStoreSpacePrimitives", { - sanitizeResources: false, - sanitizeOps: false, -}, async () => { +test("DataStoreSpacePrimitives", async () => { const db = new IndexedDBKvPrimitives("test"); await db.init(); diff --git a/client/spaces/datastore_space_primitives.ts b/client/spaces/datastore_space_primitives.ts index 7ea91905..2a393853 100644 --- a/client/spaces/datastore_space_primitives.ts +++ b/client/spaces/datastore_space_primitives.ts @@ -1,5 +1,5 @@ import type { SpacePrimitives } from "./space_primitives.ts"; -import { mime } from "mimetypes"; +import mime from "mime"; import type { FileMeta } from "@silverbulletmd/silverbullet/type/index"; import { notFoundError } from "@silverbulletmd/silverbullet/constants"; import type { KvPrimitives } from "../data/kv_primitives.ts"; diff --git a/client/spaces/space_primitives.test.ts b/client/spaces/space_primitives.test.ts index 740864e6..e1e0ff1c 100644 --- a/client/spaces/space_primitives.test.ts +++ b/client/spaces/space_primitives.test.ts @@ -1,4 +1,4 @@ -import { assert, assertEquals } from "@std/assert"; +import { expect } from "vitest"; import type { SpacePrimitives } from "./space_primitives.ts"; import type { FileMeta } from "@silverbulletmd/silverbullet/type/index"; import { notFoundError } from "@silverbulletmd/silverbullet/constants"; @@ -15,12 +15,12 @@ export async function testSpacePrimitives(spacePrimitives: SpacePrimitives) { // Ensure clean state at the end const finalFiles = await spacePrimitives.fetchFileList(); - assertEquals(finalFiles, []); + expect(finalFiles).toEqual([]); } async function testBasicOperations(spacePrimitives: SpacePrimitives) { const files = await spacePrimitives.fetchFileList(); - assertEquals(files, []); + expect(files).toEqual([]); // Write text file const fileMeta = await spacePrimitives.writeFile( @@ -39,45 +39,43 @@ async function testBasicOperations(spacePrimitives: SpacePrimitives) { const { data: retrievedData, meta: retrievedMeta } = await spacePrimitives .readFile("test.txt"); - assertEquals(retrievedData, stringToBytes("Hello World")); + expect(retrievedData).toEqual(stringToBytes("Hello World")); // Check that the meta data is persisted - assertEquals(retrievedMeta.lastModified, 20); + expect(retrievedMeta.lastModified).toEqual(20); const fbContent = (await spacePrimitives.readFile("test.txt")) .data; - assertEquals(new TextDecoder().decode(fbContent), "Hello World"); + expect(new TextDecoder().decode(fbContent)).toEqual("Hello World"); - assertEquals(await spacePrimitives.fetchFileList(), [fileMeta]); + expect(await spacePrimitives.fetchFileList()).toEqual([fileMeta]); // Write binary file const buf = new Uint8Array(1024 * 1024); buf.set([1, 2, 3, 4, 5]); await spacePrimitives.writeFile("test.bin", buf); const fileData = await spacePrimitives.readFile("test.bin"); - assertEquals(fileData.data.length, 1024 * 1024); - assertEquals((await spacePrimitives.fetchFileList()).length, 2); + expect(fileData.data.length).toEqual(1024 * 1024); + expect((await spacePrimitives.fetchFileList()).length).toEqual(2); await spacePrimitives.deleteFile("test.bin"); - assertEquals(await spacePrimitives.fetchFileList(), [fileMeta]); + expect(await spacePrimitives.fetchFileList()).toEqual([fileMeta]); // Clean up await spacePrimitives.deleteFile("test.txt"); - assertEquals(await spacePrimitives.fetchFileList(), []); + expect(await spacePrimitives.fetchFileList()).toEqual([]); // Test weird file names await spacePrimitives.writeFile("test+'s.txt", stringToBytes("Hello world!")); - assertEquals( - stringToBytes("Hello world!"), - (await spacePrimitives.readFile("test+'s.txt")).data, + expect(stringToBytes("Hello world!")).toEqual((await spacePrimitives.readFile("test+'s.txt")).data, ); await spacePrimitives.deleteFile("test+'s.txt"); // Check deletion of weird file file name try { await spacePrimitives.getFileMeta("test+'s.txt"); - assert(false); + expect(false).toBeTruthy(); } catch (e: any) { - assertEquals(e, notFoundError); + expect(e).toEqual(notFoundError); } } @@ -88,14 +86,14 @@ async function testFileOverwriting(spacePrimitives: SpacePrimitives) { await spacePrimitives.writeFile("overwrite.txt", stringToBytes("Updated")); const updatedData = await spacePrimitives.readFile("overwrite.txt"); - assertEquals(new TextDecoder().decode(updatedData.data), "Updated"); + expect(new TextDecoder().decode(updatedData.data)).toEqual("Updated"); // File list should still have only one entry for this file const filesAfterOverwrite = await spacePrimitives.fetchFileList(); const overwriteFiles = filesAfterOverwrite.filter((f) => f.name === "overwrite.txt" ); - assertEquals(overwriteFiles.length, 1); + expect(overwriteFiles.length).toEqual(1); await spacePrimitives.deleteFile("overwrite.txt"); } @@ -104,8 +102,8 @@ async function testEmptyFiles(spacePrimitives: SpacePrimitives) { // Test empty file await spacePrimitives.writeFile("empty.txt", new Uint8Array(0)); const emptyFile = await spacePrimitives.readFile("empty.txt"); - assertEquals(emptyFile.data.length, 0); - assertEquals(emptyFile.meta.size, 0); + expect(emptyFile.data.length).toEqual(0); + expect(emptyFile.meta.size).toEqual(0); await spacePrimitives.deleteFile("empty.txt"); } @@ -114,7 +112,7 @@ async function testUnicodeContent(spacePrimitives: SpacePrimitives) { const unicodeContent = "Hello 世界! 🌍 Здравствуй мир!"; await spacePrimitives.writeFile("unicode.txt", stringToBytes(unicodeContent)); const unicodeFile = await spacePrimitives.readFile("unicode.txt"); - assertEquals(new TextDecoder().decode(unicodeFile.data), unicodeContent); + expect(new TextDecoder().decode(unicodeFile.data)).toEqual(unicodeContent); await spacePrimitives.deleteFile("unicode.txt"); } @@ -136,9 +134,7 @@ async function testSpecialFileNames(spacePrimitives: SpacePrimitives) { stringToBytes(`Content of ${fileName}`), ); const fileData = await spacePrimitives.readFile(fileName); - assertEquals( - new TextDecoder().decode(fileData.data), - `Content of ${fileName}`, + expect(new TextDecoder().decode(fileData.data)).toEqual(`Content of ${fileName}`, ); } @@ -146,7 +142,7 @@ async function testSpecialFileNames(spacePrimitives: SpacePrimitives) { const allFiles = await spacePrimitives.fetchFileList(); for (const fileName of specialNames) { const found = allFiles.find((f) => f.name === fileName); - assert(found, `File ${fileName} should be in the file list`); + expect(found, `File ${fileName} should be in the file list`).toBeTruthy(); } // Clean up special files @@ -159,16 +155,16 @@ async function testErrorHandling(spacePrimitives: SpacePrimitives) { // Test error cases try { await spacePrimitives.readFile("nonexistent.txt"); - assert(false, "Should throw error for non-existent file"); + expect(false, "Should throw error for non-existent file").toBeTruthy(); } catch (e: any) { - assertEquals(e, notFoundError); + expect(e).toEqual(notFoundError); } try { await spacePrimitives.deleteFile("nonexistent.txt"); - assert(false, "Should throw error when deleting non-existent file"); + expect(false, "Should throw error when deleting non-existent file").toBeTruthy(); } catch (e: any) { - assertEquals(e, notFoundError); + expect(e).toEqual(notFoundError); } } @@ -181,12 +177,12 @@ async function testLargeFiles(spacePrimitives: SpacePrimitives) { await spacePrimitives.writeFile("large.bin", largeContent); const largeFile = await spacePrimitives.readFile("large.bin"); - assertEquals(largeFile.data.length, largeContent.length); - assertEquals(largeFile.meta.size, largeContent.length); + expect(largeFile.data.length).toEqual(largeContent.length); + expect(largeFile.meta.size).toEqual(largeContent.length); // Verify content integrity for (let i = 0; i < Math.min(1000, largeContent.length); i++) { - assertEquals(largeFile.data[i], largeContent[i]); + expect(largeFile.data[i]).toEqual(largeContent[i]); } await spacePrimitives.deleteFile("large.bin"); @@ -212,12 +208,12 @@ async function testMetadataPreservation(spacePrimitives: SpacePrimitives) { const metaFile = await spacePrimitives.readFile("meta-test.txt"); // Check that some metadata is preserved (implementations may handle timestamps differently) - assert( + expect( metaFile.meta.lastModified > 0, "LastModified timestamp should be set", - ); - assertEquals(metaFile.meta.name, "meta-test.txt"); - assertEquals(metaFile.meta.size, testContent.length); + ).toBeTruthy(); + expect(metaFile.meta.name).toEqual("meta-test.txt"); + expect(metaFile.meta.size).toEqual(testContent.length); await spacePrimitives.deleteFile("meta-test.txt"); } diff --git a/client/spaces/sync.test.ts b/client/spaces/sync.test.ts index 445d166f..d17bafd8 100644 --- a/client/spaces/sync.test.ts +++ b/client/spaces/sync.test.ts @@ -1,11 +1,11 @@ +import { expect, test } from "vitest"; import { SpaceSync, SyncSnapshot } from "./sync.ts"; -import { assertEquals } from "@std/assert"; import { sleep } from "@silverbulletmd/silverbullet/lib/async"; import { assert } from "node:console"; import { MemoryKvPrimitives } from "../data/memory_kv_primitives.ts"; import { DataStoreSpacePrimitives } from "./datastore_space_primitives.ts"; -Deno.test("Test sync with no filtering", async () => { +test("Test sync with no filtering", async () => { const primary = new DataStoreSpacePrimitives(new MemoryKvPrimitives()); const secondary = new DataStoreSpacePrimitives(new MemoryKvPrimitives()); const snapshot = new SyncSnapshot(); @@ -16,19 +16,17 @@ Deno.test("Test sync with no filtering", async () => { console.log("Write one page to primary"); await primary.writeFile("index.md", stringToBytes("Hello")); - assertEquals((await secondary.fetchFileList()).length, 0); + expect((await secondary.fetchFileList()).length).toEqual(0); console.log("Initial sync ops", await doSync()); - assertEquals((await secondary.fetchFileList()).length, 1); - assertEquals( - (await secondary.readFile("index.md")).data, - stringToBytes("Hello"), + expect((await secondary.fetchFileList()).length).toEqual(1); + expect((await secondary.readFile("index.md")).data).toEqual(stringToBytes("Hello"), ); // Should be a no-op let ops = await doSync(); - assertEquals(ops, 0); - assertEquals(snapshot.nonSyncedFiles.size, 0); + expect(ops).toEqual(0); + expect(snapshot.nonSyncedFiles.size).toEqual(0); // Now let's make a change on the secondary await secondary.writeFile("index.md", stringToBytes("Hello!!")); @@ -36,15 +34,13 @@ Deno.test("Test sync with no filtering", async () => { // And sync it ops = await doSync(); - assertEquals(ops, 2); - assertEquals(snapshot.nonSyncedFiles.size, 0); + expect(ops).toEqual(2); + expect(snapshot.nonSyncedFiles.size).toEqual(0); - assertEquals((await primary.fetchFileList()).length, 2); - assertEquals((await secondary.fetchFileList()).length, 2); + expect((await primary.fetchFileList()).length).toEqual(2); + expect((await secondary.fetchFileList()).length).toEqual(2); - assertEquals( - (await primary.readFile("index.md")).data, - stringToBytes("Hello!!"), + expect((await primary.readFile("index.md")).data).toEqual(stringToBytes("Hello!!"), ); // Let's make some random edits on both ends @@ -54,11 +50,11 @@ Deno.test("Test sync with no filtering", async () => { await secondary.writeFile("index4.md", stringToBytes("4")); await doSync(); - assertEquals((await primary.fetchFileList()).length, 5); - assertEquals((await secondary.fetchFileList()).length, 5); + expect((await primary.fetchFileList()).length).toEqual(5); + expect((await secondary.fetchFileList()).length).toEqual(5); ops = await doSync(); - assertEquals(ops, 0); + expect(ops).toEqual(0); console.log("Deleting pages"); // Delete some pages @@ -67,12 +63,12 @@ Deno.test("Test sync with no filtering", async () => { await doSync(); - assertEquals((await primary.fetchFileList()).length, 3); - assertEquals((await secondary.fetchFileList()).length, 3); + expect((await primary.fetchFileList()).length).toEqual(3); + expect((await secondary.fetchFileList()).length).toEqual(3); // No-op ops = await doSync(); - assertEquals(ops, 0); + expect(ops).toEqual(0); await secondary.deleteFile("index4.md"); await primary.deleteFile("index2.md"); @@ -80,20 +76,18 @@ Deno.test("Test sync with no filtering", async () => { await doSync(); // Just "test" left - assertEquals((await primary.fetchFileList()).length, 1); - assertEquals((await secondary.fetchFileList()).length, 1); + expect((await primary.fetchFileList()).length).toEqual(1); + expect((await secondary.fetchFileList()).length).toEqual(1); // No-op ops = await doSync(); - assertEquals(ops, 0); + expect(ops).toEqual(0); await secondary.writeFile("index.md", stringToBytes("I'm back")); await doSync(); - assertEquals( - (await primary.readFile("index.md")).data, - stringToBytes("I'm back"), + expect((await primary.readFile("index.md")).data).toEqual(stringToBytes("I'm back"), ); // Cause a conflict @@ -107,18 +101,14 @@ Deno.test("Test sync with no filtering", async () => { await doSync(); // Verify that primary won - assertEquals( - (await primary.readFile("index.md")).data, - stringToBytes("Hello 1"), + expect((await primary.readFile("index.md")).data).toEqual(stringToBytes("Hello 1"), ); - assertEquals( - (await secondary.readFile("index.md")).data, - stringToBytes("Hello 1"), + expect((await secondary.readFile("index.md")).data).toEqual(stringToBytes("Hello 1"), ); // test + index + index.conflicting copy - assertEquals((await primary.fetchFileList()).length, 3); - assertEquals((await secondary.fetchFileList()).length, 3); + expect((await primary.fetchFileList()).length).toEqual(3); + expect((await secondary.fetchFileList()).length).toEqual(3); // Introducing a fake conflict (same content, so not really conflicting) await primary.writeFile("index.md", stringToBytes("Hello 1")); @@ -128,7 +118,7 @@ Deno.test("Test sync with no filtering", async () => { await doSync(); // test + index + index.md + previous index.conflicting copy but nothing more - assertEquals((await primary.fetchFileList()).length, 3); + expect((await primary.fetchFileList()).length).toEqual(3); async function doSync() { await sleep(10); @@ -138,7 +128,7 @@ Deno.test("Test sync with no filtering", async () => { } }); -Deno.test("Test sync with filtering", async () => { +test("Test sync with filtering", async () => { const primary = new DataStoreSpacePrimitives(new MemoryKvPrimitives()); const secondary = new DataStoreSpacePrimitives(new MemoryKvPrimitives()); @@ -156,29 +146,27 @@ Deno.test("Test sync with filtering", async () => { "Write one non-sync file on the primary, which SHOULD sync to the secondary", ); await primary.writeFile("index.txt", stringToBytes("Hello")); - assertEquals((await secondary.fetchFileList()).length, 0); + expect((await secondary.fetchFileList()).length).toEqual(0); let ops = await doSync(); - assertEquals(ops, 1); + expect(ops).toEqual(1); // Note: this number should be 0 because the file DOES have a local representation so it's not technically non-synced - assertEquals(snapshot.nonSyncedFiles.size, 0); + expect(snapshot.nonSyncedFiles.size).toEqual(0); - assertEquals((await secondary.fetchFileList()).length, 1); - assertEquals( - (await secondary.readFile("index.txt")).data, - stringToBytes("Hello"), + expect((await secondary.fetchFileList()).length).toEqual(1); + expect((await secondary.readFile("index.txt")).data).toEqual(stringToBytes("Hello"), ); console.log("Updating on secondary"); await secondary.writeFile("index.txt", stringToBytes("Hello Updated")); ops = await doSync(); - assertEquals(ops, 1); - assertEquals(snapshot.nonSyncedFiles.size, 1); + expect(ops).toEqual(1); + expect(snapshot.nonSyncedFiles.size).toEqual(1); try { await primary.getFileMeta("index.md"); - assert( + expect( false, "Local file should have been deleted locally since it's out of date", - ); + ).toBeTruthy(); } catch { // Expected } @@ -186,34 +174,34 @@ Deno.test("Test sync with filtering", async () => { console.log("Deleting remote files"); await secondary.deleteFile("index.txt"); ops = await doSync(); - assertEquals(ops, 1); - assertEquals(snapshot.nonSyncedFiles.size, 0); + expect(ops).toEqual(1); + expect(snapshot.nonSyncedFiles.size).toEqual(0); console.log("Creating a remote non-synced file"); await secondary.writeFile("index2.txt", stringToBytes("Hello 2")); ops = await doSync(); - assertEquals(ops, 0); // No-op, metadata only - assertEquals(snapshot.nonSyncedFiles.size, 1); + expect(ops).toEqual(0); // No-op, metadata only + expect(snapshot.nonSyncedFiles.size).toEqual(1); ops = await doSync(); - assertEquals(ops, 0); // No-op, metadata only - assertEquals(snapshot.nonSyncedFiles.size, 1); + expect(ops).toEqual(0); // No-op, metadata only + expect(snapshot.nonSyncedFiles.size).toEqual(1); await primary.writeFile("index2.txt", stringToBytes("Hello local")); ops = await doSync(); - assertEquals(ops, 1); - assertEquals(snapshot.nonSyncedFiles.size, 0); + expect(ops).toEqual(1); + expect(snapshot.nonSyncedFiles.size).toEqual(0); console.log("Getting into a state with some synced and non-synced files"); await secondary.writeFile("index.md", stringToBytes("This will sync")); await secondary.writeFile("index.txt", stringToBytes("This will not sync")); await secondary.writeFile("index2.txt", stringToBytes("This will not sync")); ops = await doSync(); - assertEquals(ops, 2); - assertEquals(snapshot.nonSyncedFiles.size, 2); + expect(ops).toEqual(2); + expect(snapshot.nonSyncedFiles.size).toEqual(2); // Check file listings on both ends - assertEquals((await secondary.fetchFileList()).length, 3); - assertEquals((await primary.fetchFileList()).length, 1); + expect((await secondary.fetchFileList()).length).toEqual(3); + expect((await primary.fetchFileList()).length).toEqual(1); //////////// // Now let's start another sync session, but now wanting to sync everything @@ -229,9 +217,9 @@ Deno.test("Test sync with filtering", async () => { ops = await doSync(); // This should pull 2 files from remote to local - assertEquals(ops, 2); - assertEquals((await primary.fetchFileList()).length, 3); - assertEquals((await secondary.fetchFileList()).length, 3); + expect(ops).toEqual(2); + expect((await primary.fetchFileList()).length).toEqual(3); + expect((await secondary.fetchFileList()).length).toEqual(3); console.log("And now to syncing nothing"); sync = new SpaceSync( @@ -245,11 +233,11 @@ Deno.test("Test sync with filtering", async () => { ops = await doSync(); // This should delete 3 files from the primary - assertEquals(ops, 3); + expect(ops).toEqual(3); // Leaving nothing on primary - assertEquals((await primary.fetchFileList()).length, 0); + expect((await primary.fetchFileList()).length).toEqual(0); // And everything unchanged on secondary - assertEquals((await secondary.fetchFileList()).length, 3); + expect((await secondary.fetchFileList()).length).toEqual(3); // Ok, now we're going to sync everything again sync = new SpaceSync( @@ -262,9 +250,9 @@ Deno.test("Test sync with filtering", async () => { ); // await secondary. ops = await doSync(); - assertEquals(ops, 3); - assertEquals((await primary.fetchFileList()).length, 3); - assertEquals((await secondary.fetchFileList()).length, 3); + expect(ops).toEqual(3); + expect((await primary.fetchFileList()).length).toEqual(3); + expect((await secondary.fetchFileList()).length).toEqual(3); async function doSync() { await sleep(10); @@ -273,7 +261,7 @@ Deno.test("Test sync with filtering", async () => { } }); -Deno.test("Local push sync", async () => { +test("Local push sync", async () => { const primary = new DataStoreSpacePrimitives(new MemoryKvPrimitives()); const secondary = new DataStoreSpacePrimitives(new MemoryKvPrimitives()); const snapshot = new SyncSnapshot(); @@ -287,20 +275,18 @@ Deno.test("Local push sync", async () => { ); const operations = await sync.syncFiles(snapshot); - assertEquals(operations, 0); + expect(operations).toEqual(0); await primary.writeFile("index.md", stringToBytes("Hello")); - assertEquals(1, await sync.syncSingleFile("index.md", snapshot)); + expect(1).toEqual(await sync.syncSingleFile("index.md", snapshot)); - assertEquals( - (await secondary.readFile("index.md")).data, - stringToBytes("Hello"), + expect((await secondary.readFile("index.md")).data).toEqual(stringToBytes("Hello"), ); console.log("Let's write a new file on primary that is not a sync candidate"); await primary.writeFile("test.txt", stringToBytes("Hello")); - assertEquals(1, await sync.syncSingleFile("test.txt", snapshot)); - assertEquals(snapshot.nonSyncedFiles.size, 0); + expect(1).toEqual(await sync.syncSingleFile("test.txt", snapshot)); + expect(snapshot.nonSyncedFiles.size).toEqual(0); }); function stringToBytes(s: string): Uint8Array { diff --git a/deno.json b/deno.json index 02d45ede..3353f969 100644 --- a/deno.json +++ b/deno.json @@ -9,7 +9,8 @@ "checks": "deno task check && deno task lint && deno task test", "lint": "deno lint --fix", "fmt": "deno fmt", - "test": "deno test -A --fail-fast", + "test": "deno run -A npm:vitest run", + "test-deno-old": "deno test -A --fail-fast", "bench": "deno bench -A", "plugs": "deno run -A --no-lock build_plugs_libraries.ts" }, @@ -122,6 +123,8 @@ "idb": "npm:idb@8.0.3", "js-yaml": "npm:js-yaml@4.1.0", "mimetypes": "https://deno.land/x/mimetypes@v1.0.0/mod.ts", + "mime": "npm:mime@4.0.4", + "vitest": "npm:vitest@4.0.18", "preact": "npm:preact@10.28.2", "preact-feather": "npm:preact-feather@4.2.1", "preact-feather/types": "npm:preact-feather@4.2.1/dist/types", diff --git a/deno.lock b/deno.lock index 654f7d90..996f9960 100644 --- a/deno.lock +++ b/deno.lock @@ -829,10 +829,64 @@ "npm:gitignore-parser@0.0.2", "npm:idb@8.0.3", "npm:js-yaml@4.1.0", + "npm:mime@4.0.4", "npm:preact-feather@4.2.1", "npm:preact@10.28.2", "npm:style-mod@4.1.2", - "npm:turndown@7.2.2" - ] + "npm:turndown@7.2.2", + "npm:vitest@4.0.18" + ], + "packageJson": { + "dependencies": [ + "npm:@codemirror/autocomplete@6.20.0", + "npm:@codemirror/commands@6.10.1", + "npm:@codemirror/lang-css@6.3.1", + "npm:@codemirror/lang-html@6.4.11", + "npm:@codemirror/lang-javascript@6.2.4", + "npm:@codemirror/lang-markdown@6.5.0", + "npm:@codemirror/language@6.12.1", + "npm:@codemirror/legacy-modes@6.5.2", + "npm:@codemirror/lint@6.9.2", + "npm:@codemirror/search@6.6.0", + "npm:@codemirror/state@6.5.4", + "npm:@codemirror/view@6.39.11", + "npm:@joplin/turndown-plugin-gfm@1.0.64", + "npm:@lezer/common@1.5.0", + "npm:@lezer/css@1.3.0", + "npm:@lezer/highlight@1.2.3", + "npm:@lezer/html@1.3.13", + "npm:@lezer/javascript@1.5.4", + "npm:@lezer/lr@1.4.7", + "npm:@lezer/markdown@1.6.3", + "npm:@msgpack/msgpack@3.1.3", + "npm:@preact/preset-vite@^2.10.3", + "npm:@replit/codemirror-lang-nix@6.0.1", + "npm:@replit/codemirror-vim@6.3.0", + "npm:@types/node@22", + "npm:ajv@8.17.1", + "npm:commander@^14.0.3", + "npm:crelt@1.0.6", + "npm:esbuild@~0.27.3", + "npm:fake-indexeddb@6.0.1", + "npm:fast-diff@1.3.0", + "npm:fast-glob@^3.3.0", + "npm:fuse.js@7.1.0", + "npm:gitignore-parser@0.0.2", + "npm:idb@8.0.3", + "npm:js-yaml@4.1.0", + "npm:mime@4.1.0", + "npm:picomatch@4", + "npm:preact-feather@4.2.1", + "npm:preact@10.28.2", + "npm:react-icons@5.5.0", + "npm:sass@^1.97.3", + "npm:style-mod@4.1.2", + "npm:tsx@^4.19.0", + "npm:turndown@7.2.2", + "npm:typescript@^5.9.3", + "npm:vite@^7.3.1", + "npm:vitest@^4.0.18" + ] + } } } diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..722d4a92 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3569 @@ +{ + "name": "@silverbulletmd/silverbullet", + "version": "2.4.3", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@silverbulletmd/silverbullet", + "version": "2.4.3", + "dependencies": { + "@codemirror/autocomplete": "6.20.0", + "@codemirror/commands": "6.10.1", + "@codemirror/lang-css": "6.3.1", + "@codemirror/lang-html": "6.4.11", + "@codemirror/lang-javascript": "6.2.4", + "@codemirror/lang-markdown": "6.5.0", + "@codemirror/language": "6.12.1", + "@codemirror/legacy-modes": "6.5.2", + "@codemirror/lint": "6.9.2", + "@codemirror/search": "6.6.0", + "@codemirror/state": "6.5.4", + "@codemirror/view": "6.39.11", + "@joplin/turndown-plugin-gfm": "1.0.64", + "@lezer/common": "1.5.0", + "@lezer/css": "1.3.0", + "@lezer/highlight": "1.2.3", + "@lezer/html": "1.3.13", + "@lezer/javascript": "1.5.4", + "@lezer/lr": "1.4.7", + "@lezer/markdown": "1.6.3", + "@msgpack/msgpack": "3.1.3", + "@replit/codemirror-lang-nix": "6.0.1", + "@replit/codemirror-vim": "6.3.0", + "ajv": "8.17.1", + "commander": "^14.0.3", + "crelt": "1.0.6", + "esbuild": "^0.27.3", + "fast-diff": "1.3.0", + "fast-glob": "^3.3.3", + "fuse.js": "7.1.0", + "gitignore-parser": "0.0.2", + "idb": "8.0.3", + "js-yaml": "^4.1.1", + "mime": "4.1.0", + "picomatch": "^4.0.3", + "preact": "10.28.2", + "preact-feather": "4.2.1", + "react-icons": "5.5.0", + "sass": "^1.97.3", + "style-mod": "4.1.2", + "turndown": "7.2.2" + }, + "bin": { + "plug-compile": "dist/plug-compile.js" + }, + "devDependencies": { + "@preact/preset-vite": "^2.10.3", + "@types/gitignore-parser": "^0.0.3", + "@types/js-yaml": "^4.0.9", + "@types/node": "^22.0.0", + "@types/picomatch": "^4.0.2", + "@types/turndown": "^5.0.6", + "fake-indexeddb": "6.0.1", + "tsx": "^4.19.0", + "typescript": "^5.9.3", + "vite": "^7.3.1", + "vitest": "^4.0.18" + }, + "engines": { + "node": ">=24.0.0", + "npm": ">=10.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.0.tgz", + "integrity": "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.28.5", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.0.tgz", + "integrity": "sha512-T1NCJqT/j9+cn8fvkt7jtwbLBfLC/1y1c7NtCeXFRgzGTsafi68MRv8yzkYSapBnFA6L3U2VSc02ciDzoAJhJg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz", + "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.0", + "@babel/generator": "^7.29.0", + "@babel/helper-compilation-targets": "^7.28.6", + "@babel/helper-module-transforms": "^7.28.6", + "@babel/helpers": "^7.28.6", + "@babel/parser": "^7.29.0", + "@babel/template": "^7.28.6", + "@babel/traverse": "^7.29.0", + "@babel/types": "^7.29.0", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.1", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.1.tgz", + "integrity": "sha512-qsaF+9Qcm2Qv8SRIMMscAvG4O3lJ0F1GuMo5HR/Bp02LopNgnZBC/EkbevHFeGs4ls/oPz9v+Bsmzbkbe+0dUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.0", + "@babel/types": "^7.29.0", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-annotate-as-pure": { + "version": "7.27.3", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.27.3.tgz", + "integrity": "sha512-fXSwMQqitTGeHLBC08Eq5yXz2m37E4pJX1qAU1+2cNedz/ifv/bVXft90VeSav5nFO61EcNgwr0aJxbyPaWBPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.27.3" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.28.6.tgz", + "integrity": "sha512-JYtls3hqi15fcx5GaSNL7SCTJ2MNmjrkHXg4FSpOA/grxK8KwyZ5bubHsCq8FXCkua6xhuaaBit+3b7+VZRfcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.28.6", + "@babel/helper-validator-option": "^7.27.1", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.28.0.tgz", + "integrity": "sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.28.6.tgz", + "integrity": "sha512-l5XkZK7r7wa9LucGw9LwZyyCUscb4x37JWTPz7swwFE/0FMQAGpiWUZn8u9DzkSBWEcK25jmvubfpw2dnAMdbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.28.6", + "@babel/types": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.28.6.tgz", + "integrity": "sha512-67oXFAYr2cDLDVGLXTEABjdBJZ6drElUSI7WKp70NrpyISso3plG9SAGEF6y7zbha/wOzUByWWTJvEDVNIUGcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.28.6", + "@babel/helper-validator-identifier": "^7.28.5", + "@babel/traverse": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.28.6.tgz", + "integrity": "sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz", + "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.28.6.tgz", + "integrity": "sha512-xOBvwq86HHdB7WUDTfKfT/Vuxh7gElQ+Sfti2Cy6yIWNW05P8iUslOVcZ4/sKbE+/jQaukQAdz/gf3724kYdqw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.28.6", + "@babel/types": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.0.tgz", + "integrity": "sha512-IyDgFV5GeDUVX4YdF/3CPULtVGSXXMLh1xVIgdCgxApktqnQV0r7/8Nqthg+8YLGaAtdyIlo2qIdZrbCv4+7ww==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.0" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.28.6.tgz", + "integrity": "sha512-wgEmr06G6sIpqr8YDwA2dSRTE3bJ+V0IfpzfSY3Lfgd7YWOaAdlykvJi13ZKBt8cZHfgH1IXN+CL656W3uUa4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.28.6.tgz", + "integrity": "sha512-61bxqhiRfAACulXSLd/GxqmAedUSrRZIu/cbaT18T1CetkTmtDN15it7i80ru4DVqRK1WMxQhXs+Lf9kajm5Ow==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.3", + "@babel/helper-module-imports": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6", + "@babel/plugin-syntax-jsx": "^7.28.6", + "@babel/types": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-development": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.27.1.tgz", + "integrity": "sha512-ykDdF5yI4f1WrAolLqeF3hmYU12j9ntLQl/AOG1HAS21jxyg1Q0/J/tpREuYLfatGdGmXp/3yS0ZA76kOlVq9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/plugin-transform-react-jsx": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.28.6.tgz", + "integrity": "sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.28.6", + "@babel/parser": "^7.28.6", + "@babel/types": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.0.tgz", + "integrity": "sha512-4HPiQr0X7+waHfyXPZpWPfWL/J7dcN1mx9gL6WdQVMbPnF3+ZhSMs8tCxN7oHddJE9fhNE7+lxdnlyemKfJRuA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.0", + "@babel/generator": "^7.29.0", + "@babel/helper-globals": "^7.28.0", + "@babel/parser": "^7.29.0", + "@babel/template": "^7.28.6", + "@babel/types": "^7.29.0", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", + "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@codemirror/autocomplete": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.0.tgz", + "integrity": "sha512-bOwvTOIJcG5FVo5gUUupiwYh8MioPLQ4UcqbcRf7UQ98X90tCa9E1kZ3Z7tqwpZxYyOvh1YTYbmZE9RTfTp5hg==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0" + } + }, + "node_modules/@codemirror/commands": { + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.10.1.tgz", + "integrity": "sha512-uWDWFypNdQmz2y1LaNJzK7fL7TYKLeUAU0npEC685OKTF3KcQ2Vu3klIM78D7I6wGhktme0lh3CuQLv0ZCrD9Q==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.4.0", + "@codemirror/view": "^6.27.0", + "@lezer/common": "^1.1.0" + } + }, + "node_modules/@codemirror/lang-css": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.3.1.tgz", + "integrity": "sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@lezer/common": "^1.0.2", + "@lezer/css": "^1.1.7" + } + }, + "node_modules/@codemirror/lang-html": { + "version": "6.4.11", + "resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.4.11.tgz", + "integrity": "sha512-9NsXp7Nwp891pQchI7gPdTwBuSuT3K65NGTHWHNJ55HjYcHLllr0rbIZNdOzas9ztc1EUVBlHou85FFZS4BNnw==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/lang-css": "^6.0.0", + "@codemirror/lang-javascript": "^6.0.0", + "@codemirror/language": "^6.4.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0", + "@lezer/css": "^1.1.0", + "@lezer/html": "^1.3.12" + } + }, + "node_modules/@codemirror/lang-javascript": { + "version": "6.2.4", + "resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.4.tgz", + "integrity": "sha512-0WVmhp1QOqZ4Rt6GlVGwKJN3KW7Xh4H2q8ZZNGZaP6lRdxXJzmjm4FqvmOojVj6khWJHIb9sp7U/72W7xQgqAA==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.6.0", + "@codemirror/lint": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0", + "@lezer/javascript": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-markdown": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@codemirror/lang-markdown/-/lang-markdown-6.5.0.tgz", + "integrity": "sha512-0K40bZ35jpHya6FriukbgaleaqzBLZfOh7HuzqbMxBXkbYMJDxfF39c23xOgxFezR+3G+tR2/Mup+Xk865OMvw==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.7.1", + "@codemirror/lang-html": "^6.0.0", + "@codemirror/language": "^6.3.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "@lezer/common": "^1.2.1", + "@lezer/markdown": "^1.0.0" + } + }, + "node_modules/@codemirror/language": { + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.1.tgz", + "integrity": "sha512-Fa6xkSiuGKc8XC8Cn96T+TQHYj4ZZ7RdFmXA3i9xe/3hLHfwPZdM+dqfX0Cp0zQklBKhVD8Yzc8LS45rkqcwpQ==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.23.0", + "@lezer/common": "^1.5.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0", + "style-mod": "^4.0.0" + } + }, + "node_modules/@codemirror/legacy-modes": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/@codemirror/legacy-modes/-/legacy-modes-6.5.2.tgz", + "integrity": "sha512-/jJbwSTazlQEDOQw2FJ8LEEKVS72pU0lx6oM54kGpL8t/NJ2Jda3CZ4pcltiKTdqYSRk3ug1B3pil1gsjA6+8Q==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0" + } + }, + "node_modules/@codemirror/lint": { + "version": "6.9.2", + "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.2.tgz", + "integrity": "sha512-sv3DylBiIyi+xKwRCJAAsBZZZWo82shJ/RTMymLabAdtbkV5cSKwWDeCgtUq3v8flTaXS2y1kKkICuRYtUswyQ==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.35.0", + "crelt": "^1.0.5" + } + }, + "node_modules/@codemirror/search": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.6.0.tgz", + "integrity": "sha512-koFuNXcDvyyotWcgOnZGmY7LZqEOXZaaxD/j6n18TCLx2/9HieZJ5H6hs1g8FiRxBD0DNfs0nXn17g872RmYdw==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.37.0", + "crelt": "^1.0.5" + } + }, + "node_modules/@codemirror/state": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.5.4.tgz", + "integrity": "sha512-8y7xqG/hpB53l25CIoit9/ngxdfoG+fx+V3SHBrinnhOtLvKHRyAJJuHzkWrR4YXXLX8eXBsejgAAxHUOdW1yw==", + "license": "MIT", + "dependencies": { + "@marijn/find-cluster-break": "^1.0.0" + } + }, + "node_modules/@codemirror/view": { + "version": "6.39.11", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.39.11.tgz", + "integrity": "sha512-bWdeR8gWM87l4DB/kYSF9A+dVackzDb/V56Tq7QVrQ7rn86W0rgZFtlL3g3pem6AeGcb9NQNoy3ao4WpW4h5tQ==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.5.0", + "crelt": "^1.0.6", + "style-mod": "^4.1.0", + "w3c-keyname": "^2.2.4" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz", + "integrity": "sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.3.tgz", + "integrity": "sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.3.tgz", + "integrity": "sha512-YdghPYUmj/FX2SYKJ0OZxf+iaKgMsKHVPF1MAq/P8WirnSpCStzKJFjOjzsW0QQ7oIAiccHdcqjbHmJxRb/dmg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.3.tgz", + "integrity": "sha512-IN/0BNTkHtk8lkOM8JWAYFg4ORxBkZQf9zXiEOfERX/CzxW3Vg1ewAhU7QSWQpVIzTW+b8Xy+lGzdYXV6UZObQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.3.tgz", + "integrity": "sha512-Re491k7ByTVRy0t3EKWajdLIr0gz2kKKfzafkth4Q8A5n1xTHrkqZgLLjFEHVD+AXdUGgQMq+Godfq45mGpCKg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.3.tgz", + "integrity": "sha512-vHk/hA7/1AckjGzRqi6wbo+jaShzRowYip6rt6q7VYEDX4LEy1pZfDpdxCBnGtl+A5zq8iXDcyuxwtv3hNtHFg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.3.tgz", + "integrity": "sha512-ipTYM2fjt3kQAYOvo6vcxJx3nBYAzPjgTCk7QEgZG8AUO3ydUhvelmhrbOheMnGOlaSFUoHXB6un+A7q4ygY9w==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.3.tgz", + "integrity": "sha512-dDk0X87T7mI6U3K9VjWtHOXqwAMJBNN2r7bejDsc+j03SEjtD9HrOl8gVFByeM0aJksoUuUVU9TBaZa2rgj0oA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.3.tgz", + "integrity": "sha512-s6nPv2QkSupJwLYyfS+gwdirm0ukyTFNl3KTgZEAiJDd+iHZcbTPPcWCcRYH+WlNbwChgH2QkE9NSlNrMT8Gfw==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.3.tgz", + "integrity": "sha512-sZOuFz/xWnZ4KH3YfFrKCf1WyPZHakVzTiqji3WDc0BCl2kBwiJLCXpzLzUBLgmp4veFZdvN5ChW4Eq/8Fc2Fg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.3.tgz", + "integrity": "sha512-yGlQYjdxtLdh0a3jHjuwOrxQjOZYD/C9PfdbgJJF3TIZWnm/tMd/RcNiLngiu4iwcBAOezdnSLAwQDPqTmtTYg==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.3.tgz", + "integrity": "sha512-WO60Sn8ly3gtzhyjATDgieJNet/KqsDlX5nRC5Y3oTFcS1l0KWba+SEa9Ja1GfDqSF1z6hif/SkpQJbL63cgOA==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.3.tgz", + "integrity": "sha512-APsymYA6sGcZ4pD6k+UxbDjOFSvPWyZhjaiPyl/f79xKxwTnrn5QUnXR5prvetuaSMsb4jgeHewIDCIWljrSxw==", + "cpu": [ + "mips64el" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.3.tgz", + "integrity": "sha512-eizBnTeBefojtDb9nSh4vvVQ3V9Qf9Df01PfawPcRzJH4gFSgrObw+LveUyDoKU3kxi5+9RJTCWlj4FjYXVPEA==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.3.tgz", + "integrity": "sha512-3Emwh0r5wmfm3ssTWRQSyVhbOHvqegUDRd0WhmXKX2mkHJe1SFCMJhagUleMq+Uci34wLSipf8Lagt4LlpRFWQ==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.3.tgz", + "integrity": "sha512-pBHUx9LzXWBc7MFIEEL0yD/ZVtNgLytvx60gES28GcWMqil8ElCYR4kvbV2BDqsHOvVDRrOxGySBM9Fcv744hw==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.3.tgz", + "integrity": "sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.3.tgz", + "integrity": "sha512-sDpk0RgmTCR/5HguIZa9n9u+HVKf40fbEUt+iTzSnCaGvY9kFP0YKBWZtJaraonFnqef5SlJ8/TiPAxzyS+UoA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.3.tgz", + "integrity": "sha512-P14lFKJl/DdaE00LItAukUdZO5iqNH7+PjoBm+fLQjtxfcfFE20Xf5CrLsmZdq5LFFZzb5JMZ9grUwvtVYzjiA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.3.tgz", + "integrity": "sha512-AIcMP77AvirGbRl/UZFTq5hjXK+2wC7qFRGoHSDrZ5v5b8DK/GYpXW3CPRL53NkvDqb9D+alBiC/dV0Fb7eJcw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.3.tgz", + "integrity": "sha512-DnW2sRrBzA+YnE70LKqnM3P+z8vehfJWHXECbwBmH/CU51z6FiqTQTHFenPlHmo3a8UgpLyH3PT+87OViOh1AQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.3.tgz", + "integrity": "sha512-NinAEgr/etERPTsZJ7aEZQvvg/A6IsZG/LgZy+81wON2huV7SrK3e63dU0XhyZP4RKGyTm7aOgmQk0bGp0fy2g==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.3.tgz", + "integrity": "sha512-PanZ+nEz+eWoBJ8/f8HKxTTD172SKwdXebZ0ndd953gt1HRBbhMsaNqjTyYLGLPdoWHy4zLU7bDVJztF5f3BHA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.3.tgz", + "integrity": "sha512-B2t59lWWYrbRDw/tjiWOuzSsFh1Y/E95ofKz7rIVYSQkUYBjfSgf6oeYPNWHToFRr2zx52JKApIcAS/D5TUBnA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.3.tgz", + "integrity": "sha512-QLKSFeXNS8+tHW7tZpMtjlNb7HKau0QDpwm49u0vUp9y1WOF+PEzkU84y9GqYaAVW8aH8f3GcBck26jh54cX4Q==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.3.tgz", + "integrity": "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@joplin/turndown-plugin-gfm": { + "version": "1.0.64", + "resolved": "https://registry.npmjs.org/@joplin/turndown-plugin-gfm/-/turndown-plugin-gfm-1.0.64.tgz", + "integrity": "sha512-8GJ7f9OenE3zkSVII5B6qzIkvgF7C/a20gaASEjM6jWPLPJFFQ2nQ3Ou/kXH1mPUTs9dC9VYs8QXVPvZabKXBQ==", + "license": "MIT" + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@lezer/common": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.0.tgz", + "integrity": "sha512-PNGcolp9hr4PJdXR4ix7XtixDrClScvtSCYW3rQG106oVMOOI+jFb+0+J3mbeL/53g1Zd6s0kJzaw6Ri68GmAA==", + "license": "MIT" + }, + "node_modules/@lezer/css": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.0.tgz", + "integrity": "sha512-pBL7hup88KbI7hXnZV3PQsn43DHy6TWyzuyk2AO9UyoXcDltvIdqWKE1dLL/45JVZ+YZkHe1WVHqO6wugZZWcw==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.3.0" + } + }, + "node_modules/@lezer/highlight": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.3.tgz", + "integrity": "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.3.0" + } + }, + "node_modules/@lezer/html": { + "version": "1.3.13", + "resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.13.tgz", + "integrity": "sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/javascript": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.4.tgz", + "integrity": "sha512-vvYx3MhWqeZtGPwDStM2dwgljd5smolYD2lR2UyFcHfxbBQebqx8yjmFmxtJ/E6nN6u1D9srOiVWm3Rb4tmcUA==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.1.3", + "@lezer/lr": "^1.3.0" + } + }, + "node_modules/@lezer/lr": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.7.tgz", + "integrity": "sha512-wNIFWdSUfX9Jc6ePMzxSPVgTVB4EOfDIwLQLWASyiUdHKaMsiilj9bYiGkGQCKVodd0x6bgQCV207PILGFCF9Q==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.0.0" + } + }, + "node_modules/@lezer/markdown": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.6.3.tgz", + "integrity": "sha512-jpGm5Ps+XErS+xA4urw7ogEGkeZOahVQF21Z6oECF0sj+2liwZopd2+I8uH5I/vZsRuuze3OxBREIANLf6KKUw==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.5.0", + "@lezer/highlight": "^1.0.0" + } + }, + "node_modules/@marijn/find-cluster-break": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz", + "integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==", + "license": "MIT" + }, + "node_modules/@mixmark-io/domino": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@mixmark-io/domino/-/domino-2.2.0.tgz", + "integrity": "sha512-Y28PR25bHXUg88kCV7nivXrP2Nj2RueZ3/l/jdx6J9f8J4nsEGcgX0Qe6lt7Pa+J79+kPiJU3LguR6O/6zrLOw==", + "license": "BSD-2-Clause" + }, + "node_modules/@msgpack/msgpack": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@msgpack/msgpack/-/msgpack-3.1.3.tgz", + "integrity": "sha512-47XIizs9XZXvuJgoaJUIE2lFoID8ugvc0jzSHP+Ptfk8nTbnR8g788wv48N03Kx0UkAv559HWRQ3yzOgzlRNUA==", + "license": "ISC", + "engines": { + "node": ">= 18" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@parcel/watcher": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.6.tgz", + "integrity": "sha512-tmmZ3lQxAe/k/+rNnXQRawJ4NjxO2hqiOLTHvWchtGZULp4RyFeh6aU4XdOYBFe2KE1oShQTv4AblOs2iOrNnQ==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "dependencies": { + "detect-libc": "^2.0.3", + "is-glob": "^4.0.3", + "node-addon-api": "^7.0.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "@parcel/watcher-android-arm64": "2.5.6", + "@parcel/watcher-darwin-arm64": "2.5.6", + "@parcel/watcher-darwin-x64": "2.5.6", + "@parcel/watcher-freebsd-x64": "2.5.6", + "@parcel/watcher-linux-arm-glibc": "2.5.6", + "@parcel/watcher-linux-arm-musl": "2.5.6", + "@parcel/watcher-linux-arm64-glibc": "2.5.6", + "@parcel/watcher-linux-arm64-musl": "2.5.6", + "@parcel/watcher-linux-x64-glibc": "2.5.6", + "@parcel/watcher-linux-x64-musl": "2.5.6", + "@parcel/watcher-win32-arm64": "2.5.6", + "@parcel/watcher-win32-ia32": "2.5.6", + "@parcel/watcher-win32-x64": "2.5.6" + } + }, + "node_modules/@parcel/watcher-android-arm64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.6.tgz", + "integrity": "sha512-YQxSS34tPF/6ZG7r/Ih9xy+kP/WwediEUsqmtf0cuCV5TPPKw/PQHRhueUo6JdeFJaqV3pyjm0GdYjZotbRt/A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-arm64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.6.tgz", + "integrity": "sha512-Z2ZdrnwyXvvvdtRHLmM4knydIdU9adO3D4n/0cVipF3rRiwP+3/sfzpAwA/qKFL6i1ModaabkU7IbpeMBgiVEA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-x64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.6.tgz", + "integrity": "sha512-HgvOf3W9dhithcwOWX9uDZyn1lW9R+7tPZ4sug+NGrGIo4Rk1hAXLEbcH1TQSqxts0NYXXlOWqVpvS1SFS4fRg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-freebsd-x64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.6.tgz", + "integrity": "sha512-vJVi8yd/qzJxEKHkeemh7w3YAn6RJCtYlE4HPMoVnCpIXEzSrxErBW5SJBgKLbXU3WdIpkjBTeUNtyBVn8TRng==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-glibc": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.6.tgz", + "integrity": "sha512-9JiYfB6h6BgV50CCfasfLf/uvOcJskMSwcdH1PHH9rvS1IrNy8zad6IUVPVUfmXr+u+Km9IxcfMLzgdOudz9EQ==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-musl": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.6.tgz", + "integrity": "sha512-Ve3gUCG57nuUUSyjBq/MAM0CzArtuIOxsBdQ+ftz6ho8n7s1i9E1Nmk/xmP323r2YL0SONs1EuwqBp2u1k5fxg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-glibc": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.6.tgz", + "integrity": "sha512-f2g/DT3NhGPdBmMWYoxixqYr3v/UXcmLOYy16Bx0TM20Tchduwr4EaCbmxh1321TABqPGDpS8D/ggOTaljijOA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-musl": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.6.tgz", + "integrity": "sha512-qb6naMDGlbCwdhLj6hgoVKJl2odL34z2sqkC7Z6kzir8b5W65WYDpLB6R06KabvZdgoHI/zxke4b3zR0wAbDTA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-glibc": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.6.tgz", + "integrity": "sha512-kbT5wvNQlx7NaGjzPFu8nVIW1rWqV780O7ZtkjuWaPUgpv2NMFpjYERVi0UYj1msZNyCzGlaCWEtzc+exjMGbQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-musl": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.6.tgz", + "integrity": "sha512-1JRFeC+h7RdXwldHzTsmdtYR/Ku8SylLgTU/reMuqdVD7CtLwf0VR1FqeprZ0eHQkO0vqsbvFLXUmYm/uNKJBg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-arm64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.6.tgz", + "integrity": "sha512-3ukyebjc6eGlw9yRt678DxVF7rjXatWiHvTXqphZLvo7aC5NdEgFufVwjFfY51ijYEWpXbqF5jtrK275z52D4Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-ia32": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.6.tgz", + "integrity": "sha512-k35yLp1ZMwwee3Ez/pxBi5cf4AoBKYXj00CZ80jUz5h8prpiaQsiRPKQMxoLstNuqe2vR4RNPEAEcjEFzhEz/g==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-x64": { + "version": "2.5.6", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.6.tgz", + "integrity": "sha512-hbQlYcCq5dlAX9Qx+kFb0FHue6vbjlf0FrNzSKdYK2APUf7tGfGxQCk2ihEREmbR6ZMc0MVAD5RIX/41gpUzTw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@preact/preset-vite": { + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/@preact/preset-vite/-/preset-vite-2.10.3.tgz", + "integrity": "sha512-1SiS+vFItpkNdBs7q585PSAIln0wBeBdcpJYbzPs1qipsb/FssnkUioNXuRsb8ZnU8YEQHr+3v8+/mzWSnTQmg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/plugin-transform-react-jsx": "^7.27.1", + "@babel/plugin-transform-react-jsx-development": "^7.27.1", + "@prefresh/vite": "^2.4.11", + "@rollup/pluginutils": "^5.0.0", + "babel-plugin-transform-hook-names": "^1.0.2", + "debug": "^4.4.3", + "picocolors": "^1.1.1", + "vite-prerender-plugin": "^0.5.8" + }, + "peerDependencies": { + "@babel/core": "7.x", + "vite": "2.x || 3.x || 4.x || 5.x || 6.x || 7.x" + } + }, + "node_modules/@prefresh/babel-plugin": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@prefresh/babel-plugin/-/babel-plugin-0.5.2.tgz", + "integrity": "sha512-AOl4HG6dAxWkJ5ndPHBgBa49oo/9bOiJuRDKHLSTyH+Fd9x00shTXpdiTj1W41l6oQIwUOAgJeHMn4QwIDpHkA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@prefresh/core": { + "version": "1.5.9", + "resolved": "https://registry.npmjs.org/@prefresh/core/-/core-1.5.9.tgz", + "integrity": "sha512-IKBKCPaz34OFVC+adiQ2qaTF5qdztO2/4ZPf4KsRTgjKosWqxVXmEbxCiUydYZRY8GVie+DQlKzQr9gt6HQ+EQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "preact": "^10.0.0 || ^11.0.0-0" + } + }, + "node_modules/@prefresh/utils": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@prefresh/utils/-/utils-1.2.1.tgz", + "integrity": "sha512-vq/sIuN5nYfYzvyayXI4C2QkprfNaHUQ9ZX+3xLD8nL3rWyzpxOm1+K7RtMbhd+66QcaISViK7amjnheQ/4WZw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@prefresh/vite": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/@prefresh/vite/-/vite-2.4.11.tgz", + "integrity": "sha512-/XjURQqdRiCG3NpMmWqE9kJwrg9IchIOWHzulCfqg2sRe/8oQ1g5De7xrk9lbqPIQLn7ntBkKdqWXIj4E9YXyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.22.1", + "@prefresh/babel-plugin": "0.5.2", + "@prefresh/core": "^1.5.0", + "@prefresh/utils": "^1.2.0", + "@rollup/pluginutils": "^4.2.1" + }, + "peerDependencies": { + "preact": "^10.4.0 || ^11.0.0-0", + "vite": ">=2.0.0" + } + }, + "node_modules/@prefresh/vite/node_modules/@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/@prefresh/vite/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@replit/codemirror-lang-nix": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@replit/codemirror-lang-nix/-/codemirror-lang-nix-6.0.1.tgz", + "integrity": "sha512-lvzjoYn9nfJzBD5qdm3Ut6G3+Or2wEacYIDJ49h9+19WSChVnxv4ojf+rNmQ78ncuxIt/bfbMvDLMeMP0xze6g==", + "license": "MIT", + "peerDependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "@lezer/common": "^1.0.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@replit/codemirror-vim": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@replit/codemirror-vim/-/codemirror-vim-6.3.0.tgz", + "integrity": "sha512-aTx931ULAMuJx6xLf7KQDOL7CxD+Sa05FktTDrtLaSy53uj01ll3Zf17JdKsriER248oS55GBzg0CfCTjEneAQ==", + "license": "MIT", + "peerDependencies": { + "@codemirror/commands": "6.x.x", + "@codemirror/language": "6.x.x", + "@codemirror/search": "6.x.x", + "@codemirror/state": "6.x.x", + "@codemirror/view": "6.x.x" + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.3.0.tgz", + "integrity": "sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.57.1.tgz", + "integrity": "sha512-A6ehUVSiSaaliTxai040ZpZ2zTevHYbvu/lDoeAteHI8QnaosIzm4qwtezfRg1jOYaUmnzLX1AOD6Z+UJjtifg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.57.1.tgz", + "integrity": "sha512-dQaAddCY9YgkFHZcFNS/606Exo8vcLHwArFZ7vxXq4rigo2bb494/xKMMwRRQW6ug7Js6yXmBZhSBRuBvCCQ3w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.57.1.tgz", + "integrity": "sha512-crNPrwJOrRxagUYeMn/DZwqN88SDmwaJ8Cvi/TN1HnWBU7GwknckyosC2gd0IqYRsHDEnXf328o9/HC6OkPgOg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.57.1.tgz", + "integrity": "sha512-Ji8g8ChVbKrhFtig5QBV7iMaJrGtpHelkB3lsaKzadFBe58gmjfGXAOfI5FV0lYMH8wiqsxKQ1C9B0YTRXVy4w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.57.1.tgz", + "integrity": "sha512-R+/WwhsjmwodAcz65guCGFRkMb4gKWTcIeLy60JJQbXrJ97BOXHxnkPFrP+YwFlaS0m+uWJTstrUA9o+UchFug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.57.1.tgz", + "integrity": "sha512-IEQTCHeiTOnAUC3IDQdzRAGj3jOAYNr9kBguI7MQAAZK3caezRrg0GxAb6Hchg4lxdZEI5Oq3iov/w/hnFWY9Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.57.1.tgz", + "integrity": "sha512-F8sWbhZ7tyuEfsmOxwc2giKDQzN3+kuBLPwwZGyVkLlKGdV1nvnNwYD0fKQ8+XS6hp9nY7B+ZeK01EBUE7aHaw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.57.1.tgz", + "integrity": "sha512-rGfNUfn0GIeXtBP1wL5MnzSj98+PZe/AXaGBCRmT0ts80lU5CATYGxXukeTX39XBKsxzFpEeK+Mrp9faXOlmrw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.57.1.tgz", + "integrity": "sha512-MMtej3YHWeg/0klK2Qodf3yrNzz6CGjo2UntLvk2RSPlhzgLvYEB3frRvbEF2wRKh1Z2fDIg9KRPe1fawv7C+g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.57.1.tgz", + "integrity": "sha512-1a/qhaaOXhqXGpMFMET9VqwZakkljWHLmZOX48R0I/YLbhdxr1m4gtG1Hq7++VhVUmf+L3sTAf9op4JlhQ5u1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.57.1.tgz", + "integrity": "sha512-QWO6RQTZ/cqYtJMtxhkRkidoNGXc7ERPbZN7dVW5SdURuLeVU7lwKMpo18XdcmpWYd0qsP1bwKPf7DNSUinhvA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.57.1.tgz", + "integrity": "sha512-xpObYIf+8gprgWaPP32xiN5RVTi/s5FCR+XMXSKmhfoJjrpRAjCuuqQXyxUa/eJTdAE6eJ+KDKaoEqjZQxh3Gw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.57.1.tgz", + "integrity": "sha512-4BrCgrpZo4hvzMDKRqEaW1zeecScDCR+2nZ86ATLhAoJ5FQ+lbHVD3ttKe74/c7tNT9c6F2viwB3ufwp01Oh2w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.57.1.tgz", + "integrity": "sha512-NOlUuzesGauESAyEYFSe3QTUguL+lvrN1HtwEEsU2rOwdUDeTMJdO5dUYl/2hKf9jWydJrO9OL/XSSf65R5+Xw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.57.1.tgz", + "integrity": "sha512-ptA88htVp0AwUUqhVghwDIKlvJMD/fmL/wrQj99PRHFRAG6Z5nbWoWG4o81Nt9FT+IuqUQi+L31ZKAFeJ5Is+A==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.57.1.tgz", + "integrity": "sha512-S51t7aMMTNdmAMPpBg7OOsTdn4tySRQvklmL3RpDRyknk87+Sp3xaumlatU+ppQ+5raY7sSTcC2beGgvhENfuw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.57.1.tgz", + "integrity": "sha512-Bl00OFnVFkL82FHbEqy3k5CUCKH6OEJL54KCyx2oqsmZnFTR8IoNqBF+mjQVcRCT5sB6yOvK8A37LNm/kPJiZg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.57.1.tgz", + "integrity": "sha512-ABca4ceT4N+Tv/GtotnWAeXZUZuM/9AQyCyKYyKnpk4yoA7QIAuBt6Hkgpw8kActYlew2mvckXkvx0FfoInnLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.57.1.tgz", + "integrity": "sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.57.1.tgz", + "integrity": "sha512-H+hXEv9gdVQuDTgnqD+SQffoWoc0Of59AStSzTEj/feWTBAnSfSD3+Dql1ZruJQxmykT/JVY0dE8Ka7z0DH1hw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.57.1.tgz", + "integrity": "sha512-4wYoDpNg6o/oPximyc/NG+mYUejZrCU2q+2w6YZqrAs2UcNUChIZXjtafAiiZSUc7On8v5NyNj34Kzj/Ltk6dQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.57.1.tgz", + "integrity": "sha512-O54mtsV/6LW3P8qdTcamQmuC990HDfR71lo44oZMZlXU4tzLrbvTii87Ni9opq60ds0YzuAlEr/GNwuNluZyMQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.57.1.tgz", + "integrity": "sha512-P3dLS+IerxCT/7D2q2FYcRdWRl22dNbrbBEtxdWhXrfIMPP9lQhb5h4Du04mdl5Woq05jVCDPCMF7Ub0NAjIew==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.57.1.tgz", + "integrity": "sha512-VMBH2eOOaKGtIJYleXsi2B8CPVADrh+TyNxJ4mWPnKfLB/DBUmzW+5m1xUrcwWoMfSLagIRpjUFeW5CO5hyciQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.57.1.tgz", + "integrity": "sha512-mxRFDdHIWRxg3UfIIAwCm6NzvxG0jDX/wBN6KsQFTvKFqqg9vTrWUE68qEjHt19A5wwx5X5aUi2zuZT7YR0jrA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/gitignore-parser": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@types/gitignore-parser/-/gitignore-parser-0.0.3.tgz", + "integrity": "sha512-sbdu1sG2pQcwjEYWTsX78OqJo5pKnonwC4FV3m2JeQRE2xYb3q0icHHopCHEvpn4uIBuvWBTpJUCJ76ISK24CA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/js-yaml": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz", + "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.19.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.11.tgz", + "integrity": "sha512-BH7YwL6rA93ReqeQS1c4bsPpcfOmJasG+Fkr6Y59q83f9M1WcBRHR2vM+P9eOisYRcN3ujQoiZY8uk5W+1WL8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-qHHxQ+P9PysNEGbALT8f8YOSHW0KJu6l2xU8DYY0fu/EmGxXdVnuTLvFUvBgPJMSqXq29SYHveejeAha+4AYgA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/turndown": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@types/turndown/-/turndown-5.0.6.tgz", + "integrity": "sha512-ru00MoyeeouE5BX4gRL+6m/BsDfbRayOskWqUvh7CLGW+UXxHQItqALa38kKnOiZPqJrtzJUgAC2+F0rL1S4Pg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@vitest/expect": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.18.tgz", + "integrity": "sha512-8sCWUyckXXYvx4opfzVY03EOiYVxyNrHS5QxX3DAIi5dpJAAkyJezHCP77VMX4HKA2LDT/Jpfo8i2r5BE3GnQQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.0.0", + "@types/chai": "^5.2.2", + "@vitest/spy": "4.0.18", + "@vitest/utils": "4.0.18", + "chai": "^6.2.1", + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.18.tgz", + "integrity": "sha512-HhVd0MDnzzsgevnOWCBj5Otnzobjy5wLBe4EdeeFGv8luMsGcYqDuFRMcttKWZA5vVO8RFjexVovXvAM4JoJDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "4.0.18", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.21" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^6.0.0 || ^7.0.0-0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/mocker/node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/@vitest/pretty-format": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.18.tgz", + "integrity": "sha512-P24GK3GulZWC5tz87ux0m8OADrQIUVDPIjjj65vBXYG17ZeU3qD7r+MNZ1RNv4l8CGU2vtTRqixrOi9fYk/yKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.18.tgz", + "integrity": "sha512-rpk9y12PGa22Jg6g5M3UVVnTS7+zycIGk9ZNGN+m6tZHKQb7jrP7/77WfZy13Y/EUDd52NDsLRQhYKtv7XfPQw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "4.0.18", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.18.tgz", + "integrity": "sha512-PCiV0rcl7jKQjbgYqjtakly6T1uwv/5BQ9SwBLekVg/EaYeQFPiXcgrC2Y7vDMA8dM1SUEAEV82kgSQIlXNMvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.0.18", + "magic-string": "^0.30.21", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.18.tgz", + "integrity": "sha512-cbQt3PTSD7P2OARdVW3qWER5EGq7PHlvE+QfzSC0lbwO+xnt7+XH06ZzFjFRgzUX//JmpxrCu92VdwvEPlWSNw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.18.tgz", + "integrity": "sha512-msMRKLMVLWygpK3u2Hybgi4MNjcYJvwTb0Ru09+fOyCXIgT5raYP041DRRdiJiI3k/2U6SEbAETB3YtBrUkCFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.0.18", + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "license": "Python-2.0" + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/babel-plugin-transform-hook-names": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-hook-names/-/babel-plugin-transform-hook-names-1.0.2.tgz", + "integrity": "sha512-5gafyjyyBTTdX/tQQ0hRgu4AhNHG/hqWi0ZZmg2xvs2FgRkJXzDNKBZCyoYqgFkovfDrgM8OoKg8karoUvWeCw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@babel/core": "^7.12.10" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.9.19", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.19.tgz", + "integrity": "sha512-ipDqC8FrAl/76p2SSWKSI+H9tFwm7vYqXQrItCuiVPt26Km0jS+NzSsBWAaBusvSbQcfJG+JitdMm+wZAgTYqg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.js" + } + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true, + "license": "ISC" + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.1.tgz", + "integrity": "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.9.0", + "caniuse-lite": "^1.0.30001759", + "electron-to-chromium": "^1.5.263", + "node-releases": "^2.0.27", + "update-browserslist-db": "^1.2.0" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001769", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001769.tgz", + "integrity": "sha512-BCfFL1sHijQlBGWBMuJyhZUhzo7wer5sVj9hqekB/7xn0Ypy+pER/edCYQm4exbXj4WiySGp40P8UuTh6w1srg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/chai": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", + "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/commander": { + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.3.tgz", + "integrity": "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==", + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/crelt": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz", + "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==", + "license": "MIT" + }, + "node_modules/css-select": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.2.2.tgz", + "integrity": "sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-what": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.2.2.tgz", + "integrity": "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "optional": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "BSD-2-Clause" + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", + "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.286", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.286.tgz", + "integrity": "sha512-9tfDXhJ4RKFNerfjdCcZfufu49vg620741MNs26a9+bhLThdB+plgMeou98CAaHu/WATj2iHOOHTp1hWtABj2A==", + "dev": true, + "license": "ISC" + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-module-lexer": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.3.tgz", + "integrity": "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==", + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.3", + "@esbuild/android-arm": "0.27.3", + "@esbuild/android-arm64": "0.27.3", + "@esbuild/android-x64": "0.27.3", + "@esbuild/darwin-arm64": "0.27.3", + "@esbuild/darwin-x64": "0.27.3", + "@esbuild/freebsd-arm64": "0.27.3", + "@esbuild/freebsd-x64": "0.27.3", + "@esbuild/linux-arm": "0.27.3", + "@esbuild/linux-arm64": "0.27.3", + "@esbuild/linux-ia32": "0.27.3", + "@esbuild/linux-loong64": "0.27.3", + "@esbuild/linux-mips64el": "0.27.3", + "@esbuild/linux-ppc64": "0.27.3", + "@esbuild/linux-riscv64": "0.27.3", + "@esbuild/linux-s390x": "0.27.3", + "@esbuild/linux-x64": "0.27.3", + "@esbuild/netbsd-arm64": "0.27.3", + "@esbuild/netbsd-x64": "0.27.3", + "@esbuild/openbsd-arm64": "0.27.3", + "@esbuild/openbsd-x64": "0.27.3", + "@esbuild/openharmony-arm64": "0.27.3", + "@esbuild/sunos-x64": "0.27.3", + "@esbuild/win32-arm64": "0.27.3", + "@esbuild/win32-ia32": "0.27.3", + "@esbuild/win32-x64": "0.27.3" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/expect-type": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", + "integrity": "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fake-indexeddb": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fake-indexeddb/-/fake-indexeddb-6.0.1.tgz", + "integrity": "sha512-He2AjQGHe46svIFq5+L2Nx/eHDTI1oKgoevBP+TthnjymXiKkeJQ3+ITeWey99Y5+2OaPFbI1qEsx/5RsGtWnQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT" + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "license": "Apache-2.0" + }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz", + "integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/fastq": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz", + "integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==", + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/fuse.js": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.1.0.tgz", + "integrity": "sha512-trLf4SzuuUxfusZADLINj+dE8clK1frKdmqiJNb1Es75fmI5oY6X2mxLVUciLLjxqw/xr72Dhy+lER6dGd02FQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=10" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-tsconfig": { + "version": "4.13.6", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.6.tgz", + "integrity": "sha512-shZT/QMiSHc/YBLxxOkMtgSid5HFoauqCE3/exfsEcwg1WkeqjG+V40yBbBrsD+jW2HDXcs28xOfcbm2jI8Ddw==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/gitignore-parser": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/gitignore-parser/-/gitignore-parser-0.0.2.tgz", + "integrity": "sha512-X6mpqUv59uWLGD4n3hZ8Cu8KbF2PMWPSFYmxZjdkpm3yOU7hSUYnzTkZI1mcWqchphvqyuz3/BhgBR4E/JtkCg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "license": "MIT", + "bin": { + "he": "bin/he" + } + }, + "node_modules/idb": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/idb/-/idb-8.0.3.tgz", + "integrity": "sha512-LtwtVyVYO5BqRvcsKuB2iUMnHwPVByPCXFXOpuU96IZPPoPN6xjOGxZQ74pgSVVLQWtUOYgyeL4GE98BY5D3wg==", + "license": "ISC" + }, + "node_modules/immutable": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.4.tgz", + "integrity": "sha512-p6u1bG3YSnINT5RQmx/yRZBpenIl30kVxkTLDyHLIMk0gict704Q9n+thfDI7lTRm9vXdDYutVzXhzcThxTnXA==", + "license": "MIT" + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "license": "MIT" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/kolorist": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/kolorist/-/kolorist-1.8.0.tgz", + "integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/mime": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-4.1.0.tgz", + "integrity": "sha512-X5ju04+cAzsojXKes0B/S4tcYtFAJ6tTMuSPBEn9CPGlrWr8Fiw7qYeLT0XyH80HSoAoqWCaz+MWKh22P7G1cw==", + "funding": [ + "https://github.com/sponsors/broofa" + ], + "license": "MIT", + "bin": { + "mime": "bin/cli.js" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-addon-api": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", + "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", + "license": "MIT", + "optional": true + }, + "node_modules/node-html-parser": { + "version": "6.1.13", + "resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-6.1.13.tgz", + "integrity": "sha512-qIsTMOY4C/dAa5Q5vsobRpOOvPfC4pB61UVW2uSwZNUp0QU/jCekTal1vMmbO0DgdHeLUJpv/ARmDqErVxA3Sg==", + "dev": true, + "license": "MIT", + "dependencies": { + "css-select": "^5.1.0", + "he": "1.2.0" + } + }, + "node_modules/node-releases": { + "version": "2.0.27", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.27.tgz", + "integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, + "node_modules/obug": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz", + "integrity": "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT" + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/preact": { + "version": "10.28.2", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.28.2.tgz", + "integrity": "sha512-lbteaWGzGHdlIuiJ0l2Jq454m6kcpI1zNje6d8MlGAFlYvP2GO4ibnat7P74Esfz4sPTdM6UxtTwh/d3pwM9JA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, + "node_modules/preact-feather": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/preact-feather/-/preact-feather-4.2.1.tgz", + "integrity": "sha512-yK5kYW64AoOkm+xTtUjwcFx0zNrqVTbwmtww8G2AmAB6f8wyQgwZgc6oRXllSYeg7q1I8VbkUpErJuKJ6Vq2eA==", + "license": "MIT", + "peerDependencies": { + "preact": "^10.0.0" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/react": { + "version": "19.2.4", + "resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz", + "integrity": "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-icons": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.5.0.tgz", + "integrity": "sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw==", + "license": "MIT", + "peerDependencies": { + "react": "*" + } + }, + "node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rollup": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.57.1.tgz", + "integrity": "sha512-oQL6lgK3e2QZeQ7gcgIkS2YZPg5slw37hYufJ3edKlfQSGGm8ICoxswK15ntSzF/a8+h7ekRy7k7oWc3BQ7y8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.57.1", + "@rollup/rollup-android-arm64": "4.57.1", + "@rollup/rollup-darwin-arm64": "4.57.1", + "@rollup/rollup-darwin-x64": "4.57.1", + "@rollup/rollup-freebsd-arm64": "4.57.1", + "@rollup/rollup-freebsd-x64": "4.57.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.57.1", + "@rollup/rollup-linux-arm-musleabihf": "4.57.1", + "@rollup/rollup-linux-arm64-gnu": "4.57.1", + "@rollup/rollup-linux-arm64-musl": "4.57.1", + "@rollup/rollup-linux-loong64-gnu": "4.57.1", + "@rollup/rollup-linux-loong64-musl": "4.57.1", + "@rollup/rollup-linux-ppc64-gnu": "4.57.1", + "@rollup/rollup-linux-ppc64-musl": "4.57.1", + "@rollup/rollup-linux-riscv64-gnu": "4.57.1", + "@rollup/rollup-linux-riscv64-musl": "4.57.1", + "@rollup/rollup-linux-s390x-gnu": "4.57.1", + "@rollup/rollup-linux-x64-gnu": "4.57.1", + "@rollup/rollup-linux-x64-musl": "4.57.1", + "@rollup/rollup-openbsd-x64": "4.57.1", + "@rollup/rollup-openharmony-arm64": "4.57.1", + "@rollup/rollup-win32-arm64-msvc": "4.57.1", + "@rollup/rollup-win32-ia32-msvc": "4.57.1", + "@rollup/rollup-win32-x64-gnu": "4.57.1", + "@rollup/rollup-win32-x64-msvc": "4.57.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/sass": { + "version": "1.97.3", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.97.3.tgz", + "integrity": "sha512-fDz1zJpd5GycprAbu4Q2PV/RprsRtKC/0z82z0JLgdytmcq0+ujJbJ/09bPGDxCLkKY3Np5cRAOcWiVkLXJURg==", + "license": "MIT", + "dependencies": { + "chokidar": "^4.0.0", + "immutable": "^5.0.2", + "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=14.0.0" + }, + "optionalDependencies": { + "@parcel/watcher": "^2.4.1" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, + "node_modules/simple-code-frame": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/simple-code-frame/-/simple-code-frame-1.3.0.tgz", + "integrity": "sha512-MB4pQmETUBlNs62BBeRjIFGeuy/x6gGKh7+eRUemn1rCFhqo7K+4slPqsyizCbcbYLnaYqaoZ2FWsZ/jN06D8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "kolorist": "^1.6.0" + } + }, + "node_modules/source-map": { + "version": "0.7.6", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz", + "integrity": "sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">= 12" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stack-trace": { + "version": "1.0.0-pre2", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-1.0.0-pre2.tgz", + "integrity": "sha512-2ztBJRek8IVofG9DBJqdy2N5kulaacX30Nz7xmkYF6ale9WBVmIy6mFBchvGX7Vx/MyjBhx+Rcxqrj+dbOnQ6A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", + "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", + "dev": true, + "license": "MIT" + }, + "node_modules/style-mod": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.2.tgz", + "integrity": "sha512-wnD1HyVqpJUI2+eKZ+eo1UwghftP6yuFheBqqe+bWCotBjC2K1YnteJILRMs3SM4V/0dLEW1SC27MWP5y+mwmw==", + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", + "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyrainbow": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", + "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/tsx": { + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz", + "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.27.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/turndown": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/turndown/-/turndown-7.2.2.tgz", + "integrity": "sha512-1F7db8BiExOKxjSMU2b7if62D/XOyQyZbPKq/nUwopfgnHlqXHqQ0lvfUTeUIr1lZJzOPFn43dODyMSIfvWRKQ==", + "license": "MIT", + "dependencies": { + "@mixmark-io/domino": "^2.2.0" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/update-browserslist-db": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz", + "integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/vite": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.1.tgz", + "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.27.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite-prerender-plugin": { + "version": "0.5.12", + "resolved": "https://registry.npmjs.org/vite-prerender-plugin/-/vite-prerender-plugin-0.5.12.tgz", + "integrity": "sha512-EiwhbMn+flg14EysbLTmZSzq8NGTxhytgK3bf4aGRF1evWLGwZiHiUJ1KZDvbxgKbMf2pG6fJWGEa3UZXOnR1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "kolorist": "^1.8.0", + "magic-string": "0.x >= 0.26.0", + "node-html-parser": "^6.1.12", + "simple-code-frame": "^1.3.0", + "source-map": "^0.7.4", + "stack-trace": "^1.0.0-pre2" + }, + "peerDependencies": { + "vite": "5.x || 6.x || 7.x" + } + }, + "node_modules/vitest": { + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.18.tgz", + "integrity": "sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "4.0.18", + "@vitest/mocker": "4.0.18", + "@vitest/pretty-format": "4.0.18", + "@vitest/runner": "4.0.18", + "@vitest/snapshot": "4.0.18", + "@vitest/spy": "4.0.18", + "@vitest/utils": "4.0.18", + "es-module-lexer": "^1.7.0", + "expect-type": "^1.2.2", + "magic-string": "^0.30.21", + "obug": "^2.1.1", + "pathe": "^2.0.3", + "picomatch": "^4.0.3", + "std-env": "^3.10.0", + "tinybench": "^2.9.0", + "tinyexec": "^1.0.2", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.0.3", + "vite": "^6.0.0 || ^7.0.0", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^20.0.0 || ^22.0.0 || >=24.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "4.0.18", + "@vitest/browser-preview": "4.0.18", + "@vitest/browser-webdriverio": "4.0.18", + "@vitest/ui": "4.0.18", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@opentelemetry/api": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/w3c-keyname": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==", + "license": "MIT" + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..a98c6b87 --- /dev/null +++ b/package.json @@ -0,0 +1,123 @@ +{ + "name": "@silverbulletmd/silverbullet", + "version": "2.4.3", + "type": "module", + "description": "A self-hosted, web-based note taking app", + "publishConfig": { + "access": "public" + }, + "exports": { + "./syscall": "./plug-api/syscall.ts", + "./syscalls": "./plug-api/syscalls.ts", + "./constants": "./plug-api/constants.ts", + "./lib/json": "./plug-api/lib/json.ts", + "./lib/tree": "./plug-api/lib/tree.ts", + "./lib/ref": "./plug-api/lib/ref.ts", + "./lib/resolve": "./plug-api/lib/resolve.ts", + "./lib/dates": "./plug-api/lib/dates.ts", + "./lib/async": "./plug-api/lib/async.ts", + "./lib/crypto": "./plug-api/lib/crypto.ts", + "./lib/limited_map": "./plug-api/lib/limited_map.ts", + "./lib/tags": "./plug-api/lib/tags.ts", + "./lib/transclusion": "./plug-api/lib/transclusion.ts", + "./lib/native_fetch": "./plug-api/lib/native_fetch.ts", + "./lib/query_expression": "./plug-api/lib/query_expression.ts", + "./type/client": "./plug-api/types/client.ts", + "./type/config": "./plug-api/types/config.ts", + "./type/manifest": "./plug-api/types/manifest.ts", + "./type/namespace": "./plug-api/types/namespace.ts", + "./type/datastore": "./plug-api/types/datastore.ts", + "./type/event": "./plug-api/types/event.ts", + "./type/index": "./plug-api/types/index.ts" + }, + "bin": { + "plug-compile": "dist/plug-compile.js" + }, + "files": [ + "plug-api/**/*.ts", + "!plug-api/**/*.test.ts", + "!plug-api/**/*.bench.ts", + "client/plugos/**/*.ts", + "!client/plugos/**/*.test.ts", + "client/asset_bundle/bundle.ts", + "client/data/kv_primitives.ts", + "client/data/datastore.ts", + "client/space_lua/**/*.ts", + "!client/space_lua/**/*.test.ts", + "!client/space_lua/**/*.bench.ts", + "client/markdown_parser/constants.ts", + "plugs/builtin_plugs.ts", + "dist/plug-compile.js", + "dist/worker_runtime_bundle.js" + ], + "scripts": { + "build": "tsx build_worker_runtime.ts && npm run build:plugs && npm run build:client", + "build:plugs": "tsx build_plugs_libraries.ts", + "build:client": "tsx build_client.ts", + "build:plug-compile": "tsx build_worker_runtime.ts && tsx build_plug_compile.ts", + "prepublishOnly": "npm run build:plug-compile", + "test": "vitest run", + "check": "tsc --noEmit", + "bench": "vitest bench" + }, + "dependencies": { + "@codemirror/autocomplete": "6.20.0", + "@codemirror/commands": "6.10.1", + "@codemirror/lang-css": "6.3.1", + "@codemirror/lang-html": "6.4.11", + "@codemirror/lang-javascript": "6.2.4", + "@codemirror/lang-markdown": "6.5.0", + "@codemirror/language": "6.12.1", + "@codemirror/legacy-modes": "6.5.2", + "@codemirror/lint": "6.9.2", + "@codemirror/search": "6.6.0", + "@codemirror/state": "6.5.4", + "@codemirror/view": "6.39.11", + "@joplin/turndown-plugin-gfm": "1.0.64", + "@lezer/common": "1.5.0", + "@lezer/css": "1.3.0", + "@lezer/highlight": "1.2.3", + "@lezer/html": "1.3.13", + "@lezer/javascript": "1.5.4", + "@lezer/lr": "1.4.7", + "@lezer/markdown": "1.6.3", + "@msgpack/msgpack": "3.1.3", + "@replit/codemirror-lang-nix": "6.0.1", + "@replit/codemirror-vim": "6.3.0", + "ajv": "8.17.1", + "commander": "^14.0.3", + "crelt": "1.0.6", + "esbuild": "^0.27.3", + "fast-diff": "1.3.0", + "fast-glob": "^3.3.3", + "fuse.js": "7.1.0", + "gitignore-parser": "0.0.2", + "idb": "8.0.3", + "js-yaml": "^4.1.1", + "mime": "4.1.0", + "picomatch": "^4.0.3", + "preact": "10.28.2", + "preact-feather": "4.2.1", + "react-icons": "5.5.0", + "sass": "^1.97.3", + "style-mod": "4.1.2", + "turndown": "7.2.2" + }, + "devDependencies": { + "@preact/preset-vite": "^2.10.3", + "@types/gitignore-parser": "^0.0.3", + "@types/js-yaml": "^4.0.9", + "@types/node": "^22.0.0", + "@types/picomatch": "^4.0.2", + "@types/turndown": "^5.0.6", + "fake-indexeddb": "6.0.1", + "tsx": "^4.19.0", + "typescript": "^5.9.3", + "vite": "^7.3.1", + "vitest": "^4.0.18" + }, + "engines": { + "node": ">=24.0.0", + "npm": ">=10.0.0" + } +} diff --git a/plug-api/lib/async.test.ts b/plug-api/lib/async.test.ts index bbce5dc8..42ae16d1 100644 --- a/plug-api/lib/async.test.ts +++ b/plug-api/lib/async.test.ts @@ -1,4 +1,4 @@ -import { assert, assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { batchRequests, processWithConcurrency, @@ -6,7 +6,7 @@ import { sleep, } from "./async.ts"; -Deno.test("PromiseQueue test", async () => { +test("PromiseQueue test", async () => { const q = new PromiseQueue(); let r1RanFirst = false; const r1 = q.runInQueue(async () => { @@ -20,17 +20,17 @@ Deno.test("PromiseQueue test", async () => { await sleep(4); return 2; }); - assertEquals(await Promise.all([r1, r2]), [1, 2]); - assertEquals(r1RanFirst, true); + expect(await Promise.all([r1, r2])).toEqual([1, 2]); + expect(r1RanFirst).toEqual(true); let wasRun = false; await q.runInQueue(async () => { await sleep(4); wasRun = true; }); - assertEquals(wasRun, true); + expect(wasRun).toEqual(true); }); -Deno.test("processWithConcurrency test - basic functionality", async () => { +test("processWithConcurrency test - basic functionality", async () => { const items = [1, 2, 3, 4, 5]; const results = await processWithConcurrency( items, @@ -40,10 +40,10 @@ Deno.test("processWithConcurrency test - basic functionality", async () => { }, 2, ); - assertEquals(results, [2, 4, 6, 8, 10]); + expect(results).toEqual([2, 4, 6, 8, 10]); }); -Deno.test("processWithConcurrency test - maintains order", async () => { +test("processWithConcurrency test - maintains order", async () => { const items = [1, 2, 3, 4, 5]; const startTimes: number[] = []; const endTimes: number[] = []; @@ -62,10 +62,10 @@ Deno.test("processWithConcurrency test - maintains order", async () => { ); // Results should be in original order despite different processing times - assertEquals(results, ["item-1", "item-2", "item-3", "item-4", "item-5"]); + expect(results).toEqual(["item-1", "item-2", "item-3", "item-4", "item-5"]); }); -Deno.test("processWithConcurrency test - concurrency limit", async () => { +test("processWithConcurrency test - concurrency limit", async () => { const items = [1, 2, 3, 4, 5, 6]; const activeCount = { value: 0 }; const maxActive = { value: 0 }; @@ -82,21 +82,21 @@ Deno.test("processWithConcurrency test - concurrency limit", async () => { 3, ); - assertEquals(results, [1, 2, 3, 4, 5, 6]); + expect(results).toEqual([1, 2, 3, 4, 5, 6]); // Should never exceed concurrency limit of 3 - assertEquals(maxActive.value <= 3, true); + expect(maxActive.value <= 3).toEqual(true); }); -Deno.test("processWithConcurrency test - empty array", async () => { +test("processWithConcurrency test - empty array", async () => { const results = await processWithConcurrency( [], (item) => Promise.resolve(item), 2, ); - assertEquals(results, []); + expect(results).toEqual([]); }); -Deno.test("processWithConcurrency test - concurrency higher than item count", async () => { +test("processWithConcurrency test - concurrency higher than item count", async () => { const items = [1, 2, 3]; const results = await processWithConcurrency( items, @@ -106,10 +106,10 @@ Deno.test("processWithConcurrency test - concurrency higher than item count", as }, 10, // Higher than items.length ); - assertEquals(results, [11, 12, 13]); + expect(results).toEqual([11, 12, 13]); }); -Deno.test("processWithConcurrency test - error handling", async () => { +test("processWithConcurrency test - error handling", async () => { const items = [1, 2, 3, 4, 5]; try { @@ -123,16 +123,16 @@ Deno.test("processWithConcurrency test - error handling", async () => { }, 2, ); - assert(false, "Should have thrown an error"); + expect(false).toEqual(true); // Should have thrown an error } catch (error) { - assert( + expect( error instanceof Error && error.message.includes("Error processing item 3"), - ); + ).toBeTruthy(); } }); -Deno.test("processWithConcurrency test - performance with concurrency", async () => { +test("processWithConcurrency test - performance with concurrency", async () => { const items = Array.from({ length: 6 }, (_, i) => i + 1); const delay = 30; @@ -162,24 +162,23 @@ Deno.test("processWithConcurrency test - performance with concurrency", async () // Parallel should be significantly faster than sequential // Allow some margin for timing variations - assert( + expect( parallel < sequential * 0.8, - `Parallel (${parallel}ms) should be faster than sequential (${sequential}ms)`, - ); + ).toBeTruthy(); // `Parallel (${parallel}ms) should be faster than sequential (${sequential}ms)` }); -Deno.test("Batch test", async () => { +test("Batch test", async () => { // Generate an array with numbers up to 100 const elements = Array.from(Array(100).keys()); const multiplied = await batchRequests(elements, async (batch) => { await sleep(2); // Batches should be 9 or smaller (last batch will be smaller) - assert(batch.length <= 9); + expect(batch.length <= 9).toBeTruthy(); return batch.map((e) => e * 2); }, 9); - assertEquals(multiplied, elements.map((e) => e * 2)); + expect(multiplied).toEqual(elements.map((e) => e * 2)); const multiplied2 = await batchRequests(elements, (batch) => { return Promise.resolve(batch.map((e) => e * 2)); }, 10000); - assertEquals(multiplied2, elements.map((e) => e * 2)); + expect(multiplied2).toEqual(elements.map((e) => e * 2)); }); diff --git a/plug-api/lib/crypto.test.ts b/plug-api/lib/crypto.test.ts index 0ad48c6e..a2e06655 100644 --- a/plug-api/lib/crypto.test.ts +++ b/plug-api/lib/crypto.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from "vitest"; import { decryptAesGcm, decryptStringDeterministic, @@ -6,9 +7,8 @@ import { encryptAesGcm, encryptStringDeterministic, } from "@silverbulletmd/silverbullet/lib/crypto"; -import { assertEquals } from "@std/assert"; -Deno.test("Crypto test", async () => { +test("Crypto test", async () => { const salt = new Uint8Array(16); // zeroes for testing const ctr = await deriveCTRKeyFromPassword("12345", salt); const gcm = await deriveGCMKeyFromCTR(ctr); @@ -16,13 +16,13 @@ Deno.test("Crypto test", async () => { const encrypted = await encryptStringDeterministic(ctr, text); const encrypted2 = await encryptStringDeterministic(ctr, text); // Ensure determinism - assertEquals(encrypted, encrypted2); + expect(encrypted).toEqual(encrypted2); const decrypted = await decryptStringDeterministic(ctr, encrypted); - assertEquals(decrypted, text); + expect(decrypted).toEqual(text); // Now gcm const buffer = new Uint8Array(100).fill(32); const encryptedBuf = await encryptAesGcm(gcm, buffer); const decryptedBuf = await decryptAesGcm(gcm, encryptedBuf); - assertEquals(decryptedBuf, buffer); + expect(decryptedBuf).toEqual(buffer); }); diff --git a/plug-api/lib/crypto.ts b/plug-api/lib/crypto.ts index 8282fc83..eed173e8 100644 --- a/plug-api/lib/crypto.ts +++ b/plug-api/lib/crypto.ts @@ -85,7 +85,7 @@ export async function encryptStringDeterministic( key: CryptoKey, clearText: string, ): Promise { - const encrypted = await crypto.subtle.encrypt( + const encrypted = await globalThis.crypto.subtle.encrypt( { name: "AES-CTR", counter: fixedCounter, length: fixedCounter.length * 8 }, key, new TextEncoder().encode(clearText), @@ -97,7 +97,7 @@ export async function decryptStringDeterministic( key: CryptoKey, cipherText: string, ): Promise { - const decrypted = await crypto.subtle.decrypt( + const decrypted = await globalThis.crypto.subtle.decrypt( { name: "AES-CTR", counter: fixedCounter, length: fixedCounter.length * 8 }, key, base64Decode(cipherText) as BufferSource, @@ -110,8 +110,8 @@ export async function encryptAesGcm( key: CryptoKey, data: Uint8Array, ): Promise { - const iv = crypto.getRandomValues(new Uint8Array(12)); // 96-bit IV recommended for GCM - const encryptedBuffer = await crypto.subtle.encrypt( + const iv = globalThis.crypto.getRandomValues(new Uint8Array(12)); // 96-bit IV recommended for GCM + const encryptedBuffer = await globalThis.crypto.subtle.encrypt( { name: "AES-GCM", iv }, key, data as BufferSource, @@ -132,7 +132,7 @@ export async function decryptAesGcm( ): Promise { const iv = encryptedData.slice(0, 12); // extract IV (first 12 bytes) const ciphertext = encryptedData.slice(12); - const decryptedBuffer = await crypto.subtle.decrypt( + const decryptedBuffer = await globalThis.crypto.subtle.decrypt( { name: "AES-GCM", iv }, key, ciphertext, @@ -148,7 +148,7 @@ export async function deriveCTRKeyFromPassword( const passwordBytes = new TextEncoder().encode(password); // Import password as a CryptoKey - const baseKey = await crypto.subtle.importKey( + const baseKey = await globalThis.crypto.subtle.importKey( "raw", passwordBytes, { name: "PBKDF2" }, @@ -156,7 +156,7 @@ export async function deriveCTRKeyFromPassword( ["deriveBits", "deriveKey"], ); - return crypto.subtle.deriveKey( + return globalThis.crypto.subtle.deriveKey( { name: "PBKDF2", salt: salt as BufferSource, @@ -174,7 +174,7 @@ export async function deriveCTRKeyFromPassword( } export function importKey(b64EncodedKey: string): Promise { - return crypto.subtle.importKey( + return globalThis.crypto.subtle.importKey( "raw", base64Decode(b64EncodedKey) as BufferSource, { name: "AES-CTR" }, @@ -184,15 +184,15 @@ export function importKey(b64EncodedKey: string): Promise { } export async function exportKey(ctrKey: CryptoKey): Promise { - const key = await crypto.subtle.exportKey("raw", ctrKey); + const key = await globalThis.crypto.subtle.exportKey("raw", ctrKey); return base64Encode(new Uint8Array(key)); } export async function deriveGCMKeyFromCTR( ctrKey: CryptoKey, ): Promise { - const rawKey = await crypto.subtle.exportKey("raw", ctrKey); - return crypto.subtle.importKey( + const rawKey = await globalThis.crypto.subtle.exportKey("raw", ctrKey); + return globalThis.crypto.subtle.importKey( "raw", rawKey, { name: "AES-GCM" }, diff --git a/plug-api/lib/dates.test.ts b/plug-api/lib/dates.test.ts index e6bd056d..f945ed1e 100644 --- a/plug-api/lib/dates.test.ts +++ b/plug-api/lib/dates.test.ts @@ -1,5 +1,6 @@ +import { expect, test } from "vitest"; import { localDateString } from "./dates.ts"; -Deno.test("Dates", () => { +test("Dates", () => { console.log("Local date string", localDateString(new Date())); }); diff --git a/plug-api/lib/json.test.ts b/plug-api/lib/json.test.ts index 3dd20a41..f1a440ea 100644 --- a/plug-api/lib/json.test.ts +++ b/plug-api/lib/json.test.ts @@ -1,46 +1,46 @@ -import { assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { cleanupJSON, deepClone, deepEqual } from "./json.ts"; -Deno.test("JSON utils", () => { - assertEquals(deepEqual({ a: 1 }, { a: 1 }), true); - assertEquals(deepEqual({ a: null }, { a: null }), true); - assertEquals(deepEqual({ a: {} }, { a: null }), false); - assertEquals(deepEqual({ a: {} }, { a: undefined }), false); - assertEquals(deepEqual({ a: null }, { a: {} }), false); - assertEquals(cleanupJSON({ "a.b": 1 }), { a: { b: 1 } }); - assertEquals(cleanupJSON({ a: { "a.b": 1 } }), { +test("JSON utils", () => { + expect(deepEqual({ a: 1 }, { a: 1 })).toBe(true); + expect(deepEqual({ a: null }, { a: null })).toBe(true); + expect(deepEqual({ a: {} }, { a: null })).toBe(false); + expect(deepEqual({ a: {} }, { a: undefined })).toBe(false); + expect(deepEqual({ a: null }, { a: {} })).toBe(false); + expect(cleanupJSON({ "a.b": 1 })).toEqual({ a: { b: 1 } }); + expect(cleanupJSON({ a: { "a.b": 1 } })).toEqual({ a: { a: { b: 1 } }, }); - assertEquals(cleanupJSON({ a: [{ "a.b": 1 }] }), { + expect(cleanupJSON({ a: [{ "a.b": 1 }] })).toEqual({ a: [{ a: { b: 1 } }], }); - assertEquals(cleanupJSON(new Date("2023-05-03T00:00:00Z")), "2023-05-03"); + expect(cleanupJSON(new Date("2023-05-03T00:00:00Z"))).toBe("2023-05-03"); }); -Deno.test("JSON utils - deepObjectMerge", () => { +test("JSON utils - deepObjectMerge", () => { // Tests for deepClone const obj1 = { a: 1, b: { c: 2, d: [3, 4] }, e: new Date("2023-08-21") }; const clone1 = deepClone(obj1); - assertEquals(clone1, obj1); - assertEquals(clone1 === obj1, false); // Ensuring deep clone, not shallow - assertEquals(clone1.b === obj1.b, false); // Nested object should be different reference - assertEquals(clone1.e === obj1.e, false); // Date object should be different reference + expect(clone1).toEqual(obj1); + expect(clone1 === obj1).toBe(false); // Ensuring deep clone, not shallow + expect(clone1.b === obj1.b).toBe(false); // Nested object should be different reference + expect(clone1.e === obj1.e).toBe(false); // Date object should be different reference const arrayTest = [1, 2, { a: 3, b: [4, 5] }]; const cloneArray = deepClone(arrayTest); - assertEquals(cloneArray, arrayTest); - assertEquals(cloneArray === arrayTest, false); // Array itself should be different reference - assertEquals(cloneArray[2] === arrayTest[2], false); // Nested object in array should be different reference + expect(cloneArray).toEqual(arrayTest); + expect(cloneArray === arrayTest).toBe(false); // Array itself should be different reference + expect(cloneArray[2] === arrayTest[2]).toBe(false); // Nested object in array should be different reference const nullTest = { a: null, b: undefined, c: { d: null } }; const cloneNullTest = deepClone(nullTest); - assertEquals(cloneNullTest, nullTest); - assertEquals(cloneNullTest === nullTest, false); // Ensure it's a deep clone - assertEquals(cloneNullTest.c === nullTest.c, false); // Nested object should be different reference + expect(cloneNullTest).toEqual(nullTest); + expect(cloneNullTest === nullTest).toBe(false); // Ensure it's a deep clone + expect(cloneNullTest.c === nullTest.c).toBe(false); // Nested object should be different reference const dateTest = new Date(); const cloneDateTest = deepClone(dateTest); - assertEquals(cloneDateTest.getTime(), dateTest.getTime()); - assertEquals(cloneDateTest === dateTest, false); // Date instance should be different reference + expect(cloneDateTest.getTime()).toBe(dateTest.getTime()); + expect(cloneDateTest === dateTest).toBe(false); // Date instance should be different reference }); diff --git a/plug-api/lib/limited_map.test.ts b/plug-api/lib/limited_map.test.ts index 2fc86905..b46dd4fd 100644 --- a/plug-api/lib/limited_map.test.ts +++ b/plug-api/lib/limited_map.test.ts @@ -1,23 +1,23 @@ -import { assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { LimitedMap } from "./limited_map.ts"; import { sleep } from "./async.ts"; -Deno.test("limited map", async () => { +test("limited map", async () => { const mp = new LimitedMap(3); mp.set("a", "a"); mp.set("b", "b", 5); mp.set("c", "c"); - assertEquals(mp.get("a"), "a"); - assertEquals(mp.get("b"), "b"); - assertEquals(mp.get("c"), "c"); + expect(mp.get("a")).toEqual("a"); + expect(mp.get("b")).toEqual("b"); + expect(mp.get("c")).toEqual("c"); // Drops the first key mp.set("d", "d"); // console.log(mp.toJSON()); - assertEquals(mp.get("a"), undefined); + expect(mp.get("a")).toEqual(undefined); await sleep(10); // "b" should have been dropped - assertEquals(mp.get("b"), undefined); - assertEquals(mp.get("c"), "c"); + expect(mp.get("b")).toEqual(undefined); + expect(mp.get("c")).toEqual("c"); console.log(mp.toJSON()); }); diff --git a/plug-api/lib/memory_cache.test.ts b/plug-api/lib/memory_cache.test.ts index fb40058c..7e729061 100644 --- a/plug-api/lib/memory_cache.test.ts +++ b/plug-api/lib/memory_cache.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import { ttlCache } from "./memory_cache.ts"; import { sleep } from "./async.ts"; -import { assertEquals } from "@std/assert"; -Deno.test("Memory cache", async () => { +test("Memory cache", async () => { let calls = 0; async function expensiveFunction(key: string) { @@ -11,9 +11,9 @@ Deno.test("Memory cache", async () => { return key; } - assertEquals("key", await ttlCache("key", expensiveFunction, 0.01)); - assertEquals(1, calls); - assertEquals("key", await ttlCache("key", expensiveFunction, 0.01)); - assertEquals(1, calls); + expect("key").toEqual(await ttlCache("key", expensiveFunction, 0.01)); + expect(1).toEqual(calls); + expect("key").toEqual(await ttlCache("key", expensiveFunction, 0.01)); + expect(1).toEqual(calls); await sleep(10); }); diff --git a/plug-api/lib/ref.test.ts b/plug-api/lib/ref.test.ts index 8161b485..6eef1ae6 100644 --- a/plug-api/lib/ref.test.ts +++ b/plug-api/lib/ref.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from "vitest"; import { decodePageURI, encodePageURI, @@ -6,128 +7,118 @@ import { isValidPath, parseToRef, } from "./ref.ts"; -import { assert, assertEquals } from "@std/assert"; -Deno.test("parseToRef() default cases", () => { - assertEquals(parseToRef("foo"), { path: "foo.md" }); - assertEquals(parseToRef("/foo"), { path: "foo.md" }); - assertEquals(parseToRef("foo/bar"), { path: "foo/bar.md" }); - assertEquals(parseToRef("foo.png"), { path: "foo.png" }); - assertEquals(parseToRef("foo.md"), { path: "foo.md" }); - assertEquals(parseToRef("foo."), { path: "foo..md" }); - assertEquals(parseToRef("foo.."), { path: "foo...md" }); - assertEquals(parseToRef(" .foo"), { path: " .foo" }); - assertEquals(parseToRef("foo[bar"), { path: "foo[bar.md" }); - assertEquals(parseToRef("foo]bar"), { path: "foo]bar.md" }); - assertEquals(parseToRef("foo(bar"), { path: "foo(bar.md" }); - assertEquals(parseToRef("foo)bar"), { path: "foo)bar.md" }); - assertEquals(parseToRef("/bar/.../foo"), { path: "bar/.../foo.md" }); +test("parseToRef() default cases", () => { + expect(parseToRef("foo")).toEqual({ path: "foo.md" }); + expect(parseToRef("/foo")).toEqual({ path: "foo.md" }); + expect(parseToRef("foo/bar")).toEqual({ path: "foo/bar.md" }); + expect(parseToRef("foo.png")).toEqual({ path: "foo.png" }); + expect(parseToRef("foo.md")).toEqual({ path: "foo.md" }); + expect(parseToRef("foo.")).toEqual({ path: "foo..md" }); + expect(parseToRef("foo..")).toEqual({ path: "foo...md" }); + expect(parseToRef(" .foo")).toEqual({ path: " .foo" }); + expect(parseToRef("foo[bar")).toEqual({ path: "foo[bar.md" }); + expect(parseToRef("foo]bar")).toEqual({ path: "foo]bar.md" }); + expect(parseToRef("foo(bar")).toEqual({ path: "foo(bar.md" }); + expect(parseToRef("foo)bar")).toEqual({ path: "foo)bar.md" }); + expect(parseToRef("/bar/.../foo")).toEqual({ path: "bar/.../foo.md" }); - assertEquals(parseToRef("/foo/.bar.md"), null); - assertEquals(parseToRef("foo.md.md"), null); - assertEquals(parseToRef("/.../foo"), null); - assertEquals(parseToRef("^.foo"), null); - assertEquals(parseToRef(".foobar"), null); - assertEquals(parseToRef("foo[[bar"), null); - assertEquals(parseToRef("foo]]bar"), null); - assertEquals(parseToRef("foo|bar"), null); - assertEquals(parseToRef("foo@bar"), null); - assertEquals(parseToRef("/../foo"), null); - assertEquals(parseToRef("/./foo"), null); - assertEquals(parseToRef("/bar/../foo"), null); - assertEquals(parseToRef("/bar/./foo"), null); + expect(parseToRef("/foo/.bar.md")).toEqual(null); + expect(parseToRef("foo.md.md")).toEqual(null); + expect(parseToRef("/.../foo")).toEqual(null); + expect(parseToRef("^.foo")).toEqual(null); + expect(parseToRef(".foobar")).toEqual(null); + expect(parseToRef("foo[[bar")).toEqual(null); + expect(parseToRef("foo]]bar")).toEqual(null); + expect(parseToRef("foo|bar")).toEqual(null); + expect(parseToRef("foo@bar")).toEqual(null); + expect(parseToRef("/../foo")).toEqual(null); + expect(parseToRef("/./foo")).toEqual(null); + expect(parseToRef("/bar/../foo")).toEqual(null); + expect(parseToRef("/bar/./foo")).toEqual(null); - assertEquals(parseToRef(""), { path: "" }); - assertEquals(parseToRef("/"), { path: "" }); - assertEquals(parseToRef("/.md"), null); - assertEquals(parseToRef("/.foo"), null); - assertEquals(parseToRef("/@132"), { + expect(parseToRef("")).toEqual({ path: "" }); + expect(parseToRef("/")).toEqual({ path: "" }); + expect(parseToRef("/.md")).toEqual(null); + expect(parseToRef("/.foo")).toEqual(null); + expect(parseToRef("/@132")).toEqual({ path: "", details: { type: "position", pos: 132 }, }); }); -Deno.test("parseToRef() link cases", () => { - assertEquals(parseToRef("^foo"), { path: "foo.md", meta: true }); +test("parseToRef() link cases", () => { + expect(parseToRef("^foo")).toEqual({ path: "foo.md", meta: true }); - assertEquals(parseToRef("foo# header"), { + expect(parseToRef("foo# header")).toEqual({ path: "foo.md", details: { type: "header", header: "header" }, }); - assertEquals(parseToRef("foo# header@123"), { + expect(parseToRef("foo# header@123")).toEqual({ path: "foo.md", details: { type: "header", header: "header@123" }, }); - assertEquals(parseToRef("foo@1231"), { + expect(parseToRef("foo@1231")).toEqual({ path: "foo.md", details: { type: "position", pos: 1231 }, }); - assertEquals(parseToRef("foo@l42c69"), { + expect(parseToRef("foo@l42c69")).toEqual({ path: "foo.md", details: { type: "linecolumn", line: 42, column: 69 }, }); - assertEquals(parseToRef("foo@L42C69"), { + expect(parseToRef("foo@L42C69")).toEqual({ path: "foo.md", details: { type: "linecolumn", line: 42, column: 69 }, }); - assertEquals(parseToRef("foo@L42"), { + expect(parseToRef("foo@L42")).toEqual({ path: "foo.md", details: { type: "linecolumn", line: 42, column: 1 }, }); - assertEquals(parseToRef("foo@ 123"), null); - assertEquals(parseToRef("foo@c69"), null); - assertEquals(parseToRef("foo@123#header"), null); - assertEquals(parseToRef("foo@123@l29"), null); + expect(parseToRef("foo@ 123")).toEqual(null); + expect(parseToRef("foo@c69")).toEqual(null); + expect(parseToRef("foo@123#header")).toEqual(null); + expect(parseToRef("foo@123@l29")).toEqual(null); }); -Deno.test("encodeRef() cases", () => { +test("encodeRef() cases", () => { // Encoding - assertEquals(encodeRef({ path: "foo.md" }), "foo"); - assertEquals( - encodeRef({ path: "foo.md", details: { type: "position", pos: 10 } }), - "foo@10", - ); - assertEquals( - encodeRef({ - path: "foo.md", - details: { type: "linecolumn", line: 10, column: 69 }, - }), - "foo@L10C69", - ); - assertEquals( - encodeRef({ - path: "foo.md", - details: { type: "header", header: "bar" }, - }), - "foo#bar", - ); + expect(encodeRef({ path: "foo.md" })).toEqual("foo"); + expect(encodeRef({ path: "foo.md", details: { type: "position", pos: 10 } })).toEqual("foo@10"); + expect(encodeRef({ + path: "foo.md", + details: { type: "linecolumn", line: 10, column: 69 }, + })).toEqual("foo@L10C69"); + expect(encodeRef({ + path: "foo.md", + details: { type: "header", header: "bar" }, + })).toEqual("foo#bar"); }); -Deno.test("isValidPath() and isValidName()", () => { - assert(isValidPath("foo.md")); - assert(!isValidPath("foo")); - assert(!isValidPath("foo.md@123")); +test("isValidPath() and isValidName()", () => { + expect(isValidPath("foo.md")).toBeTruthy(); + expect(!isValidPath("foo")).toBeTruthy(); + expect(!isValidPath("foo.md@123")).toBeTruthy(); - assert(isValidName("foo")); - assert(!isValidName("foo.md")); - assert(!isValidName("foo@123")); - assert(!isValidName("^foo@123")); - assert(!isValidName("foo[[bar")); + expect(isValidName("foo")).toBeTruthy(); + expect(!isValidName("foo.md")).toBeTruthy(); + expect(!isValidName("foo@123")).toBeTruthy(); + expect(!isValidName("^foo@123")).toBeTruthy(); + expect(!isValidName("foo[[bar")).toBeTruthy(); // Disallow < and > in ref names - assert(!isValidName("hellothere")); + expect(!isValidName("hellothere")).toBeTruthy(); }); -Deno.test("Page URI encoding", () => { - assertEquals(encodePageURI("foo"), "foo"); - assertEquals(encodePageURI("folder/foo"), "folder/foo"); - assertEquals(encodePageURI("hello there"), "hello%20there"); - assertEquals(encodePageURI("hello?there"), "hello%3Fthere"); +test("Page URI encoding", () => { + expect(encodePageURI("foo")).toEqual("foo"); + expect(encodePageURI("folder/foo")).toEqual("folder/foo"); + expect(encodePageURI("hello there")).toEqual("hello%20there"); + expect(encodePageURI("hello?there")).toEqual("hello%3Fthere"); // Now ensure all these cases are reversible - assertEquals(decodePageURI("foo"), "foo"); - assertEquals(decodePageURI("folder/foo"), "folder/foo"); - assertEquals(decodePageURI("hello%20there"), "hello there"); - assertEquals(decodePageURI("hello%3Fthere"), "hello?there"); + expect(decodePageURI("foo")).toEqual("foo"); + expect(decodePageURI("folder/foo")).toEqual("folder/foo"); + expect(decodePageURI("hello%20there")).toEqual("hello there"); + expect(decodePageURI("hello%3Fthere")).toEqual("hello?there"); }); diff --git a/plug-api/lib/resolve.test.ts b/plug-api/lib/resolve.test.ts index f41da09b..94ba5b68 100644 --- a/plug-api/lib/resolve.test.ts +++ b/plug-api/lib/resolve.test.ts @@ -1,52 +1,41 @@ +import { expect, test } from "vitest"; import { resolveMarkdownLink } from "@silverbulletmd/silverbullet/lib/resolve"; -import { assertEquals } from "@std/assert"; -Deno.test("Test URL resolver", () => { +test("Test URL resolver", () => { // Absolute paths - assertEquals( + expect( resolveMarkdownLink("foo", "/bar"), - "bar", - ); - assertEquals( + ).toEqual("bar"); + expect( resolveMarkdownLink("/foo/bar/baz", "/qux"), - "qux", - ); - assertEquals( + ).toEqual("qux"); + expect( resolveMarkdownLink("foo", "/bar@123#456"), - "bar@123#456", - ); - assertEquals( + ).toEqual("bar@123#456"); + expect( resolveMarkdownLink("foo/bar", "/baz.jpg"), - "baz.jpg", - ); + ).toEqual("baz.jpg"); // Relative paths - assertEquals( + expect( resolveMarkdownLink("bar", "foo"), - "foo", - ); - assertEquals( + ).toEqual("foo"); + expect( resolveMarkdownLink("foo/bar.jpg", "baz"), - "foo/baz", - ); - assertEquals( + ).toEqual("foo/baz"); + expect( resolveMarkdownLink("/foo/bar", "baz"), - "/foo/baz", - ); - assertEquals( + ).toEqual("/foo/baz"); + expect( resolveMarkdownLink("foo///bar", "baz"), - "foo///baz", - ); - assertEquals( + ).toEqual("foo///baz"); + expect( resolveMarkdownLink("bar", "../foo/baz"), - "foo/baz", - ); - assertEquals( + ).toEqual("foo/baz"); + expect( resolveMarkdownLink("bar", "../../foo/baz"), - "foo/baz", - ); - assertEquals( + ).toEqual("foo/baz"); + expect( resolveMarkdownLink("bar/qux", "foo/../baz"), - "bar/foo/../baz", - ); + ).toEqual("bar/foo/../baz"); }); diff --git a/plug-api/lib/tree.test.ts b/plug-api/lib/tree.test.ts index be4e19eb..180aa149 100644 --- a/plug-api/lib/tree.test.ts +++ b/plug-api/lib/tree.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from "vitest"; // import { parse } from "./parse_tree.ts"; import { addParentPointers, @@ -8,7 +9,6 @@ import { renderToText, replaceNodesMatching, } from "./tree.ts"; -import { assertEquals, assertNotEquals } from "@std/assert"; import { parse } from "../../client/markdown_parser/parse_tree.ts"; import { extendedMarkdownLanguage } from "../../client/markdown_parser/parser.ts"; @@ -39,22 +39,19 @@ name: something \`\`\` `; -Deno.test("Test parsing", () => { +test("Test parsing", () => { const mdTree = parse(extendedMarkdownLanguage, mdTest1); addParentPointers(mdTree); // console.log(JSON.stringify(mdTree, null, 2)); const wikiLink = nodeAtPos(mdTree, mdTest1.indexOf("Wiki Page"))!; - assertEquals(wikiLink.type, "WikiLinkPage"); - assertNotEquals( - findParentMatching(wikiLink, (n) => n.type === "BulletList"), - null, - ); + expect(wikiLink.type).toEqual("WikiLinkPage"); + expect(findParentMatching(wikiLink, (n) => n.type === "BulletList")).not.toEqual(null); const allTodos = collectNodesMatching(mdTree, (n) => n.type === "Task"); - assertEquals(allTodos.length, 2); + expect(allTodos.length).toEqual(2); // Render back into markdown should be equivalent - assertEquals(renderToText(mdTree), mdTest1); + expect(renderToText(mdTree)).toEqual(mdTest1); removeParentPointers(mdTree); replaceNodesMatching(mdTree, (n) => { diff --git a/plug-api/lib/yaml.test.ts b/plug-api/lib/yaml.test.ts index f9425efc..0ad71af2 100644 --- a/plug-api/lib/yaml.test.ts +++ b/plug-api/lib/yaml.test.ts @@ -1,7 +1,7 @@ -import { assertEquals, assertExists } from "@std/assert"; +import { expect, test } from "vitest"; import { applyPatches, type YamlPatch } from "./yaml.ts"; -Deno.test("YAML patching - basic operations and value types", () => { +test("YAML patching - basic operations and value types", () => { const initialYaml = ` name: my-package version: 1.0.0 @@ -20,23 +20,23 @@ description: A sample package const result = applyPatches(initialYaml, patches); - assertExists(result); + expect(result).toBeDefined(); // Basic scalar updates - assertEquals(result.includes("version: 1.1.0"), true); - assertEquals(result.includes("description: Updated description"), true); - assertEquals(result.includes("name: my-package"), true); + expect(result.includes("version: 1.1.0")).toEqual(true); + expect(result.includes("description: Updated description")).toEqual(true); + expect(result.includes("name: my-package")).toEqual(true); // Special values and characters - assertEquals(result.includes('empty: ""'), true); - assertEquals(result.includes('special: "value:with:colons"'), true); - assertEquals(result.includes("null: null"), true); + expect(result.includes('empty: ""')).toEqual(true); + expect(result.includes('special: "value:with:colons"')).toEqual(true); + expect(result.includes("null: null")).toEqual(true); // Empty collections - assertEquals(result.includes("emptyList: []"), true); - assertEquals(result.includes("emptyObject: {}"), true); + expect(result.includes("emptyList: []")).toEqual(true); + expect(result.includes("emptyObject: {}")).toEqual(true); }); -Deno.test("YAML patching - collections and nested structures", () => { +test("YAML patching - collections and nested structures", () => { const initialYaml = ` name: my-package tags: @@ -63,25 +63,25 @@ tags: const result = applyPatches(initialYaml, patches); - assertExists(result); + expect(result).toBeDefined(); // Array values - assertEquals(result.includes("tags:"), true); - assertEquals(result.includes("- deno"), true); - assertEquals(result.includes("- typescript"), true); - assertEquals(result.includes("- yaml"), true); - assertEquals(result.includes("dependencies:"), true); - assertEquals(result.includes("- std"), true); - assertEquals(result.includes("- testing"), true); + expect(result.includes("tags:")).toEqual(true); + expect(result.includes("- deno")).toEqual(true); + expect(result.includes("- typescript")).toEqual(true); + expect(result.includes("- yaml")).toEqual(true); + expect(result.includes("dependencies:")).toEqual(true); + expect(result.includes("- std")).toEqual(true); + expect(result.includes("- testing")).toEqual(true); // Nested object values - assertEquals(result.includes("config:"), true); - assertEquals(result.includes(" port: 3000"), true); - assertEquals(result.includes(" host: localhost"), true); - assertEquals(result.includes(" debug: true"), true); - assertEquals(result.includes(" timeout: 5000"), true); + expect(result.includes("config:")).toEqual(true); + expect(result.includes(" port: 3000")).toEqual(true); + expect(result.includes(" host: localhost")).toEqual(true); + expect(result.includes(" debug: true")).toEqual(true); + expect(result.includes(" timeout: 5000")).toEqual(true); }); -Deno.test("YAML patching - comments and formatting preservation", () => { +test("YAML patching - comments and formatting preservation", () => { const initialYaml = ` # Main package configuration name: my-package # The package name @@ -103,45 +103,45 @@ license: MIT # License type const result = applyPatches(initialYaml, patches); // Verify all comments are preserved - assertEquals(result.includes("# Main package configuration"), true); - assertEquals(result.includes("# The package name"), true); - assertEquals(result.includes("# Current version"), true); - assertEquals(result.includes("# Additional metadata"), true); - assertEquals(result.includes("# Package maintainer"), true); - assertEquals(result.includes("# License type"), true); + expect(result.includes("# Main package configuration")).toEqual(true); + expect(result.includes("# The package name")).toEqual(true); + expect(result.includes("# Current version")).toEqual(true); + expect(result.includes("# Additional metadata")).toEqual(true); + expect(result.includes("# Package maintainer")).toEqual(true); + expect(result.includes("# License type")).toEqual(true); // Verify content is correct and in order - assertEquals(result.includes("version: 2.0.0"), true); - assertEquals(result.includes("description: An updated package"), true); - assertEquals(result.includes("newProp: new value"), true); + expect(result.includes("version: 2.0.0")).toEqual(true); + expect(result.includes("description: An updated package")).toEqual(true); + expect(result.includes("newProp: new value")).toEqual(true); // Verify trailing newlines are preserved - assertEquals(result.endsWith("\n"), true); + expect(result.endsWith("\n")).toEqual(true); const lines = result.split("\n"); - assertEquals(lines[lines.length - 1], ""); + expect(lines[lines.length - 1]).toEqual(""); }); -Deno.test("YAML patching - edge cases", () => { +test("YAML patching - edge cases", () => { // Test empty input const emptyResult = applyPatches("", [ { op: "set-key", path: "name", value: "new-package" }, ]); - assertEquals(emptyResult.trim(), "name: new-package"); + expect(emptyResult.trim()).toEqual("name: new-package"); // Test single line with trailing newline const singleLineResult = applyPatches("key: value\n", [ { op: "set-key", path: "key", value: "new value" }, ]); - assertEquals(singleLineResult, "key: new value\n"); + expect(singleLineResult).toEqual("key: new value\n"); // Test multiple trailing newlines const multiNewlineResult = applyPatches("key: value\n\n\n", [ { op: "set-key", path: "key", value: "new value" }, ]); - assertEquals(multiNewlineResult, "key: new value\n"); + expect(multiNewlineResult).toEqual("key: new value\n"); }); -Deno.test("YAML patching - delete key basic operations", () => { +test("YAML patching - delete key basic operations", () => { const initialYaml = ` name: my-package version: 1.0.0 @@ -157,18 +157,18 @@ license: MIT const result = applyPatches(initialYaml, patches); - assertExists(result); + expect(result).toBeDefined(); // Verify deleted keys are gone - assertEquals(result.includes("version:"), false); - assertEquals(result.includes("author:"), false); + expect(result.includes("version:")).toEqual(false); + expect(result.includes("author:")).toEqual(false); // Verify remaining keys are still present - assertEquals(result.includes("name: my-package"), true); - assertEquals(result.includes("description: A sample package"), true); - assertEquals(result.includes("license: MIT"), true); + expect(result.includes("name: my-package")).toEqual(true); + expect(result.includes("description: A sample package")).toEqual(true); + expect(result.includes("license: MIT")).toEqual(true); }); -Deno.test("YAML patching - delete key with comments", () => { +test("YAML patching - delete key with comments", () => { const initialYaml = ` # Package configuration name: my-package @@ -188,20 +188,20 @@ author: John Doe # Main author const result = applyPatches(initialYaml, patches); // Verify the key and its comments are removed - assertEquals(result.includes("version:"), false); - assertEquals(result.includes("# Version number"), false); - assertEquals(result.includes("# Current version"), false); + expect(result.includes("version:")).toEqual(false); + expect(result.includes("# Version number")).toEqual(false); + expect(result.includes("# Current version")).toEqual(false); // Verify other content remains - assertEquals(result.includes("# Package configuration"), true); - assertEquals(result.includes("name: my-package"), true); - assertEquals(result.includes("# Description"), true); - assertEquals(result.includes("description: A sample package"), true); - assertEquals(result.includes("author: John Doe"), true); - assertEquals(result.includes("# Main author"), true); + expect(result.includes("# Package configuration")).toEqual(true); + expect(result.includes("name: my-package")).toEqual(true); + expect(result.includes("# Description")).toEqual(true); + expect(result.includes("description: A sample package")).toEqual(true); + expect(result.includes("author: John Doe")).toEqual(true); + expect(result.includes("# Main author")).toEqual(true); }); -Deno.test("YAML patching - delete key with list values", () => { +test("YAML patching - delete key with list values", () => { const initialYaml = ` name: my-package tags: @@ -221,20 +221,20 @@ author: John Doe const result = applyPatches(initialYaml, patches); // Verify the key and its list values are removed - assertEquals(result.includes("tags:"), false); - assertEquals(result.includes("- node"), false); - assertEquals(result.includes("- typescript"), false); - assertEquals(result.includes("- yaml"), false); + expect(result.includes("tags:")).toEqual(false); + expect(result.includes("- node")).toEqual(false); + expect(result.includes("- typescript")).toEqual(false); + expect(result.includes("- yaml")).toEqual(false); // Verify other content remains - assertEquals(result.includes("name: my-package"), true); - assertEquals(result.includes("dependencies:"), true); - assertEquals(result.includes("- std"), true); - assertEquals(result.includes("- testing"), true); - assertEquals(result.includes("author: John Doe"), true); + expect(result.includes("name: my-package")).toEqual(true); + expect(result.includes("dependencies:")).toEqual(true); + expect(result.includes("- std")).toEqual(true); + expect(result.includes("- testing")).toEqual(true); + expect(result.includes("author: John Doe")).toEqual(true); }); -Deno.test("YAML patching - delete key with nested object values", () => { +test("YAML patching - delete key with nested object values", () => { const initialYaml = ` name: my-package config: @@ -253,18 +253,18 @@ author: John Doe const result = applyPatches(initialYaml, patches); // Verify the key and its nested content are removed - assertEquals(result.includes("config:"), false); - assertEquals(result.includes("port: 3000"), false); - assertEquals(result.includes("host: localhost"), false); - assertEquals(result.includes("debug: true"), false); - assertEquals(result.includes("timeout: 5000"), false); + expect(result.includes("config:")).toEqual(false); + expect(result.includes("port: 3000")).toEqual(false); + expect(result.includes("host: localhost")).toEqual(false); + expect(result.includes("debug: true")).toEqual(false); + expect(result.includes("timeout: 5000")).toEqual(false); // Verify other content remains - assertEquals(result.includes("name: my-package"), true); - assertEquals(result.includes("author: John Doe"), true); + expect(result.includes("name: my-package")).toEqual(true); + expect(result.includes("author: John Doe")).toEqual(true); }); -Deno.test("YAML patching - delete non-existent key", () => { +test("YAML patching - delete non-existent key", () => { const initialYaml = ` name: my-package version: 1.0.0 @@ -277,12 +277,12 @@ version: 1.0.0 const result = applyPatches(initialYaml, patches); // Verify nothing changes when deleting a non-existent key - assertEquals(result.includes("name: my-package"), true); - assertEquals(result.includes("version: 1.0.0"), true); - assertEquals(result, initialYaml); + expect(result.includes("name: my-package")).toEqual(true); + expect(result.includes("version: 1.0.0")).toEqual(true); + expect(result).toEqual(initialYaml); }); -Deno.test("YAML patching - mixed set and delete operations", () => { +test("YAML patching - mixed set and delete operations", () => { const initialYaml = ` name: my-package version: 1.0.0 @@ -301,19 +301,19 @@ license: MIT const result = applyPatches(initialYaml, patches); // Verify deletions - assertEquals(result.includes("author:"), false); - assertEquals(result.includes("description:"), false); + expect(result.includes("author:")).toEqual(false); + expect(result.includes("description:")).toEqual(false); // Verify updates and additions - assertEquals(result.includes("version: 2.0.0"), true); - assertEquals(result.includes("maintainer: Jane Smith"), true); + expect(result.includes("version: 2.0.0")).toEqual(true); + expect(result.includes("maintainer: Jane Smith")).toEqual(true); // Verify unchanged content - assertEquals(result.includes("name: my-package"), true); - assertEquals(result.includes("license: MIT"), true); + expect(result.includes("name: my-package")).toEqual(true); + expect(result.includes("license: MIT")).toEqual(true); }); -Deno.test("YAML patching - delete all keys", () => { +test("YAML patching - delete all keys", () => { const initialYaml = ` name: my-package version: 1.0.0 @@ -327,10 +327,10 @@ version: 1.0.0 const result = applyPatches(initialYaml, patches); // Result should be effectively empty (just newlines) - assertEquals(result.trim(), ""); + expect(result.trim()).toEqual(""); }); -Deno.test("YAML patching - delete key preserves surrounding structure", () => { +test("YAML patching - delete key preserves surrounding structure", () => { const initialYaml = ` # Header comment name: my-package @@ -348,12 +348,12 @@ license: MIT const result = applyPatches(initialYaml, patches); // Verify structure is maintained - assertEquals(result.includes("# Header comment"), true); - assertEquals(result.includes("name: my-package"), true); - assertEquals(result.includes("description: A sample package"), true); - assertEquals(result.includes("# Footer comment"), true); - assertEquals(result.includes("license: MIT"), true); + expect(result.includes("# Header comment")).toEqual(true); + expect(result.includes("name: my-package")).toEqual(true); + expect(result.includes("description: A sample package")).toEqual(true); + expect(result.includes("# Footer comment")).toEqual(true); + expect(result.includes("license: MIT")).toEqual(true); // Verify deleted key is gone - assertEquals(result.includes("version:"), false); + expect(result.includes("version:")).toEqual(false); }); diff --git a/plug-api/syscall.ts b/plug-api/syscall.ts index 00de7358..5d4cc417 100644 --- a/plug-api/syscall.ts +++ b/plug-api/syscall.ts @@ -3,11 +3,9 @@ // } // This is the case when running tests only, so giving it a dummy syscall function -if (typeof self === "undefined") { - (self as any) = { - syscall: () => { - throw new Error("Not implemented here"); - }, +if (typeof (globalThis as any).syscall === "undefined") { + (globalThis as any).syscall = () => { + throw new Error("Not implemented here"); }; } diff --git a/plugs/emoji/build.ts b/plugs/emoji/build.ts index 77911e22..7955f964 100644 --- a/plugs/emoji/build.ts +++ b/plugs/emoji/build.ts @@ -1,8 +1,10 @@ // Generates emoji.json from emoji-data.txt +import { readFileSync, writeFileSync } from "node:fs"; + const emojiRe = /#\s([^\s]+)\s+E[^\s]+\s+(.+)$/; -const text = Deno.readTextFileSync("emoji-data.txt"); -const lines = text.split("\n").filter((line) => !line.startsWith("#")); +const text = readFileSync("emoji-data.txt", "utf-8"); +const lines = text.split("\n").filter((line: string) => !line.startsWith("#")); const emojis: string[] = []; for (const line of lines) { @@ -14,7 +16,4 @@ for (const line of lines) { } } -Deno.writeFileSync( - "emoji.json", - new TextEncoder().encode(JSON.stringify(emojis.join("|"))), -); +writeFileSync("emoji.json", JSON.stringify(emojis.join("|")), "utf-8"); diff --git a/plugs/index/cheap_yaml.test.ts b/plugs/index/cheap_yaml.test.ts index 2175254b..bf58c584 100644 --- a/plugs/index/cheap_yaml.test.ts +++ b/plugs/index/cheap_yaml.test.ts @@ -1,16 +1,13 @@ -import { assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { determineTags } from "./cheap_yaml.ts"; -Deno.test("cheap yaml", () => { - assertEquals([], determineTags("")); - assertEquals([], determineTags("hank: bla")); - assertEquals(["template"], determineTags("tags: template")); - assertEquals(["bla", "template"], determineTags("tags: bla,template")); - assertEquals(["bla", "template"], determineTags("tags:\n- bla\n- template")); - assertEquals(["bla", "template"], determineTags(`tags: "#bla,#template"`)); - assertEquals(["bla", "template"], determineTags(`tags: '#bla, #template'`)); - assertEquals( - ["bla", "template"], - determineTags(`tags:\n- "#bla"\n- template`), - ); +test("cheap yaml", () => { + expect(determineTags("")).toEqual([]); + expect(determineTags("hank: bla")).toEqual([]); + expect(determineTags("tags: template")).toEqual(["template"]); + expect(determineTags("tags: bla,template")).toEqual(["bla", "template"]); + expect(determineTags("tags:\n- bla\n- template")).toEqual(["bla", "template"]); + expect(determineTags(`tags: "#bla,#template"`)).toEqual(["bla", "template"]); + expect(determineTags(`tags: '#bla, #template'`)).toEqual(["bla", "template"]); + expect(determineTags(`tags:\n- "#bla"\n- template`)).toEqual(["bla", "template"]); }); diff --git a/plugs/index/data.test.ts b/plugs/index/data.test.ts index dbfccf38..1c724977 100644 --- a/plugs/index/data.test.ts +++ b/plugs/index/data.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from "vitest"; import { parseMarkdown } from "../../client/markdown_parser/parser.ts"; import { createMockSystem } from "../../plug-api/system_mock.ts"; import type { @@ -5,7 +6,6 @@ import type { PageMeta, } from "@silverbulletmd/silverbullet/type/index"; import { extractFrontMatter } from "./frontmatter.ts"; -import { assertEquals } from "@std/assert"; import { indexData } from "./data.ts"; const testPage = ` @@ -22,7 +22,7 @@ age: 101 \`\`\` `.trim(); -Deno.test("Test indexers", async () => { +test("Test indexers", async () => { createMockSystem(); const tree = parseMarkdown(testPage); const frontmatter = extractFrontMatter(tree); @@ -42,17 +42,17 @@ Deno.test("Test indexers", async () => { tree, ); // 1 data 1 tag - assertEquals(datas.length, 3); + expect(datas.length).toEqual(3); // data object first - assertEquals(datas[0].tag, "superduper"); - assertEquals(datas[0].itags, ["superduper", "data"]); - assertEquals(datas[0].name, "Pete"); - assertEquals(datas[0].age, 100); + expect(datas[0].tag).toEqual("superduper"); + expect(datas[0].itags).toEqual(["superduper", "data"]); + expect(datas[0].name).toEqual("Pete"); + expect(datas[0].age).toEqual(100); // data object first - assertEquals(datas[1].tag, "superduper"); - assertEquals(datas[1].itags, ["superduper", "data"]); - assertEquals(datas[1].name, "Hank"); - assertEquals(datas[1].age, 101); + expect(datas[1].tag).toEqual("superduper"); + expect(datas[1].itags).toEqual(["superduper", "data"]); + expect(datas[1].name).toEqual("Hank"); + expect(datas[1].age).toEqual(101); }); diff --git a/plugs/index/header.test.ts b/plugs/index/header.test.ts index a1662ab5..ee48412f 100644 --- a/plugs/index/header.test.ts +++ b/plugs/index/header.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import { parseMarkdown } from "../../client/markdown_parser/parser.ts"; import { createMockSystem } from "../../plug-api/system_mock.ts"; import type { PageMeta } from "@silverbulletmd/silverbullet/type/index"; import { extractFrontMatter } from "./frontmatter.ts"; -import { assertEquals } from "@std/assert"; import { indexHeaders } from "./header.ts"; const testPage = ` @@ -11,7 +11,7 @@ const testPage = ` # Header 2 [testAttr: 10] `.trim(); -Deno.test("Test header indexing", async () => { +test("Test header indexing", async () => { createMockSystem(); const tree = parseMarkdown(testPage); const frontmatter = await extractFrontMatter(tree); @@ -31,10 +31,10 @@ Deno.test("Test header indexing", async () => { tree, ); // 1 data 1 tag - assertEquals(headers.length, 3); + expect(headers.length).toEqual(3); - assertEquals(headers[0].name, "Header 1"); - assertEquals(headers[0].level, 1); - assertEquals(headers[1].name, "Header 1.1"); - assertEquals(headers[1].level, 2); + expect(headers[0].name).toEqual("Header 1"); + expect(headers[0].level).toEqual(1); + expect(headers[1].name).toEqual("Header 1.1"); + expect(headers[1].level).toEqual(2); }); diff --git a/plugs/index/item.test.ts b/plugs/index/item.test.ts index a4cd39d3..1b4fb738 100644 --- a/plugs/index/item.test.ts +++ b/plugs/index/item.test.ts @@ -1,6 +1,6 @@ +import { expect, test } from "vitest"; import { parseMarkdown } from "../../client/markdown_parser/parser.ts"; import { indexItems } from "./item.ts"; -import { assertEquals } from "@std/assert"; import { createMockSystem } from "../../plug-api/system_mock.ts"; import { extractFrontMatter } from "./frontmatter.ts"; import type { PageMeta } from "@silverbulletmd/silverbullet/type/index"; @@ -17,7 +17,7 @@ const itemsMd = ` * Child second [[link 2|alias]] `; -Deno.test("Test item indexing", async () => { +test("Test item indexing", async () => { createMockSystem(); const tree = parseMarkdown(itemsMd); const frontmatter = extractFrontMatter(tree); @@ -30,46 +30,44 @@ Deno.test("Test item indexing", async () => { perm: "rw", }; const items = await indexItems(pageMeta, frontmatter, tree); - assertEquals(items.length, 9); + expect(items.length).toEqual(9); // Test regular items - assertEquals(items[0].name, "Item 1"); - assertEquals(items[0].age, 100); - assertEquals(items[0].page, "test"); - assertEquals(items[0].parent, undefined); - assertEquals(items[0].text, "Item 1 #tag1 #tag2 [age: 100]"); - assertEquals(new Set(items[0].tags), new Set(["tag1", "tag2"])); - assertEquals(new Set(items[0].itags), new Set(["item", "tag1", "tag2"])); + expect(items[0].name).toEqual("Item 1"); + expect(items[0].age).toEqual(100); + expect(items[0].page).toEqual("test"); + expect(items[0].parent).toEqual(undefined); + expect(items[0].text).toEqual("Item 1 #tag1 #tag2 [age: 100]"); + expect(new Set(items[0].tags)).toEqual(new Set(["tag1", "tag2"])); + expect(new Set(items[0].itags)).toEqual(new Set(["item", "tag1", "tag2"])); - assertEquals(items[1].name, "Item 1.1"); - assertEquals(new Set(items[1].tags), new Set(["tag3", "tag1"])); - assertEquals( - new Set(items[1].itags), - new Set(["tag3", "tag2", "tag1", "item"]), + expect(items[1].name).toEqual("Item 1.1"); + expect(new Set(items[1].tags)).toEqual(new Set(["tag3", "tag1"])); + expect(new Set(items[1].itags)).toEqual(new Set(["tag3", "tag2", "tag1", "item"]), ); - assertEquals(items[1].parent, items[0].ref); + expect(items[1].parent).toEqual(items[0].ref); - assertEquals(items[2].name, "Item 1.1.1"); - assertEquals(items[2].parent, items[1].ref); + expect(items[2].name).toEqual("Item 1.1.1"); + expect(items[2].parent).toEqual(items[1].ref); // Test tasks - assertEquals(items[3].tag, "task"); - assertEquals(items[3].name, "Task 1"); - assertEquals(items[3].done, false); - assertEquals(items[3].state, " "); + expect(items[3].tag).toEqual("task"); + expect(items[3].name).toEqual("Task 1"); + expect(items[3].done).toEqual(false); + expect(items[3].state).toEqual(" "); - assertEquals(items[4].tag, "task"); - assertEquals(items[4].name, "Task 2"); - assertEquals(items[4].done, true); - assertEquals(items[4].state, "x"); + expect(items[4].tag).toEqual("task"); + expect(items[4].name).toEqual("Task 2"); + expect(items[4].done).toEqual(true); + expect(items[4].state).toEqual("x"); - assertEquals(items[6].tag, "task"); - assertEquals(items[6].name, "Sub task"); - assertEquals(items[6].done, false); - assertEquals(items[6].parent, items[5].ref); - assertEquals(new Set(items[6].itags), new Set(["task", "tag4"])); + expect(items[6].tag).toEqual("task"); + expect(items[6].name).toEqual("Sub task"); + expect(items[6].done).toEqual(false); + expect(items[6].parent).toEqual(items[5].ref); + expect(new Set(items[6].itags)).toEqual(new Set(["task", "tag4"])); - assertEquals(items[7].links, ["link"]); - assertEquals(items[7].ilinks, ["link"]); - assertEquals(items[8].links, ["link 2"]); - assertEquals(new Set(items[8].ilinks), new Set(["link", "link 2"])); + expect(items[7].links).toEqual(["link"]); + expect(items[7].ilinks).toEqual(["link"]); + expect(items[8].links).toEqual(["link 2"]); + expect(new Set(items[8].ilinks)).toEqual(new Set(["link", "link 2"])); }); diff --git a/plugs/index/link.test.ts b/plugs/index/link.test.ts index a0941efe..a3c9d8bb 100644 --- a/plugs/index/link.test.ts +++ b/plugs/index/link.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import { parseMarkdown } from "../../client/markdown_parser/parser.ts"; import { createMockSystem } from "../../plug-api/system_mock.ts"; import type { PageMeta } from "@silverbulletmd/silverbullet/type/index"; import { extractFrontMatter } from "./frontmatter.ts"; -import { assertEquals } from "@std/assert"; import { indexLinks } from "./link.ts"; const testPage = ` @@ -12,7 +12,7 @@ attribute: "[[fm-link]]" This is a [[page-link]] to [[aliased-link|aliased]], or [this](md-link), and [[broken]], or [external](https://example.com), or [document](test.jpg), or [[test2.jpg]] `.trim(); -Deno.test("Test page link indexing", async () => { +test("Test page link indexing", async () => { const { space } = createMockSystem(); // Create dummy targets to avoid a lot of aspiring pages @@ -34,22 +34,22 @@ Deno.test("Test page link indexing", async () => { }; const objects = await indexLinks(pageMeta, frontmatter, tree, testPage); - assertEquals(objects.length, 9); // 7 links + 1 aspiring page - assertEquals(objects[0].toPage, "fm-link"); - assertEquals(objects[0].type, "page"); - assertEquals(objects[1].toPage, "page-link"); - assertEquals(objects[1].type, "page"); - assertEquals(objects[2].toPage, "aliased-link"); - assertEquals(objects[2].type, "page"); - assertEquals(objects[2].alias, "aliased"); - assertEquals(objects[3].toPage, "folder/md-link"); // relative - assertEquals(objects[3].type, "page"); - assertEquals(objects[4].toPage, "broken"); - assertEquals(objects[4].type, "page"); - assertEquals(objects[5].toURL, "https://example.com"); - assertEquals(objects[5].type, "url"); - assertEquals(objects[6].toFile, "folder/test.jpg"); - assertEquals(objects[6].type, "file"); - assertEquals(objects[7].toFile, "test2.jpg"); - assertEquals(objects[7].type, "file"); + expect(objects.length).toEqual(9); // 7 links + 1 aspiring page + expect(objects[0].toPage).toEqual("fm-link"); + expect(objects[0].type).toEqual("page"); + expect(objects[1].toPage).toEqual("page-link"); + expect(objects[1].type).toEqual("page"); + expect(objects[2].toPage).toEqual("aliased-link"); + expect(objects[2].type).toEqual("page"); + expect(objects[2].alias).toEqual("aliased"); + expect(objects[3].toPage).toEqual("folder/md-link"); // relative + expect(objects[3].type).toEqual("page"); + expect(objects[4].toPage).toEqual("broken"); + expect(objects[4].type).toEqual("page"); + expect(objects[5].toURL).toEqual("https://example.com"); + expect(objects[5].type).toEqual("url"); + expect(objects[6].toFile).toEqual("folder/test.jpg"); + expect(objects[6].type).toEqual("file"); + expect(objects[7].toFile).toEqual("test2.jpg"); + expect(objects[7].type).toEqual("file"); }); diff --git a/plugs/index/page.test.ts b/plugs/index/page.test.ts index 371708e8..d9ce5d3b 100644 --- a/plugs/index/page.test.ts +++ b/plugs/index/page.test.ts @@ -1,9 +1,9 @@ +import { expect, test } from "vitest"; import { parseMarkdown } from "../../client/markdown_parser/parser.ts"; import { createMockSystem } from "../../plug-api/system_mock.ts"; import type { PageMeta } from "@silverbulletmd/silverbullet/type/index"; import { indexPage } from "./page.ts"; import { extractFrontMatter } from "./frontmatter.ts"; -import { assertEquals } from "@std/assert"; const testPage = ` --- @@ -15,7 +15,7 @@ hello: attribute `.trim(); -Deno.test("Test page indexing", async () => { +test("Test page indexing", async () => { createMockSystem(); const tree = parseMarkdown(testPage); const frontmatter = extractFrontMatter(tree); @@ -30,7 +30,7 @@ Deno.test("Test page indexing", async () => { }; const [pm] = await indexPage(pageMeta, frontmatter, tree); - assertEquals(pm.hello, "attribute"); - assertEquals(pm.hello2, 12); - assertEquals(pm.itags, ["page"]); + expect(pm.hello).toEqual("attribute"); + expect(pm.hello2).toEqual(12); + expect(pm.itags).toEqual(["page"]); }); diff --git a/plugs/index/paragraph.test.ts b/plugs/index/paragraph.test.ts index 3e659091..e208f837 100644 --- a/plugs/index/paragraph.test.ts +++ b/plugs/index/paragraph.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import { parseMarkdown } from "../../client/markdown_parser/parser.ts"; import { createMockSystem } from "../../plug-api/system_mock.ts"; import type { PageMeta } from "@silverbulletmd/silverbullet/type/index"; import { extractFrontMatter } from "./frontmatter.ts"; -import { assertEquals } from "@std/assert"; import { indexParagraphs } from "./paragraph.ts"; const testPage = ` @@ -15,7 +15,7 @@ Another paragraph that is #tagged * Item paragraph (don't index) `.trim(); -Deno.test("Test paragraph indexing", async () => { +test("Test paragraph indexing", async () => { const { config } = createMockSystem(); config.set("index.paragraph.all", true); @@ -34,14 +34,14 @@ Deno.test("Test paragraph indexing", async () => { let paragraphs = await indexParagraphs(pageMeta, frontmatter, tree); console.log(paragraphs); - assertEquals(paragraphs.length, 2); - assertEquals([...new Set(paragraphs[0].itags)], ["paragraph", "tag-only"]); - assertEquals(paragraphs[1].tags, ["tagged"]); + expect(paragraphs.length).toEqual(2); + expect([...new Set(paragraphs[0].itags)]).toEqual(["paragraph", "tag-only"]); + expect(paragraphs[1].tags).toEqual(["tagged"]); config.set("index.paragraph.all", false); tree = parseMarkdown(testPage); frontmatter = extractFrontMatter(tree); paragraphs = await indexParagraphs(pageMeta, frontmatter, tree); - assertEquals(paragraphs.length, 1); + expect(paragraphs.length).toEqual(1); }); diff --git a/plugs/index/snippet.test.ts b/plugs/index/snippet.test.ts index 8f44ab93..d99b9993 100644 --- a/plugs/index/snippet.test.ts +++ b/plugs/index/snippet.test.ts @@ -1,7 +1,7 @@ -import { assertEquals } from "@std/assert"; +import { expect, test } from "vitest"; import { extractSnippet } from "./snippet.ts"; -Deno.test("extractSnippetByIndentation", () => { +test("extractSnippetByIndentation", () => { const text = `* Item 1 * Item 1.1 * Item 1.1.1 @@ -12,28 +12,24 @@ Deno.test("extractSnippetByIndentation", () => { * Item 2.1`; // Unindented line with children - assertEquals( + expect( extractSnippet("test", text, text.indexOf("* Item 1")), - "* Item 1\n * Item 1.1\n * Item 1.1.1\n * Item 1.1.1.1\n * Item 1.1.2\n * Item 1.2", - ); + ).toEqual("* Item 1\n * Item 1.1\n * Item 1.1.1\n * Item 1.1.1.1\n * Item 1.1.2\n * Item 1.2"); // Indented line with children (left-aligned) - assertEquals( + expect( extractSnippet("test", text, text.indexOf("Item 1.1")), - "* Item 1.1\n * Item 1.1.1\n * Item 1.1.1.1\n * Item 1.1.2", - ); + ).toEqual("* Item 1.1\n * Item 1.1.1\n * Item 1.1.1.1\n * Item 1.1.2"); // Deeply nested line (left-aligned) - assertEquals( + expect( extractSnippet("test", text, text.indexOf("Item 1.1.1.1")), - "* Item 1.1.1.1", - ); + ).toEqual("* Item 1.1.1.1"); // Stops at sibling - assertEquals( + expect( extractSnippet("test", text, text.indexOf("Item 1.2")), - "* Item 1.2", - ); + ).toEqual("* Item 1.2"); // Stops at empty line const text2 = `* Item A @@ -41,18 +37,16 @@ Deno.test("extractSnippetByIndentation", () => { Content * Item A.2`; - assertEquals( + expect( extractSnippet("test", text2, text2.indexOf("Item A.1")), - "* Item A.1\n Content", - ); + ).toEqual("* Item A.1\n Content"); // Header extracts only itself and strips # marker const text3 = `## Sub Header More text`; - assertEquals( + expect( extractSnippet("test", text3, text3.indexOf("## Sub Header")), - "Sub Header", - ); + ).toEqual("Sub Header"); // maxLines limits the number of lines const text4 = `* Item X @@ -60,17 +54,15 @@ More text`; * Item X.2 * Item X.3 * Item X.4`; - assertEquals( + expect( extractSnippet("test", text4, text4.indexOf("* Item X"), 3), - "* Item X\n * Item X.1\n * Item X.2\n...", - ); + ).toEqual("* Item X\n * Item X.1\n * Item X.2\n..."); // maxLines limits the number of lines const text5 = ` * Item X * [ ] Hello`; const taskPos = text5.indexOf("* [ ]"); - assertEquals( + expect( extractSnippet("test", text5, text4.indexOf("* Item X")), - `* Item X\n * [ ] [[test@${taskPos}]] Hello`, - ); + ).toEqual(`* Item X\n * [ ] [[test@${taskPos}]] Hello`); }); diff --git a/plugs/index/space_lua.test.ts b/plugs/index/space_lua.test.ts index 87334121..66b58a92 100644 --- a/plugs/index/space_lua.test.ts +++ b/plugs/index/space_lua.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import { parseMarkdown } from "../../client/markdown_parser/parser.ts"; import { createMockSystem } from "../../plug-api/system_mock.ts"; import type { PageMeta } from "@silverbulletmd/silverbullet/type/index"; import { extractFrontMatter } from "./frontmatter.ts"; -import { assertEquals } from "@std/assert"; import { indexSpaceLua } from "./space_lua.ts"; const testPage = ` @@ -19,7 +19,7 @@ end \`\`\` `.trim(); -Deno.test("Test space lua indexing", async () => { +test("Test space lua indexing", async () => { createMockSystem(); const tree = parseMarkdown(testPage); @@ -35,7 +35,7 @@ Deno.test("Test space lua indexing", async () => { }; const objects = await indexSpaceLua(pageMeta, frontmatter, tree); - assertEquals(objects.length, 2); - assertEquals(objects[0].priority, undefined); - assertEquals(objects[1].priority, 10); + expect(objects.length).toEqual(2); + expect(objects[0].priority).toEqual(undefined); + expect(objects[1].priority).toEqual(10); }); diff --git a/plugs/index/space_style.test.ts b/plugs/index/space_style.test.ts index a654ca07..94228771 100644 --- a/plugs/index/space_style.test.ts +++ b/plugs/index/space_style.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import { parseMarkdown } from "../../client/markdown_parser/parser.ts"; import { createMockSystem } from "../../plug-api/system_mock.ts"; import type { PageMeta } from "@silverbulletmd/silverbullet/type/index"; import { extractFrontMatter } from "./frontmatter.ts"; -import { assertEquals } from "@std/assert"; import { indexSpaceStyle } from "./space_style.ts"; const testPage = ` @@ -17,7 +17,7 @@ Hello \`\`\` `.trim(); -Deno.test("Test space style indexing", async () => { +test("Test space style indexing", async () => { createMockSystem(); const tree = parseMarkdown(testPage); @@ -33,7 +33,7 @@ Deno.test("Test space style indexing", async () => { }; const objects = await indexSpaceStyle(pageMeta, frontmatter, tree); - assertEquals(objects.length, 2); - assertEquals(objects[0].priority, undefined); - assertEquals(objects[1].priority, 10); + expect(objects.length).toEqual(2); + expect(objects[0].priority).toEqual(undefined); + expect(objects[1].priority).toEqual(10); }); diff --git a/plugs/index/table.test.ts b/plugs/index/table.test.ts index 13f1f5be..bc6adfea 100644 --- a/plugs/index/table.test.ts +++ b/plugs/index/table.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import { parseMarkdown } from "../../client/markdown_parser/parser.ts"; import { createMockSystem } from "../../plug-api/system_mock.ts"; import type { PageMeta } from "@silverbulletmd/silverbullet/type/index"; import { extractFrontMatter } from "./frontmatter.ts"; -import { assertEquals } from "@std/assert"; import { indexTables } from "./table.ts"; const testPage = ` @@ -12,7 +12,7 @@ const testPage = ` | Fred | 21 | `.trim(); -Deno.test("Test table indexing", async () => { +test("Test table indexing", async () => { createMockSystem(); const tree = parseMarkdown(testPage); @@ -28,9 +28,9 @@ Deno.test("Test table indexing", async () => { }; const datas = await indexTables(pageMeta, frontmatter, tree); - assertEquals(datas.length, 2); - assertEquals(datas[0].name, "Frank"); - assertEquals(datas[0].age, "20"); - assertEquals(datas[1].name, "Fred"); - assertEquals(datas[1].age, "21"); + expect(datas.length).toEqual(2); + expect(datas[0].name).toEqual("Frank"); + expect(datas[0].age).toEqual("20"); + expect(datas[1].name).toEqual("Fred"); + expect(datas[1].age).toEqual("21"); }); diff --git a/plugs/index/tags.test.ts b/plugs/index/tags.test.ts index 37c2f5b8..d596c653 100644 --- a/plugs/index/tags.test.ts +++ b/plugs/index/tags.test.ts @@ -1,8 +1,8 @@ +import { expect, test } from "vitest"; import { parseMarkdown } from "../../client/markdown_parser/parser.ts"; import { createMockSystem } from "../../plug-api/system_mock.ts"; import type { PageMeta } from "@silverbulletmd/silverbullet/type/index"; import { extractFrontMatter } from "./frontmatter.ts"; -import { assertEquals } from "@std/assert"; import { indexTags } from "./tags.ts"; const testPage = ` @@ -12,7 +12,7 @@ const testPage = ` * [ ] Task #task-tag `.trim(); -Deno.test("Test tag indexing", async () => { +test("Test tag indexing", async () => { createMockSystem(); const tree = parseMarkdown(testPage); @@ -28,11 +28,11 @@ Deno.test("Test tag indexing", async () => { }; const objects = await indexTags(pageMeta, frontmatter, tree); - assertEquals(objects.length, 3); - assertEquals(objects[0].name, "page-tag"); - assertEquals(objects[0].parent, "page"); - assertEquals(objects[1].name, "item-tag"); - assertEquals(objects[1].parent, "item"); - assertEquals(objects[2].name, "task-tag"); - assertEquals(objects[2].parent, "task"); + expect(objects.length).toEqual(3); + expect(objects[0].name).toEqual("page-tag"); + expect(objects[0].parent).toEqual("page"); + expect(objects[1].name).toEqual("item-tag"); + expect(objects[1].parent).toEqual("item"); + expect(objects[2].name).toEqual("task-tag"); + expect(objects[2].parent).toEqual("task"); }); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..25c35dc2 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "lib": ["DOM", "DOM.Iterable", "ES2024"], + "types": ["node"], + "jsx": "react-jsx", + "jsxImportSource": "preact", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "noEmit": true, + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "paths": { + "@silverbulletmd/silverbullet/syscall": ["./plug-api/syscall.ts"], + "@silverbulletmd/silverbullet/syscalls": ["./plug-api/syscalls.ts"], + "@silverbulletmd/silverbullet/constants": ["./plug-api/constants.ts"], + "@silverbulletmd/silverbullet/lib/*": ["./plug-api/lib/*.ts"], + "@silverbulletmd/silverbullet/type/*": ["./plug-api/types/*.ts"], + "fuse": ["./node_modules/fuse.js"] + } + }, + "include": [ + "client/**/*", + "plug-api/**/*", + "plugs/**/*", + "bin/**/*", + "build_*.ts", + "version.ts" + ], + "exclude": ["node_modules", "dist", "client_bundle", "website"] +} diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 00000000..66a6cd1d --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,52 @@ +import { defineConfig } from "vitest/config"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +export default defineConfig({ + resolve: { + alias: [ + // @silverbulletmd/silverbullet/* → local plug-api/ files + { + find: /^@silverbulletmd\/silverbullet\/lib\/(.*)$/, + replacement: path.resolve(__dirname, "plug-api/lib/$1.ts"), + }, + { + find: /^@silverbulletmd\/silverbullet\/type\/(.*)$/, + replacement: path.resolve(__dirname, "plug-api/types/$1.ts"), + }, + { + find: "@silverbulletmd/silverbullet/syscall", + replacement: path.resolve(__dirname, "plug-api/syscall.ts"), + }, + { + find: "@silverbulletmd/silverbullet/syscalls", + replacement: path.resolve(__dirname, "plug-api/syscalls.ts"), + }, + { + find: "@silverbulletmd/silverbullet/constants", + replacement: path.resolve(__dirname, "plug-api/constants.ts"), + }, + // fuse → fuse.js + { + find: "fuse", + replacement: "fuse.js", + }, + ], + }, + test: { + include: ["**/*.test.ts"], + exclude: [ + "**/node_modules/**", + "**/.opencode/**", + "dist", + "client_bundle", + "website", + "server", + // Exclude helper test files (no test() blocks, only export helper functions) + "client/data/kv_primitives.test.ts", + "client/spaces/space_primitives.test.ts", + ], + }, +});