@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.d.mts +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +22 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -102329,11 +102329,12 @@ declare function generatePageContentHash(content: DocumentationPageEditorModel,
|
|
|
102329
102329
|
|
|
102330
102330
|
type HierarchyObserver = (hierarchy: DTODocumentationHierarchyV2) => void;
|
|
102331
102331
|
type SettingsObserver = (settings: DTODocumentationSettings) => void;
|
|
102332
|
+
type ErrorObserver<T> = (error: unknown, actionMetadata: T | undefined) => void;
|
|
102332
102333
|
type TransactionExecutor = (trx: DTOElementActionInput) => Promise<void>;
|
|
102333
102334
|
type TransactionIdGenerator = () => string;
|
|
102334
102335
|
type Action = DTOElementActionInputOfType<SupportedActionType>;
|
|
102335
|
-
type InputAction = OmitStrict<Action, "tId">;
|
|
102336
|
-
declare class DocsStructureRepository {
|
|
102336
|
+
type InputAction<T> = OmitStrict<Action, "tId">;
|
|
102337
|
+
declare class DocsStructureRepository<T> {
|
|
102337
102338
|
private userId;
|
|
102338
102339
|
private designSystemVersionId;
|
|
102339
102340
|
private readonly yDoc;
|
|
@@ -102345,8 +102346,10 @@ declare class DocsStructureRepository {
|
|
|
102345
102346
|
private readonly actionQueue;
|
|
102346
102347
|
private readonly hierarchyObservers;
|
|
102347
102348
|
private readonly settingsObservers;
|
|
102349
|
+
private readonly errorObservers;
|
|
102348
102350
|
private readonly initCallbacks;
|
|
102349
102351
|
private readonly transactionIdGenerator;
|
|
102352
|
+
private readonly transactionExecutor;
|
|
102350
102353
|
constructor(config: {
|
|
102351
102354
|
userId: string;
|
|
102352
102355
|
designSystemVersionId: string;
|
|
@@ -102360,11 +102363,14 @@ declare class DocsStructureRepository {
|
|
|
102360
102363
|
removeHierarchyObserver(observer: HierarchyObserver): void;
|
|
102361
102364
|
addSettingsObserver(observer: SettingsObserver): void;
|
|
102362
102365
|
removeSettingsObserver(observer: SettingsObserver): void;
|
|
102366
|
+
addErrorObserver(observer: ErrorObserver<T>): void;
|
|
102367
|
+
removeErrorObserver(observer: ErrorObserver<T>): void;
|
|
102363
102368
|
dispose(): void;
|
|
102364
102369
|
get currentHierarchy(): DTODocumentationHierarchyV2;
|
|
102365
|
-
executeAction(action: InputAction): void;
|
|
102366
|
-
executeActionPromise(action: InputAction): Promise<void>;
|
|
102370
|
+
executeAction(action: InputAction<T>, metadata?: T): void;
|
|
102371
|
+
executeActionPromise(action: InputAction<T>, metadata?: T): Promise<void>;
|
|
102367
102372
|
notifyPageContentUpdated(pagePersistentId: string, content: DocumentationPageEditorModel, definitions: DTOPageBlockDefinition[]): void;
|
|
102373
|
+
private executeInternalAction;
|
|
102368
102374
|
private refreshState;
|
|
102369
102375
|
private refreshSettings;
|
|
102370
102376
|
private refreshHierarchy;
|
package/dist/index.d.ts
CHANGED
|
@@ -102329,11 +102329,12 @@ declare function generatePageContentHash(content: DocumentationPageEditorModel,
|
|
|
102329
102329
|
|
|
102330
102330
|
type HierarchyObserver = (hierarchy: DTODocumentationHierarchyV2) => void;
|
|
102331
102331
|
type SettingsObserver = (settings: DTODocumentationSettings) => void;
|
|
102332
|
+
type ErrorObserver<T> = (error: unknown, actionMetadata: T | undefined) => void;
|
|
102332
102333
|
type TransactionExecutor = (trx: DTOElementActionInput) => Promise<void>;
|
|
102333
102334
|
type TransactionIdGenerator = () => string;
|
|
102334
102335
|
type Action = DTOElementActionInputOfType<SupportedActionType>;
|
|
102335
|
-
type InputAction = OmitStrict<Action, "tId">;
|
|
102336
|
-
declare class DocsStructureRepository {
|
|
102336
|
+
type InputAction<T> = OmitStrict<Action, "tId">;
|
|
102337
|
+
declare class DocsStructureRepository<T> {
|
|
102337
102338
|
private userId;
|
|
102338
102339
|
private designSystemVersionId;
|
|
102339
102340
|
private readonly yDoc;
|
|
@@ -102345,8 +102346,10 @@ declare class DocsStructureRepository {
|
|
|
102345
102346
|
private readonly actionQueue;
|
|
102346
102347
|
private readonly hierarchyObservers;
|
|
102347
102348
|
private readonly settingsObservers;
|
|
102349
|
+
private readonly errorObservers;
|
|
102348
102350
|
private readonly initCallbacks;
|
|
102349
102351
|
private readonly transactionIdGenerator;
|
|
102352
|
+
private readonly transactionExecutor;
|
|
102350
102353
|
constructor(config: {
|
|
102351
102354
|
userId: string;
|
|
102352
102355
|
designSystemVersionId: string;
|
|
@@ -102360,11 +102363,14 @@ declare class DocsStructureRepository {
|
|
|
102360
102363
|
removeHierarchyObserver(observer: HierarchyObserver): void;
|
|
102361
102364
|
addSettingsObserver(observer: SettingsObserver): void;
|
|
102362
102365
|
removeSettingsObserver(observer: SettingsObserver): void;
|
|
102366
|
+
addErrorObserver(observer: ErrorObserver<T>): void;
|
|
102367
|
+
removeErrorObserver(observer: ErrorObserver<T>): void;
|
|
102363
102368
|
dispose(): void;
|
|
102364
102369
|
get currentHierarchy(): DTODocumentationHierarchyV2;
|
|
102365
|
-
executeAction(action: InputAction): void;
|
|
102366
|
-
executeActionPromise(action: InputAction): Promise<void>;
|
|
102370
|
+
executeAction(action: InputAction<T>, metadata?: T): void;
|
|
102371
|
+
executeActionPromise(action: InputAction<T>, metadata?: T): Promise<void>;
|
|
102367
102372
|
notifyPageContentUpdated(pagePersistentId: string, content: DocumentationPageEditorModel, definitions: DTOPageBlockDefinition[]): void;
|
|
102373
|
+
private executeInternalAction;
|
|
102368
102374
|
private refreshState;
|
|
102369
102375
|
private refreshSettings;
|
|
102370
102376
|
private refreshHierarchy;
|
package/dist/index.js
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.
|
|
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
|
//
|