@twilio/flex-plugin-webpack 5.0.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.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/compiler.d.ts +34 -0
- package/dist/compiler.js +223 -0
- package/dist/compiler.js.map +1 -0
- package/dist/devServer/ipcServer.d.ts +83 -0
- package/dist/devServer/ipcServer.js +227 -0
- package/dist/devServer/ipcServer.js.map +1 -0
- package/dist/devServer/pluginServer.d.ts +78 -0
- package/dist/devServer/pluginServer.js +273 -0
- package/dist/devServer/pluginServer.js.map +1 -0
- package/dist/devServer/webpackDevServer.d.ts +11 -0
- package/dist/devServer/webpackDevServer.js +108 -0
- package/dist/devServer/webpackDevServer.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/DelayRenderStaticPlugin.d.ts +4 -0
- package/dist/plugins/DelayRenderStaticPlugin.js +63 -0
- package/dist/plugins/DelayRenderStaticPlugin.js.map +1 -0
- package/dist/prints/devServerSuccessful.d.ts +12 -0
- package/dist/prints/devServerSuccessful.js +48 -0
- package/dist/prints/devServerSuccessful.js.map +1 -0
- package/dist/prints/dotEnvIncorrectVariable.d.ts +2 -0
- package/dist/prints/dotEnvIncorrectVariable.js +11 -0
- package/dist/prints/dotEnvIncorrectVariable.js.map +1 -0
- package/dist/prints/index.d.ts +3 -0
- package/dist/prints/index.js +13 -0
- package/dist/prints/index.js.map +1 -0
- package/dist/prints/remotePluginNotFound.d.ts +9 -0
- package/dist/prints/remotePluginNotFound.js +57 -0
- package/dist/prints/remotePluginNotFound.js.map +1 -0
- package/dist/webpack/clientVariables.d.ts +26 -0
- package/dist/webpack/clientVariables.js +78 -0
- package/dist/webpack/clientVariables.js.map +1 -0
- package/dist/webpack/pnpTs.d.ts +10 -0
- package/dist/webpack/pnpTs.js +13 -0
- package/dist/webpack/pnpTs.js.map +1 -0
- package/dist/webpack/webpack.config.d.ts +78 -0
- package/dist/webpack/webpack.config.js +506 -0
- package/dist/webpack/webpack.config.js.map +1 -0
- package/dist/webpack/webpack.dev.d.ts +22 -0
- package/dist/webpack/webpack.dev.js +75 -0
- package/dist/webpack/webpack.dev.js.map +1 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2018, Twilio, Inc. <help@twilio.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
10
|
+
so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+
[](../../LICENSE)
|
|
4
|
+
|
|
5
|
+
# Flex Plugin Webpack
|
|
6
|
+
|
|
7
|
+
To be filled
|
|
8
|
+
|
|
9
|
+
## Contributors
|
|
10
|
+
|
|
11
|
+
Thank you to all the lovely contributors to this project. Please check the main repository to see [all contributors](https://github.com/twilio/flex-plugin-builder#contributors).
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
[MIT](../../LICENSE)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SyncHook } from 'tapable';
|
|
2
|
+
import webpack, { Compiler as WebpackCompiler, Configuration } from 'webpack';
|
|
3
|
+
import { OnCompileCompletePayload } from './devServer/ipcServer';
|
|
4
|
+
import { OnRemotePlugins } from './devServer/pluginServer';
|
|
5
|
+
import CompilerHooks = webpack.compilation.CompilerHooks;
|
|
6
|
+
interface Hook extends CompilerHooks {
|
|
7
|
+
tsCompiled: SyncHook<string[], string[]>;
|
|
8
|
+
}
|
|
9
|
+
export interface Compiler extends WebpackCompiler {
|
|
10
|
+
hooks: Hook;
|
|
11
|
+
}
|
|
12
|
+
declare type OnCompile = (payload: OnCompileCompletePayload) => void;
|
|
13
|
+
interface CompilerRenderer {
|
|
14
|
+
onCompile: OnCompile;
|
|
15
|
+
onRemotePlugins: OnRemotePlugins;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: (config: Configuration, devServer: boolean, isJavaScriptServer: boolean, onCompile: OnCompile) => Compiler;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a webpack compiler
|
|
20
|
+
*
|
|
21
|
+
* @param config the Webpack configuration
|
|
22
|
+
* @param devServer whether to run the devserver or not
|
|
23
|
+
* @param type the webpack compile type
|
|
24
|
+
* @param localPlugins the names of plugins to run locally
|
|
25
|
+
*/
|
|
26
|
+
export default _default;
|
|
27
|
+
/**
|
|
28
|
+
* Prints the errors and warnings or a successful message when compilation finishes
|
|
29
|
+
* @param port the port the server is running on
|
|
30
|
+
* @param localPlugins the local plugins running
|
|
31
|
+
* @param showSuccessMsg whether to show succecss message or not
|
|
32
|
+
* @param hasRemote whether there are any remote plugins
|
|
33
|
+
*/
|
|
34
|
+
export declare const compilerRenderer: (port: number, localPlugins: string[], showSuccessMsg: boolean, hasRemote: boolean) => CompilerRenderer;
|
package/dist/compiler.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
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
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
40
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
41
|
+
if (!m) return o;
|
|
42
|
+
var i = m.call(o), r, ar = [], e;
|
|
43
|
+
try {
|
|
44
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
45
|
+
}
|
|
46
|
+
catch (error) { e = { error: error }; }
|
|
47
|
+
finally {
|
|
48
|
+
try {
|
|
49
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
50
|
+
}
|
|
51
|
+
finally { if (e) throw e.error; }
|
|
52
|
+
}
|
|
53
|
+
return ar;
|
|
54
|
+
};
|
|
55
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
56
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
57
|
+
to[j] = from[i];
|
|
58
|
+
return to;
|
|
59
|
+
};
|
|
60
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
61
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
62
|
+
};
|
|
63
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
+
exports.compilerRenderer = void 0;
|
|
65
|
+
var flex_dev_utils_1 = require("@twilio/flex-dev-utils");
|
|
66
|
+
var errors_1 = require("@twilio/flex-dev-utils/dist/errors");
|
|
67
|
+
var tapable_1 = require("tapable");
|
|
68
|
+
var fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
69
|
+
var typescript_compile_error_formatter_1 = __importDefault(require("@k88/typescript-compile-error-formatter"));
|
|
70
|
+
var webpack_1 = __importDefault(require("webpack"));
|
|
71
|
+
var fs_1 = require("@twilio/flex-dev-utils/dist/fs");
|
|
72
|
+
var format_webpack_messages_1 = __importDefault(require("@k88/format-webpack-messages"));
|
|
73
|
+
var urls_1 = require("@twilio/flex-dev-utils/dist/urls");
|
|
74
|
+
var prints_1 = require("./prints");
|
|
75
|
+
// Holds all compilation errors
|
|
76
|
+
var results = {};
|
|
77
|
+
/**
|
|
78
|
+
* Creates a webpack compiler
|
|
79
|
+
*
|
|
80
|
+
* @param config the Webpack configuration
|
|
81
|
+
* @param devServer whether to run the devserver or not
|
|
82
|
+
* @param type the webpack compile type
|
|
83
|
+
* @param localPlugins the names of plugins to run locally
|
|
84
|
+
*/
|
|
85
|
+
/* istanbul ignore next */
|
|
86
|
+
exports.default = (function (config, devServer, isJavaScriptServer, onCompile) {
|
|
87
|
+
flex_dev_utils_1.logger.debug('Creating webpack compiler');
|
|
88
|
+
try {
|
|
89
|
+
var compiler_1 = webpack_1.default(config);
|
|
90
|
+
compiler_1.hooks.tsCompiled = new tapable_1.SyncHook(['warnings', 'errors']);
|
|
91
|
+
// For build, we don't need to tap into any hooks
|
|
92
|
+
if (!devServer) {
|
|
93
|
+
return compiler_1;
|
|
94
|
+
}
|
|
95
|
+
var tsMessagesPromise_1;
|
|
96
|
+
var tsMessagesResolver_1;
|
|
97
|
+
if (fs_1.getPaths().app.isTSProject()) {
|
|
98
|
+
compiler_1.hooks.beforeCompile.tap('beforeCompile', function () {
|
|
99
|
+
tsMessagesPromise_1 = new Promise(function (resolve) {
|
|
100
|
+
tsMessagesResolver_1 = function (msgs) { return resolve(msgs); };
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
fork_ts_checker_webpack_plugin_1.default.getCompilerHooks(compiler_1).receive.tap('afterTSCheck', function (diagnostics, lints) {
|
|
104
|
+
var allMsgs = __spreadArray(__spreadArray([], __read(diagnostics)), __read(lints));
|
|
105
|
+
var format = function (issue) { return issue.file + "\n" + typescript_compile_error_formatter_1.default(issue); };
|
|
106
|
+
if (tsMessagesResolver_1) {
|
|
107
|
+
tsMessagesResolver_1({
|
|
108
|
+
errors: allMsgs.filter(function (msg) { return msg.severity === 'error'; }).map(format),
|
|
109
|
+
warnings: allMsgs.filter(function (msg) { return msg.severity === 'warning'; }).map(format),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
// invalid is `bundle invalidated` and is invoked when files are modified in dev-server.
|
|
115
|
+
compiler_1.hooks.invalid.tap('invalid', function () {
|
|
116
|
+
flex_dev_utils_1.logger.clearTerminal();
|
|
117
|
+
flex_dev_utils_1.logger.info("Re-compiling **" + fs_1.getPaths().app.name + "**");
|
|
118
|
+
});
|
|
119
|
+
compiler_1.hooks.done.tap('done', function (stats) { return __awaiter(void 0, void 0, void 0, function () {
|
|
120
|
+
var result, delayedMsg, messages, config;
|
|
121
|
+
var _a, _b, _c, _d;
|
|
122
|
+
return __generator(this, function (_e) {
|
|
123
|
+
switch (_e.label) {
|
|
124
|
+
case 0:
|
|
125
|
+
result = stats.toJson({ all: false, errors: true, warnings: true });
|
|
126
|
+
if (!(fs_1.getPaths().app.isTSProject() && !stats.hasErrors())) return [3 /*break*/, 2];
|
|
127
|
+
delayedMsg = setTimeout(function () {
|
|
128
|
+
flex_dev_utils_1.logger.notice('Waiting for Typescript check results...');
|
|
129
|
+
}, 100);
|
|
130
|
+
return [4 /*yield*/, tsMessagesPromise_1];
|
|
131
|
+
case 1:
|
|
132
|
+
messages = _e.sent();
|
|
133
|
+
clearTimeout(delayedMsg);
|
|
134
|
+
// Push ts-compile errors into compiler
|
|
135
|
+
(_a = result.errors).push.apply(_a, __spreadArray([], __read(messages.errors)));
|
|
136
|
+
(_b = stats.compilation.errors).push.apply(_b, __spreadArray([], __read(messages.errors)));
|
|
137
|
+
(_c = result.warnings).push.apply(_c, __spreadArray([], __read(messages.warnings)));
|
|
138
|
+
(_d = stats.compilation.warnings).push.apply(_d, __spreadArray([], __read(messages.warnings)));
|
|
139
|
+
compiler_1.hooks.tsCompiled.call(messages.warnings, messages.errors);
|
|
140
|
+
_e.label = 2;
|
|
141
|
+
case 2:
|
|
142
|
+
config = fs_1.readRunPluginsJson();
|
|
143
|
+
// Add the plugin to the loaded plugins configuration file
|
|
144
|
+
if (isJavaScriptServer) {
|
|
145
|
+
config.loadedPlugins.push(fs_1.getPaths().app.name);
|
|
146
|
+
fs_1.writeJSONFile(config, fs_1.getCliPaths().localPluginsJsonPath);
|
|
147
|
+
}
|
|
148
|
+
// Check to see if the plugin is the last bundle to be loaded
|
|
149
|
+
onCompile({
|
|
150
|
+
result: result,
|
|
151
|
+
appName: fs_1.getPaths().app.name,
|
|
152
|
+
lastPluginBundle: config.plugins.length === config.loadedPlugins.length,
|
|
153
|
+
});
|
|
154
|
+
return [2 /*return*/];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}); });
|
|
158
|
+
return compiler_1;
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
throw new errors_1.FlexPluginError("Failed to create a webpack compiler: " + err.message);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
/**
|
|
165
|
+
* Prints the errors and warnings or a successful message when compilation finishes
|
|
166
|
+
* @param port the port the server is running on
|
|
167
|
+
* @param localPlugins the local plugins running
|
|
168
|
+
* @param showSuccessMsg whether to show succecss message or not
|
|
169
|
+
* @param hasRemote whether there are any remote plugins
|
|
170
|
+
*/
|
|
171
|
+
var compilerRenderer = function (port, localPlugins, showSuccessMsg, hasRemote) {
|
|
172
|
+
var _a = urls_1.getLocalAndNetworkUrls(port), local = _a.local, network = _a.network;
|
|
173
|
+
var remotePlugins = [];
|
|
174
|
+
var serverSuccessful = function (list) {
|
|
175
|
+
list.forEach(function (l) {
|
|
176
|
+
if (!remotePlugins.some(function (r) { return r.name === l.name; })) {
|
|
177
|
+
remotePlugins.push(l);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
flex_dev_utils_1.logger.clearTerminal();
|
|
181
|
+
prints_1.devServerSuccessful(local, network, localPlugins, remotePlugins, hasRemote);
|
|
182
|
+
};
|
|
183
|
+
return {
|
|
184
|
+
onRemotePlugins: serverSuccessful,
|
|
185
|
+
onCompile: function (_a) {
|
|
186
|
+
var result = _a.result, appName = _a.appName;
|
|
187
|
+
flex_dev_utils_1.logger.clearTerminal();
|
|
188
|
+
results[appName] = result;
|
|
189
|
+
var isSuccessful = Object.values(results).every(function (r) { return r.errors.length === 0 && r.warnings.length === 0; });
|
|
190
|
+
if (isSuccessful) {
|
|
191
|
+
if (showSuccessMsg) {
|
|
192
|
+
serverSuccessful([]);
|
|
193
|
+
}
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
Object.keys(results).forEach(function (name) {
|
|
197
|
+
var formatted = format_webpack_messages_1.default({
|
|
198
|
+
errors: results[name].errors,
|
|
199
|
+
warnings: results[name].warnings,
|
|
200
|
+
});
|
|
201
|
+
// Only show errors if both exist
|
|
202
|
+
if (results[name].errors.length) {
|
|
203
|
+
/*
|
|
204
|
+
* Most errors are duplicate of the same error
|
|
205
|
+
* So only show the first error
|
|
206
|
+
*/
|
|
207
|
+
formatted.errors.length = 1;
|
|
208
|
+
flex_dev_utils_1.logger.error("Failed to compile plugin " + flex_dev_utils_1.logger.colors.red.bold(name) + ".");
|
|
209
|
+
flex_dev_utils_1.logger.info(formatted.errors.join('\n'));
|
|
210
|
+
flex_dev_utils_1.logger.newline();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (results[name].warnings.length) {
|
|
214
|
+
flex_dev_utils_1.logger.warning("Compiled plugin " + flex_dev_utils_1.logger.colors.yellow.bold(name) + " with warning(s).");
|
|
215
|
+
flex_dev_utils_1.logger.info(formatted.warnings.join('\n'));
|
|
216
|
+
flex_dev_utils_1.logger.newline();
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
exports.compilerRenderer = compilerRenderer;
|
|
223
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":";AAAA,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1B,yDAAoE;AACpE,6DAAqE;AACrE,mCAAmC;AACnC,kGAAwE;AACxE,+GAAqF;AACrF,oDAA8E;AAC9E,qDAA0G;AAC1G,yFAAiE;AACjE,yDAA0E;AAI1E,mCAA+C;AAwB/C,+BAA+B;AAC/B,IAAM,OAAO,GAAoB,EAAE,CAAC;AAEpC;;;;;;;GAOG;AACH,0BAA0B;AAC1B,mBAAe,UACb,MAAqB,EACrB,SAAkB,EAClB,kBAA2B,EAC3B,SAAoB;IAEpB,uBAAM,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAE1C,IAAI;QACF,IAAM,UAAQ,GAAG,iBAAO,CAAC,MAAM,CAAa,CAAC;QAC7C,UAAQ,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,kBAAQ,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;QAEjE,iDAAiD;QACjD,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,UAAQ,C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AAC,CAAC,QAAQ,CAAC,MAAM,EAAE;oBACjC,uBAAM,CAAC,OAAO,CAAC,qBAAmB,uBAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAmB,CAAC,CAAC;oBACtF,uBAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;oBAC3C,uBAAM,CAAC,OAAO,EAAE,CAAC;iBAClB;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA7DW,QAAA,gBAAgB,oBA6D3B"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
import ToJsonOutput = webpack.Stats.ToJsonOutput;
|
|
3
|
+
export declare enum IPCType {
|
|
4
|
+
onCompileComplete = "onCompileComplete",
|
|
5
|
+
onDevServerCrashed = "onDevServerCrashed",
|
|
6
|
+
onEmitAllCompilesComplete = "onEmitAllCompilesComplete"
|
|
7
|
+
}
|
|
8
|
+
export interface OnCompileCompletePayload {
|
|
9
|
+
result: ToJsonOutput;
|
|
10
|
+
appName: string;
|
|
11
|
+
lastPluginBundle: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface OnDevServerCrashedPayload {
|
|
14
|
+
exception: {
|
|
15
|
+
message: string;
|
|
16
|
+
stack?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface IPCPayload {
|
|
20
|
+
onCompileComplete: OnCompileCompletePayload;
|
|
21
|
+
onDevServerCrashed: OnDevServerCrashedPayload;
|
|
22
|
+
onEmitAllCompilesComplete: unknown;
|
|
23
|
+
}
|
|
24
|
+
declare type MessageCallback<T extends IPCType> = (payload: IPCPayload[T]) => void;
|
|
25
|
+
export declare const isServerRunning: () => boolean;
|
|
26
|
+
export declare const isClientConnected: () => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Processes the emit queue
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
export declare const _processEmitQueue: () => Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Processes the on server message
|
|
34
|
+
* @param data
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
export declare const _onServerMessage: (data: {
|
|
38
|
+
payload: unknown;
|
|
39
|
+
type: string;
|
|
40
|
+
}) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Processes on client connected
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
export declare const _onClientConnected: () => Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Emits to the server
|
|
48
|
+
* @param type the event type
|
|
49
|
+
* @param payload the event payload
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
export declare const _emitToServer: <T extends IPCType>(type: T, payload: IPCPayload[T]) => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Starts an IPC server
|
|
55
|
+
*/
|
|
56
|
+
export declare const startIPCServer: () => void;
|
|
57
|
+
/**
|
|
58
|
+
* Starts an IPC Client
|
|
59
|
+
*/
|
|
60
|
+
export declare const startIPCClient: () => void;
|
|
61
|
+
/**
|
|
62
|
+
* onMessage event for the IPC server
|
|
63
|
+
* @param type
|
|
64
|
+
* @param callback
|
|
65
|
+
*/
|
|
66
|
+
export declare const onIPCServerMessage: <T extends IPCType>(type: T, callback: MessageCallback<T>) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Emits to the server that all of the JS Bundles have completed compiling
|
|
69
|
+
* @param payload
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
export declare const emitAllCompilesComplete: () => Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Emits a compilation complete event
|
|
75
|
+
* @param payload
|
|
76
|
+
*/
|
|
77
|
+
export declare const emitCompileComplete: (payload: OnCompileCompletePayload) => Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Emits a dev-server failed event
|
|
80
|
+
* @param error
|
|
81
|
+
*/
|
|
82
|
+
export declare const emitDevServerCrashed: (error: Error) => Promise<void>;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,227 @@
|
|
|
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
|
+
exports.emitDevServerCrashed = exports.emitCompileComplete = exports.emitAllCompilesComplete = exports.onIPCServerMessage = exports.startIPCClient = exports.startIPCServer = exports._emitToServer = exports._onClientConnected = exports._onServerMessage = exports._processEmitQueue = exports.isClientConnected = exports.isServerRunning = exports.IPCType = void 0;
|
|
43
|
+
var node_ipc_1 = __importDefault(require("node-ipc"));
|
|
44
|
+
var flex_dev_utils_1 = require("@twilio/flex-dev-utils");
|
|
45
|
+
var IPCType;
|
|
46
|
+
(function (IPCType) {
|
|
47
|
+
IPCType["onCompileComplete"] = "onCompileComplete";
|
|
48
|
+
IPCType["onDevServerCrashed"] = "onDevServerCrashed";
|
|
49
|
+
IPCType["onEmitAllCompilesComplete"] = "onEmitAllCompilesComplete";
|
|
50
|
+
})(IPCType = exports.IPCType || (exports.IPCType = {}));
|
|
51
|
+
node_ipc_1.default.config.id = 'twilio.flex.plugin-builder';
|
|
52
|
+
node_ipc_1.default.config.retry = 1500;
|
|
53
|
+
node_ipc_1.default.config.silent = !flex_dev_utils_1.env.isDebug();
|
|
54
|
+
var _isServerRunning = false;
|
|
55
|
+
var _isClientConnected = false;
|
|
56
|
+
/* istanbul ignore next */
|
|
57
|
+
var isServerRunning = function () { return _isServerRunning; };
|
|
58
|
+
exports.isServerRunning = isServerRunning;
|
|
59
|
+
/* istanbul ignore next */
|
|
60
|
+
var isClientConnected = function () { return _isClientConnected; };
|
|
61
|
+
exports.isClientConnected = isClientConnected;
|
|
62
|
+
var clientNode = null;
|
|
63
|
+
var messageCallbacks = {};
|
|
64
|
+
/*
|
|
65
|
+
* This is used only to set the type of this queue
|
|
66
|
+
* This is the only way to get dynamic typing in TS :(
|
|
67
|
+
*/
|
|
68
|
+
var getEmitItem = function (type, payload) { return ({ type: type, payload: payload }); };
|
|
69
|
+
var emitQueue = [getEmitItem()].slice(1);
|
|
70
|
+
/**
|
|
71
|
+
* Processes the emit queue
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
/* istanbul ignore next */
|
|
75
|
+
var _processEmitQueue = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
if (!exports.isClientConnected()) {
|
|
78
|
+
return [2 /*return*/];
|
|
79
|
+
}
|
|
80
|
+
while (emitQueue.length) {
|
|
81
|
+
clientNode.emit('message', emitQueue.pop());
|
|
82
|
+
}
|
|
83
|
+
return [2 /*return*/];
|
|
84
|
+
});
|
|
85
|
+
}); };
|
|
86
|
+
exports._processEmitQueue = _processEmitQueue;
|
|
87
|
+
/**
|
|
88
|
+
* Processes the on server message
|
|
89
|
+
* @param data
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
var _onServerMessage = function (data) {
|
|
93
|
+
if (!data.type) {
|
|
94
|
+
flex_dev_utils_1.logger.error('IPC got an unexpected message: ', data);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
Object.keys(messageCallbacks)
|
|
98
|
+
.filter(function (type) { return type === data.type; })
|
|
99
|
+
.forEach(function (type) {
|
|
100
|
+
var _a;
|
|
101
|
+
if (messageCallbacks[type]) {
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
+
(_a = messageCallbacks[type]) === null || _a === void 0 ? void 0 : _a.forEach(function (cb) { return cb(data.payload); });
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
exports._onServerMessage = _onServerMessage;
|
|
108
|
+
/**
|
|
109
|
+
* Processes on client connected
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
var _onClientConnected = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
_isClientConnected = true;
|
|
117
|
+
return [4 /*yield*/, exports._processEmitQueue()];
|
|
118
|
+
case 1:
|
|
119
|
+
_a.sent();
|
|
120
|
+
return [2 /*return*/];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}); };
|
|
124
|
+
exports._onClientConnected = _onClientConnected;
|
|
125
|
+
/**
|
|
126
|
+
* Emits to the server
|
|
127
|
+
* @param type the event type
|
|
128
|
+
* @param payload the event payload
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
131
|
+
var _emitToServer = function (type, payload) { return __awaiter(void 0, void 0, void 0, function () {
|
|
132
|
+
return __generator(this, function (_a) {
|
|
133
|
+
switch (_a.label) {
|
|
134
|
+
case 0:
|
|
135
|
+
emitQueue.push({ type: type, payload: payload });
|
|
136
|
+
return [4 /*yield*/, exports._processEmitQueue()];
|
|
137
|
+
case 1:
|
|
138
|
+
_a.sent();
|
|
139
|
+
return [2 /*return*/];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}); };
|
|
143
|
+
exports._emitToServer = _emitToServer;
|
|
144
|
+
/**
|
|
145
|
+
* Starts an IPC server
|
|
146
|
+
*/
|
|
147
|
+
var startIPCServer = function () {
|
|
148
|
+
if (exports.isServerRunning()) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
node_ipc_1.default.serve(function () { return node_ipc_1.default.server.on('message', exports._onServerMessage); });
|
|
152
|
+
node_ipc_1.default.server.start();
|
|
153
|
+
_isServerRunning = true;
|
|
154
|
+
};
|
|
155
|
+
exports.startIPCServer = startIPCServer;
|
|
156
|
+
/**
|
|
157
|
+
* Starts an IPC Client
|
|
158
|
+
*/
|
|
159
|
+
var startIPCClient = function () {
|
|
160
|
+
if (exports.isClientConnected()) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
node_ipc_1.default.connectTo(node_ipc_1.default.config.id, function () {
|
|
164
|
+
clientNode = node_ipc_1.default.of[node_ipc_1.default.config.id];
|
|
165
|
+
clientNode.on('connect', exports._onClientConnected);
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
exports.startIPCClient = startIPCClient;
|
|
169
|
+
/**
|
|
170
|
+
* onMessage event for the IPC server
|
|
171
|
+
* @param type
|
|
172
|
+
* @param callback
|
|
173
|
+
*/
|
|
174
|
+
/* istanbul ignore next */
|
|
175
|
+
var onIPCServerMessage = function (type, callback) {
|
|
176
|
+
if (!(type in messageCallbacks)) {
|
|
177
|
+
messageCallbacks[type] = [];
|
|
178
|
+
}
|
|
179
|
+
// @ts-ignore
|
|
180
|
+
messageCallbacks[type].push(callback);
|
|
181
|
+
};
|
|
182
|
+
exports.onIPCServerMessage = onIPCServerMessage;
|
|
183
|
+
/**
|
|
184
|
+
* Emits to the server that all of the JS Bundles have completed compiling
|
|
185
|
+
* @param payload
|
|
186
|
+
* @returns
|
|
187
|
+
*/
|
|
188
|
+
var emitAllCompilesComplete = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
189
|
+
return [2 /*return*/, exports._emitToServer(IPCType.onEmitAllCompilesComplete, {})];
|
|
190
|
+
}); }); };
|
|
191
|
+
exports.emitAllCompilesComplete = emitAllCompilesComplete;
|
|
192
|
+
/**
|
|
193
|
+
* Emits a compilation complete event
|
|
194
|
+
* @param payload
|
|
195
|
+
*/
|
|
196
|
+
var emitCompileComplete = function (payload) { return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
+
return __generator(this, function (_a) {
|
|
198
|
+
switch (_a.label) {
|
|
199
|
+
case 0: return [4 /*yield*/, exports._emitToServer(IPCType.onCompileComplete, payload)];
|
|
200
|
+
case 1:
|
|
201
|
+
_a.sent();
|
|
202
|
+
if (!payload.lastPluginBundle) return [3 /*break*/, 3];
|
|
203
|
+
return [4 /*yield*/, exports.emitAllCompilesComplete()];
|
|
204
|
+
case 2:
|
|
205
|
+
_a.sent();
|
|
206
|
+
_a.label = 3;
|
|
207
|
+
case 3: return [2 /*return*/];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}); };
|
|
211
|
+
exports.emitCompileComplete = emitCompileComplete;
|
|
212
|
+
/**
|
|
213
|
+
* Emits a dev-server failed event
|
|
214
|
+
* @param error
|
|
215
|
+
*/
|
|
216
|
+
var emitDevServerCrashed = function (error) { return __awaiter(void 0, void 0, void 0, function () {
|
|
217
|
+
return __generator(this, function (_a) {
|
|
218
|
+
return [2 /*return*/, exports._emitToServer(IPCType.onDevServerCrashed, {
|
|
219
|
+
exception: {
|
|
220
|
+
message: error.message,
|
|
221
|
+
stack: error.stack,
|
|
222
|
+
},
|
|
223
|
+
})];
|
|
224
|
+
});
|
|
225
|
+
}); };
|
|
226
|
+
exports.emitDevServerCrashed = emitDevServerCrashed;
|
|
227
|
+
//# sourceMappingURL=ipcServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipcServer.js","sourceRoot":"","sources":["../../src/devServer/ipcServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA2B;AAC3B,yDAAqD;AAUrD,IAAY,OAIX;AAJD,WAAY,OAA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