@coolon/angular-ui-powerups 0.0.123 → 0.0.126

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.
@@ -3,13 +3,12 @@
3
3
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4
4
  */
5
5
  import * as tslib_1 from "tslib";
6
- import { assert, Binding, DebugContext, lang, Trace } from '@coolon/pectin';
6
+ import { assert, Binding, DebugContext, lang } from '@coolon/pectin';
7
7
  import { Klass } from '@coolon/typescript-utilities';
8
8
  import { Memoize } from '@typescript-plus/fast-memoize-decorator';
9
9
  import 'reflect-metadata';
10
10
  import { DisposableComponent } from '../components/disposable-component';
11
11
  import { PlaceDefinition } from './place-definition';
12
- import { ParameterDefinition } from './route/parameter-definition.class';
13
12
  // RAKE: making this Symbol(...) broke things.
14
13
  /** @type {?} */
15
14
  export const DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';
@@ -36,6 +35,7 @@ export class PlaceComponent extends DisposableComponent {
36
35
  this.installBinding(parameterDef);
37
36
  }));
38
37
  }
38
+ // @Trace()
39
39
  /**
40
40
  * @private
41
41
  * @template T, S
@@ -97,12 +97,6 @@ export class PlaceComponent extends DisposableComponent {
97
97
  onPlaceReady() {
98
98
  }
99
99
  }
100
- tslib_1.__decorate([
101
- Trace(),
102
- tslib_1.__metadata("design:type", Function),
103
- tslib_1.__metadata("design:paramtypes", [ParameterDefinition]),
104
- tslib_1.__metadata("design:returntype", void 0)
105
- ], PlaceComponent.prototype, "installBinding", null);
106
100
  tslib_1.__decorate([
107
101
  Memoize(),
108
102
  tslib_1.__metadata("design:type", PlaceDefinition),
@@ -1 +1 @@
1
- {"version":3,"file":"place-component.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/place-component.ts"],"names":[],"mappings":";;;;;AACA,OAAO,EACL,MAAM,EACN,OAAO,EAEP,YAAY,EAEZ,IAAI,EAAE,KA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sB,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACtF,CAAC;IAFe,0CAA2B,8BAE1C,CAAA;;;;;IAED,SAAgB,kBAAkB,CAAC,KAAoC;QACrE,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC;IACpE,CAAC;IAFe,iCAAkB,qBAEjC,CAAA;;;;;IAED,SAAgB,aAAa,CAAC,KAAoC;QAChE,OAAO,OAAO,CAAC,WAAW,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IAFe,4BAAa,gBAE5B,CAAA;;;;;;IAED,SAAgB,gBAAgB,CAAC,KAAoC,EAAE,UAA2B;QAChG,OAAO,CAAC,cAAc,CAAC,wBAAwB,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAFe,+BAAgB,mBAE/B,CAAA;AAEH,CAAC,EAlBgB,cAAc,KAAd,cAAc,QAkB9B","sourcesContent":["import { AfterViewInit } from '@angular/core';\nimport {\n assert,\n Binding,\n Constructable,\n DebugContext,\n IMutableHasValue,\n lang, Trace,\n TransactionObserver,\n ValueModel\n} from '@coolon/pectin';\nimport { Klass } from '@coolon/typescript-utilities';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator';\nimport 'reflect-metadata';\nimport { DisposableComponent } from '../components/disposable-component';\nimport { InteractionContext } from '../interaction/interaction-context';\nimport { PlaceDefinition } from './place-definition';\nimport { ParameterDefinition } from './route/parameter-definition.class';\nimport { Visit } from './visit';\n\n// RAKE: making this Symbol(...) broke things.\nexport const DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';\n// this one seems ok.\nexport const ROUTE_PARAMETER_LIST_KEY = Symbol('place:route:parameters');\n\nexport class PlaceComponent extends DisposableComponent {\n\n private visit: ValueModel<Visit>;\n // private _inDeactivationGuard = new MutableValueModel<boolean>(false);\n\n interactionContext?: InteractionContext;\n\n canDeactivate?(interactionContext: InteractionContext): boolean | Promise<boolean>;\n\n constructor() {\n super();\n }\n\n public initialiseVisit(visit: ValueModel<Visit>) {\n assert.isNil(this.visit);\n this.visit = visit;\n DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);\n this.placeDefinition.getVisitParameterDefs().forEach(parameterDef => {\n this.installBinding(parameterDef);\n });\n }\n\n @Trace()\n private installBinding<T, S>(parameterDef: ParameterDefinition<T, S>) {\n const model = this[parameterDef.propertyName] as IMutableHasValue<S>;\n DebugContext.tag(model, `${this.placeDefinition.component.name}.${parameterDef.propertyName}`);\n const binding = this.registerDisposable(new Binding(this.visit, model, {\n toRight(visit: Visit): S {\n const value = visit.getParameter(parameterDef.name);\n console.log('push to component', {name:parameterDef.name, value, visit});\n return value;\n },\n toLeft(value: S, currentVisit?: Visit): Visit {\n console.log('push to route', { name: parameterDef.name, value, currentVisit });\n return currentVisit.replace(parameterDef, value);\n }\n }));\n setTimeout(() => {\n binding.writeRight();\n })\n }\n\n @Memoize()\n get placeDefinition(): PlaceDefinition {\n return PlaceComponent.getDefinition(this.constructor as any as Constructable<PlaceComponent>);\n }\n\n get childPlaces(): Constructable<PlaceComponent>[] {\n return this.placeDefinition.children.map(d => d.component);\n }\n\n onPlaceReady() {\n }\n\n}\n\nexport namespace PlaceComponent {\n\n export function isPlaceComponentConstructor(target: any): target is Constructable<PlaceComponent> {\n return lang.constructorChain(target as Constructable<any>).includes(PlaceComponent);\n }\n\n export function getRouteParameters(klass: Constructable<PlaceComponent>): ParameterDefinition<any>[] {\n return Klass.get(klass).getMetadataList(ROUTE_PARAMETER_LIST_KEY);\n }\n\n export function getDefinition(klass: Constructable<PlaceComponent>): PlaceDefinition {\n return Reflect.getMetadata(DEFINITION_META_DATA_KEY, klass);\n }\n\n export function injectDefinition(klass: Constructable<PlaceComponent>, definition: PlaceDefinition) {\n Reflect.defineMetadata(DEFINITION_META_DATA_KEY, definition, klass);\n }\n\n}\n"]}
1
+ {"version":3,"file":"place-component.js","sourceRo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AAA,MAAM,EAAsB,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACtF,CAAC;IAFe,0CAA2B,8BAE1C,CAAA;;;;;IAED,SAAgB,kBAAkB,CAAC,KAAoC;QACrE,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC;IACpE,CAAC;IAFe,iCAAkB,qBAEjC,CAAA;;;;;IAED,SAAgB,aAAa,CAAC,KAAoC;QAChE,OAAO,OAAO,CAAC,WAAW,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IAFe,4BAAa,gBAE5B,CAAA;;;;;;IAED,SAAgB,gBAAgB,CAAC,KAAoC,EAAE,UAA2B;QAChG,OAAO,CAAC,cAAc,CAAC,wBAAwB,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAFe,+BAAgB,mBAE/B,CAAA;AAEH,CAAC,EAlBgB,cAAc,KAAd,cAAc,QAkB9B","sourcesContent":["import { AfterViewInit } from '@angular/core';\nimport {\n assert,\n Binding,\n Constructable,\n DebugContext,\n IMutableHasValue,\n lang, Trace,\n TransactionObserver,\n ValueModel\n} from '@coolon/pectin';\nimport { Klass } from '@coolon/typescript-utilities';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator';\nimport 'reflect-metadata';\nimport { DisposableComponent } from '../components/disposable-component';\nimport { InteractionContext } from '../interaction/interaction-context';\nimport { PlaceDefinition } from './place-definition';\nimport { ParameterDefinition } from './route/parameter-definition.class';\nimport { Visit } from './visit';\n\n// RAKE: making this Symbol(...) broke things.\nexport const DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';\n// this one seems ok.\nexport const ROUTE_PARAMETER_LIST_KEY = Symbol('place:route:parameters');\n\nexport class PlaceComponent extends DisposableComponent {\n\n private visit: ValueModel<Visit>;\n // private _inDeactivationGuard = new MutableValueModel<boolean>(false);\n\n interactionContext?: InteractionContext;\n\n canDeactivate?(interactionContext: InteractionContext): boolean | Promise<boolean>;\n\n constructor() {\n super();\n }\n\n public initialiseVisit(visit: ValueModel<Visit>) {\n assert.isNil(this.visit);\n this.visit = visit;\n DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);\n this.placeDefinition.getVisitParameterDefs().forEach(parameterDef => {\n this.installBinding(parameterDef);\n });\n }\n\n // @Trace()\n private installBinding<T, S>(parameterDef: ParameterDefinition<T, S>) {\n const model = this[parameterDef.propertyName] as IMutableHasValue<S>;\n DebugContext.tag(model, `${this.placeDefinition.component.name}.${parameterDef.propertyName}`);\n const binding = this.registerDisposable(new Binding(this.visit, model, {\n toRight(visit: Visit): S {\n const value = visit.getParameter(parameterDef.name);\n console.log('push to component', {name:parameterDef.name, value, visit});\n return value;\n },\n toLeft(value: S, currentVisit?: Visit): Visit {\n console.log('push to route', { name: parameterDef.name, value, currentVisit });\n return currentVisit.replace(parameterDef, value);\n }\n }));\n setTimeout(() => {\n binding.writeRight();\n })\n }\n\n @Memoize()\n get placeDefinition(): PlaceDefinition {\n return PlaceComponent.getDefinition(this.constructor as any as Constructable<PlaceComponent>);\n }\n\n get childPlaces(): Constructable<PlaceComponent>[] {\n return this.placeDefinition.children.map(d => d.component);\n }\n\n onPlaceReady() {\n }\n\n}\n\nexport namespace PlaceComponent {\n\n export function isPlaceComponentConstructor(target: any): target is Constructable<PlaceComponent> {\n return lang.constructorChain(target as Constructable<any>).includes(PlaceComponent);\n }\n\n export function getRouteParameters(klass: Constructable<PlaceComponent>): ParameterDefinition<any>[] {\n return Klass.get(klass).getMetadataList(ROUTE_PARAMETER_LIST_KEY);\n }\n\n export function getDefinition(klass: Constructable<PlaceComponent>): PlaceDefinition {\n return Reflect.getMetadata(DEFINITION_META_DATA_KEY, klass);\n }\n\n export function injectDefinition(klass: Constructable<PlaceComponent>, definition: PlaceDefinition) {\n Reflect.defineMetadata(DEFINITION_META_DATA_KEY, definition, klass);\n }\n\n}\n"]}
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"DEFINITION_META_DATA_KEY":"PLACE_DEFINITION_OPTIONS","ROUTE_PARAMETER_LIST_KEY":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Symbol"},"arguments":["place:route:parameters"]},"PlaceComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../components/disposable-component","name":"DisposableComponent","line":25,"character":36},"members":{"canDeactivate":[{"__symbolic":"method"}],"__ctor__":[{"__symbolic":"constructor"}],"initialiseVisit":[{"__symbolic":"method"}],"installBinding":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"Trace","line":47,"character":3}}]}],"placeDefinition":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@typescript-plus/fast-memoize-decorator","name":"Memoize","line":67,"character":3}}]}],"onPlaceReady":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"DEFINITION_META_DATA_KEY":"PLACE_DEFINITION_OPTIONS","ROUTE_PARAMETER_LIST_KEY":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Symbol"},"arguments":["place:route:parameters"]},"PlaceComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../components/disposable-component","name":"DisposableComponent","line":25,"character":36},"members":{"canDeactivate":[{"__symbolic":"method"}],"__ctor__":[{"__symbolic":"constructor"}],"initialiseVisit":[{"__symbolic":"method"}],"installBinding":[{"__symbolic":"method"}],"placeDefinition":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@typescript-plus/fast-memoize-decorator","name":"Memoize","line":67,"character":3}}]}],"onPlaceReady":[{"__symbolic":"method"}]}}}}]
@@ -2,7 +2,7 @@
2
2
  * @fileoverview added by tsickle
3
3
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4
4
  */
