From 15f3d9d3ae8c613e014946d0b07b5b2492eaa541 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 15:10:02 +0100 Subject: [PATCH 01/18] Fixed async handling --- examples/balls/client/index.ts | 2 +- examples/balls/server/index.ts | 2 +- examples/chat/client/index.ts | 16 ++++++- examples/chat/server/index.ts | 16 ++++--- examples/chat/webpack.config.cjs | 2 +- examples/todo/client/client.ts | 2 +- examples/todo/server/index.ts | 2 +- examples/todo/webpack.config.cjs | 72 ++++++++++++++-------------- package-lock.json | 12 ++--- package.json | 8 ++-- src/2_jsonrpc/index.ts | 81 +++++++++----------------------- src/3_jet/daemon/index.ts | 2 +- src/3_jet/peer/index.ts | 4 +- 13 files changed, 99 insertions(+), 122 deletions(-) diff --git a/examples/balls/client/index.ts b/examples/balls/client/index.ts index 4d85e54..766d430 100644 --- a/examples/balls/client/index.ts +++ b/examples/balls/client/index.ts @@ -2,7 +2,7 @@ * Jet client-server communications: */ import { select, selectAll, pointer } from 'd3-selection' -import { Fetcher, Peer } from '../../../src' +import { Fetcher, Peer } from '../../../lib' import { canvasSize } from '../defs' import { ballType } from '../server' diff --git a/examples/balls/server/index.ts b/examples/balls/server/index.ts index 92ba722..acb1de2 100644 --- a/examples/balls/server/index.ts +++ b/examples/balls/server/index.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node -import { Daemon, Method, Peer, State } from '../../../src' +import { Daemon, Method, Peer, State } from '../../../lib' import { canvasSize } from '../defs' var port = parseInt(process.argv[2]) || 8081 diff --git a/examples/chat/client/index.ts b/examples/chat/client/index.ts index 9872ddf..45e1eb0 100644 --- a/examples/chat/client/index.ts +++ b/examples/chat/client/index.ts @@ -1,10 +1,15 @@ /* * Jet client-server communications: */ -import { Fetcher, Peer } from '../../../src' +import { Peer } from '../../../lib/3_jet/peer/index.js' +import { Fetcher } from '../../../lib/3_jet/peer/fetcher.js' import './base.css' +import { LogLevel } from '../../../lib/jet.js' -const peer = new Peer({ url: 'ws://localhost:8081/' }) +const peer = new Peer({ + url: 'ws://localhost:8081/', + log: { logName: '', logCallbacks: [console.log], logLevel: LogLevel.socket } +}) const renderMessages = (messages: { value: string[] }) => { const messageContainer = document.getElementById('messages')! @@ -26,6 +31,13 @@ document .getElementById('message-form')! .addEventListener('submit', function (event) { event.preventDefault() + // const ps = [ + // new Promise((res,rej)=>{peer.set("test1",5).then(res).catch(rej)}), + // new Promise((res,rej)=>{peer.set("test2",15).then(res).catch(rej)}) + // ] + // Promise.allSettled(ps).then((res)=>{ + // console.log(res) + // }) const messageInput = document.getElementById('message')! as HTMLInputElement const sendButton = document.getElementById('send')! as HTMLButtonElement const message = messageInput.value diff --git a/examples/chat/server/index.ts b/examples/chat/server/index.ts index ebdcb5d..a92b63f 100644 --- a/examples/chat/server/index.ts +++ b/examples/chat/server/index.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node -import { Daemon, Method, Peer, State } from '../../../src' +import { Daemon, LogLevel, Method, Peer, State } from '../../../lib/jet.js' const wsPort = parseInt(process.argv[2]) || 8081 const internalPort = 10222 @@ -21,7 +21,8 @@ console.log('listening on port', wsPort) // Create Jet Peer const peer = new Peer({ - port: internalPort + port: internalPort, + log: { logName: '', logCallbacks: [console.log], logLevel: LogLevel.socket } }) // the messages state is simply an array @@ -44,10 +45,13 @@ const clear = new Method('chat/clear') clear.on('call', () => { messages.value([]) }) - peer .connect() - .then(() => - Promise.all([peer.add(messages), peer.add(append), peer.add(clear)]) - ) + .then(() => { + peer.batch(() => { + peer.add(messages) + peer.add(append) + peer.add(clear) + }) + }) .then(() => {}) diff --git a/examples/chat/webpack.config.cjs b/examples/chat/webpack.config.cjs index e92d514..86ef14d 100644 --- a/examples/chat/webpack.config.cjs +++ b/examples/chat/webpack.config.cjs @@ -73,4 +73,4 @@ const clientConfig = { ] } -module.exports = [clientConfig, serverConfig] +module.exports = [serverConfig,clientConfig] diff --git a/examples/todo/client/client.ts b/examples/todo/client/client.ts index 11ed737..4e147e5 100644 --- a/examples/todo/client/client.ts +++ b/examples/todo/client/client.ts @@ -1,7 +1,7 @@ /* * Jet client-server communications: */ -import { Fetcher, Peer, PublishMessage, ValueType } from '../../../src' +import { Fetcher, Peer, PublishMessage, ValueType } from '../../../lib' import { Todo } from '../server/Todo' import './base.css' diff --git a/examples/todo/server/index.ts b/examples/todo/server/index.ts index 968c31d..c1ea408 100644 --- a/examples/todo/server/index.ts +++ b/examples/todo/server/index.ts @@ -1,4 +1,4 @@ -import { Daemon, Method, Peer, State, ValueType } from '../../../src' +import { Daemon, Method, Peer, State, ValueType } from '../../../lib' import { Todo } from './Todo' var port = parseInt(process.argv[2]) || 8081 diff --git a/examples/todo/webpack.config.cjs b/examples/todo/webpack.config.cjs index 3741bc5..c5eaf39 100644 --- a/examples/todo/webpack.config.cjs +++ b/examples/todo/webpack.config.cjs @@ -38,40 +38,40 @@ const serverConfig = { level: 'log' // enables logging required for problem matchers } } -const clientConfig = { - target: 'web', - mode: 'none', - context: path.resolve('./', 'examples', 'todo', 'client'), - entry: './client.ts', - output: { - path: path.resolve('./', 'examples', 'todo', 'dist'), - filename: 'client.js', - publicPath: '/', - clean: true - }, - module: { - rules: [ - { - test: /\.ts$/, - use: ['ts-loader'] - }, - { - test: /\.(scss|css)$/, - use: ['style-loader', 'css-loader', 'postcss-loader'] - } - ] - }, - resolve: { - extensions: ['.ts', '.js'], - alias: { events: require.resolve('events/') } - }, - devtool: 'nosources-source-map', - plugins: [ - new HtmlWebpackPlugin({ - title: 'TODO', - template: 'index.html' - }) - ] -} +// const clientConfig = { +// target: 'web', +// mode: 'none', +// context: path.resolve('./', 'examples', 'todo', 'client'), +// entry: './client.ts', +// output: { +// path: path.resolve('./', 'examples', 'todo', 'dist'), +// filename: 'client.js', +// publicPath: '/', +// clean: true +// }, +// module: { +// rules: [ +// { +// test: /\.ts$/, +// use: ['ts-loader'] +// }, +// { +// test: /\.(scss|css)$/, +// use: ['style-loader', 'css-loader', 'postcss-loader'] +// } +// ] +// }, +// resolve: { +// extensions: ['.ts', '.js'], +// alias: { events: require.resolve('events/') } +// }, +// devtool: 'nosources-source-map', +// plugins: [ +// new HtmlWebpackPlugin({ +// title: 'TODO', +// template: 'index.html' +// }) +// ] +// } -module.exports = [clientConfig, serverConfig] +module.exports = [serverConfig] diff --git a/package-lock.json b/package-lock.json index 938d83a..0c7309a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-jet", - "version": "3.0.10", + "version": "3.0.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-jet", - "version": "3.0.10", + "version": "3.0.11", "license": "MIT", "dependencies": { "css-loader": "^6.8.1", @@ -40,7 +40,7 @@ "typescript": "^5.2.2", "wait-for-expect": "^3.0.2", "wait-on": "^7.0.1", - "webpack": "^5.88.2", + "webpack": "^5.89.0", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.15.1" }, @@ -9076,9 +9076,9 @@ } }, "node_modules/webpack": { - "version": "5.88.2", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.88.2.tgz", - "integrity": "sha512-JmcgNZ1iKj+aiR0OvTYtWQqJwq37Pf683dY9bVORwVbUrDhLhdn/PlO2sHsFHPkj7sHNQF3JwaAkp49V+Sq1tQ==", + "version": "5.89.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.89.0.tgz", + "integrity": "sha512-qyfIC10pOr70V+jkmud8tMfajraGCZMBWJtrmuBymQKCrLTRejBI8STDp1MCyZu/QTdZSeacCQYpYNQVOzX5kw==", "dependencies": { "@types/eslint-scope": "^3.7.3", "@types/estree": "^1.0.0", diff --git a/package.json b/package.json index 18df841..847bff5 100644 --- a/package.json +++ b/package.json @@ -41,9 +41,9 @@ "ci:type-check": "tsc --noEmit --skipLibCheck", "prettier": "prettier --write $npm_package_config_files", "eslint": "eslint --max-warnings 0 --ignore-path .prettierignore $npm_package_config_files", - "ex:chat": "concurrently \"webpack serve --config examples/chat/webpack.config.cjs\" \"wait-on examples/chat/dist/server.cjs && node examples/chat/dist/server.cjs\"", - "ex:todo": "concurrently \"webpack serve --config examples/todo/webpack.config.cjs\" \"wait-on examples/todo/dist/server.cjs && node examples/todo/dist/server.cjs\"", - "ex:balls": "concurrently \"webpack serve --config examples/balls/webpack.config.cjs\" \"wait-on examples/balls/dist/server.cjs && node examples/balls/dist/server.cjs\"" + "ex:chat": "npm run build && concurrently \"webpack serve --config examples/chat/webpack.config.cjs\" \"wait-on examples/chat/dist/server.cjs && node examples/chat/dist/server.cjs\"", + "ex:todo": "npm run build && concurrently \"webpack serve --config examples/todo/webpack.config.cjs\" \"wait-on examples/todo/dist/server.cjs && node examples/todo/dist/server.cjs\"", + "ex:balls": "npm run build && concurrently \"webpack serve --config examples/balls/webpack.config.cjs\" \"wait-on examples/balls/dist/server.cjs && node examples/balls/dist/server.cjs\"" }, "dependencies": { "css-loader": "^6.8.1", @@ -77,7 +77,7 @@ "typescript": "^5.2.2", "wait-for-expect": "^3.0.2", "wait-on": "^7.0.1", - "webpack": "^5.88.2", + "webpack": "^5.89.0", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.15.1" }, diff --git a/src/2_jsonrpc/index.ts b/src/2_jsonrpc/index.ts index ceb2737..47cfcb7 100644 --- a/src/2_jsonrpc/index.ts +++ b/src/2_jsonrpc/index.ts @@ -205,11 +205,9 @@ export class JsonRPC extends EventEmitter { _dispatchSingleMessage = ( message: MethodRequest | ResultMessage | ErrorMessage ) => { - if (isResultMessage(message) || isErrorMessage(message)) { + if (isResultMessage(message) || isErrorMessage(message)) this._dispatchResponse(message) - } else { - this._dispatchRequest(castMessage(message)) - } + else this._dispatchRequest(castMessage(message)) } /** @@ -219,12 +217,8 @@ export class JsonRPC extends EventEmitter { */ _dispatchResponse = (message: ResultMessage | ErrorMessage) => { const mid = message.id - if (isResultMessage(message)) { - this.successCb(mid, message.result) - } - if (isErrorMessage(message)) { - this.errorCb(mid, message.error) - } + if (isResultMessage(message)) this.successCb(mid, message.result) + if (isErrorMessage(message)) this.errorCb(mid, message.error) } /** @@ -237,28 +231,16 @@ export class JsonRPC extends EventEmitter { if (this.listenerCount(message.method) === 0) { this.logger.error(`Method ${message.method} is unknown`) this.respond(message.id, new methodNotFoundError(message.method), false) - } else { - this.emit(message.method, this, message.id, message.params) - } + } else this.emit(message.method, this, message.id, message.params) } /** * Queue. */ queue = (message: T, id = '') => { - if (!this._isOpen) { - return Promise.reject(new ConnectionClosed()) - } - if (id) { - this.messages.push({ method: id, params: message } as Message) - } else { - this.messages.push(message as Message) - } - if (this.sendImmediate) { - return this.send() - } else { - return Promise.resolve() - } + if (!this._isOpen) return Promise.reject(new ConnectionClosed()) + if (id) this.messages.push({ method: id, params: message } as Message) + else this.messages.push(message as Message) } /** @@ -272,19 +254,7 @@ export class JsonRPC extends EventEmitter { this.logger.sock(`Sending message: ${encoded}`) this.sock.send(encoded) this.messages = [] - } else { - return Promise.resolve() } - return Promise.all(this.batchPromises) - .then((res) => { - this.batchPromises = [] - return Promise.resolve(res) - }) - .catch((ex) => { - this.batchPromises = [] - this.logger.error(JSON.stringify(ex)) - return Promise.reject(ex) - }) } /** @@ -295,6 +265,7 @@ export class JsonRPC extends EventEmitter { */ respond = (id: string, params: ValueType, success: boolean) => { this.queue({ id, [success ? 'result' : 'error']: params }) + if (this.sendImmediate) this.send() } successCb = (id: string, result: ValueType) => { @@ -314,36 +285,28 @@ export class JsonRPC extends EventEmitter { */ sendRequest = ( method: string, - params: JsonParams, - immediate: boolean | undefined = undefined - ): Promise => { - const promise = new Promise((resolve, reject) => { - if (!this._isOpen) { - reject(new ConnectionClosed()) - } else { + params: JsonParams + ): Promise => + new Promise((resolve, reject) => { + console.log('Sending request') + if (!this._isOpen) reject(new ConnectionClosed()) + else { const rpcId = this.messageId.toString() this.messageId++ - this.openRequests[rpcId] = { resolve, reject } + this.openRequests[rpcId] = { + resolve: resolve as ( + value: ValueType | PromiseLike + ) => void, + reject + } this.queue({ id: rpcId.toString(), method, params }) - if (immediate) { - this.send() - } + if (this.sendImmediate) this.send() } }) - this.batchPromises.push(promise) - if (immediate || this.sendImmediate) - return promise.catch((err) => { - this.logger.error(JSON.stringify(err)) - return Promise.reject(err) - }) as Promise - else { - return Promise.resolve({} as T) - } - } } export default JsonRPC diff --git a/src/3_jet/daemon/index.ts b/src/3_jet/daemon/index.ts index 616ee98..a135e60 100644 --- a/src/3_jet/daemon/index.ts +++ b/src/3_jet/daemon/index.ts @@ -283,7 +283,7 @@ export class Daemon extends EventEmitter { ) { return Promise.reject(new NotAuthorized(params.path)) } - return this.routes[params.path].owner.sendRequest(method, params, true) + return this.routes[params.path].owner.sendRequest(method, params) } /* diff --git a/src/3_jet/peer/index.ts b/src/3_jet/peer/index.ts index 38995f2..06d077f 100644 --- a/src/3_jet/peer/index.ts +++ b/src/3_jet/peer/index.ts @@ -310,9 +310,7 @@ export class Peer extends EventEmitter { * */ batch = (action: () => void) => { - if (this.#daemonInfo.features?.batches) { - this.#jsonrpc.sendImmediate = false - } + this.#jsonrpc.sendImmediate = false action() this.#jsonrpc.sendImmediate = true return this.#jsonrpc.send() From 01a1830eaec84f5e7e31ac8c9e9374b6c6ad3c02 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 15:22:40 +0100 Subject: [PATCH 02/18] fixed tests --- src/2_jsonrpc/index.ts | 1 - test/jsonrpc/index.test.ts | 22 +++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/2_jsonrpc/index.ts b/src/2_jsonrpc/index.ts index 47cfcb7..f0d8abe 100644 --- a/src/2_jsonrpc/index.ts +++ b/src/2_jsonrpc/index.ts @@ -288,7 +288,6 @@ export class JsonRPC extends EventEmitter { params: JsonParams ): Promise => new Promise((resolve, reject) => { - console.log('Sending request') if (!this._isOpen) reject(new ConnectionClosed()) else { const rpcId = this.messageId.toString() diff --git a/test/jsonrpc/index.test.ts b/test/jsonrpc/index.test.ts index b8177f4..f6857a9 100644 --- a/test/jsonrpc/index.test.ts +++ b/test/jsonrpc/index.test.ts @@ -106,9 +106,12 @@ describe('Testing JsonRpc', () => { done() }) const jsonrpc = new JsonRPC(new Logger()) - jsonrpc.connect().then(() => + jsonrpc.connect().then(() =>{ // eslint-disable-next-line @typescript-eslint/no-explicit-any jsonrpc.queue({ event: 'Add', path: 'foo', value: 1 } as any, '_f') + jsonrpc.send() + } + ) sock.emit('open') }) @@ -496,14 +499,15 @@ describe('Testing JsonRpc', () => { jsonrpc.connect().then(async () => { jsonrpc.sendImmediate = false jsonrpc.sendRequest('add', { path: 'foo', value: 3 }) - jsonrpc.sendRequest('add', { path: 'foo1', value: 4 }) - await waitForExpect(() => - expect(() => jsonrpc.send()).rejects.toEqual({ - code: 0, - name: 'error' - }) - ) - done() + const p1 = jsonrpc.sendRequest('add', { path: 'foo1', value: 4 }).catch((ex)=>{ + expect(ex).toEqual({"code": 0, "name": "error"}) + done() + }) + jsonrpc.sendImmediate = true + jsonrpc.send() + + + }) sock.emit('open') From 13dc1b3bf9b50d909afad76e1e9ad43b832443e6 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 15:23:21 +0100 Subject: [PATCH 03/18] Fixed version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 847bff5..202eebc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-jet", - "version": "3.0.11", + "version": "3.0.12", "description": "Jet Realtime Message Bus for the Web. Daemon and Peer implementation.", "url": "https://github.com/hbm/node-jet", "author": { From 21d5f47daee07e219deb46ead648aa88ab9c63ae Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 15:24:55 +0100 Subject: [PATCH 04/18] Fixing ci --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17546bd..734c7c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,8 +2,10 @@ name: node-jet CI env: NODE_VERSION: '20.8' on: - release: - types: [created] + pull_request: + branches: [ master ] + types: [opened, closed] + jobs: build: From 90ab35b9b28326100f25b4a9dfb38fda882f083b Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 15:32:00 +0100 Subject: [PATCH 05/18] Fixed eslint --- .github/workflows/ci.yml | 6 ++++-- package.json | 2 +- test/jsonrpc/index.test.ts | 13 ++++--------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 734c7c0..df1cf3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,11 +2,12 @@ name: node-jet CI env: NODE_VERSION: '20.8' on: + release: + types: [created] pull_request: - branches: [ master ] + branches: [master] types: [opened, closed] - jobs: build: runs-on: ubuntu-latest @@ -22,6 +23,7 @@ jobs: - run: npm test publish-npm: + if: startsWith(github.ref, 'refs/tags/v') needs: build runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index 202eebc..0a8f691 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "ci:prettier": "prettier --check $npm_package_config_files ", "ci:type-check": "tsc --noEmit --skipLibCheck", "prettier": "prettier --write $npm_package_config_files", - "eslint": "eslint --max-warnings 0 --ignore-path .prettierignore $npm_package_config_files", + "eslint": "eslint --fix --max-warnings 0 --ignore-path .prettierignore $npm_package_config_files", "ex:chat": "npm run build && concurrently \"webpack serve --config examples/chat/webpack.config.cjs\" \"wait-on examples/chat/dist/server.cjs && node examples/chat/dist/server.cjs\"", "ex:todo": "npm run build && concurrently \"webpack serve --config examples/todo/webpack.config.cjs\" \"wait-on examples/todo/dist/server.cjs && node examples/todo/dist/server.cjs\"", "ex:balls": "npm run build && concurrently \"webpack serve --config examples/balls/webpack.config.cjs\" \"wait-on examples/balls/dist/server.cjs && node examples/balls/dist/server.cjs\"" diff --git a/test/jsonrpc/index.test.ts b/test/jsonrpc/index.test.ts index f6857a9..0ed972b 100644 --- a/test/jsonrpc/index.test.ts +++ b/test/jsonrpc/index.test.ts @@ -106,13 +106,11 @@ describe('Testing JsonRpc', () => { done() }) const jsonrpc = new JsonRPC(new Logger()) - jsonrpc.connect().then(() =>{ + jsonrpc.connect().then(() => { // eslint-disable-next-line @typescript-eslint/no-explicit-any jsonrpc.queue({ event: 'Add', path: 'foo', value: 1 } as any, '_f') jsonrpc.send() - } - - ) + }) sock.emit('open') }) it('Should test batch notify', (done) => { @@ -499,15 +497,12 @@ describe('Testing JsonRpc', () => { jsonrpc.connect().then(async () => { jsonrpc.sendImmediate = false jsonrpc.sendRequest('add', { path: 'foo', value: 3 }) - const p1 = jsonrpc.sendRequest('add', { path: 'foo1', value: 4 }).catch((ex)=>{ - expect(ex).toEqual({"code": 0, "name": "error"}) + jsonrpc.sendRequest('add', { path: 'foo1', value: 4 }).catch((ex) => { + expect(ex).toEqual({ code: 0, name: 'error' }) done() }) jsonrpc.sendImmediate = true jsonrpc.send() - - - }) sock.emit('open') From 4175747ed33723cbef3207e8f30fb8986aa7dcc7 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 15:33:29 +0100 Subject: [PATCH 06/18] Testing new ci --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df1cf3e..cb62e97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,8 @@ on: release: types: [created] pull_request: - branches: [master] - types: [opened, closed] + branches: + - master jobs: build: From acf5a6900869b55ddd4a2cc59855d1447df3890f Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 15:34:53 +0100 Subject: [PATCH 07/18] Trying with old version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0a8f691..b59f9d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-jet", - "version": "3.0.12", + "version": "3.0.11", "description": "Jet Realtime Message Bus for the Web. Daemon and Peer implementation.", "url": "https://github.com/hbm/node-jet", "author": { From f4a080a1a6ec94cde7f24ccabea41bf2052f09c8 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 15:59:28 +0100 Subject: [PATCH 08/18] Fixing --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index b59f9d7..40699ae 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ ], "scripts": { "test": "jest", + "prepare": "npm version patch", "build": "tsc", "ci": "npm run ci:eslint && npm run ci:prettier && npm run ci:type-check && npm run test", "ci:eslint": "eslint --max-warnings 0 --ignore-path .prettierignore $npm_package_config_files", From f725e91b4afcdc8cbbe147bb9467763f1414d47c Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 15:59:40 +0100 Subject: [PATCH 09/18] 3.0.12 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0c7309a..973dc34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-jet", - "version": "3.0.11", + "version": "3.0.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-jet", - "version": "3.0.11", + "version": "3.0.12", "license": "MIT", "dependencies": { "css-loader": "^6.8.1", diff --git a/package.json b/package.json index 40699ae..c93df23 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-jet", - "version": "3.0.11", + "version": "3.0.12", "description": "Jet Realtime Message Bus for the Web. Daemon and Peer implementation.", "url": "https://github.com/hbm/node-jet", "author": { From 7722df863126886a6148a6078a87efac01c77d23 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 16:00:08 +0100 Subject: [PATCH 10/18] 3.0.13 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 973dc34..b99099a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-jet", - "version": "3.0.12", + "version": "3.0.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-jet", - "version": "3.0.12", + "version": "3.0.13", "license": "MIT", "dependencies": { "css-loader": "^6.8.1", diff --git a/package.json b/package.json index c93df23..ed45c64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-jet", - "version": "3.0.12", + "version": "3.0.13", "description": "Jet Realtime Message Bus for the Web. Daemon and Peer implementation.", "url": "https://github.com/hbm/node-jet", "author": { From 3653d6632699656dec4fab01136b5e99da17d498 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 16:05:01 +0100 Subject: [PATCH 11/18] Added release --- .github/workflows/ci.yml | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb62e97..6a28a03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,7 @@ jobs: node-version: ${{ env.NODE_VERSION }} registry-url: https://registry.npmjs.org/ - run: npm ci + - run: npm version ${{ env.RELEASE_VERSION }} - run: npm run build - run: npm publish env: diff --git a/package.json b/package.json index ed45c64..40699ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-jet", - "version": "3.0.13", + "version": "3.0.11", "description": "Jet Realtime Message Bus for the Web. Daemon and Peer implementation.", "url": "https://github.com/hbm/node-jet", "author": { From 0393dbff2d3c8940b10d3694f68847d253dcb06a Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 16:11:37 +0100 Subject: [PATCH 12/18] Fixed example --- examples/todo/webpack.config.cjs | 72 ++++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/examples/todo/webpack.config.cjs b/examples/todo/webpack.config.cjs index c5eaf39..cfe343c 100644 --- a/examples/todo/webpack.config.cjs +++ b/examples/todo/webpack.config.cjs @@ -38,40 +38,40 @@ const serverConfig = { level: 'log' // enables logging required for problem matchers } } -// const clientConfig = { -// target: 'web', -// mode: 'none', -// context: path.resolve('./', 'examples', 'todo', 'client'), -// entry: './client.ts', -// output: { -// path: path.resolve('./', 'examples', 'todo', 'dist'), -// filename: 'client.js', -// publicPath: '/', -// clean: true -// }, -// module: { -// rules: [ -// { -// test: /\.ts$/, -// use: ['ts-loader'] -// }, -// { -// test: /\.(scss|css)$/, -// use: ['style-loader', 'css-loader', 'postcss-loader'] -// } -// ] -// }, -// resolve: { -// extensions: ['.ts', '.js'], -// alias: { events: require.resolve('events/') } -// }, -// devtool: 'nosources-source-map', -// plugins: [ -// new HtmlWebpackPlugin({ -// title: 'TODO', -// template: 'index.html' -// }) -// ] -// } +const clientConfig = { + target: 'web', + mode: 'none', + context: path.resolve('./', 'examples', 'todo', 'client'), + entry: './client.ts', + output: { + path: path.resolve('./', 'examples', 'todo', 'dist'), + filename: 'client.js', + publicPath: '/', + clean: true + }, + module: { + rules: [ + { + test: /\.ts$/, + use: ['ts-loader'] + }, + { + test: /\.(scss|css)$/, + use: ['style-loader', 'css-loader', 'postcss-loader'] + } + ] + }, + resolve: { + extensions: ['.ts', '.js'], + alias: { events: require.resolve('events/') } + }, + devtool: 'nosources-source-map', + plugins: [ + new HtmlWebpackPlugin({ + title: 'TODO', + template: 'index.html' + }) + ] +} -module.exports = [serverConfig] +module.exports = [serverConfig,clientConfig] From 437dde651079cd1da0fa42fe981f56abf65edde3 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 16:11:46 +0100 Subject: [PATCH 13/18] 3.0.12 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b99099a..973dc34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-jet", - "version": "3.0.13", + "version": "3.0.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-jet", - "version": "3.0.13", + "version": "3.0.12", "license": "MIT", "dependencies": { "css-loader": "^6.8.1", diff --git a/package.json b/package.json index 40699ae..c93df23 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-jet", - "version": "3.0.11", + "version": "3.0.12", "description": "Jet Realtime Message Bus for the Web. Daemon and Peer implementation.", "url": "https://github.com/hbm/node-jet", "author": { From d4c1f34e04d6dd2809bb17916e552eb92ed95d22 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 16:21:10 +0100 Subject: [PATCH 14/18] Testing ci stuff --- .github/workflows/ci.yml | 6 ++++-- package.json | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a28a03..2be1f5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: - run: npm test publish-npm: - if: startsWith(github.ref, 'refs/tags/v') + # if: startsWith(github.ref, 'refs/tags/v') needs: build runs-on: ubuntu-latest steps: @@ -33,8 +33,10 @@ jobs: node-version: ${{ env.NODE_VERSION }} registry-url: https://registry.npmjs.org/ - run: npm ci + - run: git config --global user.email "you@example.com" + - run: git config --global user.name "you@example.com" - run: npm version ${{ env.RELEASE_VERSION }} - run: npm run build - - run: npm publish + - run: npm publish --dry-run env: NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/package.json b/package.json index c93df23..0a8f691 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ ], "scripts": { "test": "jest", - "prepare": "npm version patch", "build": "tsc", "ci": "npm run ci:eslint && npm run ci:prettier && npm run ci:type-check && npm run test", "ci:eslint": "eslint --max-warnings 0 --ignore-path .prettierignore $npm_package_config_files", From 23117933728e4d383520c488fa937f77ffcfd1f7 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 16:21:37 +0100 Subject: [PATCH 15/18] Fixed version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2be1f5d..e4c51ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: - run: npm ci - run: git config --global user.email "you@example.com" - run: git config --global user.name "you@example.com" - - run: npm version ${{ env.RELEASE_VERSION }} + - run: npm version v13.0.20 - run: npm run build - run: npm publish --dry-run env: From 765d0dfa24c89e11637e12d47ee21738a4054da3 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 16:24:34 +0100 Subject: [PATCH 16/18] Finalized tests --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4c51ec..aa38929 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: - run: npm test publish-npm: - # if: startsWith(github.ref, 'refs/tags/v') + if: startsWith(github.ref, 'refs/tags/v') needs: build runs-on: ubuntu-latest steps: @@ -33,9 +33,9 @@ jobs: node-version: ${{ env.NODE_VERSION }} registry-url: https://registry.npmjs.org/ - run: npm ci - - run: git config --global user.email "you@example.com" - - run: git config --global user.name "you@example.com" - - run: npm version v13.0.20 + - run: git config --global user.email "schopp@hbkworld.com" + - run: git config --global user.name "Florian Schopp" + - run: npm version ${{ env.RELEASE_VERSION }} - run: npm run build - run: npm publish --dry-run env: From b6e74a58cdd09fe647fa768cf22c8b55ae4d57c3 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 16:25:51 +0100 Subject: [PATCH 17/18] Deleted dry-run --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa38929..455f4ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,6 @@ jobs: - run: git config --global user.name "Florian Schopp" - run: npm version ${{ env.RELEASE_VERSION }} - run: npm run build - - run: npm publish --dry-run + - run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.npm_token}} From 967cb1cfed6dc53aa0e4906ce1f0b0f50c34c5d3 Mon Sep 17 00:00:00 2001 From: Florian Schopp Date: Tue, 31 Oct 2023 16:27:23 +0100 Subject: [PATCH 18/18] Deleted comment --- examples/chat/client/index.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/examples/chat/client/index.ts b/examples/chat/client/index.ts index 45e1eb0..d0b3f0c 100644 --- a/examples/chat/client/index.ts +++ b/examples/chat/client/index.ts @@ -31,13 +31,6 @@ document .getElementById('message-form')! .addEventListener('submit', function (event) { event.preventDefault() - // const ps = [ - // new Promise((res,rej)=>{peer.set("test1",5).then(res).catch(rej)}), - // new Promise((res,rej)=>{peer.set("test2",15).then(res).catch(rej)}) - // ] - // Promise.allSettled(ps).then((res)=>{ - // console.log(res) - // }) const messageInput = document.getElementById('message')! as HTMLInputElement const sendButton = document.getElementById('send')! as HTMLButtonElement const message = messageInput.value