@powerhousedao/connect 1.0.17-dev.1 → 1.0.17-dev.2

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 (34) hide show
  1. package/dist/.env +1 -1
  2. package/dist/assets/AnalyticsProfiler-DD1sT8NE.js +22 -0
  3. package/dist/assets/AnalyticsProfiler-DD1sT8NE.js.map +1 -0
  4. package/dist/assets/{app-CySbX590.js → app-CayLrjAy.js} +8081 -3607
  5. package/dist/assets/app-CayLrjAy.js.map +1 -0
  6. package/dist/assets/{app-loader-cqvNNM8Y.js → app-loader-Ej0QwX6c.js} +483 -217
  7. package/dist/assets/app-loader-Ej0QwX6c.js.map +1 -0
  8. package/dist/assets/browser-BfB4Waw5.js +27235 -0
  9. package/dist/assets/browser-BfB4Waw5.js.map +1 -0
  10. package/dist/assets/{ccip-Da4Q-CTl.js → ccip-DBZNMhmz.js} +4 -3
  11. package/dist/assets/ccip-DBZNMhmz.js.map +1 -0
  12. package/dist/assets/{content-Bh_hCjls.js → content-DnXO71l4.js} +5 -3
  13. package/dist/assets/content-DnXO71l4.js.map +1 -0
  14. package/dist/assets/{index-CQTP2hD2.js → index-BbMglwKh.js} +21 -15
  15. package/dist/assets/index-BbMglwKh.js.map +1 -0
  16. package/dist/assets/{index-DrP8_N4_.js → index-CCSrpy8s.js} +4 -3
  17. package/dist/assets/index-CCSrpy8s.js.map +1 -0
  18. package/dist/assets/{index-5oH-QGI2.js → index-CU3_V46J.js} +4 -3
  19. package/dist/assets/index-CU3_V46J.js.map +1 -0
  20. package/dist/assets/{main.NENY9z_J.js → main.D0KZAQpb.js} +2 -1
  21. package/dist/assets/main.D0KZAQpb.js.map +1 -0
  22. package/dist/assets/reactor-analytics-BioFquA0.js +605 -0
  23. package/dist/assets/reactor-analytics-BioFquA0.js.map +1 -0
  24. package/dist/assets/router-BF9pgdRU.js +2177 -0
  25. package/dist/assets/router-BF9pgdRU.js.map +1 -0
  26. package/dist/external-packages.js +1 -0
  27. package/dist/external-packages.js.map +1 -0
  28. package/dist/hmr.js +1 -0
  29. package/dist/hmr.js.map +1 -0
  30. package/dist/index.html +1 -1
  31. package/dist/service-worker.js +1 -0
  32. package/dist/service-worker.js.map +1 -0
  33. package/dist/vite-envs.sh +1 -1
  34. package/package.json +9 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-CySbX590.js","assets/main.NENY9z_J.js","assets/app-CDOWlDp2.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-CayLrjAy.js","assets/main.D0KZAQpb.js","assets/app-CDOWlDp2.css"])))=>i.map(i=>d[i]);
2
2
  var __defProp = Object.defineProperty;
3
3
  var __typeError = (msg) => {
4
4
  throw TypeError(msg);
@@ -11,7 +11,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11
11
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
12
12
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
13
13
  var _tags, _levelString, _errorHandler, _ConsoleLogger_instances, levelValue_get, _getDocumentModelModule, _drives, _ReadModeService_instances, parseGraphQLErrors_fn, fetchDrive_fn, _a, _ServiceWorkerManager_instances, handleServiceWorkerMessage_fn, handleServiceWorker_fn;
14
- import { _ as __vitePreload } from "./main.NENY9z_J.js";
14
+ import { _ as __vitePreload } from "./main.D0KZAQpb.js";
15
15
  import { jsx, jsxs } from "react/jsx-runtime";
16
16
  import { useState, useEffect, Suspense, lazy } from "react";
17
17
  function _mergeNamespaces(n, m) {
@@ -7534,21 +7534,186 @@ function UpdateStateExampleInputSchema() {
7534
7534
  newExample: z.string()
7535
7535
  });
7536
7536
  }