5
- import { Binding, DebugContext, Logger, MutableListModel, MutableValueModel, UseDelegate } from '@coolon/pectin';
5
+ import { Binding, DebugContext, Logger, MutableListModel, MutableValueModel } from '@coolon/pectin';
6
6
  import { Klass, Opts } from '@coolon/typescript-utilities';
7
7
  import { ROUTE_PARAMETER_LIST_KEY } from '../place-component';
8
8
  import { ParameterDefinition } from './parameter-definition.class';
@@ -55,6 +55,57 @@ if (false) {
55
55
  /** @type {?|undefined} */
56
56
  RouteListParameterOptions.prototype.storeInUrl;
57
57
  }
58
+ /**
59
+ * @template M
60
+ * @param {?} prototype
61
+ * @param {?} propertyKey
62
+ * @param {?} backingModel
63
+ * @param {?} tagPrefix
64
+ * @param {?} isEmpty
65
+ * @return {?}
66
+ */
67
+ function installMechanics(prototype, propertyKey, backingModel, tagPrefix, isEmpty) {
68
+ /** @type {?} */
69
+ const mechanics = {
70
+ backingModel: backingModel,
71
+ binding: (/** @type {?} */ (null))
72
+ };
73
+ /** @type {?} */
74
+ const tag = `${tagPrefix}(${prototype.constructor.name}.${propertyKey.toString()})`;
75
+ DebugContext.get(mechanics.backingModel).tag(tag);
76
+ Logger.get(mechanics.backingModel).tag(tag);
77
+ Object.defineProperty(prototype, propertyKey, {
78
+ get: (/**
79
+ * @return {?}
80
+ */
81
+ function () {
82
+ return mechanics.backingModel;
83
+ }),
84
+ set: (/**
85
+ * @param {?} userModel
86
+ * @return {?}
87
+ */
88
+ function (userModel) {
89
+ // This handles the scenario where we want to push an existing value model (such as a form model)
90
+ // to and from the route.
91
+ if (mechanics.binding) {
92
+ mechanics.binding.dispose();
93
+ }
94
+ if (userModel) {
95
+ mechanics.binding = new Binding(mechanics.backingModel, userModel);
96
+ if (isEmpty(userModel)) {
97
+ mechanics.binding.writeRight(); // push the visit into the user model;
98
+ }
99
+ else {
100
+ if (!isEmpty(mechanics.backingModel)) {
101
+ console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
102
+ }
103
+ mechanics.binding.writeLeft(); // push the user model into the visit
104
+ }
105
+ }
106
+ })
107
+ });
108
+ }
58
109
  /**
59
110
  * @template T
60
111
  * @param {?} type
@@ -71,8 +122,11 @@ export function RouteId(type, options) {
71
122
  /** @type {?} */
72
123
  const param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);
73
124
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
74
- UseDelegate({ tag: `@RouteId(${prototype.constructor.name}.${propertyKey.toString()})` })(prototype, propertyKey);
75
- // UseDelegate()(prototype, propertyKey);
125
+ installMechanics(prototype, propertyKey, new MutableValueModel(), "@RouteId", (/**
126
+ * @param {?} m
127
+ * @return {?}
128
+ */
129
+ m => m.query().isNil()));
76
130
  });
77
131
  }
78
132
  /**
@@ -92,46 +146,11 @@ export function VisitParameter(options) {
92
146
  /** @type {?} */
93
147
  const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
94
148
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
95
- /** @type {?} */
96
- const mechanics = {
97
- backingModel: new MutableValueModel(),
98
- binding: (/** @type {?} */ (null))
99
- };
100
- /** @type {?} */
101
- const tag = `@VisitParameter(${prototype.constructor.name}.${propertyKey.toString()})`;
102
- DebugContext.get(mechanics.backingModel).tag(tag);
103
- Logger.get(mechanics.backingModel).tag(tag);
104
- Object.defineProperty(prototype, propertyKey, {
105
- get: (/**
106
- * @return {?}
107
- */
108
- function () {
109
- return mechanics.backingModel;
110
- }),
111
- set: (/**
112
- * @param {?} userModel
113
- * @return {?}
114
- */
115
- function (userModel) {
116
- // This handles the scenario where we want to push an existing value model (such as a form model)
117
- // to and from the route.
118
- if (mechanics.binding) {
119
- mechanics.binding.dispose();
120
- }
121
- if (userModel) {
122
- mechanics.binding = new Binding(mechanics.backingModel, userModel);
123
- if (userModel.query().isNil()) {
124
- mechanics.binding.writeRight(); // push the visit into the user model;
125
- }
126
- else {
127
- if (!mechanics.backingModel.query().isNil()) {
128
- console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
129
- }
130
- mechanics.binding.writeLeft(); // push the user model into the visit
131
- }
132
- }
133
- })
134
- });
149
+ installMechanics(prototype, propertyKey, new MutableValueModel(), "@VisitParameter", (/**
150
+ * @param {?} m
151
+ * @return {?}
152
+ */
153
+ m => m.query().isNil()));
135
154
  });
136
155
  }
137
156
  /**
@@ -151,46 +170,11 @@ export function VisitParameterList(options) {
151
170
  /** @type {?} */
152
171
  const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
153
172
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
154
- /** @type {?} */
155
- const mechanics = {
156
- backingModel: new MutableListModel(),
157
- binding: (/** @type {?} */ (null))
158
- };
159
- /** @type {?} */
160
- const tag = `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})`;
161
- DebugContext.get(mechanics.backingModel).tag(tag);
162
- Logger.get(mechanics.backingModel).tag(tag);
163
- Object.defineProperty(prototype, propertyKey, {
164
- get: (/**
165
- * @return {?}
166
- */
167
- function () {
168
- return mechanics.backingModel;
169
- }),
170
- set: (/**
171
- * @param {?} userModel
172
- * @return {?}
173
- */
174
- function (userModel) {
175
- // This handles the scenario where we want to push an existing value model (such as a form model)
176
- // to and from the route.
177
- if (mechanics.binding) {
178
- mechanics.binding.dispose();
179
- }
180
- if (userModel) {
181
- mechanics.binding = new Binding(mechanics.backingModel, userModel);
182
- if (userModel.query().isEmpty()) {
183
- mechanics.binding.writeRight(); // push the visit into the user model;
184
- }
185
- else {
186
- if (!mechanics.backingModel.query().isEmpty()) {
187
- console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
188
- }
189
- mechanics.binding.writeLeft(); // push the user model into the visit
190
- }
191
- }
192
- })
193
- });
173
+ installMechanics(prototype, propertyKey, new MutableListModel(), "@VisitParameterList", (/**
174
+ * @param {?} m
175
+ * @return {?}
176
+ */
177
+ m => m.query().isEmpty()));
194
178
  });
