@tiddlywiki/mws 0.1.13 → 0.2.0

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.
Files changed (118) hide show
  1. package/README.md +41 -20
  2. package/dist/metafile-esm.json +1 -1
  3. package/dist/mws.js +40249 -20249
  4. package/dist/mws.js.map +1 -1
  5. package/mws.run.mjs +28 -8
  6. package/package.json +20 -33
  7. package/plugins/client/plugin.info +1 -1
  8. package/plugins/client/src/multiwikiclientadaptor.ts +11 -39
  9. package/plugins/client/src/mws.d.ts +2 -1
  10. package/plugins/client/src/new-multiwikiclientadaptor.ts +634 -0
  11. package/plugins/client/src/types.d.ts +2531 -1036
  12. package/plugins/client/tiddlers/managetiddleraction.js +0 -5
  13. package/plugins/client/tiddlers/syncer/multiwikiclientadaptor.js +1 -1
  14. package/plugins/client/tiddlers/syncer/new-multiwikiclientadaptor.js +432 -0
  15. package/plugins/client/tiddlers/syncer/syncer.js +123 -241
  16. package/plugins/client/tsconfig.json +5 -1
  17. package/prisma/browser.ts +2 -0
  18. package/prisma/client/browser.ts +84 -0
  19. package/prisma/client/client.ts +108 -0
  20. package/prisma/client/commonInputTypes.ts +598 -0
  21. package/prisma/client/enums.ts +42 -0
  22. package/prisma/client/internal/class.ts +326 -0
  23. package/prisma/client/internal/prismaNamespace.ts +1870 -0
  24. package/prisma/client/internal/prismaNamespaceBrowser.ts +259 -0
  25. package/prisma/client/models/Bag.ts +1701 -0
  26. package/prisma/client/models/BagPermission.ts +1284 -0
  27. package/prisma/client/models/Recipe.ts +1722 -0
  28. package/prisma/client/models/RecipeBag.ts +1518 -0
  29. package/prisma/client/models/RecipePermission.ts +1284 -0
  30. package/prisma/client/models/Roles.ts +1316 -0
  31. package/prisma/client/models/Sessions.ts +1344 -0
  32. package/prisma/client/models/Settings.ts +1093 -0
  33. package/prisma/client/models/Template.ts +1477 -0
  34. package/prisma/client/models/TemplatePermission.ts +1284 -0
  35. package/prisma/client/models/Tiddler.ts +1434 -0
  36. package/prisma/client/models/TiddlerEvent.ts +1360 -0
  37. package/prisma/client/models/Users.ts +1579 -0
  38. package/prisma/client/models.ts +24 -0
  39. package/prisma/client/pjtg.ts +183 -0
  40. package/prisma/index.ts +74 -0
  41. package/prisma/migrations/20260708160259_init/migration.sql +172 -0
  42. package/prisma/migrations-v1/migration_lock.toml +3 -0
  43. package/prisma/package.json +12 -0
  44. package/prisma/schema.prisma +147 -89
  45. package/prisma/types.ts +9 -0
  46. package/public/.default.html +1 -0
  47. package/public/admin-vanilla/fish.svg +399 -0
  48. package/public/admin-vanilla/fish2.svg +389 -0
  49. package/public/admin-vanilla/main-64WYHWYI.js +1791 -0
  50. package/public/admin-vanilla/main-64WYHWYI.js.map +7 -0
  51. package/public/admin-vanilla/main-LYDE4NDJ.css +1 -0
  52. package/public/admin-vanilla/normalize.css +349 -0
  53. package/public/admin-vanilla/polyfill-ADOI2A4V.js +2 -0
  54. package/public/admin-vanilla/polyfill-ADOI2A4V.js.map +7 -0
  55. package/public/{react-admin → admin-vanilla}/site.webmanifest +1 -1
  56. package/public/admin-vanilla.html +62 -0
  57. package/public/admin-vanilla.json +1 -0
  58. package/public/{react-admin → stats}/stats.html +5 -2
  59. package/public/{react-admin → stats}/stats.js +2 -1
  60. package/scripts/build-docs.sh +30 -0
  61. package/scripts/helpers.mjs +107 -0
  62. package/scripts/json.js +8 -0
  63. package/scripts/scripts.mjs +114 -0
  64. package/prisma/client/client.d.ts +0 -1
  65. package/prisma/client/client.js +0 -3
  66. package/prisma/client/default.d.ts +0 -1
  67. package/prisma/client/default.js +0 -3
  68. package/prisma/client/edge.d.ts +0 -1
  69. package/prisma/client/edge.js +0 -297
  70. package/prisma/client/index-browser.js +0 -275
  71. package/prisma/client/index.d.ts +0 -17770
  72. package/prisma/client/index.js +0 -324
  73. package/prisma/client/package.json +0 -173
  74. package/prisma/client/query_engine_bg.js +0 -811
  75. package/prisma/client/query_engine_bg.wasm +0 -0
  76. package/prisma/client/runtime/edge-esm.js +0 -10000
  77. package/prisma/client/runtime/edge.js +0 -10036
  78. package/prisma/client/runtime/index-browser.d.ts +0 -370
  79. package/prisma/client/runtime/index-browser.js +0 -2300
  80. package/prisma/client/runtime/library.d.ts +0 -3681
  81. package/prisma/client/runtime/library.js +0 -10604
  82. package/prisma/client/runtime/react-native.js +0 -10629
  83. package/prisma/client/runtime/wasm-compiler-edge.js +0 -11238
  84. package/prisma/client/runtime/wasm-engine-edge.js +0 -7801
  85. package/prisma/client/schema.prisma +0 -156
  86. package/prisma/client/wasm-edge-light-loader.mjs +0 -4
  87. package/prisma/client/wasm-worker-loader.mjs +0 -4
  88. package/prisma/client/wasm.d.ts +0 -1
  89. package/prisma/client/wasm.js +0 -304
  90. package/prisma/global.ts +0 -53
  91. package/public/react-admin/chunk-YALWN5OT.js +0 -2
  92. package/public/react-admin/esm-L4WLVWJN.js +0 -3
  93. package/public/react-admin/esm-L4WLVWJN.js.map +0 -7
  94. package/public/react-admin/esm-QMNGI3LF.js +0 -3
  95. package/public/react-admin/esm-QMNGI3LF.js.map +0 -7
  96. package/public/react-admin/index.html +0 -36
  97. package/public/react-admin/main.js +0 -268
  98. package/public/react-admin/main.js.map +0 -7
  99. package/public/react-admin/stats.json +0 -1
  100. package/scripts.mjs +0 -142
  101. /package/prisma/{migrations → migrations-v1}/20250606001949_init/migration.sql +0 -0
  102. /package/prisma/{migrations → migrations-v1}/20250613000526_remove_group/migration.sql +0 -0
  103. /package/prisma/{migrations → migrations-v1}/20250620014502_settings/migration.sql +0 -0
  104. /package/prisma/{migrations → migrations-v1}/20250707205229_recipes/migration.sql +0 -0
  105. /package/public/{react-admin → admin-vanilla}/android-chrome-192x192.png +0 -0
  106. /package/public/{react-admin → admin-vanilla}/android-chrome-512x512.png +0 -0
  107. /package/public/{react-admin → admin-vanilla}/apple-touch-icon.png +0 -0
  108. /package/public/{react-admin → admin-vanilla}/favicon-16x16.png +0 -0
  109. /package/public/{react-admin → admin-vanilla}/favicon-32x32.png +0 -0
  110. /package/public/{react-admin → admin-vanilla}/favicon.ico +0 -0
  111. /package/public/{react-admin → admin-vanilla}/favicon.png +0 -0
  112. /package/public/{react-admin/chunk-YALWN5OT.js.map → admin-vanilla/main-LYDE4NDJ.css.map} +0 -0
  113. /package/public/{react-admin → admin-vanilla}/missing-favicon.png +0 -0
  114. /package/public/{react-admin → admin-vanilla}/motovun-jack.jpg +0 -0
  115. /package/public/{react-admin → admin-vanilla}/mws-icon.png +0 -0
  116. /package/public/{react-admin → admin-vanilla}/vite.svg +0 -0
  117. /package/public/{react-admin → stats}/stats.css +0 -0
  118. /package/public/{react-admin → stats}/stats.svg +0 -0
package/mws.run.mjs CHANGED
@@ -3,28 +3,48 @@
3
3
  import { existsSync, readFileSync, } from "fs";
4
4
 
5
5
  const cwd = process.cwd();
6
+
6
7
  /** @type {import("./package.json") | null} */
7
- const pkg = existsSync(`${cwd}/package.json`)
8
- ? tryParseJSON(readFileSync(`${cwd}/package.json`, "utf8"))
9
- : null;
8
+ const pkg = existsSync(`${cwd}/package.json`) && tryParseJSON(readFileSync(`${cwd}/package.json`, "utf8")) || null;
10
9
 
11
- if(pkg?.name === "@tiddlywiki/mws" && existsSync(`${cwd}/mws.dev.mjs`)) {
10
+ if (pkg && pkg.name === "@tiddlywiki/mws" && existsSync(`${cwd}/mws.dev.mjs`)) {
12
11
  console.error("This appears to be a development version of MWS.");
13
12
  process.exit(1);
14
13
  }
15
14
 
16
- if(!pkg?.dependencies?.["@tiddlywiki/mws"] || pkg.name !== "@tiddlywiki/mws-instance" || !pkg.private) {
15
+ if (pkg && pkg.name === "@tiddlywiki/mws-instance" && pkg.private) {
16
+ if (pkg.version !== "0.2.0") {
17
+ console.log([
18
+ "=======================================================================================",
19
+ "The data folder you are trying to open appears to be from a different version of MWS.",
20
+ "",
21
+ "Folder: " + process.cwd(),
22
+ "Version: " + pkg.version,
23
+ "",
24
+ "To prevent data loss the program will now exit.",
25
+ "=======================================================================================",
26
+ ].join("\n"));
27
+ process.exit(1);
28
+ }
29
+ // need absolute path because of cwd
30
+ import(`file://${cwd}/node_modules/@tiddlywiki/mws/dist/mws.js`)
31
+ .then(mws => mws.default(pkg.version))
32
+ .catch(console.error);
33
+ } else {
17
34
  console.error("This does not appear to be a valid MWS data folder.");
18
35
  console.error("Please run this command in the root of your MWS data folder.");
19
36
  process.exit(1);
20
37
  }
21
38
 
22
- import(`file://${cwd}/node_modules/@tiddlywiki/mws/dist/mws.js`).then(mws => mws.default()).catch(console.error);
23
-
39
+ /**
40
+ *
41
+ * @param {string} file
42
+ * @returns
43
+ */
24
44
  function tryParseJSON(file) {
25
45
  try {
26
46
  return JSON.parse(file);
27
- } catch(e) {
47
+ } catch (e) {
28
48
  return undefined;
29
49
  }
30
50
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tiddlywiki/mws",
3
3
  "description": "TiddlyWiki Multiple Wiki Server",
4
4
  "private": false,
5
- "version": "0.1.13",
5
+ "version": "0.2.0",
6
6
  "bin": {
7
7
  "mws": "./mws.run.mjs"
8
8
  },
@@ -19,12 +19,8 @@
19
19
  }
20
20
  },
21
21
  "workspaces": [
22
- "packages/events",
23
- "packages/commander",
24
- "packages/server",
25
- "packages/mws",
26
- "packages/react-admin",
27
- "packages/tiddlywiki-types"
22
+ "packages/*",
23
+ "prisma"
28
24
  ],
29
25
  "files": [
30
26
  "dist",
@@ -32,7 +28,7 @@
32
28
  "plugins",
33
29
  "prisma",
34
30
  "public",
35
- "scripts.mjs",
31
+ "scripts",
36
32
  "mws.run.mjs"
37
33
  ],
38
34
  "engines": {
@@ -40,37 +36,28 @@
40
36
  },
41
37
  "scripts": {
42
38
  "install-android": "GYP_DEFINES=\"android_ndk_path=''\" npm install",
43
- "docs": "node scripts.mjs docs",
44
- "start": "node scripts.mjs start",
39
+ "docs": "node scripts/scripts.mjs docs",
40
+ "start": "node scripts/scripts.mjs start",
45
41
  "certs": "(cd dev && bash localhost_certs.sh)",
46
42
  "tsc": "TSCMWS=1 npx tsup",
47
- "build": "tsup && npm run build:admin",
48
- "build:admin": "node scripts.mjs client-build",
43
+ "tsc2": "tsc -p tsconfig.json --noEmit",
44
+ "tsc-client": "cd packages/react-admin && npm run tsc",
45
+ "build": "node scripts/scripts.mjs build",
49
46
  "build:client": "cd plugins/client && tsc",
50
- "dev:init-store": "rm -rf dev/wiki/store && DEBUG= npm start init-store",
47
+ "prisma:gen": "cd tools && npm run prisma:gen",
48
+ "prisma:mig": "cd tools && npm run prisma:mig",
49
+ "dev-quick-reset": "node scripts/scripts.mjs dev-quick-reset",
51
50
  "env": "env",
52
- "test": "node scripts.mjs test",
53
- "prisma:format": "prettier --write prisma/client/*.js prisma/client/*/*.js",
54
- "prisma:generate": "node scripts.mjs prisma:generate",
55
- "prisma:migrate": "DATABASE_URL=file:test.sqlite npx prisma migrate dev --create-only --skip-generate --schema prisma/schema.prisma"
51
+ "test": "node scripts/scripts.mjs test"
56
52
  },
57
53
  "dependencies": {
58
- "@prisma/adapter-better-sqlite3": "6.10.1",
59
- "@serenity-kit/opaque": "^0.8.4",
60
- "prisma-client": "file:prisma/client",
61
- "source-map-support": "^0.5.21",
62
- "tiddlywiki": "^5.3.2"
54
+ "@prisma/adapter-better-sqlite3": "7.8.0",
55
+ "@prisma/client": "7.8.0",
56
+ "@serenity-kit/opaque": "1.1.0",
57
+ "source-map-support": "0.5.21"
63
58
  },
64
59
  "devDependencies": {
65
- "@prisma/client": "6.10.1",
66
- "@types/node": "^24.0.0",
67
- "prettier": "^3.6.1",
68
- "prisma": "6.10.1",
69
- "prisma-json-types-generator": "3.5.0",
70
- "tsup": "^8.5.0",
71
- "typescript": "^5.8.3"
72
- },
73
- "peerDependencies": {
74
- "tiddlywiki": "^5.3.2"
60
+ "@types/node": "^24.6.0",
61
+ "@types/source-map-support": "0.5.10"
75
62
  }
76
- }
63
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "title": "$:/plugins/mws/client",
3
3
  "name": "MultiWikiClient",
