diff --git a/build_bundle.ts b/build_bundle.ts index c223fefa..50e5fa6e 100644 --- a/build_bundle.ts +++ b/build_bundle.ts @@ -1,4 +1,5 @@ -import { denoPlugins, esbuild } from "./lib/plugos/deps.ts"; +import { denoPlugins } from "esbuild_deno_loader"; +import * as esbuild from "esbuild"; await Deno.mkdir("dist", { recursive: true }); await esbuild.build({ diff --git a/build_plugs.ts b/build_plugs.ts index 5129d00f..da82ec80 100644 --- a/build_plugs.ts +++ b/build_plugs.ts @@ -1,9 +1,11 @@ -import { esbuild, flags, path } from "./lib/plugos/deps.ts"; -import { compileManifests } from "./lib/plugos/compile.ts"; +import { path } from "./lib/deps_server.ts"; +import * as esbuild from "esbuild"; +import { compileManifests } from "./cmd/compile.ts"; import { builtinPlugNames } from "./plugs/builtin_plugs.ts"; +import { parse } from "$std/flags/mod.ts"; if (import.meta.main) { - const args = flags.parse(Deno.args, { + const args = parse(Deno.args, { boolean: ["debug", "watch", "reload", "info"], alias: { w: "watch" }, }); diff --git a/build_web.ts b/build_web.ts index d6bde12b..2597db78 100644 --- a/build_web.ts +++ b/build_web.ts @@ -1,11 +1,12 @@ -import { copy } from "https://deno.land/std@0.165.0/fs/copy.ts"; +import { copy } from "$std/fs/copy.ts"; -import sass from "https://deno.land/x/denosass@1.0.4/mod.ts"; +import sass from "denosass"; import { bundleFolder } from "./lib/asset_bundle/builder.ts"; -import * as flags from "https://deno.land/std@0.165.0/flags/mod.ts"; -import { patchDenoLibJS } from "./lib/plugos/compile.ts"; -import { denoPlugins, esbuild } from "./lib/plugos/deps.ts"; +import { parse } from "$std/flags/mod.ts"; +import { patchDenoLibJS } from "./cmd/compile.ts"; +import { denoPlugins } from "esbuild_deno_loader"; +import * as esbuild from "esbuild"; export async function bundleAll( watch: boolean, @@ -126,7 +127,7 @@ async function buildCopyBundleAssets() { } if (import.meta.main) { - const args = flags.parse(Deno.args, { + const args = parse(Deno.args, { boolean: ["watch"], alias: { w: "watch" }, default: { diff --git a/lib/plugos/compile.ts b/cmd/compile.ts similarity index 92% rename from lib/plugos/compile.ts rename to cmd/compile.ts index bd331304..a605574e 100644 --- a/lib/plugos/compile.ts +++ b/cmd/compile.ts @@ -1,8 +1,9 @@ -import { denoPlugins, esbuild, path, YAML } from "./deps.ts"; - -import { bundleAssets } from "$lib/asset_bundle/builder.ts"; -import { Manifest } from "$lib/plugos/types.ts"; -import { version } from "../../version.ts"; +import { path, YAML } from "../lib/deps_server.ts"; +import { denoPlugins } from "esbuild_deno_loader"; +import * as esbuild from "esbuild"; +import { bundleAssets } from "../lib/asset_bundle/builder.ts"; +import { Manifest } from "../lib/plugos/types.ts"; +import { version } from "../version.ts"; // const workerRuntimeUrl = new URL("./worker_runtime.ts", import.meta.url); const workerRuntimeUrl = @@ -104,7 +105,7 @@ setupMessageListener(functionMapping, manifest); ...denoPlugins({ // TODO do this differently importMapURL: options.importMap || - new URL("../../import_map.json", import.meta.url).toString(), + new URL("../import_map.json", import.meta.url).toString(), loader: "native", }), ], diff --git a/cmd/plug_compile.ts b/cmd/plug_compile.ts index 499fa7df..9bf9e351 100644 --- a/cmd/plug_compile.ts +++ b/cmd/plug_compile.ts @@ -1,5 +1,5 @@ -import { compileManifests } from "../lib/plugos/compile.ts"; -import { esbuild } from "../lib/plugos/deps.ts"; +import { compileManifests } from "./compile.ts"; +import * as esbuild from "esbuild"; export async function plugCompileCommand( { watch, dist, debug, info, importmap, runtimeUrl }: { diff --git a/cmd/plug_run.ts b/cmd/plug_run.ts index 9283ebd6..e73d7af2 100644 --- a/cmd/plug_run.ts +++ b/cmd/plug_run.ts @@ -1,7 +1,5 @@ -import { path } from "$common/deps.ts"; -import assets from "../dist/plug_asset_bundle.json" assert { - type: "json", -}; +import { resolve } from "$std/path/mod.ts"; +import assets from "../dist/plug_asset_bundle.json" with { type: "json" }; import { determineDatabaseBackend } from "../server/db_backend.ts"; import { KvPrimitives } from "$lib/data/kv_primitives.ts"; import { DiskSpacePrimitives } from "$common/spaces/disk_space_primitives.ts"; @@ -10,7 +8,7 @@ import { ServerSystem } from "../server/server_system.ts"; import { AssetBundlePlugSpacePrimitives } from "$common/spaces/asset_bundle_space_primitives.ts"; import { EndpointHook } from "../server/hooks/endpoint.ts"; import { LocalShell } from "../server/shell_backend.ts"; -import { Hono } from "../server/deps.ts"; +import { Hono } from "hono/mod.ts"; import { DataStore } from "$lib/data/datastore.ts"; import { DataStoreMQ } from "$lib/data/mq.datastore.ts"; import { EventHook } from "../common/hooks/event.ts"; @@ -29,7 +27,7 @@ export async function plugRunCommand( functionName: string | undefined, ...args: string[] ) { - spacePath = path.resolve(spacePath); + spacePath = resolve(spacePath); console.log("Space path", spacePath); console.log("Function to run:", functionName, "with arguments", args); diff --git a/cmd/plug_run.test.ts b/cmd/test/plug_run.test.ts similarity index 52% rename from cmd/plug_run.test.ts rename to cmd/test/plug_run.test.ts index aa67cda1..6533f616 100644 --- a/cmd/plug_run.test.ts +++ b/cmd/test/plug_run.test.ts @@ -1,11 +1,11 @@ import { AssetBundle } from "$lib/asset_bundle/bundle.ts"; -import { compileManifest } from "$lib/plugos/compile.ts"; -import { esbuild } from "$lib/plugos/deps.ts"; -import assets from "../dist/plug_asset_bundle.json" assert { type: "json" }; -import { assertEquals } from "$lib/test_deps.ts"; -import { path } from "$common/deps.ts"; +import { compileManifest } from "../compile.ts"; +import * as esbuild from "esbuild"; +import assets from "../../dist/plug_asset_bundle.json" assert { type: "json" }; +import { assertEquals } from "$std/testing/asserts.ts"; +import { dirname, join } from "$std/path/mod.ts"; import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; -import { runPlug } from "./plug_run.ts"; +import { runPlug } from "../plug_run.ts"; Deno.test("Test plug run", { sanitizeResources: false, @@ -13,14 +13,14 @@ Deno.test("Test plug run", { }, async () => { const assetBundle = new AssetBundle(assets); - const testFolder = path.dirname(new URL(import.meta.url).pathname); - const testSpaceFolder = path.join(testFolder, "test_space"); + const testFolder = dirname(new URL(import.meta.url).pathname); + const testSpaceFolder = join(testFolder, "test_space"); - const plugFolder = path.join(testSpaceFolder, "_plug"); + const plugFolder = join(testSpaceFolder, "_plug"); await Deno.mkdir(plugFolder, { recursive: true }); await compileManifest( - path.join(testFolder, "test.plug.yaml"), + join(testFolder, "test_plug_run.plug.yaml"), plugFolder, ); assertEquals( diff --git a/cmd/plug_test.ts b/cmd/test/plug_test.ts similarity index 100% rename from cmd/plug_test.ts rename to cmd/test/plug_test.ts diff --git a/lib/plugos/runtime.test.ts b/cmd/test/runtime.test.ts similarity index 79% rename from lib/plugos/runtime.test.ts rename to cmd/test/runtime.test.ts index 26bc511b..5d56b24e 100644 --- a/lib/plugos/runtime.test.ts +++ b/cmd/test/runtime.test.ts @@ -1,14 +1,14 @@ -import { createSandbox } from "./sandboxes/deno_worker_sandbox.ts"; -import { System } from "./system.ts"; -import { assert, assertEquals } from "$lib/test_deps.ts"; -import { compileManifest } from "./compile.ts"; -import { esbuild } from "./deps.ts"; +import { createSandbox } from "../../lib/plugos/sandboxes/deno_worker_sandbox.ts"; +import { System } from "../../lib/plugos/system.ts"; +import { assert, assertEquals } from "$std/testing/asserts.ts"; +import { compileManifest } from "../compile.ts"; +import * as esbuild from "esbuild"; import { createSandbox as createNoSandbox, runWithSystemLock, -} from "./sandboxes/no_sandbox.ts"; -import { SysCallMapping } from "./system.ts"; -import { sleep } from "../async.ts"; +} from "../../lib/plugos/sandboxes/no_sandbox.ts"; +import { SysCallMapping } from "../../lib/plugos/system.ts"; +import { sleep } from "../../lib/async.ts"; Deno.test("Run a deno sandbox", { sanitizeResources: false, @@ -37,7 +37,7 @@ Deno.test("Run a deno sandbox", { const tempDir = await Deno.makeTempDir(); const workerPath = await compileManifest( - new URL("test.plug.yaml", import.meta.url).pathname, + new URL("test_runtime.plug.yaml", import.meta.url).pathname, tempDir, ); diff --git a/lib/plugos/test_func.test.ts b/cmd/test/test_func.test.ts similarity index 100% rename from lib/plugos/test_func.test.ts rename to cmd/test/test_func.test.ts diff --git a/cmd/test.plug.yaml b/cmd/test/test_plug_run.plug.yaml similarity index 100% rename from cmd/test.plug.yaml rename to cmd/test/test_plug_run.plug.yaml diff --git a/lib/plugos/test.plug.yaml b/cmd/test/test_runtime.plug.yaml similarity index 100% rename from lib/plugos/test.plug.yaml rename to cmd/test/test_runtime.plug.yaml diff --git a/cmd/upgrade.ts b/cmd/upgrade.ts index 7292a8e6..7e4778ce 100644 --- a/cmd/upgrade.ts +++ b/cmd/upgrade.ts @@ -37,7 +37,7 @@ export async function upgradeCommand() { } // WIP: This is not yet working, but it's a start -import { dirname } from "https://deno.land/std@0.186.0/path/mod.ts"; +import { dirname } from "$std/path/mod.ts"; const silverBulletReleases = "https://github.com/silverbulletmd/silverbullet/releases"; diff --git a/common/command.test.ts b/common/command.test.ts index c4d7c9ef..ef7f2db4 100644 --- a/common/command.test.ts +++ b/common/command.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { parseCommand } from "./command.ts"; Deno.test("Command parser", () => { diff --git a/common/common_system.ts b/common/common_system.ts index 3d47aa62..7108ac52 100644 --- a/common/common_system.ts +++ b/common/common_system.ts @@ -1,6 +1,7 @@ -import { AppCommand, CommandHook } from "./hooks/command.ts"; +import { AppCommand } from "$lib/command.ts"; +import { CommandHook } from "./hooks/command.ts"; import { PlugNamespaceHook } from "$common/hooks/plug_namespace.ts"; -import { SilverBulletHooks } from "./manifest.ts"; +import { SilverBulletHooks } from "../lib/manifest.ts"; import { buildQueryFunctions } from "./query_functions.ts"; import { ScriptEnvironment } from "./space_script.ts"; import { EventHook } from "./hooks/event.ts"; diff --git a/common/deps.ts b/common/deps.ts deleted file mode 100644 index cbd5ac8e..00000000 --- a/common/deps.ts +++ /dev/null @@ -1,93 +0,0 @@ -export { styleTags, Tag, tagHighlighter, tags } from "@lezer/highlight"; - -export * as YAML from "js-yaml"; -export * as path from "$std/path/mod.ts"; - -import { - Intl, - Temporal, - toTemporalInstant, -} from "https://esm.sh/@js-temporal/polyfill@0.4.4"; - -// @ts-ignore: temporal polygifill -Date.prototype.toTemporalInstant = toTemporalInstant; -// @ts-ignore: Temporal polyfill -globalThis.Temporal = Temporal; -// @ts-ignore: Intl polyfill -globalThis.Intl = Intl; - -export type { - BlockContext, - Element, - LeafBlock, - LeafBlockParser, - Line, - MarkdownConfig, - MarkdownExtension, -} from "@lezer/markdown"; - -export { - Emoji, - GFM, - MarkdownParser, - parseCode, - parser as baseParser, - Strikethrough, - Subscript, - Superscript, - Table, - TaskList, -} from "@lezer/markdown"; - -export type { NodeType, SyntaxNode, SyntaxNodeRef, Tree } from "@lezer/common"; - -export { markdown } from "@codemirror/lang-markdown"; - -// Language modes -export { yaml as yamlLanguage } from "@codemirror/legacy-modes/mode/yaml?external=@codemirror/language&target=es2022"; -export { - pgSQL as postgresqlLanguage, - standardSQL as sqlLanguage, -} from "@codemirror/legacy-modes/mode/sql?external=@codemirror/language&target=es2022"; -export { rust as rustLanguage } from "@codemirror/legacy-modes/mode/rust?external=@codemirror/language&target=es2022"; -export { css as cssLanguage } from "@codemirror/legacy-modes/mode/css?external=@codemirror/language&target=es2022"; -export { python as pythonLanguage } from "@codemirror/legacy-modes/mode/python?external=@codemirror/language&target=es2022"; -export { protobuf as protobufLanguage } from "@codemirror/legacy-modes/mode/protobuf?external=@codemirror/language&target=es2022"; -export { shell as shellLanguage } from "@codemirror/legacy-modes/mode/shell?external=@codemirror/language&target=es2022"; -export { swift as swiftLanguage } from "@codemirror/legacy-modes/mode/swift?external=@codemirror/language&target=es2022"; -export { toml as tomlLanguage } from "@codemirror/legacy-modes/mode/toml?external=@codemirror/language&target=es2022"; -export { xml as xmlLanguage } from "@codemirror/legacy-modes/mode/xml?external=@codemirror/language&target=es2022"; -export { json as jsonLanguage } from "@codemirror/legacy-modes/mode/javascript?external=@codemirror/language&target=es2022"; -export { htmlLanguage } from "@codemirror/lang-html"; -export { go as goLanguage } from "@codemirror/legacy-modes/mode/go?external=@codemirror/language&target=es2022"; -export { diff as diffLanguage } from "@codemirror/legacy-modes/mode/diff?external=@codemirror/language&target=es2022"; -export { powerShell as powerShellLanguage } from "@codemirror/legacy-modes/mode/powershell?external=@codemirror/language&target=es2022"; -export { perl as perlLanguage } from "@codemirror/legacy-modes/mode/perl?external=@codemirror/language&target=es2022"; -export { tcl as tclLanguage } from "@codemirror/legacy-modes/mode/tcl?external=@codemirror/language&target=es2022"; -export { verilog as verilogLanguage } from "@codemirror/legacy-modes/mode/verilog?external=@codemirror/language&target=es2022"; -export { vhdl as vhdlLanguage } from "@codemirror/legacy-modes/mode/vhdl?external=@codemirror/language&target=es2022"; -export { dockerFile as dockerfileLanguage } from "@codemirror/legacy-modes/mode/dockerfile?external=@codemirror/language&target=es2022"; -export { cmake as cmakeLanguage } from "@codemirror/legacy-modes/mode/cmake?external=@codemirror/language&target=es2022"; -export { Language, StreamLanguage } from "@codemirror/language"; -export { - c as cLanguage, - cpp as cppLanguage, - csharp as csharpLanguage, - dart as dartLanguage, - java as javaLanguage, - kotlin as kotlinLanguage, - objectiveC as objectiveCLanguage, - objectiveCpp as objectiveCppLanguage, - scala as scalaLanguage, -} from "@codemirror/legacy-modes/mode/clike?external=@codemirror/language&target=es2022"; - -export { - javascriptLanguage, - typescriptLanguage, -} from "@codemirror/lang-javascript"; - -export { mime } from "mimetypes"; - -export { compile as gitIgnoreCompiler } from "gitignore-parser"; - -export { z } from "zod"; diff --git a/common/hooks/command.ts b/common/hooks/command.ts index 9071db44..55b7dec4 100644 --- a/common/hooks/command.ts +++ b/common/hooks/command.ts @@ -8,35 +8,8 @@ import { } from "../../plugs/template/types.ts"; import { NewPageConfig } from "../../plugs/template/types.ts"; import { throttle } from "../../lib/async.ts"; - -export type CommandDef = { - name: string; - - contexts?: string[]; - - // Default 0, higher is higher priority = higher in the list - priority?: number; - - // Bind to keyboard shortcut - key?: string; - mac?: string; - - hide?: boolean; - requireMode?: "rw" | "ro"; -}; - -export type AppCommand = { - command: CommandDef; - run: (args?: any[]) => Promise; -}; - -export type CommandHookT = { - command?: CommandDef; -}; - -export type CommandHookEvents = { - commandsUpdated(commandMap: Map): void; -}; +import { AppCommand, CommandHookEvents } from "../../lib/command.ts"; +import { CommandHookT } from "$lib/manifest.ts"; export class CommandHook extends EventEmitter implements Hook { diff --git a/common/hooks/event.ts b/common/hooks/event.ts index 16465005..c2982779 100644 --- a/common/hooks/event.ts +++ b/common/hooks/event.ts @@ -1,15 +1,13 @@ -import type { Hook, Manifest } from "../../lib/plugos/types.ts"; -import { System } from "../../lib/plugos/system.ts"; +import type { Manifest } from "$lib/plugos/types.ts"; +import { System } from "$lib/plugos/system.ts"; import { ScriptEnvironment } from "$common/space_script.ts"; +import { EventHookI } from "$lib/plugos/eventhook.ts"; +import { EventHookT } from "$lib/manifest.ts"; // System events: // - plug:load (plugName: string) -export type EventHookT = { - events?: string[]; -}; - -export class EventHook implements Hook { +export class EventHook implements EventHookI { private system?: System; private localListeners: Map any)[]> = new Map(); public scriptEnvironment?: ScriptEnvironment; diff --git a/common/hooks/plug_namespace.ts b/common/hooks/plug_namespace.ts index e5c5fa65..f25a22b6 100644 --- a/common/hooks/plug_namespace.ts +++ b/common/hooks/plug_namespace.ts @@ -1,23 +1,9 @@ +import { NamespaceOperation } from "$lib/plugos/namespace.ts"; +import { PlugNamespaceHookT } from "$lib/manifest.ts"; import { Plug } from "../../lib/plugos/plug.ts"; import { System } from "../../lib/plugos/system.ts"; import { Hook, Manifest } from "../../lib/plugos/types.ts"; -export type NamespaceOperation = - | "readFile" - | "writeFile" - | "listFiles" - | "getFileMeta" - | "deleteFile"; - -export type PlugNamespaceDef = { - pattern: string; - operation: NamespaceOperation; -}; - -export type PlugNamespaceHookT = { - pageNamespace?: PlugNamespaceDef; -}; - type SpaceFunction = { operation: NamespaceOperation; pattern: RegExp; diff --git a/common/languages.ts b/common/languages.ts index c1c5c7c8..da048093 100644 --- a/common/languages.ts +++ b/common/languages.ts @@ -1,45 +1,48 @@ import { LRLanguage } from "@codemirror/language"; +import { yaml as yamlLanguage } from "@codemirror/legacy-modes/mode/yaml?external=@codemirror/language&target=es2022"; +import { + pgSQL as postgresqlLanguage, + standardSQL as sqlLanguage, +} from "@codemirror/legacy-modes/mode/sql?external=@codemirror/language&target=es2022"; +import { rust as rustLanguage } from "@codemirror/legacy-modes/mode/rust?external=@codemirror/language&target=es2022"; +import { python as pythonLanguage } from "@codemirror/legacy-modes/mode/python?external=@codemirror/language&target=es2022"; +import { protobuf as protobufLanguage } from "@codemirror/legacy-modes/mode/protobuf?external=@codemirror/language&target=es2022"; +import { shell as shellLanguage } from "@codemirror/legacy-modes/mode/shell?external=@codemirror/language&target=es2022"; +import { toml as tomlLanguage } from "@codemirror/legacy-modes/mode/toml?external=@codemirror/language&target=es2022"; +import { xml as xmlLanguage } from "@codemirror/legacy-modes/mode/xml?external=@codemirror/language&target=es2022"; +import { json as jsonLanguage } from "@codemirror/legacy-modes/mode/javascript?external=@codemirror/language&target=es2022"; +import { htmlLanguage } from "@codemirror/lang-html"; +import { go as goLanguage } from "@codemirror/legacy-modes/mode/go?external=@codemirror/language&target=es2022"; +import { diff as diffLanguage } from "@codemirror/legacy-modes/mode/diff?external=@codemirror/language&target=es2022"; +import { powerShell as powerShellLanguage } from "@codemirror/legacy-modes/mode/powershell?external=@codemirror/language&target=es2022"; +import { perl as perlLanguage } from "@codemirror/legacy-modes/mode/perl?external=@codemirror/language&target=es2022"; +import { tcl as tclLanguage } from "@codemirror/legacy-modes/mode/tcl?external=@codemirror/language&target=es2022"; +import { verilog as verilogLanguage } from "@codemirror/legacy-modes/mode/verilog?external=@codemirror/language&target=es2022"; +import { vhdl as vhdlLanguage } from "@codemirror/legacy-modes/mode/vhdl?external=@codemirror/language&target=es2022"; +import { dockerFile as dockerfileLanguage } from "@codemirror/legacy-modes/mode/dockerfile?external=@codemirror/language&target=es2022"; +import { cmake as cmakeLanguage } from "@codemirror/legacy-modes/mode/cmake?external=@codemirror/language&target=es2022"; +import { + c as cLanguage, + cpp as cppLanguage, + csharp as csharpLanguage, + dart as dartLanguage, + java as javaLanguage, + kotlin as kotlinLanguage, + objectiveC as objectiveCLanguage, + objectiveCpp as objectiveCppLanguage, + scala as scalaLanguage, +} from "@codemirror/legacy-modes/mode/clike?external=@codemirror/language&target=es2022"; +import { Language, StreamLanguage } from "@codemirror/language"; import { - cLanguage, - cmakeLanguage, - cppLanguage, - csharpLanguage, - cssLanguage, - dartLanguage, - diffLanguage, - dockerfileLanguage, - goLanguage, - htmlLanguage, - javaLanguage, javascriptLanguage, - jsonLanguage, - kotlinLanguage, - Language, - objectiveCLanguage, - objectiveCppLanguage, - perlLanguage, - postgresqlLanguage, - powerShellLanguage, - protobufLanguage, - pythonLanguage, - rustLanguage, - scalaLanguage, - shellLanguage, - sqlLanguage, - StreamLanguage, - tclLanguage, - tomlLanguage, typescriptLanguage, - verilogLanguage, - vhdlLanguage, - xmlLanguage, - yamlLanguage, -} from "./deps.ts"; +} from "@codemirror/lang-javascript"; import { extendedMarkdownLanguage, highlightingExpressionParser, highlightingQueryParser, } from "./markdown_parser/parser.ts"; +import { cssLanguage } from "@codemirror/lang-css"; export const builtinLanguages: Record = { "meta": StreamLanguage.define(yamlLanguage), @@ -59,8 +62,8 @@ export const builtinLanguages: Record = { "postgres": StreamLanguage.define(postgresqlLanguage), "rust": StreamLanguage.define(rustLanguage), "rs": StreamLanguage.define(rustLanguage), - "css": StreamLanguage.define(cssLanguage), - "space-style": StreamLanguage.define(cssLanguage), + "css": cssLanguage, + "space-style": cssLanguage, "html": htmlLanguage, "python": StreamLanguage.define(pythonLanguage), "py": StreamLanguage.define(pythonLanguage), diff --git a/common/manifest.ts b/common/manifest.ts deleted file mode 100644 index ea5bab37..00000000 --- a/common/manifest.ts +++ /dev/null @@ -1,34 +0,0 @@ -import * as plugos from "../lib/plugos/types.ts"; -import { CronHookT } from "../lib/plugos/hooks/cron.ts"; -import { EventHookT } from "./hooks/event.ts"; -import { CommandHookT } from "./hooks/command.ts"; -import { SlashCommandHookT } from "../web/hooks/slash_command.ts"; -import { PlugNamespaceHookT } from "./hooks/plug_namespace.ts"; -import { CodeWidgetT } from "../web/hooks/code_widget.ts"; -import { MQHookT } from "../lib/plugos/hooks/mq.ts"; -import { EndpointHookT } from "../server/hooks/endpoint.ts"; -import { PanelWidgetT } from "../web/hooks/panel_widget.ts"; - -/** Silverbullet hooks give plugs access to silverbullet core systems. - * - * Hooks are associated with typescript functions through a manifest file. - * On various triggers (user enters a slash command, an HTTP endpoint is hit, user clicks, etc) the typescript function is called. - * - * related: plugos/type.ts#FunctionDef - */ -export type SilverBulletHooks = - & CommandHookT - & SlashCommandHookT - & CronHookT - & MQHookT - & EventHookT - & CodeWidgetT - & PanelWidgetT - & EndpointHookT - & PlugNamespaceHookT; - -/** A plug manifest configures hooks, declares syntax extensions, and describes plug metadata. - * - * Typically the manifest file is in a plug's root directory, named `${plugName}.plug.yaml`. - */ -export type Manifest = plugos.Manifest; diff --git a/common/markdown_parser/customtags.ts b/common/markdown_parser/customtags.ts index bdde3070..3e5bcd4f 100644 --- a/common/markdown_parser/customtags.ts +++ b/common/markdown_parser/customtags.ts @@ -1,4 +1,4 @@ -import { Tag } from "../deps.ts"; +import { Tag } from "@lezer/highlight"; export const CommandLinkTag = Tag.define(); export const CommandLinkNameTag = Tag.define(); diff --git a/common/markdown_parser/extended_task.ts b/common/markdown_parser/extended_task.ts index cef77706..1ed7680d 100644 --- a/common/markdown_parser/extended_task.ts +++ b/common/markdown_parser/extended_task.ts @@ -3,7 +3,7 @@ import { LeafBlock, LeafBlockParser, MarkdownConfig, -} from "../deps.ts"; +} from "@lezer/markdown"; import { tags as t } from "@lezer/highlight"; import { TaskStateTag } from "./customtags.ts"; diff --git a/common/markdown_parser/parse_tree.ts b/common/markdown_parser/parse_tree.ts index 003928d4..85125ca0 100644 --- a/common/markdown_parser/parse_tree.ts +++ b/common/markdown_parser/parse_tree.ts @@ -1,5 +1,6 @@ import type { ParseTree } from "../../plug-api/lib/tree.ts"; -import type { Language, SyntaxNode } from "../deps.ts"; +import type { SyntaxNode } from "@lezer/common"; +import type { Language } from "@codemirror/language"; export function lezerToParseTree( text: string, diff --git a/common/markdown_parser/parser.test.ts b/common/markdown_parser/parser.test.ts index 6d0ef9c3..213564d8 100644 --- a/common/markdown_parser/parser.test.ts +++ b/common/markdown_parser/parser.test.ts @@ -4,7 +4,7 @@ import { findNodeOfType, renderToText, } from "$sb/lib/tree.ts"; -import { assertEquals, assertNotEquals } from "$lib/test_deps.ts"; +import { assertEquals, assertNotEquals } from "$std/testing/asserts.ts"; import { extendedMarkdownLanguage } from "./parser.ts"; const sample1 = `--- diff --git a/common/markdown_parser/parser.ts b/common/markdown_parser/parser.ts index 84bdf6d1..a29aea51 100644 --- a/common/markdown_parser/parser.ts +++ b/common/markdown_parser/parser.ts @@ -1,25 +1,24 @@ import { commandLinkRegex } from "../command.ts"; +import { yaml as yamlLanguage } from "@codemirror/legacy-modes/mode/yaml?external=@codemirror/language&target=es2022"; +import { styleTags, Tag, tags as t } from "@lezer/highlight"; import { BlockContext, LeafBlock, LeafBlockParser, Line, - markdown, MarkdownConfig, - StreamLanguage, Strikethrough, - styleTags, - Tag, - tags as t, - yamlLanguage, -} from "../deps.ts"; +} from "@lezer/markdown"; +import { markdown } from "@codemirror/lang-markdown"; +import { StreamLanguage } from "@codemirror/language"; import * as ct from "./customtags.ts"; import { NakedURLTag } from "./customtags.ts"; import { TaskList } from "./extended_task.ts"; export const pageLinkRegex = /^\[\[([^\]\|]+)(\|([^\]]+))?\]\]/; -export const tagRegex = /#[^\d\s!@#$%^&*(),.?":{}|<>\\][^\s!@#$%^&*(),.?":{}|<>\\]*/; +export const tagRegex = + /#[^\d\s!@#$%^&*(),.?":{}|<>\\][^\s!@#$%^&*(),.?":{}|<>\\]*/; const WikiLink: MarkdownConfig = { defineNodes: [ diff --git a/common/markdown_parser/table_parser.ts b/common/markdown_parser/table_parser.ts index 236be799..e26db3fb 100644 --- a/common/markdown_parser/table_parser.ts +++ b/common/markdown_parser/table_parser.ts @@ -5,8 +5,8 @@ import { LeafBlockParser, Line, MarkdownConfig, - tags as t, -} from "../deps.ts"; +} from "@lezer/markdown"; +import { tags as t } from "@lezer/highlight"; // Forked from https://github.com/lezer-parser/markdown/blob/main/src/extension.ts // MIT License diff --git a/common/query_functions.test.ts b/common/query_functions.test.ts index ebba234a..d895ebb2 100644 --- a/common/query_functions.test.ts +++ b/common/query_functions.test.ts @@ -1,7 +1,11 @@ import { beforeEach, describe, it } from "$std/testing/bdd.ts"; import { buildQueryFunctions } from "$common/query_functions.ts"; import type { System } from "$lib/plugos/system.ts"; -import { assertEquals, assertRejects, assertThrows } from "$lib/test_deps.ts"; +import { + assertEquals, + assertRejects, + assertThrows, +} from "$std/testing/asserts.ts"; let functions: ReturnType; diff --git a/common/settings.test.ts b/common/settings.test.ts index d3d4720c..590160ca 100644 --- a/common/settings.test.ts +++ b/common/settings.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { parseYamlSettings } from "./settings.ts"; Deno.test("Settings regex", () => { diff --git a/common/settings.ts b/common/settings.ts index 6ad68e0a..f554cb2c 100644 --- a/common/settings.ts +++ b/common/settings.ts @@ -1,4 +1,4 @@ -import { YAML } from "./deps.ts"; +import YAML from "js-yaml"; import { INDEX_TEMPLATE, SETTINGS_TEMPLATE } from "./PAGE_TEMPLATES.ts"; import { SpacePrimitives } from "./spaces/space_primitives.ts"; import { expandPropertyNames } from "../plug-api/lib/json.ts"; diff --git a/common/space_script.ts b/common/space_script.ts index 4fc2e947..c6866057 100644 --- a/common/space_script.ts +++ b/common/space_script.ts @@ -1,7 +1,15 @@ import { System } from "../lib/plugos/system.ts"; import { ParseTree } from "../plug-api/lib/tree.ts"; import { ScriptObject } from "../plugs/index/script.ts"; -import { AppCommand, CommandDef } from "./hooks/command.ts"; +import { AppCommand, CommandDef } from "$lib/command.ts"; +import { Intl, Temporal, toTemporalInstant } from "@js-temporal/polyfill"; + +// @ts-ignore: Temporal polyfill +Date.prototype.toTemporalInstant = toTemporalInstant; +// @ts-ignore: Temporal polyfill +globalThis.Temporal = Temporal; +// @ts-ignore: Intl polyfill +globalThis.Intl = Intl; type FunctionDef = { name: string; diff --git a/common/spaces/chunked_datastore_space_primitives.test.ts b/common/spaces/chunked_datastore_space_primitives.test.ts index b58986a3..1dded6b0 100644 --- a/common/spaces/chunked_datastore_space_primitives.test.ts +++ b/common/spaces/chunked_datastore_space_primitives.test.ts @@ -1,5 +1,5 @@ import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { ChunkedKvStoreSpacePrimitives } from "./chunked_datastore_space_primitives.ts"; import { testSpacePrimitives } from "./space_primitives.test.ts"; diff --git a/common/spaces/datastore_space_primitives.test.ts b/common/spaces/datastore_space_primitives.test.ts index 98de1f78..dbf1d46d 100644 --- a/common/spaces/datastore_space_primitives.test.ts +++ b/common/spaces/datastore_space_primitives.test.ts @@ -1,4 +1,4 @@ -import "https://esm.sh/fake-indexeddb@4.0.2/auto"; +import "fake-indexeddb/auto"; import { DataStore } from "$lib/data/datastore.ts"; import { IndexedDBKvPrimitives } from "$lib/data/indexeddb_kv_primitives.ts"; import { DataStoreSpacePrimitives } from "./datastore_space_primitives.ts"; diff --git a/common/spaces/disk_space_primitives.ts b/common/spaces/disk_space_primitives.ts index a44178cb..911eceb8 100644 --- a/common/spaces/disk_space_primitives.ts +++ b/common/spaces/disk_space_primitives.ts @@ -1,7 +1,7 @@ -import * as path from "https://deno.land/std@0.189.0/path/mod.ts"; -import { readAll } from "https://deno.land/std@0.165.0/streams/conversion.ts"; +import * as path from "$std/path/mod.ts"; +import { readAll } from "$std/streams/read_all.ts"; import { SpacePrimitives } from "./space_primitives.ts"; -import { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts"; +import { mime } from "mimetypes"; import { FileMeta } from "../../plug-api/types.ts"; function lookupContentType(path: string): string { diff --git a/common/spaces/encrypted_space_primitives.test.ts b/common/spaces/encrypted_space_primitives.test.ts index 5eb2c79c..b347a701 100644 --- a/common/spaces/encrypted_space_primitives.test.ts +++ b/common/spaces/encrypted_space_primitives.test.ts @@ -1,5 +1,5 @@ import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; -import { assert, assertEquals } from "$lib/test_deps.ts"; +import { assert, assertEquals } from "$std/testing/asserts.ts"; import { ChunkedKvStoreSpacePrimitives } from "./chunked_datastore_space_primitives.ts"; import { EncryptedSpacePrimitives } from "./encrypted_space_primitives.ts"; import { testSpacePrimitives } from "./space_primitives.test.ts"; diff --git a/common/spaces/plug_space_primitives.ts b/common/spaces/plug_space_primitives.ts index ab185aba..ccc8f4e2 100644 --- a/common/spaces/plug_space_primitives.ts +++ b/common/spaces/plug_space_primitives.ts @@ -1,9 +1,7 @@ import { SpacePrimitives } from "$common/spaces/space_primitives.ts"; +import { NamespaceOperation } from "$lib/plugos/namespace.ts"; import { FileMeta } from "../../plug-api/types.ts"; -import { - NamespaceOperation, - PlugNamespaceHook, -} from "../hooks/plug_namespace.ts"; +import { PlugNamespaceHook } from "../hooks/plug_namespace.ts"; export class PlugSpacePrimitives implements SpacePrimitives { constructor( diff --git a/common/spaces/s3_space_primitives.ts b/common/spaces/s3_space_primitives.ts index 2e013681..75f912e0 100644 --- a/common/spaces/s3_space_primitives.ts +++ b/common/spaces/s3_space_primitives.ts @@ -1,9 +1,9 @@ // We're explicitly using 0.4.0 to be able to hijack the path encoding, which is inconsisently broken in 0.5.0 -import { S3Client } from "https://deno.land/x/s3_lite_client@0.4.0/mod.ts"; -import type { ClientOptions } from "https://deno.land/x/s3_lite_client@0.4.0/client.ts"; +import { S3Client } from "s3_lite_client/mod.ts"; +import type { ClientOptions } from "s3_lite_client/client.ts"; import { KvMetaSpacePrimitives } from "./kv_meta_space_primitives.ts"; import { KvPrimitives } from "$lib/data/kv_primitives.ts"; -import { mime } from "../deps.ts"; +import { mime } from "mimetypes"; import { KV, KvKey } from "../../plug-api/types.ts"; import { PrefixedKvPrimitives } from "$lib/data/prefixed_kv_primitives.ts"; diff --git a/common/spaces/space_primitives.test.ts b/common/spaces/space_primitives.test.ts index 019ff00f..dff34ad1 100644 --- a/common/spaces/space_primitives.test.ts +++ b/common/spaces/space_primitives.test.ts @@ -1,4 +1,4 @@ -import { assert, assertEquals } from "$lib/test_deps.ts"; +import { assert, assertEquals } from "$std/testing/asserts.ts"; import { SpacePrimitives } from "./space_primitives.ts"; export async function testSpacePrimitives(spacePrimitives: SpacePrimitives) { diff --git a/common/spaces/sync.test.ts b/common/spaces/sync.test.ts index 0cf4b31e..72c922c1 100644 --- a/common/spaces/sync.test.ts +++ b/common/spaces/sync.test.ts @@ -1,6 +1,6 @@ import { SpaceSync, SyncStatusItem } from "./sync.ts"; import { DiskSpacePrimitives } from "./disk_space_primitives.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; Deno.test("Test store", async () => { const primaryPath = await Deno.makeTempDir(); diff --git a/common/syscalls/system.ts b/common/syscalls/system.ts index 29d2d117..9e0f30f2 100644 --- a/common/syscalls/system.ts +++ b/common/syscalls/system.ts @@ -1,7 +1,7 @@ import { SyscallMeta } from "../../plug-api/types.ts"; import { SysCallMapping, System } from "../../lib/plugos/system.ts"; import type { Client } from "../../web/client.ts"; -import { CommandDef } from "../hooks/command.ts"; +import { CommandDef } from "$lib/command.ts"; import { proxySyscall } from "../../web/syscalls/util.ts"; import type { CommonSystem } from "../common_system.ts"; import { version } from "../../version.ts"; diff --git a/common/syscalls/yaml.ts b/common/syscalls/yaml.ts index 7a284fdb..b56e26a8 100644 --- a/common/syscalls/yaml.ts +++ b/common/syscalls/yaml.ts @@ -1,5 +1,5 @@ import { SysCallMapping } from "../../lib/plugos/system.ts"; -import { YAML } from "../../web/deps.ts"; +import YAML from "js-yaml"; type YamlStringifyOptions = { /** indentation width to use (in spaces). */ diff --git a/common/template/render.test.ts b/common/template/render.test.ts index 4cc7da84..ea8f9690 100644 --- a/common/template/render.test.ts +++ b/common/template/render.test.ts @@ -1,5 +1,5 @@ import { builtinFunctions } from "../../lib/builtin_query_functions.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { renderTemplate } from "./render.ts"; import { parseTemplate } from "./template_parser.ts"; diff --git a/common/template/template_parser.test.ts b/common/template/template_parser.test.ts index 2a3d80d8..3462bb9c 100644 --- a/common/template/template_parser.test.ts +++ b/common/template/template_parser.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { parseTemplate } from "./template_parser.ts"; Deno.test("Test template", () => { diff --git a/import_map.json b/import_map.json index 913e684f..39b72564 100644 --- a/import_map.json +++ b/import_map.json @@ -21,10 +21,23 @@ "@codemirror/lang-javascript": "https://esm.sh/@codemirror/lang-javascript@6.2.1?external=@codemirror/language,@codemirror/autocomplete,@codemirror/view,@codemirror/state,@codemirror/lint,@lezer/common,@lezer/lr,@lezer/javascript,@codemirror/commands&target=es2022", "@replit/codemirror-vim": "https://esm.sh/@replit/codemirror-vim@6.0.14?external=@codemirror/state,@codemirror/language,@codemirror/view,@codemirror/search,@codemirror/commands", + "@js-temporal/polyfill": "https://esm.sh/@js-temporal/polyfill@0.4.4", + "cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.3/", + "denosass": "https://deno.land/x/denosass@1.0.4/mod.ts", "djwt": "https://deno.land/x/djwt@v3.0.1/mod.ts", + "esbuild": "https://deno.land/x/esbuild@v0.20.0/mod.js", + "esbuild_deno_loader": "https://deno.land/x/esbuild_deno_loader@0.8.5/mod.ts", + "fake-indexeddb/": "https://esm.sh/fake-indexeddb@4.0.2/", + "fast-diff": "https://esm.sh/fast-diff@1.3.0", + "fuse": "https://deno.land/x/fuse@v6.4.1/dist/fuse.esm.min.js", + "gitignore-parser": "https://esm.sh/gitignore-parser@0.0.2", + "hono/": "https://deno.land/x/hono@v3.12.2/", "js-yaml": "https://esm.sh/js-yaml@4.1.0", "mimetypes": "https://deno.land/x/mimetypes@v1.0.0/mod.ts", - "gitignore-parser": "https://esm.sh/gitignore-parser@0.0.2", + "porter-stemmer": "https://esm.sh/porter-stemmer@0.9.1", + "preact-feather": "https://esm.sh/preact-feather@4.2.1?external=preact", + "preact-feather/types": "https://esm.sh/preact-feather@4.2.1/dist/types?external=preact", + "s3_lite_client/": "https://deno.land/x/s3_lite_client@0.4.0/", "turndown": "https://cdn.skypack.dev/turndown@7.1.1", "turndown-plugin-gfm": "https://cdn.skypack.dev/@joplin/turndown-plugin-gfm@1.0.45", @@ -33,6 +46,7 @@ "$type/": "./type/", "preact": "https://esm.sh/preact@10.11.1", + "preact/": "https://esm.sh/preact@10.11.1/", "$sb/": "./plug-api/", "zod": "https://deno.land/x/zod@v3.22.4/mod.ts", "$std/": "https://deno.land/std@0.189.0/" diff --git a/lib/asset_bundle/builder.ts b/lib/asset_bundle/builder.ts index 0fdcc83d..4113a543 100644 --- a/lib/asset_bundle/builder.ts +++ b/lib/asset_bundle/builder.ts @@ -1,4 +1,4 @@ -import { globToRegExp, mime, path, walk } from "../plugos/deps.ts"; +import { globToRegExp, mime, path, walk } from "../deps_server.ts"; import { AssetBundle } from "./bundle.ts"; export async function bundleAssets( diff --git a/lib/asset_bundle/bundle.test.ts b/lib/asset_bundle/bundle.test.ts index 1a65febf..02730a34 100644 --- a/lib/asset_bundle/bundle.test.ts +++ b/lib/asset_bundle/bundle.test.ts @@ -1,5 +1,5 @@ import { AssetBundle } from "./bundle.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; Deno.test("Asset bundle", () => { const assetBundle = new AssetBundle(); diff --git a/lib/asset_bundle/bundle.ts b/lib/asset_bundle/bundle.ts index a64cd9cd..a9705afc 100644 --- a/lib/asset_bundle/bundle.ts +++ b/lib/asset_bundle/bundle.ts @@ -1,4 +1,4 @@ -import { base64Decode, base64EncodedDataUrl } from "$lib/crypto.ts"; +import { base64Decode, base64EncodedDataUrl } from "../crypto.ts"; type DataUrl = string; diff --git a/lib/async.test.ts b/lib/async.test.ts index 75cc2fc8..4bf78922 100644 --- a/lib/async.test.ts +++ b/lib/async.test.ts @@ -1,4 +1,4 @@ -import { assert, assertEquals } from "$lib/test_deps.ts"; +import { assert, assertEquals } from "$std/testing/asserts.ts"; import { batchRequests, PromiseQueue, sleep } from "./async.ts"; Deno.test("PromiseQueue test", async () => { diff --git a/lib/builtin_query_functions.test.ts b/lib/builtin_query_functions.test.ts index 91623595..75cd301d 100644 --- a/lib/builtin_query_functions.test.ts +++ b/lib/builtin_query_functions.test.ts @@ -1,6 +1,6 @@ import { describe, it } from "$std/testing/bdd.ts"; import { builtinFunctions } from "./builtin_query_functions.ts"; -import { assertEquals, assertThrows } from "$lib/test_deps.ts"; +import { assertEquals, assertThrows } from "$std/testing/asserts.ts"; describe("replace()", () => { const { replace } = builtinFunctions; diff --git a/lib/cheap_yaml.test.ts b/lib/cheap_yaml.test.ts index a0edea55..9424f39f 100644 --- a/lib/cheap_yaml.test.ts +++ b/lib/cheap_yaml.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { determineTags, isTemplate } from "./cheap_yaml.ts"; Deno.test("cheap yaml", () => { diff --git a/lib/command.ts b/lib/command.ts new file mode 100644 index 00000000..8187e97d --- /dev/null +++ b/lib/command.ts @@ -0,0 +1,24 @@ +export type CommandDef = { + name: string; + + contexts?: string[]; + + // Default 0, higher is higher priority = higher in the list + priority?: number; + + // Bind to keyboard shortcut + key?: string; + mac?: string; + + hide?: boolean; + requireMode?: "rw" | "ro"; +}; + +export type AppCommand = { + command: CommandDef; + run: (args?: any[]) => Promise; +}; + +export type CommandHookEvents = { + commandsUpdated(commandMap: Map): void; +}; diff --git a/lib/data/datastore.test.ts b/lib/data/datastore.test.ts index a7c57792..8e13bde3 100644 --- a/lib/data/datastore.test.ts +++ b/lib/data/datastore.test.ts @@ -1,9 +1,9 @@ -import "https://esm.sh/fake-indexeddb@4.0.2/auto"; +import "fake-indexeddb/auto"; import { IndexedDBKvPrimitives } from "../data/indexeddb_kv_primitives.ts"; import { DataStore } from "../data/datastore.ts"; import { DenoKvPrimitives } from "../data/deno_kv_primitives.ts"; import { KvPrimitives } from "../data/kv_primitives.ts"; -import { assertEquals } from "https://deno.land/std@0.165.0/testing/asserts.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { PrefixedKvPrimitives } from "../data/prefixed_kv_primitives.ts"; import { Query } from "../../plug-api/types.ts"; diff --git a/lib/data/datastore.ts b/lib/data/datastore.ts index bc822b29..71fcff8e 100644 --- a/lib/data/datastore.ts +++ b/lib/data/datastore.ts @@ -1,8 +1,8 @@ -import { applyQueryNoFilterKV } from "$sb/lib/query.ts"; +import { applyQueryNoFilterKV } from "../../plug-api/lib/query.ts"; import { FunctionMap, KV, KvKey, KvQuery } from "../../plug-api/types.ts"; -import { builtinFunctions } from "$lib/builtin_query_functions.ts"; +import { builtinFunctions } from "../builtin_query_functions.ts"; import { KvPrimitives } from "./kv_primitives.ts"; -import { evalQueryExpression } from "$sb/lib/query_expression.ts"; +import { evalQueryExpression } from "../../plug-api/lib/query_expression.ts"; /** * This is the data store class you'll actually want to use, wrapping the primitives * in a more user-friendly way diff --git a/lib/data/dynamodb_kv_primitives.ts b/lib/data/dynamodb_kv_primitives.ts index b8c2b826..732c3cb6 100644 --- a/lib/data/dynamodb_kv_primitives.ts +++ b/lib/data/dynamodb_kv_primitives.ts @@ -1,9 +1,6 @@ import { KV, KvKey } from "../../plug-api/types.ts"; import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts"; -import { - createClient, - DynamoDBClient, -} from "https://denopkg.com/chiefbiiko/dynamodb@master/mod.ts"; +import { createClient, DynamoDBClient } from "../deps_server.ts"; export type AwsOptions = { accessKey: string; diff --git a/lib/data/indexeddb_kv_primitives.test.ts b/lib/data/indexeddb_kv_primitives.test.ts index a4c8aa0d..fe64ce79 100644 --- a/lib/data/indexeddb_kv_primitives.test.ts +++ b/lib/data/indexeddb_kv_primitives.test.ts @@ -1,4 +1,4 @@ -import "https://esm.sh/fake-indexeddb@4.0.2/auto"; +import "fake-indexeddb/auto"; import { IndexedDBKvPrimitives } from "./indexeddb_kv_primitives.ts"; import { allTests } from "./kv_primitives.test.ts"; diff --git a/lib/data/indexeddb_kv_primitives.ts b/lib/data/indexeddb_kv_primitives.ts index e22cd652..7ffa73e7 100644 --- a/lib/data/indexeddb_kv_primitives.ts +++ b/lib/data/indexeddb_kv_primitives.ts @@ -1,6 +1,6 @@ import { KV, KvKey } from "../../plug-api/types.ts"; import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts"; -import { IDBPDatabase, openDB } from "https://esm.sh/idb@7.1.1/with-async-ittr"; +import { type IDBPDatabase, openDB } from "../deps_client.ts"; const sep = "\0"; const objectStoreName = "data"; diff --git a/lib/data/kv_primitives.test.ts b/lib/data/kv_primitives.test.ts index d150af05..9c405838 100644 --- a/lib/data/kv_primitives.test.ts +++ b/lib/data/kv_primitives.test.ts @@ -1,5 +1,5 @@ import { KvPrimitives } from "./kv_primitives.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { KV } from "../../plug-api/types.ts"; export async function allTests(db: KvPrimitives) { diff --git a/lib/data/mq.datastore.test.ts b/lib/data/mq.datastore.test.ts index 8e7f2daf..46b13ddc 100644 --- a/lib/data/mq.datastore.test.ts +++ b/lib/data/mq.datastore.test.ts @@ -1,5 +1,5 @@ import { DataStoreMQ } from "./mq.datastore.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { DenoKvPrimitives } from "./deno_kv_primitives.ts"; import { DataStore } from "./datastore.ts"; import { PrefixedKvPrimitives } from "./prefixed_kv_primitives.ts"; diff --git a/lib/deps_client.ts b/lib/deps_client.ts new file mode 100644 index 00000000..7a74320f --- /dev/null +++ b/lib/deps_client.ts @@ -0,0 +1,7 @@ +// Remember to keep in sync with import_map.json ! +// We have to use different deps for client and server as esbuild doesn't +// support wildcard exporting. See https://github.com/evanw/esbuild/issues/1420 +export { + type IDBPDatabase, + openDB, +} from "https://esm.sh/idb@7.1.1/with-async-ittr"; diff --git a/lib/deps_server.ts b/lib/deps_server.ts new file mode 100644 index 00000000..d87c42f3 --- /dev/null +++ b/lib/deps_server.ts @@ -0,0 +1,13 @@ +// Remember to keep in sync with import_map.json ! +// We have to use different deps for client and server as esbuild doesn't +// support wildcard exporting. See https://github.com/evanw/esbuild/issues/1420 +export { globToRegExp } from "https://deno.land/std@0.165.0/path/glob.ts"; +export { walk } from "https://deno.land/std@0.165.0/fs/mod.ts"; +export * as path from "https://deno.land/std@0.165.0/path/mod.ts"; +export { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts"; +export * as YAML from "https://deno.land/std@0.184.0/yaml/mod.ts"; +export { + createClient, + type DynamoDBClient, +} from "https://denopkg.com/chiefbiiko/dynamodb@55e60a5/mod.ts"; +export { Cron } from "https://deno.land/x/croner@4.4.1/src/croner.js"; diff --git a/lib/limited_map.test.ts b/lib/limited_map.test.ts index 1b676fa2..e2d5f2c9 100644 --- a/lib/limited_map.test.ts +++ b/lib/limited_map.test.ts @@ -1,5 +1,5 @@ import { sleep } from "$lib/async.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { LimitedMap } from "./limited_map.ts"; Deno.test("limited map", async () => { diff --git a/lib/manifest.ts b/lib/manifest.ts new file mode 100644 index 00000000..edf17b93 --- /dev/null +++ b/lib/manifest.ts @@ -0,0 +1,82 @@ +import { Manifest as PlugosManifest } from "./plugos/types.ts"; +import { CommandDef } from "./command.ts"; +import { NamespaceOperation } from "./plugos/namespace.ts"; + +export type CodeWidgetT = { + codeWidget?: string; + renderMode?: "markdown" | "iframe"; +}; + +export type CommandHookT = { + command?: CommandDef; +}; + +export type CronHookT = { + cron?: string | string[]; +}; + +type EndPointDef = { + method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS" | "ANY"; + path: string; +}; +export type EndpointHookT = { + http?: EndPointDef | EndPointDef[]; +}; + +export type EventHookT = { + events?: string[]; +}; + +type MQSubscription = { + queue: string; + batchSize?: number; + autoAck?: boolean; +}; +export type MQHookT = { + mqSubscriptions?: MQSubscription[]; +}; + +export type PanelWidgetT = { + panelWidget?: "top" | "bottom"; +}; + +export type PlugNamespaceDef = { + pattern: string; + operation: NamespaceOperation; +}; +export type PlugNamespaceHookT = { + pageNamespace?: PlugNamespaceDef; +}; + +export type SlashCommandDef = { + name: string; + description?: string; + boost?: number; +}; +export type SlashCommandHookT = { + slashCommand?: SlashCommandDef; +}; + +/** Silverbullet hooks give plugs access to silverbullet core systems. + * + * Hooks are associated with typescript functions through a manifest file. + * On various triggers (user enters a slash command, an HTTP endpoint is hit, user clicks, etc) the typescript function is called. + * + * related: plugos/type.ts#FunctionDef + */ +export type SilverBulletHooks = + & CommandHookT + & SlashCommandHookT + & CronHookT + & MQHookT + & EventHookT + & CodeWidgetT + & PanelWidgetT + & EndpointHookT + & PlugNamespaceHookT; + +/** A plug manifest configures hooks, declares syntax extensions, and describes plug metadata. + * + * Typically the manifest file is in a plug's root directory, named `${plugName}.plug.yaml`. + */ +export type Manifest = PlugosManifest; diff --git a/lib/memory_cache.test.ts b/lib/memory_cache.test.ts index 52ba7564..fcaf5e01 100644 --- a/lib/memory_cache.test.ts +++ b/lib/memory_cache.test.ts @@ -1,6 +1,6 @@ import { ttlCache } from "$lib/memory_cache.ts"; import { sleep } from "$lib/async.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; Deno.test("Memory cache", async () => { let calls = 0; diff --git a/lib/path.test.ts b/lib/path.test.ts index 4a3ac7f2..6b869956 100644 --- a/lib/path.test.ts +++ b/lib/path.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { folderName, resolve } from "./path.ts"; Deno.test("Path functions", () => { diff --git a/lib/plugos/deps.ts b/lib/plugos/deps.ts deleted file mode 100644 index 6025eea4..00000000 --- a/lib/plugos/deps.ts +++ /dev/null @@ -1,10 +0,0 @@ -export { globToRegExp } from "https://deno.land/std@0.165.0/path/glob.ts"; -export { walk } from "https://deno.land/std@0.165.0/fs/mod.ts"; -export * as path from "https://deno.land/std@0.165.0/path/mod.ts"; -export { expandGlobSync } from "https://deno.land/std@0.165.0/fs/mod.ts"; -export { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts"; -export { default as cacheDir } from "https://deno.land/x/cache_dir@0.2.0/mod.ts"; -export * as flags from "https://deno.land/std@0.165.0/flags/mod.ts"; -export * as esbuild from "https://deno.land/x/esbuild@v0.20.0/mod.js"; -export { denoPlugins } from "https://deno.land/x/esbuild_deno_loader@0.8.5/mod.ts"; -export * as YAML from "https://deno.land/std@0.184.0/yaml/mod.ts"; diff --git a/lib/plugos/eventhook.ts b/lib/plugos/eventhook.ts new file mode 100644 index 00000000..43b722f1 --- /dev/null +++ b/lib/plugos/eventhook.ts @@ -0,0 +1,7 @@ +import { EventHookT } from "$lib/manifest.ts"; +import { Hook } from "./types.ts"; + +export interface EventHookI extends Hook { + dispatchEvent(eventName: string, ...args: unknown[]): Promise; + listEvents(): string[]; +} diff --git a/lib/plugos/hooks/cron.ts b/lib/plugos/hooks/cron.ts index 1c710a28..96a3ee29 100644 --- a/lib/plugos/hooks/cron.ts +++ b/lib/plugos/hooks/cron.ts @@ -1,9 +1,7 @@ import { Hook, Manifest } from "../types.ts"; -import { Cron } from "https://cdn.jsdelivr.net/gh/hexagon/croner@4/src/croner.js"; +import { Cron } from "../../deps_server.ts"; import { System } from "../system.ts"; -export type CronHookT = { - cron?: string | string[]; -}; +import { CronHookT } from "$lib/manifest.ts"; export class CronHook implements Hook { tasks: Cron[] = []; diff --git a/lib/plugos/hooks/mq.ts b/lib/plugos/hooks/mq.ts index 82df924d..c107f7c3 100644 --- a/lib/plugos/hooks/mq.ts +++ b/lib/plugos/hooks/mq.ts @@ -1,18 +1,9 @@ import { Hook, Manifest } from "../types.ts"; import { System } from "../system.ts"; import { MQMessage } from "../../../plug-api/types.ts"; -import { MessageQueue } from "$lib/data/mq.ts"; -import { throttle } from "$lib/async.ts"; - -type MQSubscription = { - queue: string; - batchSize?: number; - autoAck?: boolean; -}; - -export type MQHookT = { - mqSubscriptions?: MQSubscription[]; -}; +import { MessageQueue } from "../../data/mq.ts"; +import { throttle } from "../../async.ts"; +import { MQHookT } from "$lib/manifest.ts"; export class MQHook implements Hook { subscriptions: (() => void)[] = []; diff --git a/lib/plugos/manifest_cache.ts b/lib/plugos/manifest_cache.ts index f1f50aba..3f9af989 100644 --- a/lib/plugos/manifest_cache.ts +++ b/lib/plugos/manifest_cache.ts @@ -1,4 +1,4 @@ -import { KvPrimitives } from "$lib/data/kv_primitives.ts"; +import { KvPrimitives } from "../data/kv_primitives.ts"; import { Plug } from "./plug.ts"; import { Manifest } from "./types.ts"; diff --git a/lib/plugos/namespace.ts b/lib/plugos/namespace.ts new file mode 100644 index 00000000..e58bfba5 --- /dev/null +++ b/lib/plugos/namespace.ts @@ -0,0 +1,6 @@ +export type NamespaceOperation = + | "readFile" + | "writeFile" + | "listFiles" + | "getFileMeta" + | "deleteFile"; diff --git a/lib/plugos/protocol.ts b/lib/plugos/protocol.ts index 7925d9b4..64a35915 100644 --- a/lib/plugos/protocol.ts +++ b/lib/plugos/protocol.ts @@ -1,4 +1,4 @@ -import type { Manifest } from "$common/manifest.ts"; +import type { Manifest } from "../manifest.ts"; // Messages received from the worker export type ControllerMessage = diff --git a/lib/plugos/syscalls/datastore.ts b/lib/plugos/syscalls/datastore.ts index 4bdb88bf..476c3dfe 100644 --- a/lib/plugos/syscalls/datastore.ts +++ b/lib/plugos/syscalls/datastore.ts @@ -1,5 +1,5 @@ import { KV, KvKey, KvQuery } from "../../../plug-api/types.ts"; -import type { DataStore } from "$lib/data/datastore.ts"; +import type { DataStore } from "../../data/datastore.ts"; import type { SysCallMapping } from "../system.ts"; /** diff --git a/lib/plugos/syscalls/event.ts b/lib/plugos/syscalls/event.ts index 69f25dd5..19d1d24e 100644 --- a/lib/plugos/syscalls/event.ts +++ b/lib/plugos/syscalls/event.ts @@ -1,7 +1,7 @@ import { SysCallMapping } from "../system.ts"; -import { EventHook } from "../../../common/hooks/event.ts"; +import { EventHookI } from "../eventhook.ts"; -export function eventSyscalls(eventHook: EventHook): SysCallMapping { +export function eventSyscalls(eventHook: EventHookI): SysCallMapping { return { "event.dispatch": (_ctx, eventName: string, data: any) => { return eventHook.dispatchEvent(eventName, data); diff --git a/lib/plugos/syscalls/fetch.ts b/lib/plugos/syscalls/fetch.ts index 8706006c..d098c548 100644 --- a/lib/plugos/syscalls/fetch.ts +++ b/lib/plugos/syscalls/fetch.ts @@ -1,5 +1,5 @@ import type { SysCallMapping } from "../system.ts"; -import { ProxyFetchRequest, ProxyFetchResponse } from "$common/proxy_fetch.ts"; +import { ProxyFetchRequest, ProxyFetchResponse } from "../../proxy_fetch.ts"; import { base64Encode } from "../../crypto.ts"; export function sandboxFetchSyscalls(): SysCallMapping { diff --git a/lib/plugos/syscalls/fs.deno.test.ts b/lib/plugos/syscalls/fs.deno.test.ts index 91e5bbf9..8e7f3680 100644 --- a/lib/plugos/syscalls/fs.deno.test.ts +++ b/lib/plugos/syscalls/fs.deno.test.ts @@ -1,6 +1,6 @@ import { FileMeta } from "../../../plug-api/types.ts"; -import { assert } from "$lib/test_deps.ts"; -import { path } from "../deps.ts"; +import { assert } from "$std/testing/asserts.ts"; +import { path } from "../../deps_server.ts"; import fileSystemSyscalls from "./fs.deno.ts"; Deno.test("Test FS operations", async () => { diff --git a/lib/plugos/syscalls/fs.deno.ts b/lib/plugos/syscalls/fs.deno.ts index 246b76ed..81ffeb7c 100644 --- a/lib/plugos/syscalls/fs.deno.ts +++ b/lib/plugos/syscalls/fs.deno.ts @@ -1,5 +1,5 @@ import type { SysCallMapping } from "../system.ts"; -import { mime, path, walk } from "../deps.ts"; +import { mime, path, walk } from "../../deps_server.ts"; import { FileMeta } from "../../../plug-api/types.ts"; import { base64DecodeDataUrl, base64Encode } from "../../crypto.ts"; diff --git a/lib/plugos/syscalls/mq.ts b/lib/plugos/syscalls/mq.ts index a62125b6..2f0d40a1 100644 --- a/lib/plugos/syscalls/mq.ts +++ b/lib/plugos/syscalls/mq.ts @@ -1,5 +1,5 @@ import { SysCallMapping } from "../system.ts"; -import { MessageQueue } from "$lib/data/mq.ts"; +import { MessageQueue } from "../../data/mq.ts"; export function mqSyscalls( mq: MessageQueue, diff --git a/lib/plugos/types.ts b/lib/plugos/types.ts index 9ecf7a1d..f01f1f7a 100644 --- a/lib/plugos/types.ts +++ b/lib/plugos/types.ts @@ -1,5 +1,5 @@ import { System } from "./system.ts"; -import { AssetJson } from "$lib/asset_bundle/bundle.ts"; +import { AssetJson } from "../asset_bundle/bundle.ts"; /** The generic top level of a plug manifest file. * Defines plug metadata and functions. diff --git a/lib/plugos/worker_runtime.ts b/lib/plugos/worker_runtime.ts index 7f1b188e..a173ad54 100644 --- a/lib/plugos/worker_runtime.ts +++ b/lib/plugos/worker_runtime.ts @@ -1,9 +1,6 @@ // This is the runtime imported from the compiled plug worker code import type { ControllerMessage, WorkerMessage } from "./protocol.ts"; -import type { - ProxyFetchRequest, - ProxyFetchResponse, -} from "$common/proxy_fetch.ts"; +import type { ProxyFetchRequest, ProxyFetchResponse } from "../proxy_fetch.ts"; declare global { function syscall(name: string, ...args: any[]): Promise; diff --git a/common/proxy_fetch.ts b/lib/proxy_fetch.ts similarity index 93% rename from common/proxy_fetch.ts rename to lib/proxy_fetch.ts index f9a6d6a1..373823e4 100644 --- a/common/proxy_fetch.ts +++ b/lib/proxy_fetch.ts @@ -1,4 +1,4 @@ -import { base64Decode, base64Encode } from "$lib/crypto.ts"; +import { base64Decode, base64Encode } from "./crypto.ts"; export type ProxyFetchRequest = { method?: string; diff --git a/lib/test_deps.ts b/lib/test_deps.ts deleted file mode 100644 index 24ee9729..00000000 --- a/lib/test_deps.ts +++ /dev/null @@ -1,13 +0,0 @@ -export { - assert, - assertEquals, - AssertionError, - assertMatch, - assertNotEquals, - assertRejects, - assertThrows, - equal, - fail, - unimplemented, - unreachable, -} from "https://deno.land/std@0.165.0/testing/asserts.ts"; diff --git a/lib/web.ts b/lib/web.ts new file mode 100644 index 00000000..13a79800 --- /dev/null +++ b/lib/web.ts @@ -0,0 +1,35 @@ +// Used by FilterBox +export type FilterOption = { + name: string; + description?: string; + orderId?: number; + hint?: string; +} & Record; + +export type Notification = { + id: number; + message: string; + type: "info" | "error"; + date: Date; +}; + +export type PanelMode = number; + +export type Shortcut = { + key?: string; + mac?: string; + priority?: number; + command: string; +}; + +export type ActionButton = { + icon: string; + description?: string; + command: string; + args?: any[]; + mobile?: boolean; +}; + +export type EmojiConfig = { + aliases: string[][]; +}; diff --git a/plug-api/lib/attribute.test.ts b/plug-api/lib/attribute.test.ts index 908e5d0a..2e4cb4ef 100644 --- a/plug-api/lib/attribute.test.ts +++ b/plug-api/lib/attribute.test.ts @@ -1,7 +1,7 @@ import "$sb/lib/syscall_mock.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts"; import { extractAttributes } from "$sb/lib/attribute.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { renderToText } from "./tree.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; diff --git a/plug-api/lib/attribute.ts b/plug-api/lib/attribute.ts index 5827adfc..61fc1b01 100644 --- a/plug-api/lib/attribute.ts +++ b/plug-api/lib/attribute.ts @@ -5,7 +5,7 @@ import { replaceNodesMatchingAsync, } from "./tree.ts"; -import { system, YAML } from "$sb/syscalls.ts"; +import { system, YAML } from "../syscalls.ts"; /** * Extracts attributes from a tree, optionally cleaning them out of the tree. diff --git a/plug-api/lib/feed.test.ts b/plug-api/lib/feed.test.ts index 3fc2e036..d57d4dfc 100644 --- a/plug-api/lib/feed.test.ts +++ b/plug-api/lib/feed.test.ts @@ -1,6 +1,6 @@ import "$sb/lib/syscall_mock.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { extractFeedItems } from "$sb/lib/feed.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; diff --git a/plug-api/lib/frontmatter.ts b/plug-api/lib/frontmatter.ts index ed111cd6..755f353b 100644 --- a/plug-api/lib/frontmatter.ts +++ b/plug-api/lib/frontmatter.ts @@ -6,7 +6,7 @@ import { traverseTreeAsync, } from "./tree.ts"; import { expandPropertyNames } from "./json.ts"; -import { YAML } from "$sb/syscalls.ts"; +import { YAML } from "../syscalls.ts"; export type FrontMatter = { tags?: string[] } & Record; diff --git a/plug-api/lib/json.test.ts b/plug-api/lib/json.test.ts index 9d365558..dbf1c4e4 100644 --- a/plug-api/lib/json.test.ts +++ b/plug-api/lib/json.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { deepEqual, deepObjectMerge, expandPropertyNames } from "./json.ts"; Deno.test("utils", () => { diff --git a/plug-api/lib/page_ref.test.ts b/plug-api/lib/page_ref.test.ts index de31de15..b827a83a 100644 --- a/plug-api/lib/page_ref.test.ts +++ b/plug-api/lib/page_ref.test.ts @@ -1,5 +1,5 @@ import { encodePageRef, parsePageRef } from "./page_ref.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; Deno.test("Page utility functions", () => { // Base cases diff --git a/plug-api/lib/parser-query.test.ts b/plug-api/lib/parser-query.test.ts index 4a5d9c64..ab8e1503 100644 --- a/plug-api/lib/parser-query.test.ts +++ b/plug-api/lib/parser-query.test.ts @@ -1,6 +1,6 @@ import { parse } from "$common/markdown_parser/parse_tree.ts"; -import { AST, collectNodesOfType, parseTreeToAST } from "$sb/lib/tree.ts"; -import { assert, assertEquals } from "$lib/test_deps.ts"; +import { AST, collectNodesOfType, parseTreeToAST } from "./tree.ts"; +import { assert, assertEquals } from "$std/testing/asserts.ts"; import { astToKvQuery } from "$sb/lib/parse-query.ts"; import { languageFor } from "$common/languages.ts"; diff --git a/plug-api/lib/query.ts b/plug-api/lib/query.ts index 660fe196..698c785f 100644 --- a/plug-api/lib/query.ts +++ b/plug-api/lib/query.ts @@ -1,5 +1,5 @@ import { FunctionMap, KV, Query, QueryExpression } from "../types.ts"; -import { evalQueryExpression } from "$sb/lib/query_expression.ts"; +import { evalQueryExpression } from "./query_expression.ts"; /** * Looks for an attribute assignment in the expression, and returns the expression assigned to the attribute or throws an error when not found diff --git a/plug-api/lib/query_expression.test.ts b/plug-api/lib/query_expression.test.ts index 280c6fb9..39f31eb7 100644 --- a/plug-api/lib/query_expression.test.ts +++ b/plug-api/lib/query_expression.test.ts @@ -1,5 +1,5 @@ import { evalQueryExpression } from "$sb/lib/query_expression.ts"; -import { assert, assertEquals } from "$lib/test_deps.ts"; +import { assert, assertEquals } from "$std/testing/asserts.ts"; Deno.test("Test query expression evaluation", async () => { assertEquals( diff --git a/plug-api/lib/resolve.test.ts b/plug-api/lib/resolve.test.ts index c5701e2a..43f61b65 100644 --- a/plug-api/lib/resolve.test.ts +++ b/plug-api/lib/resolve.test.ts @@ -5,8 +5,8 @@ import { resolvePath, rewritePageRefs, } from "$sb/lib/resolve.ts"; -import { assertEquals } from "$lib/test_deps.ts"; -import { ParseTree, renderToText } from "$sb/lib/tree.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; +import { ParseTree, renderToText } from "./tree.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; diff --git a/plug-api/lib/settings_page.ts b/plug-api/lib/settings_page.ts index 69b3c687..b6a8e3f2 100644 --- a/plug-api/lib/settings_page.ts +++ b/plug-api/lib/settings_page.ts @@ -1,5 +1,5 @@ -import { readYamlPage } from "$sb/lib/yaml_page.ts"; -import { editor, space, YAML } from "$sb/syscalls.ts"; +import { readYamlPage } from "./yaml_page.ts"; +import { editor, space, YAML } from "../syscalls.ts"; /** * Convenience function to read a specific set of settings from the `SETTINGS` page as well as default values diff --git a/plug-api/lib/syscall_mock.ts b/plug-api/lib/syscall_mock.ts index 4470e8bb..75c6b96e 100644 --- a/plug-api/lib/syscall_mock.ts +++ b/plug-api/lib/syscall_mock.ts @@ -1,9 +1,9 @@ -import { YAML } from "$common/deps.ts"; +import { YAML } from "../../lib/deps_server.ts"; globalThis.syscall = (name: string, ...args: readonly any[]) => { switch (name) { case "yaml.parse": - return Promise.resolve(YAML.load(args[0])); + return Promise.resolve(YAML.parse(args[0])); case "system.applyAttributeExtractors": return Promise.resolve({}); default: diff --git a/plug-api/lib/tags.ts b/plug-api/lib/tags.ts index 82260c8e..4333141d 100644 --- a/plug-api/lib/tags.ts +++ b/plug-api/lib/tags.ts @@ -1,4 +1,4 @@ -import { FrontMatter } from "$sb/lib/frontmatter.ts"; +import { FrontMatter } from "./frontmatter.ts"; import { ObjectValue } from "../types.ts"; export function updateITags(obj: ObjectValue, frontmatter: FrontMatter) { diff --git a/plug-api/lib/tree.test.ts b/plug-api/lib/tree.test.ts index 27026c82..5ae2c426 100644 --- a/plug-api/lib/tree.test.ts +++ b/plug-api/lib/tree.test.ts @@ -8,8 +8,8 @@ import { removeParentPointers, renderToText, replaceNodesMatching, -} from "$sb/lib/tree.ts"; -import { assertEquals, assertNotEquals } from "$lib/test_deps.ts"; +} from "./tree.ts"; +import { assertEquals, assertNotEquals } from "$std/testing/asserts.ts"; import { parse } from "$common/markdown_parser/parse_tree.ts"; import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts"; diff --git a/plug-api/lib/yaml_page.ts b/plug-api/lib/yaml_page.ts index 49f61ff3..5af54522 100644 --- a/plug-api/lib/yaml_page.ts +++ b/plug-api/lib/yaml_page.ts @@ -1,5 +1,5 @@ -import { findNodeOfType, traverseTree } from "$sb/lib/tree.ts"; -import { markdown, space, YAML } from "$sb/syscalls.ts"; +import { findNodeOfType, traverseTree } from "./tree.ts"; +import { markdown, space, YAML } from "../syscalls.ts"; export async function readCodeBlockPage( pageName: string, diff --git a/plug-api/syscalls/datastore.ts b/plug-api/syscalls/datastore.ts index bfdf4d91..b906d1ba 100644 --- a/plug-api/syscalls/datastore.ts +++ b/plug-api/syscalls/datastore.ts @@ -1,4 +1,4 @@ -import { syscall } from "$sb/syscall.ts"; +import { syscall } from "../syscall.ts"; import { KV, KvKey, KvQuery } from "../types.ts"; export function set(key: KvKey, value: any): Promise { diff --git a/plug-api/syscalls/editor.ts b/plug-api/syscalls/editor.ts index 554e8931..dd35d479 100644 --- a/plug-api/syscalls/editor.ts +++ b/plug-api/syscalls/editor.ts @@ -1,7 +1,7 @@ -import type { FilterOption } from "../../type/web.ts"; import { UploadFile } from "../types.ts"; import { syscall } from "../syscall.ts"; -import type { PageRef } from "$sb/lib/page_ref.ts"; +import type { PageRef } from "../lib/page_ref.ts"; +import type { FilterOption } from "../../lib/web.ts"; export function getCurrentPage(): Promise { return syscall("editor.getCurrentPage"); diff --git a/plug-api/syscalls/language.ts b/plug-api/syscalls/language.ts index cf4091ef..710a08e2 100644 --- a/plug-api/syscalls/language.ts +++ b/plug-api/syscalls/language.ts @@ -1,5 +1,4 @@ import { syscall } from "../syscall.ts"; - import type { ParseTree } from "../lib/tree.ts"; /** diff --git a/plug-api/syscalls/mq.ts b/plug-api/syscalls/mq.ts index f848903f..8537506e 100644 --- a/plug-api/syscalls/mq.ts +++ b/plug-api/syscalls/mq.ts @@ -1,4 +1,4 @@ -import { syscall } from "$sb/syscall.ts"; +import { syscall } from "../syscall.ts"; import type { MQStats } from "../types.ts"; export function send(queue: string, body: any) { diff --git a/plug-api/syscalls/system.ts b/plug-api/syscalls/system.ts index e2889693..c4df4597 100644 --- a/plug-api/syscalls/system.ts +++ b/plug-api/syscalls/system.ts @@ -1,4 +1,4 @@ -import type { CommandDef } from "$common/hooks/command.ts"; +import type { CommandDef } from "../../lib/command.ts"; import type { SyscallMeta } from "../types.ts"; import type { ParseTree } from "../lib/tree.ts"; import { syscall } from "../syscall.ts"; diff --git a/plugs/emoji/emoji.ts b/plugs/emoji/emoji.ts index 20b00bc5..20f25e54 100644 --- a/plugs/emoji/emoji.ts +++ b/plugs/emoji/emoji.ts @@ -1,8 +1,8 @@ -import emojiBlob from "./emoji.json" assert { type: "json" }; +import emojiBlob from "./emoji.json" with { type: "json" }; import type { CompleteEvent } from "../../plug-api/types.ts"; import { readSetting } from "$sb/lib/settings_page.ts"; import { editor } from "$sb/syscalls.ts"; -import type { EmojiConfig } from "../../type/web.ts"; +import type { EmojiConfig } from "$lib/web.ts"; let emojiConfig: EmojiConfig = { aliases: [] }; diff --git a/plugs/index/snippet_extractor.test.ts b/plugs/index/snippet_extractor.test.ts index 7d9a92f0..3b2471ec 100644 --- a/plugs/index/snippet_extractor.test.ts +++ b/plugs/index/snippet_extractor.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { extractSnippetAroundIndex } from "./snippet_extractor.ts"; Deno.test("SnippetExtractor", () => { diff --git a/plugs/markdown/html_render.test.ts b/plugs/markdown/html_render.test.ts index 824b1c3b..3ae739b6 100644 --- a/plugs/markdown/html_render.test.ts +++ b/plugs/markdown/html_render.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "https://deno.land/std@0.165.0/testing/asserts.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { renderHtml } from "./html_render.ts"; Deno.test("HTML Render", () => { diff --git a/plugs/query/widget.ts b/plugs/query/widget.ts index efc1303b..9b8da3b6 100644 --- a/plugs/query/widget.ts +++ b/plugs/query/widget.ts @@ -14,7 +14,7 @@ import { loadPageObject, replaceTemplateVars } from "../template/page.ts"; import { CodeWidgetContent } from "../../plug-api/types.ts"; import { jsonToMDTable } from "../template/util.ts"; import { renderQuery } from "./api.ts"; -import { ChangeSpec } from "../../web/deps.ts"; +import type { ChangeSpec } from "@codemirror/state"; export async function widget( bodyText: string, diff --git a/plugs/search/engine.ts b/plugs/search/engine.ts index 03faddf2..abf5c2e2 100644 --- a/plugs/search/engine.ts +++ b/plugs/search/engine.ts @@ -1,4 +1,4 @@ -import { stemmer } from "https://esm.sh/porter-stemmer@0.9.1"; +import { stemmer } from "porter-stemmer"; import { batchSet, query } from "../index/plug_api.ts"; type ResultObject = { diff --git a/scripts/generate_fs_list.ts b/scripts/generate_fs_list.ts index 481b9446..a9f5b57e 100644 --- a/scripts/generate_fs_list.ts +++ b/scripts/generate_fs_list.ts @@ -1,6 +1,6 @@ -import { walk } from "https://deno.land/std@0.165.0/fs/mod.ts"; -import { resolve } from "https://deno.land/std@0.165.0/path/mod.ts"; -import { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts"; +import { walk } from "$std/fs/walk.ts"; +import { resolve } from "$std/path/mod.ts"; +import { mime } from "mimetypes"; import { FileMeta } from "../plug-api/types.ts"; const rootDir = resolve("website_build"); diff --git a/server/crypto.test.ts b/server/crypto.test.ts index f7cbf8fb..5f5b0d39 100644 --- a/server/crypto.test.ts +++ b/server/crypto.test.ts @@ -1,6 +1,6 @@ import { sleep } from "$lib/async.ts"; import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; -import { assertEquals } from "$lib/test_deps.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; import { JWTIssuer } from "./crypto.ts"; Deno.test("Test JWT crypto", async () => { diff --git a/server/db_backend.ts b/server/db_backend.ts index c1087b97..47893725 100644 --- a/server/db_backend.ts +++ b/server/db_backend.ts @@ -1,7 +1,7 @@ import { DenoKvPrimitives } from "$lib/data/deno_kv_primitives.ts"; import { KvPrimitives } from "$lib/data/kv_primitives.ts"; import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts"; -import { path } from "./deps.ts"; +import { resolve } from "$std/path/mod.ts"; /** * Environment variables: @@ -20,7 +20,7 @@ export async function determineDatabaseBackend( if (singleTenantFolder) { // If we're running in single tenant mode, we may as well use the tenant's space folder to keep the database - dbFile = path.resolve(singleTenantFolder, dbFile); + dbFile = resolve(singleTenantFolder, dbFile); } if (Deno.env.get("DENO_DEPLOYMENT_ID") !== undefined) { // We're running in Deno Deploy diff --git a/server/deps.ts b/server/deps.ts deleted file mode 100644 index 7f2a4722..00000000 --- a/server/deps.ts +++ /dev/null @@ -1,15 +0,0 @@ -export * from "$common/deps.ts"; - -export { Hono } from "https://deno.land/x/hono@v3.12.2/mod.ts"; -export { - deleteCookie, - getCookie, - setCookie, -} from "https://deno.land/x/hono@v3.12.2/helper.ts"; -export { cors } from "https://deno.land/x/hono@v3.12.2/middleware.ts"; - -export type { - Context, - HonoRequest, - Next, -} from "https://deno.land/x/hono@v3.12.2/mod.ts"; diff --git a/server/hooks/endpoint.ts b/server/hooks/endpoint.ts index b4e23389..359d3c98 100644 --- a/server/hooks/endpoint.ts +++ b/server/hooks/endpoint.ts @@ -1,6 +1,7 @@ import { Hook, Manifest } from "../../lib/plugos/types.ts"; import { System } from "../../lib/plugos/system.ts"; -import { Context, Next } from "../../server/deps.ts"; +import type { Context, Next } from "hono/mod.ts"; +import { EndpointHookT } from "$lib/manifest.ts"; export type EndpointRequest = { method: string; @@ -16,15 +17,6 @@ export type EndpointResponse = { body: any; }; -export type EndpointHookT = { - http?: EndPointDef | EndPointDef[]; -}; - -export type EndPointDef = { - method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS" | "ANY"; - path: string; -}; - export class EndpointHook implements Hook { readonly prefix: string; diff --git a/server/http_server.ts b/server/http_server.ts index f33c0942..c09153b2 100644 --- a/server/http_server.ts +++ b/server/http_server.ts @@ -1,12 +1,6 @@ -import { - Context, - cors, - deleteCookie, - getCookie, - Hono, - HonoRequest, - setCookie, -} from "./deps.ts"; +import { deleteCookie, getCookie, setCookie } from "hono/helper.ts"; +import { cors } from "hono/middleware.ts"; +import { type Context, Hono, type HonoRequest } from "hono/mod.ts"; import { AssetBundle } from "../lib/asset_bundle/bundle.ts"; import { FileMeta } from "../plug-api/types.ts"; import { ShellRequest } from "../type/rpc.ts"; diff --git a/server/instance.ts b/server/instance.ts index 885439f3..94fa4a37 100644 --- a/server/instance.ts +++ b/server/instance.ts @@ -1,4 +1,4 @@ -import { SilverBulletHooks } from "$common/manifest.ts"; +import { SilverBulletHooks } from "../lib/manifest.ts"; import { ensureAndLoadSettingsAndIndex } from "$common/settings.ts"; import { AssetBundlePlugSpacePrimitives } from "$common/spaces/asset_bundle_space_primitives.ts"; import { FilteredSpacePrimitives } from "$common/spaces/filtered_space_primitives.ts"; @@ -12,7 +12,7 @@ import { DataStoreMQ } from "$lib/data/mq.datastore.ts"; import { System } from "$lib/plugos/system.ts"; import { BuiltinSettings } from "../type/web.ts"; import { JWTIssuer } from "./crypto.ts"; -import { gitIgnoreCompiler } from "./deps.ts"; +import { compile as gitIgnoreCompiler } from "gitignore-parser"; import { ServerSystem } from "./server_system.ts"; import { determineShellBackend, NotSupportedShell } from "./shell_backend.ts"; import { ShellBackend } from "./shell_backend.ts"; diff --git a/server/server_system.ts b/server/server_system.ts index 7e19954c..54b8d225 100644 --- a/server/server_system.ts +++ b/server/server_system.ts @@ -1,5 +1,5 @@ import { PlugNamespaceHook } from "$common/hooks/plug_namespace.ts"; -import { SilverBulletHooks } from "$common/manifest.ts"; +import { SilverBulletHooks } from "../lib/manifest.ts"; import { EventedSpacePrimitives } from "$common/spaces/evented_space_primitives.ts"; import { PlugSpacePrimitives } from "$common/spaces/plug_space_primitives.ts"; import { createSandbox } from "../lib/plugos/sandboxes/web_worker_sandbox.ts"; diff --git a/server/storage_backend.ts b/server/storage_backend.ts index 68ea0d3c..caacf01e 100644 --- a/server/storage_backend.ts +++ b/server/storage_backend.ts @@ -1,6 +1,6 @@ import { DiskSpacePrimitives } from "$common/spaces/disk_space_primitives.ts"; import { SpacePrimitives } from "$common/spaces/space_primitives.ts"; -import { path } from "./deps.ts"; +import { resolve } from "$std/path/mod.ts"; import { S3SpacePrimitives } from "$common/spaces/s3_space_primitives.ts"; import { KvPrimitives } from "$lib/data/kv_primitives.ts"; import { ChunkedKvStoreSpacePrimitives } from "$common/spaces/chunked_datastore_space_primitives.ts"; @@ -48,7 +48,7 @@ export async function determineStorageBackend( Deno.env.get("SB_AUTH_TOKEN"), ); } else { - folder = path.resolve(Deno.cwd(), folder); + folder = resolve(Deno.cwd(), folder); console.info(`Using local disk as a storage backend: ${folder}`); return new DiskSpacePrimitives(folder); } diff --git a/silverbullet.ts b/silverbullet.ts index 3ea458fb..73b710c1 100755 --- a/silverbullet.ts +++ b/silverbullet.ts @@ -1,5 +1,5 @@ import.meta.main = false; -import { Command } from "https://deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts"; +import { Command } from "cliffy/command/command.ts"; import { version } from "./version.ts"; diff --git a/type/web.ts b/type/web.ts index 65cb04e6..df4de583 100644 --- a/type/web.ts +++ b/type/web.ts @@ -1,43 +1,15 @@ -import { Manifest } from "$common/manifest.ts"; +import { Manifest } from "../lib/manifest.ts"; import { PageMeta } from "../plug-api/types.ts"; -import { AppCommand } from "$common/hooks/command.ts"; +import { AppCommand } from "../lib/command.ts"; import { defaultSettings } from "$common/settings.ts"; - -// Used by FilterBox -export type FilterOption = { - name: string; - description?: string; - orderId?: number; - hint?: string; -} & Record; - -export type Notification = { - id: number; - message: string; - type: "info" | "error"; - date: Date; -}; - -export type PanelMode = number; - -export type Shortcut = { - key?: string; - mac?: string; - priority?: number; - command: string; -}; - -export type ActionButton = { - icon: string; - description?: string; - command: string; - args?: any[]; - mobile?: boolean; -}; - -export type EmojiConfig = { - aliases: string[][]; -}; +import { + ActionButton, + EmojiConfig, + FilterOption, + Notification, + PanelMode, + Shortcut, +} from "$lib/web.ts"; export type BuiltinSettings = { indexPage: string; diff --git a/web/change.test.ts b/web/change.test.ts index df478fc2..c55bef09 100644 --- a/web/change.test.ts +++ b/web/change.test.ts @@ -1,5 +1,5 @@ import { rangeLength, rangesOverlap } from "./change.ts"; -import { assertEquals } from "https://deno.land/std@0.165.0/testing/asserts.ts"; +import { assertEquals } from "$std/testing/asserts.ts"; Deno.test("rangeLength", () => { assertEquals(rangeLength({ from: 4, to: 11 }), 7); diff --git a/web/client.ts b/web/client.ts index ffe35c3a..be055633 100644 --- a/web/client.ts +++ b/web/client.ts @@ -1,17 +1,13 @@ -// Third party web dependencies -import { - Compartment, - CompletionContext, - CompletionResult, - EditorView, - gitIgnoreCompiler, - SyntaxNode, - syntaxTree, -} from "./deps.ts"; +import { CompletionContext, CompletionResult } from "@codemirror/autocomplete"; +import type { Compartment } from "@codemirror/state"; +import { EditorView } from "@codemirror/view"; +import { syntaxTree } from "@codemirror/language"; +import { compile as gitIgnoreCompiler } from "gitignore-parser"; +import { SyntaxNode } from "@lezer/common"; import { Space } from "../common/space.ts"; -import { FilterOption } from "../type/web.ts"; +import { FilterOption } from "$lib/web.ts"; import { EventHook } from "../common/hooks/event.ts"; -import { AppCommand } from "$common/hooks/command.ts"; +import { AppCommand } from "$lib/command.ts"; import { PageState, parsePageRefFromURI, diff --git a/web/client_system.ts b/web/client_system.ts index 91358326..09085368 100644 --- a/web/client_system.ts +++ b/web/client_system.ts @@ -1,5 +1,5 @@ import { PlugNamespaceHook } from "$common/hooks/plug_namespace.ts"; -import { SilverBulletHooks } from "$common/manifest.ts"; +import { SilverBulletHooks } from "../lib/manifest.ts"; import { CronHook } from "../lib/plugos/hooks/cron.ts"; import { EventHook } from "../common/hooks/event.ts"; import { createSandbox } from "../lib/plugos/sandboxes/web_worker_sandbox.ts"; diff --git a/web/cm_plugins/admonition.ts b/web/cm_plugins/admonition.ts index 2c8c804a..08df5f14 100644 --- a/web/cm_plugins/admonition.ts +++ b/web/cm_plugins/admonition.ts @@ -1,11 +1,7 @@ -import { - Decoration, - EditorState, - EditorView, - SyntaxNodeRef, - syntaxTree, - WidgetType, -} from "../deps.ts"; +import { EditorState } from "@codemirror/state"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration, EditorView, WidgetType } from "@codemirror/view"; +import { SyntaxNodeRef } from "@lezer/common"; import { Client } from "../client.ts"; import { decoratorStateField, isCursorInRange } from "./util.ts"; diff --git a/web/cm_plugins/block.ts b/web/cm_plugins/block.ts index 1f0c02ae..a17167d0 100644 --- a/web/cm_plugins/block.ts +++ b/web/cm_plugins/block.ts @@ -1,4 +1,6 @@ -import { Decoration, EditorState, syntaxTree } from "../deps.ts"; +import { EditorState } from "@codemirror/state"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration } from "@codemirror/view"; import { decoratorStateField, invisibleDecoration, diff --git a/web/cm_plugins/block_quote.ts b/web/cm_plugins/block_quote.ts index 1ed2cd11..cedf927b 100644 --- a/web/cm_plugins/block_quote.ts +++ b/web/cm_plugins/block_quote.ts @@ -1,4 +1,6 @@ -import { Decoration, EditorState, syntaxTree } from "../deps.ts"; +import { EditorState } from "@codemirror/state"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration } from "@codemirror/view"; import { decoratorStateField, invisibleDecoration, diff --git a/web/cm_plugins/clean.ts b/web/cm_plugins/clean.ts index 8f5d288e..611232d9 100644 --- a/web/cm_plugins/clean.ts +++ b/web/cm_plugins/clean.ts @@ -1,5 +1,5 @@ import type { ClickEvent } from "../../plug-api/types.ts"; -import type { Extension } from "../deps.ts"; +import type { Extension } from "@codemirror/state"; import type { Client } from "../client.ts"; import { blockquotePlugin } from "./block_quote.ts"; import { admonitionPlugin } from "./admonition.ts"; diff --git a/web/cm_plugins/code_copy.ts b/web/cm_plugins/code_copy.ts index d1bcb7c5..8bffef16 100644 --- a/web/cm_plugins/code_copy.ts +++ b/web/cm_plugins/code_copy.ts @@ -1,14 +1,14 @@ import { Client } from "../client.ts"; +import { Range } from "@codemirror/state"; +import { DecorationSet } from "@codemirror/view"; +import { syntaxTree } from "@codemirror/language"; import { Decoration, - DecorationSet, EditorView, - Range, - syntaxTree, ViewPlugin, ViewUpdate, WidgetType, -} from "../deps.ts"; +} from "@codemirror/view"; const ICON_SVG = ''; diff --git a/web/cm_plugins/command_link.ts b/web/cm_plugins/command_link.ts index f01a59dc..b0b87737 100644 --- a/web/cm_plugins/command_link.ts +++ b/web/cm_plugins/command_link.ts @@ -1,5 +1,6 @@ import { ClickEvent } from "../../plug-api/types.ts"; -import { Decoration, syntaxTree } from "../deps.ts"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration } from "@codemirror/view"; import { Client } from "../client.ts"; import { ButtonWidget, diff --git a/web/cm_plugins/editor_paste.ts b/web/cm_plugins/editor_paste.ts index 9c0af9d7..6b9b68da 100644 --- a/web/cm_plugins/editor_paste.ts +++ b/web/cm_plugins/editor_paste.ts @@ -1,4 +1,5 @@ -import { EditorView, syntaxTree, ViewPlugin, ViewUpdate } from "../deps.ts"; +import { syntaxTree } from "@codemirror/language"; +import { EditorView, ViewPlugin, ViewUpdate } from "@codemirror/view"; import { Client } from "../client.ts"; // We use turndown to convert HTML to Markdown diff --git a/web/cm_plugins/fenced_code.ts b/web/cm_plugins/fenced_code.ts index 217b3962..6577a7aa 100644 --- a/web/cm_plugins/fenced_code.ts +++ b/web/cm_plugins/fenced_code.ts @@ -1,4 +1,6 @@ -import { Decoration, EditorState, syntaxTree } from "../deps.ts"; +import { EditorState } from "@codemirror/state"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration } from "@codemirror/view"; import type { Client } from "../client.ts"; import { decoratorStateField, diff --git a/web/cm_plugins/frontmatter.ts b/web/cm_plugins/frontmatter.ts index 97ff448a..b728a703 100644 --- a/web/cm_plugins/frontmatter.ts +++ b/web/cm_plugins/frontmatter.ts @@ -1,4 +1,6 @@ -import { Decoration, EditorState, foldedRanges, syntaxTree } from "../deps.ts"; +import { EditorState } from "@codemirror/state"; +import { foldedRanges, syntaxTree } from "@codemirror/language"; +import { Decoration } from "@codemirror/view"; import { decoratorStateField, HtmlWidget, isCursorInRange } from "./util.ts"; export function frontmatterPlugin() { diff --git a/web/cm_plugins/hide_mark.ts b/web/cm_plugins/hide_mark.ts index 219c4003..3a20e0a2 100644 --- a/web/cm_plugins/hide_mark.ts +++ b/web/cm_plugins/hide_mark.ts @@ -2,7 +2,9 @@ // Original author: Pranav Karawale // License: Apache License 2.0. -import { Decoration, EditorState, syntaxTree } from "../deps.ts"; +import { EditorState } from "@codemirror/state"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration } from "@codemirror/view"; import { checkRangeOverlap, decoratorStateField, diff --git a/web/cm_plugins/iframe_widget.ts b/web/cm_plugins/iframe_widget.ts index 0fa48e77..25762588 100644 --- a/web/cm_plugins/iframe_widget.ts +++ b/web/cm_plugins/iframe_widget.ts @@ -1,5 +1,5 @@ import { CodeWidgetCallback, WidgetContent } from "../../plug-api/types.ts"; -import { WidgetType } from "../deps.ts"; +import { WidgetType } from "@codemirror/view"; import type { Client } from "../client.ts"; import { createWidgetSandboxIFrame } from "../components/widget_sandbox_iframe.ts"; diff --git a/web/cm_plugins/inline_image.ts b/web/cm_plugins/inline_image.ts index 9a90d23d..11109806 100644 --- a/web/cm_plugins/inline_image.ts +++ b/web/cm_plugins/inline_image.ts @@ -1,12 +1,7 @@ -import { - Decoration, - EditorState, - Range, - syntaxTree, - WidgetType, -} from "../deps.ts"; +import { EditorState, Range } from "@codemirror/state"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration, WidgetType } from "@codemirror/view"; import { decoratorStateField } from "./util.ts"; - import type { Client } from "../client.ts"; import { resolveAttachmentPath, resolvePath } from "$sb/lib/resolve.ts"; diff --git a/web/cm_plugins/line_wrapper.ts b/web/cm_plugins/line_wrapper.ts index 34efb040..e99851ad 100644 --- a/web/cm_plugins/line_wrapper.ts +++ b/web/cm_plugins/line_wrapper.ts @@ -1,4 +1,6 @@ -import { Decoration, EditorState, Range, syntaxTree } from "../deps.ts"; +import { EditorState, Range } from "@codemirror/state"; +import { Decoration } from "@codemirror/view"; +import { syntaxTree } from "@codemirror/language"; import { decoratorStateField } from "./util.ts"; interface WrapElement { diff --git a/web/cm_plugins/link.ts b/web/cm_plugins/link.ts index 9dd2d9f6..6466cb99 100644 --- a/web/cm_plugins/link.ts +++ b/web/cm_plugins/link.ts @@ -1,6 +1,7 @@ import { resolveAttachmentPath } from "$sb/lib/resolve.ts"; import { Client } from "../client.ts"; -import { Decoration, syntaxTree } from "../deps.ts"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration } from "@codemirror/view"; import { decoratorStateField, invisibleDecoration, diff --git a/web/cm_plugins/list.ts b/web/cm_plugins/list.ts index 0e1b73d6..871375ac 100644 --- a/web/cm_plugins/list.ts +++ b/web/cm_plugins/list.ts @@ -2,7 +2,8 @@ // Original author: Pranav Karawale // License: Apache License 2.0. -import { Decoration, syntaxTree, WidgetType } from "../deps.ts"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration, WidgetType } from "@codemirror/view"; import { decoratorStateField, isCursorInRange } from "./util.ts"; const bulletListMarkerRE = /^[-+*]/; diff --git a/web/cm_plugins/markdown_widget.ts b/web/cm_plugins/markdown_widget.ts index 926ccb1a..a40e852b 100644 --- a/web/cm_plugins/markdown_widget.ts +++ b/web/cm_plugins/markdown_widget.ts @@ -1,4 +1,4 @@ -import { WidgetType } from "../deps.ts"; +import { WidgetType } from "@codemirror/view"; import type { Client } from "../client.ts"; import type { CodeWidgetButton, diff --git a/web/cm_plugins/readonly.ts b/web/cm_plugins/readonly.ts index 05eebe29..5496a580 100644 --- a/web/cm_plugins/readonly.ts +++ b/web/cm_plugins/readonly.ts @@ -1,4 +1,4 @@ -import { EditorState } from "../deps.ts"; +import { EditorState } from "@codemirror/state"; export function readonlyMode() { return EditorState.changeFilter.of((tr): boolean => { diff --git a/web/cm_plugins/smart_quotes.ts b/web/cm_plugins/smart_quotes.ts index 01b1d25d..d9598e03 100644 --- a/web/cm_plugins/smart_quotes.ts +++ b/web/cm_plugins/smart_quotes.ts @@ -1,4 +1,5 @@ -import { KeyBinding, syntaxTree } from "../deps.ts"; +import { KeyBinding } from "@codemirror/view"; +import { syntaxTree } from "@codemirror/language"; const straightQuoteContexts = [ "CommentBlock", diff --git a/web/cm_plugins/table.ts b/web/cm_plugins/table.ts index 0f27176c..5acf6439 100644 --- a/web/cm_plugins/table.ts +++ b/web/cm_plugins/table.ts @@ -1,4 +1,6 @@ -import { Decoration, EditorState, syntaxTree, WidgetType } from "../deps.ts"; +import { EditorState } from "@codemirror/state"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration, WidgetType } from "@codemirror/view"; import { decoratorStateField, invisibleDecoration, diff --git a/web/cm_plugins/task.ts b/web/cm_plugins/task.ts index a0cca4ef..345afb25 100644 --- a/web/cm_plugins/task.ts +++ b/web/cm_plugins/task.ts @@ -1,4 +1,6 @@ -import { Decoration, NodeType, syntaxTree, WidgetType } from "../deps.ts"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration, WidgetType } from "@codemirror/view"; +import { NodeType } from "@lezer/common"; import { decoratorStateField, isCursorInRange } from "./util.ts"; /** diff --git a/web/cm_plugins/top_bottom_panels.ts b/web/cm_plugins/top_bottom_panels.ts index 85630fbd..52dcd185 100644 --- a/web/cm_plugins/top_bottom_panels.ts +++ b/web/cm_plugins/top_bottom_panels.ts @@ -1,4 +1,5 @@ -import { Decoration, EditorState } from "../deps.ts"; +import { EditorState } from "@codemirror/state"; +import { Decoration } from "@codemirror/view"; import type { Client } from "../client.ts"; import { decoratorStateField } from "./util.ts"; import { MarkdownWidget } from "./markdown_widget.ts"; diff --git a/web/cm_plugins/util.ts b/web/cm_plugins/util.ts index ca2bc3c6..b7a53c17 100644 --- a/web/cm_plugins/util.ts +++ b/web/cm_plugins/util.ts @@ -1,16 +1,9 @@ // Forked from https://codeberg.org/retronav/ixora // Original author: Pranav Karawale // License: Apache License 2.0. -import { - Decoration, - DecorationSet, - EditorState, - EditorView, - StateField, - Transaction, - WidgetType, -} from "../deps.ts"; - +import { EditorState, StateField, Transaction } from "@codemirror/state"; +import { DecorationSet } from "@codemirror/view"; +import { Decoration, EditorView, WidgetType } from "@codemirror/view"; type LinkOptions = { text: string; href?: string; diff --git a/web/cm_plugins/wiki_link.ts b/web/cm_plugins/wiki_link.ts index 0faf8b9d..0da7b3b5 100644 --- a/web/cm_plugins/wiki_link.ts +++ b/web/cm_plugins/wiki_link.ts @@ -1,6 +1,7 @@ import { pageLinkRegex } from "$common/markdown_parser/parser.ts"; import { ClickEvent } from "../../plug-api/types.ts"; -import { Decoration, syntaxTree } from "../deps.ts"; +import { syntaxTree } from "@codemirror/language"; +import { Decoration } from "@codemirror/view"; import { Client } from "../client.ts"; import { decoratorStateField, diff --git a/web/cm_util.ts b/web/cm_util.ts index 7c9af6cd..d958afa2 100644 --- a/web/cm_util.ts +++ b/web/cm_util.ts @@ -1,4 +1,4 @@ -import diff, { DELETE, INSERT } from "https://esm.sh/fast-diff@1.3.0"; +import diff, { DELETE, INSERT } from "fast-diff"; import type { ChangeSpec } from "@codemirror/state"; export function diffAndPrepareChanges( diff --git a/web/components/basic_modals.tsx b/web/components/basic_modals.tsx index bd4aea37..150b1ce8 100644 --- a/web/components/basic_modals.tsx +++ b/web/components/basic_modals.tsx @@ -1,5 +1,5 @@ -import type { CompletionContext, CompletionResult } from "../deps.ts"; -import { useRef, useState } from "../deps.ts"; +import { CompletionContext, CompletionResult } from "@codemirror/autocomplete"; +import { useRef, useState } from "preact/hooks"; import { MiniEditor } from "./mini_editor.tsx"; export function Prompt({ diff --git a/web/components/command_palette.tsx b/web/components/command_palette.tsx index f95f43bc..fd01283a 100644 --- a/web/components/command_palette.tsx +++ b/web/components/command_palette.tsx @@ -1,7 +1,9 @@ import { FilterList } from "./filter.tsx"; -import { CompletionContext, CompletionResult, featherIcons } from "../deps.ts"; -import { AppCommand } from "$common/hooks/command.ts"; -import { BuiltinSettings, FilterOption } from "../../type/web.ts"; +import { CompletionContext, CompletionResult } from "@codemirror/autocomplete"; +import { Terminal } from "preact-feather"; +import { AppCommand } from "../../lib/command.ts"; +import { FilterOption } from "$lib/web.ts"; +import { BuiltinSettings } from "../../type/web.ts"; import { parseCommand } from "$common/command.ts"; export function CommandPalette({ @@ -58,7 +60,7 @@ export function CommandPalette({ placeholder="Command" options={options} allowNew={false} - icon={featherIcons.Terminal} + icon={Terminal} completer={completer} vimMode={vimMode} darkMode={darkMode} diff --git a/web/components/filter.tsx b/web/components/filter.tsx index 408b2918..30a1d5ef 100644 --- a/web/components/filter.tsx +++ b/web/components/filter.tsx @@ -1,13 +1,8 @@ -import { - CompletionContext, - CompletionResult, - FeatherProps, - FunctionalComponent, - useEffect, - useRef, - useState, -} from "../deps.ts"; -import { FilterOption } from "../../type/web.ts"; +import { FeatherProps } from "preact-feather/types"; +import { CompletionContext, CompletionResult } from "@codemirror/autocomplete"; +import { FunctionalComponent } from "preact"; +import { useEffect, useRef, useState } from "preact/hooks"; +import { FilterOption } from "$lib/web.ts"; import { MiniEditor } from "./mini_editor.tsx"; import { fuzzySearchAndSort } from "../fuse_search.ts"; import { deepEqual } from "../../plug-api/lib/json.ts"; diff --git a/web/components/mini_editor.tsx b/web/components/mini_editor.tsx index 1075fe1d..61295200 100644 --- a/web/components/mini_editor.tsx +++ b/web/components/mini_editor.tsx @@ -1,25 +1,22 @@ +import { useEffect, useRef } from "preact/hooks"; +import { history, historyKeymap, standardKeymap } from "@codemirror/commands"; import { autocompletion, closeBracketsKeymap, CompletionContext, completionKeymap, CompletionResult, - EditorState, +} from "@codemirror/autocomplete"; +import { EditorState } from "@codemirror/state"; +import { EditorView, highlightSpecialChars, - history, - historyKeymap, keymap, placeholder, - standardKeymap, - useEffect, - useRef, ViewPlugin, ViewUpdate, - Vim, - vim, - vimGetCm, -} from "../deps.ts"; +} from "@codemirror/view"; +import { getCM as vimGetCm, Vim, vim } from "@replit/codemirror-vim"; import { createCommandKeyBindings } from "../editor_state.ts"; type MiniEditorEvents = { diff --git a/web/components/page_navigator.tsx b/web/components/page_navigator.tsx index 0e83c021..236f0377 100644 --- a/web/components/page_navigator.tsx +++ b/web/components/page_navigator.tsx @@ -1,6 +1,6 @@ import { FilterList } from "./filter.tsx"; -import { FilterOption } from "../../type/web.ts"; -import { CompletionContext, CompletionResult } from "../deps.ts"; +import { FilterOption } from "$lib/web.ts"; +import { CompletionContext, CompletionResult } from "@codemirror/autocomplete"; import { PageMeta } from "../../plug-api/types.ts"; import { isFederationPath } from "$sb/lib/resolve.ts"; import { tagRegex as mdTagRegex } from "$common/markdown_parser/parser.ts"; diff --git a/web/components/panel.tsx b/web/components/panel.tsx index b625188a..87f6f035 100644 --- a/web/components/panel.tsx +++ b/web/components/panel.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef } from "../deps.ts"; +import { useEffect, useRef } from "https://esm.sh/preact@10.11.1/hooks"; import { Client } from "../client.ts"; import { PanelConfig } from "../../type/web.ts"; import { panelHtml } from "./panel_html.ts"; diff --git a/web/components/top_bar.tsx b/web/components/top_bar.tsx index 3e52fe10..446c0072 100644 --- a/web/components/top_bar.tsx +++ b/web/components/top_bar.tsx @@ -1,7 +1,7 @@ -import { CompletionContext, CompletionResult, useEffect } from "../deps.ts"; -import type { ComponentChildren, FunctionalComponent } from "../deps.ts"; -import { Notification } from "../../type/web.ts"; -import { FeatherProps } from "https://esm.sh/v99/preact-feather@4.2.1/dist/types"; +import { CompletionContext, CompletionResult } from "@codemirror/autocomplete"; +import type { ComponentChildren, FunctionalComponent } from "preact"; +import { Notification } from "$lib/web.ts"; +import { FeatherProps } from "preact-feather/types"; import { MiniEditor } from "./mini_editor.tsx"; export type ActionButton = { @@ -46,7 +46,6 @@ export function TopBar({ lhs?: ComponentChildren; rhs?: ComponentChildren; }) { - return (
{ diff --git a/web/fuse_search.ts b/web/fuse_search.ts index cacef13d..7003a51f 100644 --- a/web/fuse_search.ts +++ b/web/fuse_search.ts @@ -1,6 +1,6 @@ // @deno-types="https://deno.land/x/fuse@v6.4.1/dist/fuse.d.ts" -import Fuse from "https://deno.land/x/fuse@v6.4.1/dist/fuse.esm.min.js"; -import { FilterOption } from "../type/web.ts"; +import Fuse from "fuse"; +import { FilterOption } from "$lib/web.ts"; type FuseOption = FilterOption & { baseName: string; diff --git a/web/hooks/code_widget.ts b/web/hooks/code_widget.ts index 97f1bdf0..fedf5fc7 100644 --- a/web/hooks/code_widget.ts +++ b/web/hooks/code_widget.ts @@ -1,11 +1,7 @@ import { Hook, Manifest } from "../../lib/plugos/types.ts"; import { System } from "../../lib/plugos/system.ts"; import { CodeWidgetCallback } from "../../plug-api/types.ts"; - -export type CodeWidgetT = { - codeWidget?: string; - renderMode?: "markdown" | "iframe"; -}; +import { CodeWidgetT } from "$lib/manifest.ts"; export class CodeWidgetHook implements Hook { codeWidgetCallbacks = new Map(); diff --git a/web/hooks/panel_widget.ts b/web/hooks/panel_widget.ts index 7d0f4d15..f99ece0b 100644 --- a/web/hooks/panel_widget.ts +++ b/web/hooks/panel_widget.ts @@ -1,10 +1,7 @@ import { Hook, Manifest } from "../../lib/plugos/types.ts"; import { System } from "../../lib/plugos/system.ts"; import { CodeWidgetCallback } from "../../plug-api/types.ts"; - -export type PanelWidgetT = { - panelWidget?: "top" | "bottom"; -}; +import { PanelWidgetT } from "$lib/manifest.ts"; export class PanelWidgetHook implements Hook { callbacks = new Map(); diff --git a/web/hooks/slash_command.ts b/web/hooks/slash_command.ts index d0b1d102..80d3252b 100644 --- a/web/hooks/slash_command.ts +++ b/web/hooks/slash_command.ts @@ -1,29 +1,24 @@ -import { Hook, Manifest } from "../../lib/plugos/types.ts"; -import { System } from "../../lib/plugos/system.ts"; -import { Completion, CompletionContext, CompletionResult } from "../deps.ts"; +import { Hook, Manifest } from "$lib/plugos/types.ts"; +import { System } from "$lib/plugos/system.ts"; +import { + Completion, + CompletionContext, + CompletionResult, +} from "@codemirror/autocomplete"; import { Client } from "../client.ts"; -import { syntaxTree } from "../deps.ts"; +import { syntaxTree } from "@codemirror/language"; import { SlashCompletionOption, SlashCompletions, } from "../../plug-api/types.ts"; import { safeRun } from "$lib/async.ts"; - -export type SlashCommandDef = { - name: string; - description?: string; - boost?: number; -}; +import { SlashCommandDef, SlashCommandHookT } from "$lib/manifest.ts"; export type AppSlashCommand = { slashCommand: SlashCommandDef; run: () => Promise; }; -export type SlashCommandHookT = { - slashCommand?: SlashCommandDef; -}; - const slashCommandRegexp = /([^\w:]|^)\/[\w#\-]*/; export class SlashCommandHook implements Hook { diff --git a/web/style.ts b/web/style.ts index d2f3c97f..5396bbc6 100644 --- a/web/style.ts +++ b/web/style.ts @@ -1,5 +1,5 @@ -import { HighlightStyle } from "./deps.ts"; -import { tagHighlighter, tags as t } from "./deps.ts"; +import { HighlightStyle } from "@codemirror/language"; +import { tagHighlighter, tags as t } from "@lezer/highlight"; import * as ct from "$common/markdown_parser/customtags.ts"; export default function highlightStyles() { diff --git a/web/syscalls/editor.ts b/web/syscalls/editor.ts index 413bb662..ac478014 100644 --- a/web/syscalls/editor.ts +++ b/web/syscalls/editor.ts @@ -1,22 +1,20 @@ import { Client } from "../client.ts"; import { - EditorView, foldAll, foldCode, - redo, toggleFold, - Transaction, - undo, unfoldAll, unfoldCode, - Vim, - vimGetCm, -} from "../deps.ts"; +} from "@codemirror/language"; +import { redo, undo } from "@codemirror/commands"; +import { Transaction } from "@codemirror/state"; +import { EditorView } from "@codemirror/view"; +import { getCM as vimGetCm, Vim } from "@replit/codemirror-vim"; import { SysCallMapping } from "$lib/plugos/system.ts"; -import type { FilterOption } from "../../type/web.ts"; +import type { FilterOption } from "$lib/web.ts"; import { UploadFile } from "../../plug-api/types.ts"; import { PageRef } from "$sb/lib/page_ref.ts"; -import { openSearchPanel } from "../deps.ts"; +import { openSearchPanel } from "@codemirror/search"; import { diffAndPrepareChanges } from "../cm_util.ts"; export function editorSyscalls(client: Client): SysCallMapping { diff --git a/web/syscalls/fetch.ts b/web/syscalls/fetch.ts index 7b8b7ed0..b51f69df 100644 --- a/web/syscalls/fetch.ts +++ b/web/syscalls/fetch.ts @@ -3,7 +3,7 @@ import { performLocalFetch, ProxyFetchRequest, ProxyFetchResponse, -} from "$common/proxy_fetch.ts"; +} from "../../lib/proxy_fetch.ts"; import type { Client } from "../client.ts"; import { base64Decode, base64Encode } from "$lib/crypto.ts";