Compare commits

..

7 Commits

Author SHA1 Message Date
5b9e785159 2.0.1 2022-03-25 00:31:10 +01:00
a5bca90eeb fix(core): update 2022-03-25 00:31:10 +01:00
244016faed 2.0.0 2022-03-24 23:09:36 +01:00
61719769a0 1.0.27 2022-03-24 22:46:09 +01:00
6e2855cf3c fix(core): update 2022-03-24 22:46:08 +01:00
916052ef0b 1.0.26 2022-03-08 00:14:41 +01:00
2f51e10fc4 fix(core): update 2022-03-08 00:14:40 +01:00
6 changed files with 5721 additions and 13556 deletions

19209
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,31 +1,33 @@
{
"name": "@apiglobal/typedsocket",
"version": "1.0.25",
"version": "2.0.1",
"private": false,
"description": "a typedrequest extension supporting websockets",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)"
"build": "(tsbuild --web --allowimplicitany)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.29",
"@gitzone/tsbundle": "^1.0.88",
"@gitzone/tstest": "^1.0.60",
"@pushrocks/tapbundle": "^3.2.15",
"@types/node": "^17.0.10",
"@gitzone/tsbuild": "^2.1.61",
"@gitzone/tsbundle": "^1.0.101",
"@gitzone/tstest": "^1.0.69",
"@pushrocks/smartenv": "^5.0.0",
"@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^17.0.23",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"@apiglobal/typedrequest": "^1.0.65",
"@apiglobal/typedrequest": "^2.0.0",
"@apiglobal/typedrequest-interfaces": "^1.0.15",
"@pushrocks/isohash": "^1.0.2",
"@pushrocks/smartsocket": "^1.2.22",
"@pushrocks/smartstring": "^3.0.24"
"@pushrocks/isohash": "^2.0.0",
"@pushrocks/smartsocket": "^2.0.4",
"@pushrocks/smartstring": "^4.0.2"
},
"browserslist": [
"last 1 chrome versions"

View File

@@ -1,6 +1,6 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as typedsocket from '../ts/index';
import * as typedsocket from '../ts/index.js';
tap.test('should create a client', async () => {
console.log('Browser test') // TODO: implement browser tests

View File

@@ -2,7 +2,7 @@ import { expect, tap } from '@pushrocks/tapbundle';
import * as typedrequest from '@apiglobal/typedrequest';
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
import * as typedsocket from '../ts/index';
import * as typedsocket from '../ts/index.js';
interface IRequest_Client_Server extends typedrequestInterfaces.implementsTR<
typedrequestInterfaces.ITypedRequest,

View File

@@ -1 +1 @@
export * from './typedsocket.classes.typedsocket';
export * from './typedsocket.classes.typedsocket.js';

View File

@@ -1,9 +1,9 @@
import * as plugins from './typedsocket.plugins';
import * as plugins from './typedsocket.plugins.js';
const publicRoleName = 'publicRoleName';
const publicRolePass = 'publicRolePass';
export type TTypedSocketSide = 'server' | 'client';
export type TTypedSocketSide = 'server' | 'client';
export class TypedSocket {
// STATIC
@@ -11,7 +11,7 @@ export class TypedSocket {
* creates a typedsocket server
* note: this will fail in browser environments as server libs are not bundled.
*/
public static async createServer(
public static async createServer (
typedrouterArg: plugins.typedrequest.TypedRouter,
smartexpressServerArg?: any
): Promise<TypedSocket> {
@@ -22,7 +22,7 @@ export class TypedSocket {
if (smartexpressServerArg) {
smartsocketServer.setExternalServer('smartexpress', smartexpressServerArg);
}
smartsocketServer.socketFunctions.add(
new plugins.smartsocket.SocketFunction({
funcName: 'processMessage',
@@ -34,7 +34,7 @@ export class TypedSocket {
const typedsocket = new TypedSocket(
'server',
typedrouterArg,
async <T extends plugins.typedrequestInterfaces.ITypedRequest>(
async <T extends plugins.typedrequestInterfaces.ITypedRequest> (
dataArg: T,
targetConnectionArg?: plugins.smartsocket.SocketConnection
): Promise<T> => {
@@ -43,7 +43,7 @@ export class TypedSocket {
console.log(
'Since no targetConnection was supplied and there is only one active one present, choosing that one automatically'
);
targetConnectionArg = smartsocketServer.socketConnections.getArray()[0];
targetConnectionArg = smartsocketServer.socketConnections.getArray()[ 0 ];
} else {
throw new Error('you need to specify the wanted targetConnection. Currently no target is selectable automatically.');
}
@@ -62,7 +62,7 @@ export class TypedSocket {
return typedsocket;
}
public static async createClient(
public static async createClient (
typedrouterArg: plugins.typedrequest.TypedRouter,
serverUrlArg: string,
aliasArg = 'clientArg'
@@ -89,7 +89,7 @@ export class TypedSocket {
const typedsocket = new TypedSocket(
'client',
typedrouterArg,
async <T extends plugins.typedrequestInterfaces.ITypedRequest>(dataArg: T): Promise<T> => {
async <T extends plugins.typedrequestInterfaces.ITypedRequest> (dataArg: T): Promise<T> => {
const response: T = (smartsocketClient.serverCall('processMessage', dataArg) as any) as T;
return response;
},
@@ -122,7 +122,7 @@ export class TypedSocket {
this.socketServerOrClient = socketServerOrClientArg;
}
public addTag(keyArg: string, payloadArg: any) {
public addTag (keyArg: string, payloadArg: any) {
if (this.side === 'client' && this.socketServerOrClient instanceof plugins.smartsocket.SmartsocketClient) {
this.socketServerOrClient.socketConnection.addTag({
id: keyArg,
@@ -133,8 +133,8 @@ export class TypedSocket {
}
}
public createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest>(
methodName: T['method'],
public createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest> (
methodName: T[ 'method' ],
targetConnection?: plugins.smartsocket.SocketConnection
): plugins.typedrequest.TypedRequest<T> {
const typedrequest = new plugins.typedrequest.TypedRequest<T>(
@@ -154,7 +154,7 @@ export class TypedSocket {
* @param asyncFindFuncArg
* @returns
*/
public async findAllTargetConnections(
public async findAllTargetConnections (
asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection) => Promise<boolean>
) {
if (this.socketServerOrClient instanceof plugins.smartsocket.Smartsocket) {
@@ -175,31 +175,31 @@ export class TypedSocket {
* @param asyncFindFuncArg
* @returns
*/
public async findTargetConnection(
public async findTargetConnection (
asyncFindFuncArg: (connectionArg: plugins.smartsocket.SocketConnection) => Promise<boolean>
) {
const allMatching = await this.findAllTargetConnections(asyncFindFuncArg);
return allMatching[0];
return allMatching[ 0 ];
}
public async findAllTargetConnectionsByTag(keyArg: string, payloadArg?: any) {
public async findAllTargetConnectionsByTag (keyArg: string, payloadArg?: any) {
return this.findAllTargetConnections(async socketConnectionArg => {
let result: boolean;
if (!payloadArg) {
result = !!(await socketConnectionArg.getTagById(keyArg));
} else {
result = !!(await socketConnectionArg.getTagById(keyArg)) === payloadArg;
result = !!((await socketConnectionArg.getTagById(keyArg)).payload === payloadArg);
}
return result;
})
}
public async findTargetConnectionByTag(keyArg: string, payloadArg?: any) {
public async findTargetConnectionByTag (keyArg: string, payloadArg?: any) {
const allResults = await this.findAllTargetConnectionsByTag(keyArg, payloadArg)
return allResults[0];
return allResults[ 0 ];
}
public async stop() {
public async stop () {
await this.socketServerOrClient.stop()
}
}