@inditextech/weave-store-websockets 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 +27 -239
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,279 +4,67 @@ 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 / Azure Web PubSub Store
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
This package generates the `@inditextech/weave-store-websockets` package, this package defines a client and server tools to setup Weave using native [Websockets API](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) as transport.
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
We support servers like:
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
- Express.js
|
|
14
|
+
- Koa
|
|
15
15
|
|
|
16
|
-
|
|
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.
|
|
16
|
+
## Setup
|
|
20
17
|
|
|
21
|
-
|
|
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:
|
|
18
|
+
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.
|
|
59
19
|
|
|
60
20
|
```sh
|
|
61
|
-
$
|
|
62
|
-
$ cd PROJECT
|
|
21
|
+
$ npm install
|
|
63
22
|
```
|
|
64
23
|
|
|
65
|
-
|
|
24
|
+
## Usage
|
|
66
25
|
|
|
67
|
-
|
|
68
|
-
$ npm install -S myLib
|
|
69
|
-
```
|
|
26
|
+
This is a monorepo, this commands need to be from the `/code` folder of the repo.
|
|
70
27
|
|
|
71
|
-
|
|
28
|
+
### Build the package
|
|
72
29
|
|
|
73
30
|
```sh
|
|
74
|
-
$
|
|
31
|
+
$ npm run build --workspace=@inditextech/weave-store-websockets
|
|
75
32
|
```
|
|
76
33
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
### Serving the app
|
|
34
|
+
### Link the package
|
|
80
35
|
|
|
81
36
|
```sh
|
|
82
|
-
$ npm
|
|
37
|
+
$ npm run link --workspace=@inditextech/weave-store-websockets
|
|
83
38
|
```
|
|
84
39
|
|
|
85
|
-
###
|
|
40
|
+
### Lint the package
|
|
86
41
|
|
|
87
42
|
```sh
|
|
88
|
-
$ npm
|
|
43
|
+
$ npm run lint --workspace=@inditextech/weave-store-websockets
|
|
89
44
|
```
|
|
90
45
|
|
|
91
|
-
###
|
|
46
|
+
### Test the package
|
|
92
47
|
|
|
93
48
|
```sh
|
|
94
|
-
$ npm run
|
|
49
|
+
$ npm run test --workspace=@inditextech/weave-store-websockets
|
|
95
50
|
```
|
|
96
51
|
|
|
97
|
-
|
|
98
|
-
inside your local `dist/` folder
|
|
52
|
+
### To launch a local test server
|
|
99
53
|
|
|
100
|
-
|
|
54
|
+
To launch a local test server using Express.js, use the command:
|
|
101
55
|
|
|
102
56
|
```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));
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Supported options and result fields for the `useBasicFetch` hook are listed below.
|
|
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
|
-
}
|
|
147
|
-
|
|
148
|
-
return (
|
|
149
|
-
<div className="App">
|
|
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)
|
|
57
|
+
$ npm run dev:server:express --workspace=@inditextech/weave-store-websockets
|
|
202
58
|
```
|
|
203
59
|
|
|
204
|
-
|
|
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);
|
|
60
|
+
To launch a local test server using Koa, use the command:
|
|
223
61
|
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
};
|
|
62
|
+
```sh
|
|
63
|
+
$ npm run dev:server:koa --workspace=@inditextech/weave-store-websockets
|
|
246
64
|
```
|
|
247
65
|
|
|
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
66
|
## License
|
|
281
67
|
|
|
282
|
-
[
|
|
68
|
+
This project is licensed under the terms of the [Apache-2.0](LICENSE) license.
|
|
69
|
+
|
|
70
|
+
© 2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inditextech/weave-store-websockets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"yjs": "13.6.26"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@inditextech/weave-sdk": "0.
|
|
60
|
+
"@inditextech/weave-sdk": "0.28.0",
|
|
61
61
|
"@types/express": "^5.0.1",
|
|
62
62
|
"@types/ioredis": "^4.28.10",
|
|
63
63
|
"@types/koa": "^2.15.0",
|