Refactor: Merging common/ into web/

This commit is contained in:
Zef Hemel
2025-06-04 14:01:59 +02:00
parent e5c137a505
commit bf2e0cdb87
122 changed files with 194 additions and 235 deletions
-1
View File
@@ -21,7 +21,6 @@ export async function bundleAll(
if (watch) {
const watcher = Deno.watchFs([
"web",
"common",
"dist_plug_bundle/_plug",
"Library",
]);
+1 -1
View File
@@ -1,4 +1,4 @@
import { SpaceSync, type SyncStatusItem } from "$common/spaces/sync.ts";
import { SpaceSync, type SyncStatusItem } from "../web/spaces/sync.ts";
import { determineStorageBackend } from "../server/storage_backend.ts";
export async function syncCommand(
-1
View File
@@ -110,7 +110,6 @@
"@silverbulletmd/silverbullet/type/config": "./type/config.ts",
"@silverbulletmd/silverbullet/type/rpc": "./type/rpc.ts",
"@silverbulletmd/silverbullet/type/client": "./type/client.ts",
"$common/": "./common/",
"$lib/": "./lib/",
"@codemirror/autocomplete": "https://esm.sh/@codemirror/autocomplete@6.18.1?external=@codemirror/state,@codemirror/commands,@lezer/common,@codemirror/view,@codemirror/language&target=es2022",
"@codemirror/commands": "https://esm.sh/@codemirror/commands@6.7.0?external=@codemirror/state,@codemirror/view,@codemirror/language,@lezer/common&target=es2022",
+2 -2
View File
@@ -5,8 +5,8 @@ import type { KvPrimitives } from "../data/kv_primitives.ts";
import { assertEquals } from "@std/assert";
import { PrefixedKvPrimitives } from "../data/prefixed_kv_primitives.ts";
import { DataStore } from "$lib/data/datastore.ts";
import { LuaEnv, LuaStackFrame } from "$common/space_lua/runtime.ts";
import { parseExpressionString } from "$common/space_lua/parse.ts";
import { LuaEnv, LuaStackFrame } from "../../web/space_lua/runtime.ts";
import { parseExpressionString } from "../../web/space_lua/parse.ts";
async function test(db: KvPrimitives) {
const datastore = new DataStore(new PrefixedKvPrimitives(db, ["ds"]));
+2 -2
View File
@@ -1,8 +1,8 @@
import {
type LuaCollectionQuery,
queryLua,
} from "$common/space_lua/query_collection.ts";
import { LuaEnv, LuaStackFrame } from "$common/space_lua/runtime.ts";
} from "../../web/space_lua/query_collection.ts";
import { LuaEnv, LuaStackFrame } from "../../web/space_lua/runtime.ts";
import type { KV, KvKey } from "../../plug-api/types.ts";
import type { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
+2 -2
View File
@@ -6,8 +6,8 @@ import type {
MQSubscribeOptions,
} from "../../plug-api/types.ts";
import type { DataStore } from "./datastore.ts";
import { parseExpressionString } from "$common/space_lua/parse.ts";
import { LuaEnv } from "$common/space_lua/runtime.ts";
import { parseExpressionString } from "../../web/space_lua/parse.ts";
import { LuaEnv } from "../../web/space_lua/runtime.ts";
export type ProcessingMessage = MQMessage & {
ts: number;
+2 -2
View File
@@ -1,12 +1,12 @@
import "./syscall_mock.ts";
import { parse } from "$common/markdown_parser/parse_tree.ts";
import { parse } from "../../web/markdown_parser/parse_tree.ts";
import {
cleanAttributes,
extractAttributes,
} from "@silverbulletmd/silverbullet/lib/attribute";
import { assertEquals } from "@std/assert";
import { renderToText } from "./tree.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
import { extendedMarkdownLanguage } from "../../web/markdown_parser/parser.ts";
const inlineAttributeSample = `
# My document
+2 -2
View File
@@ -5,8 +5,8 @@ import {
} from "@silverbulletmd/silverbullet/lib/resolve";
import { assertEquals } from "@std/assert";
import { type ParseTree, renderToText } from "./tree.ts";
import { parse } from "$common/markdown_parser/parse_tree.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
import { parse } from "../../web/markdown_parser/parse_tree.ts";
import { extendedMarkdownLanguage } from "../../web/markdown_parser/parser.ts";
Deno.test("Test URL resolver", () => {
// Absolute paths
+1 -1
View File
@@ -4,7 +4,7 @@ import {
type ParseTree,
traverseTree,
} from "@silverbulletmd/silverbullet/lib/tree";
import { tagRegex } from "../../common/markdown_parser/constants.ts";
import { tagRegex } from "../../web/markdown_parser/constants.ts";
export function updateITags<T>(obj: ObjectValue<T>, frontmatter: FrontMatter) {
const itags = [obj.tag, ...frontmatter.tags || []];
+2 -2
View File
@@ -9,8 +9,8 @@ import {
replaceNodesMatching,
} from "./tree.ts";
import { assertEquals, assertNotEquals } from "@std/assert";
import { parse } from "$common/markdown_parser/parse_tree.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
import { parse } from "../../web/markdown_parser/parse_tree.ts";
import { extendedMarkdownLanguage } from "../../web/markdown_parser/parser.ts";
const mdTest1 = `
# Heading
+1 -1
View File
@@ -1,4 +1,4 @@
import type { LuaCollectionQuery } from "$common/space_lua/query_collection.ts";
import type { LuaCollectionQuery } from "../../web/space_lua/query_collection.ts";
import { syscall } from "../syscall.ts";
import type { KV, KvKey, KvQuery } from "../types.ts";
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ObjectValue } from "@silverbulletmd/silverbullet/types";
import type { LuaCollectionQuery } from "$common/space_lua/query_collection.ts";
import type { LuaCollectionQuery } from "../../web/space_lua/query_collection.ts";
import { syscall } from "@silverbulletmd/silverbullet/syscall";
/**
+1 -1
View File
@@ -1,5 +1,5 @@
import { syscall } from "../syscall.ts";
import type { LuaBlock, LuaExpression } from "$common/space_lua/ast.ts";
import type { LuaBlock, LuaExpression } from "../../web/space_lua/ast.ts";
export function parse(
code: string,
+1 -1
View File
@@ -1,4 +1,4 @@
import type { ShellStreamClient } from "$common/shell_stream_client.ts";
import type { ShellStreamClient } from "../../web/shell_stream_client.ts";
import { syscall } from "../syscall.ts";
/**
+1 -1
View File
@@ -1,7 +1,7 @@
import { datastore, markdown } from "@silverbulletmd/silverbullet/syscalls";
import type { KV, KvKey, KvQuery, ObjectValue } from "../../plug-api/types.ts";
import { ttlCache } from "$lib/memory_cache.ts";
import type { LuaCollectionQuery } from "$common/space_lua/query_collection.ts";
import type { LuaCollectionQuery } from "../../web/space_lua/query_collection.ts";
import {
extractFrontmatter as extractFrontmatterFromTree,
type FrontMatter,
+1 -1
View File
@@ -1,5 +1,5 @@
import "../../plug-api/lib/syscall_mock.ts";
import { parseMarkdown } from "$common/markdown_parser/parser.ts";
import { parseMarkdown } from "../../web/markdown_parser/parser.ts";
import { extractItems } from "./item.ts";
import { assertEquals } from "@std/assert";
+1 -1
View File
@@ -23,7 +23,7 @@ import { extractSnippetAroundIndex } from "./snippet_extractor.ts";
import {
mdLinkRegex,
wikiLinkRegex,
} from "$common/markdown_parser/constants.ts";
} from "../../web/markdown_parser/constants.ts";
import { lua, space } from "@silverbulletmd/silverbullet/syscalls";
export type LinkObject = ObjectValue<
+2 -2
View File
@@ -1,9 +1,9 @@
import { parse } from "$common/markdown_parser/parse_tree.ts";
import { parse } from "../../web/markdown_parser/parse_tree.ts";
import { System } from "../../lib/plugos/system.ts";
import { createSandbox } from "../../lib/plugos/sandboxes/deno_worker_sandbox.ts";
import { renderMarkdownToHtml } from "./markdown_render.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
import { extendedMarkdownLanguage } from "../../web/markdown_parser/parser.ts";
import { assertEquals } from "@std/assert";
import { fileURLToPath } from "node:url";
+1 -1
View File
@@ -1,5 +1,5 @@
import "../../plug-api/lib/syscall_mock.ts";
import { parseMarkdown } from "$common/markdown_parser/parser.ts";
import { parseMarkdown } from "../../web/markdown_parser/parser.ts";
import { extractTasks } from "./task.ts";
import { assertEquals } from "@std/assert";
-13
View File
@@ -1,13 +0,0 @@
# Step 1: Lua APIs
The `common/space_lua/stdlib` folder contains implementations of the standard Lua library functions in TypeScript. These APIs should all be documented in a markdown format under `website/API` folder. The markdown files should be named after the Lua module they represent. For example, the `string` module should be documented in `website/API/string.md`.
Ignore the `printf` module, as it is not part of the standard Lua library.
Please compare the APIs implemented in TypeScript and make sure they appear in the API documentation. Add documentation for any missing APIs, follow the same format as the existing documentation.
# Step 2: Syscall documentation
Also in the `website/API` are markdown files for syscalls exposed in SilverBullet. Interfaces for all of theses are implemented under the `plug-api/syscalls/` folder. Each .ts file there should have a matching .md file under `website/API` documenting the APIs using the format similar to `website/API/editor.md`.
Check if all the syscalls defined in the .ts files are present under the API docs, and if not, add them.
For exising API documentation, verify if it is complete and no syscalls are missing. If it is missing, add it.
-11
View File
@@ -1,11 +0,0 @@
# Steps
1. Look at deno.json to find all dependencies under `imports`
3. Find out online (use web search) if there is a NEWER version available for each dependency, exclude the current version number from your search for better results. Note that the esm.sh ones are really npm dependencies, so you may want to search on npmjs.com for the latest version
4. Only when you discover a newer version (higher version number), bump the version number, otherwise leave it as is
After each dependency bump run:
* `deno task check` to ensure type checks
* `deno task test` to ensure all tests still pass
* `deno task lint` to ensure all linting rules are adhered to
Fix any issues as you go along.
+2 -2
View File
@@ -9,8 +9,8 @@ import {
} from "./shell_endpoints.ts";
import { SpaceServer } from "./space_server.ts";
import type { KvPrimitives } from "$lib/data/kv_primitives.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
import { parse } from "$common/markdown_parser/parse_tree.ts";
import { extendedMarkdownLanguage } from "../web/markdown_parser/parser.ts";
import { parse } from "../web/markdown_parser/parse_tree.ts";
import { renderMarkdownToHtml } from "../plugs/markdown/markdown_render.ts";
import {
decodePageURI,
+2 -2
View File
@@ -6,8 +6,8 @@ import { sleep } from "../lib/async.ts";
import {
ShellStreamClient,
type ShellStreamEvent,
} from "../common/shell_stream_client.ts";
import { HttpSpacePrimitives } from "../common/spaces/http_space_primitives.ts";
} from "../web/shell_stream_client.ts";
import { HttpSpacePrimitives } from "../web/spaces/http_space_primitives.ts";
// Create a test script
async function createTestScript(dir: string): Promise<string> {
+5 -5
View File
@@ -1,7 +1,7 @@
import { AssetBundlePlugSpacePrimitives } from "$common/spaces/asset_bundle_space_primitives.ts";
import { FilteredSpacePrimitives } from "$common/spaces/filtered_space_primitives.ts";
import { ReadOnlySpacePrimitives } from "$common/spaces/ro_space_primitives.ts";
import type { SpacePrimitives } from "$common/spaces/space_primitives.ts";
import { AssetBundlePlugSpacePrimitives } from "../web/spaces/asset_bundle_space_primitives.ts";
import { FilteredSpacePrimitives } from "../web/spaces/filtered_space_primitives.ts";
import { ReadOnlySpacePrimitives } from "../web/spaces/ro_space_primitives.ts";
import type { SpacePrimitives } from "../web/spaces/space_primitives.ts";
import type { AssetBundle } from "../lib/asset_bundle/bundle.ts";
import type { KvPrimitives } from "$lib/data/kv_primitives.ts";
import { JWTIssuer } from "./crypto.ts";
@@ -11,7 +11,7 @@ import type { ShellBackend } from "./shell_backend.ts";
import { determineStorageBackend } from "./storage_backend.ts";
import type { ServerOptions } from "./http_server.ts";
import type { AuthOptions } from "../cmd/server.ts";
import { CONFIG_TEMPLATE, INDEX_TEMPLATE } from "$common/PAGE_TEMPLATES.ts";
import { CONFIG_TEMPLATE, INDEX_TEMPLATE } from "../web/PAGE_TEMPLATES.ts";
// Equivalent of Client on the server
export class SpaceServer {
+3 -3
View File
@@ -1,7 +1,7 @@
import { DiskSpacePrimitives } from "$common/spaces/disk_space_primitives.ts";
import type { SpacePrimitives } from "$common/spaces/space_primitives.ts";
import { DiskSpacePrimitives } from "../web/spaces/disk_space_primitives.ts";
import type { SpacePrimitives } from "../web/spaces/space_primitives.ts";
import { resolve } from "@std/path";
import { HttpSpacePrimitives } from "$common/spaces/http_space_primitives.ts";
import { HttpSpacePrimitives } from "../web/spaces/http_space_primitives.ts";
export function determineStorageBackend(
folder: string,
View File
+14 -15
View File
@@ -7,9 +7,9 @@ import { EditorView } from "@codemirror/view";
import { syntaxTree } from "@codemirror/language";
import { history, isolateHistory } from "@codemirror/commands";
import type { SyntaxNode } from "@lezer/common";
import { Space } from "../common/space.ts";
import { Space } from "./space.ts";
import type { FilterOption } from "@silverbulletmd/silverbullet/type/client";
import { EventHook } from "../common/hooks/event.ts";
import { EventHook } from "./hooks/event.ts";
import { type AppCommand, isValidEditor } from "$lib/command.ts";
import {
type LocationState,
@@ -31,13 +31,13 @@ import type {
} from "../plug-api/types.ts";
import type { StyleObject } from "../plugs/index/style.ts";
import { throttle } from "$lib/async.ts";
import { PlugSpacePrimitives } from "$common/spaces/plug_space_primitives.ts";
import { EventedSpacePrimitives } from "$common/spaces/evented_space_primitives.ts";
import { PlugSpacePrimitives } from "./spaces/plug_space_primitives.ts";
import { EventedSpacePrimitives } from "./spaces/evented_space_primitives.ts";
import { pageSyncInterval, SyncService } from "./sync_service.ts";
import { simpleHash } from "$lib/crypto.ts";
import type { SyncStatus } from "$common/spaces/sync.ts";
import { HttpSpacePrimitives } from "$common/spaces/http_space_primitives.ts";
import { FallbackSpacePrimitives } from "$common/spaces/fallback_space_primitives.ts";
import type { SyncStatus } from "./spaces/sync.ts";
import { HttpSpacePrimitives } from "./spaces/http_space_primitives.ts";
import { FallbackSpacePrimitives } from "./spaces/fallback_space_primitives.ts";
import {
encodePageURI,
encodeRef,
@@ -49,7 +49,7 @@ import { ClientSystem } from "./client_system.ts";
import { createEditorState } from "./editor_state.ts";
import { MainUI } from "./editor_ui.tsx";
import { cleanPageRef } from "@silverbulletmd/silverbullet/lib/resolve";
import type { SpacePrimitives } from "$common/spaces/space_primitives.ts";
import type { SpacePrimitives } from "./spaces/space_primitives.ts";
import type {
CodeWidgetButton,
FileMeta,
@@ -58,15 +58,15 @@ import type {
import { DataStore } from "$lib/data/datastore.ts";
import { IndexedDBKvPrimitives } from "$lib/data/indexeddb_kv_primitives.ts";
import { DataStoreMQ } from "$lib/data/mq.datastore.ts";
import { DataStoreSpacePrimitives } from "$common/spaces/datastore_space_primitives.ts";
import { DataStoreSpacePrimitives } from "./spaces/datastore_space_primitives.ts";
import { ReadOnlySpacePrimitives } from "$common/spaces/ro_space_primitives.ts";
import { ReadOnlySpacePrimitives } from "./spaces/ro_space_primitives.ts";
import { LimitedMap } from "$lib/limited_map.ts";
import { plugPrefix } from "$common/spaces/constants.ts";
import { plugPrefix } from "./spaces/constants.ts";
import { diffAndPrepareChanges } from "./cm_util.ts";
import { DocumentEditor } from "./document_editor.ts";
import { parseExpressionString } from "$common/space_lua/parse.ts";
import { Config } from "$common/config.ts";
import { parseExpressionString } from "./space_lua/parse.ts";
import { Config } from "./config.ts";
const frontMatterRegex = /^---\n(([^\n]|\n)*?)---\n/;
@@ -1479,8 +1479,7 @@ export class Client {
return;
}
const customStylesContent = spaceStyles.map(s => s.style).join("\n\n");
console.info("Accumulated styles", customStylesContent)
const customStylesContent = spaceStyles.map((s) => s.style).join("\n\n");
this.ui.viewDispatch({
type: "set-ui-option",
key: "customStyles",
+19 -19
View File
@@ -1,6 +1,6 @@
import { PlugNamespaceHook } from "$common/hooks/plug_namespace.ts";
import { PlugNamespaceHook } from "./hooks/plug_namespace.ts";
import type { SilverBulletHooks } from "../lib/manifest.ts";
import type { EventHook } from "../common/hooks/event.ts";
import type { EventHook } from "./hooks/event.ts";
import { createSandbox } from "../lib/plugos/sandboxes/web_worker_sandbox.ts";
import assetSyscalls from "../lib/plugos/syscalls/asset.ts";
@@ -8,44 +8,44 @@ import { eventSyscalls } from "../lib/plugos/syscalls/event.ts";
import { System } from "../lib/plugos/system.ts";
import type { Client } from "./client.ts";
import { CodeWidgetHook } from "./hooks/code_widget.ts";
import { CommandHook } from "$common/hooks/command.ts";
import { CommandHook } from "./hooks/command.ts";
import { SlashCommandHook } from "./hooks/slash_command.ts";
import { SyscallHook } from "./hooks/syscall.ts";
import { clientStoreSyscalls } from "./syscalls/clientStore.ts";
import { editorSyscalls } from "./syscalls/editor.ts";
import { sandboxFetchSyscalls } from "./syscalls/fetch.ts";
import { markdownSyscalls } from "$common/syscalls/markdown.ts";
import { markdownSyscalls } from "./syscalls/markdown.ts";
import { shellSyscalls } from "./syscalls/shell.ts";
import { spaceReadSyscalls, spaceWriteSyscalls } from "./syscalls/space.ts";
import { syncSyscalls } from "./syscalls/sync.ts";
import { systemSyscalls } from "$common/syscalls/system.ts";
import { yamlSyscalls } from "$common/syscalls/yaml.ts";
import type { Space } from "../common/space.ts";
import { systemSyscalls } from "./syscalls/system.ts";
import { yamlSyscalls } from "./syscalls/yaml.ts";
import type { Space } from "./space.ts";
import { MQHook } from "../lib/plugos/hooks/mq.ts";
import { mqSyscalls } from "../lib/plugos/syscalls/mq.ts";
import {
dataStoreReadSyscalls,
dataStoreWriteSyscalls,
} from "../lib/plugos/syscalls/datastore.ts";
} from "./syscalls/datastore.ts";
import type { DataStore } from "$lib/data/datastore.ts";
import { languageSyscalls } from "$common/syscalls/language.ts";
import { languageSyscalls } from "./syscalls/language.ts";
import { codeWidgetSyscalls } from "./syscalls/code_widget.ts";
import { clientCodeWidgetSyscalls } from "./syscalls/client_code_widget.ts";
import { KVPrimitivesManifestCache } from "$lib/plugos/manifest_cache.ts";
import { createKeyBindings } from "./editor_state.ts";
import type { DataStoreMQ } from "$lib/data/mq.datastore.ts";
import { plugPrefix } from "$common/spaces/constants.ts";
import { jsonschemaSyscalls } from "$common/syscalls/jsonschema.ts";
import { luaSyscalls } from "$common/syscalls/lua.ts";
import { indexSyscalls } from "$common/syscalls/index.ts";
import { commandSyscalls } from "$common/syscalls/command.ts";
import { configSyscalls } from "$common/syscalls/config.ts";
import { eventListenerSyscalls } from "$common/syscalls/event.ts";
import { plugPrefix } from "./spaces/constants.ts";
import { jsonschemaSyscalls } from "./syscalls/jsonschema.ts";
import { luaSyscalls } from "./syscalls/lua.ts";
import { indexSyscalls } from "./syscalls/index.ts";
import { commandSyscalls } from "./syscalls/command.ts";
import { configSyscalls } from "./syscalls/config.ts";
import { eventListenerSyscalls } from "./syscalls/event.ts";
import { DocumentEditorHook } from "./hooks/document_editor.ts";
import type { LuaCollectionQuery } from "$common/space_lua/query_collection.ts";
import type { LuaCollectionQuery } from "./space_lua/query_collection.ts";
import type { AppCommand } from "$lib/command.ts";
import { ScriptEnvironment } from "$common/space_script.ts";
import { SpaceLuaEnvironment } from "$common/space_lua.ts";
import { ScriptEnvironment } from "./space_script.ts";
import { SpaceLuaEnvironment } from "./space_lua.ts";
import type { ParseTree } from "@silverbulletmd/silverbullet/lib/tree";
const plugNameExtractRegex = /\/(.+)\.plug\.js$/;
+1 -1
View File
@@ -8,7 +8,7 @@ import TurndownService from "turndown";
// With tables and task notation as well
import { tables, taskListItems } from "turndown-plugin-gfm";
import { lezerToParseTree } from "$common/markdown_parser/parse_tree.ts";
import { lezerToParseTree } from "../markdown_parser/parse_tree.ts";
import {
addParentPointers,
findParentMatching,
+2 -2
View File
@@ -1,8 +1,8 @@
import { type Diagnostic, linter } from "@codemirror/lint";
import type { Client } from "../client.ts";
import { parse } from "$common/markdown_parser/parse_tree.ts";
import { parse } from "../markdown_parser/parse_tree.ts";
import type { LintEvent } from "../../plug-api/types.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
import { extendedMarkdownLanguage } from "../markdown_parser/parser.ts";
export function plugLinter(client: Client) {
return linter(async (view): Promise<Diagnostic[]> => {
+6 -9
View File
@@ -7,21 +7,18 @@ import {
isCursorInRange,
} from "./util.ts";
import type { Client } from "../client.ts";
import { parse as parseLua } from "$common/space_lua/parse.ts";
import type {
LuaBlock,
LuaFunctionCallStatement,
} from "$common/space_lua/ast.ts";
import { evalExpression } from "$common/space_lua/eval.ts";
import { parse as parseLua } from "../space_lua/parse.ts";
import type { LuaBlock, LuaFunctionCallStatement } from "../space_lua/ast.ts";
import { evalExpression } from "../space_lua/eval.ts";
import {
LuaEnv,
LuaStackFrame,
luaValueToJS,
singleResult,
} from "$common/space_lua/runtime.ts";
import { LuaRuntimeError } from "$common/space_lua/runtime.ts";
} from "../space_lua/runtime.ts";
import { LuaRuntimeError } from "../space_lua/runtime.ts";
import { encodeRef } from "@silverbulletmd/silverbullet/lib/page_ref";
import { resolveASTReference } from "$common/space_lua.ts";
import { resolveASTReference } from "../space_lua.ts";
import { LuaWidget } from "./lua_widget.ts";
import type { PageMeta } from "@silverbulletmd/silverbullet/types";
import YAML from "js-yaml";
+5 -5
View File
@@ -5,16 +5,16 @@ import {
isLocalPath,
resolvePath,
} from "@silverbulletmd/silverbullet/lib/resolve";
import { parse } from "$common/markdown_parser/parse_tree.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
import { parse } from "../markdown_parser/parse_tree.ts";
import { extendedMarkdownLanguage } from "../markdown_parser/parser.ts";
import { renderToText } from "@silverbulletmd/silverbullet/lib/tree";
import {
attachWidgetEventHandlers,
moveCursorIntoText,
} from "./widget_util.ts";
import { expandMarkdown } from "$common/markdown.ts";
import { LuaStackFrame, LuaTable } from "$common/space_lua/runtime.ts";
import { jsonToMDTable } from "$common/markdown_util.ts";
import { expandMarkdown } from "../markdown.ts";
import { LuaStackFrame, LuaTable } from "../space_lua/runtime.ts";
import { jsonToMDTable } from "../markdown_util.ts";
import { activeWidgets } from "./code_widget.ts";
export type LuaWidgetCallback = (
+1 -1
View File
@@ -9,7 +9,7 @@ import {
import { renderMarkdownToHtml } from "../../plugs/markdown/markdown_render.ts";
import { type ParseTree, renderToText } from "../../plug-api/lib/tree.ts";
import { lezerToParseTree } from "$common/markdown_parser/parse_tree.ts";
import { lezerToParseTree } from "../markdown_parser/parse_tree.ts";
import type { Client } from "../client.ts";
import {
isLocalPath,
+1 -1
View File
@@ -9,7 +9,7 @@ import type {
FilterOption,
Shortcut,
} from "@silverbulletmd/silverbullet/type/client";
import type { Config } from "$common/config.ts";
import type { Config } from "../config.ts";
export function CommandPalette({
commands,
+1 -1
View File
@@ -8,7 +8,7 @@ import type {
DocumentMeta,
PageMeta,
} from "@silverbulletmd/silverbullet/types";
import { tagRegex as mdTagRegex } from "$common/markdown_parser/constants.ts";
import { tagRegex as mdTagRegex } from "../markdown_parser/constants.ts";
import { extractHashtag } from "@silverbulletmd/silverbullet/lib/tags";
const tagRegex = new RegExp(mdTagRegex.source, "g");
View File
+3 -3
View File
@@ -46,10 +46,10 @@ import {
} from "./cm_plugins/editor_paste.ts";
import type { TextChange } from "./change.ts";
import { postScriptPrefacePlugin } from "./cm_plugins/top_bottom_panels.ts";
import { languageFor } from "$common/languages.ts";
import { languageFor } from "./languages.ts";
import { plugLinter } from "./cm_plugins/lint.ts";
import { Compartment, type Extension } from "@codemirror/state";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
import { extendedMarkdownLanguage } from "./markdown_parser/parser.ts";
import { safeRun } from "$lib/async.ts";
import { codeCopyPlugin } from "./cm_plugins/code_copy.ts";
import { disableSpellcheck } from "./cm_plugins/spell_checking.ts";
@@ -311,7 +311,7 @@ export function createCommandKeyBindings(client: Client): KeyBinding[] {
// Keyboard shortcuts from SETTINGS take precedense
if (client.config.has("shortcuts")) {
for (const shortcut of client.config.get<Shortcut[]>("shortcuts", [])) {
overriddenCommands.add(shortcut.command)
overriddenCommands.add(shortcut.command);
commandKeyBindings.push({
key: shortcut.key,
mac: shortcut.mac,
+1 -1
View File
@@ -1,6 +1,6 @@
import type { Manifest } from "$lib/plugos/types.ts";
import type { System } from "$lib/plugos/system.ts";
import type { ScriptEnvironment } from "$common/space_script.ts";
import type { ScriptEnvironment } from "../space_script.ts";
import type { EventHookI } from "$lib/plugos/eventhook.ts";
import type { EventHookT } from "$lib/manifest.ts";
+1 -1
View File
@@ -41,7 +41,7 @@ import {
} from "@codemirror/lang-javascript";
import { cssLanguage } from "@codemirror/lang-css";
import { nixLanguage } from "@replit/codemirror-lang-nix";
import { luaLanguage } from "$common/space_lua/parse.ts";
import { luaLanguage } from "./space_lua/parse.ts";
const yamlStreamLanguage = StreamLanguage.define(yamlLanguage);
+6 -6
View File
@@ -9,12 +9,12 @@ import {
type Ref,
validatePageName,
} from "@silverbulletmd/silverbullet/lib/page_ref";
import { parseMarkdown } from "$common/markdown_parser/parser.ts";
import type { LuaExpression } from "$common/space_lua/ast.ts";
import { evalExpression } from "$common/space_lua/eval.ts";
import type { LuaEnv, LuaStackFrame } from "$common/space_lua/runtime.ts";
import { parseExpressionString } from "$common/space_lua/parse.ts";
import { renderExpressionResult } from "$common/markdown_util.ts";
import { parseMarkdown } from "./markdown_parser/parser.ts";
import type { LuaExpression } from "./space_lua/ast.ts";
import { evalExpression } from "./space_lua/eval.ts";
import type { LuaEnv, LuaStackFrame } from "./space_lua/runtime.ts";
import { parseExpressionString } from "./space_lua/parse.ts";
import { renderExpressionResult } from "./markdown_util.ts";
import type { Client } from "../web/client.ts";
/**
@@ -309,10 +309,10 @@ const TaskDeadline = regexParser({
import { Table } from "./table_parser.ts";
import { foldNodeProp } from "@codemirror/language";
import { pWikiLinkRegex, tagRegex } from "$common/markdown_parser/constants.ts";
import { parse } from "$common/markdown_parser/parse_tree.ts";
import { pWikiLinkRegex, tagRegex } from "../markdown_parser/constants.ts";
import { parse } from "../markdown_parser/parse_tree.ts";
import type { ParseTree } from "@silverbulletmd/silverbullet/lib/tree";
import { luaLanguage } from "$common/space_lua/parse.ts";
import { luaLanguage } from "../space_lua/parse.ts";
// FrontMatter parser
@@ -1,4 +1,4 @@
import { LuaTable, luaToString } from "$common/space_lua/runtime.ts";
import { LuaTable, luaToString } from "./space_lua/runtime.ts";
export function defaultTransformer(v: any): Promise<string> {
if (v === undefined) {
+1 -1
View File
@@ -1,4 +1,4 @@
import type { FileContent } from "$common/spaces/datastore_space_primitives.ts";
import type { FileContent } from "./spaces/datastore_space_primitives.ts";
import { simpleHash } from "$lib/crypto.ts";
import { DataStore } from "$lib/data/datastore.ts";
import { IndexedDBKvPrimitives } from "$lib/data/indexeddb_kv_primitives.ts";
+3 -3
View File
@@ -1,10 +1,10 @@
import { plugPrefix } from "$common/spaces/constants.ts";
import { plugPrefix } from "./spaces/constants.ts";
import type { DocumentMeta, FileMeta, PageMeta } from "../plug-api/types.ts";
import type { EventHook } from "./hooks/event.ts";
import type { EventHook } from "../web/hooks/event.ts";
import { safeRun } from "../lib/async.ts";
import { localDateString } from "$lib/dates.ts";
import type { EventedSpacePrimitives } from "$common/spaces/evented_space_primitives.ts";
import type { EventedSpacePrimitives } from "./spaces/evented_space_primitives.ts";
const pageWatchInterval = 5000;
+6 -13
View File
@@ -1,19 +1,12 @@
import type { System } from "../lib/plugos/system.ts";
import type { ScriptObject } from "../plugs/index/script.ts";
import {
LuaEnv,
LuaRuntimeError,
LuaStackFrame,
} from "$common/space_lua/runtime.ts";
import {
parse as parseLua,
parseExpressionString,
} from "$common/space_lua/parse.ts";
import { evalStatement } from "$common/space_lua/eval.ts";
import { LuaEnv, LuaRuntimeError, LuaStackFrame } from "./space_lua/runtime.ts";
import { parse as parseLua, parseExpressionString } from "./space_lua/parse.ts";
import { evalStatement } from "./space_lua/eval.ts";
import { parseRef, type Ref } from "@silverbulletmd/silverbullet/lib/page_ref";
import type { ASTCtx } from "$common/space_lua/ast.ts";
import { buildLuaEnv } from "$common/space_lua_api.ts";
import type { LuaCollectionQuery } from "$common/space_lua/query_collection.ts";
import type { ASTCtx } from "./space_lua/ast.ts";
import { buildLuaEnv } from "./space_lua_api.ts";
import type { LuaCollectionQuery } from "./space_lua/query_collection.ts";
export class SpaceLuaEnvironment {
env: LuaEnv = new LuaEnv();
@@ -10,7 +10,7 @@ import {
import { parse } from "./parse.ts";
import type { LuaBlock, LuaFunctionCallStatement } from "./ast.ts";
import { evalExpression, evalStatement } from "./eval.ts";
import { luaBuildStandardEnv } from "$common/space_lua/stdlib.ts";
import { luaBuildStandardEnv } from "../space_lua/stdlib.ts";
const sf = LuaStackFrame.lostFrame;
@@ -3,15 +3,15 @@ import type {
LuaExpression,
LuaLValue,
LuaStatement,
} from "$common/space_lua/ast.ts";
import { evalPromiseValues } from "$common/space_lua/util.ts";
} from "../space_lua/ast.ts";
import { evalPromiseValues } from "../space_lua/util.ts";
import {
luaCall,
luaEquals,
luaIndexValue,
luaSet,
type LuaStackFrame,
} from "$common/space_lua/runtime.ts";
} from "../space_lua/runtime.ts";
import {
type ILuaFunction,
type ILuaGettable,
@@ -34,9 +34,9 @@ import {
import {
ArrayQueryCollection,
type LuaCollectionQuery,
} from "$common/space_lua/query_collection.ts";
import { luaValueToJS } from "$common/space_lua/runtime.ts";
import { jsToLuaValue } from "$common/space_lua/runtime.ts";
} from "../space_lua/query_collection.ts";
import { luaValueToJS } from "../space_lua/runtime.ts";
import { jsToLuaValue } from "../space_lua/runtime.ts";
function handleVarargSync(env: LuaEnv): LuaValue[] | Promise<LuaValue[]> {
const varargs = env.get("...");
@@ -1,11 +1,11 @@
import { parse } from "$common/space_lua/parse.ts";
import { luaBuildStandardEnv } from "$common/space_lua/stdlib.ts";
import { parse } from "../space_lua/parse.ts";
import { luaBuildStandardEnv } from "../space_lua/stdlib.ts";
import {
LuaEnv,
LuaRuntimeError,
LuaStackFrame,
} from "$common/space_lua/runtime.ts";
import { evalStatement } from "$common/space_lua/eval.ts";
} from "../space_lua/runtime.ts";
import { evalStatement } from "../space_lua/eval.ts";
import { assert } from "@std/assert/assert";
import { fileURLToPath } from "node:url";
@@ -2,8 +2,8 @@ import {
parse,
parseExpressionString,
stripLuaComments,
} from "$common/space_lua/parse.ts";
import type { LuaNumberLiteral } from "$common/space_lua/ast.ts";
} from "../space_lua/parse.ts";
import type { LuaNumberLiteral } from "../space_lua/ast.ts";
import { assertEquals } from "@std/assert/equals";
Deno.test("Test Lua parser", () => {
@@ -1,4 +1,4 @@
import { lezerToParseTree } from "$common/markdown_parser/parse_tree.ts";
import { lezerToParseTree } from "../markdown_parser/parse_tree.ts";
import {
cleanTree,
type ParseTree,
@@ -1,10 +1,10 @@
import { parseExpressionString } from "$common/space_lua/parse.ts";
import { parseExpressionString } from "../space_lua/parse.ts";
import { ArrayQueryCollection } from "./query_collection.ts";
import {
LuaEnv,
LuaNativeJSFunction,
LuaStackFrame,
} from "$common/space_lua/runtime.ts";
} from "../space_lua/runtime.ts";
import { assert, assertEquals } from "@std/assert";
Deno.test("ArrayQueryCollection", async () => {
@@ -1,12 +1,12 @@
import type { LuaExpression } from "$common/space_lua/ast.ts";
import type { LuaExpression } from "../space_lua/ast.ts";
import {
LuaEnv,
luaGet,
luaKeys,
LuaStackFrame,
} from "$common/space_lua/runtime.ts";
import { evalExpression } from "$common/space_lua/eval.ts";
import { asyncQuickSort } from "$common/space_lua/util.ts";
} from "../space_lua/runtime.ts";
import { evalExpression } from "../space_lua/eval.ts";
import { asyncQuickSort } from "../space_lua/util.ts";
import type { DataStore } from "$lib/data/datastore.ts";
import type { KvKey } from "@silverbulletmd/silverbullet/types";
import type { KvPrimitives } from "$lib/data/kv_primitives.ts";
@@ -5,7 +5,7 @@ import {
LuaMultiRes,
LuaStackFrame,
luaToString,
} from "$common/space_lua/runtime.ts";
} from "../space_lua/runtime.ts";
Deno.test("Test Lua Rutime", async () => {
// Test LuaMultires
@@ -11,15 +11,15 @@ import {
luaToString,
luaTypeOf,
type LuaValue,
} from "$common/space_lua/runtime.ts";
import { stringApi } from "$common/space_lua/stdlib/string.ts";
import { tableApi } from "$common/space_lua/stdlib/table.ts";
import { osApi } from "$common/space_lua/stdlib/os.ts";
import { jsApi } from "$common/space_lua/stdlib/js.ts";
import { spaceluaApi } from "$common/space_lua/stdlib/space_lua.ts";
import { mathApi } from "$common/space_lua/stdlib/math.ts";
import { parse } from "$common/space_lua/parse.ts";
import { evalStatement } from "$common/space_lua/eval.ts";
} from "../space_lua/runtime.ts";
import { stringApi } from "../space_lua/stdlib/string.ts";
import { tableApi } from "../space_lua/stdlib/table.ts";
import { osApi } from "../space_lua/stdlib/os.ts";
import { jsApi } from "../space_lua/stdlib/js.ts";
import { spaceluaApi } from "../space_lua/stdlib/space_lua.ts";
import { mathApi } from "../space_lua/stdlib/math.ts";
import { parse } from "../space_lua/parse.ts";
import { evalStatement } from "../space_lua/eval.ts";
const printFunction = new LuaBuiltinFunction(async (_sf, ...args) => {
console.log(
@@ -3,7 +3,7 @@ import {
LuaBuiltinFunction,
LuaTable,
luaValueToJS,
} from "$common/space_lua/runtime.ts";
} from "../runtime.ts";
export const jsApi = new LuaTable({
/**
@@ -1,8 +1,4 @@
import {
LuaBuiltinFunction,
LuaRuntimeError,
LuaTable,
} from "$common/space_lua/runtime.ts";
import { LuaBuiltinFunction, LuaRuntimeError, LuaTable } from "../runtime.ts";
export const mathApi = new LuaTable({
/**
@@ -1,4 +1,4 @@
import { LuaBuiltinFunction, LuaTable } from "$common/space_lua/runtime.ts";
import { LuaBuiltinFunction, LuaTable } from "../runtime.ts";
const ONE_DAY = 1000 * 60 * 60 * 24;
const ONE_WEEK = ONE_DAY * 7;
@@ -24,7 +24,7 @@ function weekNumber(inDate: Date, weekStartDay: number, iso: boolean): number {
); // Monday of that week
const diff = target.getTime() - weekStart.getTime();
return 1 + Math.floor(diff / (ONE_WEEK));
return 1 + Math.floor(diff / ONE_WEEK);
} else {
// Non-ISO week: Week 1 starts on the first weekStartDay of the year
const yearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1));
@@ -38,7 +38,7 @@ function weekNumber(inDate: Date, weekStartDay: number, iso: boolean): number {
}
const diff = date.getTime() - firstWeekStart.getTime();
return 1 + Math.floor(diff / (ONE_WEEK));
return 1 + Math.floor(diff / ONE_WEEK);
}
}
@@ -1,6 +1,6 @@
import { parseExpressionString } from "$common/space_lua/parse.ts";
import type { LuaExpression } from "$common/space_lua/ast.ts";
import { evalExpression } from "$common/space_lua/eval.ts";
import { parseExpressionString } from "../parse.ts";
import type { LuaExpression } from "../ast.ts";
import { evalExpression } from "../eval.ts";
import {
LuaBuiltinFunction,
LuaEnv,
@@ -10,7 +10,7 @@ import {
luaToString,
luaValueToJS,
singleResult,
} from "$common/space_lua/runtime.ts";
} from "../runtime.ts";
/**
* These are Space Lua specific functions that are available to all scripts, but are not part of the standard Lua language.
@@ -4,7 +4,7 @@ import {
LuaMultiRes,
LuaTable,
luaToString,
} from "$common/space_lua/runtime.ts";
} from "../runtime.ts";
import printf from "./printf.ts";
// Bits and pieces borrowed from https://github.com/paulcuth/starlight/blob/master/src/runtime/lib/string.js
@@ -8,8 +8,8 @@ import {
LuaRuntimeError,
LuaTable,
type LuaValue,
} from "$common/space_lua/runtime.ts";
import { asyncQuickSort } from "$common/space_lua/util.ts";
} from "../runtime.ts";
import { asyncQuickSort } from "../util.ts";
export const tableApi = new LuaTable({
/**
@@ -1,4 +1,4 @@
import { evalPromiseValues } from "$common/space_lua/util.ts";
import { evalPromiseValues } from "../space_lua/util.ts";
import { assertEquals } from "@std/assert/equals";
import { assert } from "@std/assert";
@@ -1,4 +1,4 @@
import { luaBuildStandardEnv } from "$common/space_lua/stdlib.ts";
import { luaBuildStandardEnv } from "./space_lua/stdlib.ts";
import { parseRef } from "@silverbulletmd/silverbullet/lib/page_ref";
import {
LuaEnv,
@@ -6,7 +6,7 @@ import {
type LuaRuntimeError,
LuaStackFrame,
LuaTable,
} from "$common/space_lua/runtime.ts";
} from "./space_lua/runtime.ts";
import type { System } from "$lib/plugos/system.ts";
export function buildLuaEnv(system: System<any>) {
@@ -2,7 +2,7 @@ import type { ParseTree } from "../plug-api/lib/tree.ts";
import type { AppCommand, CommandDef, SlashCommand } from "$lib/command.ts";
import type { SlashCommandDef } from "$lib/manifest.ts";
import type { JSONSchemaType } from "ajv";
import { jsToLuaValue, type LuaTable } from "$common/space_lua/runtime.ts";
import { jsToLuaValue, type LuaTable } from "./space_lua/runtime.ts";
type FunctionDef = {
name: string;
@@ -1,6 +1,6 @@
import type { FileMeta } from "@silverbulletmd/silverbullet/types";
import type { EventHook } from "$common/hooks/event.ts";
import { plugPrefix } from "$common/spaces/constants.ts";
import type { EventHook } from "../../web/hooks/event.ts";
import { plugPrefix } from "../spaces/constants.ts";
import type { SpacePrimitives } from "./space_primitives.ts";

Some files were not shown because too many files have changed in this diff Show More