@twilio/flex-plugin-webpack 5.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/compiler.d.ts +34 -0
  4. package/dist/compiler.js +223 -0
  5. package/dist/compiler.js.map +1 -0
  6. package/dist/devServer/ipcServer.d.ts +83 -0
  7. package/dist/devServer/ipcServer.js +227 -0
  8. package/dist/devServer/ipcServer.js.map +1 -0
  9. package/dist/devServer/pluginServer.d.ts +78 -0
  10. package/dist/devServer/pluginServer.js +273 -0
  11. package/dist/devServer/pluginServer.js.map +1 -0
  12. package/dist/devServer/webpackDevServer.d.ts +11 -0
  13. package/dist/devServer/webpackDevServer.js +108 -0
  14. package/dist/devServer/webpackDevServer.js.map +1 -0
  15. package/dist/index.d.ts +16 -0
  16. package/dist/index.js +41 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/plugins/DelayRenderStaticPlugin.d.ts +4 -0
  19. package/dist/plugins/DelayRenderStaticPlugin.js +63 -0
  20. package/dist/plugins/DelayRenderStaticPlugin.js.map +1 -0
  21. package/dist/prints/devServerSuccessful.d.ts +12 -0
  22. package/dist/prints/devServerSuccessful.js +48 -0
  23. package/dist/prints/devServerSuccessful.js.map +1 -0
  24. package/dist/prints/dotEnvIncorrectVariable.d.ts +2 -0
  25. package/dist/prints/dotEnvIncorrectVariable.js +11 -0
  26. package/dist/prints/dotEnvIncorrectVariable.js.map +1 -0
  27. package/dist/prints/index.d.ts +3 -0
  28. package/dist/prints/index.js +13 -0
  29. package/dist/prints/index.js.map +1 -0
  30. package/dist/prints/remotePluginNotFound.d.ts +9 -0
  31. package/dist/prints/remotePluginNotFound.js +57 -0
  32. package/dist/prints/remotePluginNotFound.js.map +1 -0
  33. package/dist/webpack/clientVariables.d.ts +26 -0
  34. package/dist/webpack/clientVariables.js +78 -0
  35. package/dist/webpack/clientVariables.js.map +1 -0
  36. package/dist/webpack/pnpTs.d.ts +10 -0
  37. package/dist/webpack/pnpTs.js +13 -0
  38. package/dist/webpack/pnpTs.js.map +1 -0
  39. package/dist/webpack/webpack.config.d.ts +78 -0
  40. package/dist/webpack/webpack.config.js +506 -0
  41. package/dist/webpack/webpack.config.js.map +1 -0
  42. package/dist/webpack/webpack.dev.d.ts +22 -0
  43. package/dist/webpack/webpack.dev.js +75 -0
  44. package/dist/webpack/webpack.dev.js.map +1 -0
  45. package/package.json +85 -0
