@supernova-studio/client 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +52 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -13586,18 +13586,21 @@ var LocalDocsElementActionExecutor = class {
|
|
|
13586
13586
|
__publicField(this, "pages");
|
|
13587
13587
|
__publicField(this, "groups");
|
|
13588
13588
|
__publicField(this, "approvalStates");
|
|
13589
|
+
__publicField(this, "pageLiveblockRoomIds");
|
|
13589
13590
|
const { designSystemVersionId, remoteState, userId } = config;
|
|
13590
13591
|
this.userId = userId;
|
|
13591
13592
|
this.designSystemVersionId = designSystemVersionId;
|
|
13592
13593
|
this.pages = mapByUnique(remoteState.pages, (p) => p.persistentId);
|
|
13593
13594
|
this.groups = mapByUnique(remoteState.groups, (p) => p.persistentId);
|
|
13594
13595
|
this.approvalStates = mapByUnique(remoteState.approvals, (a) => a.pagePersistentId);
|
|
13596
|
+
this.pageLiveblockRoomIds = { ...remoteState.pageLiveblockRoomIds };
|
|
13595
13597
|
}
|
|
13596
13598
|
get localState() {
|
|
13597
13599
|
return {
|
|
13598
13600
|
pages: Array.from(this.pages.values()),
|
|
13599
13601
|
groups: Array.from(this.groups.values()),
|
|
13600
|
-
approvals: Array.from(this.approvalStates.values())
|
|
13602
|
+
approvals: Array.from(this.approvalStates.values()),
|
|
13603
|
+
pageLiveblockRoomIds: this.pageLiveblockRoomIds
|
|
13601
13604
|
};
|
|
13602
13605
|
}
|
|
13603
13606
|
applyActions(trx) {
|
|
@@ -13630,6 +13633,7 @@ var LocalDocsElementActionExecutor = class {
|
|
|
13630
13633
|
case "DocumentationPageRestore":
|
|
13631
13634
|
throw new Error(`Transaction type ${trx.type} is not yet implemented`);
|
|
13632
13635
|
case "DocumentationTabCreate":
|
|
13636
|
+
return this.documentationTabCreate(trx);
|
|
13633
13637
|
case "DocumentationTabGroupDelete":
|
|
13634
13638
|
throw new Error(`Transaction type ${trx.type} is not yet implemented`);
|
|
13635
13639
|
case "FigmaNodeRender":
|
|
@@ -13642,6 +13646,7 @@ var LocalDocsElementActionExecutor = class {
|
|
|
13642
13646
|
//
|
|
13643
13647
|
documentationPageCreate(trx) {
|
|
13644
13648
|
const { input } = trx;
|
|
13649
|
+
const { persistentId } = input;
|
|
13645
13650
|
if (this.pages.has(input.persistentId)) {
|
|
13646
13651
|
return;
|
|
13647
13652
|
}
|
|
@@ -13649,9 +13654,9 @@ var LocalDocsElementActionExecutor = class {
|
|
|
13649
13654
|
throw new Error(`Cannot create page: parent persistent id ${input.parentPersistentId} was not found`);
|
|
13650
13655
|
}
|
|
13651
13656
|
const localPage = {
|
|
13657
|
+
persistentId,
|
|
13652
13658
|
createdAt: /* @__PURE__ */ new Date(),
|
|
13653
13659
|
parentPersistentId: input.parentPersistentId,
|
|
13654
|
-
persistentId: input.persistentId,
|
|
13655
13660
|
shortPersistentId: generateShortPersistentId(),
|
|
13656
13661
|
slug: slugify(input.title),
|
|
13657
13662
|
meta: { name: input.title },
|
|
@@ -13663,7 +13668,9 @@ var LocalDocsElementActionExecutor = class {
|
|
|
13663
13668
|
sortOrder: this.calculateSortOrder(input.parentPersistentId, input.afterPersistentId),
|
|
13664
13669
|
designSystemVersionId: this.designSystemVersionId
|
|
13665
13670
|
};
|
|
13666
|
-
this.pages.set(
|
|
13671
|
+
this.pages.set(persistentId, localPage);
|
|
13672
|
+
const roomId = `${RoomType.DocumentationPage}:${this.designSystemVersionId}:${persistentId}`;
|
|
13673
|
+
this.pageLiveblockRoomIds[persistentId] = roomId;
|
|
13667
13674
|
}
|
|
13668
13675
|
documentationPageUpdate(trx) {
|
|
13669
13676
|
const { input } = trx;
|
|
@@ -13707,6 +13714,7 @@ var LocalDocsElementActionExecutor = class {
|
|
|
13707
13714
|
if (!this.pages.delete(trx.input.id)) {
|
|
13708
13715
|
throw new Error(`Cannot delete page: page id ${input.id} was not found`);
|
|
13709
13716
|
}
|
|
13717
|
+
delete this.pageLiveblockRoomIds[trx.input.id];
|
|
13710
13718
|
}
|
|
13711
13719
|
//
|
|
13712
13720
|
// Group
|
|
@@ -13780,6 +13788,40 @@ var LocalDocsElementActionExecutor = class {
|
|
|
13780
13788
|
}
|
|
13781
13789
|
}
|
|
13782
13790
|
//
|
|
13791
|
+
// Tabs
|
|
13792
|
+
//
|
|
13793
|
+
documentationTabCreate(trx) {
|
|
13794
|
+
const { input } = trx;
|
|
13795
|
+
const page = this.pages.get(input.fromItemPersistentId);
|
|
13796
|
+
if (!page) {
|
|
13797
|
+
throw new Error(`Cannot create tab: page id ${input.fromItemPersistentId} was not found`);
|
|
13798
|
+
}
|
|
13799
|
+
const tabGroup = {
|
|
13800
|
+
parentPersistentId: page.parentPersistentId,
|
|
13801
|
+
persistentId: input.persistentId,
|
|
13802
|
+
shortPersistentId: generateShortPersistentId(),
|
|
13803
|
+
slug: page.slug,
|
|
13804
|
+
meta: page.meta,
|
|
13805
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
13806
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
13807
|
+
data: {
|
|
13808
|
+
behavior: "Tabs",
|
|
13809
|
+
configuration: page?.data.configuration
|
|
13810
|
+
},
|
|
13811
|
+
sortOrder: page.sortOrder,
|
|
13812
|
+
designSystemVersionId: this.designSystemVersionId
|
|
13813
|
+
};
|
|
13814
|
+
this.groups.set(input.persistentId, tabGroup);
|
|
13815
|
+
const newLocalPage = {
|
|
13816
|
+
...page,
|
|
13817
|
+
userSlug: void 0,
|
|
13818
|
+
sortOrder: 0,
|
|
13819
|
+
parentPersistentId: input.persistentId,
|
|
13820
|
+
meta: { name: input.tabName }
|
|
13821
|
+
};
|
|
13822
|
+
this.pages.set(newLocalPage.persistentId, newLocalPage);
|
|
13823
|
+
}
|
|
13824
|
+
//
|
|
13783
13825
|
// Approval states
|
|
13784
13826
|
//
|
|
13785
13827
|
documentationApprovalStateUpdate(trx) {
|
|
@@ -13962,7 +14004,7 @@ var DocsStructureRepository = class {
|
|
|
13962
14004
|
const executedTransactionIds = new Set(yState.executedTransactionIds);
|
|
13963
14005
|
const localActions = this.localActions.filter((a) => a.tId && !executedTransactionIds.has(a.tId));
|
|
13964
14006
|
this.localActions = localActions;
|
|
13965
|
-
const { pages, groups, approvals } = applyActionsLocally({
|
|
14007
|
+
const { pages, groups, approvals, pageLiveblockRoomIds } = applyActionsLocally({
|
|
13966
14008
|
userId: this.userId,
|
|
13967
14009
|
designSystemVersionId: this.designSystemVersionId,
|
|
13968
14010
|
remoteState: yState,
|
|
@@ -13970,14 +14012,16 @@ var DocsStructureRepository = class {
|
|
|
13970
14012
|
});
|
|
13971
14013
|
const hierarchy = computeDocsHierarchy(
|
|
13972
14014
|
{
|
|
14015
|
+
// Merged remote + local
|
|
13973
14016
|
pages,
|
|
13974
14017
|
groups,
|
|
13975
14018
|
approvals,
|
|
14019
|
+
pageLiveblockRoomIds,
|
|
14020
|
+
// Remote only
|
|
13976
14021
|
groupSnapshots: yState.groupSnapshots,
|
|
13977
14022
|
pageContentHashes: yState.pageContentHashes,
|
|
13978
14023
|
pageSnapshots: yState.pageSnapshots,
|
|
13979
|
-
settings: yState.settings
|
|
13980
|
-
pageLiveblockRoomIds: yState.pageLiveblockRoomIds
|
|
14024
|
+
settings: yState.settings
|
|
13981
14025
|
},
|
|
13982
14026
|
{ includeDeletedContent: true }
|
|
13983
14027
|
);
|