195
179
  }
196
180
  //# sourceMappingURL=parameter-decorators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parameter-decorators.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/route/parameter-decorators.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;;;;;AAGnE,oCAMC;;;IALC,4BAAY;;IACZ,kCAAmB;;IACnB,kCAAmB;;IACnB,sCAAiB;;;;;;AAInB,2CAOC;;;IANC,mCAAY;;IACZ,yCAAmB;;IACnB,yCAAmB;;IACnB,6CAAiB;;IACjB,2CAAyB;;;;;;AAI3B,+CAOC;;;IANC,uCAAY;;IACZ,6CAAmB;;IACnB,6CAAmB;;IACnB,iDAAmB;;IACnB,+CAAyB;;;;;;;;AAI3B,MAAM,UAAU,OAAO,CAA4B,IAAkB,EAAE,OAA2B;IAChG;;;;;IAAO,CAAC,SAAiB,EAAE,WAA4B,EAAE,EAAE;;cACnD,KAAK,GAAG,IAAI,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC;QACpF,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC3E,WAAW,CAAC,EAAE,GAAG,EAAE,YAAY,SAAS,CAAC,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAClH,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E,WAAW,EAAE;YAC5C,GAAG;;;YAAE;gBACH,OAAO,SAAS,CAAC,YAAY,CAAC;YAChC,CAAC,CAAA;YACD,GAAG;;;;YAAE,UAAS,SAA8B;gBAC1C,iGAAiG;gBACjG,yBAAyB;gBACzB,IAAI,SAAS,CAAC,OAAO,EAAE;oBACrB,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;iBAC7B;gBACD,IAAI,SAAS,EAAE;oBACb,SAAS,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;oBACnE,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE;wBAC/B,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,sCAAsC;qBACvE;yBAAM;wBACL,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE;4BAC7C,OAAO,CAAC,IAAI,CAAC,iIAAiI,CAAC,CAAC;yBACjJ;wBACD,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,qCAAqC;qBACrE;iBACF;YACH,CAAC,CAAA;SACF,CAAC,CAAC;IAEL,CAAC,EAAC;AACJ,CAAC","sourcesContent":["import { Binding, DebugContext, Logger, MutableListModel, MutableValueModel, UseDelegate } from '@coolon/pectin';\nimport { Klass, Opts } from '@coolon/typescript-utilities';\nimport { ROUTE_PARAMETER_LIST_KEY } from '../place-component';\nimport { Formatter } from './formatter';\nimport { ParameterDefinition } from './parameter-definition.class';\n\n\nexport interface RouteIdOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteListParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T[];\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T[]>> | ParameterSanitiser<T[]>;\n}\n\nexport function RouteId<T extends string | number>(type: Formatter<T>, options?: RouteIdOptions<T>): PropertyDecorator {\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n UseDelegate({ tag: `@RouteId(${prototype.constructor.name}.${propertyKey.toString()})` })(prototype, propertyKey);\n // UseDelegate()(prototype, propertyKey);\n };\n}\n\nexport function VisitParameter<T>(options?: RouteParameterOptions<T>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n const mechanics = {\n backingModel: new MutableValueModel<T>(),\n binding: null as Binding<T, T>\n };\n const tag = `@VisitParameter(${prototype.constructor.name}.${propertyKey.toString()})`;\n DebugContext.get(mechanics.backingModel).tag(tag);\n Logger.get(mechanics.backingModel).tag(tag);\n Object.defineProperty(prototype, propertyKey, {\n get: function() {\n return mechanics.backingModel;\n },\n set: function(userModel: MutableValueModel<T>) {\n // This handles the scenario where we want to push an existing value model (such as a form model)\n // to and from the route.\n if (mechanics.binding) {\n mechanics.binding.dispose();\n }\n if (userModel) {\n mechanics.binding = new Binding(mechanics.backingModel, userModel);\n if (userModel.query().isNil()) {\n mechanics.binding.writeRight(); // push the visit into the user model;\n } else {\n if (!mechanics.backingModel.query().isNil()) {\n console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');\n }\n mechanics.binding.writeLeft(); // push the user model into the visit\n }\n }\n }\n });\n };\n}\n\nexport function VisitParameterList<E>(options?: RouteListParameterOptions<E>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n const mechanics = {\n backingModel: new MutableListModel<E>(),\n binding: null as Binding<E[], E[]>\n };\n const tag = `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})`;\n DebugContext.get(mechanics.backingModel).tag(tag);\n Logger.get(mechanics.backingModel).tag(tag);\n Object.defineProperty(prototype, propertyKey, {\n get: function() {\n return mechanics.backingModel;\n },\n set: function(userModel: MutableListModel<E>) {\n // This handles the scenario where we want to push an existing value model (such as a form model)\n // to and from the route.\n if (mechanics.binding) {\n mechanics.binding.dispose();\n }\n if (userModel) {\n mechanics.binding = new Binding(mechanics.backingModel, userModel);\n if (userModel.query().isEmpty()) {\n mechanics.binding.writeRight(); // push the visit into the user model;\n } else {\n if (!mechanics.backingModel.query().isEmpty()) {\n console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');\n }\n mechanics.binding.writeLeft(); // push the user model into the visit\n }\n }\n }\n });\n\n };\n}\n\n// export function RouteParameter<T>(type: ParameterType<T>, options?: RouteParameterOptions<T>): PropertyDecorator {\n// return (prototype: Object, propertyKey: string | symbol) => {\n// const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, type);\n// Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n// UseDelegate()(prototype, propertyKey);\n// };\n// }\n//\n// export function RouteParameterList<E>(elementType: ParameterType<E>, options?: RouteListParameterOptions<E>): PropertyDecorator {\n// return (prototype: Object, propertyKey: string | symbol) => {\n// const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, elementType);\n// Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n// UseDelegate()(prototype, propertyKey);\n// };\n// }\n"]}
