Parcel upgrade and global dependency update

pull/3/head
Zef Hemel 2022-06-13 13:06:53 +02:00
parent 254a2e0736
commit 24ac6bbd25
12 changed files with 1680 additions and 1831 deletions

3162
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -16,14 +16,14 @@
"publish-all": "npm publish --access public --ws" "publish-all": "npm publish --access public --ws"
}, },
"devDependencies": { "devDependencies": {
"@parcel/core": "2.3.2", "@parcel/core": "2.6.0",
"@parcel/packager-raw-url": "2.3.2", "@parcel/packager-raw-url": "2.6.0",
"@parcel/service-worker": "2.3.2", "@parcel/service-worker": "2.6.0",
"@parcel/transformer-inline-string": "2.3.2", "@parcel/transformer-inline-string": "2.6.0",
"@parcel/transformer-sass": "2.3.2", "@parcel/transformer-sass": "2.6.0",
"@parcel/transformer-webmanifest": "2.3.2", "@parcel/transformer-webmanifest": "2.6.0",
"@parcel/validator-typescript": "2.3.2", "@parcel/validator-typescript": "2.6.0",
"parcel": "2.3.2", "parcel": "2.6.0",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"process": "^0.11.10", "process": "^0.11.10",
"ts-node": "^10.7.0", "ts-node": "^10.7.0",

View File

@ -65,13 +65,13 @@
}, },
"devDependencies": { "devDependencies": {
"@lezer/lr": "^0.15.0", "@lezer/lr": "^0.15.0",
"@parcel/optimizer-data-url": "2.3.2", "@parcel/optimizer-data-url": "2.6.0",
"@parcel/packager-raw-url": "2.3.2", "@parcel/packager-raw-url": "2.6.0",
"@parcel/service-worker": "2.3.2", "@parcel/service-worker": "2.6.0",
"@parcel/transformer-inline-string": "2.3.2", "@parcel/transformer-inline-string": "2.6.0",
"@parcel/transformer-sass": "2.3.2", "@parcel/transformer-sass": "2.6.0",
"@parcel/transformer-webmanifest": "2.3.2", "@parcel/transformer-webmanifest": "2.6.0",
"@parcel/validator-typescript": "2.3.2", "@parcel/validator-typescript": "2.6.0",
"@types/events": "^3.0.0", "@types/events": "^3.0.0",
"@types/jest": "^27.4.1", "@types/jest": "^27.4.1",
"@types/node": "^17.0.21", "@types/node": "^17.0.21",
@ -82,7 +82,7 @@
"@vscode/sqlite3": "^5.0.7", "@vscode/sqlite3": "^5.0.7",
"assert": "^2.0.0", "assert": "^2.0.0",
"events": "^3.3.0", "events": "^3.3.0",
"parcel": "2.3.2", "parcel": "2.6.0",
"prettier": "^2.5.1" "prettier": "^2.5.1"
} }
} }

View File

@ -1,55 +1,8 @@
import { sandboxCompile, sandboxCompileModule } from "../compile"; import { sandboxCompile, sandboxCompileModule } from "../compile";
import { SysCallMapping } from "../system"; import { SysCallMapping } from "../system";
import globalModules from "../../common/dist/global.plug.json"; // TODO: FIgure out a better way to do this
const builtinModules = ["yaml", "handlebars"];
import * as ts from "typescript";
type CompileError = {
message: string;
pos: number;
};
function checkTypeScript(scriptFile: string): void {
let program = ts.createProgram([scriptFile], {
noEmit: true,
allowJs: true,
});
let emitResult = program.emit();
let allDiagnostics = ts
.getPreEmitDiagnostics(program)
.concat(emitResult.diagnostics);
let errors: CompileError[] = [];
allDiagnostics.forEach((diagnostic) => {
if (diagnostic.file) {
let { line, character } = ts.getLineAndCharacterOfPosition(
diagnostic.file,
diagnostic.start!
);
let message = ts.flattenDiagnosticMessageText(
diagnostic.messageText,
"\n"
);
errors.push({
message: ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"),
pos: diagnostic.start!,
});
// console.log(
// `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`
// );
} else {
console.log(
ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
);
}
});
let exitCode = emitResult.emitSkipped ? 1 : 0;
console.log(`Process exiting with code '${exitCode}'.`);
process.exit(exitCode);
}
export function esbuildSyscalls(): SysCallMapping { export function esbuildSyscalls(): SysCallMapping {
return { return {
@ -71,17 +24,14 @@ export function esbuildSyscalls(): SysCallMapping {
functionName, functionName,
true, true,
[], [],
[...Object.keys(globalModules.dependencies), ...excludeModules] [...builtinModules, ...excludeModules]
); );
}, },
"esbuild.compileModule": async ( "esbuild.compileModule": async (
ctx, ctx,
moduleName: string moduleName: string
): Promise<string> => { ): Promise<string> => {
return await sandboxCompileModule( return await sandboxCompileModule(moduleName, builtinModules);
moduleName,
Object.keys(globalModules.dependencies)
);
}, },
}; };
} }

View File

