Compare commits

..

30 Commits

Author SHA1 Message Date
72430fdb0d 2.0.24 2023-09-10 10:41:41 +02:00
ee827dd5b3 fix(core): update 2023-09-10 10:41:41 +02:00
2aefae00de 2.0.23 2023-09-09 23:32:12 +02:00
6753a4fefc fix(core): update 2023-09-09 23:32:12 +02:00
8c5428baf8 2.0.22 2023-08-06 16:30:45 +02:00
69c1ad04dc fix(core): update 2023-08-06 16:30:44 +02:00
61d5301de8 2.0.21 2023-08-06 16:09:28 +02:00
72fa7f790c fix(core): update 2023-08-06 16:09:28 +02:00
dcc087c04d 2.0.20 2023-07-21 03:53:41 +02:00
c8556355c0 fix(core): update 2023-07-21 03:53:41 +02:00
9cfc41ace8 2.0.19 2023-03-29 19:02:35 +02:00
2827a1676b fix(core): update 2023-03-29 19:02:34 +02:00
424ad80b60 2.0.18 2023-03-29 16:15:31 +02:00
682a0c53ce fix(core): update 2023-03-29 16:15:30 +02:00
4fc09af779 2.0.17 2023-03-29 16:07:54 +02:00
f73d973383 fix(core): update 2023-03-29 16:07:54 +02:00
d87a942ab3 2.0.16 2023-03-20 18:51:02 +01:00
60e8657467 fix(core): update 2023-03-20 18:51:02 +01:00
5215be946e 2.0.15 2023-02-07 12:32:48 +01:00
b9c67666fa fix(core): update 2023-02-07 12:32:48 +01:00
4b0fb073e6 2.0.14 2022-12-29 13:28:11 +01:00
fc458b6827 fix(core): update 2022-12-29 13:28:11 +01:00
f27b9f8143 2.0.13 2022-12-29 11:18:16 +01:00
38058aba57 fix(core): update 2022-12-29 11:18:15 +01:00
ba38dae64f 2.0.12 2022-12-28 19:51:09 +01:00
69e862a6cf fix(core): update 2022-12-28 19:51:09 +01:00
4562ac355b 2.0.11 2022-12-28 14:02:15 +01:00
b029dc191e fix(core): update 2022-12-28 14:02:14 +01:00
2640275d04 2.0.10 2022-12-28 13:52:17 +01:00
7bbcc91300 fix(core): update 2022-12-28 13:52:16 +01:00
21 changed files with 3322 additions and 1602 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

View File

@ -1,141 +0,0 @@
# 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
before_script:
- npm install -g @shipzone/npmci
# ====================
# 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

View File

@ -22,6 +22,5 @@
} }
} }
} }
], ]
"typescript.tsdk": "node_modules/typescript/lib"
} }

View File

@ -3,10 +3,10 @@
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "push.rocks",
"gitrepo": "smartsocket", "gitrepo": "smartsocket",
"description": "easy and secure websocket communication", "description": "easy and secure websocket communication",
"npmPackagename": "@pushrocks/smartsocket", "npmPackagename": "@push.rocks/smartsocket",
"license": "MIT", "license": "MIT",
"projectDomain": "push.rocks" "projectDomain": "push.rocks"
} }

View File

