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