@supernova-studio/client 1.87.0 → 1.87.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.
package/dist/index.mjs CHANGED
@@ -5806,7 +5806,8 @@ var DesignSystemVersionRoomInitialState = z182.object({
5806
5806
  groupSnapshots: z182.array(ElementGroupSnapshot),
5807
5807
  pageApprovals: z182.array(DocumentationPageApproval),
5808
5808
  internalSettings: DesignSystemVersionRoomInternalSettings,
5809
- pageHashes: z182.record(z182.string()).optional()
5809
+ pageHashes: z182.record(z182.string()).optional(),
5810
+ storageVersion: z182.literal(1).or(z182.literal(2))
5810
5811
  });
5811
5812
  var DesignSystemVersionRoomUpdate = z182.object({
5812
5813
  pages: z182.array(DocumentationPageV2),
@@ -6350,7 +6351,8 @@ var FlaggedFeature = z208.enum([
6350
6351
  "ForgeRestartPlaywright",
6351
6352
  "ForgeCopyTemplatePreset",
6352
6353
  "ForgeSandboxTimeout",
6353
- "ForgeFileUploadBatchSize"
6354
+ "ForgeFileUploadBatchSize",
6355
+ "DSVersionRoomYJSStorageVersion"
6354
6356
  ]);
6355
6357
  var FeatureFlagMap = z208.record(FlaggedFeature, z208.boolean());
6356
6358
  var FeatureFlag = z208.object({
@@ -14827,6 +14829,45 @@ import PQueue from "p-queue";
14827
14829
  // src/yjs/design-system-content/documentation-hierarchy.ts
14828
14830
  import { z as z372 } from "zod";
14829
14831
 
14832
+ // src/yjs/utils/key-value-storage.ts
14833
+ import { YKeyValue } from "y-utility/y-keyvalue";
14834
+ var YJSKeyValueStorageV1 = class {
14835
+ constructor(yDoc, key) {
14836
+ __publicField(this, "map");
14837
+ this.map = yDoc.getMap(key);
14838
+ }
14839
+ forEach(fn) {
14840
+ this.map.forEach((value, key) => fn(value, key));
14841
+ }
14842
+ get(key) {
14843
+ return this.map.get(key);
14844
+ }
14845
+ set(key, value) {
14846
+ this.map.set(key, value);
14847
+ }
14848
+ delete(key) {
14849
+ this.map.delete(key);
14850
+ }
14851
+ };
14852
+ var YJSKeyValueStorageV2 = class {
14853
+ constructor(yDoc, key) {
14854
+ __publicField(this, "kv");
14855
+ this.kv = new YKeyValue(yDoc.getArray(key));
14856
+ }
14857
+ forEach(fn) {
14858
+ this.kv.yarray.forEach(({ key, val }) => fn(val, key));
14859
+ }
14860
+ get(key) {
14861
+ return this.kv.get(key);
14862
+ }
14863
+ set(key, value) {
14864
+ this.kv.set(key, value);
14865
+ }
14866
+ delete(key) {
14867
+ this.kv.delete(key);
14868
+ }
14869
+ };
14870
+
14830
14871
  // src/yjs/version-room/base.ts
14831
14872
  var VersionRoomBaseYDoc = class {
14832
14873
  constructor(yDoc) {
@@ -14846,7 +14887,8 @@ var VersionRoomBaseYDoc = class {
14846
14887
  pageSnapshots: this.getPageSnapshots(),
14847
14888
  settings: this.getDocumentationInternalSettings(),
14848
14889
  pageLiveblockRoomIds: this.getDocumentationPageLiveblocksRoomIds(),
14849
- executedTransactionIds: this.getExecutedTransactionIds()
14890
+ executedTransactionIds: this.getExecutedTransactionIds(),
14891
+ storageVersion: this.getStorageVersion()
14850
14892
  };
14851
14893
  }
14852
14894
  //
@@ -14870,7 +14912,7 @@ var VersionRoomBaseYDoc = class {
14870
14912
  this.deleteObjects(this.pagesYMap, ids);
14871
14913
  }
14872
14914
  get pagesYMap() {
14873
- return this.yDoc.getMap("documentationPages");
14915
+ return this.getKeyValueStorage("documentationPages");
14874
14916
  }
14875
14917
  //
14876
14918
  // Groups
@@ -14885,7 +14927,7 @@ var VersionRoomBaseYDoc = class {
14885
14927
  this.deleteObjects(this.groupsYMap, ids);
14886
14928
  }
14887
14929
  get groupsYMap() {
14888
- return this.yDoc.getMap("documentationGroups");
14930
+ return this.getKeyValueStorage("documentationGroups");
14889
14931
  }
14890
14932
  //
14891
14933
  // Documentation internal settings
@@ -14920,7 +14962,7 @@ var VersionRoomBaseYDoc = class {
14920
14962
  );
14921
14963
  }
14922
14964
  get internalSettingsYMap() {
14923
- return this.yDoc.getMap("documentationInternalSettings");
14965
+ return this.getKeyValueStorage("documentationInternalSettings");
14924
14966
  }
14925
14967
  //
14926
14968
  // Documentation page snapshot
@@ -14935,7 +14977,7 @@ var VersionRoomBaseYDoc = class {
14935
14977
  this.deleteObjects(this.documentationPagePublishedStatesYMap, ids);
14936
14978
  }
14937
14979
  get documentationPagePublishedStatesYMap() {
14938
- return this.yDoc.getMap("documentationPageSnapshots");
14980
+ return this.getKeyValueStorage("documentationPageSnapshots");
14939
14981
  }
14940
14982
  //
14941
14983
  // Documentation group snapshots
@@ -14950,7 +14992,7 @@ var VersionRoomBaseYDoc = class {
14950
14992
  this.deleteObjects(this.documentationGroupPublishedStatesYMap, ids);
14951
14993
  }
14952
14994
  get documentationGroupPublishedStatesYMap() {
14953
- return this.yDoc.getMap("documentationGroupSnapshots");
14995
+ return this.getKeyValueStorage("documentationGroupSnapshots");
14954
14996
  }
14955
14997
  //
14956
14998
  // Utils
@@ -14986,14 +15028,14 @@ var VersionRoomBaseYDoc = class {
14986
15028
  return result;
14987
15029
  }
14988
15030
  get documentationPageLiveblocksRoomIdsYMap() {
14989
- return this.yDoc.getMap("documentationPageLiveblocksRoomIds");
15031
+ return this.getKeyValueStorage("documentationPageLiveblocksRoomIds");
14990
15032
  }
14991
15033
  updateDocumentationPageContentHashes(hashes) {
14992
15034
  const map = this.documentationPageContentHashesYMap;
14993
15035
  Object.entries(hashes).forEach(([key, hash2]) => map.set(key, hash2));
14994
15036
  }
14995
15037
  get documentationPageContentHashesYMap() {
14996
- return this.yDoc.getMap("documentationPageHashes");
15038
+ return this.getKeyValueStorage("documentationPageHashes");
14997
15039
  }
14998
15040
  //
14999
15041
  // Approval states
@@ -15008,7 +15050,7 @@ var VersionRoomBaseYDoc = class {
15008
15050
  return this.getObjects(this.documentationPageApprovalsMap, DocumentationPageApproval);
15009
15051
  }
15010
15052
  get documentationPageApprovalsMap() {
15011
- return this.yDoc.getMap("documentationPageApprovals");
15053
+ return this.getKeyValueStorage("documentationPageApprovals");
15012
15054
  }
15013
15055
  //
15014
15056
  // Executed transactions
@@ -15031,6 +15073,32 @@ var VersionRoomBaseYDoc = class {
15031
15073
  get executedTransactionIdsArray() {
15032
15074
  return this.yDoc.getArray("executedTransactionIds");
15033
15075
  }
15076
+ //
15077
+ // Room metadata
15078
+ //
15079
+ setStorageVersion(version) {
15080
+ this.roomMetadataMap.set("storageVersion", version.toString());
15081
+ }
15082
+ getStorageVersion() {
15083
+ const storageVersion = this.roomMetadataMap.get("storageVersion");
15084
+ if (storageVersion === "2") return 2;
15085
+ else return 1;
15086
+ }
15087
+ get roomMetadataMap() {
15088
+ return this.yDoc.getMap("roomMetadata");
15089
+ }
15090
+ //
15091
+ // Utils
15092
+ //
15093
+ getKeyValueStorage(key) {
15094
+ const version = this.getStorageVersion();
15095
+ switch (version) {
15096
+ case 2:
15097
+ return new YJSKeyValueStorageV2(this.yDoc, key);
15098
+ default:
15099
+ return new YJSKeyValueStorageV1(this.yDoc, key);
15100
+ }
15101
+ }
15034
15102
  };
15035
15103
 
15036
15104
  // src/yjs/version-room/compute-dto.ts
@@ -20165,6 +20233,7 @@ var BackendVersionRoomYDoc = class {
20165
20233
  updateDocumentationHierarchy(transaction) {
20166
20234
  this.yDoc.transact((trx) => {
20167
20235
  const yDoc = new VersionRoomBaseYDoc(trx.doc);
20236
+ transaction.roomMetadata?.storageVersion && yDoc.setStorageVersion(transaction.roomMetadata.storageVersion);
20168
20237
  transaction.pageIdsToDelete && yDoc.deletePages(transaction.pageIdsToDelete);
20169
20238
  transaction.pages && yDoc.updatePages(transaction.pages);
20170
20239
  transaction.groupIdsToDelete && yDoc.deleteGroups(transaction.groupIdsToDelete);