@coolon/angular-ui-powerups 12.0.0-alpha.2 → 12.0.0-alpha.3
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/bundles/coolon-angular-ui-powerups.umd.js +213 -238
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/lib/place/navigation/session/event-cleanup/wait-until-link-triggered-navigation-interaction-cancelation-type-determined.js +3 -15
- package/esm2015/lib/place/navigation/session/event-cleanup/wait-until-link-triggered-navigation-interaction-cancelation-type-determined.js.map +1 -1
- package/esm2015/lib/place/navigation/session/event-cleanup/wait-until-link-triggered-navigation-interaction-cancelation-type-determined.metadata.json +1 -1
- package/esm2015/lib/place/place-component.js +5 -17
- package/esm2015/lib/place/place-component.js.map +1 -1
- package/esm2015/lib/place/place-component.metadata.json +1 -1
- package/esm2015/lib/place/route/parameter-definition.js +2 -11
- package/esm2015/lib/place/route/parameter-definition.js.map +1 -1
- package/esm2015/lib/place/route/parameter-definition.metadata.json +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +207 -232
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/package.json +1 -1
|
@@ -6248,212 +6248,6 @@
|
|
|
6248
6248
|
},] }
|
|
6249
6249
|
];
|
|
6250
6250
|
|
|
6251
|
-
exports.PlaceHistory = /** @class */ (function () {
|
|
6252
|
-
function PlaceHistory() {
|
|
6253
|
-
this._archive = new Map();
|
|
6254
|
-
this.placeHistoryDepth = 4;
|
|
6255
|
-
}
|
|
6256
|
-
PlaceHistory.prototype.notifyNavigationStarted = function () {
|
|
6257
|
-
if (this._activeVisits) {
|
|
6258
|
-
this.archive(this._activeVisits.visits);
|
|
6259
|
-
this._previousVisits = this._activeVisits;
|
|
6260
|
-
}
|
|
6261
|
-
};
|
|
6262
|
-
PlaceHistory.prototype.notifyNavigationFinished = function (visits) {
|
|
6263
|
-
this._activeVisits = new PlaceHistory.VisitRecord(visits);
|
|
6264
|
-
};
|
|
6265
|
-
PlaceHistory.prototype.updateVisit = function (visit) {
|
|
6266
|
-
pectin.assert.isTruthy(this._activeVisits);
|
|
6267
|
-
this._activeVisits.update(visit);
|
|
6268
|
-
};
|
|
6269
|
-
PlaceHistory.prototype.lastVisitIncluded = function (placeDef) {
|
|
6270
|
-
var _a;
|
|
6271
|
-
return !!((_a = this._previousVisits) === null || _a === void 0 ? void 0 : _a.getVisitFor(placeDef));
|
|
6272
|
-
};
|
|
6273
|
-
PlaceHistory.prototype.getMostRecentVisitFor = function (placeDef) {
|
|
6274
|
-
return ___default['default'].first(this.getHistory(placeDef));
|
|
6275
|
-
};
|
|
6276
|
-
PlaceHistory.prototype.getHistory = function (placeDef) {
|
|
6277
|
-
var history = this._archive.get(placeDef);
|
|
6278
|
-
if (!history) {
|
|
6279
|
-
history = [];
|
|
6280
|
-
this.setHistory(placeDef, history);
|
|
6281
|
-
}
|
|
6282
|
-
return history;
|
|
6283
|
-
};
|
|
6284
|
-
PlaceHistory.prototype.setHistory = function (placeDef, history) {
|
|
6285
|
-
this._archive.set(placeDef, history);
|
|
6286
|
-
};
|
|
6287
|
-
PlaceHistory.prototype.archive = function (visits) {
|
|
6288
|
-
var _this = this;
|
|
6289
|
-
visits.forEach(function (state) {
|
|
6290
|
-
var history = _this.getHistory(state.placeDefinition);
|
|
6291
|
-
var previousState = ___default['default'].first(history);
|
|
6292
|
-
if (!previousState || state.hasChangedFrom(previousState)) {
|
|
6293
|
-
history.unshift(state); // LIFO
|
|
6294
|
-
_this.setHistory(state.placeDefinition, history.slice(0, _this.placeHistoryDepth));
|
|
6295
|
-
}
|
|
6296
|
-
});
|
|
6297
|
-
};
|
|
6298
|
-
return PlaceHistory;
|
|
6299
|
-
}());
|
|
6300
|
-
exports.PlaceHistory.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PlaceHistory_Factory() { return new exports.PlaceHistory(); }, token: exports.PlaceHistory, providedIn: "root" });
|
|
6301
|
-
exports.PlaceHistory.decorators = [
|
|
6302
|
-
{ type: i0.Injectable, args: [{
|
|
6303
|
-
providedIn: 'root'
|
|
6304
|
-
},] }
|
|
6305
|
-
];
|
|
6306
|
-
exports.PlaceHistory.ctorParameters = function () { return []; };
|
|
6307
|
-
(function (PlaceHistory) {
|
|
6308
|
-
var VisitRecord = /** @class */ (function () {
|
|
6309
|
-
function VisitRecord(visits) {
|
|
6310
|
-
this.visits = visits;
|
|
6311
|
-
}
|
|
6312
|
-
VisitRecord.prototype.update = function (visit) {
|
|
6313
|
-
this.visits = this.visits.filter(function (v) { return v.placeDefinition !== visit.placeDefinition; }).concat(visit);
|
|
6314
|
-
};
|
|
6315
|
-
VisitRecord.prototype.getVisitFor = function (placeDef) {
|
|
6316
|
-
return this.visits.find(function (v) { return v.placeDefinition === placeDef; });
|
|
6317
|
-
};
|
|
6318
|
-
return VisitRecord;
|
|
6319
|
-
}());
|
|
6320
|
-
PlaceHistory.VisitRecord = VisitRecord;
|
|
6321
|
-
// export class Query {
|
|
6322
|
-
// private _history: Visit.State[];
|
|
6323
|
-
// private _places: Place[];
|
|
6324
|
-
// private _predicate: (visit: any) => boolean;
|
|
6325
|
-
// private _limit: number;
|
|
6326
|
-
//
|
|
6327
|
-
// constructor(history, limit = history.length) {
|
|
6328
|
-
// this._history = history;
|
|
6329
|
-
// this._places = [];
|
|
6330
|
-
// this._predicate = (visit => true);
|
|
6331
|
-
// this._limit = limit;
|
|
6332
|
-
// }
|
|
6333
|
-
//
|
|
6334
|
-
// to(...places:Place[]):this {
|
|
6335
|
-
// this._places = places;
|
|
6336
|
-
// return this;
|
|
6337
|
-
// }
|
|
6338
|
-
//
|
|
6339
|
-
// with(parameters: { [parameter: string]: any }): this {
|
|
6340
|
-
// this.matching(state => {
|
|
6341
|
-
// return Object.keys(parameters).reduce((acc, key) => {
|
|
6342
|
-
// const matchValue = parameters[key];
|
|
6343
|
-
// const visitValue = state.get(key);
|
|
6344
|
-
// const matched = matchValue === '*' ? !_.isNil(visitValue) : visitValue == matchValue;
|
|
6345
|
-
// // Logger.get(this).info(`matched=${matched}`, parameters, visitValue);
|
|
6346
|
-
// return acc && matched;
|
|
6347
|
-
// }, true);
|
|
6348
|
-
// });
|
|
6349
|
-
// return this;
|
|
6350
|
-
// }
|
|
6351
|
-
//
|
|
6352
|
-
// last(): Visit.State {
|
|
6353
|
-
// return _.findLast(this._history, visit => this._matches(visit))
|
|
6354
|
-
// }
|
|
6355
|
-
//
|
|
6356
|
-
// // @trace
|
|
6357
|
-
// allThatMatch(): Visit.State[] {
|
|
6358
|
-
// return _.filter(this._history, visit => this._matches(visit)).slice(-this._limit);
|
|
6359
|
-
// }
|
|
6360
|
-
//
|
|
6361
|
-
// // @trace
|
|
6362
|
-
// mostRecentValueOf<T=any>(param: string, defaultValue: T = null): T {
|
|
6363
|
-
// const lastStateWithParam = _.findLast(this.allThatMatch(), state => !_.isNil(state.get(param)));
|
|
6364
|
-
// return _.isNil(lastStateWithParam) ? defaultValue : lastStateWithParam.get(param);
|
|
6365
|
-
// }
|
|
6366
|
-
//
|
|
6367
|
-
// limit(limit: number): this {
|
|
6368
|
-
// this._limit = limit;
|
|
6369
|
-
// return this;
|
|
6370
|
-
// }
|
|
6371
|
-
//
|
|
6372
|
-
// matching(predicate: (visit: Visit.State) => boolean): this {
|
|
6373
|
-
// this._predicate = predicate;
|
|
6374
|
-
// return this;
|
|
6375
|
-
// }
|
|
6376
|
-
//
|
|
6377
|
-
// _matches(visit: Visit.State) {
|
|
6378
|
-
// return this._isPlaceMatch(visit) && this._predicate(visit);
|
|
6379
|
-
// }
|
|
6380
|
-
//
|
|
6381
|
-
// _isPlaceMatch(visit: Visit.State) {
|
|
6382
|
-
// return this._places.length < 1 || this._places.includes(visit.place)
|
|
6383
|
-
// }
|
|
6384
|
-
//
|
|
6385
|
-
// }
|
|
6386
|
-
})(exports.PlaceHistory || (exports.PlaceHistory = {}));
|
|
6387
|
-
|
|
6388
|
-
var Visit = /** @class */ (function () {
|
|
6389
|
-
function Visit(placeDefinition, visitParameters) {
|
|
6390
|
-
if (visitParameters === void 0) { visitParameters = {}; }
|
|
6391
|
-
this.placeDefinition = placeDefinition;
|
|
6392
|
-
this.visitParameters = visitParameters;
|
|
6393
|
-
}
|
|
6394
|
-
// @Trace()
|
|
6395
|
-
Visit.prototype.getRouteId = function () {
|
|
6396
|
-
return this.placeDefinition.getRouteIdFrom(this);
|
|
6397
|
-
};
|
|
6398
|
-
// @Trace()
|
|
6399
|
-
Visit.prototype.hasRouteId = function () {
|
|
6400
|
-
return !___namespace.isNil(this.getRouteId());
|
|
6401
|
-
};
|
|
6402
|
-
/**
|
|
6403
|
-
* Returns the value of the place parameter with the specified name. The parameter
|
|
6404
|
-
* name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
|
|
6405
|
-
* same as the the ValueModel property name.
|
|
6406
|
-
* @param parameterName the field name of the property model or the `as` option if specified.
|
|
6407
|
-
*/
|
|
6408
|
-
Visit.prototype.getParameter = function (parameterName) {
|
|
6409
|
-
return this.visitParameters[parameterName];
|
|
6410
|
-
};
|
|
6411
|
-
// @Trace()
|
|
6412
|
-
Visit.prototype.hasParameter = function (parameterName) {
|
|
6413
|
-
return Object.keys(this.visitParameters).includes(parameterName);
|
|
6414
|
-
};
|
|
6415
|
-
Visit.prototype.replace = function (parameter, value) {
|
|
6416
|
-
var _a;
|
|
6417
|
-
return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), (_a = {}, _a[parameter.name] = value, _a)));
|
|
6418
|
-
};
|
|
6419
|
-
Visit.prototype.mergeRouteParameters = function (routeParams) {
|
|
6420
|
-
var _this = this;
|
|
6421
|
-
// todo: whitelist parameters.
|
|
6422
|
-
var routeParameterKeys = Object.keys(routeParams);
|
|
6423
|
-
var params = {};
|
|
6424
|
-
this.placeDefinition.getVisitParameterDefs().forEach(function (def) {
|
|
6425
|
-
if (def.isRouteId || def.isRouteParameter) {
|
|
6426
|
-
if (routeParameterKeys.includes(def.name)) {
|
|
6427
|
-
params[def.name] = routeParams[def.name];
|
|
6428
|
-
}
|
|
6429
|
-
}
|
|
6430
|
-
else {
|
|
6431
|
-
// copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
|
|
6432
|
-
// defaults and remember sanitisation process.
|
|
6433
|
-
var value = _this.getParameter(def.name);
|
|
6434
|
-
if (_this.hasParameter(def.name)) {
|
|
6435
|
-
params[def.name] = value;
|
|
6436
|
-
}
|
|
6437
|
-
}
|
|
6438
|
-
});
|
|
6439
|
-
return new Visit(this.placeDefinition, params);
|
|
6440
|
-
};
|
|
6441
|
-
Visit.prototype.hasRoutingChangedFrom = function (other) {
|
|
6442
|
-
var samePlace = other.placeDefinition === this.placeDefinition;
|
|
6443
|
-
var sameRouteParameters = ___namespace.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
|
|
6444
|
-
return !samePlace || !sameRouteParameters;
|
|
6445
|
-
};
|
|
6446
|
-
Visit.prototype.hasChangedFrom = function (other) {
|
|
6447
|
-
var sameNonRouteParameters = ___namespace.isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
|
|
6448
|
-
return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
|
|
6449
|
-
};
|
|
6450
|
-
Visit.prototype.toDebugString = function () {
|
|
6451
|
-
var _this = this;
|
|
6452
|
-
return Object.keys(this.visitParameters).map(function (k) { return k + "=" + _this.visitParameters[k]; }).join(',');
|
|
6453
|
-
};
|
|
6454
|
-
return Visit;
|
|
6455
|
-
}());
|
|
6456
|
-
|
|
6457
6251
|
exports.ParameterDefinition = /** @class */ (function () {
|
|
6458
6252
|
function ParameterDefinition(propertyName, options, urlFormat) {
|
|
6459
6253
|
this.propertyName = propertyName;
|
|
@@ -6480,6 +6274,7 @@
|
|
|
6480
6274
|
ParameterDefinition.prototype.getOptionValue = function (key) {
|
|
6481
6275
|
return this.options.getOptional(key, null);
|
|
6482
6276
|
};
|
|
6277
|
+
// @Trace()
|
|
6483
6278
|
ParameterDefinition.prototype.sanitise = function (value, visit, placeHistory, injector, isPopState) {
|
|
6484
6279
|
return __awaiter(this, void 0, void 0, function () {
|
|
6485
6280
|
var returningFromSomewhereElse, lastKnownVisit;
|
|
@@ -6504,12 +6299,6 @@
|
|
|
6504
6299
|
};
|
|
6505
6300
|
return ParameterDefinition;
|
|
6506
6301
|
}());
|
|
6507
|
-
__decorate([
|
|
6508
|
-
pectin.Trace(),
|
|
6509
|
-
__metadata("design:type", Function),
|
|
6510
|
-
__metadata("design:paramtypes", [Object, Visit, exports.PlaceHistory, i0.Injector, Boolean]),
|
|
6511
|
-
__metadata("design:returntype", Promise)
|
|
6512
|
-
], exports.ParameterDefinition.prototype, "sanitise", null);
|
|
6513
6302
|
(function (ParameterDefinition) {
|
|
6514
6303
|
var RouteId = /** @class */ (function (_super) {
|
|
6515
6304
|
__extends(RouteId, _super);
|
|
@@ -6723,6 +6512,7 @@
|
|
|
6723
6512
|
_this.childPlaces = _this.placeDefinition.children.map(function (d) { return d.component; });
|
|
6724
6513
|
return _this;
|
|
6725
6514
|
}
|
|
6515
|
+
// @Trace()
|
|
6726
6516
|
PlaceComponent.prototype.initialiseVisit = function (visit, notifyVisitChanged) {
|
|
6727
6517
|
var _this = this;
|
|
6728
6518
|
pectin.assert.isNil(this.visitModel.value);
|
|
@@ -6745,17 +6535,18 @@
|
|
|
6745
6535
|
PlaceComponent.prototype.isInitialised = function () {
|
|
6746
6536
|
return !!this.visitModel.value;
|
|
6747
6537
|
};
|
|
6538
|
+
// @Trace()
|
|
6748
6539
|
PlaceComponent.prototype.installBinding = function (parameterDef) {
|
|
6749
6540
|
var model = this[parameterDef.propertyName];
|
|
6750
6541
|
pectin.DebugContext.tag(model, this.placeDefinition.component.name + "." + parameterDef.propertyName);
|
|
6751
6542
|
var binding = this.registerDisposable(new pectin.Binding(this.visitModel, model, {
|
|
6752
6543
|
toRight: function (visit) {
|
|
6753
6544
|
var value = visit.getParameter(parameterDef.name);
|
|
6754
|
-
console.log('push to component', { name: parameterDef.name, value
|
|
6545
|
+
// console.log('push to component', { name: parameterDef.name, value, visit });
|
|
6755
6546
|
return value;
|
|
6756
6547
|
},
|
|
6757
6548
|
toLeft: function (value, currentVisit) {
|
|
6758
|
-
console.log('push to route', { name: parameterDef.name, value
|
|
6549
|
+
// console.log('push to route', { name: parameterDef.name, value, currentVisit });
|
|
6759
6550
|
return currentVisit.replace(parameterDef, value);
|
|
6760
6551
|
}
|
|
6761
6552
|
}));
|
|
@@ -6789,18 +6580,6 @@
|
|
|
6789
6580
|
{ type: i0.Directive }
|
|
6790
6581
|
];
|
|
6791
6582
|
exports.PlaceComponent.ctorParameters = function () { return []; };
|
|
6792
|
-
__decorate([
|
|
6793
|
-
pectin.Trace(),
|
|
6794
|
-
__metadata("design:type", Function),
|
|
6795
|
-
__metadata("design:paramtypes", [Visit, Function]),
|
|
6796
|
-
__metadata("design:returntype", void 0)
|
|
6797
|
-
], exports.PlaceComponent.prototype, "initialiseVisit", null);
|
|
6798
|
-
__decorate([
|
|
6799
|
-
pectin.Trace(),
|
|
6800
|
-
__metadata("design:type", Function),
|
|
6801
|
-
__metadata("design:paramtypes", [exports.ParameterDefinition]),
|
|
6802
|
-
__metadata("design:returntype", void 0)
|
|
6803
|
-
], exports.PlaceComponent.prototype, "installBinding", null);
|
|
6804
6583
|
__decorate([
|
|
6805
6584
|
fastMemoizeDecorator.Memoize(),
|
|
6806
6585
|
__metadata("design:type", PlaceDefinition),
|
|
@@ -7413,9 +7192,11 @@
|
|
|
7413
7192
|
_this.debugPropertyKeys = ['idle', 'startingUrl', 'clickedLinkUrl', 'firstCancelEventUrl', 'clickedLinkMatchedBackButtonUrl', 'popStateEventUrl'];
|
|
7414
7193
|
return _this;
|
|
7415
7194
|
}
|
|
7195
|
+
// @Trace()
|
|
7416
7196
|
WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined.prototype.onRouterStarted = function (event) {
|
|
7417
7197
|
this.ignore(event);
|
|
7418
7198
|
};
|
|
7199
|
+
// @Trace()
|
|
7419
7200
|
WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined.prototype.onRouterCancelled = function (event) {
|
|
7420
7201
|
if (event.url === this.clickedLinkUrl) {
|
|
7421
7202
|
this.context.transitionTo(new WaitForLinkSameAsBackToPlayOut(this.context, this.startingUrl, this.clickedLinkUrl));
|
|
@@ -7433,18 +7214,6 @@
|
|
|
7433
7214
|
};
|
|
7434
7215
|
return WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined;
|
|
7435
7216
|
}(EventCleanUpSession));
|
|
7436
|
-
__decorate([
|
|
7437
|
-
pectin.Trace(),
|
|
7438
|
-
__metadata("design:type", Function),
|
|
7439
|
-
__metadata("design:paramtypes", [i1$1.NavigationStart]),
|
|
7440
|
-
__metadata("design:returntype", void 0)
|
|
7441
|
-
], WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined.prototype, "onRouterStarted", null);
|
|
7442
|
-
__decorate([
|
|
7443
|
-
pectin.Trace(),
|
|
7444
|
-
__metadata("design:type", Function),
|
|
7445
|
-
__metadata("design:paramtypes", [i1$1.NavigationCancel]),
|
|
7446
|
-
__metadata("design:returntype", void 0)
|
|
7447
|
-
], WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined.prototype, "onRouterCancelled", null);
|
|
7448
7217
|
var WaitForLinkSameAsBackToPlayOut = /** @class */ (function (_super) {
|
|
7449
7218
|
__extends(WaitForLinkSameAsBackToPlayOut, _super);
|
|
7450
7219
|
function WaitForLinkSameAsBackToPlayOut(context, startingUrl, clickedLinkUrl) {
|
|
@@ -7718,6 +7487,143 @@
|
|
|
7718
7487
|
PlaceAccessGuard.NoAuth = NoAuth;
|
|
7719
7488
|
})(exports.PlaceAccessGuard || (exports.PlaceAccessGuard = {}));
|
|
7720
7489
|
|
|
7490
|
+
exports.PlaceHistory = /** @class */ (function () {
|
|
7491
|
+
function PlaceHistory() {
|
|
7492
|
+
this._archive = new Map();
|
|
7493
|
+
this.placeHistoryDepth = 4;
|
|
7494
|
+
}
|
|
7495
|
+
PlaceHistory.prototype.notifyNavigationStarted = function () {
|
|
7496
|
+
if (this._activeVisits) {
|
|
7497
|
+
this.archive(this._activeVisits.visits);
|
|
7498
|
+
this._previousVisits = this._activeVisits;
|
|
7499
|
+
}
|
|
7500
|
+
};
|
|
7501
|
+
PlaceHistory.prototype.notifyNavigationFinished = function (visits) {
|
|
7502
|
+
this._activeVisits = new PlaceHistory.VisitRecord(visits);
|
|
7503
|
+
};
|
|
7504
|
+
PlaceHistory.prototype.updateVisit = function (visit) {
|
|
7505
|
+
pectin.assert.isTruthy(this._activeVisits);
|
|
7506
|
+
this._activeVisits.update(visit);
|
|
7507
|
+
};
|
|
7508
|
+
PlaceHistory.prototype.lastVisitIncluded = function (placeDef) {
|
|
7509
|
+
var _a;
|
|
7510
|
+
return !!((_a = this._previousVisits) === null || _a === void 0 ? void 0 : _a.getVisitFor(placeDef));
|
|
7511
|
+
};
|
|
7512
|
+
PlaceHistory.prototype.getMostRecentVisitFor = function (placeDef) {
|
|
7513
|
+
return ___default['default'].first(this.getHistory(placeDef));
|
|
7514
|
+
};
|
|
7515
|
+
PlaceHistory.prototype.getHistory = function (placeDef) {
|
|
7516
|
+
var history = this._archive.get(placeDef);
|
|
7517
|
+
if (!history) {
|
|
7518
|
+
history = [];
|
|
7519
|
+
this.setHistory(placeDef, history);
|
|
7520
|
+
}
|
|
7521
|
+
return history;
|
|
7522
|
+
};
|
|
7523
|
+
PlaceHistory.prototype.setHistory = function (placeDef, history) {
|
|
7524
|
+
this._archive.set(placeDef, history);
|
|
7525
|
+
};
|
|
7526
|
+
PlaceHistory.prototype.archive = function (visits) {
|
|
7527
|
+
var _this = this;
|
|
7528
|
+
visits.forEach(function (state) {
|
|
7529
|
+
var history = _this.getHistory(state.placeDefinition);
|
|
7530
|
+
var previousState = ___default['default'].first(history);
|
|
7531
|
+
if (!previousState || state.hasChangedFrom(previousState)) {
|
|
7532
|
+
history.unshift(state); // LIFO
|
|
7533
|
+
_this.setHistory(state.placeDefinition, history.slice(0, _this.placeHistoryDepth));
|
|
7534
|
+
}
|
|
7535
|
+
});
|
|
7536
|
+
};
|
|
7537
|
+
return PlaceHistory;
|
|
7538
|
+
}());
|
|
7539
|
+
exports.PlaceHistory.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PlaceHistory_Factory() { return new exports.PlaceHistory(); }, token: exports.PlaceHistory, providedIn: "root" });
|
|
7540
|
+
exports.PlaceHistory.decorators = [
|
|
7541
|
+
{ type: i0.Injectable, args: [{
|
|
7542
|
+
providedIn: 'root'
|
|
7543
|
+
},] }
|
|
7544
|
+
];
|
|
7545
|
+
exports.PlaceHistory.ctorParameters = function () { return []; };
|
|
7546
|
+
(function (PlaceHistory) {
|
|
7547
|
+
var VisitRecord = /** @class */ (function () {
|
|
7548
|
+
function VisitRecord(visits) {
|
|
7549
|
+
this.visits = visits;
|
|
7550
|
+
}
|
|
7551
|
+
VisitRecord.prototype.update = function (visit) {
|
|
7552
|
+
this.visits = this.visits.filter(function (v) { return v.placeDefinition !== visit.placeDefinition; }).concat(visit);
|
|
7553
|
+
};
|
|
7554
|
+
VisitRecord.prototype.getVisitFor = function (placeDef) {
|
|
7555
|
+
return this.visits.find(function (v) { return v.placeDefinition === placeDef; });
|
|
7556
|
+
};
|
|
7557
|
+
return VisitRecord;
|
|
7558
|
+
}());
|
|
7559
|
+
PlaceHistory.VisitRecord = VisitRecord;
|
|
7560
|
+
// export class Query {
|
|
7561
|
+
// private _history: Visit.State[];
|
|
7562
|
+
// private _places: Place[];
|
|
7563
|
+
// private _predicate: (visit: any) => boolean;
|
|
7564
|
+
// private _limit: number;
|
|
7565
|
+
//
|
|
7566
|
+
// constructor(history, limit = history.length) {
|
|
7567
|
+
// this._history = history;
|
|
7568
|
+
// this._places = [];
|
|
7569
|
+
// this._predicate = (visit => true);
|
|
7570
|
+
// this._limit = limit;
|
|
7571
|
+
// }
|
|
7572
|
+
//
|
|
7573
|
+
// to(...places:Place[]):this {
|
|
7574
|
+
// this._places = places;
|
|
7575
|
+
// return this;
|
|
7576
|
+
// }
|
|
7577
|
+
//
|
|
7578
|
+
// with(parameters: { [parameter: string]: any }): this {
|
|
7579
|
+
// this.matching(state => {
|
|
7580
|
+
// return Object.keys(parameters).reduce((acc, key) => {
|
|
7581
|
+
// const matchValue = parameters[key];
|
|
7582
|
+
// const visitValue = state.get(key);
|
|
7583
|
+
// const matched = matchValue === '*' ? !_.isNil(visitValue) : visitValue == matchValue;
|
|
7584
|
+
// // Logger.get(this).info(`matched=${matched}`, parameters, visitValue);
|
|
7585
|
+
// return acc && matched;
|
|
7586
|
+
// }, true);
|
|
7587
|
+
// });
|
|
7588
|
+
// return this;
|
|
7589
|
+
// }
|
|
7590
|
+
//
|
|
7591
|
+
// last(): Visit.State {
|
|
7592
|
+
// return _.findLast(this._history, visit => this._matches(visit))
|
|
7593
|
+
// }
|
|
7594
|
+
//
|
|
7595
|
+
// // @trace
|
|
7596
|
+
// allThatMatch(): Visit.State[] {
|
|
7597
|
+
// return _.filter(this._history, visit => this._matches(visit)).slice(-this._limit);
|
|
7598
|
+
// }
|
|
7599
|
+
//
|
|
7600
|
+
// // @trace
|
|
7601
|
+
// mostRecentValueOf<T=any>(param: string, defaultValue: T = null): T {
|
|
7602
|
+
// const lastStateWithParam = _.findLast(this.allThatMatch(), state => !_.isNil(state.get(param)));
|
|
7603
|
+
// return _.isNil(lastStateWithParam) ? defaultValue : lastStateWithParam.get(param);
|
|
7604
|
+
// }
|
|
7605
|
+
//
|
|
7606
|
+
// limit(limit: number): this {
|
|
7607
|
+
// this._limit = limit;
|
|
7608
|
+
// return this;
|
|
7609
|
+
// }
|
|
7610
|
+
//
|
|
7611
|
+
// matching(predicate: (visit: Visit.State) => boolean): this {
|
|
7612
|
+
// this._predicate = predicate;
|
|
7613
|
+
// return this;
|
|
7614
|
+
// }
|
|
7615
|
+
//
|
|
7616
|
+
// _matches(visit: Visit.State) {
|
|
7617
|
+
// return this._isPlaceMatch(visit) && this._predicate(visit);
|
|
7618
|
+
// }
|
|
7619
|
+
//
|
|
7620
|
+
// _isPlaceMatch(visit: Visit.State) {
|
|
7621
|
+
// return this._places.length < 1 || this._places.includes(visit.place)
|
|
7622
|
+
// }
|
|
7623
|
+
//
|
|
7624
|
+
// }
|
|
7625
|
+
})(exports.PlaceHistory || (exports.PlaceHistory = {}));
|
|
7626
|
+
|
|
7721
7627
|
exports.UrlSnapshot = /** @class */ (function () {
|
|
7722
7628
|
// TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
|
|
7723
7629
|
function UrlSnapshot(urlSerializer, url) {
|
|
@@ -8243,6 +8149,75 @@
|
|
|
8243
8149
|
PlaceRouter.State = State;
|
|
8244
8150
|
})(exports.PlaceRouter || (exports.PlaceRouter = {}));
|
|
8245
8151
|
|
|
8152
|
+
var Visit = /** @class */ (function () {
|
|
8153
|
+
function Visit(placeDefinition, visitParameters) {
|
|
8154
|
+
if (visitParameters === void 0) { visitParameters = {}; }
|
|
8155
|
+
this.placeDefinition = placeDefinition;
|
|
8156
|
+
this.visitParameters = visitParameters;
|
|
8157
|
+
}
|
|
8158
|
+
// @Trace()
|
|
8159
|
+
Visit.prototype.getRouteId = function () {
|
|
8160
|
+
return this.placeDefinition.getRouteIdFrom(this);
|
|
8161
|
+
};
|
|
8162
|
+
// @Trace()
|
|
8163
|
+
Visit.prototype.hasRouteId = function () {
|
|
8164
|
+
return !___namespace.isNil(this.getRouteId());
|
|
8165
|
+
};
|
|
8166
|
+
/**
|
|
8167
|
+
* Returns the value of the place parameter with the specified name. The parameter
|
|
8168
|
+
* name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
|
|
8169
|
+
* same as the the ValueModel property name.
|
|
8170
|
+
* @param parameterName the field name of the property model or the `as` option if specified.
|
|
8171
|
+
*/
|
|
8172
|
+
Visit.prototype.getParameter = function (parameterName) {
|
|
8173
|
+
return this.visitParameters[parameterName];
|
|
8174
|
+
};
|
|
8175
|
+
// @Trace()
|
|
8176
|
+
Visit.prototype.hasParameter = function (parameterName) {
|
|
8177
|
+
return Object.keys(this.visitParameters).includes(parameterName);
|
|
8178
|
+
};
|
|
8179
|
+
Visit.prototype.replace = function (parameter, value) {
|
|
8180
|
+
var _a;
|
|
8181
|
+
return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), (_a = {}, _a[parameter.name] = value, _a)));
|
|
8182
|
+
};
|
|
8183
|
+
Visit.prototype.mergeRouteParameters = function (routeParams) {
|
|
8184
|
+
var _this = this;
|
|
8185
|
+
// todo: whitelist parameters.
|
|
8186
|
+
var routeParameterKeys = Object.keys(routeParams);
|
|
8187
|
+
var params = {};
|
|
8188
|
+
this.placeDefinition.getVisitParameterDefs().forEach(function (def) {
|
|
8189
|
+
if (def.isRouteId || def.isRouteParameter) {
|
|
8190
|
+
if (routeParameterKeys.includes(def.name)) {
|
|
8191
|
+
params[def.name] = routeParams[def.name];
|
|
8192
|
+
}
|
|
8193
|
+
}
|
|
8194
|
+
else {
|
|
8195
|
+
// copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
|
|
8196
|
+
// defaults and remember sanitisation process.
|
|
8197
|
+
var value = _this.getParameter(def.name);
|
|
8198
|
+
if (_this.hasParameter(def.name)) {
|
|
8199
|
+
params[def.name] = value;
|
|
8200
|
+
}
|
|
8201
|
+
}
|
|
8202
|
+
});
|
|
8203
|
+
return new Visit(this.placeDefinition, params);
|
|
8204
|
+
};
|
|
8205
|
+
Visit.prototype.hasRoutingChangedFrom = function (other) {
|
|
8206
|
+
var samePlace = other.placeDefinition === this.placeDefinition;
|
|
8207
|
+
var sameRouteParameters = ___namespace.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
|
|
8208
|
+
return !samePlace || !sameRouteParameters;
|
|
8209
|
+
};
|
|
8210
|
+
Visit.prototype.hasChangedFrom = function (other) {
|
|
8211
|
+
var sameNonRouteParameters = ___namespace.isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
|
|
8212
|
+
return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
|
|
8213
|
+
};
|
|
8214
|
+
Visit.prototype.toDebugString = function () {
|
|
8215
|
+
var _this = this;
|
|
8216
|
+
return Object.keys(this.visitParameters).map(function (k) { return k + "=" + _this.visitParameters[k]; }).join(',');
|
|
8217
|
+
};
|
|
8218
|
+
return Visit;
|
|
8219
|
+
}());
|
|
8220
|
+
|
|
8246
8221
|
var AUP_PLACE_CONFIG = new i0.InjectionToken('AUP_PLACE_CONFIG');
|
|
8247
8222
|
|
|
8248
8223
|
var NotAuthorisedNoticeComponent = /** @class */ (function () {
|