123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- function initWPSSocket(messageHandler) {
-
- let options;
- try {
- options = ʎɐɹɔosǝʌɹǝs;
- } catch (e) {
-
- return;
- }
- const { ClientSocket } = require('webpack-plugin-serve/lib/client/ClientSocket');
- const { address, client = {}, secure } = options;
- const protocol = secure ? 'wss' : 'ws';
- const socket = new ClientSocket(client, protocol + '://' + (client.address || address) + '/wps');
- socket.addEventListener('message', function listener(message) {
- const { action, data } = JSON.parse(message.data);
- switch (action) {
- case 'done': {
- messageHandler({ type: 'ok' });
- break;
- }
- case 'problems': {
- if (data.errors.length) {
- messageHandler({ type: 'errors', data: data.errors });
- } else if (data.warnings.length) {
- messageHandler({ type: 'warnings', data: data.warnings });
- }
- break;
- }
- default: {
-
- }
- }
- });
- }
- module.exports = initWPSSocket;
|