More JSR dependency moves

pull/1003/head
Zef Hemel 2024-07-30 17:24:17 +02:00
parent 64e116f75e
commit 9f353f7de1
58 changed files with 120 additions and 102 deletions

View File

@ -2,10 +2,10 @@ import { path } from "./lib/deps_server.ts";
import * as esbuild from "esbuild"; import * as esbuild from "esbuild";
import { compileManifests } from "./cmd/compile.ts"; import { compileManifests } from "./cmd/compile.ts";
import { builtinPlugNames } from "./plugs/builtin_plugs.ts"; import { builtinPlugNames } from "./plugs/builtin_plugs.ts";
import { parse } from "$std/flags/mod.ts"; import { parseArgs } from "@std/cli/parse-args";
if (import.meta.main) { if (import.meta.main) {
const args = parse(Deno.args, { const args = parseArgs(Deno.args, {
boolean: ["debug", "watch", "reload", "info"], boolean: ["debug", "watch", "reload", "info"],
alias: { w: "watch" }, alias: { w: "watch" },
}); });

View File

@ -1,9 +1,9 @@
import { copy } from "$std/fs/copy.ts"; import { copy } from "@std/fs";
import sass from "denosass"; import sass from "denosass";
import { bundleFolder } from "./lib/asset_bundle/builder.ts"; import { bundleFolder } from "./lib/asset_bundle/builder.ts";
import { parse } from "$std/flags/mod.ts"; import { parseArgs } from "@std/cli/parse-args";
import { patchDenoLibJS } from "./cmd/compile.ts"; import { patchDenoLibJS } from "./cmd/compile.ts";
import { denoPlugins } from "@luca/esbuild-deno-loader"; import { denoPlugins } from "@luca/esbuild-deno-loader";
import * as esbuild from "esbuild"; import * as esbuild from "esbuild";
@ -126,7 +126,7 @@ async function buildCopyBundleAssets() {
} }
if (import.meta.main) { if (import.meta.main) {
const args = parse(Deno.args, { const args = parseArgs(Deno.args, {
boolean: ["watch"], boolean: ["watch"],
alias: { w: "watch" }, alias: { w: "watch" },
default: { default: {

View File

@ -2,7 +2,7 @@ import { path, YAML } from "../lib/deps_server.ts";
import { denoPlugins } from "@luca/esbuild-deno-loader"; import { denoPlugins } from "@luca/esbuild-deno-loader";
import * as esbuild from "esbuild"; import * as esbuild from "esbuild";
import { bundleAssets } from "../lib/asset_bundle/builder.ts"; import { bundleAssets } from "../lib/asset_bundle/builder.ts";
import { Manifest } from "../lib/plugos/types.ts"; import type { Manifest } from "../lib/plugos/types.ts";
import { version } from "../version.ts"; import { version } from "../version.ts";
// const workerRuntimeUrl = new URL("./worker_runtime.ts", import.meta.url); // const workerRuntimeUrl = new URL("./worker_runtime.ts", import.meta.url);

View File

@ -1,4 +1,4 @@
import { resolve } from "$std/path/mod.ts"; import { resolve } from "@std/path";
import assets from "../dist/plug_asset_bundle.json" with { type: "json" }; import assets from "../dist/plug_asset_bundle.json" with { type: "json" };
import { determineDatabaseBackend } from "../server/db_backend.ts"; import { determineDatabaseBackend } from "../server/db_backend.ts";
import { KvPrimitives } from "$lib/data/kv_primitives.ts"; import { KvPrimitives } from "$lib/data/kv_primitives.ts";

View File

@ -2,8 +2,8 @@ import { AssetBundle } from "$lib/asset_bundle/bundle.ts";
import { compileManifest } from "../compile.ts"; import { compileManifest } from "../compile.ts";
import * as esbuild from "esbuild"; import * as esbuild from "esbuild";
import assets from "../../dist/plug_asset_bundle.json" with { type: "json" }; import assets from "../../dist/plug_asset_bundle.json" with { type: "json" };
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { dirname, join } from "$std/path/mod.ts"; import { dirname, join } from "@std/path";
import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts";
import { runPlug } from "../plug_run.ts"; import { runPlug } from "../plug_run.ts";

View File

@ -1,6 +1,6 @@
import { createSandbox } from "../../lib/plugos/sandboxes/deno_worker_sandbox.ts"; import { createSandbox } from "../../lib/plugos/sandboxes/deno_worker_sandbox.ts";
import { System } from "../../lib/plugos/system.ts"; import { System } from "../../lib/plugos/system.ts";
import { assert, assertEquals } from "$std/testing/asserts.ts"; import { assert, assertEquals } from "@std/assert";
import { compileManifest } from "../compile.ts"; import { compileManifest } from "../compile.ts";
import * as esbuild from "esbuild"; import * as esbuild from "esbuild";
import { import {

View File

@ -1,6 +1,7 @@
import * as YAML from "js-yaml"; import * as YAML from "js-yaml";
export async function hello() { export async function hello() {
// @ts-ignore: syscall is a global function
const numbers = await syscall("addNumbers", 1, 2); const numbers = await syscall("addNumbers", 1, 2);
return { return {
yamlMessage: YAML.dump({ hello: "world" }), yamlMessage: YAML.dump({ hello: "world" }),

View File

@ -37,7 +37,7 @@ export async function upgradeCommand() {
} }
// WIP: This is not yet working, but it's a start // WIP: This is not yet working, but it's a start
import { dirname } from "$std/path/mod.ts"; import { dirname } from "@std/path";
const silverBulletReleases = const silverBulletReleases =
"https://github.com/silverbulletmd/silverbullet/releases"; "https://github.com/silverbulletmd/silverbullet/releases";

View File

@ -1,4 +1,4 @@
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { parseCommand } from "./command.ts"; import { parseCommand } from "./command.ts";
Deno.test("Command parser", () => { Deno.test("Command parser", () => {

View File

@ -1,4 +1,4 @@
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { parseExpression } from "$common/expression_parser.ts"; import { parseExpression } from "$common/expression_parser.ts";
Deno.test("Test expression parser", () => { Deno.test("Test expression parser", () => {

View File

@ -4,7 +4,7 @@ import {
findNodeOfType, findNodeOfType,
renderToText, renderToText,
} from "$sb/lib/tree.ts"; } from "$sb/lib/tree.ts";
import { assertEquals, assertNotEquals } from "$std/testing/asserts.ts"; import { assertEquals, assertNotEquals } from "@std/assert";
import { extendedMarkdownLanguage } from "./parser.ts"; import { extendedMarkdownLanguage } from "./parser.ts";
const sample1 = `--- const sample1 = `---

View File

@ -1,11 +1,7 @@
import { beforeEach, describe, it } from "$std/testing/bdd.ts"; import { beforeEach, describe, it } from "@std/testing/bdd";
import { buildQueryFunctions } from "$common/query_functions.ts"; import { buildQueryFunctions } from "$common/query_functions.ts";
import type { System } from "$lib/plugos/system.ts"; import type { System } from "$lib/plugos/system.ts";
import { import { assertEquals, assertRejects, assertThrows } from "@std/assert";
assertEquals,
assertRejects,
assertThrows,
} from "$std/testing/asserts.ts";
let functions: ReturnType<typeof buildQueryFunctions>; let functions: ReturnType<typeof buildQueryFunctions>;

View File

@ -1,4 +1,4 @@
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { parseYamlSettings } from "./settings.ts"; import { parseYamlSettings } from "./settings.ts";
Deno.test("Settings regex", () => { Deno.test("Settings regex", () => {

View File

@ -1,5 +1,5 @@
import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { ChunkedKvStoreSpacePrimitives } from "./chunked_datastore_space_primitives.ts"; import { ChunkedKvStoreSpacePrimitives } from "./chunked_datastore_space_primitives.ts";
import { testSpacePrimitives } from "./space_primitives.test.ts"; import { testSpacePrimitives } from "./space_primitives.test.ts";

View File

@ -1,5 +1,5 @@
import * as path from "$std/path/mod.ts"; import * as path from "@std/path";
import { readAll } from "$std/streams/read_all.ts"; import { readAll } from "@std/io/read-all";
import { SpacePrimitives } from "./space_primitives.ts"; import { SpacePrimitives } from "./space_primitives.ts";
import { mime } from "mimetypes"; import { mime } from "mimetypes";
import { FileMeta } from "../../plug-api/types.ts"; import { FileMeta } from "../../plug-api/types.ts";

View File

@ -1,4 +1,4 @@
import { assert, assertEquals } from "$std/testing/asserts.ts"; import { assert, assertEquals } from "@std/assert";
import { SpacePrimitives } from "./space_primitives.ts"; import { SpacePrimitives } from "./space_primitives.ts";
export async function testSpacePrimitives(spacePrimitives: SpacePrimitives) { export async function testSpacePrimitives(spacePrimitives: SpacePrimitives) {

View File

@ -1,6 +1,6 @@
import { SpaceSync, SyncStatusItem } from "./sync.ts"; import { SpaceSync, SyncStatusItem } from "./sync.ts";
import { DiskSpacePrimitives } from "./disk_space_primitives.ts"; import { DiskSpacePrimitives } from "./disk_space_primitives.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
Deno.test("Test store", async () => { Deno.test("Test store", async () => {
const primaryPath = await Deno.makeTempDir(); const primaryPath = await Deno.makeTempDir();

View File

@ -1,5 +1,5 @@
import { builtinFunctions } from "../../lib/builtin_query_functions.ts"; import { builtinFunctions } from "../../lib/builtin_query_functions.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { renderTemplate } from "./render.ts"; import { renderTemplate } from "./render.ts";
import { parseTemplate } from "./template_parser.ts"; import { parseTemplate } from "./template_parser.ts";

View File

@ -1,4 +1,4 @@
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { parseTemplate } from "./template_parser.ts"; import { parseTemplate } from "./template_parser.ts";
Deno.test("Test template", () => { Deno.test("Test template", () => {

View File

@ -1,4 +1,15 @@
{ {
"name": "@silverbulletmd/silverbullet",
"version": "0.0.1",
"exports": {
"./syscalls": "./plug-api/syscalls.ts"
},
"publish": {
"exclude": [
"website",
"CHANGELOG.md"
]
},
"tasks": { "tasks": {
"clean": "rm -rf dist dist_client_bundle dist_plug_bundle website_build", "clean": "rm -rf dist dist_client_bundle dist_plug_bundle website_build",
"deep-clean-mac": "rm -f deno.lock && rm -rf $HOME/Library/Caches/deno && deno task clean", "deep-clean-mac": "rm -f deno.lock && rm -rf $HOME/Library/Caches/deno && deno task clean",
@ -59,7 +70,6 @@
"$common/": "./common/", "$common/": "./common/",
"$lib/": "./lib/", "$lib/": "./lib/",
"$sb/": "./plug-api/", "$sb/": "./plug-api/",
"$std/": "https://deno.land/std@0.189.0/",
"$type/": "./type/", "$type/": "./type/",
"@codemirror/autocomplete": "https://esm.sh/@codemirror/autocomplete@6.17.0?external=@codemirror/state,@codemirror/commands,@lezer/common,@codemirror/view,@codemirror/language&target=es2022", "@codemirror/autocomplete": "https://esm.sh/@codemirror/autocomplete@6.17.0?external=@codemirror/state,@codemirror/commands,@lezer/common,@codemirror/view,@codemirror/language&target=es2022",
"@codemirror/commands": "https://esm.sh/@codemirror/commands@6.6.0?external=@codemirror/state,@codemirror/view,@codemirror/language,@lezer/common&target=es2022", "@codemirror/commands": "https://esm.sh/@codemirror/commands@6.6.0?external=@codemirror/state,@codemirror/view,@codemirror/language,@lezer/common&target=es2022",
@ -83,6 +93,13 @@
"@lezer/markdown": "https://esm.sh/@lezer/markdown@1.3.0?external=@lezer/common,@codemirror/language,@lezer/highlight,@lezer/lr&target=es2022", "@lezer/markdown": "https://esm.sh/@lezer/markdown@1.3.0?external=@lezer/common,@codemirror/language,@lezer/highlight,@lezer/lr&target=es2022",
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.10.3", "@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.10.3",
"@replit/codemirror-vim": "https://esm.sh/@replit/codemirror-vim@6.2.1?external=@codemirror/state,@codemirror/language,@codemirror/view,@codemirror/search,@codemirror/commands", "@replit/codemirror-vim": "https://esm.sh/@replit/codemirror-vim@6.2.1?external=@codemirror/state,@codemirror/language,@codemirror/view,@codemirror/search,@codemirror/commands",
"@std/assert": "jsr:@std/assert@^1.0.1",
"@std/cli": "jsr:@std/cli@^1.0.1",
"@std/fs": "jsr:@std/fs@^1.0.0",
"@std/io": "jsr:@std/io@^0.224.3",
"@std/io/read-all": "jsr:@std/io@^0.224.3/read-all",
"@std/path": "jsr:@std/path@^1.0.2",
"@std/testing": "jsr:@std/testing@^0.225.3",
"cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.4/", "cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.4/",
"crelt": "https://esm.sh/crelt@1.0.6", "crelt": "https://esm.sh/crelt@1.0.6",
"denosass": "https://deno.land/x/denosass@1.0.6/mod.ts", "denosass": "https://deno.land/x/denosass@1.0.6/mod.ts",

View File

@ -1,5 +1,5 @@
import { AssetBundle } from "./bundle.ts"; import { AssetBundle } from "./bundle.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
Deno.test("Asset bundle", () => { Deno.test("Asset bundle", () => {
const assetBundle = new AssetBundle(); const assetBundle = new AssetBundle();

View File

@ -1,4 +1,4 @@
import { assert, assertEquals } from "$std/testing/asserts.ts"; import { assert, assertEquals } from "@std/assert";
import { batchRequests, PromiseQueue, sleep } from "./async.ts"; import { batchRequests, PromiseQueue, sleep } from "./async.ts";
Deno.test("PromiseQueue test", async () => { Deno.test("PromiseQueue test", async () => {

View File

@ -1,6 +1,6 @@
import { describe, it } from "$std/testing/bdd.ts"; import { describe, it } from "@std/testing/bdd";
import { builtinFunctions } from "./builtin_query_functions.ts"; import { builtinFunctions } from "./builtin_query_functions.ts";
import { assertEquals, assertThrows } from "$std/testing/asserts.ts"; import { assertEquals, assertThrows } from "@std/assert";
describe("replace()", () => { describe("replace()", () => {
const { replace } = builtinFunctions; const { replace } = builtinFunctions;

View File

@ -1,4 +1,4 @@
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { determineTags, isTemplate } from "./cheap_yaml.ts"; import { determineTags, isTemplate } from "./cheap_yaml.ts";
Deno.test("cheap yaml", () => { Deno.test("cheap yaml", () => {

View File

@ -3,7 +3,7 @@ import { IndexedDBKvPrimitives } from "../data/indexeddb_kv_primitives.ts";
import { cleanupEmptyObjects, DataStore } from "../data/datastore.ts"; import { cleanupEmptyObjects, DataStore } from "../data/datastore.ts";
import { DenoKvPrimitives } from "../data/deno_kv_primitives.ts"; import { DenoKvPrimitives } from "../data/deno_kv_primitives.ts";
import { KvPrimitives } from "../data/kv_primitives.ts"; import { KvPrimitives } from "../data/kv_primitives.ts";
import { assertEquals, assertThrows } from "$std/testing/asserts.ts"; import { assertEquals, assertThrows } from "@std/assert";
import { PrefixedKvPrimitives } from "../data/prefixed_kv_primitives.ts"; import { PrefixedKvPrimitives } from "../data/prefixed_kv_primitives.ts";
import { Query } from "../../plug-api/types.ts"; import { Query } from "../../plug-api/types.ts";

View File

@ -1,5 +1,5 @@
import { KvPrimitives } from "./kv_primitives.ts"; import { KvPrimitives } from "./kv_primitives.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { KV } from "../../plug-api/types.ts"; import { KV } from "../../plug-api/types.ts";
export async function allTests(db: KvPrimitives) { export async function allTests(db: KvPrimitives) {

View File

@ -1,9 +1,9 @@
import { DataStoreMQ } from "./mq.datastore.ts"; import { DataStoreMQ } from "./mq.datastore.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { DenoKvPrimitives } from "./deno_kv_primitives.ts"; import { DenoKvPrimitives } from "./deno_kv_primitives.ts";
import { DataStore } from "./datastore.ts"; import { DataStore } from "./datastore.ts";
import { PrefixedKvPrimitives } from "./prefixed_kv_primitives.ts"; import { PrefixedKvPrimitives } from "./prefixed_kv_primitives.ts";
import { FakeTime } from "$std/testing/time.ts"; import { FakeTime } from "@std/testing/time";
import type { MQMessage } from "../../plug-api/types.ts"; import type { MQMessage } from "../../plug-api/types.ts";
Deno.test("DataStore MQ", async () => { Deno.test("DataStore MQ", async () => {

View File

@ -1,5 +1,5 @@
import { sleep } from "$lib/async.ts"; import { sleep } from "$lib/async.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { LimitedMap } from "./limited_map.ts"; import { LimitedMap } from "./limited_map.ts";
Deno.test("limited map", async () => { Deno.test("limited map", async () => {

View File

@ -1,6 +1,6 @@
import { ttlCache } from "$lib/memory_cache.ts"; import { ttlCache } from "$lib/memory_cache.ts";
import { sleep } from "$lib/async.ts"; import { sleep } from "$lib/async.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
Deno.test("Memory cache", async () => { Deno.test("Memory cache", async () => {
let calls = 0; let calls = 0;

View File

@ -1,5 +1,5 @@
import { FileMeta } from "../../../plug-api/types.ts"; import { FileMeta } from "../../../plug-api/types.ts";
import { assert } from "$std/testing/asserts.ts"; import { assert } from "@std/assert";
import { path } from "../../deps_server.ts"; import { path } from "../../deps_server.ts";
import fileSystemSyscalls from "./fs.deno.ts"; import fileSystemSyscalls from "./fs.deno.ts";

View File

@ -1,7 +1,7 @@
import "$sb/lib/syscall_mock.ts"; import "$sb/lib/syscall_mock.ts";
import { parse } from "$common/markdown_parser/parse_tree.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts";
import { extractAttributes } from "$sb/lib/attribute.ts"; import { extractAttributes } from "$sb/lib/attribute.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { renderToText } from "./tree.ts"; import { renderToText } from "./tree.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";

View File

@ -1,6 +1,6 @@
import "$sb/lib/syscall_mock.ts"; import "$sb/lib/syscall_mock.ts";
import { parse } from "$common/markdown_parser/parse_tree.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { extractFeedItems } from "$sb/lib/feed.ts"; import { extractFeedItems } from "$sb/lib/feed.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";

View File

@ -1,4 +1,4 @@
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { cleanupJSON, deepEqual, deepObjectMerge } from "./json.ts"; import { cleanupJSON, deepEqual, deepObjectMerge } from "./json.ts";
Deno.test("utils", () => { Deno.test("utils", () => {
@ -18,6 +18,9 @@ Deno.test("utils", () => {
assertEquals(cleanupJSON({ a: [{ "a.b": 1 }] }), { assertEquals(cleanupJSON({ a: [{ "a.b": 1 }] }), {
a: [{ a: { b: 1 } }], a: [{ a: { b: 1 } }],
}); });
assertEquals(cleanupJSON(new Date("2023-05-13T12:30:00Z")), "2023-05-13T12:30:00.000Z"); assertEquals(
cleanupJSON(new Date("2023-05-13T12:30:00Z")),
"2023-05-13T12:30:00.000Z",
);
assertEquals(cleanupJSON(new Date("2023-05-03T00:00:00Z")), "2023-05-03"); assertEquals(cleanupJSON(new Date("2023-05-03T00:00:00Z")), "2023-05-03");
}); });

View File

@ -1,9 +1,5 @@
import { encodePageRef, parsePageRef, validatePageName } from "./page_ref.ts"; import { encodePageRef, parsePageRef, validatePageName } from "./page_ref.ts";
import { import { assertEquals, AssertionError, assertThrows } from "@std/assert";
assertEquals,
AssertionError,
assertThrows,
} from "$std/testing/asserts.ts";
Deno.test("Page utility functions", () => { Deno.test("Page utility functions", () => {
// Base cases // Base cases

View File

@ -1,6 +1,6 @@
import { parse } from "$common/markdown_parser/parse_tree.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts";
import { AST, collectNodesOfType, parseTreeToAST } from "./tree.ts"; import { AST, collectNodesOfType, parseTreeToAST } from "./tree.ts";
import { assert, assertEquals } from "$std/testing/asserts.ts"; import { assert, assertEquals } from "@std/assert";
import { astToKvQuery } from "$sb/lib/parse-query.ts"; import { astToKvQuery } from "$sb/lib/parse-query.ts";
import { languageFor } from "$common/languages.ts"; import { languageFor } from "$common/languages.ts";

View File

@ -1,5 +1,5 @@
import { evalQueryExpression } from "$sb/lib/query_expression.ts"; import { evalQueryExpression } from "$sb/lib/query_expression.ts";
import { assert, assertEquals } from "$std/testing/asserts.ts"; import { assert, assertEquals } from "@std/assert";
Deno.test("Test query expression evaluation", async () => { Deno.test("Test query expression evaluation", async () => {
assertEquals( assertEquals(

View File

@ -4,7 +4,7 @@ import {
resolvePath, resolvePath,
rewritePageRefs, rewritePageRefs,
} from "$sb/lib/resolve.ts"; } from "$sb/lib/resolve.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { ParseTree, renderToText } from "./tree.ts"; import { ParseTree, renderToText } from "./tree.ts";
import { parse } from "$common/markdown_parser/parse_tree.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";

View File

@ -1,5 +1,6 @@
import { YAML } from "../../lib/deps_server.ts"; import { YAML } from "../../lib/deps_server.ts";
// @ts-ignore: syscall is a global function
globalThis.syscall = (name: string, ...args: readonly any[]) => { globalThis.syscall = (name: string, ...args: readonly any[]) => {
switch (name) { switch (name) {
case "yaml.parse": case "yaml.parse":

View File

@ -9,7 +9,7 @@ import {
renderToText, renderToText,
replaceNodesMatching, replaceNodesMatching,
} from "./tree.ts"; } from "./tree.ts";
import { assertEquals, assertNotEquals } from "$std/testing/asserts.ts"; import { assertEquals, assertNotEquals } from "@std/assert";
import { parse } from "$common/markdown_parser/parse_tree.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";

View File

@ -1,16 +1,14 @@
declare global { // declare global {
function syscall(name: string, ...args: any[]): Promise<any>; // function syscall(name: string, ...args: any[]): Promise<any>;
} // }
// This is the case when running tests only, so giving it a dummy syscall function // This is the case when running tests only, so giving it a dummy syscall function
if (typeof self === "undefined") { if (typeof self === "undefined") {
// @ts-ignore: test (self as any) = {
// deno-lint-ignore no-global-assign
self = {
syscall: () => { syscall: () => {
throw new Error("Not implemented here"); throw new Error("Not implemented here");
}, },
}; };
} }
export const syscall = globalThis.syscall; export const syscall = (globalThis as any).syscall;

View File

@ -10,6 +10,6 @@ export function render(
} }
// Refresh all code widgets on the page that support it // Refresh all code widgets on the page that support it
export function refreshAll() { export function refreshAll(): Promise<void> {
return syscall("codeWidget.refreshAll"); return syscall("codeWidget.refreshAll");
} }

View File

@ -1,12 +1,12 @@
import { syscall } from "../syscall.ts"; import { syscall } from "../syscall.ts";
export function resetClient() { export function resetClient(): Promise<void> {
return syscall("debug.resetClient"); return syscall("debug.resetClient");
} }
/** /**
* Wipes the entire state KV store and the entire space KV store. * Wipes the entire state KV store and the entire space KV store.
*/ */
export function cleanup() { export function cleanup(): Promise<void> {
return syscall("debug.cleanup"); return syscall("debug.cleanup");
} }

View File

@ -19,7 +19,7 @@ export function getText(): Promise<string> {
* This updates the editor text, but in a minimal-diff way: * This updates the editor text, but in a minimal-diff way:
* it compares the current editor text with the new text, and only sends the changes to the editor, thereby preserving cursor location * it compares the current editor text with the new text, and only sends the changes to the editor, thereby preserving cursor location
*/ */
export function setText(newText: string) { export function setText(newText: string): Promise<void> {
return syscall("editor.setText", newText); return syscall("editor.setText", newText);
} }
@ -183,36 +183,36 @@ export function vimEx(exCommand: string): Promise<any> {
} }
// Folding // Folding
export function fold() { export function fold(): Promise<void> {
return syscall("editor.fold"); return syscall("editor.fold");
} }
export function unfold() { export function unfold(): Promise<void> {
return syscall("editor.unfold"); return syscall("editor.unfold");
} }
export function toggleFold() { export function toggleFold(): Promise<void> {
return syscall("editor.toggleFold"); return syscall("editor.toggleFold");
} }
export function foldAll() { export function foldAll(): Promise<void> {
return syscall("editor.foldAll"); return syscall("editor.foldAll");
} }
export function unfoldAll() { export function unfoldAll(): Promise<void> {
return syscall("editor.unfoldAll"); return syscall("editor.unfoldAll");
} }
// Undo/redo // Undo/redo
export function undo() { export function undo(): Promise<void> {
return syscall("editor.undo"); return syscall("editor.undo");
} }
export function redo() { export function redo(): Promise<void> {
return syscall("editor.redo"); return syscall("editor.redo");
} }
export function openSearchPanel() { export function openSearchPanel(): Promise<void> {
return syscall("editor.openSearchPanel"); return syscall("editor.openSearchPanel");
} }
@ -220,6 +220,6 @@ export function copyToClipboard(data: string | Blob): Promise<void> {
return syscall("editor.copyToClipboard", data); return syscall("editor.copyToClipboard", data);
} }
export function deleteLine() { export function deleteLine(): Promise<void> {
return syscall("editor.deleteLine"); return syscall("editor.deleteLine");
} }

View File

@ -14,7 +14,7 @@ export function dispatchEvent(
}, timeout); }, timeout);
} }
syscall("event.dispatch", eventName, data) syscall("event.dispatch", eventName, data)
.then((r) => { .then((r: any) => {
if (timeouter !== -1) { if (timeouter !== -1) {
clearTimeout(timeouter); clearTimeout(timeouter);
} }

View File

@ -1,19 +1,19 @@
import { syscall } from "../syscall.ts"; import { syscall } from "../syscall.ts";
import type { MQStats } from "../types.ts"; import type { MQStats } from "../types.ts";
export function send(queue: string, body: any) { export function send(queue: string, body: any): Promise<void> {
return syscall("mq.send", queue, body); return syscall("mq.send", queue, body);
} }
export function batchSend(queue: string, bodies: any[]) { export function batchSend(queue: string, bodies: any[]): Promise<void> {
return syscall("mq.batchSend", queue, bodies); return syscall("mq.batchSend", queue, bodies);
} }
export function ack(queue: string, id: string) { export function ack(queue: string, id: string): Promise<void> {
return syscall("mq.ack", queue, id); return syscall("mq.ack", queue, id);
} }
export function batchAck(queue: string, ids: string[]) { export function batchAck(queue: string, ids: string[]): Promise<void> {
return syscall("mq.batchAck", queue, ids); return syscall("mq.batchAck", queue, ids);
} }

View File

@ -39,7 +39,7 @@ export function applyAttributeExtractors(
return syscall("system.applyAttributeExtractors", tags, text, tree); return syscall("system.applyAttributeExtractors", tags, text, tree);
} }
export function reloadPlugs() { export function reloadPlugs(): Promise<void> {
return syscall("system.reloadPlugs"); return syscall("system.reloadPlugs");
} }

View File

@ -1,4 +1,4 @@
import { assert, assertEquals } from "$std/testing/asserts.ts"; import { assert, assertEquals } from "@std/assert";
import { federatedPathToLocalPath, wildcardPathToRegex } from "./util.ts"; import { federatedPathToLocalPath, wildcardPathToRegex } from "./util.ts";
Deno.test("Test wildcardPathToRegex", () => { Deno.test("Test wildcardPathToRegex", () => {

View File

@ -1,4 +1,9 @@
import { KV, KvQuery, ObjectQuery, ObjectValue } from "../../plug-api/types.ts"; import type {
KV,
KvQuery,
ObjectQuery,
ObjectValue,
} from "../../plug-api/types.ts";
import { ttlCache } from "$lib/memory_cache.ts"; import { ttlCache } from "$lib/memory_cache.ts";
import { system } from "$sb/syscalls.ts"; import { system } from "$sb/syscalls.ts";

View File

@ -1,4 +1,4 @@
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { extractSnippetAroundIndex } from "./snippet_extractor.ts"; import { extractSnippetAroundIndex } from "./snippet_extractor.ts";
Deno.test("SnippetExtractor", () => { Deno.test("SnippetExtractor", () => {

View File

@ -1,4 +1,4 @@
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { renderHtml } from "./html_render.ts"; import { renderHtml } from "./html_render.ts";
Deno.test("HTML Render", () => { Deno.test("HTML Render", () => {

View File

@ -4,7 +4,7 @@ import { System } from "../../lib/plugos/system.ts";
import { createSandbox } from "../../lib/plugos/sandboxes/deno_worker_sandbox.ts"; import { createSandbox } from "../../lib/plugos/sandboxes/deno_worker_sandbox.ts";
import { renderMarkdownToHtml } from "./markdown_render.ts"; import { renderMarkdownToHtml } from "./markdown_render.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
Deno.test("Markdown render", async () => { Deno.test("Markdown render", async () => {
const system = new System<any>("server"); const system = new System<any>("server");

View File

@ -1,5 +1,5 @@
import { walk } from "$std/fs/walk.ts"; import { walk } from "@std/fs/walk";
import { resolve } from "$std/path/mod.ts"; import { resolve } from "@std/path";
import { mime } from "mimetypes"; import { mime } from "mimetypes";
import { FileMeta } from "../plug-api/types.ts"; import { FileMeta } from "../plug-api/types.ts";

View File

@ -1,6 +1,6 @@
import { sleep } from "$lib/async.ts"; import { sleep } from "$lib/async.ts";
import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { JWTIssuer } from "./crypto.ts"; import { JWTIssuer } from "./crypto.ts";
Deno.test("Test JWT crypto", async () => { Deno.test("Test JWT crypto", async () => {

View File

@ -1,7 +1,7 @@
import { DenoKvPrimitives } from "$lib/data/deno_kv_primitives.ts"; import { DenoKvPrimitives } from "$lib/data/deno_kv_primitives.ts";
import { KvPrimitives } from "$lib/data/kv_primitives.ts"; import { KvPrimitives } from "$lib/data/kv_primitives.ts";
import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts";
import { resolve } from "$std/path/mod.ts"; import { resolve } from "@std/path";
/** /**
* Environment variables: * Environment variables:

View File

@ -1,18 +1,19 @@
import { deleteCookie, getCookie, setCookie } from "hono/helper.ts"; import { deleteCookie, getCookie, setCookie } from "hono/helper.ts";
import { cors } from "hono/middleware.ts"; import { cors } from "hono/middleware.ts";
import { type Context, Hono, type HonoRequest, validator } from "hono/mod.ts"; import { type Context, Hono, type HonoRequest, validator } from "hono/mod.ts";
import { AssetBundle } from "$lib/asset_bundle/bundle.ts"; import type { AssetBundle } from "$lib/asset_bundle/bundle.ts";
import { EndpointRequest, EndpointResponse, FileMeta } from "$sb/types.ts"; import type { EndpointRequest, EndpointResponse, FileMeta } from "$sb/types.ts";
import { ShellRequest } from "$type/rpc.ts"; import type { ShellRequest } from "$type/rpc.ts";
import { SpaceServer, SpaceServerConfig } from "./instance.ts"; import { SpaceServer } from "./instance.ts";
import { KvPrimitives } from "$lib/data/kv_primitives.ts"; import type { SpaceServerConfig } from "./instance.ts";
import type { KvPrimitives } from "$lib/data/kv_primitives.ts";
import { PrefixedKvPrimitives } from "$lib/data/prefixed_kv_primitives.ts"; import { PrefixedKvPrimitives } from "$lib/data/prefixed_kv_primitives.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
import { parse } from "$common/markdown_parser/parse_tree.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts";
import { renderMarkdownToHtml } from "../plugs/markdown/markdown_render.ts"; import { renderMarkdownToHtml } from "../plugs/markdown/markdown_render.ts";
import { looksLikePathWithExtension, parsePageRef } from "$sb/lib/page_ref.ts"; import { looksLikePathWithExtension, parsePageRef } from "$sb/lib/page_ref.ts";
import { base64Encode } from "$lib/crypto.ts"; import { base64Encode } from "$lib/crypto.ts";
import * as path from "$std/path/mod.ts"; import { basename, dirname, join } from "@std/path";
const authenticationExpirySeconds = 60 * 60 * 24 * 7; // 1 week const authenticationExpirySeconds = 60 * 60 * 24 * 7; // 1 week
@ -600,10 +601,10 @@ export class HttpServer {
} }
} }
const filename = path.posix.basename(name, mdExt); const filename = basename(name, mdExt);
if (filename.trim() !== filename) { if (filename.trim() !== filename) {
const newName = path.posix.join( const newName = join(
path.posix.dirname(name), dirname(name),
filename.trim(), filename.trim(),
); );
return c.redirect(`/${newName}`); return c.redirect(`/${newName}`);
@ -647,7 +648,7 @@ export class HttpServer {
return c.text("Forbidden", 403); return c.text("Forbidden", 403);
} }
const filename = path.posix.basename(name, mdExt); const filename = basename(name, mdExt);
if (filename.trim() !== filename) { if (filename.trim() !== filename) {
return c.text("Malformed filename", 400); return c.text("Malformed filename", 400);
} }

View File

@ -1,6 +1,6 @@
import { DiskSpacePrimitives } from "$common/spaces/disk_space_primitives.ts"; import { DiskSpacePrimitives } from "$common/spaces/disk_space_primitives.ts";
import { SpacePrimitives } from "$common/spaces/space_primitives.ts"; import { SpacePrimitives } from "$common/spaces/space_primitives.ts";
import { resolve } from "$std/path/mod.ts"; import { resolve } from "@std/path";
import { S3SpacePrimitives } from "$common/spaces/s3_space_primitives.ts"; import { S3SpacePrimitives } from "$common/spaces/s3_space_primitives.ts";
import { KvPrimitives } from "$lib/data/kv_primitives.ts"; import { KvPrimitives } from "$lib/data/kv_primitives.ts";
import { ChunkedKvStoreSpacePrimitives } from "$common/spaces/chunked_datastore_space_primitives.ts"; import { ChunkedKvStoreSpacePrimitives } from "$common/spaces/chunked_datastore_space_primitives.ts";

View File

@ -1,5 +1,5 @@
import { rangeLength, rangesOverlap } from "./change.ts"; import { rangeLength, rangesOverlap } from "./change.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
Deno.test("rangeLength", () => { Deno.test("rangeLength", () => {
assertEquals(rangeLength({ from: 4, to: 11 }), 7); assertEquals(rangeLength({ from: 4, to: 11 }), 7);

View File

@ -1,5 +1,5 @@
import { FilterOption } from "$lib/web.ts"; import { FilterOption } from "$lib/web.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "@std/assert";
import { fuzzySearchAndSort } from "./fuse_search.ts"; import { fuzzySearchAndSort } from "./fuse_search.ts";
Deno.test("testFuzzyFilter", () => { Deno.test("testFuzzyFilter", () => {