@inditextech/weave-store-standalone 1.0.4 → 1.1.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.ts +10 -219
- package/dist/client.js +9 -20
- package/dist/server.d.ts +10 -219
- package/dist/server.js +9 -20
- package/package.json +3 -3
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as Y$1 from "yjs";
|
|
2
|
-
import * as Y$2 from "yjs";
|
|
3
1
|
import * as Y from "yjs";
|
|
2
|
+
import { Doc } from "yjs";
|
|
3
|
+
import { DeepPartial, MappedTypeDescription, WeaveActionBase, WeaveConfig, WeaveElementAttributes, WeaveElementInstance, WeaveExportNodesOptions, WeaveFont, WeaveLoggerConfig, WeaveMousePointInfo, WeaveMousePointInfoSimple, WeaveNodeBase, WeaveNodeConfiguration, WeaveNodeFound, WeavePluginBase, WeavePosition, WeaveSelection, WeaveSerializedGroup, WeaveState, WeaveStateElement, WeaveStatus, WeaveStoreBase, WeaveStoreConnectionStatus, WeaveStoreOptions, WeaveUser } from "@inditextech/weave-types";
|
|
4
4
|
import Konva from "konva";
|
|
5
5
|
import pino, { Logger } from "pino";
|
|
6
6
|
import * as konva_lib_Node8 from "konva/lib/Node";
|
|
@@ -10,223 +10,33 @@ import * as konva_lib_Node11 from "konva/lib/Node";
|
|
|
10
10
|
import { KonvaEventObject } from "konva/lib/Node";
|
|
11
11
|
import { Stage, StageConfig } from "konva/lib/Stage";
|
|
12
12
|
import { TransformerConfig } from "konva/lib/shapes/Transformer";
|
|
13
|
-
import * as
|
|
13
|
+
import * as konva_lib_types6 from "konva/lib/types";
|
|
14
14
|
import "konva/lib/Group";
|
|
15
15
|
import "konva/lib/Layer";
|
|
16
16
|
|
|
17
17
|
//#region ../sdk/dist/sdk.node.d.ts
|
|
18
18
|
|
|
19
|
-
//#region ../types/dist/types.d.ts
|
|
20
|
-
//#region src/base/node.d.ts
|
|
21
|
-
interface WeaveNodeBase {
|
|
22
|
-
getNodeType(): string;
|
|
23
|
-
create(id: string, props: WeaveElementAttributes): WeaveStateElement;
|
|
24
|
-
onAdd?(nodeInstance: WeaveElementInstance): void;
|
|
25
|
-
onRender(props: WeaveElementAttributes): WeaveElementInstance;
|
|
26
|
-
onUpdate(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
|
|
27
|
-
onDestroy(instance: WeaveElementInstance): void;
|
|
28
|
-
serialize(instance: WeaveElementInstance): WeaveStateElement;
|
|
29
|
-
setupDefaultNodeAugmentation(node: Konva.Node): void;
|
|
30
|
-
setupDefaultNodeEvents(node: Konva.Node): void;
|
|
31
|
-
isNodeSelected(ele: Konva.Node): boolean;
|
|
32
|
-
lock(instance: Konva.Node): void;
|
|
33
|
-
unlock(instance: Konva.Node): void;
|
|
34
|
-
isLocked(instance: Konva.Node): boolean;
|
|
35
|
-
isSelecting(): boolean;
|
|
36
|
-
isPasting(): boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/base/action.d.ts
|
|
41
|
-
interface WeaveActionBase {
|
|
42
|
-
onInit?(): void;
|
|
43
|
-
trigger(cancelAction: () => void, params?: unknown): unknown;
|
|
44
|
-
internalUpdate?(): void;
|
|
45
|
-
cleanup?(): void;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/base/plugin.d.ts
|
|
50
|
-
interface WeavePluginBase {
|
|
51
|
-
onInit?(): void;
|
|
52
|
-
onRender?(): void;
|
|
53
|
-
enable(): void;
|
|
54
|
-
disable(): void;
|
|
55
|
-
isEnabled(): boolean;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/base/store.d.ts
|
|
60
|
-
type WeaveStoreOptions$1 = {
|
|
61
|
-
getUser: () => WeaveUser$1;
|
|
62
|
-
undoManagerOptions?: WeaveUndoManagerOptions$1;
|
|
63
|
-
};
|
|
64
|
-
interface WeaveStoreBase {
|
|
65
|
-
connect(): void;
|
|
66
|
-
disconnect(): void;
|
|
67
|
-
handleAwarenessChange(emit: boolean): void;
|
|
68
|
-
setAwarenessInfo(field: string, value: unknown): void;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/types.d.ts
|
|
73
|
-
type WeaveFontsPreloadFunction = () => Promise<WeaveFont[]>;
|
|
74
|
-
type WeaveConfig = {
|
|
75
|
-
store: WeaveStoreBase;
|
|
76
|
-
nodes?: WeaveNodeBase[];
|
|
77
|
-
actions?: WeaveActionBase[];
|
|
78
|
-
plugins?: WeavePluginBase[];
|
|
79
|
-
fonts?: WeaveFont[] | WeaveFontsPreloadFunction;
|
|
80
|
-
logger?: WeaveLoggerConfig;
|
|
81
|
-
serverSide?: boolean;
|
|
82
|
-
};
|
|
83
|
-
type WeaveStatusKeys = keyof typeof WEAVE_INSTANCE_STATUS;
|
|
84
|
-
type WeaveStatus = (typeof WEAVE_INSTANCE_STATUS)[WeaveStatusKeys];
|
|
85
|
-
type WeaveElementAttributes = {
|
|
86
|
-
[key: string]: any;
|
|
87
|
-
id?: string;
|
|
88
|
-
nodeType?: string;
|
|
89
|
-
children?: WeaveStateElement[];
|
|
90
|
-
};
|
|
91
|
-
type WeaveStateElement = {
|
|
92
|
-
key: string;
|
|
93
|
-
type: string;
|
|
94
|
-
props: WeaveElementAttributes;
|
|
95
|
-
};
|
|
96
|
-
type WeaveState = {
|
|
97
|
-
weave: {
|
|
98
|
-
key: "stage";
|
|
99
|
-
type: "stage";
|
|
100
|
-
props: {
|
|
101
|
-
[key: string]: unknown;
|
|
102
|
-
id: "stage";
|
|
103
|
-
children: WeaveStateElement[];
|
|
104
|
-
};
|
|
105
|
-
} | Record<string, WeaveStateElement>;
|
|
106
|
-
};
|
|
107
|
-
type WeaveSelection = {
|
|
108
|
-
instance: Konva.Shape | Konva.Group;
|
|
109
|
-
node: WeaveStateElement | undefined;
|
|
110
|
-
};
|
|
111
|
-
type WeaveMousePointInfoSimple = {
|
|
112
|
-
mousePoint: Konva.Vector2d;
|
|
113
|
-
container: Konva.Layer | Konva.Node | undefined;
|
|
114
|
-
};
|
|
115
|
-
type WeaveMousePointInfo = WeaveMousePointInfoSimple & {
|
|
116
|
-
measureContainer: Konva.Layer | Konva.Group | undefined;
|
|
117
|
-
};
|
|
118
|
-
type WeaveSerializedGroup = {
|
|
119
|
-
serializedNodes: WeaveStateElement[];
|
|
120
|
-
minPoint: Konva.Vector2d;
|
|
121
|
-
} | undefined;
|
|
122
|
-
type WeaveNodeFound = {
|
|
123
|
-
node: WeaveStateElement | null;
|
|
124
|
-
parent: WeaveStateElement | null;
|
|
125
|
-
index: number;
|
|
126
|
-
};
|
|
127
|
-
type WeaveElementInstance = Konva.Layer | Konva.Group | Konva.Shape;
|
|
128
|
-
type WeaveLoggerConfig = {
|
|
129
|
-
disabled?: boolean;
|
|
130
|
-
level?: "debug" | "info" | "warn" | "error";
|
|
131
|
-
};
|
|
132
|
-
type WeavePositionKeys = keyof typeof WEAVE_NODE_POSITION;
|
|
133
|
-
type WeavePosition = (typeof WEAVE_NODE_POSITION)[WeavePositionKeys];
|
|
134
|
-
type WeaveExportFormatsKeys = keyof typeof WEAVE_EXPORT_FORMATS;
|
|
135
|
-
type WeaveExportFormats = (typeof WEAVE_EXPORT_FORMATS)[WeaveExportFormatsKeys];
|
|
136
|
-
type WeaveExportNodesOptions = {
|
|
137
|
-
format?: WeaveExportFormats;
|
|
138
|
-
padding?: number;
|
|
139
|
-
pixelRatio?: number;
|
|
140
|
-
backgroundColor?: string;
|
|
141
|
-
quality?: number;
|
|
142
|
-
backend?: WeaveKonvaBackend;
|
|
143
|
-
};
|
|
144
|
-
type WeaveUser$1 = {
|
|
145
|
-
id: string;
|
|
146
|
-
name: string;
|
|
147
|
-
email: string;
|
|
148
|
-
[key: string]: any;
|
|
149
|
-
};
|
|
150
|
-
type WeaveFont = {
|
|
151
|
-
id: string;
|
|
152
|
-
name: string;
|
|
153
|
-
offsetX?: number;
|
|
154
|
-
offsetY?: number;
|
|
155
|
-
};
|
|
156
|
-
type WeaveUndoManagerOptions$1 = {
|
|
157
|
-
captureTimeout?: number;
|
|
158
|
-
trackedOrigins?: Set<any>;
|
|
159
|
-
};
|
|
160
|
-
type WeaveStoreConnectionStatusKeys = keyof typeof WEAVE_STORE_CONNECTION_STATUS;
|
|
161
|
-
type WeaveStoreConnectionStatus = (typeof WEAVE_STORE_CONNECTION_STATUS)[WeaveStoreConnectionStatusKeys];
|
|
162
|
-
declare type docElementTypeDescription = "xml" | "text" | Array<any> | object;
|
|
163
|
-
declare type DocTypeDescription = {
|
|
164
|
-
[key: string]: docElementTypeDescription;
|
|
165
|
-
};
|
|
166
|
-
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 };
|
|
167
|
-
type WeaveNodeTransformerProperties = Konva.TransformerConfig;
|
|
168
|
-
type WeaveNodeConfiguration = {
|
|
169
|
-
transform: Partial<WeaveNodeTransformerProperties>;
|
|
170
|
-
};
|
|
171
|
-
type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? T[P] extends Function ? T[P] : DeepPartial<T[P]> : T[P] };
|
|
172
|
-
type WeaveKonvaBackendKeys = keyof typeof WEAVE_KONVA_BACKEND;
|
|
173
|
-
type WeaveKonvaBackend = (typeof WEAVE_KONVA_BACKEND)[WeaveKonvaBackendKeys];
|
|
174
|
-
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region src/constants.d.ts
|
|
177
|
-
|
|
178
|
-
declare const WEAVE_INSTANCE_STATUS: {
|
|
179
|
-
readonly "IDLE": "idle";
|
|
180
|
-
readonly "STARTING": "starting";
|
|
181
|
-
readonly "LOADING_FONTS": "loadingFonts";
|
|
182
|
-
readonly "CONNECTING_TO_ROOM": "connectingToRoom";
|
|
183
|
-
readonly "CONNECTING_ERROR": "connectingError";
|
|
184
|
-
readonly "LOADING_ROOM": "loadingRoom";
|
|
185
|
-
readonly "RUNNING": "running";
|
|
186
|
-
};
|
|
187
|
-
declare const WEAVE_NODE_POSITION: {
|
|
188
|
-
readonly "UP": "up";
|
|
189
|
-
readonly "DOWN": "down";
|
|
190
|
-
readonly "FRONT": "front";
|
|
191
|
-
readonly "BACK": "back";
|
|
192
|
-
};
|
|
193
|
-
declare const WEAVE_EXPORT_FORMATS: {
|
|
194
|
-
readonly "PNG": "image/png";
|
|
195
|
-
readonly "JPEG": "image/jpeg";
|
|
196
|
-
};
|
|
197
|
-
declare const WEAVE_STORE_CONNECTION_STATUS: {
|
|
198
|
-
readonly "ERROR": "error";
|
|
199
|
-
readonly "CONNECTING": "connecting";
|
|
200
|
-
readonly "CONNECTED": "connected";
|
|
201
|
-
readonly "DISCONNECTED": "disconnected";
|
|
202
|
-
};
|
|
203
|
-
declare const WEAVE_KONVA_BACKEND: {
|
|
204
|
-
readonly "CANVAS": "canvas";
|
|
205
|
-
readonly "SKIA": "skia";
|
|
206
|
-
}; //#endregion
|
|
207
19
|
//#region src/stores/store.d.ts
|
|
208
|
-
|
|
209
|
-
//#endregion
|
|
210
20
|
declare abstract class WeaveStore implements WeaveStoreBase {
|
|
211
21
|
protected instance: Weave;
|
|
212
22
|
protected name: string;
|
|
213
23
|
protected supportsUndoManager: boolean;
|
|
214
|
-
protected config: WeaveStoreOptions
|
|
24
|
+
protected config: WeaveStoreOptions;
|
|
215
25
|
private state;
|
|
216
26
|
private latestState;
|
|
217
27
|
private document;
|
|
218
28
|
private logger;
|
|
219
29
|
private undoManager;
|
|
220
30
|
private isRoomLoaded;
|
|
221
|
-
constructor(config: WeaveStoreOptions
|
|
31
|
+
constructor(config: WeaveStoreOptions);
|
|
222
32
|
getName(): string;
|
|
223
33
|
getLogger(): Logger;
|
|
224
34
|
register(instance: Weave): WeaveStore;
|
|
225
|
-
getUser(): WeaveUser
|
|
35
|
+
getUser(): WeaveUser;
|
|
226
36
|
setState(state: WeaveState): void;
|
|
227
37
|
setLatestState(newState: WeaveState): void;
|
|
228
38
|
getLatestState(): WeaveState;
|
|
229
|
-
getDocument(): Y
|
|
39
|
+
getDocument(): Y.Doc;
|
|
230
40
|
getState(): MappedTypeDescription<WeaveState>;
|
|
231
41
|
getStateJson(): WeaveState;
|
|
232
42
|
getStateSnapshot(): Uint8Array;
|
|
@@ -664,7 +474,7 @@ declare class WeaveStagePanningPlugin extends WeavePlugin {
|
|
|
664
474
|
getNodesEdgeSnappingPlugin(): WeaveNodesEdgeSnappingPlugin | undefined;
|
|
665
475
|
getNodesDistanceSnappingPlugin(): WeaveNodesDistanceSnappingPlugin | undefined;
|
|
666
476
|
getStageGridPlugin(): WeaveStageGridPlugin | undefined;
|
|
667
|
-
getCurrentPointer():
|
|
477
|
+
getCurrentPointer(): konva_lib_types6.Vector2d | null;
|
|
668
478
|
cleanupEdgeMoveIntervals(): void;
|
|
669
479
|
enable(): void;
|
|
670
480
|
disable(): void;
|
|
@@ -1058,31 +868,12 @@ declare class Weave {
|
|
|
1058
868
|
resolveAsyncElement(nodeId: string, type: string): void;
|
|
1059
869
|
isServerSide(): boolean;
|
|
1060
870
|
} //#endregion
|
|
1061
|
-
//#region
|
|
871
|
+
//#region src/types.d.ts
|
|
1062
872
|
|
|
1063
873
|
//#endregion
|
|
1064
874
|
//#region src/stores/types.d.ts
|
|
1065
875
|
//# sourceMappingURL=weave.d.ts.map
|
|
1066
|
-
|
|
1067
|
-
//#region src/base/store.d.ts
|
|
1068
|
-
type WeaveStoreOptions = {
|
|
1069
|
-
getUser: () => WeaveUser;
|
|
1070
|
-
undoManagerOptions?: WeaveUndoManagerOptions;
|
|
1071
|
-
};
|
|
1072
|
-
type WeaveUser = {
|
|
1073
|
-
id: string;
|
|
1074
|
-
name: string;
|
|
1075
|
-
email: string;
|
|
1076
|
-
[key: string]: any;
|
|
1077
|
-
};
|
|
1078
|
-
type WeaveUndoManagerOptions = {
|
|
1079
|
-
captureTimeout?: number;
|
|
1080
|
-
trackedOrigins?: Set<any>;
|
|
1081
|
-
};
|
|
1082
|
-
|
|
1083
|
-
//#endregion
|
|
1084
|
-
//#region src/types.d.ts
|
|
1085
|
-
type FetchInitialState = (doc: Y.Doc) => void;
|
|
876
|
+
type FetchInitialState = (doc: Doc) => void;
|
|
1086
877
|
type WeaveStoreStandaloneParams = {
|
|
1087
878
|
roomData: string;
|
|
1088
879
|
initialState?: FetchInitialState;
|
package/dist/client.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import * as Y$1 from "yjs";
|
|
2
1
|
import * as Y from "yjs";
|
|
3
2
|
import { WeaveStore } from "@inditextech/weave-sdk/server";
|
|
4
|
-
import
|
|
3
|
+
import "@inditextech/weave-types";
|
|
5
4
|
|
|
6
|
-
//#region
|
|
7
|
-
|
|
8
|
-
["TOP_LEFT"]: "top-left",
|
|
9
|
-
["TOP_CENTER"]: "top-center",
|
|
10
|
-
["TOP_RIGHT"]: "top-right",
|
|
11
|
-
["MIDDLE_RIGHT"]: "middle-right",
|
|
12
|
-
["MIDDLE_LEFT"]: "middle-left",
|
|
13
|
-
["BOTTOM_LEFT"]: "bottom-left",
|
|
14
|
-
["BOTTOM_CENTER"]: "bottom-center",
|
|
15
|
-
["BOTTOM_RIGHT"]: "bottom-right"
|
|
16
|
-
};
|
|
17
|
-
const WEAVE_DEFAULT_ENABLED_ANCHORS = Object.values(WEAVE_TRANSFORMER_ANCHORS);
|
|
5
|
+
//#region src/yjs.ts
|
|
6
|
+
var yjs_default = Y;
|
|
18
7
|
|
|
19
8
|
//#endregion
|
|
20
9
|
//#region src/constants.ts
|
|
@@ -23,18 +12,18 @@ const WEAVE_STORE_STANDALONE = "store-standalone";
|
|
|
23
12
|
//#endregion
|
|
24
13
|
//#region src/default-initial-state.ts
|
|
25
14
|
const yjsLayer = function(id) {
|
|
26
|
-
const newLayerMap = new
|
|
15
|
+
const newLayerMap = new yjs_default.Map();
|
|
27
16
|
newLayerMap.set("key", id);
|
|
28
17
|
newLayerMap.set("type", "layer");
|
|
29
|
-
const newLayerMapProps = new
|
|
18
|
+
const newLayerMapProps = new yjs_default.Map();
|
|
30
19
|
newLayerMapProps.set("id", id);
|
|
31
20
|
newLayerMapProps.set("nodeType", "layer");
|
|
32
|
-
newLayerMapProps.set("children", new
|
|
21
|
+
newLayerMapProps.set("children", new yjs_default.Array());
|
|
33
22
|
newLayerMap.set("props", newLayerMapProps);
|
|
34
23
|
return newLayerMap;
|
|
35
24
|
};
|
|
36
25
|
function defaultInitialState(doc) {
|
|
37
|
-
const children = new
|
|
26
|
+
const children = new yjs_default.Array();
|
|
38
27
|
children.insert(0, [
|
|
39
28
|
yjsLayer("gridLayer"),
|
|
40
29
|
yjsLayer("mainLayer"),
|
|
@@ -42,7 +31,7 @@ function defaultInitialState(doc) {
|
|
|
42
31
|
yjsLayer("usersPointersLayer"),
|
|
43
32
|
yjsLayer("utilityLayer")
|
|
44
33
|
]);
|
|
45
|
-
const stageProps = new
|
|
34
|
+
const stageProps = new yjs_default.Map();
|
|
46
35
|
stageProps.set("id", "stage");
|
|
47
36
|
stageProps.set("children", children);
|
|
48
37
|
doc.getMap("weave").set("key", "stage");
|
|
@@ -62,7 +51,7 @@ var WeaveStoreStandalone = class extends WeaveStore {
|
|
|
62
51
|
}
|
|
63
52
|
async connect() {
|
|
64
53
|
const roomDataSnapshot = Buffer.from(this.roomData, "base64");
|
|
65
|
-
if (roomDataSnapshot)
|
|
54
|
+
if (roomDataSnapshot) yjs_default.applyUpdate(this.getDocument(), roomDataSnapshot);
|
|
66
55
|
else this.initialState(this.getDocument());
|
|
67
56
|
}
|
|
68
57
|
disconnect() {}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as Y$1 from "yjs";
|
|
2
|
-
import * as Y$2 from "yjs";
|
|
3
1
|
import * as Y from "yjs";
|
|
2
|
+
import { Doc } from "yjs";
|
|
3
|
+
import { DeepPartial, MappedTypeDescription, WeaveActionBase, WeaveConfig, WeaveElementAttributes, WeaveElementInstance, WeaveExportNodesOptions, WeaveFont, WeaveLoggerConfig, WeaveMousePointInfo, WeaveMousePointInfoSimple, WeaveNodeBase, WeaveNodeConfiguration, WeaveNodeFound, WeavePluginBase, WeavePosition, WeaveSelection, WeaveSerializedGroup, WeaveState, WeaveStateElement, WeaveStatus, WeaveStoreBase, WeaveStoreConnectionStatus, WeaveStoreOptions, WeaveUser } from "@inditextech/weave-types";
|
|
4
4
|
import Konva from "konva";
|
|
5
5
|
import pino, { Logger } from "pino";
|
|
6
6
|
import * as konva_lib_Node8 from "konva/lib/Node";
|
|
@@ -10,223 +10,33 @@ import * as konva_lib_Node11 from "konva/lib/Node";
|
|
|
10
10
|
import { KonvaEventObject } from "konva/lib/Node";
|
|
11
11
|
import { Stage, StageConfig } from "konva/lib/Stage";
|
|
12
12
|
import { TransformerConfig } from "konva/lib/shapes/Transformer";
|
|
13
|
-
import * as
|
|
13
|
+
import * as konva_lib_types6 from "konva/lib/types";
|
|
14
14
|
import "konva/lib/Group";
|
|
15
15
|
import "konva/lib/Layer";
|
|
16
16
|
|
|
17
17
|
//#region ../sdk/dist/sdk.node.d.ts
|
|
18
18
|
|
|
19
|
-
//#region ../types/dist/types.d.ts
|
|
20
|
-
//#region src/base/node.d.ts
|
|
21
|
-
interface WeaveNodeBase {
|
|
22
|
-
getNodeType(): string;
|
|
23
|
-
create(id: string, props: WeaveElementAttributes): WeaveStateElement;
|
|
24
|
-
onAdd?(nodeInstance: WeaveElementInstance): void;
|
|
25
|
-
onRender(props: WeaveElementAttributes): WeaveElementInstance;
|
|
26
|
-
onUpdate(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
|
|
27
|
-
onDestroy(instance: WeaveElementInstance): void;
|
|
28
|
-
serialize(instance: WeaveElementInstance): WeaveStateElement;
|
|
29
|
-
setupDefaultNodeAugmentation(node: Konva.Node): void;
|
|
30
|
-
setupDefaultNodeEvents(node: Konva.Node): void;
|
|
31
|
-
isNodeSelected(ele: Konva.Node): boolean;
|
|
32
|
-
lock(instance: Konva.Node): void;
|
|
33
|
-
unlock(instance: Konva.Node): void;
|
|
34
|
-
isLocked(instance: Konva.Node): boolean;
|
|
35
|
-
isSelecting(): boolean;
|
|
36
|
-
isPasting(): boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/base/action.d.ts
|
|
41
|
-
interface WeaveActionBase {
|
|
42
|
-
onInit?(): void;
|
|
43
|
-
trigger(cancelAction: () => void, params?: unknown): unknown;
|
|
44
|
-
internalUpdate?(): void;
|
|
45
|
-
cleanup?(): void;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/base/plugin.d.ts
|
|
50
|
-
interface WeavePluginBase {
|
|
51
|
-
onInit?(): void;
|
|
52
|
-
onRender?(): void;
|
|
53
|
-
enable(): void;
|
|
54
|
-
disable(): void;
|
|
55
|
-
isEnabled(): boolean;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/base/store.d.ts
|
|
60
|
-
type WeaveStoreOptions$1 = {
|
|
61
|
-
getUser: () => WeaveUser$1;
|
|
62
|
-
undoManagerOptions?: WeaveUndoManagerOptions$1;
|
|
63
|
-
};
|
|
64
|
-
interface WeaveStoreBase {
|
|
65
|
-
connect(): void;
|
|
66
|
-
disconnect(): void;
|
|
67
|
-
handleAwarenessChange(emit: boolean): void;
|
|
68
|
-
setAwarenessInfo(field: string, value: unknown): void;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/types.d.ts
|
|
73
|
-
type WeaveFontsPreloadFunction = () => Promise<WeaveFont[]>;
|
|
74
|
-
type WeaveConfig = {
|
|
75
|
-
store: WeaveStoreBase;
|
|
76
|
-
nodes?: WeaveNodeBase[];
|
|
77
|
-
actions?: WeaveActionBase[];
|
|
78
|
-
plugins?: WeavePluginBase[];
|
|
79
|
-
fonts?: WeaveFont[] | WeaveFontsPreloadFunction;
|
|
80
|
-
logger?: WeaveLoggerConfig;
|
|
81
|
-
serverSide?: boolean;
|
|
82
|
-
};
|
|
83
|
-
type WeaveStatusKeys = keyof typeof WEAVE_INSTANCE_STATUS;
|
|
84
|
-
type WeaveStatus = (typeof WEAVE_INSTANCE_STATUS)[WeaveStatusKeys];
|
|
85
|
-
type WeaveElementAttributes = {
|
|
86
|
-
[key: string]: any;
|
|
87
|
-
id?: string;
|
|
88
|
-
nodeType?: string;
|
|
89
|
-
children?: WeaveStateElement[];
|
|
90
|
-
};
|
|
91
|
-
type WeaveStateElement = {
|
|
92
|
-
key: string;
|
|
93
|
-
type: string;
|
|
94
|
-
props: WeaveElementAttributes;
|
|
95
|
-
};
|
|
96
|
-
type WeaveState = {
|
|
97
|
-
weave: {
|
|
98
|
-
key: "stage";
|
|
99
|
-
type: "stage";
|
|
100
|
-
props: {
|
|
101
|
-
[key: string]: unknown;
|
|
102
|
-
id: "stage";
|
|
103
|
-
children: WeaveStateElement[];
|
|
104
|
-
};
|
|
105
|
-
} | Record<string, WeaveStateElement>;
|
|
106
|
-
};
|
|
107
|
-
type WeaveSelection = {
|
|
108
|
-
instance: Konva.Shape | Konva.Group;
|
|
109
|
-
node: WeaveStateElement | undefined;
|
|
110
|
-
};
|
|
111
|
-
type WeaveMousePointInfoSimple = {
|
|
112
|
-
mousePoint: Konva.Vector2d;
|
|
113
|
-
container: Konva.Layer | Konva.Node | undefined;
|
|
114
|
-
};
|
|
115
|
-
type WeaveMousePointInfo = WeaveMousePointInfoSimple & {
|
|
116
|
-
measureContainer: Konva.Layer | Konva.Group | undefined;
|
|
117
|
-
};
|
|
118
|
-
type WeaveSerializedGroup = {
|
|
119
|
-
serializedNodes: WeaveStateElement[];
|
|
120
|
-
minPoint: Konva.Vector2d;
|
|
121
|
-
} | undefined;
|
|
122
|
-
type WeaveNodeFound = {
|
|
123
|
-
node: WeaveStateElement | null;
|
|
124
|
-
parent: WeaveStateElement | null;
|
|
125
|
-
index: number;
|
|
126
|
-
};
|
|
127
|
-
type WeaveElementInstance = Konva.Layer | Konva.Group | Konva.Shape;
|
|
128
|
-
type WeaveLoggerConfig = {
|
|
129
|
-
disabled?: boolean;
|
|
130
|
-
level?: "debug" | "info" | "warn" | "error";
|
|
131
|
-
};
|
|
132
|
-
type WeavePositionKeys = keyof typeof WEAVE_NODE_POSITION;
|
|
133
|
-
type WeavePosition = (typeof WEAVE_NODE_POSITION)[WeavePositionKeys];
|
|
134
|
-
type WeaveExportFormatsKeys = keyof typeof WEAVE_EXPORT_FORMATS;
|
|
135
|
-
type WeaveExportFormats = (typeof WEAVE_EXPORT_FORMATS)[WeaveExportFormatsKeys];
|
|
136
|
-
type WeaveExportNodesOptions = {
|
|
137
|
-
format?: WeaveExportFormats;
|
|
138
|
-
padding?: number;
|
|
139
|
-
pixelRatio?: number;
|
|
140
|
-
backgroundColor?: string;
|
|
141
|
-
quality?: number;
|
|
142
|
-
backend?: WeaveKonvaBackend;
|
|
143
|
-
};
|
|
144
|
-
type WeaveUser$1 = {
|
|
145
|
-
id: string;
|
|
146
|
-
name: string;
|
|
147
|
-
email: string;
|
|
148
|
-
[key: string]: any;
|
|
149
|
-
};
|
|
150
|
-
type WeaveFont = {
|
|
151
|
-
id: string;
|
|
152
|
-
name: string;
|
|
153
|
-
offsetX?: number;
|
|
154
|
-
offsetY?: number;
|
|
155
|
-
};
|
|
156
|
-
type WeaveUndoManagerOptions$1 = {
|
|
157
|
-
captureTimeout?: number;
|
|
158
|
-
trackedOrigins?: Set<any>;
|
|
159
|
-
};
|
|
160
|
-
type WeaveStoreConnectionStatusKeys = keyof typeof WEAVE_STORE_CONNECTION_STATUS;
|
|
161
|
-
type WeaveStoreConnectionStatus = (typeof WEAVE_STORE_CONNECTION_STATUS)[WeaveStoreConnectionStatusKeys];
|
|
162
|
-
declare type docElementTypeDescription = "xml" | "text" | Array<any> | object;
|
|
163
|
-
declare type DocTypeDescription = {
|
|
164
|
-
[key: string]: docElementTypeDescription;
|
|
165
|
-
};
|
|
166
|
-
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 };
|
|
167
|
-
type WeaveNodeTransformerProperties = Konva.TransformerConfig;
|
|
168
|
-
type WeaveNodeConfiguration = {
|
|
169
|
-
transform: Partial<WeaveNodeTransformerProperties>;
|
|
170
|
-
};
|
|
171
|
-
type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? T[P] extends Function ? T[P] : DeepPartial<T[P]> : T[P] };
|
|
172
|
-
type WeaveKonvaBackendKeys = keyof typeof WEAVE_KONVA_BACKEND;
|
|
173
|
-
type WeaveKonvaBackend = (typeof WEAVE_KONVA_BACKEND)[WeaveKonvaBackendKeys];
|
|
174
|
-
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region src/constants.d.ts
|
|
177
|
-
|
|
178
|
-
declare const WEAVE_INSTANCE_STATUS: {
|
|
179
|
-
readonly "IDLE": "idle";
|
|
180
|
-
readonly "STARTING": "starting";
|
|
181
|
-
readonly "LOADING_FONTS": "loadingFonts";
|
|
182
|
-
readonly "CONNECTING_TO_ROOM": "connectingToRoom";
|
|
183
|
-
readonly "CONNECTING_ERROR": "connectingError";
|
|
184
|
-
readonly "LOADING_ROOM": "loadingRoom";
|
|
185
|
-
readonly "RUNNING": "running";
|
|
186
|
-
};
|
|
187
|
-
declare const WEAVE_NODE_POSITION: {
|
|
188
|
-
readonly "UP": "up";
|
|
189
|
-
readonly "DOWN": "down";
|
|
190
|
-
readonly "FRONT": "front";
|
|
191
|
-
readonly "BACK": "back";
|
|
192
|
-
};
|
|
193
|
-
declare const WEAVE_EXPORT_FORMATS: {
|
|
194
|
-
readonly "PNG": "image/png";
|
|
195
|
-
readonly "JPEG": "image/jpeg";
|
|
196
|
-
};
|
|
197
|
-
declare const WEAVE_STORE_CONNECTION_STATUS: {
|
|
198
|
-
readonly "ERROR": "error";
|
|
199
|
-
readonly "CONNECTING": "connecting";
|
|
200
|
-
readonly "CONNECTED": "connected";
|
|
201
|
-
readonly "DISCONNECTED": "disconnected";
|
|
202
|
-
};
|
|
203
|
-
declare const WEAVE_KONVA_BACKEND: {
|
|
204
|
-
readonly "CANVAS": "canvas";
|
|
205
|
-
readonly "SKIA": "skia";
|
|
206
|
-
}; //#endregion
|
|
207
19
|
//#region src/stores/store.d.ts
|
|
208
|
-
|
|
209
|
-
//#endregion
|
|
210
20
|
declare abstract class WeaveStore implements WeaveStoreBase {
|
|
211
21
|
protected instance: Weave;
|
|
212
22
|
protected name: string;
|
|
213
23
|
protected supportsUndoManager: boolean;
|
|
214
|
-
protected config: WeaveStoreOptions
|
|
24
|
+
protected config: WeaveStoreOptions;
|
|
215
25
|
private state;
|
|
216
26
|
private latestState;
|
|
217
27
|
private document;
|
|
218
28
|
private logger;
|
|
219
29
|
private undoManager;
|
|
220
30
|
private isRoomLoaded;
|
|
221
|
-
constructor(config: WeaveStoreOptions
|
|
31
|
+
constructor(config: WeaveStoreOptions);
|
|
222
32
|
getName(): string;
|
|
223
33
|
getLogger(): Logger;
|
|
224
34
|
register(instance: Weave): WeaveStore;
|
|
225
|
-
getUser(): WeaveUser
|
|
35
|
+
getUser(): WeaveUser;
|
|
226
36
|
setState(state: WeaveState): void;
|
|
227
37
|
setLatestState(newState: WeaveState): void;
|
|
228
38
|
getLatestState(): WeaveState;
|
|
229
|
-
getDocument(): Y
|
|
39
|
+
getDocument(): Y.Doc;
|
|
230
40
|
getState(): MappedTypeDescription<WeaveState>;
|
|
231
41
|
getStateJson(): WeaveState;
|
|
232
42
|
getStateSnapshot(): Uint8Array;
|
|
@@ -664,7 +474,7 @@ declare class WeaveStagePanningPlugin extends WeavePlugin {
|
|
|
664
474
|
getNodesEdgeSnappingPlugin(): WeaveNodesEdgeSnappingPlugin | undefined;
|
|
665
475
|
getNodesDistanceSnappingPlugin(): WeaveNodesDistanceSnappingPlugin | undefined;
|
|
666
476
|
getStageGridPlugin(): WeaveStageGridPlugin | undefined;
|
|
667
|
-
getCurrentPointer():
|
|
477
|
+
getCurrentPointer(): konva_lib_types6.Vector2d | null;
|
|
668
478
|
cleanupEdgeMoveIntervals(): void;
|
|
669
479
|
enable(): void;
|
|
670
480
|
disable(): void;
|
|
@@ -1058,31 +868,12 @@ declare class Weave {
|
|
|
1058
868
|
resolveAsyncElement(nodeId: string, type: string): void;
|
|
1059
869
|
isServerSide(): boolean;
|
|
1060
870
|
} //#endregion
|
|
1061
|
-
//#region
|
|
871
|
+
//#region src/types.d.ts
|
|
1062
872
|
|
|
1063
873
|
//#endregion
|
|
1064
874
|
//#region src/stores/types.d.ts
|
|
1065
875
|
//# sourceMappingURL=weave.d.ts.map
|
|
1066
|
-
|
|
1067
|
-
//#region src/base/store.d.ts
|
|
1068
|
-
type WeaveStoreOptions = {
|
|
1069
|
-
getUser: () => WeaveUser;
|
|
1070
|
-
undoManagerOptions?: WeaveUndoManagerOptions;
|
|
1071
|
-
};
|
|
1072
|
-
type WeaveUser = {
|
|
1073
|
-
id: string;
|
|
1074
|
-
name: string;
|
|
1075
|
-
email: string;
|
|
1076
|
-
[key: string]: any;
|
|
1077
|
-
};
|
|
1078
|
-
type WeaveUndoManagerOptions = {
|
|
1079
|
-
captureTimeout?: number;
|
|
1080
|
-
trackedOrigins?: Set<any>;
|
|
1081
|
-
};
|
|
1082
|
-
|
|
1083
|
-
//#endregion
|
|
1084
|
-
//#region src/types.d.ts
|
|
1085
|
-
type FetchInitialState = (doc: Y.Doc) => void;
|
|
876
|
+
type FetchInitialState = (doc: Doc) => void;
|
|
1086
877
|
type WeaveStoreStandaloneParams = {
|
|
1087
878
|
roomData: string;
|
|
1088
879
|
initialState?: FetchInitialState;
|
package/dist/server.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import * as Y$1 from "yjs";
|
|
2
1
|
import * as Y from "yjs";
|
|
3
2
|
import { WeaveStore } from "@inditextech/weave-sdk/server";
|
|
4
|
-
import
|
|
3
|
+
import "@inditextech/weave-types";
|
|
5
4
|
|
|
6
|
-
//#region
|
|
7
|
-
|
|
8
|
-
["TOP_LEFT"]: "top-left",
|
|
9
|
-
["TOP_CENTER"]: "top-center",
|
|
10
|
-
["TOP_RIGHT"]: "top-right",
|
|
11
|
-
["MIDDLE_RIGHT"]: "middle-right",
|
|
12
|
-
["MIDDLE_LEFT"]: "middle-left",
|
|
13
|
-
["BOTTOM_LEFT"]: "bottom-left",
|
|
14
|
-
["BOTTOM_CENTER"]: "bottom-center",
|
|
15
|
-
["BOTTOM_RIGHT"]: "bottom-right"
|
|
16
|
-
};
|
|
17
|
-
const WEAVE_DEFAULT_ENABLED_ANCHORS = Object.values(WEAVE_TRANSFORMER_ANCHORS);
|
|
5
|
+
//#region src/yjs.ts
|
|
6
|
+
var yjs_default = Y;
|
|
18
7
|
|
|
19
8
|
//#endregion
|
|
20
9
|
//#region src/constants.ts
|
|
@@ -23,18 +12,18 @@ const WEAVE_STORE_STANDALONE = "store-standalone";
|
|
|
23
12
|
//#endregion
|
|
24
13
|
//#region src/default-initial-state.ts
|
|
25
14
|
const yjsLayer = function(id) {
|
|
26
|
-
const newLayerMap = new
|
|
15
|
+
const newLayerMap = new yjs_default.Map();
|
|
27
16
|
newLayerMap.set("key", id);
|
|
28
17
|
newLayerMap.set("type", "layer");
|
|
29
|
-
const newLayerMapProps = new
|
|
18
|
+
const newLayerMapProps = new yjs_default.Map();
|
|
30
19
|
newLayerMapProps.set("id", id);
|
|
31
20
|
newLayerMapProps.set("nodeType", "layer");
|
|
32
|
-
newLayerMapProps.set("children", new
|
|
21
|
+
newLayerMapProps.set("children", new yjs_default.Array());
|
|
33
22
|
newLayerMap.set("props", newLayerMapProps);
|
|
34
23
|
return newLayerMap;
|
|
35
24
|
};
|
|
36
25
|
function defaultInitialState(doc) {
|
|
37
|
-
const children = new
|
|
26
|
+
const children = new yjs_default.Array();
|
|
38
27
|
children.insert(0, [
|
|
39
28
|
yjsLayer("gridLayer"),
|
|
40
29
|
yjsLayer("mainLayer"),
|
|
@@ -42,7 +31,7 @@ function defaultInitialState(doc) {
|
|
|
42
31
|
yjsLayer("usersPointersLayer"),
|
|
43
32
|
yjsLayer("utilityLayer")
|
|
44
33
|
]);
|
|
45
|
-
const stageProps = new
|
|
34
|
+
const stageProps = new yjs_default.Map();
|
|
46
35
|
stageProps.set("id", "stage");
|
|
47
36
|
stageProps.set("children", children);
|
|
48
37
|
doc.getMap("weave").set("key", "stage");
|
|
@@ -62,7 +51,7 @@ var WeaveStoreStandalone = class extends WeaveStore {
|
|
|
62
51
|
}
|
|
63
52
|
async connect() {
|
|
64
53
|
const roomDataSnapshot = Buffer.from(this.roomData, "base64");
|
|
65
|
-
if (roomDataSnapshot)
|
|
54
|
+
if (roomDataSnapshot) yjs_default.applyUpdate(this.getDocument(), roomDataSnapshot);
|
|
66
55
|
else this.initialState(this.getDocument());
|
|
67
56
|
}
|
|
68
57
|
disconnect() {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inditextech/weave-store-standalone",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
|
|
@@ -50,10 +50,11 @@
|
|
|
50
50
|
"version:release": "npm version $RELEASE_VERSION -m \"[npm-scripts] prepare release $RELEASE_VERSION\" --tag-version-prefix \"\""
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@inditextech/weave-types": "1.1.0",
|
|
54
|
+
"@inditextech/weave-sdk": "1.1.0",
|
|
53
55
|
"@syncedstore/core": "0.6.0"
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
|
-
"@inditextech/weave-sdk": "1.0.4",
|
|
57
58
|
"@types/lodash.debounce": "^4.0.9",
|
|
58
59
|
"@types/node": "^22.15.3",
|
|
59
60
|
"@typescript-eslint/eslint-plugin": "8.26.0",
|
|
@@ -71,7 +72,6 @@
|
|
|
71
72
|
"vitest-sonar-reporter": "2.0.0"
|
|
72
73
|
},
|
|
73
74
|
"peerDependencies": {
|
|
74
|
-
"@inditextech/weave-sdk": ">= 1.x",
|
|
75
75
|
"konva": "10.0.2",
|
|
76
76
|
"yjs": "13.6.27"
|
|
77
77
|
},
|