@inditextech/weave-sdk 0.27.3 → 0.28.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/README.md +18 -249
- package/dist/sdk.cjs +66 -149
- package/dist/sdk.d.cts +38 -64
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +38 -64
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +64 -145
- package/dist/sdk.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,279 +4,48 @@ SPDX-FileCopyrightText: 2025 2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.
|
|
|
4
4
|
SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
-->
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
[](https://github.com/prettier/prettier)
|
|
7
|
+
# Weave.js / SDK
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
This package generates the `@inditextech/weave-sdk` package, the Weave SDK, designed power-lift all the necessary stuff to build collaborative applications using real-time data synchronization powered by [Yjs](https://github.com/yjs/yjs/tree/master), relying on [CRDTs](https://github.com/yjs/yjs/blob/master/README.md#Yjs-CRDT-Algorithm) (Conflict-Free Replicated Data Types).
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
## Setup
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
This project requires NodeJS (version 8 or later) and NPM.
|
|
17
|
-
[Node](http://nodejs.org/) and [NPM](https://npmjs.org/) are really easy to install.
|
|
18
|
-
To make sure you have them available on your machine,
|
|
19
|
-
try running the following command.
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
$ npm -v && node -v
|
|
23
|
-
6.4.1
|
|
24
|
-
v8.16.0
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Table of contents
|
|
28
|
-
|
|
29
|
-
- [Project Name](#project-name)
|
|
30
|
-
- [Prerequisites](#prerequisites)
|
|
31
|
-
- [Table of contents](#table-of-contents)
|
|
32
|
-
- [Getting Started](#getting-started)
|
|
33
|
-
- [Installation](#installation)
|
|
34
|
-
- [Usage](#usage)
|
|
35
|
-
- [Serving the app](#serving-the-app)
|
|
36
|
-
- [Running the tests](#running-the-tests)
|
|
37
|
-
- [Building a distribution version](#building-a-distribution-version)
|
|
38
|
-
- [Serving the distribution version](#serving-the-distribution-version)
|
|
39
|
-
- [API](#api)
|
|
40
|
-
- [useBasicFetch](#usebasicfetch)
|
|
41
|
-
- [Options](#options)
|
|
42
|
-
- [fetchData](#fetchdata)
|
|
43
|
-
- [Contributing](#contributing)
|
|
44
|
-
- [Credits](#credits)
|
|
45
|
-
- [Built With](#built-with)
|
|
46
|
-
- [Versioning](#versioning)
|
|
47
|
-
- [Authors](#authors)
|
|
48
|
-
- [License](#license)
|
|
49
|
-
|
|
50
|
-
## Getting Started
|
|
51
|
-
|
|
52
|
-
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
|
|
53
|
-
|
|
54
|
-
## Installation
|
|
55
|
-
|
|
56
|
-
**BEFORE YOU INSTALL:** please read the [prerequisites](#prerequisites)
|
|
57
|
-
|
|
58
|
-
Start with cloning this repo on your local machine:
|
|
59
|
-
|
|
60
|
-
```sh
|
|
61
|
-
$ git clone https://github.com/ORG/PROJECT.git
|
|
62
|
-
$ cd PROJECT
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
To install and set up the library, run:
|
|
66
|
-
|
|
67
|
-
```sh
|
|
68
|
-
$ npm install -S myLib
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Or if you prefer using Yarn:
|
|
13
|
+
This is a monorepo, to install this package dependencies, just setup the monorepo, this can be done by locating on the `/code` project and execute the following command.
|
|
72
14
|
|
|
73
15
|
```sh
|
|
74
|
-
$
|
|
16
|
+
$ npm install
|
|
75
17
|
```
|
|
76
18
|
|
|
77
19
|
## Usage
|
|
78
20
|
|
|
79
|
-
|
|
21
|
+
This is a monorepo, this commands need to be from the `/code` folder of the repo.
|
|
80
22
|
|
|
81
|
-
|
|
82
|
-
$ npm start
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Running the tests
|
|
23
|
+
### Build the package
|
|
86
24
|
|
|
87
25
|
```sh
|
|
88
|
-
$ npm
|
|
26
|
+
$ npm run build --workspace=@inditextech/weave-sdk
|
|
89
27
|
```
|
|
90
28
|
|
|
91
|
-
###
|
|
29
|
+
### Link the package
|
|
92
30
|
|
|
93
31
|
```sh
|
|
94
|
-
$ npm run
|
|
32
|
+
$ npm run link --workspace=@inditextech/weave-sdk
|
|
95
33
|
```
|
|
96
34
|
|
|
97
|
-
|
|
98
|
-
inside your local `dist/` folder
|
|
99
|
-
|
|
100
|
-
### Serving the distribution version
|
|
35
|
+
### Lint the package
|
|
101
36
|
|
|
102
37
|
```sh
|
|
103
|
-
$ npm run
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
This will use `lite-server` for servign your already
|
|
107
|
-
generated distribution version of the project.
|
|
108
|
-
|
|
109
|
-
_Note_ this requires
|
|
110
|
-
[Building a distribution version](#building-a-distribution-version) first.
|
|
111
|
-
|
|
112
|
-
## API
|
|
113
|
-
|
|
114
|
-
### useBasicFetch
|
|
115
|
-
|
|
116
|
-
```js
|
|
117
|
-
useBasicFetch(((url: string) = ''), ((delay: number) = 0));
|
|
38
|
+
$ npm run lint --workspace=@inditextech/weave-sdk
|
|
118
39
|
```
|
|
119
40
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
#### Options
|
|
123
|
-
|
|
124
|
-
`url`
|
|
125
|
-
|
|
126
|
-
| Type | Default value |
|
|
127
|
-
| ------ | ------------- |
|
|
128
|
-
| string | '' |
|
|
129
|
-
|
|
130
|
-
If present, the request will be performed as soon as the component is mounted
|
|
131
|
-
|
|
132
|
-
Example:
|
|
133
|
-
|
|
134
|
-
```tsx
|
|
135
|
-
const MyComponent: React.FC = () => {
|
|
136
|
-
const { data, error, loading } = useBasicFetch(
|
|
137
|
-
'https://api.icndb.com/jokes/random'
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
if (error) {
|
|
141
|
-
return <p>Error</p>;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (loading) {
|
|
145
|
-
return <p>Loading...</p>;
|
|
146
|
-
}
|
|
41
|
+
### Test the package
|
|
147
42
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
<h2>Chuck Norris Joke of the day</h2>
|
|
151
|
-
{data && data.value && <p>{data.value.joke}</p>}
|
|
152
|
-
</div>
|
|
153
|
-
);
|
|
154
|
-
};
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
`delay`
|
|
158
|
-
|
|
159
|
-
| Type | Default value | Description |
|
|
160
|
-
| ------ | ------------- | -------------------- |
|
|
161
|
-
| number | 0 | Time in milliseconds |
|
|
162
|
-
|
|
163
|
-
If present, the request will be delayed by the given amount of time
|
|
164
|
-
|
|
165
|
-
Example:
|
|
166
|
-
|
|
167
|
-
```tsx
|
|
168
|
-
type Joke = {
|
|
169
|
-
value: {
|
|
170
|
-
id: number;
|
|
171
|
-
joke: string;
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const MyComponent: React.FC = () => {
|
|
176
|
-
const { data, error, loading } = useBasicFetch<Joke>(
|
|
177
|
-
'https://api.icndb.com/jokes/random',
|
|
178
|
-
2000
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
if (error) {
|
|
182
|
-
return <p>Error</p>;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (loading) {
|
|
186
|
-
return <p>Loading...</p>;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return (
|
|
190
|
-
<div className="App">
|
|
191
|
-
<h2>Chuck Norris Joke of the day</h2>
|
|
192
|
-
{data && data.value && <p>{data.value.joke}</p>}
|
|
193
|
-
</div>
|
|
194
|
-
);
|
|
195
|
-
};
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### fetchData
|
|
199
|
-
|
|
200
|
-
```js
|
|
201
|
-
fetchData(url: string)
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
Perform an asynchronous http request against a given url
|
|
205
|
-
|
|
206
|
-
```tsx
|
|
207
|
-
type Joke = {
|
|
208
|
-
value: {
|
|
209
|
-
id: number;
|
|
210
|
-
joke: string;
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
const ChuckNorrisJokes: React.FC = () => {
|
|
215
|
-
const { data, fetchData, error, loading } = useBasicFetch<Joke>();
|
|
216
|
-
const [jokeId, setJokeId] = useState(1);
|
|
217
|
-
|
|
218
|
-
useEffect(() => {
|
|
219
|
-
fetchData(`https://api.icndb.com/jokes/${jokeId}`);
|
|
220
|
-
}, [jokeId, fetchData]);
|
|
221
|
-
|
|
222
|
-
const handleNext = () => setJokeId(jokeId + 1);
|
|
223
|
-
|
|
224
|
-
if (error) {
|
|
225
|
-
return <p>Error</p>;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const jokeData = data && data.value;
|
|
229
|
-
|
|
230
|
-
return (
|
|
231
|
-
<div className="Comments">
|
|
232
|
-
{loading && <p>Loading...</p>}
|
|
233
|
-
{!loading && jokeData && (
|
|
234
|
-
<div>
|
|
235
|
-
<p>Joke ID: {jokeData.id}</p>
|
|
236
|
-
<p>{jokeData.joke}</p>
|
|
237
|
-
</div>
|
|
238
|
-
)}
|
|
239
|
-
{!loading && jokeData && !jokeData.joke && <p>{jokeData}</p>}
|
|
240
|
-
<button disabled={loading} onClick={handleNext}>
|
|
241
|
-
Next Joke
|
|
242
|
-
</button>
|
|
243
|
-
</div>
|
|
244
|
-
);
|
|
245
|
-
};
|
|
43
|
+
```sh
|
|
44
|
+
$ npm run test --workspace=@inditextech/weave-sdk
|
|
246
45
|
```
|
|
247
46
|
|
|
248
|
-
## Contributing
|
|
249
|
-
|
|
250
|
-
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
|
|
251
|
-
|
|
252
|
-
1. Fork it!
|
|
253
|
-
2. Create your feature branch: `git checkout -b my-new-feature`
|
|
254
|
-
3. Add your changes: `git add .`
|
|
255
|
-
4. Commit your changes: `git commit -am 'Add some feature'`
|
|
256
|
-
5. Push to the branch: `git push origin my-new-feature`
|
|
257
|
-
6. Submit a pull request :sunglasses:
|
|
258
|
-
|
|
259
|
-
## Credits
|
|
260
|
-
|
|
261
|
-
TODO: Write credits
|
|
262
|
-
|
|
263
|
-
## Built With
|
|
264
|
-
|
|
265
|
-
- Dropwizard - Bla bla bla
|
|
266
|
-
- Maven - Maybe
|
|
267
|
-
- Atom - ergaerga
|
|
268
|
-
- Love
|
|
269
|
-
|
|
270
|
-
## Versioning
|
|
271
|
-
|
|
272
|
-
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
|
|
273
|
-
|
|
274
|
-
## Authors
|
|
275
|
-
|
|
276
|
-
- **John Doe** - _Initial work_ - [JohnDoe](https://github.com/JohnDoe)
|
|
277
|
-
|
|
278
|
-
See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.
|
|
279
|
-
|
|
280
47
|
## License
|
|
281
48
|
|
|
282
|
-
[
|
|
49
|
+
This project is licensed under the terms of the [Apache-2.0](LICENSE) license.
|
|
50
|
+
|
|
51
|
+
© 2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.)
|
package/dist/sdk.cjs
CHANGED
|
@@ -15810,6 +15810,26 @@ function moveNodeToContainer(instance, node) {
|
|
|
15810
15810
|
}
|
|
15811
15811
|
return void 0;
|
|
15812
15812
|
}
|
|
15813
|
+
function getContrastTextColor(hex) {
|
|
15814
|
+
const cleaned = hex.replace(/^#/, "");
|
|
15815
|
+
const r = parseInt(cleaned.slice(0, 2), 16);
|
|
15816
|
+
const g = parseInt(cleaned.slice(2, 4), 16);
|
|
15817
|
+
const b = parseInt(cleaned.slice(4, 6), 16);
|
|
15818
|
+
const luminance = (.299 * r + .587 * g + .114 * b) / 255;
|
|
15819
|
+
return luminance > .5 ? "black" : "white";
|
|
15820
|
+
}
|
|
15821
|
+
function stringToColor(str) {
|
|
15822
|
+
let hash = 0;
|
|
15823
|
+
str.split("").forEach((char) => {
|
|
15824
|
+
hash = char.charCodeAt(0) + ((hash << 5) - hash);
|
|
15825
|
+
});
|
|
15826
|
+
let color = "#";
|
|
15827
|
+
for (let i = 0; i < 3; i++) {
|
|
15828
|
+
const value = hash >> i * 8 & 255;
|
|
15829
|
+
color += value.toString(16).padStart(2, "0");
|
|
15830
|
+
}
|
|
15831
|
+
return color;
|
|
15832
|
+
}
|
|
15813
15833
|
|
|
15814
15834
|
//#endregion
|
|
15815
15835
|
//#region src/plugins/users-selection/constants.ts
|
|
@@ -16024,8 +16044,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16024
16044
|
stage.container().style.cursor = actualCursor;
|
|
16025
16045
|
});
|
|
16026
16046
|
}
|
|
16027
|
-
const usersSelectionPlugin = this.instance.getPlugin(WEAVE_USERS_SELECTION_KEY);
|
|
16028
|
-
if (usersSelectionPlugin) usersSelectionPlugin.sendSelectionAwarenessInfo(this.tr);
|
|
16029
16047
|
tr.forceUpdate();
|
|
16030
16048
|
});
|
|
16031
16049
|
this.tr = tr;
|
|
@@ -16516,9 +16534,6 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
16516
16534
|
//#endregion
|
|
16517
16535
|
//#region src/nodes/node.ts
|
|
16518
16536
|
const augmentKonvaStageClass = () => {
|
|
16519
|
-
konva.default.Stage.prototype.isFocused = function() {
|
|
16520
|
-
return false;
|
|
16521
|
-
};
|
|
16522
16537
|
konva.default.Stage.prototype.isMouseWheelPressed = function() {
|
|
16523
16538
|
return false;
|
|
16524
16539
|
};
|
|
@@ -16604,10 +16619,9 @@ var WeaveNode = class {
|
|
|
16604
16619
|
this.scaleReset(node$1);
|
|
16605
16620
|
const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
|
|
16606
16621
|
this.instance.updateNode(nodeHandler.serialize(node$1));
|
|
16607
|
-
e.cancelBubble = true;
|
|
16608
16622
|
}
|
|
16609
16623
|
};
|
|
16610
|
-
node.on("transform", (0, import_lodash.throttle)(handleTransform,
|
|
16624
|
+
node.on("transform", (0, import_lodash.throttle)(handleTransform, 100));
|
|
16611
16625
|
node.on("transformend", (e) => {
|
|
16612
16626
|
const node$1 = e.target;
|
|
16613
16627
|
transforming = false;
|
|
@@ -16637,9 +16651,11 @@ var WeaveNode = class {
|
|
|
16637
16651
|
clearContainerTargets(this.instance);
|
|
16638
16652
|
const layerToMove = checkIfOverContainer(this.instance, e.target);
|
|
16639
16653
|
if (layerToMove) layerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
|
|
16654
|
+
const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
|
|
16655
|
+
this.instance.updateNode(nodeHandler.serialize(node));
|
|
16640
16656
|
}
|
|
16641
16657
|
};
|
|
16642
|
-
node.on("dragmove", (0, import_lodash.throttle)(handleDragMove,
|
|
16658
|
+
node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
|
|
16643
16659
|
node.on("dragend", (e) => {
|
|
16644
16660
|
if (this.isSelecting() && this.isNodeSelected(node)) {
|
|
16645
16661
|
clearContainerTargets(this.instance);
|
|
@@ -18139,7 +18155,7 @@ var WeaveRegisterManager = class {
|
|
|
18139
18155
|
|
|
18140
18156
|
//#endregion
|
|
18141
18157
|
//#region package.json
|
|
18142
|
-
var version = "0.
|
|
18158
|
+
var version = "0.28.0";
|
|
18143
18159
|
|
|
18144
18160
|
//#endregion
|
|
18145
18161
|
//#region src/managers/setup.ts
|
|
@@ -19643,8 +19659,9 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
19643
19659
|
this.imageId = v4_default();
|
|
19644
19660
|
this.imageURL = imageURL;
|
|
19645
19661
|
this.preloadImgs[this.imageId] = new Image();
|
|
19646
|
-
this.preloadImgs[this.imageId].onerror = (
|
|
19647
|
-
|
|
19662
|
+
this.preloadImgs[this.imageId].onerror = () => {
|
|
19663
|
+
this.instance.emitEvent("onImageLoadEnd", new Error("Error loading image"));
|
|
19664
|
+
this.cancelAction();
|
|
19648
19665
|
};
|
|
19649
19666
|
this.preloadImgs[this.imageId].onload = () => {
|
|
19650
19667
|
this.instance.emitEvent("onImageLoadEnd", void 0);
|
|
@@ -19656,10 +19673,6 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
19656
19673
|
};
|
|
19657
19674
|
this.addImageNode(position);
|
|
19658
19675
|
};
|
|
19659
|
-
this.preloadImgs[this.imageId].onerror = () => {
|
|
19660
|
-
this.instance.emitEvent("onImageLoadEnd", new Error("Error loading image"));
|
|
19661
|
-
this.cancelAction();
|
|
19662
|
-
};
|
|
19663
19676
|
this.preloadImgs[this.imageId].src = imageURL;
|
|
19664
19677
|
this.instance.emitEvent("onImageLoadStart");
|
|
19665
19678
|
}
|
|
@@ -20625,64 +20638,6 @@ var WeaveRegularPolygonNode = class extends WeaveNode {
|
|
|
20625
20638
|
//#endregion
|
|
20626
20639
|
//#region src/nodes/frame/constants.ts
|
|
20627
20640
|
const WEAVE_FRAME_NODE_TYPE = "frame";
|
|
20628
|
-
const WEAVE_FRAME_NODE_SIZES_MULTIPLIER = 5;
|
|
20629
|
-
const WEAVE_FRAME_NODE_SIZES_ORIENTATION = {
|
|
20630
|
-
landscape: "landscape",
|
|
20631
|
-
portrait: "portrait"
|
|
20632
|
-
};
|
|
20633
|
-
const WEAVE_FRAME_NODE_SIZES_TYPES = {
|
|
20634
|
-
A1: "A1",
|
|
20635
|
-
A2: "A2",
|
|
20636
|
-
A3: "A3",
|
|
20637
|
-
A4: "A4",
|
|
20638
|
-
CUSTOM: "custom"
|
|
20639
|
-
};
|
|
20640
|
-
const WEAVE_FRAME_NODE_SIZES = {
|
|
20641
|
-
landscape: {
|
|
20642
|
-
A1: {
|
|
20643
|
-
width: 841,
|
|
20644
|
-
height: 594
|
|
20645
|
-
},
|
|
20646
|
-
A2: {
|
|
20647
|
-
width: 592,
|
|
20648
|
-
height: 420
|
|
20649
|
-
},
|
|
20650
|
-
A3: {
|
|
20651
|
-
width: 420,
|
|
20652
|
-
height: 297
|
|
20653
|
-
},
|
|
20654
|
-
A4: {
|
|
20655
|
-
width: 297,
|
|
20656
|
-
height: 210
|
|
20657
|
-
},
|
|
20658
|
-
custom: {
|
|
20659
|
-
width: 0,
|
|
20660
|
-
height: 0
|
|
20661
|
-
}
|
|
20662
|
-
},
|
|
20663
|
-
portrait: {
|
|
20664
|
-
A1: {
|
|
20665
|
-
width: 594,
|
|
20666
|
-
height: 841
|
|
20667
|
-
},
|
|
20668
|
-
A2: {
|
|
20669
|
-
width: 420,
|
|
20670
|
-
height: 594
|
|
20671
|
-
},
|
|
20672
|
-
A3: {
|
|
20673
|
-
width: 297,
|
|
20674
|
-
height: 420
|
|
20675
|
-
},
|
|
20676
|
-
A4: {
|
|
20677
|
-
width: 210,
|
|
20678
|
-
height: 297
|
|
20679
|
-
},
|
|
20680
|
-
custom: {
|
|
20681
|
-
width: 0,
|
|
20682
|
-
height: 0
|
|
20683
|
-
}
|
|
20684
|
-
}
|
|
20685
|
-
};
|
|
20686
20641
|
const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
|
|
20687
20642
|
fontFamily: "Arial",
|
|
20688
20643
|
fontStyle: "bold",
|
|
@@ -20709,10 +20664,8 @@ const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
|
|
|
20709
20664
|
};
|
|
20710
20665
|
const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
|
|
20711
20666
|
title: "Frame XXX",
|
|
20712
|
-
frameWidth:
|
|
20713
|
-
frameHeight:
|
|
20714
|
-
frameType: WEAVE_FRAME_NODE_SIZES_TYPES.A4,
|
|
20715
|
-
frameOrientation: WEAVE_FRAME_NODE_SIZES_ORIENTATION.landscape
|
|
20667
|
+
frameWidth: 1920,
|
|
20668
|
+
frameHeight: 1080
|
|
20716
20669
|
};
|
|
20717
20670
|
|
|
20718
20671
|
//#endregion
|
|
@@ -20740,8 +20693,6 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
20740
20693
|
...props.title && { title: props.title },
|
|
20741
20694
|
...props.frameWidth && { frameWidth: props.frameWidth },
|
|
20742
20695
|
...props.frameHeight && { frameHeight: props.frameHeight },
|
|
20743
|
-
...props.frameType && { frameType: props.frameType },
|
|
20744
|
-
...props.frameOrientation && { frameOrientation: props.frameOrientation },
|
|
20745
20696
|
children: []
|
|
20746
20697
|
}
|
|
20747
20698
|
};
|
|
@@ -20989,10 +20940,10 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
20989
20940
|
serialize(instance) {
|
|
20990
20941
|
const stage = this.instance.getStage();
|
|
20991
20942
|
const attrs = instance.getAttrs();
|
|
20992
|
-
let mainNode =
|
|
20993
|
-
if (attrs.id?.indexOf("-selector-area") !== -1) mainNode = stage
|
|
20994
|
-
let frameInternal =
|
|
20995
|
-
if (attrs.id?.indexOf("-selector-area") !== -1) frameInternal =
|
|
20943
|
+
let mainNode = instance;
|
|
20944
|
+
if (attrs.id?.indexOf("-selector-area") !== -1) mainNode = stage.findOne(`#${attrs.nodeId}`);
|
|
20945
|
+
let frameInternal = stage.findOne(`#${attrs.containerId}`);
|
|
20946
|
+
if (attrs.id?.indexOf("-selector-area") !== -1) frameInternal = stage.findOne(`#${attrs.containerId}`);
|
|
20996
20947
|
const childrenMapped = [];
|
|
20997
20948
|
if (frameInternal) {
|
|
20998
20949
|
const children = [...frameInternal.getChildren()];
|
|
@@ -23842,6 +23793,7 @@ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
|
|
|
23842
23793
|
return stage.findOne(`#${this.getLayerName()}`);
|
|
23843
23794
|
}
|
|
23844
23795
|
onInit() {
|
|
23796
|
+
const stage = this.instance.getStage();
|
|
23845
23797
|
this.instance.addEventListener("onAwarenessChange", (changes) => {
|
|
23846
23798
|
const selfUser = this.config.getUser();
|
|
23847
23799
|
const allActiveUsers = [];
|
|
@@ -23850,15 +23802,18 @@ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
|
|
|
23850
23802
|
if (change[WEAVE_USER_SELECTION_KEY] && selfUser.name !== change[WEAVE_USER_SELECTION_KEY].user) {
|
|
23851
23803
|
const userSelection = change[WEAVE_USER_SELECTION_KEY];
|
|
23852
23804
|
allActiveUsers.push(userSelection.user);
|
|
23853
|
-
this.usersSelection[userSelection.user] =
|
|
23854
|
-
oldNodes: this.usersSelection[userSelection.user]?.actualNodes ?? {
|
|
23855
|
-
user: userSelection.user,
|
|
23856
|
-
nodes: []
|
|
23857
|
-
},
|
|
23858
|
-
actualNodes: userSelection
|
|
23859
|
-
};
|
|
23805
|
+
this.usersSelection[userSelection.user] = userSelection;
|
|
23860
23806
|
}
|
|
23861
23807
|
}
|
|
23808
|
+
const allNodesSelections = Object.keys(this.usersSelection);
|
|
23809
|
+
const inactiveUsers = allNodesSelections.filter((user) => !allNodesSelections.includes(user));
|
|
23810
|
+
for (let i = 0; i < inactiveUsers.length; i++) delete this.usersSelection[inactiveUsers[i]];
|
|
23811
|
+
this.renderSelectors();
|
|
23812
|
+
});
|
|
23813
|
+
stage.on("dragstart dragmove dragend", () => {
|
|
23814
|
+
this.renderSelectors();
|
|
23815
|
+
});
|
|
23816
|
+
stage.on("transformstart transform transformend", () => {
|
|
23862
23817
|
this.renderSelectors();
|
|
23863
23818
|
});
|
|
23864
23819
|
this.renderSelectors();
|
|
@@ -23875,18 +23830,6 @@ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
|
|
|
23875
23830
|
const store = this.instance.getStore();
|
|
23876
23831
|
store.setAwarenessInfo(WEAVE_USER_SELECTION_KEY, void 0);
|
|
23877
23832
|
}
|
|
23878
|
-
stringToColor(str) {
|
|
23879
|
-
let hash = 0;
|
|
23880
|
-
str.split("").forEach((char) => {
|
|
23881
|
-
hash = char.charCodeAt(0) + ((hash << 5) - hash);
|
|
23882
|
-
});
|
|
23883
|
-
let color = "#";
|
|
23884
|
-
for (let i = 0; i < 3; i++) {
|
|
23885
|
-
const value = hash >> i * 8 & 255;
|
|
23886
|
-
color += value.toString(16).padStart(2, "0");
|
|
23887
|
-
}
|
|
23888
|
-
return color;
|
|
23889
|
-
}
|
|
23890
23833
|
getSelectedNodesRect(nodes) {
|
|
23891
23834
|
const stage = this.instance.getStage();
|
|
23892
23835
|
const maxPoint = {
|
|
@@ -23925,10 +23868,10 @@ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
|
|
|
23925
23868
|
for (const selector of selectors) selector.destroy();
|
|
23926
23869
|
for (const userPointerKey of Object.keys(this.usersSelection)) {
|
|
23927
23870
|
const userSelector = this.usersSelection[userPointerKey];
|
|
23928
|
-
const selectionRect = this.getSelectedNodesRect(userSelector.
|
|
23871
|
+
const selectionRect = this.getSelectedNodesRect(userSelector.nodes);
|
|
23929
23872
|
const userSelectorNode = new konva.default.Group({
|
|
23930
23873
|
name: "selector",
|
|
23931
|
-
id: `selector_${userSelector.
|
|
23874
|
+
id: `selector_${userSelector.user}`,
|
|
23932
23875
|
x: selectionRect.x,
|
|
23933
23876
|
y: selectionRect.y,
|
|
23934
23877
|
listening: false
|
|
@@ -23937,12 +23880,12 @@ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
|
|
|
23937
23880
|
const userSelectorRect = new konva.default.Rect({
|
|
23938
23881
|
x: -this.padding / stage.scaleX(),
|
|
23939
23882
|
y: -this.padding / stage.scaleY(),
|
|
23940
|
-
id: `selector_${userSelector.
|
|
23883
|
+
id: `selector_${userSelector.user}_rect`,
|
|
23941
23884
|
width: (selectionRect.width + 2 * this.padding) / stage.scaleX(),
|
|
23942
23885
|
height: (selectionRect.height + 2 * this.padding) / stage.scaleY(),
|
|
23943
23886
|
fill: "transparent",
|
|
23944
23887
|
listening: false,
|
|
23945
|
-
stroke:
|
|
23888
|
+
stroke: stringToColor(userSelector.user),
|
|
23946
23889
|
strokeWidth: 3,
|
|
23947
23890
|
strokeScaleEnabled: false
|
|
23948
23891
|
});
|
|
@@ -24033,14 +23976,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
24033
23976
|
if (change[WEAVE_USER_POINTER_KEY] && selfUser.name !== change[WEAVE_USER_POINTER_KEY].user) {
|
|
24034
23977
|
const userPointer = change[WEAVE_USER_POINTER_KEY];
|
|
24035
23978
|
allActiveUsers.push(userPointer.user);
|
|
24036
|
-
this.usersPointers[userPointer.user] =
|
|
24037
|
-
oldPos: this.usersPointers[userPointer.user]?.actualPos ?? {
|
|
24038
|
-
user: userPointer.user,
|
|
24039
|
-
x: 0,
|
|
24040
|
-
y: 0
|
|
24041
|
-
},
|
|
24042
|
-
actualPos: userPointer
|
|
24043
|
-
};
|
|
23979
|
+
this.usersPointers[userPointer.user] = userPointer;
|
|
24044
23980
|
}
|
|
24045
23981
|
}
|
|
24046
23982
|
const allPointers = Object.keys(this.usersPointers);
|
|
@@ -24070,26 +24006,6 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
24070
24006
|
});
|
|
24071
24007
|
this.renderPointers();
|
|
24072
24008
|
}
|
|
24073
|
-
getContrastTextColor(hex) {
|
|
24074
|
-
const cleaned = hex.replace(/^#/, "");
|
|
24075
|
-
const r = parseInt(cleaned.slice(0, 2), 16);
|
|
24076
|
-
const g = parseInt(cleaned.slice(2, 4), 16);
|
|
24077
|
-
const b = parseInt(cleaned.slice(4, 6), 16);
|
|
24078
|
-
const luminance = (.299 * r + .587 * g + .114 * b) / 255;
|
|
24079
|
-
return luminance > .5 ? "black" : "white";
|
|
24080
|
-
}
|
|
24081
|
-
stringToColor(str) {
|
|
24082
|
-
let hash = 0;
|
|
24083
|
-
str.split("").forEach((char) => {
|
|
24084
|
-
hash = char.charCodeAt(0) + ((hash << 5) - hash);
|
|
24085
|
-
});
|
|
24086
|
-
let color = "#";
|
|
24087
|
-
for (let i = 0; i < 3; i++) {
|
|
24088
|
-
const value = hash >> i * 8 & 255;
|
|
24089
|
-
color += value.toString(16).padStart(2, "0");
|
|
24090
|
-
}
|
|
24091
|
-
return color;
|
|
24092
|
-
}
|
|
24093
24009
|
renderPointers() {
|
|
24094
24010
|
const stage = this.instance.getStage();
|
|
24095
24011
|
const pointersLayer = this.getLayer();
|
|
@@ -24100,9 +24016,9 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
24100
24016
|
const userPointer = this.usersPointers[userPointerKey];
|
|
24101
24017
|
const userPointerNode = new konva.default.Group({
|
|
24102
24018
|
name: "pointer",
|
|
24103
|
-
id: `pointer_${userPointer.
|
|
24104
|
-
x: userPointer.
|
|
24105
|
-
y: userPointer.
|
|
24019
|
+
id: `pointer_${userPointer.user}`,
|
|
24020
|
+
x: userPointer.x,
|
|
24021
|
+
y: userPointer.y,
|
|
24106
24022
|
opacity: 1,
|
|
24107
24023
|
listening: false,
|
|
24108
24024
|
scaleX: 1 / stage.scaleX(),
|
|
@@ -24110,10 +24026,10 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
24110
24026
|
});
|
|
24111
24027
|
userPointerNode.moveToTop();
|
|
24112
24028
|
const { separation, pointer: { circleRadius, circleStrokeWidth }, name: { fontFamily, fontSize, backgroundCornerRadius, backgroundPaddingX, backgroundPaddingY } } = this.uiConfig;
|
|
24113
|
-
const userColor =
|
|
24114
|
-
const userContrastColor =
|
|
24029
|
+
const userColor = stringToColor(userPointer.user);
|
|
24030
|
+
const userContrastColor = getContrastTextColor(userColor);
|
|
24115
24031
|
const userPointNode = new konva.default.Circle({
|
|
24116
|
-
id: `pointer_${userPointer.
|
|
24032
|
+
id: `pointer_${userPointer.user}_userPoint`,
|
|
24117
24033
|
x: 0,
|
|
24118
24034
|
y: 0,
|
|
24119
24035
|
radius: circleRadius,
|
|
@@ -24124,10 +24040,10 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
24124
24040
|
listening: false
|
|
24125
24041
|
});
|
|
24126
24042
|
const userNameNode = new konva.default.Text({
|
|
24127
|
-
id: `pointer_${userPointer.
|
|
24043
|
+
id: `pointer_${userPointer.user}_userPointName`,
|
|
24128
24044
|
x: separation,
|
|
24129
24045
|
y: -circleRadius * 2 + backgroundPaddingY,
|
|
24130
|
-
text: userPointer.
|
|
24046
|
+
text: userPointer.user.trim(),
|
|
24131
24047
|
fontSize,
|
|
24132
24048
|
fontFamily,
|
|
24133
24049
|
lineHeight: .9,
|
|
@@ -24143,7 +24059,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
24143
24059
|
userNameNode.width(textWidth + backgroundPaddingX * 2);
|
|
24144
24060
|
userNameNode.height(textHeight + backgroundPaddingY * 2);
|
|
24145
24061
|
const userNameBackground = new konva.default.Rect({
|
|
24146
|
-
id: `pointer_${userPointer.
|
|
24062
|
+
id: `pointer_${userPointer.user}_userPointRect`,
|
|
24147
24063
|
x: separation,
|
|
24148
24064
|
y: -backgroundPaddingY,
|
|
24149
24065
|
width: textWidth + backgroundPaddingX * 2,
|
|
@@ -24297,7 +24213,10 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
24297
24213
|
node = nodesSelectionPlugin.getTransformer();
|
|
24298
24214
|
skipNodes = [...nodes];
|
|
24299
24215
|
}
|
|
24300
|
-
if (e.type === "transform")
|
|
24216
|
+
if (e.type === "transform") {
|
|
24217
|
+
node = e.target;
|
|
24218
|
+
skipNodes.push(node.getAttrs().id ?? "");
|
|
24219
|
+
}
|
|
24301
24220
|
if (typeof node === "undefined") return;
|
|
24302
24221
|
const lineGuideStops = this.getLineGuideStops(skipNodes);
|
|
24303
24222
|
const itemBounds = this.getObjectSnappingEdges(node);
|
|
@@ -24612,10 +24531,6 @@ exports.WEAVE_DEFAULT_USER_INFO_FUNCTION = WEAVE_DEFAULT_USER_INFO_FUNCTION
|
|
|
24612
24531
|
exports.WEAVE_ELLIPSE_NODE_TYPE = WEAVE_ELLIPSE_NODE_TYPE
|
|
24613
24532
|
exports.WEAVE_FRAME_NODE_DEFAULT_CONFIG = WEAVE_FRAME_NODE_DEFAULT_CONFIG
|
|
24614
24533
|
exports.WEAVE_FRAME_NODE_DEFAULT_PROPS = WEAVE_FRAME_NODE_DEFAULT_PROPS
|
|
24615
|
-
exports.WEAVE_FRAME_NODE_SIZES = WEAVE_FRAME_NODE_SIZES
|
|
24616
|
-
exports.WEAVE_FRAME_NODE_SIZES_MULTIPLIER = WEAVE_FRAME_NODE_SIZES_MULTIPLIER
|
|
24617
|
-
exports.WEAVE_FRAME_NODE_SIZES_ORIENTATION = WEAVE_FRAME_NODE_SIZES_ORIENTATION
|
|
24618
|
-
exports.WEAVE_FRAME_NODE_SIZES_TYPES = WEAVE_FRAME_NODE_SIZES_TYPES
|
|
24619
24534
|
exports.WEAVE_FRAME_NODE_TYPE = WEAVE_FRAME_NODE_TYPE
|
|
24620
24535
|
exports.WEAVE_GRID_DEFAULT_COLOR = WEAVE_GRID_DEFAULT_COLOR
|
|
24621
24536
|
exports.WEAVE_GRID_DEFAULT_ORIGIN_COLOR = WEAVE_GRID_DEFAULT_ORIGIN_COLOR
|
|
@@ -24692,5 +24607,7 @@ exports.WeaveZoomInToolAction = WeaveZoomInToolAction
|
|
|
24692
24607
|
exports.WeaveZoomOutToolAction = WeaveZoomOutToolAction
|
|
24693
24608
|
exports.checkIfOverContainer = checkIfOverContainer
|
|
24694
24609
|
exports.clearContainerTargets = clearContainerTargets
|
|
24610
|
+
exports.getContrastTextColor = getContrastTextColor
|
|
24695
24611
|
exports.moveNodeToContainer = moveNodeToContainer
|
|
24696
|
-
exports.resetScale = resetScale
|
|
24612
|
+
exports.resetScale = resetScale
|
|
24613
|
+
exports.stringToColor = stringToColor
|