parent
ec858b8b8f
commit
e919aa82e9
|
@ -10,7 +10,7 @@ import { CodeWidgetHook } from "../web/hooks/code_widget.ts";
|
|||
import { PanelWidgetHook } from "../web/hooks/panel_widget.ts";
|
||||
import { SlashCommandHook } from "../web/hooks/slash_command.ts";
|
||||
import { DataStoreMQ } from "$lib/data/mq.datastore.ts";
|
||||
import { ParseTree } from "$lib/tree.ts";
|
||||
import { ParseTree } from "../plug-api/lib/tree.ts";
|
||||
|
||||
export abstract class CommonSystem {
|
||||
system!: System<SilverBulletHooks>;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Hook, Manifest } from "../../lib/plugos/types.ts";
|
||||
import { System } from "../../lib/plugos/system.ts";
|
||||
import { EventEmitter } from "../../lib/plugos/event.ts";
|
||||
import { ObjectValue } from "../../type/types.ts";
|
||||
import { ObjectValue } from "../../plug-api/types.ts";
|
||||
import {
|
||||
FrontmatterConfig,
|
||||
SnippetConfig,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { ParseTree } from "$lib/tree.ts";
|
||||
import type { ParseTree } from "../../plug-api/lib/tree.ts";
|
||||
import type { Language, SyntaxNode } from "../deps.ts";
|
||||
|
||||
export function lezerToParseTree(
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import { parse } from "./parse_tree.ts";
|
||||
import { collectNodesOfType, findNodeOfType, renderToText } from "$lib/tree.ts";
|
||||
import {
|
||||
collectNodesOfType,
|
||||
findNodeOfType,
|
||||
renderToText,
|
||||
} from "$sb/lib/tree.ts";
|
||||
import { assertEquals, assertNotEquals } from "$lib/test_deps.ts";
|
||||
import { extendedMarkdownLanguage } from "./parser.ts";
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { FunctionMap } from "../type/types.ts";
|
||||
import { FunctionMap } from "../plug-api/types.ts";
|
||||
import { builtinFunctions } from "../lib/builtin_query_functions.ts";
|
||||
import { System } from "../lib/plugos/system.ts";
|
||||
import { Query } from "../type/types.ts";
|
||||
import { Query } from "../plug-api/types.ts";
|
||||
import { LimitedMap } from "$lib/limited_map.ts";
|
||||
|
||||
const pageCacheTtl = 10 * 1000; // 10s
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { YAML } from "./deps.ts";
|
||||
import { INDEX_TEMPLATE, SETTINGS_TEMPLATE } from "./PAGE_TEMPLATES.ts";
|
||||
import { SpacePrimitives } from "./spaces/space_primitives.ts";
|
||||
import { expandPropertyNames } from "../lib/json.ts";
|
||||
import { expandPropertyNames } from "../plug-api/lib/json.ts";
|
||||
import type { BuiltinSettings } from "../type/web.ts";
|
||||
|
||||
const yamlSettingsRegex = /^(```+|~~~+)ya?ml\r?\n([\S\s]+)\1/m;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { SpacePrimitives } from "$common/spaces/space_primitives.ts";
|
||||
import { plugPrefix } from "$common/spaces/constants.ts";
|
||||
|
||||
import { AttachmentMeta, FileMeta, PageMeta } from "../type/types.ts";
|
||||
import { AttachmentMeta, FileMeta, PageMeta } from "../plug-api/types.ts";
|
||||
import { EventHook } from "./hooks/event.ts";
|
||||
import { safeRun } from "../lib/async.ts";
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { System } from "../lib/plugos/system.ts";
|
||||
import { ParseTree } from "$lib/tree.ts";
|
||||
import { ParseTree } from "../plug-api/lib/tree.ts";
|
||||
import { ScriptObject } from "../plugs/index/script.ts";
|
||||
import { AppCommand, CommandDef } from "./hooks/command.ts";
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { SpacePrimitives } from "./space_primitives.ts";
|
||||
import { AssetBundle } from "../../lib/asset_bundle/bundle.ts";
|
||||
import { FileMeta } from "../../type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
|
||||
export class AssetBundlePlugSpacePrimitives implements SpacePrimitives {
|
||||
constructor(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import type { SpacePrimitives } from "./space_primitives.ts";
|
||||
import { KvKey } from "$type/types.ts";
|
||||
import { KvKey } from "../../plug-api/types.ts";
|
||||
import { KvPrimitives } from "$lib/data/kv_primitives.ts";
|
||||
import { KvMetaSpacePrimitives } from "./kv_meta_space_primitives.ts";
|
||||
import { PrefixedKvPrimitives } from "$lib/data/prefixed_kv_primitives.ts";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { SpacePrimitives } from "./space_primitives.ts";
|
||||
import { mime } from "mimetypes";
|
||||
import { FileMeta } from "$type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
import { DataStore } from "$lib/data/datastore.ts";
|
||||
|
||||
export type FileContent = {
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as path from "https://deno.land/std@0.189.0/path/mod.ts";
|
|||
import { readAll } from "https://deno.land/std@0.165.0/streams/conversion.ts";
|
||||
import { SpacePrimitives } from "./space_primitives.ts";
|
||||
import { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts";
|
||||
import { FileMeta } from "$type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
|
||||
function lookupContentType(path: string): string {
|
||||
return mime.getType(path) || "application/octet-stream";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FileMeta } from "../../type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
import {
|
||||
base32Decode,
|
||||
base32Encode,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FileMeta } from "../../type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
import { EventHook } from "../hooks/event.ts";
|
||||
|
||||
import type { SpacePrimitives } from "./space_primitives.ts";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FileMeta } from "../../type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
import type { SpacePrimitives } from "./space_primitives.ts";
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FileMeta } from "../../type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
import { SpacePrimitives } from "./space_primitives.ts";
|
||||
|
||||
export class FilteredSpacePrimitives implements SpacePrimitives {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { SpacePrimitives } from "./space_primitives.ts";
|
||||
import { FileMeta } from "../../type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
import { flushCachesAndUnregisterServiceWorker } from "../sw_util.ts";
|
||||
|
||||
export class HttpSpacePrimitives implements SpacePrimitives {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FileMeta } from "$type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
import { mime } from "mimetypes";
|
||||
import { KvPrimitives } from "$lib/data/kv_primitives.ts";
|
||||
import { SpacePrimitives } from "./space_primitives.ts";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { SpacePrimitives } from "$common/spaces/space_primitives.ts";
|
||||
import { FileMeta } from "../../type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
import {
|
||||
NamespaceOperation,
|
||||
PlugNamespaceHook,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FileMeta } from "../../type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
import { SpacePrimitives } from "./space_primitives.ts";
|
||||
|
||||
export class ReadOnlySpacePrimitives implements SpacePrimitives {
|
||||
|
|
|
@ -4,7 +4,7 @@ import type { ClientOptions } from "https://deno.land/x/s3_lite_client@0.4.0/cli
|
|||
import { KvMetaSpacePrimitives } from "./kv_meta_space_primitives.ts";
|
||||
import { KvPrimitives } from "$lib/data/kv_primitives.ts";
|
||||
import { mime } from "../deps.ts";
|
||||
import { KV, KvKey } from "$type/types.ts";
|
||||
import { KV, KvKey } from "../../plug-api/types.ts";
|
||||
import { PrefixedKvPrimitives } from "$lib/data/prefixed_kv_primitives.ts";
|
||||
|
||||
export type S3SpacePrimitivesOptions = ClientOptions;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { FileMeta } from "../../type/types.ts";
|
||||
import type { FileMeta } from "../../plug-api/types.ts";
|
||||
|
||||
/**
|
||||
* 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 { SpacePrimitives } from "./space_primitives.ts";
|
||||
import { EventEmitter } from "../../lib/plugos/event.ts";
|
||||
import { FileMeta } from "../../type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
import { plugPrefix } from "./constants.ts";
|
||||
|
||||
type SyncHash = number;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { SysCallMapping } from "../../lib/plugos/system.ts";
|
||||
import { parse } from "../markdown_parser/parse_tree.ts";
|
||||
import type { ParseTree } from "$lib/tree.ts";
|
||||
import type { ParseTree } from "../../plug-api/lib/tree.ts";
|
||||
import { builtinLanguages, languageFor } from "../languages.ts";
|
||||
|
||||
export function languageSyscalls(): SysCallMapping {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { SysCallMapping } from "../../lib/plugos/system.ts";
|
||||
import { parse } from "../markdown_parser/parse_tree.ts";
|
||||
import type { ParseTree } from "$lib/tree.ts";
|
||||
import type { ParseTree } from "../../plug-api/lib/tree.ts";
|
||||
import { extendedMarkdownLanguage } from "../markdown_parser/parser.ts";
|
||||
|
||||
export function markdownSyscalls(): SysCallMapping {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { SyscallMeta } from "../../type/types.ts";
|
||||
import { SyscallMeta } from "../../plug-api/types.ts";
|
||||
import { SysCallMapping, System } from "../../lib/plugos/system.ts";
|
||||
import type { Client } from "../../web/client.ts";
|
||||
import { CommandDef } from "../hooks/command.ts";
|
||||
import { proxySyscall } from "../../web/syscalls/util.ts";
|
||||
import type { CommonSystem } from "../common_system.ts";
|
||||
import { version } from "../../version.ts";
|
||||
import { ParseTree } from "$lib/tree.ts";
|
||||
import { ParseTree } from "../../plug-api/lib/tree.ts";
|
||||
|
||||
export function systemSyscalls(
|
||||
system: System<any>,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { FunctionMap } from "$type/types.ts";
|
||||
import { AST } from "$lib/tree.ts";
|
||||
import { FunctionMap } from "../../plug-api/types.ts";
|
||||
import { AST } from "../../plug-api/lib/tree.ts";
|
||||
import { SysCallMapping } from "$lib/plugos/system.ts";
|
||||
import { renderTemplate } from "$common/template/render.ts";
|
||||
import { parseTemplate } from "$common/template/template_parser.ts";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { AST } from "$lib/tree.ts";
|
||||
import { AST } from "../../plug-api/lib/tree.ts";
|
||||
import { evalQueryExpression } from "$sb/lib/query_expression.ts";
|
||||
import { expressionToKvQueryExpression } from "$sb/lib/parse-query.ts";
|
||||
import { FunctionMap } from "../../type/types.ts";
|
||||
import { FunctionMap } from "../../plug-api/types.ts";
|
||||
import { jsonToMDTable } from "../../plugs/template/util.ts";
|
||||
|
||||
export async function renderTemplate(
|
||||
|
|
|
@ -4,8 +4,8 @@ import { parse } from "../markdown_parser/parse_tree.ts";
|
|||
import { parser as templateParser } from "./parse-template.js";
|
||||
import { parser as expressionParser } from "../markdown_parser/parse-expression.js";
|
||||
import { parser as queryParser } from "../markdown_parser/parse-query.js";
|
||||
import { AST, parseTreeToAST } from "$lib/tree.ts";
|
||||
import { deepEqual } from "../../lib/json.ts";
|
||||
import { AST, parseTreeToAST } from "../../plug-api/lib/tree.ts";
|
||||
import { deepEqual } from "../../plug-api/lib/json.ts";
|
||||
|
||||
export const templateLanguage = LRLanguage.define({
|
||||
name: "template",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { FunctionMap } from "../type/types.ts";
|
||||
import type { FunctionMap } from "../plug-api/types.ts";
|
||||
import { niceDate, niceTime } from "./dates.ts";
|
||||
|
||||
export const builtinFunctions: FunctionMap = {
|
||||
|
|
|
@ -5,7 +5,7 @@ import { DenoKvPrimitives } from "../data/deno_kv_primitives.ts";
|
|||
import { KvPrimitives } from "../data/kv_primitives.ts";
|
||||
import { assertEquals } from "https://deno.land/std@0.165.0/testing/asserts.ts";
|
||||
import { PrefixedKvPrimitives } from "../data/prefixed_kv_primitives.ts";
|
||||
import { Query } from "$type/types.ts";
|
||||
import { Query } from "../../plug-api/types.ts";
|
||||
|
||||
async function test(db: KvPrimitives) {
|
||||
const datastore = new DataStore(new PrefixedKvPrimitives(db, ["ds"]), {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { applyQueryNoFilterKV } from "$sb/lib/query.ts";
|
||||
import { FunctionMap, KV, KvKey, KvQuery } from "$type/types.ts";
|
||||
import { FunctionMap, KV, KvKey, KvQuery } from "../../plug-api/types.ts";
|
||||
import { builtinFunctions } from "$lib/builtin_query_functions.ts";
|
||||
import { KvPrimitives } from "./kv_primitives.ts";
|
||||
import { evalQueryExpression } from "$sb/lib/query_expression.ts";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference lib="deno.unstable" />
|
||||
|
||||
import { KV, KvKey } from "$type/types.ts";
|
||||
import { KV, KvKey } from "../../plug-api/types.ts";
|
||||
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
||||
|
||||
const kvBatchSize = 100;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { KV, KvKey } from "$type/types.ts";
|
||||
import { KV, KvKey } from "../../plug-api/types.ts";
|
||||
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
||||
import {
|
||||
createClient,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { KV, KvKey } from "$type/types.ts";
|
||||
import { KV, KvKey } from "../../plug-api/types.ts";
|
||||
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
||||
import { IDBPDatabase, openDB } from "https://esm.sh/idb@7.1.1/with-async-ittr";
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { KvPrimitives } from "./kv_primitives.ts";
|
||||
import { assertEquals } from "$lib/test_deps.ts";
|
||||
import { KV } from "$type/types.ts";
|
||||
import { KV } from "../../plug-api/types.ts";
|
||||
|
||||
export async function allTests(db: KvPrimitives) {
|
||||
await db.batchSet([
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { KV, KvKey } from "$type/types.ts";
|
||||
import { KV, KvKey } from "../../plug-api/types.ts";
|
||||
|
||||
export type KvQueryOptions = {
|
||||
prefix?: KvKey;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { KV, KvKey } from "$type/types.ts";
|
||||
import { KV, KvKey } from "../../plug-api/types.ts";
|
||||
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
||||
|
||||
const memoryKeySeparator = "\0";
|
||||
|
|
|
@ -4,7 +4,7 @@ import { DenoKvPrimitives } from "./deno_kv_primitives.ts";
|
|||
import { DataStore } from "./datastore.ts";
|
||||
import { PrefixedKvPrimitives } from "./prefixed_kv_primitives.ts";
|
||||
import { FakeTime } from "$std/testing/time.ts";
|
||||
import type { MQMessage } from "$type/types.ts";
|
||||
import type { MQMessage } from "../../plug-api/types.ts";
|
||||
|
||||
Deno.test("DataStore MQ", async () => {
|
||||
const time = new FakeTime();
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
import { KV, MQMessage, MQStats, MQSubscribeOptions } from "$type/types.ts";
|
||||
import {
|
||||
KV,
|
||||
MQMessage,
|
||||
MQStats,
|
||||
MQSubscribeOptions,
|
||||
} from "../../plug-api/types.ts";
|
||||
import { MessageQueue } from "./mq.ts";
|
||||
import { DataStore } from "./datastore.ts";
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import { MQMessage, MQStats, MQSubscribeOptions } from "$type/types.ts";
|
||||
import {
|
||||
MQMessage,
|
||||
MQStats,
|
||||
MQSubscribeOptions,
|
||||
} from "../../plug-api/types.ts";
|
||||
|
||||
export interface MessageQueue {
|
||||
batchSend(queue: string, bodies: any[]): Promise<void>;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { KV, KvKey } from "$type/types.ts";
|
||||
import { KV, KvKey } from "../../plug-api/types.ts";
|
||||
import { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
import { assertEquals } from "$lib/test_deps.ts";
|
||||
import { deepEqual, deepObjectMerge, expandPropertyNames } from "./json.ts";
|
||||
|
||||
Deno.test("utils", () => {
|
||||
assertEquals(deepEqual({ a: 1 }, { a: 1 }), true);
|
||||
assertEquals(deepObjectMerge({ a: 1 }, { a: 2 }), { a: 2 });
|
||||
assertEquals(
|
||||
deepObjectMerge({ list: [1, 2, 3] }, { list: [4, 5, 6] }),
|
||||
{ list: [1, 2, 3, 4, 5, 6] },
|
||||
);
|
||||
assertEquals(deepObjectMerge({ a: { b: 1 } }, { a: { c: 2 } }), {
|
||||
a: { b: 1, c: 2 },
|
||||
});
|
||||
assertEquals(expandPropertyNames({ "a.b": 1 }), { a: { b: 1 } });
|
||||
assertEquals(expandPropertyNames({ a: { "a.b": 1 } }), {
|
||||
a: { a: { b: 1 } },
|
||||
});
|
||||
assertEquals(expandPropertyNames({ a: [{ "a.b": 1 }] }), {
|
||||
a: [{ a: { b: 1 } }],
|
||||
});
|
||||
});
|
86
lib/json.ts
86
lib/json.ts
|
@ -1,86 +0,0 @@
|
|||
// Compares two objects deeply
|
||||
export function deepEqual(a: any, b: any): boolean {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
if (typeof a !== typeof b) {
|
||||
return false;
|
||||
}
|
||||
if (typeof a === "object") {
|
||||
if (Array.isArray(a) && Array.isArray(b)) {
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (!deepEqual(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
const aKeys = Object.keys(a);
|
||||
const bKeys = Object.keys(b);
|
||||
if (aKeys.length !== bKeys.length) {
|
||||
return false;
|
||||
}
|
||||
for (const key of aKeys) {
|
||||
if (!deepEqual(a[key], b[key])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Expands property names in an object containing a .-separated path
|
||||
export function expandPropertyNames(a: any): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (typeof a !== "object") {
|
||||
return a;
|
||||
}
|
||||
if (Array.isArray(a)) {
|
||||
return a.map(expandPropertyNames);
|
||||
}
|
||||
const expanded: any = {};
|
||||
for (const key of Object.keys(a)) {
|
||||
const parts = key.split(".");
|
||||
let target = expanded;
|
||||
for (let i = 0; i < parts.length - 1; i++) {
|
||||
const part = parts[i];
|
||||
if (!target[part]) {
|
||||
target[part] = {};
|
||||
}
|
||||
target = target[part];
|
||||
}
|
||||
target[parts[parts.length - 1]] = expandPropertyNames(a[key]);
|
||||
}
|
||||
return expanded;
|
||||
}
|
||||
|
||||
export function deepObjectMerge(a: any, b: any): any {
|
||||
if (typeof a !== typeof b) {
|
||||
return b;
|
||||
}
|
||||
if (typeof a === "object") {
|
||||
if (Array.isArray(a) && Array.isArray(b)) {
|
||||
return [...a, ...b];
|
||||
} else {
|
||||
const aKeys = Object.keys(a);
|
||||
const bKeys = Object.keys(b);
|
||||
const merged = { ...a };
|
||||
for (const key of bKeys) {
|
||||
if (aKeys.includes(key)) {
|
||||
merged[key] = deepObjectMerge(a[key], b[key]);
|
||||
} else {
|
||||
merged[key] = b[key];
|
||||
}
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { Hook, Manifest } from "../types.ts";
|
||||
import { System } from "../system.ts";
|
||||
import { MQMessage } from "$type/types.ts";
|
||||
import { MQMessage } from "../../../plug-api/types.ts";
|
||||
import { MessageQueue } from "$lib/data/mq.ts";
|
||||
import { throttle } from "$lib/async.ts";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { KV, KvKey, KvQuery } from "$type/types.ts";
|
||||
import { KV, KvKey, KvQuery } from "../../../plug-api/types.ts";
|
||||
import type { DataStore } from "$lib/data/datastore.ts";
|
||||
import type { SysCallMapping } from "../system.ts";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FileMeta } from "../../../type/types.ts";
|
||||
import { FileMeta } from "../../../plug-api/types.ts";
|
||||
import { assert } from "$lib/test_deps.ts";
|
||||
import { path } from "../deps.ts";
|
||||
import fileSystemSyscalls from "./fs.deno.ts";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { SysCallMapping } from "../system.ts";
|
||||
import { mime, path, walk } from "../deps.ts";
|
||||
import { FileMeta } from "../../../type/types.ts";
|
||||
import { FileMeta } from "../../../plug-api/types.ts";
|
||||
import { base64DecodeDataUrl, base64Encode } from "../../crypto.ts";
|
||||
|
||||
export default function fileSystemSyscalls(root = "/"): SysCallMapping {
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
// import { parse } from "./parse_tree.ts";
|
||||
import {
|
||||
addParentPointers,
|
||||
collectNodesMatching,
|
||||
findParentMatching,
|
||||
nodeAtPos,
|
||||
parseTreeToAST,
|
||||
removeParentPointers,
|
||||
renderToText,
|
||||
replaceNodesMatching,
|
||||
} from "./tree.ts";
|
||||
import { assertEquals, assertNotEquals } from "$lib/test_deps.ts";
|
||||
import { parse } from "$common/markdown_parser/parse_tree.ts";
|
||||
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
|
||||
|
||||
const mdTest1 = `
|
||||
# Heading
|
||||
## Sub _heading_ cool
|
||||
|
||||
Hello, this is some **bold** text and *italic*. And [a link](http://zef.me).
|
||||
|
||||
%% My comment here
|
||||
%% And second line
|
||||
|
||||
And an @mention
|
||||
|
||||
http://zef.plus
|
||||
|
||||
- This is a list [[PageLink]]
|
||||
- With another item
|
||||
- TODOs:
|
||||
- [ ] A task that's not yet done
|
||||
- [x] Hello
|
||||
- And a _third_ one [[Wiki Page]] yo
|
||||
`;
|
||||
|
||||
const mdTest2 = `
|
||||
Hello
|
||||
|
||||
* Item 1
|
||||
*
|
||||
|
||||
Sup`;
|
||||
|
||||
const mdTest3 = `
|
||||
\`\`\`yaml
|
||||
name: something
|
||||
\`\`\`
|
||||
`;
|
||||
|
||||
Deno.test("Test parsing", () => {
|
||||
const mdTree = parse(extendedMarkdownLanguage, mdTest1);
|
||||
addParentPointers(mdTree);
|
||||
// console.log(JSON.stringify(mdTree, null, 2));
|
||||
const wikiLink = nodeAtPos(mdTree, mdTest1.indexOf("Wiki Page"))!;
|
||||
assertEquals(wikiLink.type, "WikiLinkPage");
|
||||
assertNotEquals(
|
||||
findParentMatching(wikiLink, (n) => n.type === "BulletList"),
|
||||
null,
|
||||
);
|
||||
|
||||
const allTodos = collectNodesMatching(mdTree, (n) => n.type === "Task");
|
||||
assertEquals(allTodos.length, 2);
|
||||
|
||||
// Render back into markdown should be equivalent
|
||||
assertEquals(renderToText(mdTree), mdTest1);
|
||||
|
||||
removeParentPointers(mdTree);
|
||||
replaceNodesMatching(mdTree, (n) => {
|
||||
if (n.type === "Task") {
|
||||
return {
|
||||
type: "Tosk",
|
||||
};
|
||||
}
|
||||
});
|
||||
// console.log(JSON.stringify(mdTree, null, 2));
|
||||
let mdTree3 = parse(extendedMarkdownLanguage, mdTest3);
|
||||
// console.log(JSON.stringify(mdTree3, null, 2));
|
||||
});
|
||||
|
||||
Deno.test("AST functions", () => {
|
||||
const mdTree = parse(extendedMarkdownLanguage, mdTest1);
|
||||
console.log(JSON.stringify(parseTreeToAST(mdTree), null, 2));
|
||||
});
|
237
lib/tree.ts
237
lib/tree.ts
|
@ -1,237 +0,0 @@
|
|||
export type ParseTree = {
|
||||
type?: string; // undefined === text node
|
||||
from?: number;
|
||||
to?: number;
|
||||
text?: string;
|
||||
children?: ParseTree[];
|
||||
// Only present after running addParentPointers
|
||||
parent?: ParseTree;
|
||||
};
|
||||
|
||||
export type AST = [string, ...AST[]] | string;
|
||||
|
||||
export function addParentPointers(tree: ParseTree) {
|
||||
if (!tree.children) {
|
||||
return;
|
||||
}
|
||||
for (const child of tree.children) {
|
||||
if (child.parent) {
|
||||
// Already added parent pointers before
|
||||
return;
|
||||
}
|
||||
child.parent = tree;
|
||||
addParentPointers(child);
|
||||
}
|
||||
}
|
||||
|
||||
export function removeParentPointers(tree: ParseTree) {
|
||||
delete tree.parent;
|
||||
if (!tree.children) {
|
||||
return;
|
||||
}
|
||||
for (const child of tree.children) {
|
||||
removeParentPointers(child);
|
||||
}
|
||||
}
|
||||
|
||||
export function findParentMatching(
|
||||
tree: ParseTree,
|
||||
matchFn: (tree: ParseTree) => boolean,
|
||||
): ParseTree | null {
|
||||
let node = tree.parent;
|
||||
while (node) {
|
||||
if (matchFn(node)) {
|
||||
return node;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function collectNodesOfType(
|
||||
tree: ParseTree,
|
||||
nodeType: string,
|
||||
): ParseTree[] {
|
||||
return collectNodesMatching(tree, (n) => n.type === nodeType);
|
||||
}
|
||||
|
||||
export function collectNodesMatching(
|
||||
tree: ParseTree,
|
||||
matchFn: (tree: ParseTree) => boolean,
|
||||
): ParseTree[] {
|
||||
if (matchFn(tree)) {
|
||||
return [tree];
|
||||
}
|
||||
let results: ParseTree[] = [];
|
||||
if (tree.children) {
|
||||
for (const child of tree.children) {
|
||||
results = [...results, ...collectNodesMatching(child, matchFn)];
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
export async function collectNodesMatchingAsync(
|
||||
tree: ParseTree,
|
||||
matchFn: (tree: ParseTree) => Promise<boolean>,
|
||||
): Promise<ParseTree[]> {
|
||||
if (await matchFn(tree)) {
|
||||
return [tree];
|
||||
}
|
||||
let results: ParseTree[] = [];
|
||||
if (tree.children) {
|
||||
for (const child of tree.children) {
|
||||
results = [
|
||||
...results,
|
||||
...await collectNodesMatchingAsync(child, matchFn),
|
||||
];
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
// return value: returning undefined = not matched, continue, null = delete, new node = replace
|
||||
export function replaceNodesMatching(
|
||||
tree: ParseTree,
|
||||
substituteFn: (tree: ParseTree) => ParseTree | null | undefined,
|
||||
) {
|
||||
if (tree.children) {
|
||||
const children = tree.children.slice();
|
||||
for (const child of children) {
|
||||
const subst = substituteFn(child);
|
||||
if (subst !== undefined) {
|
||||
const pos = tree.children.indexOf(child);
|
||||
if (subst) {
|
||||
tree.children.splice(pos, 1, subst);
|
||||
} else {
|
||||
// null = delete
|
||||
tree.children.splice(pos, 1);
|
||||
}
|
||||
} else {
|
||||
replaceNodesMatching(child, substituteFn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function replaceNodesMatchingAsync(
|
||||
tree: ParseTree,
|
||||
substituteFn: (tree: ParseTree) => Promise<ParseTree | null | undefined>,
|
||||
) {
|
||||
if (tree.children) {
|
||||
const children = tree.children.slice();
|
||||
for (const child of children) {
|
||||
const subst = await substituteFn(child);
|
||||
if (subst !== undefined) {
|
||||
const pos = tree.children.indexOf(child);
|
||||
if (subst) {
|
||||
tree.children.splice(pos, 1, subst);
|
||||
} else {
|
||||
// null = delete
|
||||
tree.children.splice(pos, 1);
|
||||
}
|
||||
} else {
|
||||
await replaceNodesMatchingAsync(child, substituteFn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function findNodeMatching(
|
||||
tree: ParseTree,
|
||||
matchFn: (tree: ParseTree) => boolean,
|
||||
): ParseTree | null {
|
||||
return collectNodesMatching(tree, matchFn)[0];
|
||||
}
|
||||
|
||||
export function findNodeOfType(
|
||||
tree: ParseTree,
|
||||
nodeType: string,
|
||||
): ParseTree | null {
|
||||
return collectNodesMatching(tree, (n) => n.type === nodeType)[0];
|
||||
}
|
||||
|
||||
export function traverseTree(
|
||||
tree: ParseTree,
|
||||
// Return value = should stop traversal?
|
||||
matchFn: (tree: ParseTree) => boolean,
|
||||
): void {
|
||||
// Do a collect, but ignore the result
|
||||
collectNodesMatching(tree, matchFn);
|
||||
}
|
||||
|
||||
export async function traverseTreeAsync(
|
||||
tree: ParseTree,
|
||||
// Return value = should stop traversal?
|
||||
matchFn: (tree: ParseTree) => Promise<boolean>,
|
||||
): Promise<void> {
|
||||
// Do a collect, but ignore the result
|
||||
await collectNodesMatchingAsync(tree, matchFn);
|
||||
}
|
||||
|
||||
// Finds non-text node at position
|
||||
export function nodeAtPos(tree: ParseTree, pos: number): ParseTree | null {
|
||||
if (pos < tree.from! || pos >= tree.to!) {
|
||||
return null;
|
||||
}
|
||||
if (!tree.children) {
|
||||
return tree;
|
||||
}
|
||||
for (const child of tree.children) {
|
||||
const n = nodeAtPos(child, pos);
|
||||
if (n && n.text !== undefined) {
|
||||
// Got a text node, let's return its parent
|
||||
return tree;
|
||||
} else if (n) {
|
||||
// Got it
|
||||
return n;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Turn ParseTree back into text
|
||||
export function renderToText(tree?: ParseTree): string {
|
||||
if (!tree) {
|
||||
return "";
|
||||
}
|
||||
const pieces: string[] = [];
|
||||
if (tree.text !== undefined) {
|
||||
return tree.text;
|
||||
}
|
||||
for (const child of tree.children!) {
|
||||
pieces.push(renderToText(child));
|
||||
}
|
||||
return pieces.join("");
|
||||
}
|
||||
|
||||
export function cloneTree(tree: ParseTree): ParseTree {
|
||||
const newTree = { ...tree };
|
||||
if (tree.children) {
|
||||
newTree.children = tree.children.map(cloneTree);
|
||||
}
|
||||
delete newTree.parent;
|
||||
return newTree;
|
||||
}
|
||||
|
||||
export function parseTreeToAST(tree: ParseTree, omitTrimmable = true): AST {
|
||||
const parseErrorNodes = collectNodesOfType(tree, "⚠");
|
||||
if (parseErrorNodes.length > 0) {
|
||||
throw new Error(
|
||||
`Parse error in: ${renderToText(tree)}`,
|
||||
);
|
||||
}
|
||||
if (tree.text !== undefined) {
|
||||
return tree.text;
|
||||
}
|
||||
const ast: AST = [tree.type!];
|
||||
for (const node of tree.children!) {
|
||||
if (node.type && !node.type.endsWith("Mark")) {
|
||||
ast.push(parseTreeToAST(node, omitTrimmable));
|
||||
}
|
||||
if (node.text && (omitTrimmable && node.text.trim() || !omitTrimmable)) {
|
||||
ast.push(node.text);
|
||||
}
|
||||
}
|
||||
return ast;
|
||||
}
|
|
@ -2,7 +2,7 @@ import "$sb/lib/syscall_mock.ts";
|
|||
import { parse } from "$common/markdown_parser/parse_tree.ts";
|
||||
import { extractAttributes } from "$sb/lib/attribute.ts";
|
||||
import { assertEquals } from "$lib/test_deps.ts";
|
||||
import { renderToText } from "$lib/tree.ts";
|
||||
import { renderToText } from "./tree.ts";
|
||||
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
|
||||
|
||||
const inlineAttributeSample = `
|
||||
|
|
|
@ -3,7 +3,7 @@ import {
|
|||
ParseTree,
|
||||
renderToText,
|
||||
replaceNodesMatchingAsync,
|
||||
} from "$lib/tree.ts";
|
||||
} from "./tree.ts";
|
||||
|
||||
import { system, YAML } from "$sb/syscalls.ts";
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import {
|
|||
findNodeOfType,
|
||||
ParseTree,
|
||||
renderToText,
|
||||
} from "$lib/tree.ts";
|
||||
} from "./tree.ts";
|
||||
|
||||
/**
|
||||
* Feed parsing functionality (WIP)
|
||||
|
|
|
@ -4,8 +4,8 @@ import {
|
|||
renderToText,
|
||||
replaceNodesMatchingAsync,
|
||||
traverseTreeAsync,
|
||||
} from "$lib/tree.ts";
|
||||
import { expandPropertyNames } from "$lib/json.ts";
|
||||
} from "./tree.ts";
|
||||
import { expandPropertyNames } from "./json.ts";
|
||||
import { YAML } from "$sb/syscalls.ts";
|
||||
|
||||
export type FrontMatter = { tags?: string[] } & Record<string, any>;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { type AST, parseTreeToAST } from "$lib/tree.ts";
|
||||
import type { Query, QueryExpression } from "../../type/types.ts";
|
||||
import { type AST, parseTreeToAST } from "./tree.ts";
|
||||
import type { Query, QueryExpression } from "../types.ts";
|
||||
import { language } from "$sb/syscalls.ts";
|
||||
|
||||
export function astToKvQuery(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { parse } from "$common/markdown_parser/parse_tree.ts";
|
||||
import { AST, collectNodesOfType, parseTreeToAST } from "$lib/tree.ts";
|
||||
import { AST, collectNodesOfType, parseTreeToAST } from "$sb/lib/tree.ts";
|
||||
import { assert, assertEquals } from "$lib/test_deps.ts";
|
||||
import { astToKvQuery } from "$sb/lib/parse-query.ts";
|
||||
import { languageFor } from "$common/languages.ts";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FunctionMap, KV, Query, QueryExpression } from "../../type/types.ts";
|
||||
import { FunctionMap, KV, Query, QueryExpression } from "../types.ts";
|
||||
import { evalQueryExpression } from "$sb/lib/query_expression.ts";
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FunctionMap, QueryExpression } from "../../type/types.ts";
|
||||
import { FunctionMap, QueryExpression } from "../types.ts";
|
||||
|
||||
export function evalQueryExpression(
|
||||
val: QueryExpression,
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
rewritePageRefs,
|
||||
} from "$sb/lib/resolve.ts";
|
||||
import { assertEquals } from "$lib/test_deps.ts";
|
||||
import { ParseTree, renderToText } from "$lib/tree.ts";
|
||||
import { ParseTree, renderToText } from "$sb/lib/tree.ts";
|
||||
import { parse } from "$common/markdown_parser/parse_tree.ts";
|
||||
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { findNodeOfType, ParseTree, traverseTree } from "$lib/tree.ts";
|
||||
import { findNodeOfType, ParseTree, traverseTree } from "./tree.ts";
|
||||
|
||||
export function resolvePath(
|
||||
currentPage: string,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { FrontMatter } from "$sb/lib/frontmatter.ts";
|
||||
import { ObjectValue } from "../../type/types.ts";
|
||||
import { ObjectValue } from "../types.ts";
|
||||
|
||||
export function updateITags<T>(obj: ObjectValue<T>, frontmatter: FrontMatter) {
|
||||
const itags = [obj.tag, ...frontmatter.tags || []];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { findNodeOfType, traverseTree } from "$lib/tree.ts";
|
||||
import { findNodeOfType, traverseTree } from "$sb/lib/tree.ts";
|
||||
import { markdown, space, YAML } from "$sb/syscalls.ts";
|
||||
|
||||
export async function readCodeBlockPage(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { base64DecodeDataUrl } from "$lib/crypto.ts";
|
||||
import { base64DecodeDataUrl } from "../../lib/crypto.ts";
|
||||
import { syscall } from "../syscall.ts";
|
||||
|
||||
export async function readAsset(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { CodeWidgetContent } from "$type/types.ts";
|
||||
import type { CodeWidgetContent } from "../types.ts";
|
||||
import { syscall } from "../syscall.ts";
|
||||
|
||||
export function render(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { syscall } from "$sb/syscall.ts";
|
||||
import { KV, KvKey, KvQuery } from "$type/types.ts";
|
||||
import { KV, KvKey, KvQuery } from "../types.ts";
|
||||
|
||||
export function set(key: KvKey, value: any): Promise<void> {
|
||||
return syscall("datastore.set", key, value);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import type { FilterOption } from "../../type/web.ts";
|
||||
import { UploadFile } from "$type/types.ts";
|
||||
import { UploadFile } from "../types.ts";
|
||||
import { syscall } from "../syscall.ts";
|
||||
import type { PageRef } from "$sb/lib/page_ref.ts";
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { syscall } from "../syscall.ts";
|
||||
|
||||
import type { ParseTree } from "$lib/tree.ts";
|
||||
import type { ParseTree } from "../lib/tree.ts";
|
||||
|
||||
/**
|
||||
* Parses a piece of code using any of the supported SB languages, see `common/languages.ts` for a list
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { syscall } from "../syscall.ts";
|
||||
|
||||
import type { ParseTree } from "$lib/tree.ts";
|
||||
import type { ParseTree } from "../lib/tree.ts";
|
||||
|
||||
export function parseMarkdown(text: string): Promise<ParseTree> {
|
||||
return syscall("markdown.parseMarkdown", text);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { syscall } from "$sb/syscall.ts";
|
||||
import type { MQStats } from "$type/types.ts";
|
||||
import type { MQStats } from "../types.ts";
|
||||
|
||||
export function send(queue: string, body: any) {
|
||||
return syscall("mq.send", queue, body);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { syscall } from "../syscall.ts";
|
||||
import { AttachmentMeta, FileMeta, PageMeta } from "$type/types.ts";
|
||||
import { AttachmentMeta, FileMeta, PageMeta } from "../types.ts";
|
||||
|
||||
export function listPages(unfiltered = false): Promise<PageMeta[]> {
|
||||
return syscall("space.listPages", unfiltered);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { CommandDef } from "$common/hooks/command.ts";
|
||||
import type { SyscallMeta } from "$type/types.ts";
|
||||
import type { ParseTree } from "$lib/tree.ts";
|
||||
import type { SyscallMeta } from "../types.ts";
|
||||
import type { ParseTree } from "../lib/tree.ts";
|
||||
import { syscall } from "../syscall.ts";
|
||||
|
||||
export function invokeFunction(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { system } from "$sb/syscalls.ts";
|
||||
import { CompleteEvent } from "$type/types.ts";
|
||||
import { CompleteEvent } from "../../plug-api/types.ts";
|
||||
|
||||
export async function commandComplete(completeEvent: CompleteEvent) {
|
||||
const match = /\{\[([^\]\[]*)$/.exec(completeEvent.linePrefix);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CompleteEvent, FileMeta, PageMeta } from "$type/types.ts";
|
||||
import { CompleteEvent, FileMeta, PageMeta } from "../../plug-api/types.ts";
|
||||
import { cacheFileListing } from "../federation/federation.ts";
|
||||
import { queryObjects } from "../index/plug_api.ts";
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { YAML } from "$sb/syscalls.ts";
|
||||
import type { WidgetContent } from "$type/types.ts";
|
||||
import type { WidgetContent } from "../../plug-api/types.ts";
|
||||
|
||||
type EmbedConfig = {
|
||||
url: string;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { nodeAtPos } from "$lib/tree.ts";
|
||||
import { nodeAtPos } from "../../plug-api/lib/tree.ts";
|
||||
import { editor, events, markdown } from "$sb/syscalls.ts";
|
||||
import { extractYoutubeVideoId } from "./embed.ts";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { ClickEvent } from "$type/types.ts";
|
||||
import type { ClickEvent } from "../../plug-api/types.ts";
|
||||
import { editor, markdown, system } from "$sb/syscalls.ts";
|
||||
import {
|
||||
addParentPointers,
|
||||
|
@ -6,7 +6,7 @@ import {
|
|||
findParentMatching,
|
||||
nodeAtPos,
|
||||
ParseTree,
|
||||
} from "$lib/tree.ts";
|
||||
} from "$sb/lib/tree.ts";
|
||||
import { resolveAttachmentPath, resolvePath } from "$sb/lib/resolve.ts";
|
||||
import { parsePageRef } from "$sb/lib/page_ref.ts";
|
||||
import { tagPrefix } from "../index/constants.ts";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { editor, space } from "$sb/syscalls.ts";
|
||||
import { UploadFile } from "$type/types.ts";
|
||||
import { UploadFile } from "../../plug-api/types.ts";
|
||||
|
||||
const maximumAttachmentSize = 1024 * 1024 * 10; // 10MB
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import emojiBlob from "./emoji.json" assert { type: "json" };
|
||||
import type { CompleteEvent } from "$type/types.ts";
|
||||
import type { CompleteEvent } from "../../plug-api/types.ts";
|
||||
import { readSetting } from "$sb/lib/settings_page.ts";
|
||||
import { editor } from "$sb/syscalls.ts";
|
||||
import type { EmojiConfig } from "../../type/web.ts";
|
||||
|
|
|
@ -2,7 +2,7 @@ import "$sb/lib/native_fetch.ts";
|
|||
import { federatedPathToUrl } from "$sb/lib/resolve.ts";
|
||||
import { readFederationConfigs } from "./config.ts";
|
||||
import { datastore } from "$sb/syscalls.ts";
|
||||
import type { FileMeta } from "../../type/types.ts";
|
||||
import type { FileMeta } from "../../plug-api/types.ts";
|
||||
|
||||
async function responseToFileMeta(
|
||||
r: Response,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { collectNodesOfType } from "$lib/tree.ts";
|
||||
import type { CompleteEvent, IndexTreeEvent } from "$type/types.ts";
|
||||
import { ObjectValue, QueryExpression } from "$type/types.ts";
|
||||
import { collectNodesOfType } from "$sb/lib/tree.ts";
|
||||
import type { CompleteEvent, IndexTreeEvent } from "../../plug-api/types.ts";
|
||||
import { ObjectValue, QueryExpression } from "../../plug-api/types.ts";
|
||||
import { indexObjects, queryObjects } from "./api.ts";
|
||||
import { parsePageRef } from "$sb/lib/page_ref.ts";
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import {
|
|||
KvQuery,
|
||||
ObjectQuery,
|
||||
ObjectValue,
|
||||
} from "../../type/types.ts";
|
||||
import { QueryProviderEvent } from "$type/types.ts";
|
||||
} from "../../plug-api/types.ts";
|
||||
import { QueryProviderEvent } from "../../plug-api/types.ts";
|
||||
import { builtins } from "./builtins.ts";
|
||||
import { determineType } from "./attributes.ts";
|
||||
import { ttlCache } from "$lib/memory_cache.ts";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import type { CompleteEvent } from "$type/types.ts";
|
||||
import type { CompleteEvent } from "../../plug-api/types.ts";
|
||||
import { events } from "$sb/syscalls.ts";
|
||||
import { queryObjects } from "./api.ts";
|
||||
import { ObjectValue, QueryExpression } from "../../type/types.ts";
|
||||
import { ObjectValue, QueryExpression } from "../../plug-api/types.ts";
|
||||
import { determineTags } from "$lib/cheap_yaml.ts";
|
||||
|
||||
export type AttributeObject = ObjectValue<{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ObjectValue } from "../../type/types.ts";
|
||||
import { ObjectValue } from "../../plug-api/types.ts";
|
||||
import { system } from "$sb/syscalls.ts";
|
||||
import { indexObjects } from "./api.ts";
|
||||
import { QueryProviderEvent } from "$type/types.ts";
|
||||
import { QueryProviderEvent } from "../../plug-api/types.ts";
|
||||
import { applyQuery } from "$sb/lib/query.ts";
|
||||
import { builtinFunctions } from "$lib/builtin_query_functions.ts";
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { editor, events, markdown, mq, space, system } from "$sb/syscalls.ts";
|
||||
import { IndexEvent } from "$type/types.ts";
|
||||
import { MQMessage } from "$type/types.ts";
|
||||
import { IndexEvent } from "../../plug-api/types.ts";
|
||||
import { MQMessage } from "../../plug-api/types.ts";
|
||||
import { isTemplate } from "$lib/cheap_yaml.ts";
|
||||
import { sleep } from "$lib/async.ts";
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import type { IndexTreeEvent } from "$type/types.ts";
|
||||
import type { IndexTreeEvent } from "../../plug-api/types.ts";
|
||||
import { YAML } from "$sb/syscalls.ts";
|
||||
import { collectNodesOfType, findNodeOfType } from "$lib/tree.ts";
|
||||
import { ObjectValue } from "../../type/types.ts";
|
||||
import { collectNodesOfType, findNodeOfType } from "$sb/lib/tree.ts";
|
||||
import { ObjectValue } from "../../plug-api/types.ts";
|
||||
import { indexObjects } from "./api.ts";
|
||||
import { TagObject } from "./tags.ts";
|
||||
import { extractFrontmatter } from "$sb/lib/frontmatter.ts";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { collectNodesMatching } from "$lib/tree.ts";
|
||||
import type { CompleteEvent, IndexTreeEvent } from "$type/types.ts";
|
||||
import { ObjectValue } from "$type/types.ts";
|
||||
import { collectNodesMatching } from "$sb/lib/tree.ts";
|
||||
import type { CompleteEvent, IndexTreeEvent } from "../../plug-api/types.ts";
|
||||
import { ObjectValue } from "../../plug-api/types.ts";
|
||||
import { indexObjects, queryObjects } from "./api.ts";
|
||||
import { parsePageRef } from "$sb/lib/page_ref.ts";
|
||||
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
import type { IndexTreeEvent } from "$type/types.ts";
|
||||
import type { IndexTreeEvent } from "../../plug-api/types.ts";
|
||||
|
||||
import { collectNodesOfType, ParseTree, renderToText } from "$lib/tree.ts";
|
||||
import {
|
||||
collectNodesOfType,
|
||||
ParseTree,
|
||||
renderToText,
|
||||
} from "../../plug-api/lib/tree.ts";
|
||||
import { extractAttributes } from "$sb/lib/attribute.ts";
|
||||
import { rewritePageRefs } from "$sb/lib/resolve.ts";
|
||||
import { ObjectValue } from "$type/types.ts";
|
||||
import { ObjectValue } from "../../plug-api/types.ts";
|
||||
import { indexObjects } from "./api.ts";
|
||||
import { updateITags } from "$sb/lib/tags.ts";
|
||||
import { extractFrontmatter } from "$sb/lib/frontmatter.ts";
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
import { YAML } from "$sb/syscalls.ts";
|
||||
import { LintDiagnostic, QueryExpression } from "../../type/types.ts";
|
||||
import { findNodeOfType, renderToText, traverseTreeAsync } from "$lib/tree.ts";
|
||||
import { LintEvent } from "$type/types.ts";
|
||||
import { LintDiagnostic, QueryExpression } from "../../plug-api/types.ts";
|
||||
import {
|
||||
findNodeOfType,
|
||||
renderToText,
|
||||
traverseTreeAsync,
|
||||
} from "$sb/lib/tree.ts";
|
||||
import { LintEvent } from "../../plug-api/types.ts";
|
||||
import { queryObjects } from "./api.ts";
|
||||
import { AttributeObject } from "./attributes.ts";
|
||||
import { extractFrontmatter } from "$sb/lib/frontmatter.ts";
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
import type { IndexTreeEvent } from "$type/types.ts";
|
||||
import type { IndexTreeEvent } from "../../plug-api/types.ts";
|
||||
import { editor, markdown, space, YAML } from "$sb/syscalls.ts";
|
||||
|
||||
import type { LintDiagnostic, PageMeta } from "../../type/types.ts";
|
||||
import type { LintDiagnostic, PageMeta } from "../../plug-api/types.ts";
|
||||
import { extractFrontmatter } from "$sb/lib/frontmatter.ts";
|
||||
import { extractAttributes } from "$sb/lib/attribute.ts";
|
||||
import { indexObjects } from "./api.ts";
|
||||
import { findNodeOfType, renderToText, traverseTreeAsync } from "$lib/tree.ts";
|
||||
import {
|
||||
findNodeOfType,
|
||||
renderToText,
|
||||
traverseTreeAsync,
|
||||
} from "../../plug-api/lib/tree.ts";
|
||||
import { updateITags } from "$sb/lib/tags.ts";
|
||||
|
||||
export async function indexPage({ name, tree }: IndexTreeEvent) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { findNodeOfType, renderToText, traverseTree } from "$lib/tree.ts";
|
||||
import { IndexTreeEvent } from "$type/types.ts";
|
||||
import { findNodeOfType, renderToText, traverseTree } from "$sb/lib/tree.ts";
|
||||
import { IndexTreeEvent } from "../../plug-api/types.ts";
|
||||
import { resolvePath } from "$sb/lib/resolve.ts";
|
||||
import { indexObjects, queryObjects } from "./api.ts";
|
||||
import { ObjectValue } from "$type/types.ts";
|
||||
import { ObjectValue } from "../../plug-api/types.ts";
|
||||
import { extractFrontmatter } from "$sb/lib/frontmatter.ts";
|
||||
import { updateITags } from "$sb/lib/tags.ts";
|
||||
import { parsePageRef } from "$sb/lib/page_ref.ts";
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import type { IndexTreeEvent } from "$type/types.ts";
|
||||
import type { IndexTreeEvent } from "../../plug-api/types.ts";
|
||||
import { indexObjects } from "./api.ts";
|
||||
import {
|
||||
collectNodesOfType,
|
||||
findParentMatching,
|
||||
renderToText,
|
||||
traverseTreeAsync,
|
||||
} from "$lib/tree.ts";
|
||||
} from "../../plug-api/lib/tree.ts";
|
||||
import { extractAttributes } from "$sb/lib/attribute.ts";
|
||||
import { ObjectValue } from "$type/types.ts";
|
||||
import { ObjectValue } from "../../plug-api/types.ts";
|
||||
import { updateITags } from "$sb/lib/tags.ts";
|
||||
import { extractFrontmatter } from "$sb/lib/frontmatter.ts";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { KV, KvQuery, ObjectQuery, ObjectValue } from "$type/types.ts";
|
||||
import { KV, KvQuery, ObjectQuery, ObjectValue } from "../../plug-api/types.ts";
|
||||
import { ttlCache } from "$lib/memory_cache.ts";
|
||||
import { system } from "$sb/syscalls.ts";
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { IndexTreeEvent } from "$type/types.ts";
|
||||
import { collectNodesOfType, findNodeOfType } from "$lib/tree.ts";
|
||||
import { ObjectValue } from "$type/types.ts";
|
||||
import { IndexTreeEvent } from "../../plug-api/types.ts";
|
||||
import { collectNodesOfType, findNodeOfType } from "../../plug-api/lib/tree.ts";
|
||||
import { ObjectValue } from "../../plug-api/types.ts";
|
||||
import { indexObjects } from "./api.ts";
|
||||
|
||||
export type ScriptObject = ObjectValue<{
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { IndexTreeEvent, ObjectValue } from "$type/types.ts";
|
||||
import { collectNodesMatching, ParseTree } from "$lib/tree.ts";
|
||||
import { IndexTreeEvent, ObjectValue } from "../../plug-api/types.ts";
|
||||
import {
|
||||
collectNodesMatching,
|
||||
collectNodesOfType,
|
||||
ParseTree,
|
||||
} from "$sb/lib/tree.ts";
|
||||
import { indexObjects } from "./api.ts";
|
||||
import { collectNodesOfType } from "$lib/tree.ts";
|
||||
|
||||
type TableRowObject =
|
||||
& ObjectValue<{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { FileMeta } from "$type/types.ts";
|
||||
import { FileMeta } from "../../plug-api/types.ts";
|
||||
import { markdown, system } from "$sb/syscalls.ts";
|
||||
import { renderToText } from "$lib/tree.ts";
|
||||
import { renderToText } from "$sb/lib/tree.ts";
|
||||
import { tagPrefix } from "./constants.ts";
|
||||
|
||||
export async function readFileTag(
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import type { CompleteEvent, IndexTreeEvent } from "$type/types.ts";
|
||||
import type { CompleteEvent, IndexTreeEvent } from "../../plug-api/types.ts";
|
||||
import { extractFrontmatter } from "$sb/lib/frontmatter.ts";
|
||||
import { indexObjects, queryObjects } from "./api.ts";
|
||||
import {
|
||||
addParentPointers,
|
||||
collectNodesOfType,
|
||||
findParentMatching,
|
||||
} from "$lib/tree.ts";
|
||||
import type { ObjectValue } from "../../type/types.ts";
|
||||
} from "$sb/lib/tree.ts";
|
||||
import type { ObjectValue } from "../../plug-api/types.ts";
|
||||
|
||||
export type TagObject = ObjectValue<{
|
||||
name: string;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { editor, markdown, YAML } from "$sb/syscalls.ts";
|
||||
import { CodeWidgetContent } from "../../type/types.ts";
|
||||
import { renderToText, traverseTree } from "$lib/tree.ts";
|
||||
import { CodeWidgetContent } from "../../plug-api/types.ts";
|
||||
import { renderToText, traverseTree } from "$sb/lib/tree.ts";
|
||||
|
||||
type Header = {
|
||||
name: string;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { codeWidget, editor, language, markdown, space } from "$sb/syscalls.ts";
|
||||
import { parseTreeToAST, renderToText } from "$lib/tree.ts";
|
||||
import { CodeWidgetContent } from "$type/types.ts";
|
||||
import { parseTreeToAST, renderToText } from "$sb/lib/tree.ts";
|
||||
import { CodeWidgetContent } from "../../plug-api/types.ts";
|
||||
import { loadPageObject } from "../template/page.ts";
|
||||
import { queryObjects } from "./api.ts";
|
||||
import { TemplateObject, WidgetConfig } from "../template/types.ts";
|
||||
|
|
|
@ -3,7 +3,7 @@ import {
|
|||
ParseTree,
|
||||
renderToText,
|
||||
replaceNodesMatchingAsync,
|
||||
} from "$lib/tree.ts";
|
||||
} from "../../plug-api/lib/tree.ts";
|
||||
import { codeWidget } from "$sb/syscalls.ts";
|
||||
import { parseMarkdown } from "../../plug-api/syscalls/markdown.ts";
|
||||
import {
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
removeParentPointers,
|
||||
renderToText,
|
||||
traverseTree,
|
||||
} from "$lib/tree.ts";
|
||||
} from "../../plug-api/lib/tree.ts";
|
||||
import { encodePageRef, parsePageRef } from "$sb/lib/page_ref.ts";
|
||||
import { Fragment, renderHtml, Tag } from "./html_render.ts";
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue