@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
@@ -89,7 +89,7 @@ function Syncer(options) {
89
89
  self.processTaskQueue();
90
90
  } else {
91
91
  // Look for deletions of tiddlers we're already syncing
92
- var outstandingDeletion = false
92
+ var outstandingDeletion = false;
93
93
  $tw.utils.each(changes,function(change,title,object) {
94
94
  if(change.deleted && $tw.utils.hop(self.tiddlerInfo,title)) {
95
95
  outstandingDeletion = true;
@@ -139,9 +139,9 @@ function Syncer(options) {
139
139
  self.handleLazyLoadEvent(title);
140
140
  });
141
141
  }
142
-
143
- if(this.syncadaptor.registerSyncer)
144
- this.syncadaptor.registerSyncer(this);
142
+ if(this.syncadaptor.subscribe) this.syncadaptor.subscribe(function(){
143
+ self.syncFromServer();
144
+ });
145
145
 
146
146
  // Get the login status
147
147
  this.getStatus(function(err,isLoggedIn) {
@@ -309,7 +309,7 @@ Syncer.prototype.syncFromServer = function() {
309
309
 
310
310
  Syncer.prototype.canSyncFromServer = function() {
311
311
  return !!this.syncadaptor.getUpdatedTiddlers || !!this.syncadaptor.getSkinnyTiddlers;
312
- }
312
+ };
313
313
 
314
314
  /*
315
315
  Force load a tiddler from the server
@@ -424,25 +424,25 @@ Syncer.prototype.handleRefreshEvent = function() {
424
424
  Process the next task
425
425
  */
426
426
  Syncer.prototype.processTaskQueue = function() {
427
- var self = this;
428
427
  // Only process a task if the sync adaptor is fully initialised and we're not already performing
429
428
  // a task. If we are already performing a task then we'll dispatch the next one when it completes
430
429
  if((!this.syncadaptor.isReady || this.syncadaptor.isReady()) && this.numTasksInProgress === 0) {
431
430
  // Choose the next task to perform
432
- var task = this.chooseNextTask();
431
+ const task = this.chooseNextTask();
433
432
  // Perform the task if we had one
434
- if(typeof task === "object" && task !== null) {
433
+ if(typeof task === "function") {
435
434
  this.numTasksInProgress += 1;
436
- task.run(function(err) {
437
- self.numTasksInProgress -= 1;
435
+ task(err => {
436
+ this.numTasksInProgress -= 1;
438
437
  if(err) {
439
- self.displayError("Sync error while processing " + task.type + " of '" + task.title + "'",err);
440
- self.updateDirtyStatus();
441
- self.triggerTimeout(self.errorRetryInterval);
438
+ const [,name] = /(save|load|delete|sync)Task$/.exec(task.name) || [];
439
+ this.displayError("Sync error while processing " + name + " task", err);
440
+ this.updateDirtyStatus();
441
+ this.triggerTimeout(this.errorRetryInterval);
442
442
  } else {
443
- self.updateDirtyStatus();
443
+ this.updateDirtyStatus();
444
444
  // Process the next task
445
- self.processTaskQueue.call(self);
445
+ this.processTaskQueue.call(this);
446
446
  }
447
447
  });
448
448
  } else {
@@ -480,43 +480,28 @@ Returns either:
480
480
  * the boolean true if there are pending sync tasks that aren't yet due
481
481
  * null if there's no pending sync tasks (just the next poll)
482
482
  */
483
-
483
+ /** @returns {((callback: () => void) => void) | boolean} */
484
484
  Syncer.prototype.chooseNextTask = function() {
485
485
  var pending = this.getPendingTitles();
486
486
 
487
487
  if(pending.savePending.length){
488
- if(this.syncadaptor.saveTiddlers){
489
- return new SaveAllTiddlersTask(this, pending.savePending);
490
- } else {
491
- return new SaveTiddlerTask(this, pending.savePending[0]);
492
- }
488
+ return saveTask.bind(this, pending.savePending);
493
489
  }
494
490
  if(pending.syncServer){
495
- return new SyncFromServerTask(this);
491
+ return syncTask.bind(this);
496
492
  }
497
493
  if(pending.deletePending.length){
498
- if(this.syncadaptor.deleteTiddlers){
499
- return new DeleteAllTiddlersTask(this, pending.deletePending);
500
- } else {
501
- return new DeleteTiddlerTask(this, pending.deletePending[0]);
502
- }
494
+ return deleteTask.bind(this, pending.deletePending);
503
495
  }
504
496
  if(pending.loadPending.length){
505
- if(this.syncadaptor.loadTiddlers){
506
- var self = this;
507
- pending.loadPending.forEach(function(e){ delete self.titlesToBeLoaded[e]; });
508
- return new LoadAllTiddlersTask(this, pending.loadPending);
509
- } else {
510
- delete this.titlesToBeLoaded[pending.loadPending[0]];
511
- return new LoadTiddlerTask(this, pending.loadPending[0]);
512
- }
497
+ return loadTask.bind(this, pending.loadPending);
513
498
  }
514
499
  return pending.havePending;
515
500
  };
516
501
 
517
502
  Syncer.prototype.getPendingTitles = function() {
518
503
  var now = new Date(),
519
- thresholdLastSaved = now - this.throttleInterval,
504
+ thresholdLastSaved = now.valueOf() - this.throttleInterval,
520
505
  havePending = null,
521
506
  savePending = [],
522
507
  syncServer = false,
@@ -534,7 +519,6 @@ Syncer.prototype.getPendingTitles = function() {
534
519
  isReadyToSave = !tiddlerInfo || !tiddlerInfo.timestampLastSaved || tiddlerInfo.timestampLastSaved < thresholdLastSaved;
535
520
  if(hasChanged) {
536
521
  if(isReadyToSave) {
537
- // return new SaveTiddlerTask(this,title);
538
522
  savePending.push(title);
539
523
  } else {
540
524
  havePending = true;
@@ -544,7 +528,6 @@ Syncer.prototype.getPendingTitles = function() {
544
528
  }
545
529
  // Second we check for an outstanding sync from server
546
530
  if(this.forceSyncFromServer || (this.timestampLastSyncFromServer && (now.valueOf() >= (this.timestampLastSyncFromServer.valueOf() + this.pollTimerInterval)))) {
547
- // return new SyncFromServerTask(this);
548
531
  syncServer = true;
549
532
  }
550
533
  // Third, we check tiddlers that are known from the server but not currently in the store, and so need deleting on the server
@@ -554,248 +537,147 @@ Syncer.prototype.getPendingTitles = function() {
554
537
  tiddlerInfo = this.tiddlerInfo[title];
555
538
  tiddler = this.wiki.tiddlerExists(title) && this.wiki.getTiddler(title);
556
539
  if(!tiddler) {
557
- // return new DeleteTiddlerTask(this,title);
558
540
  deletePending.push(title);
559
541
  }
560
542
  }
561
543
  // Finally, check for tiddlers that need loading
562
- // title = Object.keys(this.titlesToBeLoaded)[0];
563
- // if(title) {
564
- // delete this.titlesToBeLoaded[title];
565
- // return new LoadTiddlerTask(this,title);
566
- // }
567
544
  loadPending.push(...Object.keys(this.titlesToBeLoaded));
568
545
  // No tasks are ready now, but might be in the future
569
546
  return {havePending: havePending, loadPending: loadPending, savePending: savePending, deletePending: deletePending, syncServer: syncServer};
570
547
  };
571
548
 
572
- function SaveTiddlerTask(syncer,title) {
573
- this.syncer = syncer;
574
- this.title = title;
575
- this.type = "save";
576
- }
577
-
578
- SaveTiddlerTask.prototype.toString = function() {
579
- return "SAVE " + this.title;
580
- }
581
-
582
- SaveTiddlerTask.prototype.run = function(callback) {
583
- var self = this,
584
- changeCount = this.syncer.wiki.getChangeCount(this.title),
585
- tiddler = this.syncer.wiki.tiddlerExists(this.title) && this.syncer.wiki.getTiddler(this.title);
586
- this.syncer.logger.log("Dispatching 'save' task:",this.title);
587
- if(tiddler) {
588
- this.syncer.syncadaptor.saveTiddler(tiddler,function(err,adaptorInfo,revision) {
589
- // If there's an error, exit without changing any internal state
590
- if(err) {
591
- return callback(err);
592
- }
593
- // Adjust the info stored about this tiddler
594
- self.syncer.tiddlerInfo[self.title] = {
595
- changeCount: changeCount,
596
- adaptorInfo: adaptorInfo,
597
- revision: revision,
598
- timestampLastSaved: new Date()
599
- };
600
- // Invoke the callback
601
- callback(null);
602
- },{
603
- tiddlerInfo: self.syncer.tiddlerInfo[self.title]
604
- });
605
- } else {
606
- $tw.utils.nextTick(callback(null));
607
- }
608
- };
609
-
610
- function SaveAllTiddlersTask(syncer,titles) {
611
- this.syncer = syncer;
612
- this.titles = titles;
613
- this.type = "save all";
614
- }
615
-
616
- SaveAllTiddlersTask.prototype.toString = function() {
617
- return "SAVE ALL " + this.titles;
618
- }
619
-
620
- SaveAllTiddlersTask.prototype.run = function(callback) {
621
- var self = this;
622
- this.syncer.logger.log("Dispatching 'save all' task:",this.titles);
623
- var changeCounts = this.titles.reduce(function (r,title) { r[title] = self.syncer.wiki.getChangeCount(title); return r; }, {});
624
- var tiddlers = this.titles
625
- .map(function(title){return self.syncer.wiki.tiddlerExists(title) && self.syncer.wiki.getTiddler(title);})
626
- .filter(function(title){return title;});
627
- if(!tiddlers.length) return void $tw.utils.nextTick(callback(null));
628
- this.syncer.syncadaptor.saveTiddlers({
629
- syncer: this.syncer,
549
+ /** @this {Syncer} */
550
+ function saveTask(titles, callback) {
551
+ this.logger.log("Dispatching 'save' task");
552
+ var changeCounts = titles.reduce((r, title) => { r[title] = this.wiki.getChangeCount(title); return r; }, {});
553
+ var tiddlers = titles.map(title => this.wiki.tiddlerExists(title) && this.wiki.getTiddler(title)).filter(e => e);
554
+ if(!tiddlers.length) return $tw.utils.nextTick(() => { callback(null); });
555
+ const options = {
556
+ syncer: this,
630
557
  tiddlers: tiddlers,
631
- onNext: function(title,adaptorInfo,revision){
632
- self.syncer.tiddlerInfo[title] = {
558
+ onNext: (title, adaptorInfo, revision) => {
559
+ this.tiddlerInfo[title] = {
633
560
  changeCount: changeCounts[title],
634
561
  adaptorInfo: adaptorInfo,
635
562
  revision: revision,
636
563
  timestampLastSaved: new Date()
637
564
  };
638
565
  },
639
- onDone: function(){callback(null);},
640
- onError: function(err){callback(err);},
641
- });
642
- };
643
-
644
- function DeleteTiddlerTask(syncer,title) {
645
- this.syncer = syncer;
646
- this.title = title;
647
- this.type = "delete";
648
- }
649
-
650
- DeleteTiddlerTask.prototype.toString = function() {
651
- return "DELETE " + this.title;
652
- }
653
-
654
- DeleteTiddlerTask.prototype.run = function(callback) {
655
- var self = this;
656
- this.syncer.logger.log("Dispatching 'delete' task:",this.title);
657
- this.syncer.syncadaptor.deleteTiddler(this.title,function(err) {
658
- // If there's an error, exit without changing any internal state
659
- if(err) {
660
- return callback(err);
661
- }
662
- // Remove the info stored about this tiddler
663
- delete self.syncer.tiddlerInfo[self.title];
664
- // Invoke the callback
665
- callback(null);
666
- },{
667
- tiddlerInfo: self.syncer.tiddlerInfo[this.title]
668
- });
669
- };
670
-
671
- function DeleteAllTiddlersTask(syncer,titles) {
672
- this.syncer = syncer;
673
- this.titles = titles;
674
- this.type = "delete all";
675
- }
676
-
677
- DeleteAllTiddlersTask.prototype.toString = function() {
678
- return "DELETE ALL " + this.titles;
679
- }
680
-
681
- DeleteAllTiddlersTask.prototype.run = function(callback) {
682
- var self = this;
683
- this.syncer.logger.log("Dispatching 'delete all' task:",this.titles);
684
- this.syncer.syncadaptor.deleteTiddlers({
685
- syncer: this.syncer,
686
- titles: this.titles,
687
- onNext: function(title){
688
- delete self.syncer.tiddlerInfo[title];
689
- },
690
- onDone: function(){callback(null);},
691
- onError: function(err){callback(err);},
692
- });
566
+ onDone: () => { callback(null); },
567
+ onError: err => { callback(err); },
568
+ };
569
+ if(this.syncadaptor.saveTiddlers) {
570
+ this.syncadaptor.saveTiddlers(options);
571
+ } else {
572
+ const tiddler = options.tiddlers[0],
573
+ title = tiddler.fields.title;
574
+ this.syncadaptor.saveTiddler(tiddler, function (err, adaptorInfo, revision) {
575
+ if(err) {
576
+ options.onError(err);
577
+ } else {
578
+ options.onNext(title, adaptorInfo, revision);
579
+ options.onDone();
580
+ }
581
+ }, { tiddlerInfo: this.tiddlerInfo[title] });
582
+ }
693
583
  };
694
584
 
695
- function LoadTiddlerTask(syncer,title) {
696
- this.syncer = syncer;
697
- this.title = title;
698
- this.type = "load";
699
- }
700
-
701
- LoadTiddlerTask.prototype.toString = function() {
702
- return "LOAD " + this.title;
703
- }
704
-
705
- LoadTiddlerTask.prototype.run = function(callback) {
706
- var self = this;
707
- this.syncer.logger.log("Dispatching 'load' task:",this.title);
708
- this.syncer.syncadaptor.loadTiddler(this.title,function(err,tiddlerFields) {
709
- // If there's an error, exit without changing any internal state
710
- if(err) {
711
- return callback(err);
712
- }
713
- // Update the info stored about this tiddler
714
- if(tiddlerFields) {
715
- self.syncer.storeTiddler(tiddlerFields);
716
- }
717
- // Invoke the callback
718
- callback(null);
719
- });
585
+ /** @this {Syncer} */
586
+ function deleteTask(titles, callback) {
587
+ this.logger.log("Dispatching 'delete' task");
588
+ const options = {
589
+ syncer: this,
590
+ titles,
591
+ onNext: title => { delete this.tiddlerInfo[title]; },
592
+ onDone: () => { callback(null); },
593
+ onError: err => { callback(err); },
594
+ };
595
+ if(this.syncadaptor.deleteTiddlers) {
596
+ this.syncadaptor.deleteTiddlers(options);
597
+ } else {
598
+ const title = options.titles[0];
599
+ this.syncadaptor.deleteTiddler(title, function (err) {
600
+ if(err) {
601
+ options.onError(err);
602
+ } else {
603
+ options.onNext(title);
604
+ options.onDone();
605
+ }
606
+ }, { tiddlerInfo: this.tiddlerInfo[title] });
607
+ }
720
608
  };
721
609
 
722
- function LoadAllTiddlersTask(syncer,titles) {
723
- this.syncer = syncer;
724
- this.titles = titles;
725
- this.type = "load all";
726
- }
727
-
728
- LoadAllTiddlersTask.prototype.toString = function() {
729
- return "LOAD ALL" + this.titles;
730
- }
731
-
732
- LoadAllTiddlersTask.prototype.run = function(callback) {
733
- var self = this;
734
- this.syncer.logger.log("Dispatching 'load all' task:",this.titles);
735
- this.syncer.syncadaptor.loadTiddlers({
736
- syncer: this.syncer,
737
- titles: this.titles,
738
- onNext: function(tiddlerFields){
739
- self.syncer.storeTiddler(tiddlerFields);
740
- },
741
- onDone: function(){callback(null);},
742
- onError: function(err){callback(err);},
743
- });
610
+ /** @this {Syncer} */
611
+ function loadTask(titles, callback) {
612
+ this.logger.log("Dispatching 'load' task");
613
+ const options = {
614
+ syncer: this,
615
+ titles,
616
+ onNext: tiddlerFields => { this.storeTiddler(tiddlerFields); },
617
+ onDone: () => { callback(null); },
618
+ onError: err => { callback(err); },
619
+ };
620
+ if(this.syncadaptor.loadTiddlers) {
621
+ options.titles.forEach(e => { delete this.titlesToBeLoaded[e]; });
622
+ this.syncadaptor.loadTiddlers(options);
623
+ } else {
624
+ delete this.titlesToBeLoaded[options.titles[0]];
625
+ this.syncadaptor.loadTiddler(options.titles[0], function (err, tiddlerFields) {
626
+ if(err) {
627
+ options.onError(err);
628
+ } else {
629
+ options.onNext(tiddlerFields);
630
+ options.onDone();
631
+ }
632
+ });
633
+ }
744
634
  };
745
635
 
746
- function SyncFromServerTask(syncer) {
747
- this.syncer = syncer;
748
- this.type = "syncfromserver";
749
- }
750
-
751
- SyncFromServerTask.prototype.toString = function() {
752
- return "SYNCFROMSERVER";
753
- }
754
-
755
- SyncFromServerTask.prototype.run = function(callback) {
636
+ /** @this {Syncer} */
637
+ function syncTask(callback) {
756
638
  var self = this;
757
- var syncSystemFromServer = (self.syncer.wiki.getTiddlerText("$:/config/SyncSystemTiddlersFromServer") === "yes" ? true : false);
639
+ var syncSystemFromServer = (self.wiki.getTiddlerText("$:/config/SyncSystemTiddlersFromServer") === "yes" ? true : false);
758
640
  var successCallback = function() {
759
- self.syncer.forceSyncFromServer = false;
760
- self.syncer.timestampLastSyncFromServer = new Date();
641
+ self.forceSyncFromServer = false;
642
+ self.timestampLastSyncFromServer = new Date();
761
643
  callback(null);
762
644
  };
763
- if(this.syncer.syncadaptor.getUpdatedTiddlers) {
764
- this.syncer.syncadaptor.getUpdatedTiddlers(self.syncer,function(err,updates) {
645
+ if(this.syncadaptor.getUpdatedTiddlers) {
646
+ this.syncadaptor.getUpdatedTiddlers(self,function(err,updates) {
765
647
  if(err) {
766
- self.syncer.displayError($tw.language.getString("Error/RetrievingSkinny"),err);
648
+ self.displayError($tw.language.getString("Error/RetrievingSkinny"),err);
767
649
  return callback(err);
768
650
  }
769
651
  if(updates) {
770
652
  $tw.utils.each(updates.modifications,function(title) {
771
- self.syncer.titlesToBeLoaded[title] = true;
653
+ self.titlesToBeLoaded[title] = true;
772
654
  });
773
655
  $tw.utils.each(updates.deletions,function(title) {
774
- if(syncSystemFromServer || !self.syncer.wiki.isSystemTiddler(title)) {
775
- delete self.syncer.tiddlerInfo[title];
776
- self.syncer.logger.log("Deleting tiddler missing from server:",title);
777
- self.syncer.wiki.deleteTiddler(title);
656
+ if(syncSystemFromServer || !self.wiki.isSystemTiddler(title)) {
657
+ delete self.tiddlerInfo[title];
658
+ self.logger.log("Deleting tiddler missing from server:",title);
659
+ self.wiki.deleteTiddler(title);
778
660
  }
779
661
  });
780
662
  }
781
663
  return successCallback();
782
664
  });
783
- } else if(this.syncer.syncadaptor.getSkinnyTiddlers) {
784
- this.syncer.syncadaptor.getSkinnyTiddlers(function(err,tiddlers) {
665
+ } else if(this.syncadaptor.getSkinnyTiddlers) {
666
+ this.syncadaptor.getSkinnyTiddlers(function(err,tiddlers) {
785
667
  // Check for errors
786
668
  if(err) {
787
- self.syncer.displayError($tw.language.getString("Error/RetrievingSkinny"),err);
669
+ self.displayError($tw.language.getString("Error/RetrievingSkinny"),err);
788
670
  return callback(err);
789
671
  }
790
672
  // Keep track of which tiddlers we already know about have been reported this time
791
- var previousTitles = Object.keys(self.syncer.tiddlerInfo);
673
+ var previousTitles = Object.keys(self.tiddlerInfo);
792
674
  // Process each incoming tiddler
793
675
  for(var t=0; t<tiddlers.length; t++) {
794
676
  // Get the incoming tiddler fields, and the existing tiddler
795
677
  var tiddlerFields = tiddlers[t],
796
678
  incomingRevision = tiddlerFields.revision + "",
797
- tiddler = self.syncer.wiki.tiddlerExists(tiddlerFields.title) && self.syncer.wiki.getTiddler(tiddlerFields.title),
798
- tiddlerInfo = self.syncer.tiddlerInfo[tiddlerFields.title],
679
+ tiddler = self.wiki.tiddlerExists(tiddlerFields.title) && self.wiki.getTiddler(tiddlerFields.title),
680
+ tiddlerInfo = self.tiddlerInfo[tiddlerFields.title],
799
681
  currRevision = tiddlerInfo ? tiddlerInfo.revision : null,
800
682
  indexInPreviousTitles = previousTitles.indexOf(tiddlerFields.title);
801
683
  if(indexInPreviousTitles !== -1) {
@@ -805,22 +687,22 @@ SyncFromServerTask.prototype.run = function(callback) {
805
687
  if(currRevision !== incomingRevision) {
806
688
  // Only load the skinny version if we don't already have a fat version of the tiddler
807
689
  if(!tiddler || tiddler.fields.text === undefined) {
808
- self.syncer.storeTiddler(tiddlerFields);
690
+ self.storeTiddler(tiddlerFields);
809
691
  }
810
692
  // Do a full load of this tiddler
811
- self.syncer.titlesToBeLoaded[tiddlerFields.title] = true;
693
+ self.titlesToBeLoaded[tiddlerFields.title] = true;
812
694
  }
813
695
  }
814
696
  // Delete any tiddlers that were previously reported but missing this time
815
697
  $tw.utils.each(previousTitles,function(title) {
816
- if(syncSystemFromServer || !self.syncer.wiki.isSystemTiddler(title)) {
817
- delete self.syncer.tiddlerInfo[title];
818
- self.syncer.logger.log("Deleting tiddler missing from server:",title);
819
- self.syncer.wiki.deleteTiddler(title);
698
+ if(syncSystemFromServer || !self.wiki.isSystemTiddler(title)) {
699
+ delete self.tiddlerInfo[title];
700
+ self.logger.log("Deleting tiddler missing from server:",title);
701
+ self.wiki.deleteTiddler(title);
820
702
  }
821
703
  });
822
- self.syncer.forceSyncFromServer = false;
823
- self.syncer.timestampLastSyncFromServer = new Date();
704
+ self.forceSyncFromServer = false;
705
+ self.timestampLastSyncFromServer = new Date();
824
706
  return successCallback();
825
707
  });
826
708
  } else {
@@ -828,4 +710,4 @@ SyncFromServerTask.prototype.run = function(callback) {
828
710
  }
829
711
  };
830
712
 
831
- exports.Syncer = Syncer;
713
+ exports.Syncer = Syncer;
@@ -12,6 +12,10 @@
12
12
  "alwaysStrict": true,
13
13
  "rootDir": "./src",
14
14
  "esModuleInterop": true,
15
+ "allowImportingTsExtensions": false,
16
+ "inlineSourceMap": true,
17
+ "inlineSources": true,
18
+ // "sourceRoot": ""
15
19
  // "noUnusedLocals": false,
16
20
  // "noUnusedParameters": false,
17
21
  // "noFallthroughCasesInSwitch": true,
@@ -21,6 +25,6 @@
21
25
 
22
26
  },
23
27
  "files": [
24
- "src/multiwikiclientadaptor.ts"
28
+ "src/new-multiwikiclientadaptor.ts"
25
29
  ],
26
30
  }
@@ -0,0 +1,2 @@
1
+ export * from "./client/browser";
2
+ export * from "./types";
@@ -0,0 +1,84 @@
1
+
2
+ /* !!! This is code generated by Prisma. Do not edit directly. !!! */
3
+ /* eslint-disable */
4
+ // biome-ignore-all lint: generated file
5
+ // @ts-nocheck
6
+ /*
7
+ * This file should be your main import to use Prisma-related types and utilities in a browser.
8
+ * Use it to get access to models, enums, and input types.
9
+ *
10
+ * This file does not contain a `PrismaClient` class, nor several other helpers that are intended as server-side only.
11
+ * See `client.ts` for the standard, server-side entry point.
12
+ *
13
+ * 🟢 You can import this file directly.
14
+ */
15
+
16
+ import * as Prisma from './internal/prismaNamespaceBrowser.ts'
17
+ export { Prisma }
18
+ export * as $Enums from './enums.ts'
19
+ export * from './enums.ts';
20
+ /**
21
+ * Model Bag
22
+ *
23
+ */
24
+ export type Bag = Prisma.BagModel
25
+ /**
26
+ * Model BagPermission
27
+ *
28
+ */
29
+ export type BagPermission = Prisma.BagPermissionModel
30
+ /**
31
+ * Model Tiddler
32
+ *
33
+ */
34
+ export type Tiddler = Prisma.TiddlerModel
35
+ /**
36
+ * Model TiddlerEvent
37
+ *
38
+ */
39
+ export type TiddlerEvent = Prisma.TiddlerEventModel
40
+ /**
41
+ * Model Template
42
+ *
43
+ */
44
+ export type Template = Prisma.TemplateModel
45
+ /**
46
+ * Model TemplatePermission
47
+ *
48
+ */
49
+ export type TemplatePermission = Prisma.TemplatePermissionModel
50
+ /**
51
+ * Model Recipe
52
+ *
53
+ */
54
+ export type Recipe = Prisma.RecipeModel
55
+ /**
56
+ * Model RecipePermission
57
+ *
58
+ */
59
+ export type RecipePermission = Prisma.RecipePermissionModel
60
+ /**
61
+ * Model RecipeBag
62
+ *
63
+ */
64
+ export type RecipeBag = Prisma.RecipeBagModel
65
+ /**
66
+ * Model Settings
67
+ *
68
+ */
69
+ export type Settings = Prisma.SettingsModel
70
+ /**
71
+ * Model Roles
72
+ *
73
+ */
74
+ export type Roles = Prisma.RolesModel
75
+ /**
76
+ * Model Users
77
+ *
78
+ */
79
+ export type Users = Prisma.UsersModel
80
+ /**
81
+ * Model Sessions
82
+ *
83
+ */
84
+ export type Sessions = Prisma.SessionsModel