angular-toolbox 0.9.2 → 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 (26) 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/index.mjs +2 -1
  6. package/esm2022/lib/model/business/index.mjs +2 -1
  7. package/esm2022/lib/model/business/subscription/index.mjs +2 -0
  8. package/esm2022/lib/model/business/subscription/subscription-manager.mjs +9 -0
  9. package/esm2022/lib/model/business/version/index.mjs +2 -1
  10. package/esm2022/lib/model/business/version/version-manager.mjs +10 -0
  11. package/esm2022/lib/model/service/subscription/subscription.service.mjs +6 -98
  12. package/esm2022/lib/model/service/version/version.service.mjs +4 -20
  13. package/fesm2022/angular-toolbox.mjs +204 -148
  14. package/fesm2022/angular-toolbox.mjs.map +1 -1
  15. package/lib/core/abstract/abstract-subscription-manager.d.ts +73 -0
  16. package/lib/core/abstract/abstract-version-manager.d.ts +34 -0
  17. package/lib/core/abstract/index.d.ts +2 -0
  18. package/lib/core/index.d.ts +1 -0
  19. package/lib/model/business/index.d.ts +1 -0
  20. package/lib/model/business/subscription/index.d.ts +1 -0
  21. package/lib/model/business/subscription/subscription-manager.d.ts +52 -0
  22. package/lib/model/business/version/index.d.ts +1 -0
  23. package/lib/model/business/version/version-manager.d.ts +25 -0
  24. package/lib/model/service/subscription/subscription.service.d.ts +3 -59
  25. package/lib/model/service/version/version.service.d.ts +3 -18
  26. package/package.json +1 -1
@@ -366,6 +366,186 @@ class IdentifiableComponent {
366
366
  }
367
367
  ;
368
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
+
369
549
  /**
370
550
  * @license
371
551
  * Copyright Pascal ECHEMANN. All Rights Reserved.
@@ -723,6 +903,15 @@ const VERSION_CONFIG = {
723
903
  buildTimestamp: NaN
724
904
  };
725
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
+
726
915
  /**
727
916
  * @license
728
917
  * Copyright Pascal ECHEMANN. All Rights Reserved.
@@ -885,6 +1074,14 @@ const DARK_MODE_CONFIG = {
885
1074
  * the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
886
1075
  */
887
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
+
888
1085
  /**
889
1086
  * @license
890
1087
  * Copyright Pascal ECHEMANN. All Rights Reserved.
@@ -895,103 +1092,12 @@ const DARK_MODE_CONFIG = {
895
1092
  /**
896
1093
  * A lightweight service that helps to manage unregistration issues of Angular subscriptions.
897
1094
  */
898
- class SubscriptionService {
899
- constructor() {
900
- /**
901
- * @private
902
- * Stores an internal reference to the last reference used with the `register()`
903
- * method.
904
- */
905
- this._lastRef = null;
906
- /**
907
- * @private
908
- * The internal `Subscription` instances storage.
909
- */
910
- this._subMap = new Map();
911
- }
912
- /**
913
- * Stores a new `Subscription` instance associated with the specified reference.
914
- *
915
- * @param ref The reference for which to store a new `Subscription` instance.
916
- * Can be either a string or an `Identifiable` object.
917
- * @param subscription The `Subscription` instance to register.
918
- *
919
- * @returns A reference to this `SubscriptionService` instance.
920
- */
921
- register(ref, subscription) {
922
- const REF = this.getRef(ref);
923
- this._lastRef = REF;
924
- if (!this._subMap.has(REF))
925
- this._subMap.set(REF, []);
926
- this._subMap.get(REF)?.push(subscription);
927
- return this;
928
- }
929
- /**
930
- * Stores a new `Subscription` instance associated with the reference specified
931
- * by the last `register()` method invokation.
932
- *
933
- * @param subscription The `Subscription` instance to register.
934
- *
935
- * @returns A reference to this `SubscriptionService` instance.
936
- */
937
- append(subscription) {
938
- if (!this._lastRef)
939
- throw new SubscriptionError("Illegal Access Error: you must call the register() method before invoking the append() method.");
940
- return this.register(this._lastRef, subscription);
941
- }
942
- /**
943
- * Unsubscribes and removes all `Subscription` instances associated with the specified reference.
944
- *
945
- * @param ref The reference for which to remove all `Subscription` instances.
946
- * Can be either a string or an `Identifiable` object.
947
- *
948
- * @returns `true` whether the specified reference exists; `false` otherwise.
949
- */
950
- clearAll(ref) {
951
- const REF = this.getRef(ref);
952
- let result = false;
953
- if (this._lastRef === REF)
954
- this._lastRef = null;
955
- if (this._subMap.has(REF)) {
956
- this._subMap.get(REF)?.forEach(subscription => {
957
- if (!subscription.closed)
958
- subscription.unsubscribe();
959
- });
960
- this._subMap.delete(REF);
961
- result = true;
962
- }
963
- return result;
964
- }
965
- /**
966
- * Returns all `Subscription` instances associated with the specified reference.
967
- *
968
- * @param ref The reference for which to remove get `Subscription` instances.
969
- * Can be either a string or an `Identifiable` object.
970
- *
971
- * @returns All `Subscription` instances associated with the specified reference, or
972
- * `null` whether the specified reference does not exists.
973
- */
974
- get(ref) {
975
- return this._subMap.get(this.getRef(ref)) || null;
976
- }
1095
+ class SubscriptionService extends AbstractSubscriptionManager {
977
1096
  /**
978
1097
  * @private
979
- * Returns the string reference for the regsitration process.
980
- *
981
- * @param ref The reference to be used the regsitration process.
982
- * Can be either a string or an `Identifiable` object.
983
- *
984
- * @returns the string reference for the regsitration process.
985
1098
  */
986
- getRef(ref) {
987
- let targetRef;
988
- if (typeof ref === "string")
989
- targetRef = ref;
990
- else if (ref instanceof IdentifiableComponent)
991
- targetRef = ref.getID().toString();
992
- else
993
- throw new TypeError("ref must be of type of string or Identifiable");
994
- return targetRef;
1099
+ constructor() {
1100
+ super();
995
1101
  }
996
1102
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.3", ngImport: i0, type: SubscriptionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
997
1103
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.3", ngImport: i0, type: SubscriptionService, providedIn: 'root' }); }
@@ -1001,7 +1107,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.3", ngImpor
1001
1107
  args: [{
1002
1108
  providedIn: 'root'
1003
1109
  }]
1004
- }] });
1110
+ }], ctorParameters: () => [] });
1005
1111
 
1006
1112
  /**
1007
1113
  * @license
@@ -1482,40 +1588,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.3", ngImpor
1482
1588
  args: [DOCUMENT]
1483
1589
  }] }] });
1484
1590
 
1485
- /**
1486
- * @license
1487
- * Copyright Pascal ECHEMANN. All Rights Reserved.
1488
- *
1489
- * Use of this source code is governed by an MIT-style license that can be ound in
1490
- * fthe LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
1491
- */
1492
- /**
1493
- * @private
1494
- * Specifies the semantic versioning of an API.
1495
- */
1496
- class VersionImpl {
1497
- /**
1498
- * @private
1499
- */
1500
- constructor(major, minor, patch, buildTimeStamp) {
1501
- this.major = major;
1502
- this.minor = minor;
1503
- this.patch = patch;
1504
- this.buildTimeStamp = buildTimeStamp;
1505
- }
1506
- /**
1507
- * Returns a string representation of this `Version` object in the form `M.m.p`, where
1508
- * `M` represents the major number, `m` represents the minor number and `p` represents
1509
- * the patch number of this `VersionImpl` instance.
1510
- *
1511
- * @returns A string representation of this `VersionImpl` instance.
1512
- */
1513
- toString() {
1514
- return `${this.major}.${this.minor}.${this.patch}`;
1515
- }
1516
- }
1517
- ;
1518
-
1519
1591
  /**
1520
1592
  * @license
1521
1593
  * Copyright Pascal ECHEMANN. All Rights Reserved.
@@ -1526,29 +1598,13 @@ class VersionImpl {
1526
1598
  /**
1527
1599
  * A lightweight service that provides Semantic Versioning implementation for your Angular projects.
1528
1600
  */
1529
- class VersionService {
1601
+ class VersionService extends AbstractVersionManager {
1530
1602
  /**
1531
1603
  * Creates a new VersionService instance.
1532
1604
  * @param config the reference to the VersionConfig provider.
1533
1605
  */
1534
1606
  constructor(config) {
1535
- this._version = new VersionImpl(config.major, config.minor, config.patch, config.buildTimestamp);
1536
- }
1537
- /**
1538
- * Returns the version of the associated Angular project.
1539
- *
1540
- * @return the version of the associated Angular project.
1541
- */
1542
- getVersion() {
1543
- return this._version;
1544
- }
1545
- /**
1546
- * Returns the build timestamp of the associated Angular project.
1547
- *
1548
- * @return the build timestamp of the associated Angular project.
1549
- */
1550
- getBuildTimestamp() {
1551
- return this._version.buildTimeStamp;
1607
+ super(config);
1552
1608
  }
1553
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 }); }
1554
1610
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.3", ngImport: i0, type: VersionService, providedIn: 'root' }); }
@@ -3721,5 +3777,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.3", ngImpor
3721
3777
  * Generated bundle index. Do not edit.
3722
3778
  */
3723
3779
 
3724
- 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 };
3725
3781
  //# sourceMappingURL=angular-toolbox.mjs.map