ui: fix worker types

pull/422/head^2
undefined 2 years ago
parent ccb380852f
commit fd8c0c373b

@ -1,6 +1,9 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const dir = path.dirname(path.dirname(require.resolve('@types/node/package.json')));
const files = fs.readdirSync(dir);
const compilerOptionsBase = { const compilerOptionsBase = {
target: 'es2020', target: 'es2020',
module: 'commonjs', module: 'commonjs',
@ -14,6 +17,7 @@ const compilerOptionsBase = {
// emitDecoratorMetadata: true, // emitDecoratorMetadata: true,
noEmit: true, noEmit: true,
incremental: true, incremental: true,
types: files.filter((i) => !['sharedworker', 'serviceworker'].includes(i)),
}; };
const config = { const config = {
compilerOptions: compilerOptionsBase, compilerOptions: compilerOptionsBase,

@ -1,4 +1,6 @@
/* eslint-disable no-restricted-globals */ /* eslint-disable no-restricted-globals */
/// <reference no-default-lib="true" />
/// <reference lib="ES2015" />
/// <reference types="@types/sharedworker" /> /// <reference types="@types/sharedworker" />
import ReconnectingWebsocket from 'reconnecting-websocket'; 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) { // eslint-disable-line no-undef
onconnect = function (e) {
const port = e.ports[0]; const port = e.ports[0];
port.addEventListener('message', (msg: { data: RequestPayload }) => { port.addEventListener('message', (msg: { data: RequestPayload }) => {

@ -1,3 +1,5 @@
/// <reference no-default-lib="true"/>
/// <reference lib="ES2015" />
/// <reference types="@types/serviceworker" /> /// <reference types="@types/serviceworker" />
/* global clients */ /* global clients */
// eslint-disable-next-line no-restricted-globals // 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 (client.url === '/home/messages' && 'focus' in client) return client.focus();
} }
if (clients.openWindow) clients.openWindow('/home/messages'); if (clients.openWindow) clients.openWindow('/home/messages');
return null;
})); }));
}); });

Loading…
Cancel
Save