@rxap/remote-method 14.0.2 → 16.0.0-dev.0

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.
Files changed (65) hide show
  1. package/directive/lib/remote-method-template-collection.directive.d.ts +1 -1
  2. package/directive/lib/remote-method-template.directive.d.ts +1 -1
  3. package/directive/lib/remote-method.directive.d.ts +1 -1
  4. package/esm2022/directive/lib/remote-method-template-collection.directive.mjs +335 -0
  5. package/esm2022/directive/lib/remote-method-template.directive.mjs +203 -0
  6. package/esm2022/directive/lib/remote-method.directive.mjs +167 -0
  7. package/esm2022/http/directive/lib/contenteditable.directive.mjs +88 -0
  8. package/esm2022/http/directive/lib/http-remote-method.directive.mjs +81 -0
  9. package/esm2022/http/lib/base-http.remote-method.mjs +83 -0
  10. package/esm2022/http/lib/http-remote-method.loader.mjs +31 -0
  11. package/esm2022/http/lib/http.remote-method.mjs +46 -0
  12. package/esm2022/lib/base.remote-method.mjs +74 -0
  13. package/esm2022/lib/proxy.remote-method.mjs +30 -0
  14. package/esm2022/lib/remote-method-loader.mjs +18 -0
  15. package/{fesm2020 → fesm2022}/rxap-remote-method-directive.mjs +91 -91
  16. package/{fesm2020 → fesm2022}/rxap-remote-method-directive.mjs.map +1 -1
  17. package/{fesm2020 → fesm2022}/rxap-remote-method-http-directive.mjs +14 -14
  18. package/fesm2022/rxap-remote-method-http-directive.mjs.map +1 -0
  19. package/{fesm2020 → fesm2022}/rxap-remote-method-http.mjs +9 -9
  20. package/{fesm2020 → fesm2022}/rxap-remote-method-http.mjs.map +1 -1
  21. package/{fesm2020 → fesm2022}/rxap-remote-method.mjs +9 -9
  22. package/{fesm2020 → fesm2022}/rxap-remote-method.mjs.map +1 -1
  23. package/http/directive/lib/contenteditable.directive.d.ts +1 -1
  24. package/http/directive/lib/http-remote-method.directive.d.ts +1 -1
  25. package/package.json +30 -43
  26. package/testing/lib/remote-method-testing-loader.d.ts +1 -1
  27. package/esm2020/directive/lib/remote-method-template-collection.directive.mjs +0 -333
  28. package/esm2020/directive/lib/remote-method-template.directive.mjs +0 -201
  29. package/esm2020/directive/lib/remote-method.directive.mjs +0 -165
  30. package/esm2020/http/directive/lib/contenteditable.directive.mjs +0 -86
  31. package/esm2020/http/directive/lib/http-remote-method.directive.mjs +0 -79
  32. package/esm2020/http/lib/base-http.remote-method.mjs +0 -82
  33. package/esm2020/http/lib/http-remote-method.loader.mjs +0 -30
  34. package/esm2020/http/lib/http.remote-method.mjs +0 -45
  35. package/esm2020/lib/base.remote-method.mjs +0 -73
  36. package/esm2020/lib/proxy.remote-method.mjs +0 -29
  37. package/esm2020/lib/remote-method-loader.mjs +0 -17
  38. package/fesm2015/rxap-remote-method-directive.mjs +0 -712
  39. package/fesm2015/rxap-remote-method-directive.mjs.map +0 -1
  40. package/fesm2015/rxap-remote-method-http-directive.mjs +0 -172
  41. package/fesm2015/rxap-remote-method-http-directive.mjs.map +0 -1
  42. package/fesm2015/rxap-remote-method-http.mjs +0 -158
  43. package/fesm2015/rxap-remote-method-http.mjs.map +0 -1
  44. package/fesm2015/rxap-remote-method-testing.mjs +0 -60
  45. package/fesm2015/rxap-remote-method-testing.mjs.map +0 -1
  46. package/fesm2015/rxap-remote-method.mjs +0 -137
  47. package/fesm2015/rxap-remote-method.mjs.map +0 -1
  48. package/fesm2020/rxap-remote-method-http-directive.mjs.map +0 -1
  49. /package/{esm2020 → esm2022}/directive/lib/error.mjs +0 -0
  50. /package/{esm2020 → esm2022}/directive/lib/tokens.mjs +0 -0
  51. /package/{esm2020 → esm2022}/directive/public_api.mjs +0 -0
  52. /package/{esm2020 → esm2022}/directive/rxap-remote-method-directive.mjs +0 -0
  53. /package/{esm2020 → esm2022}/http/directive/public_api.mjs +0 -0
  54. /package/{esm2020 → esm2022}/http/directive/rxap-remote-method-http-directive.mjs +0 -0
  55. /package/{esm2020 → esm2022}/http/public_api.mjs +0 -0
  56. /package/{esm2020 → esm2022}/http/rxap-remote-method-http.mjs +0 -0
  57. /package/{esm2020 → esm2022}/index.mjs +0 -0
  58. /package/{esm2020 → esm2022}/lib/error.mjs +0 -0
  59. /package/{esm2020 → esm2022}/lib/tokens.mjs +0 -0
  60. /package/{esm2020 → esm2022}/rxap-remote-method.mjs +0 -0
  61. /package/{esm2020 → esm2022}/testing/lib/remote-method-testing-loader.mjs +0 -0
  62. /package/{esm2020 → esm2022}/testing/public_api.mjs +0 -0
  63. /package/{esm2020 → esm2022}/testing/rxap-remote-method-testing.mjs +0 -0
  64. /package/{fesm2020 → fesm2022}/rxap-remote-method-testing.mjs +0 -0
  65. /package/{fesm2020 → fesm2022}/rxap-remote-method-testing.mjs.map +0 -0
