@adaas/a-utils 0.3.5 → 0.3.7

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 (63) hide show
  1. package/.conf/tsconfig.browser.json +4 -1
  2. package/.conf/tsconfig.node.json +5 -2
  3. package/dist/browser/a-service.mjs +12 -12
  4. package/dist/browser/a-service.mjs.map +1 -1
  5. package/dist/browser/a-signal.d.mts +51 -30
  6. package/dist/browser/a-signal.mjs +100 -65
  7. package/dist/browser/a-signal.mjs.map +1 -1
  8. package/dist/browser/chunk-S2RSPZXR.mjs +143 -0
  9. package/dist/browser/chunk-S2RSPZXR.mjs.map +1 -0
  10. package/dist/browser/helpers.d.mts +56 -0
  11. package/dist/browser/helpers.mjs +5 -0
  12. package/dist/browser/helpers.mjs.map +1 -0
  13. package/dist/node/{A-Signal.types-P5VKMKMs.d.mts → A-Signal.types-DxQHmPm6.d.mts} +23 -27
  14. package/dist/node/{A-Signal.types-P5VKMKMs.d.ts → A-Signal.types-DxQHmPm6.d.ts} +23 -27
  15. package/dist/node/helpers/A-Utils.helper.d.mts +56 -0
  16. package/dist/node/helpers/A-Utils.helper.d.ts +56 -0
  17. package/dist/node/helpers/A-Utils.helper.js +153 -0
  18. package/dist/node/helpers/A-Utils.helper.js.map +1 -0
  19. package/dist/node/helpers/A-Utils.helper.mjs +143 -0
  20. package/dist/node/helpers/A-Utils.helper.mjs.map +1 -0
  21. package/dist/node/helpers/index.d.mts +3 -0
  22. package/dist/node/helpers/index.d.ts +3 -0
  23. package/dist/node/helpers/index.js +12 -0
  24. package/dist/node/helpers/index.js.map +1 -0
  25. package/dist/node/helpers/index.mjs +4 -0
  26. package/dist/node/helpers/index.mjs.map +1 -0
  27. package/dist/node/lib/A-Service/A-Service.container.js +12 -12
  28. package/dist/node/lib/A-Service/A-Service.container.js.map +1 -1
  29. package/dist/node/lib/A-Service/A-Service.container.mjs +12 -12
  30. package/dist/node/lib/A-Service/A-Service.container.mjs.map +1 -1
  31. package/dist/node/lib/A-Signal/A-Signal.types.d.mts +1 -1
  32. package/dist/node/lib/A-Signal/A-Signal.types.d.ts +1 -1
  33. package/dist/node/lib/A-Signal/components/A-SignalBus.component.d.mts +1 -1
  34. package/dist/node/lib/A-Signal/components/A-SignalBus.component.d.ts +1 -1
  35. package/dist/node/lib/A-Signal/context/A-SignalConfig.context.d.mts +1 -1
  36. package/dist/node/lib/A-Signal/context/A-SignalConfig.context.d.ts +1 -1
  37. package/dist/node/lib/A-Signal/context/A-SignalState.context.d.mts +1 -1
  38. package/dist/node/lib/A-Signal/context/A-SignalState.context.d.ts +1 -1
  39. package/dist/node/lib/A-Signal/entities/A-Signal.entity.d.mts +1 -1
  40. package/dist/node/lib/A-Signal/entities/A-Signal.entity.d.ts +1 -1
  41. package/dist/node/lib/A-Signal/entities/A-Signal.entity.js +35 -59
  42. package/dist/node/lib/A-Signal/entities/A-Signal.entity.js.map +1 -1
  43. package/dist/node/lib/A-Signal/entities/A-Signal.entity.mjs +35 -59
  44. package/dist/node/lib/A-Signal/entities/A-Signal.entity.mjs.map +1 -1
  45. package/dist/node/lib/A-Signal/entities/A-SignalVector.entity.d.mts +29 -4
  46. package/dist/node/lib/A-Signal/entities/A-SignalVector.entity.d.ts +29 -4
  47. package/dist/node/lib/A-Signal/entities/A-SignalVector.entity.js +64 -5
  48. package/dist/node/lib/A-Signal/entities/A-SignalVector.entity.js.map +1 -1
  49. package/dist/node/lib/A-Signal/entities/A-SignalVector.entity.mjs +65 -6
  50. package/dist/node/lib/A-Signal/entities/A-SignalVector.entity.mjs.map +1 -1
  51. package/dist/node/lib/A-Signal/index.d.mts +1 -1
  52. package/dist/node/lib/A-Signal/index.d.ts +1 -1
  53. package/jest.config.ts +3 -1
  54. package/package.json +19 -3
  55. package/src/helpers/A-Utils.helper.ts +186 -0
  56. package/src/helpers/index.ts +1 -0
  57. package/src/lib/A-Service/A-Service.container.ts +12 -12
  58. package/src/lib/A-Signal/A-Signal.types.ts +2 -2
  59. package/src/lib/A-Signal/entities/A-Signal.entity.ts +44 -84
  60. package/src/lib/A-Signal/entities/A-SignalVector.entity.ts +80 -11
  61. package/tests/A-Signal.test.ts +16 -12
  62. package/tsconfig.json +4 -1
  63. package/tsup.config.ts +2 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/A-Service/A-Service.container.ts"],"names":["A_Service","A_Container","A_ServiceFeatures","A_Service_Error","A_Error","A_Polyfill","A_Concept","A_Feature","A_Logger","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAmBaA,iBAAA,GAAN,wBAAwBC,oBAAA,CAAY;AAAA;AAAA;AAAA;AAAA,EAOvC,MAAM,IAAA,GAAO;AACT,IAAA,IAAI;AACA,MAAA,MAAM,IAAA,CAAK,IAAA,CAAKC,oCAAA,CAAkB,YAAY,CAAA;AAE9C,MAAA,MAAM,IAAA,CAAK,IAAA,CAAKA,oCAAA,CAAkB,MAAM,CAAA;AAExC,MAAA,MAAM,IAAA,CAAK,IAAA,CAAKA,oCAAA,CAAkB,WAAW,CAAA;AAAA,IAEjD,SAAS,KAAA,EAAO;AAEZ,MAAA,IAAI,YAAA;AAEJ,MAAA,QAAQ,IAAA;AAAM,QACV,KAAK,KAAA,YAAiBC,8BAAA;AAClB,UAAA,YAAA,GAAe,KAAA;AACf,UAAA;AAAA,QAEJ,MAAK,KAAA,YAAiBC,gBAAA,IAAW,KAAA,CAAM,aAAA,YAAyBD,8BAAA;AAC5D,UAAA,YAAA,GAAe,KAAA,CAAM,aAAA;AACrB,UAAA;AAAA,QAEJ;AACI,UAAA,YAAA,GAAe,IAAIA,8BAAA,CAAgB;AAAA,YAC/B,OAAOA,8BAAA,CAAgB,gBAAA;AAAA,YACvB,WAAA,EAAa,iDAAA;AAAA,YACb,aAAA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,EALNS,eAAQ,SAAA,CAAU;AAAA,IACf,SAAA,EAAW,SAAA;AAAA,IACX,IAAA,EAAM,WAAA;AAAA,IACN,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYT,iBAAA,CAAA","file":"A-Service.container.js","sourcesContent":["import { A_Concept, A_Container, A_Error, A_Feature, A_Inject } from \"@adaas/a-concept\";\nimport { A_ServiceFeatures } from \"./A-Service.constants\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Service_Error } from \"./A-Service.error\";\nimport { A_Frame } from \"@adaas/a-frame\";\nimport { A_Polyfill } from '@adaas/a-utils/a-polyfill';\n\n\n\n/**\n * A-Service is a container that can run different types of services, such as HTTP servers, workers, etc.\n * Depending on the provided config and configuration, it will load the necessary components and start the service.\n * \n */\n@A_Frame.Container({\n namespace: 'A-Utils',\n name: 'A-Service',\n description: 'Service container that manages the lifecycle of various types of services, such as HTTP servers and workers or UI loader. It dynamically loads necessary components based on the provided configuration and orchestrates the start and stop processes, ensuring proper error handling and extensibility through feature hooks.'\n})\nexport class A_Service extends A_Container {\n\n\n @A_Concept.Load()\n /**\n * Load the service\n */\n async load() {\n try {\n await this.call(A_ServiceFeatures.onBeforeLoad);\n\n await this.call(A_ServiceFeatures.onLoad);\n\n await this.call(A_ServiceFeatures.onAfterLoad);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceLoadError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError);\n }\n\n }\n\n\n @A_Concept.Start()\n /**\n * Start the server\n */\n async start() {\n try {\n await this.call(A_ServiceFeatures.onBeforeStart);\n\n await this.call(A_ServiceFeatures.onStart);\n\n await this.call(A_ServiceFeatures.onAfterStart);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceStartError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError);\n }\n\n }\n\n @A_Concept.Stop()\n /**\n * Stop the server\n */\n async stop() {\n try {\n await this.call(A_ServiceFeatures.onBeforeStop);\n\n await this.call(A_ServiceFeatures.onStop);\n\n await this.call(A_ServiceFeatures.onAfterStop);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceStopError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError);\n }\n }\n\n\n\n\n // ======================================================================================\n // ============================= A-Service Lifecycle =================================\n // ======================================================================================\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeLoad](\n @A_Inject(A_Polyfill) polyfill: A_Polyfill,\n ...args: any[]\n ): Promise<void> {\n // Initialize Polyfill\n if (!polyfill) {\n this.scope.register(A_Polyfill);\n polyfill = this.scope.resolve(A_Polyfill)!\n }\n }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onLoad](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterLoad](...args: any[]) { }\n\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeStart](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onStart](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterStart](...args: any[]) { }\n\n\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeStop](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onStop](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterStop](...args: any[]) { }\n\n\n\n @A_Feature.Extend({\n before: /.*/\n })\n protected async [A_ServiceFeatures.onError](\n @A_Inject(A_Error) error: A_Error,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n logger?.error(error);\n }\n\n}\n\n\n\n\n\n\n\n\n"]}
1
+ {"version":3,"sources":["../../../../src/lib/A-Service/A-Service.container.ts"],"names":["A_Service","A_Container","A_ServiceFeatures","A_Service_Error","A_Error","A_Polyfill","A_Concept","A_Feature","A_Logger","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAmBaA,iBAAA,GAAN,wBAAwBC,oBAAA,CAAY;AAAA;AAAA;AAAA;AAAA,EAOvC,MAAM,IAAA,GAAO;AACT,IAAA,IAAI;AACA,MAAA,MAAM,IAAA,CAAK,IAAA,CAAKC,oCAAA,CAAkB,YAAA,EAAc,KAAK,KAAK,CAAA;AAE1D,MAAA,MAAM,IAAA,CAAK,IAAA,CAAKA,oCAAA,CAAkB,MAAA,EAAQ,KAAK,KAAK,CAAA;AAEpD,MAAA,MAAM,IAAA,CAAK,IAAA,CAAKA,oCAAA,CAAkB,WAAA,EAAa,KAAK,KAAK,CAAA;AAAA,IAE7D,SAAS,KAAA,EAAO;AAEZ,MAAA,IAAI,YAAA;AAEJ,MAAA,QAAQ,IAAA;AAAM,QACV,KAAK,KAAA,YAAiBC,8BAAA;AAClB,UAAA,YAAA,GAAe,KAAA;AACf,UAAA;AAAA,QAEJ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Q,SAAA,EAAA,EAAA,EAAA,CAAA,CAAA;AAGA,eAAA,CAAA;AAAA,EADhBO,mBAAU,MAAA;AAAO,CAAA,EAzKTP,iBAAA,CA0KQ,SAAA,EAAA,EAAA,EAAA,CAAA,CAAA;AAOA,eAAA,CAAA;AAAA,EAHhBO,mBAAU,MAAA,CAAO;AAAA,IACd,MAAA,EAAQ;AAAA,GACX,CAAA;AAAA,EAEI,qCAASH,gBAAO,CAAA,CAAA;AAAA,EAChB,qCAASI,gBAAQ,CAAA;AAAA,CAAA,EAnLbR,iBAAA,CAiLQ,SAAA,EAAA,EAAA,EAAA,CAAA,CAAA;AAjLRA,iBAAA,GAAN,eAAA,CAAA;AAAA,EALNS,eAAQ,SAAA,CAAU;AAAA,IACf,SAAA,EAAW,SAAA;AAAA,IACX,IAAA,EAAM,WAAA;AAAA,IACN,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYT,iBAAA,CAAA","file":"A-Service.container.js","sourcesContent":["import { A_Concept, A_Container, A_Error, A_Feature, A_Inject } from \"@adaas/a-concept\";\nimport { A_ServiceFeatures } from \"./A-Service.constants\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Service_Error } from \"./A-Service.error\";\nimport { A_Frame } from \"@adaas/a-frame\";\nimport { A_Polyfill } from '@adaas/a-utils/a-polyfill';\n\n\n\n/**\n * A-Service is a container that can run different types of services, such as HTTP servers, workers, etc.\n * Depending on the provided config and configuration, it will load the necessary components and start the service.\n * \n */\n@A_Frame.Container({\n namespace: 'A-Utils',\n name: 'A-Service',\n description: 'Service container that manages the lifecycle of various types of services, such as HTTP servers and workers or UI loader. It dynamically loads necessary components based on the provided configuration and orchestrates the start and stop processes, ensuring proper error handling and extensibility through feature hooks.'\n})\nexport class A_Service extends A_Container {\n\n\n @A_Concept.Load()\n /**\n * Load the service\n */\n async load() {\n try {\n await this.call(A_ServiceFeatures.onBeforeLoad, this.scope);\n\n await this.call(A_ServiceFeatures.onLoad, this.scope);\n\n await this.call(A_ServiceFeatures.onAfterLoad, this.scope);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceLoadError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError, this.scope);\n }\n\n }\n\n\n @A_Concept.Start()\n /**\n * Start the server\n */\n async start() {\n try {\n await this.call(A_ServiceFeatures.onBeforeStart, this.scope);\n\n await this.call(A_ServiceFeatures.onStart, this.scope);\n\n await this.call(A_ServiceFeatures.onAfterStart, this.scope);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceStartError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError, this.scope);\n }\n\n }\n\n @A_Concept.Stop()\n /**\n * Stop the server\n */\n async stop() {\n try {\n await this.call(A_ServiceFeatures.onBeforeStop, this.scope);\n\n await this.call(A_ServiceFeatures.onStop, this.scope);\n\n await this.call(A_ServiceFeatures.onAfterStop, this.scope);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceStopError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError, this.scope);\n }\n }\n\n\n\n\n // ======================================================================================\n // ============================= A-Service Lifecycle =================================\n // ======================================================================================\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeLoad](\n @A_Inject(A_Polyfill) polyfill: A_Polyfill,\n ...args: any[]\n ): Promise<void> {\n // Initialize Polyfill\n if (!polyfill) {\n this.scope.register(A_Polyfill);\n polyfill = this.scope.resolve(A_Polyfill)!\n }\n }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onLoad](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterLoad](...args: any[]) { }\n\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeStart](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onStart](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterStart](...args: any[]) { }\n\n\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeStop](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onStop](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterStop](...args: any[]) { }\n\n\n\n @A_Feature.Extend({\n before: /.*/\n })\n protected async [A_ServiceFeatures.onError](\n @A_Inject(A_Error) error: A_Error,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n logger?.error(error);\n }\n\n}\n\n\n\n\n\n\n\n\n"]}
@@ -13,9 +13,9 @@ let A_Service = class extends A_Container {
13
13
  */
14
14
  async load() {
15
15
  try {
16
- await this.call(A_ServiceFeatures.onBeforeLoad);
17
- await this.call(A_ServiceFeatures.onLoad);
18
- await this.call(A_ServiceFeatures.onAfterLoad);
16
+ await this.call(A_ServiceFeatures.onBeforeLoad, this.scope);
17
+ await this.call(A_ServiceFeatures.onLoad, this.scope);
18
+ await this.call(A_ServiceFeatures.onAfterLoad, this.scope);
19
19
  } catch (error) {
20
20
  let wrappedError;
21
21
  switch (true) {
@@ -34,7 +34,7 @@ let A_Service = class extends A_Container {
34
34
  break;
35
35
  }
36
36
  this.scope.register(wrappedError);
37
- await this.call(A_ServiceFeatures.onError);
37
+ await this.call(A_ServiceFeatures.onError, this.scope);
38
38
  }
39
39
  }
40
40
  /**
@@ -42,9 +42,9 @@ let A_Service = class extends A_Container {
42
42
  */
43
43
  async start() {
44
44
  try {
45
- await this.call(A_ServiceFeatures.onBeforeStart);
46
- await this.call(A_ServiceFeatures.onStart);
47
- await this.call(A_ServiceFeatures.onAfterStart);
45
+ await this.call(A_ServiceFeatures.onBeforeStart, this.scope);
46
+ await this.call(A_ServiceFeatures.onStart, this.scope);
47
+ await this.call(A_ServiceFeatures.onAfterStart, this.scope);
48
48
  } catch (error) {
49
49
  let wrappedError;
50
50
  switch (true) {
@@ -63,7 +63,7 @@ let A_Service = class extends A_Container {
63
63
  break;
64
64
  }
65
65
  this.scope.register(wrappedError);
66
- await this.call(A_ServiceFeatures.onError);
66
+ await this.call(A_ServiceFeatures.onError, this.scope);
67
67
  }
68
68
  }
69
69
  /**
@@ -71,9 +71,9 @@ let A_Service = class extends A_Container {
71
71
  */
72
72
  async stop() {
73
73
  try {
74
- await this.call(A_ServiceFeatures.onBeforeStop);
75
- await this.call(A_ServiceFeatures.onStop);
76
- await this.call(A_ServiceFeatures.onAfterStop);
74
+ await this.call(A_ServiceFeatures.onBeforeStop, this.scope);
75
+ await this.call(A_ServiceFeatures.onStop, this.scope);
76
+ await this.call(A_ServiceFeatures.onAfterStop, this.scope);
77
77
  } catch (error) {
78
78
  let wrappedError;
79
79
  switch (true) {
@@ -92,7 +92,7 @@ let A_Service = class extends A_Container {
92
92
  break;
93
93
  }
94
94
  this.scope.register(wrappedError);
95
- await this.call(A_ServiceFeatures.onError);
95
+ await this.call(A_ServiceFeatures.onError, this.scope);
96
96
  }
97
97
  }
98
98
  async [_j = A_ServiceFeatures.onBeforeLoad](polyfill, ...args) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/A-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B,UAAU,MAAA;AAAO,CAAA,EA3JT,SAAA,CA4JQ,SAAA,EAAA,EAAA,EAAA,CAAA,CAAA;AAGC,eAAA,CAAA;AAAA,EADjB,UAAU,MAAA;AAAO,CAAA,EA9JT,SAAA,CA+JS,SAAA,EAAA,EAAA,EAAA,CAAA,CAAA;AAKD,eAAA,CAAA;AAAA,EADhB,UAAU,MAAA;AAAO,CAAA,EAnKT,SAAA,CAoKQ,SAAA,EAAA,EAAA,EAAA,CAAA,CAAA;AAGA,eAAA,CAAA;AAAA,EADhB,UAAU,MAAA;AAAO,CAAA,EAtKT,SAAA,CAuKQ,SAAA,EAAA,EAAA,EAAA,CAAA,CAAA;AAGA,eAAA,CAAA;AAAA,EADhB,UAAU,MAAA;AAAO,CAAA,EAzKT,SAAA,CA0KQ,SAAA,EAAA,EAAA,EAAA,CAAA,CAAA;AAOA,eAAA,CAAA;AAAA,EAHhB,UAAU,MAAA,CAAO;AAAA,IACd,MAAA,EAAQ;AAAA,GACX,CAAA;AAAA,EAEI,4BAAS,OAAO,CAAA,CAAA;AAAA,EAChB,4BAAS,QAAQ,CAAA;AAAA,CAAA,EAnLb,SAAA,CAiLQ,SAAA,EAAA,EAAA,EAAA,CAAA,CAAA;AAjLR,SAAA,GAAN,eAAA,CAAA;AAAA,EALN,QAAQ,SAAA,CAAU;AAAA,IACf,SAAA,EAAW,SAAA;AAAA,IACX,IAAA,EAAM,WAAA;AAAA,IACN,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,SAAA,CAAA","file":"A-Service.container.mjs","sourcesContent":["import { A_Concept, A_Container, A_Error, A_Feature, A_Inject } from \"@adaas/a-concept\";\nimport { A_ServiceFeatures } from \"./A-Service.constants\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Service_Error } from \"./A-Service.error\";\nimport { A_Frame } from \"@adaas/a-frame\";\nimport { A_Polyfill } from '@adaas/a-utils/a-polyfill';\n\n\n\n/**\n * A-Service is a container that can run different types of services, such as HTTP servers, workers, etc.\n * Depending on the provided config and configuration, it will load the necessary components and start the service.\n * \n */\n@A_Frame.Container({\n namespace: 'A-Utils',\n name: 'A-Service',\n description: 'Service container that manages the lifecycle of various types of services, such as HTTP servers and workers or UI loader. It dynamically loads necessary components based on the provided configuration and orchestrates the start and stop processes, ensuring proper error handling and extensibility through feature hooks.'\n})\nexport class A_Service extends A_Container {\n\n\n @A_Concept.Load()\n /**\n * Load the service\n */\n async load() {\n try {\n await this.call(A_ServiceFeatures.onBeforeLoad);\n\n await this.call(A_ServiceFeatures.onLoad);\n\n await this.call(A_ServiceFeatures.onAfterLoad);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceLoadError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError);\n }\n\n }\n\n\n @A_Concept.Start()\n /**\n * Start the server\n */\n async start() {\n try {\n await this.call(A_ServiceFeatures.onBeforeStart);\n\n await this.call(A_ServiceFeatures.onStart);\n\n await this.call(A_ServiceFeatures.onAfterStart);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceStartError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError);\n }\n\n }\n\n @A_Concept.Stop()\n /**\n * Stop the server\n */\n async stop() {\n try {\n await this.call(A_ServiceFeatures.onBeforeStop);\n\n await this.call(A_ServiceFeatures.onStop);\n\n await this.call(A_ServiceFeatures.onAfterStop);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceStopError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError);\n }\n }\n\n\n\n\n // ======================================================================================\n // ============================= A-Service Lifecycle =================================\n // ======================================================================================\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeLoad](\n @A_Inject(A_Polyfill) polyfill: A_Polyfill,\n ...args: any[]\n ): Promise<void> {\n // Initialize Polyfill\n if (!polyfill) {\n this.scope.register(A_Polyfill);\n polyfill = this.scope.resolve(A_Polyfill)!\n }\n }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onLoad](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterLoad](...args: any[]) { }\n\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeStart](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onStart](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterStart](...args: any[]) { }\n\n\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeStop](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onStop](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterStop](...args: any[]) { }\n\n\n\n @A_Feature.Extend({\n before: /.*/\n })\n protected async [A_ServiceFeatures.onError](\n @A_Inject(A_Error) error: A_Error,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n logger?.error(error);\n }\n\n}\n\n\n\n\n\n\n\n\n"]}
1
+ {"version":3,"sources":["../../../../src/lib/A-Service/A-Service.container.ts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A_ServiceFeatures } from \"./A-Service.constants\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Service_Error } from \"./A-Service.error\";\nimport { A_Frame } from \"@adaas/a-frame\";\nimport { A_Polyfill } from '@adaas/a-utils/a-polyfill';\n\n\n\n/**\n * A-Service is a container that can run different types of services, such as HTTP servers, workers, etc.\n * Depending on the provided config and configuration, it will load the necessary components and start the service.\n * \n */\n@A_Frame.Container({\n namespace: 'A-Utils',\n name: 'A-Service',\n description: 'Service container that manages the lifecycle of various types of services, such as HTTP servers and workers or UI loader. It dynamically loads necessary components based on the provided configuration and orchestrates the start and stop processes, ensuring proper error handling and extensibility through feature hooks.'\n})\nexport class A_Service extends A_Container {\n\n\n @A_Concept.Load()\n /**\n * Load the service\n */\n async load() {\n try {\n await this.call(A_ServiceFeatures.onBeforeLoad, this.scope);\n\n await this.call(A_ServiceFeatures.onLoad, this.scope);\n\n await this.call(A_ServiceFeatures.onAfterLoad, this.scope);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceLoadError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError, this.scope);\n }\n\n }\n\n\n @A_Concept.Start()\n /**\n * Start the server\n */\n async start() {\n try {\n await this.call(A_ServiceFeatures.onBeforeStart, this.scope);\n\n await this.call(A_ServiceFeatures.onStart, this.scope);\n\n await this.call(A_ServiceFeatures.onAfterStart, this.scope);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceStartError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError, this.scope);\n }\n\n }\n\n @A_Concept.Stop()\n /**\n * Stop the server\n */\n async stop() {\n try {\n await this.call(A_ServiceFeatures.onBeforeStop, this.scope);\n\n await this.call(A_ServiceFeatures.onStop, this.scope);\n\n await this.call(A_ServiceFeatures.onAfterStop, this.scope);\n\n } catch (error) {\n\n let wrappedError;\n\n switch (true) {\n case error instanceof A_Service_Error:\n wrappedError = error;\n break;\n\n case error instanceof A_Error && error.originalError instanceof A_Service_Error:\n wrappedError = error.originalError;\n break;\n\n default:\n wrappedError = new A_Service_Error({\n title: A_Service_Error.ServiceStopError,\n description: 'An error occurred while processing the request.',\n originalError: error\n })\n break;\n }\n\n this.scope.register(wrappedError);\n\n await this.call(A_ServiceFeatures.onError, this.scope);\n }\n }\n\n\n\n\n // ======================================================================================\n // ============================= A-Service Lifecycle =================================\n // ======================================================================================\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeLoad](\n @A_Inject(A_Polyfill) polyfill: A_Polyfill,\n ...args: any[]\n ): Promise<void> {\n // Initialize Polyfill\n if (!polyfill) {\n this.scope.register(A_Polyfill);\n polyfill = this.scope.resolve(A_Polyfill)!\n }\n }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onLoad](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterLoad](...args: any[]) { }\n\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeStart](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onStart](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterStart](...args: any[]) { }\n\n\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onBeforeStop](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onStop](...args: any[]) { }\n\n @A_Feature.Extend()\n protected async [A_ServiceFeatures.onAfterStop](...args: any[]) { }\n\n\n\n @A_Feature.Extend({\n before: /.*/\n })\n protected async [A_ServiceFeatures.onError](\n @A_Inject(A_Error) error: A_Error,\n @A_Inject(A_Logger) logger?: A_Logger,\n ...args: any[]\n ) {\n logger?.error(error);\n }\n\n}\n\n\n\n\n\n\n\n\n"]}
@@ -1,2 +1,2 @@
1
1
  import '@adaas/a-concept';
2
- export { a as A_SignalConfig_Init, b as A_SignalTValue, c as A_SignalTValueArray, d as A_SignalVector_Init, e as A_SignalVector_Serialized, f as A_Signal_Init, g as A_Signal_Serialized, h as A_Signal_TSignalsConstructors } from '../../A-Signal.types-P5VKMKMs.mjs';
2
+ export { a as A_SignalConfig_Init, b as A_SignalTValue, c as A_SignalTValueArray, d as A_SignalVector_Init, e as A_SignalVector_Serialized, f as A_Signal_Init, g as A_Signal_Serialized, h as A_Signal_TSignalsConstructors } from '../../A-Signal.types-DxQHmPm6.mjs';
@@ -1,2 +1,2 @@
1
1
  import '@adaas/a-concept';
2
- export { a as A_SignalConfig_Init, b as A_SignalTValue, c as A_SignalTValueArray, d as A_SignalVector_Init, e as A_SignalVector_Serialized, f as A_Signal_Init, g as A_Signal_Serialized, h as A_Signal_TSignalsConstructors } from '../../A-Signal.types-P5VKMKMs.js';
2
+ export { a as A_SignalConfig_Init, b as A_SignalTValue, c as A_SignalTValueArray, d as A_SignalVector_Init, e as A_SignalVector_Serialized, f as A_Signal_Init, g as A_Signal_Serialized, h as A_Signal_TSignalsConstructors } from '../../A-Signal.types-DxQHmPm6.js';
@@ -1,7 +1,7 @@
1
1
  import { A_Component, A_Error, A_Scope } from '@adaas/a-concept';
2
2
  import { A_SignalState } from '../context/A-SignalState.context.mjs';
3
3
  import { A_SignalConfig } from '../context/A-SignalConfig.context.mjs';
4
- import { A as A_Signal } from '../../../A-Signal.types-P5VKMKMs.mjs';
4
+ import { A as A_Signal } from '../../../A-Signal.types-DxQHmPm6.mjs';
5
5
  import { A_Logger } from '../../A-Logger/A-Logger.component.mjs';
6
6
  import { A_Config } from '../../A-Config/A-Config.context.mjs';
7
7
  import { A_SignalBusFeatures } from './A-SignalBus.constants.mjs';
@@ -1,7 +1,7 @@
1
1
  import { A_Component, A_Error, A_Scope } from '@adaas/a-concept';
2
2
  import { A_SignalState } from '../context/A-SignalState.context.js';
3
3
  import { A_SignalConfig } from '../context/A-SignalConfig.context.js';
4
- import { A as A_Signal } from '../../../A-Signal.types-P5VKMKMs.js';
4
+ import { A as A_Signal } from '../../../A-Signal.types-DxQHmPm6.js';
5
5
  import { A_Logger } from '../../A-Logger/A-Logger.component.js';
6
6
  import { A_Config } from '../../A-Config/A-Config.context.js';
7
7
  import { A_SignalBusFeatures } from './A-SignalBus.constants.js';
@@ -1,5 +1,5 @@
1
1
  import { A_Fragment, A_TYPES__Entity_Constructor } from '@adaas/a-concept';
2
- import { A as A_Signal, a as A_SignalConfig_Init } from '../../../A-Signal.types-P5VKMKMs.mjs';
2
+ import { A as A_Signal, a as A_SignalConfig_Init } from '../../../A-Signal.types-DxQHmPm6.mjs';
3
3
 
4
4
  /**
5
5
  * This component should dictate a structure of the vector for all signals within a given scope.
@@ -1,5 +1,5 @@
1
1
  import { A_Fragment, A_TYPES__Entity_Constructor } from '@adaas/a-concept';
2
- import { A as A_Signal, a as A_SignalConfig_Init } from '../../../A-Signal.types-P5VKMKMs.js';
2
+ import { A as A_Signal, a as A_SignalConfig_Init } from '../../../A-Signal.types-DxQHmPm6.js';
3
3
 
4
4
  /**
5
5
  * This component should dictate a structure of the vector for all signals within a given scope.
@@ -1,5 +1,5 @@
1
1
  import { A_Fragment, A_TYPES__Component_Constructor } from '@adaas/a-concept';
2
- import { A as A_Signal } from '../../../A-Signal.types-P5VKMKMs.mjs';
2
+ import { A as A_Signal } from '../../../A-Signal.types-DxQHmPm6.mjs';
3
3
  import { A_SignalVector } from '../entities/A-SignalVector.entity.mjs';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { A_Fragment, A_TYPES__Component_Constructor } from '@adaas/a-concept';
2
- import { A as A_Signal } from '../../../A-Signal.types-P5VKMKMs.js';
2
+ import { A as A_Signal } from '../../../A-Signal.types-DxQHmPm6.js';
3
3
  import { A_SignalVector } from '../entities/A-SignalVector.entity.js';
4
4
 
5
5
  /**
@@ -1,2 +1,2 @@
1
1
  import '@adaas/a-concept';
2
- export { A as A_Signal } from '../../../A-Signal.types-P5VKMKMs.mjs';
2
+ export { A as A_Signal } from '../../../A-Signal.types-DxQHmPm6.mjs';
@@ -1,2 +1,2 @@
1
1
  import '@adaas/a-concept';
2
- export { A as A_Signal } from '../../../A-Signal.types-P5VKMKMs.js';
2
+ export { A as A_Signal } from '../../../A-Signal.types-DxQHmPm6.js';
@@ -2,6 +2,7 @@
2
2
 
3
3
  var aConcept = require('@adaas/a-concept');
4
4
  var aFrame = require('@adaas/a-frame');
5
+ var helpers = require('@adaas/a-utils/helpers');
5
6
 
6
7
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
8
  var __decorateClass = (decorators, target, key, kind) => {
@@ -12,61 +13,6 @@ var __decorateClass = (decorators, target, key, kind) => {
12
13
  return result;
13
14
  };
14
15
  exports.A_Signal = class A_Signal extends aConcept.A_Entity {
15
- // ========================================================================
16
- // ========================== Static Methods ==============================
17
- // ========================================================================
18
- /**
19
- * Allows to define default data for the signal.
20
- *
21
- * If no data is provided during initialization, the default data will be used.
22
- *
23
- * @returns
24
- */
25
- static async default() {
26
- return void 0;
27
- }
28
- createHash(str) {
29
- let hashSource;
30
- if (str instanceof Map) {
31
- hashSource = JSON.stringify(Array.from(str.entries()));
32
- } else if (str instanceof Set) {
33
- hashSource = JSON.stringify(Array.from(str.values()));
34
- } else {
35
- switch (typeof str) {
36
- case "string":
37
- hashSource = str;
38
- break;
39
- case "undefined":
40
- hashSource = "undefined";
41
- break;
42
- case "object":
43
- if ("toJSON" in str)
44
- hashSource = JSON.stringify(str.toJSON());
45
- else
46
- hashSource = JSON.stringify(str);
47
- break;
48
- case "number":
49
- hashSource = str.toString();
50
- break;
51
- case "boolean":
52
- hashSource = str ? "true" : "false";
53
- break;
54
- case "function":
55
- hashSource = str.toString();
56
- break;
57
- default:
58
- hashSource = String(str);
59
- }
60
- }
61
- let hash = 0, i, chr;
62
- for (i = 0; i < hashSource.length; i++) {
63
- chr = hashSource.charCodeAt(i);
64
- hash = (hash << 5) - hash + chr;
65
- hash |= 0;
66
- }
67
- const hashString = hash.toString();
68
- return hashString;
69
- }
70
16
  /**
71
17
  * This method compares the current signal with another signal instance by deduplication ID
72
18
  * this id can be configured during initialization with the "id" property.
@@ -86,22 +32,52 @@ exports.A_Signal = class A_Signal extends aConcept.A_Entity {
86
32
  }
87
33
  return true;
88
34
  }
89
- fromJSON(serializedEntity) {
90
- super.fromJSON(serializedEntity);
91
- this.data = serializedEntity.data;
35
+ /**
36
+ * Allows to define default data for the signal.
37
+ *
38
+ * If no data is provided during initialization, the default data will be used.
39
+ *
40
+ * @returns
41
+ */
42
+ fromUndefined() {
43
+ const name = this.constructor.entity;
44
+ this.data = void 0;
45
+ const identity = {
46
+ name,
47
+ data: this.data
48
+ };
49
+ const id = helpers.A_UtilsHelper.hash(identity);
50
+ this.aseid = this.generateASEID({
51
+ entity: name,
52
+ id
53
+ });
92
54
  }
55
+ /**
56
+ * Allows to initialize the signal from a new signal entity. This is useful for example when we want to create a new instance of the signal entity with the same data as another instance, but with a different ASEID.
57
+ *
58
+ * @param newEntity
59
+ */
93
60
  fromNew(newEntity) {
94
61
  this.data = newEntity.data;
95
62
  const identity = newEntity.id || {
96
63
  name: newEntity.name,
97
64
  data: this.data
98
65
  };
99
- const id = this.createHash(identity);
66
+ const id = helpers.A_UtilsHelper.hash(identity);
100
67
  this.aseid = this.generateASEID({
101
68
  entity: newEntity.name,
102
69
  id
103
70
  });
104
71
  }
72
+ /**
73
+ * Allows to initialize the signal from a serialized version of the signal. This is useful for example when we receive a signal from the server and we want to create an instance of the signal entity from the received data.
74
+ *
75
+ * @param serializedEntity
76
+ */
77
+ fromJSON(serializedEntity) {
78
+ super.fromJSON(serializedEntity);
79
+ this.data = serializedEntity.data;
80
+ }
105
81
  toJSON() {
106
82
  return {
107
83
  ...super.toJSON(),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/lib/A-Signal/entities/A-Signal.entity.ts"],"names":["A_Signal","A_Entity","A_Frame"],"mappings":";;;;;;;;;;;;;AAsBaA,gBAAA,GAAN,uBAEGC,iBAAA,CAAiF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAavF,aAAa,OAAA,GAAyC;AAClD,IAAA,OAAO,MAAA;AAAA,EACX;AAAA,EAyBU,WAAW,GAAA,EAAmB;AACpC,IAAA,IAAI,UAAA;AAEJ,IAAA,IAAI,eAAe,GAAA,EAAK;AACpB,MAAA,UAAA,GAAa,KAAK,SAAA,CAAU,KAAA,CAAM,KAAK,GAAA,CAAI,OAAA,EAAS,CAAC,CAAA;AAAA,IACzD,CAAA,MAAA,IAAW,eAAe,GAAA,EAAK;AAC3B,MAAA,UAAA,GAAa,KAAK,SAAA,CAAU,KAAA,CAAM,KAAK,GAAA,CAAI,MAAA,EAAQ,CAAC,CAAA;AAAA,IACxD,CAAA,MAAO;AACH,MAAA,QAAQ,OAAO,GAAA;AAAK,QAChB,KAAK,QAAA;AACD,UAAA,UAAA,GAAa,GAAA;AACb,UAAA;AAAA,QACJ,KAAK,WAAA;AACD,UAAA,UAAA,GAAa,WAAA;AACb,UAAA;AAAA,QAEJ,KAAK,QAAA;AACD,UAAA,IAAI,QAAA,IAAY,GAAA;AACZ,YAAA,UAAA,GAAa,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,MAAA,EAAQ,CAAA;AAAA;AAGxC,YAAA,UAAA,GAAa,IAAA,CAAK,UAAU,GAAG,CAAA;AACnC,UAAA;AAAA,QACJ,KAAK,QAAA;AACD,UAAA,UAAA,GAAa,IAAI,QAAA,EAAS;AAC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,IAAA,CAAK;AAAA,KACf;AAEA,IAAA,MAAM,EAAA,GAAK,IAAA,CAAK,UAAA,CAAW,QAAQ,CAAA;AAEnC,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAK,aAAA,CAAc;AAAA,MAC5B,QAAQ,SAAA,CAAU,IAAA;AAAA,MAClB;AAAA,KACH,CAAA;AAAA,EACL;AAAA,EAGA,MAAA,GAAgD;AAC5C,IAAA,OAAO;AAAA,MACH,GAAG,MAAM,MAAA,EAAO;AAAA,MAChB,MAAM,IAAA,CAAK;AAAA,KACf;AAAA,EACJ;AAEJ;AAhJaD,gBAAA,GAAN,eAAA,CAAA;AAAA,EALNE,eAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,SAAA;AAAA,IACX,IAAA,EAAM,UAAA;AAAA,IACN,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYF,gBAAA,CAAA","file":"A-Signal.entity.js","sourcesContent":["import { A_Entity, A_Scope } from \"@adaas/a-concept\";\nimport { A_Signal_Init, A_Signal_Serialized } from \"../A-Signal.types\";\nimport { A_Frame } from \"@adaas/a-frame\";\n\n/**\n * A Signal Entity is an individual signal instance that carries data.\n * Signals is a event types that uses for vectors of signals to be used for further processing. \n * \n * Comparing to standard events, signals should be used in case when the event impacts some \"state\" \n * and the state should be used instead of the event itself.\n * \n * For example, a signal can represent the current status of a user (online/offline/away), \n * while an event would represent a single action (user logged in/logged out).\n * \n * Signals are typically used in scenarios where the current state is more important than individual events, \n * such as monitoring systems, real-time dashboards, or stateful applications.\n */\n@A_Frame.Entity({\n namespace: 'A-Utils',\n name: 'A-Signal',\n description: 'A Signal Entity represents an individual signal instance that carries data, used for managing state within an application context. Signals are designed to reflect the current state rather than individual events, making them suitable for scenarios where state monitoring and real-time updates are essential.'\n})\nexport class A_Signal<\n _TSignalDataType extends Record<string, any> = Record<string, any>\n> extends A_Entity<A_Signal_Init<_TSignalDataType>, A_Signal_Serialized<_TSignalDataType>> {\n\n\n // ========================================================================\n // ========================== Static Methods ==============================\n // ========================================================================\n /**\n * Allows to define default data for the signal.\n * \n * If no data is provided during initialization, the default data will be used.\n * \n * @returns \n */\n static async default(): Promise<A_Signal | undefined> {\n return undefined;\n }\n\n // ========================================================================\n // ========================== Instance Properties ========================\n // ========================================================================\n\n /**\n * The actual data carried by the signal.\n */\n data!: _TSignalDataType;\n\n /**\n * Generates signal hash uses for comparison\n * \n * @param str \n */\n protected createHash(str?: string): string\n protected createHash(str?: undefined): string\n protected createHash(str?: Record<string, any>): string\n protected createHash(str?: Array<any>): string\n protected createHash(str?: number): string\n protected createHash(str?: boolean): string\n protected createHash(str?: null): string\n protected createHash(map?: Map<any, any>): string\n protected createHash(set?: Set<any>): string\n protected createHash(str?: any): string {\n let hashSource: string;\n\n if (str instanceof Map) {\n hashSource = JSON.stringify(Array.from(str.entries()));\n } else if (str instanceof Set) {\n hashSource = JSON.stringify(Array.from(str.values()));\n } else {\n switch (typeof str) {\n case 'string':\n hashSource = str;\n break;\n case 'undefined':\n hashSource = 'undefined';\n break;\n\n case 'object':\n if ('toJSON' in str)\n hashSource = JSON.stringify(str.toJSON());\n\n else\n hashSource = JSON.stringify(str);\n break;\n case 'number':\n hashSource = str.toString();\n break;\n case 'boolean':\n hashSource = str ? 'true' : 'false';\n break;\n case 'function':\n hashSource = str.toString();\n break;\n default:\n hashSource = String(str);\n }\n }\n\n let hash = 0, i, chr;\n for (i = 0; i < hashSource.length; i++) {\n chr = hashSource.charCodeAt(i);\n hash = ((hash << 5) - hash) + chr;\n hash |= 0; // Convert to 32bit integer\n }\n\n const hashString = hash.toString();\n\n return hashString;\n }\n\n /**\n * This method compares the current signal with another signal instance by deduplication ID\n * this id can be configured during initialization with the \"id\" property.\n * \n * example: \n * * const signalA = new A_Signal({ id: ['user-status', 'user123'], data: { status: 'online' } });\n * * const signalB = new A_Signal({ id: ['user-status', 'user123'], data: { status: 'offline' } });\n * \n * signalA.compare(signalB) // true because both signals have the same deduplication ID\n * \n * @param other \n * @returns \n */\n compare(other: A_Signal<_TSignalDataType>): boolean {\n if (this.aseid.id !== other.aseid.id) {\n return false;\n }\n\n return true;\n }\n \n\n\n fromJSON(serializedEntity: A_Signal_Serialized<_TSignalDataType>): void {\n super.fromJSON(serializedEntity);\n this.data = serializedEntity.data;\n }\n\n\n fromNew(newEntity: A_Signal_Init<_TSignalDataType>): void {\n this.data = newEntity.data;\n\n const identity = newEntity.id || {\n name: newEntity.name,\n data: this.data\n };\n\n const id = this.createHash(identity);\n\n this.aseid = this.generateASEID({\n entity: newEntity.name,\n id: id,\n });\n }\n\n\n toJSON(): A_Signal_Serialized<_TSignalDataType> {\n return {\n ...super.toJSON(),\n data: this.data\n };\n }\n\n}"]}
1
+ {"version":3,"sources":["../../../../../src/lib/A-Signal/entities/A-Signal.entity.ts"],"names":["A_Signal","A_Entity","A_UtilsHelper","A_Frame"],"mappings":";;;;;;;;;;;;;;AAuBaA,gBAAA,GAAN,uBAGGC,iBAAA,CAA2F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BjG,QAAQ,KAAA,EAA4C;AAChD,IAAA,IAAI,IAAA,CAAK,KAAA,CAAM,EAAA,KAAO,KAAA,CAAM,MAAM,EAAA,EAAI;AAClC,MAAA,OAAO,KAAA;AAAA,IACX;AAEA,IAAA,OAAO,IAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAA,GAAsB;AAClB,IAAA,MAAM,IAAA,GAAQ,KAAK,WAAA,CAAgC,MAAA;AAEnD,IAAA,IAAA,CAAK,IAAA,GAAO,MAAA;AAEZ,IAAA,MAAM,QAAA,GAAW;AAAA,MACb,IAAA;AAAA,MACA,MAAM,IAAA,CAAK;AAAA,KACf;AAEA,IAAA,MAAM,EAAA,GAAKC,qBAAA,CAAc,IAAA,CAAK,QAAQ,CAAA;AAEtC,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAK,aAAA,CAAc;AAAA,MAC5B,MAAA,EAAQ,IAAA;AAAA,MACR;AAAA,KACH,CAAA;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAQ,SAAA,EAAkD;AACtD,IAAA,IAAA,CAAK,OAAO,SAAA,CAAU,IAAA;AAEtB,IAAA,MAAM,QAAA,GAAW,UAAU,EAAA,IAAM;AAAA,MAC7B,MAAM,SAAA,CAAU,IAAA;AAAA,MAChB,MAAM,IAAA,CAAK;AAAA,KACf;AAEA,IAAA,MAAM,EAAA,GAAKA,qBAAA,CAAc,IAAA,CAAK,QAAQ,CAAA;AAEtC,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAK,aAAA,CAAc;AAAA,MAC5B,QAAQ,SAAA,CAAU,IAAA;AAAA,MAClB;AAAA,KACH,CAAA;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS,gBAAA,EAAyE;AAC9E,IAAA,KAAA,CAAM,SAAS,gBAAgB,CAAA;AAC/B,IAAA,IAAA,CAAK,OAAO,gBAAA,CAAiB,IAAA;AAAA,EACjC;AAAA,EAEA,MAAA,GAA0D;AACtD,IAAA,OAAO;AAAA,MACH,GAAG,MAAM,MAAA,EAAO;AAAA,MAChB,MAAM,IAAA,CAAK;AAAA,KACf;AAAA,EACJ;AAEJ;AAvGaF,gBAAA,GAAN,eAAA,CAAA;AAAA,EALNG,eAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,SAAA;AAAA,IACX,IAAA,EAAM,UAAA;AAAA,IACN,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYH,gBAAA,CAAA","file":"A-Signal.entity.js","sourcesContent":["import { A_Entity } from \"@adaas/a-concept\";\nimport { A_Signal_Init, A_Signal_Serialized } from \"../A-Signal.types\";\nimport { A_Frame } from \"@adaas/a-frame\";\nimport { A_UtilsHelper } from \"@adaas/a-utils/helpers\";\n\n/**\n * A Signal Entity is an individual signal instance that carries data.\n * Signals is a event types that uses for vectors of signals to be used for further processing. \n * \n * Comparing to standard events, signals should be used in case when the event impacts some \"state\" \n * and the state should be used instead of the event itself.\n * \n * For example, a signal can represent the current status of a user (online/offline/away), \n * while an event would represent a single action (user logged in/logged out).\n * \n * Signals are typically used in scenarios where the current state is more important than individual events, \n * such as monitoring systems, real-time dashboards, or stateful applications.\n */\n@A_Frame.Entity({\n namespace: 'A-Utils',\n name: 'A-Signal',\n description: 'A Signal Entity represents an individual signal instance that carries data, used for managing state within an application context. Signals are designed to reflect the current state rather than individual events, making them suitable for scenarios where state monitoring and real-time updates are essential.'\n})\nexport class A_Signal<\n _TSignalDataType extends any = any,\n _TSignalSerializedDataType extends any = _TSignalDataType,\n> extends A_Entity<A_Signal_Init<_TSignalDataType>, A_Signal_Serialized<_TSignalSerializedDataType>> {\n\n\n // ========================================================================\n // ========================== Static Methods ==============================\n // ========================================================================\n\n // ========================================================================\n // ========================== Instance Properties ========================\n // ========================================================================\n\n /**\n * The actual data carried by the signal.\n */\n data!: _TSignalDataType;\n\n /**\n * This method compares the current signal with another signal instance by deduplication ID\n * this id can be configured during initialization with the \"id\" property.\n * \n * example: \n * * const signalA = new A_Signal({ id: ['user-status', 'user123'], data: { status: 'online' } });\n * * const signalB = new A_Signal({ id: ['user-status', 'user123'], data: { status: 'offline' } });\n * \n * signalA.compare(signalB) // true because both signals have the same deduplication ID\n * \n * @param other \n * @returns \n */\n compare(other: A_Signal<_TSignalDataType>): boolean {\n if (this.aseid.id !== other.aseid.id) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Allows to define default data for the signal.\n * \n * If no data is provided during initialization, the default data will be used.\n * \n * @returns \n */\n fromUndefined(): void {\n const name = (this.constructor as typeof A_Entity).entity;\n\n this.data = undefined as unknown as _TSignalDataType;\n\n const identity = {\n name: name,\n data: this.data\n };\n\n const id = A_UtilsHelper.hash(identity);\n\n this.aseid = this.generateASEID({\n entity: name,\n id: id,\n });\n }\n\n /**\n * Allows to initialize the signal from a new signal entity. This is useful for example when we want to create a new instance of the signal entity with the same data as another instance, but with a different ASEID.\n * \n * @param newEntity \n */\n fromNew(newEntity: A_Signal_Init<_TSignalDataType>): void {\n this.data = newEntity.data;\n\n const identity = newEntity.id || {\n name: newEntity.name,\n data: this.data\n };\n\n const id = A_UtilsHelper.hash(identity);\n\n this.aseid = this.generateASEID({\n entity: newEntity.name,\n id: id,\n });\n }\n\n /**\n * Allows to initialize the signal from a serialized version of the signal. This is useful for example when we receive a signal from the server and we want to create an instance of the signal entity from the received data.\n * \n * @param serializedEntity \n */\n fromJSON(serializedEntity: A_Signal_Serialized<_TSignalSerializedDataType>): void {\n super.fromJSON(serializedEntity);\n this.data = serializedEntity.data as unknown as _TSignalDataType;\n }\n\n toJSON(): A_Signal_Serialized<_TSignalSerializedDataType> {\n return {\n ...super.toJSON(),\n data: this.data as unknown as _TSignalSerializedDataType\n };\n }\n\n}"]}
@@ -1,63 +1,9 @@
1
1
  import { __decorateClass } from '../../../chunk-EQQGB2QZ.mjs';
2
2
  import { A_Entity } from '@adaas/a-concept';
3
3
  import { A_Frame } from '@adaas/a-frame';
4
+ import { A_UtilsHelper } from '@adaas/a-utils/helpers';
4
5
 
5
6
  let A_Signal = class extends A_Entity {
6
- // ========================================================================
7
- // ========================== Static Methods ==============================
8
- // ========================================================================
9
- /**
10
- * Allows to define default data for the signal.
11
- *
12
- * If no data is provided during initialization, the default data will be used.
13
- *
14
- * @returns
15
- */
16
- static async default() {
17
- return void 0;
18
- }
19
- createHash(str) {
20
- let hashSource;
21
- if (str instanceof Map) {
22
- hashSource = JSON.stringify(Array.from(str.entries()));
23
- } else if (str instanceof Set) {
24
- hashSource = JSON.stringify(Array.from(str.values()));
25
- } else {
26
- switch (typeof str) {
27
- case "string":
28
- hashSource = str;
29
- break;
30
- case "undefined":
31
- hashSource = "undefined";
32
- break;
33
- case "object":
34
- if ("toJSON" in str)
35
- hashSource = JSON.stringify(str.toJSON());
36
- else
37
- hashSource = JSON.stringify(str);
38
- break;
39
- case "number":
40
- hashSource = str.toString();
41
- break;
42
- case "boolean":
43
- hashSource = str ? "true" : "false";
44
- break;
45
- case "function":
46
- hashSource = str.toString();
47
- break;
48
- default:
49
- hashSource = String(str);
50
- }
51
- }
52
- let hash = 0, i, chr;
53
- for (i = 0; i < hashSource.length; i++) {
54
- chr = hashSource.charCodeAt(i);
55
- hash = (hash << 5) - hash + chr;
56
- hash |= 0;
57
- }
58
- const hashString = hash.toString();
59
- return hashString;
60
- }
61
7
  /**
62
8
  * This method compares the current signal with another signal instance by deduplication ID
63
9
  * this id can be configured during initialization with the "id" property.
@@ -77,22 +23,52 @@ let A_Signal = class extends A_Entity {
77
23
  }
78
24
  return true;
79
25
  }
80
- fromJSON(serializedEntity) {
81
- super.fromJSON(serializedEntity);
82
- this.data = serializedEntity.data;
26
+ /**
27
+ * Allows to define default data for the signal.
28
+ *
29
+ * If no data is provided during initialization, the default data will be used.
30
+ *
31
+ * @returns
32
+ */
33
+ fromUndefined() {
34
+ const name = this.constructor.entity;
35
+ this.data = void 0;
36
+ const identity = {
37
+ name,
38
+ data: this.data
39
+ };
40
+ const id = A_UtilsHelper.hash(identity);
41
+ this.aseid = this.generateASEID({
42
+ entity: name,
43
+ id
44
+ });
83
45
  }
46
+ /**
47
+ * Allows to initialize the signal from a new signal entity. This is useful for example when we want to create a new instance of the signal entity with the same data as another instance, but with a different ASEID.
48
+ *
49
+ * @param newEntity
50
+ */
84
51
  fromNew(newEntity) {
85
52
  this.data = newEntity.data;
86
53
  const identity = newEntity.id || {
87
54
  name: newEntity.name,
88
55
  data: this.data
89
56
  };
90
- const id = this.createHash(identity);
57
+ const id = A_UtilsHelper.hash(identity);
91
58
  this.aseid = this.generateASEID({
92
59
  entity: newEntity.name,
93
60
  id
94
61
  });
95
62
  }
63
+ /**
64
+ * Allows to initialize the signal from a serialized version of the signal. This is useful for example when we receive a signal from the server and we want to create an instance of the signal entity from the received data.
65
+ *
66
+ * @param serializedEntity
67
+ */
68
+ fromJSON(serializedEntity) {
69
+ super.fromJSON(serializedEntity);
70
+ this.data = serializedEntity.data;
71
+ }
96
72
  toJSON() {
97
73
  return {
98
74
  ...super.toJSON(),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/lib/A-Signal/entities/A-Signal.entity.ts"],"names":[],"mappings":";;;;AAsBO,IAAM,QAAA,GAAN,cAEG,QAAA,CAAiF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAavF,aAAa,OAAA,GAAyC;AAClD,IAAA,OAAO,MAAA;AAAA,EACX;AAAA,EAyBU,WAAW,GAAA,EAAmB;AACpC,IAAA,IAAI,UAAA;AAEJ,IAAA,IAAI,eAAe,GAAA,EAAK;AACpB,MAAA,UAAA,GAAa,KAAK,SAAA,CAAU,KAAA,CAAM,KAAK,GAAA,CAAI,OAAA,EAAS,CAAC,CAAA;AAAA,IACzD,CAAA,MAAA,IAAW,eAAe,GAAA,EAAK;AAC3B,MAAA,UAAA,GAAa,KAAK,SAAA,CAAU,KAAA,CAAM,KAAK,GAAA,CAAI,MAAA,EAAQ,CAAC,CAAA;AAAA,IACxD,CAAA,MAAO;AACH,MAAA,QAAQ,OAAO,GAAA;AAAK,QAChB,KAAK,QAAA;AACD,UAAA,UAAA,GAAa,GAAA;AACb,UAAA;AAAA,QACJ,KAAK,WAAA;AACD,UAAA,UAAA,GAAa,WAAA;AACb,UAAA;AAAA,QAEJ,KAAK,QAAA;AACD,UAAA,IAAI,QAAA,IAAY,GAAA;AACZ,YAAA,UAAA,GAAa,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,MAAA,EAAQ,CAAA;AAAA;AAGxC,YAAA,UAAA,GAAa,IAAA,CAAK,UAAU,GAAG,CAAA;AACnC,UAAA;AAAA,QACJ,KAAK,QAAA;AACD,UAAA,UAAA,GAAa,IAAI,QAAA,EAAS;AAC1B,UAAA;AAAA,QACJ,KAAK,SAAA;AACD,UAAA,UAAA,GAAa,MAA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CAAK,UAAA,CAAW,QAAQ,CAAA;AAEnC,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAK,aAAA,CAAc;AAAA,MAC5B,QAAQ,SAAA,CAAU,IAAA;AAAA,MAClB;AAAA,KACH,CAAA;AAAA,EACL;AAAA,EAGA,MAAA,GAAgD;AAC5C,IAAA,OAAO;AAAA,MACH,GAAG,MAAM,MAAA,EAAO;AAAA,MAChB,MAAM,IAAA,CAAK;AAAA,KACf;AAAA,EACJ;AAEJ;AAhJa,QAAA,GAAN,eAAA,CAAA;AAAA,EALN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,SAAA;AAAA,IACX,IAAA,EAAM,UAAA;AAAA,IACN,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,QAAA,CAAA","file":"A-Signal.entity.mjs","sourcesContent":["import { A_Entity, A_Scope } from \"@adaas/a-concept\";\nimport { A_Signal_Init, A_Signal_Serialized } from \"../A-Signal.types\";\nimport { A_Frame } from \"@adaas/a-frame\";\n\n/**\n * A Signal Entity is an individual signal instance that carries data.\n * Signals is a event types that uses for vectors of signals to be used for further processing. \n * \n * Comparing to standard events, signals should be used in case when the event impacts some \"state\" \n * and the state should be used instead of the event itself.\n * \n * For example, a signal can represent the current status of a user (online/offline/away), \n * while an event would represent a single action (user logged in/logged out).\n * \n * Signals are typically used in scenarios where the current state is more important than individual events, \n * such as monitoring systems, real-time dashboards, or stateful applications.\n */\n@A_Frame.Entity({\n namespace: 'A-Utils',\n name: 'A-Signal',\n description: 'A Signal Entity represents an individual signal instance that carries data, used for managing state within an application context. Signals are designed to reflect the current state rather than individual events, making them suitable for scenarios where state monitoring and real-time updates are essential.'\n})\nexport class A_Signal<\n _TSignalDataType extends Record<string, any> = Record<string, any>\n> extends A_Entity<A_Signal_Init<_TSignalDataType>, A_Signal_Serialized<_TSignalDataType>> {\n\n\n // ========================================================================\n // ========================== Static Methods ==============================\n // ========================================================================\n /**\n * Allows to define default data for the signal.\n * \n * If no data is provided during initialization, the default data will be used.\n * \n * @returns \n */\n static async default(): Promise<A_Signal | undefined> {\n return undefined;\n }\n\n // ========================================================================\n // ========================== Instance Properties ========================\n // ========================================================================\n\n /**\n * The actual data carried by the signal.\n */\n data!: _TSignalDataType;\n\n /**\n * Generates signal hash uses for comparison\n * \n * @param str \n */\n protected createHash(str?: string): string\n protected createHash(str?: undefined): string\n protected createHash(str?: Record<string, any>): string\n protected createHash(str?: Array<any>): string\n protected createHash(str?: number): string\n protected createHash(str?: boolean): string\n protected createHash(str?: null): string\n protected createHash(map?: Map<any, any>): string\n protected createHash(set?: Set<any>): string\n protected createHash(str?: any): string {\n let hashSource: string;\n\n if (str instanceof Map) {\n hashSource = JSON.stringify(Array.from(str.entries()));\n } else if (str instanceof Set) {\n hashSource = JSON.stringify(Array.from(str.values()));\n } else {\n switch (typeof str) {\n case 'string':\n hashSource = str;\n break;\n case 'undefined':\n hashSource = 'undefined';\n break;\n\n case 'object':\n if ('toJSON' in str)\n hashSource = JSON.stringify(str.toJSON());\n\n else\n hashSource = JSON.stringify(str);\n break;\n case 'number':\n hashSource = str.toString();\n break;\n case 'boolean':\n hashSource = str ? 'true' : 'false';\n break;\n case 'function':\n hashSource = str.toString();\n break;\n default:\n hashSource = String(str);\n }\n }\n\n let hash = 0, i, chr;\n for (i = 0; i < hashSource.length; i++) {\n chr = hashSource.charCodeAt(i);\n hash = ((hash << 5) - hash) + chr;\n hash |= 0; // Convert to 32bit integer\n }\n\n const hashString = hash.toString();\n\n return hashString;\n }\n\n /**\n * This method compares the current signal with another signal instance by deduplication ID\n * this id can be configured during initialization with the \"id\" property.\n * \n * example: \n * * const signalA = new A_Signal({ id: ['user-status', 'user123'], data: { status: 'online' } });\n * * const signalB = new A_Signal({ id: ['user-status', 'user123'], data: { status: 'offline' } });\n * \n * signalA.compare(signalB) // true because both signals have the same deduplication ID\n * \n * @param other \n * @returns \n */\n compare(other: A_Signal<_TSignalDataType>): boolean {\n if (this.aseid.id !== other.aseid.id) {\n return false;\n }\n\n return true;\n }\n \n\n\n fromJSON(serializedEntity: A_Signal_Serialized<_TSignalDataType>): void {\n super.fromJSON(serializedEntity);\n this.data = serializedEntity.data;\n }\n\n\n fromNew(newEntity: A_Signal_Init<_TSignalDataType>): void {\n this.data = newEntity.data;\n\n const identity = newEntity.id || {\n name: newEntity.name,\n data: this.data\n };\n\n const id = this.createHash(identity);\n\n this.aseid = this.generateASEID({\n entity: newEntity.name,\n id: id,\n });\n }\n\n\n toJSON(): A_Signal_Serialized<_TSignalDataType> {\n return {\n ...super.toJSON(),\n data: this.data\n };\n }\n\n}"]}
1
+ {"version":3,"sources":["../../../../../src/lib/A-Signal/entities/A-Signal.entity.ts"],"names":[],"mappings":";;;;;AAuBO,IAAM,QAAA,GAAN,cAGG,QAAA,CAA2F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BjG,QAAQ,KAAA,EAA4C;AAChD,IAAA,IAAI,IAAA,CAAK,KAAA,CAAM,EAAA,KAAO,KAAA,CAAM,MAAM,EAAA,EAAI;AAClC,MAAA,OAAO,KAAA;AAAA,IACX;AAEA,IAAA,OAAO,IAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAA,GAAsB;AAClB,IAAA,MAAM,IAAA,GAAQ,KAAK,WAAA,CAAgC,MAAA;AAEnD,IAAA,IAAA,CAAK,IAAA,GAAO,MAAA;AAEZ,IAAA,MAAM,QAAA,GAAW;AAAA,MACb,IAAA;AAAA,MACA,MAAM,IAAA,CAAK;AAAA,KACf;AAEA,IAAA,MAAM,EAAA,GAAK,aAAA,CAAc,IAAA,CAAK,QAAQ,CAAA;AAEtC,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAK,aAAA,CAAc;AAAA,MAC5B,MAAA,EAAQ,IAAA;AAAA,MACR;AAAA,KACH,CAAA;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAQ,SAAA,EAAkD;AACtD,IAAA,IAAA,CAAK,OAAO,SAAA,CAAU,IAAA;AAEtB,IAAA,MAAM,QAAA,GAAW,UAAU,EAAA,IAAM;AAAA,MAC7B,MAAM,SAAA,CAAU,IAAA;AAAA,MAChB,MAAM,IAAA,CAAK;AAAA,KACf;AAEA,IAAA,MAAM,EAAA,GAAK,aAAA,CAAc,IAAA,CAAK,QAAQ,CAAA;AAEtC,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAK,aAAA,CAAc;AAAA,MAC5B,QAAQ,SAAA,CAAU,IAAA;AAAA,MAClB;AAAA,KACH,CAAA;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS,gBAAA,EAAyE;AAC9E,IAAA,KAAA,CAAM,SAAS,gBAAgB,CAAA;AAC/B,IAAA,IAAA,CAAK,OAAO,gBAAA,CAAiB,IAAA;AAAA,EACjC;AAAA,EAEA,MAAA,GAA0D;AACtD,IAAA,OAAO;AAAA,MACH,GAAG,MAAM,MAAA,EAAO;AAAA,MAChB,MAAM,IAAA,CAAK;AAAA,KACf;AAAA,EACJ;AAEJ;AAvGa,QAAA,GAAN,eAAA,CAAA;AAAA,EALN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,SAAA;AAAA,IACX,IAAA,EAAM,UAAA;AAAA,IACN,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,QAAA,CAAA","file":"A-Signal.entity.mjs","sourcesContent":["import { A_Entity } from \"@adaas/a-concept\";\nimport { A_Signal_Init, A_Signal_Serialized } from \"../A-Signal.types\";\nimport { A_Frame } from \"@adaas/a-frame\";\nimport { A_UtilsHelper } from \"@adaas/a-utils/helpers\";\n\n/**\n * A Signal Entity is an individual signal instance that carries data.\n * Signals is a event types that uses for vectors of signals to be used for further processing. \n * \n * Comparing to standard events, signals should be used in case when the event impacts some \"state\" \n * and the state should be used instead of the event itself.\n * \n * For example, a signal can represent the current status of a user (online/offline/away), \n * while an event would represent a single action (user logged in/logged out).\n * \n * Signals are typically used in scenarios where the current state is more important than individual events, \n * such as monitoring systems, real-time dashboards, or stateful applications.\n */\n@A_Frame.Entity({\n namespace: 'A-Utils',\n name: 'A-Signal',\n description: 'A Signal Entity represents an individual signal instance that carries data, used for managing state within an application context. Signals are designed to reflect the current state rather than individual events, making them suitable for scenarios where state monitoring and real-time updates are essential.'\n})\nexport class A_Signal<\n _TSignalDataType extends any = any,\n _TSignalSerializedDataType extends any = _TSignalDataType,\n> extends A_Entity<A_Signal_Init<_TSignalDataType>, A_Signal_Serialized<_TSignalSerializedDataType>> {\n\n\n // ========================================================================\n // ========================== Static Methods ==============================\n // ========================================================================\n\n // ========================================================================\n // ========================== Instance Properties ========================\n // ========================================================================\n\n /**\n * The actual data carried by the signal.\n */\n data!: _TSignalDataType;\n\n /**\n * This method compares the current signal with another signal instance by deduplication ID\n * this id can be configured during initialization with the \"id\" property.\n * \n * example: \n * * const signalA = new A_Signal({ id: ['user-status', 'user123'], data: { status: 'online' } });\n * * const signalB = new A_Signal({ id: ['user-status', 'user123'], data: { status: 'offline' } });\n * \n * signalA.compare(signalB) // true because both signals have the same deduplication ID\n * \n * @param other \n * @returns \n */\n compare(other: A_Signal<_TSignalDataType>): boolean {\n if (this.aseid.id !== other.aseid.id) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Allows to define default data for the signal.\n * \n * If no data is provided during initialization, the default data will be used.\n * \n * @returns \n */\n fromUndefined(): void {\n const name = (this.constructor as typeof A_Entity).entity;\n\n this.data = undefined as unknown as _TSignalDataType;\n\n const identity = {\n name: name,\n data: this.data\n };\n\n const id = A_UtilsHelper.hash(identity);\n\n this.aseid = this.generateASEID({\n entity: name,\n id: id,\n });\n }\n\n /**\n * Allows to initialize the signal from a new signal entity. This is useful for example when we want to create a new instance of the signal entity with the same data as another instance, but with a different ASEID.\n * \n * @param newEntity \n */\n fromNew(newEntity: A_Signal_Init<_TSignalDataType>): void {\n this.data = newEntity.data;\n\n const identity = newEntity.id || {\n name: newEntity.name,\n data: this.data\n };\n\n const id = A_UtilsHelper.hash(identity);\n\n this.aseid = this.generateASEID({\n entity: newEntity.name,\n id: id,\n });\n }\n\n /**\n * Allows to initialize the signal from a serialized version of the signal. This is useful for example when we receive a signal from the server and we want to create an instance of the signal entity from the received data.\n * \n * @param serializedEntity \n */\n fromJSON(serializedEntity: A_Signal_Serialized<_TSignalSerializedDataType>): void {\n super.fromJSON(serializedEntity);\n this.data = serializedEntity.data as unknown as _TSignalDataType;\n }\n\n toJSON(): A_Signal_Serialized<_TSignalSerializedDataType> {\n return {\n ...super.toJSON(),\n data: this.data as unknown as _TSignalSerializedDataType\n };\n }\n\n}"]}