@inditextech/weave-types 0.1.1 → 0.2.1
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/types.cjs +64 -1
- package/dist/types.d.cts +201 -0
- package/dist/types.d.ts +201 -203
- package/dist/types.js +32 -28
- package/package.json +8 -7
- package/dist/types.cjs.gz +0 -0
- package/dist/types.js.gz +0 -0
package/dist/types.cjs
CHANGED
|
@@ -1 +1,64 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
require("konva");
|
|
26
|
+
require("yjs");
|
|
27
|
+
|
|
28
|
+
//#region src/constants.ts
|
|
29
|
+
const WEAVE_NODE_LAYER_ID = "mainLayer";
|
|
30
|
+
const WEAVE_INSTANCE_STATUS = {
|
|
31
|
+
["IDLE"]: "idle",
|
|
32
|
+
["STARTING"]: "starting",
|
|
33
|
+
["LOADING_FONTS"]: "loadingFonts",
|
|
34
|
+
["RUNNING"]: "running"
|
|
35
|
+
};
|
|
36
|
+
const WEAVE_NODE_POSITION = {
|
|
37
|
+
["UP"]: "up",
|
|
38
|
+
["DOWN"]: "down",
|
|
39
|
+
["FRONT"]: "front",
|
|
40
|
+
["BACK"]: "back"
|
|
41
|
+
};
|
|
42
|
+
const WEAVE_EXPORT_BACKGROUND_COLOR = "white";
|
|
43
|
+
const WEAVE_EXPORT_FORMATS = {
|
|
44
|
+
["PNG"]: "image/png",
|
|
45
|
+
["JPEG"]: "image/jpeg"
|
|
46
|
+
};
|
|
47
|
+
const WEAVE_EXPORT_FILE_FORMAT = {
|
|
48
|
+
["image/png"]: ".png",
|
|
49
|
+
["image/jpeg"]: ".jpg"
|
|
50
|
+
};
|
|
51
|
+
const STATE_ACTIONS = {
|
|
52
|
+
["CREATE"]: "create",
|
|
53
|
+
["UPDATE"]: "update",
|
|
54
|
+
["DELETE"]: "delete"
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
exports.STATE_ACTIONS = STATE_ACTIONS
|
|
59
|
+
exports.WEAVE_EXPORT_BACKGROUND_COLOR = WEAVE_EXPORT_BACKGROUND_COLOR
|
|
60
|
+
exports.WEAVE_EXPORT_FILE_FORMAT = WEAVE_EXPORT_FILE_FORMAT
|
|
61
|
+
exports.WEAVE_EXPORT_FORMATS = WEAVE_EXPORT_FORMATS
|
|
62
|
+
exports.WEAVE_INSTANCE_STATUS = WEAVE_INSTANCE_STATUS
|
|
63
|
+
exports.WEAVE_NODE_LAYER_ID = WEAVE_NODE_LAYER_ID
|
|
64
|
+
exports.WEAVE_NODE_POSITION = WEAVE_NODE_POSITION
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import Konva from "konva";
|
|
2
|
+
import * as Y from "yjs";
|
|
3
|
+
import { Vector2d } from "konva/lib/types";
|
|
4
|
+
|
|
5
|
+
//#region src/constants.d.ts
|
|
6
|
+
declare const WEAVE_NODE_LAYER_ID = "mainLayer";
|
|
7
|
+
declare const WEAVE_INSTANCE_STATUS: {
|
|
8
|
+
readonly "IDLE": "idle";
|
|
9
|
+
readonly "STARTING": "starting";
|
|
10
|
+
readonly "LOADING_FONTS": "loadingFonts";
|
|
11
|
+
readonly "RUNNING": "running";
|
|
12
|
+
};
|
|
13
|
+
declare const WEAVE_NODE_POSITION: {
|
|
14
|
+
readonly "UP": "up";
|
|
15
|
+
readonly "DOWN": "down";
|
|
16
|
+
readonly "FRONT": "front";
|
|
17
|
+
readonly "BACK": "back";
|
|
18
|
+
};
|
|
19
|
+
declare const WEAVE_EXPORT_BACKGROUND_COLOR = "white";
|
|
20
|
+
declare const WEAVE_EXPORT_FORMATS: {
|
|
21
|
+
readonly "PNG": "image/png";
|
|
22
|
+
readonly "JPEG": "image/jpeg";
|
|
23
|
+
};
|
|
24
|
+
declare const WEAVE_EXPORT_FILE_FORMAT: {
|
|
25
|
+
readonly "image/png": ".png";
|
|
26
|
+
readonly "image/jpeg": ".jpg";
|
|
27
|
+
};
|
|
28
|
+
declare const STATE_ACTIONS: {
|
|
29
|
+
readonly "CREATE": "create";
|
|
30
|
+
readonly "UPDATE": "update";
|
|
31
|
+
readonly "DELETE": "delete";
|
|
32
|
+
}; //#endregion
|
|
33
|
+
//#region src/base/action.d.ts
|
|
34
|
+
interface WeaveActionBase {
|
|
35
|
+
init?(): void;
|
|
36
|
+
trigger(cancelAction: () => void, params?: unknown): unknown;
|
|
37
|
+
internalUpdate?(): void;
|
|
38
|
+
cleanup?(): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/base/plugin.d.ts
|
|
43
|
+
interface WeavePluginBase {
|
|
44
|
+
init?(): void;
|
|
45
|
+
render?(): void;
|
|
46
|
+
enable(): void;
|
|
47
|
+
disable(): void;
|
|
48
|
+
isEnabled(): boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/base/store.d.ts
|
|
53
|
+
type WeaveStoreOptions = {
|
|
54
|
+
getUser: () => WeaveUser;
|
|
55
|
+
undoManagerOptions?: WeaveUndoManagerOptions;
|
|
56
|
+
};
|
|
57
|
+
interface WeaveStoreBase {
|
|
58
|
+
connect(): void;
|
|
59
|
+
disconnect(): void;
|
|
60
|
+
onAwarenessChange<K extends string, T>(callback: (changes: WeaveAwarenessChange<K, T>[]) => void): void;
|
|
61
|
+
setAwarenessInfo(field: string, value: unknown): void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/types.d.ts
|
|
66
|
+
type WeaveConfig = {
|
|
67
|
+
store: WeaveStoreBase;
|
|
68
|
+
nodes?: WeaveNodeBase[];
|
|
69
|
+
actions?: WeaveActionBase[];
|
|
70
|
+
plugins?: WeavePluginBase[];
|
|
71
|
+
fonts?: WeaveFont[];
|
|
72
|
+
callbacks?: WeaveCallbacks;
|
|
73
|
+
logger?: WeaveLoggerConfig;
|
|
74
|
+
};
|
|
75
|
+
type WeaveStatusKeys = keyof typeof WEAVE_INSTANCE_STATUS;
|
|
76
|
+
type WeaveStatus = (typeof WEAVE_INSTANCE_STATUS)[WeaveStatusKeys];
|
|
77
|
+
type StateActionKeys = keyof typeof STATE_ACTIONS;
|
|
78
|
+
type StateAction = (typeof STATE_ACTIONS)[StateActionKeys];
|
|
79
|
+
type NodesStateChange = {
|
|
80
|
+
action: StateAction;
|
|
81
|
+
value: NodeSerializable;
|
|
82
|
+
};
|
|
83
|
+
type GroupsStateChange = {
|
|
84
|
+
action: StateAction;
|
|
85
|
+
value: GroupSerializable;
|
|
86
|
+
};
|
|
87
|
+
type NodeSerializable = Konva.NodeConfig & {
|
|
88
|
+
id: string;
|
|
89
|
+
type: string;
|
|
90
|
+
};
|
|
91
|
+
type GroupSerializable = Konva.NodeConfig & {
|
|
92
|
+
id: string;
|
|
93
|
+
type: "group";
|
|
94
|
+
nodes: string[];
|
|
95
|
+
};
|
|
96
|
+
type WeaveElementAttributes = {
|
|
97
|
+
[key: string]: any;
|
|
98
|
+
id?: string;
|
|
99
|
+
nodeType?: string;
|
|
100
|
+
children?: WeaveStateElement[];
|
|
101
|
+
};
|
|
102
|
+
type WeaveStateElement = {
|
|
103
|
+
key: string;
|
|
104
|
+
type: string;
|
|
105
|
+
props: WeaveElementAttributes;
|
|
106
|
+
};
|
|
107
|
+
type WeaveState = {
|
|
108
|
+
weave: {
|
|
109
|
+
key: "stage";
|
|
110
|
+
type: "stage";
|
|
111
|
+
props: {
|
|
112
|
+
[key: string]: unknown;
|
|
113
|
+
id: "stage";
|
|
114
|
+
children: WeaveStateElement[];
|
|
115
|
+
};
|
|
116
|
+
} | Record<string, WeaveStateElement>;
|
|
117
|
+
};
|
|
118
|
+
type WeaveSelection = {
|
|
119
|
+
instance: Konva.Shape | Konva.Group;
|
|
120
|
+
node: WeaveStateElement;
|
|
121
|
+
};
|
|
122
|
+
type WeaveMousePointInfoSimple = {
|
|
123
|
+
mousePoint: Vector2d;
|
|
124
|
+
container: Konva.Layer | Konva.Group | undefined;
|
|
125
|
+
};
|
|
126
|
+
type WeaveMousePointInfo = WeaveMousePointInfoSimple & {
|
|
127
|
+
measureContainer: Konva.Layer | Konva.Group | undefined;
|
|
128
|
+
};
|
|
129
|
+
type WeaveSerializedGroup = {
|
|
130
|
+
serializedNodes: WeaveStateElement[];
|
|
131
|
+
minPoint: Vector2d;
|
|
132
|
+
} | undefined;
|
|
133
|
+
type WeaveNodeFound = {
|
|
134
|
+
node: WeaveStateElement | null;
|
|
135
|
+
parent: WeaveStateElement | null;
|
|
136
|
+
index: number;
|
|
137
|
+
};
|
|
138
|
+
type WeaveAwarenessChange<K extends string, T> = { [key in K]: T };
|
|
139
|
+
type WeaveElementInstance = Konva.Layer | Konva.Group | Konva.Shape;
|
|
140
|
+
type WeaveLoggerConfig = {
|
|
141
|
+
disabled?: boolean;
|
|
142
|
+
level?: "debug" | "info" | "warn" | "error";
|
|
143
|
+
};
|
|
144
|
+
type WeavePositionKeys = keyof typeof WEAVE_NODE_POSITION;
|
|
145
|
+
type WeavePosition = (typeof WEAVE_NODE_POSITION)[WeavePositionKeys];
|
|
146
|
+
type WeaveExportNodeOptions = {
|
|
147
|
+
format?: typeof WEAVE_EXPORT_FORMATS.PNG;
|
|
148
|
+
padding?: number;
|
|
149
|
+
pixelRatio?: number;
|
|
150
|
+
backgroundColor?: string;
|
|
151
|
+
quality?: number;
|
|
152
|
+
};
|
|
153
|
+
type WeaveExportFormatKeys = keyof typeof WEAVE_EXPORT_FORMATS;
|
|
154
|
+
type WeaveExportFormat = (typeof WEAVE_EXPORT_FORMATS)[WeaveExportFormatKeys];
|
|
155
|
+
type WeaveExportFileFormatKeys = keyof typeof WEAVE_EXPORT_FILE_FORMAT;
|
|
156
|
+
type WeaveExportFileFormat = (typeof WEAVE_EXPORT_FILE_FORMAT)[WeaveExportFileFormatKeys];
|
|
157
|
+
type WeaveUser = {
|
|
158
|
+
name: string;
|
|
159
|
+
email: string;
|
|
160
|
+
};
|
|
161
|
+
type WeaveFont = {
|
|
162
|
+
id: string;
|
|
163
|
+
name: string;
|
|
164
|
+
};
|
|
165
|
+
type WeaveUndoManagerOptions = {
|
|
166
|
+
captureTimeout?: number;
|
|
167
|
+
trackedOrigins?: Set<any>;
|
|
168
|
+
};
|
|
169
|
+
type WeaveUndoRedoChange = {
|
|
170
|
+
canRedo: boolean;
|
|
171
|
+
canUndo: boolean;
|
|
172
|
+
redoStackLength: number;
|
|
173
|
+
undoStackLength: number;
|
|
174
|
+
};
|
|
175
|
+
type WeaveCallbacks = {
|
|
176
|
+
onRender?: () => void;
|
|
177
|
+
onRoomLoaded?: (loaded: boolean) => void;
|
|
178
|
+
onInstanceStatus?: (status: WeaveStatus) => void;
|
|
179
|
+
onActiveActionChange?: (actionName: string | undefined) => void;
|
|
180
|
+
onStateChange?: (state: WeaveState) => void;
|
|
181
|
+
onUndoManagerStatusChange?: (undoManagerStatus: WeaveUndoRedoChange) => void;
|
|
182
|
+
};
|
|
183
|
+
declare type docElementTypeDescription = "xml" | "text" | Array<any> | object;
|
|
184
|
+
declare type DocTypeDescription = {
|
|
185
|
+
[key: string]: docElementTypeDescription;
|
|
186
|
+
};
|
|
187
|
+
declare type MappedTypeDescription<T extends DocTypeDescription> = { readonly [P in keyof T]: T[P] extends "xml" ? Y.XmlFragment : T[P] extends "text" ? Y.Text : T[P] extends Array<any> ? T[P] : T[P] extends object ? Partial<T[P]> : never };
|
|
188
|
+
declare function crdtDoc<T extends DocTypeDescription>(doc: Y.Doc, typeDescription: T): MappedTypeDescription<T>;
|
|
189
|
+
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/base/node.d.ts
|
|
192
|
+
interface WeaveNodeBase {
|
|
193
|
+
createNode(id: string, props: WeaveElementAttributes): WeaveStateElement;
|
|
194
|
+
createInstance(props: WeaveElementAttributes): WeaveElementInstance;
|
|
195
|
+
updateInstance(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
|
|
196
|
+
removeInstance(instance: WeaveElementInstance): void;
|
|
197
|
+
toNode(instance: WeaveElementInstance): WeaveStateElement;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
//#endregion
|
|
201
|
+
export { DocTypeDescription, GroupSerializable, GroupsStateChange, MappedTypeDescription, NodeSerializable, NodesStateChange, STATE_ACTIONS, StateAction, StateActionKeys, WEAVE_EXPORT_BACKGROUND_COLOR, WEAVE_EXPORT_FILE_FORMAT, WEAVE_EXPORT_FORMATS, WEAVE_INSTANCE_STATUS, WEAVE_NODE_LAYER_ID, WEAVE_NODE_POSITION, WeaveActionBase, WeaveAwarenessChange, WeaveCallbacks, WeaveConfig, WeaveElementAttributes, WeaveElementInstance, WeaveExportFileFormat, WeaveExportFileFormatKeys, WeaveExportFormat, WeaveExportFormatKeys, WeaveExportNodeOptions, WeaveFont, WeaveLoggerConfig, WeaveMousePointInfo, WeaveMousePointInfoSimple, WeaveNodeBase, WeaveNodeFound, WeavePluginBase, WeavePosition, WeavePositionKeys, WeaveSelection, WeaveSerializedGroup, WeaveState, WeaveStateElement, WeaveStatus, WeaveStatusKeys, WeaveStoreBase, WeaveStoreOptions, WeaveUndoManagerOptions, WeaveUndoRedoChange, WeaveUser, crdtDoc, docElementTypeDescription };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,203 +1,201 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export { }
|
|
1
|
+
import Konva from "konva";
|
|
2
|
+
import * as Y from "yjs";
|
|
3
|
+
import { Vector2d } from "konva/lib/types";
|
|
4
|
+
|
|
5
|
+
//#region src/constants.d.ts
|
|
6
|
+
declare const WEAVE_NODE_LAYER_ID = "mainLayer";
|
|
7
|
+
declare const WEAVE_INSTANCE_STATUS: {
|
|
8
|
+
readonly "IDLE": "idle";
|
|
9
|
+
readonly "STARTING": "starting";
|
|
10
|
+
readonly "LOADING_FONTS": "loadingFonts";
|
|
11
|
+
readonly "RUNNING": "running";
|
|
12
|
+
};
|
|
13
|
+
declare const WEAVE_NODE_POSITION: {
|
|
14
|
+
readonly "UP": "up";
|
|
15
|
+
readonly "DOWN": "down";
|
|
16
|
+
readonly "FRONT": "front";
|
|
17
|
+
readonly "BACK": "back";
|
|
18
|
+
};
|
|
19
|
+
declare const WEAVE_EXPORT_BACKGROUND_COLOR = "white";
|
|
20
|
+
declare const WEAVE_EXPORT_FORMATS: {
|
|
21
|
+
readonly "PNG": "image/png";
|
|
22
|
+
readonly "JPEG": "image/jpeg";
|
|
23
|
+
};
|
|
24
|
+
declare const WEAVE_EXPORT_FILE_FORMAT: {
|
|
25
|
+
readonly "image/png": ".png";
|
|
26
|
+
readonly "image/jpeg": ".jpg";
|
|
27
|
+
};
|
|
28
|
+
declare const STATE_ACTIONS: {
|
|
29
|
+
readonly "CREATE": "create";
|
|
30
|
+
readonly "UPDATE": "update";
|
|
31
|
+
readonly "DELETE": "delete";
|
|
32
|
+
}; //#endregion
|
|
33
|
+
//#region src/base/action.d.ts
|
|
34
|
+
interface WeaveActionBase {
|
|
35
|
+
init?(): void;
|
|
36
|
+
trigger(cancelAction: () => void, params?: unknown): unknown;
|
|
37
|
+
internalUpdate?(): void;
|
|
38
|
+
cleanup?(): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/base/plugin.d.ts
|
|
43
|
+
interface WeavePluginBase {
|
|
44
|
+
init?(): void;
|
|
45
|
+
render?(): void;
|
|
46
|
+
enable(): void;
|
|
47
|
+
disable(): void;
|
|
48
|
+
isEnabled(): boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/base/store.d.ts
|
|
53
|
+
type WeaveStoreOptions = {
|
|
54
|
+
getUser: () => WeaveUser;
|
|
55
|
+
undoManagerOptions?: WeaveUndoManagerOptions;
|
|
56
|
+
};
|
|
57
|
+
interface WeaveStoreBase {
|
|
58
|
+
connect(): void;
|
|
59
|
+
disconnect(): void;
|
|
60
|
+
onAwarenessChange<K extends string, T>(callback: (changes: WeaveAwarenessChange<K, T>[]) => void): void;
|
|
61
|
+
setAwarenessInfo(field: string, value: unknown): void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/types.d.ts
|
|
66
|
+
type WeaveConfig = {
|
|
67
|
+
store: WeaveStoreBase;
|
|
68
|
+
nodes?: WeaveNodeBase[];
|
|
69
|
+
actions?: WeaveActionBase[];
|
|
70
|
+
plugins?: WeavePluginBase[];
|
|
71
|
+
fonts?: WeaveFont[];
|
|
72
|
+
callbacks?: WeaveCallbacks;
|
|
73
|
+
logger?: WeaveLoggerConfig;
|
|
74
|
+
};
|
|
75
|
+
type WeaveStatusKeys = keyof typeof WEAVE_INSTANCE_STATUS;
|
|
76
|
+
type WeaveStatus = (typeof WEAVE_INSTANCE_STATUS)[WeaveStatusKeys];
|
|
77
|
+
type StateActionKeys = keyof typeof STATE_ACTIONS;
|
|
78
|
+
type StateAction = (typeof STATE_ACTIONS)[StateActionKeys];
|
|
79
|
+
type NodesStateChange = {
|
|
80
|
+
action: StateAction;
|
|
81
|
+
value: NodeSerializable;
|
|
82
|
+
};
|
|
83
|
+
type GroupsStateChange = {
|
|
84
|
+
action: StateAction;
|
|
85
|
+
value: GroupSerializable;
|
|
86
|
+
};
|
|
87
|
+
type NodeSerializable = Konva.NodeConfig & {
|
|
88
|
+
id: string;
|
|
89
|
+
type: string;
|
|
90
|
+
};
|
|
91
|
+
type GroupSerializable = Konva.NodeConfig & {
|
|
92
|
+
id: string;
|
|
93
|
+
type: "group";
|
|
94
|
+
nodes: string[];
|
|
95
|
+
};
|
|
96
|
+
type WeaveElementAttributes = {
|
|
97
|
+
[key: string]: any;
|
|
98
|
+
id?: string;
|
|
99
|
+
nodeType?: string;
|
|
100
|
+
children?: WeaveStateElement[];
|
|
101
|
+
};
|
|
102
|
+
type WeaveStateElement = {
|
|
103
|
+
key: string;
|
|
104
|
+
type: string;
|
|
105
|
+
props: WeaveElementAttributes;
|
|
106
|
+
};
|
|
107
|
+
type WeaveState = {
|
|
108
|
+
weave: {
|
|
109
|
+
key: "stage";
|
|
110
|
+
type: "stage";
|
|
111
|
+
props: {
|
|
112
|
+
[key: string]: unknown;
|
|
113
|
+
id: "stage";
|
|
114
|
+
children: WeaveStateElement[];
|
|
115
|
+
};
|
|
116
|
+
} | Record<string, WeaveStateElement>;
|
|
117
|
+
};
|
|
118
|
+
type WeaveSelection = {
|
|
119
|
+
instance: Konva.Shape | Konva.Group;
|
|
120
|
+
node: WeaveStateElement;
|
|
121
|
+
};
|
|
122
|
+
type WeaveMousePointInfoSimple = {
|
|
123
|
+
mousePoint: Vector2d;
|
|
124
|
+
container: Konva.Layer | Konva.Group | undefined;
|
|
125
|
+
};
|
|
126
|
+
type WeaveMousePointInfo = WeaveMousePointInfoSimple & {
|
|
127
|
+
measureContainer: Konva.Layer | Konva.Group | undefined;
|
|
128
|
+
};
|
|
129
|
+
type WeaveSerializedGroup = {
|
|
130
|
+
serializedNodes: WeaveStateElement[];
|
|
131
|
+
minPoint: Vector2d;
|
|
132
|
+
} | undefined;
|
|
133
|
+
type WeaveNodeFound = {
|
|
134
|
+
node: WeaveStateElement | null;
|
|
135
|
+
parent: WeaveStateElement | null;
|
|
136
|
+
index: number;
|
|
137
|
+
};
|
|
138
|
+
type WeaveAwarenessChange<K extends string, T> = { [key in K]: T };
|
|
139
|
+
type WeaveElementInstance = Konva.Layer | Konva.Group | Konva.Shape;
|
|
140
|
+
type WeaveLoggerConfig = {
|
|
141
|
+
disabled?: boolean;
|
|
142
|
+
level?: "debug" | "info" | "warn" | "error";
|
|
143
|
+
};
|
|
144
|
+
type WeavePositionKeys = keyof typeof WEAVE_NODE_POSITION;
|
|
145
|
+
type WeavePosition = (typeof WEAVE_NODE_POSITION)[WeavePositionKeys];
|
|
146
|
+
type WeaveExportNodeOptions = {
|
|
147
|
+
format?: typeof WEAVE_EXPORT_FORMATS.PNG;
|
|
148
|
+
padding?: number;
|
|
149
|
+
pixelRatio?: number;
|
|
150
|
+
backgroundColor?: string;
|
|
151
|
+
quality?: number;
|
|
152
|
+
};
|
|
153
|
+
type WeaveExportFormatKeys = keyof typeof WEAVE_EXPORT_FORMATS;
|
|
154
|
+
type WeaveExportFormat = (typeof WEAVE_EXPORT_FORMATS)[WeaveExportFormatKeys];
|
|
155
|
+
type WeaveExportFileFormatKeys = keyof typeof WEAVE_EXPORT_FILE_FORMAT;
|
|
156
|
+
type WeaveExportFileFormat = (typeof WEAVE_EXPORT_FILE_FORMAT)[WeaveExportFileFormatKeys];
|
|
157
|
+
type WeaveUser = {
|
|
158
|
+
name: string;
|
|
159
|
+
email: string;
|
|
160
|
+
};
|
|
161
|
+
type WeaveFont = {
|
|
162
|
+
id: string;
|
|
163
|
+
name: string;
|
|
164
|
+
};
|
|
165
|
+
type WeaveUndoManagerOptions = {
|
|
166
|
+
captureTimeout?: number;
|
|
167
|
+
trackedOrigins?: Set<any>;
|
|
168
|
+
};
|
|
169
|
+
type WeaveUndoRedoChange = {
|
|
170
|
+
canRedo: boolean;
|
|
171
|
+
canUndo: boolean;
|
|
172
|
+
redoStackLength: number;
|
|
173
|
+
undoStackLength: number;
|
|
174
|
+
};
|
|
175
|
+
type WeaveCallbacks = {
|
|
176
|
+
onRender?: () => void;
|
|
177
|
+
onRoomLoaded?: (loaded: boolean) => void;
|
|
178
|
+
onInstanceStatus?: (status: WeaveStatus) => void;
|
|
179
|
+
onActiveActionChange?: (actionName: string | undefined) => void;
|
|
180
|
+
onStateChange?: (state: WeaveState) => void;
|
|
181
|
+
onUndoManagerStatusChange?: (undoManagerStatus: WeaveUndoRedoChange) => void;
|
|
182
|
+
};
|
|
183
|
+
declare type docElementTypeDescription = "xml" | "text" | Array<any> | object;
|
|
184
|
+
declare type DocTypeDescription = {
|
|
185
|
+
[key: string]: docElementTypeDescription;
|
|
186
|
+
};
|
|
187
|
+
declare type MappedTypeDescription<T extends DocTypeDescription> = { readonly [P in keyof T]: T[P] extends "xml" ? Y.XmlFragment : T[P] extends "text" ? Y.Text : T[P] extends Array<any> ? T[P] : T[P] extends object ? Partial<T[P]> : never };
|
|
188
|
+
declare function crdtDoc<T extends DocTypeDescription>(doc: Y.Doc, typeDescription: T): MappedTypeDescription<T>;
|
|
189
|
+
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/base/node.d.ts
|
|
192
|
+
interface WeaveNodeBase {
|
|
193
|
+
createNode(id: string, props: WeaveElementAttributes): WeaveStateElement;
|
|
194
|
+
createInstance(props: WeaveElementAttributes): WeaveElementInstance;
|
|
195
|
+
updateInstance(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
|
|
196
|
+
removeInstance(instance: WeaveElementInstance): void;
|
|
197
|
+
toNode(instance: WeaveElementInstance): WeaveStateElement;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
//#endregion
|
|
201
|
+
export { DocTypeDescription, GroupSerializable, GroupsStateChange, MappedTypeDescription, NodeSerializable, NodesStateChange, STATE_ACTIONS, StateAction, StateActionKeys, WEAVE_EXPORT_BACKGROUND_COLOR, WEAVE_EXPORT_FILE_FORMAT, WEAVE_EXPORT_FORMATS, WEAVE_INSTANCE_STATUS, WEAVE_NODE_LAYER_ID, WEAVE_NODE_POSITION, WeaveActionBase, WeaveAwarenessChange, WeaveCallbacks, WeaveConfig, WeaveElementAttributes, WeaveElementInstance, WeaveExportFileFormat, WeaveExportFileFormatKeys, WeaveExportFormat, WeaveExportFormatKeys, WeaveExportNodeOptions, WeaveFont, WeaveLoggerConfig, WeaveMousePointInfo, WeaveMousePointInfoSimple, WeaveNodeBase, WeaveNodeFound, WeavePluginBase, WeavePosition, WeavePositionKeys, WeaveSelection, WeaveSerializedGroup, WeaveState, WeaveStateElement, WeaveStatus, WeaveStatusKeys, WeaveStoreBase, WeaveStoreOptions, WeaveUndoManagerOptions, WeaveUndoRedoChange, WeaveUser, crdtDoc, docElementTypeDescription };
|
package/dist/types.js
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}, T = "white", O = {
|
|
12
|
-
PNG: "image/png",
|
|
13
|
-
JPEG: "image/jpeg"
|
|
14
|
-
}, _ = {
|
|
15
|
-
"image/png": ".png",
|
|
16
|
-
"image/jpeg": ".jpg"
|
|
17
|
-
}, e = {
|
|
18
|
-
CREATE: "create",
|
|
19
|
-
UPDATE: "update",
|
|
20
|
-
DELETE: "delete"
|
|
1
|
+
import Konva from "konva";
|
|
2
|
+
import "yjs";
|
|
3
|
+
|
|
4
|
+
//#region src/constants.ts
|
|
5
|
+
const WEAVE_NODE_LAYER_ID = "mainLayer";
|
|
6
|
+
const WEAVE_INSTANCE_STATUS = {
|
|
7
|
+
["IDLE"]: "idle",
|
|
8
|
+
["STARTING"]: "starting",
|
|
9
|
+
["LOADING_FONTS"]: "loadingFonts",
|
|
10
|
+
["RUNNING"]: "running"
|
|
21
11
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
n as WEAVE_INSTANCE_STATUS,
|
|
28
|
-
E as WEAVE_NODE_LAYER_ID,
|
|
29
|
-
A as WEAVE_NODE_POSITION
|
|
12
|
+
const WEAVE_NODE_POSITION = {
|
|
13
|
+
["UP"]: "up",
|
|
14
|
+
["DOWN"]: "down",
|
|
15
|
+
["FRONT"]: "front",
|
|
16
|
+
["BACK"]: "back"
|
|
30
17
|
};
|
|
18
|
+
const WEAVE_EXPORT_BACKGROUND_COLOR = "white";
|
|
19
|
+
const WEAVE_EXPORT_FORMATS = {
|
|
20
|
+
["PNG"]: "image/png",
|
|
21
|
+
["JPEG"]: "image/jpeg"
|
|
22
|
+
};
|
|
23
|
+
const WEAVE_EXPORT_FILE_FORMAT = {
|
|
24
|
+
["image/png"]: ".png",
|
|
25
|
+
["image/jpeg"]: ".jpg"
|
|
26
|
+
};
|
|
27
|
+
const STATE_ACTIONS = {
|
|
28
|
+
["CREATE"]: "create",
|
|
29
|
+
["UPDATE"]: "update",
|
|
30
|
+
["DELETE"]: "delete"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { STATE_ACTIONS, WEAVE_EXPORT_BACKGROUND_COLOR, WEAVE_EXPORT_FILE_FORMAT, WEAVE_EXPORT_FORMATS, WEAVE_INSTANCE_STATUS, WEAVE_NODE_LAYER_ID, WEAVE_NODE_POSITION };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inditextech/weave-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build:snapshot": "
|
|
25
|
-
"build": "
|
|
24
|
+
"build:snapshot": "tsdown --sourcemap",
|
|
25
|
+
"build": "tsdown",
|
|
26
26
|
"bump:snapshot": "npm version $npm_package_version.$(date \"+%s\")",
|
|
27
27
|
"bundle:analyze": "vite-bundle-visualizer",
|
|
28
28
|
"check": "echo \"Monorepo test script\" && exit 0",
|
|
@@ -41,6 +41,10 @@
|
|
|
41
41
|
"version:development": "npm version $(npm version minor)-SNAPSHOT",
|
|
42
42
|
"version:release": "npm version $RELEASE_VERSION -m \"[npm-scripts] prepare release $RELEASE_VERSION\" --tag-version-prefix \"\""
|
|
43
43
|
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"konva": "9.3.20",
|
|
46
|
+
"yjs": "13.6.26"
|
|
47
|
+
},
|
|
44
48
|
"devDependencies": {
|
|
45
49
|
"@typescript-eslint/eslint-plugin": "8.26.0",
|
|
46
50
|
"@typescript-eslint/parser": "8.26.0",
|
|
@@ -49,11 +53,8 @@
|
|
|
49
53
|
"eslint": "8.57.1",
|
|
50
54
|
"eslint-plugin-react": "7.34.1",
|
|
51
55
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
56
|
+
"tsdown": "^0.10.2",
|
|
52
57
|
"typescript-eslint": "8.22.0",
|
|
53
|
-
"vite": "5.2.9",
|
|
54
|
-
"vite-bundle-visualizer": "1.1.0",
|
|
55
|
-
"vite-plugin-compression2": "1.0.0",
|
|
56
|
-
"vite-plugin-dts": "4.0.3",
|
|
57
58
|
"vitest": "1.6.0",
|
|
58
59
|
"vitest-sonar-reporter": "2.0.0"
|
|
59
60
|
},
|
package/dist/types.cjs.gz
DELETED
|
Binary file
|
package/dist/types.js.gz
DELETED
|
Binary file
|