@supernova-studio/client 1.0.0-alpha.11 → 1.0.0-alpha.12
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 +89 -72
- package/dist/index.d.ts +89 -72
- package/dist/index.js +29 -308
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -342
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8357,11 +8357,32 @@ var SupernovaApiClient = class {
|
|
|
8357
8357
|
}
|
|
8358
8358
|
};
|
|
8359
8359
|
|
|
8360
|
+
// src/events/design-system.ts
|
|
8361
|
+
import { z as z266 } from "zod";
|
|
8362
|
+
var DTOEventFigmaNodesRendered = z266.object({
|
|
8363
|
+
type: z266.literal("DesignSystem.FigmaNodesRendered"),
|
|
8364
|
+
designSystemId: z266.string(),
|
|
8365
|
+
versionId: z266.string(),
|
|
8366
|
+
figmaNodePersistentIds: z266.string().array()
|
|
8367
|
+
});
|
|
8368
|
+
var DTOEventDataSourcesImported = z266.object({
|
|
8369
|
+
type: z266.literal("DesignSystem.ImportJobFinished"),
|
|
8370
|
+
designSystemId: z266.string(),
|
|
8371
|
+
versionId: z266.string(),
|
|
8372
|
+
importJobId: z266.string(),
|
|
8373
|
+
dataSourceType: DataSourceRemoteType,
|
|
8374
|
+
dataSourceIds: z266.string().array()
|
|
8375
|
+
});
|
|
8376
|
+
|
|
8377
|
+
// src/events/event.ts
|
|
8378
|
+
import { z as z267 } from "zod";
|
|
8379
|
+
var DTOEvent = z267.discriminatedUnion("type", [DTOEventDataSourcesImported, DTOEventFigmaNodesRendered]);
|
|
8380
|
+
|
|
8360
8381
|
// src/sync/docs-structure-repo.ts
|
|
8361
8382
|
import PQueue from "p-queue";
|
|
8362
8383
|
|
|
8363
8384
|
// src/yjs/design-system-content/documentation-hierarchy.ts
|
|
8364
|
-
import { z as
|
|
8385
|
+
import { z as z268 } from "zod";
|
|
8365
8386
|
|
|
8366
8387
|
// src/yjs/version-room/base.ts
|
|
8367
8388
|
var VersionRoomBaseYDoc = class {
|
|
@@ -8896,24 +8917,24 @@ var FrontendVersionRoomYDoc = class {
|
|
|
8896
8917
|
};
|
|
8897
8918
|
|
|
8898
8919
|
// src/yjs/design-system-content/documentation-hierarchy.ts
|
|
8899
|
-
var DocumentationHierarchySettings =
|
|
8900
|
-
routingVersion:
|
|
8901
|
-
isDraftFeatureAdopted:
|
|
8902
|
-
isApprovalFeatureEnabled:
|
|
8903
|
-
approvalRequiredForPublishing:
|
|
8920
|
+
var DocumentationHierarchySettings = z268.object({
|
|
8921
|
+
routingVersion: z268.string(),
|
|
8922
|
+
isDraftFeatureAdopted: z268.boolean(),
|
|
8923
|
+
isApprovalFeatureEnabled: z268.boolean(),
|
|
8924
|
+
approvalRequiredForPublishing: z268.boolean()
|
|
8904
8925
|
});
|
|
8905
8926
|
function yjsToDocumentationHierarchy(doc) {
|
|
8906
8927
|
return new FrontendVersionRoomYDoc(doc).getDocumentationHierarchy();
|
|
8907
8928
|
}
|
|
8908
8929
|
|
|
8909
8930
|
// src/yjs/design-system-content/item-configuration.ts
|
|
8910
|
-
import { z as
|
|
8911
|
-
var DTODocumentationPageRoomHeaderData =
|
|
8912
|
-
title:
|
|
8931
|
+
import { z as z269 } from "zod";
|
|
8932
|
+
var DTODocumentationPageRoomHeaderData = z269.object({
|
|
8933
|
+
title: z269.string(),
|
|
8913
8934
|
configuration: DTODocumentationItemConfigurationV2
|
|
8914
8935
|
});
|
|
8915
|
-
var DTODocumentationPageRoomHeaderDataUpdate =
|
|
8916
|
-
title:
|
|
8936
|
+
var DTODocumentationPageRoomHeaderDataUpdate = z269.object({
|
|
8937
|
+
title: z269.string().optional(),
|
|
8917
8938
|
configuration: DTODocumentationItemConfigurationV2.omit({ header: true }).extend({ header: DocumentationItemHeaderV2.partial() }).optional()
|
|
8918
8939
|
});
|
|
8919
8940
|
function itemConfigurationToYjs(yDoc, item) {
|
|
@@ -8964,7 +8985,7 @@ function yjsToItemConfiguration(yDoc) {
|
|
|
8964
8985
|
header: rawHeader
|
|
8965
8986
|
};
|
|
8966
8987
|
return {
|
|
8967
|
-
title:
|
|
8988
|
+
title: z269.string().parse(title),
|
|
8968
8989
|
configuration: DTODocumentationItemConfigurationV2.parse(rawConfig)
|
|
8969
8990
|
};
|
|
8970
8991
|
}
|
|
@@ -8974,9 +8995,9 @@ var PageBlockEditorModel = PageBlockEditorModelV2;
|
|
|
8974
8995
|
var PageSectionEditorModel = PageSectionEditorModelV2;
|
|
8975
8996
|
|
|
8976
8997
|
// src/yjs/docs-editor/model/page.ts
|
|
8977
|
-
import { z as
|
|
8978
|
-
var DocumentationPageEditorModel =
|
|
8979
|
-
blocks:
|
|
8998
|
+
import { z as z270 } from "zod";
|
|
8999
|
+
var DocumentationPageEditorModel = z270.object({
|
|
9000
|
+
blocks: z270.array(DocumentationPageContentItem)
|
|
8980
9001
|
});
|
|
8981
9002
|
|
|
8982
9003
|
// src/yjs/docs-editor/prosemirror/inner-editor-schema.ts
|
|
@@ -12535,7 +12556,7 @@ var blocks = [
|
|
|
12535
12556
|
|
|
12536
12557
|
// src/yjs/docs-editor/prosemirror-to-blocks.ts
|
|
12537
12558
|
import { yXmlFragmentToProsemirrorJSON } from "y-prosemirror";
|
|
12538
|
-
import { z as
|
|
12559
|
+
import { z as z271 } from "zod";
|
|
12539
12560
|
function yDocToPage(yDoc, definitions) {
|
|
12540
12561
|
return yXmlFragmentToPage(yDoc.getXmlFragment("default"), definitions);
|
|
12541
12562
|
}
|
|
@@ -12615,7 +12636,7 @@ function prosemirrorNodeToSectionItem(prosemirrorNode, definitionsMap) {
|
|
|
12615
12636
|
return null;
|
|
12616
12637
|
return {
|
|
12617
12638
|
id,
|
|
12618
|
-
title: getProsemirrorAttribute(prosemirrorNode, "title",
|
|
12639
|
+
title: getProsemirrorAttribute(prosemirrorNode, "title", z271.string()) ?? "",
|
|
12619
12640
|
columns: (prosemirrorNode.content ?? []).filter((c) => c.type === "sectionItemColumn").map((c) => prosemirrorNodeToSectionColumns(c, definitionsMap)).filter(nonNullFilter)
|
|
12620
12641
|
};
|
|
12621
12642
|
}
|
|
@@ -12650,7 +12671,7 @@ function internalProsemirrorNodesToBlocks(prosemirrorNodes, definitionsMap, dept
|
|
|
12650
12671
|
});
|
|
12651
12672
|
}
|
|
12652
12673
|
function internalProsemirrorNodeToBlock(prosemirrorNode, definitionsMap, depth) {
|
|
12653
|
-
const definitionId = getProsemirrorAttribute(prosemirrorNode, "definitionId",
|
|
12674
|
+
const definitionId = getProsemirrorAttribute(prosemirrorNode, "definitionId", z271.string());
|
|
12654
12675
|
if (!definitionId) {
|
|
12655
12676
|
console.warn(`definitionId on ${prosemirrorNode.type} is required to be interpreted as a block, skipping node`);
|
|
12656
12677
|
return [];
|
|
@@ -12692,7 +12713,7 @@ function parseAsRichText(prosemirrorNode, definition, property) {
|
|
|
12692
12713
|
if (!id)
|
|
12693
12714
|
return null;
|
|
12694
12715
|
const variantId = getProsemirrorBlockVariantId(prosemirrorNode);
|
|
12695
|
-
const calloutType = parseCalloutType(getProsemirrorAttribute(prosemirrorNode, "type",
|
|
12716
|
+
const calloutType = parseCalloutType(getProsemirrorAttribute(prosemirrorNode, "type", z271.string().optional()));
|
|
12696
12717
|
return {
|
|
12697
12718
|
id,
|
|
12698
12719
|
type: "Block",
|
|
@@ -12820,10 +12841,10 @@ function parseRichTextAttribute(mark) {
|
|
|
12820
12841
|
return null;
|
|
12821
12842
|
}
|
|
12822
12843
|
function parseProsemirrorLink(mark) {
|
|
12823
|
-
const href = getProsemirrorAttribute(mark, "href",
|
|
12844
|
+
const href = getProsemirrorAttribute(mark, "href", z271.string().optional());
|
|
12824
12845
|
if (!href)
|
|
12825
12846
|
return null;
|
|
12826
|
-
const target = getProsemirrorAttribute(mark, "target",
|
|
12847
|
+
const target = getProsemirrorAttribute(mark, "target", z271.string().optional());
|
|
12827
12848
|
const openInNewTab = target === "_blank";
|
|
12828
12849
|
if (href.startsWith("@")) {
|
|
12829
12850
|
return {
|
|
@@ -12842,10 +12863,10 @@ function parseProsemirrorLink(mark) {
|
|
|
12842
12863
|
}
|
|
12843
12864
|
}
|
|
12844
12865
|
function parseProsemirrorCommentHighlight(mark) {
|
|
12845
|
-
const highlightId = getProsemirrorAttribute(mark, "highlightId",
|
|
12866
|
+
const highlightId = getProsemirrorAttribute(mark, "highlightId", z271.string().optional());
|
|
12846
12867
|
if (!highlightId)
|
|
12847
12868
|
return null;
|
|
12848
|
-
const isResolved = getProsemirrorAttribute(mark, "resolved",
|
|
12869
|
+
const isResolved = getProsemirrorAttribute(mark, "resolved", z271.boolean().optional()) ?? false;
|
|
12849
12870
|
return {
|
|
12850
12871
|
type: "Comment",
|
|
12851
12872
|
commentHighlightId: highlightId,
|
|
@@ -12857,7 +12878,7 @@ function parseAsTable(prosemirrorNode, definition, property) {
|
|
|
12857
12878
|
if (!id)
|
|
12858
12879
|
return null;
|
|
12859
12880
|
const variantId = getProsemirrorBlockVariantId(prosemirrorNode);
|
|
12860
|
-
const hasBorder = getProsemirrorAttribute(prosemirrorNode, "hasBorder",
|
|
12881
|
+
const hasBorder = getProsemirrorAttribute(prosemirrorNode, "hasBorder", z271.boolean().optional()) !== false;
|
|
12861
12882
|
const tableChild = prosemirrorNode.content?.find((c) => c.type === "table");
|
|
12862
12883
|
if (!tableChild) {
|
|
12863
12884
|
return emptyTable(id, variantId, 0);
|
|
@@ -12904,9 +12925,9 @@ function parseAsTableCell(prosemirrorNode) {
|
|
|
12904
12925
|
const id = getProsemirrorBlockId(prosemirrorNode);
|
|
12905
12926
|
if (!id)
|
|
12906
12927
|
return null;
|
|
12907
|
-
const textAlign = getProsemirrorAttribute(prosemirrorNode, "textAlign",
|
|
12928
|
+
const textAlign = getProsemirrorAttribute(prosemirrorNode, "textAlign", z271.string().optional());
|
|
12908
12929
|
let columnWidth;
|
|
12909
|
-
const columnWidthArray = getProsemirrorAttribute(prosemirrorNode, "colwidth",
|
|
12930
|
+
const columnWidthArray = getProsemirrorAttribute(prosemirrorNode, "colwidth", z271.array(z271.number()).nullish());
|
|
12910
12931
|
if (columnWidthArray) {
|
|
12911
12932
|
columnWidth = roundDimension(columnWidthArray[0]);
|
|
12912
12933
|
}
|
|
@@ -12944,7 +12965,7 @@ function parseAsTableNode(prosemirrorNode) {
|
|
|
12944
12965
|
value: parseRichText(prosemirrorNode.content ?? [])
|
|
12945
12966
|
};
|
|
12946
12967
|
case "image":
|
|
12947
|
-
const items = getProsemirrorAttribute(prosemirrorNode, "items",
|
|
12968
|
+
const items = getProsemirrorAttribute(prosemirrorNode, "items", z271.string());
|
|
12948
12969
|
if (!items)
|
|
12949
12970
|
return null;
|
|
12950
12971
|
const parsedItems = PageBlockItemV2.array().safeParse(JSON.parse(items));
|
|
@@ -13064,7 +13085,7 @@ function definitionExpectsPlaceholderItem(definition) {
|
|
|
13064
13085
|
);
|
|
13065
13086
|
}
|
|
13066
13087
|
function parseBlockItems(prosemirrorNode, definition) {
|
|
13067
|
-
const itemsString = getProsemirrorAttribute(prosemirrorNode, "items",
|
|
13088
|
+
const itemsString = getProsemirrorAttribute(prosemirrorNode, "items", z271.string());
|
|
13068
13089
|
if (!itemsString)
|
|
13069
13090
|
return null;
|
|
13070
13091
|
const itemsJson = JSON.parse(itemsString);
|
|
@@ -13076,18 +13097,18 @@ function parseBlockItems(prosemirrorNode, definition) {
|
|
|
13076
13097
|
}
|
|
13077
13098
|
function parseAppearance(prosemirrorNode) {
|
|
13078
13099
|
let appearance = {};
|
|
13079
|
-
const rawAppearanceString = getProsemirrorAttribute(prosemirrorNode, "appearance",
|
|
13100
|
+
const rawAppearanceString = getProsemirrorAttribute(prosemirrorNode, "appearance", z271.string().optional());
|
|
13080
13101
|
if (rawAppearanceString) {
|
|
13081
13102
|
const parsedAppearance = PageBlockAppearanceV2.safeParse(JSON.parse(rawAppearanceString));
|
|
13082
13103
|
if (parsedAppearance.success) {
|
|
13083
13104
|
appearance = parsedAppearance.data;
|
|
13084
13105
|
}
|
|
13085
13106
|
}
|
|
13086
|
-
const columns = getProsemirrorAttribute(prosemirrorNode, "columns",
|
|
13107
|
+
const columns = getProsemirrorAttribute(prosemirrorNode, "columns", z271.number().optional());
|
|
13087
13108
|
if (columns) {
|
|
13088
13109
|
appearance.numberOfColumns = columns;
|
|
13089
13110
|
}
|
|
13090
|
-
const backgroundColor = getProsemirrorAttribute(prosemirrorNode, "backgroundColor",
|
|
13111
|
+
const backgroundColor = getProsemirrorAttribute(prosemirrorNode, "backgroundColor", z271.string().optional());
|
|
13091
13112
|
if (backgroundColor) {
|
|
13092
13113
|
const parsedColor = PageBlockColorV2.safeParse(JSON.parse(backgroundColor));
|
|
13093
13114
|
if (parsedColor.success) {
|
|
@@ -13182,13 +13203,13 @@ function valueSchemaForPropertyType(type) {
|
|
|
13182
13203
|
}
|
|
13183
13204
|
}
|
|
13184
13205
|
function getProsemirrorBlockId(prosemirrorNode) {
|
|
13185
|
-
const id = getProsemirrorAttribute(prosemirrorNode, "id",
|
|
13206
|
+
const id = getProsemirrorAttribute(prosemirrorNode, "id", z271.string());
|
|
13186
13207
|
if (!id)
|
|
13187
13208
|
console.warn(`Prosemirror attribute "id" on ${prosemirrorNode.type} is required`);
|
|
13188
13209
|
return id;
|
|
13189
13210
|
}
|
|
13190
13211
|
function getProsemirrorBlockVariantId(prosemirrorNode) {
|
|
13191
|
-
return getProsemirrorAttribute(prosemirrorNode, "variantId", nullishToOptional(
|
|
13212
|
+
return getProsemirrorAttribute(prosemirrorNode, "variantId", nullishToOptional(z271.string()));
|
|
13192
13213
|
}
|
|
13193
13214
|
function getProsemirrorAttribute(prosemirrorNode, attributeName, validationSchema) {
|
|
13194
13215
|
const parsedAttr = validationSchema.safeParse(prosemirrorNode.attrs?.[attributeName]);
|
|
@@ -13246,308 +13267,7 @@ var BackendVersionRoomYDoc = class {
|
|
|
13246
13267
|
}
|
|
13247
13268
|
};
|
|
13248
13269
|
|
|
13249
|
-
// src/sync/local-
|
|
13250
|
-
var LocalStorage = class {
|
|
13251
|
-
constructor() {
|
|
13252
|
-
__publicField(this, "pages", /* @__PURE__ */ new Map());
|
|
13253
|
-
__publicField(this, "liveblocksRoomIds", /* @__PURE__ */ new Map());
|
|
13254
|
-
__publicField(this, "deletedPageIds", /* @__PURE__ */ new Set());
|
|
13255
|
-
__publicField(this, "groups", /* @__PURE__ */ new Map());
|
|
13256
|
-
}
|
|
13257
|
-
setPage(page) {
|
|
13258
|
-
if (this.pages.has(page.persistentId)) {
|
|
13259
|
-
throw new Error(`Page with id ${page.persistentId} already exists`);
|
|
13260
|
-
}
|
|
13261
|
-
this.pages.set(page.persistentId, page);
|
|
13262
|
-
}
|
|
13263
|
-
deletePage(persistentId) {
|
|
13264
|
-
this.pages.delete(persistentId);
|
|
13265
|
-
this.deletedPageIds.add(persistentId);
|
|
13266
|
-
}
|
|
13267
|
-
tryGetPage(persistentId) {
|
|
13268
|
-
return this.pages.get(persistentId);
|
|
13269
|
-
}
|
|
13270
|
-
getPage(persistentId) {
|
|
13271
|
-
const page = this.tryGetPage(persistentId);
|
|
13272
|
-
if (!page)
|
|
13273
|
-
throw new Error(`Page with id ${persistentId} doesn't exist`);
|
|
13274
|
-
return page;
|
|
13275
|
-
}
|
|
13276
|
-
getAllPages() {
|
|
13277
|
-
return Array.from(this.pages.values());
|
|
13278
|
-
}
|
|
13279
|
-
getAllDeletedPages() {
|
|
13280
|
-
return this.deletedPageIds;
|
|
13281
|
-
}
|
|
13282
|
-
removePage(persistentId) {
|
|
13283
|
-
this.pages.delete(persistentId);
|
|
13284
|
-
}
|
|
13285
|
-
setPageLiveblocksRoomId(pagePersistentId, id) {
|
|
13286
|
-
this.liveblocksRoomIds.set(pagePersistentId, id);
|
|
13287
|
-
}
|
|
13288
|
-
getPageLiveblocksRoomId(pagePersistentId) {
|
|
13289
|
-
return this.liveblocksRoomIds.get(pagePersistentId);
|
|
13290
|
-
}
|
|
13291
|
-
getAllPageLiveblocksRoomIds() {
|
|
13292
|
-
return this.liveblocksRoomIds;
|
|
13293
|
-
}
|
|
13294
|
-
};
|
|
13295
|
-
|
|
13296
|
-
// src/sync/docs-structure-repo.ts
|
|
13297
|
-
var DocsStructureRepository = class {
|
|
13298
|
-
constructor(designSystemVersionId, yDoc, transactionExecutor) {
|
|
13299
|
-
__publicField(this, "localState", new LocalStorage());
|
|
13300
|
-
__publicField(this, "designSystemVersionId");
|
|
13301
|
-
__publicField(this, "yDoc");
|
|
13302
|
-
__publicField(this, "yObserver");
|
|
13303
|
-
__publicField(this, "_yState");
|
|
13304
|
-
__publicField(this, "_currentHierarchy");
|
|
13305
|
-
__publicField(this, "trxQueue");
|
|
13306
|
-
__publicField(this, "hierarchyObservers", /* @__PURE__ */ new Set());
|
|
13307
|
-
__publicField(this, "initCallbacks", /* @__PURE__ */ new Set());
|
|
13308
|
-
this.designSystemVersionId = designSystemVersionId;
|
|
13309
|
-
this.yDoc = yDoc;
|
|
13310
|
-
this.yObserver = yDoc.on("update", () => this.onYUpdate());
|
|
13311
|
-
this.onYUpdate();
|
|
13312
|
-
this.trxQueue = new TransactionQueue(transactionExecutor);
|
|
13313
|
-
}
|
|
13314
|
-
//
|
|
13315
|
-
// Convenience
|
|
13316
|
-
//
|
|
13317
|
-
get yState() {
|
|
13318
|
-
const yState = this._yState;
|
|
13319
|
-
if (!yState)
|
|
13320
|
-
throw SupernovaException.shouldNotHappen(`Accessing Y state before it was loaded`);
|
|
13321
|
-
return yState;
|
|
13322
|
-
}
|
|
13323
|
-
//
|
|
13324
|
-
// Lifecycle
|
|
13325
|
-
//
|
|
13326
|
-
get isInitialized() {
|
|
13327
|
-
return !!this._currentHierarchy;
|
|
13328
|
-
}
|
|
13329
|
-
onInitialized() {
|
|
13330
|
-
if (this.isInitialized)
|
|
13331
|
-
return Promise.resolve();
|
|
13332
|
-
return new Promise((resolve) => {
|
|
13333
|
-
this.initCallbacks.add(resolve);
|
|
13334
|
-
});
|
|
13335
|
-
}
|
|
13336
|
-
addHierarchyObserver(observer) {
|
|
13337
|
-
this.hierarchyObservers.add(observer);
|
|
13338
|
-
if (this._currentHierarchy)
|
|
13339
|
-
observer(this._currentHierarchy);
|
|
13340
|
-
}
|
|
13341
|
-
removeHierarchyObserver(observer) {
|
|
13342
|
-
this.hierarchyObservers.delete(observer);
|
|
13343
|
-
}
|
|
13344
|
-
dispose() {
|
|
13345
|
-
this.yDoc.off("update", this.yObserver);
|
|
13346
|
-
this.hierarchyObservers.clear();
|
|
13347
|
-
this.trxQueue.clear();
|
|
13348
|
-
}
|
|
13349
|
-
//
|
|
13350
|
-
// Accessors
|
|
13351
|
-
//
|
|
13352
|
-
get currentHierarchy() {
|
|
13353
|
-
const hierarchy = this._currentHierarchy;
|
|
13354
|
-
if (!hierarchy)
|
|
13355
|
-
throw new Error(`Hierarchy cannot be accessed while it's still loading`);
|
|
13356
|
-
return hierarchy;
|
|
13357
|
-
}
|
|
13358
|
-
//
|
|
13359
|
-
// Actions
|
|
13360
|
-
//
|
|
13361
|
-
createPage(input) {
|
|
13362
|
-
void this.createPagePromise(input);
|
|
13363
|
-
}
|
|
13364
|
-
createPagePromise(input) {
|
|
13365
|
-
this.localState.setPage({
|
|
13366
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
13367
|
-
parentPersistentId: input.parentPersistentId,
|
|
13368
|
-
persistentId: input.persistentId,
|
|
13369
|
-
shortPersistentId: generateShortPersistentId(),
|
|
13370
|
-
slug: slugify(input.title),
|
|
13371
|
-
meta: { name: input.title },
|
|
13372
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
13373
|
-
data: { configuration: input.configuration },
|
|
13374
|
-
sortOrder: this.calculateSortOrder(input.parentPersistentId, input.afterPersistentId),
|
|
13375
|
-
designSystemVersionId: ""
|
|
13376
|
-
});
|
|
13377
|
-
this.localState.setPageLiveblocksRoomId(
|
|
13378
|
-
input.persistentId,
|
|
13379
|
-
`${RoomType.DocumentationPage}:${this.designSystemVersionId}:${input.persistentId}`
|
|
13380
|
-
);
|
|
13381
|
-
this.refreshHierarchy();
|
|
13382
|
-
return this.trxQueue.enqueue({
|
|
13383
|
-
type: "DocumentationPageCreate",
|
|
13384
|
-
input: {
|
|
13385
|
-
persistentId: input.persistentId,
|
|
13386
|
-
parentPersistentId: input.parentPersistentId,
|
|
13387
|
-
title: input.title,
|
|
13388
|
-
afterPersistentId: input.afterPersistentId,
|
|
13389
|
-
configuration: input.configuration
|
|
13390
|
-
}
|
|
13391
|
-
});
|
|
13392
|
-
}
|
|
13393
|
-
updatePage(update) {
|
|
13394
|
-
void this.updatePagePromise(update);
|
|
13395
|
-
}
|
|
13396
|
-
updatePagePromise(update) {
|
|
13397
|
-
this.updatePageLocally(update);
|
|
13398
|
-
this.refreshHierarchy();
|
|
13399
|
-
return this.trxQueue.enqueue({
|
|
13400
|
-
type: "DocumentationPageUpdate",
|
|
13401
|
-
input: {
|
|
13402
|
-
id: update.persistentId,
|
|
13403
|
-
configuration: update.configuration,
|
|
13404
|
-
title: update.title
|
|
13405
|
-
}
|
|
13406
|
-
});
|
|
13407
|
-
}
|
|
13408
|
-
updatePageLocally(update) {
|
|
13409
|
-
const basePage = this.lookupPage(update.persistentId);
|
|
13410
|
-
this.localState.setPage(this.createLocalPageUpdate(basePage, update));
|
|
13411
|
-
}
|
|
13412
|
-
deletePagePromise(persistentId) {
|
|
13413
|
-
this.lookupPage(persistentId);
|
|
13414
|
-
this.localState.deletePage(persistentId);
|
|
13415
|
-
this.refreshHierarchy();
|
|
13416
|
-
return this.trxQueue.enqueue({
|
|
13417
|
-
type: "DocumentationPageDelete",
|
|
13418
|
-
input: {
|
|
13419
|
-
id: persistentId
|
|
13420
|
-
}
|
|
13421
|
-
});
|
|
13422
|
-
}
|
|
13423
|
-
deletePage(persistentId) {
|
|
13424
|
-
void this.deletePagePromise(persistentId);
|
|
13425
|
-
}
|
|
13426
|
-
createLocalPageUpdate(basePage, update) {
|
|
13427
|
-
let updatedConfiguration = basePage.data.configuration;
|
|
13428
|
-
if (update.configuration && Object.keys(update.configuration).length) {
|
|
13429
|
-
updatedConfiguration = { ...updatedConfiguration ?? defaultDocumentationItemConfigurationV2 };
|
|
13430
|
-
updatedConfiguration.header = update.configuration.header ?? updatedConfiguration.header;
|
|
13431
|
-
updatedConfiguration.isHidden = update.configuration.isHidden ?? updatedConfiguration.isHidden;
|
|
13432
|
-
updatedConfiguration.isPrivate = update.configuration.isPrivate ?? updatedConfiguration.isPrivate;
|
|
13433
|
-
updatedConfiguration.showSidebar = update.configuration.showSidebar ?? updatedConfiguration.showSidebar;
|
|
13434
|
-
}
|
|
13435
|
-
return {
|
|
13436
|
-
createdAt: basePage.createdAt,
|
|
13437
|
-
data: {
|
|
13438
|
-
configuration: updatedConfiguration
|
|
13439
|
-
},
|
|
13440
|
-
designSystemVersionId: basePage.designSystemVersionId,
|
|
13441
|
-
meta: { name: update.title ?? basePage.meta.name },
|
|
13442
|
-
parentPersistentId: basePage.parentPersistentId,
|
|
13443
|
-
persistentId: basePage.persistentId,
|
|
13444
|
-
shortPersistentId: basePage.shortPersistentId,
|
|
13445
|
-
sortOrder: basePage.sortOrder,
|
|
13446
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
13447
|
-
slug: basePage.slug
|
|
13448
|
-
};
|
|
13449
|
-
}
|
|
13450
|
-
lookupPage(persistentId) {
|
|
13451
|
-
const localPageToUpdate = this.localState.tryGetPage(persistentId);
|
|
13452
|
-
if (localPageToUpdate)
|
|
13453
|
-
return localPageToUpdate;
|
|
13454
|
-
const remotePage = this.yState.pages.find((p) => p.persistentId === persistentId);
|
|
13455
|
-
if (remotePage)
|
|
13456
|
-
return remotePage;
|
|
13457
|
-
throw SupernovaException.notFound(`Page ${persistentId} was not found`);
|
|
13458
|
-
}
|
|
13459
|
-
//
|
|
13460
|
-
// Reactions
|
|
13461
|
-
//
|
|
13462
|
-
refreshHierarchy() {
|
|
13463
|
-
const hierarchy = this.calculateHierarchy();
|
|
13464
|
-
if (!hierarchy)
|
|
13465
|
-
return;
|
|
13466
|
-
this._currentHierarchy = hierarchy;
|
|
13467
|
-
this.initCallbacks.forEach((f) => f());
|
|
13468
|
-
this.initCallbacks.clear();
|
|
13469
|
-
this.hierarchyObservers.forEach((o) => o(hierarchy));
|
|
13470
|
-
}
|
|
13471
|
-
calculateHierarchy() {
|
|
13472
|
-
const yState = this._yState;
|
|
13473
|
-
if (!yState)
|
|
13474
|
-
return;
|
|
13475
|
-
const allPagesById = mapByUnique(yState.pages, (p) => p.persistentId);
|
|
13476
|
-
this.localState.getAllPages().forEach((p) => {
|
|
13477
|
-
allPagesById.set(p.persistentId, p);
|
|
13478
|
-
});
|
|
13479
|
-
this.localState.getAllDeletedPages().forEach((id) => allPagesById.delete(id));
|
|
13480
|
-
const pageLiveblockRoomIds = { ...this.yState.pageLiveblockRoomIds };
|
|
13481
|
-
this.localState.getAllPageLiveblocksRoomIds().forEach((v, k) => {
|
|
13482
|
-
pageLiveblockRoomIds[k] = v;
|
|
13483
|
-
});
|
|
13484
|
-
const hierarchy = computeDocsHierarchy({
|
|
13485
|
-
approvals: yState.approvals,
|
|
13486
|
-
groups: yState.groups,
|
|
13487
|
-
groupSnapshots: yState.groupSnapshots,
|
|
13488
|
-
pageContentHashes: yState.pageContentHashes,
|
|
13489
|
-
pages: Array.from(allPagesById.values()),
|
|
13490
|
-
pageSnapshots: yState.pageSnapshots,
|
|
13491
|
-
settings: yState.settings,
|
|
13492
|
-
pageLiveblockRoomIds
|
|
13493
|
-
});
|
|
13494
|
-
return hierarchy;
|
|
13495
|
-
}
|
|
13496
|
-
onYUpdate() {
|
|
13497
|
-
const newState = new VersionRoomBaseYDoc(this.yDoc).getState();
|
|
13498
|
-
if (newState.groups.length) {
|
|
13499
|
-
this._yState = newState;
|
|
13500
|
-
this.refreshHierarchy();
|
|
13501
|
-
}
|
|
13502
|
-
}
|
|
13503
|
-
//
|
|
13504
|
-
// Utils
|
|
13505
|
-
//
|
|
13506
|
-
calculateSortOrder(parentPersistentId, afterPersistentId) {
|
|
13507
|
-
const sortOrderStep = Math.pow(2, 16);
|
|
13508
|
-
const neighbours = [
|
|
13509
|
-
...this.yState.pages.filter((p) => p.parentPersistentId === parentPersistentId),
|
|
13510
|
-
...this.yState.groups.filter((g) => g.parentPersistentId === parentPersistentId)
|
|
13511
|
-
];
|
|
13512
|
-
if (!neighbours.length)
|
|
13513
|
-
return 0;
|
|
13514
|
-
neighbours.sort((lhs, rhs) => lhs.sortOrder - rhs.sortOrder);
|
|
13515
|
-
if (afterPersistentId === null)
|
|
13516
|
-
return neighbours[0].sortOrder - sortOrderStep;
|
|
13517
|
-
if (!afterPersistentId)
|
|
13518
|
-
return neighbours[neighbours.length - 1].sortOrder + sortOrderStep;
|
|
13519
|
-
const index = neighbours.findIndex((e) => e.persistentId === afterPersistentId);
|
|
13520
|
-
if (index < 0 || index === neighbours.length - 1) {
|
|
13521
|
-
return neighbours[neighbours.length - 1].sortOrder + sortOrderStep;
|
|
13522
|
-
}
|
|
13523
|
-
const left = neighbours[index].sortOrder;
|
|
13524
|
-
const right = neighbours[index + 1]?.sortOrder ?? left + sortOrderStep * 2;
|
|
13525
|
-
return (right + left) / 2;
|
|
13526
|
-
}
|
|
13527
|
-
};
|
|
13528
|
-
var TransactionQueue = class {
|
|
13529
|
-
constructor(executor) {
|
|
13530
|
-
__publicField(this, "executor");
|
|
13531
|
-
__publicField(this, "queue", new PQueue({
|
|
13532
|
-
concurrency: 1
|
|
13533
|
-
}));
|
|
13534
|
-
this.executor = executor;
|
|
13535
|
-
}
|
|
13536
|
-
enqueue(trx) {
|
|
13537
|
-
return this.queue.add(() => this.executor(trx));
|
|
13538
|
-
}
|
|
13539
|
-
onEmpty() {
|
|
13540
|
-
return this.queue.onEmpty();
|
|
13541
|
-
}
|
|
13542
|
-
clear() {
|
|
13543
|
-
this.queue.clear();
|
|
13544
|
-
}
|
|
13545
|
-
};
|
|
13546
|
-
|
|
13547
|
-
// src/sync-v2/docs-structure-repo.ts
|
|
13548
|
-
import PQueue2 from "p-queue";
|
|
13549
|
-
|
|
13550
|
-
// src/sync-v2/local-action-executor.ts
|
|
13270
|
+
// src/sync/local-action-executor.ts
|
|
13551
13271
|
function applyActionsLocally(versionId, remoteState, trx) {
|
|
13552
13272
|
const actionExecutor = new LocalDocsElementActionExecutor(versionId, remoteState);
|
|
13553
13273
|
actionExecutor.applyTransactions(trx);
|
|
@@ -13691,8 +13411,8 @@ var LocalDocsElementActionExecutor = class {
|
|
|
13691
13411
|
}
|
|
13692
13412
|
};
|
|
13693
13413
|
|
|
13694
|
-
// src/sync
|
|
13695
|
-
var
|
|
13414
|
+
// src/sync/docs-structure-repo.ts
|
|
13415
|
+
var DocsStructureRepository = class {
|
|
13696
13416
|
constructor(designSystemVersionId, yDoc, transactionExecutor) {
|
|
13697
13417
|
__publicField(this, "designSystemVersionId");
|
|
13698
13418
|
__publicField(this, "yDoc");
|
|
@@ -13707,7 +13427,7 @@ var DocsStructureRepositoryV2 = class {
|
|
|
13707
13427
|
this.yDoc = yDoc;
|
|
13708
13428
|
this.yObserver = yDoc.on("update", () => this.onYUpdate());
|
|
13709
13429
|
this.onYUpdate();
|
|
13710
|
-
this.actionQueue = new
|
|
13430
|
+
this.actionQueue = new TransactionQueue(transactionExecutor);
|
|
13711
13431
|
}
|
|
13712
13432
|
//
|
|
13713
13433
|
// Lifecycle
|
|
@@ -13792,10 +13512,10 @@ var DocsStructureRepositoryV2 = class {
|
|
|
13792
13512
|
}
|
|
13793
13513
|
}
|
|
13794
13514
|
};
|
|
13795
|
-
var
|
|
13515
|
+
var TransactionQueue = class {
|
|
13796
13516
|
constructor(executor) {
|
|
13797
13517
|
__publicField(this, "executor");
|
|
13798
|
-
__publicField(this, "queue", new
|
|
13518
|
+
__publicField(this, "queue", new PQueue({
|
|
13799
13519
|
concurrency: 1
|
|
13800
13520
|
}));
|
|
13801
13521
|
this.executor = executor;
|
|
@@ -13974,6 +13694,9 @@ export {
|
|
|
13974
13694
|
DTOElementsGetOutputV2,
|
|
13975
13695
|
DTOElementsGetQuerySchema,
|
|
13976
13696
|
DTOElementsGetTypeFilter,
|
|
13697
|
+
DTOEvent,
|
|
13698
|
+
DTOEventDataSourcesImported,
|
|
13699
|
+
DTOEventFigmaNodesRendered,
|
|
13977
13700
|
DTOExportJob,
|
|
13978
13701
|
DTOExportJobCreatedBy,
|
|
13979
13702
|
DTOExportJobDesignSystemPreview,
|
|
@@ -14118,7 +13841,6 @@ export {
|
|
|
14118
13841
|
DesignSystemsEndpoint,
|
|
14119
13842
|
DimensionsVariableScopeType,
|
|
14120
13843
|
DocsStructureRepository,
|
|
14121
|
-
DocsStructureRepositoryV2,
|
|
14122
13844
|
DocumentationEndpoint,
|
|
14123
13845
|
DocumentationHierarchySettings,
|
|
14124
13846
|
DocumentationPageEditorModel,
|
|
@@ -14138,7 +13860,6 @@ export {
|
|
|
14138
13860
|
ImportJobsEndpoint,
|
|
14139
13861
|
ListTreeBuilder,
|
|
14140
13862
|
LiveblocksEndpoint,
|
|
14141
|
-
LocalStorage,
|
|
14142
13863
|
NpmRegistryInput,
|
|
14143
13864
|
ObjectMeta2 as ObjectMeta,
|
|
14144
13865
|
OverridesEndpoint,
|