@ -30,8 +30,7 @@ function $255163dfff8c42fb$export$6dcbc6776594ee95(tree, matchFn) {
return null; return null;
} }
function $255163dfff8c42fb$export$dddeb721bf64f8df(tree, nodeType) { function $255163dfff8c42fb$export$dddeb721bf64f8df(tree, nodeType) {
return $255163dfff8c42fb$export$b86407c733c9fe3(tree, (n)=>n.type === nodeType return $255163dfff8c42fb$export$b86407c733c9fe3(tree, (n)=>n.type === nodeType);
);
} }
function $255163dfff8c42fb$export$b86407c733c9fe3(tree, matchFn) { function $255163dfff8c42fb$export$b86407c733c9fe3(tree, matchFn) {
if (matchFn(tree)) return [ if (matchFn(tree)) return [
@ -62,8 +61,7 @@ function $255163dfff8c42fb$export$4d49acedd23f9b0a(tree, matchFn) {
return $255163dfff8c42fb$export$b86407c733c9fe3(tree, matchFn)[0]; return $255163dfff8c42fb$export$b86407c733c9fe3(tree, matchFn)[0];
} }
function $255163dfff8c42fb$export$80a8b4335833eeeb(tree, nodeType) { function $255163dfff8c42fb$export$80a8b4335833eeeb(tree, nodeType) {
return $255163dfff8c42fb$export$b86407c733c9fe3(tree, (n)=>n.type === nodeType return $255163dfff8c42fb$export$b86407c733c9fe3(tree, (n)=>n.type === nodeType)[0];
)[0];
} }
function $255163dfff8c42fb$export$a41716fb83443983(tree, pos) { function $255163dfff8c42fb$export$a41716fb83443983(tree, pos) {
if (pos < tree.from || pos > tree.to) return null; if (pos < tree.from || pos > tree.to) return null;
@ -158,12 +156,12 @@ function $88d466d5aaf7a497$export$98e6a39c04603d36(language, text) {
const $d85524f23de2149a$export$8f49e4af10703ce3 = $hVExJ$lezerlr.LRParser.deserialize({ const $d85524f23de2149a$export$8f49e4af10703ce3 = (0, $hVExJ$lezerlr.LRParser).deserialize({
version: 13, version: 13,
states: "&fOVQPOOOmQQO'#C^QOQPOOOtQPO'#C`OyQQO'#CkO!OQPO'#CmO!TQPO'#CnO!YQPO'#CoOOQO'#Cp'#CpO!_QQO,58xO!fQQO'#CcO#TQQO'#CaOOQO'#Ca'#CaOOQO,58z,58zO#lQPO,59VOOQO,59X,59XO#qQQO'#D`OOQO,59Y,59YOOQO,59Z,59ZOOQO-E6n-E6nO$YQQO,58}OtQPO,58|O$qQQO1G.qO%]QPO'#CrO%bQQO,59zOOQO'#Cg'#CgOOQO'#Ci'#CiO$YQQO'#CjOOQO'#Cd'#CdOOQO1G.i1G.iOOQO1G.h1G.hOOQO'#Cl'#ClOOQO7+$]7+$]OOQO,59^,59^OOQO-E6p-E6pO%yQPO'#C|O&RQPO,59UO$YQQO'#CqO&WQPO,59hOOQO1G.p1G.pOOQO,59],59]OOQO-E6o-E6o", states: "&fOVQPOOOmQQO'#C^QOQPOOOtQPO'#C`OyQQO'#CkO!OQPO'#CmO!TQPO'#CnO!YQPO'#CoOOQO'#Cp'#CpO!_QQO,58xO!fQQO'#CcO#TQQO'#CaOOQO'#Ca'#CaOOQO,58z,58zO#lQPO,59VOOQO,59X,59XO#qQQO'#D`OOQO,59Y,59YOOQO,59Z,59ZOOQO-E6n-E6nO$YQQO,58}OtQPO,58|O$qQQO1G.qO%]QPO'#CrO%bQQO,59zOOQO'#Cg'#CgOOQO'#Ci'#CiO$YQQO'#CjOOQO'#Cd'#CdOOQO1G.i1G.iOOQO1G.h1G.hOOQO'#Cl'#ClOOQO7+$]7+$]OOQO,59^,59^OOQO-E6p-E6pO%yQPO'#C|O&RQPO,59UO$YQQO'#CqO&WQPO,59hOOQO1G.p1G.pOOQO,59],59]OOQO-E6o-E6o",
stateData: "&`~OiOS~ORPO~OjRO|SO!QTO!RUO!TVO~OgQX~P[ORYO~O}^O~OX_O~OR`O~OYbO~OgQa~P[OkdOsdOtdOudOvdOwdOxdOydOzdO~O{eOgTXjTX|TX!QTX!RTX!TTX~ORfO~OqgOg!SXj!SX|!SX!Q!SX!R!SX!T!SX~OXlOYlO[lOliOmiOnjOokO~O!OoO!PoOg_ij_i|_i!Q_i!R_i!T_i~ORqO~OqgOg!Saj!Sa|!Sa!Q!Sa!R!Sa!T!Sa~OquOrpX~OrwO~OquOrpa~O", stateData: "&`~OiOS~ORPO~OjRO|SO!QTO!RUO!TVO~OgQX~P[ORYO~O}^O~OX_O~OR`O~OYbO~OgQa~P[OkdOsdOtdOudOvdOwdOxdOydOzdO~O{eOgTXjTX|TX!QTX!RTX!TTX~ORfO~OqgOg!SXj!SX|!SX!Q!SX!R!SX!T!SX~OXlOYlO[lOliOmiOnjOokO~O!OoO!PoOg_ij_i|_i!Q_i!R_i!T_i~ORqO~OqgOg!Saj!Sa|!Sa!Q!Sa!R!Sa!T!Sa~OquOrpX~OrwO~OquOrpa~O",
goto: "#d!TPP!UP!X!]!`!c!iPP!rP!r!r!X!w!X!X!X!z#Q#WPPPPPPPPP#^PPPPPPPPPPPPPPPPP#aRQOTWPXR]RR[RQZRRneQmdQskRxuVldkuRpfQXPRcXQvsRyvQh`RrhRtkRaU", goto: "#d!TPP!UP!X!]!`!c!iPP!rP!r!r!X!w!X!X!X!z#Q#WPPPPPPPPP#^PPPPPPPPPPPPPPPPP#aRQOTWPXR]RR[RQZRRneQmdQskRxuVldkuRpfQXPRcXQvsRyvQh`RrhRtkRaU",
nodeNames: " Program Query Name WhereClause LogicalExpr AndExpr FilterExpr Value Number String Bool Regex Null List OrderClause Order LimitClause SelectClause RenderClause", nodeNames: "\u26A0 Program Query Name WhereClause LogicalExpr AndExpr FilterExpr Value Number String Bool Regex Null List OrderClause Order LimitClause SelectClause RenderClause",
maxTerm: 51, maxTerm: 51,
skippedNodes: [ skippedNodes: [
0 0
@ -188,88 +186,88 @@ const $4ba3510c824e3aea$export$c5be9092dbf465c = self.syscall;
async function $2780e5830b4782c9$export$c3455d2d4767a60b(unfiltered = false) { async function $2780e5830b4782c9$export$c3455d2d4767a60b(unfiltered = false) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("space.listPages", unfiltered); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("space.listPages", unfiltered);
} }
async function $2780e5830b4782c9$export$126f79da5c357ad(name) { async function $2780e5830b4782c9$export$126f79da5c357ad(name) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("space.readPage", name); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("space.readPage", name);
} }
async function $2780e5830b4782c9$export$7ed3b3f07f54e00c(name, text) { async function $2780e5830b4782c9$export$7ed3b3f07f54e00c(name, text) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("space.writePage", name, text); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("space.writePage", name, text);
} }
async function $2780e5830b4782c9$export$2e9858c25869c949(name) { async function $2780e5830b4782c9$export$2e9858c25869c949(name) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("space.deletePage", name); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("space.deletePage", name);
} }
function $11a7e2bff790f35a$export$7945ba8eb1c827e6() { function $11a7e2bff790f35a$export$7945ba8eb1c827e6() {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.getCurrentPage"); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.getCurrentPage");
} }
function $11a7e2bff790f35a$export$5e830c5f3cd8a610(newName) { function $11a7e2bff790f35a$export$5e830c5f3cd8a610(newName) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.setPage", newName); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.setPage", newName);
} }
function $11a7e2bff790f35a$export$c72d34660a162238() { function $11a7e2bff790f35a$export$c72d34660a162238() {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.getText"); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.getText");
} }
function $11a7e2bff790f35a$export$da3f040fb23d21f() { function $11a7e2bff790f35a$export$da3f040fb23d21f() {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.getCursor"); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.getCursor");
} }
function $11a7e2bff790f35a$export$a1544dad697b423d() { function $11a7e2bff790f35a$export$a1544dad697b423d() {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.save"); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.save");
} }
function $11a7e2bff790f35a$export$ff7962acd6052c28(name, pos) { function $11a7e2bff790f35a$export$ff7962acd6052c28(name, pos) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.navigate", name, pos); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.navigate", name, pos);
} }
function $11a7e2bff790f35a$export$da22d4a5076a7905() { function $11a7e2bff790f35a$export$da22d4a5076a7905() {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.reloadPage"); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.reloadPage");
} }
function $11a7e2bff790f35a$export$a238cfe4a10e6279(url) { function $11a7e2bff790f35a$export$a238cfe4a10e6279(url) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.openUrl", url); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.openUrl", url);
} }
function $11a7e2bff790f35a$export$4f02334034b5dd8c(message) { function $11a7e2bff790f35a$export$4f02334034b5dd8c(message) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.flashNotification", message); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.flashNotification", message);
} }
function $11a7e2bff790f35a$export$83b9d7a71bc0a208(label, options, helpText = "", placeHolder = "") { function $11a7e2bff790f35a$export$83b9d7a71bc0a208(label, options, helpText = "", placeHolder = "") {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.filterBox", label, options, helpText, placeHolder); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.filterBox", label, options, helpText, placeHolder);
} }
function $11a7e2bff790f35a$export$53ed0b99a5f8822e(html, script, flex = 1) { function $11a7e2bff790f35a$export$53ed0b99a5f8822e(html, script, flex = 1) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.showRhs", html, script, flex); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.showRhs", html, script, flex);
} }
function $11a7e2bff790f35a$export$f19f28e8a128fabe() { function $11a7e2bff790f35a$export$f19f28e8a128fabe() {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.hideRhs"); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.hideRhs");
} }
function $11a7e2bff790f35a$export$dcf0ace441f4b3a4(html, script, flex = 1) { function $11a7e2bff790f35a$export$dcf0ace441f4b3a4(html, script, flex = 1) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.showLhs", html, script, flex); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.showLhs", html, script, flex);
} }
function $11a7e2bff790f35a$export$1be2ad20c6324dcf() { function $11a7e2bff790f35a$export$1be2ad20c6324dcf() {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.hideLhs"); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.hideLhs");
} }
function $11a7e2bff790f35a$export$6ebe231c70cc6efb(html, script, flex = 1) { function $11a7e2bff790f35a$export$6ebe231c70cc6efb(html, script, flex = 1) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.showBhs", html, script, flex); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.showBhs", html, script, flex);
} }
function $11a7e2bff790f35a$export$a7a5aa8ba1cd9dc3() { function $11a7e2bff790f35a$export$a7a5aa8ba1cd9dc3() {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.hideBhs"); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.hideBhs");
} }
function $11a7e2bff790f35a$export$f1124a4ce9f9bf29(text, pos) { function $11a7e2bff790f35a$export$f1124a4ce9f9bf29(text, pos) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.insertAtPos", text, pos); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.insertAtPos", text, pos);
} }
function $11a7e2bff790f35a$export$54cb80d99fa58e48(from, to, text) { function $11a7e2bff790f35a$export$54cb80d99fa58e48(from, to, text) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.replaceRange", from, to, text); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.replaceRange", from, to, text);
} }
function $11a7e2bff790f35a$export$185d1f0722e636b2(pos) { function $11a7e2bff790f35a$export$185d1f0722e636b2(pos) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.moveCursor", pos); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.moveCursor", pos);
} }
function $11a7e2bff790f35a$export$df659347c0c138a9(text) { function $11a7e2bff790f35a$export$df659347c0c138a9(text) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.insertAtCursor", text); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.insertAtCursor", text);
} }
function $11a7e2bff790f35a$export$c4c1b7dbe675fa50(re) { function $11a7e2bff790f35a$export$c4c1b7dbe675fa50(re) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.matchBefore", re); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.matchBefore", re);
} }
function $11a7e2bff790f35a$export$635e15bbd66f01ea(change) { function $11a7e2bff790f35a$export$635e15bbd66f01ea(change) {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.dispatch", change); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.dispatch", change);
} }
function $11a7e2bff790f35a$export$195ba6d62321b933(message, defaultValue = "") { function $11a7e2bff790f35a$export$195ba6d62321b933(message, defaultValue = "") {
return $4ba3510c824e3aea$export$c5be9092dbf465c("editor.prompt", message, defaultValue); return (0, $4ba3510c824e3aea$export$c5be9092dbf465c)("editor.prompt", message, defaultValue);
} }
@ -278,19 +276,19 @@ function $c3893eec0c49ec96$export$5dc1410f87262ed6(d) {
return d.toISOString().split("T")[0]; return d.toISOString().split("T")[0];
} }
async function $c3893eec0c49ec96$export$151bb3c215c78d5a() { async function $c3893eec0c49ec96$export$151bb3c215c78d5a() {
await $11a7e2bff790f35a$export$df659347c0c138a9($c3893eec0c49ec96$export$5dc1410f87262ed6(new Date())); await (0, $11a7e2bff790f35a$export$df659347c0c138a9)($c3893eec0c49ec96$export$5dc1410f87262ed6(new Date()));
} }
async function $c3893eec0c49ec96$export$2177dd573df27382() { async function $c3893eec0c49ec96$export$2177dd573df27382() {
let d = new Date(); let d = new Date();
d.setDate(d.getDate() + 1); d.setDate(d.getDate() + 1);
await $11a7e2bff790f35a$export$df659347c0c138a9($c3893eec0c49ec96$export$5dc1410f87262ed6(d)); await (0, $11a7e2bff790f35a$export$df659347c0c138a9)($c3893eec0c49ec96$export$5dc1410f87262ed6(d));
} }
function $9072202279b76d33$export$1e8473eaf75b0d10(query) { function $9072202279b76d33$export$1e8473eaf75b0d10(query) {
let n1 = $88d466d5aaf7a497$export$87cc1c28aef74af1(query, $d85524f23de2149a$export$8f49e4af10703ce3.parse(query).topNode); let n1 = (0, $88d466d5aaf7a497$export$87cc1c28aef74af1)(query, (0, $d85524f23de2149a$export$8f49e4af10703ce3).parse(query).topNode);
// Clean the tree a bit // Clean the tree a bit
$255163dfff8c42fb$export$90b8ac453fa63932(n1, (n)=>{ (0, $255163dfff8c42fb$export$90b8ac453fa63932)(n1, (n)=>{
if (!n.type) { if (!n.type) {
let trimmed = n.text.trim(); let trimmed = n.text.trim();
if (!trimmed) return null; if (!trimmed) return null;
@ -303,19 +301,19 @@ function $9072202279b76d33$export$1e8473eaf75b0d10(query) {
table: queryNode.children[0].children[0].text, table: queryNode.children[0].children[0].text,
filter: [] filter: []
}; };
let orderByNode = $255163dfff8c42fb$export$80a8b4335833eeeb(queryNode, "OrderClause"); let orderByNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(queryNode, "OrderClause");
if (orderByNode) { if (orderByNode) {
let nameNode = $255163dfff8c42fb$export$80a8b4335833eeeb(orderByNode, "Name"); let nameNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(orderByNode, "Name");
parsedQuery.orderBy = nameNode.children[0].text; parsedQuery.orderBy = nameNode.children[0].text;
let orderNode = $255163dfff8c42fb$export$80a8b4335833eeeb(orderByNode, "Order"); let orderNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(orderByNode, "Order");
parsedQuery.orderDesc = orderNode ? orderNode.children[0].text === "desc" : false; parsedQuery.orderDesc = orderNode ? orderNode.children[0].text === "desc" : false;
} }
let limitNode = $255163dfff8c42fb$export$80a8b4335833eeeb(queryNode, "LimitClause"); let limitNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(queryNode, "LimitClause");
if (limitNode) { if (limitNode) {
let nameNode = $255163dfff8c42fb$export$80a8b4335833eeeb(limitNode, "Number"); let nameNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(limitNode, "Number");
parsedQuery.limit = $9072202279b76d33$var$valueNodeToVal(nameNode); parsedQuery.limit = $9072202279b76d33$var$valueNodeToVal(nameNode);
} }
let filterNodes = $255163dfff8c42fb$export$dddeb721bf64f8df(queryNode, "FilterExpr"); let filterNodes = (0, $255163dfff8c42fb$export$dddeb721bf64f8df)(queryNode, "FilterExpr");
for (let filterNode of filterNodes){ for (let filterNode of filterNodes){
let val = undefined; let val = undefined;
let valNode = filterNode.children[2].children[0]; let valNode = filterNode.children[2].children[0];
@ -327,19 +325,19 @@ function $9072202279b76d33$export$1e8473eaf75b0d10(query) {
}; };
parsedQuery.filter.push(f); parsedQuery.filter.push(f);
} }
let selectNode = $255163dfff8c42fb$export$80a8b4335833eeeb(queryNode, "SelectClause"); let selectNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(queryNode, "SelectClause");
if (selectNode) { if (selectNode) {
// console.log("Select node", JSON.stringify(selectNode)); // console.log("Select node", JSON.stringify(selectNode));
parsedQuery.select = []; parsedQuery.select = [];
$255163dfff8c42fb$export$dddeb721bf64f8df(selectNode, "Name").forEach((t)=>{ (0, $255163dfff8c42fb$export$dddeb721bf64f8df)(selectNode, "Name").forEach((t)=>{
parsedQuery.select.push(t.children[0].text); parsedQuery.select.push(t.children[0].text);
}); });
// let nameNode = findNodeOfType(selectNode, "Number"); // let nameNode = findNodeOfType(selectNode, "Number");
// parsedQuery.limit = +nameNode!.children![0].text!; // parsedQuery.limit = +nameNode!.children![0].text!;
} }
let renderNode = $255163dfff8c42fb$export$80a8b4335833eeeb(queryNode, "RenderClause"); let renderNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(queryNode, "RenderClause");
if (renderNode) { if (renderNode) {
let renderNameNode = $255163dfff8c42fb$export$80a8b4335833eeeb(renderNode, "String"); let renderNameNode = (0, $255163dfff8c42fb$export$80a8b4335833eeeb)(renderNode, "String");
parsedQuery.render = $9072202279b76d33$var$valueNodeToVal(renderNameNode); parsedQuery.render = $9072202279b76d33$var$valueNodeToVal(renderNameNode);
} }
// console.log(JSON.stringify(queryNode, null, 2)); // console.log(JSON.stringify(queryNode, null, 2));
@ -362,8 +360,7 @@ function $9072202279b76d33$var$valueNodeToVal(valNode) {
let stringVal = valNode.children[0].text; let stringVal = valNode.children[0].text;
return stringVal.substring(1, stringVal.length - 1); return stringVal.substring(1, stringVal.length - 1);
case "List": case "List":
return $255163dfff8c42fb$export$dddeb721bf64f8df(valNode, "Value").map((t)=>$9072202279b76d33$var$valueNodeToVal(t.children[0]) return (0, $255163dfff8c42fb$export$dddeb721bf64f8df)(valNode, "Value").map((t)=>$9072202279b76d33$var$valueNodeToVal(t.children[0]));
);
} }
} }
function $9072202279b76d33$export$5884dae03c64f759(parsedQuery, records) { function $9072202279b76d33$export$5884dae03c64f759(parsedQuery, records) {
@ -413,8 +410,7 @@ function $9072202279b76d33$export$5884dae03c64f759(parsedQuery, records) {
}); });
if (parsedQuery.limit) resultRecords = resultRecords.slice(0, parsedQuery.limit); if (parsedQuery.limit) resultRecords = resultRecords.slice(0, parsedQuery.limit);
if (parsedQuery.select) resultRecords = resultRecords.map((rec)=>{ if (parsedQuery.select) resultRecords = resultRecords.map((rec)=>{
let newRec = { let newRec = {};
};
for (let k of parsedQuery.select)newRec[k] = rec[k]; for (let k of parsedQuery.select)newRec[k] = rec[k];
return newRec; return newRec;
}); });
@ -422,19 +418,17 @@ function $9072202279b76d33$export$5884dae03c64f759(parsedQuery, records) {
} }
async function $9072202279b76d33$export$b3c659c1456e61b0(parsedQuery, data) { async function $9072202279b76d33$export$b3c659c1456e61b0(parsedQuery, data) {
if (parsedQuery.render) { if (parsedQuery.render) {
($parcel$interopDefault($hVExJ$handlebars)).registerHelper("json", (v)=>JSON.stringify(v) (0, ($parcel$interopDefault($hVExJ$handlebars))).registerHelper("json", (v)=>JSON.stringify(v));
); (0, ($parcel$interopDefault($hVExJ$handlebars))).registerHelper("niceDate", (ts)=>(0, $c3893eec0c49ec96$export$5dc1410f87262ed6)(new Date(ts)));
($parcel$interopDefault($hVExJ$handlebars)).registerHelper("niceDate", (ts)=>$c3893eec0c49ec96$export$5dc1410f87262ed6(new Date(ts)) (0, ($parcel$interopDefault($hVExJ$handlebars))).registerHelper("yaml", (v, prefix)=>{
);
($parcel$interopDefault($hVExJ$handlebars)).registerHelper("yaml", (v, prefix)=>{
if (typeof prefix === "string") { if (typeof prefix === "string") {
let yaml = ($parcel$interopDefault($hVExJ$yaml)).stringify(v).split("\n").join("\n" + prefix).trim(); let yaml = (0, ($parcel$interopDefault($hVExJ$yaml))).stringify(v).split("\n").join("\n" + prefix).trim();
if (Array.isArray(v)) return "\n" + prefix + yaml; if (Array.isArray(v)) return "\n" + prefix + yaml;
else return yaml; else return yaml;
} else return ($parcel$interopDefault($hVExJ$yaml)).stringify(v).trim(); } else return (0, ($parcel$interopDefault($hVExJ$yaml))).stringify(v).trim();
}); });
let { text: templateText } = await $2780e5830b4782c9$export$126f79da5c357ad(parsedQuery.render); let { text: templateText } = await (0, $2780e5830b4782c9$export$126f79da5c357ad)(parsedQuery.render);
let template = ($parcel$interopDefault($hVExJ$handlebars)).compile(templateText, { let template = (0, ($parcel$interopDefault($hVExJ$handlebars))).compile(templateText, {
noEscape: true noEscape: true
}); });
return template(data); return template(data);
@ -443,49 +437,49 @@ async function $9072202279b76d33$export$b3c659c1456e61b0(parsedQuery, data) {
} }
$hVExJ$jestglobals.test("Test parser", ()=>{ (0, $hVExJ$jestglobals.test)("Test parser", ()=>{
let parsedBasicQuery = $9072202279b76d33$export$1e8473eaf75b0d10(`page`); let parsedBasicQuery = (0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page`);
$hVExJ$jestglobals.expect(parsedBasicQuery.table).toBe("page"); (0, $hVExJ$jestglobals.expect)(parsedBasicQuery.table).toBe("page");
let parsedQuery1 = $9072202279b76d33$export$1e8473eaf75b0d10(`task where completed = false and dueDate <= "{{today}}" order by dueDate desc limit 5`); let parsedQuery1 = (0, $9072202279b76d33$export$1e8473eaf75b0d10)(`task where completed = false and dueDate <= "{{today}}" order by dueDate desc limit 5`);
$hVExJ$jestglobals.expect(parsedQuery1.table).toBe("task"); (0, $hVExJ$jestglobals.expect)(parsedQuery1.table).toBe("task");
$hVExJ$jestglobals.expect(parsedQuery1.orderBy).toBe("dueDate"); (0, $hVExJ$jestglobals.expect)(parsedQuery1.orderBy).toBe("dueDate");
$hVExJ$jestglobals.expect(parsedQuery1.orderDesc).toBe(true); (0, $hVExJ$jestglobals.expect)(parsedQuery1.orderDesc).toBe(true);
$hVExJ$jestglobals.expect(parsedQuery1.limit).toBe(5); (0, $hVExJ$jestglobals.expect)(parsedQuery1.limit).toBe(5);
$hVExJ$jestglobals.expect(parsedQuery1.filter.length).toBe(2); (0, $hVExJ$jestglobals.expect)(parsedQuery1.filter.length).toBe(2);
$hVExJ$jestglobals.expect(parsedQuery1.filter[0]).toStrictEqual({ (0, $hVExJ$jestglobals.expect)(parsedQuery1.filter[0]).toStrictEqual({
op: "=", op: "=",
prop: "completed", prop: "completed",
value: false value: false
}); });
$hVExJ$jestglobals.expect(parsedQuery1.filter[1]).toStrictEqual({ (0, $hVExJ$jestglobals.expect)(parsedQuery1.filter[1]).toStrictEqual({
op: "<=", op: "<=",
prop: "dueDate", prop: "dueDate",
value: "{{today}}" value: "{{today}}"
}); });
let parsedQuery2 = $9072202279b76d33$export$1e8473eaf75b0d10(`page where name =~ /interview\\/.*/"`); let parsedQuery2 = (0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where name =~ /interview\\/.*/"`);
$hVExJ$jestglobals.expect(parsedQuery2.table).toBe("page"); (0, $hVExJ$jestglobals.expect)(parsedQuery2.table).toBe("page");
$hVExJ$jestglobals.expect(parsedQuery2.filter.length).toBe(1); (0, $hVExJ$jestglobals.expect)(parsedQuery2.filter.length).toBe(1);
$hVExJ$jestglobals.expect(parsedQuery2.filter[0]).toStrictEqual({ (0, $hVExJ$jestglobals.expect)(parsedQuery2.filter[0]).toStrictEqual({
op: "=~", op: "=~",
prop: "name", prop: "name",
value: "interview\\/.*" value: "interview\\/.*"
}); });
let parsedQuery3 = $9072202279b76d33$export$1e8473eaf75b0d10(`page where something != null`); let parsedQuery3 = (0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where something != null`);
$hVExJ$jestglobals.expect(parsedQuery3.table).toBe("page"); (0, $hVExJ$jestglobals.expect)(parsedQuery3.table).toBe("page");
$hVExJ$jestglobals.expect(parsedQuery3.filter.length).toBe(1); (0, $hVExJ$jestglobals.expect)(parsedQuery3.filter.length).toBe(1);
$hVExJ$jestglobals.expect(parsedQuery3.filter[0]).toStrictEqual({ (0, $hVExJ$jestglobals.expect)(parsedQuery3.filter[0]).toStrictEqual({
op: "!=", op: "!=",
prop: "something", prop: "something",
value: null value: null
}); });
$hVExJ$jestglobals.expect($9072202279b76d33$export$1e8473eaf75b0d10(`page select name`).select).toStrictEqual([ (0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page select name`).select).toStrictEqual([
"name" "name"
]); ]);
$hVExJ$jestglobals.expect($9072202279b76d33$export$1e8473eaf75b0d10(`page select name, age`).select).toStrictEqual([ (0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page select name, age`).select).toStrictEqual([
"name", "name",
"age", "age",
]); ]);
$hVExJ$jestglobals.expect($9072202279b76d33$export$1e8473eaf75b0d10(`gh-events where type in ["PushEvent", "somethingElse"]`)).toStrictEqual({ (0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`gh-events where type in ["PushEvent", "somethingElse"]`)).toStrictEqual({
table: "gh-events", table: "gh-events",
filter: [ filter: [
{ {
@ -498,13 +492,13 @@ $hVExJ$jestglobals.test("Test parser", ()=>{
}, },
] ]
}); });
$hVExJ$jestglobals.expect($9072202279b76d33$export$1e8473eaf75b0d10(`something render "template/table"`)).toStrictEqual({ (0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`something render "template/table"`)).toStrictEqual({
table: "something", table: "something",
filter: [], filter: [],
render: "template/table" render: "template/table"
}); });
}); });
$hVExJ$jestglobals.test("Test performing the queries", ()=>{ (0, $hVExJ$jestglobals.test)("Test performing the queries", ()=>{
let data = [ let data = [
{ {
name: "interview/My Interview", name: "interview/My Interview",
@ -523,7 +517,7 @@ $hVExJ$jestglobals.test("Test performing the queries", ()=>{
age: 28 age: 28
}, },
]; ];
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where name =~ /interview\\/.*/`), data)).toStrictEqual([ (0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where name =~ /interview\\/.*/`), data)).toStrictEqual([
{ {
name: "interview/My Interview", name: "interview/My Interview",
lastModified: 1 lastModified: 1
@ -533,7 +527,7 @@ $hVExJ$jestglobals.test("Test performing the queries", ()=>{
lastModified: 2 lastModified: 2
}, },
]); ]);
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where name =~ /interview\\/.*/ order by lastModified`), data)).toStrictEqual([ (0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where name =~ /interview\\/.*/ order by lastModified`), data)).toStrictEqual([
{ {
name: "interview/My Interview", name: "interview/My Interview",
lastModified: 1 lastModified: 1
@ -543,7 +537,7 @@ $hVExJ$jestglobals.test("Test performing the queries", ()=>{
lastModified: 2 lastModified: 2
}, },
]); ]);
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where name =~ /interview\\/.*/ order by lastModified desc`), data)).toStrictEqual([ (0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where name =~ /interview\\/.*/ order by lastModified desc`), data)).toStrictEqual([
{ {
name: "interview/My Interview 2", name: "interview/My Interview 2",
lastModified: 2 lastModified: 2
@ -553,19 +547,19 @@ $hVExJ$jestglobals.test("Test performing the queries", ()=>{
lastModified: 1 lastModified: 1
}, },
]); ]);
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where age > 30`), data)).toStrictEqual([ (0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where age > 30`), data)).toStrictEqual([
{ {
name: "Pete", name: "Pete",
age: 38 age: 38
}, },
]); ]);
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where age > 28 and age < 38`), data)).toStrictEqual([]); (0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where age > 28 and age < 38`), data)).toStrictEqual([]);
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where age > 30 select name`), data)).toStrictEqual([ (0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where age > 30 select name`), data)).toStrictEqual([
{ {
name: "Pete" name: "Pete"
} }
]); ]);
$hVExJ$jestglobals.expect($9072202279b76d33$export$5884dae03c64f759($9072202279b76d33$export$1e8473eaf75b0d10(`page where name in ["Pete"] select name`), data)).toStrictEqual([ (0, $hVExJ$jestglobals.expect)((0, $9072202279b76d33$export$5884dae03c64f759)((0, $9072202279b76d33$export$1e8473eaf75b0d10)(`page where name in ["Pete"] select name`), data)).toStrictEqual([
{ {
name: "Pete" name: "Pete"
} }

File diff suppressed because one or more lines are too long

View File

@ -8,8 +8,8 @@
"license": "MIT", "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 --dist ../common/dist global.plug.yaml && plugos-bundle --debug -w --dist dist --exclude @lezer/lr yaml handlebars -- */*.plug.yaml", "watch": "plugos-bundle --dist ../web/dist global.plug.yaml && plugos-bundle --debug -w --dist dist --exclude @lezer/lr yaml handlebars -- */*.plug.yaml",
"build": "plugos-bundle --dist ../common/dist global.plug.yaml && plugos-bundle --dist dist --exclude @lezer/lr yaml handlebars -- */*.plug.yaml", "build": "plugos-bundle --dist ../web/dist global.plug.yaml && plugos-bundle --dist dist --exclude @lezer/lr yaml handlebars -- */*.plug.yaml",
"test": "jest build/test" "test": "jest build/test"
}, },
"files": [ "files": [

View File

@ -17,7 +17,10 @@ import { NodeCronHook } from "@plugos/plugos/hooks/node_cron";
import { markdownSyscalls } from "@silverbulletmd/common/syscalls/markdown"; import { markdownSyscalls } from "@silverbulletmd/common/syscalls/markdown";
import { EventedSpacePrimitives } from "@silverbulletmd/common/spaces/evented_space_primitives"; import { EventedSpacePrimitives } from "@silverbulletmd/common/spaces/evented_space_primitives";
import { Space } from "@silverbulletmd/common/spaces/space"; import { Space } from "@silverbulletmd/common/spaces/space";
import { createSandbox } from "@plugos/plugos/environments/node_sandbox"; import {
createSandbox,
nodeModulesDir,
} from "@plugos/plugos/environments/node_sandbox";
import { jwtSyscalls } from "@plugos/plugos/syscalls/jwt"; import { jwtSyscalls } from "@plugos/plugos/syscalls/jwt";
import buildMarkdown from "@silverbulletmd/common/parser"; import buildMarkdown from "@silverbulletmd/common/parser";
import { loadMarkdownExtensions } from "@silverbulletmd/common/markdown_ext"; import { loadMarkdownExtensions } from "@silverbulletmd/common/markdown_ext";
@ -29,7 +32,14 @@ import { plugPrefix } from "@silverbulletmd/common/spaces/constants";
import { Authenticator } from "./auth"; import { Authenticator } from "./auth";
import sandboxSyscalls from "@plugos/plugos/syscalls/sandbox"; import sandboxSyscalls from "@plugos/plugos/syscalls/sandbox";
import globalModules from "../common/dist/global.plug.json"; // import globalModules from "../common/dist/global.plug.json";
const globalModules: any = JSON.parse(
readFileSync(
nodeModulesDir + "/node_modules/@silverbulletmd/web/dist/global.plug.json",
"utf-8"
)
);
import { safeRun } from "./util"; import { safeRun } from "./util";
import { import {
@ -38,6 +48,7 @@ import {
} from "@plugos/plugos/syscalls/fulltext.knex_sqlite"; } from "@plugos/plugos/syscalls/fulltext.knex_sqlite";
import { PlugSpacePrimitives } from "./hooks/plug_space_primitives"; import { PlugSpacePrimitives } from "./hooks/plug_space_primitives";
import { PageNamespaceHook } from "./hooks/page_namespace"; import { PageNamespaceHook } from "./hooks/page_namespace";
import { readFileSync } from "fs";
const safeFilename = /^[a-zA-Z0-9_\-\.]+$/; const safeFilename = /^[a-zA-Z0-9_\-\.]+$/;
@ -114,7 +125,7 @@ export class ExpressServer {
for (let [modName, code] of Object.entries( for (let [modName, code] of Object.entries(
globalModules.dependencies globalModules.dependencies
)) { )) {
await plug.sandbox.loadDependency(modName, code); await plug.sandbox.loadDependency(modName, code as string);
} }
}); });
}, },

