@design.estate/dees-comms 1.0.24 → 1.0.27
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_bundle/bundle.js +2152 -3149
- package/dist_bundle/bundle.js.map +4 -4
- package/dist_ts/00_commitinfo_data.js +3 -3
- package/dist_ts/dees-comms.classes.deescomms.js +1 -1
- package/npmextra.json +18 -2
- package/package.json +29 -17
- package/readme.hints.md +1 -0
- package/readme.md +117 -29
- package/ts/00_commitinfo_data.ts +2 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@design.estate/dees-comms',
|
|
6
|
-
version: '1.0.
|
|
7
|
-
description: '
|
|
6
|
+
version: '1.0.27',
|
|
7
|
+
description: 'A communications module for enabling DOM-based messaging and synchronization across browser tabs and workers.'
|
|
8
8
|
};
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSwyQkFBMkI7SUFDakMsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLCtHQUErRztDQUM3SCxDQUFBIn0=
|
|
@@ -50,4 +50,4 @@ export class DeesComms {
|
|
|
50
50
|
this.typedrouter.addTypedHandler(new plugins.typedrequest.TypedHandler(methodArg, handlerFunction));
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2Z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extra.json
CHANGED
|
@@ -2,17 +2,33 @@
|
|
|
2
2
|
"gitzone": {
|
|
3
3
|
"projectType": "npm",
|
|
4
4
|
"module": {
|
|
5
|
-
"githost": "
|
|
5
|
+
"githost": "code.foss.global",
|
|
6
6
|
"gitscope": "design.estate",
|
|
7
7
|
"gitrepo": "dees-comms",
|
|
8
8
|
"shortDescription": "a comms module for communicating within the DOM",
|
|
9
9
|
"npmPackagename": "@design.estate/dees-comms",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"projectDomain": "design.estate"
|
|
11
|
+
"projectDomain": "design.estate",
|
|
12
|
+
"description": "A communications module for enabling DOM-based messaging and synchronization across browser tabs and workers.",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"DOM communication",
|
|
15
|
+
"message broadcasting",
|
|
16
|
+
"cross-browser",
|
|
17
|
+
"cross-tab",
|
|
18
|
+
"web workers",
|
|
19
|
+
"typed messages",
|
|
20
|
+
"TypeScript",
|
|
21
|
+
"broadcast channel",
|
|
22
|
+
"client-side messaging",
|
|
23
|
+
"module"
|
|
24
|
+
]
|
|
12
25
|
}
|
|
13
26
|
},
|
|
14
27
|
"npmci": {
|
|
15
28
|
"npmGlobalTools": [],
|
|
16
29
|
"npmAccessLevel": "public"
|
|
30
|
+
},
|
|
31
|
+
"tsdoc": {
|
|
32
|
+
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
|
17
33
|
}
|
|
18
34
|
}
|
package/package.json
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@design.estate/dees-comms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "A communications module for enabling DOM-based messaging and synchronization across browser tabs and workers.",
|
|
6
6
|
"main": "dist_ts/index.js",
|
|
7
7
|
"typings": "dist_ts/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"author": "Lossless GmbH",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"test": "(tstest test/ --web)",
|
|
13
|
-
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)"
|
|
14
|
-
},
|
|
15
11
|
"devDependencies": {
|
|
16
|
-
"@
|
|
17
|
-
"@
|
|
18
|
-
"@
|
|
19
|
-
"@
|
|
20
|
-
"@push.rocks/tapbundle": "^5.0.
|
|
21
|
-
"@types/node": "^20.
|
|
12
|
+
"@git.zone/tsbuild": "^2.1.66",
|
|
13
|
+
"@git.zone/tsbundle": "^2.0.8",
|
|
14
|
+
"@git.zone/tsrun": "^1.2.44",
|
|
15
|
+
"@git.zone/tstest": "^1.0.77",
|
|
16
|
+
"@push.rocks/tapbundle": "^5.0.23",
|
|
17
|
+
"@types/node": "^20.12.12"
|
|
22
18
|
},
|
|
23
19
|
"dependencies": {
|
|
24
|
-
"@api.global/typedrequest": "^3.0.
|
|
25
|
-
"@api.global/typedrequest-interfaces": "^3.0.
|
|
20
|
+
"@api.global/typedrequest": "^3.0.25",
|
|
21
|
+
"@api.global/typedrequest-interfaces": "^3.0.19",
|
|
26
22
|
"@push.rocks/smartdelay": "^3.0.5",
|
|
27
|
-
"broadcast-channel": "^
|
|
23
|
+
"broadcast-channel": "^7.0.0"
|
|
28
24
|
},
|
|
29
25
|
"files": [
|
|
30
26
|
"ts/**/*",
|
|
@@ -40,5 +36,21 @@
|
|
|
40
36
|
],
|
|
41
37
|
"browserslist": [
|
|
42
38
|
"last 1 chrome versions"
|
|
43
|
-
]
|
|
44
|
-
|
|
39
|
+
],
|
|
40
|
+
"keywords": [
|
|
41
|
+
"DOM communication",
|
|
42
|
+
"message broadcasting",
|
|
43
|
+
"cross-browser",
|
|
44
|
+
"cross-tab",
|
|
45
|
+
"web workers",
|
|
46
|
+
"typed messages",
|
|
47
|
+
"TypeScript",
|
|
48
|
+
"broadcast channel",
|
|
49
|
+
"client-side messaging",
|
|
50
|
+
"module"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"test": "(tstest test/ --web)",
|
|
54
|
+
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)"
|
|
55
|
+
}
|
|
56
|
+
}
|
package/readme.hints.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/readme.md
CHANGED
|
@@ -1,39 +1,127 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @design.estate/dees-comms
|
|
2
2
|
a comms module for communicating within the DOM
|
|
3
3
|
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Status Category | Status Badge
|
|
13
|
-
-- | --
|
|
14
|
-
GitLab Pipelines | [](https://lossless.cloud)
|
|
15
|
-
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
|
16
|
-
npm | [](https://lossless.cloud)
|
|
17
|
-
Snyk | [](https://lossless.cloud)
|
|
18
|
-
TypeScript Support | [](https://lossless.cloud)
|
|
19
|
-
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
20
|
-
Code Style | [](https://lossless.cloud)
|
|
21
|
-
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
|
22
|
-
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
|
23
|
-
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
|
24
|
-
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
4
|
+
## Install
|
|
5
|
+
To integrate `@design.estate/dees-comms` into your project, run the following command in your terminal:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @design.estate/dees-comms --save
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This will add the package to your project dependencies.
|
|
25
12
|
|
|
26
13
|
## Usage
|
|
27
14
|
|
|
28
|
-
|
|
15
|
+
`@design.estate/dees-comms` facilitates communication within the DOM, especially between various workers and tabs in client-side JavaScript. Using TypeScript and the provided ESM syntax will enhance your development experience with better intellisense support and type safety.
|
|
16
|
+
|
|
17
|
+
### Setting Up
|
|
18
|
+
|
|
19
|
+
First, make sure to import the module in your TypeScript file:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { DeesComms } from '@design.estate/dees-comms';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Initializing the Communication Module
|
|
26
|
+
|
|
27
|
+
Create an instance of the `DeesComms` class to start using the module. This instance will act as the central communication hub in your application.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
const myDeesComms = new DeesComms();
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Sending Messages
|
|
34
|
+
|
|
35
|
+
To send messages, you'll need to create a typed request. Let's assume we are sending a message that requires a response:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
// Define the message type
|
|
39
|
+
interface MyMessageType {
|
|
40
|
+
method: 'myMethod';
|
|
41
|
+
someData: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Creating a typed request
|
|
45
|
+
const myTypedRequest = myDeesComms.createTypedRequest<MyMessageType>('myMethod');
|
|
46
|
+
|
|
47
|
+
// Firing the request
|
|
48
|
+
myTypedRequest.fire({
|
|
49
|
+
someData: 'Hello, World!',
|
|
50
|
+
}).then(response => {
|
|
51
|
+
console.log('Received response:', response);
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Receiving and Handling Messages
|
|
56
|
+
|
|
57
|
+
To handle incoming messages, you need to define handlers for the types of messages you expect to receive.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// Define the handler for the 'myMethod' message
|
|
61
|
+
myDeesComms.createTypedHandler<MyMessageType>('myMethod', async (incomingMessage) => {
|
|
62
|
+
console.log('Message received:', incomingMessage);
|
|
63
|
+
|
|
64
|
+
// Process the incoming message...
|
|
65
|
+
|
|
66
|
+
// Return a response (if needed)
|
|
67
|
+
return {
|
|
68
|
+
response: 'Message received loud and clear!'
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Communication Between Tabs or Workers
|
|
74
|
+
|
|
75
|
+
`@design.estate/dees-comms` uses the Broadcast Channel API and a polyfill for environments where it's not available, enabling seamless communication between different contexts like tabs, iframes, or web workers.
|
|
76
|
+
|
|
77
|
+
### Clean Up
|
|
78
|
+
|
|
79
|
+
When you're done with communication, or before creating a new instance for any reason, ensure you clean up properly to prevent memory leaks or other unexpected behaviors:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// Currently, the cleanup should be handled according to the specific needs of your application
|
|
83
|
+
// e.g., closing or nullifying references to the DeesComms instance.
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Complete Example
|
|
87
|
+
|
|
88
|
+
Putting it all together, let's create a small application that sends a message and listens for a response:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { DeesComms } from '@design.estate/dees-comms';
|
|
92
|
+
|
|
93
|
+
const appDeesComms = new DeesComms();
|
|
94
|
+
|
|
95
|
+
// Setting up the listener
|
|
96
|
+
appDeesComms.createTypedHandler<{ method: 'greet'; name: string }>('greet', async (message) => {
|
|
97
|
+
console.log(`Greetings received from ${message.name}`);
|
|
98
|
+
return { reply: `Hello ${message.name}, nice to meet you!` };
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Sending a greeting message
|
|
102
|
+
const greetRequest = appDeesComms.createTypedRequest<{ method: 'greet'; name: string }>('greet');
|
|
103
|
+
greetRequest.fire({ name: 'Alice' }).then(response => {
|
|
104
|
+
console.log(response.reply); // Expected output: "Hello Alice, nice to meet you!"
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
This module provides a powerful and flexible way to handle communications within the DOM, leveraging modern JavaScript features and patterns. The usage of TypeScript ensures type safety and enhances code understandability and maintainability.
|
|
109
|
+
|
|
110
|
+
## License and Legal Information
|
|
111
|
+
|
|
112
|
+
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
|
113
|
+
|
|
114
|
+
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
115
|
+
|
|
116
|
+
### Trademarks
|
|
29
117
|
|
|
30
|
-
|
|
118
|
+
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
|
31
119
|
|
|
32
|
-
|
|
120
|
+
### Company Information
|
|
33
121
|
|
|
34
|
-
|
|
122
|
+
Task Venture Capital GmbH
|
|
123
|
+
Registered at District court Bremen HRB 35230 HB, Germany
|
|
35
124
|
|
|
36
|
-
|
|
37
|
-
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
|
125
|
+
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
|
38
126
|
|
|
39
|
-
|
|
127
|
+
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@design.estate/dees-comms',
|
|
6
|
-
version: '1.0.
|
|
7
|
-
description: '
|
|
6
|
+
version: '1.0.27',
|
|
7
|
+
description: 'A communications module for enabling DOM-based messaging and synchronization across browser tabs and workers.'
|
|
8
8
|
}
|