parent
e1ac990de9
commit
60d3199d64
|
@ -15,6 +15,5 @@
|
||||||
},
|
},
|
||||||
"[typescript]": {
|
"[typescript]": {
|
||||||
"editor.defaultFormatter": "denoland.vscode-deno"
|
"editor.defaultFormatter": "denoland.vscode-deno"
|
||||||
},
|
}
|
||||||
"deno.documentPreloadLimit": 0
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { denoPlugins, esbuild } from "./plugos/deps.ts";
|
import { denoPlugins, esbuild } from "./lib/plugos/deps.ts";
|
||||||
|
|
||||||
await Deno.mkdir("dist", { recursive: true });
|
await Deno.mkdir("dist", { recursive: true });
|
||||||
await esbuild.build({
|
await esbuild.build({
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { esbuild, flags, path } from "./plugos/deps.ts";
|
import { esbuild, flags, path } from "./lib/plugos/deps.ts";
|
||||||
import { compileManifests } from "./plugos/compile.ts";
|
import { compileManifests } from "./lib/plugos/compile.ts";
|
||||||
import { builtinPlugNames } from "./plugs/builtin_plugs.ts";
|
import { builtinPlugNames } from "./plugs/builtin_plugs.ts";
|
||||||
|
|
||||||
if (import.meta.main) {
|
if (import.meta.main) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { copy } from "https://deno.land/std@0.165.0/fs/copy.ts";
|
import { copy } from "https://deno.land/std@0.165.0/fs/copy.ts";
|
||||||
|
|
||||||
import sass from "https://deno.land/x/denosass@1.0.4/mod.ts";
|
import sass from "https://deno.land/x/denosass@1.0.4/mod.ts";
|
||||||
import { bundleFolder } from "./plugos/asset_bundle/builder.ts";
|
import { bundleFolder } from "./lib/asset_bundle/builder.ts";
|
||||||
|
|
||||||
import * as flags from "https://deno.land/std@0.165.0/flags/mod.ts";
|
import * as flags from "https://deno.land/std@0.165.0/flags/mod.ts";
|
||||||
import { patchDenoLibJS } from "./plugos/compile.ts";
|
import { patchDenoLibJS } from "./lib/plugos/compile.ts";
|
||||||
import { denoPlugins, esbuild } from "./plugos/deps.ts";
|
import { denoPlugins, esbuild } from "./lib/plugos/deps.ts";
|
||||||
|
|
||||||
export async function bundleAll(
|
export async function bundleAll(
|
||||||
watch: boolean,
|
watch: boolean,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { AssetBundle } from "../plugos/asset_bundle/bundle.ts";
|
import { AssetBundle } from "$lib/asset_bundle/bundle.ts";
|
||||||
import { compileManifest } from "../plugos/compile.ts";
|
import { compileManifest } from "$lib/plugos/compile.ts";
|
||||||
import { esbuild } from "../plugos/deps.ts";
|
import { esbuild } from "$lib/plugos/deps.ts";
|
||||||
import { runPlug } from "./plug_run.ts";
|
import { runPlug } from "./plug_run.ts";
|
||||||
import assets from "../dist/plug_asset_bundle.json" assert { type: "json" };
|
import assets from "../dist/plug_asset_bundle.json" assert { type: "json" };
|
||||||
import { assertEquals } from "../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
import { path } from "../common/deps.ts";
|
import { path } from "$common/deps.ts";
|
||||||
import { MemoryKvPrimitives } from "../plugos/lib/memory_kv_primitives.ts";
|
import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts";
|
||||||
|
|
||||||
Deno.test("Test plug run", {
|
Deno.test("Test plug run", {
|
||||||
sanitizeResources: false,
|
sanitizeResources: false,
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { DiskSpacePrimitives } from "../common/spaces/disk_space_primitives.ts";
|
import { DiskSpacePrimitives } from "$common/spaces/disk_space_primitives.ts";
|
||||||
import { AssetBundle } from "../plugos/asset_bundle/bundle.ts";
|
import { AssetBundle } from "../lib/asset_bundle/bundle.ts";
|
||||||
|
|
||||||
import { sleep } from "$sb/lib/async.ts";
|
|
||||||
import { ServerSystem } from "../server/server_system.ts";
|
import { ServerSystem } from "../server/server_system.ts";
|
||||||
import { AssetBundlePlugSpacePrimitives } from "../common/spaces/asset_bundle_space_primitives.ts";
|
import { AssetBundlePlugSpacePrimitives } from "$common/spaces/asset_bundle_space_primitives.ts";
|
||||||
import { EndpointHook } from "../plugos/hooks/endpoint.ts";
|
import { EndpointHook } from "../server/hooks/endpoint.ts";
|
||||||
import { LocalShell } from "../server/shell_backend.ts";
|
import { LocalShell } from "../server/shell_backend.ts";
|
||||||
import { Hono } from "../server/deps.ts";
|
import { Hono } from "../server/deps.ts";
|
||||||
import { KvPrimitives } from "../plugos/lib/kv_primitives.ts";
|
import { KvPrimitives } from "$lib/data/kv_primitives.ts";
|
||||||
import { DataStore } from "../plugos/lib/datastore.ts";
|
import { DataStore } from "$lib/data/datastore.ts";
|
||||||
import { DataStoreMQ } from "../plugos/lib/mq.datastore.ts";
|
import { DataStoreMQ } from "$lib/data/mq.datastore.ts";
|
||||||
import { EventHook } from "../plugos/hooks/event.ts";
|
import { EventHook } from "$lib/plugos/hooks/event.ts";
|
||||||
|
import { sleep } from "$lib/async.ts";
|
||||||
|
|
||||||
export async function runPlug(
|
export async function runPlug(
|
||||||
spacePath: string,
|
spacePath: string,
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
export const silverBulletDbFile = ".silverbullet.db";
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { compileManifests } from "../plugos/compile.ts";
|
import { compileManifests } from "../lib/plugos/compile.ts";
|
||||||
import { esbuild } from "../plugos/deps.ts";
|
import { esbuild } from "../lib/plugos/deps.ts";
|
||||||
|
|
||||||
export async function plugCompileCommand(
|
export async function plugCompileCommand(
|
||||||
{ watch, dist, debug, info, importmap, runtimeUrl }: {
|
{ watch, dist, debug, info, importmap, runtimeUrl }: {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { runPlug } from "../cli/plug_run.ts";
|
import { runPlug } from "../cli/plug_run.ts";
|
||||||
import { path } from "../common/deps.ts";
|
import { path } from "$common/deps.ts";
|
||||||
import assets from "../dist/plug_asset_bundle.json" assert {
|
import assets from "../dist/plug_asset_bundle.json" assert {
|
||||||
type: "json",
|
type: "json",
|
||||||
};
|
};
|
||||||
import { AssetBundle } from "../plugos/asset_bundle/bundle.ts";
|
import { AssetBundle } from "$lib/asset_bundle/bundle.ts";
|
||||||
import { determineDatabaseBackend } from "../server/db_backend.ts";
|
import { determineDatabaseBackend } from "../server/db_backend.ts";
|
||||||
|
|
||||||
export async function plugRunCommand(
|
export async function plugRunCommand(
|
||||||
|
|
|
@ -5,13 +5,13 @@ import clientAssetBundle from "../dist/client_asset_bundle.json" assert {
|
||||||
import plugAssetBundle from "../dist/plug_asset_bundle.json" assert {
|
import plugAssetBundle from "../dist/plug_asset_bundle.json" assert {
|
||||||
type: "json",
|
type: "json",
|
||||||
};
|
};
|
||||||
import { AssetBundle, AssetJson } from "../plugos/asset_bundle/bundle.ts";
|
import { AssetBundle, AssetJson } from "../lib/asset_bundle/bundle.ts";
|
||||||
import { sleep } from "$sb/lib/async.ts";
|
|
||||||
|
|
||||||
import { determineDatabaseBackend } from "../server/db_backend.ts";
|
import { determineDatabaseBackend } from "../server/db_backend.ts";
|
||||||
import { SpaceServerConfig } from "../server/instance.ts";
|
import { SpaceServerConfig } from "../server/instance.ts";
|
||||||
import { runPlug } from "../cli/plug_run.ts";
|
import { runPlug } from "../cli/plug_run.ts";
|
||||||
import { PrefixedKvPrimitives } from "../plugos/lib/prefixed_kv_primitives.ts";
|
import { PrefixedKvPrimitives } from "$lib/data/prefixed_kv_primitives.ts";
|
||||||
|
import { sleep } from "$lib/async.ts";
|
||||||
|
|
||||||
export async function serveCommand(
|
export async function serveCommand(
|
||||||
options: {
|
options: {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { SpaceSync, SyncStatusItem } from "../common/spaces/sync.ts";
|
import { SpaceSync, SyncStatusItem } from "$common/spaces/sync.ts";
|
||||||
import { MemoryKvPrimitives } from "../plugos/lib/memory_kv_primitives.ts";
|
import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts";
|
||||||
import { determineStorageBackend } from "../server/storage_backend.ts";
|
import { determineStorageBackend } from "../server/storage_backend.ts";
|
||||||
|
|
||||||
export async function syncCommand(
|
export async function syncCommand(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { assertEquals } from "../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
import { parseCommand } from "./command.ts";
|
import { parseCommand } from "./command.ts";
|
||||||
|
|
||||||
Deno.test("Command parser", () => {
|
Deno.test("Command parser", () => {
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import { AppCommand, CommandHook } from "./hooks/command.ts";
|
import { AppCommand, CommandHook } from "./hooks/command.ts";
|
||||||
import { PlugNamespaceHook } from "./hooks/plug_namespace.ts";
|
import { PlugNamespaceHook } from "$common/hooks/plug_namespace.ts";
|
||||||
import { SilverBulletHooks } from "./manifest.ts";
|
import { SilverBulletHooks } from "./manifest.ts";
|
||||||
import { buildQueryFunctions } from "./query_functions.ts";
|
import { buildQueryFunctions } from "./query_functions.ts";
|
||||||
import { ScriptEnvironment } from "./space_script.ts";
|
import { ScriptEnvironment } from "./space_script.ts";
|
||||||
import { EventHook } from "../plugos/hooks/event.ts";
|
import { EventHook } from "../lib/plugos/hooks/event.ts";
|
||||||
import { DataStore } from "../plugos/lib/datastore.ts";
|
import { DataStore } from "$lib/data/datastore.ts";
|
||||||
import { System } from "../plugos/system.ts";
|
import { System } from "$lib/plugos/system.ts";
|
||||||
import { CodeWidgetHook } from "../web/hooks/code_widget.ts";
|
import { CodeWidgetHook } from "../web/hooks/code_widget.ts";
|
||||||
import { PanelWidgetHook } from "../web/hooks/panel_widget.ts";
|
import { PanelWidgetHook } from "../web/hooks/panel_widget.ts";
|
||||||
import { SlashCommandHook } from "../web/hooks/slash_command.ts";
|
import { SlashCommandHook } from "../web/hooks/slash_command.ts";
|
||||||
import { DataStoreMQ } from "../plugos/lib/mq.datastore.ts";
|
import { DataStoreMQ } from "$lib/data/mq.datastore.ts";
|
||||||
|
|
||||||
export abstract class CommonSystem {
|
export abstract class CommonSystem {
|
||||||
system!: System<SilverBulletHooks>;
|
system!: System<SilverBulletHooks>;
|
||||||
|
|
118
common/deps.ts
118
common/deps.ts
|
@ -1,22 +1,7 @@
|
||||||
export {
|
|
||||||
history,
|
|
||||||
historyKeymap,
|
|
||||||
indentWithTab,
|
|
||||||
standardKeymap,
|
|
||||||
} from "@codemirror/commands";
|
|
||||||
export {
|
|
||||||
autocompletion,
|
|
||||||
closeBrackets,
|
|
||||||
closeBracketsKeymap,
|
|
||||||
CompletionContext,
|
|
||||||
completionKeymap,
|
|
||||||
} from "@codemirror/autocomplete";
|
|
||||||
export type { Completion, CompletionResult } from "@codemirror/autocomplete";
|
|
||||||
|
|
||||||
export { styleTags, Tag, tagHighlighter, tags } from "@lezer/highlight";
|
export { styleTags, Tag, tagHighlighter, tags } from "@lezer/highlight";
|
||||||
|
|
||||||
export * as YAML from "https://esm.sh/js-yaml@4.1.0";
|
export * as YAML from "js-yaml";
|
||||||
export * as path from "https://deno.land/std@0.189.0/path/mod.ts";
|
export * as path from "$std/path/mod.ts";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Intl,
|
Intl,
|
||||||
|
@ -56,84 +41,27 @@ export {
|
||||||
|
|
||||||
export type { NodeType, SyntaxNode, SyntaxNodeRef, Tree } from "@lezer/common";
|
export type { NodeType, SyntaxNode, SyntaxNodeRef, Tree } from "@lezer/common";
|
||||||
|
|
||||||
export {
|
export { markdown } from "@codemirror/lang-markdown";
|
||||||
closeSearchPanel,
|
|
||||||
openSearchPanel,
|
|
||||||
searchKeymap,
|
|
||||||
} from "@codemirror/search";
|
|
||||||
export {
|
|
||||||
Decoration,
|
|
||||||
drawSelection,
|
|
||||||
dropCursor,
|
|
||||||
EditorView,
|
|
||||||
gutter,
|
|
||||||
highlightSpecialChars,
|
|
||||||
keymap,
|
|
||||||
placeholder,
|
|
||||||
runScopeHandlers,
|
|
||||||
ViewPlugin,
|
|
||||||
ViewUpdate,
|
|
||||||
WidgetType,
|
|
||||||
} from "@codemirror/view";
|
|
||||||
export type { DecorationSet, KeyBinding } from "@codemirror/view";
|
|
||||||
|
|
||||||
export { markdown } from "https://esm.sh/@codemirror/lang-markdown@6.2.3?external=@codemirror/state,@lezer/common,@codemirror/language,@lezer/markdown,@codemirror/view,@lezer/highlight,@codemirror/lang-html&target=es2022";
|
// Language modes
|
||||||
|
export { yaml as yamlLanguage } from "@codemirror/legacy-modes/mode/yaml?external=@codemirror/language&target=es2022";
|
||||||
export {
|
|
||||||
EditorSelection,
|
|
||||||
EditorState,
|
|
||||||
Range,
|
|
||||||
SelectionRange,
|
|
||||||
StateField,
|
|
||||||
Text,
|
|
||||||
Transaction,
|
|
||||||
} from "@codemirror/state";
|
|
||||||
export type {
|
|
||||||
ChangeSpec,
|
|
||||||
Compartment,
|
|
||||||
Extension,
|
|
||||||
StateCommand,
|
|
||||||
} from "@codemirror/state";
|
|
||||||
export {
|
|
||||||
codeFolding,
|
|
||||||
defaultHighlightStyle,
|
|
||||||
defineLanguageFacet,
|
|
||||||
foldAll,
|
|
||||||
foldCode,
|
|
||||||
foldedRanges,
|
|
||||||
foldGutter,
|
|
||||||
foldInside,
|
|
||||||
HighlightStyle,
|
|
||||||
indentNodeProp,
|
|
||||||
indentOnInput,
|
|
||||||
Language,
|
|
||||||
languageDataProp,
|
|
||||||
LanguageDescription,
|
|
||||||
LanguageSupport,
|
|
||||||
ParseContext,
|
|
||||||
StreamLanguage,
|
|
||||||
syntaxHighlighting,
|
|
||||||
syntaxTree,
|
|
||||||
toggleFold,
|
|
||||||
unfoldAll,
|
|
||||||
unfoldCode,
|
|
||||||
} from "@codemirror/language";
|
|
||||||
|
|
||||||
export { yaml as yamlLanguage } from "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/yaml?external=@codemirror/language&target=es2022";
|
|
||||||
export {
|
export {
|
||||||
pgSQL as postgresqlLanguage,
|
pgSQL as postgresqlLanguage,
|
||||||
standardSQL as sqlLanguage,
|
standardSQL as sqlLanguage,
|
||||||
} from "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/sql?external=@codemirror/language&target=es2022";
|
} from "@codemirror/legacy-modes/mode/sql?external=@codemirror/language&target=es2022";
|
||||||
export { rust as rustLanguage } from "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/rust?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 "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/css?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 { htmlLanguage } from "@codemirror/lang-html";
|
||||||
export { python as pythonLanguage } from "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/python?external=@codemirror/language&target=es2022";
|
|
||||||
export { protobuf as protobufLanguage } from "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/protobuf?external=@codemirror/language&target=es2022";
|
export { Language, StreamLanguage } from "@codemirror/language";
|
||||||
export { shell as shellLanguage } from "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/shell?external=@codemirror/language&target=es2022";
|
|
||||||
export { swift as swiftLanguage } from "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/swift?external=@codemirror/language&target=es2022";
|
|
||||||
export { toml as tomlLanguage } from "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/toml?external=@codemirror/language&target=es2022";
|
|
||||||
export { xml as xmlLanguage } from "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/xml?external=@codemirror/language&target=es2022";
|
|
||||||
export { json as jsonLanguage } from "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/javascript?external=@codemirror/language&target=es2022";
|
|
||||||
export {
|
export {
|
||||||
c as cLanguage,
|
c as cLanguage,
|
||||||
cpp as cppLanguage,
|
cpp as cppLanguage,
|
||||||
|
@ -144,15 +72,15 @@ export {
|
||||||
objectiveC as objectiveCLanguage,
|
objectiveC as objectiveCLanguage,
|
||||||
objectiveCpp as objectiveCppLanguage,
|
objectiveCpp as objectiveCppLanguage,
|
||||||
scala as scalaLanguage,
|
scala as scalaLanguage,
|
||||||
} from "https://esm.sh/@codemirror/legacy-modes@6.3.3/mode/clike?external=@codemirror/language&target=es2022";
|
} from "@codemirror/legacy-modes/mode/clike?external=@codemirror/language&target=es2022";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
javascriptLanguage,
|
javascriptLanguage,
|
||||||
typescriptLanguage,
|
typescriptLanguage,
|
||||||
} from "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";
|
} from "@codemirror/lang-javascript";
|
||||||
|
|
||||||
export { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts";
|
export { mime } from "mimetypes";
|
||||||
|
|
||||||
export { compile as gitIgnoreCompiler } from "https://esm.sh/gitignore-parser@0.0.2";
|
export { compile as gitIgnoreCompiler } from "gitignore-parser";
|
||||||
|
|
||||||
export { z } from "https://deno.land/x/zod@v3.22.4/mod.ts";
|
export { z } from "zod";
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { Hook, Manifest } from "../../plugos/types.ts";
|
import { Hook, Manifest } from "../../lib/plugos/types.ts";
|
||||||
import { System } from "../../plugos/system.ts";
|
import { System } from "../../lib/plugos/system.ts";
|
||||||
import { EventEmitter } from "../../plugos/event.ts";
|
import { EventEmitter } from "../../lib/plugos/event.ts";
|
||||||
import { ObjectValue } from "$sb/types.ts";
|
import { ObjectValue } from "../../type/types.ts";
|
||||||
import {
|
import {
|
||||||
FrontmatterConfig,
|
FrontmatterConfig,
|
||||||
SnippetConfig,
|
SnippetConfig,
|
||||||
} from "../../plugs/template/types.ts";
|
} from "../../plugs/template/types.ts";
|
||||||
import { throttle } from "$sb/lib/async.ts";
|
|
||||||
import { NewPageConfig } from "../../plugs/template/types.ts";
|
import { NewPageConfig } from "../../plugs/template/types.ts";
|
||||||
|
import { throttle } from "../../lib/async.ts";
|
||||||
|
|
||||||
export type CommandDef = {
|
export type CommandDef = {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Plug } from "../../plugos/plug.ts";
|
import { Plug } from "../../lib/plugos/plug.ts";
|
||||||
import { System } from "../../plugos/system.ts";
|
import { System } from "../../lib/plugos/system.ts";
|
||||||
import { Hook, Manifest } from "../../plugos/types.ts";
|
import { Hook, Manifest } from "../../lib/plugos/types.ts";
|
||||||
|
|
||||||
export type NamespaceOperation =
|
export type NamespaceOperation =
|
||||||
| "readFile"
|
| "readFile"
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
import { assertEquals } from "../test_deps.ts";
|
|
||||||
import { decodeBSON, encodeBSON, traverseAndRewriteJSON } from "./json.ts";
|
|
||||||
|
|
||||||
Deno.test("traverseAndRewrite", () => {
|
|
||||||
const bufArray = new Uint8Array([1, 2, 3]);
|
|
||||||
const obj = {
|
|
||||||
foo: "bar",
|
|
||||||
list: ["hello", { sup: "world" }],
|
|
||||||
nested: {
|
|
||||||
baz: "qux",
|
|
||||||
},
|
|
||||||
special: {
|
|
||||||
value: () => {
|
|
||||||
return bufArray;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const rewritten = traverseAndRewriteJSON(obj, (val) => {
|
|
||||||
if (typeof val?.value === "function") {
|
|
||||||
return val.value();
|
|
||||||
}
|
|
||||||
if (typeof val === "string") {
|
|
||||||
return val.toUpperCase();
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
});
|
|
||||||
|
|
||||||
assertEquals(rewritten, {
|
|
||||||
foo: "BAR",
|
|
||||||
list: ["HELLO", { sup: "WORLD" }],
|
|
||||||
nested: {
|
|
||||||
baz: "QUX",
|
|
||||||
},
|
|
||||||
special: bufArray,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
Deno.test("BSON encoding", () => {
|
|
||||||
// Test some primitives
|
|
||||||
assertEquals(decodeBSON(encodeBSON("test")), "test");
|
|
||||||
assertEquals(decodeBSON(encodeBSON([1, 2, 3])), [1, 2, 3]);
|
|
||||||
assertEquals(decodeBSON(encodeBSON(true)), true);
|
|
||||||
assertEquals(decodeBSON(encodeBSON(false)), false);
|
|
||||||
assertEquals(decodeBSON(encodeBSON(null)), null);
|
|
||||||
assertEquals(decodeBSON(encodeBSON(0)), 0);
|
|
||||||
|
|
||||||
assertEquals(decodeBSON(encodeBSON(undefined)), undefined);
|
|
||||||
|
|
||||||
const blob = new Uint8Array([1, 2, 3]);
|
|
||||||
assertEquals(decodeBSON(encodeBSON(blob)), blob);
|
|
||||||
|
|
||||||
// Then move to more advanced wrapped content
|
|
||||||
const obj = {
|
|
||||||
foo: "bar",
|
|
||||||
list: ["hello", { sup: "world" }],
|
|
||||||
nested: {
|
|
||||||
baz: "qux",
|
|
||||||
},
|
|
||||||
bin: blob,
|
|
||||||
};
|
|
||||||
assertEquals(decodeBSON(encodeBSON(obj)), obj);
|
|
||||||
});
|
|
|
@ -1,73 +0,0 @@
|
||||||
import { BSON } from "https://esm.sh/bson@6.2.0";
|
|
||||||
|
|
||||||
// BSON doesn't support top-level primitives, so we need to wrap them in an object
|
|
||||||
const topLevelValueKey = "$_tl";
|
|
||||||
|
|
||||||
// BSON doesn't support undefined, so we need to encode it as a "magic" string
|
|
||||||
const undefinedPlaceHolder = "$_undefined_$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BSON encoder, but also supporting "edge cases" like encoding strings, numbers, etc.
|
|
||||||
* @param obj
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
export function encodeBSON(obj: any): Uint8Array {
|
|
||||||
if (
|
|
||||||
obj === undefined || obj === null ||
|
|
||||||
!(typeof obj === "object" && obj.constructor === Object)
|
|
||||||
) {
|
|
||||||
obj = { [topLevelValueKey]: obj };
|
|
||||||
}
|
|
||||||
obj = traverseAndRewriteJSON(obj, (val) => {
|
|
||||||
if (val === undefined) {
|
|
||||||
return undefinedPlaceHolder;
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
});
|
|
||||||
return BSON.serialize(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function decodeBSON(data: Uint8Array): any {
|
|
||||||
let result = BSON.deserialize(data);
|
|
||||||
// For whatever reason the BSON library doesn't unwrap binary blobs automatically
|
|
||||||
result = traverseAndRewriteJSON(result, (val) => {
|
|
||||||
if (typeof val?.value === "function") {
|
|
||||||
return val.value();
|
|
||||||
} else if (val === undefinedPlaceHolder) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
});
|
|
||||||
if (Object.hasOwn(result, topLevelValueKey)) {
|
|
||||||
return result[topLevelValueKey];
|
|
||||||
} else {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Traverses and rewrites an object recursively.
|
|
||||||
*
|
|
||||||
* @param obj - The object to traverse and rewrite.
|
|
||||||
* @param rewrite - The function to apply for rewriting each value.
|
|
||||||
* @returns The rewritten object.
|
|
||||||
*/
|
|
||||||
export function traverseAndRewriteJSON(
|
|
||||||
obj: any,
|
|
||||||
rewrite: (val: any) => any,
|
|
||||||
): any {
|
|
||||||
// Apply rewrite to object as a whole
|
|
||||||
obj = rewrite(obj);
|
|
||||||
// Recurse down if this is an array or a "plain object"
|
|
||||||
if (
|
|
||||||
obj && (Array.isArray(obj) ||
|
|
||||||
(typeof obj === "object" && obj.constructor === Object))
|
|
||||||
) {
|
|
||||||
const keys = Object.keys(obj);
|
|
||||||
for (let i = 0; i < keys.length; i++) {
|
|
||||||
const key = keys[i];
|
|
||||||
obj[key] = traverseAndRewriteJSON(obj[key], rewrite);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
|
@ -1,12 +1,12 @@
|
||||||
import * as plugos from "../plugos/types.ts";
|
import * as plugos from "../lib/plugos/types.ts";
|
||||||
import { CronHookT } from "../plugos/hooks/cron.ts";
|
import { CronHookT } from "../lib/plugos/hooks/cron.ts";
|
||||||
import { EventHookT } from "../plugos/hooks/event.ts";
|
import { EventHookT } from "../lib/plugos/hooks/event.ts";
|
||||||
import { CommandHookT } from "./hooks/command.ts";
|
import { CommandHookT } from "./hooks/command.ts";
|
||||||
import { SlashCommandHookT } from "../web/hooks/slash_command.ts";
|
import { SlashCommandHookT } from "../web/hooks/slash_command.ts";
|
||||||
import { PlugNamespaceHookT } from "./hooks/plug_namespace.ts";
|
import { PlugNamespaceHookT } from "./hooks/plug_namespace.ts";
|
||||||
import { CodeWidgetT } from "../web/hooks/code_widget.ts";
|
import { CodeWidgetT } from "../web/hooks/code_widget.ts";
|
||||||
import { MQHookT } from "../plugos/hooks/mq.ts";
|
import { MQHookT } from "../lib/plugos/hooks/mq.ts";
|
||||||
import { EndpointHookT } from "../plugos/hooks/endpoint.ts";
|
import { EndpointHookT } from "../server/hooks/endpoint.ts";
|
||||||
import { PanelWidgetT } from "../web/hooks/panel_widget.ts";
|
import { PanelWidgetT } from "../web/hooks/panel_widget.ts";
|
||||||
|
|
||||||
/** Silverbullet hooks give plugs access to silverbullet core systems.
|
/** Silverbullet hooks give plugs access to silverbullet core systems.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { ParseTree } from "$sb/lib/tree.ts";
|
import type { ParseTree } from "$lib/tree.ts";
|
||||||
import type { Language, SyntaxNode } from "../deps.ts";
|
import type { Language, SyntaxNode } from "../deps.ts";
|
||||||
|
|
||||||
export function lezerToParseTree(
|
export function lezerToParseTree(
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
import { parse } from "./parse_tree.ts";
|
import { parse } from "./parse_tree.ts";
|
||||||
import {
|
import { collectNodesOfType, findNodeOfType, renderToText } from "$lib/tree.ts";
|
||||||
collectNodesOfType,
|
import { assertEquals, assertNotEquals } from "$lib/test_deps.ts";
|
||||||
findNodeOfType,
|
|
||||||
renderToText,
|
|
||||||
} from "../../plug-api/lib/tree.ts";
|
|
||||||
import { assertEquals, assertNotEquals } from "../../test_deps.ts";
|
|
||||||
import { extendedMarkdownLanguage } from "./parser.ts";
|
import { extendedMarkdownLanguage } from "./parser.ts";
|
||||||
|
|
||||||
const sample1 = `---
|
const sample1 = `---
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { base64Decode, base64Encode } from "../plugos/asset_bundle/base64.ts";
|
import { base64Decode, base64Encode } from "../lib/crypto.ts";
|
||||||
|
|
||||||
export type ProxyFetchRequest = {
|
export type ProxyFetchRequest = {
|
||||||
method?: string;
|
method?: string;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { FunctionMap } from "$sb/types.ts";
|
import { FunctionMap } from "../type/types.ts";
|
||||||
import { builtinFunctions } from "$sb/lib/builtin_query_functions.ts";
|
import { builtinFunctions } from "../lib/builtin_query_functions.ts";
|
||||||
import { System } from "../plugos/system.ts";
|
import { System } from "../lib/plugos/system.ts";
|
||||||
import { Query } from "$sb/types.ts";
|
import { Query } from "../type/types.ts";
|
||||||
import { LimitedMap } from "$sb/lib/limited_map.ts";
|
import { LimitedMap } from "$lib/limited_map.ts";
|
||||||
|
|
||||||
const pageCacheTtl = 10 * 1000; // 10s
|
const pageCacheTtl = 10 * 1000; // 10s
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,9 @@
|
||||||
import { INDEX_TEMPLATE, SETTINGS_TEMPLATE } from "./PAGE_TEMPLATES.ts";
|
|
||||||
import { YAML } from "./deps.ts";
|
import { YAML } from "./deps.ts";
|
||||||
|
import { INDEX_TEMPLATE, SETTINGS_TEMPLATE } from "./PAGE_TEMPLATES.ts";
|
||||||
import { SpacePrimitives } from "./spaces/space_primitives.ts";
|
import { SpacePrimitives } from "./spaces/space_primitives.ts";
|
||||||
import { expandPropertyNames } from "$sb/lib/json.ts";
|
import { expandPropertyNames } from "../lib/json.ts";
|
||||||
import type { BuiltinSettings } from "../web/types.ts";
|
import type { BuiltinSettings } from "../web/types.ts";
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a function safely by catching any errors and logging them to the console.
|
|
||||||
* @param fn - The function to run.
|
|
||||||
*/
|
|
||||||
export function safeRun(fn: () => Promise<void>) {
|
|
||||||
fn().catch((e) => {
|
|
||||||
console.error(e);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the current platform is Mac-like (Mac, iPhone, iPod, iPad).
|
|
||||||
* @returns A boolean indicating if the platform is Mac-like.
|
|
||||||
*/
|
|
||||||
export function isMacLike() {
|
|
||||||
return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: This is naive, may be better to use a proper parser
|
// TODO: This is naive, may be better to use a proper parser
|
||||||
const yamlSettingsRegex = /```yaml([^`]+)```/;
|
const yamlSettingsRegex = /```yaml([^`]+)```/;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { SpacePrimitives } from "../common/spaces/space_primitives.ts";
|
import { SpacePrimitives } from "$common/spaces/space_primitives.ts";
|
||||||
import { plugPrefix } from "../common/spaces/constants.ts";
|
import { plugPrefix } from "$common/spaces/constants.ts";
|
||||||
import { safeRun } from "../common/util.ts";
|
|
||||||
|
|
||||||
import { AttachmentMeta, FileMeta, PageMeta } from "$sb/types.ts";
|
import { AttachmentMeta, FileMeta, PageMeta } from "../type/types.ts";
|
||||||
import { EventHook } from "../plugos/hooks/event.ts";
|
import { EventHook } from "../lib/plugos/hooks/event.ts";
|
||||||
|
import { safeRun } from "../lib/async.ts";
|
||||||
|
|
||||||
const pageWatchInterval = 5000;
|
const pageWatchInterval = 5000;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { DataStore } from "../plugos/lib/datastore.ts";
|
import { DataStore } from "$lib/data/datastore.ts";
|
||||||
import { System } from "../plugos/system.ts";
|
import { System } from "$lib/plugos/system.ts";
|
||||||
|
|
||||||
const indexVersionKey = ["$indexVersion"];
|
const indexVersionKey = ["$indexVersion"];
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { System } from "../plugos/system.ts";
|
import { System } from "../lib/plugos/system.ts";
|
||||||
import { ScriptObject } from "../plugs/index/script.ts";
|
import { ScriptObject } from "../plugs/index/script.ts";
|
||||||
import { AppCommand, CommandDef } from "./hooks/command.ts";
|
import { AppCommand, CommandDef } from "./hooks/command.ts";
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { SpacePrimitives } from "./space_primitives.ts";
|
import { SpacePrimitives } from "./space_primitives.ts";
|
||||||
import { AssetBundle } from "../../plugos/asset_bundle/bundle.ts";
|
import { AssetBundle } from "../../lib/asset_bundle/bundle.ts";
|
||||||
import { FileMeta } from "$sb/types.ts";
|
import { FileMeta } from "../../type/types.ts";
|
||||||
|
|
||||||
export class AssetBundlePlugSpacePrimitives implements SpacePrimitives {
|
export class AssetBundlePlugSpacePrimitives implements SpacePrimitives {
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { MemoryKvPrimitives } from "../../plugos/lib/memory_kv_primitives.ts";
|
import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts";
|
||||||
import { assertEquals } from "../../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
import { ChunkedKvStoreSpacePrimitives } from "./chunked_datastore_space_primitives.ts";
|
import { ChunkedKvStoreSpacePrimitives } from "./chunked_datastore_space_primitives.ts";
|
||||||
import { testSpacePrimitives } from "./space_primitives.test.ts";
|
import { testSpacePrimitives } from "./space_primitives.test.ts";
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import type { SpacePrimitives } from "./space_primitives.ts";
|
import type { SpacePrimitives } from "./space_primitives.ts";
|
||||||
import { KvKey } from "$sb/types.ts";
|
import { KvKey } from "$type/types.ts";
|
||||||
import { KvPrimitives } from "../../plugos/lib/kv_primitives.ts";
|
import { KvPrimitives } from "$lib/data/kv_primitives.ts";
|
||||||
import { KvMetaSpacePrimitives } from "./kv_meta_space_primitives.ts";
|
import { KvMetaSpacePrimitives } from "./kv_meta_space_primitives.ts";
|
||||||
import { PrefixedKvPrimitives } from "../../plugos/lib/prefixed_kv_primitives.ts";
|
import { PrefixedKvPrimitives } from "$lib/data/prefixed_kv_primitives.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A space primitives implementation that stores files in chunks in a KV store.
|
* A space primitives implementation that stores files in chunks in a KV store.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import "https://esm.sh/fake-indexeddb@4.0.2/auto";
|
import "https://esm.sh/fake-indexeddb@4.0.2/auto";
|
||||||
import { DataStore } from "../../plugos/lib/datastore.ts";
|
import { DataStore } from "$lib/data/datastore.ts";
|
||||||
import { IndexedDBKvPrimitives } from "../../plugos/lib/indexeddb_kv_primitives.ts";
|
import { IndexedDBKvPrimitives } from "$lib/data/indexeddb_kv_primitives.ts";
|
||||||
import { DataStoreSpacePrimitives } from "./datastore_space_primitives.ts";
|
import { DataStoreSpacePrimitives } from "./datastore_space_primitives.ts";
|
||||||
import { testSpacePrimitives } from "./space_primitives.test.ts";
|
import { testSpacePrimitives } from "./space_primitives.test.ts";
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { SpacePrimitives } from "./space_primitives.ts";
|
import type { SpacePrimitives } from "./space_primitives.ts";
|
||||||
import { mime } from "../deps.ts";
|
import { mime } from "mimetypes";
|
||||||
import { FileMeta } from "$sb/types.ts";
|
import { FileMeta } from "$type/types.ts";
|
||||||
import { DataStore } from "../../plugos/lib/datastore.ts";
|
import { DataStore } from "$lib/data/datastore.ts";
|
||||||
|
|
||||||
export type FileContent = {
|
export type FileContent = {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { DenoKvPrimitives } from "../../plugos/lib/deno_kv_primitives.ts";
|
import { DenoKvPrimitives } from "$lib/data/deno_kv_primitives.ts";
|
||||||
import { ChunkedKvStoreSpacePrimitives } from "./chunked_datastore_space_primitives.ts";
|
import { ChunkedKvStoreSpacePrimitives } from "$common/spaces/chunked_datastore_space_primitives.ts";
|
||||||
import { testSpacePrimitives } from "./space_primitives.test.ts";
|
import { testSpacePrimitives } from "$common/spaces/space_primitives.test.ts";
|
||||||
|
|
||||||
Deno.test("deno kv test", async () => {
|
Deno.test("deno kv test", async () => {
|
||||||
const tempFile = await Deno.makeTempFile({ suffix: ".db" });
|
const tempFile = await Deno.makeTempFile({ suffix: ".db" });
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { readAll } from "https://deno.land/std@0.165.0/streams/conversion.ts";
|
||||||
import { SpacePrimitives } from "./space_primitives.ts";
|
import { SpacePrimitives } from "./space_primitives.ts";
|
||||||
import { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts";
|
import { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts";
|
||||||
import { walk } from "https://deno.land/std@0.198.0/fs/walk.ts";
|
import { walk } from "https://deno.land/std@0.198.0/fs/walk.ts";
|
||||||
import { FileMeta } from "$sb/types.ts";
|
import { FileMeta } from "../../type/types.ts";
|
||||||
|
|
||||||
function lookupContentType(path: string): string {
|
function lookupContentType(path: string): string {
|
||||||
return mime.getType(path) || "application/octet-stream";
|
return mime.getType(path) || "application/octet-stream";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { MemoryKvPrimitives } from "../../plugos/lib/memory_kv_primitives.ts";
|
import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts";
|
||||||
import { assert, assertEquals } from "../../test_deps.ts";
|
import { assert, assertEquals } from "$lib/test_deps.ts";
|
||||||
import { ChunkedKvStoreSpacePrimitives } from "./chunked_datastore_space_primitives.ts";
|
import { ChunkedKvStoreSpacePrimitives } from "./chunked_datastore_space_primitives.ts";
|
||||||
import { EncryptedSpacePrimitives } from "./encrypted_space_primitives.ts";
|
import { EncryptedSpacePrimitives } from "./encrypted_space_primitives.ts";
|
||||||
import { testSpacePrimitives } from "./space_primitives.test.ts";
|
import { testSpacePrimitives } from "./space_primitives.test.ts";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { FileMeta } from "../../plug-api/types.ts";
|
import { FileMeta } from "../../type/types.ts";
|
||||||
import {
|
import {
|
||||||
base32Decode,
|
base32Decode,
|
||||||
base32Encode,
|
base32Encode,
|
||||||
|
@ -8,7 +8,8 @@ import {
|
||||||
exportKey,
|
exportKey,
|
||||||
generateSalt,
|
generateSalt,
|
||||||
importKey,
|
importKey,
|
||||||
} from "../crypto.ts";
|
} from "../../lib/crypto.ts";
|
||||||
|
import { plugPrefix } from "./constants.ts";
|
||||||
import { SpacePrimitives } from "./space_primitives.ts";
|
import { SpacePrimitives } from "./space_primitives.ts";
|
||||||
|
|
||||||
export const encryptedFileExt = ".crypt";
|
export const encryptedFileExt = ".crypt";
|
||||||
|
@ -178,7 +179,7 @@ export class EncryptedSpacePrimitives implements SpacePrimitives {
|
||||||
}
|
}
|
||||||
|
|
||||||
isUnencryptedPath(name: string) {
|
isUnencryptedPath(name: string) {
|
||||||
return name.startsWith("_plug/");
|
return name.startsWith(plugPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { FileMeta } from "$sb/types.ts";
|
import { FileMeta } from "../../type/types.ts";
|
||||||
import { EventHook } from "../../plugos/hooks/event.ts";
|
import { EventHook } from "../../lib/plugos/hooks/event.ts";
|
||||||
|
|
||||||
import type { SpacePrimitives } from "./space_primitives.ts";
|
import type { SpacePrimitives } from "./space_primitives.ts";
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { FileMeta } from "$sb/types.ts";
|
import { FileMeta } from "../../type/types.ts";
|
||||||
import type { SpacePrimitives } from "./space_primitives.ts";
|
import type { SpacePrimitives } from "./space_primitives.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { FileMeta } from "$sb/types.ts";
|
import { FileMeta } from "../../type/types.ts";
|
||||||
import { SpacePrimitives } from "./space_primitives.ts";
|
import { SpacePrimitives } from "./space_primitives.ts";
|
||||||
|
|
||||||
export class FilteredSpacePrimitives implements SpacePrimitives {
|
export class FilteredSpacePrimitives implements SpacePrimitives {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { SpacePrimitives } from "./space_primitives.ts";
|
import { SpacePrimitives } from "./space_primitives.ts";
|
||||||
import { flushCachesAndUnregisterServiceWorker } from "../sw_util.ts";
|
import { FileMeta } from "../../type/types.ts";
|
||||||
import { FileMeta } from "$sb/types.ts";
|
import { flushCachesAndUnregisterServiceWorker } from "./sw_util.ts";
|
||||||
|
|
||||||
export class HttpSpacePrimitives implements SpacePrimitives {
|
export class HttpSpacePrimitives implements SpacePrimitives {
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { FileMeta } from "$sb/types.ts";
|
import { FileMeta } from "$type/types.ts";
|
||||||
import { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts";
|
import { mime } from "mimetypes";
|
||||||
import { KvPrimitives } from "../../plugos/lib/kv_primitives.ts";
|
import { KvPrimitives } from "$lib/data/kv_primitives.ts";
|
||||||
import { SpacePrimitives } from "./space_primitives.ts";
|
import { SpacePrimitives } from "./space_primitives.ts";
|
||||||
|
|
||||||
export type KvMetaSpacePrimitivesCallbacks = {
|
export type KvMetaSpacePrimitivesCallbacks = {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { SpacePrimitives } from "../../common/spaces/space_primitives.ts";
|
import { SpacePrimitives } from "$common/spaces/space_primitives.ts";
|
||||||
import { FileMeta } from "$sb/types.ts";
|
import { FileMeta } from "../../type/types.ts";
|
||||||
import {
|
import {
|
||||||
NamespaceOperation,
|
NamespaceOperation,
|
||||||
PlugNamespaceHook,
|
PlugNamespaceHook,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { FileMeta } from "$sb/types.ts";
|
import { FileMeta } from "../../type/types.ts";
|
||||||
import { SpacePrimitives } from "./space_primitives.ts";
|
import { SpacePrimitives } from "./space_primitives.ts";
|
||||||
|
|
||||||
export class ReadOnlySpacePrimitives implements SpacePrimitives {
|
export class ReadOnlySpacePrimitives implements SpacePrimitives {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { S3SpacePrimitives } from "./s3_space_primitives.ts";
|
import { S3SpacePrimitives } from "./s3_space_primitives.ts";
|
||||||
import { MemoryKvPrimitives } from "../../plugos/lib/memory_kv_primitives.ts";
|
import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts";
|
||||||
import { testSpacePrimitives } from "./space_primitives.test.ts";
|
import { testSpacePrimitives } from "$common/spaces/space_primitives.test.ts";
|
||||||
|
|
||||||
Deno.test("s3_space_primitives", async () => {
|
Deno.test("s3_space_primitives", async () => {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
import { S3Client } from "https://deno.land/x/s3_lite_client@0.4.0/mod.ts";
|
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 type { ClientOptions } from "https://deno.land/x/s3_lite_client@0.4.0/client.ts";
|
||||||
import { KvMetaSpacePrimitives } from "./kv_meta_space_primitives.ts";
|
import { KvMetaSpacePrimitives } from "./kv_meta_space_primitives.ts";
|
||||||
import { KvPrimitives } from "../../plugos/lib/kv_primitives.ts";
|
import { KvPrimitives } from "$lib/data/kv_primitives.ts";
|
||||||
import { mime } from "../deps.ts";
|
import { mime } from "../deps.ts";
|
||||||
import { KV, KvKey } from "$sb/types.ts";
|
import { KV, KvKey } from "$type/types.ts";
|
||||||
import { PrefixedKvPrimitives } from "../../plugos/lib/prefixed_kv_primitives.ts";
|
import { PrefixedKvPrimitives } from "$lib/data/prefixed_kv_primitives.ts";
|
||||||
|
|
||||||
export type S3SpacePrimitivesOptions = ClientOptions;
|
export type S3SpacePrimitivesOptions = ClientOptions;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { assert, assertEquals } from "../../test_deps.ts";
|
import { assert, assertEquals } from "$lib/test_deps.ts";
|
||||||
import { SpacePrimitives } from "./space_primitives.ts";
|
import { SpacePrimitives } from "./space_primitives.ts";
|
||||||
|
|
||||||
export async function testSpacePrimitives(spacePrimitives: SpacePrimitives) {
|
export async function testSpacePrimitives(spacePrimitives: SpacePrimitives) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { FileMeta } from "$sb/types.ts";
|
import type { FileMeta } from "../../type/types.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A generic interface used by `Space` to interact with the underlying storage, designed to be easy to implement for different storage backends
|
* A generic interface used by `Space` to interact with the underlying storage, designed to be easy to implement for different storage backends
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { SpaceSync, SyncStatusItem } from "./sync.ts";
|
import { SpaceSync, SyncStatusItem } from "./sync.ts";
|
||||||
import { DiskSpacePrimitives } from "./disk_space_primitives.ts";
|
import { DiskSpacePrimitives } from "./disk_space_primitives.ts";
|
||||||
import { assertEquals } from "../../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
|
|
||||||
Deno.test("Test store", async () => {
|
Deno.test("Test store", async () => {
|
||||||
const primaryPath = await Deno.makeTempDir();
|
const primaryPath = await Deno.makeTempDir();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { SpacePrimitives } from "./space_primitives.ts";
|
import { SpacePrimitives } from "./space_primitives.ts";
|
||||||
import { EventEmitter } from "../../plugos/event.ts";
|
import { EventEmitter } from "../../lib/plugos/event.ts";
|
||||||
import { FileMeta } from "$sb/types.ts";
|
import { FileMeta } from "../../type/types.ts";
|
||||||
|
import { plugPrefix } from "./constants.ts";
|
||||||
|
|
||||||
type SyncHash = number;
|
type SyncHash = number;
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ export class SpaceSync extends EventEmitter<SyncEvents> {
|
||||||
// Just make sure that _plug/ files appear first
|
// Just make sure that _plug/ files appear first
|
||||||
// This is important for the initial sync: plugs are loaded the moment they are pulled into the space,
|
// This is important for the initial sync: plugs are loaded the moment they are pulled into the space,
|
||||||
// which would activate e.g. any indexing logic for the remaining space content
|
// which would activate e.g. any indexing logic for the remaining space content
|
||||||
return a.startsWith("_plug/") ? -1 : 1;
|
return a.startsWith(plugPrefix) ? -1 : 1;
|
||||||
});
|
});
|
||||||
// console.log("[sync]", "Iterating over all files");
|
// console.log("[sync]", "Iterating over all files");
|
||||||
let filesProcessed = 0;
|
let filesProcessed = 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { SysCallMapping } from "../../plugos/system.ts";
|
import { SysCallMapping } from "../../lib/plugos/system.ts";
|
||||||
import { parse } from "../markdown_parser/parse_tree.ts";
|
import { parse } from "../markdown_parser/parse_tree.ts";
|
||||||
import type { ParseTree } from "$sb/lib/tree.ts";
|
import type { ParseTree } from "$lib/tree.ts";
|
||||||
import { builtinLanguages, languageFor } from "../languages.ts";
|
import { builtinLanguages, languageFor } from "../languages.ts";
|
||||||
|
|
||||||
export function languageSyscalls(): SysCallMapping {
|
export function languageSyscalls(): SysCallMapping {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { SysCallMapping } from "../../plugos/system.ts";
|
import { SysCallMapping } from "../../lib/plugos/system.ts";
|
||||||
import { parse } from "../markdown_parser/parse_tree.ts";
|
import { parse } from "../markdown_parser/parse_tree.ts";
|
||||||
import type { ParseTree } from "$sb/lib/tree.ts";
|
import type { ParseTree } from "$lib/tree.ts";
|
||||||
import { extendedMarkdownLanguage } from "../markdown_parser/parser.ts";
|
import { extendedMarkdownLanguage } from "../markdown_parser/parser.ts";
|
||||||
|
|
||||||
export function markdownSyscalls(): SysCallMapping {
|
export function markdownSyscalls(): SysCallMapping {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { SyscallMeta } from "$sb/types.ts";
|
import { SyscallMeta } from "../../type/types.ts";
|
||||||
import { SysCallMapping, System } from "../../plugos/system.ts";
|
import { SysCallMapping, System } from "../../lib/plugos/system.ts";
|
||||||
import type { Client } from "../../web/client.ts";
|
import type { Client } from "../../web/client.ts";
|
||||||
import { CommandDef } from "../hooks/command.ts";
|
import { CommandDef } from "../hooks/command.ts";
|
||||||
import { proxySyscall } from "../../web/syscalls/util.ts";
|
import { proxySyscall } from "../../web/syscalls/util.ts";
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { FunctionMap } from "$sb/types.ts";
|
import { FunctionMap } from "$type/types.ts";
|
||||||
import { AST } from "$sb/lib/tree.ts";
|
import { AST } from "$lib/tree.ts";
|
||||||
import { SysCallMapping } from "../../plugos/system.ts";
|
import { SysCallMapping } from "$lib/plugos/system.ts";
|
||||||
import { renderTemplate } from "../template/render.ts";
|
import { renderTemplate } from "$common/template/render.ts";
|
||||||
import { parseTemplate } from "../template/template_parser.ts";
|
import { parseTemplate } from "$common/template/template_parser.ts";
|
||||||
import { DataStore } from "../../plugos/lib/datastore.ts";
|
import { DataStore } from "$lib/data/datastore.ts";
|
||||||
|
|
||||||
export function templateSyscalls(ds: DataStore): SysCallMapping {
|
export function templateSyscalls(ds: DataStore): SysCallMapping {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { SysCallMapping } from "../../plugos/system.ts";
|
import { SysCallMapping } from "../../lib/plugos/system.ts";
|
||||||
import { YAML } from "../../web/deps.ts";
|
import { YAML } from "../../web/deps.ts";
|
||||||
|
|
||||||
type YamlStringifyOptions = {
|
type YamlStringifyOptions = {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { builtinFunctions } from "$sb/lib/builtin_query_functions.ts";
|
import { builtinFunctions } from "../../lib/builtin_query_functions.ts";
|
||||||
import { assertEquals } from "../../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
import { renderTemplate } from "./render.ts";
|
import { renderTemplate } from "./render.ts";
|
||||||
import { parseTemplate } from "./template_parser.ts";
|
import { parseTemplate } from "./template_parser.ts";
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { AST } from "$sb/lib/tree.ts";
|
import { AST } from "$lib/tree.ts";
|
||||||
import { evalQueryExpression } from "$sb/lib/query_expression.ts";
|
import { evalQueryExpression } from "$sb/lib/query_expression.ts";
|
||||||
import { expressionToKvQueryExpression } from "$sb/lib/parse-query.ts";
|
import { expressionToKvQueryExpression } from "$sb/lib/parse-query.ts";
|
||||||
import { FunctionMap } from "$sb/types.ts";
|
import { FunctionMap } from "../../type/types.ts";
|
||||||
import { jsonToMDTable } from "../../plugs/template/util.ts";
|
import { jsonToMDTable } from "../../plugs/template/util.ts";
|
||||||
|
|
||||||
export async function renderTemplate(
|
export async function renderTemplate(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { assertEquals } from "../../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
import { parseTemplate } from "./template_parser.ts";
|
import { parseTemplate } from "./template_parser.ts";
|
||||||
|
|
||||||
Deno.test("Test template", () => {
|
Deno.test("Test template", () => {
|
||||||
|
|
|
@ -4,9 +4,8 @@ import { parse } from "../markdown_parser/parse_tree.ts";
|
||||||
import { parser as templateParser } from "./parse-template.js";
|
import { parser as templateParser } from "./parse-template.js";
|
||||||
import { parser as expressionParser } from "../markdown_parser/parse-expression.js";
|
import { parser as expressionParser } from "../markdown_parser/parse-expression.js";
|
||||||
import { parser as queryParser } from "../markdown_parser/parse-query.js";
|
import { parser as queryParser } from "../markdown_parser/parse-query.js";
|
||||||
import { AST } from "$sb/lib/tree.ts";
|
import { AST, parseTreeToAST } from "$lib/tree.ts";
|
||||||
import { parseTreeToAST } from "$sb/lib/tree.ts";
|
import { deepEqual } from "../../lib/json.ts";
|
||||||
import { deepEqual } from "$sb/lib/json.ts";
|
|
||||||
|
|
||||||
export const templateLanguage = LRLanguage.define({
|
export const templateLanguage = LRLanguage.define({
|
||||||
name: "template",
|
name: "template",
|
||||||
|
|
|
@ -16,9 +16,25 @@
|
||||||
"@codemirror/lang-css": "https://esm.sh/@codemirror/lang-css@6.2.1?external=@codemirror/language,@codemirror/autocomplete,@codemirror/state,@lezer/lr,@lezer/html&target=es2022",
|
"@codemirror/lang-css": "https://esm.sh/@codemirror/lang-css@6.2.1?external=@codemirror/language,@codemirror/autocomplete,@codemirror/state,@lezer/lr,@lezer/html&target=es2022",
|
||||||
"@codemirror/lang-html": "https://esm.sh/@codemirror/lang-html@6.4.7?external=@codemirror/language,@codemirror/autocomplete,@codemirror/lang-css,@codemirror/state,@lezer/lr,@lezer/html&target=es2022",
|
"@codemirror/lang-html": "https://esm.sh/@codemirror/lang-html@6.4.7?external=@codemirror/language,@codemirror/autocomplete,@codemirror/lang-css,@codemirror/state,@lezer/lr,@lezer/html&target=es2022",
|
||||||
"@codemirror/search": "https://esm.sh/@codemirror/search@6.5.5?external=@codemirror/state,@codemirror/view&target=es2022",
|
"@codemirror/search": "https://esm.sh/@codemirror/search@6.5.5?external=@codemirror/state,@codemirror/view&target=es2022",
|
||||||
|
"@codemirror/lang-markdown": "https://esm.sh/@codemirror/lang-markdown@6.2.3?external=@codemirror/state,@lezer/common,@codemirror/language,@lezer/markdown,@codemirror/view,@lezer/highlight,@codemirror/lang-html&target=es2022",
|
||||||
|
"@codemirror/legacy-modes/": "https://esm.sh/@codemirror/legacy-modes@6.3.3/",
|
||||||
|
"@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",
|
||||||
|
|
||||||
|
"djwt": "https://deno.land/x/djwt@v3.0.1/mod.ts",
|
||||||
|
"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",
|
||||||
|
"turndown": "https://cdn.skypack.dev/turndown@7.1.1",
|
||||||
|
"turndown-plugin-gfm": "https://cdn.skypack.dev/@joplin/turndown-plugin-gfm@1.0.45",
|
||||||
|
|
||||||
|
"$common/": "./common/",
|
||||||
|
"$lib/": "./lib/",
|
||||||
|
"$type/": "./type/",
|
||||||
|
|
||||||
"preact": "https://esm.sh/preact@10.11.1",
|
"preact": "https://esm.sh/preact@10.11.1",
|
||||||
"$sb/": "./plug-api/",
|
"$sb/": "./plug-api/",
|
||||||
"zod": "https://deno.land/x/zod@v3.22.4/mod.ts"
|
"zod": "https://deno.land/x/zod@v3.22.4/mod.ts",
|
||||||
|
"$std/": "https://deno.land/std@0.189.0/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
This folder contains library functions that is generally reusable, not specific to SilverBullet. This code can be used from within plugs or the core code base.
|
|
@ -1,4 +1,4 @@
|
||||||
import { globToRegExp, mime, path, walk } from "../deps.ts";
|
import { globToRegExp, mime, path, walk } from "../plugos/deps.ts";
|
||||||
import { AssetBundle } from "./bundle.ts";
|
import { AssetBundle } from "./bundle.ts";
|
||||||
|
|
||||||
export async function bundleAssets(
|
export async function bundleAssets(
|
|
@ -1,5 +1,5 @@
|
||||||
import { AssetBundle } from "./bundle.ts";
|
import { AssetBundle } from "./bundle.ts";
|
||||||
import { assertEquals } from "../../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
|
|
||||||
Deno.test("Asset bundle", () => {
|
Deno.test("Asset bundle", () => {
|
||||||
const assetBundle = new AssetBundle();
|
const assetBundle = new AssetBundle();
|
|
@ -1,4 +1,4 @@
|
||||||
import { base64Decode, base64EncodedDataUrl } from "./base64.ts";
|
import { base64Decode, base64EncodedDataUrl } from "$lib/crypto.ts";
|
||||||
|
|
||||||
type DataUrl = string;
|
type DataUrl = string;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { assert, assertEquals } from "../../test_deps.ts";
|
import { assert, assertEquals } from "$lib/test_deps.ts";
|
||||||
import { batchRequests, PromiseQueue, sleep } from "./async.ts";
|
import { batchRequests, PromiseQueue, sleep } from "./async.ts";
|
||||||
|
|
||||||
Deno.test("PromiseQueue test", async () => {
|
Deno.test("PromiseQueue test", async () => {
|
|
@ -89,3 +89,13 @@ export async function batchRequests<I, O>(
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a function safely by catching any errors and logging them to the console.
|
||||||
|
* @param fn - The function to run.
|
||||||
|
*/
|
||||||
|
export function safeRun(fn: () => Promise<void>) {
|
||||||
|
fn().catch((e) => {
|
||||||
|
console.error(e);
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import type { FunctionMap } from "$sb/types.ts";
|
import type { FunctionMap } from "../type/types.ts";
|
||||||
import { niceDate, niceTime } from "$sb/lib/dates.ts";
|
import { niceDate, niceTime } from "./dates.ts";
|
||||||
|
|
||||||
export const builtinFunctions: FunctionMap = {
|
export const builtinFunctions: FunctionMap = {
|
||||||
today() {
|
today() {
|
|
@ -1,4 +1,4 @@
|
||||||
import { assertEquals } from "../../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
import { determineTags, isTemplate } from "./cheap_yaml.ts";
|
import { determineTags, isTemplate } from "./cheap_yaml.ts";
|
||||||
|
|
||||||
Deno.test("cheap yaml", () => {
|
Deno.test("cheap yaml", () => {
|
|
@ -146,3 +146,37 @@ function appendBuffer(buffer1: Uint8Array, buffer2: Uint8Array): Uint8Array {
|
||||||
tmp.set(new Uint8Array(buffer2), buffer1.byteLength);
|
tmp.set(new Uint8Array(buffer2), buffer1.byteLength);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function base64Decode(s: string): Uint8Array {
|
||||||
|
const binString = atob(s);
|
||||||
|
const len = binString.length;
|
||||||
|
const bytes = new Uint8Array(len);
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
bytes[i] = binString.charCodeAt(i);
|
||||||
|
}
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function base64Encode(buffer: Uint8Array | string): string {
|
||||||
|
if (typeof buffer === "string") {
|
||||||
|
buffer = new TextEncoder().encode(buffer);
|
||||||
|
}
|
||||||
|
let binary = "";
|
||||||
|
const len = buffer.byteLength;
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
binary += String.fromCharCode(buffer[i]);
|
||||||
|
}
|
||||||
|
return btoa(binary);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function base64EncodedDataUrl(
|
||||||
|
mimeType: string,
|
||||||
|
buffer: Uint8Array,
|
||||||
|
): string {
|
||||||
|
return `data:${mimeType};base64,${base64Encode(buffer)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function base64DecodeDataUrl(dataUrl: string): Uint8Array {
|
||||||
|
const b64Encoded = dataUrl.split(",", 2)[1];
|
||||||
|
return base64Decode(b64Encoded);
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
import "https://esm.sh/fake-indexeddb@4.0.2/auto";
|
import "https://esm.sh/fake-indexeddb@4.0.2/auto";
|
||||||
import { IndexedDBKvPrimitives } from "./indexeddb_kv_primitives.ts";
|
import { IndexedDBKvPrimitives } from "../data/indexeddb_kv_primitives.ts";
|
||||||
import { DataStore } from "./datastore.ts";
|
import { DataStore } from "../data/datastore.ts";
|
||||||
import { DenoKvPrimitives } from "./deno_kv_primitives.ts";
|
import { DenoKvPrimitives } from "../data/deno_kv_primitives.ts";
|
||||||
import { KvPrimitives } from "./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 "https://deno.land/std@0.165.0/testing/asserts.ts";
|
||||||
import { PrefixedKvPrimitives } from "./prefixed_kv_primitives.ts";
|
import { PrefixedKvPrimitives } from "../data/prefixed_kv_primitives.ts";
|
||||||
import { Query } from "$sb/types.ts";
|
import { Query } from "$type/types.ts";
|
||||||
|
|
||||||
async function test(db: KvPrimitives) {
|
async function test(db: KvPrimitives) {
|
||||||
const datastore = new DataStore(new PrefixedKvPrimitives(db, ["ds"]), {
|
const datastore = new DataStore(new PrefixedKvPrimitives(db, ["ds"]), {
|
|
@ -1,6 +1,6 @@
|
||||||
import { applyQueryNoFilterKV } from "$sb/lib/query.ts";
|
import { applyQueryNoFilterKV } from "$sb/lib/query.ts";
|
||||||
import { FunctionMap, KV, KvKey, KvQuery } from "$sb/types.ts";
|
import { FunctionMap, KV, KvKey, KvQuery } from "$type/types.ts";
|
||||||
import { builtinFunctions } from "$sb/lib/builtin_query_functions.ts";
|
import { builtinFunctions } from "$lib/builtin_query_functions.ts";
|
||||||
import { KvPrimitives } from "./kv_primitives.ts";
|
import { KvPrimitives } from "./kv_primitives.ts";
|
||||||
import { evalQueryExpression } from "$sb/lib/query_expression.ts";
|
import { evalQueryExpression } from "$sb/lib/query_expression.ts";
|
||||||
/**
|
/**
|
|
@ -1,6 +1,6 @@
|
||||||
/// <reference lib="deno.unstable" />
|
/// <reference lib="deno.unstable" />
|
||||||
|
|
||||||
import { KV, KvKey } from "$sb/types.ts";
|
import { KV, KvKey } from "$type/types.ts";
|
||||||
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
||||||
|
|
||||||
const kvBatchSize = 100;
|
const kvBatchSize = 100;
|
|
@ -1,4 +1,4 @@
|
||||||
import { KV, KvKey } from "../../plug-api/types.ts";
|
import { KV, KvKey } from "$type/types.ts";
|
||||||
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
||||||
import {
|
import {
|
||||||
createClient,
|
createClient,
|
|
@ -1,4 +1,4 @@
|
||||||
import { KV, KvKey } from "$sb/types.ts";
|
import { KV, KvKey } from "$type/types.ts";
|
||||||
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
||||||
import { IDBPDatabase, openDB } from "https://esm.sh/idb@7.1.1/with-async-ittr";
|
import { IDBPDatabase, openDB } from "https://esm.sh/idb@7.1.1/with-async-ittr";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { KvPrimitives } from "./kv_primitives.ts";
|
import { KvPrimitives } from "./kv_primitives.ts";
|
||||||
import { assertEquals } from "../../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
import { KV } from "$sb/types.ts";
|
import { KV } from "$type/types.ts";
|
||||||
|
|
||||||
export async function allTests(db: KvPrimitives) {
|
export async function allTests(db: KvPrimitives) {
|
||||||
await db.batchSet([
|
await db.batchSet([
|
|
@ -1,4 +1,4 @@
|
||||||
import { KV, KvKey } from "$sb/types.ts";
|
import { KV, KvKey } from "$type/types.ts";
|
||||||
|
|
||||||
export type KvQueryOptions = {
|
export type KvQueryOptions = {
|
||||||
prefix?: KvKey;
|
prefix?: KvKey;
|
|
@ -1,4 +1,4 @@
|
||||||
import { KV, KvKey } from "$sb/types.ts";
|
import { KV, KvKey } from "$type/types.ts";
|
||||||
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
||||||
|
|
||||||
const memoryKeySeparator = "\0";
|
const memoryKeySeparator = "\0";
|
|
@ -1,9 +1,9 @@
|
||||||
import { DataStoreMQ } from "./mq.datastore.ts";
|
import { DataStoreMQ } from "./mq.datastore.ts";
|
||||||
import { assertEquals } from "../../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
import { sleep } from "$sb/lib/async.ts";
|
|
||||||
import { DenoKvPrimitives } from "./deno_kv_primitives.ts";
|
import { DenoKvPrimitives } from "./deno_kv_primitives.ts";
|
||||||
import { DataStore } from "./datastore.ts";
|
import { DataStore } from "./datastore.ts";
|
||||||
import { PrefixedKvPrimitives } from "./prefixed_kv_primitives.ts";
|
import { PrefixedKvPrimitives } from "./prefixed_kv_primitives.ts";
|
||||||
|
import { sleep } from "$lib/async.ts";
|
||||||
|
|
||||||
Deno.test("DataStore MQ", async () => {
|
Deno.test("DataStore MQ", async () => {
|
||||||
const tmpFile = await Deno.makeTempFile();
|
const tmpFile = await Deno.makeTempFile();
|
|
@ -1,4 +1,4 @@
|
||||||
import { KV, MQMessage, MQStats, MQSubscribeOptions } from "$sb/types.ts";
|
import { KV, MQMessage, MQStats, MQSubscribeOptions } from "$type/types.ts";
|
||||||
import { MessageQueue } from "./mq.ts";
|
import { MessageQueue } from "./mq.ts";
|
||||||
import { DataStore } from "./datastore.ts";
|
import { DataStore } from "./datastore.ts";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { MQMessage, MQStats, MQSubscribeOptions } from "$sb/types.ts";
|
import { MQMessage, MQStats, MQSubscribeOptions } from "$type/types.ts";
|
||||||
|
|
||||||
export interface MessageQueue {
|
export interface MessageQueue {
|
||||||
batchSend(queue: string, bodies: any[]): Promise<void>;
|
batchSend(queue: string, bodies: any[]): Promise<void>;
|
|
@ -1,4 +1,4 @@
|
||||||
import { KV, KvKey } from "$sb/types.ts";
|
import { KV, KvKey } from "$type/types.ts";
|
||||||
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,4 +1,4 @@
|
||||||
import { assertEquals } from "../../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
import { deepEqual, deepObjectMerge, expandPropertyNames } from "./json.ts";
|
import { deepEqual, deepObjectMerge, expandPropertyNames } from "./json.ts";
|
||||||
|
|
||||||
Deno.test("utils", () => {
|
Deno.test("utils", () => {
|
|
@ -1,5 +1,5 @@
|
||||||
import { sleep } from "$sb/lib/async.ts";
|
import { sleep } from "$lib/async.ts";
|
||||||
import { assertEquals } from "../../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
import { LimitedMap } from "./limited_map.ts";
|
import { LimitedMap } from "./limited_map.ts";
|
||||||
|
|
||||||
Deno.test("limited map", async () => {
|
Deno.test("limited map", async () => {
|
|
@ -1,6 +1,6 @@
|
||||||
import { sleep } from "$sb/lib/async.ts";
|
import { ttlCache } from "$lib/memory_cache.ts";
|
||||||
import { ttlCache } from "$sb/lib/memory_cache.ts";
|
import { sleep } from "$lib/async.ts";
|
||||||
import { assertEquals } from "../../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
|
|
||||||
Deno.test("Memory cache", async () => {
|
Deno.test("Memory cache", async () => {
|
||||||
let calls = 0;
|
let calls = 0;
|
|
@ -1,4 +1,4 @@
|
||||||
import { LimitedMap } from "$sb/lib/limited_map.ts";
|
import { LimitedMap } from "./limited_map.ts";
|
||||||
|
|
||||||
const cache = new LimitedMap<any>(50);
|
const cache = new LimitedMap<any>(50);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { assertEquals } from "../test_deps.ts";
|
import { assertEquals } from "$lib/test_deps.ts";
|
||||||
import { folderName, resolve } from "./path.ts";
|
import { folderName, resolve } from "./path.ts";
|
||||||
|
|
||||||
Deno.test("Path functions", () => {
|
Deno.test("Path functions", () => {
|
|
@ -1,8 +1,8 @@
|
||||||
import { denoPlugins, esbuild, path, YAML } from "./deps.ts";
|
import { denoPlugins, esbuild, path, YAML } from "./deps.ts";
|
||||||
|
|
||||||
import { bundleAssets } from "./asset_bundle/builder.ts";
|
import { bundleAssets } from "$lib/asset_bundle/builder.ts";
|
||||||
import { Manifest } from "./types.ts";
|
import { Manifest } from "$lib/plugos/types.ts";
|
||||||
import { version } from "../version.ts";
|
import { version } from "../../version.ts";
|
||||||
|
|
||||||
// const workerRuntimeUrl = new URL("./worker_runtime.ts", import.meta.url);
|
// const workerRuntimeUrl = new URL("./worker_runtime.ts", import.meta.url);
|
||||||
const workerRuntimeUrl =
|
const workerRuntimeUrl =
|
||||||
|
@ -104,7 +104,7 @@ setupMessageListener(functionMapping, manifest);
|
||||||
...denoPlugins({
|
...denoPlugins({
|
||||||
// TODO do this differently
|
// TODO do this differently
|
||||||
importMapURL: options.importMap ||
|
importMapURL: options.importMap ||
|
||||||
new URL("../import_map.json", import.meta.url).toString(),
|
new URL("../../import_map.json", import.meta.url).toString(),
|
||||||
loader: "native",
|
loader: "native",
|
||||||
}),
|
}),
|
||||||
],
|
],
|
|
@ -1,8 +1,8 @@
|
||||||
import { Hook, Manifest } from "../types.ts";
|
import { Hook, Manifest } from "../types.ts";
|
||||||
import { System } from "../system.ts";
|
import { System } from "../system.ts";
|
||||||
import { MQMessage } from "$sb/types.ts";
|
import { MQMessage } from "$type/types.ts";
|
||||||
import { MessageQueue } from "../lib/mq.ts";
|
import { MessageQueue } from "$lib/data/mq.ts";
|
||||||
import { throttle } from "$sb/lib/async.ts";
|
import { throttle } from "$lib/async.ts";
|
||||||
|
|
||||||
type MQSubscription = {
|
type MQSubscription = {
|
||||||
queue: string;
|
queue: string;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue