Compare commits

..

No commits in common. "master" and "v1.0.24" have entirely different histories.

10 changed files with 3253 additions and 5260 deletions

138
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,138 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

24
.vscode/launch.json vendored
View File

@ -2,10 +2,28 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"command": "npm test", "name": "current file",
"name": "Run npm test", "type": "node",
"request": "launch", "request": "launch",
"type": "node-terminal" "args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
} }
] ]
} }

View File

@ -2,33 +2,17 @@
"gitzone": { "gitzone": {
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "code.foss.global", "githost": "gitlab.com",
"gitscope": "design.estate", "gitscope": "design.estate",
"gitrepo": "dees-comms", "gitrepo": "dees-comms",
"shortDescription": "a comms module for communicating within the DOM", "shortDescription": "a comms module for communicating within the DOM",
"npmPackagename": "@design.estate/dees-comms", "npmPackagename": "@design.estate/dees-comms",
"license": "MIT", "license": "MIT",
"projectDomain": "design.estate", "projectDomain": "design.estate"
"description": "A communications module for enabling DOM-based messaging and synchronization across browser tabs and workers.",
"keywords": [
"DOM communication",
"message broadcasting",
"cross-browser",
"cross-tab",
"web workers",
"typed messages",
"TypeScript",
"broadcast channel",
"client-side messaging",
"module"
]
} }
}, },
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "npmAccessLevel": "public"
},
"tsdoc": {
"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"
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"name": "@design.estate/dees-comms", "name": "@design.estate/dees-comms",
"version": "1.0.27", "version": "1.0.24",
"private": false, "private": false,
"description": "A communications module for enabling DOM-based messaging and synchronization across browser tabs and workers.", "description": "a comms module for communicating within the DOM",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module", "type": "module",
@ -13,18 +13,18 @@
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)" "build": "(tsbuild --web --allowimplicitany && tsbundle npm)"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.1.66", "@gitzone/tsbuild": "^2.1.66",
"@git.zone/tsbundle": "^2.0.8", "@gitzone/tsbundle": "^2.0.8",
"@git.zone/tsrun": "^1.2.44", "@gitzone/tsrun": "^1.2.44",
"@git.zone/tstest": "^1.0.77", "@gitzone/tstest": "^1.0.77",
"@push.rocks/tapbundle": "^5.0.23", "@push.rocks/tapbundle": "^5.0.12",
"@types/node": "^20.12.12" "@types/node": "^20.4.8"
}, },
"dependencies": { "dependencies": {
"@api.global/typedrequest": "^3.0.25", "@api.global/typedrequest": "^3.0.1",
"@api.global/typedrequest-interfaces": "^3.0.19", "@api.global/typedrequest-interfaces": "^3.0.1",
"@push.rocks/smartdelay": "^3.0.5", "@push.rocks/smartdelay": "^3.0.5",
"broadcast-channel": "^7.0.0" "broadcast-channel": "^3.7.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
@ -40,17 +40,5 @@
], ],
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
],
"keywords": [
"DOM communication",
"message broadcasting",
"cross-browser",
"cross-tab",
"web workers",
"typed messages",
"TypeScript",
"broadcast channel",
"client-side messaging",
"module"
] ]
} }

8139
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@

142
readme.md
View File

@ -1,127 +1,39 @@
# @design.estate/dees-comms # @designestate/dees-comms
a comms module for communicating within the DOM a comms module for communicating within the DOM
## Install ## Availabililty and Links
To integrate `@design.estate/dees-comms` into your project, run the following command in your terminal: * [npmjs.org (npm package)](https://www.npmjs.com/package/@designestate/dees-comms)
* [gitlab.com (source)](https://gitlab.com/designestate/dees-comms)
* [github.com (source mirror)](https://github.com/designestate/dees-comms)
* [docs (typedoc)](https://designestate.gitlab.io/dees-comms/)
```bash ## Status for master
npm install @design.estate/dees-comms --save
```
This will add the package to your project dependencies. Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/designestate/dees-comms/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/designestate/dees-comms/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@designestate/dees-comms)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/designestate/dees-comms)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@designestate/dees-comms)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@designestate/dees-comms)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@designestate/dees-comms)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage ## Usage
`@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. Use TypeScript for best in class intellisense
### Setting Up ## Contribution
First, make sure to import the module in your TypeScript file: We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
```typescript For further information read the linked docs at the top of this readme.
import { DeesComms } from '@design.estate/dees-comms';
```
### Initializing the Communication Module > MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
Create an instance of the `DeesComms` class to start using the module. This instance will act as the central communication hub in your application. [![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
```typescript
const myDeesComms = new DeesComms();
```
### Sending Messages
To send messages, you'll need to create a typed request. Let's assume we are sending a message that requires a response:
```typescript
// Define the message type
interface MyMessageType {
method: 'myMethod';
someData: string;
}
// Creating a typed request
const myTypedRequest = myDeesComms.createTypedRequest<MyMessageType>('myMethod');
// Firing the request
myTypedRequest.fire({
someData: 'Hello, World!',
}).then(response => {
console.log('Received response:', response);
});
```
### Receiving and Handling Messages
To handle incoming messages, you need to define handlers for the types of messages you expect to receive.
```typescript
// Define the handler for the 'myMethod' message
myDeesComms.createTypedHandler<MyMessageType>('myMethod', async (incomingMessage) => {
console.log('Message received:', incomingMessage);
// Process the incoming message...
// Return a response (if needed)
return {
response: 'Message received loud and clear!'
};
});
```
### Communication Between Tabs or Workers
`@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.
### Clean Up
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:
```typescript
// Currently, the cleanup should be handled according to the specific needs of your application
// e.g., closing or nullifying references to the DeesComms instance.
```
### Complete Example
Putting it all together, let's create a small application that sends a message and listens for a response:
```typescript
import { DeesComms } from '@design.estate/dees-comms';
const appDeesComms = new DeesComms();
// Setting up the listener
appDeesComms.createTypedHandler<{ method: 'greet'; name: string }>('greet', async (message) => {
console.log(`Greetings received from ${message.name}`);
return { reply: `Hello ${message.name}, nice to meet you!` };
});
// Sending a greeting message
const greetRequest = appDeesComms.createTypedRequest<{ method: 'greet'; name: string }>('greet');
greetRequest.fire({ name: 'Alice' }).then(response => {
console.log(response.reply); // Expected output: "Hello Alice, nice to meet you!"
});
```
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.
## License and Legal Information
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.
**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.
### Trademarks
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.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
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.

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@design.estate/dees-comms', name: '@design.estate/dees-comms',
version: '1.0.27', version: '1.0.24',
description: 'A communications module for enabling DOM-based messaging and synchronization across browser tabs and workers.' description: 'a comms module for communicating within the DOM'
} }

View File

@ -3,12 +3,9 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"useDefineForClassFields": false, "useDefineForClassFields": false,
"target": "ES2022", "target": "ES2022",
"module": "NodeNext", "module": "ES2022",
"moduleResolution": "NodeNext", "moduleResolution": "nodenext",
"esModuleInterop": true, "esModuleInterop": true,
"verbatimModuleSyntax": true "verbatimModuleSyntax": true,
}, }
"exclude": [
"dist_*/**/*.d.ts"
]
} }