7537
+ var dist = {};
7538
+ var hasRequiredDist;
7539
+ function requireDist() {
7540
+ if (hasRequiredDist) return dist;
7541
+ hasRequiredDist = 1;
7542
+ (function(exports) {
7543
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
7544
+ function getDefaultExportFromCjs2(x) {
7545
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
7546
+ }
7547
+ var browser = { exports: {} };
7548
+ var process2 = browser.exports = {};
7549
+ var cachedSetTimeout;
7550
+ var cachedClearTimeout;
7551
+ function defaultSetTimout() {
7552
+ throw new Error("setTimeout has not been defined");
7553
+ }
7554
+ function defaultClearTimeout() {
7555
+ throw new Error("clearTimeout has not been defined");
7556
+ }
7557
+ (function() {
7558
+ try {
7559
+ if (typeof setTimeout === "function") {
7560
+ cachedSetTimeout = setTimeout;
7561
+ } else {
7562
+ cachedSetTimeout = defaultSetTimout;
7563
+ }
7564
+ } catch (e) {
7565
+ cachedSetTimeout = defaultSetTimout;
7566
+ }
7567
+ try {
7568
+ if (typeof clearTimeout === "function") {
7569
+ cachedClearTimeout = clearTimeout;
7570
+ } else {
7571
+ cachedClearTimeout = defaultClearTimeout;
7572
+ }
7573
+ } catch (e) {
7574
+ cachedClearTimeout = defaultClearTimeout;
7575
+ }
7576
+ })();
7577
+ function runTimeout(fun) {
7578
+ if (cachedSetTimeout === setTimeout) {
7579
+ return setTimeout(fun, 0);
7580
+ }
7581
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
7582
+ cachedSetTimeout = setTimeout;
7583
+ return setTimeout(fun, 0);
7584
+ }
7585
+ try {
7586
+ return cachedSetTimeout(fun, 0);
7587
+ } catch (e) {
7588
+ try {
7589
+ return cachedSetTimeout.call(null, fun, 0);
7590
+ } catch (e2) {
7591
+ return cachedSetTimeout.call(this, fun, 0);
7592
+ }
7593
+ }
7594
+ }
7595
+ function runClearTimeout(marker) {
7596
+ if (cachedClearTimeout === clearTimeout) {
7597
+ return clearTimeout(marker);
7598
+ }
7599
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
7600
+ cachedClearTimeout = clearTimeout;
7601
+ return clearTimeout(marker);
7602
+ }
7603
+ try {
7604
+ return cachedClearTimeout(marker);
7605
+ } catch (e) {
7606
+ try {
7607
+ return cachedClearTimeout.call(null, marker);
7608
+ } catch (e2) {
7609
+ return cachedClearTimeout.call(this, marker);
7610
+ }
7611
+ }
7612
+ }
7613
+ var queue = [];
7614
+ var draining = false;
7615
+ var currentQueue;
7616
+ var queueIndex = -1;
7617
+ function cleanUpNextTick() {
7618
+ if (!draining || !currentQueue) {
7619
+ return;
7620
+ }
7621
+ draining = false;
7622
+ if (currentQueue.length) {
7623
+ queue = currentQueue.concat(queue);
7624
+ } else {
7625
+ queueIndex = -1;
7626
+ }
7627
+ if (queue.length) {
7628
+ drainQueue();
7629
+ }
7630
+ }
7631
+ function drainQueue() {
7632
+ if (draining) {
7633
+ return;
7634
+ }
7635
+ var timeout = runTimeout(cleanUpNextTick);
7636
+ draining = true;
7637
+ var len = queue.length;
7638
+ while (len) {
7639
+ currentQueue = queue;
7640
+ queue = [];
7641
+ while (++queueIndex < len) {
7642
+ if (currentQueue) {
7643
+ currentQueue[queueIndex].run();
7644
+ }
7645
+ }
7646
+ queueIndex = -1;
7647
+ len = queue.length;
7648
+ }
7649
+ currentQueue = null;
7650
+ draining = false;
7651
+ runClearTimeout(timeout);
7652
+ }
7653
+ process2.nextTick = function(fun) {
7654
+ var args = new Array(arguments.length - 1);
7655
+ if (arguments.length > 1) {
7656
+ for (var i = 1; i < arguments.length; i++) {
7657
+ args[i - 1] = arguments[i];
7658
+ }
7659
+ }
7660
+ queue.push(new Item(fun, args));
7661
+ if (queue.length === 1 && !draining) {
7662
+ runTimeout(drainQueue);
7663
+ }
7664
+ };
7665
+ function Item(fun, array) {
7666
+ this.fun = fun;
7667
+ this.array = array;
7668
+ }
7669
+ Item.prototype.run = function() {
7670
+ this.fun.apply(null, this.array);
7671
+ };
7672
+ process2.title = "browser";
7673
+ process2.browser = true;
7674
+ process2.env = {};
7675
+ process2.argv = [];
7676
+ process2.version = "";
7677
+ process2.versions = {};
7678
+ function noop2() {
7679
+ }
7680
+ process2.on = noop2;
7681
+ process2.addListener = noop2;
7682
+ process2.once = noop2;
7683
+ process2.off = noop2;
7684
+ process2.removeListener = noop2;
7685
+ process2.removeAllListeners = noop2;
7686
+ process2.emit = noop2;
7687
+ process2.prependListener = noop2;
7688
+ process2.prependOnceListener = noop2;
7689
+ process2.listeners = function(name2) {
7690
+ return [];
7691
+ };
7692
+ process2.binding = function(name2) {
7693
+ throw new Error("process.binding is not supported");
7694
+ };
7695
+ process2.cwd = function() {
7696
+ return "/";
7697
+ };
7698
+ process2.chdir = function(dir) {
7699
+ throw new Error("process.chdir is not supported");
7700
+ };
7701
+ process2.umask = function() {
7702
+ return 0;
7703
+ };
7704
+ var browserExports = browser.exports;
7705
+ const process$1 = /* @__PURE__ */ getDefaultExportFromCjs2(browserExports);
7706
+ exports.default = process$1;
7707
+ exports.process = process$1;
7708
+ })(dist);
7709
+ return dist;
7710
+ }
7711
+ var distExports = requireDist();
7712
+ const process = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
7537
7713
  function commonjsRequire(path) {
7538
7714
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
7539
7715
  }
7540
7716
  var jszip_min = { exports: {} };
7541
- /*!
7542
-
7543
- JSZip v3.10.1 - A JavaScript class for generating and reading zip files
7544
- <http://stuartk.com/jszip>
7545
-
7546
- (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
7547
- Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
7548
-
7549
- JSZip uses the library pako released under the MIT license :
7550
- https://github.com/nodeca/pako/blob/main/LICENSE
7551
- */
7552
7717
  var hasRequiredJszip_min;
