@inditextech/weave-store-azure-web-pubsub 0.2.0 → 0.3.0

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/client.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { FetchClient, FetchInitialState, FetchRoom, PersistRoom, WEAVE_STORE_AZURE_WEB_PUBSUB, WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS, WeaveAzureWebPubsubConfig, WeaveStoreAzureWebPubsubConnectionStatus, WeaveStoreAzureWebPubsubConnectionStatusKeys, WeaveStoreAzureWebPubsubOptions, WeaveStoreAzureWebPubsubStoreCallbacks } from "./types.d-BjiC_a5v.cjs";
2
1
  import Konva from "konva";
3
2
  import { Vector2d } from "konva/lib/types";
4
- import { MappedTypeDescription } from "@syncedstore/core/types/doc";
3
+ import * as Y$1 from "yjs";
4
+ import * as Y from "yjs";
5
5
  import { Doc } from "yjs";
6
6
  import Emittery from "emittery";
7
7
  import pino, { Logger } from "pino";
@@ -30,7 +30,7 @@ declare const WEAVE_EXPORT_FORMATS: {
30
30
  //#endregion
31
31
  //#region src/base/action.d.ts
32
32
  interface WeaveActionBase {
33
- init?(): void;
33
+ onInit?(): void;
34
34
  trigger(cancelAction: () => void, params?: unknown): unknown;
35
35
  internalUpdate?(): void;
36
36
  cleanup?(): void;
@@ -39,8 +39,8 @@ interface WeaveActionBase {
39
39
  //#endregion
40
40
  //#region src/base/plugin.d.ts
41
41
  interface WeavePluginBase {
42
- init?(): void;
43
- render?(): void;
42
+ onInit?(): void;
43
+ onRender?(): void;
44
44
  enable(): void;
45
45
  disable(): void;
46
46
  isEnabled(): boolean;
@@ -155,15 +155,19 @@ type WeaveCallbacks = {
155
155
  onStateChange?: (state: WeaveState) => void;
156
156
  onUndoManagerStatusChange?: (undoManagerStatus: WeaveUndoRedoChange) => void;
157
157
  };
158
-
158
+ declare type docElementTypeDescription = "xml" | "text" | Array<any> | object;
159
+ declare type DocTypeDescription = {
160
+ [key: string]: docElementTypeDescription;
161
+ };
162
+ declare type MappedTypeDescription<T extends DocTypeDescription> = { readonly [P in keyof T]: T[P] extends "xml" ? Y$1.XmlFragment : T[P] extends "text" ? Y$1.Text : T[P] extends Array<any> ? T[P] : T[P] extends object ? Partial<T[P]> : never };
159
163
  //#endregion
160
164
  //#region src/base/node.d.ts
161
165
  interface WeaveNodeBase {
162
- createNode(id: string, props: WeaveElementAttributes): WeaveStateElement;
163
- createInstance(props: WeaveElementAttributes): WeaveElementInstance;
164
- updateInstance(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
165
- removeInstance(instance: WeaveElementInstance): void;
166
- toNode(instance: WeaveElementInstance): WeaveStateElement;
166
+ create(id: string, props: WeaveElementAttributes): WeaveStateElement;
167
+ onRender(props: WeaveElementAttributes): WeaveElementInstance;
168
+ onUpdate(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
169
+ onDestroy(instance: WeaveElementInstance): void;
170
+ serialize(instance: WeaveElementInstance): WeaveStateElement;
167
171
  } //#endregion
168
172
  //#region src/stores/store.d.ts
169
173
 
@@ -212,8 +216,8 @@ declare abstract class WeavePlugin implements WeavePluginBase {
212
216
  getName(): string;
213
217
  getLogger(): Logger;
214
218
  isEnabled(): boolean;
215
- abstract init?(): void;
216
- abstract render?(): void;
219
+ abstract onInit?(): void;
220
+ abstract onRender?(): void;
217
221
  abstract enable(): void;
218
222
  abstract disable(): void;
219
223
  }
@@ -237,12 +241,12 @@ declare class WeaveNodesSelectionPlugin extends WeavePlugin {
237
241
  private selecting;
238
242
  private initialized;
239
243
  private callbacks;
240
- render: undefined;
244
+ onRender: undefined;
241
245
  constructor(callbacks: WeaveNodesSelectionPluginCallbacks);
242
246
  getName(): string;
243
247
  getLayerName(): string;
244
248
  initLayer(): void;
245
- init(): void;
249
+ onInit(): void;
246
250
  private getLayer;
247
251
  private triggerSelectedNodesEvent;
248
252
  private initEvents;
@@ -271,11 +275,11 @@ declare abstract class WeaveNode implements WeaveNodeBase {
271
275
  isPasting(): boolean;
272
276
  isNodeSelected(ele: Konva.Node): boolean;
273
277
  setupDefaultNodeEvents(node: Konva.Node): void;
274
- abstract createNode(id: string, props: WeaveElementAttributes): WeaveStateElement;
275
- abstract createInstance(props: WeaveElementAttributes): WeaveElementInstance;
276
- abstract updateInstance(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
277
- abstract removeInstance(instance: WeaveElementInstance): void;
278
- abstract toNode(instance: WeaveElementInstance): WeaveStateElement;
278
+ create(key: string, props: WeaveElementAttributes): WeaveStateElement;
279
+ abstract onRender(props: WeaveElementAttributes): WeaveElementInstance;
280
+ abstract onUpdate(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
281
+ onDestroy(nodeInstance: WeaveElementInstance): void;
282
+ serialize(instance: WeaveElementInstance): WeaveStateElement;
279
283
  }
280
284
 
281
285
  //#endregion
@@ -299,7 +303,7 @@ declare abstract class WeaveAction {
299
303
  register(instance: Weave): WeaveAction;
300
304
  updateProps(props: WeaveElementAttributes): void;
301
305
  getProps(): WeaveElementAttributes;
302
- abstract init?(): void;
306
+ abstract onInit?(): void;
303
307
  abstract trigger(cancelAction: () => void, params?: unknown): unknown;
304
308
  abstract internalUpdate?(): void;
305
309
  abstract cleanup?(): void;
@@ -470,6 +474,41 @@ type WeaveUndoManagerOptions = {
470
474
  trackedOrigins?: Set<any>;
471
475
  };
472
476
 
477
+ //#endregion
478
+ //#region src/constants.d.ts
479
+ declare const WEAVE_STORE_AZURE_WEB_PUBSUB = "store-azure-web-pubsub";
480
+ declare const WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS: {
481
+ readonly "CONNECTED": "connected";
482
+ readonly "DISCONNECTED": "disconnected";
483
+ };
484
+
485
+ //#endregion
486
+ //#region src/types.d.ts
487
+ type WeaveStoreAzureWebPubsubConnectionStatusKeys = keyof typeof WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS;
488
+ type WeaveStoreAzureWebPubsubConnectionStatus = (typeof WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS)[WeaveStoreAzureWebPubsubConnectionStatusKeys];
489
+ type WeaveAzureWebPubsubConfig = {
490
+ endpoint: string;
491
+ key: string;
492
+ hubName: string;
493
+ };
494
+ type WeaveStoreAzureWebPubsubOptions = {
495
+ roomId: string;
496
+ url: string;
497
+ fetchClient?: FetchClient;
498
+ callbacks?: WeaveStoreAzureWebPubsubStoreCallbacks;
499
+ };
500
+ type WeaveStoreAzureWebPubsubStoreCallbacks = {
501
+ onFetchConnectionUrl?: (payload: {
502
+ loading: boolean;
503
+ error: Error | null;
504
+ }) => void;
505
+ onConnectionStatusChange?: (status: WeaveStoreAzureWebPubsubConnectionStatus) => void;
506
+ };
507
+ type FetchClient = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
508
+ type FetchInitialState = (doc: Y.Doc) => void;
509
+ type PersistRoom = (roomId: string, actualState: Uint8Array<ArrayBufferLike>) => Promise<void>;
510
+ type FetchRoom = (roomId: string) => Promise<Uint8Array | null>;
511
+
473
512
  //#endregion
474
513
  //#region src/client.d.ts
475
514
  interface ClientOptions {
package/dist/client.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { FetchClient, FetchInitialState, FetchRoom, PersistRoom, WEAVE_STORE_AZURE_WEB_PUBSUB$1 as WEAVE_STORE_AZURE_WEB_PUBSUB, WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS$1 as WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS, WeaveAzureWebPubsubConfig, WeaveStoreAzureWebPubsubConnectionStatus, WeaveStoreAzureWebPubsubConnectionStatusKeys, WeaveStoreAzureWebPubsubOptions, WeaveStoreAzureWebPubsubStoreCallbacks } from "./types.d-Cw5mafrL.js";
2
- import { Doc } from "yjs";
3
1
  import Emittery from "emittery";
2
+ import * as Y$1 from "yjs";
3
+ import * as Y from "yjs";
4
+ import { Doc } from "yjs";
4
5
  import ReconnectingWebSocket from "reconnecting-websocket";
5
6
  import Konva from "konva";
6
7
  import { Vector2d } from "konva/lib/types";
7
- import { MappedTypeDescription } from "@syncedstore/core/types/doc";
8
8
  import pino, { Logger } from "pino";
9
9
  import { StageConfig } from "konva/lib/Stage";
10
10
  import * as awarenessProtocol from "y-protocols/awareness";
@@ -30,7 +30,7 @@ declare const WEAVE_EXPORT_FORMATS: {
30
30
  //#endregion
31
31
  //#region src/base/action.d.ts
32
32
  interface WeaveActionBase {
33
- init?(): void;
33
+ onInit?(): void;
34
34
  trigger(cancelAction: () => void, params?: unknown): unknown;
35
35
  internalUpdate?(): void;
36
36
  cleanup?(): void;
@@ -39,8 +39,8 @@ interface WeaveActionBase {
39
39
  //#endregion
40
40
  //#region src/base/plugin.d.ts
41
41
  interface WeavePluginBase {
42
- init?(): void;
43
- render?(): void;
42
+ onInit?(): void;
43
+ onRender?(): void;
44
44
  enable(): void;
45
45
  disable(): void;
46
46
  isEnabled(): boolean;
@@ -155,15 +155,19 @@ type WeaveCallbacks = {
155
155
  onStateChange?: (state: WeaveState) => void;
156
156
  onUndoManagerStatusChange?: (undoManagerStatus: WeaveUndoRedoChange) => void;
157
157
  };
158
-
158
+ declare type docElementTypeDescription = "xml" | "text" | Array<any> | object;
159
+ declare type DocTypeDescription = {
160
+ [key: string]: docElementTypeDescription;
161
+ };
162
+ declare type MappedTypeDescription<T extends DocTypeDescription> = { readonly [P in keyof T]: T[P] extends "xml" ? Y$1.XmlFragment : T[P] extends "text" ? Y$1.Text : T[P] extends Array<any> ? T[P] : T[P] extends object ? Partial<T[P]> : never };
159
163
  //#endregion
160
164
  //#region src/base/node.d.ts
161
165
  interface WeaveNodeBase {
162
- createNode(id: string, props: WeaveElementAttributes): WeaveStateElement;
163
- createInstance(props: WeaveElementAttributes): WeaveElementInstance;
164
- updateInstance(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
165
- removeInstance(instance: WeaveElementInstance): void;
166
- toNode(instance: WeaveElementInstance): WeaveStateElement;
166
+ create(id: string, props: WeaveElementAttributes): WeaveStateElement;
167
+ onRender(props: WeaveElementAttributes): WeaveElementInstance;
168
+ onUpdate(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
169
+ onDestroy(instance: WeaveElementInstance): void;
170
+ serialize(instance: WeaveElementInstance): WeaveStateElement;
167
171
  } //#endregion
168
172
  //#region src/stores/store.d.ts
169
173
 
@@ -212,8 +216,8 @@ declare abstract class WeavePlugin implements WeavePluginBase {
212
216
  getName(): string;
213
217
  getLogger(): Logger;
214
218
  isEnabled(): boolean;
215
- abstract init?(): void;
216
- abstract render?(): void;
219
+ abstract onInit?(): void;
220
+ abstract onRender?(): void;
217
221
  abstract enable(): void;
218
222
  abstract disable(): void;
219
223
  }
@@ -237,12 +241,12 @@ declare class WeaveNodesSelectionPlugin extends WeavePlugin {
237
241
  private selecting;
238
242
  private initialized;
239
243
  private callbacks;
240
- render: undefined;
244
+ onRender: undefined;
241
245
  constructor(callbacks: WeaveNodesSelectionPluginCallbacks);
242
246
  getName(): string;
243
247
  getLayerName(): string;
244
248
  initLayer(): void;
245
- init(): void;
249
+ onInit(): void;
246
250
  private getLayer;
247
251
  private triggerSelectedNodesEvent;
248
252
  private initEvents;
@@ -271,11 +275,11 @@ declare abstract class WeaveNode implements WeaveNodeBase {
271
275
  isPasting(): boolean;
272
276
  isNodeSelected(ele: Konva.Node): boolean;
273
277
  setupDefaultNodeEvents(node: Konva.Node): void;
274
- abstract createNode(id: string, props: WeaveElementAttributes): WeaveStateElement;
275
- abstract createInstance(props: WeaveElementAttributes): WeaveElementInstance;
276
- abstract updateInstance(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
277
- abstract removeInstance(instance: WeaveElementInstance): void;
278
- abstract toNode(instance: WeaveElementInstance): WeaveStateElement;
278
+ create(key: string, props: WeaveElementAttributes): WeaveStateElement;
279
+ abstract onRender(props: WeaveElementAttributes): WeaveElementInstance;
280
+ abstract onUpdate(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
281
+ onDestroy(nodeInstance: WeaveElementInstance): void;
282
+ serialize(instance: WeaveElementInstance): WeaveStateElement;
279
283
  }
280
284
 
281
285
  //#endregion
@@ -299,7 +303,7 @@ declare abstract class WeaveAction {
299
303
  register(instance: Weave): WeaveAction;
300
304
  updateProps(props: WeaveElementAttributes): void;
301
305
  getProps(): WeaveElementAttributes;
302
- abstract init?(): void;
306
+ abstract onInit?(): void;
303
307
  abstract trigger(cancelAction: () => void, params?: unknown): unknown;
304
308
  abstract internalUpdate?(): void;
305
309
  abstract cleanup?(): void;
@@ -470,6 +474,41 @@ type WeaveUndoManagerOptions = {
470
474
  trackedOrigins?: Set<any>;
471
475
  };
472
476
 
477
+ //#endregion
478
+ //#region src/constants.d.ts
479
+ declare const WEAVE_STORE_AZURE_WEB_PUBSUB = "store-azure-web-pubsub";
480
+ declare const WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS: {
481
+ readonly "CONNECTED": "connected";
482
+ readonly "DISCONNECTED": "disconnected";
483
+ };
484
+
485
+ //#endregion
486
+ //#region src/types.d.ts
487
+ type WeaveStoreAzureWebPubsubConnectionStatusKeys = keyof typeof WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS;
488
+ type WeaveStoreAzureWebPubsubConnectionStatus = (typeof WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS)[WeaveStoreAzureWebPubsubConnectionStatusKeys];
489
+ type WeaveAzureWebPubsubConfig = {
490
+ endpoint: string;
491
+ key: string;
492
+ hubName: string;
493
+ };
494
+ type WeaveStoreAzureWebPubsubOptions = {
495
+ roomId: string;
496
+ url: string;
497
+ fetchClient?: FetchClient;
498
+ callbacks?: WeaveStoreAzureWebPubsubStoreCallbacks;
499
+ };
500
+ type WeaveStoreAzureWebPubsubStoreCallbacks = {
501
+ onFetchConnectionUrl?: (payload: {
502
+ loading: boolean;
503
+ error: Error | null;
504
+ }) => void;
505
+ onConnectionStatusChange?: (status: WeaveStoreAzureWebPubsubConnectionStatus) => void;
506
+ };
507
+ type FetchClient = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
508
+ type FetchInitialState = (doc: Y.Doc) => void;
509
+ type PersistRoom = (roomId: string, actualState: Uint8Array<ArrayBufferLike>) => Promise<void>;
510
+ type FetchRoom = (roomId: string) => Promise<Uint8Array | null>;
511
+
473
512
  //#endregion
474
513
  //#region src/client.d.ts
475
514
  interface ClientOptions {