@antv/g-lite 1.0.52 → 1.0.53
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.esm.js +196 -985
- package/dist/index.js +197 -986
- package/dist/index.umd.js +202 -986
- package/dist/index.umd.min.js +1 -1
- package/dist/services/RenderingService.d.ts +17 -17
- package/dist/services/RenderingService.d.ts.map +1 -1
- package/dist/utils/tapable/AsyncParallelHook.d.ts +4 -4
- package/dist/utils/tapable/AsyncParallelHook.d.ts.map +1 -1
- package/dist/utils/tapable/AsyncSeriesWaterfallHook.d.ts +5 -4
- package/dist/utils/tapable/AsyncSeriesWaterfallHook.d.ts.map +1 -1
- package/dist/utils/tapable/Hook.d.ts +0 -50
- package/dist/utils/tapable/Hook.d.ts.map +1 -1
- package/dist/utils/tapable/SyncHook.d.ts +5 -4
- package/dist/utils/tapable/SyncHook.d.ts.map +1 -1
- package/dist/utils/tapable/SyncWaterfallHook.d.ts +5 -4
- package/dist/utils/tapable/SyncWaterfallHook.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/utils/tapable/HookCodeFactory.d.ts +0 -47
- package/dist/utils/tapable/HookCodeFactory.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -3242,916 +3242,145 @@ function isFillOrStrokeAffected(pointerEvents, fill, stroke) {
|
|
|
3242
3242
|
return [hasFill, hasStroke];
|
|
3243
3243
|
}
|
|
3244
3244
|
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
// tap?: (tap: FullTap & IfSet<AdditionalOptions>) => void;
|
|
3249
|
-
// call?: (...args: any[]) => void;
|
|
3250
|
-
// loop?: (...args: any[]) => void;
|
|
3251
|
-
// error?: (err: Error) => void;
|
|
3252
|
-
// result?: (result: R) => void;
|
|
3253
|
-
// done?: () => void;
|
|
3254
|
-
// register?: (tap: FullTap & IfSet<AdditionalOptions>) => FullTap & IfSet<AdditionalOptions>;
|
|
3255
|
-
// }
|
|
3256
|
-
// type ArgumentNames<T extends any[]> = FixedSizeArray<T['length'], string>;
|
|
3257
|
-
// export declare class AsyncHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<
|
|
3258
|
-
// T,
|
|
3259
|
-
// R,
|
|
3260
|
-
// AdditionalOptions
|
|
3261
|
-
// > {
|
|
3262
|
-
// tapAsync(
|
|
3263
|
-
// options: string | (Tap & IfSet<AdditionalOptions>),
|
|
3264
|
-
// fn: (...args: Append<AsArray<T>, InnerCallback<Error, R>>) => void,
|
|
3265
|
-
// ): void;
|
|
3266
|
-
// tapPromise(
|
|
3267
|
-
// options: string | (Tap & IfSet<AdditionalOptions>),
|
|
3268
|
-
// fn: (...args: AsArray<T>) => Promise<R>,
|
|
3269
|
-
// ): void;
|
|
3270
|
-
// }
|
|
3271
|
-
var CALL_DELEGATE = function CALL_DELEGATE() {
|
|
3272
|
-
this.call = this._createCall('sync');
|
|
3273
|
-
return this.call.apply(this, arguments);
|
|
3274
|
-
};
|
|
3275
|
-
var CALL_ASYNC_DELEGATE = function CALL_ASYNC_DELEGATE() {
|
|
3276
|
-
this.callAsync = this._createCall('async');
|
|
3277
|
-
return this.callAsync.apply(this, arguments);
|
|
3278
|
-
};
|
|
3279
|
-
var PROMISE_DELEGATE = function PROMISE_DELEGATE() {
|
|
3280
|
-
this.promise = this._createCall('promise');
|
|
3281
|
-
return this.promise.apply(this, arguments);
|
|
3282
|
-
};
|
|
3283
|
-
var Hook = /*#__PURE__*/function () {
|
|
3284
|
-
function Hook(args, name) {
|
|
3285
|
-
if (args === void 0) {
|
|
3286
|
-
args = [];
|
|
3287
|
-
}
|
|
3288
|
-
if (name === void 0) {
|
|
3289
|
-
name = undefined;
|
|
3290
|
-
}
|
|
3291
|
-
this.name = void 0;
|
|
3292
|
-
this.taps = void 0;
|
|
3293
|
-
this.promise = void 0;
|
|
3294
|
-
this._promise = void 0;
|
|
3295
|
-
this._args = args;
|
|
3296
|
-
this.name = name;
|
|
3297
|
-
this.taps = [];
|
|
3298
|
-
this.interceptors = [];
|
|
3299
|
-
this._call = CALL_DELEGATE;
|
|
3300
|
-
this.call = CALL_DELEGATE;
|
|
3301
|
-
this._callAsync = CALL_ASYNC_DELEGATE;
|
|
3302
|
-
this.callAsync = CALL_ASYNC_DELEGATE;
|
|
3303
|
-
this._promise = PROMISE_DELEGATE;
|
|
3304
|
-
this.promise = PROMISE_DELEGATE;
|
|
3305
|
-
this._x = undefined;
|
|
3306
|
-
// this.compile = this.compile;
|
|
3307
|
-
// this.tap = this.tap;
|
|
3308
|
-
// this.tapAsync = this.tapAsync;
|
|
3309
|
-
// this.tapPromise = this.tapPromise;
|
|
3310
|
-
}
|
|
3311
|
-
var _proto = Hook.prototype;
|
|
3312
|
-
_proto.compile = function compile(options) {
|
|
3313
|
-
throw new Error('Abstract: should be overridden');
|
|
3314
|
-
};
|
|
3315
|
-
_proto._createCall = function _createCall(type) {
|
|
3316
|
-
return this.compile({
|
|
3317
|
-
taps: this.taps,
|
|
3318
|
-
interceptors: this.interceptors,
|
|
3319
|
-
args: this._args,
|
|
3320
|
-
type: type
|
|
3321
|
-
});
|
|
3322
|
-
};
|
|
3323
|
-
_proto._tap = function _tap(type, options, fn) {
|
|
3324
|
-
if (typeof options === 'string') {
|
|
3325
|
-
options = {
|
|
3326
|
-
name: options.trim()
|
|
3327
|
-
};
|
|
3328
|
-
} else if (typeof options !== 'object' || options === null) {
|
|
3329
|
-
throw new Error('Invalid tap options');
|
|
3330
|
-
}
|
|
3331
|
-
if (typeof options.name !== 'string' || options.name === '') {
|
|
3332
|
-
throw new Error('Missing name for tap');
|
|
3333
|
-
}
|
|
3334
|
-
// if (typeof options.context !== "undefined") {
|
|
3335
|
-
// deprecateContext();
|
|
3336
|
-
// }
|
|
3337
|
-
options = Object.assign({
|
|
3338
|
-
type: type,
|
|
3339
|
-
fn: fn
|
|
3340
|
-
}, options);
|
|
3341
|
-
options = this._runRegisterInterceptors(options);
|
|
3342
|
-
this._insert(options);
|
|
3343
|
-
};
|
|
3344
|
-
_proto.tap = function tap(options, fn) {
|
|
3345
|
-
this._tap('sync', options, fn);
|
|
3346
|
-
};
|
|
3347
|
-
_proto.tapAsync = function tapAsync(options, fn) {
|
|
3348
|
-
this._tap('async', options, fn);
|
|
3349
|
-
};
|
|
3350
|
-
_proto.tapPromise = function tapPromise(options, fn) {
|
|
3351
|
-
this._tap('promise', options, fn);
|
|
3352
|
-
};
|
|
3353
|
-
_proto._runRegisterInterceptors = function _runRegisterInterceptors(options) {
|
|
3354
|
-
for (var _iterator = _createForOfIteratorHelperLoose(this.interceptors), _step; !(_step = _iterator()).done;) {
|
|
3355
|
-
var interceptor = _step.value;
|
|
3356
|
-
if (interceptor.register) {
|
|
3357
|
-
var newOptions = interceptor.register(options);
|
|
3358
|
-
if (newOptions !== undefined) {
|
|
3359
|
-
options = newOptions;
|
|
3360
|
-
}
|
|
3361
|
-
}
|
|
3362
|
-
}
|
|
3363
|
-
return options;
|
|
3364
|
-
};
|
|
3365
|
-
_proto.withOptions = function withOptions(options) {
|
|
3366
|
-
var _this = this;
|
|
3367
|
-
var mergeOptions = function mergeOptions(opt) {
|
|
3368
|
-
return Object.assign({}, options, typeof opt === 'string' ? {
|
|
3369
|
-
name: opt
|
|
3370
|
-
} : opt);
|
|
3371
|
-
};
|
|
3372
|
-
return {
|
|
3373
|
-
name: this.name,
|
|
3374
|
-
tap: function tap(opt, fn) {
|
|
3375
|
-
return _this.tap(mergeOptions(opt), fn);
|
|
3376
|
-
},
|
|
3377
|
-
tapAsync: function tapAsync(opt, fn) {
|
|
3378
|
-
return _this.tapAsync(mergeOptions(opt), fn);
|
|
3379
|
-
},
|
|
3380
|
-
tapPromise: function tapPromise(opt, fn) {
|
|
3381
|
-
return _this.tapPromise(mergeOptions(opt), fn);
|
|
3382
|
-
},
|
|
3383
|
-
// intercept: (interceptor) => this.intercept(interceptor),
|
|
3384
|
-
isUsed: function isUsed() {
|
|
3385
|
-
return _this.isUsed();
|
|
3386
|
-
},
|
|
3387
|
-
withOptions: function withOptions(opt) {
|
|
3388
|
-
return _this.withOptions(mergeOptions(opt));
|
|
3389
|
-
}
|
|
3390
|
-
};
|
|
3391
|
-
};
|
|
3392
|
-
_proto.isUsed = function isUsed() {
|
|
3393
|
-
return this.taps.length > 0 || this.interceptors.length > 0;
|
|
3245
|
+
var AsyncParallelHook = /*#__PURE__*/function () {
|
|
3246
|
+
function AsyncParallelHook() {
|
|
3247
|
+
this.callbacks = [];
|
|
3394
3248
|
}
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
var stage = 0;
|
|
3419
|
-
if (typeof item.stage === 'number') {
|
|
3420
|
-
stage = item.stage;
|
|
3421
|
-
}
|
|
3422
|
-
var i = this.taps.length;
|
|
3423
|
-
while (i > 0) {
|
|
3424
|
-
i--;
|
|
3425
|
-
var x = this.taps[i];
|
|
3426
|
-
this.taps[i + 1] = x;
|
|
3427
|
-
var xStage = x.stage || 0;
|
|
3428
|
-
if (before) {
|
|
3429
|
-
if (before.has(x.name)) {
|
|
3430
|
-
before.delete(x.name);
|
|
3431
|
-
continue;
|
|
3432
|
-
}
|
|
3433
|
-
if (before.size > 0) {
|
|
3434
|
-
continue;
|
|
3249
|
+
var _proto = AsyncParallelHook.prototype;
|
|
3250
|
+
_proto.tapPromise = function tapPromise(options, fn) {
|
|
3251
|
+
this.callbacks.push(fn);
|
|
3252
|
+
};
|
|
3253
|
+
_proto.promise = /*#__PURE__*/function () {
|
|
3254
|
+
var _promise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
3255
|
+
var _len,
|
|
3256
|
+
args,
|
|
3257
|
+
_key,
|
|
3258
|
+
_args = arguments;
|
|
3259
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3260
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3261
|
+
case 0:
|
|
3262
|
+
for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3263
|
+
args[_key] = _args[_key];
|
|
3264
|
+
}
|
|
3265
|
+
_context.next = 3;
|
|
3266
|
+
return Promise.all(this.callbacks.map(function (callback) {
|
|
3267
|
+
return callback.apply(void 0, args);
|
|
3268
|
+
}));
|
|
3269
|
+
case 3:
|
|
3270
|
+
case "end":
|
|
3271
|
+
return _context.stop();
|
|
3435
3272
|
}
|
|
3436
|
-
}
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
i++;
|
|
3441
|
-
break;
|
|
3273
|
+
}, _callee, this);
|
|
3274
|
+
}));
|
|
3275
|
+
function promise() {
|
|
3276
|
+
return _promise.apply(this, arguments);
|
|
3442
3277
|
}
|
|
3443
|
-
|
|
3444
|
-
};
|
|
3445
|
-
return
|
|
3278
|
+
return promise;
|
|
3279
|
+
}();
|
|
3280
|
+
return AsyncParallelHook;
|
|
3446
3281
|
}();
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
function HookCodeFactory(config) {
|
|
3452
|
-
this.config = config;
|
|
3453
|
-
this.options = undefined;
|
|
3454
|
-
this._args = undefined;
|
|
3455
|
-
}
|
|
3456
|
-
var _proto = HookCodeFactory.prototype;
|
|
3457
|
-
_proto.create = function create(options) {
|
|
3458
|
-
this.init(options);
|
|
3459
|
-
var fn;
|
|
3460
|
-
switch (this.options.type) {
|
|
3461
|
-
case 'sync':
|
|
3462
|
-
fn = new Function(this.args(), '"use strict";\n' + this.header() + this.contentWithInterceptors({
|
|
3463
|
-
onError: function onError(err) {
|
|
3464
|
-
return "throw " + err + ";\n";
|
|
3465
|
-
},
|
|
3466
|
-
onResult: function onResult(result) {
|
|
3467
|
-
return "return " + result + ";\n";
|
|
3468
|
-
},
|
|
3469
|
-
resultReturns: true,
|
|
3470
|
-
onDone: function onDone() {
|
|
3471
|
-
return '';
|
|
3472
|
-
},
|
|
3473
|
-
rethrowIfPossible: true
|
|
3474
|
-
}));
|
|
3475
|
-
break;
|
|
3476
|
-
case 'async':
|
|
3477
|
-
fn = new Function(this.args({
|
|
3478
|
-
after: '_callback'
|
|
3479
|
-
}), '"use strict";\n' + this.header() + this.contentWithInterceptors({
|
|
3480
|
-
onError: function onError(err) {
|
|
3481
|
-
return "_callback(" + err + ");\n";
|
|
3482
|
-
},
|
|
3483
|
-
onResult: function onResult(result) {
|
|
3484
|
-
return "_callback(null, " + result + ");\n";
|
|
3485
|
-
},
|
|
3486
|
-
onDone: function onDone() {
|
|
3487
|
-
return '_callback();\n';
|
|
3488
|
-
}
|
|
3489
|
-
}));
|
|
3490
|
-
break;
|
|
3491
|
-
case 'promise':
|
|
3492
|
-
var errorHelperUsed = false;
|
|
3493
|
-
var content = this.contentWithInterceptors({
|
|
3494
|
-
onError: function onError(err) {
|
|
3495
|
-
errorHelperUsed = true;
|
|
3496
|
-
return "_error(" + err + ");\n";
|
|
3497
|
-
},
|
|
3498
|
-
onResult: function onResult(result) {
|
|
3499
|
-
return "_resolve(" + result + ");\n";
|
|
3500
|
-
},
|
|
3501
|
-
onDone: function onDone() {
|
|
3502
|
-
return '_resolve();\n';
|
|
3503
|
-
}
|
|
3504
|
-
});
|
|
3505
|
-
var code = '';
|
|
3506
|
-
code += '"use strict";\n';
|
|
3507
|
-
code += this.header();
|
|
3508
|
-
code += 'return new Promise((function(_resolve, _reject) {\n';
|
|
3509
|
-
if (errorHelperUsed) {
|
|
3510
|
-
code += 'var _sync = true;\n';
|
|
3511
|
-
code += 'function _error(_err) {\n';
|
|
3512
|
-
code += 'if(_sync)\n';
|
|
3513
|
-
code += '_resolve(Promise.resolve().then((function() { throw _err; })));\n';
|
|
3514
|
-
code += 'else\n';
|
|
3515
|
-
code += '_reject(_err);\n';
|
|
3516
|
-
code += '};\n';
|
|
3517
|
-
}
|
|
3518
|
-
code += content;
|
|
3519
|
-
if (errorHelperUsed) {
|
|
3520
|
-
code += '_sync = false;\n';
|
|
3521
|
-
}
|
|
3522
|
-
code += '}));\n';
|
|
3523
|
-
fn = new Function(this.args(), code);
|
|
3524
|
-
break;
|
|
3525
|
-
}
|
|
3526
|
-
this.deinit();
|
|
3527
|
-
return fn;
|
|
3528
|
-
};
|
|
3529
|
-
_proto.setup = function setup(instance, options) {
|
|
3530
|
-
instance._x = options.taps.map(function (t) {
|
|
3531
|
-
return t.fn;
|
|
3532
|
-
});
|
|
3282
|
+
|
|
3283
|
+
var AsyncSeriesWaterfallHook = /*#__PURE__*/function () {
|
|
3284
|
+
function AsyncSeriesWaterfallHook() {
|
|
3285
|
+
this.callbacks = [];
|
|
3533
3286
|
}
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
var code = '';
|
|
3552
|
-
for (var i = 0; i < this.options.interceptors.length; i++) {
|
|
3553
|
-
var interceptor = this.options.interceptors[i];
|
|
3554
|
-
if (interceptor.call) {
|
|
3555
|
-
code += this.getInterceptor(i) + ".call(" + this.args({
|
|
3556
|
-
before: interceptor.context ? '_context' : undefined
|
|
3557
|
-
}) + ");\n";
|
|
3558
|
-
}
|
|
3559
|
-
}
|
|
3560
|
-
code += this.content(Object.assign(options, {
|
|
3561
|
-
onError: onError && function (err) {
|
|
3562
|
-
var code = '';
|
|
3563
|
-
for (var _i = 0; _i < _this.options.interceptors.length; _i++) {
|
|
3564
|
-
var _interceptor = _this.options.interceptors[_i];
|
|
3565
|
-
if (_interceptor.error) {
|
|
3566
|
-
code += _this.getInterceptor(_i) + ".error(" + err + ");\n";
|
|
3567
|
-
}
|
|
3568
|
-
}
|
|
3569
|
-
code += onError(err);
|
|
3570
|
-
return code;
|
|
3571
|
-
},
|
|
3572
|
-
onResult: onResult && function (result) {
|
|
3573
|
-
var code = '';
|
|
3574
|
-
for (var _i2 = 0; _i2 < _this.options.interceptors.length; _i2++) {
|
|
3575
|
-
var _interceptor2 = _this.options.interceptors[_i2];
|
|
3576
|
-
if (_interceptor2.result) {
|
|
3577
|
-
code += _this.getInterceptor(_i2) + ".result(" + result + ");\n";
|
|
3287
|
+
var _proto = AsyncSeriesWaterfallHook.prototype;
|
|
3288
|
+
_proto.tapPromise = function tapPromise(options, fn) {
|
|
3289
|
+
this.callbacks.push(fn);
|
|
3290
|
+
};
|
|
3291
|
+
_proto.promise = /*#__PURE__*/function () {
|
|
3292
|
+
var _promise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
3293
|
+
var _this$callbacks,
|
|
3294
|
+
result,
|
|
3295
|
+
i,
|
|
3296
|
+
callback,
|
|
3297
|
+
_args = arguments;
|
|
3298
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3299
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3300
|
+
case 0:
|
|
3301
|
+
if (!this.callbacks.length) {
|
|
3302
|
+
_context.next = 14;
|
|
3303
|
+
break;
|
|
3578
3304
|
}
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
code += _this.getInterceptor(_i3) + ".done();\n";
|
|
3305
|
+
_context.next = 3;
|
|
3306
|
+
return (_this$callbacks = this.callbacks)[0].apply(_this$callbacks, _args);
|
|
3307
|
+
case 3:
|
|
3308
|
+
result = _context.sent;
|
|
3309
|
+
i = 0;
|
|
3310
|
+
case 5:
|
|
3311
|
+
if (!(i < this.callbacks.length - 1)) {
|
|
3312
|
+
_context.next = 13;
|
|
3313
|
+
break;
|
|
3589
3314
|
}
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
}
|
|
3607
|
-
code += 'var _x = this._x;\n';
|
|
3608
|
-
if (this.options.interceptors.length > 0) {
|
|
3609
|
-
code += 'var _taps = this.taps;\n';
|
|
3610
|
-
code += 'var _interceptors = this.interceptors;\n';
|
|
3611
|
-
}
|
|
3612
|
-
return code;
|
|
3613
|
-
};
|
|
3614
|
-
_proto.needContext = function needContext() {
|
|
3615
|
-
for (var _iterator = _createForOfIteratorHelperLoose(this.options.taps), _step; !(_step = _iterator()).done;) {
|
|
3616
|
-
var tap = _step.value;
|
|
3617
|
-
if (tap.context) return true;
|
|
3618
|
-
}
|
|
3619
|
-
return false;
|
|
3620
|
-
};
|
|
3621
|
-
_proto.callTap = function callTap(tapIndex, _ref) {
|
|
3622
|
-
var onError = _ref.onError,
|
|
3623
|
-
onResult = _ref.onResult,
|
|
3624
|
-
onDone = _ref.onDone,
|
|
3625
|
-
rethrowIfPossible = _ref.rethrowIfPossible;
|
|
3626
|
-
var code = '';
|
|
3627
|
-
var hasTapCached = false;
|
|
3628
|
-
for (var i = 0; i < this.options.interceptors.length; i++) {
|
|
3629
|
-
var interceptor = this.options.interceptors[i];
|
|
3630
|
-
if (interceptor.tap) {
|
|
3631
|
-
if (!hasTapCached) {
|
|
3632
|
-
code += "var _tap" + tapIndex + " = " + this.getTap(tapIndex) + ";\n";
|
|
3633
|
-
hasTapCached = true;
|
|
3634
|
-
}
|
|
3635
|
-
code += this.getInterceptor(i) + ".tap(" + (interceptor.context ? '_context, ' : '') + "_tap" + tapIndex + ");\n";
|
|
3636
|
-
}
|
|
3637
|
-
}
|
|
3638
|
-
code += "var _fn" + tapIndex + " = " + this.getTapFn(tapIndex) + ";\n";
|
|
3639
|
-
var tap = this.options.taps[tapIndex];
|
|
3640
|
-
switch (tap.type) {
|
|
3641
|
-
case 'sync':
|
|
3642
|
-
if (!rethrowIfPossible) {
|
|
3643
|
-
code += "var _hasError" + tapIndex + " = false;\n";
|
|
3644
|
-
code += 'try {\n';
|
|
3645
|
-
}
|
|
3646
|
-
if (onResult) {
|
|
3647
|
-
code += "var _result" + tapIndex + " = _fn" + tapIndex + "(" + this.args({
|
|
3648
|
-
before: tap.context ? '_context' : undefined
|
|
3649
|
-
}) + ");\n";
|
|
3650
|
-
} else {
|
|
3651
|
-
code += "_fn" + tapIndex + "(" + this.args({
|
|
3652
|
-
before: tap.context ? '_context' : undefined
|
|
3653
|
-
}) + ");\n";
|
|
3654
|
-
}
|
|
3655
|
-
if (!rethrowIfPossible) {
|
|
3656
|
-
code += '} catch(_err) {\n';
|
|
3657
|
-
code += "_hasError" + tapIndex + " = true;\n";
|
|
3658
|
-
code += onError('_err');
|
|
3659
|
-
code += '}\n';
|
|
3660
|
-
code += "if(!_hasError" + tapIndex + ") {\n";
|
|
3661
|
-
}
|
|
3662
|
-
if (onResult) {
|
|
3663
|
-
code += onResult("_result" + tapIndex);
|
|
3664
|
-
}
|
|
3665
|
-
if (onDone) {
|
|
3666
|
-
code += onDone();
|
|
3667
|
-
}
|
|
3668
|
-
if (!rethrowIfPossible) {
|
|
3669
|
-
code += '}\n';
|
|
3670
|
-
}
|
|
3671
|
-
break;
|
|
3672
|
-
case 'async':
|
|
3673
|
-
var cbCode = '';
|
|
3674
|
-
if (onResult) cbCode += "(function(_err" + tapIndex + ", _result" + tapIndex + ") {\n";else cbCode += "(function(_err" + tapIndex + ") {\n";
|
|
3675
|
-
cbCode += "if(_err" + tapIndex + ") {\n";
|
|
3676
|
-
cbCode += onError("_err" + tapIndex);
|
|
3677
|
-
cbCode += '} else {\n';
|
|
3678
|
-
if (onResult) {
|
|
3679
|
-
cbCode += onResult("_result" + tapIndex);
|
|
3680
|
-
}
|
|
3681
|
-
if (onDone) {
|
|
3682
|
-
cbCode += onDone();
|
|
3683
|
-
}
|
|
3684
|
-
cbCode += '}\n';
|
|
3685
|
-
cbCode += '})';
|
|
3686
|
-
code += "_fn" + tapIndex + "(" + this.args({
|
|
3687
|
-
before: tap.context ? '_context' : undefined,
|
|
3688
|
-
after: cbCode
|
|
3689
|
-
}) + ");\n";
|
|
3690
|
-
break;
|
|
3691
|
-
case 'promise':
|
|
3692
|
-
code += "var _hasResult" + tapIndex + " = false;\n";
|
|
3693
|
-
code += "var _promise" + tapIndex + " = _fn" + tapIndex + "(" + this.args({
|
|
3694
|
-
before: tap.context ? '_context' : undefined
|
|
3695
|
-
}) + ");\n";
|
|
3696
|
-
code += "if (!_promise" + tapIndex + " || !_promise" + tapIndex + ".then)\n";
|
|
3697
|
-
code += " throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise" + tapIndex + " + ')');\n";
|
|
3698
|
-
code += "_promise" + tapIndex + ".then((function(_result" + tapIndex + ") {\n";
|
|
3699
|
-
code += "_hasResult" + tapIndex + " = true;\n";
|
|
3700
|
-
if (onResult) {
|
|
3701
|
-
code += onResult("_result" + tapIndex);
|
|
3702
|
-
}
|
|
3703
|
-
if (onDone) {
|
|
3704
|
-
code += onDone();
|
|
3315
|
+
callback = this.callbacks[i]; // @ts-ignore
|
|
3316
|
+
_context.next = 9;
|
|
3317
|
+
return callback(result);
|
|
3318
|
+
case 9:
|
|
3319
|
+
result = _context.sent;
|
|
3320
|
+
case 10:
|
|
3321
|
+
i++;
|
|
3322
|
+
_context.next = 5;
|
|
3323
|
+
break;
|
|
3324
|
+
case 13:
|
|
3325
|
+
return _context.abrupt("return", result);
|
|
3326
|
+
case 14:
|
|
3327
|
+
return _context.abrupt("return", null);
|
|
3328
|
+
case 15:
|
|
3329
|
+
case "end":
|
|
3330
|
+
return _context.stop();
|
|
3705
3331
|
}
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
break;
|
|
3711
|
-
}
|
|
3712
|
-
return code;
|
|
3713
|
-
};
|
|
3714
|
-
_proto.callTapsSeries = function callTapsSeries(_ref2) {
|
|
3715
|
-
var _this2 = this;
|
|
3716
|
-
var _onError = _ref2.onError,
|
|
3717
|
-
onResult = _ref2.onResult,
|
|
3718
|
-
resultReturns = _ref2.resultReturns,
|
|
3719
|
-
onDone = _ref2.onDone,
|
|
3720
|
-
doneReturns = _ref2.doneReturns,
|
|
3721
|
-
rethrowIfPossible = _ref2.rethrowIfPossible;
|
|
3722
|
-
if (this.options.taps.length === 0) return onDone();
|
|
3723
|
-
var firstAsync = this.options.taps.findIndex(function (t) {
|
|
3724
|
-
return t.type !== 'sync';
|
|
3725
|
-
});
|
|
3726
|
-
var somethingReturns = resultReturns || doneReturns;
|
|
3727
|
-
var code = '';
|
|
3728
|
-
var current = onDone;
|
|
3729
|
-
var unrollCounter = 0;
|
|
3730
|
-
var _loop = function _loop() {
|
|
3731
|
-
var i = j;
|
|
3732
|
-
var unroll = current !== onDone && (_this2.options.taps[i].type !== 'sync' || unrollCounter++ > 20);
|
|
3733
|
-
if (unroll) {
|
|
3734
|
-
unrollCounter = 0;
|
|
3735
|
-
code += "function _next" + i + "() {\n";
|
|
3736
|
-
code += current();
|
|
3737
|
-
code += "}\n";
|
|
3738
|
-
current = function current() {
|
|
3739
|
-
return (somethingReturns ? 'return ' : '') + "_next" + i + "();\n";
|
|
3740
|
-
};
|
|
3741
|
-
}
|
|
3742
|
-
var done = current;
|
|
3743
|
-
var doneBreak = function doneBreak(skipDone) {
|
|
3744
|
-
if (skipDone) return '';
|
|
3745
|
-
return onDone();
|
|
3746
|
-
};
|
|
3747
|
-
var content = _this2.callTap(i, {
|
|
3748
|
-
onError: function onError(error) {
|
|
3749
|
-
return _onError(i, error, done, doneBreak);
|
|
3750
|
-
},
|
|
3751
|
-
onResult: onResult && function (result) {
|
|
3752
|
-
return onResult(i, result, done, doneBreak);
|
|
3753
|
-
},
|
|
3754
|
-
onDone: !onResult && done,
|
|
3755
|
-
rethrowIfPossible: rethrowIfPossible && (firstAsync < 0 || i < firstAsync)
|
|
3756
|
-
});
|
|
3757
|
-
current = function current() {
|
|
3758
|
-
return content;
|
|
3759
|
-
};
|
|
3760
|
-
};
|
|
3761
|
-
for (var j = this.options.taps.length - 1; j >= 0; j--) {
|
|
3762
|
-
_loop();
|
|
3763
|
-
}
|
|
3764
|
-
code += current();
|
|
3765
|
-
return code;
|
|
3766
|
-
};
|
|
3767
|
-
_proto.callTapsLooping = function callTapsLooping(_ref3) {
|
|
3768
|
-
var onError = _ref3.onError,
|
|
3769
|
-
onDone = _ref3.onDone,
|
|
3770
|
-
rethrowIfPossible = _ref3.rethrowIfPossible;
|
|
3771
|
-
if (this.options.taps.length === 0) return onDone();
|
|
3772
|
-
var syncOnly = this.options.taps.every(function (t) {
|
|
3773
|
-
return t.type === 'sync';
|
|
3774
|
-
});
|
|
3775
|
-
var code = '';
|
|
3776
|
-
if (!syncOnly) {
|
|
3777
|
-
code += 'var _looper = (function() {\n';
|
|
3778
|
-
code += 'var _loopAsync = false;\n';
|
|
3779
|
-
}
|
|
3780
|
-
code += 'var _loop;\n';
|
|
3781
|
-
code += 'do {\n';
|
|
3782
|
-
code += '_loop = false;\n';
|
|
3783
|
-
for (var i = 0; i < this.options.interceptors.length; i++) {
|
|
3784
|
-
var interceptor = this.options.interceptors[i];
|
|
3785
|
-
if (interceptor.loop) {
|
|
3786
|
-
code += this.getInterceptor(i) + ".loop(" + this.args({
|
|
3787
|
-
before: interceptor.context ? '_context' : undefined
|
|
3788
|
-
}) + ");\n";
|
|
3789
|
-
}
|
|
3790
|
-
}
|
|
3791
|
-
code += this.callTapsSeries({
|
|
3792
|
-
onError: onError,
|
|
3793
|
-
onResult: function onResult(i, result, next, doneBreak) {
|
|
3794
|
-
var code = '';
|
|
3795
|
-
code += "if(" + result + " !== undefined) {\n";
|
|
3796
|
-
code += '_loop = true;\n';
|
|
3797
|
-
if (!syncOnly) code += 'if(_loopAsync) _looper();\n';
|
|
3798
|
-
code += doneBreak(true);
|
|
3799
|
-
code += "} else {\n";
|
|
3800
|
-
code += next();
|
|
3801
|
-
code += "}\n";
|
|
3802
|
-
return code;
|
|
3803
|
-
},
|
|
3804
|
-
onDone: onDone && function () {
|
|
3805
|
-
var code = '';
|
|
3806
|
-
code += 'if(!_loop) {\n';
|
|
3807
|
-
code += onDone();
|
|
3808
|
-
code += '}\n';
|
|
3809
|
-
return code;
|
|
3810
|
-
},
|
|
3811
|
-
rethrowIfPossible: rethrowIfPossible && syncOnly
|
|
3812
|
-
});
|
|
3813
|
-
code += '} while(_loop);\n';
|
|
3814
|
-
if (!syncOnly) {
|
|
3815
|
-
code += '_loopAsync = true;\n';
|
|
3816
|
-
code += '});\n';
|
|
3817
|
-
code += '_looper();\n';
|
|
3818
|
-
}
|
|
3819
|
-
return code;
|
|
3820
|
-
};
|
|
3821
|
-
_proto.callTapsParallel = function callTapsParallel(_ref4) {
|
|
3822
|
-
var _this3 = this;
|
|
3823
|
-
var _onError2 = _ref4.onError,
|
|
3824
|
-
onResult = _ref4.onResult,
|
|
3825
|
-
onDone = _ref4.onDone,
|
|
3826
|
-
rethrowIfPossible = _ref4.rethrowIfPossible,
|
|
3827
|
-
_ref4$onTap = _ref4.onTap,
|
|
3828
|
-
onTap = _ref4$onTap === void 0 ? function (i, run) {
|
|
3829
|
-
return run();
|
|
3830
|
-
} : _ref4$onTap;
|
|
3831
|
-
if (this.options.taps.length <= 1) {
|
|
3832
|
-
return this.callTapsSeries({
|
|
3833
|
-
onError: _onError2,
|
|
3834
|
-
onResult: onResult,
|
|
3835
|
-
onDone: onDone,
|
|
3836
|
-
rethrowIfPossible: rethrowIfPossible
|
|
3837
|
-
});
|
|
3838
|
-
}
|
|
3839
|
-
var code = '';
|
|
3840
|
-
code += 'do {\n';
|
|
3841
|
-
code += "var _counter = " + this.options.taps.length + ";\n";
|
|
3842
|
-
if (onDone) {
|
|
3843
|
-
code += 'var _done = (function() {\n';
|
|
3844
|
-
code += onDone();
|
|
3845
|
-
code += '});\n';
|
|
3846
|
-
}
|
|
3847
|
-
var _loop2 = function _loop2(i) {
|
|
3848
|
-
var done = function done() {
|
|
3849
|
-
if (onDone) return 'if(--_counter === 0) _done();\n';else return '--_counter;';
|
|
3850
|
-
};
|
|
3851
|
-
var doneBreak = function doneBreak(skipDone) {
|
|
3852
|
-
if (skipDone || !onDone) return '_counter = 0;\n';else return '_counter = 0;\n_done();\n';
|
|
3853
|
-
};
|
|
3854
|
-
code += 'if(_counter <= 0) break;\n';
|
|
3855
|
-
code += onTap(i, function () {
|
|
3856
|
-
return _this3.callTap(i, {
|
|
3857
|
-
onError: function onError(error) {
|
|
3858
|
-
var code = '';
|
|
3859
|
-
code += 'if(_counter > 0) {\n';
|
|
3860
|
-
code += _onError2(i, error, done, doneBreak);
|
|
3861
|
-
code += '}\n';
|
|
3862
|
-
return code;
|
|
3863
|
-
},
|
|
3864
|
-
onResult: onResult && function (result) {
|
|
3865
|
-
var code = '';
|
|
3866
|
-
code += 'if(_counter > 0) {\n';
|
|
3867
|
-
code += onResult(i, result, done, doneBreak);
|
|
3868
|
-
code += '}\n';
|
|
3869
|
-
return code;
|
|
3870
|
-
},
|
|
3871
|
-
onDone: !onResult && function () {
|
|
3872
|
-
return done();
|
|
3873
|
-
},
|
|
3874
|
-
rethrowIfPossible: rethrowIfPossible
|
|
3875
|
-
});
|
|
3876
|
-
}, done, doneBreak);
|
|
3877
|
-
};
|
|
3878
|
-
for (var i = 0; i < this.options.taps.length; i++) {
|
|
3879
|
-
_loop2(i);
|
|
3880
|
-
}
|
|
3881
|
-
code += '} while(false);\n';
|
|
3882
|
-
return code;
|
|
3883
|
-
};
|
|
3884
|
-
_proto.args = function args(_temp) {
|
|
3885
|
-
var _ref5 = _temp === void 0 ? {} : _temp,
|
|
3886
|
-
before = _ref5.before,
|
|
3887
|
-
after = _ref5.after;
|
|
3888
|
-
var allArgs = this._args;
|
|
3889
|
-
if (before) allArgs = [before].concat(allArgs);
|
|
3890
|
-
if (after) allArgs = allArgs.concat(after);
|
|
3891
|
-
if (allArgs.length === 0) {
|
|
3892
|
-
return '';
|
|
3893
|
-
} else {
|
|
3894
|
-
return allArgs.join(', ');
|
|
3332
|
+
}, _callee, this);
|
|
3333
|
+
}));
|
|
3334
|
+
function promise() {
|
|
3335
|
+
return _promise.apply(this, arguments);
|
|
3895
3336
|
}
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
};
|
|
3900
|
-
_proto.getTap = function getTap(idx) {
|
|
3901
|
-
return "_taps[" + idx + "]";
|
|
3902
|
-
};
|
|
3903
|
-
_proto.getInterceptor = function getInterceptor(idx) {
|
|
3904
|
-
return "_interceptors[" + idx + "]";
|
|
3905
|
-
};
|
|
3906
|
-
return HookCodeFactory;
|
|
3337
|
+
return promise;
|
|
3338
|
+
}();
|
|
3339
|
+
return AsyncSeriesWaterfallHook;
|
|
3907
3340
|
}();
|
|
3908
3341
|
|
|
3909
|
-
var
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
return _HookCodeFactory.apply(this, arguments) || this;
|
|
3913
|
-
}
|
|
3914
|
-
var _proto = AsyncParallelHookCodeFactory.prototype;
|
|
3915
|
-
_proto.content = function content(_ref) {
|
|
3916
|
-
var _onError = _ref.onError,
|
|
3917
|
-
onDone = _ref.onDone;
|
|
3918
|
-
return this.callTapsParallel({
|
|
3919
|
-
onError: function onError(i, err, done, doneBreak) {
|
|
3920
|
-
return _onError(err) + doneBreak(true);
|
|
3921
|
-
},
|
|
3922
|
-
onDone: onDone
|
|
3923
|
-
});
|
|
3924
|
-
};
|
|
3925
|
-
return AsyncParallelHookCodeFactory;
|
|
3926
|
-
}(HookCodeFactory);
|
|
3927
|
-
var factory = new AsyncParallelHookCodeFactory();
|
|
3928
|
-
var COMPILE = function COMPILE(options) {
|
|
3929
|
-
factory.setup(this, options);
|
|
3930
|
-
return factory.create(options);
|
|
3931
|
-
};
|
|
3932
|
-
var AsyncParallelHook = /*#__PURE__*/function (_Hook) {
|
|
3933
|
-
_inheritsLoose(AsyncParallelHook, _Hook);
|
|
3934
|
-
function AsyncParallelHook(args, name) {
|
|
3935
|
-
var _this;
|
|
3936
|
-
if (args === void 0) {
|
|
3937
|
-
args = [];
|
|
3938
|
-
}
|
|
3939
|
-
if (name === void 0) {
|
|
3940
|
-
name = undefined;
|
|
3941
|
-
}
|
|
3942
|
-
_this = _Hook.call(this, args, name) || this;
|
|
3943
|
-
_this.compile = COMPILE;
|
|
3944
|
-
_this._call = undefined;
|
|
3945
|
-
_this.call = undefined;
|
|
3946
|
-
return _this;
|
|
3947
|
-
}
|
|
3948
|
-
return AsyncParallelHook;
|
|
3949
|
-
}(Hook);
|
|
3950
|
-
// export function AsyncParallelHook(args = [], name = undefined) {
|
|
3951
|
-
// const hook = new Hook(args, name);
|
|
3952
|
-
// hook.constructor = AsyncParallelHook;
|
|
3953
|
-
// hook.compile = COMPILE;
|
|
3954
|
-
// hook._call = undefined;
|
|
3955
|
-
// hook.call = undefined;
|
|
3956
|
-
// return hook;
|
|
3957
|
-
// }
|
|
3958
|
-
// AsyncParallelHook.prototype = null;
|
|
3959
|
-
|
|
3960
|
-
var AsyncSeriesWaterfallHookCodeFactory = /*#__PURE__*/function (_HookCodeFactory) {
|
|
3961
|
-
_inheritsLoose(AsyncSeriesWaterfallHookCodeFactory, _HookCodeFactory);
|
|
3962
|
-
function AsyncSeriesWaterfallHookCodeFactory() {
|
|
3963
|
-
return _HookCodeFactory.apply(this, arguments) || this;
|
|
3342
|
+
var SyncHook = /*#__PURE__*/function () {
|
|
3343
|
+
function SyncHook() {
|
|
3344
|
+
this.callbacks = [];
|
|
3964
3345
|
}
|
|
3965
|
-
var _proto =
|
|
3966
|
-
_proto.
|
|
3967
|
-
|
|
3968
|
-
var _onError = _ref.onError,
|
|
3969
|
-
onResult = _ref.onResult,
|
|
3970
|
-
onDone = _ref.onDone;
|
|
3971
|
-
return this.callTapsSeries({
|
|
3972
|
-
onError: function onError(i, err, next, doneBreak) {
|
|
3973
|
-
return _onError(err) + doneBreak(true);
|
|
3974
|
-
},
|
|
3975
|
-
onResult: function onResult(i, result, next) {
|
|
3976
|
-
var code = '';
|
|
3977
|
-
code += "if(" + result + " !== undefined) {\n";
|
|
3978
|
-
code += _this._args[0] + " = " + result + ";\n";
|
|
3979
|
-
code += "}\n";
|
|
3980
|
-
code += next();
|
|
3981
|
-
return code;
|
|
3982
|
-
},
|
|
3983
|
-
onDone: function onDone() {
|
|
3984
|
-
return onResult(_this._args[0]);
|
|
3985
|
-
}
|
|
3986
|
-
});
|
|
3346
|
+
var _proto = SyncHook.prototype;
|
|
3347
|
+
_proto.tap = function tap(options, fn) {
|
|
3348
|
+
this.callbacks.push(fn);
|
|
3987
3349
|
};
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
};
|
|
3995
|
-
// export function AsyncSeriesWaterfallHook(args = [], name = undefined) {
|
|
3996
|
-
// if (args.length < 1) throw new Error('Waterfall hooks must have at least one argument');
|
|
3997
|
-
// const hook = new Hook(args, name);
|
|
3998
|
-
// hook.constructor = AsyncSeriesWaterfallHook;
|
|
3999
|
-
// hook.compile = COMPILE;
|
|
4000
|
-
// hook._call = undefined;
|
|
4001
|
-
// hook.call = undefined;
|
|
4002
|
-
// return hook;
|
|
4003
|
-
// }
|
|
4004
|
-
// AsyncSeriesWaterfallHook.prototype = null;
|
|
4005
|
-
var AsyncSeriesWaterfallHook = /*#__PURE__*/function (_Hook) {
|
|
4006
|
-
_inheritsLoose(AsyncSeriesWaterfallHook, _Hook);
|
|
4007
|
-
function AsyncSeriesWaterfallHook(args, name) {
|
|
4008
|
-
var _this2;
|
|
4009
|
-
if (args === void 0) {
|
|
4010
|
-
args = [];
|
|
4011
|
-
}
|
|
4012
|
-
if (name === void 0) {
|
|
4013
|
-
name = undefined;
|
|
4014
|
-
}
|
|
4015
|
-
_this2 = _Hook.call(this, args, name) || this;
|
|
4016
|
-
_this2.compile = COMPILE$1;
|
|
4017
|
-
_this2._call = undefined;
|
|
4018
|
-
_this2.call = undefined;
|
|
4019
|
-
return _this2;
|
|
4020
|
-
}
|
|
4021
|
-
return AsyncSeriesWaterfallHook;
|
|
4022
|
-
}(Hook);
|
|
4023
|
-
|
|
4024
|
-
var SyncHookCodeFactory = /*#__PURE__*/function (_HookCodeFactory) {
|
|
4025
|
-
_inheritsLoose(SyncHookCodeFactory, _HookCodeFactory);
|
|
4026
|
-
function SyncHookCodeFactory() {
|
|
4027
|
-
return _HookCodeFactory.apply(this, arguments) || this;
|
|
4028
|
-
}
|
|
4029
|
-
var _proto = SyncHookCodeFactory.prototype;
|
|
4030
|
-
_proto.content = function content(_ref) {
|
|
4031
|
-
var _onError = _ref.onError,
|
|
4032
|
-
onDone = _ref.onDone,
|
|
4033
|
-
rethrowIfPossible = _ref.rethrowIfPossible;
|
|
4034
|
-
return this.callTapsSeries({
|
|
4035
|
-
onError: function onError(i, err) {
|
|
4036
|
-
return _onError(err);
|
|
4037
|
-
},
|
|
4038
|
-
onDone: onDone,
|
|
4039
|
-
rethrowIfPossible: rethrowIfPossible
|
|
3350
|
+
_proto.call = function call() {
|
|
3351
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3352
|
+
args[_key] = arguments[_key];
|
|
3353
|
+
}
|
|
3354
|
+
this.callbacks.forEach(function (callback) {
|
|
3355
|
+
callback.apply(void 0, args);
|
|
4040
3356
|
});
|
|
4041
3357
|
};
|
|
4042
|
-
return SyncHookCodeFactory;
|
|
4043
|
-
}(HookCodeFactory);
|
|
4044
|
-
var factory$2 = new SyncHookCodeFactory();
|
|
4045
|
-
var TAP_ASYNC = function TAP_ASYNC() {
|
|
4046
|
-
throw new Error('tapAsync is not supported on a SyncHook');
|
|
4047
|
-
};
|
|
4048
|
-
var TAP_PROMISE = function TAP_PROMISE() {
|
|
4049
|
-
throw new Error('tapPromise is not supported on a SyncHook');
|
|
4050
|
-
};
|
|
4051
|
-
var COMPILE$2 = function COMPILE(options) {
|
|
4052
|
-
factory$2.setup(this, options);
|
|
4053
|
-
return factory$2.create(options);
|
|
4054
|
-
};
|
|
4055
|
-
var SyncHook = /*#__PURE__*/function (_Hook) {
|
|
4056
|
-
_inheritsLoose(SyncHook, _Hook);
|
|
4057
|
-
function SyncHook(args, name) {
|
|
4058
|
-
var _this;
|
|
4059
|
-
if (args === void 0) {
|
|
4060
|
-
args = [];
|
|
4061
|
-
}
|
|
4062
|
-
if (name === void 0) {
|
|
4063
|
-
name = undefined;
|
|
4064
|
-
}
|
|
4065
|
-
_this = _Hook.call(this, args, name) || this;
|
|
4066
|
-
_this.tapAsync = TAP_ASYNC;
|
|
4067
|
-
_this.tapPromise = TAP_PROMISE;
|
|
4068
|
-
_this.compile = COMPILE$2;
|
|
4069
|
-
return _this;
|
|
4070
|
-
}
|
|
4071
3358
|
return SyncHook;
|
|
4072
|
-
}(
|
|
4073
|
-
// export function SyncHook(args = [], name = undefined) {
|
|
4074
|
-
// const hook = new Hook(args, name);
|
|
4075
|
-
// hook.constructor = SyncHook;
|
|
4076
|
-
// hook.tapAsync = TAP_ASYNC;
|
|
4077
|
-
// hook.tapPromise = TAP_PROMISE;
|
|
4078
|
-
// hook.compile = COMPILE;
|
|
4079
|
-
// return hook;
|
|
4080
|
-
// }
|
|
4081
|
-
// SyncHook.prototype = null;
|
|
3359
|
+
}();
|
|
4082
3360
|
|
|
4083
|
-
var
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
return _HookCodeFactory.apply(this, arguments) || this;
|
|
3361
|
+
var SyncWaterfallHook = /*#__PURE__*/function () {
|
|
3362
|
+
function SyncWaterfallHook() {
|
|
3363
|
+
this.callbacks = [];
|
|
4087
3364
|
}
|
|
4088
|
-
var _proto =
|
|
4089
|
-
_proto.
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
code += next();
|
|
4105
|
-
return code;
|
|
4106
|
-
},
|
|
4107
|
-
onDone: function onDone() {
|
|
4108
|
-
return onResult(_this._args[0]);
|
|
4109
|
-
},
|
|
4110
|
-
doneReturns: resultReturns,
|
|
4111
|
-
rethrowIfPossible: rethrowIfPossible
|
|
4112
|
-
});
|
|
3365
|
+
var _proto = SyncWaterfallHook.prototype;
|
|
3366
|
+
_proto.tap = function tap(options, fn) {
|
|
3367
|
+
this.callbacks.push(fn);
|
|
3368
|
+
};
|
|
3369
|
+
_proto.call = function call() {
|
|
3370
|
+
if (this.callbacks.length) {
|
|
3371
|
+
var _this$callbacks;
|
|
3372
|
+
var result = (_this$callbacks = this.callbacks)[0].apply(_this$callbacks, arguments);
|
|
3373
|
+
for (var i = 0; i < this.callbacks.length - 1; i++) {
|
|
3374
|
+
var callback = this.callbacks[i];
|
|
3375
|
+
// @ts-ignore
|
|
3376
|
+
result = callback(result);
|
|
3377
|
+
}
|
|
3378
|
+
return result;
|
|
3379
|
+
}
|
|
3380
|
+
return null;
|
|
4113
3381
|
};
|
|
4114
|
-
return SyncWaterfallHookCodeFactory;
|
|
4115
|
-
}(HookCodeFactory);
|
|
4116
|
-
var factory$3 = new SyncWaterfallHookCodeFactory();
|
|
4117
|
-
var TAP_ASYNC$1 = function TAP_ASYNC() {
|
|
4118
|
-
throw new Error('tapAsync is not supported on a SyncWaterfallHook');
|
|
4119
|
-
};
|
|
4120
|
-
var TAP_PROMISE$1 = function TAP_PROMISE() {
|
|
4121
|
-
throw new Error('tapPromise is not supported on a SyncWaterfallHook');
|
|
4122
|
-
};
|
|
4123
|
-
var COMPILE$3 = function COMPILE(options) {
|
|
4124
|
-
factory$3.setup(this, options);
|
|
4125
|
-
return factory$3.create(options);
|
|
4126
|
-
};
|
|
4127
|
-
var SyncWaterfallHook = /*#__PURE__*/function (_SyncHook) {
|
|
4128
|
-
_inheritsLoose(SyncWaterfallHook, _SyncHook);
|
|
4129
|
-
function SyncWaterfallHook(args, name) {
|
|
4130
|
-
var _this2;
|
|
4131
|
-
if (args === void 0) {
|
|
4132
|
-
args = [];
|
|
4133
|
-
}
|
|
4134
|
-
if (name === void 0) {
|
|
4135
|
-
name = undefined;
|
|
4136
|
-
}
|
|
4137
|
-
_this2 = _SyncHook.call(this, args, name) || this;
|
|
4138
|
-
_this2.tapAsync = TAP_ASYNC$1;
|
|
4139
|
-
_this2.tapPromise = TAP_PROMISE$1;
|
|
4140
|
-
_this2.compile = COMPILE$3;
|
|
4141
|
-
return _this2;
|
|
4142
|
-
}
|
|
4143
3382
|
return SyncWaterfallHook;
|
|
4144
|
-
}(
|
|
4145
|
-
// export function SyncWaterfallHook(args = [], name = undefined) {
|
|
4146
|
-
// if (args.length < 1) throw new Error('Waterfall hooks must have at least one argument');
|
|
4147
|
-
// const hook = new Hook(args, name);
|
|
4148
|
-
// hook.constructor = SyncWaterfallHook;
|
|
4149
|
-
// hook.tapAsync = TAP_ASYNC;
|
|
4150
|
-
// hook.tapPromise = TAP_PROMISE;
|
|
4151
|
-
// hook.compile = COMPILE;
|
|
4152
|
-
// return hook;
|
|
4153
|
-
// }
|
|
4154
|
-
// SyncWaterfallHook.prototype = null;
|
|
3383
|
+
}();
|
|
4155
3384
|
|
|
4156
3385
|
var genericFontFamilies = ['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui'];
|
|
4157
3386
|
var stringRegExp = /([\"\'])[^\'\"]+\1/;
|
|
@@ -6129,13 +5358,12 @@ var AABB = /*#__PURE__*/function () {
|
|
|
6129
5358
|
}();
|
|
6130
5359
|
|
|
6131
5360
|
var Plane = /*#__PURE__*/function () {
|
|
6132
|
-
/**
|
|
6133
|
-
* lookup table for p-vertex & n-vertex when doing frustum culling
|
|
6134
|
-
*/
|
|
6135
|
-
|
|
6136
5361
|
function Plane(distance, normal) {
|
|
6137
5362
|
this.distance = void 0;
|
|
6138
5363
|
this.normal = void 0;
|
|
5364
|
+
/**
|
|
5365
|
+
* lookup table for p-vertex & n-vertex when doing frustum culling
|
|
5366
|
+
*/
|
|
6139
5367
|
this.pnVertexFlag = void 0;
|
|
6140
5368
|
this.distance = distance || 0;
|
|
6141
5369
|
this.normal = normal || glMatrix.vec3.fromValues(0, 1, 0);
|
|
@@ -8556,32 +7784,29 @@ var DATASET_PREFIX = 'data-';
|
|
|
8556
7784
|
*/
|
|
8557
7785
|
var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
8558
7786
|
_inheritsLoose(DisplayObject, _Element);
|
|
8559
|
-
/**
|
|
8560
|
-
* contains style props in constructor's params, eg. fill, stroke...
|
|
8561
|
-
*/
|
|
8562
|
-
|
|
8563
|
-
/**
|
|
8564
|
-
* push to active animations after calling `animate()`
|
|
8565
|
-
*/
|
|
8566
|
-
|
|
8567
|
-
/**
|
|
8568
|
-
* Use data-* attribute.
|
|
8569
|
-
* @see https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
|
|
8570
|
-
* @example
|
|
8571
|
-
* group.dataset.prop1 = 1;
|
|
8572
|
-
* group.getAttribute('data-prop1'); // 1
|
|
8573
|
-
*/
|
|
8574
|
-
|
|
8575
7787
|
function DisplayObject(config) {
|
|
8576
7788
|
var _this$config$capture;
|
|
8577
7789
|
var _this;
|
|
8578
7790
|
_this = _Element.call(this) || this;
|
|
8579
7791
|
// assign name, id to config
|
|
8580
7792
|
// eg. group.get('name')
|
|
7793
|
+
/**
|
|
7794
|
+
* contains style props in constructor's params, eg. fill, stroke...
|
|
7795
|
+
*/
|
|
8581
7796
|
_this.config = void 0;
|
|
8582
7797
|
_this.isCustomElement = false;
|
|
8583
7798
|
_this.isMutationObserved = false;
|
|
7799
|
+
/**
|
|
7800
|
+
* push to active animations after calling `animate()`
|
|
7801
|
+
*/
|
|
8584
7802
|
_this.activeAnimations = [];
|
|
7803
|
+
/**
|
|
7804
|
+
* Use data-* attribute.
|
|
7805
|
+
* @see https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
|
|
7806
|
+
* @example
|
|
7807
|
+
* group.dataset.prop1 = 1;
|
|
7808
|
+
* group.getAttribute('data-prop1'); // 1
|
|
7809
|
+
*/
|
|
8585
7810
|
_this.dataset = void 0;
|
|
8586
7811
|
/**
|
|
8587
7812
|
* Use `this.style.clipPath` instead.
|
|
@@ -9322,10 +8547,6 @@ var _excluded$1 = ["style"];
|
|
|
9322
8547
|
*/
|
|
9323
8548
|
var CustomElement = /*#__PURE__*/function (_DisplayObject) {
|
|
9324
8549
|
_inheritsLoose(CustomElement, _DisplayObject);
|
|
9325
|
-
// static get observedAttributes(): string[] {
|
|
9326
|
-
// return [];
|
|
9327
|
-
// }
|
|
9328
|
-
|
|
9329
8550
|
// private shadowNodes: DisplayObject[] = [];
|
|
9330
8551
|
function CustomElement(_temp) {
|
|
9331
8552
|
var _this;
|
|
@@ -9338,6 +8559,9 @@ var CustomElement = /*#__PURE__*/function (_DisplayObject) {
|
|
|
9338
8559
|
y: ''
|
|
9339
8560
|
}, style) : _extends({}, style)
|
|
9340
8561
|
}, rest)) || this;
|
|
8562
|
+
// static get observedAttributes(): string[] {
|
|
8563
|
+
// return [];
|
|
8564
|
+
// }
|
|
9341
8565
|
_this.isCustomElement = true;
|
|
9342
8566
|
return _this;
|
|
9343
8567
|
}
|
|
@@ -9661,10 +8885,6 @@ var EMPTY_PARSED_PATH = {
|
|
|
9661
8885
|
};
|
|
9662
8886
|
var Path = /*#__PURE__*/function (_DisplayObject) {
|
|
9663
8887
|
_inheritsLoose(Path, _DisplayObject);
|
|
9664
|
-
/**
|
|
9665
|
-
* markers placed at the mid
|
|
9666
|
-
*/
|
|
9667
|
-
|
|
9668
8888
|
function Path(_temp) {
|
|
9669
8889
|
var _this;
|
|
9670
8890
|
var _ref = _temp === void 0 ? {} : _temp,
|
|
@@ -9683,6 +8903,9 @@ var Path = /*#__PURE__*/function (_DisplayObject) {
|
|
|
9683
8903
|
}, rest)) || this;
|
|
9684
8904
|
_this.markerStartAngle = 0;
|
|
9685
8905
|
_this.markerEndAngle = 0;
|
|
8906
|
+
/**
|
|
8907
|
+
* markers placed at the mid
|
|
8908
|
+
*/
|
|
9686
8909
|
_this.markerMidList = [];
|
|
9687
8910
|
var _this$parsedStyle = _this.parsedStyle,
|
|
9688
8911
|
markerStart = _this$parsedStyle.markerStart,
|
|
@@ -9889,10 +9112,6 @@ var Path = /*#__PURE__*/function (_DisplayObject) {
|
|
|
9889
9112
|
var _excluded$8 = ["style"];
|
|
9890
9113
|
var Polygon = /*#__PURE__*/function (_DisplayObject) {
|
|
9891
9114
|
_inheritsLoose(Polygon, _DisplayObject);
|
|
9892
|
-
/**
|
|
9893
|
-
* markers placed at the mid
|
|
9894
|
-
*/
|
|
9895
|
-
|
|
9896
9115
|
function Polygon(_temp) {
|
|
9897
9116
|
var _this;
|
|
9898
9117
|
var _ref = _temp === void 0 ? {} : _temp,
|
|
@@ -9917,6 +9136,9 @@ var Polygon = /*#__PURE__*/function (_DisplayObject) {
|
|
|
9917
9136
|
}, rest)) || this;
|
|
9918
9137
|
_this.markerStartAngle = 0;
|
|
9919
9138
|
_this.markerEndAngle = 0;
|
|
9139
|
+
/**
|
|
9140
|
+
* markers placed at the mid
|
|
9141
|
+
*/
|
|
9920
9142
|
_this.markerMidList = [];
|
|
9921
9143
|
var _this$parsedStyle = _this.parsedStyle,
|
|
9922
9144
|
markerStart = _this$parsedStyle.markerStart,
|
|
@@ -13108,48 +12330,48 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
13108
12330
|
/**
|
|
13109
12331
|
* only dirty object which has sth changed will be rendered
|
|
13110
12332
|
*/
|
|
13111
|
-
dirtycheck: new SyncWaterfallHook(
|
|
12333
|
+
dirtycheck: new SyncWaterfallHook(),
|
|
13112
12334
|
/**
|
|
13113
12335
|
* do culling
|
|
13114
12336
|
*/
|
|
13115
|
-
cull: new SyncWaterfallHook(
|
|
12337
|
+
cull: new SyncWaterfallHook(),
|
|
13116
12338
|
/**
|
|
13117
12339
|
* called at beginning of each frame, won't get called if nothing to re-render
|
|
13118
12340
|
*/
|
|
13119
|
-
beginFrame: new SyncHook(
|
|
12341
|
+
beginFrame: new SyncHook(),
|
|
13120
12342
|
/**
|
|
13121
12343
|
* called before every dirty object get rendered
|
|
13122
12344
|
*/
|
|
13123
|
-
beforeRender: new SyncHook(
|
|
12345
|
+
beforeRender: new SyncHook(),
|
|
13124
12346
|
/**
|
|
13125
12347
|
* called when every dirty object rendering even it's culled
|
|
13126
12348
|
*/
|
|
13127
|
-
render: new SyncHook(
|
|
12349
|
+
render: new SyncHook(),
|
|
13128
12350
|
/**
|
|
13129
12351
|
* called after every dirty object get rendered
|
|
13130
12352
|
*/
|
|
13131
|
-
afterRender: new SyncHook(
|
|
13132
|
-
endFrame: new SyncHook(
|
|
13133
|
-
destroy: new SyncHook(
|
|
12353
|
+
afterRender: new SyncHook(),
|
|
12354
|
+
endFrame: new SyncHook(),
|
|
12355
|
+
destroy: new SyncHook(),
|
|
13134
12356
|
/**
|
|
13135
12357
|
* use async but faster method such as GPU-based picking in `g-plugin-device-renderer`
|
|
13136
12358
|
*/
|
|
13137
|
-
pick: new AsyncSeriesWaterfallHook(
|
|
12359
|
+
pick: new AsyncSeriesWaterfallHook(),
|
|
13138
12360
|
/**
|
|
13139
12361
|
* Unsafe but sync version of pick.
|
|
13140
12362
|
*/
|
|
13141
|
-
pickSync: new SyncWaterfallHook(
|
|
12363
|
+
pickSync: new SyncWaterfallHook(),
|
|
13142
12364
|
/**
|
|
13143
12365
|
* used in event system
|
|
13144
12366
|
*/
|
|
13145
|
-
pointerDown: new SyncHook(
|
|
13146
|
-
pointerUp: new SyncHook(
|
|
13147
|
-
pointerMove: new SyncHook(
|
|
13148
|
-
pointerOut: new SyncHook(
|
|
13149
|
-
pointerOver: new SyncHook(
|
|
13150
|
-
pointerWheel: new SyncHook(
|
|
13151
|
-
pointerCancel: new SyncHook(
|
|
13152
|
-
click: new SyncHook(
|
|
12367
|
+
pointerDown: new SyncHook(),
|
|
12368
|
+
pointerUp: new SyncHook(),
|
|
12369
|
+
pointerMove: new SyncHook(),
|
|
12370
|
+
pointerOut: new SyncHook(),
|
|
12371
|
+
pointerOver: new SyncHook(),
|
|
12372
|
+
pointerWheel: new SyncHook(),
|
|
12373
|
+
pointerCancel: new SyncHook(),
|
|
12374
|
+
click: new SyncHook()
|
|
13153
12375
|
};
|
|
13154
12376
|
this.globalRuntime = globalRuntime;
|
|
13155
12377
|
this.context = context;
|
|
@@ -15267,66 +14489,55 @@ var afterRenderEvent = new CustomEvent(exports.CanvasEvent.AFTER_RENDER);
|
|
|
15267
14489
|
*/
|
|
15268
14490
|
var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
15269
14491
|
_inheritsLoose(Canvas, _EventTarget);
|
|
15270
|
-
/**
|
|
15271
|
-
* window.document
|
|
15272
|
-
*/
|
|
15273
|
-
|
|
15274
|
-
/**
|
|
15275
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry
|
|
15276
|
-
*/
|
|
15277
|
-
|
|
15278
|
-
/**
|
|
15279
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
|
|
15280
|
-
*/
|
|
15281
|
-
|
|
15282
|
-
/**
|
|
15283
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/cancelAnimationFrame
|
|
15284
|
-
*/
|
|
15285
|
-
|
|
15286
|
-
/**
|
|
15287
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
|
|
15288
|
-
*/
|
|
15289
|
-
|
|
15290
|
-
/**
|
|
15291
|
-
* whether the runtime supports PointerEvent?
|
|
15292
|
-
* if not, the event system won't trigger pointer events like `pointerdown`
|
|
15293
|
-
*/
|
|
15294
|
-
|
|
15295
|
-
/**
|
|
15296
|
-
* whether the runtime supports TouchEvent?
|
|
15297
|
-
* if not, the event system won't trigger touch events like `touchstart`
|
|
15298
|
-
*/
|
|
15299
|
-
|
|
15300
|
-
/**
|
|
15301
|
-
* is this native event a TouchEvent?
|
|
15302
|
-
*/
|
|
15303
|
-
|
|
15304
|
-
/**
|
|
15305
|
-
* is this native event a MouseEvent?
|
|
15306
|
-
*/
|
|
15307
|
-
|
|
15308
|
-
/**
|
|
15309
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element
|
|
15310
|
-
*/
|
|
15311
|
-
|
|
15312
|
-
/**
|
|
15313
|
-
* rAF in auto rendering
|
|
15314
|
-
*/
|
|
15315
|
-
|
|
15316
14492
|
function Canvas(config) {
|
|
15317
14493
|
var _this;
|
|
15318
14494
|
_this = _EventTarget.call(this) || this;
|
|
15319
14495
|
// create document
|
|
14496
|
+
/**
|
|
14497
|
+
* window.document
|
|
14498
|
+
*/
|
|
15320
14499
|
_this.document = void 0;
|
|
14500
|
+
/**
|
|
14501
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry
|
|
14502
|
+
*/
|
|
15321
14503
|
_this.customElements = void 0;
|
|
14504
|
+
/**
|
|
14505
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
|
|
14506
|
+
*/
|
|
15322
14507
|
_this.requestAnimationFrame = void 0;
|
|
14508
|
+
/**
|
|
14509
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/cancelAnimationFrame
|
|
14510
|
+
*/
|
|
15323
14511
|
_this.cancelAnimationFrame = void 0;
|
|
14512
|
+
/**
|
|
14513
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
|
|
14514
|
+
*/
|
|
15324
14515
|
_this.devicePixelRatio = void 0;
|
|
14516
|
+
/**
|
|
14517
|
+
* whether the runtime supports PointerEvent?
|
|
14518
|
+
* if not, the event system won't trigger pointer events like `pointerdown`
|
|
14519
|
+
*/
|
|
15325
14520
|
_this.supportsPointerEvents = void 0;
|
|
14521
|
+
/**
|
|
14522
|
+
* whether the runtime supports TouchEvent?
|
|
14523
|
+
* if not, the event system won't trigger touch events like `touchstart`
|
|
14524
|
+
*/
|
|
15326
14525
|
_this.supportsTouchEvents = void 0;
|
|
14526
|
+
/**
|
|
14527
|
+
* is this native event a TouchEvent?
|
|
14528
|
+
*/
|
|
15327
14529
|
_this.isTouchEvent = void 0;
|
|
14530
|
+
/**
|
|
14531
|
+
* is this native event a MouseEvent?
|
|
14532
|
+
*/
|
|
15328
14533
|
_this.isMouseEvent = void 0;
|
|
14534
|
+
/**
|
|
14535
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element
|
|
14536
|
+
*/
|
|
15329
14537
|
_this.Element = DisplayObject;
|
|
14538
|
+
/**
|
|
14539
|
+
* rAF in auto rendering
|
|
14540
|
+
*/
|
|
15330
14541
|
_this.frameId = void 0;
|
|
15331
14542
|
_this.inited = false;
|
|
15332
14543
|
_this.readyPromise = void 0;
|