Refactor and renaming
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import * as plugos from "../plugos/types";
|
||||
import { EndpointHookT } from "../plugos/hooks/endpoint";
|
||||
import { CronHookT } from "../plugos/hooks/node_cron";
|
||||
import { EventHookT } from "../plugos/hooks/event";
|
||||
import * as plugos from "@plugos/plugos/types";
|
||||
import { EndpointHookT } from "@plugos/plugos/hooks/endpoint";
|
||||
import { CronHookT } from "@plugos/plugos/hooks/node_cron";
|
||||
import { EventHookT } from "@plugos/plugos/hooks/event";
|
||||
import { CommandHookT } from "@silverbulletmd/web/hooks/command";
|
||||
import { SlashCommandHookT } from "@silverbulletmd/web/hooks/slash_command";
|
||||
|
||||
+10
-2
@@ -1,8 +1,16 @@
|
||||
import { mkdir, readdir, readFile, stat, unlink, utimes, writeFile } from "fs/promises";
|
||||
import {
|
||||
mkdir,
|
||||
readdir,
|
||||
readFile,
|
||||
stat,
|
||||
unlink,
|
||||
utimes,
|
||||
writeFile,
|
||||
} from "fs/promises";
|
||||
import * as path from "path";
|
||||
import { PageMeta } from "../types";
|
||||
import { SpacePrimitives } from "./space_primitives";
|
||||
import { Plug } from "../../plugos/plug";
|
||||
import { Plug } from "@plugos/plugos/plug";
|
||||
|
||||
export class DiskSpacePrimitives implements SpacePrimitives {
|
||||
rootPath: string;
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { SpacePrimitives } from "./space_primitives";
|
||||
import { EventHook } from "../../plugos/hooks/event";
|
||||
import { EventHook } from "@plugos/plugos/hooks/event";
|
||||
import { PageMeta } from "../types";
|
||||
import { Plug } from "../../plugos/plug";
|
||||
import { Plug } from "@plugos/plugos/plug";
|
||||
import { trashPrefix } from "./constants";
|
||||
|
||||
export class EventedSpacePrimitives implements SpacePrimitives {
|
||||
+1
-2
@@ -1,5 +1,5 @@
|
||||
import { PageMeta } from "../types";
|
||||
import { Plug } from "../../plugos/plug";
|
||||
import { Plug } from "@plugos/plugos/plug";
|
||||
import { SpacePrimitives } from "./space_primitives";
|
||||
|
||||
export class HttpSpacePrimitives implements SpacePrimitives {
|
||||
@@ -7,7 +7,6 @@ export class HttpSpacePrimitives implements SpacePrimitives {
|
||||
private plugUrl: string;
|
||||
|
||||
constructor(url: string) {
|
||||
console.log("UR", url);
|
||||
this.pageUrl = url + "/fs";
|
||||
this.plugUrl = url + "/plug";
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { SpacePrimitives } from "./space_primitives";
|
||||
import { PageMeta } from "../types";
|
||||
import Dexie, { Table } from "dexie";
|
||||
import { Plug } from "../../plugos/plug";
|
||||
import { Plug } from "@plugos/plugos/plug";
|
||||
|
||||
type Page = {
|
||||
name: string;
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SpacePrimitives } from "./space_primitives";
|
||||
import { PageMeta } from "../types";
|
||||
import { EventEmitter } from "../event";
|
||||
import { Plug } from "../../plugos/plug";
|
||||
import { EventEmitter } from "@plugos/plugos/event";
|
||||
import { Plug } from "@plugos/plugos/plug";
|
||||
import { Manifest } from "../manifest";
|
||||
import { plugPrefix, trashPrefix } from "./constants";
|
||||
import { safeRun } from "../util";
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { Plug } from "../../plugos/plug";
|
||||
import { Plug } from "@plugos/plugos/plug";
|
||||
import { PageMeta } from "../types";
|
||||
|
||||
export interface SpacePrimitives {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { SysCallMapping } from "../../plugos/system";
|
||||
import { SysCallMapping } from "@plugos/plugos/system";
|
||||
import { parse } from "../parse_tree";
|
||||
import { Language } from "@codemirror/language";
|
||||
import type { ParseTree } from "../tree";
|
||||
@@ -1,5 +1,5 @@
|
||||
import { syscall } from "./syscall";
|
||||
import { FilterOption } from "../silverbullet-common/types";
|
||||
import { FilterOption } from "../common/types";
|
||||
|
||||
export function getCurrentPage(): Promise<string> {
|
||||
return syscall("editor.getCurrentPage");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { syscall } from "./syscall";
|
||||
|
||||
import type { ParseTree } from "../silverbullet-common/tree";
|
||||
import type { ParseTree } from "../common/tree";
|
||||
|
||||
export async function parseMarkdown(text: string): Promise<ParseTree> {
|
||||
return syscall("markdown.parseMarkdown", text);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"name": "@silverbulletmd/plugos-silverbullet-syscall",
|
||||
"name": "@plugos/plugos-silverbullet-syscall",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { syscall } from "./syscall";
|
||||
import { PageMeta } from "../silverbullet-common/types";
|
||||
import { PageMeta } from "../common/types";
|
||||
|
||||
export async function listPages(): Promise<PageMeta[]> {
|
||||
return syscall("space.listPages");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"name": "@silverbulletmd/plugos-syscall",
|
||||
"name": "@plugos/plugos-syscall",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ import yargs from "yargs";
|
||||
import { hideBin } from "yargs/helpers";
|
||||
import { Manifest } from "../types";
|
||||
import YAML from "yaml";
|
||||
import { preloadModules } from "../../silverbullet-common/preload_modules";
|
||||
import { mkdirSync } from "fs";
|
||||
|
||||
async function compile(
|
||||
filePath: string,
|
||||
functionName: string,
|
||||
debug: boolean,
|
||||
excludeModules: string[],
|
||||
meta = false
|
||||
) {
|
||||
let outFile = "_out.tmp";
|
||||
@@ -40,7 +40,7 @@ async function compile(
|
||||
minify: !debug,
|
||||
outfile: outFile,
|
||||
metafile: true,
|
||||
external: preloadModules,
|
||||
external: excludeModules,
|
||||
});
|
||||
|
||||
if (meta) {
|
||||
@@ -57,7 +57,11 @@ async function compile(
|
||||
return mod;})()`;
|
||||
}
|
||||
|
||||
async function bundle(manifestPath: string, sourceMaps: boolean) {
|
||||
async function bundle(
|
||||
manifestPath: string,
|
||||
sourceMaps: boolean,
|
||||
excludeModules: string[]
|
||||
) {
|
||||
const rootPath = path.dirname(manifestPath);
|
||||
const manifest = YAML.parse(
|
||||
(await readFile(manifestPath)).toString()
|
||||
@@ -70,7 +74,12 @@ async function bundle(manifestPath: string, sourceMaps: boolean) {
|
||||
[filePath, jsFunctionName] = filePath.split(":");
|
||||
}
|
||||
|
||||
def.code = await compile(filePath, jsFunctionName, sourceMaps);
|
||||
def.code = await compile(
|
||||
filePath,
|
||||
jsFunctionName,
|
||||
sourceMaps,
|
||||
excludeModules
|
||||
);
|
||||
delete def.path;
|
||||
}
|
||||
return manifest;
|
||||
@@ -79,9 +88,10 @@ async function bundle(manifestPath: string, sourceMaps: boolean) {
|
||||
async function buildManifest(
|
||||
manifestPath: string,
|
||||
distPath: string,
|
||||
debug: boolean
|
||||
debug: boolean,
|
||||
excludeModules: string[]
|
||||
) {
|
||||
let generatedManifest = await bundle(manifestPath, debug);
|
||||
let generatedManifest = await bundle(manifestPath, debug, excludeModules);
|
||||
const outFile =
|
||||
manifestPath.substring(
|
||||
0,
|
||||
@@ -106,20 +116,31 @@ async function run() {
|
||||
type: "string",
|
||||
default: ".",
|
||||
})
|
||||
.option("exclude", {
|
||||
type: "array",
|
||||
default: [],
|
||||
})
|
||||
.parse();
|
||||
if (args._.length === 0) {
|
||||
console.log(
|
||||
"Usage: plugos-bundle [--debug] [--dist <path>] <manifest.plug.yaml> <manifest2.plug.yaml> ..."
|
||||
"Usage: plugos-bundle [--debug] [--dist <path>] [--exclude package1 package2] -- <manifest.plug.yaml> <manifest2.plug.yaml> ..."
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log("Args", args);
|
||||
|
||||
async function buildAll() {
|
||||
mkdirSync(args.dist, { recursive: true });
|
||||
for (const plugManifestPath of args._) {
|
||||
let manifestPath = plugManifestPath as string;
|
||||
try {
|
||||
await buildManifest(manifestPath, args.dist, !!args.debug);
|
||||
await buildManifest(
|
||||
manifestPath,
|
||||
args.dist,
|
||||
!!args.debug,
|
||||
args.exclude
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(`Error building ${manifestPath}:`, e);
|
||||
}
|
||||
|
||||
@@ -36,15 +36,21 @@ class NodeWorkerWrapper implements WorkerLike {
|
||||
}
|
||||
|
||||
// Look for the node_modules directory, to be passed to the worker to find e.g. the vm2 module
|
||||
let nodeModulesDir = __dirname;
|
||||
export let nodeModulesDir = __dirname;
|
||||
while (!fs.existsSync(nodeModulesDir + "/node_modules/vm2")) {
|
||||
nodeModulesDir = path.dirname(nodeModulesDir);
|
||||
}
|
||||
|
||||
export function createSandbox(plug: Plug<any>) {
|
||||
export function createSandbox(
|
||||
plug: Plug<any>,
|
||||
preloadedModules: string[] = []
|
||||
) {
|
||||
let worker = new Worker(workerCode, {
|
||||
eval: true,
|
||||
workerData: path.join(nodeModulesDir, "node_modules"),
|
||||
workerData: {
|
||||
nodeModulesPath: path.join(nodeModulesDir, "node_modules"),
|
||||
preloadedModules,
|
||||
},
|
||||
});
|
||||
return new Sandbox(plug, new NodeWorkerWrapper(worker));
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { preloadModules } from "../../silverbullet-common/preload_modules";
|
||||
const {
|
||||
parentPort,
|
||||
workerData: { preloadedModules, nodeModulesPath },
|
||||
} = require("worker_threads");
|
||||
|
||||
const { parentPort, workerData } = require("worker_threads");
|
||||
const { VM, VMScript } = require(`${workerData}/vm2`);
|
||||
const fetch = require(`${workerData}/node-fetch`);
|
||||
const WebSocket = require(`${workerData}/ws`);
|
||||
|
||||
// console.log("Process env", process.env);
|
||||
const { VM, VMScript } = require(`${nodeModulesPath}/vm2`);
|
||||
|
||||
let loadedFunctions = new Map<string, Function>();
|
||||
let pendingRequests = new Map<
|
||||
@@ -26,14 +24,14 @@ let vm = new VM({
|
||||
clearTimeout,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
fetch,
|
||||
WebSocket,
|
||||
fetch: require(`${nodeModulesPath}/node-fetch`),
|
||||
WebSocket: require(`${nodeModulesPath}/ws`),
|
||||
// This is only going to be called for pre-bundled modules, we won't allow
|
||||
// arbitrary requiring of modules
|
||||
require: (moduleName: string): any => {
|
||||
// console.log("Loading", moduleName);
|
||||
if (preloadModules.includes(moduleName)) {
|
||||
return require(`${workerData}/${moduleName}`);
|
||||
if (preloadedModules.includes(moduleName)) {
|
||||
return require(`${nodeModulesPath}/${moduleName}`);
|
||||
} else {
|
||||
throw Error("Cannot import arbitrary modules");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@silverbulletmd/plugos",
|
||||
"name": "@plugos/plugos",
|
||||
"version": "0.0.1",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Hook, Manifest, RuntimeEnvironment } from "./types";
|
||||
import { EventEmitter } from "../silverbullet-common/event";
|
||||
import { EventEmitter } from "./event";
|
||||
import { SandboxFactory } from "./sandbox";
|
||||
import { Plug } from "./plug";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"include": ["bin/*", "environments/*", "hooks/**", "syscalls/*", "*"],
|
||||
"include": ["bin/*", "environments/*", "hooks/*", "syscalls/*", "*"],
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"strict": true,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { insertAtCursor } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import { insertAtCursor } from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
|
||||
const dateMatchRegex = /(\d{4}\-\d{2}\-\d{2})/g;
|
||||
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import type { IndexTreeEvent } from "@silverbulletmd/web/app_event";
|
||||
|
||||
import { batchSet, scanPrefixGlobal } from "@silverbulletmd/plugos-silverbullet-syscall/index";
|
||||
import { collectNodesOfType, ParseTree, renderToText } from "@silverbulletmd/common/tree";
|
||||
import {
|
||||
batchSet,
|
||||
scanPrefixGlobal,
|
||||
} from "@plugos/plugos-silverbullet-syscall/index";
|
||||
import {
|
||||
collectNodesOfType,
|
||||
ParseTree,
|
||||
renderToText,
|
||||
} from "@silverbulletmd/common/tree";
|
||||
import { removeQueries } from "../query/util";
|
||||
import { applyQuery, QueryProviderEvent } from "../query/engine";
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { getCursor, getText, insertAtPos, replaceRange } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import {
|
||||
getCursor,
|
||||
getText,
|
||||
insertAtPos,
|
||||
replaceRange,
|
||||
} from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
|
||||
export async function toggleH1() {
|
||||
await togglePrefix("# ");
|
||||
|
||||
@@ -3,9 +3,9 @@ import {
|
||||
getCursor,
|
||||
getText,
|
||||
navigate as navigateTo,
|
||||
openUrl
|
||||
} from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
|
||||
openUrl,
|
||||
} from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown";
|
||||
import { nodeAtPos, ParseTree } from "@silverbulletmd/common/tree";
|
||||
|
||||
const materializedQueryPrefix = /<!--\s*#query\s+/;
|
||||
|
||||
+10
-10
@@ -4,32 +4,32 @@ import {
|
||||
clearPageIndex as clearPageIndexSyscall,
|
||||
clearPageIndexForPage,
|
||||
scanPrefixGlobal,
|
||||
set
|
||||
} from "@silverbulletmd/plugos-silverbullet-syscall/index";
|
||||
set,
|
||||
} from "@plugos/plugos-silverbullet-syscall/index";
|
||||
import {
|
||||
flashNotification,
|
||||
getCurrentPage,
|
||||
getText,
|
||||
matchBefore,
|
||||
navigate,
|
||||
prompt
|
||||
} from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
prompt,
|
||||
} from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
|
||||
import { dispatch } from "@silverbulletmd/plugos-syscall/event";
|
||||
import { dispatch } from "@plugos/plugos-syscall/event";
|
||||
import {
|
||||
deletePage as deletePageSyscall,
|
||||
listPages,
|
||||
readPage,
|
||||
writePage
|
||||
} from "@silverbulletmd/plugos-silverbullet-syscall/space";
|
||||
import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
|
||||
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
|
||||
writePage,
|
||||
} from "@plugos/plugos-silverbullet-syscall/space";
|
||||
import { invokeFunction } from "@plugos/plugos-silverbullet-syscall/system";
|
||||
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown";
|
||||
import {
|
||||
addParentPointers,
|
||||
collectNodesMatching,
|
||||
ParseTree,
|
||||
renderToText,
|
||||
replaceNodesMatching
|
||||
replaceNodesMatching,
|
||||
} from "@silverbulletmd/common/tree";
|
||||
import { applyQuery, QueryProviderEvent } from "../query/engine";
|
||||
import { PageMeta } from "@silverbulletmd/common/types";
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { EndpointRequest, EndpointResponse } from "@silverbulletmd/plugos/hooks/endpoint";
|
||||
import {
|
||||
EndpointRequest,
|
||||
EndpointResponse,
|
||||
} from "@plugos/plugos/hooks/endpoint";
|
||||
|
||||
export function endpointTest(req: EndpointRequest): EndpointResponse {
|
||||
console.log("I'm running on the server!", req);
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import { listPages, readPage, writePage } from "@silverbulletmd/plugos-silverbullet-syscall/space";
|
||||
import { filterBox, navigate, prompt } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
|
||||
import {
|
||||
listPages,
|
||||
readPage,
|
||||
writePage,
|
||||
} from "@plugos/plugos-silverbullet-syscall/space";
|
||||
import {
|
||||
filterBox,
|
||||
navigate,
|
||||
prompt,
|
||||
} from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown";
|
||||
import { extractMeta } from "../query/data";
|
||||
import { renderToText } from "@silverbulletmd/common/tree";
|
||||
import { niceDate } from "./dates";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as clientStore from "@silverbulletmd/plugos-silverbullet-syscall/clientStore";
|
||||
import * as clientStore from "@plugos/plugos-silverbullet-syscall/clientStore";
|
||||
|
||||
export async function toggleMode() {
|
||||
let currentValue = !!(await clientStore.get("enableDraftMode"));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @ts-ignore
|
||||
import emojis from "./emoji.json";
|
||||
import { matchBefore } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import { matchBefore } from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
|
||||
const emojiMatcher = /\(([^\)]+)\)\s+(.+)$/;
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { readPage, writePage } from "@silverbulletmd/plugos-silverbullet-syscall/space";
|
||||
import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
|
||||
import { getCurrentPage, getText } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import { readPage, writePage } from "@plugos/plugos-silverbullet-syscall/space";
|
||||
import { invokeFunction } from "@plugos/plugos-silverbullet-syscall/system";
|
||||
import {
|
||||
getCurrentPage,
|
||||
getText,
|
||||
} from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
import { cleanMarkdown } from "../markdown/util";
|
||||
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
|
||||
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown";
|
||||
import { extractMeta } from "../query/data";
|
||||
|
||||
type GhostConfig = {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { run } from "@silverbulletmd/plugos-syscall/shell";
|
||||
import { flashNotification, prompt } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
|
||||
import { run } from "@plugos/plugos-syscall/shell";
|
||||
import {
|
||||
flashNotification,
|
||||
prompt,
|
||||
} from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
import { invokeFunction } from "@plugos/plugos-silverbullet-syscall/system";
|
||||
|
||||
export async function commit(message?: string) {
|
||||
if (!message) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { hideRhs } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
|
||||
import * as clientStore from "@silverbulletmd/plugos-silverbullet-syscall/clientStore";
|
||||
import { hideRhs } from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
import { invokeFunction } from "@plugos/plugos-silverbullet-syscall/system";
|
||||
import * as clientStore from "@plugos/plugos-silverbullet-syscall/clientStore";
|
||||
|
||||
export async function togglePreview() {
|
||||
let currentValue = !!(await clientStore.get("enableMarkdownPreview"));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import MarkdownIt from "markdown-it";
|
||||
import { getText, showRhs } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import * as clientStore from "@silverbulletmd/plugos-silverbullet-syscall/clientStore";
|
||||
import { getText, showRhs } from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
import * as clientStore from "@plugos/plugos-silverbullet-syscall/clientStore";
|
||||
import { cleanMarkdown } from "./util";
|
||||
|
||||
const css = `
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { findNodeOfType, renderToText, replaceNodesMatching } from "@silverbulletmd/common/tree";
|
||||
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
|
||||
import {
|
||||
findNodeOfType,
|
||||
renderToText,
|
||||
replaceNodesMatching,
|
||||
} from "@silverbulletmd/common/tree";
|
||||
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown";
|
||||
|
||||
export function encodePageUrl(name: string): string {
|
||||
return name.replaceAll(" ", "_");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Client4 } from "@mattermost/client";
|
||||
import { applyQuery, QueryProviderEvent } from "../query/engine";
|
||||
import { readPage } from "@silverbulletmd/plugos-silverbullet-syscall/space";
|
||||
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
|
||||
import { readPage } from "@plugos/plugos-silverbullet-syscall/space";
|
||||
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown";
|
||||
import { extractMeta } from "../query/data";
|
||||
import { niceDate } from "../core/dates";
|
||||
import { Post } from "@mattermost/types/lib/posts";
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"generate": "lezer-generator query/query.grammar -o query/parse-query.js",
|
||||
"watch": "plugos-bundle -w --dist dist */*.plug.yaml",
|
||||
"build": "plugos-bundle --dist dist */*.plug.yaml"
|
||||
"watch": "plugos-bundle -w --dist dist --exclude @lezer/lr yaml -- */*.plug.yaml",
|
||||
"build": "plugos-bundle --dist dist --exclude @lezer/lr yaml -- */*.plug.yaml"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jest/globals": "^27.5.1",
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { getCursor, insertAtCursor, moveCursor } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import {
|
||||
getCursor,
|
||||
insertAtCursor,
|
||||
moveCursor,
|
||||
} from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
|
||||
export async function insertQuery() {
|
||||
let cursorPos = await getCursor();
|
||||
|
||||
@@ -2,8 +2,16 @@
|
||||
// data:page@pos
|
||||
|
||||
import type { IndexTreeEvent } from "@silverbulletmd/web/app_event";
|
||||
import { batchSet, scanPrefixGlobal } from "@silverbulletmd/plugos-silverbullet-syscall";
|
||||
import { collectNodesOfType, findNodeOfType, ParseTree, replaceNodesMatching } from "@silverbulletmd/common/tree";
|
||||
import {
|
||||
batchSet,
|
||||
scanPrefixGlobal,
|
||||
} from "@plugos/plugos-silverbullet-syscall";
|
||||
import {
|
||||
collectNodesOfType,
|
||||
findNodeOfType,
|
||||
ParseTree,
|
||||
replaceNodesMatching,
|
||||
} from "@silverbulletmd/common/tree";
|
||||
import { parse as parseYaml, parseAllDocuments } from "yaml";
|
||||
import type { QueryProviderEvent } from "./engine";
|
||||
import { applyQuery } from "./engine";
|
||||
|
||||
@@ -3,17 +3,17 @@ import {
|
||||
getCurrentPage,
|
||||
getText,
|
||||
reloadPage,
|
||||
save
|
||||
} from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
save,
|
||||
} from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
|
||||
import { readPage, writePage } from "@silverbulletmd/plugos-silverbullet-syscall/space";
|
||||
import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
|
||||
import { readPage, writePage } from "@plugos/plugos-silverbullet-syscall/space";
|
||||
import { invokeFunction } from "@plugos/plugos-silverbullet-syscall/system";
|
||||
import { parseQuery } from "./engine";
|
||||
import { replaceTemplateVars } from "../core/template";
|
||||
import { queryRegex, removeQueries } from "./util";
|
||||
import { dispatch } from "@silverbulletmd/plugos-syscall/event";
|
||||
import { dispatch } from "@plugos/plugos-syscall/event";
|
||||
import { replaceAsync } from "../lib/util";
|
||||
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
|
||||
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown";
|
||||
|
||||
export async function updateMaterializedQueriesCommand() {
|
||||
const currentPage = await getCurrentPage();
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import type { ClickEvent, IndexTreeEvent } from "@silverbulletmd/web/app_event";
|
||||
|
||||
import { batchSet, scanPrefixGlobal } from "@silverbulletmd/plugos-silverbullet-syscall/index";
|
||||
import { readPage, writePage } from "@silverbulletmd/plugos-silverbullet-syscall/space";
|
||||
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
|
||||
import { dispatch, filterBox, getCursor, getText } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import {
|
||||
batchSet,
|
||||
scanPrefixGlobal,
|
||||
} from "@plugos/plugos-silverbullet-syscall/index";
|
||||
import { readPage, writePage } from "@plugos/plugos-silverbullet-syscall/space";
|
||||
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown";
|
||||
import {
|
||||
dispatch,
|
||||
filterBox,
|
||||
getCursor,
|
||||
getText,
|
||||
} from "@plugos/plugos-silverbullet-syscall/editor";
|
||||
import {
|
||||
addParentPointers,
|
||||
collectNodesMatching,
|
||||
@@ -11,7 +19,7 @@ import {
|
||||
findNodeOfType,
|
||||
nodeAtPos,
|
||||
ParseTree,
|
||||
renderToText
|
||||
renderToText,
|
||||
} from "@silverbulletmd/common/tree";
|
||||
import { removeQueries } from "../query/util";
|
||||
import { applyQuery, QueryProviderEvent } from "../query/engine";
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
import express, { Express } from "express";
|
||||
import { SilverBulletHooks } from "@silverbulletmd/common/manifest";
|
||||
import { EndpointHook } from "@silverbulletmd/plugos/hooks/endpoint";
|
||||
import { EndpointHook } from "@plugos/plugos/hooks/endpoint";
|
||||
import { readFile } from "fs/promises";
|
||||
import { System } from "@silverbulletmd/plugos/system";
|
||||
import { System } from "@plugos/plugos/system";
|
||||
import cors from "cors";
|
||||
import { DiskSpacePrimitives } from "@silverbulletmd/common/spaces/disk_space_primitives";
|
||||
import path from "path";
|
||||
import bodyParser from "body-parser";
|
||||
import { EventHook } from "@silverbulletmd/plugos/hooks/event";
|
||||
import { EventHook } from "@plugos/plugos/hooks/event";
|
||||
import spaceSyscalls from "./syscalls/space";
|
||||
import { eventSyscalls } from "@silverbulletmd/plugos/syscalls/event";
|
||||
import { eventSyscalls } from "@plugos/plugos/syscalls/event";
|
||||
import { ensurePageIndexTable, pageIndexSyscalls } from "./syscalls";
|
||||
import knex, { Knex } from "knex";
|
||||
import shellSyscalls from "@silverbulletmd/plugos/syscalls/shell.node";
|
||||
import { NodeCronHook } from "@silverbulletmd/plugos/hooks/node_cron";
|
||||
import shellSyscalls from "@plugos/plugos/syscalls/shell.node";
|
||||
import { NodeCronHook } from "@plugos/plugos/hooks/node_cron";
|
||||
import { markdownSyscalls } from "@silverbulletmd/common/syscalls/markdown";
|
||||
import { EventedSpacePrimitives } from "@silverbulletmd/common/spaces/evented_space_primitives";
|
||||
import { Space } from "@silverbulletmd/common/spaces/space";
|
||||
import { safeRun, throttle } from "@silverbulletmd/common/util";
|
||||
import { createSandbox } from "@silverbulletmd/plugos/environments/node_sandbox";
|
||||
import { jwtSyscalls } from "@silverbulletmd/plugos/syscalls/jwt";
|
||||
import { createSandbox } from "@plugos/plugos/environments/node_sandbox";
|
||||
import { jwtSyscalls } from "@plugos/plugos/syscalls/jwt";
|
||||
import buildMarkdown from "@silverbulletmd/web/parser";
|
||||
import { loadMarkdownExtensions } from "@silverbulletmd/web/markdown_ext";
|
||||
import http, { Server } from "http";
|
||||
@@ -17,7 +17,7 @@
|
||||
"isLibrary": true,
|
||||
"context": "node",
|
||||
"includeNodeModules": [
|
||||
"@silverbulletmd/plugos",
|
||||
"@plugos/plugos",
|
||||
"@silverbulletmd/common",
|
||||
"@silverbulletmd/web"
|
||||
]
|
||||
@@ -31,6 +31,7 @@
|
||||
"@codemirror/stream-parser": "^0.19.9",
|
||||
"@jest/globals": "^27.5.1",
|
||||
"@lezer/markdown": "^0.15.0",
|
||||
"@silverbulletmd/web": "^0.0.1",
|
||||
"better-sqlite3": "^7.5.0",
|
||||
"body-parser": "^1.19.2",
|
||||
"buffer": "^6.0.3",
|
||||
@@ -3,7 +3,7 @@
|
||||
import yargs from "yargs";
|
||||
import { hideBin } from "yargs/helpers";
|
||||
import { ExpressServer } from "./api_server";
|
||||
import path from "path";
|
||||
import { nodeModulesDir } from "@plugos/plugos/environments/node_sandbox";
|
||||
|
||||
let args = yargs(hideBin(process.argv))
|
||||
.option("port", {
|
||||
@@ -20,9 +20,11 @@ if (!args._.length) {
|
||||
const pagesPath = args._[0] as string;
|
||||
|
||||
const port = args.port;
|
||||
const distDir = path.resolve(`${__dirname}/../../silverbullet-web/dist`);
|
||||
const webappDistDir = `${nodeModulesDir}/node_modules/@silverbulletmd/web/dist`;
|
||||
|
||||
const expressServer = new ExpressServer(port, pagesPath, distDir);
|
||||
// console.log("This is where the static files live", webappDistDir);
|
||||
|
||||
const expressServer = new ExpressServer(port, pagesPath, webappDistDir);
|
||||
expressServer.start().catch((e) => {
|
||||
console.error(e);
|
||||
});
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Knex } from "knex";
|
||||
import { SysCallMapping } from "../../plugos/system";
|
||||
import { SysCallMapping } from "@plugos/plugos/system";
|
||||
|
||||
import { ensureTable, storeSyscalls } from "../../plugos/syscalls/store.knex_node";
|
||||
import {
|
||||
ensureTable,
|
||||
storeSyscalls,
|
||||
} from "@plugos/plugos/syscalls/store.knex_node";
|
||||
|
||||
type IndexItem = {
|
||||
page: string;
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PageMeta } from "@silverbulletmd/common/types";
|
||||
import { SysCallMapping } from "@silverbulletmd/plugos/system";
|
||||
import { SysCallMapping } from "@plugos/plugos/system";
|
||||
import { Space } from "@silverbulletmd/common/spaces/space";
|
||||
|
||||
export default (space: Space): SysCallMapping => {
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Editor } from "./editor";
|
||||
import { safeRun } from "../silverbullet-common/util";
|
||||
import { safeRun } from "../common/util";
|
||||
import { Space } from "@silverbulletmd/common/spaces/space";
|
||||
import { HttpSpacePrimitives } from "@silverbulletmd/common/spaces/http_space_primitives";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { isMacLike } from "../../silverbullet-common/util";
|
||||
import { isMacLike } from "../../common/util";
|
||||
import { FilterList } from "./filter";
|
||||
import { faPersonRunning } from "@fortawesome/free-solid-svg-icons";
|
||||
import { AppCommand } from "../hooks/command";
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { EditorView } from "@codemirror/view";
|
||||
import * as util from "../../silverbullet-common/util";
|
||||
import * as util from "../../common/util";
|
||||
|
||||
export function StatusBar({ editorView }: { editorView?: EditorView }) {
|
||||
let wordCount = 0,
|
||||
@@ -1,4 +1,8 @@
|
||||
import { autocompletion, completionKeymap, CompletionResult } from "@codemirror/autocomplete";
|
||||
import {
|
||||
autocompletion,
|
||||
completionKeymap,
|
||||
CompletionResult,
|
||||
} from "@codemirror/autocomplete";
|
||||
import { closeBrackets, closeBracketsKeymap } from "@codemirror/closebrackets";
|
||||
import { indentWithTab, standardKeymap } from "@codemirror/commands";
|
||||
import { history, historyKeymap } from "@codemirror/history";
|
||||
@@ -13,11 +17,11 @@ import {
|
||||
KeyBinding,
|
||||
keymap,
|
||||
ViewPlugin,
|
||||
ViewUpdate
|
||||
ViewUpdate,
|
||||
} from "@codemirror/view";
|
||||
import React, { useEffect, useReducer } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { createSandbox as createIFrameSandbox } from "../plugos/environments/webworker_sandbox";
|
||||
import { createSandbox as createIFrameSandbox } from "@plugos/plugos/environments/webworker_sandbox";
|
||||
import { AppEvent, ClickEvent } from "./app_event";
|
||||
import * as commands from "./commands";
|
||||
import { CommandPalette } from "./components/command_palette";
|
||||
@@ -37,9 +41,9 @@ import { indexerSyscalls } from "./syscalls";
|
||||
import { spaceSyscalls } from "./syscalls/space";
|
||||
import { Action, AppViewState, initialViewState } from "./types";
|
||||
import { SilverBulletHooks } from "@silverbulletmd/common/manifest";
|
||||
import { safeRun, throttle } from "../silverbullet-common/util";
|
||||
import { System } from "../plugos/system";
|
||||
import { EventHook } from "../plugos/hooks/event";
|
||||
import { safeRun, throttle } from "../common/util";
|
||||
import { System } from "@plugos/plugos/system";
|
||||
import { EventHook } from "@plugos/plugos/hooks/event";
|
||||
import { systemSyscalls } from "./syscalls/system";
|
||||
import { Panel } from "./components/panel";
|
||||
import { CommandHook } from "./hooks/command";
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Hook, Manifest } from "@silverbulletmd/plugos/types";
|
||||
import { System } from "@silverbulletmd/plugos/system";
|
||||
import { EventEmitter } from "@silverbulletmd/common/event";
|
||||
import { Hook, Manifest } from "@plugos/plugos/types";
|
||||
import { System } from "@plugos/plugos/system";
|
||||
import { EventEmitter } from "@plugos/plugos/event";
|
||||
|
||||
export type CommandDef = {
|
||||
name: string;
|
||||
+8
-4
@@ -1,8 +1,12 @@
|
||||
import { Hook, Manifest } from "../../plugos/types";
|
||||
import { System } from "../../plugos/system";
|
||||
import { Completion, CompletionContext, CompletionResult } from "@codemirror/autocomplete";
|
||||
import { Hook, Manifest } from "@plugos/plugos/types";
|
||||
import { System } from "@plugos/plugos/system";
|
||||
import {
|
||||
Completion,
|
||||
CompletionContext,
|
||||
CompletionResult,
|
||||
} from "@codemirror/autocomplete";
|
||||
import { slashCommandRegexp } from "../types";
|
||||
import { safeRun } from "../../silverbullet-common/util";
|
||||
import { safeRun } from "../../common/util";
|
||||
import { Editor } from "../editor";
|
||||
|
||||
export type SlashCommandDef = {
|
||||
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
@@ -1,6 +1,6 @@
|
||||
import { Tag } from "@codemirror/highlight";
|
||||
import type { MarkdownConfig } from "@lezer/markdown";
|
||||
import { System } from "@silverbulletmd/plugos/system";
|
||||
import { System } from "@plugos/plugos/system";
|
||||
import { Manifest } from "@silverbulletmd/common/manifest";
|
||||
|
||||
export type MDExt = {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { safeRun } from "../silverbullet-common/util";
|
||||
import { safeRun } from "../common/util";
|
||||
|
||||
function encodePageUrl(name: string): string {
|
||||
return name.replaceAll(" ", "_");
|
||||
@@ -1,12 +1,31 @@
|
||||
import { styleTags, tags as t } from "@codemirror/highlight";
|
||||
import { BlockContext, LeafBlock, LeafBlockParser, MarkdownConfig, parseCode, Table, TaskList } from "@lezer/markdown";
|
||||
import {
|
||||
BlockContext,
|
||||
LeafBlock,
|
||||
LeafBlockParser,
|
||||
MarkdownConfig,
|
||||
parseCode,
|
||||
Table,
|
||||
TaskList,
|
||||
} from "@lezer/markdown";
|
||||
import { commonmark, getCodeParser, mkLang } from "./markdown/markdown";
|
||||
import * as ct from "./customtags";
|
||||
import { Language, LanguageDescription, LanguageSupport } from "@codemirror/language";
|
||||
import {
|
||||
Language,
|
||||
LanguageDescription,
|
||||
LanguageSupport,
|
||||
} from "@codemirror/language";
|
||||
import { StreamLanguage } from "@codemirror/stream-parser";
|
||||
import { yaml } from "@codemirror/legacy-modes/mode/yaml";
|
||||
import { javascriptLanguage, typescriptLanguage } from "@codemirror/lang-javascript";
|
||||
import { MDExt, mdExtensionStyleTags, mdExtensionSyntaxConfig } from "./markdown_ext";
|
||||
import {
|
||||
javascriptLanguage,
|
||||
typescriptLanguage,
|
||||
} from "@codemirror/lang-javascript";
|
||||
import {
|
||||
MDExt,
|
||||
mdExtensionStyleTags,
|
||||
mdExtensionSyntaxConfig,
|
||||
} from "./markdown_ext";
|
||||
|
||||
export const pageLinkRegex = /^\[\[([^\]]+)\]\]/;
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import { proxySyscalls } from "../../plugos/syscalls/transport";
|
||||
import { SysCallMapping } from "../../plugos/system";
|
||||
import { storeSyscalls } from "../../plugos/syscalls/store.dexie_browser";
|
||||
import { proxySyscalls } from "@plugos/plugos/syscalls/transport";
|
||||
import { SysCallMapping } from "@plugos/plugos/system";
|
||||
import { storeSyscalls } from "@plugos/plugos/syscalls/store.dexie_browser";
|
||||
|
||||
export function clientStoreSyscalls(): SysCallMapping {
|
||||
const storeCalls = storeSyscalls("local", "localData");
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Editor } from "../editor";
|
||||
import { Transaction } from "@codemirror/state";
|
||||
import { SysCallMapping } from "@silverbulletmd/plugos/system";
|
||||
import { SysCallMapping } from "@plugos/plugos/system";
|
||||
import { FilterOption } from "@silverbulletmd/common/types";
|
||||
|
||||
type SyntaxNode = {
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SysCallMapping } from "@silverbulletmd/plugos/system";
|
||||
import { proxySyscalls } from "@silverbulletmd/plugos/syscalls/transport";
|
||||
import { SysCallMapping } from "@plugos/plugos/system";
|
||||
import { proxySyscalls } from "@plugos/plugos/syscalls/transport";
|
||||
import { Space } from "@silverbulletmd/common/spaces/space";
|
||||
|
||||
export function indexerSyscalls(space: Space): SysCallMapping {
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Editor } from "../editor";
|
||||
import { SysCallMapping } from "@silverbulletmd/plugos/system";
|
||||
import { SysCallMapping } from "@plugos/plugos/system";
|
||||
import { PageMeta } from "@silverbulletmd/common/types";
|
||||
|
||||
export function spaceSyscalls(editor: Editor): SysCallMapping {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SysCallMapping } from "../../plugos/system";
|
||||
import { SysCallMapping } from "@plugos/plugos/system";
|
||||
import { Space } from "@silverbulletmd/common/spaces/space";
|
||||
|
||||
export function systemSyscalls(space: Space): SysCallMapping {
|
||||
Reference in New Issue
Block a user