@tiddlywiki/mws 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.d.ts +6 -5
- package/dist/server.js +18 -26
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/server.d.ts
CHANGED
|
@@ -554,6 +554,9 @@ declare const Z2: Z2<FieldTypeGroups>;
|
|
|
554
554
|
declare global {
|
|
555
555
|
type PrismaTxnClient = Omit<Commander["engine"], "$connect" | "$disconnect" | "$on" | "$transaction" | "$use" | "$extends">;
|
|
556
556
|
type ART<T extends (...args: any) => any> = Awaited<ReturnType<T>>;
|
|
557
|
+
type Complete<T> = {
|
|
558
|
+
[K in keyof T]-?: T[K];
|
|
559
|
+
};
|
|
557
560
|
/**
|
|
558
561
|
* This primarily makes sure that positional arguments are used correctly
|
|
559
562
|
* (so you can't switch a title and bag_name around).
|
|
@@ -774,10 +777,8 @@ declare class StreamerState {
|
|
|
774
777
|
}
|
|
775
778
|
|
|
776
779
|
declare function startupCache(rootRoute: rootRoute, commander: Commander): Promise<{
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
tiddlerFiles: Map<string, string>;
|
|
780
|
-
tiddlerHashes: Map<string, string>;
|
|
780
|
+
tiddlerFiles: Map<any, any>;
|
|
781
|
+
tiddlerHashes: Map<any, any>;
|
|
781
782
|
}>;
|
|
782
783
|
type CacheState = ART<typeof startupCache>;
|
|
783
784
|
|
|
@@ -888,7 +889,7 @@ interface MWSConfigConfig {
|
|
|
888
889
|
readonly pathPrefix?: string;
|
|
889
890
|
readonly enablePluginCache?: boolean;
|
|
890
891
|
}
|
|
891
|
-
interface SiteConfig extends MWSConfigConfig {
|
|
892
|
+
interface SiteConfig extends Complete<MWSConfigConfig> {
|
|
892
893
|
wikiPath: string;
|
|
893
894
|
attachmentSizeLimit: number;
|
|
894
895
|
attachmentsEnabled: boolean;
|
package/dist/server.js
CHANGED
|
@@ -152,8 +152,8 @@ var init_global = __esm({
|
|
|
152
152
|
});
|
|
153
153
|
};
|
|
154
154
|
__Result = class __Result {
|
|
155
|
-
constructor(
|
|
156
|
-
this.ok =
|
|
155
|
+
constructor(ok7, error, value) {
|
|
156
|
+
this.ok = ok7;
|
|
157
157
|
this.error = error;
|
|
158
158
|
this.value = value;
|
|
159
159
|
}
|
|
@@ -14366,8 +14366,7 @@ var init_bag_file_server = __esm({
|
|
|
14366
14366
|
fields: true
|
|
14367
14367
|
},
|
|
14368
14368
|
where: {
|
|
14369
|
-
is_deleted: false
|
|
14370
|
-
bag: { is_plugin: false }
|
|
14369
|
+
is_deleted: false
|
|
14371
14370
|
}
|
|
14372
14371
|
}
|
|
14373
14372
|
}
|
|
@@ -14991,21 +14990,13 @@ var init_setupDevServer = __esm({
|
|
|
14991
14990
|
});
|
|
14992
14991
|
|
|
14993
14992
|
// src/routes/cache.ts
|
|
14994
|
-
import { ok as ok4 } from "assert";
|
|
14995
14993
|
import * as fs2 from "fs";
|
|
14996
14994
|
import * as path3 from "path";
|
|
14997
14995
|
import * as crypto from "crypto";
|
|
14998
14996
|
async function startupCache(rootRoute2, commander2) {
|
|
14999
14997
|
const $tw2 = commander2.$tw;
|
|
15000
|
-
|
|
15001
|
-
const
|
|
15002
|
-
ok4(coreTiddler);
|
|
15003
|
-
const tiddlerMemoryCache = new Map([
|
|
15004
|
-
...bootTiddlers.map((e) => e.title && [e.title, JSON.stringify(e)]).filter(truthy),
|
|
15005
|
-
[coreTiddler.title, JSON.stringify(coreTiddler)]
|
|
15006
|
-
]);
|
|
15007
|
-
const tiddlerFileCache = /* @__PURE__ */ new Map();
|
|
15008
|
-
const { tiddlerFiles, tiddlerHashes } = await importTW5(path3.join($tw2.boot.corePath, ".."), commander2.cachePath, "client", $tw2);
|
|
14998
|
+
console.log(commander2.siteConfig.enablePluginCache);
|
|
14999
|
+
const { tiddlerFiles, tiddlerHashes } = commander2.siteConfig.enablePluginCache ? await importTW5(path3.join($tw2.boot.corePath, ".."), commander2.cachePath, "client", $tw2) : { tiddlerFiles: /* @__PURE__ */ new Map(), tiddlerHashes: /* @__PURE__ */ new Map() };
|
|
15009
15000
|
rootRoute2.defineRoute({
|
|
15010
15001
|
method: ["GET", "HEAD"],
|
|
15011
15002
|
path: /^\/\$cache\/(.*)\/plugin\.js$/,
|
|
@@ -15020,7 +15011,7 @@ async function startupCache(rootRoute2, commander2) {
|
|
|
15020
15011
|
reqpath: state.pathParams.plugin + "/plugin.js"
|
|
15021
15012
|
});
|
|
15022
15013
|
});
|
|
15023
|
-
return {
|
|
15014
|
+
return { tiddlerFiles, tiddlerHashes };
|
|
15024
15015
|
}
|
|
15025
15016
|
async function importTW5(twFolder, cacheFolder, type, $tw2) {
|
|
15026
15017
|
const readLevel = /* @__PURE__ */ __name((d) => {
|
|
@@ -15180,14 +15171,14 @@ var init_router = __esm({
|
|
|
15180
15171
|
return this.siteConfig.pathPrefix;
|
|
15181
15172
|
}
|
|
15182
15173
|
handleIncomingRequest(req, res) {
|
|
15183
|
-
const [
|
|
15174
|
+
const [ok7, err, streamer] = function() {
|
|
15184
15175
|
try {
|
|
15185
15176
|
return [true, void 0, new Streamer(req, res, this)];
|
|
15186
15177
|
} catch (e) {
|
|
15187
15178
|
return [false, e, void 0];
|
|
15188
15179
|
}
|
|
15189
15180
|
}.call(this);
|
|
15190
|
-
if (!
|
|
15181
|
+
if (!ok7) {
|
|
15191
15182
|
if (err === STREAM_ENDED) return;
|
|
15192
15183
|
res.writeHead(500, { "x-reason": "handle incoming request" }).end();
|
|
15193
15184
|
throw err;
|
|
@@ -15358,7 +15349,7 @@ var init_router = __esm({
|
|
|
15358
15349
|
|
|
15359
15350
|
// src/tiddlywiki.ts
|
|
15360
15351
|
import { TiddlyWiki as TiddlyWiki2 } from "tiddlywiki";
|
|
15361
|
-
import { ok as
|
|
15352
|
+
import { ok as ok4 } from "node:assert";
|
|
15362
15353
|
async function bootTiddlyWiki(wikiPath) {
|
|
15363
15354
|
const $tw2 = TiddlyWiki2();
|
|
15364
15355
|
$tw2.utils.eachAsync = eachAsync;
|
|
@@ -15402,7 +15393,7 @@ async function bootTiddlyWiki(wikiPath) {
|
|
|
15402
15393
|
// this should be inert
|
|
15403
15394
|
];
|
|
15404
15395
|
await new Promise((resolve13) => $tw2.boot.boot(resolve13));
|
|
15405
|
-
|
|
15396
|
+
ok4(!$tw2.boot.tasks.readBrowserTiddlers);
|
|
15406
15397
|
return $tw2;
|
|
15407
15398
|
}
|
|
15408
15399
|
var init_tiddlywiki = __esm({
|
|
@@ -19817,7 +19808,7 @@ __export(listen_exports, {
|
|
|
19817
19808
|
ListenerHTTPS: () => ListenerHTTPS,
|
|
19818
19809
|
info: () => info7
|
|
19819
19810
|
});
|
|
19820
|
-
import { ok as
|
|
19811
|
+
import { ok as ok5 } from "assert";
|
|
19821
19812
|
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
19822
19813
|
import { createServer } from "http";
|
|
19823
19814
|
import * as http2 from "node:http2";
|
|
@@ -19874,8 +19865,8 @@ var init_listen = __esm({
|
|
|
19874
19865
|
const { port, host } = config;
|
|
19875
19866
|
if (port && typeof port !== "number") throw new Error("If specified, port must be a number");
|
|
19876
19867
|
const bindInfo = host ? `HTTPS ${host} ${port}` : `HTTPS ${port}`;
|
|
19877
|
-
|
|
19878
|
-
|
|
19868
|
+
ok5(config.key && existsSync4(config.key), "Key file not found");
|
|
19869
|
+
ok5(config.cert && existsSync4(config.cert), "Cert file not found");
|
|
19879
19870
|
const key = readFileSync3(config.key);
|
|
19880
19871
|
const cert = readFileSync3(config.cert);
|
|
19881
19872
|
super(http2.createSecureServer({ key, cert, allowHTTP1: true }), router, bindInfo);
|
|
@@ -20181,7 +20172,7 @@ var init_sqlite_adapter = __esm({
|
|
|
20181
20172
|
import * as path5 from "node:path";
|
|
20182
20173
|
import { PrismaClient as PrismaClient2 } from "@prisma/client";
|
|
20183
20174
|
import { existsSync as existsSync6, mkdirSync as mkdirSync3, readFileSync as readFileSync4 } from "node:fs";
|
|
20184
|
-
import { ok as
|
|
20175
|
+
import { ok as ok6 } from "node:assert";
|
|
20185
20176
|
var _StartupCommander, StartupCommander, _Commander, Commander;
|
|
20186
20177
|
var init_commander = __esm({
|
|
20187
20178
|
"src/commander.ts"() {
|
|
@@ -20202,8 +20193,8 @@ var init_commander = __esm({
|
|
|
20202
20193
|
this.setupRequired = true;
|
|
20203
20194
|
this.fieldModules = $tw2.Tiddler.fieldModules;
|
|
20204
20195
|
if (config.config?.pathPrefix) {
|
|
20205
|
-
|
|
20206
|
-
|
|
20196
|
+
ok6(config.config.pathPrefix.startsWith("/"), "pathPrefix must start with a slash");
|
|
20197
|
+
ok6(!config.config.pathPrefix.endsWith("/"), "pathPrefix must not end with a slash");
|
|
20207
20198
|
}
|
|
20208
20199
|
this.wikiPath = config.wikiPath;
|
|
20209
20200
|
this.storePath = path5.resolve(this.wikiPath, "store");
|
|
@@ -20226,7 +20217,8 @@ var init_commander = __esm({
|
|
|
20226
20217
|
contentTypeInfo: $tw2.config.contentTypeInfo,
|
|
20227
20218
|
storePath: this.storePath,
|
|
20228
20219
|
pathPrefix: config.config?.pathPrefix ?? "",
|
|
20229
|
-
saveLargeTextToFileSystem: void 0
|
|
20220
|
+
saveLargeTextToFileSystem: void 0,
|
|
20221
|
+
enablePluginCache: config.config?.enablePluginCache ?? false
|
|
20230
20222
|
};
|
|
20231
20223
|
this.SessionManager = config.SessionManager || SessionManager;
|
|
20232
20224
|
this.AttachmentService = config.AttachmentService || AttachmentService;
|