@tiddlywiki/mws 0.2.3 → 0.2.5

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/mws.js CHANGED
@@ -1204,7 +1204,7 @@ var require_command = __commonJS({
1204
1204
  init_esm_shims();
1205
1205
  var EventEmitter3 = __require("events").EventEmitter;
1206
1206
  var childProcess = __require("child_process");
1207
- var path10 = __require("path");
1207
+ var path11 = __require("path");
1208
1208
  var fs5 = __require("fs");
1209
1209
  var process5 = __require("process");
1210
1210
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -2207,9 +2207,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2207
2207
  let launchWithNode = false;
2208
2208
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2209
2209
  function findFile(baseDir, baseName) {
2210
- const localBin = path10.resolve(baseDir, baseName);
2210
+ const localBin = path11.resolve(baseDir, baseName);
2211
2211
  if (fs5.existsSync(localBin)) return localBin;
2212
- if (sourceExt.includes(path10.extname(baseName))) return void 0;
2212
+ if (sourceExt.includes(path11.extname(baseName))) return void 0;
2213
2213
  const foundExt = sourceExt.find(
2214
2214
  (ext) => fs5.existsSync(`${localBin}${ext}`)
2215
2215
  );
@@ -2228,17 +2228,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
2228
2228
  } catch {
2229
2229
  resolvedScriptPath = this._scriptPath;
2230
2230
  }
2231
- executableDir = path10.resolve(
2232
- path10.dirname(resolvedScriptPath),
2231
+ executableDir = path11.resolve(
2232
+ path11.dirname(resolvedScriptPath),
2233
2233
  executableDir
2234
2234
  );
2235
2235
  }
2236
2236
  if (executableDir) {
2237
2237
  let localFile = findFile(executableDir, executableFile);
2238
2238
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2239
- const legacyName = path10.basename(
2239
+ const legacyName = path11.basename(
2240
2240
  this._scriptPath,
2241
- path10.extname(this._scriptPath)
2241
+ path11.extname(this._scriptPath)
2242
2242
  );
2243
2243
  if (legacyName !== this._name) {
2244
2244
  localFile = findFile(
@@ -2249,7 +2249,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2249
2249
  }
2250
2250
  executableFile = localFile || executableFile;
2251
2251
  }
2252
- launchWithNode = sourceExt.includes(path10.extname(executableFile));
2252
+ launchWithNode = sourceExt.includes(path11.extname(executableFile));
2253
2253
  let proc;
2254
2254
  if (process5.platform !== "win32") {
2255
2255
  if (launchWithNode) {
@@ -3097,7 +3097,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3097
3097
  * @return {Command}
3098
3098
  */
3099
3099
  nameFromFilename(filename) {
3100
- this._name = path10.basename(filename, path10.extname(filename));
3100
+ this._name = path11.basename(filename, path11.extname(filename));
3101
3101
  return this;
3102
3102
  }
3103
3103
  /**
@@ -3111,9 +3111,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3111
3111
  * @param {string} [path]
3112
3112
  * @return {(string|null|Command)}
3113
3113
  */
3114
- executableDir(path11) {
3115
- if (path11 === void 0) return this._executableDir;
3116
- this._executableDir = path11;
3114
+ executableDir(path12) {
3115
+ if (path12 === void 0) return this._executableDir;
3116
+ this._executableDir = path12;
3117
3117
  return this;
3118
3118
  }
3119
3119
  /**
@@ -21888,11 +21888,11 @@ var require_mime_types = __commonJS({
21888
21888
  return exts[0];
21889
21889
  }
21890
21890
  __name(extension, "extension");
21891
- function lookup(path10) {
21892
- if (!path10 || typeof path10 !== "string") {
21891
+ function lookup(path11) {
21892
+ if (!path11 || typeof path11 !== "string") {
21893
21893
  return false;
21894
21894
  }
21895
- var extension2 = extname2("x." + path10).toLowerCase().substr(1);
21895
+ var extension2 = extname2("x." + path11).toLowerCase().substr(1);
21896
21896
  if (!extension2) {
21897
21897
  return false;
21898
21898
  }
@@ -22850,6 +22850,9 @@ var ServerEvents = class extends EventEmitter {
22850
22850
  };
22851
22851
  var serverEvents = new ServerEvents();
22852
22852
 
22853
+ // packages/mws/src/index.ts
22854
+ import * as path10 from "path";
22855
+
22853
22856
  // packages/commander/src/index.ts
22854
22857
  init_esm_shims();
22855
22858
 
@@ -25779,10 +25782,10 @@ function cloneDef(schema) {
25779
25782
  return mergeDefs(schema._zod.def);
25780
25783
  }
25781
25784
  __name(cloneDef, "cloneDef");
25782
- function getElementAtPath(obj, path10) {
25783
- if (!path10)
25785
+ function getElementAtPath(obj, path11) {
25786
+ if (!path11)
25784
25787
  return obj;
25785
- return path10.reduce((acc, key) => acc?.[key], obj);
25788
+ return path11.reduce((acc, key) => acc?.[key], obj);
25786
25789
  }
25787
25790
  __name(getElementAtPath, "getElementAtPath");
25788
25791
  function promiseAllObject(promisesObj) {
@@ -26188,11 +26191,11 @@ function aborted(x, startIndex = 0) {
26188
26191
  return false;
26189
26192
  }
26190
26193
  __name(aborted, "aborted");
26191
- function prefixIssues(path10, issues) {
26194
+ function prefixIssues(path11, issues) {
26192
26195
  return issues.map((iss) => {
26193
26196
  var _a2;
26194
26197
  (_a2 = iss).path ?? (_a2.path = []);
26195
- iss.path.unshift(path10);
26198
+ iss.path.unshift(path11);
26196
26199
  return iss;
26197
26200
  });
26198
26201
  }
@@ -26394,7 +26397,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
26394
26397
  __name(formatError, "formatError");
26395
26398
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
26396
26399
  const result = { errors: [] };
26397
- const processError = /* @__PURE__ */ __name((error49, path10 = []) => {
26400
+ const processError = /* @__PURE__ */ __name((error49, path11 = []) => {
26398
26401
  var _a2, _b;
26399
26402
  for (const issue2 of error49.issues) {
26400
26403
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -26404,7 +26407,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
26404
26407
  } else if (issue2.code === "invalid_element") {
26405
26408
  processError({ issues: issue2.issues }, issue2.path);
26406
26409
  } else {
26407
- const fullpath = [...path10, ...issue2.path];
26410
+ const fullpath = [...path11, ...issue2.path];
26408
26411
  if (fullpath.length === 0) {
26409
26412
  result.errors.push(mapper(issue2));
26410
26413
  continue;
@@ -26437,8 +26440,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
26437
26440
  __name(treeifyError, "treeifyError");
26438
26441
  function toDotPath(_path) {
26439
26442
  const segs = [];
26440
- const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
26441
- for (const seg of path10) {
26443
+ const path11 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
26444
+ for (const seg of path11) {
26442
26445
  if (typeof seg === "number")
26443
26446
  segs.push(`[${seg}]`);
26444
26447
  else if (typeof seg === "symbol")
@@ -38852,13 +38855,13 @@ function resolveRef(ref, ctx) {
38852
38855
  if (!ref.startsWith("#")) {
38853
38856
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
38854
38857
  }
38855
- const path10 = ref.slice(1).split("/").filter(Boolean);
38856
- if (path10.length === 0) {
38858
+ const path11 = ref.slice(1).split("/").filter(Boolean);
38859
+ if (path11.length === 0) {
38857
38860
  return ctx.rootSchema;
38858
38861
  }
38859
38862
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
38860
- if (path10[0] === defsKey) {
38861
- const key = path10[1];
38863
+ if (path11[0] === defsKey) {
38864
+ const key = path11[1];
38862
38865
  if (!key || !ctx.defs[key]) {
38863
38866
  throw new Error(`Reference not found: ${ref}`);
38864
38867
  }
@@ -42669,10 +42672,10 @@ var ENCODINGS = {
42669
42672
  gzip: ".gz"
42670
42673
  };
42671
42674
  var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
42672
- var getStats = /* @__PURE__ */ __name((path10) => {
42675
+ var getStats = /* @__PURE__ */ __name((path11) => {
42673
42676
  let stats;
42674
42677
  try {
42675
- stats = statSync(path10);
42678
+ stats = statSync(path11);
42676
42679
  } catch {
42677
42680
  }
42678
42681
  return stats;
@@ -42706,29 +42709,29 @@ var serveStatic = /* @__PURE__ */ __name((options = { root: "" }) => {
42706
42709
  await options.onNotFound?.(c.req.path, c);
42707
42710
  return next();
42708
42711
  }
42709
- let path10 = join(root, !optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename);
42710
- let stats = getStats(path10);
42712
+ let path11 = join(root, !optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename);
42713
+ let stats = getStats(path11);
42711
42714
  if (stats && stats.isDirectory()) {
42712
42715
  const indexFile = options.index ?? "index.html";
42713
- path10 = join(path10, indexFile);
42714
- stats = getStats(path10);
42716
+ path11 = join(path11, indexFile);
42717
+ stats = getStats(path11);
42715
42718
  }
42716
42719
  if (!stats) {
42717
- await options.onNotFound?.(path10, c);
42720
+ await options.onNotFound?.(path11, c);
42718
42721
  return next();
42719
42722
  }
42720
- const mimeType = getMimeType(path10);
42723
+ const mimeType = getMimeType(path11);
42721
42724
  c.header("Content-Type", mimeType || "application/octet-stream");
42722
42725
  if (options.precompressed && (!mimeType || mimeType === "application/octet-stream" || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
42723
42726
  const acceptEncodingSet = new Set(c.req.header("Accept-Encoding")?.split(",").map((encoding) => encoding.trim()));
42724
42727
  for (const encoding of ENCODINGS_ORDERED_KEYS) {
42725
42728
  if (!acceptEncodingSet.has(encoding)) continue;
42726
- const precompressedStats = getStats(path10 + ENCODINGS[encoding]);
42729
+ const precompressedStats = getStats(path11 + ENCODINGS[encoding]);
42727
42730
  if (precompressedStats) {
42728
42731
  c.header("Content-Encoding", encoding);
42729
42732
  c.header("Vary", "Accept-Encoding", { append: true });
42730
42733
  stats = precompressedStats;
42731
- path10 = path10 + ENCODINGS[encoding];
42734
+ path11 = path11 + ENCODINGS[encoding];
42732
42735
  break;
42733
42736
  }
42734
42737
  }
@@ -42743,7 +42746,7 @@ var serveStatic = /* @__PURE__ */ __name((options = { root: "" }) => {
42743
42746
  result = c.body(null);
42744
42747
  } else if (!range) {
42745
42748
  c.header("Content-Length", size.toString());
42746
- result = c.body(createStreamBody(createReadStream(path10)), 200);
42749
+ result = c.body(createStreamBody(createReadStream(path11)), 200);
42747
42750
  } else {
42748
42751
  c.header("Accept-Ranges", "bytes");
42749
42752
  const parts = range.replace(/bytes=/, "").split("-", 2);
@@ -42751,7 +42754,7 @@ var serveStatic = /* @__PURE__ */ __name((options = { root: "" }) => {
42751
42754
  let end = parseInt(parts[1], 10) || size - 1;
42752
42755
  if (size < end - start + 1) end = size - 1;
42753
42756
  const chunksize = end - start + 1;
42754
- const stream = createReadStream(path10, {
42757
+ const stream = createReadStream(path11, {
42755
42758
  start,
42756
42759
  end
42757
42760
  });
@@ -42759,7 +42762,7 @@ var serveStatic = /* @__PURE__ */ __name((options = { root: "" }) => {
42759
42762
  c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
42760
42763
  result = c.body(createStreamBody(stream), 206);
42761
42764
  }
42762
- await options.onFound?.(path10, c);
42765
+ await options.onFound?.(path11, c);
42763
42766
  return result;
42764
42767
  };
42765
42768
  }, "serveStatic");
@@ -42781,26 +42784,26 @@ init_esm_shims();
42781
42784
 
42782
42785
  // node_modules/hono/dist/utils/url.js
42783
42786
  init_esm_shims();
42784
- var splitPath = /* @__PURE__ */ __name((path10) => {
42785
- const paths = path10.split("/");
42787
+ var splitPath = /* @__PURE__ */ __name((path11) => {
42788
+ const paths = path11.split("/");
42786
42789
  if (paths[0] === "") {
42787
42790
  paths.shift();
42788
42791
  }
42789
42792
  return paths;
42790
42793
  }, "splitPath");
42791
42794
  var splitRoutingPath = /* @__PURE__ */ __name((routePath) => {
42792
- const { groups, path: path10 } = extractGroupsFromPath(routePath);
42793
- const paths = splitPath(path10);
42795
+ const { groups, path: path11 } = extractGroupsFromPath(routePath);
42796
+ const paths = splitPath(path11);
42794
42797
  return replaceGroupMarks(paths, groups);
42795
42798
  }, "splitRoutingPath");
42796
- var extractGroupsFromPath = /* @__PURE__ */ __name((path10) => {
42799
+ var extractGroupsFromPath = /* @__PURE__ */ __name((path11) => {
42797
42800
  const groups = [];
42798
- path10 = path10.replace(/\{[^}]+\}/g, (match2, index) => {
42801
+ path11 = path11.replace(/\{[^}]+\}/g, (match2, index) => {
42799
42802
  const mark = `@${index}`;
42800
42803
  groups.push([mark, match2]);
42801
42804
  return mark;
42802
42805
  });
42803
- return { groups, path: path10 };
42806
+ return { groups, path: path11 };
42804
42807
  }, "extractGroupsFromPath");
42805
42808
  var replaceGroupMarks = /* @__PURE__ */ __name((paths, groups) => {
42806
42809
  for (let i = groups.length - 1; i >= 0; i--) {
@@ -42857,8 +42860,8 @@ var getPath = /* @__PURE__ */ __name((request) => {
42857
42860
  const queryIndex = url2.indexOf("?", i);
42858
42861
  const hashIndex = url2.indexOf("#", i);
42859
42862
  const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
42860
- const path10 = url2.slice(start, end);
42861
- return tryDecodeURI2(path10.includes("%25") ? path10.replace(/%25/g, "%2525") : path10);
42863
+ const path11 = url2.slice(start, end);
42864
+ return tryDecodeURI2(path11.includes("%25") ? path11.replace(/%25/g, "%2525") : path11);
42862
42865
  } else if (charCode === 63 || charCode === 35) {
42863
42866
  break;
42864
42867
  }
@@ -42875,11 +42878,11 @@ var mergePath = /* @__PURE__ */ __name((base, sub, ...rest) => {
42875
42878
  }
42876
42879
  return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
42877
42880
  }, "mergePath");
42878
- var checkOptionalParameter = /* @__PURE__ */ __name((path10) => {
42879
- if (path10.charCodeAt(path10.length - 1) !== 63 || !path10.includes(":")) {
42881
+ var checkOptionalParameter = /* @__PURE__ */ __name((path11) => {
42882
+ if (path11.charCodeAt(path11.length - 1) !== 63 || !path11.includes(":")) {
42880
42883
  return null;
42881
42884
  }
42882
- const segments = path10.split("/");
42885
+ const segments = path11.split("/");
42883
42886
  const results = [];
42884
42887
  let basePath = "";
42885
42888
  segments.forEach((segment) => {
@@ -43316,9 +43319,9 @@ var Streamer = class extends StreamerRequest {
43316
43319
  root: options.root,
43317
43320
  index: options.index,
43318
43321
  precompressed: options.precompressed,
43319
- onNotFound: /* @__PURE__ */ __name(async (path10, c) => {
43322
+ onNotFound: /* @__PURE__ */ __name(async (path11, c) => {
43320
43323
  if (options.on404)
43321
- await options.on404(path10, this);
43324
+ await options.on404(path11, this);
43322
43325
  else
43323
43326
  this.res.sendResponse(await c.notFound());
43324
43327
  }, "onNotFound")
@@ -43761,9 +43764,9 @@ var HonoRequest = class {
43761
43764
  */
43762
43765
  path;
43763
43766
  bodyCache = {};
43764
- constructor(request, path10 = "/", matchResult = [[]]) {
43767
+ constructor(request, path11 = "/", matchResult = [[]]) {
43765
43768
  this.raw = request;
43766
- this.path = path10;
43769
+ this.path = path11;
43767
43770
  this.#matchResult = matchResult;
43768
43771
  this.#validatedData = {};
43769
43772
  }
@@ -44527,8 +44530,8 @@ var Hono = class _Hono {
44527
44530
  return this;
44528
44531
  };
44529
44532
  });
44530
- this.on = (method, path10, ...handlers) => {
44531
- for (const p2 of [path10].flat()) {
44533
+ this.on = (method, path11, ...handlers) => {
44534
+ for (const p2 of [path11].flat()) {
44532
44535
  this.#path = p2;
44533
44536
  for (const m2 of [method].flat()) {
44534
44537
  handlers.map((handler) => {
@@ -44585,8 +44588,8 @@ var Hono = class _Hono {
44585
44588
  * app.route("/api", app2) // GET /api/user
44586
44589
  * ```
44587
44590
  */
44588
- route(path10, app) {
44589
- const subApp = this.basePath(path10);
44591
+ route(path11, app) {
44592
+ const subApp = this.basePath(path11);
44590
44593
  app.routes.map((r) => {
44591
44594
  let handler;
44592
44595
  if (app.errorHandler === errorHandler) {
@@ -44612,9 +44615,9 @@ var Hono = class _Hono {
44612
44615
  * const api = new Hono().basePath('/api')
44613
44616
  * ```
44614
44617
  */
44615
- basePath(path10) {
44618
+ basePath(path11) {
44616
44619
  const subApp = this.#clone();
44617
- subApp._basePath = mergePath(this._basePath, path10);
44620
+ subApp._basePath = mergePath(this._basePath, path11);
44618
44621
  return subApp;
44619
44622
  }
44620
44623
  /**
@@ -44688,7 +44691,7 @@ var Hono = class _Hono {
44688
44691
  * })
44689
44692
  * ```
44690
44693
  */
44691
- mount(path10, applicationHandler, options) {
44694
+ mount(path11, applicationHandler, options) {
44692
44695
  let replaceRequest;
44693
44696
  let optionHandler;
44694
44697
  if (options) {
@@ -44715,7 +44718,7 @@ var Hono = class _Hono {
44715
44718
  return [c.env, executionContext];
44716
44719
  };
44717
44720
  replaceRequest ||= (() => {
44718
- const mergedPath = mergePath(this._basePath, path10);
44721
+ const mergedPath = mergePath(this._basePath, path11);
44719
44722
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
44720
44723
  return (request) => {
44721
44724
  const url2 = new URL(request.url);
@@ -44730,19 +44733,19 @@ var Hono = class _Hono {
44730
44733
  }
44731
44734
  await next();
44732
44735
  }, "handler");
44733
- this.#addRoute(METHOD_NAME_ALL, mergePath(path10, "*"), handler);
44736
+ this.#addRoute(METHOD_NAME_ALL, mergePath(path11, "*"), handler);
44734
44737
  return this;
44735
44738
  }
44736
- #addRoute(method, path10, handler, baseRoutePath) {
44739
+ #addRoute(method, path11, handler, baseRoutePath) {
44737
44740
  method = method.toUpperCase();
44738
- path10 = mergePath(this._basePath, path10);
44741
+ path11 = mergePath(this._basePath, path11);
44739
44742
  const r = {
44740
44743
  basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
44741
- path: path10,
44744
+ path: path11,
44742
44745
  method,
44743
44746
  handler
44744
44747
  };
44745
- this.router.add(method, path10, [handler, r]);
44748
+ this.router.add(method, path11, [handler, r]);
44746
44749
  this.routes.push(r);
44747
44750
  }
44748
44751
  #handleError(err, c) {
@@ -44755,10 +44758,10 @@ var Hono = class _Hono {
44755
44758
  if (method === "HEAD") {
44756
44759
  return (async () => new Response(null, await this.#dispatch(request, executionCtx, env3, "GET")))();
44757
44760
  }
44758
- const path10 = this.getPath(request, { env: env3 });
44759
- const matchResult = this.router.match(method, path10);
44761
+ const path11 = this.getPath(request, { env: env3 });
44762
+ const matchResult = this.router.match(method, path11);
44760
44763
  const c = new Context(request, {
44761
- path: path10,
44764
+ path: path11,
44762
44765
  matchResult,
44763
44766
  env: env3,
44764
44767
  executionCtx,
@@ -44865,7 +44868,7 @@ init_esm_shims();
44865
44868
  // node_modules/hono/dist/router/reg-exp-router/matcher.js
44866
44869
  init_esm_shims();
44867
44870
  var emptyParam = [];
44868
- function match(method, path10) {
44871
+ function match(method, path11) {
44869
44872
  const matchers = this.buildAllMatchers();
44870
44873
  const match2 = /* @__PURE__ */ __name(((method2, path22) => {
44871
44874
  const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
@@ -44881,7 +44884,7 @@ function match(method, path10) {
44881
44884
  return [matcher[1][index], match3];
44882
44885
  }), "match2");
44883
44886
  this.match = match2;
44884
- return match2(method, path10);
44887
+ return match2(method, path11);
44885
44888
  }
44886
44889
  __name(match, "match");
44887
44890
 
@@ -45006,12 +45009,12 @@ var Trie = class {
45006
45009
  }
45007
45010
  #context = { varIndex: 0 };
45008
45011
  #root = new Node();
45009
- insert(path10, index, pathErrorCheckOnly) {
45012
+ insert(path11, index, pathErrorCheckOnly) {
45010
45013
  const paramAssoc = [];
45011
45014
  const groups = [];
45012
45015
  for (let i = 0; ; ) {
45013
45016
  let replaced = false;
45014
- path10 = path10.replace(/\{[^}]+\}/g, (m2) => {
45017
+ path11 = path11.replace(/\{[^}]+\}/g, (m2) => {
45015
45018
  const mark = `@\\${i}`;
45016
45019
  groups[i] = [mark, m2];
45017
45020
  i++;
@@ -45022,7 +45025,7 @@ var Trie = class {
45022
45025
  break;
45023
45026
  }
45024
45027
  }
45025
- const tokens = path10.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
45028
+ const tokens = path11.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
45026
45029
  for (let i = groups.length - 1; i >= 0; i--) {
45027
45030
  const [mark] = groups[i];
45028
45031
  for (let j2 = tokens.length - 1; j2 >= 0; j2--) {
@@ -45061,9 +45064,9 @@ var Trie = class {
45061
45064
  // node_modules/hono/dist/router/reg-exp-router/router.js
45062
45065
  var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
45063
45066
  var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
45064
- function buildWildcardRegExp(path10) {
45065
- return wildcardRegExpCache[path10] ??= new RegExp(
45066
- path10 === "*" ? "" : `^${path10.replace(
45067
+ function buildWildcardRegExp(path11) {
45068
+ return wildcardRegExpCache[path11] ??= new RegExp(
45069
+ path11 === "*" ? "" : `^${path11.replace(
45067
45070
  /\/\*$|([.\\+*[^\]$()])/g,
45068
45071
  (_2, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
45069
45072
  )}$`
@@ -45087,17 +45090,17 @@ function buildMatcherFromPreprocessedRoutes(routes) {
45087
45090
  );
45088
45091
  const staticMap = /* @__PURE__ */ Object.create(null);
45089
45092
  for (let i = 0, j2 = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
45090
- const [pathErrorCheckOnly, path10, handlers] = routesWithStaticPathFlag[i];
45093
+ const [pathErrorCheckOnly, path11, handlers] = routesWithStaticPathFlag[i];
45091
45094
  if (pathErrorCheckOnly) {
45092
- staticMap[path10] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
45095
+ staticMap[path11] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
45093
45096
  } else {
45094
45097
  j2++;
45095
45098
  }
45096
45099
  let paramAssoc;
45097
45100
  try {
45098
- paramAssoc = trie.insert(path10, j2, pathErrorCheckOnly);
45101
+ paramAssoc = trie.insert(path11, j2, pathErrorCheckOnly);
45099
45102
  } catch (e) {
45100
- throw e === PATH_ERROR ? new UnsupportedPathError(path10) : e;
45103
+ throw e === PATH_ERROR ? new UnsupportedPathError(path11) : e;
45101
45104
  }
45102
45105
  if (pathErrorCheckOnly) {
45103
45106
  continue;
@@ -45132,12 +45135,12 @@ function buildMatcherFromPreprocessedRoutes(routes) {
45132
45135
  return [regexp, handlerMap, staticMap];
45133
45136
  }
45134
45137
  __name(buildMatcherFromPreprocessedRoutes, "buildMatcherFromPreprocessedRoutes");
45135
- function findMiddleware(middleware, path10) {
45138
+ function findMiddleware(middleware, path11) {
45136
45139
  if (!middleware) {
45137
45140
  return void 0;
45138
45141
  }
45139
45142
  for (const k2 of Object.keys(middleware).sort((a, b2) => b2.length - a.length)) {
45140
- if (buildWildcardRegExp(k2).test(path10)) {
45143
+ if (buildWildcardRegExp(k2).test(path11)) {
45141
45144
  return [...middleware[k2]];
45142
45145
  }
45143
45146
  }
@@ -45155,7 +45158,7 @@ var RegExpRouter = class {
45155
45158
  this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
45156
45159
  this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
45157
45160
  }
45158
- add(method, path10, handler) {
45161
+ add(method, path11, handler) {
45159
45162
  const middleware = this.#middleware;
45160
45163
  const routes = this.#routes;
45161
45164
  if (!middleware || !routes) {
@@ -45170,18 +45173,18 @@ var RegExpRouter = class {
45170
45173
  });
45171
45174
  });
45172
45175
  }
45173
- if (path10 === "/*") {
45174
- path10 = "*";
45176
+ if (path11 === "/*") {
45177
+ path11 = "*";
45175
45178
  }
45176
- const paramCount = (path10.match(/\/:/g) || []).length;
45177
- if (/\*$/.test(path10)) {
45178
- const re2 = buildWildcardRegExp(path10);
45179
+ const paramCount = (path11.match(/\/:/g) || []).length;
45180
+ if (/\*$/.test(path11)) {
45181
+ const re2 = buildWildcardRegExp(path11);
45179
45182
  if (method === METHOD_NAME_ALL) {
45180
45183
  Object.keys(middleware).forEach((m2) => {
45181
- middleware[m2][path10] ||= findMiddleware(middleware[m2], path10) || findMiddleware(middleware[METHOD_NAME_ALL], path10) || [];
45184
+ middleware[m2][path11] ||= findMiddleware(middleware[m2], path11) || findMiddleware(middleware[METHOD_NAME_ALL], path11) || [];
45182
45185
  });
45183
45186
  } else {
45184
- middleware[method][path10] ||= findMiddleware(middleware[method], path10) || findMiddleware(middleware[METHOD_NAME_ALL], path10) || [];
45187
+ middleware[method][path11] ||= findMiddleware(middleware[method], path11) || findMiddleware(middleware[METHOD_NAME_ALL], path11) || [];
45185
45188
  }
45186
45189
  Object.keys(middleware).forEach((m2) => {
45187
45190
  if (method === METHOD_NAME_ALL || method === m2) {
@@ -45199,7 +45202,7 @@ var RegExpRouter = class {
45199
45202
  });
45200
45203
  return;
45201
45204
  }
45202
- const paths = checkOptionalParameter(path10) || [path10];
45205
+ const paths = checkOptionalParameter(path11) || [path11];
45203
45206
  for (let i = 0, len = paths.length; i < len; i++) {
45204
45207
  const path22 = paths[i];
45205
45208
  Object.keys(routes).forEach((m2) => {
@@ -45226,13 +45229,13 @@ var RegExpRouter = class {
45226
45229
  const routes = [];
45227
45230
  let hasOwnRoute = method === METHOD_NAME_ALL;
45228
45231
  [this.#middleware, this.#routes].forEach((r) => {
45229
- const ownRoute = r[method] ? Object.keys(r[method]).map((path10) => [path10, r[method][path10]]) : [];
45232
+ const ownRoute = r[method] ? Object.keys(r[method]).map((path11) => [path11, r[method][path11]]) : [];
45230
45233
  if (ownRoute.length !== 0) {
45231
45234
  hasOwnRoute ||= true;
45232
45235
  routes.push(...ownRoute);
45233
45236
  } else if (method !== METHOD_NAME_ALL) {
45234
45237
  routes.push(
45235
- ...Object.keys(r[METHOD_NAME_ALL]).map((path10) => [path10, r[METHOD_NAME_ALL][path10]])
45238
+ ...Object.keys(r[METHOD_NAME_ALL]).map((path11) => [path11, r[METHOD_NAME_ALL][path11]])
45236
45239
  );
45237
45240
  }
45238
45241
  });
@@ -45262,13 +45265,13 @@ var SmartRouter = class {
45262
45265
  constructor(init) {
45263
45266
  this.#routers = init.routers;
45264
45267
  }
45265
- add(method, path10, handler) {
45268
+ add(method, path11, handler) {
45266
45269
  if (!this.#routes) {
45267
45270
  throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
45268
45271
  }
45269
- this.#routes.push([method, path10, handler]);
45272
+ this.#routes.push([method, path11, handler]);
45270
45273
  }
45271
- match(method, path10) {
45274
+ match(method, path11) {
45272
45275
  if (!this.#routes) {
45273
45276
  throw new Error("Fatal error");
45274
45277
  }
@@ -45283,7 +45286,7 @@ var SmartRouter = class {
45283
45286
  for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
45284
45287
  router.add(...routes[i2]);
45285
45288
  }
45286
- res = router.match(method, path10);
45289
+ res = router.match(method, path11);
45287
45290
  } catch (e) {
45288
45291
  if (e instanceof UnsupportedPathError) {
45289
45292
  continue;
@@ -45343,10 +45346,10 @@ var Node2 = class _Node2 {
45343
45346
  }
45344
45347
  this.#patterns = [];
45345
45348
  }
45346
- insert(method, path10, handler) {
45349
+ insert(method, path11, handler) {
45347
45350
  this.#order = ++this.#order;
45348
45351
  let curNode = this;
45349
- const parts = splitRoutingPath(path10);
45352
+ const parts = splitRoutingPath(path11);
45350
45353
  const possibleKeys = [];
45351
45354
  for (let i = 0, len = parts.length; i < len; i++) {
45352
45355
  const p2 = parts[i];
@@ -45395,12 +45398,12 @@ var Node2 = class _Node2 {
45395
45398
  }
45396
45399
  }
45397
45400
  }
45398
- search(method, path10) {
45401
+ search(method, path11) {
45399
45402
  const handlerSets = [];
45400
45403
  this.#params = emptyParams;
45401
45404
  const curNode = this;
45402
45405
  let curNodes = [curNode];
45403
- const parts = splitPath(path10);
45406
+ const parts = splitPath(path11);
45404
45407
  const curNodesQueue = [];
45405
45408
  const len = parts.length;
45406
45409
  let partOffsets = null;
@@ -45442,13 +45445,13 @@ var Node2 = class _Node2 {
45442
45445
  if (matcher instanceof RegExp) {
45443
45446
  if (partOffsets === null) {
45444
45447
  partOffsets = new Array(len);
45445
- let offset = path10[0] === "/" ? 1 : 0;
45448
+ let offset = path11[0] === "/" ? 1 : 0;
45446
45449
  for (let p2 = 0; p2 < len; p2++) {
45447
45450
  partOffsets[p2] = offset;
45448
45451
  offset += parts[p2].length + 1;
45449
45452
  }
45450
45453
  }
45451
- const restPathString = path10.substring(partOffsets[i]);
45454
+ const restPathString = path11.substring(partOffsets[i]);
45452
45455
  const m2 = matcher.exec(restPathString);
45453
45456
  if (m2) {
45454
45457
  params[name] = m2[0];
@@ -45504,18 +45507,18 @@ var TrieRouter = class {
45504
45507
  constructor() {
45505
45508
  this.#node = new Node2();
45506
45509
  }
45507
- add(method, path10, handler) {
45508
- const results = checkOptionalParameter(path10);
45510
+ add(method, path11, handler) {
45511
+ const results = checkOptionalParameter(path11);
45509
45512
  if (results) {
45510
45513
  for (let i = 0, len = results.length; i < len; i++) {
45511
45514
  this.#node.insert(method, results[i], handler);
45512
45515
  }
45513
45516
  return;
45514
45517
  }
45515
- this.#node.insert(method, path10, handler);
45518
+ this.#node.insert(method, path11, handler);
45516
45519
  }
45517
- match(method, path10) {
45518
- return this.#node.search(method, path10);
45520
+ match(method, path11) {
45521
+ return this.#node.search(method, path11);
45519
45522
  }
45520
45523
  };
45521
45524
 
@@ -45709,212 +45712,15 @@ var superHeaderClasses = {
45709
45712
  "vary": Vary
45710
45713
  };
45711
45714
 
45712
- // prisma/client/internal/prismaNamespace.ts
45713
- var prismaNamespace_exports = {};
45714
- __export(prismaNamespace_exports, {
45715
- AnyNull: () => AnyNull2,
45716
- BagPermissionScalarFieldEnum: () => BagPermissionScalarFieldEnum,
45717
- BagScalarFieldEnum: () => BagScalarFieldEnum,
45718
- DbNull: () => DbNull2,
45719
- Decimal: () => Decimal2,
45720
- JsonNull: () => JsonNull2,
45721
- JsonNullValueFilter: () => JsonNullValueFilter,
45722
- JsonNullValueInput: () => JsonNullValueInput,
45723
- ModelName: () => ModelName,
45724
- NullTypes: () => NullTypes2,
45725
- NullsOrder: () => NullsOrder,
45726
- PrismaClientInitializationError: () => PrismaClientInitializationError2,
45727
- PrismaClientKnownRequestError: () => PrismaClientKnownRequestError2,
45728
- PrismaClientRustPanicError: () => PrismaClientRustPanicError2,
45729
- PrismaClientUnknownRequestError: () => PrismaClientUnknownRequestError2,
45730
- PrismaClientValidationError: () => PrismaClientValidationError2,
45731
- QueryMode: () => QueryMode,
45732
- RecipeBagScalarFieldEnum: () => RecipeBagScalarFieldEnum,
45733
- RecipePermissionScalarFieldEnum: () => RecipePermissionScalarFieldEnum,
45734
- RecipeScalarFieldEnum: () => RecipeScalarFieldEnum,
45735
- RolesScalarFieldEnum: () => RolesScalarFieldEnum,
45736
- SessionsScalarFieldEnum: () => SessionsScalarFieldEnum,
45737
- SettingsScalarFieldEnum: () => SettingsScalarFieldEnum,
45738
- SortOrder: () => SortOrder,
45739
- Sql: () => Sql2,
45740
- TemplatePermissionScalarFieldEnum: () => TemplatePermissionScalarFieldEnum,
45741
- TemplateScalarFieldEnum: () => TemplateScalarFieldEnum,
45742
- TiddlerEventScalarFieldEnum: () => TiddlerEventScalarFieldEnum,
45743
- TiddlerScalarFieldEnum: () => TiddlerScalarFieldEnum,
45744
- TransactionIsolationLevel: () => TransactionIsolationLevel,
45745
- UsersScalarFieldEnum: () => UsersScalarFieldEnum,
45746
- defineExtension: () => defineExtension,
45747
- empty: () => empty2,
45748
- getExtensionContext: () => getExtensionContext,
45749
- join: () => join3,
45750
- prismaVersion: () => prismaVersion,
45751
- raw: () => raw3,
45752
- sql: () => sql
45753
- });
45754
- init_esm_shims();
45755
- import * as runtime from "@prisma/client/runtime/client";
45756
- var PrismaClientKnownRequestError2 = runtime.PrismaClientKnownRequestError;
45757
- var PrismaClientUnknownRequestError2 = runtime.PrismaClientUnknownRequestError;
45758
- var PrismaClientRustPanicError2 = runtime.PrismaClientRustPanicError;
45759
- var PrismaClientInitializationError2 = runtime.PrismaClientInitializationError;
45760
- var PrismaClientValidationError2 = runtime.PrismaClientValidationError;
45761
- var sql = runtime.sqltag;
45762
- var empty2 = runtime.empty;
45763
- var join3 = runtime.join;
45764
- var raw3 = runtime.raw;
45765
- var Sql2 = runtime.Sql;
45766
- var Decimal2 = runtime.Decimal;
45767
- var getExtensionContext = runtime.Extensions.getExtensionContext;
45768
- var prismaVersion = {
45769
- client: "7.8.0",
45770
- engine: "3c6e192761c0362d496ed980de936e2f3cebcd3a"
45771
- };
45772
- var NullTypes2 = {
45773
- DbNull: runtime.NullTypes.DbNull,
45774
- JsonNull: runtime.NullTypes.JsonNull,
45775
- AnyNull: runtime.NullTypes.AnyNull
45776
- };
45777
- var DbNull2 = runtime.DbNull;
45778
- var JsonNull2 = runtime.JsonNull;
45779
- var AnyNull2 = runtime.AnyNull;
45780
- var ModelName = {
45781
- Bag: "Bag",
45782
- BagPermission: "BagPermission",
45783
- Tiddler: "Tiddler",
45784
- TiddlerEvent: "TiddlerEvent",
45785
- Template: "Template",
45786
- TemplatePermission: "TemplatePermission",
45787
- Recipe: "Recipe",
45788
- RecipePermission: "RecipePermission",
45789
- RecipeBag: "RecipeBag",
45790
- Settings: "Settings",
45791
- Roles: "Roles",
45792
- Users: "Users",
45793
- Sessions: "Sessions"
45794
- };
45795
- var TransactionIsolationLevel = runtime.makeStrictEnum({
45796
- Serializable: "Serializable"
45797
- });
45798
- var BagScalarFieldEnum = {
45799
- id: "id",
45800
- name: "name",
45801
- created: "created",
45802
- updated: "updated",
45803
- description: "description"
45804
- };
45805
- var BagPermissionScalarFieldEnum = {
45806
- bag_id: "bag_id",
45807
- role_id: "role_id",
45808
- level: "level"
45809
- };
45810
- var TiddlerScalarFieldEnum = {
45811
- bag_id: "bag_id",
45812
- title: "title",
45813
- created: "created",
45814
- updated: "updated",
45815
- revision: "revision",
45816
- fields: "fields"
45817
- };
45818
- var TiddlerEventScalarFieldEnum = {
45819
- seq: "seq",
45820
- bag_id: "bag_id",
45821
- title: "title",
45822
- type: "type"
45823
- };
45824
- var TemplateScalarFieldEnum = {
45825
- id: "id",
45826
- name: "name",
45827
- created: "created",
45828
- updated: "updated",
45829
- type: "type",
45830
- definition: "definition"
45831
- };
45832
- var TemplatePermissionScalarFieldEnum = {
45833
- template_id: "template_id",
45834
- role_id: "role_id",
45835
- level: "level"
45836
- };
45837
- var RecipeScalarFieldEnum = {
45838
- id: "id",
45839
- slug: "slug",
45840
- created: "created",
45841
- updated: "updated",
45842
- template_id: "template_id",
45843
- definition: "definition",
45844
- plugins: "plugins",
45845
- compiledAt: "compiledAt"
45846
- };
45847
- var RecipePermissionScalarFieldEnum = {
45848
- recipe_id: "recipe_id",
45849
- role_id: "role_id",
45850
- level: "level"
45851
- };
45852
- var RecipeBagScalarFieldEnum = {
45853
- recipe_id: "recipe_id",
45854
- bag_id: "bag_id",
45855
- priority: "priority",
45856
- is_writable: "is_writable",
45857
- prefix: "prefix"
45858
- };
45859
- var SettingsScalarFieldEnum = {
45860
- key: "key",
45861
- value: "value",
45862
- updated: "updated"
45863
- };
45864
- var RolesScalarFieldEnum = {
45865
- role_id: "role_id",
45866
- role_name: "role_name",
45867
- description: "description"
45868
- };
45869
- var UsersScalarFieldEnum = {
45870
- user_id: "user_id",
45871
- username: "username",
45872
- email: "email",
45873
- password: "password",
45874
- resetCode: "resetCode",
45875
- created_at: "created_at",
45876
- last_login: "last_login"
45877
- };
45878
- var SessionsScalarFieldEnum = {
45879
- session_id: "session_id",
45880
- created_at: "created_at",
45881
- last_accessed: "last_accessed",
45882
- session_key: "session_key",
45883
- user_id: "user_id"
45884
- };
45885
- var SortOrder = {
45886
- asc: "asc",
45887
- desc: "desc"
45888
- };
45889
- var JsonNullValueInput = {
45890
- JsonNull: JsonNull2
45891
- };
45892
- var JsonNullValueFilter = {
45893
- DbNull: DbNull2,
45894
- JsonNull: JsonNull2,
45895
- AnyNull: AnyNull2
45896
- };
45897
- var QueryMode = {
45898
- default: "default",
45899
- insensitive: "insensitive"
45900
- };
45901
- var NullsOrder = {
45902
- first: "first",
45903
- last: "last"
45904
- };
45905
- var defineExtension = runtime.Extensions.defineExtension;
45906
-
45907
45715
  // packages/server/src/router.ts
45908
45716
  var debug = (0, import_debug.default)("mws:router:matching");
45909
45717
  var debugnomatch = (0, import_debug.default)("mws:router:nomatch");
45910
- var catcher = /* @__PURE__ */ __name((errorKey, err) => {
45718
+ var catcher = /* @__PURE__ */ __name((errorKey, err, inner) => {
45911
45719
  if (err === STREAM_ENDED) return;
45912
- if (!err.skiplog)
45913
- console.log(errorKey, err);
45914
45720
  if (err instanceof Error && err.name === "AbortError") return;
45915
- if (err instanceof PrismaClientKnownRequestError2) {
45916
- console.log(err.meta?.driverAdapterError?.cause);
45917
- }
45721
+ inner(err);
45722
+ if (!err) console.log("A falsey error was thrown");
45723
+ if (typeof err !== "object" || !err.skiplog) console.log(errorKey, err);
45918
45724
  if (!(err instanceof SendError)) {
45919
45725
  err = new SendError("INTERNAL_SERVER_ERROR", 500, {
45920
45726
  message: "Internal Server Error. Details have been logged."
@@ -46019,13 +45825,15 @@ var Router = class _Router {
46019
45825
  get fetch() {
46020
45826
  return this.hono.fetch;
46021
45827
  }
45828
+ catcherInner = /* @__PURE__ */ __name((e) => {
45829
+ }, "catcherInner");
46022
45830
  routeHandlerMiddleware = createMiddleware((c, next) => {
46023
45831
  let resolve11;
46024
45832
  const prom = new Promise((r) => {
46025
45833
  resolve11 = r;
46026
45834
  });
46027
45835
  this.handleHonoRequest(c, resolve11, next).catch((err) => {
46028
- const err2 = catcher(`${c.req.method} ${c.req.url}`, err);
45836
+ const err2 = catcher(`${c.req.method} ${c.req.url}`, err, this.catcherInner);
46029
45837
  if (!err2)
46030
45838
  return;
46031
45839
  if (err2.reason === "REDIRECT")
@@ -46224,28 +46032,28 @@ var registerZodRoutes = /* @__PURE__ */ __name((parent, router, keys) => {
46224
46032
  defineZodRoute(parent, key, router[key]);
46225
46033
  });
46226
46034
  }, "registerZodRoutes");
46227
- function buildPathRegex(path10, key, keyReplacer) {
46228
- if (!path10.startsWith("/")) throw new Error(`Path ${path10} must start with a forward slash`);
46035
+ function buildPathRegex(path11, key, keyReplacer) {
46036
+ if (!path11.startsWith("/")) throw new Error(`Path ${path11} must start with a forward slash`);
46229
46037
  if (key.startsWith(":")) throw new Error(`Key ${key} must not start with a colon`);
46230
- if (path10 !== path10.trim()) throw new Error(`Path ${path10} must not have leading and trailing white space or line terminator characters`);
46231
- const parts = path10.split("/");
46038
+ if (path11 !== path11.trim()) throw new Error(`Path ${path11} must not have leading and trailing white space or line terminator characters`);
46039
+ const parts = path11.split("/");
46232
46040
  return "^" + parts.map((e, i) => {
46233
46041
  const last = i === parts.length - 1;
46234
46042
  if (e === "") {
46235
- if (!last && i !== 0) throw new Error(`Path ${path10} has an empty part at index ${i}`);
46043
+ if (!last && i !== 0) throw new Error(`Path ${path11} has an empty part at index ${i}`);
46236
46044
  return "";
46237
46045
  }
46238
46046
  const name = e.startsWith(":") && e.slice(1);
46239
46047
  if (e === keyReplacer) return key;
46240
46048
  if (!name) return e;
46241
- return last && !path10.endsWith("/") ? `(?<${name}>.+)` : `(?<${name}>[^/]+)`;
46242
- }).join("/") + (path10.endsWith("/") ? "(?=/)" : "$");
46049
+ return last && !path11.endsWith("/") ? `(?<${name}>.+)` : `(?<${name}>[^/]+)`;
46050
+ }).join("/") + (path11.endsWith("/") ? "(?=/)" : "$");
46243
46051
  }
46244
46052
  __name(buildPathRegex, "buildPathRegex");
46245
46053
  function defineZodRoute(parent, key, route) {
46246
46054
  const {
46247
46055
  method,
46248
- path: path10,
46056
+ path: path11,
46249
46057
  bodyFormat,
46250
46058
  registerError,
46251
46059
  keyReplacer,
@@ -46257,7 +46065,7 @@ function defineZodRoute(parent, key, route) {
46257
46065
  } = route;
46258
46066
  if (method.includes("OPTIONS") && method.length > 1)
46259
46067
  throw new Error(key + " includes OPTIONS. The OPTIONS method should be set on its own handler since it is path-specific and setting it more than once per path will result in confusing behavior.");
46260
- const pathregex = typeof path10 === "string" ? buildPathRegex(path10, key, keyReplacer ?? "") : path10;
46068
+ const pathregex = typeof path11 === "string" ? buildPathRegex(path11, key, keyReplacer ?? "") : path11;
46261
46069
  try {
46262
46070
  return parent.defineRoute({
46263
46071
  method,
@@ -46523,11 +46331,11 @@ import { readFileSync as readFileSync2 } from "fs";
46523
46331
  // packages/mws/src/new-managers/sessions.ts
46524
46332
  init_esm_shims();
46525
46333
  import { createHash, randomBytes } from "crypto";
46526
- function zodSession(path10, zodRequest, preflight, inner) {
46334
+ function zodSession(path11, zodRequest, preflight, inner) {
46527
46335
  return {
46528
46336
  ...zodRoute({
46529
46337
  method: ["POST"],
46530
- path: path10,
46338
+ path: path11,
46531
46339
  bodyFormat: "json",
46532
46340
  zodPathParams: /* @__PURE__ */ __name((z3) => ({}), "zodPathParams"),
46533
46341
  zodQueryKeys: [],
@@ -46540,7 +46348,7 @@ function zodSession(path10, zodRequest, preflight, inner) {
46540
46348
  return state.$transaction(async (prisma) => await inner(state, prisma));
46541
46349
  }, "inner")
46542
46350
  }),
46543
- path: path10
46351
+ path: path11
46544
46352
  };
46545
46353
  }
46546
46354
  __name(zodSession, "zodSession");
@@ -46878,7 +46686,7 @@ var ServerState = class {
46878
46686
  settings = [
46879
46687
  // { key: "siteTitle", description: "Title for the site", valueType: "string" },
46880
46688
  // { key: "siteDescription", description: "Description for the site", valueType: "string" },
46881
- { key: "enableExternalPlugins", description: "Serve TiddlyWiki plugins via script tags", valueType: "boolean" },
46689
+ // { key: "enableExternalPlugins", description: "Serve TiddlyWiki plugins via script tags", valueType: "boolean" },
46882
46690
  { key: "enableGzip", description: "Enable gzip compression for responses", valueType: "boolean" }
46883
46691
  // { key: "enableResponseCompression", description: "Compress server responses", valueType: "boolean" },
46884
46692
  // { key: "enableBrowserCache", description: "Enable browser caching of static assets", valueType: "boolean" },
@@ -46934,7 +46742,7 @@ var ServerState = class {
46934
46742
  init_esm_shims();
46935
46743
  import { existsSync as existsSync3, rmSync } from "fs";
46936
46744
  import { readFile, writeFile } from "fs/promises";
46937
- import { join as join4, relative, resolve as resolve2 } from "path";
46745
+ import { join as join2, relative, resolve as resolve2 } from "path";
46938
46746
  var import_escape_string_regexp = __toESM(require_escape_string_regexp(), 1);
46939
46747
  var DEV_HOST = process.env.MWS_DEV_HOST || "127.0.0.20";
46940
46748
  var DEV_FALLBACK = await readFile(dist_resolve("../public/.default.html"));
@@ -46985,7 +46793,7 @@ var css_placer_regex = (0, import_escape_string_regexp.default)("<!-- CSS entry
46985
46793
  var js_placer_regex = (0, import_escape_string_regexp.default)("<!-- JS entry files -->");
46986
46794
  var title_placer_regex = (0, import_escape_string_regexp.default)("<title></title>");
46987
46795
  async function generateHtml({ js: js2, css, publicdir, rootdir, title }) {
46988
- const indexFile = (await readFile(join4(rootdir, "index.html"), "utf8").catch((e) => {
46796
+ const indexFile = (await readFile(join2(rootdir, "index.html"), "utf8").catch((e) => {
46989
46797
  console.log(e);
46990
46798
  throw e;
46991
46799
  })).replaceAll(new RegExp(`([ ]+)${css_placer_regex}`, "g"), (_2, s3) => css.map((e) => `${s3}<link rel="stylesheet" href="${"$$js:pathPrefix$$"}/${e}" />`).join("\n")).replaceAll(new RegExp(`([ ]+)${js_placer_regex}`, "g"), (_2, s3) => js2.map((e) => `${s3}<script type="module" src="${"$$js:pathPrefix$$"}/${e}"></script>`).join("\n")).replaceAll(new RegExp(`([ ]+)${title_placer_regex}`, "g"), (_2, s3) => `${s3}<title>${title}</title>`);
@@ -47255,7 +47063,7 @@ import { fileURLToPath as fileURLToPath3 } from "url";
47255
47063
 
47256
47064
  // prisma/client/internal/class.ts
47257
47065
  init_esm_shims();
47258
- import * as runtime2 from "@prisma/client/runtime/client";
47066
+ import * as runtime from "@prisma/client/runtime/client";
47259
47067
  var config2 = {
47260
47068
  "previewFeatures": [
47261
47069
  "partialIndexes"
@@ -47294,10 +47102,205 @@ config2.compilerWasm = {
47294
47102
  importName: "./query_compiler_fast_bg.js"
47295
47103
  };
47296
47104
  function getPrismaClientClass() {
47297
- return runtime2.getPrismaClient(config2);
47105
+ return runtime.getPrismaClient(config2);
47298
47106
  }
47299
47107
  __name(getPrismaClientClass, "getPrismaClientClass");
47300
47108
 
47109
+ // prisma/client/internal/prismaNamespace.ts
47110
+ var prismaNamespace_exports = {};
47111
+ __export(prismaNamespace_exports, {
47112
+ AnyNull: () => AnyNull2,
47113
+ BagPermissionScalarFieldEnum: () => BagPermissionScalarFieldEnum,
47114
+ BagScalarFieldEnum: () => BagScalarFieldEnum,
47115
+ DbNull: () => DbNull2,
47116
+ Decimal: () => Decimal2,
47117
+ JsonNull: () => JsonNull2,
47118
+ JsonNullValueFilter: () => JsonNullValueFilter,
47119
+ JsonNullValueInput: () => JsonNullValueInput,
47120
+ ModelName: () => ModelName,
47121
+ NullTypes: () => NullTypes2,
47122
+ NullsOrder: () => NullsOrder,
47123
+ PrismaClientInitializationError: () => PrismaClientInitializationError2,
47124
+ PrismaClientKnownRequestError: () => PrismaClientKnownRequestError2,
47125
+ PrismaClientRustPanicError: () => PrismaClientRustPanicError2,
47126
+ PrismaClientUnknownRequestError: () => PrismaClientUnknownRequestError2,
47127
+ PrismaClientValidationError: () => PrismaClientValidationError2,
47128
+ QueryMode: () => QueryMode,
47129
+ RecipeBagScalarFieldEnum: () => RecipeBagScalarFieldEnum,
47130
+ RecipePermissionScalarFieldEnum: () => RecipePermissionScalarFieldEnum,
47131
+ RecipeScalarFieldEnum: () => RecipeScalarFieldEnum,
47132
+ RolesScalarFieldEnum: () => RolesScalarFieldEnum,
47133
+ SessionsScalarFieldEnum: () => SessionsScalarFieldEnum,
47134
+ SettingsScalarFieldEnum: () => SettingsScalarFieldEnum,
47135
+ SortOrder: () => SortOrder,
47136
+ Sql: () => Sql2,
47137
+ TemplatePermissionScalarFieldEnum: () => TemplatePermissionScalarFieldEnum,
47138
+ TemplateScalarFieldEnum: () => TemplateScalarFieldEnum,
47139
+ TiddlerEventScalarFieldEnum: () => TiddlerEventScalarFieldEnum,
47140
+ TiddlerScalarFieldEnum: () => TiddlerScalarFieldEnum,
47141
+ TransactionIsolationLevel: () => TransactionIsolationLevel,
47142
+ UsersScalarFieldEnum: () => UsersScalarFieldEnum,
47143
+ defineExtension: () => defineExtension,
47144
+ empty: () => empty2,
47145
+ getExtensionContext: () => getExtensionContext,
47146
+ join: () => join4,
47147
+ prismaVersion: () => prismaVersion,
47148
+ raw: () => raw3,
47149
+ sql: () => sql
47150
+ });
47151
+ init_esm_shims();
47152
+ import * as runtime2 from "@prisma/client/runtime/client";
47153
+ var PrismaClientKnownRequestError2 = runtime2.PrismaClientKnownRequestError;
47154
+ var PrismaClientUnknownRequestError2 = runtime2.PrismaClientUnknownRequestError;
47155
+ var PrismaClientRustPanicError2 = runtime2.PrismaClientRustPanicError;
47156
+ var PrismaClientInitializationError2 = runtime2.PrismaClientInitializationError;
47157
+ var PrismaClientValidationError2 = runtime2.PrismaClientValidationError;
47158
+ var sql = runtime2.sqltag;
47159
+ var empty2 = runtime2.empty;
47160
+ var join4 = runtime2.join;
47161
+ var raw3 = runtime2.raw;
47162
+ var Sql2 = runtime2.Sql;
47163
+ var Decimal2 = runtime2.Decimal;
47164
+ var getExtensionContext = runtime2.Extensions.getExtensionContext;
47165
+ var prismaVersion = {
47166
+ client: "7.8.0",
47167
+ engine: "3c6e192761c0362d496ed980de936e2f3cebcd3a"
47168
+ };
47169
+ var NullTypes2 = {
47170
+ DbNull: runtime2.NullTypes.DbNull,
47171
+ JsonNull: runtime2.NullTypes.JsonNull,
47172
+ AnyNull: runtime2.NullTypes.AnyNull
47173
+ };
47174
+ var DbNull2 = runtime2.DbNull;
47175
+ var JsonNull2 = runtime2.JsonNull;
47176
+ var AnyNull2 = runtime2.AnyNull;
47177
+ var ModelName = {
47178
+ Bag: "Bag",
47179
+ BagPermission: "BagPermission",
47180
+ Tiddler: "Tiddler",
47181
+ TiddlerEvent: "TiddlerEvent",
47182
+ Template: "Template",
47183
+ TemplatePermission: "TemplatePermission",
47184
+ Recipe: "Recipe",
47185
+ RecipePermission: "RecipePermission",
47186
+ RecipeBag: "RecipeBag",
47187
+ Settings: "Settings",
47188
+ Roles: "Roles",
47189
+ Users: "Users",
47190
+ Sessions: "Sessions"
47191
+ };
47192
+ var TransactionIsolationLevel = runtime2.makeStrictEnum({
47193
+ Serializable: "Serializable"
47194
+ });
47195
+ var BagScalarFieldEnum = {
47196
+ id: "id",
47197
+ name: "name",
47198
+ created: "created",
47199
+ updated: "updated",
47200
+ description: "description"
47201
+ };
47202
+ var BagPermissionScalarFieldEnum = {
47203
+ bag_id: "bag_id",
47204
+ role_id: "role_id",
47205
+ level: "level"
47206
+ };
47207
+ var TiddlerScalarFieldEnum = {
47208
+ bag_id: "bag_id",
47209
+ title: "title",
47210
+ created: "created",
47211
+ updated: "updated",
47212
+ revision: "revision",
47213
+ fields: "fields"
47214
+ };
47215
+ var TiddlerEventScalarFieldEnum = {
47216
+ seq: "seq",
47217
+ bag_id: "bag_id",
47218
+ title: "title",
47219
+ type: "type"
47220
+ };
47221
+ var TemplateScalarFieldEnum = {
47222
+ id: "id",
47223
+ name: "name",
47224
+ created: "created",
47225
+ updated: "updated",
47226
+ type: "type",
47227
+ definition: "definition"
47228
+ };
47229
+ var TemplatePermissionScalarFieldEnum = {
47230
+ template_id: "template_id",
47231
+ role_id: "role_id",
47232
+ level: "level"
47233
+ };
47234
+ var RecipeScalarFieldEnum = {
47235
+ id: "id",
47236
+ slug: "slug",
47237
+ created: "created",
47238
+ updated: "updated",
47239
+ template_id: "template_id",
47240
+ definition: "definition",
47241
+ plugins: "plugins",
47242
+ compiledAt: "compiledAt"
47243
+ };
47244
+ var RecipePermissionScalarFieldEnum = {
47245
+ recipe_id: "recipe_id",
47246
+ role_id: "role_id",
47247
+ level: "level"
47248
+ };
47249
+ var RecipeBagScalarFieldEnum = {
47250
+ recipe_id: "recipe_id",
47251
+ bag_id: "bag_id",
47252
+ priority: "priority",
47253
+ is_writable: "is_writable",
47254
+ prefix: "prefix"
47255
+ };
47256
+ var SettingsScalarFieldEnum = {
47257
+ key: "key",
47258
+ value: "value",
47259
+ updated: "updated"
47260
+ };
47261
+ var RolesScalarFieldEnum = {
47262
+ role_id: "role_id",
47263
+ role_name: "role_name",
47264
+ description: "description"
47265
+ };
47266
+ var UsersScalarFieldEnum = {
47267
+ user_id: "user_id",
47268
+ username: "username",
47269
+ email: "email",
47270
+ password: "password",
47271
+ resetCode: "resetCode",
47272
+ created_at: "created_at",
47273
+ last_login: "last_login"
47274
+ };
47275
+ var SessionsScalarFieldEnum = {
47276
+ session_id: "session_id",
47277
+ created_at: "created_at",
47278
+ last_accessed: "last_accessed",
47279
+ session_key: "session_key",
47280
+ user_id: "user_id"
47281
+ };
47282
+ var SortOrder = {
47283
+ asc: "asc",
47284
+ desc: "desc"
47285
+ };
47286
+ var JsonNullValueInput = {
47287
+ JsonNull: JsonNull2
47288
+ };
47289
+ var JsonNullValueFilter = {
47290
+ DbNull: DbNull2,
47291
+ JsonNull: JsonNull2,
47292
+ AnyNull: AnyNull2
47293
+ };
47294
+ var QueryMode = {
47295
+ default: "default",
47296
+ insensitive: "insensitive"
47297
+ };
47298
+ var NullsOrder = {
47299
+ first: "first",
47300
+ last: "last"
47301
+ };
47302
+ var defineExtension = runtime2.Extensions.defineExtension;
47303
+
47301
47304
  // prisma/client/enums.ts
47302
47305
  var enums_exports = {};
47303
47306
  __export(enums_exports, {
@@ -47420,7 +47423,8 @@ var SqliteAdapter = class {
47420
47423
  "===============================================================",
47421
47424
  "The database does not match the configured migrations. ",
47422
47425
  "Since you are in dev mode, you probably just need to ",
47423
- "delete the store folder and init a new database."
47426
+ "delete the store folder and init a new database.",
47427
+ "==============================================================="
47424
47428
  ].join("\n"));
47425
47429
  process.exit(1);
47426
47430
  } else {
@@ -50669,11 +50673,7 @@ serverEvents.on("cli.execute.before", async (name, params, options, instance) =>
50669
50673
  await adapter.init();
50670
50674
  await serverEvents.emitAsync("mws.adapter.init.after", adapter);
50671
50675
  const engine = new PrismaClient({
50672
- log: [
50673
- ...import_debug3.default.enabled("prisma:query") ? ["query"] : [],
50674
- "info",
50675
- "warn"
50676
- ],
50676
+ log: ["info", "warn", ...import_debug3.default.enabled("prisma:query") ? ["query"] : []],
50677
50677
  adapter: adapter.adapter
50678
50678
  });
50679
50679
  const $tw = await bootDefaultTiddlyWiki(wikiPath);
@@ -50695,9 +50695,6 @@ function readPasswordMasterKey(wikiPath) {
50695
50695
  __name(readPasswordMasterKey, "readPasswordMasterKey");
50696
50696
  Router.allowedRequestedWithHeaders.TiddlyWiki = true;
50697
50697
  var clientBuildDef = {
50698
- // rootdir: dist_resolve("../packages/admin-mdui"),
50699
- // publicdir: dist_resolve("../public/admin-mdui"),
50700
- // title: "MWS Admin",
50701
50698
  rootdir: dist_resolve("../packages/admin-vanilla"),
50702
50699
  publicdir: dist_resolve("../public/admin-vanilla"),
50703
50700
  title: "MWS Admin"
@@ -50723,6 +50720,11 @@ serverEvents.on("listen.router.init", async (listen, router) => {
50723
50720
  "server": dist_resolve("metafile-esm.json")
50724
50721
  });
50725
50722
  await serverEvents.emitAsync("mws.routes.fallback", router.rootRoute, router.config);
50723
+ router.catcherInner = (err) => {
50724
+ if (err instanceof PrismaClientKnownRequestError2) {
50725
+ console.log(err.meta?.driverAdapterError?.cause);
50726
+ }
50727
+ };
50726
50728
  });
50727
50729
  serverEvents.on("mws.routes.fallback", (root, config3) => {
50728
50730
  root.defineRoute({
@@ -50844,7 +50846,6 @@ var ListenCommand = class extends BaseCommand {
50844
50846
 
50845
50847
  // packages/mws/src/new-commands/init-store.ts
50846
50848
  init_esm_shims();
50847
- import { resolve as resolve9 } from "path";
50848
50849
 
50849
50850
  // packages/mws/src/new-commands/load-wiki-folder.ts
50850
50851
  init_esm_shims();
@@ -51071,9 +51072,8 @@ var InitStoreCommand = class extends BaseCommand {
51071
51072
  });
51072
51073
  });
51073
51074
  console.log("Default user created with username 'admin' and password '1234'. Please change this password after logging in.");
51074
- const tweditions = resolve9((await getTW5Paths(this.config.wikiPath)).pop().name, "editions");
51075
- const runner = /* @__PURE__ */ __name(async (path10, bagName, bagDesc, recName, recDesc) => {
51076
- const command = new LoadWikiFolderCommand([path10], {
51075
+ const runner = /* @__PURE__ */ __name(async (path11, bagName, bagDesc, recName, recDesc) => {
51076
+ const command = new LoadWikiFolderCommand([path11], {
51077
51077
  "bag-relative-root": [dist_resolve("..")],
51078
51078
  "bag-description": [bagDesc],
51079
51079
  "recipe-name": [recName],
@@ -54463,14 +54463,12 @@ SendError.oninstance.push((e) => {
54463
54463
  case "BAG_NO_READ_PERMISSION":
54464
54464
  case "BAG_NO_WRITE_PERMISSION":
54465
54465
  case "CANNOT_WRITE_STATIC_ROWS":
54466
- // case "HOST_NOT_RECOGNIZED": // misconfigured server if this throws
54467
54466
  case "INCORRECT_SERVER_RESPONSE_SENT":
54468
54467
  case "INSTANCE_NOT_FOUND":
54469
54468
  case "INSTANCE_NOT_WRITABLE":
54470
54469
  case "INSTANCE_NO_READ_PERMISSION":
54471
54470
  case "INSTANCE_NO_WRITE_PERMISSION":
54472
54471
  case "INTERNAL_SERVER_ERROR":
54473
- // case "INVALID_BODY_FORMAT": // a bug if this throws
54474
54472
  case "INVALID_REQUEST_BODY":
54475
54473
  case "INVALID_REQUEST_PATH":
54476
54474
  case "INVALID_REQUEST_QUERY":
@@ -54499,26 +54497,73 @@ SendError.oninstance.push((e) => {
54499
54497
  case "RESPONSE_INTERCEPTED_BY_CHECKER":
54500
54498
  case "SETTING_KEY_INVALID":
54501
54499
  case "TIDDLER_WIRE_FORMAT_UNKNOWN":
54502
- case "WRITE_NOT_PERMITTED": {
54500
+ case "WRITE_NOT_PERMITTED":
54501
+ case "ACCESS_DENIED": {
54503
54502
  e.skiplog = true;
54504
54503
  break;
54505
54504
  }
54505
+ case "INVALID_BODY_FORMAT":
54506
+ // a bug if this throws
54507
+ case "HOST_NOT_RECOGNIZED": {
54508
+ break;
54509
+ }
54510
+ default: {
54511
+ const t = e;
54512
+ }
54506
54513
  }
54507
54514
  });
54508
54515
 
54509
54516
  // packages/mws/src/index.ts
54510
54517
  import * as opaque3 from "@serenity-kit/opaque";
54518
+ import { existsSync as existsSync10 } from "fs";
54519
+ import { readFile as readFile6 } from "fs/promises";
54511
54520
  install();
54512
54521
  async function runMWS() {
54513
- await opaque3.ready;
54514
54522
  if (false) {
54515
54523
  await runBuildOnce2(clientBuildDef2);
54516
- } else {
54517
- serverEvents.eventLogging = !!process.env.VERBOSE;
54518
- await startup();
54519
- await src_default();
54520
- serverEvents.eventLogging = false;
54524
+ return;
54521
54525
  }
54526
+ const wikiPath = path10.resolve(process.cwd());
54527
+ (async () => {
54528
+ if (!existsSync10(path10.join(wikiPath, "package.json")))
54529
+ throw "The wiki path does not have a package.json file";
54530
+ const wikiPkg = tryParseJSON(await readFile6(path10.join(wikiPath, "package.json"), "utf8"));
54531
+ if (!wikiPkg)
54532
+ throw "The wiki path has a package.json file with invalid JSON.";
54533
+ if (wikiPkg.name !== "@tiddlywiki/mws-instance")
54534
+ throw "The wiki path package.json file is not named '@tiddlywiki/mws-instance'. ";
54535
+ if (!wikiPkg.version.startsWith("0.2"))
54536
+ throw "The wiki path package.json file has the wrong version. Found " + wikiPkg.version + ", expected 0.2.x";
54537
+ if (wikiPkg.private !== true) "PACKAGE_JSON_PRIVATE";
54538
+ })().catch((e) => {
54539
+ if (e === "PACKAGE_JSON_PRIVATE") {
54540
+ throw 'Your data folder package.json does not have `"private": true"` set. Publishing your data folder is HIGHLY DANGEROUS and exposes all your tiddlers to the public internet as well as making your passwords easier to guess. Refusing to continue.';
54541
+ }
54542
+ if (typeof e === "string") {
54543
+ throw [
54544
+ "The current working directory does not appear to be a valid wiki path. ",
54545
+ "In order to start the server properly, you must start it from the folder ",
54546
+ "containing the passwords.key file. This is the root of your wiki folder.",
54547
+ "",
54548
+ "Error: " + e,
54549
+ "",
54550
+ "Since the package.json file for your wiki folder is created automatically, ",
54551
+ "this usually means you are in the wrong folder. You should NOT edit the package.json ",
54552
+ "file in the current folder to fix this.",
54553
+ "",
54554
+ "The current folder is: " + wikiPath,
54555
+ "",
54556
+ 'This is also known as "Start In", "Working Directory", "Current Directory", etc. '
54557
+ ].join("\n");
54558
+ } else {
54559
+ throw e;
54560
+ }
54561
+ });
54562
+ serverEvents.eventLogging = !!process.env.VERBOSE;
54563
+ await opaque3.ready;
54564
+ await startup();
54565
+ await src_default();
54566
+ serverEvents.eventLogging = false;
54522
54567
  }
54523
54568
  __name(runMWS, "runMWS");
54524
54569
  serverEvents.on("cli.commander", (program2) => {
@@ -54535,6 +54580,7 @@ export {
54535
54580
  BagDataAdapter,
54536
54581
  BagImportWriter,
54537
54582
  BagPermissionLevel,
54583
+ BaseCommand,
54538
54584
  BetterCookie,
54539
54585
  BetterHeaders,
54540
54586
  BodyFormats,
@@ -54626,6 +54672,7 @@ export {
54626
54672
  registerStatsRoute,
54627
54673
  registerZodRoutes,
54628
54674
  runBuildOnce,
54675
+ runCLI,
54629
54676
  serverEvents,
54630
54677
  setupClientBuild,
54631
54678
  startListening,