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