@twilio/flex-plugin-webpack5 0.0.1 → 7.1.4-alpha.202610130427
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 +39 -3
- package/dist/compiler.d.ts +38 -0
- package/dist/compiler.js +252 -0
- package/dist/compiler.js.map +1 -0
- package/dist/devServer/ipcServer.d.ts +73 -0
- package/dist/devServer/ipcServer.js +253 -0
- package/dist/devServer/ipcServer.js.map +1 -0
- package/dist/devServer/pluginServer.d.ts +79 -0
- package/dist/devServer/pluginServer.js +313 -0
- package/dist/devServer/pluginServer.js.map +1 -0
- package/dist/devServer/webpackDevServer.d.ts +11 -0
- package/dist/devServer/webpackDevServer.js +110 -0
- package/dist/devServer/webpackDevServer.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/DelayRenderStaticPlugin.d.ts +4 -0
- package/dist/plugins/DelayRenderStaticPlugin.js +64 -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 +25 -0
- package/dist/webpack/clientVariables.js +107 -0
- package/dist/webpack/clientVariables.js.map +1 -0
- package/dist/webpack/pnpTs.d.ts +10 -0
- package/dist/webpack/pnpTs.js +14 -0
- package/dist/webpack/pnpTs.js.map +1 -0
- package/dist/webpack/webpack.config.d.ts +74 -0
- package/dist/webpack/webpack.config.js +569 -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 +80 -0
- package/dist/webpack/webpack.dev.js.map +1 -0
- package/package.json +79 -2
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
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;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.emitDevServerCrashed = exports.emitCompileComplete = exports.emitAllCompilesComplete = exports.onIPCServerMessage = exports.startIPCClient = exports.startIPCServer = exports._emitToServer = exports._onClientConnected = exports._processEmitQueue = exports.IPCType = void 0;
|
|
66
|
+
var node_ipc_1 = __importDefault(require("node-ipc"));
|
|
67
|
+
var flex_dev_utils_1 = require("@twilio/flex-dev-utils");
|
|
68
|
+
/*
|
|
69
|
+
* Self-import so internal calls between these exports go through the (spy-able) module namespace
|
|
70
|
+
* rather than a fixed local binding - lets jest.spyOn intercept same-module calls in tests.
|
|
71
|
+
*/
|
|
72
|
+
// eslint-disable-next-line import/no-self-import
|
|
73
|
+
var self = __importStar(require("./ipcServer"));
|
|
74
|
+
var IPCType;
|
|
75
|
+
(function (IPCType) {
|
|
76
|
+
IPCType["onCompileComplete"] = "onCompileComplete";
|
|
77
|
+
IPCType["onDevServerCrashed"] = "onDevServerCrashed";
|
|
78
|
+
IPCType["onEmitAllCompilesComplete"] = "onEmitAllCompilesComplete";
|
|
79
|
+
})(IPCType = exports.IPCType || (exports.IPCType = {}));
|
|
80
|
+
node_ipc_1.default.config.id = 'twilio.flex.plugin-builder';
|
|
81
|
+
node_ipc_1.default.config.retry = 1500;
|
|
82
|
+
node_ipc_1.default.config.silent = !flex_dev_utils_1.env.isDebug();
|
|
83
|
+
var _isServerRunning = false;
|
|
84
|
+
var _isClientConnected = false;
|
|
85
|
+
/* c8 ignore next */
|
|
86
|
+
var isServerRunning = function () { return _isServerRunning; };
|
|
87
|
+
/* c8 ignore next */
|
|
88
|
+
var isClientConnected = function () { return _isClientConnected; };
|
|
89
|
+
var clientNode = null;
|
|
90
|
+
var messageCallbacks = {};
|
|
91
|
+
/*
|
|
92
|
+
* This is used only to set the type of this queue
|
|
93
|
+
* This is the only way to get dynamic typing in TS :(
|
|
94
|
+
*/
|
|
95
|
+
var getEmitItem = function (type, payload) { return ({ type: type, payload: payload }); };
|
|
96
|
+
var emitQueue = [getEmitItem()].slice(1);
|
|
97
|
+
/**
|
|
98
|
+
* Processes the emit queue
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
/* c8 ignore next */
|
|
102
|
+
var _processEmitQueue = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
if (!isClientConnected()) {
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
}
|
|
107
|
+
while (emitQueue.length) {
|
|
108
|
+
clientNode.emit('message', emitQueue.pop());
|
|
109
|
+
}
|
|
110
|
+
return [2 /*return*/];
|
|
111
|
+
});
|
|
112
|
+
}); };
|
|
113
|
+
exports._processEmitQueue = _processEmitQueue;
|
|
114
|
+
/**
|
|
115
|
+
* Processes the on server message
|
|
116
|
+
* @param data
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
var _onServerMessage = function (data) {
|
|
120
|
+
if (!data.type) {
|
|
121
|
+
flex_dev_utils_1.logger.error('IPC got an unexpected message: ', data);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
Object.keys(messageCallbacks)
|
|
125
|
+
.filter(function (type) { return type === data.type; })
|
|
126
|
+
.forEach(function (type) {
|
|
127
|
+
var _a;
|
|
128
|
+
if (messageCallbacks[type]) {
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
|
+
(_a = messageCallbacks[type]) === null || _a === void 0 ? void 0 : _a.forEach(function (cb) { return cb(data.payload); });
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Processes on client connected
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
var _onClientConnected = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
139
|
+
return __generator(this, function (_a) {
|
|
140
|
+
switch (_a.label) {
|
|
141
|
+
case 0:
|
|
142
|
+
_isClientConnected = true;
|
|
143
|
+
return [4 /*yield*/, self._processEmitQueue()];
|
|
144
|
+
case 1:
|
|
145
|
+
_a.sent();
|
|
146
|
+
return [2 /*return*/];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}); };
|
|
150
|
+
exports._onClientConnected = _onClientConnected;
|
|
151
|
+
/**
|
|
152
|
+
* Emits to the server
|
|
153
|
+
* @param type the event type
|
|
154
|
+
* @param payload the event payload
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
var _emitToServer = function (type, payload) { return __awaiter(void 0, void 0, void 0, function () {
|
|
158
|
+
return __generator(this, function (_a) {
|
|
159
|
+
switch (_a.label) {
|
|
160
|
+
case 0:
|
|
161
|
+
emitQueue.push({ type: type, payload: payload });
|
|
162
|
+
return [4 /*yield*/, self._processEmitQueue()];
|
|
163
|
+
case 1:
|
|
164
|
+
_a.sent();
|
|
165
|
+
return [2 /*return*/];
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}); };
|
|
169
|
+
exports._emitToServer = _emitToServer;
|
|
170
|
+
/**
|
|
171
|
+
* Starts an IPC server
|
|
172
|
+
*/
|
|
173
|
+
var startIPCServer = function () {
|
|
174
|
+
if (isServerRunning()) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
node_ipc_1.default.serve(function () { return node_ipc_1.default.server.on('message', _onServerMessage); });
|
|
178
|
+
node_ipc_1.default.server.start();
|
|
179
|
+
_isServerRunning = true;
|
|
180
|
+
};
|
|
181
|
+
exports.startIPCServer = startIPCServer;
|
|
182
|
+
/**
|
|
183
|
+
* Starts an IPC Client
|
|
184
|
+
*/
|
|
185
|
+
var startIPCClient = function () {
|
|
186
|
+
if (isClientConnected()) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
node_ipc_1.default.connectTo(node_ipc_1.default.config.id, function () {
|
|
190
|
+
clientNode = node_ipc_1.default.of[node_ipc_1.default.config.id];
|
|
191
|
+
clientNode.on('connect', exports._onClientConnected);
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
exports.startIPCClient = startIPCClient;
|
|
195
|
+
/**
|
|
196
|
+
* onMessage event for the IPC server
|
|
197
|
+
* @param type
|
|
198
|
+
* @param callback
|
|
199
|
+
*/
|
|
200
|
+
/* c8 ignore next */
|
|
201
|
+
var onIPCServerMessage = function (type, callback) {
|
|
202
|
+
if (!(type in messageCallbacks)) {
|
|
203
|
+
messageCallbacks[type] = [];
|
|
204
|
+
}
|
|
205
|
+
// @ts-ignore
|
|
206
|
+
messageCallbacks[type].push(callback);
|
|
207
|
+
};
|
|
208
|
+
exports.onIPCServerMessage = onIPCServerMessage;
|
|
209
|
+
/**
|
|
210
|
+
* Emits to the server that all of the JS Bundles have completed compiling
|
|
211
|
+
* @param payload
|
|
212
|
+
* @returns
|
|
213
|
+
*/
|
|
214
|
+
var emitAllCompilesComplete = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
215
|
+
return [2 /*return*/, self._emitToServer(IPCType.onEmitAllCompilesComplete, {})];
|
|
216
|
+
}); }); };
|
|
217
|
+
exports.emitAllCompilesComplete = emitAllCompilesComplete;
|
|
218
|
+
/**
|
|
219
|
+
* Emits a compilation complete event
|
|
220
|
+
* @param payload
|
|
221
|
+
*/
|
|
222
|
+
var emitCompileComplete = function (payload) { return __awaiter(void 0, void 0, void 0, function () {
|
|
223
|
+
return __generator(this, function (_a) {
|
|
224
|
+
switch (_a.label) {
|
|
225
|
+
case 0: return [4 /*yield*/, self._emitToServer(IPCType.onCompileComplete, payload)];
|
|
226
|
+
case 1:
|
|
227
|
+
_a.sent();
|
|
228
|
+
if (!payload.lastPluginBundle) return [3 /*break*/, 3];
|
|
229
|
+
return [4 /*yield*/, self.emitAllCompilesComplete()];
|
|
230
|
+
case 2:
|
|
231
|
+
_a.sent();
|
|
232
|
+
_a.label = 3;
|
|
233
|
+
case 3: return [2 /*return*/];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}); };
|
|
237
|
+
exports.emitCompileComplete = emitCompileComplete;
|
|
238
|
+
/**
|
|
239
|
+
* Emits a dev-server failed event
|
|
240
|
+
* @param error
|
|
241
|
+
*/
|
|
242
|
+
var emitDevServerCrashed = function (error) { return __awaiter(void 0, void 0, void 0, function () {
|
|
243
|
+
return __generator(this, function (_a) {
|
|
244
|
+
return [2 /*return*/, self._emitToServer(IPCType.onDevServerCrashed, {
|
|
245
|
+
exception: {
|
|
246
|
+
message: error.message,
|
|
247
|
+
stack: error.stack,
|
|
248
|
+
},
|
|
249
|
+
})];
|
|
250
|
+
});
|
|
251
|
+
}); };
|
|
252
|
+
exports.emitDevServerCrashed = emitDevServerCrashed;
|
|
253
|
+
//# 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;AAGrD;;;GAGG;AACH,iDAAiD;AACjD,gDAAoC;AAQpC,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,kDAAuC,CAAA;IACvC,oDAAyC,CAAA;IACzC,kEAAuD,CAAA;AACzD,CAAC,EAJW,OAAO,GAAP,eAAO,KAAP,eAAO,QAIlB;AAwBD,kBAAG,CAAC,MAAM,CAAC,EAA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,EAAE;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,KAAK,EAAE,KAAK,CAAC,KAAK;iBACnB;aACF,CAAC,EAAA;;KAAA,CAAC;AANQ,QAAA,oBAAoB,wBAM5B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Request, Response } from 'express-serve-static-core';
|
|
2
|
+
import { FlexConfigurationPlugin } from '@twilio/flex-dev-utils/dist/fs';
|
|
3
|
+
import { Configuration, Port } from 'webpack-dev-server-wp5';
|
|
4
|
+
import * as self from './pluginServer';
|
|
5
|
+
export declare const PLUGIN_INPUT_PARSER_REGEX: RegExp;
|
|
6
|
+
export interface Plugin {
|
|
7
|
+
phase: number;
|
|
8
|
+
name: string;
|
|
9
|
+
src: string;
|
|
10
|
+
version?: string;
|
|
11
|
+
}
|
|
12
|
+
interface StartServerPlugins {
|
|
13
|
+
local: string[];
|
|
14
|
+
remote: string[];
|
|
15
|
+
versioned: string[];
|
|
16
|
+
}
|
|
17
|
+
interface StartServerConfig {
|
|
18
|
+
port: Port | number;
|
|
19
|
+
remoteAll: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface PluginsConfig {
|
|
22
|
+
[pluginName: string]: {
|
|
23
|
+
port: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export type OnRemotePlugins = (remotePlugins: Plugin[]) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the plugin from the local configuration file
|
|
29
|
+
* @param name the plugin name
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
export declare const _getLocalPlugin: (name: string) => FlexConfigurationPlugin | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Returns local plugins from cli/plugins.json
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
export declare const _getLocalPlugins: (port: number, names: string[]) => Plugin[];
|
|
38
|
+
/**
|
|
39
|
+
* Generates the response headers
|
|
40
|
+
*
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
export declare const _getHeaders: () => Record<string, string>;
|
|
44
|
+
/**
|
|
45
|
+
* Fetches the Plugins from Flex
|
|
46
|
+
*
|
|
47
|
+
* @param token the JWE Token
|
|
48
|
+
* @param version the Flex version
|
|
49
|
+
*/
|
|
50
|
+
export declare const _getRemotePlugins: (token: string, version: string | null | undefined) => Promise<Plugin[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns versioned plugins from the CLI
|
|
53
|
+
*
|
|
54
|
+
* @param names
|
|
55
|
+
* @returns
|
|
56
|
+
*/
|
|
57
|
+
export declare const _getRemoteVersionedPlugins: (names: string[]) => Plugin[];
|
|
58
|
+
/**
|
|
59
|
+
* Merge local and remote plugins
|
|
60
|
+
* @param localPlugins the list of local plugins
|
|
61
|
+
* @param remotePlugins the lost of remote plugins
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
export declare const _mergePlugins: (localPlugins: Plugin[], remotePlugins: Plugin[], versionedPlugins: Plugin[]) => Plugin[];
|
|
65
|
+
/**
|
|
66
|
+
* Basic server to fetch plugins from Flex and return to the local dev-server
|
|
67
|
+
* @param plugins
|
|
68
|
+
* @param config
|
|
69
|
+
* @param onRemotePlugin
|
|
70
|
+
*/
|
|
71
|
+
export declare const _startServer: (plugins: StartServerPlugins, config: StartServerConfig, onRemotePlugin: OnRemotePlugins) => (req: Request, res: Response) => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Setups up the plugin servers
|
|
74
|
+
* @param plugins
|
|
75
|
+
* @param webpackConfig
|
|
76
|
+
* @param serverConfig
|
|
77
|
+
*/
|
|
78
|
+
declare const _default: (plugins: StartServerPlugins, webpackConfig: Configuration, serverConfig: StartServerConfig, onRemotePlugin: OnRemotePlugins, pluginsConfig: PluginsConfig) => void;
|
|
79
|
+
export default _default;
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
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;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
62
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
63
|
+
if (!m) return o;
|
|
64
|
+
var i = m.call(o), r, ar = [], e;
|
|
65
|
+
try {
|
|
66
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
67
|
+
}
|
|
68
|
+
catch (error) { e = { error: error }; }
|
|
69
|
+
finally {
|
|
70
|
+
try {
|
|
71
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
72
|
+
}
|
|
73
|
+
finally { if (e) throw e.error; }
|
|
74
|
+
}
|
|
75
|
+
return ar;
|
|
76
|
+
};
|
|
77
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
78
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
79
|
+
if (ar || !(i in from)) {
|
|
80
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
81
|
+
ar[i] = from[i];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
85
|
+
};
|
|
86
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
87
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
88
|
+
};
|
|
89
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
90
|
+
exports._startServer = exports._mergePlugins = exports._getRemoteVersionedPlugins = exports._getRemotePlugins = exports._getHeaders = exports._getLocalPlugins = exports._getLocalPlugin = exports.PLUGIN_INPUT_PARSER_REGEX = void 0;
|
|
91
|
+
var https_1 = __importDefault(require("https"));
|
|
92
|
+
var flex_dev_utils_1 = require("@twilio/flex-dev-utils");
|
|
93
|
+
var fs_1 = require("@twilio/flex-dev-utils/dist/fs");
|
|
94
|
+
var prints_1 = require("../prints");
|
|
95
|
+
/*
|
|
96
|
+
* Self-import so internal calls between these exports go through the (spy-able) module
|
|
97
|
+
* namespace rather than a fixed local binding - lets jest.spyOn intercept same-module calls in tests.
|
|
98
|
+
*/
|
|
99
|
+
// eslint-disable-next-line import/no-self-import
|
|
100
|
+
var self = __importStar(require("./pluginServer"));
|
|
101
|
+
exports.PLUGIN_INPUT_PARSER_REGEX = /([\w-]+)(?:@(\S+))?/;
|
|
102
|
+
/**
|
|
103
|
+
* Returns the plugin from the local configuration file
|
|
104
|
+
* @param name the plugin name
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
// eslint-disable-next-line import/no-unused-modules
|
|
108
|
+
var _getLocalPlugin = function (name) {
|
|
109
|
+
return (0, fs_1.readPluginsJson)().plugins.find(function (p) { return p.name === name; });
|
|
110
|
+
};
|
|
111
|
+
exports._getLocalPlugin = _getLocalPlugin;
|
|
112
|
+
/**
|
|
113
|
+
* Returns local plugins from cli/plugins.json
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
// eslint-disable-next-line import/no-unused-modules
|
|
117
|
+
var _getLocalPlugins = function (port, names) {
|
|
118
|
+
var protocol = "http".concat(flex_dev_utils_1.env.isHTTPS() ? 's' : '', "://");
|
|
119
|
+
return names.map(function (name) {
|
|
120
|
+
var match = self._getLocalPlugin(name);
|
|
121
|
+
if (match) {
|
|
122
|
+
return {
|
|
123
|
+
phase: 3,
|
|
124
|
+
name: name,
|
|
125
|
+
src: "".concat(protocol, "localhost:").concat(port, "/plugins/").concat(name, ".js"),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
throw new flex_dev_utils_1.FlexPluginError("The plugin ".concat(name, " was not locally found. Try running `npm install` once in the plugin directory and try again."));
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
exports._getLocalPlugins = _getLocalPlugins;
|
|
132
|
+
/**
|
|
133
|
+
* Generates the response headers
|
|
134
|
+
*
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
// eslint-disable-next-line import/no-unused-modules
|
|
138
|
+
var _getHeaders = function () { return ({
|
|
139
|
+
'Access-Control-Allow-Origin': '*',
|
|
140
|
+
'Access-Control-Allow-Methods': 'GET',
|
|
141
|
+
'Access-Control-Allow-Headers': 'Content-Type, X-Flex-Version, X-Flex-JWE',
|
|
142
|
+
'Access-Control-Allow-Credentials': 'true',
|
|
143
|
+
'Content-Type': 'application/json',
|
|
144
|
+
}); };
|
|
145
|
+
exports._getHeaders = _getHeaders;
|
|
146
|
+
/**
|
|
147
|
+
* Fetches the Plugins from Flex
|
|
148
|
+
*
|
|
149
|
+
* @param token the JWE Token
|
|
150
|
+
* @param version the Flex version
|
|
151
|
+
*/
|
|
152
|
+
/* c8 ignore next */
|
|
153
|
+
// eslint-disable-next-line import/no-unused-modules
|
|
154
|
+
var _getRemotePlugins = function (token, version) { return __awaiter(void 0, void 0, void 0, function () {
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
157
|
+
var headers = {
|
|
158
|
+
'X-Flex-JWE': token,
|
|
159
|
+
};
|
|
160
|
+
if (version) {
|
|
161
|
+
headers['X-Flex-Version'] = version;
|
|
162
|
+
}
|
|
163
|
+
var options = {
|
|
164
|
+
hostname: 'flex.twilio.com',
|
|
165
|
+
port: 443,
|
|
166
|
+
path: '/plugins',
|
|
167
|
+
method: 'GET',
|
|
168
|
+
headers: headers,
|
|
169
|
+
};
|
|
170
|
+
https_1.default
|
|
171
|
+
.request(options, function (res) {
|
|
172
|
+
var data = [];
|
|
173
|
+
res.on('data', function (chunk) { return data.push(chunk); });
|
|
174
|
+
res.on('end', function () { return resolve(JSON.parse(Buffer.concat(data).toString()).filter(function (p) { return p.phase >= 3; })); });
|
|
175
|
+
})
|
|
176
|
+
.on('error', reject)
|
|
177
|
+
.end();
|
|
178
|
+
})];
|
|
179
|
+
});
|
|
180
|
+
}); };
|
|
181
|
+
exports._getRemotePlugins = _getRemotePlugins;
|
|
182
|
+
/**
|
|
183
|
+
* Returns versioned plugins from the CLI
|
|
184
|
+
*
|
|
185
|
+
* @param names
|
|
186
|
+
* @returns
|
|
187
|
+
*/
|
|
188
|
+
var _getRemoteVersionedPlugins = function (names) {
|
|
189
|
+
return names.map(function (plugin) {
|
|
190
|
+
var groups = plugin.match(exports.PLUGIN_INPUT_PARSER_REGEX);
|
|
191
|
+
if (!groups) {
|
|
192
|
+
throw new flex_dev_utils_1.FlexPluginError('Unexpected plugin name format was provided');
|
|
193
|
+
}
|
|
194
|
+
var name = groups[1];
|
|
195
|
+
var version = groups[2];
|
|
196
|
+
return {
|
|
197
|
+
phase: 3,
|
|
198
|
+
name: name,
|
|
199
|
+
src: "https://flex.twilio.com/plugins/v1/".concat(name, "/").concat(version, "/bundle.js"),
|
|
200
|
+
version: version,
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
exports._getRemoteVersionedPlugins = _getRemoteVersionedPlugins;
|
|
205
|
+
/**
|
|
206
|
+
* Merge local and remote plugins
|
|
207
|
+
* @param localPlugins the list of local plugins
|
|
208
|
+
* @param remotePlugins the lost of remote plugins
|
|
209
|
+
* @private
|
|
210
|
+
*/
|
|
211
|
+
// eslint-disable-next-line import/no-unused-modules
|
|
212
|
+
var _mergePlugins = function (localPlugins, remotePlugins, versionedPlugins) {
|
|
213
|
+
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; }); });
|
|
214
|
+
return __spreadArray(__spreadArray(__spreadArray([], __read(localPlugins), false), __read(deduped), false), __read(versionedPlugins), false);
|
|
215
|
+
};
|
|
216
|
+
exports._mergePlugins = _mergePlugins;
|
|
217
|
+
/**
|
|
218
|
+
* Basic server to fetch plugins from Flex and return to the local dev-server
|
|
219
|
+
* @param plugins
|
|
220
|
+
* @param config
|
|
221
|
+
* @param onRemotePlugin
|
|
222
|
+
*/
|
|
223
|
+
// eslint-disable-next-line import/no-unused-modules, @typescript-eslint/explicit-module-boundary-types
|
|
224
|
+
var _startServer = function (plugins, config, onRemotePlugin) {
|
|
225
|
+
var responseHeaders = self._getHeaders();
|
|
226
|
+
return function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
227
|
+
var headers, method, jweToken, flexVersion, hasRemotePlugin, localPlugins, versionedPlugins, promise;
|
|
228
|
+
return __generator(this, function (_a) {
|
|
229
|
+
headers = req.headers, method = req.method;
|
|
230
|
+
if (method === 'OPTIONS') {
|
|
231
|
+
res.writeHead(200, responseHeaders);
|
|
232
|
+
res.end();
|
|
233
|
+
return [2 /*return*/];
|
|
234
|
+
}
|
|
235
|
+
if (method !== 'GET') {
|
|
236
|
+
res.writeHead(404, responseHeaders);
|
|
237
|
+
res.end('Route not found');
|
|
238
|
+
return [2 /*return*/];
|
|
239
|
+
}
|
|
240
|
+
flex_dev_utils_1.logger.debug('GET /plugins');
|
|
241
|
+
jweToken = headers['x-flex-jwe'];
|
|
242
|
+
flexVersion = headers['x-flex-version'];
|
|
243
|
+
if (!jweToken) {
|
|
244
|
+
res.writeHead(400, responseHeaders);
|
|
245
|
+
res.end('No X-Flex-JWE was provided');
|
|
246
|
+
return [2 /*return*/];
|
|
247
|
+
}
|
|
248
|
+
hasRemotePlugin = config.remoteAll || plugins.remote.length !== 0;
|
|
249
|
+
localPlugins = self._getLocalPlugins(config.port, plugins.local);
|
|
250
|
+
versionedPlugins = self._getRemoteVersionedPlugins(plugins.versioned);
|
|
251
|
+
promise = hasRemotePlugin
|
|
252
|
+
? self._getRemotePlugins(jweToken, flexVersion)
|
|
253
|
+
: Promise.resolve([]);
|
|
254
|
+
// eslint-disable-next-line consistent-return
|
|
255
|
+
return [2 /*return*/, (promise
|
|
256
|
+
.then(function (remotePlugins) {
|
|
257
|
+
if (config.remoteAll) {
|
|
258
|
+
return remotePlugins;
|
|
259
|
+
}
|
|
260
|
+
// Check that all remote plugins inputted are valid
|
|
261
|
+
var notFoundPlugins = plugins.remote.filter(function (plgin) { return !remotePlugins.find(function (r) { return r.name === plgin; }); });
|
|
262
|
+
if (notFoundPlugins.length) {
|
|
263
|
+
(0, prints_1.remotePluginNotFound)(notFoundPlugins, remotePlugins);
|
|
264
|
+
(0, flex_dev_utils_1.exit)(1);
|
|
265
|
+
}
|
|
266
|
+
// Filter and only return the ones that are in remoteInputPlugins
|
|
267
|
+
return remotePlugins.filter(function (r) { return plugins.remote.includes(r.name); });
|
|
268
|
+
})
|
|
269
|
+
// rebase will eventually get both local and remote plugins
|
|
270
|
+
.then(function (remotePlugins) {
|
|
271
|
+
flex_dev_utils_1.logger.trace('Got remote plugins', remotePlugins);
|
|
272
|
+
onRemotePlugin(__spreadArray(__spreadArray([], __read(versionedPlugins), false), __read(remotePlugins), false));
|
|
273
|
+
res.writeHead(200, responseHeaders);
|
|
274
|
+
res.end(JSON.stringify(self._mergePlugins(localPlugins, remotePlugins, versionedPlugins)));
|
|
275
|
+
})
|
|
276
|
+
.catch(function (err) {
|
|
277
|
+
res.writeHead(500, responseHeaders);
|
|
278
|
+
res.end(err);
|
|
279
|
+
}))];
|
|
280
|
+
});
|
|
281
|
+
}); };
|
|
282
|
+
};
|
|
283
|
+
exports._startServer = _startServer;
|
|
284
|
+
/**
|
|
285
|
+
* Setups up the plugin servers
|
|
286
|
+
* @param plugins
|
|
287
|
+
* @param webpackConfig
|
|
288
|
+
* @param serverConfig
|
|
289
|
+
*/
|
|
290
|
+
/* c8 ignore next */
|
|
291
|
+
exports.default = (function (plugins, webpackConfig, serverConfig, onRemotePlugin, pluginsConfig) {
|
|
292
|
+
serverConfig.port = webpackConfig.port || 3000;
|
|
293
|
+
webpackConfig.proxy = plugins.local.reduce(function (proxy, name) {
|
|
294
|
+
proxy["/plugins/".concat(name, ".js")] = {
|
|
295
|
+
target: "http://127.0.0.1:".concat(serverConfig.port),
|
|
296
|
+
router: function () {
|
|
297
|
+
var match = pluginsConfig[name];
|
|
298
|
+
if (!match) {
|
|
299
|
+
throw new Error();
|
|
300
|
+
}
|
|
301
|
+
return "http://127.0.0.1:".concat(match.port);
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
return proxy;
|
|
305
|
+
}, {});
|
|
306
|
+
webpackConfig.onBeforeSetupMiddleware = function (server) {
|
|
307
|
+
var _a;
|
|
308
|
+
// @ts-ignore
|
|
309
|
+
serverConfig.port = server.options.port || serverConfig.port;
|
|
310
|
+
(_a = server === null || server === void 0 ? void 0 : server.app) === null || _a === void 0 ? void 0 : _a.use('^/plugins$', (0, exports._startServer)(plugins, serverConfig, onRemotePlugin));
|
|
311
|
+
};
|
|
312
|
+
});
|
|
313
|
+
//# 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;AACjD;;;GAGG;AACH,iDAAiD;AACjD,mDAAuC;AAE1B,QAAA,yBAAyB,GAAG,qBAAqB,CAAC;AA4B/D;;;;GAIG;AACH,oDAAoD;AAC7C,IAAM,eAAe,GAAG,UAAC,IAAY;IAC1C,OAAO,IAAA,oBAAe,GAAE,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,cAAO,oBAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,QAAK,CAAC;IAEtD,OAAO,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI;QACpB,IAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAEzC,IAAI,KAAK,EAA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