1
0

Make stuff work with npm

This commit is contained in:
Zef Hemel 2022-04-25 11:24:13 +02:00
parent 44cf4c6a72
commit d52d81a909
32 changed files with 1471 additions and 10639 deletions

6187
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,8 @@
"build": "parcel build packages/{web,server,plugos}", "build": "parcel build packages/{web,server,plugos}",
"plugs": "cd packages/plugs && npm run watch", "plugs": "cd packages/plugs && npm run watch",
"server": "cd packages/server && npm start", "server": "cd packages/server && npm start",
"test": "jest packages/*/dist/test" "test": "jest packages/*/dist/test",
"publish-all": "npm publish --access public --ws"
}, },
"devDependencies": { "devDependencies": {
"@parcel/core": "2.3.2", "@parcel/core": "2.3.2",

View File

@ -1,4 +1,9 @@
{ {
"name": "@silverbulletmd/common", "name": "@silverbulletmd/common",
"version": "1.0.0" "author": {
"name": "Zef Hemel",
"email": "zef@zef.me"
},
"version": "0.0.1",
"license": "MIT"
} }

View File

@ -1,4 +1,9 @@
{ {
"name": "@plugos/plugos-silverbullet-syscall", "name": "@silverbulletmd/plugos-silverbullet-syscall",
"version": "1.0.0" "author": {
"name": "Zef Hemel",
"email": "zef@zef.me"
},
"version": "0.0.1",
"license": "MIT"
} }

View File

@ -1,4 +1,9 @@
{ {
"name": "@plugos/plugos-syscall", "name": "@plugos/plugos-syscall",
"version": "1.0.0" "author": {
"name": "Zef Hemel",
"email": "zef@zef.me"
},
"version": "0.0.1",
"license": "MIT"
} }

View File

@ -33,7 +33,7 @@ let vm = new VM({
if (preloadedModules.includes(moduleName)) { if (preloadedModules.includes(moduleName)) {
return require(`${nodeModulesPath}/${moduleName}`); return require(`${nodeModulesPath}/${moduleName}`);
} else { } else {
throw Error("Cannot import arbitrary modules"); throw Error(`Cannot import arbitrary modules like ${moduleName}`);
} }
}, },
self: { self: {

View File

@ -1,5 +1,9 @@
{ {
"name": "@plugos/plugos", "name": "@plugos/plugos",
"author": {
"name": "Zef Hemel",
"email": "zef@zef.me"
},
"version": "0.0.1", "version": "0.0.1",
"license": "MIT", "license": "MIT",
"bin": { "bin": {

View File

@ -1,116 +0,0 @@
Arguments:
/Users/zef/.nvm/versions/node/v16.13.2/bin/node /opt/homebrew/Cellar/yarn/1.22.18/libexec/bin/yarn.js install
PATH:
/Users/zef/.nvm/versions/node/v16.13.2/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/zef/.local/share/solana/install/active_release/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/zef/.cargo/bin:/Users/zef/git/silverbullet/node_modules/.bin
Yarn version:
1.22.18
Node version:
16.13.2
Platform:
darwin arm64
Trace:
SyntaxError: /Users/zef/git/silverbullet/plugos/package.json: Unexpected token ] in JSON at position 755
at JSON.parse (<anonymous>)
at /opt/homebrew/Cellar/yarn/1.22.18/libexec/lib/cli.js:1625:59
at Generator.next (<anonymous>)
at step (/opt/homebrew/Cellar/yarn/1.22.18/libexec/lib/cli.js:310:30)
at /opt/homebrew/Cellar/yarn/1.22.18/libexec/lib/cli.js:321:13
npm manifest:
{
"name": "plugos",
"version": "0.0.1",
"license": "MIT",
"bin": {
"plugos-bundle": "./dist/plugos-bundle.js",
"plugos-server": "./dist/plugos-server.js"
},
"scripts": {
"watch": "rm -rf .parcel-cache && parcel watch",
"build": "parcel build",
"clean": "rm -rf dist",
"test": "jest"
},
"files": [
"dist"
],
"targets": {
"plugos": {
"source": [
"bin/plugos-bundle.ts",
"bin/plugos-server.ts"
],
"outputFormat": "commonjs",
"isLibrary": true,
"context": "node"
},
"test": {
"source": [
"runtime.test.ts",
"feature/endpoint.test.ts",
"syscall/store.knex_node.test.ts",
"syscall/store.dexie_browser.test.ts",
],
"outputFormat": "commonjs",
"isLibrary": true,
"context": "node"
}
},
"dependencies": {
"@jest/globals": "^27.5.1",
"@parcel/optimizer-data-url": "2.3.2",
"@parcel/service-worker": "^2.3.2",
"@parcel/transformer-inline-string": "2.3.2",
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"better-sqlite3": "^7.5.0",
"body-parser": "^1.19.2",
"cors": "^2.8.5",
"esbuild": "^0.14.27",
"express": "^4.17.3",
"fake-indexeddb": "^3.1.7",
"jest": "^27.5.1",
"knex": "^1.0.4",
"node-cron": "^3.0.0",
"node-fetch": "2",
"parcel": "^2.3.2",
"supertest": "^6.2.2",
"vm2": "^3.9.9",
"yaml": "^1.10.2",
"yargs": "^17.3.1"
},
"devDependencies": {
"@parcel/packager-raw-url": "2.3.2",
"@parcel/service-worker": "^2.3.2",
"@parcel/transformer-inline-string": "2.3.2",
"@parcel/transformer-sass": "2.3.2",
"@parcel/transformer-webmanifest": "2.3.2",
"@parcel/validator-typescript": "^2.3.2",
"@types/events": "^3.0.0",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.21",
"@types/node-cron": "^3.0.1",
"@types/node-fetch": "^2.6.1",
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"@types/supertest": "^2.0.11",
"@types/yaml": "^1.9.7",
"@vscode/sqlite3": "^5.0.7",
"assert": "^2.0.0",
"events": "^3.3.0",
"parcel": "^2.3.2",
"prettier": "^2.5.1",
"typescript": "^4.6.2"
}
}
yarn manifest:
No manifest
Lockfile:
No lockfile

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
import { insertAtCursor } from "@plugos/plugos-silverbullet-syscall/editor"; import { insertAtCursor } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
const dateMatchRegex = /(\d{4}\-\d{2}\-\d{2})/g; const dateMatchRegex = /(\d{4}\-\d{2}\-\d{2})/g;

View File

@ -3,7 +3,7 @@ import type { IndexTreeEvent } from "@silverbulletmd/web/app_event";
import { import {
batchSet, batchSet,
scanPrefixGlobal, scanPrefixGlobal,
} from "@plugos/plugos-silverbullet-syscall/index"; } from "@silverbulletmd/plugos-silverbullet-syscall/index";
import { import {
collectNodesOfType, collectNodesOfType,
ParseTree, ParseTree,

View File

@ -3,7 +3,7 @@ import {
getText, getText,
insertAtPos, insertAtPos,
replaceRange, replaceRange,
} from "@plugos/plugos-silverbullet-syscall/editor"; } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
export async function toggleH1() { export async function toggleH1() {
await togglePrefix("# "); await togglePrefix("# ");

View File

@ -4,8 +4,8 @@ import {
getText, getText,
navigate as navigateTo, navigate as navigateTo,
openUrl, openUrl,
} from "@plugos/plugos-silverbullet-syscall/editor"; } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown"; import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
import { nodeAtPos, ParseTree } from "@silverbulletmd/common/tree"; import { nodeAtPos, ParseTree } from "@silverbulletmd/common/tree";
const materializedQueryPrefix = /<!--\s*#query\s+/; const materializedQueryPrefix = /<!--\s*#query\s+/;

View File

@ -5,7 +5,7 @@ import {
clearPageIndexForPage, clearPageIndexForPage,
scanPrefixGlobal, scanPrefixGlobal,
set, set,
} from "@plugos/plugos-silverbullet-syscall/index"; } from "@silverbulletmd/plugos-silverbullet-syscall/index";
import { import {
flashNotification, flashNotification,
getCurrentPage, getCurrentPage,
@ -13,7 +13,7 @@ import {
matchBefore, matchBefore,
navigate, navigate,
prompt, prompt,
} from "@plugos/plugos-silverbullet-syscall/editor"; } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { dispatch } from "@plugos/plugos-syscall/event"; import { dispatch } from "@plugos/plugos-syscall/event";
import { import {
@ -21,9 +21,9 @@ import {
listPages, listPages,
readPage, readPage,
writePage, writePage,
} from "@plugos/plugos-silverbullet-syscall/space"; } from "@silverbulletmd/plugos-silverbullet-syscall/space";
import { invokeFunction } from "@plugos/plugos-silverbullet-syscall/system"; import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown"; import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
import { import {
addParentPointers, addParentPointers,
collectNodesMatching, collectNodesMatching,

View File

@ -2,13 +2,13 @@ import {
listPages, listPages,
readPage, readPage,
writePage, writePage,
} from "@plugos/plugos-silverbullet-syscall/space"; } from "@silverbulletmd/plugos-silverbullet-syscall/space";
import { import {
filterBox, filterBox,
navigate, navigate,
prompt, prompt,
} from "@plugos/plugos-silverbullet-syscall/editor"; } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown"; import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
import { extractMeta } from "../query/data"; import { extractMeta } from "../query/data";
import { renderToText } from "@silverbulletmd/common/tree"; import { renderToText } from "@silverbulletmd/common/tree";
import { niceDate } from "./dates"; import { niceDate } from "./dates";

View File

@ -1,4 +1,4 @@
import * as clientStore from "@plugos/plugos-silverbullet-syscall/clientStore"; import * as clientStore from "@silverbulletmd/plugos-silverbullet-syscall/clientStore";
export async function toggleMode() { export async function toggleMode() {
let currentValue = !!(await clientStore.get("enableDraftMode")); let currentValue = !!(await clientStore.get("enableDraftMode"));

View File

@ -1,6 +1,6 @@
// @ts-ignore // @ts-ignore
import emojis from "./emoji.json"; import emojis from "./emoji.json";
import { matchBefore } from "@plugos/plugos-silverbullet-syscall/editor"; import { matchBefore } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
const emojiMatcher = /\(([^\)]+)\)\s+(.+)$/; const emojiMatcher = /\(([^\)]+)\)\s+(.+)$/;

View File

@ -1,11 +1,14 @@
import { readPage, writePage } from "@plugos/plugos-silverbullet-syscall/space"; import {
import { invokeFunction } from "@plugos/plugos-silverbullet-syscall/system"; readPage,
writePage,
} from "@silverbulletmd/plugos-silverbullet-syscall/space";
import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
import { import {
getCurrentPage, getCurrentPage,
getText, getText,
} from "@plugos/plugos-silverbullet-syscall/editor"; } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { cleanMarkdown } from "../markdown/util"; import { cleanMarkdown } from "../markdown/util";
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown"; import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
import { extractMeta } from "../query/data"; import { extractMeta } from "../query/data";
type GhostConfig = { type GhostConfig = {

View File

@ -2,8 +2,8 @@ import { run } from "@plugos/plugos-syscall/shell";
import { import {
flashNotification, flashNotification,
prompt, prompt,
} from "@plugos/plugos-silverbullet-syscall/editor"; } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { invokeFunction } from "@plugos/plugos-silverbullet-syscall/system"; import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
export async function commit(message?: string) { export async function commit(message?: string) {
if (!message) { if (!message) {

View File

@ -1,6 +1,6 @@
import { hideRhs } from "@plugos/plugos-silverbullet-syscall/editor"; import { hideRhs } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { invokeFunction } from "@plugos/plugos-silverbullet-syscall/system"; import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
import * as clientStore from "@plugos/plugos-silverbullet-syscall/clientStore"; import * as clientStore from "@silverbulletmd/plugos-silverbullet-syscall/clientStore";
export async function togglePreview() { export async function togglePreview() {
let currentValue = !!(await clientStore.get("enableMarkdownPreview")); let currentValue = !!(await clientStore.get("enableMarkdownPreview"));

View File

@ -1,6 +1,9 @@
import MarkdownIt from "markdown-it"; import MarkdownIt from "markdown-it";
import { getText, showRhs } from "@plugos/plugos-silverbullet-syscall/editor"; import {
import * as clientStore from "@plugos/plugos-silverbullet-syscall/clientStore"; getText,
showRhs,
} from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import * as clientStore from "@silverbulletmd/plugos-silverbullet-syscall/clientStore";
import { cleanMarkdown } from "./util"; import { cleanMarkdown } from "./util";
const css = ` const css = `

View File

@ -3,7 +3,7 @@ import {
renderToText, renderToText,
replaceNodesMatching, replaceNodesMatching,
} from "@silverbulletmd/common/tree"; } from "@silverbulletmd/common/tree";
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown"; import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
export function encodePageUrl(name: string): string { export function encodePageUrl(name: string): string {
return name.replaceAll(" ", "_"); return name.replaceAll(" ", "_");

View File

@ -1,7 +1,7 @@
import { Client4 } from "@mattermost/client"; import { Client4 } from "@mattermost/client";
import { applyQuery, QueryProviderEvent } from "../query/engine"; import { applyQuery, QueryProviderEvent } from "../query/engine";
import { readPage } from "@plugos/plugos-silverbullet-syscall/space"; import { readPage } from "@silverbulletmd/plugos-silverbullet-syscall/space";
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown"; import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
import { extractMeta } from "../query/data"; import { extractMeta } from "../query/data";
import { niceDate } from "../core/dates"; import { niceDate } from "../core/dates";
import { Post } from "@mattermost/types/lib/posts"; import { Post } from "@mattermost/types/lib/posts";

View File

@ -1,11 +1,19 @@
{ {
"name": "@silverbulletmd/plugs", "name": "@silverbulletmd/plugs",
"version": "1.0.0", "author": {
"name": "Zef Hemel",
"email": "zef@zef.me"
},
"version": "0.0.1",
"license": "MIT",
"scripts": { "scripts": {
"generate": "lezer-generator query/query.grammar -o query/parse-query.js", "generate": "lezer-generator query/query.grammar -o query/parse-query.js",
"watch": "plugos-bundle -w --dist dist --exclude @lezer/lr yaml -- */*.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" "build": "plugos-bundle --dist dist --exclude @lezer/lr yaml -- */*.plug.yaml"
}, },
"files": [
"dist"
],
"dependencies": { "dependencies": {
"@jest/globals": "^27.5.1", "@jest/globals": "^27.5.1",
"@lezer/generator": "^0.15.4", "@lezer/generator": "^0.15.4",

View File

@ -2,7 +2,7 @@ import {
getCursor, getCursor,
insertAtCursor, insertAtCursor,
moveCursor, moveCursor,
} from "@plugos/plugos-silverbullet-syscall/editor"; } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
export async function insertQuery() { export async function insertQuery() {
let cursorPos = await getCursor(); let cursorPos = await getCursor();

View File

@ -5,7 +5,7 @@ import type { IndexTreeEvent } from "@silverbulletmd/web/app_event";
import { import {
batchSet, batchSet,
scanPrefixGlobal, scanPrefixGlobal,
} from "@plugos/plugos-silverbullet-syscall"; } from "@silverbulletmd/plugos-silverbullet-syscall";
import { import {
collectNodesOfType, collectNodesOfType,
findNodeOfType, findNodeOfType,

View File

@ -4,16 +4,19 @@ import {
getText, getText,
reloadPage, reloadPage,
save, save,
} from "@plugos/plugos-silverbullet-syscall/editor"; } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { readPage, writePage } from "@plugos/plugos-silverbullet-syscall/space"; import {
import { invokeFunction } from "@plugos/plugos-silverbullet-syscall/system"; readPage,
writePage,
} from "@silverbulletmd/plugos-silverbullet-syscall/space";
import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
import { parseQuery } from "./engine"; import { parseQuery } from "./engine";
import { replaceTemplateVars } from "../core/template"; import { replaceTemplateVars } from "../core/template";
import { queryRegex, removeQueries } from "./util"; import { queryRegex, removeQueries } from "./util";
import { dispatch } from "@plugos/plugos-syscall/event"; import { dispatch } from "@plugos/plugos-syscall/event";
import { replaceAsync } from "../lib/util"; import { replaceAsync } from "../lib/util";
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown"; import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
export async function updateMaterializedQueriesCommand() { export async function updateMaterializedQueriesCommand() {
const currentPage = await getCurrentPage(); const currentPage = await getCurrentPage();

View File

@ -3,15 +3,18 @@ import type { ClickEvent, IndexTreeEvent } from "@silverbulletmd/web/app_event";
import { import {
batchSet, batchSet,
scanPrefixGlobal, scanPrefixGlobal,
} from "@plugos/plugos-silverbullet-syscall/index"; } from "@silverbulletmd/plugos-silverbullet-syscall/index";
import { readPage, writePage } from "@plugos/plugos-silverbullet-syscall/space"; import {
import { parseMarkdown } from "@plugos/plugos-silverbullet-syscall/markdown"; readPage,
writePage,
} from "@silverbulletmd/plugos-silverbullet-syscall/space";
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
import { import {
dispatch, dispatch,
filterBox, filterBox,
getCursor, getCursor,
getText, getText,
} from "@plugos/plugos-silverbullet-syscall/editor"; } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { import {
addParentPointers, addParentPointers,
collectNodesMatching, collectNodesMatching,

View File

@ -35,7 +35,12 @@ export class ExpressServer {
private port: number; private port: number;
private server?: Server; private server?: Server;
constructor(port: number, rootPath: string, distDir: string) { constructor(
port: number,
rootPath: string,
distDir: string,
preloadedModules: string[]
) {
this.port = port; this.port = port;
this.app = express(); this.app = express();
this.rootPath = rootPath; this.rootPath = rootPath;
@ -78,7 +83,9 @@ export class ExpressServer {
plugLoaded: (plugName, plug) => { plugLoaded: (plugName, plug) => {
safeRun(async () => { safeRun(async () => {
console.log("Plug load", plugName); console.log("Plug load", plugName);
await this.system.load(plugName, plug, createSandbox); await this.system.load(plugName, plug, (p) =>
createSandbox(p, preloadedModules)
);
}); });
throttledRebuildMdExtensions(); throttledRebuildMdExtensions();
}, },

View File

@ -1,5 +1,9 @@
{ {
"name": "@silverbulletmd/server", "name": "@silverbulletmd/server",
"author": {
"name": "Zef Hemel",
"email": "zef@zef.me"
},
"version": "0.0.1", "version": "0.0.1",
"license": "MIT", "license": "MIT",
"bin": { "bin": {
@ -31,7 +35,7 @@
"@codemirror/stream-parser": "^0.19.9", "@codemirror/stream-parser": "^0.19.9",
"@jest/globals": "^27.5.1", "@jest/globals": "^27.5.1",
"@lezer/markdown": "^0.15.0", "@lezer/markdown": "^0.15.0",
"@silverbulletmd/web": "^0.0.1", "@silverbulletmd/web": "^0.0.2",
"better-sqlite3": "^7.5.0", "better-sqlite3": "^7.5.0",
"body-parser": "^1.19.2", "body-parser": "^1.19.2",
"buffer": "^6.0.3", "buffer": "^6.0.3",

View File

@ -4,6 +4,7 @@ import yargs from "yargs";
import { hideBin } from "yargs/helpers"; import { hideBin } from "yargs/helpers";
import { ExpressServer } from "./api_server"; import { ExpressServer } from "./api_server";
import { nodeModulesDir } from "@plugos/plugos/environments/node_sandbox"; import { nodeModulesDir } from "@plugos/plugos/environments/node_sandbox";
import { preloadModules } from "@silverbulletmd/common/preload_modules";
let args = yargs(hideBin(process.argv)) let args = yargs(hideBin(process.argv))
.option("port", { .option("port", {
@ -18,13 +19,15 @@ if (!args._.length) {
} }
const pagesPath = args._[0] as string; const pagesPath = args._[0] as string;
const port = args.port; const port = args.port;
const webappDistDir = `${nodeModulesDir}/node_modules/@silverbulletmd/web/dist`; const webappDistDir = `${nodeModulesDir}/node_modules/@silverbulletmd/web/dist`;
// console.log("This is where the static files live", webappDistDir); const expressServer = new ExpressServer(
port,
const expressServer = new ExpressServer(port, pagesPath, webappDistDir); pagesPath,
webappDistDir,
preloadModules
);
expressServer.start().catch((e) => { expressServer.start().catch((e) => {
console.error(e); console.error(e);
}); });

View File

@ -1,6 +1,10 @@
{ {
"name": "@silverbulletmd/web", "name": "@silverbulletmd/web",
"version": "0.0.1", "author": {
"name": "Zef Hemel",
"email": "zef@zef.me"
},
"version": "0.0.2",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"watch": "rm -rf .parcel-cache && parcel watch", "watch": "rm -rf .parcel-cache && parcel watch",
@ -18,6 +22,9 @@
"context": "browser" "context": "browser"
} }
}, },
"files": [
"dist"
],
"dependencies": { "dependencies": {
"@codemirror/autocomplete": "^0.19.1", "@codemirror/autocomplete": "^0.19.1",
"@codemirror/closebrackets": "^0.19.1", "@codemirror/closebrackets": "^0.19.1",