@inditextech/weave-store-websockets 0.77.0 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inditextech/weave-store-websockets",
3
- "version": "0.77.0",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
@@ -42,6 +42,7 @@
42
42
  "link": "npm link",
43
43
  "lint:fix": "npm run lint -- --fix",
44
44
  "lint": "eslint ./src",
45
+ "pack": "npm pack",
45
46
  "publish:snapshot": "npm publish",
46
47
  "release:perform": "npm publish --access public",
47
48
  "release:prepare": "npm run verify",
@@ -53,13 +54,13 @@
53
54
  },
54
55
  "dependencies": {
55
56
  "@syncedstore/core": "0.6.0",
56
- "konva": "9.3.20",
57
+ "konva": "10.0.2",
57
58
  "ws": "8.18.1",
58
59
  "y-websocket": "3.0.0",
59
60
  "yjs": "13.6.27"
60
61
  },
61
62
  "devDependencies": {
62
- "@inditextech/weave-sdk": "0.77.0",
63
+ "@inditextech/weave-sdk": "1.0.0",
63
64
  "@types/express": "^5.0.1",
64
65
  "@types/ioredis": "^4.28.10",
65
66
  "@types/koa": "^2.15.0",
package/dist/client.cjs DELETED
@@ -1,119 +0,0 @@
1
- "use strict";
2
- //#region rolldown:runtime
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: true
22
- }) : target, mod));
23
-
24
- //#endregion
25
- const __inditextech_weave_sdk = __toESM(require("@inditextech/weave-sdk"));
26
- require("konva");
27
- require("yjs");
28
- require("http");
29
- const y_websocket = __toESM(require("y-websocket"));
30
-
31
- //#region ../types/dist/types.js
32
- const WEAVE_TRANSFORMER_ANCHORS = {
33
- ["TOP_LEFT"]: "top-left",
34
- ["TOP_CENTER"]: "top-center",
35
- ["TOP_RIGHT"]: "top-right",
36
- ["MIDDLE_RIGHT"]: "middle-right",
37
- ["MIDDLE_LEFT"]: "middle-left",
38
- ["BOTTOM_LEFT"]: "bottom-left",
39
- ["BOTTOM_CENTER"]: "bottom-center",
40
- ["BOTTOM_RIGHT"]: "bottom-right"
41
- };
42
- const WEAVE_DEFAULT_ENABLED_ANCHORS = Object.values(WEAVE_TRANSFORMER_ANCHORS);
43
- const WEAVE_STORE_CONNECTION_STATUS = {
44
- ["ERROR"]: "error",
45
- ["CONNECTING"]: "connecting",
46
- ["CONNECTED"]: "connected",
47
- ["DISCONNECTED"]: "disconnected"
48
- };
49
-
50
- //#endregion
51
- //#region src/constants.ts
52
- const WEAVE_STORE_WEBSOCKETS = "store-websockets";
53
-
54
- //#endregion
55
- //#region src/store-websockets.ts
56
- var WeaveStoreWebsockets = class extends __inditextech_weave_sdk.WeaveStore {
57
- name = WEAVE_STORE_WEBSOCKETS;
58
- supportsUndoManager = true;
59
- constructor(storeOptions, websocketOptions) {
60
- super(storeOptions);
61
- const { roomId } = websocketOptions;
62
- this.websocketOptions = websocketOptions;
63
- this.roomId = roomId;
64
- this.init();
65
- }
66
- init() {
67
- const { wsOptions: { serverUrl } } = this.websocketOptions;
68
- this.initialized = false;
69
- this.provider = new y_websocket.WebsocketProvider(serverUrl, this.roomId, this.getDocument(), {
70
- connect: false,
71
- disableBc: true
72
- });
73
- this.provider.on("status", ({ status }) => {
74
- this.handleConnectionStatusChange(status);
75
- if (!this.initialized && status === "connected") this.initialized = true;
76
- });
77
- this.provider.on("connection-close", () => {
78
- if (this.initialized) {
79
- this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.CONNECTING);
80
- return;
81
- }
82
- this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.DISCONNECTED);
83
- });
84
- this.provider.on("connection-error", () => {
85
- if (this.initialized) {
86
- this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.DISCONNECTED);
87
- return;
88
- }
89
- this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.ERROR);
90
- });
91
- }
92
- connect() {
93
- const awareness = this.provider.awareness;
94
- awareness.on("update", this.handleAwarenessChange.bind(this));
95
- awareness.on("change", this.handleAwarenessChange.bind(this));
96
- this.provider.connect();
97
- }
98
- disconnect() {
99
- const awareness = this.provider.awareness;
100
- awareness.destroy();
101
- awareness.off("update", this.handleAwarenessChange.bind(this));
102
- awareness.off("change", this.handleAwarenessChange.bind(this));
103
- this.provider.disconnect();
104
- }
105
- handleAwarenessChange(emit = true) {
106
- const awareness = this.provider.awareness;
107
- const values = Array.from(awareness.getStates().values());
108
- values.splice(awareness.clientID, 1);
109
- if (emit) this.instance.emitEvent("onAwarenessChange", values);
110
- }
111
- setAwarenessInfo(field, value) {
112
- const awareness = this.provider.awareness;
113
- awareness.setLocalStateField(field, value);
114
- }
115
- };
116
-
117
- //#endregion
118
- exports.WEAVE_STORE_WEBSOCKETS = WEAVE_STORE_WEBSOCKETS
119
- exports.WeaveStoreWebsockets = WeaveStoreWebsockets
package/dist/client.d.cts DELETED
@@ -1,61 +0,0 @@
1
- import { WeaveStore } from "@inditextech/weave-sdk";
2
- import "konva";
3
- import * as Y from "yjs";
4
- import "konva/lib/types";
5
- import { IncomingMessage } from "http";
6
- import { WebsocketProvider } from "y-websocket";
7
-
8
- //#region ../types/dist/types.d.ts
9
-
10
- //#endregion
11
- //#region src/base/store.d.ts
12
- type WeaveStoreOptions = {
13
- getUser: () => WeaveUser;
14
- undoManagerOptions?: WeaveUndoManagerOptions;
15
- };
16
- type WeaveUser = {
17
- id: string;
18
- name: string;
19
- email: string;
20
- [key: string]: any;
21
- };
22
- type WeaveUndoManagerOptions = {
23
- captureTimeout?: number;
24
- trackedOrigins?: Set<any>;
25
- }; //#endregion
26
- //#region src/types.d.ts
27
- type WeaveStoreWebsocketsOptions = {
28
- roomId: string;
29
- wsOptions: {
30
- serverUrl: string;
31
- };
32
- };
33
- type PerformUpgrade = (req: IncomingMessage) => Promise<boolean>;
34
- type ExtractRoomId = (req: IncomingMessage) => string | undefined;
35
- type FetchInitialState = (doc: Y.Doc) => void;
36
- type PersistRoom = (roomId: string, actualState: Uint8Array<ArrayBufferLike>) => Promise<void>;
37
- type FetchRoom = (roomId: string) => Promise<Uint8Array | null>;
38
-
39
- //#endregion
40
- //#region src/store-websockets.d.ts
41
- declare class WeaveStoreWebsockets extends WeaveStore {
42
- private websocketOptions;
43
- private roomId;
44
- private initialized;
45
- protected provider: WebsocketProvider;
46
- protected name: string;
47
- protected supportsUndoManager: boolean;
48
- constructor(storeOptions: WeaveStoreOptions, websocketOptions: WeaveStoreWebsocketsOptions);
49
- private init;
50
- connect(): void;
51
- disconnect(): void;
52
- handleAwarenessChange(emit?: boolean): void;
53
- setAwarenessInfo<T>(field: string, value: T): void;
54
- }
55
-
56
- //#endregion
57
- //#region src/constants.d.ts
58
- declare const WEAVE_STORE_WEBSOCKETS = "store-websockets";
59
-
60
- //#endregion
61
- export { ExtractRoomId, FetchInitialState, FetchRoom, PerformUpgrade, PersistRoom, WEAVE_STORE_WEBSOCKETS, WeaveStoreWebsockets, WeaveStoreWebsocketsOptions };