@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.d.mts CHANGED
@@ -382791,6 +382791,7 @@ type VersionRoomBaseYDocState = {
382791
382791
  approvals: DocumentationPageApproval[];
382792
382792
  settings: DocumentationHierarchySettings;
382793
382793
  executedTransactionIds: string[];
382794
+ storageVersion: number;
382794
382795
  };
382795
382796
 
382796
382797
  type LocalDocsPage = OmitStrict<DocumentationPageV2, "id" | "userSlug"> & {
@@ -406899,6 +406900,9 @@ type DocumentationHierarchyTransaction = {
406899
406900
  pageApprovals?: DocumentationPageApproval[];
406900
406901
  pageApprovalIdsToDelete?: string[];
406901
406902
  executedTransactionIds?: string[];
406903
+ roomMetadata?: {
406904
+ storageVersion?: 1 | 2;
406905
+ };
406902
406906
  };
406903
406907
  declare class BackendVersionRoomYDoc {
406904
406908
  private readonly yDoc;
@@ -407187,6 +407191,10 @@ declare class VersionRoomBaseYDoc {
407187
407191
  updateExecutedTransactionIds(transactionIds: string[]): void;
407188
407192
  getExecutedTransactionIds(): string[];
407189
407193
  private get executedTransactionIdsArray();
407194
+ setStorageVersion(version: 1 | 2): void;
407195
+ getStorageVersion(): 1 | 2;
407196
+ private get roomMetadataMap();
407197
+ private getKeyValueStorage;
407190
407198
  }
407191
407199
 
407192
407200
  type DocsPage = VersionRoomDocsPage | LocalDocsPage;
package/dist/index.d.ts CHANGED
@@ -382791,6 +382791,7 @@ type VersionRoomBaseYDocState = {
382791
382791
  approvals: DocumentationPageApproval[];
382792
382792
  settings: DocumentationHierarchySettings;
382793
382793
  executedTransactionIds: string[];
382794
+ storageVersion: number;
382794
382795
  };
382795
382796
 
382796
382797
  type LocalDocsPage = OmitStrict<DocumentationPageV2, "id" | "userSlug"> & {
@@ -406899,6 +406900,9 @@ type DocumentationHierarchyTransaction = {
406899
406900
  pageApprovals?: DocumentationPageApproval[];
406900
406901
  pageApprovalIdsToDelete?: string[];
406901
406902
  executedTransactionIds?: string[];
406903
+ roomMetadata?: {
406904
+ storageVersion?: 1 | 2;
406905
+ };
406902
406906
  };
406903
406907
  declare class BackendVersionRoomYDoc {
406904
406908
  private readonly yDoc;
@@ -407187,6 +407191,10 @@ declare class VersionRoomBaseYDoc {
407187
407191
  updateExecutedTransactionIds(transactionIds: string[]): void;
407188
407192
  getExecutedTransactionIds(): string[];
407189
407193
  private get executedTransactionIdsArray();
407194
+ setStorageVersion(version: 1 | 2): void;
407195
+ getStorageVersion(): 1 | 2;
407196
+ private get roomMetadataMap();
407197
+ private getKeyValueStorage;
407190
407198
  }
407191
407199
 
407192
407200
  type DocsPage = VersionRoomDocsPage | LocalDocsPage;
package/dist/index.js CHANGED
@@ -5806,7 +5806,8 @@ var DesignSystemVersionRoomInitialState = _zod.z.object({
5806
5806
  groupSnapshots: _zod.z.array(ElementGroupSnapshot),
5807
5807
  pageApprovals: _zod.z.array(DocumentationPageApproval),
5808
5808
  internalSettings: DesignSystemVersionRoomInternalSettings,
5809
- pageHashes: _zod.z.record(_zod.z.string()).optional()
5809
+ pageHashes: _zod.z.record(_zod.z.string()).optional(),
5810
+ storageVersion: _zod.z.literal(1).or(_zod.z.literal(2))
5810
5811
  });
5811
5812
  var DesignSystemVersionRoomUpdate = _zod.z.object({
5812
5813
  pages: _zod.z.array(DocumentationPageV2),
@@ -6350,7 +6351,8 @@ var FlaggedFeature = _zod.z.enum([
6350
6351
  "ForgeRestartPlaywright",
6351
6352
  "ForgeCopyTemplatePreset",
6352
6353
  "ForgeSandboxTimeout",
6353
- "ForgeFileUploadBatchSize"
6354
+ "ForgeFileUploadBatchSize",
6355
+ "DSVersionRoomYJSStorageVersion"
6354
6356
  ]);
6355
6357
  var FeatureFlagMap = _zod.z.record(FlaggedFeature, _zod.z.boolean());
6356
6358
  var FeatureFlag = _zod.z.object({
@@ -14827,6 +14829,45 @@ var _pqueue = require('p-queue'); var _pqueue2 = _interopRequireDefault(_pqueue)
14827
14829
  // src/yjs/design-system-content/documentation-hierarchy.ts
14828
14830
 
14829
14831
 
14832
+ // src/yjs/utils/key-value-storage.ts
14833
+ var _ykeyvalue = require('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 (0, _ykeyvalue.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
+ _optionalChain([transaction, 'access', _101 => _101.roomMetadata, 'optionalAccess', _102 => _102.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);
@@ -20474,10 +20543,10 @@ var LocalProjectActionExecutor = class {
20474
20543
  const SORT_ORDER_STEP = 1e3;
20475
20544
  if (afterItemId === void 0) {
20476
20545
  const lastSection = findLast(projectId, sectionId);
20477
- return (_nullishCoalesce(_optionalChain([lastSection, 'optionalAccess', _101 => _101.sortOrder]), () => ( 0))) + SORT_ORDER_STEP;
20546
+ return (_nullishCoalesce(_optionalChain([lastSection, 'optionalAccess', _103 => _103.sortOrder]), () => ( 0))) + SORT_ORDER_STEP;
20478
20547
  } else if (afterItemId === null) {
20479
20548
  const firstSection = findFirst(projectId, sectionId);
20480
- return (_nullishCoalesce(_optionalChain([firstSection, 'optionalAccess', _102 => _102.sortOrder]), () => ( SORT_ORDER_STEP))) - SORT_ORDER_STEP;
20549
+ return (_nullishCoalesce(_optionalChain([firstSection, 'optionalAccess', _104 => _104.sortOrder]), () => ( SORT_ORDER_STEP))) - SORT_ORDER_STEP;
20481
20550
  } else {
20482
20551
  const targetSection = findUnique(projectId, afterItemId, sectionId);
20483
20552
  if (!targetSection) return null;