View File

@ -66,12 +66,12 @@
"yargs": "^17.3.1" "yargs": "^17.3.1"
}, },
"devDependencies": { "devDependencies": {
"@parcel/packager-raw-url": "2.3.2", "@parcel/packager-raw-url": "2.6.0",
"@parcel/service-worker": "2.3.2", "@parcel/service-worker": "2.6.0",
"@parcel/transformer-inline-string": "2.3.2", "@parcel/transformer-inline-string": "2.6.0",
"@parcel/transformer-sass": "2.3.2", "@parcel/transformer-sass": "2.6.0",
"@parcel/transformer-webmanifest": "2.3.2", "@parcel/transformer-webmanifest": "2.6.0",
"@parcel/validator-typescript": "2.3.2", "@parcel/validator-typescript": "2.6.0",
"@types/cors": "^2.8.12", "@types/cors": "^2.8.12",
"@types/events": "^3.0.0", "@types/events": "^3.0.0",
"@types/express": "^4.17.13", "@types/express": "^4.17.13",
@ -79,7 +79,7 @@
"@types/node": "^17.0.21", "@types/node": "^17.0.21",
"@vscode/sqlite3": "^5.0.7", "@vscode/sqlite3": "^5.0.7",
"assert": "^2.0.0", "assert": "^2.0.0",
"parcel": "2.3.2", "parcel": "2.6.0",
"typescript": "^4.6.2" "typescript": "^4.6.2"
} }
} }

