@dxyl/utils 1.1.7 → 1.1.9
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/dist/index.es.js +13454 -8772
- package/dist/index.umd.js +47 -17
- package/lib/tapable/index.es.js +1283 -0
- package/lib/tapable/index.umd.js +1321 -0
- package/package.json +3 -3
- package/types/color/colord/src/index.d.ts +3 -3
- package/types/compose.d.ts +19 -0
- package/types/data/mobx.d.ts +2 -154
- package/types/data/redux/applyMiddleware.d.ts +40 -0
- package/types/data/redux/bindActionCreators.d.ts +27 -0
- package/types/data/redux/combineReducers.d.ts +20 -0
- package/types/data/redux/compose.d.ts +19 -0
- package/types/data/redux/createStore.d.ts +126 -0
- package/types/data/redux/index.d.ts +14 -0
- package/types/data/redux/types/actions.d.ts +64 -0
- package/types/data/redux/types/middleware.d.ts +23 -0
- package/types/data/redux/types/reducers.d.ts +71 -0
- package/types/data/redux/types/store.d.ts +190 -0
- package/types/data/redux/utils/actionTypes.d.ts +12 -0
- package/types/data/redux/utils/formatProdErrorMessage.d.ts +8 -0
- package/types/data/redux/utils/isAction.d.ts +2 -0
- package/types/data/redux/utils/isPlainObject.d.ts +5 -0
- package/types/data/redux/utils/kindOf.d.ts +2 -0
- package/types/data/redux/utils/symbol-observable.d.ts +7 -0
- package/types/data/redux/utils/warning.d.ts +6 -0
- package/types/events/Observable.d.ts +161 -28
- package/types/events/eventmitter.d.ts +3 -1
- package/types/index.d.ts +6 -0
- package/types/tapable/index.d.ts +125 -0
|
@@ -0,0 +1,1321 @@
|
|
|
1
|
+
/***dx-rollup version 2.2.1 **/
|
|
2
|
+
(function (global, factory) {
|
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
5
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.tapable = {}));
|
|
6
|
+
}(this, (function (exports) { 'use strict';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
10
|
+
Author Tobias Koppers @sokra
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
var deprecate = (fn, msg) => {
|
|
14
|
+
let once = true;
|
|
15
|
+
return function() {
|
|
16
|
+
if (once) {
|
|
17
|
+
console.warn("DeprecationWarning: " + msg);
|
|
18
|
+
once = false;
|
|
19
|
+
}
|
|
20
|
+
return fn.apply(this, arguments);
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
var utilBrowser = {
|
|
25
|
+
deprecate: deprecate
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
30
|
+
Author Tobias Koppers @sokra
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const deprecateContext = utilBrowser.deprecate(() => {},
|
|
36
|
+
"Hook.context is deprecated and will be removed");
|
|
37
|
+
|
|
38
|
+
const CALL_DELEGATE = function(...args) {
|
|
39
|
+
this.call = this._createCall("sync");
|
|
40
|
+
return this.call(...args);
|
|
41
|
+
};
|
|
42
|
+
const CALL_ASYNC_DELEGATE = function(...args) {
|
|
43
|
+
this.callAsync = this._createCall("async");
|
|
44
|
+
return this.callAsync(...args);
|
|
45
|
+
};
|
|
46
|
+
const PROMISE_DELEGATE = function(...args) {
|
|
47
|
+
this.promise = this._createCall("promise");
|
|
48
|
+
return this.promise(...args);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
class Hook {
|
|
52
|
+
constructor(args = [], name = undefined) {
|
|
53
|
+
this._args = args;
|
|
54
|
+
this.name = name;
|
|
55
|
+
this.taps = [];
|
|
56
|
+
this.interceptors = [];
|
|
57
|
+
this._call = CALL_DELEGATE;
|
|
58
|
+
this.call = CALL_DELEGATE;
|
|
59
|
+
this._callAsync = CALL_ASYNC_DELEGATE;
|
|
60
|
+
this.callAsync = CALL_ASYNC_DELEGATE;
|
|
61
|
+
this._promise = PROMISE_DELEGATE;
|
|
62
|
+
this.promise = PROMISE_DELEGATE;
|
|
63
|
+
this._x = undefined;
|
|
64
|
+
|
|
65
|
+
this.compile = this.compile;
|
|
66
|
+
this.tap = this.tap;
|
|
67
|
+
this.tapAsync = this.tapAsync;
|
|
68
|
+
this.tapPromise = this.tapPromise;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
compile(options) {
|
|
72
|
+
throw new Error("Abstract: should be overridden");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_createCall(type) {
|
|
76
|
+
return this.compile({
|
|
77
|
+
taps: this.taps,
|
|
78
|
+
interceptors: this.interceptors,
|
|
79
|
+
args: this._args,
|
|
80
|
+
type: type
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
_tap(type, options, fn) {
|
|
85
|
+
if (typeof options === "string") {
|
|
86
|
+
options = {
|
|
87
|
+
name: options.trim()
|
|
88
|
+
};
|
|
89
|
+
} else if (typeof options !== "object" || options === null) {
|
|
90
|
+
throw new Error("Invalid tap options");
|
|
91
|
+
}
|
|
92
|
+
if (typeof options.name !== "string" || options.name === "") {
|
|
93
|
+
throw new Error("Missing name for tap");
|
|
94
|
+
}
|
|
95
|
+
if (typeof options.context !== "undefined") {
|
|
96
|
+
deprecateContext();
|
|
97
|
+
}
|
|
98
|
+
options = Object.assign({ type, fn }, options);
|
|
99
|
+
options = this._runRegisterInterceptors(options);
|
|
100
|
+
this._insert(options);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
tap(options, fn) {
|
|
104
|
+
this._tap("sync", options, fn);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
tapAsync(options, fn) {
|
|
108
|
+
this._tap("async", options, fn);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
tapPromise(options, fn) {
|
|
112
|
+
this._tap("promise", options, fn);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
_runRegisterInterceptors(options) {
|
|
116
|
+
for (const interceptor of this.interceptors) {
|
|
117
|
+
if (interceptor.register) {
|
|
118
|
+
const newOptions = interceptor.register(options);
|
|
119
|
+
if (newOptions !== undefined) {
|
|
120
|
+
options = newOptions;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return options;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
withOptions(options) {
|
|
128
|
+
const mergeOptions = opt =>
|
|
129
|
+
Object.assign({}, options, typeof opt === "string" ? { name: opt } : opt);
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
name: this.name,
|
|
133
|
+
tap: (opt, fn) => this.tap(mergeOptions(opt), fn),
|
|
134
|
+
tapAsync: (opt, fn) => this.tapAsync(mergeOptions(opt), fn),
|
|
135
|
+
tapPromise: (opt, fn) => this.tapPromise(mergeOptions(opt), fn),
|
|
136
|
+
intercept: interceptor => this.intercept(interceptor),
|
|
137
|
+
isUsed: () => this.isUsed(),
|
|
138
|
+
withOptions: opt => this.withOptions(mergeOptions(opt))
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
isUsed() {
|
|
143
|
+
return this.taps.length > 0 || this.interceptors.length > 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
intercept(interceptor) {
|
|
147
|
+
this._resetCompilation();
|
|
148
|
+
this.interceptors.push(Object.assign({}, interceptor));
|
|
149
|
+
if (interceptor.register) {
|
|
150
|
+
for (let i = 0; i < this.taps.length; i++) {
|
|
151
|
+
this.taps[i] = interceptor.register(this.taps[i]);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
_resetCompilation() {
|
|
157
|
+
this.call = this._call;
|
|
158
|
+
this.callAsync = this._callAsync;
|
|
159
|
+
this.promise = this._promise;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
_insert(item) {
|
|
163
|
+
this._resetCompilation();
|
|
164
|
+
let before;
|
|
165
|
+
if (typeof item.before === "string") {
|
|
166
|
+
before = new Set([item.before]);
|
|
167
|
+
} else if (Array.isArray(item.before)) {
|
|
168
|
+
before = new Set(item.before);
|
|
169
|
+
}
|
|
170
|
+
let stage = 0;
|
|
171
|
+
if (typeof item.stage === "number") {
|
|
172
|
+
stage = item.stage;
|
|
173
|
+
}
|
|
174
|
+
let i = this.taps.length;
|
|
175
|
+
while (i > 0) {
|
|
176
|
+
i--;
|
|
177
|
+
const x = this.taps[i];
|
|
178
|
+
this.taps[i + 1] = x;
|
|
179
|
+
const xStage = x.stage || 0;
|
|
180
|
+
if (before) {
|
|
181
|
+
if (before.has(x.name)) {
|
|
182
|
+
before.delete(x.name);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (before.size > 0) {
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (xStage > stage) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
i++;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
this.taps[i] = item;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
Object.setPrototypeOf(Hook.prototype, null);
|
|
200
|
+
|
|
201
|
+
var Hook_1 = Hook;
|
|
202
|
+
|
|
203
|
+
/*
|
|
204
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
205
|
+
Author Tobias Koppers @sokra
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
class HookCodeFactory {
|
|
209
|
+
constructor(config) {
|
|
210
|
+
this.config = config;
|
|
211
|
+
this.options = undefined;
|
|
212
|
+
this._args = undefined;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
create(options) {
|
|
216
|
+
this.init(options);
|
|
217
|
+
let fn;
|
|
218
|
+
switch (this.options.type) {
|
|
219
|
+
case "sync":
|
|
220
|
+
fn = new Function(
|
|
221
|
+
this.args(),
|
|
222
|
+
'"use strict";\n' +
|
|
223
|
+
this.header() +
|
|
224
|
+
this.contentWithInterceptors({
|
|
225
|
+
onError: err => `throw ${err};\n`,
|
|
226
|
+
onResult: result => `return ${result};\n`,
|
|
227
|
+
resultReturns: true,
|
|
228
|
+
onDone: () => "",
|
|
229
|
+
rethrowIfPossible: true
|
|
230
|
+
})
|
|
231
|
+
);
|
|
232
|
+
break;
|
|
233
|
+
case "async":
|
|
234
|
+
fn = new Function(
|
|
235
|
+
this.args({
|
|
236
|
+
after: "_callback"
|
|
237
|
+
}),
|
|
238
|
+
'"use strict";\n' +
|
|
239
|
+
this.header() +
|
|
240
|
+
this.contentWithInterceptors({
|
|
241
|
+
onError: err => `_callback(${err});\n`,
|
|
242
|
+
onResult: result => `_callback(null, ${result});\n`,
|
|
243
|
+
onDone: () => "_callback();\n"
|
|
244
|
+
})
|
|
245
|
+
);
|
|
246
|
+
break;
|
|
247
|
+
case "promise":
|
|
248
|
+
let errorHelperUsed = false;
|
|
249
|
+
const content = this.contentWithInterceptors({
|
|
250
|
+
onError: err => {
|
|
251
|
+
errorHelperUsed = true;
|
|
252
|
+
return `_error(${err});\n`;
|
|
253
|
+
},
|
|
254
|
+
onResult: result => `_resolve(${result});\n`,
|
|
255
|
+
onDone: () => "_resolve();\n"
|
|
256
|
+
});
|
|
257
|
+
let code = "";
|
|
258
|
+
code += '"use strict";\n';
|
|
259
|
+
code += this.header();
|
|
260
|
+
code += "return new Promise((function(_resolve, _reject) {\n";
|
|
261
|
+
if (errorHelperUsed) {
|
|
262
|
+
code += "var _sync = true;\n";
|
|
263
|
+
code += "function _error(_err) {\n";
|
|
264
|
+
code += "if(_sync)\n";
|
|
265
|
+
code +=
|
|
266
|
+
"_resolve(Promise.resolve().then((function() { throw _err; })));\n";
|
|
267
|
+
code += "else\n";
|
|
268
|
+
code += "_reject(_err);\n";
|
|
269
|
+
code += "};\n";
|
|
270
|
+
}
|
|
271
|
+
code += content;
|
|
272
|
+
if (errorHelperUsed) {
|
|
273
|
+
code += "_sync = false;\n";
|
|
274
|
+
}
|
|
275
|
+
code += "}));\n";
|
|
276
|
+
fn = new Function(this.args(), code);
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
this.deinit();
|
|
280
|
+
return fn;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
setup(instance, options) {
|
|
284
|
+
instance._x = options.taps.map(t => t.fn);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* @param {{ type: "sync" | "promise" | "async", taps: Array<Tap>, interceptors: Array<Interceptor> }} options
|
|
289
|
+
*/
|
|
290
|
+
init(options) {
|
|
291
|
+
this.options = options;
|
|
292
|
+
this._args = options.args.slice();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
deinit() {
|
|
296
|
+
this.options = undefined;
|
|
297
|
+
this._args = undefined;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
contentWithInterceptors(options) {
|
|
301
|
+
if (this.options.interceptors.length > 0) {
|
|
302
|
+
const onError = options.onError;
|
|
303
|
+
const onResult = options.onResult;
|
|
304
|
+
const onDone = options.onDone;
|
|
305
|
+
let code = "";
|
|
306
|
+
for (let i = 0; i < this.options.interceptors.length; i++) {
|
|
307
|
+
const interceptor = this.options.interceptors[i];
|
|
308
|
+
if (interceptor.call) {
|
|
309
|
+
code += `${this.getInterceptor(i)}.call(${this.args({
|
|
310
|
+
before: interceptor.context ? "_context" : undefined
|
|
311
|
+
})});\n`;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
code += this.content(
|
|
315
|
+
Object.assign(options, {
|
|
316
|
+
onError:
|
|
317
|
+
onError &&
|
|
318
|
+
(err => {
|
|
319
|
+
let code = "";
|
|
320
|
+
for (let i = 0; i < this.options.interceptors.length; i++) {
|
|
321
|
+
const interceptor = this.options.interceptors[i];
|
|
322
|
+
if (interceptor.error) {
|
|
323
|
+
code += `${this.getInterceptor(i)}.error(${err});\n`;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
code += onError(err);
|
|
327
|
+
return code;
|
|
328
|
+
}),
|
|
329
|
+
onResult:
|
|
330
|
+
onResult &&
|
|
331
|
+
(result => {
|
|
332
|
+
let code = "";
|
|
333
|
+
for (let i = 0; i < this.options.interceptors.length; i++) {
|
|
334
|
+
const interceptor = this.options.interceptors[i];
|
|
335
|
+
if (interceptor.result) {
|
|
336
|
+
code += `${this.getInterceptor(i)}.result(${result});\n`;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
code += onResult(result);
|
|
340
|
+
return code;
|
|
341
|
+
}),
|
|
342
|
+
onDone:
|
|
343
|
+
onDone &&
|
|
344
|
+
(() => {
|
|
345
|
+
let code = "";
|
|
346
|
+
for (let i = 0; i < this.options.interceptors.length; i++) {
|
|
347
|
+
const interceptor = this.options.interceptors[i];
|
|
348
|
+
if (interceptor.done) {
|
|
349
|
+
code += `${this.getInterceptor(i)}.done();\n`;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
code += onDone();
|
|
353
|
+
return code;
|
|
354
|
+
})
|
|
355
|
+
})
|
|
356
|
+
);
|
|
357
|
+
return code;
|
|
358
|
+
} else {
|
|
359
|
+
return this.content(options);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
header() {
|
|
364
|
+
let code = "";
|
|
365
|
+
if (this.needContext()) {
|
|
366
|
+
code += "var _context = {};\n";
|
|
367
|
+
} else {
|
|
368
|
+
code += "var _context;\n";
|
|
369
|
+
}
|
|
370
|
+
code += "var _x = this._x;\n";
|
|
371
|
+
if (this.options.interceptors.length > 0) {
|
|
372
|
+
code += "var _taps = this.taps;\n";
|
|
373
|
+
code += "var _interceptors = this.interceptors;\n";
|
|
374
|
+
}
|
|
375
|
+
return code;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
needContext() {
|
|
379
|
+
for (const tap of this.options.taps) if (tap.context) return true;
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
callTap(tapIndex, { onError, onResult, onDone, rethrowIfPossible }) {
|
|
384
|
+
let code = "";
|
|
385
|
+
let hasTapCached = false;
|
|
386
|
+
for (let i = 0; i < this.options.interceptors.length; i++) {
|
|
387
|
+
const interceptor = this.options.interceptors[i];
|
|
388
|
+
if (interceptor.tap) {
|
|
389
|
+
if (!hasTapCached) {
|
|
390
|
+
code += `var _tap${tapIndex} = ${this.getTap(tapIndex)};\n`;
|
|
391
|
+
hasTapCached = true;
|
|
392
|
+
}
|
|
393
|
+
code += `${this.getInterceptor(i)}.tap(${
|
|
394
|
+
interceptor.context ? "_context, " : ""
|
|
395
|
+
}_tap${tapIndex});\n`;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
code += `var _fn${tapIndex} = ${this.getTapFn(tapIndex)};\n`;
|
|
399
|
+
const tap = this.options.taps[tapIndex];
|
|
400
|
+
switch (tap.type) {
|
|
401
|
+
case "sync":
|
|
402
|
+
if (!rethrowIfPossible) {
|
|
403
|
+
code += `var _hasError${tapIndex} = false;\n`;
|
|
404
|
+
code += "try {\n";
|
|
405
|
+
}
|
|
406
|
+
if (onResult) {
|
|
407
|
+
code += `var _result${tapIndex} = _fn${tapIndex}(${this.args({
|
|
408
|
+
before: tap.context ? "_context" : undefined
|
|
409
|
+
})});\n`;
|
|
410
|
+
} else {
|
|
411
|
+
code += `_fn${tapIndex}(${this.args({
|
|
412
|
+
before: tap.context ? "_context" : undefined
|
|
413
|
+
})});\n`;
|
|
414
|
+
}
|
|
415
|
+
if (!rethrowIfPossible) {
|
|
416
|
+
code += "} catch(_err) {\n";
|
|
417
|
+
code += `_hasError${tapIndex} = true;\n`;
|
|
418
|
+
code += onError("_err");
|
|
419
|
+
code += "}\n";
|
|
420
|
+
code += `if(!_hasError${tapIndex}) {\n`;
|
|
421
|
+
}
|
|
422
|
+
if (onResult) {
|
|
423
|
+
code += onResult(`_result${tapIndex}`);
|
|
424
|
+
}
|
|
425
|
+
if (onDone) {
|
|
426
|
+
code += onDone();
|
|
427
|
+
}
|
|
428
|
+
if (!rethrowIfPossible) {
|
|
429
|
+
code += "}\n";
|
|
430
|
+
}
|
|
431
|
+
break;
|
|
432
|
+
case "async":
|
|
433
|
+
let cbCode = "";
|
|
434
|
+
if (onResult)
|
|
435
|
+
cbCode += `(function(_err${tapIndex}, _result${tapIndex}) {\n`;
|
|
436
|
+
else cbCode += `(function(_err${tapIndex}) {\n`;
|
|
437
|
+
cbCode += `if(_err${tapIndex}) {\n`;
|
|
438
|
+
cbCode += onError(`_err${tapIndex}`);
|
|
439
|
+
cbCode += "} else {\n";
|
|
440
|
+
if (onResult) {
|
|
441
|
+
cbCode += onResult(`_result${tapIndex}`);
|
|
442
|
+
}
|
|
443
|
+
if (onDone) {
|
|
444
|
+
cbCode += onDone();
|
|
445
|
+
}
|
|
446
|
+
cbCode += "}\n";
|
|
447
|
+
cbCode += "})";
|
|
448
|
+
code += `_fn${tapIndex}(${this.args({
|
|
449
|
+
before: tap.context ? "_context" : undefined,
|
|
450
|
+
after: cbCode
|
|
451
|
+
})});\n`;
|
|
452
|
+
break;
|
|
453
|
+
case "promise":
|
|
454
|
+
code += `var _hasResult${tapIndex} = false;\n`;
|
|
455
|
+
code += `var _promise${tapIndex} = _fn${tapIndex}(${this.args({
|
|
456
|
+
before: tap.context ? "_context" : undefined
|
|
457
|
+
})});\n`;
|
|
458
|
+
code += `if (!_promise${tapIndex} || !_promise${tapIndex}.then)\n`;
|
|
459
|
+
code += ` throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise${tapIndex} + ')');\n`;
|
|
460
|
+
code += `_promise${tapIndex}.then((function(_result${tapIndex}) {\n`;
|
|
461
|
+
code += `_hasResult${tapIndex} = true;\n`;
|
|
462
|
+
if (onResult) {
|
|
463
|
+
code += onResult(`_result${tapIndex}`);
|
|
464
|
+
}
|
|
465
|
+
if (onDone) {
|
|
466
|
+
code += onDone();
|
|
467
|
+
}
|
|
468
|
+
code += `}), function(_err${tapIndex}) {\n`;
|
|
469
|
+
code += `if(_hasResult${tapIndex}) throw _err${tapIndex};\n`;
|
|
470
|
+
code += onError(`_err${tapIndex}`);
|
|
471
|
+
code += "});\n";
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
return code;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
callTapsSeries({
|
|
478
|
+
onError,
|
|
479
|
+
onResult,
|
|
480
|
+
resultReturns,
|
|
481
|
+
onDone,
|
|
482
|
+
doneReturns,
|
|
483
|
+
rethrowIfPossible
|
|
484
|
+
}) {
|
|
485
|
+
if (this.options.taps.length === 0) return onDone();
|
|
486
|
+
const firstAsync = this.options.taps.findIndex(t => t.type !== "sync");
|
|
487
|
+
const somethingReturns = resultReturns || doneReturns;
|
|
488
|
+
let code = "";
|
|
489
|
+
let current = onDone;
|
|
490
|
+
let unrollCounter = 0;
|
|
491
|
+
for (let j = this.options.taps.length - 1; j >= 0; j--) {
|
|
492
|
+
const i = j;
|
|
493
|
+
const unroll =
|
|
494
|
+
current !== onDone &&
|
|
495
|
+
(this.options.taps[i].type !== "sync" || unrollCounter++ > 20);
|
|
496
|
+
if (unroll) {
|
|
497
|
+
unrollCounter = 0;
|
|
498
|
+
code += `function _next${i}() {\n`;
|
|
499
|
+
code += current();
|
|
500
|
+
code += `}\n`;
|
|
501
|
+
current = () => `${somethingReturns ? "return " : ""}_next${i}();\n`;
|
|
502
|
+
}
|
|
503
|
+
const done = current;
|
|
504
|
+
const doneBreak = skipDone => {
|
|
505
|
+
if (skipDone) return "";
|
|
506
|
+
return onDone();
|
|
507
|
+
};
|
|
508
|
+
const content = this.callTap(i, {
|
|
509
|
+
onError: error => onError(i, error, done, doneBreak),
|
|
510
|
+
onResult:
|
|
511
|
+
onResult &&
|
|
512
|
+
(result => {
|
|
513
|
+
return onResult(i, result, done, doneBreak);
|
|
514
|
+
}),
|
|
515
|
+
onDone: !onResult && done,
|
|
516
|
+
rethrowIfPossible:
|
|
517
|
+
rethrowIfPossible && (firstAsync < 0 || i < firstAsync)
|
|
518
|
+
});
|
|
519
|
+
current = () => content;
|
|
520
|
+
}
|
|
521
|
+
code += current();
|
|
522
|
+
return code;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
callTapsLooping({ onError, onDone, rethrowIfPossible }) {
|
|
526
|
+
if (this.options.taps.length === 0) return onDone();
|
|
527
|
+
const syncOnly = this.options.taps.every(t => t.type === "sync");
|
|
528
|
+
let code = "";
|
|
529
|
+
if (!syncOnly) {
|
|
530
|
+
code += "var _looper = (function() {\n";
|
|
531
|
+
code += "var _loopAsync = false;\n";
|
|
532
|
+
}
|
|
533
|
+
code += "var _loop;\n";
|
|
534
|
+
code += "do {\n";
|
|
535
|
+
code += "_loop = false;\n";
|
|
536
|
+
for (let i = 0; i < this.options.interceptors.length; i++) {
|
|
537
|
+
const interceptor = this.options.interceptors[i];
|
|
538
|
+
if (interceptor.loop) {
|
|
539
|
+
code += `${this.getInterceptor(i)}.loop(${this.args({
|
|
540
|
+
before: interceptor.context ? "_context" : undefined
|
|
541
|
+
})});\n`;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
code += this.callTapsSeries({
|
|
545
|
+
onError,
|
|
546
|
+
onResult: (i, result, next, doneBreak) => {
|
|
547
|
+
let code = "";
|
|
548
|
+
code += `if(${result} !== undefined) {\n`;
|
|
549
|
+
code += "_loop = true;\n";
|
|
550
|
+
if (!syncOnly) code += "if(_loopAsync) _looper();\n";
|
|
551
|
+
code += doneBreak(true);
|
|
552
|
+
code += `} else {\n`;
|
|
553
|
+
code += next();
|
|
554
|
+
code += `}\n`;
|
|
555
|
+
return code;
|
|
556
|
+
},
|
|
557
|
+
onDone:
|
|
558
|
+
onDone &&
|
|
559
|
+
(() => {
|
|
560
|
+
let code = "";
|
|
561
|
+
code += "if(!_loop) {\n";
|
|
562
|
+
code += onDone();
|
|
563
|
+
code += "}\n";
|
|
564
|
+
return code;
|
|
565
|
+
}),
|
|
566
|
+
rethrowIfPossible: rethrowIfPossible && syncOnly
|
|
567
|
+
});
|
|
568
|
+
code += "} while(_loop);\n";
|
|
569
|
+
if (!syncOnly) {
|
|
570
|
+
code += "_loopAsync = true;\n";
|
|
571
|
+
code += "});\n";
|
|
572
|
+
code += "_looper();\n";
|
|
573
|
+
}
|
|
574
|
+
return code;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
callTapsParallel({
|
|
578
|
+
onError,
|
|
579
|
+
onResult,
|
|
580
|
+
onDone,
|
|
581
|
+
rethrowIfPossible,
|
|
582
|
+
onTap = (i, run) => run()
|
|
583
|
+
}) {
|
|
584
|
+
if (this.options.taps.length <= 1) {
|
|
585
|
+
return this.callTapsSeries({
|
|
586
|
+
onError,
|
|
587
|
+
onResult,
|
|
588
|
+
onDone,
|
|
589
|
+
rethrowIfPossible
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
let code = "";
|
|
593
|
+
code += "do {\n";
|
|
594
|
+
code += `var _counter = ${this.options.taps.length};\n`;
|
|
595
|
+
if (onDone) {
|
|
596
|
+
code += "var _done = (function() {\n";
|
|
597
|
+
code += onDone();
|
|
598
|
+
code += "});\n";
|
|
599
|
+
}
|
|
600
|
+
for (let i = 0; i < this.options.taps.length; i++) {
|
|
601
|
+
const done = () => {
|
|
602
|
+
if (onDone) return "if(--_counter === 0) _done();\n";
|
|
603
|
+
else return "--_counter;";
|
|
604
|
+
};
|
|
605
|
+
const doneBreak = skipDone => {
|
|
606
|
+
if (skipDone || !onDone) return "_counter = 0;\n";
|
|
607
|
+
else return "_counter = 0;\n_done();\n";
|
|
608
|
+
};
|
|
609
|
+
code += "if(_counter <= 0) break;\n";
|
|
610
|
+
code += onTap(
|
|
611
|
+
i,
|
|
612
|
+
() =>
|
|
613
|
+
this.callTap(i, {
|
|
614
|
+
onError: error => {
|
|
615
|
+
let code = "";
|
|
616
|
+
code += "if(_counter > 0) {\n";
|
|
617
|
+
code += onError(i, error, done, doneBreak);
|
|
618
|
+
code += "}\n";
|
|
619
|
+
return code;
|
|
620
|
+
},
|
|
621
|
+
onResult:
|
|
622
|
+
onResult &&
|
|
623
|
+
(result => {
|
|
624
|
+
let code = "";
|
|
625
|
+
code += "if(_counter > 0) {\n";
|
|
626
|
+
code += onResult(i, result, done, doneBreak);
|
|
627
|
+
code += "}\n";
|
|
628
|
+
return code;
|
|
629
|
+
}),
|
|
630
|
+
onDone:
|
|
631
|
+
!onResult &&
|
|
632
|
+
(() => {
|
|
633
|
+
return done();
|
|
634
|
+
}),
|
|
635
|
+
rethrowIfPossible
|
|
636
|
+
}),
|
|
637
|
+
done,
|
|
638
|
+
doneBreak
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
code += "} while(false);\n";
|
|
642
|
+
return code;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
args({ before, after } = {}) {
|
|
646
|
+
let allArgs = this._args;
|
|
647
|
+
if (before) allArgs = [before].concat(allArgs);
|
|
648
|
+
if (after) allArgs = allArgs.concat(after);
|
|
649
|
+
if (allArgs.length === 0) {
|
|
650
|
+
return "";
|
|
651
|
+
} else {
|
|
652
|
+
return allArgs.join(", ");
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
getTapFn(idx) {
|
|
657
|
+
return `_x[${idx}]`;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
getTap(idx) {
|
|
661
|
+
return `_taps[${idx}]`;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
getInterceptor(idx) {
|
|
665
|
+
return `_interceptors[${idx}]`;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
var HookCodeFactory_1 = HookCodeFactory;
|
|
670
|
+
|
|
671
|
+
/*
|
|
672
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
673
|
+
Author Tobias Koppers @sokra
|
|
674
|
+
*/
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
class SyncHookCodeFactory extends HookCodeFactory_1 {
|
|
680
|
+
content({ onError, onDone, rethrowIfPossible }) {
|
|
681
|
+
return this.callTapsSeries({
|
|
682
|
+
onError: (i, err) => onError(err),
|
|
683
|
+
onDone,
|
|
684
|
+
rethrowIfPossible
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
const factory$9 = new SyncHookCodeFactory();
|
|
690
|
+
|
|
691
|
+
const TAP_ASYNC$3 = () => {
|
|
692
|
+
throw new Error("tapAsync is not supported on a SyncHook");
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
const TAP_PROMISE$3 = () => {
|
|
696
|
+
throw new Error("tapPromise is not supported on a SyncHook");
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
const COMPILE$9 = function(options) {
|
|
700
|
+
factory$9.setup(this, options);
|
|
701
|
+
return factory$9.create(options);
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
function SyncHook$1(args = [], name = undefined) {
|
|
705
|
+
const hook = new Hook_1(args, name);
|
|
706
|
+
hook.constructor = SyncHook$1;
|
|
707
|
+
hook.tapAsync = TAP_ASYNC$3;
|
|
708
|
+
hook.tapPromise = TAP_PROMISE$3;
|
|
709
|
+
hook.compile = COMPILE$9;
|
|
710
|
+
return hook;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
SyncHook$1.prototype = null;
|
|
714
|
+
|
|
715
|
+
var SyncHook_1 = SyncHook$1;
|
|
716
|
+
|
|
717
|
+
/*
|
|
718
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
719
|
+
Author Tobias Koppers @sokra
|
|
720
|
+
*/
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
class SyncBailHookCodeFactory extends HookCodeFactory_1 {
|
|
726
|
+
content({ onError, onResult, resultReturns, onDone, rethrowIfPossible }) {
|
|
727
|
+
return this.callTapsSeries({
|
|
728
|
+
onError: (i, err) => onError(err),
|
|
729
|
+
onResult: (i, result, next) =>
|
|
730
|
+
`if(${result} !== undefined) {\n${onResult(
|
|
731
|
+
result
|
|
732
|
+
)};\n} else {\n${next()}}\n`,
|
|
733
|
+
resultReturns,
|
|
734
|
+
onDone,
|
|
735
|
+
rethrowIfPossible
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
const factory$8 = new SyncBailHookCodeFactory();
|
|
741
|
+
|
|
742
|
+
const TAP_ASYNC$2 = () => {
|
|
743
|
+
throw new Error("tapAsync is not supported on a SyncBailHook");
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
const TAP_PROMISE$2 = () => {
|
|
747
|
+
throw new Error("tapPromise is not supported on a SyncBailHook");
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
const COMPILE$8 = function(options) {
|
|
751
|
+
factory$8.setup(this, options);
|
|
752
|
+
return factory$8.create(options);
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
function SyncBailHook$1(args = [], name = undefined) {
|
|
756
|
+
const hook = new Hook_1(args, name);
|
|
757
|
+
hook.constructor = SyncBailHook$1;
|
|
758
|
+
hook.tapAsync = TAP_ASYNC$2;
|
|
759
|
+
hook.tapPromise = TAP_PROMISE$2;
|
|
760
|
+
hook.compile = COMPILE$8;
|
|
761
|
+
return hook;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
SyncBailHook$1.prototype = null;
|
|
765
|
+
|
|
766
|
+
var SyncBailHook_1 = SyncBailHook$1;
|
|
767
|
+
|
|
768
|
+
/*
|
|
769
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
770
|
+
Author Tobias Koppers @sokra
|
|
771
|
+
*/
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
class SyncWaterfallHookCodeFactory extends HookCodeFactory_1 {
|
|
777
|
+
content({ onError, onResult, resultReturns, rethrowIfPossible }) {
|
|
778
|
+
return this.callTapsSeries({
|
|
779
|
+
onError: (i, err) => onError(err),
|
|
780
|
+
onResult: (i, result, next) => {
|
|
781
|
+
let code = "";
|
|
782
|
+
code += `if(${result} !== undefined) {\n`;
|
|
783
|
+
code += `${this._args[0]} = ${result};\n`;
|
|
784
|
+
code += `}\n`;
|
|
785
|
+
code += next();
|
|
786
|
+
return code;
|
|
787
|
+
},
|
|
788
|
+
onDone: () => onResult(this._args[0]),
|
|
789
|
+
doneReturns: resultReturns,
|
|
790
|
+
rethrowIfPossible
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
const factory$7 = new SyncWaterfallHookCodeFactory();
|
|
796
|
+
|
|
797
|
+
const TAP_ASYNC$1 = () => {
|
|
798
|
+
throw new Error("tapAsync is not supported on a SyncWaterfallHook");
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
const TAP_PROMISE$1 = () => {
|
|
802
|
+
throw new Error("tapPromise is not supported on a SyncWaterfallHook");
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
const COMPILE$7 = function(options) {
|
|
806
|
+
factory$7.setup(this, options);
|
|
807
|
+
return factory$7.create(options);
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
function SyncWaterfallHook$1(args = [], name = undefined) {
|
|
811
|
+
if (args.length < 1)
|
|
812
|
+
throw new Error("Waterfall hooks must have at least one argument");
|
|
813
|
+
const hook = new Hook_1(args, name);
|
|
814
|
+
hook.constructor = SyncWaterfallHook$1;
|
|
815
|
+
hook.tapAsync = TAP_ASYNC$1;
|
|
816
|
+
hook.tapPromise = TAP_PROMISE$1;
|
|
817
|
+
hook.compile = COMPILE$7;
|
|
818
|
+
return hook;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
SyncWaterfallHook$1.prototype = null;
|
|
822
|
+
|
|
823
|
+
var SyncWaterfallHook_1 = SyncWaterfallHook$1;
|
|
824
|
+
|
|
825
|
+
/*
|
|
826
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
827
|
+
Author Tobias Koppers @sokra
|
|
828
|
+
*/
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
class SyncLoopHookCodeFactory extends HookCodeFactory_1 {
|
|
834
|
+
content({ onError, onDone, rethrowIfPossible }) {
|
|
835
|
+
return this.callTapsLooping({
|
|
836
|
+
onError: (i, err) => onError(err),
|
|
837
|
+
onDone,
|
|
838
|
+
rethrowIfPossible
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
const factory$6 = new SyncLoopHookCodeFactory();
|
|
844
|
+
|
|
845
|
+
const TAP_ASYNC = () => {
|
|
846
|
+
throw new Error("tapAsync is not supported on a SyncLoopHook");
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
const TAP_PROMISE = () => {
|
|
850
|
+
throw new Error("tapPromise is not supported on a SyncLoopHook");
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
const COMPILE$6 = function(options) {
|
|
854
|
+
factory$6.setup(this, options);
|
|
855
|
+
return factory$6.create(options);
|
|
856
|
+
};
|
|
857
|
+
|
|
858
|
+
function SyncLoopHook$1(args = [], name = undefined) {
|
|
859
|
+
const hook = new Hook_1(args, name);
|
|
860
|
+
hook.constructor = SyncLoopHook$1;
|
|
861
|
+
hook.tapAsync = TAP_ASYNC;
|
|
862
|
+
hook.tapPromise = TAP_PROMISE;
|
|
863
|
+
hook.compile = COMPILE$6;
|
|
864
|
+
return hook;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
SyncLoopHook$1.prototype = null;
|
|
868
|
+
|
|
869
|
+
var SyncLoopHook_1 = SyncLoopHook$1;
|
|
870
|
+
|
|
871
|
+
/*
|
|
872
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
873
|
+
Author Tobias Koppers @sokra
|
|
874
|
+
*/
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
class AsyncParallelHookCodeFactory extends HookCodeFactory_1 {
|
|
880
|
+
content({ onError, onDone }) {
|
|
881
|
+
return this.callTapsParallel({
|
|
882
|
+
onError: (i, err, done, doneBreak) => onError(err) + doneBreak(true),
|
|
883
|
+
onDone
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
const factory$5 = new AsyncParallelHookCodeFactory();
|
|
889
|
+
|
|
890
|
+
const COMPILE$5 = function(options) {
|
|
891
|
+
factory$5.setup(this, options);
|
|
892
|
+
return factory$5.create(options);
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
function AsyncParallelHook$1(args = [], name = undefined) {
|
|
896
|
+
const hook = new Hook_1(args, name);
|
|
897
|
+
hook.constructor = AsyncParallelHook$1;
|
|
898
|
+
hook.compile = COMPILE$5;
|
|
899
|
+
hook._call = undefined;
|
|
900
|
+
hook.call = undefined;
|
|
901
|
+
return hook;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
AsyncParallelHook$1.prototype = null;
|
|
905
|
+
|
|
906
|
+
var AsyncParallelHook_1 = AsyncParallelHook$1;
|
|
907
|
+
|
|
908
|
+
/*
|
|
909
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
910
|
+
Author Tobias Koppers @sokra
|
|
911
|
+
*/
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
class AsyncParallelBailHookCodeFactory extends HookCodeFactory_1 {
|
|
917
|
+
content({ onError, onResult, onDone }) {
|
|
918
|
+
let code = "";
|
|
919
|
+
code += `var _results = new Array(${this.options.taps.length});\n`;
|
|
920
|
+
code += "var _checkDone = function() {\n";
|
|
921
|
+
code += "for(var i = 0; i < _results.length; i++) {\n";
|
|
922
|
+
code += "var item = _results[i];\n";
|
|
923
|
+
code += "if(item === undefined) return false;\n";
|
|
924
|
+
code += "if(item.result !== undefined) {\n";
|
|
925
|
+
code += onResult("item.result");
|
|
926
|
+
code += "return true;\n";
|
|
927
|
+
code += "}\n";
|
|
928
|
+
code += "if(item.error) {\n";
|
|
929
|
+
code += onError("item.error");
|
|
930
|
+
code += "return true;\n";
|
|
931
|
+
code += "}\n";
|
|
932
|
+
code += "}\n";
|
|
933
|
+
code += "return false;\n";
|
|
934
|
+
code += "}\n";
|
|
935
|
+
code += this.callTapsParallel({
|
|
936
|
+
onError: (i, err, done, doneBreak) => {
|
|
937
|
+
let code = "";
|
|
938
|
+
code += `if(${i} < _results.length && ((_results.length = ${i +
|
|
939
|
+
1}), (_results[${i}] = { error: ${err} }), _checkDone())) {\n`;
|
|
940
|
+
code += doneBreak(true);
|
|
941
|
+
code += "} else {\n";
|
|
942
|
+
code += done();
|
|
943
|
+
code += "}\n";
|
|
944
|
+
return code;
|
|
945
|
+
},
|
|
946
|
+
onResult: (i, result, done, doneBreak) => {
|
|
947
|
+
let code = "";
|
|
948
|
+
code += `if(${i} < _results.length && (${result} !== undefined && (_results.length = ${i +
|
|
949
|
+
1}), (_results[${i}] = { result: ${result} }), _checkDone())) {\n`;
|
|
950
|
+
code += doneBreak(true);
|
|
951
|
+
code += "} else {\n";
|
|
952
|
+
code += done();
|
|
953
|
+
code += "}\n";
|
|
954
|
+
return code;
|
|
955
|
+
},
|
|
956
|
+
onTap: (i, run, done, doneBreak) => {
|
|
957
|
+
let code = "";
|
|
958
|
+
if (i > 0) {
|
|
959
|
+
code += `if(${i} >= _results.length) {\n`;
|
|
960
|
+
code += done();
|
|
961
|
+
code += "} else {\n";
|
|
962
|
+
}
|
|
963
|
+
code += run();
|
|
964
|
+
if (i > 0) code += "}\n";
|
|
965
|
+
return code;
|
|
966
|
+
},
|
|
967
|
+
onDone
|
|
968
|
+
});
|
|
969
|
+
return code;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
const factory$4 = new AsyncParallelBailHookCodeFactory();
|
|
974
|
+
|
|
975
|
+
const COMPILE$4 = function(options) {
|
|
976
|
+
factory$4.setup(this, options);
|
|
977
|
+
return factory$4.create(options);
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
function AsyncParallelBailHook$1(args = [], name = undefined) {
|
|
981
|
+
const hook = new Hook_1(args, name);
|
|
982
|
+
hook.constructor = AsyncParallelBailHook$1;
|
|
983
|
+
hook.compile = COMPILE$4;
|
|
984
|
+
hook._call = undefined;
|
|
985
|
+
hook.call = undefined;
|
|
986
|
+
return hook;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
AsyncParallelBailHook$1.prototype = null;
|
|
990
|
+
|
|
991
|
+
var AsyncParallelBailHook_1 = AsyncParallelBailHook$1;
|
|
992
|
+
|
|
993
|
+
/*
|
|
994
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
995
|
+
Author Tobias Koppers @sokra
|
|
996
|
+
*/
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
class AsyncSeriesHookCodeFactory extends HookCodeFactory_1 {
|
|
1002
|
+
content({ onError, onDone }) {
|
|
1003
|
+
return this.callTapsSeries({
|
|
1004
|
+
onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true),
|
|
1005
|
+
onDone
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
const factory$3 = new AsyncSeriesHookCodeFactory();
|
|
1011
|
+
|
|
1012
|
+
const COMPILE$3 = function(options) {
|
|
1013
|
+
factory$3.setup(this, options);
|
|
1014
|
+
return factory$3.create(options);
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
function AsyncSeriesHook$1(args = [], name = undefined) {
|
|
1018
|
+
const hook = new Hook_1(args, name);
|
|
1019
|
+
hook.constructor = AsyncSeriesHook$1;
|
|
1020
|
+
hook.compile = COMPILE$3;
|
|
1021
|
+
hook._call = undefined;
|
|
1022
|
+
hook.call = undefined;
|
|
1023
|
+
return hook;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
AsyncSeriesHook$1.prototype = null;
|
|
1027
|
+
|
|
1028
|
+
var AsyncSeriesHook_1 = AsyncSeriesHook$1;
|
|
1029
|
+
|
|
1030
|
+
/*
|
|
1031
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
1032
|
+
Author Tobias Koppers @sokra
|
|
1033
|
+
*/
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
class AsyncSeriesBailHookCodeFactory extends HookCodeFactory_1 {
|
|
1039
|
+
content({ onError, onResult, resultReturns, onDone }) {
|
|
1040
|
+
return this.callTapsSeries({
|
|
1041
|
+
onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true),
|
|
1042
|
+
onResult: (i, result, next) =>
|
|
1043
|
+
`if(${result} !== undefined) {\n${onResult(
|
|
1044
|
+
result
|
|
1045
|
+
)}\n} else {\n${next()}}\n`,
|
|
1046
|
+
resultReturns,
|
|
1047
|
+
onDone
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
const factory$2 = new AsyncSeriesBailHookCodeFactory();
|
|
1053
|
+
|
|
1054
|
+
const COMPILE$2 = function(options) {
|
|
1055
|
+
factory$2.setup(this, options);
|
|
1056
|
+
return factory$2.create(options);
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
function AsyncSeriesBailHook$1(args = [], name = undefined) {
|
|
1060
|
+
const hook = new Hook_1(args, name);
|
|
1061
|
+
hook.constructor = AsyncSeriesBailHook$1;
|
|
1062
|
+
hook.compile = COMPILE$2;
|
|
1063
|
+
hook._call = undefined;
|
|
1064
|
+
hook.call = undefined;
|
|
1065
|
+
return hook;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
AsyncSeriesBailHook$1.prototype = null;
|
|
1069
|
+
|
|
1070
|
+
var AsyncSeriesBailHook_1 = AsyncSeriesBailHook$1;
|
|
1071
|
+
|
|
1072
|
+
/*
|
|
1073
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
1074
|
+
Author Tobias Koppers @sokra
|
|
1075
|
+
*/
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
class AsyncSeriesLoopHookCodeFactory extends HookCodeFactory_1 {
|
|
1081
|
+
content({ onError, onDone }) {
|
|
1082
|
+
return this.callTapsLooping({
|
|
1083
|
+
onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true),
|
|
1084
|
+
onDone
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
const factory$1 = new AsyncSeriesLoopHookCodeFactory();
|
|
1090
|
+
|
|
1091
|
+
const COMPILE$1 = function(options) {
|
|
1092
|
+
factory$1.setup(this, options);
|
|
1093
|
+
return factory$1.create(options);
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1096
|
+
function AsyncSeriesLoopHook$1(args = [], name = undefined) {
|
|
1097
|
+
const hook = new Hook_1(args, name);
|
|
1098
|
+
hook.constructor = AsyncSeriesLoopHook$1;
|
|
1099
|
+
hook.compile = COMPILE$1;
|
|
1100
|
+
hook._call = undefined;
|
|
1101
|
+
hook.call = undefined;
|
|
1102
|
+
return hook;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
AsyncSeriesLoopHook$1.prototype = null;
|
|
1106
|
+
|
|
1107
|
+
var AsyncSeriesLoopHook_1 = AsyncSeriesLoopHook$1;
|
|
1108
|
+
|
|
1109
|
+
/*
|
|
1110
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
1111
|
+
Author Tobias Koppers @sokra
|
|
1112
|
+
*/
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
class AsyncSeriesWaterfallHookCodeFactory extends HookCodeFactory_1 {
|
|
1118
|
+
content({ onError, onResult, onDone }) {
|
|
1119
|
+
return this.callTapsSeries({
|
|
1120
|
+
onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true),
|
|
1121
|
+
onResult: (i, result, next) => {
|
|
1122
|
+
let code = "";
|
|
1123
|
+
code += `if(${result} !== undefined) {\n`;
|
|
1124
|
+
code += `${this._args[0]} = ${result};\n`;
|
|
1125
|
+
code += `}\n`;
|
|
1126
|
+
code += next();
|
|
1127
|
+
return code;
|
|
1128
|
+
},
|
|
1129
|
+
onDone: () => onResult(this._args[0])
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
const factory = new AsyncSeriesWaterfallHookCodeFactory();
|
|
1135
|
+
|
|
1136
|
+
const COMPILE = function(options) {
|
|
1137
|
+
factory.setup(this, options);
|
|
1138
|
+
return factory.create(options);
|
|
1139
|
+
};
|
|
1140
|
+
|
|
1141
|
+
function AsyncSeriesWaterfallHook$1(args = [], name = undefined) {
|
|
1142
|
+
if (args.length < 1)
|
|
1143
|
+
throw new Error("Waterfall hooks must have at least one argument");
|
|
1144
|
+
const hook = new Hook_1(args, name);
|
|
1145
|
+
hook.constructor = AsyncSeriesWaterfallHook$1;
|
|
1146
|
+
hook.compile = COMPILE;
|
|
1147
|
+
hook._call = undefined;
|
|
1148
|
+
hook.call = undefined;
|
|
1149
|
+
return hook;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
AsyncSeriesWaterfallHook$1.prototype = null;
|
|
1153
|
+
|
|
1154
|
+
var AsyncSeriesWaterfallHook_1 = AsyncSeriesWaterfallHook$1;
|
|
1155
|
+
|
|
1156
|
+
/*
|
|
1157
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
1158
|
+
Author Tobias Koppers @sokra
|
|
1159
|
+
*/
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
const defaultFactory = (key, hook) => hook;
|
|
1164
|
+
|
|
1165
|
+
class HookMap$1 {
|
|
1166
|
+
constructor(factory, name = undefined) {
|
|
1167
|
+
this._map = new Map();
|
|
1168
|
+
this.name = name;
|
|
1169
|
+
this._factory = factory;
|
|
1170
|
+
this._interceptors = [];
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
get(key) {
|
|
1174
|
+
return this._map.get(key);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
for(key) {
|
|
1178
|
+
const hook = this.get(key);
|
|
1179
|
+
if (hook !== undefined) {
|
|
1180
|
+
return hook;
|
|
1181
|
+
}
|
|
1182
|
+
let newHook = this._factory(key);
|
|
1183
|
+
const interceptors = this._interceptors;
|
|
1184
|
+
for (let i = 0; i < interceptors.length; i++) {
|
|
1185
|
+
newHook = interceptors[i].factory(key, newHook);
|
|
1186
|
+
}
|
|
1187
|
+
this._map.set(key, newHook);
|
|
1188
|
+
return newHook;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
intercept(interceptor) {
|
|
1192
|
+
this._interceptors.push(
|
|
1193
|
+
Object.assign(
|
|
1194
|
+
{
|
|
1195
|
+
factory: defaultFactory
|
|
1196
|
+
},
|
|
1197
|
+
interceptor
|
|
1198
|
+
)
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
HookMap$1.prototype.tap = utilBrowser.deprecate(function(key, options, fn) {
|
|
1204
|
+
return this.for(key).tap(options, fn);
|
|
1205
|
+
}, "HookMap#tap(key,…) is deprecated. Use HookMap#for(key).tap(…) instead.");
|
|
1206
|
+
|
|
1207
|
+
HookMap$1.prototype.tapAsync = utilBrowser.deprecate(function(key, options, fn) {
|
|
1208
|
+
return this.for(key).tapAsync(options, fn);
|
|
1209
|
+
}, "HookMap#tapAsync(key,…) is deprecated. Use HookMap#for(key).tapAsync(…) instead.");
|
|
1210
|
+
|
|
1211
|
+
HookMap$1.prototype.tapPromise = utilBrowser.deprecate(function(key, options, fn) {
|
|
1212
|
+
return this.for(key).tapPromise(options, fn);
|
|
1213
|
+
}, "HookMap#tapPromise(key,…) is deprecated. Use HookMap#for(key).tapPromise(…) instead.");
|
|
1214
|
+
|
|
1215
|
+
var HookMap_1 = HookMap$1;
|
|
1216
|
+
|
|
1217
|
+
/*
|
|
1218
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
1219
|
+
Author Tobias Koppers @sokra
|
|
1220
|
+
*/
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
class MultiHook$1 {
|
|
1225
|
+
constructor(hooks, name = undefined) {
|
|
1226
|
+
this.hooks = hooks;
|
|
1227
|
+
this.name = name;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
tap(options, fn) {
|
|
1231
|
+
for (const hook of this.hooks) {
|
|
1232
|
+
hook.tap(options, fn);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
tapAsync(options, fn) {
|
|
1237
|
+
for (const hook of this.hooks) {
|
|
1238
|
+
hook.tapAsync(options, fn);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
tapPromise(options, fn) {
|
|
1243
|
+
for (const hook of this.hooks) {
|
|
1244
|
+
hook.tapPromise(options, fn);
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
isUsed() {
|
|
1249
|
+
for (const hook of this.hooks) {
|
|
1250
|
+
if (hook.isUsed()) return true;
|
|
1251
|
+
}
|
|
1252
|
+
return false;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
intercept(interceptor) {
|
|
1256
|
+
for (const hook of this.hooks) {
|
|
1257
|
+
hook.intercept(interceptor);
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
withOptions(options) {
|
|
1262
|
+
return new MultiHook$1(
|
|
1263
|
+
this.hooks.map(h => h.withOptions(options)),
|
|
1264
|
+
this.name
|
|
1265
|
+
);
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
var MultiHook_1 = MultiHook$1;
|
|
1270
|
+
|
|
1271
|
+
/*
|
|
1272
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
1273
|
+
Author Tobias Koppers @sokra
|
|
1274
|
+
*/
|
|
1275
|
+
|
|
1276
|
+
|
|
1277
|
+
var SyncHook = SyncHook_1;
|
|
1278
|
+
var SyncBailHook = SyncBailHook_1;
|
|
1279
|
+
var SyncWaterfallHook = SyncWaterfallHook_1;
|
|
1280
|
+
var SyncLoopHook = SyncLoopHook_1;
|
|
1281
|
+
var AsyncParallelHook = AsyncParallelHook_1;
|
|
1282
|
+
var AsyncParallelBailHook = AsyncParallelBailHook_1;
|
|
1283
|
+
var AsyncSeriesHook = AsyncSeriesHook_1;
|
|
1284
|
+
var AsyncSeriesBailHook = AsyncSeriesBailHook_1;
|
|
1285
|
+
var AsyncSeriesLoopHook = AsyncSeriesLoopHook_1;
|
|
1286
|
+
var AsyncSeriesWaterfallHook = AsyncSeriesWaterfallHook_1;
|
|
1287
|
+
var HookMap = HookMap_1;
|
|
1288
|
+
var MultiHook = MultiHook_1;
|
|
1289
|
+
|
|
1290
|
+
var lib = /*#__PURE__*/Object.defineProperty({
|
|
1291
|
+
SyncHook: SyncHook,
|
|
1292
|
+
SyncBailHook: SyncBailHook,
|
|
1293
|
+
SyncWaterfallHook: SyncWaterfallHook,
|
|
1294
|
+
SyncLoopHook: SyncLoopHook,
|
|
1295
|
+
AsyncParallelHook: AsyncParallelHook,
|
|
1296
|
+
AsyncParallelBailHook: AsyncParallelBailHook,
|
|
1297
|
+
AsyncSeriesHook: AsyncSeriesHook,
|
|
1298
|
+
AsyncSeriesBailHook: AsyncSeriesBailHook,
|
|
1299
|
+
AsyncSeriesLoopHook: AsyncSeriesLoopHook,
|
|
1300
|
+
AsyncSeriesWaterfallHook: AsyncSeriesWaterfallHook,
|
|
1301
|
+
HookMap: HookMap,
|
|
1302
|
+
MultiHook: MultiHook
|
|
1303
|
+
}, '__esModule', {value: true});
|
|
1304
|
+
|
|
1305
|
+
exports.AsyncParallelBailHook = AsyncParallelBailHook;
|
|
1306
|
+
exports.AsyncParallelHook = AsyncParallelHook;
|
|
1307
|
+
exports.AsyncSeriesBailHook = AsyncSeriesBailHook;
|
|
1308
|
+
exports.AsyncSeriesHook = AsyncSeriesHook;
|
|
1309
|
+
exports.AsyncSeriesLoopHook = AsyncSeriesLoopHook;
|
|
1310
|
+
exports.AsyncSeriesWaterfallHook = AsyncSeriesWaterfallHook;
|
|
1311
|
+
exports.HookMap = HookMap;
|
|
1312
|
+
exports.MultiHook = MultiHook;
|
|
1313
|
+
exports.SyncBailHook = SyncBailHook;
|
|
1314
|
+
exports.SyncHook = SyncHook;
|
|
1315
|
+
exports.SyncLoopHook = SyncLoopHook;
|
|
1316
|
+
exports.SyncWaterfallHook = SyncWaterfallHook;
|
|
1317
|
+
exports.__moduleExports = lib;
|
|
1318
|
+
|
|
1319
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1320
|
+
|
|
1321
|
+
})));
|