24 Commits

Author SHA1 Message Date
1dc4f8230c 1.0.24 2023-08-08 01:06:24 +02:00
ebeedc6200 fix(core): update 2023-08-08 01:06:23 +02:00
9d895913eb 1.0.23 2022-05-27 01:36:28 +02:00
b5cc8e7952 fix(core): update 2022-05-27 01:36:28 +02:00
1a36912461 1.0.22 2022-03-29 14:56:22 +02:00
1dcbdcc06d fix(core): update 2022-03-29 14:56:21 +02:00
c7d0c8723f 1.0.21 2022-03-29 13:18:10 +02:00
ae377b185e fix(core): update 2022-03-29 13:18:09 +02:00
eab145e736 1.0.20 2022-03-29 13:14:10 +02:00
4060d64ed4 fix(core): update 2022-03-29 13:14:10 +02:00
b7dfd8b1d5 1.0.19 2022-03-29 10:56:16 +02:00
82f2675910 fix(core): update 2022-03-29 10:56:16 +02:00
d1149d3877 1.0.18 2022-03-29 10:01:51 +02:00
758dcd671c fix(core): update 2022-03-29 10:01:50 +02:00
4c59d38971 1.0.17 2022-03-25 14:17:13 +01:00
385acfd951 fix(core): update 2022-03-25 14:17:13 +01:00
97eba85337 1.0.16 2022-01-28 17:59:07 +01:00
61936bbdd1 fix(core): update 2022-01-28 17:59:06 +01:00
4ab1b917a9 1.0.15 2022-01-28 17:40:12 +01:00
f299cff4c9 fix(core): update 2022-01-28 17:40:12 +01:00
a6e262bbae 1.0.14 2022-01-24 05:13:21 +01:00
8a8200ca8a fix(core): update 2022-01-24 05:13:19 +01:00
e7785cc31b 1.0.13 2022-01-24 05:11:56 +01:00
63610b66bc fix(core): update 2022-01-24 05:11:55 +01:00
13 changed files with 4762 additions and 27240 deletions

View File

@@ -3,10 +3,10 @@
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "designestate", "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": "@designestate/dees-comms", "npmPackagename": "@design.estate/dees-comms",
"license": "MIT", "license": "MIT",
"projectDomain": "design.estate" "projectDomain": "design.estate"
} }