View File

@ -60,7 +60,7 @@ import { FilterList } from "./components/filter";
import { FilterOption, PageMeta } from "@silverbulletmd/common/types"; import { FilterOption, PageMeta } from "@silverbulletmd/common/types";
import { syntaxTree } from "@codemirror/language"; import { syntaxTree } from "@codemirror/language";
import sandboxSyscalls from "@plugos/plugos/syscalls/sandbox"; import sandboxSyscalls from "@plugos/plugos/syscalls/sandbox";
import globalModules from "../common/dist/global.plug.json"; // import globalModules from "../common/dist/global.plug.json";
class PageState { class PageState {
constructor( constructor(
@ -134,18 +134,6 @@ export class Editor {
sandboxSyscalls(this.system) sandboxSyscalls(this.system)
); );
this.system.on({
plugLoaded: (plug) => {
safeRun(async () => {
for (let [modName, code] of Object.entries(
globalModules.dependencies
)) {
await plug.sandbox.loadDependency(modName, code);
}
});
},
});
// Make keyboard shortcuts work even when the editor is in read only mode or not focused // Make keyboard shortcuts work even when the editor is in read only mode or not focused
window.addEventListener("keydown", (ev) => { window.addEventListener("keydown", (ev) => {
if (!this.editorView?.hasFocus) { if (!this.editorView?.hasFocus) {
@ -179,6 +167,22 @@ export class Editor {
} }
}); });
let globalModules: any = await (await fetch("/global.plug.json")).json();
console.log("Global modules", globalModules);
this.system.on({
plugLoaded: (plug) => {
safeRun(async () => {
for (let [modName, code] of Object.entries(
globalModules.dependencies
)) {
await plug.sandbox.loadDependency(modName, code as string);
}
});
},
});
this.space.on({ this.space.on({
pageChanged: (meta) => { pageChanged: (meta) => {
if (this.currentPage === meta.name) { if (this.currentPage === meta.name) {

View File

@ -55,19 +55,19 @@
"react-dom": "^17.0.2" "react-dom": "^17.0.2"
}, },
"devDependencies": { "devDependencies": {
"@parcel/packager-raw-url": "2.3.2", "@parcel/packager-raw-url": "2.6.0",
"@parcel/service-worker": "2.3.2", "@parcel/service-worker": "2.6.0",
"@parcel/transformer-inline-string": "2.3.2", "@parcel/transformer-inline-string": "2.6.0",
"@parcel/transformer-sass": "2.3.2", "@parcel/transformer-sass": "2.6.0",
"@parcel/transformer-webmanifest": "2.3.2", "@parcel/transformer-webmanifest": "2.6.0",
"@parcel/validator-typescript": "2.3.2", "@parcel/validator-typescript": "2.6.0",
"@types/cors": "^2.8.12", "@types/cors": "^2.8.12",
"@types/events": "^3.0.0", "@types/events": "^3.0.0",
"@types/jest": "^27.4.1", "@types/jest": "^27.4.1",
"@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", "assert": "^2.0.0",
"parcel": "2.3.2", "parcel": "2.6.0",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"typescript": "^4.6.2" "typescript": "^4.6.2"
} }

View File

@ -3,7 +3,7 @@ import { manifest, version } from "@parcel/service-worker";
async function install() { async function install() {
const cache = await caches.open(version); const cache = await caches.open(version);
// console.log("Installing", manifest, "version", version); // console.log("Installing", manifest, "version", version);
await cache.addAll(manifest); await cache.addAll([...manifest, "/global.plug.json"]);
// @ts-ignore // @ts-ignore
self.skipWaiting(); // This automatically enables the service worker, preventing from caching stuff forever if there's a page open self.skipWaiting(); // This automatically enables the service worker, preventing from caching stuff forever if there's a page open
// console.log("Installed"); // console.log("Installed");