1
+ {"version":3,"file":"parameter-decorators.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/route/parameter-decorators.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EACL,OAAO,EACP,YAAY,EAEZ,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;;;;;AAGnE,oCAMC;;;IALC,4BAAY;;IACZ,kCAAmB;;IACnB,kCAAmB;;IACnB,sCAAiB;;;;;;AAInB,2CAOC;;;IANC,mCAAY;;IACZ,yCAAmB;;IACnB,yCAAmB;;IACnB,6CAAiB;;IACjB,2CAAyB;;;;;;AAI3B,+CAOC;;;IANC,uCAAY;;IACZ,6CAAmB;;IACnB,6CAAmB;;IACnB,iDAAmB;;IACnB,+CAAyB;;;;;;;;;;;AAK3B,SAAS,gBAAgB,CAA0B,SAAiB,EAAE,WAA4B,EAAE,YAAe,EAAE,SAAiB,EAAE,OAA6B;;UAC7J,SAAS,GAAG;QAChB,YAAY,EAAE,YAAY;QAC1B,OAAO,EAAE,mBAAA,IAAI,EAAqB;KACnC;;UACK,GAAG,GAAG,GAAG,SAAS,IAAI,SAAS,CAAC,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,QAAQ,EAAE,GAAG;IACnF,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,WAAW,EAAE;QA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Model,\n MutableValueModel,\n UseDelegate\n} from '@coolon/pectin';\nimport { Klass, Opts } from '@coolon/typescript-utilities';\nimport { ROUTE_PARAMETER_LIST_KEY } from '../place-component';\nimport { Formatter } from './formatter';\nimport { ParameterDefinition } from './parameter-definition.class';\n\n\nexport interface RouteIdOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteListParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T[];\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T[]>> | ParameterSanitiser<T[]>;\n}\n\n\nfunction installMechanics<M extends HasValue<any>>(prototype: Object, propertyKey: string | symbol, backingModel: M, tagPrefix: string, isEmpty: (mode: M) => boolean) {\n const mechanics = {\n backingModel: backingModel,\n binding: null as Binding<any, any>\n };\n const tag = `${tagPrefix}(${prototype.constructor.name}.${propertyKey.toString()})`;\n DebugContext.get(mechanics.backingModel).tag(tag);\n Logger.get(mechanics.backingModel).tag(tag);\n Object.defineProperty(prototype, propertyKey, {\n get: function() {\n return mechanics.backingModel;\n },\n set: function(userModel: M) {\n // This handles the scenario where we want to push an existing value model (such as a form model)\n // to and from the route.\n if (mechanics.binding) {\n mechanics.binding.dispose();\n }\n if (userModel) {\n mechanics.binding = new Binding(mechanics.backingModel, userModel);\n if (isEmpty(userModel)) {\n mechanics.binding.writeRight(); // push the visit into the user model;\n } else {\n if (!isEmpty(mechanics.backingModel)) {\n console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');\n }\n mechanics.binding.writeLeft(); // push the user model into the visit\n }\n }\n }\n });\n}\n\nexport function RouteId<T extends string | number>(type: Formatter<T>, options?: RouteIdOptions<T>): PropertyDecorator {\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n installMechanics(prototype, propertyKey, new MutableValueModel<T>(), \"@RouteId\", m => m.query().isNil());\n };\n}\n\nexport function VisitParameter<T>(options?: RouteParameterOptions<T>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n installMechanics(prototype, propertyKey, new MutableValueModel<T>(), \"@VisitParameter\", m => m.query().isNil());\n };\n}\n\nexport function VisitParameterList<E>(options?: RouteListParameterOptions<E>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n installMechanics(prototype, propertyKey, new MutableListModel<E>(), \"@VisitParameterList\", m => m.query().isEmpty());\n };\n}\n"]}
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"RouteIdOptions":{"__symbolic":"interface"},"RouteParameterOptions":{"__symbolic":"interface"},"RouteListParameterOptions":{"__symbolic":"interface"},"RouteId":{"__symbolic":"function","parameters":["type","options"],"value":{"__symbolic":"error","message":"Lambda not supported","line":34,"character":9}},"VisitParameter":{"__symbolic":"function"},"VisitParameterList":{"__symbolic":"function"}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"RouteIdOptions":{"__symbolic":"interface"},"RouteParameterOptions":{"__symbolic":"interface"},"RouteListParameterOptions":{"__symbolic":"interface"},"RouteId":{"__symbolic":"function","parameters":["type","options"],"value":{"__symbolic":"error","message":"Lambda not supported","line":76,"character":9}},"VisitParameter":{"__symbolic":"function"},"VisitParameterList":{"__symbolic":"function"}}}]
@@ -3,13 +3,12 @@
3
3
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4
4
  */
5
5
  import * as tslib_1 from "tslib";
6
- import { assert, Binding, DebugContext, lang, Trace } from '@coolon/pectin';
6
+ import { assert, Binding, DebugContext, lang } from '@coolon/pectin';
7
7
  import { Klass } from '@coolon/typescript-utilities';
8
8
  import { Memoize } from '@typescript-plus/fast-memoize-decorator';
9
9
  import 'reflect-metadata';
10
10
  import { DisposableComponent } from '../components/disposable-component';
11
11
  import { PlaceDefinition } from './place-definition';
12
- import { ParameterDefinition } from './route/parameter-definition.class';
13
12
  // RAKE: making this Symbol(...) broke things.
14
13
  /** @type {?} */
15
14
  export var DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';
@@ -42,13 +41,17 @@ var PlaceComponent = /** @class */ (function (_super) {
42
41
  _this.installBinding(parameterDef);
43
42
  }));
44
43
  };
44
+ // @Trace()
45
+ // @Trace()
45
46
  /**
46
47
  * @private
47
48
  * @template T, S
48
49
  * @param {?} parameterDef
49
50
  * @return {?}
50
51
  */