@@ -0,0 +1,78 @@
1
+ import { Request, Response } from 'express-serve-static-core';
2
+ import { FlexConfigurationPlugin } from '@twilio/flex-dev-utils/dist/fs';
3
+ import { Configuration } from 'webpack-dev-server';
4
+ export declare const PLUGIN_INPUT_PARSER_REGEX: RegExp;
5
+ export interface Plugin {
6
+ phase: number;
7
+ name: string;
8
+ src: string;
9
+ version?: string;
10
+ }
11
+ interface StartServerPlugins {
12
+ local: string[];
13
+ remote: string[];
14
+ versioned: string[];
15
+ }
16
+ interface StartServerConfig {
17
+ port: number;
18
+ remoteAll: boolean;
19
+ }
20
+ export interface PluginsConfig {
21
+ [pluginName: string]: {
22
+ port: number;
23
+ };
24
+ }
25
+ export declare type OnRemotePlugins = (remotePlugins: Plugin[]) => void;
26
+ /**
27
+ * Returns the plugin from the local configuration file
28
+ * @param name the plugin name
29
+ * @private
30
+ */
31
+ export declare const _getLocalPlugin: (name: string) => FlexConfigurationPlugin | undefined;
32
+ /**
33
+ * Returns local plugins from cli/plugins.json
34
+ * @private
35
+ */
36
+ export declare const _getLocalPlugins: (port: number, names: string[]) => Plugin[];
37
+ /**
38
+ * Generates the response headers
39
+ *
40
+ * @private
41
+ */
42
+ export declare const _getHeaders: () => Record<string, string>;
43
+ /**
44
+ * Fetches the Plugins from Flex
45
+ *
46
+ * @param token the JWE Token
47
+ * @param version the Flex version
48
+ */
49
+ export declare const _getRemotePlugins: (token: string, version: string | null | undefined) => Promise<Plugin[]>;
50
+ /**
51
+ * Returns versioned plugins from the CLI
52
+ *
53
+ * @param names
54
+ * @returns
55
+ */
56
+ export declare const _getRemoteVersionedPlugins: (names: string[]) => Plugin[];
57
+ /**
58
+ * Merge local and remote plugins
59
+ * @param localPlugins the list of local plugins
60
+ * @param remotePlugins the lost of remote plugins
61
+ * @private
62
+ */
63
+ export declare const _mergePlugins: (localPlugins: Plugin[], remotePlugins: Plugin[], versionedPlugins: Plugin[]) => Plugin[];
64
+ /**
65
+ * Basic server to fetch plugins from Flex and return to the local dev-server
66
+ * @param plugins
67
+ * @param config
68
+ * @param onRemotePlugin
69
+ */
70
+ export declare const _startServer: (plugins: StartServerPlugins, config: StartServerConfig, onRemotePlugin: OnRemotePlugins) => (req: Request, res: Response) => Promise<void>;
71
+ declare const _default: (plugins: StartServerPlugins, webpackConfig: Configuration, serverConfig: StartServerConfig, onRemotePlugin: OnRemotePlugins, pluginsConfig: PluginsConfig) => void;
72
+ /**
73
+ * Setups up the plugin servers
74
+ * @param plugins
75
+ * @param webpackConfig
76
+ * @param serverConfig
77
+ */
78
+ export default _default;
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
55
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
56
+ to[j] = from[i];
57
+ return to;
58
+ };
59
+ var __importDefault = (this && this.__importDefault) || function (mod) {
60
+ return (mod && mod.__esModule) ? mod : { "default": mod };
61
+ };
62
+ Object.defineProperty(exports, "__esModule", { value: true });
63
+ exports._startServer = exports._mergePlugins = exports._getRemoteVersionedPlugins = exports._getRemotePlugins = exports._getHeaders = exports._getLocalPlugins = exports._getLocalPlugin = exports.PLUGIN_INPUT_PARSER_REGEX = void 0;
64
+ var https_1 = __importDefault(require("https"));
65
+ var flex_dev_utils_1 = require("@twilio/flex-dev-utils");
66
+ var fs_1 = require("@twilio/flex-dev-utils/dist/fs");
67
+ var prints_1 = require("../prints");
68
+ exports.PLUGIN_INPUT_PARSER_REGEX = /([\w-]+)(?:@(\S+))?/;
69
+ /**
70
+ * Returns the plugin from the local configuration file
71
+ * @param name the plugin name
72
+ * @private
73
+ */
74
+ // eslint-disable-next-line import/no-unused-modules
75
+ var _getLocalPlugin = function (name) {
76
+ return fs_1.readPluginsJson().plugins.find(function (p) { return p.name === name; });
77
+ };
78
+ exports._getLocalPlugin = _getLocalPlugin;
79
+ /**
80
+ * Returns local plugins from cli/plugins.json
81
+ * @private
82
+ */
83
+ // eslint-disable-next-line import/no-unused-modules
84
+ var _getLocalPlugins = function (port, names) {
85
+ var protocol = "http" + (flex_dev_utils_1.env.isHTTPS() ? 's' : '') + "://";
86
+ return names.map(function (name) {
87
+ var match = exports._getLocalPlugin(name);
88
+ if (match) {
89
+ return {
90
+ phase: 3,
91
+ name: name,
92
+ src: protocol + "localhost:" + port + "/plugins/" + name + ".js",
93
+ };
94
+ }
95
+ throw new flex_dev_utils_1.FlexPluginError("The plugin " + name + " was not locally found. Try running `npm install` once in the plugin directory and try again.");
96
+ });
97
+ };
98
+ exports._getLocalPlugins = _getLocalPlugins;
99
+ /**
100
+ * Generates the response headers
101
+ *
102
+ * @private
103
+ */
104
+ // eslint-disable-next-line import/no-unused-modules
105
+ var _getHeaders = function () { return ({
106
+ 'Access-Control-Allow-Origin': '*',
107
+ 'Access-Control-Allow-Methods': 'GET',
108
+ 'Access-Control-Allow-Headers': 'Content-Type, X-Flex-Version, X-Flex-JWE',
109
+ 'Access-Control-Allow-Credentials': 'true',
110
+ 'Content-Type': 'application/json',
111
+ }); };
112
+ exports._getHeaders = _getHeaders;
113
+ /**
114
+ * Fetches the Plugins from Flex
115
+ *
116
+ * @param token the JWE Token
117
+ * @param version the Flex version
118
+ */
119
+ /* istanbul ignore next */
120
+ // eslint-disable-next-line import/no-unused-modules
121
+ var _getRemotePlugins = function (token, version) { return __awaiter(void 0, void 0, void 0, function () {
122
+ return __generator(this, function (_a) {
123
+ return [2 /*return*/, new Promise(function (resolve, reject) {
124
+ var headers = {
125
+ 'X-Flex-JWE': token,
126
+ };
127
+ if (version) {
128
+ headers['X-Flex-Version'] = version;
129
+ }
130
+ var options = {
131
+ hostname: 'flex.twilio.com',
132
+ port: 443,
133
+ path: '/plugins',
134
+ method: 'GET',
135
+ headers: headers,
136
+ };
137
+ https_1.default
138
+ .request(options, function (res) {
139
+ var data = [];
140
+ res.on('data', function (chunk) { return data.push(chunk); });
141
+ res.on('end', function () { return resolve(JSON.parse(Buffer.concat(data).toString()).filter(function (p) { return p.phase >= 3; })); });
142
+ })
143
+ .on('error', reject)
144
+ .end();
145
+ })];
146
+ });
147
+ }); };
148
+ exports._getRemotePlugins = _getRemotePlugins;
149
+ /**
150
+ * Returns versioned plugins from the CLI
151
+ *
152
+ * @param names
153
+ * @returns
154
+ */
155
+ var _getRemoteVersionedPlugins = function (names) {
156
+ return names.map(function (plugin) {
157
+ var groups = plugin.match(exports.PLUGIN_INPUT_PARSER_REGEX);
158
+ if (!groups) {
159
+ throw new flex_dev_utils_1.FlexPluginError('Unexpected plugin name format was provided');
160
+ }
161
+ var name = groups[1];
162
+ var version = groups[2];
163
+ return {
164
+ phase: 3,
165
+ name: name,
166
+ src: "https://flex.twilio.com/plugins/v1/" + name + "/" + version + "/bundle.js",
167
+ version: version,
168
+ };
169
+ });
170
+ };
171
+ exports._getRemoteVersionedPlugins = _getRemoteVersionedPlugins;
172
+ /**
173
+ * Merge local and remote plugins
174
+ * @param localPlugins the list of local plugins
175
+ * @param remotePlugins the lost of remote plugins
176
+ * @private
177
+ */
178
+ // eslint-disable-next-line import/no-unused-modules
179
+ var _mergePlugins = function (localPlugins, remotePlugins, versionedPlugins) {
180
+ var deduped = remotePlugins.filter(function (r) { return !localPlugins.some(function (l) { return l.name === r.name; }) && !versionedPlugins.some(function (l) { return l.name === r.name; }); });
181
+ return __spreadArray(__spreadArray(__spreadArray([], __read(localPlugins)), __read(deduped)), __read(versionedPlugins));
182
+ };
183
+ exports._mergePlugins = _mergePlugins;
184
+ /**
185
+ * Basic server to fetch plugins from Flex and return to the local dev-server
186
+ * @param plugins
187
+ * @param config
188
+ * @param onRemotePlugin
189
+ */
190
+ // eslint-disable-next-line import/no-unused-modules, @typescript-eslint/explicit-module-boundary-types
191
+ var _startServer = function (plugins, config, onRemotePlugin) {
192
+ var responseHeaders = exports._getHeaders();
193
+ return function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
194
+ var headers, method, jweToken, flexVersion, hasRemotePlugin, localPlugins, versionedPlugins, promise;
195
+ return __generator(this, function (_a) {
196
+ headers = req.headers, method = req.method;
197
+ if (method === 'OPTIONS') {
198
+ res.writeHead(200, responseHeaders);
199
+ return [2 /*return*/, res.end()];
200
+ }
201
+ if (method !== 'GET') {
202
+ res.writeHead(404, responseHeaders);
203
+ return [2 /*return*/, res.end('Route not found')];
204
+ }
205
+ flex_dev_utils_1.logger.debug('GET /plugins');
206
+ jweToken = headers['x-flex-jwe'];
207
+ flexVersion = headers['x-flex-version'];
208
+ if (!jweToken) {
209
+ res.writeHead(400, responseHeaders);
210
+ return [2 /*return*/, res.end('No X-Flex-JWE was provided')];
211
+ }
212
+ hasRemotePlugin = config.remoteAll || plugins.remote.length !== 0;
213
+ localPlugins = exports._getLocalPlugins(config.port, plugins.local);
214
+ versionedPlugins = exports._getRemoteVersionedPlugins(plugins.versioned);
215
+ promise = hasRemotePlugin ? exports._getRemotePlugins(jweToken, flexVersion) : Promise.resolve([]);
216
+ return [2 /*return*/, (promise
217
+ .then(function (remotePlugins) {
218
+ if (config.remoteAll) {
219
+ return remotePlugins;
220
+ }
221
+ // Check that all remote plugins inputted are valid
222
+ var notFoundPlugins = plugins.remote.filter(function (plgin) { return !remotePlugins.find(function (r) { return r.name === plgin; }); });
223
+ if (notFoundPlugins.length) {
224
+ prints_1.remotePluginNotFound(notFoundPlugins, remotePlugins);
225
+ flex_dev_utils_1.exit(1);
226
+ }
227
+ // Filter and only return the ones that are in remoteInputPlugins
228
+ return remotePlugins.filter(function (r) { return plugins.remote.includes(r.name); });
229
+ })
230
+ // rebase will eventually get both local and remote plugins
231
+ .then(function (remotePlugins) {
232
+ flex_dev_utils_1.logger.trace('Got remote plugins', remotePlugins);
233
+ onRemotePlugin(__spreadArray(__spreadArray([], __read(versionedPlugins)), __read(remotePlugins)));
234
+ res.writeHead(200, responseHeaders);
235
+ res.end(JSON.stringify(exports._mergePlugins(localPlugins, remotePlugins, versionedPlugins)));
236
+ })
237
+ .catch(function (err) {
238
+ res.writeHead(500, responseHeaders);
239
+ res.end(err);
240
+ }))];
241
+ });
242
+ }); };
243
+ };
244
+ exports._startServer = _startServer;
245
+ /**
246
+ * Setups up the plugin servers
247
+ * @param plugins
248
+ * @param webpackConfig
249
+ * @param serverConfig
250
+ */
251
+ /* istanbul ignore next */
252
+ exports.default = (function (plugins, webpackConfig, serverConfig, onRemotePlugin, pluginsConfig) {
253
+ serverConfig.port = webpackConfig.port || 3000;
254
+ webpackConfig.proxy = plugins.local.reduce(function (proxy, name) {
255
+ proxy["/plugins/" + name + ".js"] = {
256
+ target: "http://localhost:" + serverConfig.port,
257
+ router: function () {
258
+ var match = pluginsConfig[name];
259
+ if (!match) {
260
+ throw new Error();
261
+ }
262
+ return "http://localhost:" + match.port;
263
+ },
264
+ };
265
+ return proxy;
266
+ }, {});
267
+ webpackConfig.before = function (app, server) {
268
+ // @ts-ignore
269
+ serverConfig.port = server.options.port || serverConfig.port;
270
+ app.use('^/plugins$', exports._startServer(plugins, serverConfig, onRemotePlugin));
271
+ };
272
+ });
273
+ //# sourceMappingURL=pluginServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginServer.js","sourceRoot":"","sources":["../../src/devServer/pluginServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAE1B,yDAA4E;AAE5E,qDAA0F;AAG1F,oCAAiD;AAEpC,QAAA,yBAAyB,GAAG,qBAAqB,CAAC;AA4B/D;;;;GAIG;AACH,oDAAoD;AAC7C,IAAM,eAAe,GAAG,UAAC,IAAY;IAC1C,OAAO,oBAAe,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,CAA0B,IAAK,OAAA,CAAC,CAAC,IAAI,KAAK,IAAI,EAAf,CAAe,CAAC,CAAC;AACzF,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B;AAEF;;;GAGG;AACH,oDAAoD;AAC7C,IAAM,gBAAgB,GAAG,UAAC,IAAY,EAAE,KAAe;IAC5D,IAAM,QAAQ,GAAG,UAAO,oBAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,SAAK,CAAC;IAEtD,OAAO,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI;QACpB,IAAM,KAAK,GAAG,uBAAe,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,KAAK,EAAE;YACT,OAAO;gBACL,KAAK,EAAE,CAAC;gBACR,IAAI,MAAA;gBACJ,GAAG,EAAK,QAAQ,kBAAa,IAAI,iBAAY,IAAI,QAAK;aACvD,CAAC;SACH;QAED,MAAM,IAAI,gCAAe,CACvB,gBAAc,IAAI,kGAAiG,CACpH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAlBW,QAA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GAAG,CAAC,CAAC;gBACf,CAAC,CAAC,CACL,EAAC;;SACH,CAAC;AACJ,CAAC,CAAC;AA/DW,QAAA,YAAY,gBA+DvB;AAEF;;;;;GAKG;AACH,0BAA0B;AAC1B,mBAAe,UACb,OAA2B,EAC3B,aAA4B,EAC5B,YAA+B,EAC/B,cAA+B,EAC/B,aAA4B;IAE5B,YAAY,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,IAAI,IAAI,CAAC;IAE/C,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,UAAC,KAAK,EAAE,IAAI;QACrD,KAAK,CAAC,cAAY,IAAI,QAAK,CAAC,GAAG;YAC7B,MAAM,EAAE,sBAAoB,YAAY,CAAC,IAAM;YAC/C,MAAM,EAAE;gBACN,IAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;gBAClC,IAAI,CAAC,KAAK,EAAE;oBACV,MAAM,IAAI,KAAK,EAAE,CAAC;iBACnB;gBAED,OAAO,sBAAoB,KAAK,CAAC,IAAM,CAAC;YAC1C,CAAC;SACF,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,aAAa,CAAC,MAAM,GAAG,UAAC,GAAG,EAAE,MAAM;QACjC,aAAa;QACb,YAAY,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC;QAC7D,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,oBAAY,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC;AACJ,CAAC,EAAC"}
@@ -0,0 +1,11 @@
1
+ import { Configuration } from 'webpack-dev-server';
2
+ import { WebpackType } from '..';
3
+ import { Compiler } from '../compiler';
4
+ declare const _default: (devCompiler: Compiler, devConfig: Configuration, type: WebpackType) => void;
5
+ /**
6
+ * Starts a {@link WebpackDevServer}
7
+ * @param devCompiler the {@link Compiler} compiler
8
+ * @param devConfig the dev {@link Configuration}
9
+ * @param type the {@link WebpackType}
10
+ */
11
+ export default _default;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
43
+ var flex_dev_utils_1 = require("@twilio/flex-dev-utils");
44
+ var urls_1 = require("@twilio/flex-dev-utils/dist/urls");
45
+ var __1 = require("..");
46
+ var termSignals = ['SIGTERM', 'SIGINT'];
47
+ /**
48
+ * Starts a {@link WebpackDevServer}
49
+ * @param devCompiler the {@link Compiler} compiler
50
+ * @param devConfig the dev {@link Configuration}
51
+ * @param type the {@link WebpackType}
52
+ */
53
+ exports.default = (function (devCompiler, devConfig, type) {
54
+ var port = flex_dev_utils_1.env.getPort();
55
+ var local = urls_1.getLocalAndNetworkUrls(port).local;
56
+ var isJavaScriptServer = type === __1.WebpackType.JavaScript;
57
+ var isStaticServer = type === __1.WebpackType.Static;
58
+ var devServer = new webpack_dev_server_1.default(devCompiler, devConfig);
59
+ if (!isStaticServer) {
60
+ // Show TS errors on browser
61
+ devCompiler.hooks.tsCompiled.tap('afterTSCompile', function (warnings, errors) {
62
+ if (warnings.length) {
63
+ devServer.sockWrite(devServer.sockets, 'warnings', warnings);
64
+ }
65
+ if (errors.length) {
66
+ devServer.sockWrite(devServer.sockets, 'errors', errors);
67
+ }
68
+ });
69
+ }
70
+ // Start the dev-server
71
+ devServer.listen(local.port, local.host, function (err) { return __awaiter(void 0, void 0, void 0, function () {
72
+ var serverType;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0:
76
+ if (err) {
77
+ flex_dev_utils_1.logger.error(err);
78
+ return [2 /*return*/];
79
+ }
80
+ serverType = type === __1.WebpackType.Complete ? '' : "(" + type + ")";
81
+ if (isJavaScriptServer) {
82
+ flex_dev_utils_1.logger.debug('Starting development server %s...', serverType);
83
+ }
84
+ else {
85
+ flex_dev_utils_1.logger.clearTerminal();
86
+ flex_dev_utils_1.logger.notice('Starting development server %s...', serverType);
87
+ }
88
+ if (!!isJavaScriptServer) return [3 /*break*/, 2];
89
+ return [4 /*yield*/, flex_dev_utils_1.open(local.url)];
90
+ case 1:
91
+ _a.sent();
92
+ _a.label = 2;
93
+ case 2: return [2 /*return*/];
94
+ }
95
+ });
96
+ }); });
97
+ // Close server and exit
98
+ var cleanUp = function () {
99
+ devServer.close();
100
+ flex_dev_utils_1.exit(0);
101
+ };
102
+ termSignals.forEach(function (sig) { return process.on(sig, cleanUp); });
103
+ if (!flex_dev_utils_1.env.isCI()) {
104
+ process.stdin.on('end', cleanUp);
105
+ process.stdin.resume();
106
+ }
107
+ });
108
+ //# sourceMappingURL=webpackDevServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpackDevServer.js","sourceRoot":"","sources":["../../src/devServer/webpackDevServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAAqE;AACrE,yDAAiE;AACjE,yDAA0E;AAE1E,wBAAiC;AAGjC,IAAM,WAAW,GAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,mBAAe,UAAC,WAAqB,EAAE,SAAwB,EAAE,IAAiB;IAChF,IAAM,IAAI,GAAG,oBAAG,CAAC,OAAO,EAAE,CAAC;IACnB,IAAA,KAAK,GAAK,6BAAsB,CAAC,IAAI,CAAC,MAAjC,CAAkC;IAC/C,IAAM,kBAAkB,GAAG,IAAI,KAAK,eAAW,CAAC,UAAU,CAAC;IAC3D,IAAM,cA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EH,wBAAwB;IACxB,IAAM,OAAO,GAAG;QACd,SAAS,CAAC,KAAK,EAAE,CAAC;QAClB,qBAAI,CAAC,CAAC,CAAC,CAAC;IACV,CAAC,CAAC;IAEF,WAAW,CAAC,OAAO,CAAC,UAAC,GAAG,IAAK,OAAA,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,EAAxB,CAAwB,CAAC,CAAC;IACvD,IAAI,CAAC,oBAAG,CAAC,IAAI,EAAE,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;KACxB;AACH,CAAC,EAAC"}
@@ -0,0 +1,16 @@
1
+ import webpack from 'webpack';
2
+ export declare enum WebpackType {
3
+ Static = "static",
4
+ JavaScript = "javascript",
5
+ Complete = "complete"
6
+ }
7
+ export { webpack };
8
+ export { Configuration as WebpackConfigurations, Compiler as WebpackCompiler } from 'webpack';
9
+ export { Configuration as WebpackDevConfigurations } from 'webpack-dev-server';
10
+ export { default as webpackFactory } from './webpack/webpack.config';
11
+ export { default as webpackDevFactory } from './webpack/webpack.dev';
12
+ export { default as compiler, compilerRenderer } from './compiler';
13
+ export { default as webpackDevServer } from './devServer/webpackDevServer';
14
+ export { default as pluginServer, Plugin, PluginsConfig, PLUGIN_INPUT_PARSER_REGEX } from './devServer/pluginServer';
15
+ export { emitCompileComplete, emitDevServerCrashed, emitAllCompilesComplete, IPCType, onIPCServerMessage, OnDevServerCrashedPayload, startIPCClient, startIPCServer, } from './devServer/ipcServer';
16
+ export { default as DelayRenderStaticPlugin } from './plugins/DelayRenderStaticPlugin';
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /* eslint-disable import/no-unused-modules */
3
+ /* istanbul ignore file */
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.DelayRenderStaticPlugin = exports.startIPCServer = exports.startIPCClient = exports.onIPCServerMessage = exports.IPCType = exports.emitAllCompilesComplete = exports.emitDevServerCrashed = exports.emitCompileComplete = exports.PLUGIN_INPUT_PARSER_REGEX = exports.pluginServer = exports.webpackDevServer = exports.compilerRenderer = exports.compiler = exports.webpackDevFactory = exports.webpackFactory = exports.WebpackCompiler = exports.webpack = exports.WebpackType = void 0;
9
+ var webpack_1 = __importDefault(require("webpack"));
10
+ exports.webpack = webpack_1.default;
11
+ var WebpackType;
12
+ (function (WebpackType) {
13
+ WebpackType["Static"] = "static";
14
+ WebpackType["JavaScript"] = "javascript";
15
+ WebpackType["Complete"] = "complete";
16
+ })(WebpackType = exports.WebpackType || (exports.WebpackType = {}));
17
+ var webpack_2 = require("webpack");
18
+ Object.defineProperty(exports, "WebpackCompiler", { enumerable: true, get: function () { return webpack_2.Compiler; } });
19
+ var webpack_config_1 = require("./webpack/webpack.config");
20
+ Object.defineProperty(exports, "webpackFactory", { enumerable: true, get: function () { return __importDefault(webpack_config_1).default; } });
21
+ var webpack_dev_1 = require("./webpack/webpack.dev");
22
+ Object.defineProperty(exports, "webpackDevFactory", { enumerable: true, get: function () { return __importDefault(webpack_dev_1).default; } });
23
+ var compiler_1 = require("./compiler");
24
+ Object.defineProperty(exports, "compiler", { enumerable: true, get: function () { return __importDefault(compiler_1).default; } });
25
+ Object.defineProperty(exports, "compilerRenderer", { enumerable: true, get: function () { return compiler_1.compilerRenderer; } });
26
+ var webpackDevServer_1 = require("./devServer/webpackDevServer");
27
+ Object.defineProperty(exports, "webpackDevServer", { enumerable: true, get: function () { return __importDefault(webpackDevServer_1).default; } });
28
+ var pluginServer_1 = require("./devServer/pluginServer");
29
+ Object.defineProperty(exports, "pluginServer", { enumerable: true, get: function () { return __importDefault(pluginServer_1).default; } });
30
+ Object.defineProperty(exports, "PLUGIN_INPUT_PARSER_REGEX", { enumerable: true, get: function () { return pluginServer_1.PLUGIN_INPUT_PARSER_REGEX; } });
31
+ var ipcServer_1 = require("./devServer/ipcServer");
32
+ Object.defineProperty(exports, "emitCompileComplete", { enumerable: true, get: function () { return ipcServer_1.emitCompileComplete; } });
33
+ Object.defineProperty(exports, "emitDevServerCrashed", { enumerable: true, get: function () { return ipcServer_1.emitDevServerCrashed; } });
34
+ Object.defineProperty(exports, "emitAllCompilesComplete", { enumerable: true, get: function () { return ipcServer_1.emitAllCompilesComplete; } });
35
+ Object.defineProperty(exports, "IPCType", { enumerable: true, get: function () { return ipcServer_1.IPCType; } });
36
+ Object.defineProperty(exports, "onIPCServerMessage", { enumerable: true, get: function () { return ipcServer_1.onIPCServerMessage; } });
37
+ Object.defineProperty(exports, "startIPCClient", { enumerable: true, get: function () { return ipcServer_1.startIPCClient; } });
38
+ Object.defineProperty(exports, "startIPCServer", { enumerable: true, get: function () { return ipcServer_1.startIPCServer; } });
39
+ var DelayRenderStaticPlugin_1 = require("./plugins/DelayRenderStaticPlugin");
40
+ Object.defineProperty(exports, "DelayRenderStaticPlugin", { enumerable: true, get: function () { return __importDefault(DelayRenderStaticPlugin_1).default; } });
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,6CAA6C;AAC7C,0BAA0B;;;;;;AAE1B,oDAA8B;AAQrB,kBARF,iBAAO,CAQE;AANhB,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,wCAAyB,CAAA;IACzB,oCAAqB,CAAA;AACvB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAGD,mCAA8F;AAA7C,0GAAA,QAAQ,OAAmB;AAG5E,2DAAqE;AAA5D,iIAAA,OAAO,OAAkB;AAClC,qDAAqE;AAA5D,iIAAA,OAAO,OAAqB;AACrC,uCAAmE;AAA1D,qHAAA,OAAO,OAAY;AAAE,4GAAA,gBAAgB,OAAA;AAC9C,iEAA2E;AAAlE,qIAAA,OAAO,OAAoB;AACpC,yDAAqH;AAA5G,6HAAA,OAAO,OAAgB;AAAyB,yHAAA,yBAAyB,OAAA;AAClF,mDAS+B;AAR7B,gHAAA,mBAAmB,OAAA;AACnB,iHAAA,oBAAoB,OAAA;AACpB,oHAAA,uBAAuB,OAAA;AACvB,oGAAA,OAAO,OAAA;AACP,+GAAA,kBAAkB,OAAA;AAElB,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AAEhB,6EAAuF;AAA9E,mJAAA,OAAO,OAA2B"}
@@ -0,0 +1,4 @@
1
+ import { Compiler } from '../compiler';
2
+ export default class DelayRenderStaticPlugin {
3
+ apply(compiler: Compiler): void;
4
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /* istanbul ignore file */
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (_) try {
19
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ var ipcServer_1 = require("../devServer/ipcServer");
41
+ var isCalled = false;
42
+ var DelayRenderStaticPlugin = /** @class */ (function () {
43
+ function DelayRenderStaticPlugin() {
44
+ }
45
+ DelayRenderStaticPlugin.prototype.apply = function (compiler) {
46
+ var _this = this;
47
+ compiler.hooks.beforeCompile.tapAsync('DelayPlugin', function (_, done) { return __awaiter(_this, void 0, void 0, function () {
48
+ return __generator(this, function (_a) {
49
+ if (isCalled) {
50
+ done();
51
+ }
52
+ ipcServer_1.onIPCServerMessage(ipcServer_1.IPCType.onEmitAllCompilesComplete, function () {
53
+ isCalled = true;
54
+ done();
55
+ });
56
+ return [2 /*return*/];
57
+ });
58
+ }); });
59
+ };
60
+ return DelayRenderStaticPlugin;
61
+ }());
62
+ exports.default = DelayRenderStaticPlugin;
63
+ //# sourceMappingURL=DelayRenderStaticPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DelayRenderStaticPlugin.js","sourceRoot":"","sources":["../../src/plugins/DelayRenderStaticPlugin.ts"],"names":[],"mappings":";AAAA,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG1B,oDAAqE;AAErE,IAAI,QAAQ,GAAG,KAAK,CAAC;AAErB;IAAA;IAYA,CAAC;IAXC,uCAAK,GAAL,UAAM,QAAkB;QAAxB,iBAUC;QATC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,aAAa,EAAE,UAAO,CAAC,EAAE,IAAI;;gBACjE,IAAI,QAAQ,EAAE;oBACZ,IAAI,EAAE,CAAC;iBACR;gBACD,8BAAkB,CAAC,mBAAO,CAAC,yBAAyB,EAAE;oBACpD,QAAQ,GAAG,IAAI,CAAC;oBAChB,IAAI,EAAE,CAAC;gBACT,CAAC,CAAC,CAAC;;;aACJ,CAAC,CAAC;IACL,CAAC;IACH,8BAAC;AAAD,CAAC,AAZD,IAYC"}
@@ -0,0 +1,12 @@
1
+ import { ServiceUrl } from '@twilio/flex-dev-utils/dist/urls';
2
+ import { Plugin } from '../devServer/pluginServer';
3
+ declare const _default: (local: ServiceUrl, network: ServiceUrl, localPlugins: string[], remotePlugins: Plugin[], hasRemote: boolean) => void;
4
+ /**
5
+ * Prints the success message when dev-server compiles
6
+ * @param local the local port
7
+ * @param network the local network
8
+ * @param localPlugins the list of local plugins
9
+ * @param remotePlugins the list of remote plugins
10
+ * @param hasRemote whether remote plugins are running
11
+ */
12
+ export default _default;