// @flow

import type { Message, WebpackStats } from "../types";

const NAMESPACE = __filename;

// WDS = Webpack Dev Server (watches, compiles and serves the client bundle)
// WWP = Webpack Watch Process (watches and compiles the server bundle)
export const TYPE_WDS_PAUSE = `${ NAMESPACE }/WDS/PAUSE`;
export const TYPE_WDS_RESUME = `${ NAMESPACE }/WDS/RESUME`;
export const TYPE_WWP_COMPILATION = `${ NAMESPACE }/WWP/COMPILATION`;
export const TYPE_WWP_DONE = `${ NAMESPACE }/WWP/DONE`;

export function wdsPause(): Message {
    return {
        type: TYPE_WDS_PAUSE
    };
}

export function wdsResume(): Message {
    return {
        type: TYPE_WDS_RESUME
    };
}

export function wwpCompilation(publisher: string): Message {
    return {
        type: TYPE_WWP_COMPILATION,
        publisher
    };
}

export function wwpDone(publisher: string, stats: WebpackStats): Message {
    return {
        type: TYPE_WWP_DONE,
        publisher,
        duration: stats.endTime - stats.startTime,
        hasErrors: stats.hasErrors(),
        hasWarnings: stats.hasWarnings(),
        errorLog: stats.toString("errors-only")
    };
}

@@ -63,39 +63,8 @@
 %22;%0A%0A
-const NAMESPACE = __filename;%0A%0A
 // W
@@ -208,16 +208,77 @@
 bundle)%0A
+// AS = Application Server (starts the actual https? server)%0A
 export c
@@ -299,32 +299,17 @@
 PAUSE = 
-%60$%7B NAMESPACE %7D/
+%22
 WDS/PAUS
@@ -309,17 +309,17 @@
 DS/PAUSE
-%60
+%22
 ;%0Aexport
@@ -343,32 +343,17 @@
 ESUME = 
-%60$%7B NAMESPACE %7D/
+%22
 WDS/RESU
@@ -354,17 +354,17 @@
 S/RESUME
-%60
+%22
 ;%0Aexport
@@ -393,32 +393,17 @@
 ATION = 
-%60$%7B NAMESPACE %7D/
+%22
 WWP/COMP
@@ -409,17 +409,17 @@
 PILATION
-%60
+%22
 ;%0Aexport
@@ -445,33 +445,67 @@
 E = 
-%60$%7B NAMESPACE %7D/WWP/DONE%60
+%22WWP/DONE%22;%0Aexport const TYPE_AS_LISTENING = %22AS/LISTENING%22
 ;%0A%0Ae

Simplify message type strings