@powerhousedao/connect 1.0.22-staging.1 → 1.0.23-dev.1

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 (37) hide show
  1. package/dist/.env +1 -1
  2. package/dist/assets/{app-CSCydE8J.css → app-D5gNm0Gn.css} +240 -181
  3. package/dist/assets/{app-BIg_-piZ.js → app-DCtCV8Sz.js} +19842 -18216
  4. package/dist/assets/app-DCtCV8Sz.js.map +1 -0
  5. package/dist/assets/{app-loader-mwZgOVwV.js → app-loader-BAEWEx-m.js} +740 -422
  6. package/dist/assets/app-loader-BAEWEx-m.js.map +1 -0
  7. package/dist/assets/{app-loader-3ipafc56.css → app-loader-NDVZu4bS.css} +238 -228
  8. package/dist/assets/browser-BeUBqndM.js +27224 -0
  9. package/dist/assets/browser-BeUBqndM.js.map +1 -0
  10. package/dist/assets/{ccip-i-oLVbil.js → ccip-CMd6tRtn.js} +6 -8
  11. package/dist/assets/ccip-CMd6tRtn.js.map +1 -0
  12. package/dist/assets/{content-CsEKVDJz.js → content-DsWyfJvF.js} +1105 -463
  13. package/dist/assets/content-DsWyfJvF.js.map +1 -0
  14. package/dist/assets/{index-M4h38SB3.js → index-ADsM2QWh.js} +23 -171
  15. package/dist/assets/index-ADsM2QWh.js.map +1 -0
  16. package/dist/assets/{index-BOWJSJaO.js → index-CCDoOj0e.js} +4 -3
  17. package/dist/assets/index-CCDoOj0e.js.map +1 -0
  18. package/dist/assets/{index-B469WXKP.js → index-CSN0Iyem.js} +615 -830
  19. package/dist/assets/index-CSN0Iyem.js.map +1 -0
  20. package/dist/assets/index-Dl8ZqWS0.js +208 -0
  21. package/dist/assets/index-Dl8ZqWS0.js.map +1 -0
  22. package/dist/assets/{main.DfFOgz9f.js → main.DW9UCmAK.js} +3 -12
  23. package/dist/assets/main.DW9UCmAK.js.map +1 -0
  24. package/dist/assets/reactor-analytics-hlzA2WG5.js +42 -0
  25. package/dist/assets/reactor-analytics-hlzA2WG5.js.map +1 -0
  26. package/dist/assets/router-DJRPUFad.js +1585 -0
  27. package/dist/assets/router-DJRPUFad.js.map +1 -0
  28. package/dist/assets/{style-0ej1afQi.css → style-CdxGKc2g.css} +39 -95
  29. package/dist/external-packages.js +1 -0
  30. package/dist/external-packages.js.map +1 -0
  31. package/dist/hmr.js +1 -0
  32. package/dist/hmr.js.map +1 -0
  33. package/dist/index.html +1 -1
  34. package/dist/service-worker.js +1 -0
  35. package/dist/service-worker.js.map +1 -0
  36. package/dist/vite-envs.sh +1 -1
  37. package/package.json +26 -19
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-BIg_-piZ.js","assets/main.DfFOgz9f.js","assets/app-CSCydE8J.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-DCtCV8Sz.js","assets/main.DW9UCmAK.js","assets/app-D5gNm0Gn.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.DfFOgz9f.js";
14
+ import { _ as __vitePreload } from "./main.DW9UCmAK.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) {
@@ -97,14 +97,51 @@ const trimResultingState = (document) => {
97
97
  });
98
98
  return { ...document, operations: { global: global2, local } };
99
99
  };