@ -1,13 +1,14 @@
{ {
"name": "@pushrocks/smartsocket", "name": "@push.rocks/smartsocket",
"version": "2.0.9", "version": "2.0.24",
"description": "easy and secure websocket communication", "description": "easy and secure websocket communication",
"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",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild --web --allowimplicitany && tsbundle --from ./ts/index.ts --to dist_bundle/bundle.js)" "build": "(tsbuild --web --allowimplicitany && tsbundle --from ./ts/index.ts --to dist_bundle/bundle.js)",
"buildDocs": "tsdoc"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -20,27 +21,29 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartsocket#README", "homepage": "https://gitlab.com/pushrocks/smartsocket#README",
"dependencies": { "dependencies": {
"@apiglobal/typedrequest-interfaces": "^2.0.1", "@api.global/typedrequest-interfaces": "^3.0.1",
"@pushrocks/isohash": "^2.0.0", "@api.global/typedserver": "^3.0.4",
"@pushrocks/isounique": "^1.0.5", "@push.rocks/isohash": "^2.0.0",
"@pushrocks/lik": "^6.0.0", "@push.rocks/isounique": "^1.0.5",
"@pushrocks/smartdelay": "^2.0.13", "@push.rocks/lik": "^6.0.5",
"@pushrocks/smartenv": "^5.0.2", "@push.rocks/smartdelay": "^3.0.5",
"@pushrocks/smartexpress": "^4.0.18", "@push.rocks/smartenv": "^5.0.5",
"@pushrocks/smartjson": "^5.0.1", "@push.rocks/smartjson": "^5.0.10",
"@pushrocks/smartlog": "^3.0.1", "@push.rocks/smartlog": "^3.0.3",
"@pushrocks/smartpromise": "^3.1.7", "@push.rocks/smartpromise": "^4.0.3",
"@pushrocks/smartrx": "^3.0.0", "@push.rocks/smartrx": "^3.0.6",
"@pushrocks/smarttime": "^4.0.0", "@push.rocks/smarttime": "^4.0.5",
"socket.io": "^4.5.1", "engine.io": "6.5.2",
"socket.io-client": "^4.5.1" "socket.io": "4.7.2",
"socket.io-client": "4.7.2"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.63", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.37", "@gitzone/tsbundle": "^2.0.8",
"@gitzone/tstest": "^1.0.72", "@gitzone/tsrun": "^1.2.44",
"@pushrocks/tapbundle": "^5.0.4", "@gitzone/tstest": "^1.0.77",
"@types/node": "^18.6.3" "@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^20.6.0"
}, },
"private": false, "private": false,
"files": [ "files": [

4400
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,26 @@
# @pushrocks/smartsocket # @push.rocks/smartsocket
easy and secure websocket communication easy and secure websocket communication
## Availabililty and Links ## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartsocket) * [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartsocket)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartsocket) * [gitlab.com (source)](https://gitlab.com/push.rocks/smartsocket)
* [github.com (source mirror)](https://github.com/pushrocks/smartsocket) * [github.com (source mirror)](https://github.com/push.rocks/smartsocket)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartsocket/) * [docs (typedoc)](https://push.rocks.gitlab.io/smartsocket/)
## Status for master ## Status for master
Status Category | Status Badge Status Category | Status Badge
-- | -- -- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartsocket/badges/master/pipeline.svg)](https://lossless.cloud) GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartsocket/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartsocket/badges/master/coverage.svg)](https://lossless.cloud) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartsocket/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartsocket)](https://lossless.cloud) npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartsocket)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartsocket)](https://lossless.cloud) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartsocket)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](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/) 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) 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/@pushrocks/smartsocket)](https://lossless.cloud) PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartsocket)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartsocket)](https://lossless.cloud) PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartsocket)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartsocket)](https://lossless.cloud) BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartsocket)](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
@ -116,7 +115,6 @@ We are always happy for code contributions. If you are not the code contributing
For further information read the linked docs at the top of this readme. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) ## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,15 +1,15 @@
// tslint:disable-next-line:no-implicit-dependencies // tslint:disable-next-line:no-implicit-dependencies
import { expect, expectAsync, tap } from '@pushrocks/tapbundle'; import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
import * as isohash from '@pushrocks/isohash'; import * as isohash from '@push.rocks/isohash';
import * as smartexpress from '@pushrocks/smartexpress'; import * as smartexpress from '@api.global/typedserver';
import * as smartsocket from '../ts/index.js'; import * as smartsocket from '../ts/index.js';
let testSmartsocket: smartsocket.Smartsocket; let testSmartsocket: smartsocket.Smartsocket;
let testSmartsocketClient: smartsocket.SmartsocketClient; let testSmartsocketClient: smartsocket.SmartsocketClient;
let testSocketFunction1: smartsocket.SocketFunction<any>; let testSocketFunction1: smartsocket.SocketFunction<any>;
let myseServer: smartexpress.Server; let myseServer: smartexpress.servertools.Server;
const testConfig = { const testConfig = {
port: 3000, port: 3000,
@ -22,7 +22,7 @@ tap.test('should create a new smartsocket', async () => {
}); });
tap.test('Should accept an smartExpressServer as server', async () => { tap.test('Should accept an smartExpressServer as server', async () => {
myseServer = new smartexpress.Server({ myseServer = new smartexpress.servertools.Server({
cors: true, cors: true,
forceSsl: false, forceSsl: false,
port: testConfig.port, port: testConfig.port,
@ -33,7 +33,6 @@ tap.test('Should accept an smartExpressServer as server', async () => {
await myseServer.start(); await myseServer.start();
}); });
// class SocketFunction // class SocketFunction
tap.test('should register a new Function', async () => { tap.test('should register a new Function', async () => {
testSocketFunction1 = new smartsocket.SocketFunction({ testSocketFunction1 = new smartsocket.SocketFunction({

View File

@ -1,5 +1,5 @@
// tslint:disable-next-line:no-implicit-dependencies // tslint:disable-next-line:no-implicit-dependencies
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@push.rocks/tapbundle';
import * as smartsocket from '../ts/index.js'; import * as smartsocket from '../ts/index.js';

View File

@ -1,5 +1,5 @@
// tslint:disable-next-line:no-implicit-dependencies // tslint:disable-next-line:no-implicit-dependencies
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@push.rocks/tapbundle';
import * as smartsocket from '../ts/index.js'; import * as smartsocket from '../ts/index.js';

View File

@ -2,7 +2,7 @@
* autocreated commitinfo by @pushrocks/commitinfo * autocreated commitinfo by @pushrocks/commitinfo
*/ */
export const commitinfo = { export const commitinfo = {
name: '@pushrocks/smartsocket', name: '@push.rocks/smartsocket',
version: '2.0.9', version: '2.0.24',
description: 'easy and secure websocket communication' description: 'easy and secure websocket communication'
} }

View File

@ -5,3 +5,6 @@ export * from './smartsocket.classes.smartsocketclient.js';
// export further classes and objects // export further classes and objects
export * from './smartsocket.classes.socketfunction.js'; export * from './smartsocket.classes.socketfunction.js';
export * from './smartsocket.classes.socketconnection.js'; export * from './smartsocket.classes.socketconnection.js';
// export types so they can be referred to
export * from './interfaces/index.js';

View File

@ -1,12 +1,13 @@
import * as plugins from './smartsocket.plugins.js'; import * as plugins from './smartsocket.plugins.js';
import * as pluginsTyped from './smartsocket.pluginstyped.js'; import * as pluginsTyped from './smartsocket.pluginstyped.js';
import * as interfaces from './interfaces/index.js';
// classes // classes
import { SocketConnection } from './smartsocket.classes.socketconnection.js'; import { SocketConnection } from './smartsocket.classes.socketconnection.js';
import { import {
ISocketFunctionCallDataRequest, type ISocketFunctionCallDataRequest,
SocketFunction, SocketFunction,
ISocketFunctionCallDataResponse, type ISocketFunctionCallDataResponse,
} from './smartsocket.classes.socketfunction.js'; } from './smartsocket.classes.socketfunction.js';
import { SocketRequest } from './smartsocket.classes.socketrequest.js'; import { SocketRequest } from './smartsocket.classes.socketrequest.js';
import { SocketServer } from './smartsocket.classes.socketserver.js'; import { SocketServer } from './smartsocket.classes.socketserver.js';
@ -30,6 +31,8 @@ export class Smartsocket {
public socketFunctions = new plugins.lik.ObjectMap<SocketFunction<any>>(); public socketFunctions = new plugins.lik.ObjectMap<SocketFunction<any>>();
public socketRequests = new plugins.lik.ObjectMap<SocketRequest<any>>(); public socketRequests = new plugins.lik.ObjectMap<SocketRequest<any>>();
public eventSubject = new plugins.smartrx.rxjs.Subject<interfaces.TConnectionStatus>();
private socketServer = new SocketServer(this); private socketServer = new SocketServer(this);
constructor(optionsArg: ISmartsocketConstructorOptions) { constructor(optionsArg: ISmartsocketConstructorOptions) {
@ -37,7 +40,6 @@ export class Smartsocket {
this.alias = plugins.isounique.uni(this.options.alias); this.alias = plugins.isounique.uni(this.options.alias);
} }
// tslint:disable-next-line:member-ordering
public async setExternalServer(serverType: 'smartexpress', serverArg: any) { public async setExternalServer(serverType: 'smartexpress', serverArg: any) {
await this.socketServer.setExternalServer(serverType, serverArg); await this.socketServer.setExternalServer(serverType, serverArg);
} }
@ -47,7 +49,13 @@ export class Smartsocket {
*/ */
public async start() { public async start() {
const socketIoModule = await this.smartenv.getSafeNodeModule('socket.io'); const socketIoModule = await this.smartenv.getSafeNodeModule('socket.io');
this.io = new socketIoModule.Server(await this.socketServer.getServerForSocketIo()); this.io = new socketIoModule.Server(await this.socketServer.getServerForSocketIo(), {
cors: {
allowedHeaders: '*',
methods: '*',
origin: '*',
},
});
await this.socketServer.start(); await this.socketServer.start();
this.io.on('connection', (socketArg) => { this.io.on('connection', (socketArg) => {
this._handleSocketConnection(socketArg); this._handleSocketConnection(socketArg);
@ -61,7 +69,10 @@ export class Smartsocket {
await plugins.smartdelay.delayFor(1000); await plugins.smartdelay.delayFor(1000);
this.socketConnections.forEach((socketObjectArg: SocketConnection) => { this.socketConnections.forEach((socketObjectArg: SocketConnection) => {
if (socketObjectArg) { if (socketObjectArg) {
logger.log('info', `disconnecting socket with >>alias ${socketObjectArg.alias} due to server stop...`); logger.log(
'info',
`disconnecting socket with >>alias ${socketObjectArg.alias} due to server stop...`
);
socketObjectArg.disconnect(); socketObjectArg.disconnect();
} }
}); });

View File

@ -4,10 +4,10 @@ import * as interfaces from './interfaces/index.js';
import { SocketConnection } from './smartsocket.classes.socketconnection.js'; import { SocketConnection } from './smartsocket.classes.socketconnection.js';
import { import {
ISocketFunctionCallDataRequest, type ISocketFunctionCallDataRequest,
SocketFunction, SocketFunction,
} from './smartsocket.classes.socketfunction.js'; } from './smartsocket.classes.socketfunction.js';
import { ISocketRequestDataObject, SocketRequest } from './smartsocket.classes.socketrequest.js'; import { type ISocketRequestDataObject, SocketRequest } from './smartsocket.classes.socketrequest.js';
import { logger } from './smartsocket.logging.js'; import { logger } from './smartsocket.logging.js';
/** /**
@ -96,11 +96,11 @@ export class SmartsocketClient {
webUrlArg: 'https://cdn.jsdelivr.net/npm/socket.io-client@4/dist/socket.io.js', webUrlArg: 'https://cdn.jsdelivr.net/npm/socket.io-client@4/dist/socket.io.js',
getFunction: () => { getFunction: () => {
const socketIoBrowserModule = (globalThis as any).io; const socketIoBrowserModule = (globalThis as any).io;
console.log('loaded socket.io for browser'); // console.log('loaded socket.io for browser');
console.log(socketIoBrowserModule);
return socketIoBrowserModule; return socketIoBrowserModule;
}, },
}); });
// console.log(socketIoClient);
logger.log('info', 'trying to connect...'); logger.log('info', 'trying to connect...');
const socketUrl = `${this.serverUrl}:${this.serverPort}`; const socketUrl = `${this.serverUrl}:${this.serverPort}`;
this.socketConnection = new SocketConnection({ this.socketConnection = new SocketConnection({
@ -110,7 +110,8 @@ export class SmartsocketClient {
smartsocketHost: this, smartsocketHost: this,
socket: await socketIoClient socket: await socketIoClient
.connect(socketUrl, { .connect(socketUrl, {
multiplex: false, multiplex: true,
rememberUpgrade: true,
autoConnect: false, autoConnect: false,
reconnectionAttempts: 0, reconnectionAttempts: 0,
rejectUnauthorized: socketUrl.startsWith('https://localhost') ? false : true, rejectUnauthorized: socketUrl.startsWith('https://localhost') ? false : true,

View File

@ -5,7 +5,7 @@ import * as interfaces from './interfaces/index.js';
// import classes // import classes
import { Smartsocket } from './smartsocket.classes.smartsocket.js'; import { Smartsocket } from './smartsocket.classes.smartsocket.js';
import { SocketFunction } from './smartsocket.classes.socketfunction.js'; import { SocketFunction } from './smartsocket.classes.socketfunction.js';
import { SocketRequest, ISocketRequestDataObject } from './smartsocket.classes.socketrequest.js'; import { SocketRequest, type ISocketRequestDataObject } from './smartsocket.classes.socketrequest.js';
// socket.io // socket.io
import { SmartsocketClient } from './smartsocket.classes.smartsocketclient.js'; import { SmartsocketClient } from './smartsocket.classes.smartsocketclient.js';
@ -161,11 +161,10 @@ export class SocketConnection {
this.socket.on('function', (dataArg: ISocketRequestDataObject<any>) => { this.socket.on('function', (dataArg: ISocketRequestDataObject<any>) => {
// check if requested function is available to the socket's scope // check if requested function is available to the socket's scope
// logger.log('info', 'function request received'); // logger.log('info', 'function request received');
const referencedFunction: SocketFunction<any> = this.smartsocketRef.socketFunctions.findSync( const referencedFunction: SocketFunction<any> =
(socketFunctionArg) => { this.smartsocketRef.socketFunctions.findSync((socketFunctionArg) => {
return socketFunctionArg.name === dataArg.funcCallData.funcName; return socketFunctionArg.name === dataArg.funcCallData.funcName;
} });
);
if (referencedFunction) { if (referencedFunction) {
// logger.log('ok', 'function in access scope'); // logger.log('ok', 'function in access scope');
const localSocketRequest = new SocketRequest(this.smartsocketRef, { const localSocketRequest = new SocketRequest(this.smartsocketRef, {
@ -197,7 +196,10 @@ export class SocketConnection {
this.remoteTagStoreObservable.next(tagStoreArg); this.remoteTagStoreObservable.next(tagStoreArg);
}); });
logger.log('info', `now listening to function requests for ${this.alias} on side ${this.side}`); logger.log(
'info',
`now listening to function requests for ${this.alias} on side ${this.side}`
);
done.resolve(this); done.resolve(this);
} else { } else {
const errMessage = 'socket needs to be authenticated first'; const errMessage = 'socket needs to be authenticated first';

View File

@ -3,8 +3,8 @@ import * as plugins from './smartsocket.plugins.js';
// import interfaces // import interfaces
import { import {
SocketFunction, SocketFunction,
ISocketFunctionCallDataRequest, type ISocketFunctionCallDataRequest,
ISocketFunctionCallDataResponse, type ISocketFunctionCallDataResponse,
} from './smartsocket.classes.socketfunction.js'; } from './smartsocket.classes.socketfunction.js';
// import classes // import classes

View File

@ -29,7 +29,7 @@ export class SocketServer {
*/ */
public async setExternalServer( public async setExternalServer(
serverType: 'smartexpress', serverType: 'smartexpress',
serverArg: pluginsTyped.smartexpress.Server serverArg: pluginsTyped.typedserver.servertools.Server
) { ) {
this.httpServerDeferred = plugins.smartpromise.defer(); this.httpServerDeferred = plugins.smartpromise.defer();
await serverArg.startedPromise; await serverArg.startedPromise;

View File

@ -1,19 +1,19 @@
// apiglobal scope // apiglobal scope
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces'; import * as typedrequestInterfaces from '@api.global/typedrequest-interfaces';
export { typedrequestInterfaces }; export { typedrequestInterfaces };
// pushrocks scope // pushrocks scope
import * as isohash from '@pushrocks/isohash'; import * as isohash from '@push.rocks/isohash';
import * as isounique from '@pushrocks/isounique'; import * as isounique from '@push.rocks/isounique';
import * as lik from '@pushrocks/lik'; import * as lik from '@push.rocks/lik';
import * as smartenv from '@pushrocks/smartenv'; import * as smartenv from '@push.rocks/smartenv';
import * as smartjson from '@pushrocks/smartjson'; import * as smartjson from '@push.rocks/smartjson';
import * as smartlog from '@pushrocks/smartlog'; import * as smartlog from '@push.rocks/smartlog';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@push.rocks/smartdelay';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@push.rocks/smartpromise';
import * as smarttime from '@pushrocks/smarttime'; import * as smarttime from '@push.rocks/smarttime';
import * as smartrx from '@pushrocks/smartrx'; import * as smartrx from '@push.rocks/smartrx';
export { export {
isohash, isohash,

View File

@ -2,15 +2,15 @@
import type * as http from 'http'; import type * as http from 'http';
import type * as https from 'https'; import type * as https from 'https';
export { http, https }; export type { http, https };
// pushrocks scope // pushrocks scope
import type * as smartexpress from '@pushrocks/smartexpress'; import type * as typedserver from '@api.global/typedserver';
export { smartexpress }; export type { typedserver };
// third party scope // third party scope
import type { Socket as ServerSocket, Server as ServerServer} from 'socket.io'; import type { Socket as ServerSocket, Server as ServerServer } from 'socket.io';
import type { Socket as ClientSocket, connect as ClientIo } from 'socket.io-client'; import type { Socket as ClientSocket, connect as ClientIo } from 'socket.io-client';
export namespace socketIo { export namespace socketIo {

View File

@ -5,6 +5,7 @@
"target": "ES2022", "target": "ES2022",
"module": "ES2022", "module": "ES2022",
"moduleResolution": "nodenext", "moduleResolution": "nodenext",
"esModuleInterop": true "esModuleInterop": true,
"verbatimModuleSyntax": true,
} }
} }