@supernova-studio/client 1.0.0-alpha.21 → 1.0.0-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -13774,15 +13774,18 @@ var DocsStructureRepository = class {
13774
13774
  __publicField(this, "actionQueue");
13775
13775
  __publicField(this, "hierarchyObservers", /* @__PURE__ */ new Set());
13776
13776
  __publicField(this, "settingsObservers", /* @__PURE__ */ new Set());
13777
+ __publicField(this, "errorObservers", /* @__PURE__ */ new Set());
13777
13778
  __publicField(this, "initCallbacks", /* @__PURE__ */ new Set());
13778
13779
  __publicField(this, "transactionIdGenerator");
13780
+ __publicField(this, "transactionExecutor");
13779
13781
  this.userId = config.userId;
13780
13782
  this.designSystemVersionId = config.designSystemVersionId;
13781
13783
  this.yDoc = config.yDoc;
13782
13784
  this.yObserver = this.yDoc.on("update", () => this.onYUpdate());
13783
13785
  this.onYUpdate();
13784
- this.actionQueue = new TransactionQueue(config.transactionExecutor);
13786
+ this.transactionExecutor = config.transactionExecutor;
13785
13787
  this.transactionIdGenerator = config.transactionIdGenerator;
13788
+ this.actionQueue = new TransactionQueue((action) => this.executeInternalAction(action));
13786
13789
  }
13787
13790
  //
13788
13791
  // Lifecycle
@@ -13813,9 +13816,17 @@ var DocsStructureRepository = class {
13813
13816
  removeSettingsObserver(observer) {
13814
13817
  this.settingsObservers.delete(observer);
13815
13818
  }
13819
+ addErrorObserver(observer) {
13820
+ this.errorObservers.add(observer);
13821
+ }
13822
+ removeErrorObserver(observer) {
13823
+ this.errorObservers.delete(observer);
13824
+ }
13816
13825
  dispose() {
13817
13826
  this.yDoc.off("update", this.yObserver);
13818
13827
  this.hierarchyObservers.clear();
13828
+ this.settingsObservers.clear();
13829
+ this.errorObservers.clear();
13819
13830
  this.actionQueue.clear();
13820
13831
  }
13821
13832
  //
@@ -13830,14 +13841,14 @@ var DocsStructureRepository = class {
13830
13841
  //
13831
13842
  // Actions
13832
13843
  //
13833
- executeAction(action) {
13844
+ executeAction(action, metadata) {
13834
13845
  void this.executeActionPromise(action);
13835
13846
  }
13836
- executeActionPromise(action) {
13847
+ executeActionPromise(action, metadata) {
13837
13848
  const fullAction = { ...action, tId: this.transactionIdGenerator() };
13838
13849
  this.localActions.push(fullAction);
13839
13850
  this.refreshHierarchy();
13840
- return this.actionQueue.enqueue(fullAction);
13851
+ return this.actionQueue.enqueue({ action: fullAction, metadata });
13841
13852
  }
13842
13853
  notifyPageContentUpdated(pagePersistentId, content, definitions) {
13843
13854
  const pageContentHash = generatePageContentHash(content, definitions);
@@ -13845,6 +13856,13 @@ var DocsStructureRepository = class {
13845
13856
  [pagePersistentId]: pageContentHash
13846
13857
  });
13847
13858
  }
13859
+ async executeInternalAction(action) {
13860
+ try {
13861
+ return this.transactionExecutor(action.action);
13862
+ } catch (e) {
13863
+ this.errorObservers.forEach((o) => o(e, action.metadata));
13864
+ }
13865
+ }
13848
13866
  //
13849
13867
  // Reactions
13850
13868
  //