51
- PlaceComponent.prototype.installBinding = /**
52
+ PlaceComponent.prototype.installBinding =
53
+ // @Trace()
54
+ /**
52
55
  * @private
53
56
  * @template T, S
54
57
  * @param {?} parameterDef
@@ -119,12 +122,6 @@ var PlaceComponent = /** @class */ (function (_super) {
119
122
  */
120
123
  function () {
121
124
  };
122
- tslib_1.__decorate([
123
- Trace(),
124
- tslib_1.__metadata("design:type", Function),
125
- tslib_1.__metadata("design:paramtypes", [ParameterDefinition]),
126
- tslib_1.__metadata("design:returntype", void 0)
127
- ], PlaceComponent.prototype, "installBinding", null);
128
125
  tslib_1.__decorate([
129
126
  Memoize(),
130
127
  tslib_1.__metadata("design:type", PlaceDefinition),
@@ -1 +1 @@
1
- {"version":3,"file":"place-component.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/place-component.ts"],"names":[],"mappings":";;;;;AACA,OAAO,EACL,MAAM,EACN,OAAO,EAEP,YAAY,EAEZ,IAAI,EAAE,KAAK,EAGZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAClE,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;;;AAIzE,MAAM,KAAO,wBAAwB,GAAG,0BAA0B;;;AAElE,MAAM,KAAO,wBAAwB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AAExE;IAAoC,0CAAmB;IASrD;eACE,iBAAO;IACT,CAAC;;;;;IAEM,wCAAe;;;;IAAtB,UAAuB,KAAwB;QAA/C,iBAOC;QANC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAI,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,WAAQ,CAAC,CAAC;QACjF,IAAI,CAAC,eAAe,CAAC,qBAAqB,EAAE,CAAC,OAAO;;;;QAAC,UAAA,YAAY;YAC/D,KAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC,EAAC,CAAC;IACL,CAAC;;;;;;;IAGO,uCAAc;;;;;;IAAtB,UAA6B,YAAuC;;YAC5D,KAAK,GAAG,mBAAA,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,EAAuB;QACpE,YAAY,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EAAE;;iDACmC,mBAAmB;;wDAiB7D;IAGD;QADC,OAAO,EAAE;0CACa,eAAe;;yDAErC;IASH,qBAAC;CAAA,AAtDD,CAAoC,mBAAmB,GAsDtD;SAtDY,cAAc;;;;;;IAEzB,+BAAiC;;IAGjC,4CAAwC;;AAmD1C,WAAiB,cAAc;;;;;IAE7B,SAAgB,2BAA2B,CAAC,MAAW;QACrD,OAAO,IAAI,CAAC,gBAAgB,CAAC,mBAAA,MAAM,EAAsB,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACtF,CAAC;IAFe,0CAA2B,8BAE1C,CAAA;;;;;IAED,SAAgB,kBAAkB,CAAC,KAAoC;QACrE,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC;IACpE,CAAC;IAFe,iCAAkB,qBAEjC,CAAA;;;;;IAED,SAAgB,aAAa,CAAC,KAAoC;QAChE,OAAO,OAAO,CAAC,WAAW,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IAFe,4BAAa,gBAE5B,CAAA;;;;;;IAED,SAAgB,gBAAgB,CAAC,KAAoC,EAAE,UAA2B;QAChG,OAAO,CAAC,cAAc,CAAC,wBAAwB,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAFe,+BAAgB,mBAE/B,CAAA;AAEH,CAAC,EAlBgB,cAAc,KAAd,cAAc,QAkB9B","sourcesContent":["import { AfterViewInit } from '@angular/core';\nimport {\n assert,\n Binding,\n Constructable,\n DebugContext,\n IMutableHasValue,\n lang, Trace,\n TransactionObserver,\n ValueModel\n} from '@coolon/pectin';\nimport { Klass } from '@coolon/typescript-utilities';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator';\nimport 'reflect-metadata';\nimport { DisposableComponent } from '../components/disposable-component';\nimport { InteractionContext } from '../interaction/interaction-context';\nimport { PlaceDefinition } from './place-definition';\nimport { ParameterDefinition } from './route/parameter-definition.class';\nimport { Visit } from './visit';\n\n// RAKE: making this Symbol(...) broke things.\nexport const DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';\n// this one seems ok.\nexport const ROUTE_PARAMETER_LIST_KEY = Symbol('place:route:parameters');\n\nexport class PlaceComponent extends DisposableComponent {\n\n private visit: ValueModel<Visit>;\n // private _inDeactivationGuard = new MutableValueModel<boolean>(false);\n\n interactionContext?: InteractionContext;\n\n canDeactivate?(interactionContext: InteractionContext): boolean | Promise<boolean>;\n\n constructor() {\n super();\n }\n\n public initialiseVisit(visit: ValueModel<Visit>) {\n assert.isNil(this.visit);\n this.visit = visit;\n DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);\n this.placeDefinition.getVisitParameterDefs().forEach(parameterDef => {\n this.installBinding(parameterDef);\n });\n }\n\n @Trace()\n private installBinding<T, S>(parameterDef: ParameterDefinition<T, S>) {\n const model = this[parameterDef.propertyName] as IMutableHasValue<S>;\n DebugContext.tag(model, `${this.placeDefinition.component.name}.${parameterDef.propertyName}`);\n const binding = this.registerDisposable(new Binding(this.visit, model, {\n toRight(visit: Visit): S {\n const value = visit.getParameter(parameterDef.name);\n console.log('push to component', {name:parameterDef.name, value, visit});\n return value;\n },\n toLeft(value: S, currentVisit?: Visit): Visit {\n console.log('push to route', { name: parameterDef.name, value, currentVisit });\n return currentVisit.replace(parameterDef, value);\n }\n }));\n setTimeout(() => {\n binding.writeRight();\n })\n }\n\n @Memoize()\n get placeDefinition(): PlaceDefinition {\n return PlaceComponent.getDefinition(this.constructor as any as Constructable<PlaceComponent>);\n }\n\n get childPlaces(): Constructable<PlaceComponent>[] {\n return this.placeDefinition.children.map(d => d.component);\n }\n\n onPlaceReady() {\n }\n\n}\n\nexport namespace PlaceComponent {\n\n export function isPlaceComponentConstructor(target: any): target is Constructable<PlaceComponent> {\n return lang.constructorChain(target as Constructable<any>).includes(PlaceComponent);\n }\n\n export function getRouteParameters(klass: Constructable<PlaceComponent>): ParameterDefinition<any>[] {\n return Klass.get(klass).getMetadataList(ROUTE_PARAMETER_LIST_KEY);\n }\n\n export function getDefinition(klass: Constructable<PlaceComponent>): PlaceDefinition {\n return Reflect.getMetadata(DEFINITION_META_DATA_KEY, klass);\n }\n\n export function injectDefinition(klass: Constructable<PlaceComponent>, definition: PlaceDefinition) {\n Reflect.defineMetadata(DEFINITION_META_DATA_KEY, definition, klass);\n }\n\n}\n"]}
1
+ {"version":3,"file":"place-component.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/place-component.ts"],"names":[],"mappings":";;;;;AACA,OAAO,EACL,MAAM,EACN,OAAO,EAEP,YAAY,EAEZ,IAAI,EAGL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAClE,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;;;AAKrD,MAAM,KAAO,wBAAwB,GAAG,0BAA0B;;;AAElE,MAAM,KAAO,wBAAwB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AAExE;IAAoC,0CAAmB;IASrD;eACE,iBAAO;IACT,CAAC;;;;;IAEM,wCAAe;;;;IAAtB,UAAuB,KAAwB;QAA/C,iBAOC;QANC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAI,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,WAAQ,CAAC,CAAC;QACjF,IAAI,CAAC,eAAe,CAAC,qBAAqB,EAAE,CAAC,OAAO;;;;QAAC,UAAA,YAAY;YAC/D,KAAI,CAAC,cAAc,C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,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG;;;;YAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,SAAS,EAAX,CAAW,EAAC,CAAC;QAC7D,CAAC;;;OAAA;;;;IAED,qCAAY;;;IAAZ;IACA,CAAC;IATD;QADC,OAAO,EAAE;0CACa,eAAe;;yDAErC;IASH,qBAAC;CAAA,AAtDD,CAAoC,mBAAmB,GAsDtD;SAtDY,cAAc;;;;;;IAEzB,+BAAiC;;IAGjC,4CAAwC;;AAmD1C,WAAiB,cAAc;;;;;IAE7B,SAAgB,2BAA2B,CAAC,MAAW;QACrD,OAAO,IAAI,CAAC,gBAAgB,CAAC,mBAAA,MAAM,EAAsB,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACtF,CAAC;IAFe,0CAA2B,8BAE1C,CAAA;;;;;IAED,SAAgB,kBAAkB,CAAC,KAAoC;QACrE,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC;IACpE,CAAC;IAFe,iCAAkB,qBAEjC,CAAA;;;;;IAED,SAAgB,aAAa,CAAC,KAAoC;QAChE,OAAO,OAAO,CAAC,WAAW,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IAFe,4BAAa,gBAE5B,CAAA;;;;;;IAED,SAAgB,gBAAgB,CAAC,KAAoC,EAAE,UAA2B;QAChG,OAAO,CAAC,cAAc,CAAC,wBAAwB,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAFe,+BAAgB,mBAE/B,CAAA;AAEH,CAAC,EAlBgB,cAAc,KAAd,cAAc,QAkB9B","sourcesContent":["import { AfterViewInit } from '@angular/core';\nimport {\n assert,\n Binding,\n Constructable,\n DebugContext,\n IMutableHasValue,\n lang, Trace,\n TransactionObserver,\n ValueModel\n} from '@coolon/pectin';\nimport { Klass } from '@coolon/typescript-utilities';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator';\nimport 'reflect-metadata';\nimport { DisposableComponent } from '../components/disposable-component';\nimport { InteractionContext } from '../interaction/interaction-context';\nimport { PlaceDefinition } from './place-definition';\nimport { ParameterDefinition } from './route/parameter-definition.class';\nimport { Visit } from './visit';\n\n// RAKE: making this Symbol(...) broke things.\nexport const DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';\n// this one seems ok.\nexport const ROUTE_PARAMETER_LIST_KEY = Symbol('place:route:parameters');\n\nexport class PlaceComponent extends DisposableComponent {\n\n private visit: ValueModel<Visit>;\n // private _inDeactivationGuard = new MutableValueModel<boolean>(false);\n\n interactionContext?: InteractionContext;\n\n canDeactivate?(interactionContext: InteractionContext): boolean | Promise<boolean>;\n\n constructor() {\n super();\n }\n\n public initialiseVisit(visit: ValueModel<Visit>) {\n assert.isNil(this.visit);\n this.visit = visit;\n DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);\n this.placeDefinition.getVisitParameterDefs().forEach(parameterDef => {\n this.installBinding(parameterDef);\n });\n }\n\n // @Trace()\n private installBinding<T, S>(parameterDef: ParameterDefinition<T, S>) {\n const model = this[parameterDef.propertyName] as IMutableHasValue<S>;\n DebugContext.tag(model, `${this.placeDefinition.component.name}.${parameterDef.propertyName}`);\n const binding = this.registerDisposable(new Binding(this.visit, model, {\n toRight(visit: Visit): S {\n const value = visit.getParameter(parameterDef.name);\n console.log('push to component', {name:parameterDef.name, value, visit});\n return value;\n },\n toLeft(value: S, currentVisit?: Visit): Visit {\n console.log('push to route', { name: parameterDef.name, value, currentVisit });\n return currentVisit.replace(parameterDef, value);\n }\n }));\n setTimeout(() => {\n binding.writeRight();\n })\n }\n\n @Memoize()\n get placeDefinition(): PlaceDefinition {\n return PlaceComponent.getDefinition(this.constructor as any as Constructable<PlaceComponent>);\n }\n\n get childPlaces(): Constructable<PlaceComponent>[] {\n return this.placeDefinition.children.map(d => d.component);\n }\n\n onPlaceReady() {\n }\n\n}\n\nexport namespace PlaceComponent {\n\n export function isPlaceComponentConstructor(target: any): target is Constructable<PlaceComponent> {\n return lang.constructorChain(target as Constructable<any>).includes(PlaceComponent);\n }\n\n export function getRouteParameters(klass: Constructable<PlaceComponent>): ParameterDefinition<any>[] {\n return Klass.get(klass).getMetadataList(ROUTE_PARAMETER_LIST_KEY);\n }\n\n export function getDefinition(klass: Constructable<PlaceComponent>): PlaceDefinition {\n return Reflect.getMetadata(DEFINITION_META_DATA_KEY, klass);\n }\n\n export function injectDefinition(klass: Constructable<PlaceComponent>, definition: PlaceDefinition) {\n Reflect.defineMetadata(DEFINITION_META_DATA_KEY, definition, klass);\n }\n\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * @fileoverview added by tsickle
3
3
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4
4
  */
5
- import { Binding, DebugContext, Logger, MutableListModel, MutableValueModel, UseDelegate } from '@coolon/pectin';
5
+ import { Binding, DebugContext, Logger, MutableListModel, MutableValueModel } from '@coolon/pectin';
6
6
  import { Klass, Opts } from '@coolon/typescript-utilities';
7
7
  import { ROUTE_PARAMETER_LIST_KEY } from '../place-component';
8
8
  import { ParameterDefinition } from './parameter-definition.class';
@@ -55,6 +55,57 @@ if (false) {
55
55
  /** @type {?|undefined} */
56
56
  RouteListParameterOptions.prototype.storeInUrl;
57
57
  }
58
+ /**
59
+ * @template M
60
+ * @param {?} prototype
61
+ * @param {?} propertyKey
62
+ * @param {?} backingModel
63
+ * @param {?} tagPrefix
64
+ * @param {?} isEmpty
65
+ * @return {?}
66
+ */
67
+ function installMechanics(prototype, propertyKey, backingModel, tagPrefix, isEmpty) {
68
+ /** @type {?} */
69
+ var mechanics = {
70
+ backingModel: backingModel,
71
+ binding: (/** @type {?} */ (null))
72
+ };
73
+ /** @type {?} */
74
+ var tag = tagPrefix + "(" + prototype.constructor.name + "." + propertyKey.toString() + ")";
75
+ DebugContext.get(mechanics.backingModel).tag(tag);
76
+ Logger.get(mechanics.backingModel).tag(tag);
77
+ Object.defineProperty(prototype, propertyKey, {
78
+ get: (/**
79
+ * @return {?}
80
+ */
81
+ function () {
82
+ return mechanics.backingModel;
83
+ }),
84
+ set: (/**
85
+ * @param {?} userModel
86
+ * @return {?}
87
+ */
88
+ function (userModel) {
89
+ // This handles the scenario where we want to push an existing value model (such as a form model)
90
+ // to and from the route.
91
+ if (mechanics.binding) {
92
+ mechanics.binding.dispose();
93
+ }
94
+ if (userModel) {
95
+ mechanics.binding = new Binding(mechanics.backingModel, userModel);
96
+ if (isEmpty(userModel)) {
97
+ mechanics.binding.writeRight(); // push the visit into the user model;
98
+ }
99
+ else {
100
+ if (!isEmpty(mechanics.backingModel)) {
101
+ console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
102
+ }
103
+ mechanics.binding.writeLeft(); // push the user model into the visit
104
+ }
105
+ }
106
+ })
107
+ });
108
+ }
58
109
  /**
59
110
  * @template T
60
111
  * @param {?} type
@@ -71,8 +122,11 @@ export function RouteId(type, options) {
71
122
  /** @type {?} */
72
123
  var param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);
73
124
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
74
- UseDelegate({ tag: "@RouteId(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
75
- // UseDelegate()(prototype, propertyKey);
125
+ installMechanics(prototype, propertyKey, new MutableValueModel(), "@RouteId", (/**
126
+ * @param {?} m
127
+ * @return {?}
128
+ */
129
+ function (m) { return m.query().isNil(); }));
76
130
  });
77
131
  }
78
132
  /**
@@ -92,46 +146,11 @@ export function VisitParameter(options) {
92
146
  /** @type {?} */
93
147
  var param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
94
148
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
95
- /** @type {?} */
96
- var mechanics = {
97
- backingModel: new MutableValueModel(),
98
- binding: (/** @type {?} */ (null))
99
- };
100
- /** @type {?} */
101
- var tag = "@VisitParameter(" + prototype.constructor.name + "." + propertyKey.toString() + ")";
102
- DebugContext.get(mechanics.backingModel).tag(tag);
103
- Logger.get(mechanics.backingModel).tag(tag);
104
- Object.defineProperty(prototype, propertyKey, {
105
- get: (/**
106
- * @return {?}
107
- */
108
- function () {
109
- return mechanics.backingModel;
110
- }),
111
- set: (/**
112
- * @param {?} userModel
113
- * @return {?}
114
- */
115
- function (userModel) {
116
- // This handles the scenario where we want to push an existing value model (such as a form model)
117
- // to and from the route.
118
- if (mechanics.binding) {
119
- mechanics.binding.dispose();
120
- }
121
- if (userModel) {
122
- mechanics.binding = new Binding(mechanics.backingModel, userModel);
123
- if (userModel.query().isNil()) {
124
- mechanics.binding.writeRight(); // push the visit into the user model;
125
- }
126
- else {
127
- if (!mechanics.backingModel.query().isNil()) {
128
- console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
129
- }
130
- mechanics.binding.writeLeft(); // push the user model into the visit
131
- }
132
- }
133
- })
134
- });
149
+ installMechanics(prototype, propertyKey, new MutableValueModel(), "@VisitParameter", (/**
150
+ * @param {?} m
151
+ * @return {?}
152
+ */
153
+ function (m) { return m.query().isNil(); }));
135
154
  });