4
- "description": "Synchronise changes from the browser to TiddlyWiki ~MultiWikiServer ",
4
+ "description": "Synchronise changes from the browser to TiddlyWiki MultiWikiServer",
5
5
  "list": "readme",
6
6
  "plugin-priority": 12,
7
7
  "stability": "STABILITY_1_EXPERIMENTAL",
@@ -19,30 +19,15 @@ previous operation to complete before sending a new one.
19
19
  // the blank line is important, and so is the following use strict
20
20
  "use strict";
21
21
 
22
- import type { ServerEventsMap } from '@tiddlywiki/events';
23
- import type { ZodRoute, WikiStatusRoutes, WikiRecipeRoutes } from '@tiddlywiki/mws';
24
- import type { zod } from '@tiddlywiki/server';
25
- import type { Syncer, Tiddler, TiddlerFields } from 'tiddlywiki';
22
+ // import type { ServerEventsMap } from '@tiddlywiki/events';
23
+ // import type { ZodRoute, WikiStatusRoutes, WikiRecipeRoutes } from '@tiddlywiki/mws';
24
+ // import type { zod } from '@tiddlywiki/server';
25
+ import type { Syncer, Tiddler, TiddlerFields, Wiki } from 'tiddlywiki';
26
+
27
+ import {} from "@tiddlywiki/mws-prisma";
26
28
  declare global { const fflate: typeof import("./fflate"); }