7553
7718
  function requireJszip_min() {
7554
7719
  if (hasRequiredJszip_min) return jszip_min.exports;
@@ -11495,7 +11660,7 @@ _errorHandler = new WeakMap();
11495
11660
  _ConsoleLogger_instances = new WeakSet();
11496
11661
  levelValue_get = function() {
11497
11662
  if (__privateGet(this, _levelString) === "env") {
11498
- const envLevel = typeof process !== "undefined" ? define_process_env_default.LOG_LEVEL : void 0;
11663
+ const envLevel = typeof process !== "undefined" && "env" in process ? define_process_env_default.LOG_LEVEL : void 0;
11499
11664
  if (!envLevel) {
11500
11665
  return LEVELS.debug;
11501
11666
  }
@@ -11549,7 +11714,7 @@ class ConflictOperationError extends OperationError {
11549
11714
  }
11550
11715
  class DocumentAlreadyExistsError extends Error {
11551
11716
  constructor(documentId) {
11552
- super(`Document with id ${documentId} already exists`);
11717
+ super(`Document with id ${documentId} uses id or slug that already exists`);
11553
11718
  __publicField(this, "documentId");
11554
11719
  this.documentId = documentId;
11555
11720
  }
@@ -23376,17 +23541,13 @@ class BaseDocumentDriveServer {
23376
23541
  if (!id) {
23377
23542
  throw new Error("Invalid Drive Id");
23378
23543
  }
23379
- const drives = await this.legacyStorage.getDrives();
23380
- if (drives.includes(id)) {
23381
- throw new DocumentAlreadyExistsError(id);
23382
- }
23383
23544
  const document = createDocument({
23384
23545
  state: input
23385
23546
  });
23386
23547
  document.meta = {
23387
23548
  preferredEditor
23388
23549
  };
23389
- await this.legacyStorage.createDrive(id, document);
23550
+ await this.documentStorage.create(id, document);
23390
23551
  if (input.global.slug) {
23391
23552
  await this.cache.deleteDriveBySlug(input.global.slug);
23392
23553
  }
@@ -23429,8 +23590,16 @@ class BaseDocumentDriveServer {
23429
23590
  }
23430
23591
  });
23431
23592
  }
23432
- getDrives() {
23433
- return this.legacyStorage.getDrives();
23593
+ // TODO: paginate
23594
+ async getDrives() {
23595
+ const drives = [];
23596
+ let cursor;
23597
+ do {
23598
+ const { documents, nextCursor } = await this.documentStorage.findByType("powerhouse/document-drive", 100, cursor);
23599
+ drives.push(...documents);
23600
+ cursor = nextCursor;
23601
+ } while (cursor);
23602
+ return drives;
23434
23603
  }
23435
23604
  async getDrive(driveId, options) {
23436
23605
  let document;
@@ -24197,17 +24366,25 @@ class MemoryStorage {
24197
24366
  exists(documentId) {
24198
24367
  return Promise.resolve(!!this.documents[documentId]);
24199
24368
  }
24200
- // TODO: this should throw an error if the document already exists.
24201
24369
  create(documentId, document) {
24202
24370
  var _a2;
24371
+ if (this.documents[documentId]) {
24372
+ throw new DocumentAlreadyExistsError(documentId);
24373
+ }
24374
+ const slug = ((_a2 = document.initialState.state.global) == null ? void 0 : _a2.slug) ?? documentId;
24375
+ if (slug && this.slugToDocumentId[slug]) {
24376
+ throw new DocumentAlreadyExistsError(documentId);
24377
+ }
24203
24378
  this.documents[documentId] = document;
24204
- const slug = (_a2 = document.initialState.state.global) == null ? void 0 : _a2.slug;
24205
24379
  if (slug) {
24206
24380
  if (this.slugToDocumentId[slug]) {
24207
- throw new Error(`Document with slug ${slug} already exists`);
24381
+ throw new DocumentAlreadyExistsError(documentId);
24208
24382
  }
24209
24383
  this.slugToDocumentId[slug] = documentId;
24210
24384
  }
24385
+ if (document.documentType === "powerhouse/document-drive") {
24386
+ this.updateDriveManifest(documentId, { documentIds: /* @__PURE__ */ new Set() });
24387
+ }
24211
24388
  return Promise.resolve();
24212
24389
  }
24213
24390
  get(documentId) {
@@ -24224,6 +24401,38 @@ class MemoryStorage {
24224
24401
  }
24225
24402
  return this.get(documentId);
24226
24403
  }
24404
+ async findByType(documentModelType, limit = 100, cursor) {
24405
+ const documentsAndIds = Object.entries(this.documents).filter(([_, doc]) => doc.documentType === documentModelType).map(([id, doc]) => ({
24406
+ id,
24407
+ document: doc
24408
+ }));
24409
+ documentsAndIds.sort((a, b) => {
24410
+ const aDate = new Date(a.document.created);
24411
+ const bDate = new Date(b.document.created);
24412
+ if (aDate.getTime() === bDate.getTime()) {
24413
+ const aId = a.id;
24414
+ const bId = b.id;
24415
+ return aId.localeCompare(bId);
24416
+ }
24417
+ return aDate.getTime() - bDate.getTime();
24418
+ });
24419
+ let startIndex = 0;
24420
+ if (cursor) {
24421
+ const index = documentsAndIds.findIndex(({ id }) => id === cursor);
24422
+ if (index !== -1) {
24423
+ startIndex = index;
24424
+ }
24425
+ }
24426
+ const endIndex = Math.min(startIndex + limit, documentsAndIds.length);
24427
+ let nextCursor;
24428
+ if (endIndex < documentsAndIds.length) {
24429
+ nextCursor = documentsAndIds[endIndex].id;
24430
+ }
24431
+ return {
24432
+ documents: documentsAndIds.slice(startIndex, endIndex).map(({ id }) => id),
24433
+ nextCursor
24434
+ };
24435
+ }
24227
24436
  async delete(documentId) {
24228
24437
  var _a2;
24229
24438
  const document = this.documents[documentId];
@@ -24233,12 +24442,17 @@ class MemoryStorage {
24233
24442
  delete this.slugToDocumentId[slug];
24234
24443
  }
24235
24444
  }
24236
- const drives = await this.getDrives();
24237
- for (const driveId of drives) {
24238
- if (driveId === documentId)
24239
- continue;
24240
- await this.removeChild(driveId, documentId);
24241
- }
24445
+ let cursor;
24446
+ do {
24447
+ const { documents, nextCursor } = await this.findByType("powerhouse/document-drive", 100, cursor);
24448
+ for (const driveId of documents) {
24449
+ if (driveId === documentId) {
24450
+ continue;
24451
+ }
24452
+ await this.removeChild(driveId, documentId);
24453
+ }
24454
+ cursor = nextCursor;
24455
+ } while (cursor);
24242
24456
  delete this.driveManifests[documentId];
24243
24457
  if (this.documents[documentId]) {
24244
24458
  delete this.documents[documentId];
@@ -24291,13 +24505,6 @@ class MemoryStorage {
24291
24505
  operations: mergedOperations
24292
24506
  };
24293
24507
  }
24294
- async getDrives() {
24295
- return Object.keys(this.driveManifests);
24296
- }
24297
- async createDrive(id, drive) {
24298
- await this.create(id, drive);
24299
- this.updateDriveManifest(id, { documentIds: /* @__PURE__ */ new Set() });
24300
- }
24301
24508
  async addDriveOperations(id, operations, header) {
24302
24509
  const drive = await this.get(id);
24303
24510
  const mergedOperations = mergeOperations(drive.operations, operations);
@@ -24309,27 +24516,31 @@ class MemoryStorage {
24309
24516
  }
24310
24517
  async deleteDrive(id) {
24311
24518
  const manifest = this.getManifest(id);
24312
- const drives = await this.getDrives();
24313
- await Promise.all([...manifest.documentIds].map((docId) => {
24314
- var _a2;
24315
- for (const driveId of drives) {
24316
- if (driveId === id) {
24317
- continue;
24318
- }
24319
- const manifest2 = this.getManifest(driveId);
24320
- if (manifest2.documentIds.has(docId)) {
24321
- return;
24519
+ let cursor;
24520
+ do {
24521
+ const { documents: drives, nextCursor } = await this.findByType("powerhouse/document-drive", 100, cursor);
24522
+ await Promise.all([...manifest.documentIds].map((docId) => {
24523
+ var _a2;
24524
+ for (const driveId of drives) {
24525
+ if (driveId === id) {
24526
+ continue;
24527
+ }
24528
+ const manifest2 = this.getManifest(driveId);
24529
+ if (manifest2.documentIds.has(docId)) {
24530
+ return;
24531
+ }
24322
24532
  }
24323
- }
24324
- const document = this.documents[docId];
24325
- if (document) {
24326
- const slug = (_a2 = document.initialState.state.global) == null ? void 0 : _a2.slug;
24327
- if (slug && this.slugToDocumentId[slug] === docId) {
24328
- delete this.slugToDocumentId[slug];
24533
+ const document = this.documents[docId];
24534
+ if (document) {
24535
+ const slug = (_a2 = document.initialState.state.global) == null ? void 0 : _a2.slug;
24536
+ if (slug && this.slugToDocumentId[slug] === docId) {
24537
+ delete this.slugToDocumentId[slug];
24538
+ }
24329
24539
  }
24330
- }
24331
- delete this.documents[docId];
24332
- }));
24540
+ delete this.documents[docId];
24541
+ }));
24542
+ cursor = nextCursor;
24543
+ } while (cursor);
24333
24544
  delete this.driveManifests[id];
24334
24545
  delete this.documents[id];
24335
24546
  }
@@ -25822,7 +26033,7 @@ const nodeOptionsMap = {
25822
26033
  };
25823
26034
  const name = "@powerhousedao/connect";
25824
26035
  const productName = "Powerhouse-Connect";
25825
- const version$1 = "1.0.17-dev.1";
26036
+ const version$1 = "1.0.17-dev.2";
25826
26037
  const description = "Powerhouse Connect";
25827
26038
  const main = "./dist/index.html";
25828
26039
  const type = "module";
@@ -25834,7 +26045,7 @@ const repository = { "type": "git", "url": "git+https://github.com/powerhouse-in
25834
26045
  const bugs = { "url": "https://github.com/powerhouse-inc/document-model-electron/issues" };
25835
26046
  const homepage = "https://github.com/powerhouse-inc/document-model-electron#readme";
25836
26047
  const scripts = { "build:tsc": "tsc --build", "start": "electron-forge start", "package": "electron-forge package", "make": "PH_CONNECT_BASE_HREF=./ electron-forge make", "make:mac": "PH_CONNECT_BASE_HREF=./ electron-forge make -p darwin", "make:linux": "PH_CONNECT_BASE_HREF=./ electron-forge make -p linux", "make:windows": "PH_CONNECT_BASE_HREF=./ electron-forge make -p win32", "publish:electron": "electron-forge publish", "prepublishOnly": "npm run build", "lint": "eslint .", "lint:fix": "eslint --fix .", "lint:nx": "eslint --quiet --fix .", "format": 'prettier --write "**/*.+(js|ts|jsx|tsx|json)"', "dev": "vite -c vite.renderer.config.mts", "dev:nocache": "rm -rf node_modules/.vite && rm -rf node_modules/.cache && npm run dev", "prebuild": "tsc --build --noEmit", "build": "NODE_OPTIONS=--max-old-space-size=6144 vite build -c vite.renderer.config.mts", "preview:web": "vite preview -c vite.renderer.config.mts", "e2e": "playwright test", "cy:open": "cypress open", "build:service-worker": "tsc --build ./tsconfig.sw.json", "clean": "rimraf dist", "clean:node_modules": "rimraf node_modules" };
25837
- const devDependencies = { "@electron-forge/cli": "^6.1.1", "@electron-forge/maker-deb": "^6.1.1", "@electron-forge/maker-rpm": "^6.1.1", "@electron-forge/maker-squirrel": "^6.1.1", "@electron-forge/maker-zip": "^6.1.1", "@electron-forge/plugin-vite": "^6.1.1", "@electron-forge/publisher-electron-release-server": "^6.2.1", "@electron-forge/publisher-github": "^7.2.0", "@electron-forge/shared-types": "^7.7.0", "@playwright/test": "^1.41.2", "@powerhousedao/builder-tools": "workspace:*", "@powerhousedao/common": "workspace:*", "@powerhousedao/config": "workspace:*", "@powerhousedao/design-system": "workspace:*", "@powerhousedao/reactor-browser": "workspace:*", "@powerhousedao/scalars": "workspace:*", "@rollup/plugin-node-resolve": "^15.2.3", "@sentry/browser": "^9.1.0", "@sentry/react": "^7.109.0", "@sentry/vite-plugin": "^2.22.2", "@tailwindcss/vite": "^4.0.9", "@tanstack/react-virtual": "^3.8.1", "@types/node": "^22.13.10", "@types/react": "^18.2.79", "@types/react-dom": "^18.2.18", "@types/uuid": "^9.0.7", "@types/wicg-file-system-access": "^2020.9.6", "@vitejs/plugin-basic-ssl": "^1.2.0", "@vitejs/plugin-react": "^4.2.1", "asar": "^3.2.0", "did-key-creator": "^1.2.0", "document-drive": "workspace:*", "document-model": "workspace:*", "electron": "30.0.0", "electron-is-dev": "^3.0.1", "electron-playwright-helpers": "^1.7.1", "electron-squirrel-startup": "^1.0.0", "electron-store": "^8.1.0", "esbuild": "^0.24.0", "graphql": "^16.8.1", "graphql-request": "^6.1.0", "i18next": "^23.7.6", "jotai": "^2.1.0", "jotai-effect": "^1.1.6", "localforage": "^1.10.0", "lz-string": "^1.5.0", "playwright": "^1.41.2", "playwright-core": "^1.41.2", "react": "^18.2.0", "react-dom": "^18.2.0", "react-error-boundary": "^4.0.11", "react-hotkeys-hook": "^4.5.0", "react-i18next": "^13.5.0", "react-router-dom": "^6.11.2", "tailwind-merge": "^3.0.2", "tailwindcss": "^4.0.9", "uuid": "^9.0.1", "viem": "^2.8.13", "vite": "^6.2.2", "vite-envs": "^4.4.11", "vite-plugin-html": "^3.2.2", "vite-plugin-node-polyfills": "^0.23.0", "vite-plugin-svgr": "^4.2.0", "vite-tsconfig-paths": "^4.3.2", "xvfb-maybe": "^0.2.1" };
26048
+ const devDependencies = { "@electron-forge/cli": "^6.1.1", "@electron-forge/maker-deb": "^6.1.1", "@electron-forge/maker-rpm": "^6.1.1", "@electron-forge/maker-squirrel": "^6.1.1", "@electron-forge/maker-zip": "^6.1.1", "@electron-forge/plugin-vite": "^6.1.1", "@electron-forge/publisher-electron-release-server": "^6.2.1", "@electron-forge/publisher-github": "^7.2.0", "@electron-forge/shared-types": "^7.7.0", "@playwright/test": "^1.41.2", "@powerhousedao/builder-tools": "workspace:*", "@powerhousedao/common": "workspace:*", "@powerhousedao/config": "workspace:*", "@powerhousedao/design-system": "workspace:*", "@powerhousedao/diff-analyzer": "^0.0.0-dev.3", "@powerhousedao/reactor-browser": "workspace:*", "@powerhousedao/scalars": "workspace:*", "@rollup/plugin-node-resolve": "^15.2.3", "@sentry/browser": "^9.1.0", "@sentry/react": "^7.109.0", "@sentry/vite-plugin": "^2.22.2", "@tailwindcss/vite": "^4.0.9", "@tanstack/react-virtual": "^3.8.1", "@types/node": "^22.13.10", "@types/react": "^18.2.79", "@types/react-dom": "^18.2.18", "@types/uuid": "^9.0.7", "@types/wicg-file-system-access": "^2020.9.6", "@vitejs/plugin-basic-ssl": "^1.2.0", "@vitejs/plugin-react": "^4.2.1", "asar": "^3.2.0", "did-key-creator": "^1.2.0", "document-drive": "workspace:*", "document-model": "workspace:*", "electron": "30.0.0", "electron-is-dev": "^3.0.1", "electron-playwright-helpers": "^1.7.1", "electron-squirrel-startup": "^1.0.0", "electron-store": "^8.1.0", "esbuild": "^0.24.0", "graphql": "^16.8.1", "graphql-request": "^6.1.0", "i18next": "^23.7.6", "jotai": "^2.1.0", "jotai-effect": "^1.1.6", "localforage": "^1.10.0", "lz-string": "^1.5.0", "playwright": "^1.41.2", "playwright-core": "^1.41.2", "react": "^18.2.0", "react-dom": "^18.2.0", "react-error-boundary": "^4.0.11", "react-hotkeys-hook": "^4.5.0", "react-i18next": "^13.5.0", "react-router-dom": "^6.11.2", "tailwind-merge": "^3.0.2", "tailwindcss": "^4.0.9", "uuid": "^9.0.1", "viem": "^2.8.13", "vite": "^6.2.2", "vite-envs": "^4.4.11", "vite-plugin-html": "^3.2.2", "vite-plugin-node-polyfills": "^0.23.0", "vite-plugin-svgr": "^4.2.0", "vite-tsconfig-paths": "^4.3.2", "xvfb-maybe": "^0.2.1" };
25838
26049
  const optionalDependencies = { "@esbuild/linux-x64": "^0.21.4", "@rollup/rollup-linux-x64-musl": "4.14.3" };
25839
26050
  const packageJson = {
25840
26051
  name,
@@ -28627,12 +28838,20 @@ const _BrowserStorage = class _BrowserStorage {
28627
28838
  const document = await db.getItem(this.buildDocumentKey(documentId));
28628
28839
  return !!document;
28629
28840
  }
28630
- // TODO: this should throw an error if the document already exists.
28631
28841
  async create(documentId, document) {
28632
28842
  var _a2;
28633
28843
  const db = await this.db;
28634
- await db.setItem(this.buildDocumentKey(documentId), document);
28844
+ if (await this.exists(documentId)) {
28845
+ throw new DocumentAlreadyExistsError(documentId);
28846
+ }
28635
28847
  const slug = ((_a2 = document.initialState.state.global) == null ? void 0 : _a2.slug) ?? documentId;
28848
+ if (slug) {
28849
+ const slugManifest = await this.getSlugManifest();
28850
+ if (slugManifest.slugToId[slug]) {
28851
+ throw new DocumentAlreadyExistsError(documentId);
28852
+ }
28853
+ }
28854
+ await db.setItem(this.buildDocumentKey(documentId), document);
28636
28855
  if (slug) {
28637
28856
  const slugManifest = await this.getSlugManifest();
28638
28857
  if (slugManifest.slugToId[slug]) {
@@ -28641,6 +28860,9 @@ const _BrowserStorage = class _BrowserStorage {
28641
28860
  slugManifest.slugToId[slug] = documentId;
28642
28861
  await this.updateSlugManifest(slugManifest);
28643
28862
  }
28863
+ if (document.documentType === "powerhouse/document-drive") {
28864
+ this.updateDriveManifest(documentId, { documentIds: [] });
28865
+ }
28644
28866
  }
28645
28867
  async get(documentId) {
28646
28868
  const db = await this.db;
@@ -28658,6 +28880,48 @@ const _BrowserStorage = class _BrowserStorage {
28658
28880
  }
28659
28881
  return this.get(documentId);
28660
28882
  }
28883
+ async findByType(documentModelType, limit = 100, cursor) {
28884
+ const db = await this.db;
28885
+ const keys = await db.keys();
28886
+ const documentKeys = keys.filter((key) => key.startsWith(`${_BrowserStorage.DOCUMENT_KEY}${_BrowserStorage.SEP}`));
28887
+ const documentsAndIds = [];
28888
+ for (const key of documentKeys) {
28889
+ const documentId = key.slice(_BrowserStorage.DOCUMENT_KEY.length + _BrowserStorage.SEP.length);
28890
+ try {
28891
+ const document = await db.getItem(key);
28892
+ if (!document || document.documentType !== documentModelType) {
28893
+ continue;
28894
+ }
28895
+ documentsAndIds.push({ id: documentId, document });
28896
+ } catch (error) {
28897
+ continue;
28898
+ }
28899
+ }
28900
+ documentsAndIds.sort((a, b) => {
28901
+ const aDate = new Date(a.document.created);
28902
+ const bDate = new Date(b.document.created);
28903
+ if (aDate.getTime() === bDate.getTime()) {
28904
+ return a.id.localeCompare(b.id);
28905
+ }
28906
+ return aDate.getTime() - bDate.getTime();
28907
+ });
28908
+ let startIndex = 0;
28909
+ if (cursor) {
28910
+ const index = documentsAndIds.findIndex(({ id }) => id === cursor);
28911
+ if (index !== -1) {
28912
+ startIndex = index;
28913
+ }
28914
+ }
28915
+ const endIndex = Math.min(startIndex + limit, documentsAndIds.length);
28916
+ let nextCursor;
28917
+ if (endIndex < documentsAndIds.length) {
28918
+ nextCursor = documentsAndIds[endIndex].id;
28919
+ }
28920
+ return {
28921
+ documents: documentsAndIds.slice(startIndex, endIndex).map(({ id }) => id),
28922
+ nextCursor
28923
+ };
28924
+ }
28661
28925
  async delete(documentId) {
28662
28926
  var _a2;
28663
28927
  const db = await this.db;
@@ -28676,12 +28940,17 @@ const _BrowserStorage = class _BrowserStorage {
28676
28940
  }
28677
28941
  } catch (error) {
28678
28942
  }
28679
- const drives = await this.getDrives();
28680
- for (const driveId of drives) {
28681
- if (driveId === documentId)
28682
- continue;
28683
- await this.removeChild(driveId, documentId);
28684
- }
28943
+ let cursor;
28944
+ do {
28945
+ const { documents: drives, nextCursor } = await this.findByType("powerhouse/document-drive", 100, cursor);
28946
+ for (const driveId of drives) {
28947
+ if (driveId === documentId) {
28948
+ continue;
28949
+ }
28950
+ await this.removeChild(driveId, documentId);
28951
+ }
28952
+ cursor = nextCursor;
28953
+ } while (cursor);
28685
28954
  await db.removeItem(this.buildManifestKey(documentId));
28686
28955
  await db.removeItem(this.buildDocumentKey(documentId));
28687
28956
  return true;
@@ -28751,15 +29020,6 @@ const _BrowserStorage = class _BrowserStorage {
28751
29020
  operations: mergedOperations
28752
29021
  });
28753
29022
  }
28754
- async getDrives() {
28755
- const db = await this.db;
28756
- const keys = await db.keys();
28757
- return keys.filter((key) => key.startsWith(_BrowserStorage.MANIFEST_KEY)).map((key) => key.slice(_BrowserStorage.MANIFEST_KEY.length + _BrowserStorage.SEP.length));
28758
- }
28759
- async createDrive(id, drive) {
28760
- await this.create(id, drive);
28761
- await this.updateDriveManifest(id, { documentIds: [] });
28762
- }
28763
29023
  async deleteDrive(id) {
28764
29024
  const documents = await this.getChildren(id);
28765
29025
  await Promise.all(documents.map((doc) => this.delete(doc)));
@@ -28807,12 +29067,16 @@ const _BrowserStorage = class _BrowserStorage {
28807
29067
  }
28808
29068
  // migrates all stored operations from legacy signature to signatures array
28809
29069
  async migrateOperationSignatures() {
28810
- const drives = await this.getDrives();
28811
- for (const drive of drives) {
28812
- await this.migrateDrive(drive);
28813
- const documents = await this.getChildren(drive);
28814
- await Promise.all(documents.map(async (docId) => this.migrateDocument(drive, docId)));
28815
- }
29070
+ let cursor;
29071
+ do {
29072
+ const { documents: drives, nextCursor } = await this.findByType("powerhouse/document-drive", 100, cursor);
29073
+ for (const drive of drives) {
29074
+ await this.migrateDrive(drive);
29075
+ const documents = await this.getChildren(drive);
29076
+ await Promise.all(documents.map(async (docId) => this.migrateDocument(drive, docId)));
29077
+ }
29078
+ cursor = nextCursor;
29079
+ } while (cursor);
28816
29080
  }
28817
29081
  async migrateDrive(driveId) {
28818
29082
  const drive = await this.get(driveId);
@@ -31446,14 +31710,14 @@ if (window.__VITE_ENVS.MODE === "development") {
31446
31710
  } else {
31447
31711
  serviceWorkerManager.registerServiceWorker(false);
31448
31712
  }
31449
- const App = lazy(() => __vitePreload(() => import("./app-CySbX590.js").then((n) => n.aY), true ? __vite__mapDeps([0,1,2]) : void 0));
31713
+ const App = lazy(() => __vitePreload(() => import("./app-CayLrjAy.js").then((n) => n.bG), true ? __vite__mapDeps([0,1,2]) : void 0));
31450
31714
  const AppLoader = /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(App, {}) });
31451
31715
  const appLoader = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
31452
31716
  __proto__: null,
31453
31717
  default: AppLoader
31454
31718
  }, Symbol.toStringTag, { value: "Module" }));
31455
31719
  export {
31456
- getDefaultExportFromCjs as $,
31720
+ Icon as $,
31457
31721
  AddStateExampleInputSchema as A,
31458
31722
  SetModuleDescriptionInputSchema as B,
31459
31723
  SetModuleNameInputSchema as C,
@@ -31480,49 +31744,49 @@ export {
31480
31744
  baseLoadFromFile as X,
31481
31745
  baseLoadFromInput as Y,
31482
31746
  pascalCase as Z,
31483
- Icon as _,
31747
+ logger$1 as _,
31484
31748
  createReducer as a,
31485
- DELETE as a$,
31486
- LOCAL as a0,
31487
- commonjsGlobal as a1,
31488
- PUBLIC as a2,
31489
- SWITCHBOARD as a3,
31490
- locationInfoByLocation as a4,
31491
- sharingTypeOptions as a5,
31492
- objectType as a6,
31493
- recordType as a7,
31494
- stringType as a8,
31495
- capitalCase as a9,
31496
- moveNode as aA,
31497
- generateNodesCopy as aB,
31498
- copyNode as aC,
31499
- createState as aD,
31500
- setDriveName as aE,
31501
- setAvailableOffline as aF,
31502
- setSharingType as aG,
31503
- SynchronizationUnitNotFoundError as aH,
31504
- removeTrigger as aI,
31505
- generateUUID as aJ,
31506
- PullResponderTransmitter as aK,
31507
- addTrigger as aL,
31508
- ReadDriveNotFoundError as aM,
31509
- openUrl as aN,
31510
- getNodeOptions as aO,
31511
- DRIVE as aP,
31512
- FOLDER as aQ,
31513
- requestPublicDrive as aR,
31514
- serviceWorkerManager as aS,
31515
- packageJson as aT,
31516
- t as aU,
31517
- gql as aV,
31518
- request as aW,
31519
- getDimensions as aX,
31520
- READ as aY,
31521
- nodeOptionsMap as aZ,
31522
- defaultFileOptions as a_,
31523
- CLOUD as aa,
31524
- createZip as ab,
31525
- logger$1 as ac,
31749
+ getNamedType as a$,
31750
+ getDefaultExportFromCjs as a0,
31751
+ LOCAL as a1,
31752
+ commonjsGlobal as a2,
31753
+ PUBLIC as a3,
31754
+ SWITCHBOARD as a4,
31755
+ locationInfoByLocation as a5,
31756
+ sharingTypeOptions as a6,
31757
+ objectType as a7,
31758
+ recordType as a8,
31759
+ stringType as a9,
31760
+ FILE as aA,
31761
+ moveNode as aB,
31762
+ generateNodesCopy as aC,
31763
+ copyNode as aD,
31764
+ createState as aE,
31765
+ setDriveName as aF,
31766
+ setAvailableOffline as aG,
31767
+ setSharingType as aH,
31768
+ SynchronizationUnitNotFoundError as aI,
31769
+ removeTrigger as aJ,
31770
+ generateUUID as aK,
31771
+ PullResponderTransmitter as aL,
31772
+ addTrigger as aM,
31773
+ ReadDriveNotFoundError as aN,
31774
+ openUrl as aO,
31775
+ getNodeOptions as aP,
31776
+ DRIVE as aQ,
31777
+ FOLDER as aR,
31778
+ requestPublicDrive as aS,
31779
+ serviceWorkerManager as aT,
31780
+ packageJson as aU,
31781
+ t as aV,
31782
+ generateId as aW,
31783
+ gql as aX,
31784
+ request as aY,
31785
+ inspect as aZ,
31786
+ GraphQLError as a_,
31787
+ capitalCase as aa,
31788
+ CLOUD as ab,
31789
+ createZip as ac,
31526
31790
  LZString as ad,
31527
31791
  buildSignedOperation as ae,
31528
31792
  getI18n as af,
@@ -31530,99 +31794,100 @@ export {
31530
31794
  connectConfig as ah,
31531
31795
  hashDocumentStateForScope as ai,
31532
31796
  getAugmentedNamespace as aj,
31533
- setErrorHandler as ak,
31534
- driveDocumentModelModule as al,
31535
- createBrowserDocumentDriveServer as am,
31536
- hashKey as an,
31537
- childLogger as ao,
31538
- reducer as ap,
31539
- isDocumentDrive as aq,
31540
- generateAddNodeAction as ar,
31541
- isFileNode as as,
31542
- uploadDocumentOperations as at,
31543
- updateFile as au,
31544
- addFolder as av,
31545
- isFolderNode as aw,
31546
- deleteNode as ax,
31547
- updateNode as ay,
31548
- FILE as az,
31797
+ process as ak,
31798
+ setErrorHandler as al,
31799
+ driveDocumentModelModule as am,
31800
+ createBrowserDocumentDriveServer as an,
31801
+ hashKey as ao,
31802
+ childLogger as ap,
31803
+ reducer as aq,
31804
+ isDocumentDrive as ar,
31805
+ generateAddNodeAction as as,
31806
+ isFileNode as at,
31807
+ uploadDocumentOperations as au,
31808
+ updateFile as av,
31809
+ addFolder as aw,
31810
+ isFolderNode as ax,
31811
+ deleteNode as ay,
31812
+ updateNode as az,
31549
31813
  SetStateSchemaInputSchema as b,
31550
- GraphQLFloat as b$,
31551
- RENAME as b0,
31552
- WRITE as b1,
31553
- DUPLICATE as b2,
31554
- defaultFolderOptions as b3,
31555
- garbageCollect as b4,
31556
- sortOperations as b5,
31557
- UI_NODE as b6,
31558
- generateId as b7,
31559
- undo as b8,
31560
- redo as b9,
31561
- isListType as bA,
31562
- snakeCase as bB,
31563
- constantCase as bC,
31564
- isAbstractType as bD,
31565
- BREAK as bE,
31566
- GraphQLInputObjectType as bF,
31567
- GraphQLList as bG,
31568
- GraphQLEnumType as bH,
31569
- GraphQLObjectType as bI,
31570
- GraphQLInterfaceType as bJ,
31571
- SchemaMetaFieldDef as bK,
31572
- TypeMetaFieldDef as bL,
31573
- TypeNameMetaFieldDef as bM,
31574
- isCompositeType as bN,
31575
- isOutputType as bO,
31576
- isInputType as bP,
31577
- GraphQLBoolean as bQ,
31578
- assertAbstractType as bR,
31579
- doTypesOverlap as bS,
31580
- DirectiveLocation as bT,
31581
- specifiedRules as bU,
31582
- NoUnusedFragmentsRule as bV,
31583
- ExecutableDefinitionsRule as bW,
31584
- validate as bX,
31585
- validateSchema as bY,
31586
- GraphQLID as bZ,
31587
- GraphQLString as b_,
31588
- useDocumentDispatch as ba,
31589
- inspect as bb,
31590
- GraphQLError as bc,
31591
- getNamedType as bd,
31592
- invariant as be,
31593
- isInputObjectType as bf,
31594
- isScalarType as bg,
31595
- isObjectType as bh,
31596
- isInterfaceType as bi,
31597
- isUnionType as bj,
31598
- isEnumType as bk,
31599
- print as bl,
31600
- isPrintableAsBlockString as bm,
31601
- Kind as bn,
31602
- astFromValue as bo,
31603
- DEFAULT_DEPRECATION_REASON as bp,
31604
- isSpecifiedDirective as bq,
31605
- isSpecifiedScalarType as br,
31606
- isIntrospectionType as bs,
31607
- z as bt,
31608
- GraphQLScalarType as bu,
31609
- parse as bv,
31610
- visit as bw,
31611
- buildASTSchema as bx,
31612
- extendSchema as by,
31613
- getNullableType as bz,
31814
+ defaultFileOptions as b$,
31815
+ invariant as b0,
31816
+ isInputObjectType as b1,
31817
+ isScalarType as b2,
31818
+ isObjectType as b3,
31819
+ isInterfaceType as b4,
31820
+ isUnionType as b5,
31821
+ isEnumType as b6,
31822
+ print as b7,
31823
+ isPrintableAsBlockString as b8,
31824
+ Kind as b9,
31825
+ isOutputType as bA,
31826
+ isInputType as bB,
31827
+ GraphQLBoolean as bC,
31828
+ assertAbstractType as bD,
31829
+ doTypesOverlap as bE,
31830
+ DirectiveLocation as bF,
31831
+ specifiedRules as bG,
31832
+ NoUnusedFragmentsRule as bH,
31833
+ ExecutableDefinitionsRule as bI,
31834
+ validate as bJ,
31835
+ validateSchema as bK,
31836
+ GraphQLID as bL,
31837
+ GraphQLString as bM,
31838
+ GraphQLFloat as bN,
31839
+ GraphQLInt as bO,
31840
+ GraphQLDirective as bP,
31841
+ GraphQLUnionType as bQ,
31842
+ isNonNullType as bR,
31843
+ GraphQLNonNull as bS,
31844
+ isNamedType as bT,
31845
+ isLeafType as bU,
31846
+ GraphQLSchema as bV,
31847
+ buildSchema as bW,
31848
+ sentenceCase as bX,
31849
+ getDimensions as bY,
31850
+ READ as bZ,
31851
+ nodeOptionsMap as b_,
31852
+ astFromValue as ba,
31853
+ DEFAULT_DEPRECATION_REASON as bb,
31854
+ isSpecifiedDirective as bc,
31855
+ isSpecifiedScalarType as bd,
31856
+ isIntrospectionType as be,
31857
+ z as bf,
31858
+ GraphQLScalarType as bg,
31859
+ parse as bh,
31860
+ visit as bi,
31861
+ buildASTSchema as bj,
31862
+ extendSchema as bk,
31863
+ getNullableType as bl,
31864
+ isListType as bm,
31865
+ snakeCase as bn,
31866
+ constantCase as bo,
31867
+ isAbstractType as bp,
31868
+ BREAK as bq,
31869
+ GraphQLInputObjectType as br,
31870
+ GraphQLList as bs,
31871
+ GraphQLEnumType as bt,
31872
+ GraphQLObjectType as bu,
31873
+ GraphQLInterfaceType as bv,
31874
+ SchemaMetaFieldDef as bw,
31875
+ TypeMetaFieldDef as bx,
31876
+ TypeNameMetaFieldDef as by,
31877
+ isCompositeType as bz,
31614
31878
  createAction as c,
31615
- GraphQLInt as c0,
31616
- GraphQLDirective as c1,
31617
- GraphQLUnionType as c2,
31618
- isNonNullType as c3,
31619
- GraphQLNonNull as c4,
31620
- isNamedType as c5,
31621
- isLeafType as c6,
31622
- GraphQLSchema as c7,
31623
- buildSchema as c8,
31624
- sentenceCase as c9,
31625
- appLoader as ca,
31879
+ DELETE as c0,
31880
+ RENAME as c1,
31881
+ WRITE as c2,
31882
+ DUPLICATE as c3,
31883
+ defaultFolderOptions as c4,
31884
+ garbageCollect as c5,
31885
+ sortOperations as c6,
31886
+ UI_NODE as c7,
31887
+ undo as c8,
31888
+ redo as c9,
31889
+ useDocumentDispatch as ca,
31890
+ appLoader as cb,
31626
31891
  ReorderModuleOperationsInputSchema as d,
31627
31892
  DeleteOperationInputSchema as e,
31628
31893
  SetOperationReducerInputSchema as f,
@@ -31647,3 +31912,4 @@ export {
31647
31912
  ReorderModulesInputSchema as y,
31648
31913
  DeleteModuleInputSchema as z
31649
31914
  };
31915
+ //# sourceMappingURL=app-loader-Ej0QwX6c.js.map