100
+ class CacheStorageManager {
101
+ constructor(cache) {
102
+ __publicField(this, "index", 0);
103
+ __publicField(this, "cache");
104
+ this.cache = cache;
105
+ }
106
+ createStorage() {
107
+ const index = this.index;
108
+ this.index += 1;
109
+ function buildKey(key) {
110
+ return `${index}-${key}`;
111
+ }
112
+ const storage = {
113
+ get: (key) => {
114
+ return this.cache.get(buildKey(key));
115
+ },
116
+ set: (key, value) => {
117
+ this.cache.set(buildKey(key), value);
118
+ return storage;
119
+ },
120
+ delete: (key) => {
121
+ return this.cache.delete(buildKey(key));
122
+ },
123
+ clear: () => {
124
+ this.cache.clear();
125
+ }
126
+ };
127
+ return storage;
128
+ }
129
+ }
100
130
  class InMemoryCache {
101
- constructor() {
102
- __publicField(this, "idTodocument", /* @__PURE__ */ new Map());
103
- __publicField(this, "idToDrive", /* @__PURE__ */ new Map());
104
- __publicField(this, "slugToDriveId", /* @__PURE__ */ new Map());
131
+ constructor(cache = /* @__PURE__ */ new Map()) {
132
+ __publicField(this, "cache");
133
+ __publicField(this, "cacheStorageManager");
134
+ __publicField(this, "idToDocument");
135
+ __publicField(this, "idToDrive");
136
+ __publicField(this, "slugToDriveId");
137
+ this.cache = cache;
138
+ this.cacheStorageManager = new CacheStorageManager(cache);
139
+ this.idToDocument = this.cacheStorageManager.createStorage();
140
+ this.idToDrive = this.cacheStorageManager.createStorage();
141
+ this.slugToDriveId = this.cacheStorageManager.createStorage();
105
142
  }
106
143
  clear() {
107
- this.idTodocument.clear();
144
+ this.idToDocument.clear();
108
145
  this.idToDrive.clear();
109
146
  this.slugToDriveId.clear();
110
147
  }
@@ -113,13 +150,13 @@ class InMemoryCache {
113
150
  /////////////////////////////////////////////////////////////////////////////
114
151
  async setDocument(documentId, document) {
115
152
  const doc = trimResultingState(document);
116
- this.idTodocument.set(documentId, doc);
153
+ this.idToDocument.set(documentId, doc);
117
154
  }
118
155
  async getDocument(documentId) {
119
- return this.idTodocument.get(documentId);
156
+ return this.idToDocument.get(documentId);
120
157
  }
121
158
  async deleteDocument(documentId) {
122
- return this.idTodocument.delete(documentId);
159
+ return this.idToDocument.delete(documentId);
123
160
  }
124
161
  async setDrive(driveId, drive) {
125
162
  const doc = trimResultingState(drive);
@@ -133,14 +170,14 @@ class InMemoryCache {
133
170
  if (!drive) {
134
171
  return false;
135
172
  }
136
- const slug = drive.state.global.slug;
173
+ const slug = drive.slug.length > 0 ? drive.slug : driveId;
137
174
  if (slug) {
138
175
  this.slugToDriveId.delete(slug);
139
176
  }
140
177
  return this.idToDrive.delete(driveId);
141
178
  }
142
179
  async setDriveBySlug(slug, drive) {
143
- const driveId = drive.state.global.id;
180
+ const driveId = drive.id;
144
181
  this.slugToDriveId.set(slug, driveId);
145
182
  this.setDrive(driveId, drive);
146
183
  }
@@ -388,8 +425,8 @@ function isBE() {
388
425
  return buf[0] === 254;
389
426
  }
390
427
  const FileSystemError = new Error("File system not available.");
391
- function generateUUID$1() {
392
- if (!crypto.randomUUID) {
428
+ function generateUUID() {
429
+ if (typeof crypto === "undefined" || !crypto.randomUUID) {
393
430
  throw new Error("generateUUID is not available in unsecure contexts.");
394
431
  }
395
432
  return crypto.randomUUID();
@@ -6777,7 +6814,7 @@ function loadStateOperation(oldDocument, newDocument) {
6777
6814
  };
6778
6815
  }
6779
6816
  function generateId(method) {
6780
- return generateUUID$1();
6817
+ return generateUUID();
6781
6818
  }
6782
6819
  function getUnixTimestamp(date) {
6783
6820
  return (new Date(date).getTime() / 1e3).toFixed(0);
@@ -6940,6 +6977,7 @@ function processSkipOperation(document, action, customReducer, skipValue, reuseO
6940
6977
  scopeState = resultingStateParser(lastRemainingOperation.resultingState);
6941
6978
  } else {
6942
6979
  const { state } = replayOperations(document.initialState, documentOperations, customReducer, void 0, void 0, void 0, void 0, {
6980
+ reuseHash: true,
6943
6981
  reuseOperationResultingState,
6944
6982
  operationResultingStateParser: resultingStateParser
6945
6983
  });
@@ -6966,6 +7004,7 @@ function processUndoOperation(document, scope, customReducer, reuseOperationResu
6966
7004
  const clearedOperations = [...documentOperations[scope]];
6967
7005
  const diff = diffOperations(garbageCollect(sortedOperations), clearedOperations);
6968
7006
  const doc = replayOperations(document.initialState, documentOperations, customReducer, void 0, void 0, void 0, void 0, {
7007
+ reuseHash: true,
6969
7008
  reuseOperationResultingState,
6970
7009
  operationResultingStateParser: resultingStateParser
6971
7010
  });
@@ -7115,7 +7154,10 @@ function createReducer(stateReducer2, documentReducer = baseReducer) {
7115
7154
  return reducer2;
7116
7155
  }
7117
7156
  function baseCreateExtendedState(initialState, createState2) {
7157
+ const id = generateUUID();
7118
7158
  return {
7159
+ id,
7160
+ slug: id,
7119
7161
  name: "",
7120
7162
  documentType: "",
7121
7163
  revision: {
@@ -7144,10 +7186,6 @@ function baseCreateDocument(initialState, createState2) {
7144
7186
  function hashDocumentStateForScope(document, scope = "global") {
7145
7187
  return hash(cjsModule(document.state[scope] || ""));
7146
7188
  }
7147
- const hashKey = (date, randomLimit = 1e3) => {
7148
- const random = Math.random() * randomLimit;
7149
- return hash(`${(/* @__PURE__ */ new Date()).toISOString()}${random}`);
7150
- };
7151
7189
  function getDocumentLastModified(document) {
7152
7190
  var _a2;
7153
7191
  const sortedOperations = sortOperations(Object.values(document.operations).flat());
@@ -7196,6 +7234,9 @@ function replayDocument(initialState, operations, reducer2, dispatch, header, sk
7196
7234
  operationsToReplay.push(...Object.values(operations).flat());
7197
7235
  }
7198
7236
  const document = baseCreateDocument(documentState);
7237
+ if (header == null ? void 0 : header.slug) {
7238
+ document.slug = header.slug;
7239
+ }
7199
7240
  document.initialState = initialState;
7200
7241
  document.operations = initialOperations;
7201
7242
  let result = document;
@@ -7534,21 +7575,186 @@ function UpdateStateExampleInputSchema() {
7534
7575
  newExample: z.string()
7535
7576
  });
7536
7577
  }
7578
+ var dist = {};
7579
+ var hasRequiredDist;
7580
+ function requireDist() {
7581
+ if (hasRequiredDist) return dist;
7582
+ hasRequiredDist = 1;
7583
+ (function(exports) {
7584
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
7585
+ function getDefaultExportFromCjs2(x) {
7586
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
7587
+ }
7588
+ var browser = { exports: {} };
7589
+ var process2 = browser.exports = {};
7590
+ var cachedSetTimeout;
7591
+ var cachedClearTimeout;
7592
+ function defaultSetTimout() {
7593
+ throw new Error("setTimeout has not been defined");
7594
+ }
7595
+ function defaultClearTimeout() {
7596
+ throw new Error("clearTimeout has not been defined");
7597
+ }
7598
+ (function() {
7599
+ try {
7600
+ if (typeof setTimeout === "function") {
7601
+ cachedSetTimeout = setTimeout;
7602
+ } else {
7603
+ cachedSetTimeout = defaultSetTimout;
7604
+ }
7605
+ } catch (e) {
7606
+ cachedSetTimeout = defaultSetTimout;
7607
+ }
7608
+ try {
7609
+ if (typeof clearTimeout === "function") {
7610
+ cachedClearTimeout = clearTimeout;
7611
+ } else {
7612
+ cachedClearTimeout = defaultClearTimeout;
7613
+ }
7614
+ } catch (e) {
7615
+ cachedClearTimeout = defaultClearTimeout;
7616
+ }
7617
+ })();
7618
+ function runTimeout(fun) {
7619
+ if (cachedSetTimeout === setTimeout) {
7620
+ return setTimeout(fun, 0);
7621
+ }
7622
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
7623
+ cachedSetTimeout = setTimeout;
7624
+ return setTimeout(fun, 0);
7625
+ }
7626
+ try {
7627
+ return cachedSetTimeout(fun, 0);
7628
+ } catch (e) {
7629
+ try {
7630
+ return cachedSetTimeout.call(null, fun, 0);
7631
+ } catch (e2) {
7632
+ return cachedSetTimeout.call(this, fun, 0);
7633
+ }
7634
+ }
7635
+ }
7636
+ function runClearTimeout(marker) {
7637
+ if (cachedClearTimeout === clearTimeout) {
7638
+ return clearTimeout(marker);
7639
+ }
7640
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
7641
+ cachedClearTimeout = clearTimeout;
7642
+ return clearTimeout(marker);
7643
+ }
7644
+ try {
7645
+ return cachedClearTimeout(marker);
7646
+ } catch (e) {
7647
+ try {
7648
+ return cachedClearTimeout.call(null, marker);
7649
+ } catch (e2) {
7650
+ return cachedClearTimeout.call(this, marker);
7651
+ }
7652
+ }
7653
+ }
7654
+ var queue = [];
7655
+ var draining = false;
7656
+ var currentQueue;
7657
+ var queueIndex = -1;
7658
+ function cleanUpNextTick() {
7659
+ if (!draining || !currentQueue) {
7660
+ return;
7661
+ }
7662
+ draining = false;
7663
+ if (currentQueue.length) {
7664
+ queue = currentQueue.concat(queue);
7665
+ } else {
7666
+ queueIndex = -1;
7667
+ }
7668
+ if (queue.length) {
7669
+ drainQueue();
7670
+ }
7671
+ }
7672
+ function drainQueue() {
7673
+ if (draining) {
7674
+ return;
7675
+ }
7676
+ var timeout = runTimeout(cleanUpNextTick);
7677
+ draining = true;
7678
+ var len = queue.length;
7679
+ while (len) {
7680
+ currentQueue = queue;
7681
+ queue = [];
7682
+ while (++queueIndex < len) {
7683
+ if (currentQueue) {
7684
+ currentQueue[queueIndex].run();
7685
+ }
7686
+ }
7687
+ queueIndex = -1;
7688
+ len = queue.length;
7689
+ }
7690
+ currentQueue = null;
7691
+ draining = false;
7692
+ runClearTimeout(timeout);
7693
+ }
7694
+ process2.nextTick = function(fun) {
7695
+ var args = new Array(arguments.length - 1);
7696
+ if (arguments.length > 1) {
7697
+ for (var i = 1; i < arguments.length; i++) {
7698
+ args[i - 1] = arguments[i];
7699
+ }
7700
+ }
7701
+ queue.push(new Item(fun, args));
7702
+ if (queue.length === 1 && !draining) {
7703
+ runTimeout(drainQueue);
7704
+ }
7705
+ };
7706
+ function Item(fun, array) {
7707
+ this.fun = fun;
7708
+ this.array = array;
7709
+ }
7710
+ Item.prototype.run = function() {
7711
+ this.fun.apply(null, this.array);
7712
+ };
7713
+ process2.title = "browser";
7714
+ process2.browser = true;
7715
+ process2.env = {};
7716
+ process2.argv = [];
7717
+ process2.version = "";
7718
+ process2.versions = {};
7719
+ function noop2() {
7720
+ }
7721
+ process2.on = noop2;
7722
+ process2.addListener = noop2;
7723
+ process2.once = noop2;
7724
+ process2.off = noop2;
7725
+ process2.removeListener = noop2;
7726
+ process2.removeAllListeners = noop2;
7727
+ process2.emit = noop2;
7728
+ process2.prependListener = noop2;
7729
+ process2.prependOnceListener = noop2;
7730
+ process2.listeners = function(name2) {
7731
+ return [];
7732
+ };
7733
+ process2.binding = function(name2) {
7734
+ throw new Error("process.binding is not supported");
7735
+ };
7736
+ process2.cwd = function() {
7737
+ return "/";
7738
+ };
7739
+ process2.chdir = function(dir) {
7740
+ throw new Error("process.chdir is not supported");
7741
+ };
7742
+ process2.umask = function() {
7743
+ return 0;
7744
+ };
7745
+ var browserExports = browser.exports;
7746
+ const process$1 = /* @__PURE__ */ getDefaultExportFromCjs2(browserExports);
7747
+ exports.default = process$1;
7748
+ exports.process = process$1;
7749
+ })(dist);
7750
+ return dist;
7751
+ }
7752
+ var distExports = requireDist();
7753
+ const process = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
7537
7754
  function commonjsRequire(path) {
7538
7755
  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
7756
  }
7540
7757
  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
7758
  var hasRequiredJszip_min;
7553
7759
  function requireJszip_min() {
7554
7760
  if (hasRequiredJszip_min) return jszip_min.exports;
@@ -9891,7 +10097,6 @@ const types = {
9891
10097
  "application/dash+xml": ["mpd"],
9892
10098
  "application/dash-patch+xml": ["mpp"],
9893
10099
  "application/davmount+xml": ["davmount"],
9894
- "application/dicom": ["dcm"],
9895
10100
  "application/docbook+xml": ["dbk"],
9896
10101
  "application/dssc+der": ["dssc"],
9897
10102
  "application/dssc+xml": ["xdssc"],
@@ -9978,14 +10183,7 @@ const types = {
9978
10183
  "application/oebps-package+xml": ["opf"],
9979
10184
  "application/ogg": ["ogx"],
9980
10185
  "application/omdoc+xml": ["omdoc"],
9981
- "application/onenote": [
9982
- "onetoc",
9983
- "onetoc2",
9984
- "onetmp",
9985
- "onepkg",
9986
- "one",
9987
- "onea"
9988
- ],
10186
+ "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"],
9989
10187
  "application/oxps": ["oxps"],
9990
10188
  "application/p2p-overlay+xml": ["relo"],
9991
10189
  "application/patch-ops-error+xml": ["xer"],
@@ -10081,7 +10279,6 @@ const types = {
10081
10279
  "application/yang": ["yang"],
10082
10280
  "application/yin+xml": ["yin"],
10083
10281
  "application/zip": ["zip"],
10084
- "application/zip+dotlottie": ["lottie"],
10085
10282
  "audio/3gpp": ["*3gpp"],
10086
10283
  "audio/aac": ["adts", "aac"],
10087
10284
  "audio/adpcm": ["adp"],
@@ -10090,7 +10287,7 @@ const types = {
10090
10287
  "audio/midi": ["mid", "midi", "kar", "rmi"],
10091
10288
  "audio/mobile-xmf": ["mxmf"],
10092
10289
  "audio/mp3": ["*mp3"],
10093
- "audio/mp4": ["m4a", "mp4a", "m4b"],
10290
+ "audio/mp4": ["m4a", "mp4a"],
10094
10291
  "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"],
10095
10292
  "audio/ogg": ["oga", "ogg", "spx", "opus"],
10096
10293
  "audio/s3m": ["s3m"],
@@ -10122,12 +10319,11 @@ const types = {
10122
10319
  "image/heif": ["heif"],
10123
10320
  "image/heif-sequence": ["heifs"],
10124
10321
  "image/hej2k": ["hej2"],
10322
+ "image/hsj2": ["hsj2"],
10125
10323
  "image/ief": ["ief"],
10126
- "image/jaii": ["jaii"],
10127
- "image/jais": ["jais"],
10128
10324
  "image/jls": ["jls"],
10129
10325
  "image/jp2": ["jp2", "jpg2"],
10130
- "image/jpeg": ["jpg", "jpeg", "jpe"],
10326
+ "image/jpeg": ["jpeg", "jpg", "jpe"],
10131
10327
  "image/jph": ["jph"],
10132
10328
  "image/jphc": ["jhc"],
10133
10329
  "image/jpm": ["jpm", "jpgm"],
@@ -10142,7 +10338,6 @@ const types = {
10142
10338
  "image/jxss": ["jxss"],
10143
10339
  "image/ktx": ["ktx"],
10144
10340
  "image/ktx2": ["ktx2"],
10145
- "image/pjpeg": ["jfif"],
10146
10341
  "image/png": ["png"],
10147
10342
  "image/sgi": ["sgi"],
10148
10343
  "image/svg+xml": ["svg", "svgz"],
@@ -10156,7 +10351,7 @@ const types = {
10156
10351
  "message/global-delivery-status": ["u8dsn"],
10157
10352
  "message/global-disposition-notification": ["u8mdn"],
10158
10353
  "message/global-headers": ["u8hdr"],
10159
- "message/rfc822": ["eml", "mime", "mht", "mhtml"],
10354
+ "message/rfc822": ["eml", "mime"],
10160
10355
  "model/3mf": ["3mf"],
10161
10356
  "model/gltf+json": ["gltf"],
10162
10357
  "model/gltf-binary": ["glb"],
@@ -10166,7 +10361,6 @@ const types = {
10166
10361
  "model/mtl": ["mtl"],
10167
10362
  "model/obj": ["obj"],
10168
10363
  "model/prc": ["prc"],
10169
- "model/step": ["step", "stp", "stpnc", "p21", "210"],
10170
10364
  "model/step+xml": ["stpx"],
10171
10365
  "model/step+zip": ["stpz"],
10172
10366
  "model/step-xml+zip": ["stpxz"],
@@ -10272,8 +10466,8 @@ class Mime {
10272
10466
  getType(path) {
10273
10467
  if (typeof path !== "string")
10274
10468
  return null;
10275
- const last = path.replace(/^.*[/\\]/s, "").toLowerCase();
10276
- const ext = last.replace(/^.*\./s, "").toLowerCase();
10469
+ const last = path.replace(/^.*[/\\]/, "").toLowerCase();
10470
+ const ext = last.replace(/^.*\./, "").toLowerCase();
10277
10471
  const hasPath = last.length < path.length;
10278
10472
  const hasDot = ext.length < last.length - 1;
10279
10473
  if (!hasDot && hasPath)
@@ -10335,8 +10529,10 @@ function validateOperations(operations) {
10335
10529
  }
10336
10530
  function createZip(document) {
10337
10531
  const zip = new JSZip();
10338
- const { name: name2, revision, documentType: documentType2, created, lastModified } = document;
10532
+ const { id, slug, name: name2, revision, documentType: documentType2, created, lastModified } = document;
10339
10533
  const header = {
10534
+ id,
10535
+ slug,
10340
10536
  name: name2,
10341
10537
  revision,
10342
10538
  documentType: documentType2,
@@ -10752,40 +10948,60 @@ const reducer$2 = {
10752
10948
  state.triggers = state.triggers.filter((trigger) => trigger.id !== action.input.triggerId);
10753
10949
  }
10754
10950
  };
10755
- const byteToHex = [];
10756
- for (let i = 0; i < 256; ++i) {
10757
- byteToHex.push((i + 256).toString(16).slice(1));
10951
+ class DocumentModelNotFoundError extends Error {
10952
+ constructor(id, cause) {
10953
+ super(`Document model "${id}" not found`, { cause });
10954
+ __publicField(this, "id");
10955
+ this.id = id;
10956
+ }
10957
+ }
10958
+ class OperationError extends Error {
10959
+ constructor(status, operation, message, cause) {
10960
+ super(message, { cause: cause ?? operation });
10961
+ __publicField(this, "status");
10962
+ __publicField(this, "operation");
10963
+ this.status = status;
10964
+ this.operation = operation;
10965
+ }
10758
10966
  }
10759
- function unsafeStringify(arr, offset = 0) {
10760
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
10967
+ class ConflictOperationError extends OperationError {
10968
+ constructor(existingOperation, newOperation) {
10969
+ super("CONFLICT", newOperation, `Conflicting operation on index ${newOperation.index}`, { existingOperation, newOperation });
10970
+ }
10761
10971
  }
10762
- let getRandomValues;
10763
- const rnds8 = new Uint8Array(16);
10764
- function rng() {
10765
- if (!getRandomValues) {
10766
- if (typeof crypto === "undefined" || !crypto.getRandomValues) {
10767
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
10768
- }
10769
- getRandomValues = crypto.getRandomValues.bind(crypto);
10972
+ class DocumentIdValidationError extends Error {
10973
+ constructor(documentId) {
10974
+ super(`Invalid document id: ${documentId}`);
10770
10975
  }
10771
- return getRandomValues(rnds8);
10772
10976
  }
10773
- const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
10774
- const native = { randomUUID };
10775
- function v4(options, buf, offset) {
10776
- var _a2;
10777
- if (native.randomUUID && true && !options) {
10778
- return native.randomUUID();
10977
+ class DocumentSlugValidationError extends Error {
10978
+ constructor(slug) {
10979
+ super(`Invalid slug: ${slug}`);
10779
10980
  }
10780
- options = options || {};
10781
- const rnds = options.random ?? ((_a2 = options.rng) == null ? void 0 : _a2.call(options)) ?? rng();
10782
- if (rnds.length < 16) {
10783
- throw new Error("Random bytes length must be >= 16");
10981
+ }
10982
+ class DocumentAlreadyExistsError extends Error {
10983
+ constructor(documentId) {
10984
+ super(`Document with id ${documentId} uses id or slug that already exists`);
10985
+ __publicField(this, "documentId");
10986
+ this.documentId = documentId;
10784
10987
  }
10785
- rnds[6] = rnds[6] & 15 | 64;
10786
- rnds[8] = rnds[8] & 63 | 128;
10787
- return unsafeStringify(rnds);
10788
10988
  }
10989
+ class DocumentNotFoundError extends Error {
10990
+ constructor(documentId) {
10991
+ super(`Document with id ${documentId} not found`);
10992
+ __publicField(this, "documentId");
10993
+ this.documentId = documentId;
10994
+ }
10995
+ }
10996
+ class SynchronizationUnitNotFoundError extends Error {
10997
+ constructor(message, syncUnitId) {
10998
+ super(message);
10999
+ __publicField(this, "syncUnitId");
11000
+ this.syncUnitId = syncUnitId;
11001
+ }
11002
+ }
11003
+ const isValidDocumentId = (id) => /^[a-zA-Z0-9_-]+$/.test(id);
11004
+ const isValidSlug = (slug) => /^[a-zA-Z0-9_-]+$/.test(slug);
10789
11005
  function isFileNode(node) {
10790
11006
  return node.kind === "file";
10791
11007
  }
@@ -10849,7 +11065,7 @@ function generateNodesCopy(src, idGenerator, nodes) {
10849
11065
  function generateSynchronizationUnitId(nodes) {
10850
11066
  let syncId = "";
10851
11067
  while (!syncId || nodes.find((node) => isFileNode(node) && node.synchronizationUnits.find((unit) => unit.syncId === syncId))) {
10852
- syncId = v4();
11068
+ syncId = generateId();
10853
11069
  }
10854
11070
  return syncId;
10855
11071
  }
@@ -10927,6 +11143,9 @@ const reducer$1 = {
10927
11143
  if (state.nodes.find((node) => node.id === action.input.id)) {
10928
11144
  throw new Error(`Node with id ${action.input.id} already exists!`);
10929
11145
  }
11146
+ if (!isValidDocumentId(action.input.id)) {
11147
+ throw new DocumentIdValidationError(action.input.id);
11148
+ }
10930
11149
  const name2 = handleTargetNameCollisions({
10931
11150
  nodes: state.nodes,
10932
11151
  srcName: action.input.name,
@@ -11019,6 +11238,9 @@ const reducer$1 = {
11019
11238
  if (!node) {
11020
11239
  throw new Error(`Node with id ${action.input.srcId} not found`);
11021
11240
  }
11241
+ if (!isValidDocumentId(action.input.targetId)) {
11242
+ throw new DocumentIdValidationError(action.input.targetId);
11243
+ }
11022
11244
  const duplicatedNode = state.nodes.find((node2) => node2.id === action.input.targetId);
11023
11245
  if (duplicatedNode) {
11024
11246
  throw new Error(`Node with id ${action.input.targetId} already exists`);
@@ -11030,8 +11252,9 @@ const reducer$1 = {
11030
11252
  });
11031
11253
  const newNode = {
11032
11254
  ...node,
11033
- name: name2,
11034
11255
  id: action.input.targetId,
11256
+ slug: action.input.targetId,
11257
+ name: name2,
11035
11258
  parentFolder: action.input.targetParentFolder || null
11036
11259
  };
11037
11260
  const isFile = isFileNode(newNode);
@@ -11163,11 +11386,9 @@ const fileExtension = "phdd";
11163
11386
  const documentType = "powerhouse/document-drive";
11164
11387
  const documentModelName = "DocumentDrive";
11165
11388
  const initialGlobalState = {
11166
- id: "",
11167
11389
  name: "",
11168
11390
  nodes: [],
11169
- icon: null,
11170
- slug: null
11391
+ icon: null
11171
11392
  };
11172
11393
  const initialLocalState = {
11173
11394
  listeners: [],
@@ -11428,8 +11649,7 @@ const driveDocumentModelModule = {
11428
11649
  actions: { ...creators, ...actions },
11429
11650
  utils: { ...documentModelUtils, ...customUtils }
11430
11651
  };
11431
- var define_process_env_default = {};
11432
- const LEVELS = {
11652
+ const LogLevels = {
11433
11653
  verbose: 1,
11434
11654
  debug: 2,
11435
11655
  info: 3,
@@ -11437,6 +11657,10 @@ const LEVELS = {
11437
11657
  error: 5,
11438
11658
  silent: 6
11439
11659
  };
11660
+ function isLogLevel(value) {
11661
+ return typeof value === "string" && value in LogLevels;
11662
+ }
11663
+ var define_process_env_default = {};
11440
11664
  class ConsoleLogger {
11441
11665
  constructor(tags, errorHandler2) {
11442
11666
  __privateAdd(this, _ConsoleLogger_instances);
@@ -11456,6 +11680,10 @@ class ConsoleLogger {
11456
11680
  return __privateGet(this, _levelString);
11457
11681
  }
11458
11682
  set level(level) {
11683
+ if (level !== "env" && !isLogLevel(level)) {
11684
+ throw new Error(`Invalid log level: ${JSON.stringify(level)}.
11685
+ Must be one of ${Object.keys(LogLevels).concat(["env"]).join(", ")}.`);
11686
+ }
11459
11687
  __privateSet(this, _levelString, level);
11460
11688
  }
11461
11689
  get errorHandler() {
@@ -11468,31 +11696,31 @@ class ConsoleLogger {
11468
11696
  return this.debug(...data);
11469
11697
  }
11470
11698
  verbose(...data) {
11471
- if (__privateGet(this, _ConsoleLogger_instances, levelValue_get) > LEVELS.verbose) {
11699
+ if (__privateGet(this, _ConsoleLogger_instances, levelValue_get) > LogLevels.verbose) {
11472
11700
  return;
11473
11701
  }
11474
11702
  return this.debug(...data);
11475
11703
  }
11476
11704
  debug(...data) {
11477
- if (__privateGet(this, _ConsoleLogger_instances, levelValue_get) > LEVELS.debug) {
11705
+ if (__privateGet(this, _ConsoleLogger_instances, levelValue_get) > LogLevels.debug) {
11478
11706
  return;
11479
11707
  }
11480
11708
  return console.debug(...[...__privateGet(this, _tags), ...data]);
11481
11709
  }
11482
11710
  info(...data) {
11483
- if (__privateGet(this, _ConsoleLogger_instances, levelValue_get) > LEVELS.info) {
11711
+ if (__privateGet(this, _ConsoleLogger_instances, levelValue_get) > LogLevels.info) {
11484
11712
  return;
11485
11713
  }
11486
11714
  return console.info(...[...__privateGet(this, _tags), ...data]);
11487
11715
  }
11488
11716
  warn(...data) {
11489
- if (__privateGet(this, _ConsoleLogger_instances, levelValue_get) > LEVELS.warn) {
11717
+ if (__privateGet(this, _ConsoleLogger_instances, levelValue_get) > LogLevels.warn) {
11490
11718
  return;
11491
11719
  }
11492
11720
  return console.warn(...[...__privateGet(this, _tags), ...data]);
11493
11721
  }
11494
11722
  error(...data) {
11495
- if (__privateGet(this, _ConsoleLogger_instances, levelValue_get) > LEVELS.error) {
11723
+ if (__privateGet(this, _ConsoleLogger_instances, levelValue_get) > LogLevels.error) {
11496
11724
  return;
11497
11725
  }
11498
11726
  if (__privateGet(this, _errorHandler)) {
@@ -11507,16 +11735,16 @@ _errorHandler = new WeakMap();
11507
11735
  _ConsoleLogger_instances = new WeakSet();
11508
11736
  levelValue_get = function() {
11509
11737
  if (__privateGet(this, _levelString) === "env") {
11510
- const envLevel = typeof process !== "undefined" ? define_process_env_default.LOG_LEVEL : void 0;
11738
+ const envLevel = typeof process !== "undefined" && "env" in process ? define_process_env_default.LOG_LEVEL : void 0;
11511
11739
  if (!envLevel) {
11512
- return LEVELS.debug;
11740
+ return LogLevels.debug;
11513
11741
  }
11514
- if (!(envLevel in LEVELS)) {
11515
- return LEVELS.debug;
11742
+ if (!(envLevel in LogLevels)) {
11743
+ return LogLevels.debug;
11516
11744
  }
11517
- return LEVELS[envLevel];
11745
+ return LogLevels[envLevel];
11518
11746
  }
11519
- return LEVELS[__privateGet(this, _levelString)];
11747
+ return LogLevels[__privateGet(this, _levelString)];
11520
11748
  };
11521
11749
  const loggerInstance = new ConsoleLogger();
11522
11750
  let logLevel = "env";
@@ -11538,48 +11766,6 @@ const childLogger = (tags) => {
11538
11766
  logger2.errorHandler = errorHandler;
11539
11767
  return logger2;
11540
11768
  };
11541
- class DocumentModelNotFoundError extends Error {
11542
- constructor(id, cause) {
11543
- super(`Document model "${id}" not found`, { cause });
11544
- __publicField(this, "id");
11545
- this.id = id;
11546
- }
11547
- }
11548
- class OperationError extends Error {
11549
- constructor(status, operation, message, cause) {
11550
- super(message, { cause: cause ?? operation });
11551
- __publicField(this, "status");
11552
- __publicField(this, "operation");
11553
- this.status = status;
11554
- this.operation = operation;
11555
- }
11556
- }
11557
- class ConflictOperationError extends OperationError {
11558
- constructor(existingOperation, newOperation) {
11559
- super("CONFLICT", newOperation, `Conflicting operation on index ${newOperation.index}`, { existingOperation, newOperation });
11560
- }
11561
- }
11562
- class DocumentAlreadyExistsError extends Error {
11563
- constructor(documentId) {
11564
- super(`Document with id ${documentId} already exists`);
11565
- __publicField(this, "documentId");
11566
- this.documentId = documentId;
11567
- }
11568
- }
11569
- class DocumentNotFoundError extends Error {
11570
- constructor(documentId) {
11571
- super(`Document with id ${documentId} not found`);
11572
- __publicField(this, "documentId");
11573
- this.documentId = documentId;
11574
- }
11575
- }
11576
- class SynchronizationUnitNotFoundError extends Error {
11577
- constructor(message, syncUnitId) {
11578
- super(message);
11579
- __publicField(this, "syncUnitId");
11580
- this.syncUnitId = syncUnitId;
11581
- }
11582
- }
11583
11769
  var RunAsap;
11584
11770
  (function(RunAsap2) {
11585
11771
  RunAsap2.useMessageChannel = (() => {
@@ -11719,9 +11905,6 @@ function mergeOperations(currentOperations, newOperations) {
11719
11905
  return { ...acc, [curr.scope]: [...existingOperations, curr] };
11720
11906
  }, currentOperations);
11721
11907
  }
11722
- function generateUUID() {
11723
- return generateId();
11724
- }
11725
11908
  function isBefore(dateA, dateB) {
11726
11909
  return new Date(dateA) < new Date(dateB);
11727
11910
  }
@@ -11822,7 +12005,7 @@ class BaseQueueManager {
11822
12005
  if (!this.delegate) {
11823
12006
  throw new Error("No server delegate defined");
11824
12007
  }
11825
- const jobId = generateUUID();
12008
+ const jobId = generateId();
11826
12009
  const queue = this.getQueue(job.driveId, job.documentId);
11827
12010
  if (await queue.isDeleted()) {
11828
12011
  throw new Error("Queue is deleted");
@@ -22161,14 +22344,18 @@ async function fetchDocument(url, documentId, documentModelModule) {
22161
22344
  local: []
22162
22345
  },
22163
22346
  attachments: {},
22164
- initialState: utils.createExtendedState({
22165
- // TODO: getDocument should return all the initial state fields
22166
- created: result.document.created,
22167
- lastModified: result.document.created,
22168
- state: utils.createState({
22169
- global: result.document.initialState.state.global
22170
- })
22171
- }),
22347
+ initialState: {
22348
+ ...utils.createExtendedState({
22349
+ // TODO: getDocument should return all the initial state fields
22350
+ created: result.document.created,
22351
+ lastModified: result.document.created,
22352
+ state: utils.createState({
22353
+ global: result.document.initialState.state.global
22354
+ })
22355
+ }),
22356
+ id: result.document.id,
22357
+ slug: result.document.slug
22358
+ },
22172
22359
  clipboard: []
22173
22360
  } : null;
22174
22361
  return {
@@ -22223,7 +22410,13 @@ class ReadModeService {
22223
22410
  return document;
22224
22411
  }
22225
22412
  async addReadDrive(url, options) {
22226
- const { id } = (options == null ? void 0 : options.expectedDriveInfo) ?? await requestPublicDrive(url);
22413
+ let id;
22414
+ if (options == null ? void 0 : options.expectedDriveInfo) {
22415
+ id = options.expectedDriveInfo.id;
22416
+ } else {
22417
+ const drive = await requestPublicDrive(url);
22418
+ id = drive.id;
22419
+ }
22227
22420
  const result = await __privateMethod(this, _ReadModeService_instances, fetchDrive_fn).call(this, id, url);
22228
22421
  if (result instanceof Error) {
22229
22422
  throw result;
@@ -22246,7 +22439,7 @@ class ReadModeService {
22246
22439
  return Promise.resolve(result ? { ...result.drive, readContext: result.context } : new ReadDriveNotFoundError(id));
22247
22440
  }
22248
22441
  async getReadDriveBySlug(slug) {
22249
- const readDrive = [...__privateGet(this, _drives).values()].find(({ drive }) => drive.state.global.slug === slug);
22442
+ const readDrive = [...__privateGet(this, _drives).values()].find(({ drive }) => drive.slug === slug);
22250
22443
  return Promise.resolve(readDrive ? { ...readDrive.drive, readContext: readDrive.context } : new ReadDriveSlugNotFoundError(slug));
22251
22444
  }
22252
22445
  getReadDriveContext(id) {
@@ -22385,8 +22578,8 @@ class DefaultDrivesManager {
22385
22578
  }
22386
22579
  async preserveDrivesById(driveIdsToPreserve, drives, removeStrategy = "detach") {
22387
22580
  const getAllDrives = drives.map((driveId) => this.server.getDrive(driveId));
22388
- const drivesToRemove = (await Promise.all(getAllDrives)).filter((drive) => drive.state.local.listeners.length > 0 || drive.state.local.triggers.length > 0).filter((drive) => !driveIdsToPreserve.includes(drive.state.global.id));
22389
- const driveIds = drivesToRemove.map((drive) => drive.state.global.id);
22581
+ const drivesToRemove = (await Promise.all(getAllDrives)).filter((drive) => drive.state.local.listeners.length > 0 || drive.state.local.triggers.length > 0).filter((drive) => !driveIdsToPreserve.includes(drive.id));
22582
+ const driveIds = drivesToRemove.map((drive) => drive.id);
22390
22583
  if (removeStrategy === "detach") {
22391
22584
  await this.detachDrivesById(driveIds);
22392
22585
  } else {
@@ -22434,7 +22627,7 @@ class DefaultDrivesManager {
22434
22627
  case "remove-all": {
22435
22628
  const getDrives = driveids.map((driveId) => this.server.getDrive(driveId));
22436
22629
  const drives = await Promise.all(getDrives);
22437
- const drivesToRemove = drives.filter((drive) => drive.state.local.listeners.length > 0 || drive.state.local.triggers.length > 0).map((drive) => drive.state.global.id);
22630
+ const drivesToRemove = drives.filter((drive) => drive.state.local.listeners.length > 0 || drive.state.local.triggers.length > 0).map((drive) => drive.id);
22438
22631
  await this.removeDrivesById(drivesToRemove);
22439
22632
  break;
22440
22633
  }
@@ -22711,7 +22904,7 @@ class PullResponderTransmitter {
22711
22904
  static async executePull(driveId, trigger, onStrandUpdate, onError, onRevisions, onAcknowledge) {
22712
22905
  var _a2, _b;
22713
22906
  staticLogger().verbose(`executePull(driveId: ${driveId}), trigger:`, trigger);
22714
- staticLogger().info(`[SYNC DEBUG] PullResponderTransmitter.executePull starting for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22907
+ staticLogger().debug(`[SYNC DEBUG] PullResponderTransmitter.executePull starting for drive: ${driveId}, listenerId: ${trigger.data.listenerId}`);
22715
22908
  const { url } = trigger.data;
22716
22909
  let strands;
22717
22910
  let error;
@@ -22875,7 +23068,7 @@ class PullResponderTransmitter {
22875
23068
  };
22876
23069
  const listenerId = await PullResponderTransmitter.registerPullResponder(driveId, url, filter);
22877
23070
  const pullTrigger = {
22878
- id: generateUUID(),
23071
+ id: generateId(),
22879
23072
  type: "PullResponder",
22880
23073
  driveId,
22881
23074
  filter,
@@ -23308,7 +23501,7 @@ class BaseDocumentDriveServer {
23308
23501
  async _initializeDrive(driveId) {
23309
23502
  var _a2, _b, _c;
23310
23503
  const drive = await this.getDrive(driveId);
23311
- this.logger.verbose(`[SYNC DEBUG] Initializing drive ${driveId} with slug "${drive.state.global.slug}"`);
23504
+ this.logger.verbose(`[SYNC DEBUG] Initializing drive ${driveId} with slug "${drive.slug}"`);
23312
23505
  await this.synchronizationManager.initializeDriveSyncStatus(driveId, drive);
23313
23506
  if (this.shouldSyncRemoteDrive(drive)) {
23314
23507
  this.logger.verbose(`[SYNC DEBUG] Starting sync for remote drive ${driveId}`);
@@ -23322,7 +23515,7 @@ class BaseDocumentDriveServer {
23322
23515
  this.logger.verbose(`[SYNC DEBUG] Created SwitchboardPush transmitter with URL: ${zodListener.callInfo.data || "none"}`);
23323
23516
  await this.listenerManager.setListener(driveId, {
23324
23517
  block: zodListener.block,
23325
- driveId: drive.state.global.id,
23518
+ driveId: drive.id,
23326
23519
  filter: {
23327
23520
  branch: zodListener.filter.branch ?? [],
23328
23521
  documentId: zodListener.filter.documentId ?? [],
@@ -23384,25 +23577,24 @@ class BaseDocumentDriveServer {
23384
23577
  return [...this.documentModelModules];
23385
23578
  }
23386
23579
  async addDrive(input, preferredEditor) {
23387
- const id = input.global.id || generateUUID();
23388
- if (!id) {
23389
- throw new Error("Invalid Drive Id");
23390
- }
23391
- const drives = await this.legacyStorage.getDrives();
23392
- if (drives.includes(id)) {
23393
- throw new DocumentAlreadyExistsError(id);
23394
- }
23395
23580
  const document = createDocument({
23396
23581
  state: input
23397
23582
  });
23583
+ if (input.id && input.id.length > 0) {
23584
+ document.id = document.initialState.id = input.id;
23585
+ document.slug = document.initialState.slug = input.id;
23586
+ }
23587
+ if (input.slug && input.slug.length > 0) {
23588
+ document.slug = document.initialState.slug = input.slug;
23589
+ }
23398
23590
  document.meta = {
23399
23591
  preferredEditor
23400
23592
  };
23401
- await this.legacyStorage.createDrive(id, document);
23402
- if (input.global.slug) {
23403
- await this.cache.deleteDriveBySlug(input.global.slug);
23593
+ await this.documentStorage.create(document);
23594
+ if (input.slug && input.slug.length > 0) {
23595
+ await this.cache.deleteDriveBySlug(input.slug);
23404
23596
  }
23405
- await this._initializeDrive(id);
23597
+ await this._initializeDrive(document.id);
23406
23598
  this.eventEmitter.emit("driveAdded", document);
23407
23599
  return document;
23408
23600
  }
@@ -23414,10 +23606,10 @@ class BaseDocumentDriveServer {
23414
23606
  pullInterval
23415
23607
  });
23416
23608
  return await this.addDrive({
23609
+ id,
23610
+ slug,
23417
23611
  global: {
23418
- id,
23419
23612
  name: name2,
23420
- slug,
23421
23613
  icon: icon ?? null
23422
23614
  },
23423
23615
  local: {
@@ -23433,7 +23625,7 @@ class BaseDocumentDriveServer {
23433
23625
  this.stopSyncRemoteDrive(driveId),
23434
23626
  this.listenerManager.removeDrive(driveId),
23435
23627
  this.cache.deleteDrive(driveId),
23436
- this.legacyStorage.deleteDrive(driveId)
23628
+ this.documentStorage.delete(driveId)
23437
23629
  ]);
23438
23630
  this.eventEmitter.emit("driveDeleted", driveId);
23439
23631
  result.forEach((r) => {
@@ -23442,8 +23634,16 @@ class BaseDocumentDriveServer {
23442
23634
  }
23443
23635
  });
23444
23636
  }
23445
- getDrives() {
23446
- return this.legacyStorage.getDrives();
23637
+ // TODO: paginate
23638
+ async getDrives() {
23639
+ const drives = [];
23640
+ let cursor;
23641
+ do {
23642
+ const { documents, nextCursor } = await this.documentStorage.findByType("powerhouse/document-drive", 100, cursor);
23643
+ drives.push(...documents);
23644
+ cursor = nextCursor;
23645
+ } while (cursor);
23646
+ return drives;
23447
23647
  }
23448
23648
  async getDrive(driveId, options) {
23449
23649
  let document;
@@ -23517,8 +23717,13 @@ class BaseDocumentDriveServer {
23517
23717
  state = doc.state;
23518
23718
  }
23519
23719
  const document = input.document ?? this.getDocumentModelModule(input.documentType).utils.createDocument();
23720
+ if (input.id && input.id.length > 0) {
23721
+ document.id = input.id;
23722
+ }
23520
23723
  const documentStorage = {
23724
+ id: document.id,
23521
23725
  name: document.name,
23726
+ slug: document.slug,
23522
23727
  revision: document.revision,
23523
23728
  documentType: document.documentType,
23524
23729
  created: document.created,
@@ -23528,7 +23733,7 @@ class BaseDocumentDriveServer {
23528
23733
  clipboard: [],
23529
23734
  state: state ?? document.state
23530
23735
  };
23531
- await this.documentStorage.create(input.id, documentStorage);
23736
+ await this.documentStorage.create(documentStorage);
23532
23737
  try {
23533
23738
  await this.documentStorage.addChild(driveId, input.id);
23534
23739
  } catch (e) {
@@ -23667,12 +23872,18 @@ class BaseDocumentDriveServer {
23667
23872
  handler = () => this.deleteDocument(driveId, signal.input.id);
23668
23873
  break;
23669
23874
  case "COPY_CHILD_DOCUMENT":
23670
- handler = () => this.getDocument(driveId, signal.input.id).then((documentToCopy) => this.createDocument(driveId, {
23671
- id: signal.input.newId,
23672
- documentType: documentToCopy.documentType,
23673
- document: documentToCopy,
23674
- synchronizationUnits: signal.input.synchronizationUnits
23675
- }));
23875
+ handler = () => this.getDocument(driveId, signal.input.id).then((documentToCopy) => {
23876
+ const doc = {
23877
+ ...documentToCopy,
23878
+ slug: signal.input.newId
23879
+ };
23880
+ return this.createDocument(driveId, {
23881
+ id: signal.input.newId,
23882
+ documentType: documentToCopy.documentType,
23883
+ document: doc,
23884
+ synchronizationUnits: signal.input.synchronizationUnits
23885
+ });
23886
+ });
23676
23887
  break;
23677
23888
  }
23678
23889
  if (handler) {
@@ -23929,13 +24140,6 @@ class BaseDocumentDriveServer {
23929
24140
  addDriveOperation(driveId, operation, options) {
23930
24141
  return this.addDriveOperations(driveId, [operation], options);
23931
24142
  }
23932
- async clearStorage() {
23933
- var _a2, _b;
23934
- for (const drive of await this.getDrives()) {
23935
- await this.deleteDrive(drive);
23936
- }
23937
- await ((_b = (_a2 = this.legacyStorage).clearStorage) == null ? void 0 : _b.call(_a2));
23938
- }
23939
24143
  async _addDriveOperations(driveId, callback) {
23940
24144
  if (!this.legacyStorage.addDriveOperationsWithTransaction) {
23941
24145
  const documentStorage = await this.documentStorage.get(driveId);
@@ -24210,17 +24414,32 @@ class MemoryStorage {
24210
24414
  exists(documentId) {
24211
24415
  return Promise.resolve(!!this.documents[documentId]);
24212
24416
  }
24213
- // TODO: this should throw an error if the document already exists.
24214
- create(documentId, document) {
24215
- var _a2;
24417
+ create(document) {
24418
+ const documentId = document.id;
24419
+ if (!isValidDocumentId(documentId)) {
24420
+ throw new DocumentIdValidationError(documentId);
24421
+ }
24422
+ if (this.documents[documentId]) {
24423
+ throw new DocumentAlreadyExistsError(documentId);
24424
+ }
24425
+ const slug = document.slug.length > 0 ? document.slug : documentId;
24426
+ if (!isValidSlug(slug)) {
24427
+ throw new DocumentSlugValidationError(slug);
24428
+ }
24429
+ if (slug && this.slugToDocumentId[slug]) {
24430
+ throw new DocumentAlreadyExistsError(documentId);
24431
+ }
24432
+ document.slug = slug;
24216
24433
  this.documents[documentId] = document;
24217
- const slug = (_a2 = document.initialState.state.global) == null ? void 0 : _a2.slug;
24218
24434
  if (slug) {
24219
24435
  if (this.slugToDocumentId[slug]) {
24220
- throw new Error(`Document with slug ${slug} already exists`);
24436
+ throw new DocumentAlreadyExistsError(documentId);
24221
24437
  }
24222
24438
  this.slugToDocumentId[slug] = documentId;
24223
24439
  }
24440
+ if (document.documentType === "powerhouse/document-drive") {
24441
+ this.updateDriveManifest(documentId, { documentIds: /* @__PURE__ */ new Set() });
24442
+ }
24224
24443
  return Promise.resolve();
24225
24444
  }
24226
24445
  get(documentId) {
@@ -24237,20 +24456,56 @@ class MemoryStorage {
24237
24456
  }
24238
24457
  return this.get(documentId);
24239
24458
  }
24459
+ async findByType(documentModelType, limit = 100, cursor) {
24460
+ const documentsAndIds = Object.entries(this.documents).filter(([_, doc]) => doc.documentType === documentModelType).map(([id, doc]) => ({
24461
+ id,
24462
+ document: doc
24463
+ }));
24464
+ documentsAndIds.sort((a, b) => {
24465
+ const aDate = new Date(a.document.created);
24466
+ const bDate = new Date(b.document.created);
24467
+ if (aDate.getTime() === bDate.getTime()) {
24468
+ const aId = a.id;
24469
+ const bId = b.id;
24470
+ return aId.localeCompare(bId);
24471
+ }
24472
+ return aDate.getTime() - bDate.getTime();
24473
+ });
24474
+ let startIndex = 0;
24475
+ if (cursor) {
24476
+ const index = documentsAndIds.findIndex(({ id }) => id === cursor);
24477
+ if (index !== -1) {
24478
+ startIndex = index;
24479
+ }
24480
+ }
24481
+ const endIndex = Math.min(startIndex + limit, documentsAndIds.length);
24482
+ let nextCursor;
24483
+ if (endIndex < documentsAndIds.length) {
24484
+ nextCursor = documentsAndIds[endIndex].id;
24485
+ }
24486
+ return {
24487
+ documents: documentsAndIds.slice(startIndex, endIndex).map(({ id }) => id),
24488
+ nextCursor
24489
+ };
24490
+ }
24240
24491
  async delete(documentId) {
24241
- var _a2;
24242
24492
  const document = this.documents[documentId];
24243
24493
  if (document) {
24244
- const slug = (_a2 = document.initialState.state.global) == null ? void 0 : _a2.slug;
24494
+ const slug = document.slug.length > 0 ? document.slug : documentId;
24245
24495
  if (slug && this.slugToDocumentId[slug] === documentId) {
24246
24496
  delete this.slugToDocumentId[slug];
24247
24497
  }
24248
24498
  }
24249
- const drives = await this.getDrives();
24250
- for (const driveId of drives) {
24251
- if (driveId === documentId)
24252
- continue;
24253
- await this.removeChild(driveId, documentId);
24499
+ const parents = await this.getParents(documentId);
24500
+ for (const parent of parents) {
24501
+ await this.removeChild(parent, documentId);
24502
+ }
24503
+ const children = await this.getChildren(documentId);
24504
+ for (const child of children) {
24505
+ const childParents = await this.getParents(child);
24506
+ if (childParents.length === 1) {
24507
+ await this.delete(child);
24508
+ }
24254
24509
  }
24255
24510
  delete this.driveManifests[documentId];
24256
24511
  if (this.documents[documentId]) {
@@ -24284,14 +24539,26 @@ class MemoryStorage {
24284
24539
  const manifest = this.getManifest(parentId);
24285
24540
  return [...manifest.documentIds];
24286
24541
  }
24542
+ async getParents(childId) {
24543
+ const parents = [];
24544
+ for (const [driveId, manifest] of Object.entries(this.driveManifests)) {
24545
+ if (manifest.documentIds.has(childId)) {
24546
+ parents.push(driveId);
24547
+ }
24548
+ }
24549
+ return parents;
24550
+ }
24287
24551
  ////////////////////////////////
24288
- // IDriveStorage
24552
+ // IDocumentAdminStorage
24289
24553
  ////////////////////////////////
24290
- async clearStorage() {
24554
+ async clear() {
24291
24555
  this.documents = {};
24292
24556
  this.driveManifests = {};
24293
24557
  this.slugToDocumentId = {};
24294
24558
  }
24559
+ ////////////////////////////////
24560
+ // IDriveStorage
24561
+ ////////////////////////////////
24295
24562
  async addDocumentOperations(drive, id, operations, header) {
24296
24563
  const document = await this.get(id);
24297
24564
  if (!document) {
@@ -24304,13 +24571,6 @@ class MemoryStorage {
24304
24571
  operations: mergedOperations
24305
24572
  };
24306
24573
  }
24307
- async getDrives() {
24308
- return Object.keys(this.driveManifests);
24309
- }
24310
- async createDrive(id, drive) {
24311
- await this.create(id, drive);
24312
- this.updateDriveManifest(id, { documentIds: /* @__PURE__ */ new Set() });
24313
- }
24314
24574
  async addDriveOperations(id, operations, header) {
24315
24575
  const drive = await this.get(id);
24316
24576
  const mergedOperations = mergeOperations(drive.operations, operations);
@@ -24320,32 +24580,6 @@ class MemoryStorage {
24320
24580
  operations: mergedOperations
24321
24581
  };
24322
24582
  }
24323
- async deleteDrive(id) {
24324
- const manifest = this.getManifest(id);
24325
- const drives = await this.getDrives();
24326
- await Promise.all([...manifest.documentIds].map((docId) => {
24327
- var _a2;
24328
- for (const driveId of drives) {
24329
- if (driveId === id) {
24330
- continue;
24331
- }
24332
- const manifest2 = this.getManifest(driveId);
24333
- if (manifest2.documentIds.has(docId)) {
24334
- return;
24335
- }
24336
- }
24337
- const document = this.documents[docId];
24338
- if (document) {
24339
- const slug = (_a2 = document.initialState.state.global) == null ? void 0 : _a2.slug;
24340
- if (slug && this.slugToDocumentId[slug] === docId) {
24341
- delete this.slugToDocumentId[slug];
24342
- }
24343
- }
24344
- delete this.documents[docId];
24345
- }));
24346
- delete this.driveManifests[id];
24347
- delete this.documents[id];
24348
- }
24349
24583
  async getSynchronizationUnitsRevision(units) {
24350
24584
  const results = await Promise.allSettled(units.map(async (unit) => {
24351
24585
  try {
@@ -25548,6 +25782,9 @@ function Syncing(props) {
25548
25782
  function Tabler(props) {
25549
25783
  return jsxs("svg", { ...props, width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("path", { d: "M4.5 9V7.5C4.5 6.30653 4.97411 5.16193 5.81802 4.31802C6.66193 3.47411 7.80653 3 9 3C10.1935 3 11.3381 3.47411 12.182 4.31802C13.0259 5.16193 13.5 6.30653 13.5 7.5V9M3 13.5C3 13.8978 3.15804 14.2794 3.43934 14.5607C3.72064 14.842 4.10218 15 4.5 15C4.89782 15 5.27936 14.842 5.56066 14.5607C5.84196 14.2794 6 13.8978 6 13.5C6 13.1022 5.84196 12.7206 5.56066 12.4393C5.27936 12.158 4.89782 12 4.5 12C4.10218 12 3.72064 12.158 3.43934 12.4393C3.15804 12.7206 3 13.1022 3 13.5ZM12 13.5C12 13.8978 12.158 14.2794 12.4393 14.5607C12.7206 14.842 13.1022 15 13.5 15C13.8978 15 14.2794 14.842 14.5607 14.5607C14.842 14.2794 15 13.8978 15 13.5C15 13.1022 14.842 12.7206 14.5607 12.4393C14.2794 12.158 13.8978 12 13.5 12C13.1022 12 12.7206 12.158 12.4393 12.4393C12.158 12.7206 12 13.1022 12 13.5Z", stroke: "currentcolor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M11.25 6.75L13.5 9L15.75 6.75", stroke: "currentcolor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] });
25550
25784
  }
25785
+ function TimelineCaret(props) {
25786
+ return jsx("svg", { ...props, width: "10", height: "7", viewBox: "0 0 10 7", fill: "currentcolor", children: jsx("path", { d: "M0.539174 0.830403L0.539396 0.830693L4.81717 6.41675L0.539174 0.830403ZM0.539174 0.830403C0.492941 0.770121 0.486776 0.69618 0.524599 0.622069C0.562768 0.547277 0.632849 0.5 0.721373 0.5L9.27711 0.5C9.36895 0.5 9.44336 0.552912 9.47789 0.620069C9.51177 0.686686 9.50789 0.767089 9.45938 0.830307L9.45889 0.83095M0.539174 0.830403L9.45889 0.83095M9.45889 0.83095C9.05222 1.36269 7.09357 3.91999 5.94678 5.41729C5.588 5.88573 5.30868 6.25042 5.18122 6.41687M9.45889 0.83095L5.18122 6.41687M5.18122 6.41687C5.1428 6.46691 5.07824 6.5 4.99924 6.5M5.18122 6.41687L4.99924 6.5M4.99924 6.5C4.92023 6.5 4.85567 6.46691 4.81726 6.41687L4.99924 6.5Z", fill: "currentcolor", stroke: "currentcolor" }) });
25787
+ }
25551
25788
  function Timeline(props) {
25552
25789
  return jsxs("svg", { ...props, width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentcolor", children: [jsx("rect", { width: "16", height: "16", fill: "url(#pattern0_1256_1508)" }), jsxs("defs", { children: [jsx("pattern", { id: "pattern0_1256_1508", patternContentUnits: "objectBoundingBox", width: "1", height: "1", children: jsx("use", { href: "#image0_1256_1508", transform: "scale(0.00195312)" }) }), jsx("image", { id: "image0_1256_1508", width: "512", height: "512", preserveAspectRatio: "none", href: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAIABJREFUeJzt3Xm0XmV96PHvyUASCEmYQsIcJpkhzJOASLWK89KrtS6r7RLtba1Xl73qte1VOzm2asVeUMTSah3QAgoqk6gI4gACgowSCFMgCRAyD+fcP573lMPhnOS8797P+9vD97PWb53U1cV+ht9+9vPu/exngyRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiSpFwPRBZDUs62BPYDdgF2BHYAdgbkj/j0DmAVs1fk7A5g+zn/vSWBo1N+ngOUjYimwBFgMPNL5u7r0mknKzgmAVG07APsDB3T+7g/syzMX/Cp4EvgdcE8n7u78vZ00aZBUQU4ApGqYDOwHHNGJhZ2/cyMLVYLFwC2duBm4CbgrtESSACcAUpRZwAnAiZ04Dtg2tET9swy4Afh55+/1pEcNkvrICYDUH9sApwJnAKcDh5B+9Qs2ATcCP+zET4BVoSWSWsAJgJTPQuBM0kX/BNJCPG3ZBtJdgUs7cVtscSRJ2rypwAuBzwKLSCvpjeJxH3A28CJgykQ7Q5KknCaTLkznk1a8R18smx5LgXOB38PJgCSpzwZIt/Q/CzxK/EWxrfEY6c7AsZvvLkmSitkOOAu4lfiLn/Hs+C3wIWDP8TpPkqRu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ygm0p9WQ74MfEnwRRcR2wY+FWbC/zx/wpYm/SN+6j+zEqlgPPL9yKUgEzgG8SfzL0O75GWpmsYswfFbEz8Avi+7PfcR9wQAntJxU2ALyL9Cwq+sTIHRuA93XqrHKYPypiOvAZ4vu2X3EVaeIjVcqJNPs1nQfwy1o5mT8q4o+AVcT3c67YCPw17f4+hCpuDvAF0l7U0SdMWTFI+ib7nBLbSWMzf1TEAcC1xPd52fFb4KQS20nK6nTS603RJ07RuAs4rdym0QSYP+rVJOCdNOMjQuuBv8f1IqqhacC7qec7u4+TnktvVXqraKLMHxWxG/Al0q3z6HzoJS4BDiq9VaQ+mwP8A/Ak8SfVluJJ4O+A2VlaQr0wf1TEocClxOfGRONnwKlZWkIKNJP0q2gR8SfZ6LiPtDrb57TVZf6oiMOAc4A1xOfL6BgErgBenq32UkVMIe1e9XXSTlZRJ91q4D9J22j6Bbb6MH9UxK7A31CNTYQeAj6B7/SrpWYDbyYNpI+T/4R7HPhq55iz+lA/5WX+qIjjSXsI9HMy8CBwHvAinDiGcjOOaplE2uP7JODIzr+fR+8nySbSfvM3Ar8Cftr592DhkqqKzB8VsTfwYuBkUu7sRznv3C8i5c/1wOXArSX8N1UCJwDVN5304Zg9SB9N2Zn0q286aRtZSLdi15EWYD1G2nBlMXA/sLbP5VW1mD/q1bbA4aSJwR6d2IX0dsoc0hsek3gmd9YDS0h580Dn76+BZf0uuCRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJkiRJOf1/TBeQ5OE/WfQAAAAASUVORK5CYII=" })] })] });
25553
25790
  }
@@ -25688,6 +25925,7 @@ const iconComponents = {
25688
25925
  Synced,
25689
25926
  Syncing,
25690
25927
  Tabler,
25928
+ TimelineCaret,
25691
25929
  Timeline,
25692
25930
  TrashFill,
25693
25931
  Trash,
@@ -25750,7 +25988,12 @@ const ADD_TRIGGER = "ADD_TRIGGER";
25750
25988
  const ADD_INVALID_TRIGGER = "ADD_INVALID_TRIGGER";
25751
25989
  const defaultDriveOptions = [NEW_FOLDER, RENAME, SETTINGS];
25752
25990
  const defaultFileOptions = [RENAME, DELETE, DUPLICATE];
25753
- const defaultFolderOptions = [RENAME, DELETE, DUPLICATE];
25991
+ const defaultFolderOptions = [
25992
+ NEW_FOLDER,
25993
+ RENAME,
25994
+ DELETE,
25995
+ DUPLICATE
25996
+ ];
25754
25997
  const debugNodeOptions = [
25755
25998
  ADD_TRIGGER,
25756
25999
  REMOVE_TRIGGER,
@@ -25830,20 +26073,22 @@ const nodeOptionsMap = {
25830
26073
  };
25831
26074
  const name = "@powerhousedao/connect";
25832
26075
  const productName = "Powerhouse-Connect";
25833
- const version$1 = "1.0.22-staging.1";
26076
+ const version$1 = "1.0.23-dev.1";
25834
26077
  const description = "Powerhouse Connect";
25835
26078
  const main = "./dist/index.html";
25836
26079
  const type = "module";
25837
26080
  const engines = { "node": ">=20.0.0" };
26081
+ const bin = { "connect": "serve ./dist" };
25838
26082
  const files$1 = ["dist", "nginx.conf", "nginx.sh", "scripts"];
25839
26083
  const license = "AGPL-3.0-only";
25840
26084
  const author = "acaldas@powerhouse.inc";
25841
26085
  const repository = { "type": "git", "url": "git+https://github.com/powerhouse-inc/document-model-electron.git" };
25842
26086
  const bugs = { "url": "https://github.com/powerhouse-inc/document-model-electron/issues" };
25843
26087
  const homepage = "https://github.com/powerhouse-inc/document-model-electron#readme";
25844
- 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" };
25845
- 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.23.0", "@tailwindcss/vite": "^4.1.4", "@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": "^2.0.0", "@vitejs/plugin-react": "^4.4.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.1.4", "uuid": "^9.0.1", "viem": "^2.8.13", "vite": "^6.3.3", "vite-envs": "^4.6.0", "vite-plugin-html": "^3.2.2", "vite-plugin-node-polyfills": "^0.23.0", "vite-plugin-svgr": "^4.3.0", "vite-tsconfig-paths": "^5.1.4", "xvfb-maybe": "^0.2.1" };
26088
+ 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": "npm run clean && 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" };
26089
+ 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.4", "@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" };
25846
26090
  const optionalDependencies = { "@esbuild/linux-x64": "^0.21.4", "@rollup/rollup-linux-x64-musl": "4.14.3" };
26091
+ const dependencies = { "serve": "^14.2.4" };
25847
26092
  const packageJson = {
25848
26093
  name,
25849
26094
  productName,
@@ -25852,6 +26097,7 @@ const packageJson = {
25852
26097
  main,
25853
26098
  type,
25854
26099
  engines,
26100
+ bin,
25855
26101
  files: files$1,
25856
26102
  license,
25857
26103
  author,
@@ -25860,7 +26106,8 @@ const packageJson = {
25860
26106
  homepage,
25861
26107
  scripts,
25862
26108
  devDependencies,
25863
- optionalDependencies
26109
+ optionalDependencies,
26110
+ dependencies
25864
26111
  };
25865
26112
  const version = packageJson.version;
25866
26113
  const APP_VERSION = window.__VITE_ENVS.APP_VERSION || version;
@@ -25883,13 +26130,15 @@ const PH_CONNECT_SENTRY_ENV = window.__VITE_ENVS.PH_CONNECT_SENTRY_ENV || "dev";
25883
26130
  const PH_CONNECT_SENTRY_TRACING_ENABLED = window.__VITE_ENVS.PH_CONNECT_SENTRY_TRACING_ENABLED || "false";
25884
26131
  const GA_TRACKING_ID = window.__VITE_ENVS.PH_CONNECT_GA_TRACKING_ID;
25885
26132
  const PH_CONNECT_CLI_VERSION = window.__VITE_ENVS.PH_CONNECT_CLI_VERSION || void 0;
25886
- setLogLevel(window.__VITE_ENVS.LOG_LEVEL);
25887
- logger$1.info(`Setting log level to ${window.__VITE_ENVS.LOG_LEVEL}.`);
26133
+ const LOG_LEVEL = isLogLevel(window.__VITE_ENVS.LOG_LEVEL) ? window.__VITE_ENVS.LOG_LEVEL : "info";
26134
+ setLogLevel(LOG_LEVEL);
26135
+ logger$1.debug(`Setting log level to ${window.__VITE_ENVS.LOG_LEVEL}.`);
25888
26136
  const connectConfig = {
25889
26137
  appVersion: APP_VERSION,
25890
26138
  studioMode: PH_CONNECT_STUDIO_MODE.toString() === "true",
25891
26139
  warnOutdatedApp: WARN_OUTDATED_APP === "true",
25892
26140
  routerBasename: PH_CONNECT_ROUTER_BASENAME,
26141
+ analyticsDatabaseName: `${PH_CONNECT_ROUTER_BASENAME}:analytics`,
25893
26142
  sentry: {
25894
26143
  dsn: PH_CONNECT_SENTRY_DSN,
25895
26144
  env: PH_CONNECT_SENTRY_ENV,
@@ -25983,6 +26232,7 @@ DriveSections.filter(
25983
26232
  };
25984
26233
  });
25985
26234
  var lzString = { exports: {} };
26235
+ lzString.exports;
25986
26236
  var hasRequiredLzString;
25987
26237
  function requireLzString() {
25988
26238
  if (hasRequiredLzString) return lzString.exports;
@@ -26914,12 +27164,12 @@ function requireLocalforage() {
26914
27164
  var toString = Object.prototype.toString;
26915
27165
  var READ_ONLY = "readonly";
26916
27166
  var READ_WRITE = "readwrite";
26917
- function _binStringToArrayBuffer(bin) {
26918
- var length2 = bin.length;
27167
+ function _binStringToArrayBuffer(bin2) {
27168
+ var length2 = bin2.length;
26919
27169
  var buf = new ArrayBuffer(length2);
26920
27170
  var arr = new Uint8Array(buf);
26921
27171
  for (var i = 0; i < length2; i++) {
26922
- arr[i] = bin.charCodeAt(i);
27172
+ arr[i] = bin2.charCodeAt(i);
26923
27173
  }
26924
27174
  return buf;
26925
27175
  }
@@ -28623,6 +28873,9 @@ const _BrowserStorage = class _BrowserStorage {
28623
28873
  name: namespace ? `${namespace}:${_BrowserStorage.DBName}` : _BrowserStorage.DBName
28624
28874
  }));
28625
28875
  }
28876
+ ////////////////////////////////
28877
+ // IDocumentAdminStorage
28878
+ ////////////////////////////////
28626
28879
  async clear() {
28627
28880
  const db = await this.db;
28628
28881
  await db.clear();
@@ -28635,19 +28888,35 @@ const _BrowserStorage = class _BrowserStorage {
28635
28888
  const document = await db.getItem(this.buildDocumentKey(documentId));
28636
28889
  return !!document;
28637
28890
  }
28638
- // TODO: this should throw an error if the document already exists.
28639
- async create(documentId, document) {
28640
- var _a2;
28891
+ async create(document) {
28892
+ const documentId = document.id;
28893
+ if (!isValidDocumentId(documentId)) {
28894
+ throw new DocumentIdValidationError(documentId);
28895
+ }
28641
28896
  const db = await this.db;
28897
+ if (await this.exists(documentId)) {
28898
+ throw new DocumentAlreadyExistsError(documentId);
28899
+ }
28900
+ const slug = document.slug.length > 0 ? document.slug : documentId;
28901
+ if (!isValidSlug(slug)) {
28902
+ throw new DocumentSlugValidationError(slug);
28903
+ }
28904
+ const slugManifest = await this.getSlugManifest();
28905
+ if (slugManifest.slugToId[slug]) {
28906
+ throw new DocumentAlreadyExistsError(documentId);
28907
+ }
28908
+ document.slug = slug;
28642
28909
  await db.setItem(this.buildDocumentKey(documentId), document);
28643
- const slug = ((_a2 = document.initialState.state.global) == null ? void 0 : _a2.slug) ?? documentId;
28644
28910
  if (slug) {
28645
- const slugManifest = await this.getSlugManifest();
28646
- if (slugManifest.slugToId[slug]) {
28911
+ const slugManifest2 = await this.getSlugManifest();
28912
+ if (slugManifest2.slugToId[slug]) {
28647
28913
  throw new Error(`Document with slug ${slug} already exists`);
28648
28914
  }
28649
- slugManifest.slugToId[slug] = documentId;
28650
- await this.updateSlugManifest(slugManifest);
28915
+ slugManifest2.slugToId[slug] = documentId;
28916
+ await this.updateSlugManifest(slugManifest2);
28917
+ }
28918
+ if (document.documentType === "powerhouse/document-drive") {
28919
+ this.updateDriveManifest(documentId, { documentIds: [] });
28651
28920
  }
28652
28921
  }
28653
28922
  async get(documentId) {
@@ -28666,15 +28935,56 @@ const _BrowserStorage = class _BrowserStorage {
28666
28935
  }
28667
28936
  return this.get(documentId);
28668
28937
  }
28938
+ async findByType(documentModelType, limit = 100, cursor) {
28939
+ const db = await this.db;
28940
+ const keys = await db.keys();
28941
+ const documentKeys = keys.filter((key) => key.startsWith(`${_BrowserStorage.DOCUMENT_KEY}${_BrowserStorage.SEP}`));
28942
+ const documentsAndIds = [];
28943
+ for (const key of documentKeys) {
28944
+ const documentId = key.slice(_BrowserStorage.DOCUMENT_KEY.length + _BrowserStorage.SEP.length);
28945
+ try {
28946
+ const document = await db.getItem(key);
28947
+ if (!document || document.documentType !== documentModelType) {
28948
+ continue;
28949
+ }
28950
+ documentsAndIds.push({ id: documentId, document });
28951
+ } catch (error) {
28952
+ continue;
28953
+ }
28954
+ }
28955
+ documentsAndIds.sort((a, b) => {
28956
+ const aDate = new Date(a.document.created);
28957
+ const bDate = new Date(b.document.created);
28958
+ if (aDate.getTime() === bDate.getTime()) {
28959
+ return a.id.localeCompare(b.id);
28960
+ }
28961
+ return aDate.getTime() - bDate.getTime();
28962
+ });
28963
+ let startIndex = 0;
28964
+ if (cursor) {
28965
+ const index = documentsAndIds.findIndex(({ id }) => id === cursor);
28966
+ if (index !== -1) {
28967
+ startIndex = index;
28968
+ }
28969
+ }
28970
+ const endIndex = Math.min(startIndex + limit, documentsAndIds.length);
28971
+ let nextCursor;
28972
+ if (endIndex < documentsAndIds.length) {
28973
+ nextCursor = documentsAndIds[endIndex].id;
28974
+ }
28975
+ return {
28976
+ documents: documentsAndIds.slice(startIndex, endIndex).map(({ id }) => id),
28977
+ nextCursor
28978
+ };
28979
+ }
28669
28980
  async delete(documentId) {
28670
- var _a2;
28671
28981
  const db = await this.db;
28672
28982
  const document = await db.getItem(this.buildDocumentKey(documentId));
28673
28983
  if (!document) {
28674
28984
  return false;
28675
28985
  }
28986
+ const slug = document.slug.length > 0 ? document.slug : documentId;
28676
28987
  try {
28677
- const slug = (_a2 = document.initialState.state.global) == null ? void 0 : _a2.slug;
28678
28988
  if (slug) {
28679
28989
  const slugManifest = await this.getSlugManifest();
28680
28990
  if (slugManifest.slugToId[slug] === documentId) {
@@ -28684,11 +28994,16 @@ const _BrowserStorage = class _BrowserStorage {
28684
28994
  }
28685
28995
  } catch (error) {
28686
28996
  }
28687
- const drives = await this.getDrives();
28688
- for (const driveId of drives) {
28689
- if (driveId === documentId)
28690
- continue;
28691
- await this.removeChild(driveId, documentId);
28997
+ const parents = await this.getParents(documentId);
28998
+ for (const parent of parents) {
28999
+ await this.removeChild(parent, documentId);
29000
+ }
29001
+ const children = await this.getChildren(documentId);
29002
+ for (const child of children) {
29003
+ const childParents = await this.getParents(child);
29004
+ if (childParents.length === 1 && childParents[0] === documentId) {
29005
+ await this.delete(child);
29006
+ }
28692
29007
  }
28693
29008
  await db.removeItem(this.buildManifestKey(documentId));
28694
29009
  await db.removeItem(this.buildDocumentKey(documentId));
@@ -28722,6 +29037,20 @@ const _BrowserStorage = class _BrowserStorage {
28722
29037
  const manifest = await this.getManifest(parentId);
28723
29038
  return manifest.documentIds;
28724
29039
  }
29040
+ async getParents(childId) {
29041
+ const db = await this.db;
29042
+ const keys = await db.keys();
29043
+ const parents = [];
29044
+ const manifestKeys = keys.filter((key) => key.startsWith(`${_BrowserStorage.MANIFEST_KEY}${_BrowserStorage.SEP}`));
29045
+ for (const key of manifestKeys) {
29046
+ const driveId = key.slice(_BrowserStorage.MANIFEST_KEY.length + _BrowserStorage.SEP.length);
29047
+ const manifest = await this.getManifest(driveId);
29048
+ if (manifest.documentIds.includes(childId)) {
29049
+ parents.push(driveId);
29050
+ }
29051
+ }
29052
+ return parents;
29053
+ }
28725
29054
  ////////////////////////////////
28726
29055
  // IDriveStorage
28727
29056
  ////////////////////////////////
@@ -28743,9 +29072,6 @@ const _BrowserStorage = class _BrowserStorage {
28743
29072
  const db = await this.db;
28744
29073
  await db.setItem(_BrowserStorage.SLUG_MANIFEST_KEY, manifest);
28745
29074
  }
28746
- async clearStorage() {
28747
- return (await this.db).clear();
28748
- }
28749
29075
  async addDocumentOperations(drive, id, operations, header) {
28750
29076
  const document = await this.get(id);
28751
29077
  if (!document) {
@@ -28759,22 +29085,6 @@ const _BrowserStorage = class _BrowserStorage {
28759
29085
  operations: mergedOperations
28760
29086
  });
28761
29087
  }
28762
- async getDrives() {
28763
- const db = await this.db;
28764
- const keys = await db.keys();
28765
- return keys.filter((key) => key.startsWith(_BrowserStorage.MANIFEST_KEY)).map((key) => key.slice(_BrowserStorage.MANIFEST_KEY.length + _BrowserStorage.SEP.length));
28766
- }
28767
- async createDrive(id, drive) {
28768
- await this.create(id, drive);
28769
- await this.updateDriveManifest(id, { documentIds: [] });
28770
- }
28771
- async deleteDrive(id) {
28772
- const documents = await this.getChildren(id);
28773
- await Promise.all(documents.map((doc) => this.delete(doc)));
28774
- const db = await this.db;
28775
- await db.removeItem(this.buildManifestKey(id));
28776
- return db.removeItem(this.buildDocumentKey(id));
28777
- }
28778
29088
  async addDriveOperations(id, operations, header) {
28779
29089
  const drive = await this.get(id);
28780
29090
  const mergedOperations = mergeOperations(drive.operations, operations);
@@ -28815,12 +29125,16 @@ const _BrowserStorage = class _BrowserStorage {
28815
29125
  }
28816
29126
  // migrates all stored operations from legacy signature to signatures array
28817
29127
  async migrateOperationSignatures() {
28818
- const drives = await this.getDrives();
28819
- for (const drive of drives) {
28820
- await this.migrateDrive(drive);
28821
- const documents = await this.getChildren(drive);
28822
- await Promise.all(documents.map(async (docId) => this.migrateDocument(drive, docId)));
28823
- }
29128
+ let cursor;
29129
+ do {
29130
+ const { documents: drives, nextCursor } = await this.findByType("powerhouse/document-drive", 100, cursor);
29131
+ for (const drive of drives) {
29132
+ await this.migrateDrive(drive);
29133
+ const documents = await this.getChildren(drive);
29134
+ await Promise.all(documents.map(async (docId) => this.migrateDocument(drive, docId)));
29135
+ }
29136
+ cursor = nextCursor;
29137
+ } while (cursor);
28824
29138
  }
28825
29139
  async migrateDrive(driveId) {
28826
29140
  const drive = await this.get(driveId);
@@ -28894,8 +29208,11 @@ const getReactorDefaultDrivesConfig = () => {
28894
29208
  }
28895
29209
  };
28896
29210
  };
28897
- function createBrowserDocumentDriveServer(documentModels, routerBasename) {
28898
- return new ReactorBuilder(documentModels).withStorage(new BrowserStorage(routerBasename)).withCache(new InMemoryCache()).withQueueManager(new BaseQueueManager(1, 10)).withOptions({ ...getReactorDefaultDrivesConfig() }).build();
29211
+ function createBrowserStorage(routerBasename) {
29212
+ return new BrowserStorage(routerBasename);
29213
+ }
29214
+ function createBrowserDocumentDriveServer(documentModels, storage) {
29215
+ return new ReactorBuilder(documentModels).withStorage(storage).withCache(new InMemoryCache()).withQueueManager(new BaseQueueManager(1, 10)).withOptions({ ...getReactorDefaultDrivesConfig() }).build();
28899
29216
  }
28900
29217
  const VERSION_CHECK_INTERVAL = parseInt(window.__VITE_ENVS.PH_CONNECT_VERSION_CHECK_INTERVAL) || 60 * 60 * 1e3;
28901
29218
  const basePath = connectConfig.routerBasename;
@@ -31454,14 +31771,14 @@ if (window.__VITE_ENVS.MODE === "development") {
31454
31771
  } else {
31455
31772
  serviceWorkerManager.registerServiceWorker(false);
31456
31773
  }
31457
- const App = lazy(() => __vitePreload(() => import("./app-BIg_-piZ.js").then((n) => n.a_), true ? __vite__mapDeps([0,1,2]) : void 0));
31774
+ const App = lazy(() => __vitePreload(() => import("./app-DCtCV8Sz.js").then((n) => n.bs), true ? __vite__mapDeps([0,1,2]) : void 0));
31458
31775
  const AppLoader = /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(App, {}) });
31459
31776
  const appLoader = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
31460
31777
  __proto__: null,
31461
31778
  default: AppLoader
31462
31779
  }, Symbol.toStringTag, { value: "Module" }));
31463
31780
  export {
31464
- getDefaultExportFromCjs as $,
31781
+ Icon as $,
31465
31782
  AddStateExampleInputSchema as A,
31466
31783
  SetModuleDescriptionInputSchema as B,
31467
31784
  SetModuleNameInputSchema as C,
@@ -31488,148 +31805,148 @@ export {
31488
31805
  baseLoadFromFile as X,
31489
31806
  baseLoadFromInput as Y,
31490
31807
  pascalCase as Z,
31491
- Icon as _,
31808
+ logger$1 as _,
31492
31809
  createReducer as a,
31493
- DELETE as a$,
31494
- LOCAL as a0,
31495
- commonjsGlobal as a1,
31496
- PUBLIC as a2,
31810
+ getNamedType as a$,
31811
+ getDefaultExportFromCjs as a0,
31812
+ LOCAL as a1,
31813
+ commonjsGlobal as a2,
31497
31814
  SWITCHBOARD as a3,
31498
- locationInfoByLocation as a4,
31499
- sharingTypeOptions as a5,
31500
- objectType as a6,
31501
- recordType as a7,
31815
+ PUBLIC as a4,
31816
+ locationInfoByLocation as a5,
31817
+ sharingTypeOptions as a6,
31818
+ objectType as a7,
31502
31819
  stringType as a8,
31503
- capitalCase as a9,
31504
- moveNode as aA,
31505
- generateNodesCopy as aB,
31506
- copyNode as aC,
31507
- createState as aD,
31508
- setDriveName as aE,
31509
- setAvailableOffline as aF,
31510
- setSharingType as aG,
31511
- SynchronizationUnitNotFoundError as aH,
31512
- removeTrigger as aI,
31513
- generateUUID as aJ,
31514
- PullResponderTransmitter as aK,
31515
- addTrigger as aL,
31516
- ReadDriveNotFoundError as aM,
31517
- openUrl as aN,
31518
- getNodeOptions as aO,
31519
- DRIVE as aP,
31520
- FOLDER as aQ,
31521
- requestPublicDrive as aR,
31522
- serviceWorkerManager as aS,
31523
- packageJson as aT,
31524
- t as aU,
31525
- gql as aV,
31526
- request as aW,
31527
- getDimensions as aX,
31528
- READ as aY,
31529
- nodeOptionsMap as aZ,
31530
- defaultFileOptions as a_,
31531
- CLOUD as aa,
31532
- createZip as ab,
31533
- logger$1 as ac,
31820
+ recordType as a9,
31821
+ updateNode as aA,
31822
+ FILE as aB,
31823
+ moveNode as aC,
31824
+ generateNodesCopy as aD,
31825
+ copyNode as aE,
31826
+ createState as aF,
31827
+ setDriveName as aG,
31828
+ setAvailableOffline as aH,
31829
+ setSharingType as aI,
31830
+ SynchronizationUnitNotFoundError as aJ,
31831
+ removeTrigger as aK,
31832
+ PullResponderTransmitter as aL,
31833
+ addTrigger as aM,
31834
+ ReadDriveNotFoundError as aN,
31835
+ openUrl as aO,
31836
+ getNodeOptions as aP,
31837
+ DRIVE as aQ,
31838
+ FOLDER as aR,
31839
+ requestPublicDrive as aS,
31840
+ serviceWorkerManager as aT,
31841
+ packageJson as aU,
31842
+ t as aV,
31843
+ gql as aW,
31844
+ request as aX,
31845
+ inspect as aY,
31846
+ GraphQLError as aZ,
31847
+ invariant as a_,
31848
+ capitalCase as aa,
31849
+ CLOUD as ab,
31850
+ createZip as ac,
31534
31851
  LZString as ad,
31535
31852
  buildSignedOperation as ae,
31536
- getI18n as af,
31537
- getDefaults as ag,
31853
+ getDefaults as af,
31854
+ getI18n as ag,
31538
31855
  connectConfig as ah,
31539
31856
  hashDocumentStateForScope as ai,
31540
31857
  getAugmentedNamespace as aj,
31541
- setErrorHandler as ak,
31542
- driveDocumentModelModule as al,
31543
- createBrowserDocumentDriveServer as am,
31544
- hashKey as an,
31545
- childLogger as ao,
31546
- reducer as ap,
31547
- isDocumentDrive as aq,
31548
- generateAddNodeAction as ar,
31549
- isFileNode as as,
31550
- uploadDocumentOperations as at,
31551
- updateFile as au,
31552
- addFolder as av,
31553
- isFolderNode as aw,
31554
- deleteNode as ax,
31555
- updateNode as ay,
31556
- FILE as az,
31858
+ childLogger as ak,
31859
+ process as al,
31860
+ setErrorHandler as am,
31861
+ driveDocumentModelModule as an,
31862
+ createBrowserStorage as ao,
31863
+ createBrowserDocumentDriveServer as ap,
31864
+ generateId as aq,
31865
+ reducer as ar,
31866
+ isDocumentDrive as as,
31867
+ generateAddNodeAction as at,
31868
+ isFileNode as au,
31869
+ uploadDocumentOperations as av,
31870
+ updateFile as aw,
31871
+ addFolder as ax,
31872
+ isFolderNode as ay,
31873
+ deleteNode as az,
31557
31874
  SetStateSchemaInputSchema as b,
31558
- GraphQLFloat as b$,
31559
- RENAME as b0,
31560
- WRITE as b1,
31561
- DUPLICATE as b2,
31562
- defaultFolderOptions as b3,
31563
- garbageCollect as b4,
31564
- sortOperations as b5,
31565
- UI_NODE as b6,
31566
- generateId as b7,
31567
- undo as b8,
31568
- redo as b9,
31569
- isListType as bA,
31570
- snakeCase as bB,
31571
- constantCase as bC,
31572
- isAbstractType as bD,
31573
- BREAK as bE,
31574
- GraphQLInputObjectType as bF,
31575
- GraphQLList as bG,
31576
- GraphQLEnumType as bH,
31577
- GraphQLObjectType as bI,
31578
- GraphQLInterfaceType as bJ,
31579
- SchemaMetaFieldDef as bK,
31580
- TypeMetaFieldDef as bL,
31581
- TypeNameMetaFieldDef as bM,
31582
- isCompositeType as bN,
31583
- isOutputType as bO,
31584
- isInputType as bP,
31585
- GraphQLBoolean as bQ,
31586
- assertAbstractType as bR,
31587
- doTypesOverlap as bS,
31588
- DirectiveLocation as bT,
31589
- specifiedRules as bU,
31590
- NoUnusedFragmentsRule as bV,
31591
- ExecutableDefinitionsRule as bW,
31592
- validate as bX,
31593
- validateSchema as bY,
31594
- GraphQLID as bZ,
31595
- GraphQLString as b_,
31596
- useDocumentDispatch as ba,
31597
- inspect as bb,
31598
- GraphQLError as bc,
31599
- getNamedType as bd,
31600
- invariant as be,
31601
- isInputObjectType as bf,
31602
- isScalarType as bg,
31603
- isObjectType as bh,
31604
- isInterfaceType as bi,
31605
- isUnionType as bj,
31606
- isEnumType as bk,
31607
- print as bl,
31608
- isPrintableAsBlockString as bm,
31609
- Kind as bn,
31610
- astFromValue as bo,
31611
- DEFAULT_DEPRECATION_REASON as bp,
31612
- isSpecifiedDirective as bq,
31613
- isSpecifiedScalarType as br,
31614
- isIntrospectionType as bs,
31615
- z as bt,
31616
- GraphQLScalarType as bu,
31617
- parse as bv,
31618
- visit as bw,
31619
- buildASTSchema as bx,
31620
- extendSchema as by,
31621
- getNullableType as bz,
31875
+ DUPLICATE as b$,
31876
+ isInputObjectType as b0,
31877
+ isScalarType as b1,
31878
+ isObjectType as b2,
31879
+ isInterfaceType as b3,
31880
+ isUnionType as b4,
31881
+ isEnumType as b5,
31882
+ astFromValue as b6,
31883
+ print as b7,
31884
+ DEFAULT_DEPRECATION_REASON as b8,
31885
+ Kind as b9,
31886
+ isInputType as bA,
31887
+ GraphQLBoolean as bB,
31888
+ assertAbstractType as bC,
31889
+ doTypesOverlap as bD,
31890
+ DirectiveLocation as bE,
31891
+ specifiedRules as bF,
31892
+ NoUnusedFragmentsRule as bG,
31893
+ ExecutableDefinitionsRule as bH,
31894
+ validate as bI,
31895
+ validateSchema as bJ,
31896
+ GraphQLID as bK,
31897
+ GraphQLString as bL,
31898
+ GraphQLFloat as bM,
31899
+ GraphQLInt as bN,
31900
+ GraphQLDirective as bO,
31901
+ GraphQLUnionType as bP,
31902
+ isNonNullType as bQ,
31903
+ GraphQLNonNull as bR,
31904
+ isNamedType as bS,
31905
+ isLeafType as bT,
31906
+ GraphQLSchema as bU,
31907
+ buildSchema as bV,
31908
+ sentenceCase as bW,
31909
+ getDimensions as bX,
31910
+ READ as bY,
31911
+ nodeOptionsMap as bZ,
31912
+ defaultFileOptions as b_,
31913
+ isPrintableAsBlockString as ba,
31914
+ isSpecifiedDirective as bb,
31915
+ isSpecifiedScalarType as bc,
31916
+ isIntrospectionType as bd,
31917
+ z as be,
31918
+ GraphQLScalarType as bf,
31919
+ parse as bg,
31920
+ visit as bh,
31921
+ buildASTSchema as bi,
31922
+ extendSchema as bj,
31923
+ getNullableType as bk,
31924
+ isListType as bl,
31925
+ snakeCase as bm,
31926
+ constantCase as bn,
31927
+ isAbstractType as bo,
31928
+ BREAK as bp,
31929
+ GraphQLInputObjectType as bq,
31930
+ GraphQLList as br,
31931
+ GraphQLEnumType as bs,
31932
+ GraphQLObjectType as bt,
31933
+ GraphQLInterfaceType as bu,
31934
+ SchemaMetaFieldDef as bv,
31935
+ TypeMetaFieldDef as bw,
31936
+ TypeNameMetaFieldDef as bx,
31937
+ isCompositeType as by,
31938
+ isOutputType as bz,
31622
31939
  createAction as c,
31623
- GraphQLInt as c0,
31624
- GraphQLDirective as c1,
31625
- GraphQLUnionType as c2,
31626
- isNonNullType as c3,
31627
- GraphQLNonNull as c4,
31628
- isNamedType as c5,
31629
- isLeafType as c6,
31630
- GraphQLSchema as c7,
31631
- buildSchema as c8,
31632
- sentenceCase as c9,
31940
+ RENAME as c0,
31941
+ WRITE as c1,
31942
+ DELETE as c2,
31943
+ defaultFolderOptions as c3,
31944
+ garbageCollect as c4,
31945
+ sortOperations as c5,
31946
+ UI_NODE as c6,
31947
+ undo as c7,
31948
+ redo as c8,
31949
+ useDocumentDispatch as c9,
31633
31950
  appLoader as ca,
31634
31951
  ReorderModuleOperationsInputSchema as d,
31635
31952
  DeleteOperationInputSchema as e,
@@ -31655,3 +31972,4 @@ export {
31655
31972
  ReorderModulesInputSchema as y,
31656
31973
  DeleteModuleInputSchema as z
31657
31974
  };
31975
+ //# sourceMappingURL=app-loader-BAEWEx-m.js.map