27
29
  declare const self: never;
28
30
 
29
- // registerZodRoutes(parent, new WikiStatusRoutes(), Object.keys({
30
- // handleGetAllBagStates: true,
31
- // handleGetBagState: true,
32
- // handleGetRecipeStatus: true,
33
- // handleGetRecipeEvents: true,
34
- // handleGetBags: true,
35
- // } satisfies RouterKeyMap<WikiStatusRoutes, true>));
36
-
37
- // registerZodRoutes(parent, new WikiRecipeRoutes(), Object.keys({
38
- // handleDeleteRecipeTiddler: true,
39
- // handleLoadRecipeTiddler: true,
40
- // handleSaveRecipeTiddler: true,
41
- // rpcDeleteRecipeTiddlerList: true,
42
- // rpcLoadRecipeTiddlerList: true,
43
- // rpcSaveRecipeTiddlerList: true,
44
- // } satisfies RouterKeyMap<WikiRecipeRoutes, true>));
45
-
46
31
  declare class Logger {
47
32
  constructor(componentName: any, options: any);
48
33
  componentName: any;
@@ -61,19 +46,6 @@ declare class Logger {
61
46
  clearAlerts(): void;
62
47
  }
63
48
 
64
- type WikiStatusTypes = {
65
- [K in keyof WikiStatusRoutes]: WikiStatusRoutes[K] extends ZodRoute<infer M, infer B, infer P, infer Q, infer T, infer R>
66
- ? { M: M, B: B, P: P, Q: Q, T: T, R: R }
67
- : never
68
- }
69
- type WikiRecipeTypes = {
70
- [K in keyof WikiRecipeRoutes]: WikiRecipeRoutes[K] extends ZodRoute<infer M, infer B, infer P, infer Q, infer T, infer R>
71
- ? { M: M, B: B, P: P, Q: Q, T: T, R: R }
72
- : never
73
- }
74
- interface RouteTypes extends WikiStatusTypes, WikiRecipeTypes {
75
- }
76
-
77
49
  declare module 'tiddlywiki' {
78
50
  export interface Syncer<AD> {
79
51
  wiki: Wiki;
@@ -236,7 +208,7 @@ interface MWSAdaptorInfo {
236
208
 
237
209
 
238
210
  class MultiWikiClientAdaptor implements SyncAdaptor<MWSAdaptorInfo> {
239
- private wiki;
211
+ private wiki: Wiki;
240
212
  private host;
241
213
  private recipe;
242
214
  private useServerSentEvents;
@@ -259,11 +231,11 @@ class MultiWikiClientAdaptor implements SyncAdaptor<MWSAdaptorInfo> {
259
231
  constructor(options: { wiki: any }) {
260
232
  this.wiki = options.wiki;
261
233
  this.host = this.getHost();
262
- this.recipe = this.wiki.getTiddlerText("$:/config/multiwikiclient/recipe");
234
+ this.recipe = this.wiki.getTiddlerText("$:/config/multiwikiclient/recipe", "default")!;
263
235
  this.useServerSentEvents = this.wiki.getTiddlerText(ENABLE_SSE_TIDDLER) === "yes";
264
236
  this.isDevMode = this.wiki.getTiddlerText(IS_DEV_MODE_TIDDLER) === "yes";
265
237
  this.useGzipStream = this.wiki.getTiddlerText(ENABLE_GZIP_STREAM_TIDDLER) === "yes";
266
- this.last_known_revision_id = this.wiki.getTiddlerText("$:/state/multiwikiclient/recipe/last_revision_id", "0")
238
+ this.last_known_revision_id = this.wiki.getTiddlerText("$:/state/multiwikiclient/recipe/last_revision_id", "0")!
267
239
  this.outstandingRequests = Object.create(null); // Hashmap by title of outstanding request object: {type: "PUT"|"GET"|"DELETE"}
268
240
  this.lastRecordedUpdate = Object.create(null); // Hashmap by title of last recorded update via SSE: {type: "update"|"detetion", revision_id:}
269
241
  this.logger = new $tw.utils.Logger("MultiWikiClientAdaptor");
@@ -272,7 +244,7 @@ class MultiWikiClientAdaptor implements SyncAdaptor<MWSAdaptorInfo> {
272
244
  this.offline = false;
273
245
  this.username = "";
274
246
  // Compile the dirty tiddler filter
275
- this.incomingUpdatesFilterFn = this.wiki.compileFilter(this.wiki.getTiddlerText(INCOMING_UPDATES_FILTER_TIDDLER));
247
+ this.incomingUpdatesFilterFn = this.wiki.compileFilter(this.wiki.getTiddlerText(INCOMING_UPDATES_FILTER_TIDDLER)!);
276
248
  this.setConnectionStatus(SERVER_NOT_CONNECTED);
277
249
  }
278
250
 
@@ -402,7 +374,7 @@ class MultiWikiClientAdaptor implements SyncAdaptor<MWSAdaptorInfo> {
402
374
  connectRecipeEvents() {
403
375
  const event = new EventSource(this.host + "recipe/" + encodeURIComponent(this.recipe) + "/events?first-event-id=" + encodeURIComponent(this.last_known_revision_id));
404
376
  this.setConnectionStatus(SERVER_CONNECTING_SSE);
405
- let syncTimeout: NodeJS.Timeout | null = null;
377
+ let syncTimeout: number | null = null;
406
378
  const debounceSyncFromServer = () => {
407
379
  if (syncTimeout) {
408
380
  clearTimeout(syncTimeout);
@@ -1,4 +1,5 @@
1
1
  import "./types";
2
2
  export * from "packages/mws/src/index";
3
3
  export * from "packages/server/src/index";
4
- export * from "packages/events/src/index";
4
+ export * from "packages/events/src/index";
5
+ export * from "packages/utils/src/index";