27171
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +1,30 @@
{ {
"name": "@designestate/dees-comms", "name": "@design.estate/dees-comms",
"version": "1.0.12", "version": "1.0.24",
"private": false, "private": false,
"description": "a comms module for communicating within the DOM", "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",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/ --web)", "test": "(tstest test/ --web)",
"build": "(tsbuild --web && tsbundle npm)" "build": "(tsbuild --web --allowimplicitany && tsbundle npm)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.29", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsbundle": "^1.0.89", "@gitzone/tsbundle": "^2.0.8",
"@gitzone/tstest": "^1.0.60", "@gitzone/tsrun": "^1.2.44",
"@pushrocks/tapbundle": "^4.0.0", "@gitzone/tstest": "^1.0.77",
"@types/node": "^17.0.10", "@push.rocks/tapbundle": "^5.0.12",
"tslint": "^6.1.3", "@types/node": "^20.4.8"
"tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@apiglobal/typedrequest": "^1.0.65", "@api.global/typedrequest": "^3.0.1",
"@apiglobal/typedrequest-interfaces": "^1.0.15", "@api.global/typedrequest-interfaces": "^3.0.1",
"broadcast-channel": "^4.9.0" "@push.rocks/smartdelay": "^3.0.5",
"broadcast-channel": "^3.7.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

4668
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

38
test/test.both.ts Normal file
View File

@@ -0,0 +1,38 @@
import { expect, tap } from '@push.rocks/tapbundle';
import * as deesComms from '../ts/index.js';
let deesCommsTest: deesComms.DeesComms;
let deesCommsTest2: deesComms.DeesComms;
tap.test('first test', async (tools) => {
deesCommsTest = new deesComms.DeesComms();
deesCommsTest2 = new deesComms.DeesComms();
let counter = 1;
deesCommsTest2.createTypedHandler<any>('test', async (requestData) => {
console.log(`got the request ${counter++}`);
return { hitheretoo: `greetings to ${requestData.hithere}` };
});
// lets fire a request
const typedrequest = deesCommsTest.createTypedRequest<any>('test');
const result = await typedrequest.fire({
hithere: 'hello',
});
console.log(JSON.stringify(result));
// lets fire a request
const typedrequest2 = deesCommsTest.createTypedRequest<any>('test2');
// TODO: return response after timeout
/* const result2 = await typedrequest2.fire({
hithere: 'hello',
});
console.log(JSON.stringify(result2)); */
});
tap.test('should end on nodejs', async (toolsArg) => {
if (globalThis.process) {
toolsArg.delayFor(2000).then(() => globalThis.process.exit(0));
}
})
tap.start();

View File

@@ -1,20 +0,0 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as deesComms from '../ts/index';
let deesCommsTest: deesComms.DeesComms;
tap.test('first test', async (tools) => {
deesCommsTest = new deesComms.DeesComms();
deesCommsTest.createTypedHandler<any>('test', async (requestData) => {
return { hitheretoo: `greetings to ${requestData.hithere}` };
});
// lets fire a request
const typedrequest = deesCommsTest.createTypedRequest<any>('test');
const result = await typedrequest.fire({
hithere: 'hello',
});
console.log(JSON.stringify(result));
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@design.estate/dees-comms',
version: '1.0.24',
description: 'a comms module for communicating within the DOM'
}

View File

@@ -1,5 +1,4 @@
import { TypedRequest } from '@apiglobal/typedrequest'; import * as plugins from './dees-comms.plugins.js';
import * as plugins from './dees-comms.plugins';
let BroadcastChannel = globalThis.BroadcastChannel; let BroadcastChannel = globalThis.BroadcastChannel;
if (!BroadcastChannel) { if (!BroadcastChannel) {
@@ -10,8 +9,9 @@ if (!BroadcastChannel) {
* a comm class for client side communication between workers and tabs. * a comm class for client side communication between workers and tabs.
*/ */
export class DeesComms { export class DeesComms {
private broadcastChannel = new BroadcastChannel('dees-comms');
// sending messages // sending messages
private postChannel = new BroadcastChannel('dees-comms');
public typedrouter = new plugins.typedrequest.TypedRouter(); public typedrouter = new plugins.typedrequest.TypedRouter();
public typedtarget = new plugins.typedrequest.TypedTarget({ public typedtarget = new plugins.typedrequest.TypedTarget({
postMethodWithTypedRouter: async (messageArg) => { postMethodWithTypedRouter: async (messageArg) => {
@@ -20,15 +20,16 @@ export class DeesComms {
typedRouterRef: this.typedrouter, typedRouterRef: this.typedrouter,
}); });
private subscriptionChannel = new BroadcastChannel('dees-comms'); // receiving messages
constructor() { constructor() {
this.subscriptionChannel.onmessage = async (eventArg) => { this.broadcastChannel.onmessage = async (eventArg) => {
const message = eventArg.data; const message = (eventArg as any).method ? eventArg : eventArg.data;
console.log(JSON.stringify(message)); console.log(JSON.stringify(message));
const response = await this.typedrouter.routeAndAddResponse(message); const response = await this.typedrouter.routeAndAddResponse(message);
if (response) { if (response && !response.error) {
this.postMessage(response); this.postMessage(response);
} else {
// console.log(response);
} }
}; };
} }
@@ -38,7 +39,7 @@ export class DeesComms {
*/ */
public createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest>( public createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest>(
methodName: T['method'] methodName: T['method']
): TypedRequest<T> { ): plugins.typedrequest.TypedRequest<T> {
const typedrequest = new plugins.typedrequest.TypedRequest(this.typedtarget, methodName); const typedrequest = new plugins.typedrequest.TypedRequest(this.typedtarget, methodName);
return typedrequest; return typedrequest;
} }
@@ -49,7 +50,7 @@ export class DeesComms {
public async postMessage<T = plugins.typedrequestInterfaces.ITypedRequest>( public async postMessage<T = plugins.typedrequestInterfaces.ITypedRequest>(
messageArg: T messageArg: T
): Promise<void> { ): Promise<void> {
this.postChannel.postMessage(messageArg); this.broadcastChannel.postMessage(messageArg);
} }
/** /**

View File

@@ -1,4 +1,4 @@
import * as plugins from './dees-comms.plugins'; import * as plugins from './dees-comms.plugins.js';
/** /**
* a message that can be sent * a message that can be sent

View File

@@ -1,10 +1,13 @@
// pushrocks scope // pushrocks scope
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces'; import * as smartdelay from '@push.rocks/smartdelay';
import * as typedrequest from '@apiglobal/typedrequest'; import * as typedrequestInterfaces from '@api.global/typedrequest-interfaces';
import * as typedrequest from '@api.global/typedrequest';
export { typedrequestInterfaces, typedrequest }; export { smartdelay, typedrequestInterfaces, typedrequest };
// thirdparty scope // third party scope
import { BroadcastChannel as BroadCastChannelPolyfill } from 'broadcast-channel'; import { BroadcastChannel as BroadCastChannelPolyfill } from 'broadcast-channel';
export { BroadCastChannelPolyfill }; export {
BroadCastChannelPolyfill
}

View File

@@ -1 +1 @@
export * from './dees-comms.classes.deescomms'; export * from './dees-comms.classes.deescomms.js';

11
tsconfig.json Normal file
View File

@@ -0,0 +1,11 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
}
}

View File

@@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}