@cocreate/socket 0.0.0-stage → 3.0.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/.github/FUNDING.yml +3 -0
- package/.github/workflows/automated.yml +69 -0
- package/CHANGELOG.md +1412 -0
- package/CONTRIBUTING.md +97 -0
- package/CoCreate.config.js +23 -0
- package/LICENSE +683 -0
- package/README.md +245 -3
- package/demo/server.js +24 -0
- package/docs/index.html +217 -0
- package/package.json +50 -4
- package/prettier.config.js +16 -0
- package/release.config.js +30 -0
- package/src/client/index.js +785 -0
- package/src/index.js +2 -0
- package/src/server/index.js +1115 -0
- package/src/server/sockets.js +149 -0
- package/test/client/transport.test.js +84 -0
- package/test/server/collections.test.js +111 -0
- package/test/server/send.test.js +257 -0
package/README.md
CHANGED
|
@@ -1,3 +1,245 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# CoCreate Socket
|
|
2
|
+
|
|
3
|
+
Client and server WebSocket interfaces for CoCreate. Send JSON envelopes from browsers or Node.js, route them through application handlers and the server mesh, and relay responses across browser contexts.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Documentation
|
|
8
|
+
|
|
9
|
+
For complete API references, protocol event schemas, configuration guides, and examples, visit the **[CoCreate Socket Documentation](https://cocreatejs.com/docs/socket)**.
|
|
10
|
+
|
|
11
|
+
## Table of Contents
|
|
12
|
+
|
|
13
|
+
- [Documentation](#documentation)
|
|
14
|
+
- [Client and server exports](#client-and-server-exports)
|
|
15
|
+
- [Client usage](#client-usage)
|
|
16
|
+
- [Client routing controls](#client-routing-controls)
|
|
17
|
+
- [Browser-context delivery](#browser-context-delivery)
|
|
18
|
+
- [Connection](#connection)
|
|
19
|
+
- [Socket collection](#socket-collection)
|
|
20
|
+
- [Message routing](#message-routing)
|
|
21
|
+
- [Client and socket selection](#client-and-socket-selection)
|
|
22
|
+
- [Authorization](#authorization)
|
|
23
|
+
- [Server mesh](#server-mesh)
|
|
24
|
+
- [Heartbeat and disconnection](#heartbeat-and-disconnection)
|
|
25
|
+
- [Installation](#installation)
|
|
26
|
+
- [Announcements and roadmap](#announcements-and-roadmap)
|
|
27
|
+
- [About](#about)
|
|
28
|
+
- [Tests](#tests)
|
|
29
|
+
- [How to Contribute](#how-to-contribute)
|
|
30
|
+
- [License](#license)
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Client and server exports
|
|
35
|
+
|
|
36
|
+
This package now contains both implementations under `src/client/` and `src/server/`. Both roles share one package and retain their own transport lifecycle.
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import { SocketServer, SocketClient } from "@cocreate/socket";
|
|
40
|
+
|
|
41
|
+
// Separate entry points:
|
|
42
|
+
import Server from "@cocreate/socket/server";
|
|
43
|
+
import Client from "@cocreate/socket/client";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The Node entry exports both roles. Browser builds resolve the client entry without loading Node server dependencies. The root default export is SocketClient for compatibility with generated CoCreate dependency loaders. The client retains its existing initialization on import. Use the server entry point to import only the server.
|
|
47
|
+
|
|
48
|
+
## Client usage
|
|
49
|
+
|
|
50
|
+
Messages use one envelope. The `method` selects the event or operation and the remaining properties contain its payload.
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import { SocketClient } from "@cocreate/socket";
|
|
54
|
+
|
|
55
|
+
const response = await SocketClient.send({
|
|
56
|
+
method: "notification",
|
|
57
|
+
message: "The workspace was updated",
|
|
58
|
+
broadcast: false,
|
|
59
|
+
broadcastClient: true
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The socket client automatically supplies connection metadata including `clientId`, `frameId`, `socketId`, `organization_id`, `uuid`, and `timeStamp`.
|
|
64
|
+
|
|
65
|
+
## Client routing controls
|
|
66
|
+
|
|
67
|
+
- `clientId` identifies the browser and is shared by its tabs, windows, and same-origin frames.
|
|
68
|
+
- `frameId` identifies one client runtime, such as a tab, window, or iframe.
|
|
69
|
+
- `socketId` identifies an individual WebSocket instance. It is generated for each socket and is not shared through session storage.
|
|
70
|
+
- `broadcast` controls server delivery. `false` targets the originating or selected client; `true` targets eligible clients in the organization.
|
|
71
|
+
- `broadcastClient` controls whether a received server message is relayed to the browser's other same-origin contexts.
|
|
72
|
+
- `broadcastSender: false` prevents the originating frame from firing normal method listeners for the response. The response still returns and resolves its UUID promise.
|
|
73
|
+
|
|
74
|
+
The socket server sends to one connected socket for each selected `clientId`. If one socket cannot be reached, it can try another socket belonging to that client. Browser-context distribution is then handled by the client when `broadcastClient` is enabled.
|
|
75
|
+
|
|
76
|
+
## Browser-context delivery
|
|
77
|
+
|
|
78
|
+
The client stores the complete relay payload in the `localSocketMessages` array of the shared `system` IndexedDB database. The `messageQueue` array uses the same internal database. Records retain `organization_id` for organization-scoped filtering, while application databases remain free of socket transport state. The client writes only the record ID and organization ID to the `localSocketMessage` local-storage key, allowing other contexts to retrieve the message without being constrained by local-storage value limits.
|
|
79
|
+
|
|
80
|
+
The native `storage` event fires in the other same-origin contexts, not in the context that performed the write. The receiving contexts read the IndexedDB record and fire their local listeners. Each new relay also removes records older than five seconds.
|
|
81
|
+
|
|
82
|
+
## Connection
|
|
83
|
+
|
|
84
|
+
Initialize the socket manager with a CoCreate server instance. The server supplies its HTTP and/or HTTPS upgrade source along with optional authentication, authorization, usage, and mesh services.
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
import { SocketServer } from "@cocreate/socket";
|
|
88
|
+
|
|
89
|
+
const wsManager = await SocketServer.init(server);
|
|
90
|
+
server.wsManager = wsManager; // Existing integrations remain supported.
|
|
91
|
+
server.socket = wsManager.collection;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The first WebSocket URL path segment is the `organization_id`. Connection options can be supplied as query parameters or as an encoded JSON WebSocket protocol value. Socket-client supplies `socketId`, `clientId`, client information, user information, and an authentication token.
|
|
95
|
+
|
|
96
|
+
The server groups each connection as:
|
|
97
|
+
|
|
98
|
+
```text
|
|
99
|
+
organization_id -> clientId -> socketId -> WebSocket
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
- `clientId` identifies a browser client and may have multiple connected sockets.
|
|
103
|
+
- `socketId` identifies one WebSocket connection.
|
|
104
|
+
- `frameId` identifies the originating client runtime, but is message metadata rather than a server-side delivery selector.
|
|
105
|
+
|
|
106
|
+
## Socket collection
|
|
107
|
+
|
|
108
|
+
CoCreate Server exposes `server.socket` over the existing manager's live indexes and delivery implementation.
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
server.socket.get(socketId); // Original WebSocket object.
|
|
112
|
+
server.socket.set(socketId, { label: "editor" });
|
|
113
|
+
server.socket.size; // Live sockets in this process.
|
|
114
|
+
server.socket.send(envelope);
|
|
115
|
+
server.socket.delete(socketId); // Close and clean up.
|
|
116
|
+
server.socket.clients.get(clientId)?.get(socketId);
|
|
117
|
+
server.socket.organizations.get(organizationId)?.clients.get(clientId);
|
|
118
|
+
server.socket.organizations.get(organizationId)?.subscriptions;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Socket collections support `get`, `has`, `add`, `set`, `delete`, `clear`, `size`, and iteration. `set` updates metadata in place without replacing transport methods, identity, or bookkeeping. It does not create missing sockets.
|
|
122
|
+
|
|
123
|
+
Client and organization collections support `get`, `has`, `add`, `delete`, `clear`, `size`, and iteration. All `add` methods accept an already authenticated WebSocket with `id`, `clientId`, and `organization_id`, using the existing connection lifecycle. Root `add` returns the socket; client and organization `add` return their corresponding record. Re-adding the same socket is idempotent; conflicting socket IDs are rejected.
|
|
124
|
+
|
|
125
|
+
Client deletion closes its sockets using the normal organization disconnect grace period. Organization deletion immediately evicts its sockets and presence. Operations preserve the existing `orgConnected` and `orgDisconnected` event flow. `wsManager` remains available for existing integrations.
|
|
126
|
+
|
|
127
|
+
## Message routing
|
|
128
|
+
|
|
129
|
+
Messages are JSON objects and must contain `method`. The same envelope is passed through application handlers and returned to clients.
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
{
|
|
133
|
+
method: "notification",
|
|
134
|
+
message: "The workspace was updated",
|
|
135
|
+
organization_id: "ORGANIZATION_ID",
|
|
136
|
+
clientId: "CLIENT_ID",
|
|
137
|
+
broadcast: false
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Incoming envelopes are dispatched as follows:
|
|
142
|
+
|
|
143
|
+
- `api` envelopes emit the `api` event.
|
|
144
|
+
- CRUD methods beginning with `storage`, `database`, `array`, `index`, or `object` emit their complete method name.
|
|
145
|
+
- `crdt` and `cursor` messages enter `server.send()`.
|
|
146
|
+
- Other messages emit the top-level portion of `method`.
|
|
147
|
+
|
|
148
|
+
## Client and socket selection
|
|
149
|
+
|
|
150
|
+
`send(data)` resolves recipients by organization and client:
|
|
151
|
+
|
|
152
|
+
- `broadcast: true` selects every client in the organization.
|
|
153
|
+
- `socketId` identifies the originating socket and its client.
|
|
154
|
+
- A server-originated direct message can provide `clientId` as one string or an array of strings.
|
|
155
|
+
|
|
156
|
+
For each selected client, the server attempts its connected sockets in order and stops after the first successful write. The originating socket is tried first for its client, including subscription delivery. Subscription matches select clients, with other sockets for those clients available as fallbacks. A write succeeds only when the WebSocket send callback reports no error. This provides socket failover without sending duplicate copies to every socket belonging to the same browser client.
|
|
157
|
+
|
|
158
|
+
`broadcastClient` and `broadcastSender` are forwarded to socket-client. Browser-context relaying and originating-frame listener suppression are handled on the client; they do not change socket selection on the server.
|
|
159
|
+
|
|
160
|
+
## Authorization
|
|
161
|
+
|
|
162
|
+
When authentication is configured, the connection token is decoded and a successfully authenticated socket receives `socket.user_id`. When authorization is configured, incoming messages are checked before dispatch and outgoing messages are checked once per selected client before a socket write is attempted.
|
|
163
|
+
|
|
164
|
+
Incoming messages receive trusted `user_id`, `socketId`, `clientId`, `organization_id`, and `host` values from the connection. A `socket` payload field has no transport meaning and is preserved as ordinary application data. Authorization receives the authenticated user separately. `replyOrganizationId` is also stamped by the server so CRUD can restore the connection's reply scope when authorization redirects an operation to platform storage; it is removed from outgoing socket messages.
|
|
165
|
+
|
|
166
|
+
Activity writes use `log: false`, and records in `activities` do not generate further activity records.
|
|
167
|
+
|
|
168
|
+
Authorization may reject a message or return an authorized envelope. The authorized envelope becomes the payload delivered to that client.
|
|
169
|
+
|
|
170
|
+
## Server mesh
|
|
171
|
+
|
|
172
|
+
Components send responses through `server.send(envelope)`. The coordinator starts
|
|
173
|
+
local `server.socket.send()` delivery, IPC delivery to the organization's workers,
|
|
174
|
+
and primary-owned `server.cluster.send()` forwarding without waiting for the
|
|
175
|
+
local socket loop first. Receiving workers call their local socket transport.
|
|
176
|
+
Socket send does not call server send, so no socket forwarding flag is needed.
|
|
177
|
+
`workerId` and `serverId` identify the origin to prevent duplicate delivery.
|
|
178
|
+
|
|
179
|
+
Direct `server.socket.send()` delivers only to this process's clients. Its Promise
|
|
180
|
+
resolves to `undefined` after local authorization and write attempts; awaiting it
|
|
181
|
+
does not wait for a client application response. Use `server.send()` for normal
|
|
182
|
+
component responses and cross-worker or peer delivery.
|
|
183
|
+
|
|
184
|
+
## Heartbeat and disconnection
|
|
185
|
+
|
|
186
|
+
The server sends WebSocket ping frames every 30 seconds. Connections that do not answer with a pong before the next heartbeat are terminated and removed from the organization, client, socket, and user maps. Reconnection and queued client messages are managed by socket-client rather than buffered by the server.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Installation
|
|
191
|
+
|
|
192
|
+
### npm
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
npm install @cocreate/socket
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Yarn
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
yarn add @cocreate/socket
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Announcements and roadmap
|
|
207
|
+
|
|
208
|
+
Updates are recorded in [CHANGELOG.md](./CHANGELOG.md) and [GitHub releases](https://github.com/CoCreateJS/socket/releases). Follow [issues](https://github.com/CoCreateJS/socket/issues) and [pull requests](https://github.com/CoCreateJS/socket/pulls) for planned work and feedback.
|
|
209
|
+
|
|
210
|
+
## About
|
|
211
|
+
|
|
212
|
+
CoCreate Socket is maintained and funded by CoCreate and supported by the CoCreate Developer Experience Team. Contact [develop@CoCreateJS.com](mailto:develop@CoCreateJS.com) with questions. CoCreate names and logos are trademarks of CoCreate, LLC.
|
|
213
|
+
|
|
214
|
+
## Tests
|
|
215
|
+
|
|
216
|
+
Tests are grouped by transport role under `test/server/` and `test/client/`.
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npm test # Both roles.
|
|
220
|
+
npm run test:server # Server collections and delivery.
|
|
221
|
+
npm run test:client # Client indexes and transport round trips.
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## How to Contribute
|
|
225
|
+
|
|
226
|
+
We encourage contributions to all CoCreate libraries. Please see our
|
|
227
|
+
[CONTRIBUTING.md](https://github.com/CoCreateJS/socket/blob/master/CONTRIBUTING.md)
|
|
228
|
+
guide for development workflows and contribution guidelines.
|
|
229
|
+
|
|
230
|
+
If you discover a bug or would like to request a feature, please open an issue on our
|
|
231
|
+
[GitHub Issues](https://github.com/CoCreateJS/socket/issues)
|
|
232
|
+
tracker.
|
|
233
|
+
|
|
234
|
+
For complete documentation, examples, and integration guides, visit:
|
|
235
|
+
|
|
236
|
+
https://cocreatejs.com/docs/socket
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
This software is dual-licensed under the GNU Affero General Public License version 3 (AGPLv3) and a commercial license.
|
|
243
|
+
|
|
244
|
+
- **Open Source Use:** For open-source projects and non-commercial use, this software is available under the AGPLv3. See the LICENSE file for the complete license text.
|
|
245
|
+
- **Commercial Use:** Commercial users must obtain a commercial license. Commercial licenses are available when signing up for an API key through the CoCreate platform.
|
package/demo/server.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const express = require('express');
|
|
3
|
+
const cors = require('cors')
|
|
4
|
+
const urlencoded = require('body-parser').urlencoded;
|
|
5
|
+
|
|
6
|
+
const app = express();
|
|
7
|
+
app.use(cors())
|
|
8
|
+
app.use(urlencoded({ extended: false }));
|
|
9
|
+
|
|
10
|
+
const socketServer = require("@cocreate/socket")
|
|
11
|
+
const wsManager = new socketServer("ws");
|
|
12
|
+
|
|
13
|
+
const { createServer } = require('http');
|
|
14
|
+
const server = createServer(app);
|
|
15
|
+
server.on('upgrade', function upgrade(request, socket, head) {
|
|
16
|
+
if (!wsManager.handleUpgrade(request, socket, head)) {
|
|
17
|
+
socket.destroy();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const components = require("./components")
|
|
22
|
+
components.init(app, wsManager)
|
|
23
|
+
|
|
24
|
+
server.listen(process.env.PORT || 3000);
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<title>socket Documentation | CoCreateJS</title>
|
|
8
|
+
<link
|
|
9
|
+
rel="icon"
|
|
10
|
+
type="image/png"
|
|
11
|
+
sizes="32x32"
|
|
12
|
+
href="https://CoCreateJS.com/images/favicon.ico" />
|
|
13
|
+
<meta
|
|
14
|
+
name="description"
|
|
15
|
+
content="A simple HTML5 and pure javascript component. Easy configuration using data-attributes and highly styleable." />
|
|
16
|
+
<meta
|
|
17
|
+
name="keywords"
|
|
18
|
+
content="helper classes, utility classes, css framework, css library, inline style classes" />
|
|
19
|
+
<meta name="robots" content="index,follow" />
|
|
20
|
+
|
|
21
|
+
<link rel="manifest" href="/manifest.json" />
|
|
22
|
+
</head>
|
|
23
|
+
|
|
24
|
+
<body>
|
|
25
|
+
<div array="" object="" key="" id="cocreate-socket">
|
|
26
|
+
<div
|
|
27
|
+
class="display:flex flex-wrap:wrap justify-content:space-between margin:10px">
|
|
28
|
+
<div class="display:flex align-items:center">
|
|
29
|
+
<h2>socket</h2>
|
|
30
|
+
</div>
|
|
31
|
+
<div
|
|
32
|
+
class="display:flex align-items:center font-size:20px"
|
|
33
|
+
share-height="600"
|
|
34
|
+
share-width="500"
|
|
35
|
+
share-media="https://via.placeholder.com/300/09f/fff.png">
|
|
36
|
+
<a
|
|
37
|
+
href="https://github.com/CoCreateJS/socket"
|
|
38
|
+
target="_blank"
|
|
39
|
+
class="margin-right:15px"
|
|
40
|
+
><i class="fab fa-github"></i
|
|
41
|
+
></a>
|
|
42
|
+
<a
|
|
43
|
+
class="margin-right:15px share"
|
|
44
|
+
share-network="twitter"
|
|
45
|
+
title="Share on twitter"
|
|
46
|
+
><i class="fab fa-twitter"></i
|
|
47
|
+
></a>
|
|
48
|
+
<a
|
|
49
|
+
class="margin-right:15px share"
|
|
50
|
+
share-network="facebook"
|
|
51
|
+
title="Share on Facebook"
|
|
52
|
+
><i class="fab fa-facebook"></i
|
|
53
|
+
></a>
|
|
54
|
+
<a
|
|
55
|
+
class="margin-right:15px share"
|
|
56
|
+
share-network="instagram"
|
|
57
|
+
title="Share on instagram"
|
|
58
|
+
><i class="fab fa-instagram"></i
|
|
59
|
+
></a>
|
|
60
|
+
<a
|
|
61
|
+
class="margin-right:15px share"
|
|
62
|
+
share-network="share"
|
|
63
|
+
title="Share on share"
|
|
64
|
+
><i class="fas fa-share-alt"></i
|
|
65
|
+
></a>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
<p class="max-width:500px margin:20px_10px">
|
|
69
|
+
A simple HTML5, CSS and pure javascript component. Easy
|
|
70
|
+
configuration using data-attributes and highly styleable.
|
|
71
|
+
</p>
|
|
72
|
+
<div id="socket-section" class="display:flex flex-wrap:wrap">
|
|
73
|
+
<div
|
|
74
|
+
class="flex-grow:1 min-width:300px width:50% padding:20px_10px">
|
|
75
|
+
<h2
|
|
76
|
+
class="border-bottom:1px_solid_lightgrey padding:5px_0px">
|
|
77
|
+
Install
|
|
78
|
+
</h2>
|
|
79
|
+
<pre
|
|
80
|
+
class="margin-top:15px"><code class="language-javascript">npm install @cocreate/socket</code></pre>
|
|
81
|
+
<p class="padding:10px_0px">Or you can use cdn link:</p>
|
|
82
|
+
<pre><code class="language-javascript">https://cdn.CoCreateJS.com/js/socket.min.js</code></pre>
|
|
83
|
+
|
|
84
|
+
<h2
|
|
85
|
+
class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
|
|
86
|
+
Usage
|
|
87
|
+
</h2>
|
|
88
|
+
<p class="padding:10px_0px">socket usage content</p>
|
|
89
|
+
<pre><code class="language-html"><div></div></code></pre>
|
|
90
|
+
|
|
91
|
+
<h2
|
|
92
|
+
class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
|
|
93
|
+
Reference
|
|
94
|
+
</h2>
|
|
95
|
+
<p class="padding:10px_0px">
|
|
96
|
+
This is socket reference content
|
|
97
|
+
</p>
|
|
98
|
+
<pre><code class="language-javascript"><div></div></code></pre>
|
|
99
|
+
<p class="padding:10px_0px">
|
|
100
|
+
This is socket reference content
|
|
101
|
+
</p>
|
|
102
|
+
|
|
103
|
+
<h2
|
|
104
|
+
class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
|
|
105
|
+
Attributes
|
|
106
|
+
</h2>
|
|
107
|
+
<ul class="list-style-type:none">
|
|
108
|
+
<li
|
|
109
|
+
class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
110
|
+
<h4>
|
|
111
|
+
<span>socket</span>
|
|
112
|
+
<span class="cocreate-badge success"
|
|
113
|
+
>string</span
|
|
114
|
+
>
|
|
115
|
+
<span class="cocreate-badge warning"
|
|
116
|
+
>optional</span
|
|
117
|
+
>
|
|
118
|
+
</h4>
|
|
119
|
+
<p>socket-attribute</p>
|
|
120
|
+
</li>
|
|
121
|
+
<li
|
|
122
|
+
class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
123
|
+
<h4>
|
|
124
|
+
<span>socket</span>
|
|
125
|
+
<span class="cocreate-badge success"
|
|
126
|
+
>string</span
|
|
127
|
+
>
|
|
128
|
+
<span class="cocreate-badge warning"
|
|
129
|
+
>optional</span
|
|
130
|
+
>
|
|
131
|
+
</h4>
|
|
132
|
+
<p>socket-attribute</p>
|
|
133
|
+
</li>
|
|
134
|
+
</ul>
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<div
|
|
138
|
+
class="flex-grow:1 min-width:300px width:50% padding:0px_10px margin:20px_0px border-bottom:1px_solid_lightgrey">
|
|
139
|
+
<!-- SandBox -->
|
|
140
|
+
<div
|
|
141
|
+
class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
|
|
142
|
+
id="playground">
|
|
143
|
+
<div
|
|
144
|
+
id="demo-code"
|
|
145
|
+
resizable
|
|
146
|
+
class="position:relative height:50%">
|
|
147
|
+
<textarea
|
|
148
|
+
type="code"
|
|
149
|
+
lang="html"
|
|
150
|
+
array="demos"
|
|
151
|
+
object=""
|
|
152
|
+
key="demo"
|
|
153
|
+
save="false"
|
|
154
|
+
id="demo"
|
|
155
|
+
class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
|
|
156
|
+
<div
|
|
157
|
+
resize="bottom"
|
|
158
|
+
class="background:lightgrey"></div>
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
<div
|
|
162
|
+
id="demo-preview"
|
|
163
|
+
class="position:relative overflow:auto background-color:white">
|
|
164
|
+
<div get-value="#demo" class="padding:20px"></div>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<div
|
|
168
|
+
class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
|
169
|
+
<a
|
|
170
|
+
class="margin-right:10px"
|
|
171
|
+
id="eye"
|
|
172
|
+
show="#eye-slash"
|
|
173
|
+
hide="#eye, #demo-preview"
|
|
174
|
+
toggle="code-height"
|
|
175
|
+
toggle-query="#demo-code"
|
|
176
|
+
><i class="far fa-eye"></i
|
|
177
|
+
></a>
|
|
178
|
+
<a
|
|
179
|
+
class="margin-right:10px"
|
|
180
|
+
hidden
|
|
181
|
+
id="eye-slash"
|
|
182
|
+
show="#eye, #demo-preview"
|
|
183
|
+
hide="#eye-slash"
|
|
184
|
+
toggle="code-height"
|
|
185
|
+
toggle-query="#demo-code"
|
|
186
|
+
><i class="fas fa-eye-slash"></i
|
|
187
|
+
></a>
|
|
188
|
+
<a
|
|
189
|
+
class="margin-right:10px"
|
|
190
|
+
id="code"
|
|
191
|
+
show="#code-slash"
|
|
192
|
+
hide="#code, #demo-code"
|
|
193
|
+
><i class="fa fa-code"></i
|
|
194
|
+
></a>
|
|
195
|
+
<a
|
|
196
|
+
class="margin-right:10px"
|
|
197
|
+
hidden
|
|
198
|
+
id="code-slash"
|
|
199
|
+
show="#code, #demo-code"
|
|
200
|
+
hide="#code-slash"
|
|
201
|
+
><i class="fas fa-code"></i
|
|
202
|
+
></a>
|
|
203
|
+
<a
|
|
204
|
+
class="margin-right:5px"
|
|
205
|
+
fullscreen
|
|
206
|
+
target="#playground"
|
|
207
|
+
><i class="fas fa-expand"></i
|
|
208
|
+
></a>
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
<!-- End SandBox -->
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
<script src="https://CoCreateJS.com/dist/CoCreate.js"></script>
|
|
216
|
+
</body>
|
|
217
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/socket",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Client and server WebSocket interfaces for CoCreate.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"websocket-server",
|
|
7
|
+
"real-time-collaboration",
|
|
8
|
+
"multi-tenancy",
|
|
9
|
+
"state-synchronization",
|
|
10
|
+
"cluster-mesh",
|
|
11
|
+
"headless-cms",
|
|
12
|
+
"low-latency",
|
|
13
|
+
"p2p-replication",
|
|
14
|
+
"event-streaming"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "./src/index.js",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"demo": "PORT=5000 node demo/server.js",
|
|
23
|
+
"test": "node --test",
|
|
24
|
+
"test:server": "node --test test/server/*.test.js",
|
|
25
|
+
"test:client": "node --test test/client/*.test.js"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/CoCreateJS/socket.git"
|
|
30
|
+
},
|
|
31
|
+
"author": "CoCreate LLC",
|
|
32
|
+
"license": "AGPL-3.0",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/CoCreateJS/socket/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://CoCreateJS.com/docs/socket",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@cocreate/config": "^2.0.0",
|
|
39
|
+
"@cocreate/utils": "^2.0.0",
|
|
40
|
+
"@cocreate/organizations": "^2.0.0",
|
|
41
|
+
"ws": "^8.21.1"
|
|
42
|
+
},
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"browser": "./src/client/index.js",
|
|
46
|
+
"default": "./src/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./server": "./src/server/index.js",
|
|
49
|
+
"./client": "./src/client/index.js"
|
|
50
|
+
},
|
|
51
|
+
"browser": "./src/client/index.js"
|
|
52
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
dryRun: false,
|
|
3
|
+
branches: ["main"],
|
|
4
|
+
plugins: [
|
|
5
|
+
"@semantic-release/commit-analyzer",
|
|
6
|
+
"@semantic-release/release-notes-generator",
|
|
7
|
+
[
|
|
8
|
+
"@semantic-release/changelog",
|
|
9
|
+
{
|
|
10
|
+
changelogFile: "CHANGELOG.md",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
"@semantic-release/npm",
|
|
14
|
+
[
|
|
15
|
+
"@semantic-release/github",
|
|
16
|
+
{
|
|
17
|
+
successComment: false,
|
|
18
|
+
failTitle: false,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
"@semantic-release/git",
|
|
23
|
+
{
|
|
24
|
+
// Only stage and commit the changelog and package.json
|
|
25
|
+
assets: ["CHANGELOG.md", "package.json"],
|
|
26
|
+
message: "chore(release): ${nextRelease.version} [skip ci]",
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
],
|
|
30
|
+
};
|