angular-toolbox 0.9.1 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +2 -2
  2. package/esm2022/lib/core/abstract/abstract-subscription-manager.mjs +113 -0
  3. package/esm2022/lib/core/abstract/abstract-version-manager.mjs +37 -0
  4. package/esm2022/lib/core/abstract/index.mjs +3 -0
  5. package/esm2022/lib/core/impl/lang/identifiable-component.mjs +18 -2
  6. package/esm2022/lib/core/index.mjs +2 -1
  7. package/esm2022/lib/model/business/index.mjs +2 -1
  8. package/esm2022/lib/model/business/lang/identifiable.mjs +1 -1
  9. package/esm2022/lib/model/business/subscription/index.mjs +2 -0
  10. package/esm2022/lib/model/business/subscription/subscription-manager.mjs +9 -0
  11. package/esm2022/lib/model/business/version/index.mjs +2 -1
  12. package/esm2022/lib/model/business/version/version-manager.mjs +10 -0
  13. package/esm2022/lib/model/service/subscription/subscription.service.mjs +6 -98
  14. package/esm2022/lib/model/service/version/version.service.mjs +4 -20
  15. package/fesm2022/angular-toolbox.mjs +221 -149
  16. package/fesm2022/angular-toolbox.mjs.map +1 -1
  17. package/lib/core/abstract/abstract-subscription-manager.d.ts +73 -0
  18. package/lib/core/abstract/abstract-version-manager.d.ts +34 -0
  19. package/lib/core/abstract/index.d.ts +2 -0
  20. package/lib/core/impl/lang/identifiable-component.d.ts +18 -0
  21. package/lib/core/index.d.ts +1 -0
  22. package/lib/model/business/index.d.ts +1 -0
  23. package/lib/model/business/lang/identifiable.d.ts +7 -0
  24. package/lib/model/business/subscription/index.d.ts +1 -0
  25. package/lib/model/business/subscription/subscription-manager.d.ts +52 -0
  26. package/lib/model/business/version/index.d.ts +1 -0
  27. package/lib/model/business/version/version-manager.d.ts +25 -0
  28. package/lib/model/service/subscription/subscription.service.d.ts +3 -59
  29. package/lib/model/service/version/version.service.d.ts +3 -18
  30. package/package.json +1 -1
@@ -333,11 +333,18 @@ const SYMBOL = "symbol";
333
333
  * Angular Toolbox Subscription Service.
334
334
  */
335
335
  class IdentifiableComponent {
336
- constructor() {
336
+ /**
337
+ * A string that represent the class reference for this object.
338
+ * This can be useful to workaround TypeScript compilation obfuscation.
339
+ *
340
+ * @param classRef The class reference for this object.
341
+ */
342
+ constructor(classRef = undefined) {
337
343
  /**
338
344
  * @private
339
345
  */
340
346
  this._uuid = Uuid.build();
347
+ this._classRef = classRef || this.constructor.name;
341
348
  }
342
349
  /**
343
350
  * Returns the unique identifier for this object.
@@ -347,9 +354,198 @@ class IdentifiableComponent {
347
354
  getID() {
348
355
  return this._uuid;
349
356
  }
357
+ /**
358
+ * Returns the class name reference of this object. Can be either the `classRef`
359
+ * paramter of the contructor method, or the constructor `name` property value.
360
+ *
361
+ * @returns the class name reference of this object.
362
+ */
363
+ getClassRef() {
364
+ return this._classRef;
365
+ }
350
366
  }
351
367
  ;
352
368
 
369
+ /**
370
+ * @license
371
+ * Copyright Pascal ECHEMANN. All Rights Reserved.
372
+ *
373
+ * Use of this source code is governed by an MIT-style license that can be found in
374
+ * the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
375
+ */
376
+ /**
377
+ * The abstract class for all services that implement the `SubscriptionManager` interface.
378
+ */
379
+ class AbstractSubscriptionManager {
380
+ constructor() {
381
+ /**
382
+ * @private
383
+ * Stores an internal reference to the last reference used with the `register()`
384
+ * method.
385
+ */
386
+ this._lastRef = null;
387
+ /**
388
+ * @private
389
+ * The internal `Subscription` instances storage.
390
+ */
391
+ this._subMap = new Map();
392
+ }
393
+ /**
394
+ * Stores a new `Subscription` instance associated with the specified reference.
395
+ *
396
+ * @param ref The reference for which to store a new `Subscription` instance.
397
+ * Can be either a string or an `Identifiable` object.
398
+ * @param subscription The `Subscription` instance to register.
399
+ *
400
+ * @returns A reference to this `SubscriptionService` instance.
401
+ */
402
+ register(ref, subscription) {
403
+ const REF = this.getRef(ref);
404
+ this._lastRef = REF;
405
+ if (!this._subMap.has(REF))
406
+ this._subMap.set(REF, []);
407
+ this._subMap.get(REF)?.push(subscription);
408
+ return this;
409
+ }
410
+ /**
411
+ * Stores a new `Subscription` instance associated with the reference specified
412
+ * by the last `register()` method invokation.
413
+ *
414
+ * @param subscription The `Subscription` instance to register.
415
+ *
416
+ * @returns A reference to this `SubscriptionService` instance.
417
+ */
418
+ append(subscription) {
419
+ if (!this._lastRef)
420
+ throw new SubscriptionError("Illegal Access Error: you must call the register() method before invoking the append() method.");
421
+ return this.register(this._lastRef, subscription);
422
+ }
423
+ /**
424
+ * Unsubscribes and removes all `Subscription` instances associated with the specified reference.
425
+ *
426
+ * @param ref The reference for which to remove all `Subscription` instances.
427
+ * Can be either a string or an `Identifiable` object.
428
+ *
429
+ * @returns `true` whether the specified reference exists; `false` otherwise.
430
+ */
431
+ clearAll(ref) {
432
+ const REF = this.getRef(ref);
433
+ let result = false;
434
+ if (this._lastRef === REF)
435
+ this._lastRef = null;
436
+ if (this._subMap.has(REF)) {
437
+ this._subMap.get(REF)?.forEach(subscription => {
438
+ if (!subscription.closed)
439
+ subscription.unsubscribe();
440
+ });
441
+ this._subMap.delete(REF);
442
+ result = true;
443
+ }
444
+ return result;
445
+ }
446
+ /**
447
+ * Returns all `Subscription` instances associated with the specified reference.
448
+ *
449
+ * @param ref The reference for which to remove get `Subscription` instances.
450
+ * Can be either a string or an `Identifiable` object.
451
+ *
452
+ * @returns All `Subscription` instances associated with the specified reference, or
453
+ * `null` whether the specified reference does not exists.
454
+ */
455
+ get(ref) {
456
+ return this._subMap.get(this.getRef(ref)) || null;
457
+ }
458
+ /**
459
+ * @private
460
+ * Returns the string reference for the regsitration process.
461
+ *
462
+ * @param ref The reference to be used the regsitration process.
463
+ * Can be either a string or an `Identifiable` object.
464
+ *
465
+ * @returns the string reference for the regsitration process.
466
+ */
467
+ getRef(ref) {
468
+ let targetRef;
469
+ if (typeof ref === STRING)
470
+ targetRef = ref;
471
+ else if (ref instanceof IdentifiableComponent)
472
+ targetRef = ref.getID().toString();
473
+ else
474
+ throw new TypeError("ref must be of type of string or Identifiable");
475
+ return targetRef;
476
+ }
477
+ }
478
+
479
+ /**
480
+ * @license
481
+ * Copyright Pascal ECHEMANN. All Rights Reserved.
482
+ *
483
+ * Use of this source code is governed by an MIT-style license that can be ound in
484
+ * fthe LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
485
+ */
486
+ /**
487
+ * @private
488
+ * Specifies the semantic versioning of an API.
489
+ */
490
+ class VersionImpl {
491
+ /**
492
+ * @private
493
+ */
494
+ constructor(major, minor, patch, buildTimeStamp) {
495
+ this.major = major;
496
+ this.minor = minor;
497
+ this.patch = patch;
498
+ this.buildTimeStamp = buildTimeStamp;
499
+ }
500
+ /**
501
+ * Returns a string representation of this `Version` object in the form `M.m.p`, where
502
+ * `M` represents the major number, `m` represents the minor number and `p` represents
503
+ * the patch number of this `VersionImpl` instance.
504
+ *
505
+ * @returns A string representation of this `VersionImpl` instance.
506
+ */
507
+ toString() {
508
+ return `${this.major}.${this.minor}.${this.patch}`;
509
+ }
510
+ }
511
+ ;
512
+
513
+ /**
514
+ * @license
515
+ * Copyright Pascal ECHEMANN. All Rights Reserved.
516
+ *
517
+ * Use of this source code is governed by an MIT-style license that can be found in
518
+ * the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
519
+ */
520
+ /**
521
+ * The abstract class for all services that implement the `VersionManager` interface.
522
+ */
523
+ class AbstractVersionManager {
524
+ /**
525
+ * Creates a new VersionManager object.
526
+ * @param config the reference to the VersionConfig provider.
527
+ */
528
+ constructor(config) {
529
+ this._version = new VersionImpl(config.major, config.minor, config.patch, config.buildTimestamp);
530
+ }
531
+ /**
532
+ * Returns the version of the associated Angular project.
533
+ *
534
+ * @return the version of the associated Angular project.
535
+ */
536
+ getVersion() {
537
+ return this._version;
538
+ }
539
+ /**
540
+ * Returns the build timestamp of the associated Angular project.
541
+ *
542
+ * @return the build timestamp of the associated Angular project.
543
+ */
544
+ getBuildTimestamp() {
545
+ return this._version.buildTimeStamp;
546
+ }
547
+ }
548
+
353
549
  /**
354
550
  * @license
355
551
  * Copyright Pascal ECHEMANN. All Rights Reserved.
@@ -707,6 +903,15 @@ const VERSION_CONFIG = {
707
903
  buildTimestamp: NaN
708
904
  };
709
905
 
906
+ /**
907
+ * @license
908
+ * Copyright Pascal ECHEMANN. All Rights Reserved.
909
+ *
910
+ * Use of this source code is governed by an MIT-style license that can be found in
911
+ * the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
912
+ */
913
+ ;
914
+
710
915
  /**
711
916
  * @license
712
917
  * Copyright Pascal ECHEMANN. All Rights Reserved.
@@ -869,6 +1074,14 @@ const DARK_MODE_CONFIG = {
869
1074
  * the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
870
1075
  */
871
1076
 
1077
+ /**
1078
+ * @license
1079
+ * Copyright Pascal ECHEMANN. All Rights Reserved.
1080
+ *
1081
+ * Use of this source code is governed by an MIT-style license that can be found in
1082
+ * the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
1083
+ */
1084
+
872
1085
  /**
873
1086
  * @license
874
1087
  * Copyright Pascal ECHEMANN. All Rights Reserved.
@@ -879,103 +1092,12 @@ const DARK_MODE_CONFIG = {
879
1092
  /**
880
1093
  * A lightweight service that helps to manage unregistration issues of Angular subscriptions.
881
1094
  */
882
- class SubscriptionService {
883
- constructor() {
884
- /**
885
- * @private
886
- * Stores an internal reference to the last reference used with the `register()`
887
- * method.
888
- */
889
- this._lastRef = null;
890
- /**
891
- * @private
892
- * The internal `Subscription` instances storage.
893
- */
894
- this._subMap = new Map();
895
- }
896
- /**
897
- * Stores a new `Subscription` instance associated with the specified reference.
898
- *
899
- * @param ref The reference for which to store a new `Subscription` instance.
900
- * Can be either a string or an `Identifiable` object.
901
- * @param subscription The `Subscription` instance to register.
902
- *
903
- * @returns A reference to this `SubscriptionService` instance.
904
- */
905
- register(ref, subscription) {
906
- const REF = this.getRef(ref);
907
- this._lastRef = REF;
908
- if (!this._subMap.has(REF))
909
- this._subMap.set(REF, []);
910
- this._subMap.get(REF)?.push(subscription);
911
- return this;
912
- }
913
- /**
914
- * Stores a new `Subscription` instance associated with the reference specified
915
- * by the last `register()` method invokation.
916
- *
917
- * @param subscription The `Subscription` instance to register.
918
- *
919
- * @returns A reference to this `SubscriptionService` instance.
920
- */
921
- append(subscription) {
922
- if (!this._lastRef)
923
- throw new SubscriptionError("Illegal Access Error: you must call the register() method before invoking the append() method.");
924
- return this.register(this._lastRef, subscription);
925
- }
926
- /**
927
- * Unsubscribes and removes all `Subscription` instances associated with the specified reference.
928
- *
929
- * @param ref The reference for which to remove all `Subscription` instances.
930
- * Can be either a string or an `Identifiable` object.
931
- *
932
- * @returns `true` whether the specified reference exists; `false` otherwise.
933
- */
934
- clearAll(ref) {
935
- const REF = this.getRef(ref);
936
- let result = false;
937
- if (this._lastRef === REF)
938
- this._lastRef = null;
939
- if (this._subMap.has(REF)) {
940
- this._subMap.get(REF)?.forEach(subscription => {
941
- if (!subscription.closed)
942
- subscription.unsubscribe();
943
- });
944
- this._subMap.delete(REF);
945
- result = true;
946
- }
947
- return result;
948
- }
949
- /**
950
- * Returns all `Subscription` instances associated with the specified reference.
951
- *
952
- * @param ref The reference for which to remove get `Subscription` instances.
953
- * Can be either a string or an `Identifiable` object.
954
- *
955
- * @returns All `Subscription` instances associated with the specified reference, or
956
- * `null` whether the specified reference does not exists.
957
- */
958
- get(ref) {
959
- return this._subMap.get(this.getRef(ref)) || null;
960
- }
1095
+ class SubscriptionService extends AbstractSubscriptionManager {
961
1096
  /**
962
1097
  * @private
963
- * Returns the string reference for the regsitration process.
964
- *
965
- * @param ref The reference to be used the regsitration process.
966
- * Can be either a string or an `Identifiable` object.
967
- *
968
- * @returns the string reference for the regsitration process.
969
1098
  */
970
- getRef(ref) {
971
- let targetRef;
972
- if (typeof ref === "string")
973
- targetRef = ref;
974
- else if (ref instanceof IdentifiableComponent)
975
- targetRef = ref.getID().toString();
976
- else
977
- throw new TypeError("ref must be of type of string or Identifiable");
978
- return targetRef;
1099
+ constructor() {
1100
+ super();
979
1101
  }
980
1102
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.3", ngImport: i0, type: SubscriptionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
981
1103
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.3", ngImport: i0, type: SubscriptionService, providedIn: 'root' }); }
@@ -985,7 +1107,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.3", ngImpor
985
1107
  args: [{
986
1108
  providedIn: 'root'
987
1109
  }]
988
- }] });
1110
+ }], ctorParameters: () => [] });
989
1111
 
990
1112
  /**
991
1113
  * @license
@@ -1466,40 +1588,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.3", ngImpor
1466
1588
  args: [DOCUMENT]
1467
1589
  }] }] });
1468
1590
 
1469
- /**
1470
- * @license
1471
- * Copyright Pascal ECHEMANN. All Rights Reserved.
1472
- *
1473
- * Use of this source code is governed by an MIT-style license that can be ound in
1474
- * fthe LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
1475
- */
1476
- /**
1477
- * @private
1478
- * Specifies the semantic versioning of an API.
1479
- */
1480
- class VersionImpl {
1481
- /**
1482
- * @private
1483
- */
1484
- constructor(major, minor, patch, buildTimeStamp) {
1485
- this.major = major;
1486
- this.minor = minor;
1487
- this.patch = patch;
1488
- this.buildTimeStamp = buildTimeStamp;
1489
- }
1490
- /**
1491
- * Returns a string representation of this `Version` object in the form `M.m.p`, where
1492
- * `M` represents the major number, `m` represents the minor number and `p` represents
1493
- * the patch number of this `VersionImpl` instance.
1494
- *
1495
- * @returns A string representation of this `VersionImpl` instance.
1496
- */
1497
- toString() {
1498
- return `${this.major}.${this.minor}.${this.patch}`;
1499
- }
1500
- }
1501
- ;
1502
-
1503
1591
  /**
1504
1592
  * @license
1505
1593
  * Copyright Pascal ECHEMANN. All Rights Reserved.
@@ -1510,29 +1598,13 @@ class VersionImpl {
1510
1598
  /**
1511
1599
  * A lightweight service that provides Semantic Versioning implementation for your Angular projects.
1512
1600
  */
1513
- class VersionService {
1601
+ class VersionService extends AbstractVersionManager {
1514
1602
  /**
1515
1603
  * Creates a new VersionService instance.
1516
1604
  * @param config the reference to the VersionConfig provider.
1517
1605
  */
1518
1606
  constructor(config) {
1519
- this._version = new VersionImpl(config.major, config.minor, config.patch, config.buildTimestamp);
1520
- }
1521
- /**
1522
- * Returns the version of the associated Angular project.
1523
- *
1524
- * @return the version of the associated Angular project.
1525
- */
1526
- getVersion() {
1527
- return this._version;
1528
- }
1529
- /**
1530
- * Returns the build timestamp of the associated Angular project.
1531
- *
1532
- * @return the build timestamp of the associated Angular project.
1533
- */
1534
- getBuildTimestamp() {
1535
- return this._version.buildTimeStamp;
1607
+ super(config);
1536
1608
  }
1537
1609
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.3", ngImport: i0, type: VersionService, deps: [{ token: VERSION_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable }); }
1538
1610
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.3", ngImport: i0, type: VersionService, providedIn: 'root' }); }
@@ -3705,5 +3777,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.3", ngImpor
3705
3777
  * Generated bundle index. Do not edit.
3706
3778
  */
3707
3779
 
3708
- export { APP_PRIDGE_REF, AnchorLinklDirective, AngularToolboxModule, AppBridgeError, AppBrigeService, BIGINT, BOOLEAN, BUTTON_ROLE, ButtonRoleDirective, CSS_PROP, ContentRendererDirective, DARK_MODE_CONFIG, DarkModeService, EMPTY_STRING, FUNCTION, HTTP_MOCK_SERVICE, HttpHeadersMockBuilder, HttpMock, HttpMockService, HttpMockServiceError, HttpResponseMockBuilder, IdentifiableComponent, IntegrityError, LINK_ROLE, NUMBER, NavigateToUrlDirective, OBJECT, STORAGE_KEY, STRING, SYMBOL, SafeHtmlPipe, ScrollService, SubscriptionError, SubscriptionService, UNDEFINED, Uuid, VERSION_CONFIG, VersionService, httpHeadersMock, httpMockFactory, httpResponseMock };
3780
+ export { APP_PRIDGE_REF, AbstractSubscriptionManager, AbstractVersionManager, AnchorLinklDirective, AngularToolboxModule, AppBridgeError, AppBrigeService, BIGINT, BOOLEAN, BUTTON_ROLE, ButtonRoleDirective, CSS_PROP, ContentRendererDirective, DARK_MODE_CONFIG, DarkModeService, EMPTY_STRING, FUNCTION, HTTP_MOCK_SERVICE, HttpHeadersMockBuilder, HttpMock, HttpMockService, HttpMockServiceError, HttpResponseMockBuilder, IdentifiableComponent, IntegrityError, LINK_ROLE, NUMBER, NavigateToUrlDirective, OBJECT, STORAGE_KEY, STRING, SYMBOL, SafeHtmlPipe, ScrollService, SubscriptionError, SubscriptionService, UNDEFINED, Uuid, VERSION_CONFIG, VersionService, httpHeadersMock, httpMockFactory, httpResponseMock };
3709
3781
  //# sourceMappingURL=angular-toolbox.mjs.map