From fd8c0c373b2b6e3468a949d2989bd832d9ec686f Mon Sep 17 00:00:00 2001 From: undefined Date: Wed, 31 Aug 2022 13:03:56 +0800 Subject: [PATCH] ui: fix worker types --- build/prepare.js | 4 ++++ packages/ui-default/components/message/worker.ts | 5 +++-- packages/ui-default/service-worker.ts | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build/prepare.js b/build/prepare.js index ac0c49df..bdee332e 100644 --- a/build/prepare.js +++ b/build/prepare.js @@ -1,6 +1,9 @@ const fs = require('fs'); const path = require('path'); +const dir = path.dirname(path.dirname(require.resolve('@types/node/package.json'))); +const files = fs.readdirSync(dir); + const compilerOptionsBase = { target: 'es2020', module: 'commonjs', @@ -14,6 +17,7 @@ const compilerOptionsBase = { // emitDecoratorMetadata: true, noEmit: true, incremental: true, + types: files.filter((i) => !['sharedworker', 'serviceworker'].includes(i)), }; const config = { compilerOptions: compilerOptionsBase, diff --git a/packages/ui-default/components/message/worker.ts b/packages/ui-default/components/message/worker.ts index 073f3b6b..6fbaf5c6 100644 --- a/packages/ui-default/components/message/worker.ts +++ b/packages/ui-default/components/message/worker.ts @@ -1,4 +1,6 @@ /* eslint-disable no-restricted-globals */ +/// +/// /// import ReconnectingWebsocket from 'reconnecting-websocket'; @@ -71,8 +73,7 @@ function initConn(path: string, port: MessagePort, cookie: any) { }; } -// eslint-disable-next-line no-undef -onconnect = function (e) { +onconnect = function (e) { // eslint-disable-line no-undef const port = e.ports[0]; port.addEventListener('message', (msg: { data: RequestPayload }) => { diff --git a/packages/ui-default/service-worker.ts b/packages/ui-default/service-worker.ts index c06bbc78..160e4b2a 100644 --- a/packages/ui-default/service-worker.ts +++ b/packages/ui-default/service-worker.ts @@ -1,3 +1,5 @@ +/// +/// /// /* global clients */ // eslint-disable-next-line no-restricted-globals @@ -10,5 +12,6 @@ addEventListener('notificationclick', (event) => { if (client.url === '/home/messages' && 'focus' in client) return client.focus(); } if (clients.openWindow) clients.openWindow('/home/messages'); + return null; })); });