@@ -1,712 +0,0 @@
1
- import { __awaiter, __decorate, __metadata } from 'tslib';
2
- import * as i0 from '@angular/core';
3
- import { InjectionToken, EventEmitter, Injector, isDevMode, INJECTOR, Directive, Inject, Optional, Self, Input, Output, HostListener, NgModule, TemplateRef, ViewContainerRef, ChangeDetectorRef, IterableDiffers, NgZone } from '@angular/core';
4
- import * as i1 from '@rxap/remote-method';
5
- import { RemoteMethodLoader, RxapRemoteMethodError } from '@rxap/remote-method';
6
- import { coerceBoolean, Required, Deprecated } from '@rxap/utilities';
7
- import { ToggleSubject } from '@rxap/utilities/rxjs';
8
- import { take, tap } from 'rxjs/operators';
9
-
10
- const RXAP_REMOTE_METHOD_DIRECTIVE_TOKEN = new InjectionToken('rxap/remote-method/directive/token');
11
-
12
- class RemoteMethodDirective {
13
- constructor(remoteMethodLoader, injector = Injector.NULL, remoteMethodToken) {
14
- this.remoteMethodLoader = remoteMethodLoader;
15
- this.injector = injector;
16
- this.remoteMethodToken = remoteMethodToken;
17
- this.executed$ = new EventEmitter();
18
- this.failure$ = new EventEmitter();
19
- this.successful$ = new EventEmitter();
20
- this.immediately = false;
21
- /**
22
- * true - a remote method call is in progress
23
- */
24
- this.executing$ = new ToggleSubject();
25
- this._hasConfirmDirective = false;
26
- if (this.remoteMethodToken) {
27
- this._remoteMethodOrIdOrToken = this.remoteMethodToken;
28
- }
29
- }
30
- set remoteMethodOrIdOrToken(value) {
31
- if (value) {
32
- this._remoteMethodOrIdOrToken = value;
33
- }
34
- }
35
- set hasConfirmDirective(value) {
36
- this._hasConfirmDirective = coerceBoolean(value);
37
- }
38
- ngOnInit() {
39
- if (this.immediately) {
40
- this.execute();
41
- }
42
- }
43
- onConfirmed() {
44
- this.execute();
45
- }
46
- onClick() {
47
- if (!this._hasConfirmDirective) {
48
- this.execute();
49
- }
50
- else {
51
- console.debug('skip remote method call. Wait for confirmation.');
52
- }
53
- }
54
- execute() {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- this.executing$.enable();
57
- try {
58
- const result = yield this.remoteMethodLoader.call$(this._remoteMethodOrIdOrToken, this.parameters, this.metadata, this.injector);
59
- this.executed(result);
60
- this.successful(result);
61
- }
62
- catch (error) {
63
- if (isDevMode()) {
64
- console.error(`Remote method directive execution failed:`, error.message);
65
- }
66
- this.failure(error);
67
- }
68
- finally {
69
- this.executing$.disable();
70
- }
71
- });
72
- }
73
- setParameter(parameterKey, value) {
74
- this.updateParameters({ [parameterKey]: value });
75
- }
76
- updateParameters(parameters) {
77
- var _a;
78
- this.parameters = Object.assign(Object.assign({}, ((_a = this.parameters) !== null && _a !== void 0 ? _a : {})), parameters);
79
- }
80
- executed(result) {
81
- this.executed$.emit(result);
82
- }
83
- failure(error) {
84
- this.failure$.emit(error);
85
- }
86
- successful(result) {
87
- this.successful$.emit(result);
88
- }
89
- /**
90
- * @deprecated removed
91
- * @protected
92
- */
93
- call() {
94
- return __awaiter(this, void 0, void 0, function* () {
95
- this.executing$.enable();
96
- const result = yield this.remoteMethodLoader.call$(this._remoteMethodOrIdOrToken, this.parameters, this.metadata, this.injector);
97
- this.executing$.disable();
98
- return result;
99
- });
100
- }
101
- }
102
- RemoteMethodDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodDirective, deps: [{ token: RemoteMethodLoader }, { token: INJECTOR }, { token: RXAP_REMOTE_METHOD_DIRECTIVE_TOKEN, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
103
- RemoteMethodDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: RemoteMethodDirective, selector: "[rxapRemoteMethod]", inputs: { remoteMethodOrIdOrToken: ["rxapRemoteMethod", "remoteMethodOrIdOrToken"], parameters: "parameters", metadata: "metadata", immediately: "immediately", hasConfirmDirective: ["rxapConfirm", "hasConfirmDirective"] }, outputs: { executed$: "executed", failure$: "failure", successful$: "successful" }, host: { listeners: { "confirmed": "onConfirmed()", "click": "onClick()" } }, exportAs: ["rxapRemoteMethod"], ngImport: i0 });
104
- __decorate([
105
- Required,
106
- __metadata("design:type", Object)
107
- ], RemoteMethodDirective.prototype, "_remoteMethodOrIdOrToken", void 0);
108
- __decorate([
109
- Deprecated('removed'),
110
- __metadata("design:type", Function),
111
- __metadata("design:paramtypes", []),
112
- __metadata("design:returntype", Promise)
113
- ], RemoteMethodDirective.prototype, "call", null);
114
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodDirective, decorators: [{
115
- type: Directive,
116
- args: [{
117
- selector: '[rxapRemoteMethod]',
118
- exportAs: 'rxapRemoteMethod'
119
- }]
120
- }], ctorParameters: function () {
121
- return [{ type: i1.RemoteMethodLoader, decorators: [{
122
- type: Inject,
123
- args: [RemoteMethodLoader]
124
- }] }, { type: i0.Injector, decorators: [{
125
- type: Inject,
126
- args: [INJECTOR]
127
- }] }, { type: undefined, decorators: [{
128
- type: Optional
129
- }, {
130
- type: Self
131
- }, {
132
- type: Inject,
133
- args: [RXAP_REMOTE_METHOD_DIRECTIVE_TOKEN]
134
- }] }];
135
- }, propDecorators: { remoteMethodOrIdOrToken: [{
136
- type: Input,
137
- args: ['rxapRemoteMethod']
138
- }], parameters: [{
139
- type: Input
140
- }], metadata: [{
141
- type: Input
142
- }], executed$: [{
143
- type: Output,
144
- args: ['executed']
145
- }], failure$: [{
146
- type: Output,
147
- args: ['failure']
148
- }], successful$: [{
149
- type: Output,
150
- args: ['successful']
151
- }], immediately: [{
152
- type: Input
153
- }], hasConfirmDirective: [{
154
- type: Input,
155
- args: ['rxapConfirm']
156
- }], _remoteMethodOrIdOrToken: [], onConfirmed: [{
157
- type: HostListener,
158
- args: ['confirmed']
159
- }], onClick: [{
160
- type: HostListener,
161
- args: ['click']
162
- }], call: [] } });
163
- class RemoteMethodDirectiveModule {
164
- }
165
- RemoteMethodDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
166
- RemoteMethodDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodDirectiveModule, declarations: [RemoteMethodDirective], exports: [RemoteMethodDirective] });
167
- RemoteMethodDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodDirectiveModule });
168
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodDirectiveModule, decorators: [{
169
- type: NgModule,
170
- args: [{
171
- declarations: [RemoteMethodDirective],
172
- exports: [RemoteMethodDirective]
173
- }]
174
- }] });
175
-
176
- class RemoteMethodTemplateCollectionDirectiveContext {
177
- constructor($implicit, index, count) {
178
- this.$implicit = $implicit;
179
- this.index = index;
180
- this.count = count;
181
- }
182
- get first() {
183
- return this.index === 0;
184
- }
185
- get last() {
186
- return this.index === this.count - 1;
187
- }
188
- get even() {
189
- return this.index % 2 === 0;
190
- }
191
- get odd() {
192
- return !this.even;
193
- }
194
- }
195
- function getTypeName(type) {
196
- return type['name'] || typeof type;
197
- }
198
- class RecordViewTuple {
199
- constructor(record, view) {
200
- this.record = record;
201
- this.view = view;
202
- }
203
- }
204
- class RemoteMethodTemplateCollectionDirective {
205
- constructor(template, remoteMethodLoader, injector, viewContainerRef, cdr, differs, zone, remoteMethodToken) {
206
- this.template = template;
207
- this.remoteMethodLoader = remoteMethodLoader;
208
- this.injector = injector;
209
- this.viewContainerRef = viewContainerRef;
210
- this.cdr = cdr;
211
- this.differs = differs;
212
- this.zone = zone;
213
- this.remoteMethodToken = remoteMethodToken;
214
- this.withoutParameters = false;
215
- this._differ = null;
216
- /**
217
- * Holds the data that should be displayed
218
- * @private
219
- */
220
- this._data = null;
221
- this._dirty = true;
222
- /**
223
- * Indicates that the remote method returned a empty collection
224
- *
225
- * true - is empty
226
- * false - is NOT empty
227
- * null - unknown
228
- *
229
- * @private
230
- */
231
- this._empty = null;
232
- /**
233
- * Holds the error that call of the remote method throws
234
- *
235
- * @private
236
- */
237
- this._error = null;
238
- /**
239
- * Holds the empty template view ref.
240
- *
241
- * Is used to determine if a empty template is added to the
242
- * view. And used to destruct the empty template if the remote method
243
- * changes from empty to not empty.
244
- *
245
- * @private
246
- */
247
- this._emptyTemplateViewRef = null;
248
- /**
249
- * Holds the error template view ref.
250
- *
251
- * Is used to determine if a error template is added to the
252
- * view. And used to destruct the error template if the remote method
253
- * is called again with an error.
254
- *
255
- * @private
256
- */
257
- this._errorTemplateViewRef = null;
258
- if (this.remoteMethodToken) {
259
- this._remoteMethodOrIdOrToken = this.remoteMethodToken;
260
- }
261
- }
262
- /**
263
- * Asserts the correct type of the context for the template that `NgForOf` will render.
264
- *
265
- * The presence of this method is a signal to the Ivy template type-check compiler that the
266
- * `NgForOf` structural directive renders its template with a specific context type.
267
- */
268
- static ngTemplateContextGuard(dir, ctx) {
269
- return true;
270
- }
271
- set remoteMethodOrIdOrToken(value) {
272
- if (value) {
273
- this._remoteMethodOrIdOrToken = value;
274
- }
275
- }
276
- /**
277
- * A function that defines how to track changes for items in the iterable.
278
- *
279
- * When items are added, moved, or removed in the iterable,
280
- * the directive must re-render the appropriate DOM nodes.
281
- * To minimize churn in the DOM, only nodes that have changed
282
- * are re-rendered.
283
- *
284
- * By default, the change detector assumes that
285
- * the object instance identifies the node in the iterable.
286
- * When this function is supplied, the directive uses
287
- * the result of calling this function to identify the item node,
288
- * rather than the identity of the object itself.
289
- *
290
- * The function receives two inputs,
291
- * the iteration index and the node object ID.
292
- */
293
- set trackBy(fn) {
294
- if (isDevMode() && fn != null && typeof fn !== 'function') {
295
- // TODO(vicb): use a log service once there is a public one available
296
- if (console && console.warn) {
297
- console.warn(`trackBy must be a function, but received ${JSON.stringify(fn)}. ` +
298
- `See https://angular.io/api/common/NgForOf#change-propagation for more information.`);
299
- }
300
- }
301
- this._trackByFn = fn;
302
- }
303
- get trackBy() {
304
- return this._trackByFn;
305
- }
306
- set data(data) {
307
- this._data = data;
308
- this._dirty = true;
309
- }
310
- ngOnChanges(changes) {
311
- const parametersChanges = changes.parameters;
312
- if (parametersChanges) {
313
- this.call(parametersChanges.currentValue);
314
- }
315
- }
316
- ngOnInit() {
317
- if (this.withoutParameters) {
318
- this.call();
319
- }
320
- }
321
- call(parameters) {
322
- this.zone.onStable.pipe(take(1), tap(() => {
323
- this.zone.run(() => {
324
- this.remoteMethodLoader
325
- .call$(this._remoteMethodOrIdOrToken, parameters, undefined, this.injector)
326
- .then(response => {
327
- this._empty = response.length === 0;
328
- this._data = response;
329
- this.cdr.detectChanges();
330
- })
331
- .catch(error => {
332
- this._error = error;
333
- this.cdr.detectChanges();
334
- });
335
- });
336
- })).subscribe();
337
- }
338
- applyChanges(changes) {
339
- const insertTuples = [];
340
- changes.forEachOperation((item, adjustedPreviousIndex, currentIndex) => {
341
- if (item.previousIndex == null) {
342
- // NgForOf is never "null" or "undefined" here because the differ detected
343
- // that a new item needs to be inserted from the iterable. This implies that
344
- // there is an iterable value for "_ngForOf".
345
- const view = this.viewContainerRef.createEmbeddedView(this.template, new RemoteMethodTemplateCollectionDirectiveContext(null, -1, -1), currentIndex === null ? undefined : currentIndex);
346
- const tuple = new RecordViewTuple(item, view);
347
- insertTuples.push(tuple);
348
- }
349
- else if (currentIndex == null) {
350
- this.viewContainerRef.remove(adjustedPreviousIndex === null ? undefined : adjustedPreviousIndex);
351
- }
352
- else if (adjustedPreviousIndex !== null) {
353
- const view = this.viewContainerRef.get(adjustedPreviousIndex);
354
- this.viewContainerRef.move(view, currentIndex);
355
- const tuple = new RecordViewTuple(item, view);
356
- insertTuples.push(tuple);
357
- }
358
- });
359
- for (let i = 0; i < insertTuples.length; i++) {
360
- this.perViewChange(insertTuples[i].view, insertTuples[i].record);
361
- }
362
- for (let i = 0, ilen = this.viewContainerRef.length; i < ilen; i++) {
363
- const viewRef = this.viewContainerRef.get(i);
364
- viewRef.context.index = i;
365
- viewRef.context.count = ilen;
366
- }
367
- changes.forEachIdentityChange((record) => {
368
- const viewRef = this.viewContainerRef.get(record.currentIndex);
369
- viewRef.context.$implicit = record.item;
370
- });
371
- }
372
- perViewChange(view, record) {
373
- view.context.$implicit = record.item;
374
- }
375
- /**
376
- * Applies the changes when needed.
377
- */
378
- ngDoCheck() {
379
- if (this._error !== null) {
380
- this.viewContainerRef.clear();
381
- this._differ = null;
382
- if (this.errorTemplate) {
383
- this._errorTemplateViewRef = this.viewContainerRef.createEmbeddedView(this.errorTemplate, { $implicit: this._error, message: this._error.message, name: this._error.name });
384
- }
385
- }
386
- else if (this._empty === true) {
387
- this.viewContainerRef.clear();
388
- this._differ = null;
389
- // attaches the empty template if the data source is empty
390
- if (this.emptyTemplate) {
391
- this._emptyTemplateViewRef = this.viewContainerRef.createEmbeddedView(this.emptyTemplate);
392
- }
393
- }
394
- else if (this._empty === false) {
395
- // detach and destroy the empty template if the data source is not
396
- // empty any more
397
- if (this._emptyTemplateViewRef) {
398
- this._emptyTemplateViewRef.detach();
399
- this._emptyTemplateViewRef.destroy();
400
- this._errorTemplateViewRef = null;
401
- }
402
- if (this._errorTemplateViewRef) {
403
- this._errorTemplateViewRef.detach();
404
- this._errorTemplateViewRef.destroy();
405
- this._errorTemplateViewRef = null;
406
- }
407
- if (this._data) {
408
- this._dirty = false;
409
- // React on ngForOf changes only once all inputs have been initialized
410
- const value = this._data;
411
- if (!this._differ && value) {
412
- try {
413
- this._differ = this.differs.find(value).create(this.trackBy);
414
- }
415
- catch (_a) {
416
- throw new Error(`Cannot find a differ supporting object '${value}' of type '${getTypeName(value)}'. NgFor only supports binding to Iterables such as Arrays.`);
417
- }
418
- }
419
- }
420
- if (this._differ) {
421
- const changes = this._differ.diff(this._data);
422
- if (changes) {
423
- this.applyChanges(changes);
424
- }
425
- }
426
- }
427
- }
428
- }
429
- RemoteMethodTemplateCollectionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateCollectionDirective, deps: [{ token: TemplateRef }, { token: RemoteMethodLoader }, { token: INJECTOR }, { token: ViewContainerRef }, { token: ChangeDetectorRef }, { token: IterableDiffers }, { token: NgZone }, { token: RXAP_REMOTE_METHOD_DIRECTIVE_TOKEN, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
430
- RemoteMethodTemplateCollectionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: RemoteMethodTemplateCollectionDirective, selector: "[rxapRemoteMethodCollection]", inputs: { remoteMethodOrIdOrToken: ["rxapRemoteMethodCollectionCall", "remoteMethodOrIdOrToken"], trackBy: ["rxapRemoteMethodCollectionTrackBy", "trackBy"], parameters: ["rxapRemoteMethodCollectionParameters", "parameters"], emptyTemplate: ["rxapRemoteMethodCollectionEmpty", "emptyTemplate"], errorTemplate: ["rxapRemoteMethodCollectionError", "errorTemplate"], withoutParameters: ["rxapRemoteMethodCollectionWithoutParameters", "withoutParameters"] }, exportAs: ["rxapRemoteMethodCollection"], usesOnChanges: true, ngImport: i0 });
431
- __decorate([
432
- Required,
433
- __metadata("design:type", Object)
434
- ], RemoteMethodTemplateCollectionDirective.prototype, "_remoteMethodOrIdOrToken", void 0);
435
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateCollectionDirective, decorators: [{
436
- type: Directive,
437
- args: [{
438
- selector: '[rxapRemoteMethodCollection]',
439
- exportAs: 'rxapRemoteMethodCollection'
440
- }]
441
- }], ctorParameters: function () {
442
- return [{ type: i0.TemplateRef, decorators: [{
443
- type: Inject,
444
- args: [TemplateRef]
445
- }] }, { type: i1.RemoteMethodLoader, decorators: [{
446
- type: Inject,
447
- args: [RemoteMethodLoader]
448
- }] }, { type: i0.Injector, decorators: [{
449
- type: Inject,
450
- args: [INJECTOR]
451
- }] }, { type: i0.ViewContainerRef, decorators: [{
452
- type: Inject,
453
- args: [ViewContainerRef]
454
- }] }, { type: i0.ChangeDetectorRef, decorators: [{
455
- type: Inject,
456
- args: [ChangeDetectorRef]
457
- }] }, { type: i0.IterableDiffers, decorators: [{
458
- type: Inject,
459
- args: [IterableDiffers]
460
- }] }, { type: i0.NgZone, decorators: [{
461
- type: Inject,
462
- args: [NgZone]
463
- }] }, { type: undefined, decorators: [{
464
- type: Optional
465
- }, {
466
- type: Self
467
- }, {
468
- type: Inject,
469
- args: [RXAP_REMOTE_METHOD_DIRECTIVE_TOKEN]
470
- }] }];
471
- }, propDecorators: { remoteMethodOrIdOrToken: [{
472
- type: Input,
473
- args: ['rxapRemoteMethodCollectionCall']
474
- }], trackBy: [{
475
- type: Input,
476
- args: ['rxapRemoteMethodCollectionTrackBy']
477
- }], parameters: [{
478
- type: Input,
479
- args: ['rxapRemoteMethodCollectionParameters']
480
- }], emptyTemplate: [{
481
- type: Input,
482
- args: ['rxapRemoteMethodCollectionEmpty']
483
- }], errorTemplate: [{
484
- type: Input,
485
- args: ['rxapRemoteMethodCollectionError']
486
- }], withoutParameters: [{
487
- type: Input,
488
- args: ['rxapRemoteMethodCollectionWithoutParameters']
489
- }], _remoteMethodOrIdOrToken: [] } });
490
- class RemoteMethodTemplateCollectionDirectiveModule {
491
- }
492
- RemoteMethodTemplateCollectionDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateCollectionDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
493
- RemoteMethodTemplateCollectionDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateCollectionDirectiveModule, declarations: [RemoteMethodTemplateCollectionDirective], exports: [RemoteMethodTemplateCollectionDirective] });
494
- RemoteMethodTemplateCollectionDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateCollectionDirectiveModule });
495
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateCollectionDirectiveModule, decorators: [{
496
- type: NgModule,
497
- args: [{
498
- declarations: [RemoteMethodTemplateCollectionDirective],
499
- exports: [RemoteMethodTemplateCollectionDirective]
500
- }]
501
- }] });
502
-
503
- class RemoteMethodTemplateDirective {
504
- constructor(template, remoteMethodLoader, injector, viewContainerRef, cdr, remoteMethodToken) {
505
- this.template = template;
506
- this.remoteMethodLoader = remoteMethodLoader;
507
- this.injector = injector;
508
- this.viewContainerRef = viewContainerRef;
509
- this.cdr = cdr;
510
- this.remoteMethodToken = remoteMethodToken;
511
- this.executed$ = new EventEmitter();
512
- this.failure$ = new EventEmitter();
513
- this.successful$ = new EventEmitter();
514
- /**
515
- * true - a remote method call is in progress
516
- */
517
- this.executing$ = new ToggleSubject();
518
- this.withoutParameters = false;
519
- this.embedded = new EventEmitter();
520
- if (this.remoteMethodToken) {
521
- this._remoteMethodOrIdOrToken = this.remoteMethodToken;
522
- }
523
- }
524
- // TODO : remove template context Guard
525
- // the template context Guard must be defined with a concrete context type
526
- // else the context guard is resolved to any
527
- // For each child directive that should have a template context guard
528
- // the template context guard must be defined
529
- // !! add generation of concrete template context guard to openapi schematics !!
530
- static ngTemplateContextGuard(dir, ctx) {
531
- return true;
532
- }
533
- set remoteMethodOrIdOrToken(value) {
534
- if (value) {
535
- this._remoteMethodOrIdOrToken = value;
536
- }
537
- }
538
- ngOnChanges(changes) {
539
- const parametersChanges = changes.parameters;
540
- if (parametersChanges) {
541
- this.execute(parametersChanges.currentValue);
542
- }
543
- }
544
- ngOnInit() {
545
- this.renderLoadingTemplate();
546
- if (this.withoutParameters) {
547
- this.execute();
548
- }
549
- }
550
- execute(parameters = this.parameters) {
551
- return __awaiter(this, void 0, void 0, function* () {
552
- this.executing$.enable();
553
- this.renderLoadingTemplate();
554
- try {
555
- const result = yield this.remoteMethodLoader.call$(this._remoteMethodOrIdOrToken, parameters, this.metadata, this.injector);
556
- this.executed(result);
557
- this.renderTemplate(result);
558
- this.successful(result);
559
- }
560
- catch (error) {
561
- if (isDevMode()) {
562
- console.error(`Remote method directive execution failed:`, error.message);
563
- }
564
- this.failure(error);
565
- }
566
- finally {
567
- this.executing$.disable();
568
- }
569
- });
570
- }
571
- /**
572
- * @deprecated removed
573
- * @protected
574
- */
575
- call(parameters) {
576
- this.execute(parameters)
577
- .catch(error => console.error('Remote method template rendering failed: ' + error.message));
578
- }
579
- setParameter(parameterKey, value) {
580
- this.updateParameters({ [parameterKey]: value });
581
- }
582
- updateParameters(parameters) {
583
- var _a;
584
- this.parameters = Object.assign(Object.assign({}, ((_a = this.parameters) !== null && _a !== void 0 ? _a : {})), parameters);
585
- }
586
- renderLoadingTemplate() {
587
- if (this.loadingTemplate) {
588
- this.viewContainerRef.clear();
589
- this.viewContainerRef.createEmbeddedView(this.loadingTemplate);
590
- }
591
- }
592
- executed(result) {
593
- this.executed$.emit(result);
594
- }
595
- failure(error) {
596
- this.failure$.emit(error);
597
- }
598
- successful(result) {
599
- this.successful$.emit(result);
600
- }
601
- renderTemplate(result) {
602
- this.viewContainerRef.clear();
603
- try {
604
- this.viewContainerRef.createEmbeddedView(this.template, { $implicit: result });
605
- }
606
- catch (error) {
607
- if (this.errorTemplate) {
608
- this.viewContainerRef.createEmbeddedView(this.errorTemplate, { $implicit: error, message: error.message });
609
- }
610
- console.error(error.message);
611
- }
612
- this.embedded.emit();
613
- this.cdr.detectChanges();
614
- }
615
- }
616
- RemoteMethodTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateDirective, deps: [{ token: TemplateRef }, { token: RemoteMethodLoader }, { token: INJECTOR }, { token: ViewContainerRef }, { token: ChangeDetectorRef }, { token: RXAP_REMOTE_METHOD_DIRECTIVE_TOKEN, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
617
- RemoteMethodTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: RemoteMethodTemplateDirective, selector: "[rxapRemoteMethod]", inputs: { remoteMethodOrIdOrToken: ["rxapRemoteMethodCall", "remoteMethodOrIdOrToken"], metadata: ["rxapRemoteMethodMetadata", "metadata"], parameters: ["rxapRemoteMethodParameters", "parameters"], errorTemplate: ["rxapRemoteMethodError", "errorTemplate"], loadingTemplate: ["rxapRemoteMethodLoading", "loadingTemplate"], withoutParameters: ["rxapRemoteMethodWithoutParameters", "withoutParameters"] }, outputs: { executed$: "executed", failure$: "failure", successful$: "successful", embedded: "embedded" }, exportAs: ["rxapRemoteMethod"], usesOnChanges: true, ngImport: i0 });
618
- __decorate([
619
- Required,
620
- __metadata("design:type", Object)
621
- ], RemoteMethodTemplateDirective.prototype, "_remoteMethodOrIdOrToken", void 0);
622
- __decorate([
623
- Deprecated('removed'),
624
- __metadata("design:type", Function),
625
- __metadata("design:paramtypes", [Object]),
626
- __metadata("design:returntype", void 0)
627
- ], RemoteMethodTemplateDirective.prototype, "call", null);
628
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateDirective, decorators: [{
629
- type: Directive,
630
- args: [{
631
- selector: '[rxapRemoteMethod]',
632
- exportAs: 'rxapRemoteMethod'
633
- }]
634
- }], ctorParameters: function () {
635
- return [{ type: i0.TemplateRef, decorators: [{
636
- type: Inject,
637
- args: [TemplateRef]
638
- }] }, { type: i1.RemoteMethodLoader, decorators: [{
639
- type: Inject,
640
- args: [RemoteMethodLoader]
641
- }] }, { type: i0.Injector, decorators: [{
642
- type: Inject,
643
- args: [INJECTOR]
644
- }] }, { type: i0.ViewContainerRef, decorators: [{
645
- type: Inject,
646
- args: [ViewContainerRef]
647
- }] }, { type: i0.ChangeDetectorRef, decorators: [{
648
- type: Inject,
649
- args: [ChangeDetectorRef]
650
- }] }, { type: undefined, decorators: [{
651
- type: Optional
652
- }, {
653
- type: Self
654
- }, {
655
- type: Inject,
656
- args: [RXAP_REMOTE_METHOD_DIRECTIVE_TOKEN]
657
- }] }];
658
- }, propDecorators: { remoteMethodOrIdOrToken: [{
659
- type: Input,
660
- args: ['rxapRemoteMethodCall']
661
- }], executed$: [{
662
- type: Output,
663
- args: ['executed']
664
- }], failure$: [{
665
- type: Output,
666
- args: ['failure']
667
- }], successful$: [{
668
- type: Output,
669
- args: ['successful']
670
- }], metadata: [{
671
- type: Input,
672
- args: ['rxapRemoteMethodMetadata']
673
- }], parameters: [{
674
- type: Input,
675
- args: ['rxapRemoteMethodParameters']
676
- }], errorTemplate: [{
677
- type: Input,
678
- args: ['rxapRemoteMethodError']
679
- }], loadingTemplate: [{
680
- type: Input,
681
- args: ['rxapRemoteMethodLoading']
682
- }], withoutParameters: [{
683
- type: Input,
684
- args: ['rxapRemoteMethodWithoutParameters']
685
- }], _remoteMethodOrIdOrToken: [], embedded: [{
686
- type: Output
687
- }], call: [] } });
688
- class RemoteMethodTemplateDirectiveModule {
689
- }
690
- RemoteMethodTemplateDirectiveModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateDirectiveModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
691
- RemoteMethodTemplateDirectiveModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateDirectiveModule, declarations: [RemoteMethodTemplateDirective], exports: [RemoteMethodTemplateDirective] });
692
- RemoteMethodTemplateDirectiveModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateDirectiveModule });
693
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RemoteMethodTemplateDirectiveModule, decorators: [{
694
- type: NgModule,
695
- args: [{
696
- declarations: [RemoteMethodTemplateDirective],
697
- exports: [RemoteMethodTemplateDirective]
698
- }]
699
- }] });
700
-
701
- class RxapRemoteMethodDirectiveError extends RxapRemoteMethodError {
702
- constructor(message, code, scope) {
703
- super(message, code !== null && code !== void 0 ? code : '', scope);
704
- }
705
- }
706
-
707
- /**
708
- * Generated bundle index. Do not edit.
709
- */
710
-
711
- export { RXAP_REMOTE_METHOD_DIRECTIVE_TOKEN, RemoteMethodDirective, RemoteMethodDirectiveModule, RemoteMethodTemplateCollectionDirective, RemoteMethodTemplateCollectionDirectiveContext, RemoteMethodTemplateCollectionDirectiveModule, RemoteMethodTemplateDirective, RemoteMethodTemplateDirectiveModule, RxapRemoteMethodDirectiveError };
712
- //# sourceMappingURL=rxap-remote-method-directive.mjs.map