136
155
  }
137
156
  /**
@@ -151,46 +170,11 @@ export function VisitParameterList(options) {
151
170
  /** @type {?} */
152
171
  var param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
153
172
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
154
- /** @type {?} */
155
- var mechanics = {
156
- backingModel: new MutableListModel(),
157
- binding: (/** @type {?} */ (null))
158
- };
159
- /** @type {?} */
160
- var tag = "@VisitParameterList(" + prototype.constructor.name + "." + propertyKey.toString() + ")";
161
- DebugContext.get(mechanics.backingModel).tag(tag);
162
- Logger.get(mechanics.backingModel).tag(tag);
163
- Object.defineProperty(prototype, propertyKey, {
164
- get: (/**
165
- * @return {?}
166
- */
167
- function () {
168
- return mechanics.backingModel;
169
- }),
170
- set: (/**
171
- * @param {?} userModel
172
- * @return {?}
173
- */
174
- function (userModel) {
175
- // This handles the scenario where we want to push an existing value model (such as a form model)
176
- // to and from the route.
177
- if (mechanics.binding) {
178
- mechanics.binding.dispose();
179
- }
180
- if (userModel) {
181
- mechanics.binding = new Binding(mechanics.backingModel, userModel);
182
- if (userModel.query().isEmpty()) {
183
- mechanics.binding.writeRight(); // push the visit into the user model;
184
- }
185
- else {
186
- if (!mechanics.backingModel.query().isEmpty()) {
187
- console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
188
- }
189
- mechanics.binding.writeLeft(); // push the user model into the visit
190
- }
191
- }
192
- })
193
- });
173
+ installMechanics(prototype, propertyKey, new MutableListModel(), "@VisitParameterList", (/**
174
+ * @param {?} m
175
+ * @return {?}
176
+ */
177
+ function (m) { return m.query().isEmpty(); }));
194
178
  });
195
179
  }
196
180
  //# sourceMappingURL=parameter-decorators.js.map