Plugbox cleanup
parent
24ceaea9d5
commit
a97bff60d9
|
@ -4,3 +4,4 @@ logo.pxd
|
||||||
node_modules
|
node_modules
|
||||||
.parcel-cache
|
.parcel-cache
|
||||||
dist
|
dist
|
||||||
|
generated
|
|
@ -1,9 +0,0 @@
|
||||||
import {syscall} from "./syscall.ts";
|
|
||||||
|
|
||||||
export async function put(key: string, value: any) {
|
|
||||||
return await syscall("db.put", key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function get(key: string) {
|
|
||||||
return await syscall("db.get", key);
|
|
||||||
}
|
|
|
@ -6,10 +6,11 @@
|
||||||
"main": "dist/bundle.js",
|
"main": "dist/bundle.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "parcel build",
|
"build": "parcel build",
|
||||||
"core": "node dist/bundle.js --debug core/core.plugin.json ../webapp/src/generated/core.plugin.json"
|
"check": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"esbuild": "^0.14.24",
|
"esbuild": "^0.14.24",
|
||||||
|
"idb": "^7.0.0",
|
||||||
"typescript": ">=3.0.0",
|
"typescript": ">=3.0.0",
|
||||||
"vm2": "^3.9.9",
|
"vm2": "^3.9.9",
|
||||||
"yargs": "^17.3.1"
|
"yargs": "^17.3.1"
|
||||||
|
|
|
@ -6,7 +6,7 @@ import yargs from "yargs";
|
||||||
import { hideBin } from "yargs/helpers";
|
import { hideBin } from "yargs/helpers";
|
||||||
import { Manifest } from "../../webapp/src/plugins/types";
|
import { Manifest } from "../../webapp/src/plugins/types";
|
||||||
|
|
||||||
async function compile(filePath: string, sourceMap: string) {
|
async function compile(filePath: string, sourceMap: boolean) {
|
||||||
let tempFile = "out.js";
|
let tempFile = "out.js";
|
||||||
let js = await esbuild.build({
|
let js = await esbuild.build({
|
||||||
entryPoints: [filePath],
|
entryPoints: [filePath],
|
||||||
|
@ -25,7 +25,7 @@ async function compile(filePath: string, sourceMap: string) {
|
||||||
return jsCode;
|
return jsCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bundle(manifestPath, sourceMaps) {
|
async function bundle(manifestPath: string, sourceMaps: boolean) {
|
||||||
const rootPath = path.dirname(manifestPath);
|
const rootPath = path.dirname(manifestPath);
|
||||||
const manifest = JSON.parse(
|
const manifest = JSON.parse(
|
||||||
(await readFile(manifestPath)).toString()
|
(await readFile(manifestPath)).toString()
|
||||||
|
@ -53,7 +53,7 @@ async function run() {
|
||||||
})
|
})
|
||||||
.parse();
|
.parse();
|
||||||
|
|
||||||
let generatedManifest = await bundle(args._[0], !!args.debug);
|
let generatedManifest = await bundle(args._[0] as string, !!args.debug);
|
||||||
writeFile(args._[1] as string, JSON.stringify(generatedManifest, null, 2));
|
writeFile(args._[1] as string, JSON.stringify(generatedManifest, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,6 @@ export class FunctionWorker {
|
||||||
private plugin: Plugin;
|
private plugin: Plugin;
|
||||||
|
|
||||||
constructor(plugin: Plugin, pathPrefix: string, name: string) {
|
constructor(plugin: Plugin, pathPrefix: string, name: string) {
|
||||||
// this.worker = new Worker(new URL("function_worker.ts", import.meta.url), {
|
|
||||||
// type: "classic",
|
|
||||||
// });
|
|
||||||
let worker = window.Worker;
|
let worker = window.Worker;
|
||||||
this.worker = new worker("/function_worker.js");
|
this.worker = new worker("/function_worker.js");
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
export function countWords(str: string): number {
|
||||||
|
var matches = str.match(/[\w\d\'\'-]+/gi);
|
||||||
|
return matches ? matches.length : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readingTime(wordCount: number): number {
|
||||||
|
// 225 is average word reading speed for adults
|
||||||
|
return Math.ceil(wordCount / 225);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function safeRun(fn: () => Promise<void>) {
|
||||||
|
fn().catch((e) => {
|
||||||
|
console.error(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function sleep(ms: number): Promise<void> {
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve();
|
||||||
|
}, ms);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isMacLike() {
|
||||||
|
return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"include": ["src/**/*", "../webapp/src/plugbox_browser/browser_system.ts"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "esnext",
|
||||||
|
"strict": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"module": "ESNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"allowSyntheticDefaultImports": true
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
||||||
|
BUILD=node ../plugbox/dist/bundle.js
|
||||||
|
|
||||||
|
core: *
|
||||||
|
${BUILD} --debug core/core.plug.json ../webapp/src/generated/core.plug.json
|
||||||
|
|
||||||
|
watch: *
|
||||||
|
ls -d core/* | entr make
|
|
@ -1,4 +1,4 @@
|
||||||
import { syscall } from "./lib/syscall.ts";
|
import { syscall } from "./lib/syscall";
|
||||||
|
|
||||||
export async function insertToday() {
|
export async function insertToday() {
|
||||||
let niceDate = new Date().toISOString().split("T")[0];
|
let niceDate = new Date().toISOString().split("T")[0];
|
|
@ -1,4 +1,4 @@
|
||||||
import { syscall } from "./lib/syscall.ts";
|
import { syscall } from "./lib/syscall";
|
||||||
|
|
||||||
export async function toggleH1() {
|
export async function toggleH1() {
|
||||||
await togglePrefix("# ");
|
await togglePrefix("# ");
|
|
@ -1,5 +1,5 @@
|
||||||
import { ClickEvent } from "../../webapp/src/app_event.ts";
|
import { ClickEvent } from "../../webapp/src/app_event";
|
||||||
import { syscall } from "./lib/syscall.ts";
|
import { syscall } from "./lib/syscall";
|
||||||
|
|
||||||
async function navigate(syntaxNode: any) {
|
async function navigate(syntaxNode: any) {
|
||||||
if (!syntaxNode) {
|
if (!syntaxNode) {
|
|
@ -1,5 +1,5 @@
|
||||||
import { ClickEvent } from "../../webapp/src/app_event.ts";
|
import { ClickEvent } from "../../webapp/src/app_event";
|
||||||
import { syscall } from "./lib/syscall.ts";
|
import { syscall } from "./lib/syscall";
|
||||||
|
|
||||||
export async function taskToggle(event: ClickEvent) {
|
export async function taskToggle(event: ClickEvent) {
|
||||||
let syntaxNode = await syscall("editor.getSyntaxNodeAtPos", event.pos);
|
let syntaxNode = await syscall("editor.getSyntaxNodeAtPos", event.pos);
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { syscall } from "./lib/syscall";
|
||||||
|
|
||||||
function countWords(str: string): number {
|
function countWords(str: string): number {
|
||||||
var matches = str.match(/[\w\d\'\'-]+/gi);
|
var matches = str.match(/[\w\d\'\'-]+/gi);
|
||||||
return matches ? matches.length : 0;
|
return matches ? matches.length : 0;
|
||||||
|
@ -8,8 +10,6 @@ function readingTime(wordCount: number): number {
|
||||||
return Math.ceil(wordCount / 225);
|
return Math.ceil(wordCount / 225);
|
||||||
}
|
}
|
||||||
|
|
||||||
import { syscall } from "./lib/syscall.ts";
|
|
||||||
|
|
||||||
export async function wordCount({ text }: { text: string }) {
|
export async function wordCount({ text }: { text: string }) {
|
||||||
let sysCallText = (await syscall("editor.getText")) as string;
|
let sysCallText = (await syscall("editor.getText")) as string;
|
||||||
const count = countWords(sysCallText);
|
const count = countWords(sysCallText);
|
|
@ -19,9 +19,20 @@
|
||||||
"@parcel/validator-typescript": "^2.3.2",
|
"@parcel/validator-typescript": "^2.3.2",
|
||||||
"@types/react": "^17.0.39",
|
"@types/react": "^17.0.39",
|
||||||
"@types/react-dom": "^17.0.11",
|
"@types/react-dom": "^17.0.11",
|
||||||
|
"assert": "^2.0.0",
|
||||||
|
"buffer": "^6.0.3",
|
||||||
|
"crypto-browserify": "^3.12.0",
|
||||||
|
"events": "^3.3.0",
|
||||||
|
"os-browserify": "^0.3.0",
|
||||||
"parcel": "^2.3.2",
|
"parcel": "^2.3.2",
|
||||||
|
"path-browserify": "^1.0.1",
|
||||||
|
"querystring-es3": "^0.2.1",
|
||||||
|
"stream-browserify": "^3.0.0",
|
||||||
|
"tty-browserify": "^0.0.1",
|
||||||
"typescript": ">=3.0.0",
|
"typescript": ">=3.0.0",
|
||||||
"uglify-js": "^3.15.1"
|
"uglify-js": "^3.15.1",
|
||||||
|
"url": "^0.11.0",
|
||||||
|
"util": "^0.12.4"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@lezer/common": "git://github.com/zefhemel/common.git#046c880d1fcab713cadad327a5b7d8bb5de6522c"
|
"@lezer/common": "git://github.com/zefhemel/common.git#046c880d1fcab713cadad327a5b7d8bb5de6522c"
|
||||||
|
|
|
@ -22,7 +22,7 @@ import {
|
||||||
|
|
||||||
import React, { useEffect, useReducer } from "react";
|
import React, { useEffect, useReducer } from "react";
|
||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
import coreManifest from "./generated/core.plugin.json";
|
import coreManifest from "./generated/core.plug.json";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
window.coreManifest = coreManifest;
|
window.coreManifest = coreManifest;
|
||||||
import { AppEvent, AppEventDispatcher, ClickEvent } from "./app_event";
|
import { AppEvent, AppEventDispatcher, ClickEvent } from "./app_event";
|
||||||
|
@ -36,9 +36,10 @@ import { lineWrapper } from "./lineWrapper";
|
||||||
import { markdown } from "./markdown";
|
import { markdown } from "./markdown";
|
||||||
import { IPageNavigator, PathPageNavigator } from "./navigator";
|
import { IPageNavigator, PathPageNavigator } from "./navigator";
|
||||||
import customMarkDown from "./parser";
|
import customMarkDown from "./parser";
|
||||||
import { BrowserSystem } from "./plugins/browser_system";
|
import { BrowserSystem } from "./plugbox_browser/browser_system";
|
||||||
import { Plugin } from "./plugins/runtime";
|
import { Plugin } from "../../plugbox/src/runtime";
|
||||||
import { slashCommandRegexp } from "./plugins/types";
|
import { slashCommandRegexp } from "../../plugbox/src/types";
|
||||||
|
|
||||||
import reducer from "./reducer";
|
import reducer from "./reducer";
|
||||||
import { smartQuoteKeymap } from "./smart_quotes";
|
import { smartQuoteKeymap } from "./smart_quotes";
|
||||||
import { Space } from "./space";
|
import { Space } from "./space";
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
import { PluginLoader, System } from "./runtime";
|
import { PluginLoader, System } from "../../../plugbox/src/runtime";
|
||||||
import { Manifest } from "./types";
|
import { Manifest } from "../../../plugbox/src/types";
|
||||||
import { sleep } from "../util";
|
import { sleep } from "../util";
|
||||||
|
|
||||||
export class BrowserLoader implements PluginLoader {
|
export class BrowserLoader implements PluginLoader {
|
||||||
|
@ -43,7 +43,7 @@ export class BrowserSystem extends System {
|
||||||
async bootServiceWorker() {
|
async bootServiceWorker() {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
let reg = navigator.serviceWorker.register(
|
let reg = navigator.serviceWorker.register(
|
||||||
new URL("../plugin_sw.ts", import.meta.url),
|
new URL("../plugbox_sw.ts", import.meta.url),
|
||||||
{
|
{
|
||||||
type: "module",
|
type: "module",
|
||||||
scope: "/",
|
scope: "/",
|
|
@ -1,12 +1,10 @@
|
||||||
import { Manifest } from "./plugins/types";
|
import { Manifest } from "../../plugbox/src/types";
|
||||||
|
|
||||||
import { openDB, wrap, unwrap } from "idb";
|
import { openDB } from "idb";
|
||||||
|
|
||||||
const rootUrl = location.origin + "/plugin";
|
const rootUrl = location.origin + "/plugin";
|
||||||
|
|
||||||
// Storing manifests in IndexedDB, y'all
|
// Storing manifests in IndexedDB, y'all
|
||||||
let manifestCache = caches.open("manifests");
|
|
||||||
|
|
||||||
const db = openDB("manifests-store", undefined, {
|
const db = openDB("manifests-store", undefined, {
|
||||||
upgrade(db) {
|
upgrade(db) {
|
||||||
db.createObjectStore("manifests");
|
db.createObjectStore("manifests");
|
|
@ -1,4 +1,4 @@
|
||||||
import { CommandDef } from "./plugins/types";
|
import { CommandDef } from "../../plugbox/src/types";
|
||||||
|
|
||||||
export type PageMeta = {
|
export type PageMeta = {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
966
webapp/yarn.lock
966
webapp/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue