@atmosx/event-product-parser 3.0.4 → 3.0.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 (212) hide show
  1. package/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +1 -1
  2. package/.github/SUPPORTED_EVENTS.md +370 -0
  3. package/.github/docs/docs-functions.md +30 -0
  4. package/.github/docs/docs-general-configurations.md +199 -0
  5. package/.github/docs/docs-integrations.md +38 -0
  6. package/.github/docs/docs-listeners.md +28 -0
  7. package/.github/docs/docs-source-configuration.md +218 -0
  8. package/.github/docs/docs-technical.md +50 -0
  9. package/.github/logo.png +0 -0
  10. package/.github/samples/SAMPLE_EAS_GENERATION.wav +0 -0
  11. package/.github/samples/SAMPLE_GEOJSON.json +204 -0
  12. package/.github/samples/SAMPLE_TEXT_PRODUCT.txt +119 -0
  13. package/README.md +157 -337
  14. package/dist/cjs/index.cjs +24125 -15815
  15. package/dist/esm/index.mjs +24144 -15839
  16. package/package.json +56 -53
  17. package/pnpm-workspace.yaml +4 -0
  18. package/src/bootstrap.ts +83 -43
  19. package/src/building/CreateEvent.ts +54 -0
  20. package/src/{@building/building.clean.ts → building/GetCleanedEvent.ts} +4 -4
  21. package/src/building/GetEventAttachments.ts +88 -0
  22. package/src/building/GetEventDirection.ts +28 -0
  23. package/src/{@building/building.enhance.ts → building/GetEventEnhancedName.ts} +13 -17
  24. package/src/{@building/building.geometry.ts → building/GetEventGeometry.ts} +19 -13
  25. package/src/{@building/building.headers.ts → building/GetEventHeader.ts} +13 -13
  26. package/src/{@building/building.polygon.ts → building/GetEventNodes.ts} +26 -22
  27. package/src/{@building/building.office.ts → building/GetEventOffice.ts} +14 -14
  28. package/src/building/GetEventProperties.ts +105 -0
  29. package/src/{@building/building.signature.ts → building/GetEventSignature.ts} +16 -17
  30. package/src/{@core/core.createListener.ts → building/GetEventTags.ts} +11 -6
  31. package/src/building/GetEventTheme.ts +26 -0
  32. package/src/building/GetEventTracking.ts +64 -0
  33. package/src/components/audio/GenerateAudioMessage.ts +149 -0
  34. package/src/components/audio/components/GetCleanDescription.ts +91 -0
  35. package/src/{@modules/@eas/eas.getFloatPCM16.ts → components/audio/components/GetFloatPCM16.ts} +3 -3
  36. package/src/{@modules/@eas/eas.getMergedPCM16.ts → components/audio/components/GetMergedPCM16.ts} +3 -3
  37. package/src/{@modules/@eas/eas.getPCM16.ts → components/audio/components/GetPCM16.ts} +13 -8
  38. package/src/{@modules/@eas/eas.getPCMToFloat.ts → components/audio/components/GetPCMToFloat.ts} +3 -3
  39. package/src/{@modules/@eas/eas.getSampledPCM16.ts → components/audio/components/GetSampledPCM16.ts} +14 -8
  40. package/src/components/audio/components/GetTTS.ts +61 -0
  41. package/src/{@modules/@eas/eas.getWavPCM16.ts → components/audio/components/GetWavPCM16.ts} +8 -8
  42. package/src/{@modules/@eas/eas.setAFSK.ts → components/audio/components/SetAFSK.ts} +12 -8
  43. package/src/{@modules/@eas/eas.setAsciiToBits.ts → components/audio/components/SetAsciiToBits.ts} +3 -4
  44. package/src/{@modules/@eas/eas.setAttentionTone.ts → components/audio/components/SetAttentionTone.ts} +11 -6
  45. package/src/{@modules/@eas/eas.setNoise.ts → components/audio/components/SetNoise.ts} +14 -8
  46. package/src/{@modules/@eas/eas.setRadioEffect.ts → components/audio/components/SetRadioEffect.ts} +14 -8
  47. package/src/{@modules/@eas/eas.setSameHeader.ts → components/audio/components/SetSameHeader.ts} +22 -15
  48. package/src/{@modules/@utilities/utilities.setWarning.ts → components/database/CreateQuery.ts} +18 -13
  49. package/src/{@modules/@database/database.cache.ts → components/database/GetCachedEvents.ts} +19 -14
  50. package/src/components/database/ImportBoundaries.ts +168 -0
  51. package/src/components/database/ImportBroadcastify.ts +60 -0
  52. package/src/components/database/ImportCities.ts +87 -0
  53. package/src/{@modules/@database/database.shapefiles.ts → components/database/ImportShapefiles.ts} +31 -37
  54. package/src/components/database/ImportStanza.ts +43 -0
  55. package/src/components/database/InitializeDatabase.ts +71 -0
  56. package/src/components/images/GenerateGraphic.ts +234 -0
  57. package/src/components/images/components/CreateRectangle.ts +22 -0
  58. package/src/components/images/components/CreateText.ts +22 -0
  59. package/src/components/images/modules/CreateSVG.ts +37 -0
  60. package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
  61. package/src/components/images/modules/GetGeographicalCities.ts +58 -0
  62. package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
  63. package/src/components/images/modules/GetGeometryBounds.ts +82 -0
  64. package/src/components/images/modules/GetParsedBoundary.ts +58 -0
  65. package/src/components/images/modules/GetSVGPath.ts +53 -0
  66. package/src/components/images/modules/NormalizePolygon.ts +57 -0
  67. package/src/{@modules/@stanza/stanza.getAwipsType.ts → components/stanza/GetAwipsType.ts} +19 -18
  68. package/src/components/stanza/ValidateStanza.ts +62 -0
  69. package/src/components/utilities/CreateHttp.ts +83 -0
  70. package/src/{@modules/@utilities/utilities.getFormattedTime.ts → components/utilities/GetFormattedTime.ts} +3 -3
  71. package/src/components/utilities/GetLatestIssuance.ts +32 -0
  72. package/src/components/utilities/GetMatched.ts +38 -0
  73. package/src/{@modules/@utilities/utilities.getShapeNearestPoint.ts → components/utilities/GetShapeNearestPoint.ts} +24 -19
  74. package/src/components/utilities/GetUnionPolygon.ts +36 -0
  75. package/src/components/utilities/QueueManager.ts +70 -0
  76. package/src/components/utilities/SetCronSchedule.ts +98 -0
  77. package/src/{@core/core.clearEvents.ts → components/utilities/SetDebug.ts} +17 -12
  78. package/src/components/utilities/SetEventEmit.ts +42 -0
  79. package/src/{@modules/@utilities/utilities.setSettings.ts → components/utilities/SetSettings.ts} +7 -7
  80. package/src/{@modules/@utilities/utilities.setSleep.ts → components/utilities/SetSleep.ts} +5 -5
  81. package/src/components/utilities/SetTimeoutAction.ts +64 -0
  82. package/src/components/utilities/SetWarning.ts +47 -0
  83. package/src/{@modules/@xmpp/xmpp.xDeploy.ts → components/xmpp/DeployXMPP.ts} +26 -27
  84. package/src/components/xmpp/ErrorXMPP.ts +27 -0
  85. package/src/{@modules/@xmpp/xmpp.xError.ts → components/xmpp/OfflineXMPP.ts} +17 -9
  86. package/src/{@modules/@xmpp/xmpp.xOnline.ts → components/xmpp/OnlineXMPP.ts} +21 -20
  87. package/src/components/xmpp/ReconnectXMPP.ts +64 -0
  88. package/src/components/xmpp/StanzaXMPP.ts +63 -0
  89. package/src/{@building/building.tags.ts → core/ClearEvents.ts} +12 -5
  90. package/src/{@core/core.getVersion.ts → core/GetEvents.ts} +5 -6
  91. package/src/core/GetNodes.ts +24 -0
  92. package/src/{@core/core.getNodes.ts → core/GetRandomEvent.ts} +5 -6
  93. package/src/core/GetVersion.ts +24 -0
  94. package/src/core/ManualEvent.ts +55 -0
  95. package/src/core/QueryStanza.ts +40 -0
  96. package/src/core/SetNode.ts +87 -0
  97. package/src/core/StartService.ts +62 -0
  98. package/src/core/StopService.ts +32 -0
  99. package/src/enums/AWIPS.ts +366 -0
  100. package/src/{@dictionaries/dictionaries.eventActions.ts → enums/Actions.ts} +3 -3
  101. package/src/{@dictionaries/dictionaries.eventCancelMessages.ts → enums/Cancellation.ts} +4 -3
  102. package/src/{@dictionaries/dictionaries.eventCauses.ts → enums/Causes.ts} +3 -3
  103. package/src/{@dictionaries/dictionaries.statusCorrelationText.ts → enums/Correlations.ts} +3 -3
  104. package/src/enums/Enhanced.ts +70 -0
  105. package/src/{@dictionaries/dictionaries.eventTypes.ts → enums/Events.ts} +3 -3
  106. package/src/{@dictionaries/dictionaries.regExp.ts → enums/Expressions.ts} +5 -4
  107. package/src/{@core/core.getEvents.ts → enums/GlobalFilter.ts} +7 -8
  108. package/src/{@dictionaries/dictionaries.hailStrings.ts → enums/Hail.ts} +9 -4
  109. package/src/{@dictionaries/dictionaries.officeICAOs.ts → enums/ICAO.ts} +5 -3
  110. package/src/enums/Matches.ts +60 -0
  111. package/src/{@dictionaries/dictionaries.eventProducts.ts → enums/Products.ts} +3 -3
  112. package/src/{@dictionaries/dictionaries.eventRecords.ts → enums/Records.ts} +3 -3
  113. package/src/{@dictionaries/dictionaries.eventSeverity.ts → enums/Severity.ts} +3 -3
  114. package/src/{@dictionaries/dictionaries.shapefileLinks.ts → enums/Shapefiles.ts} +3 -3
  115. package/src/enums/States.ts +136 -0
  116. package/src/{@dictionaries/dictionaries.eventStatus.ts → enums/Status.ts} +3 -3
  117. package/src/enums/Strings.ts +22 -0
  118. package/src/enums/Tags.ts +172 -0
  119. package/src/{@dictionaries/dictionaries.testSignatures.ts → enums/Testing.ts} +5 -4
  120. package/src/enums/Themes.ts +70 -0
  121. package/src/events/ParseAPI.ts +129 -0
  122. package/src/{@events/events.text.ts → events/ParseText.ts} +32 -23
  123. package/src/{@events/events.ugc.ts → events/ParseUGC.ts} +36 -26
  124. package/src/events/ParseVTEC.ts +88 -0
  125. package/src/index.ts +60 -38
  126. package/src/manager/MakeEvents.ts +110 -0
  127. package/src/manager/RemoveEvent.ts +74 -0
  128. package/src/{@manager/manager.setHash.ts → manager/SetHash.ts} +19 -15
  129. package/src/manager/UpdateEvents.ts +35 -0
  130. package/src/manager/UpdateNode.ts +62 -0
  131. package/src/manager/ValidateEvents.ts +144 -0
  132. package/src/{@parsers/@hvtec/hvtec.extract.ts → parsers/hvtec/HVExtract.ts} +13 -13
  133. package/src/parsers/text/GetDescriptionFromProduct.ts +59 -0
  134. package/src/parsers/text/GetEmbededText.ts +57 -0
  135. package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
  136. package/src/parsers/text/GetStringText.ts +58 -0
  137. package/src/{@parsers/@text/text.getTextFromProduct.ts → parsers/text/GetTextFromProduct.ts} +12 -12
  138. package/src/parsers/ugc/GetCache.ts +24 -0
  139. package/src/{@parsers/@ugc/ugc.expiry.ts → parsers/ugc/GetExpiry.ts} +3 -3
  140. package/src/{@parsers/@ugc/ugc.header.ts → parsers/ugc/GetHeader.ts} +6 -6
  141. package/src/parsers/ugc/GetLocations.ts +57 -0
  142. package/src/parsers/ugc/GetZonePolygon.ts +73 -0
  143. package/src/{@parsers/@ugc/ugc.zones.ts → parsers/ugc/GetZones.ts} +3 -3
  144. package/src/{@modules/@utilities/utilities.setListener.ts → parsers/ugc/SetCache.ts} +13 -10
  145. package/src/{@parsers/@ugc/ugc.extract.ts → parsers/ugc/UGCExtract.ts} +15 -15
  146. package/src/{@parsers/@pvtec/pvtec.expires.ts → parsers/vtec/GetExpiry.ts} +3 -3
  147. package/src/parsers/vtec/VTECExtract.ts +49 -0
  148. package/src/{@types/types.attributes.ts → static/Attributes.ts} +2 -3
  149. package/src/{@types/type.event.ts → static/Event.ts} +11 -8
  150. package/src/{@types/type.properties.ts → static/Properties.ts} +17 -10
  151. package/src/{@types/types.stanza.ts → static/Stanza.ts} +2 -2
  152. package/src/tasks/CreateTasks.ts +123 -0
  153. package/src/{@core/core.stop.ts → tasks/TaskGenerateJSON.ts} +14 -12
  154. package/src/tasks/TaskGenerateText.ts +34 -0
  155. package/src/tasks/TaskSendNTFY.ts +97 -0
  156. package/src/tasks/TaskSendWebhook.ts +107 -0
  157. package/src/types/Actions.ts +37 -0
  158. package/src/{@types/types.hvtec.ts → types/HVTEC.ts} +6 -6
  159. package/src/{@types/types.hash.ts → types/Hash.ts} +5 -5
  160. package/src/types/Nodes.ts +29 -0
  161. package/src/{@types/types.settings.ts → types/Settings.ts} +42 -10
  162. package/src/{@types/types.compiled.ts → types/StanzaCompiled.ts} +15 -14
  163. package/src/{@types/types.ugc.ts → types/UGC.ts} +5 -5
  164. package/src/{@modules/@utilities/utilities.getSettings.ts → types/VTEC.ts} +12 -7
  165. package/tools/build.js +47 -0
  166. package/tsconfig.json +28 -1
  167. package/dist/index.d.mts +0 -239
  168. package/dist/index.d.ts +0 -239
  169. package/src/@building/building.create.ts +0 -42
  170. package/src/@building/building.properties.ts +0 -89
  171. package/src/@building/building.tracking.ts +0 -68
  172. package/src/@building/building.validate.ts +0 -147
  173. package/src/@core/core.getRandomEvent.ts +0 -25
  174. package/src/@core/core.setNode.ts +0 -81
  175. package/src/@core/core.start.ts +0 -61
  176. package/src/@dictionaries/dictionaries.betterEventNames.ts +0 -99
  177. package/src/@dictionaries/dictionaries.eventAwipAbreviations.ts +0 -364
  178. package/src/@dictionaries/dictionaries.eventTags.ts +0 -93
  179. package/src/@dictionaries/dictionaries.eventsMatchText.ts +0 -36
  180. package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +0 -68
  181. package/src/@events/events.api.ts +0 -113
  182. package/src/@events/events.vtec.ts +0 -87
  183. package/src/@manager/manager.mkEvent.ts +0 -96
  184. package/src/@manager/manager.rmEvent.ts +0 -49
  185. package/src/@manager/manager.updateEvents.ts +0 -35
  186. package/src/@manager/manager.updateNodes.ts +0 -55
  187. package/src/@manager/manager.updateWebhooks.ts +0 -50
  188. package/src/@modules/@database/database.init.ts +0 -45
  189. package/src/@modules/@database/database.stanza.ts +0 -48
  190. package/src/@modules/@eas/eas.setEasTone.ts +0 -137
  191. package/src/@modules/@stanza/stanza.validate.ts +0 -50
  192. package/src/@modules/@utilities/utilities.createHttp.ts +0 -85
  193. package/src/@modules/@utilities/utilities.createWebhook.ts +0 -115
  194. package/src/@modules/@utilities/utilities.setCronSchedule.ts +0 -65
  195. package/src/@modules/@utilities/utilities.setEventEmit.ts +0 -41
  196. package/src/@modules/@utilities/utilities.setTimeoutAction.ts +0 -59
  197. package/src/@modules/@xmpp/xmpp.xOffline.ts +0 -38
  198. package/src/@modules/@xmpp/xmpp.xReconnect.ts +0 -64
  199. package/src/@modules/@xmpp/xmpp.xStanza.ts +0 -63
  200. package/src/@parsers/@pvtec/pvtec.extract.ts +0 -49
  201. package/src/@parsers/@text/text.getDescriptionFromProduct.ts +0 -53
  202. package/src/@parsers/@text/text.getPolygonFromProduct.ts +0 -32
  203. package/src/@parsers/@text/text.getXML.ts +0 -61
  204. package/src/@parsers/@ugc/ugc.coordinates.ts +0 -110
  205. package/src/@parsers/@ugc/ugc.locations.ts +0 -29
  206. package/src/@types/types.pvtec.ts +0 -30
  207. package/src/@types/types.webhook.ts +0 -27
  208. package/test.js +0 -91
  209. package/tsup.config.ts +0 -16
  210. /package/{CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md} +0 -0
  211. /package/{LICENSE → .github/LICENSE} +0 -0
  212. /package/{SECURITY.md → .github/SECURITY.md} +0 -0
@@ -11,14 +11,14 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
20
 
21
- export const getFloatPCM16 = (float32: Float32Array): Int16Array => {
21
+ export const GetFloatPCM16 = (float32: Float32Array): Int16Array => {
22
22
  const out = new Int16Array(float32.length);
23
23
  for (let i = 0; i < float32.length; i++) {
24
24
  let v = Math.max(-1, Math.min(1, float32[i]));
@@ -11,14 +11,14 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
20
 
21
- export const getMergedPCM16 = (arrays: Int16Array[]): Int16Array => {
21
+ export const GetMergedPCM16 = (arrays: Int16Array[]): Int16Array => {
22
22
  let total = 0;
23
23
  for (const a of arrays) total += a.length;
24
24
  const out = new Int16Array(total);
@@ -11,19 +11,24 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
20
 
21
- export const getPCM16 = (samples: Record<string, number>[], sampleRate: number): Buffer => {
21
+ interface GetPCM16Options {
22
+ Samples: Record<string, number>[]
23
+ SampleRate: number
24
+ }
25
+
26
+ export const GetPCM16 = ({ Samples, SampleRate }: GetPCM16Options): Buffer => {
22
27
  let o = 0;
23
28
  const bytesPerSample = 2;
24
29
  const blockAlign = 1 * bytesPerSample;
25
- const byteRate = sampleRate * blockAlign;
26
- const subchunk2Size = samples.length * bytesPerSample;
30
+ const byteRate = SampleRate * blockAlign;
31
+ const subchunk2Size = Samples.length * bytesPerSample;
27
32
  const chunkSize = 36 + subchunk2Size;
28
33
  const buffer = Buffer.alloc(44 + subchunk2Size);
29
34
 
@@ -35,7 +40,7 @@ export const getPCM16 = (samples: Record<string, number>[], sampleRate: number):
35
40
  buffer.writeUInt32LE(16, o); o += 4;
36
41
  buffer.writeUInt16LE(1, o); o += 2;
37
42
  buffer.writeUInt16LE(1, o); o += 2;
38
- buffer.writeUInt32LE(sampleRate, o); o += 4;
43
+ buffer.writeUInt32LE(SampleRate, o); o += 4;
39
44
  buffer.writeUInt32LE(byteRate, o); o += 4;
40
45
  buffer.writeUInt16LE(blockAlign, o); o += 2;
41
46
  buffer.writeUInt16LE(16, o); o += 2;
@@ -43,8 +48,8 @@ export const getPCM16 = (samples: Record<string, number>[], sampleRate: number):
43
48
  buffer.write("data", o); o += 4;
44
49
  buffer.writeUInt32LE(subchunk2Size, o); o += 4;
45
50
 
46
- for (let i = 0; i < samples.length; i++, o += 2) {
47
- buffer.writeInt16LE(samples[i].value, o);
51
+ for (let i = 0; i < Samples.length; i++, o += 2) {
52
+ buffer.writeInt16LE(Samples[i].value, o);
48
53
  }
49
54
  return buffer;
50
55
  }
@@ -11,14 +11,14 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
20
 
21
- export const getPCMToFloat = (int16: Int16Array): Float32Array => {
21
+ export const GetPCMToFloat = (int16: Int16Array): Float32Array => {
22
22
  const out = new Float32Array(int16.length);
23
23
  for (let i = 0; i < int16.length; i++) out[i] = int16[i] / 32768;
24
24
  return out;
@@ -11,24 +11,30 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
20
 
21
- export const getSampledPCM16 = (int16: Int16Array, originalRate: number, targetRate: number): Int16Array => {
22
- if (originalRate === targetRate) return int16;
23
- const ratio = targetRate / originalRate;
24
- const outLen = Math.max(1, Math.round(int16.length * ratio));
21
+ interface GetSampledPCM16Options {
22
+ Int16: Int16Array
23
+ OriginalRate: number
24
+ TargetRate: number
25
+ }
26
+
27
+ export const GetSampledPCM16 = ({ Int16, OriginalRate, TargetRate }: GetSampledPCM16Options): Int16Array => {
28
+ if (OriginalRate === TargetRate) return Int16;
29
+ const ratio = TargetRate / OriginalRate;
30
+ const outLen = Math.max(1, Math.round(Int16.length * ratio));
25
31
  const out = new Int16Array(outLen);
26
32
  for (let i = 0; i < outLen; i++) {
27
33
  const pos = i / ratio;
28
34
  const i0 = Math.floor(pos);
29
- const i1 = Math.min(i0 + 1, int16.length - 1);
35
+ const i1 = Math.min(i0 + 1, Int16.length - 1);
30
36
  const frac = pos - i0;
31
- const v = int16[i0] * (1 - frac) + int16[i1] * frac;
37
+ const v = Int16[i0] * (1 - frac) + Int16[i1] * frac;
32
38
  out[i] = Math.round(v);
33
39
  }
34
40
  return out;
@@ -0,0 +1,61 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Independent Package: @atmosx/event-product-parser
17
+
18
+
19
+ */
20
+
21
+ import { platform } from "os"
22
+ import { writeFileSync, unlinkSync} from "fs"
23
+ import { execSync } from "child_process"
24
+
25
+
26
+ interface GetTTSOptions {
27
+ Text: string
28
+ OutputPath: string
29
+ }
30
+
31
+ export const GetTTS = async ({ Text, OutputPath }: GetTTSOptions): Promise<void> => {
32
+ const vPlatform = platform();
33
+ switch (vPlatform) {
34
+ case 'win32': {
35
+ try {
36
+ const txtPath = OutputPath + ".txt";
37
+ writeFileSync(txtPath, Text, "utf8");
38
+ const command = [
39
+ "Add-Type -AssemblyName System.Speech;",
40
+ `$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer;`,
41
+ `$text = Get-Content -Raw -LiteralPath '${txtPath}';`,
42
+ `$speak.SetOutputToWaveFile('${OutputPath}');`,
43
+ `$speak.Speak($text);`,
44
+ `$speak.Dispose();`
45
+ ].join(" ");
46
+ execSync(`powershell -Command "${command}"`, { stdio: 'inherit' })
47
+ try{ unlinkSync(txtPath) } catch {}
48
+ } catch(error) {
49
+ console.error('Error occurred while generating TTS:', error);
50
+ }
51
+ break;
52
+ }
53
+ case 'linux':
54
+ try {
55
+ execSync(`espeak -w "${OutputPath}" "${Text.replace(/"/g, '\\"')}"`);
56
+ } catch {}
57
+ break;
58
+ default: break;
59
+ }
60
+ };
61
+
@@ -11,21 +11,21 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
20
 
21
21
  interface getWavPCM16Response {
22
- samples: Int16Array
23
- sampleRate: number
24
- channels: number
25
- bitsPerSample: number
22
+ Samples: Int16Array
23
+ SampleRate: number
24
+ Channels: number
25
+ BitsPerSample: number
26
26
  }
27
27
 
28
- export const getWavPCM16 = (buffer: Buffer): getWavPCM16Response => {
28
+ export const GetWavPCM16 = (buffer: Buffer): getWavPCM16Response => {
29
29
  if (buffer.toString("ascii", 0, 4) !== "RIFF" || buffer.toString("ascii", 8, 12) !== "WAVE") { return null; }
30
30
  let fmt = null;
31
31
  let data = null;
@@ -46,7 +46,7 @@ export const getWavPCM16 = (buffer: Buffer): getWavPCM16Response => {
46
46
  const bitsPerSample = fmt.readUInt16LE(14);
47
47
  if (audioFormat !== 1 || bitsPerSample !== 16 || channels !== 1) { return null; }
48
48
  const samples = new Int16Array(data.buffer, data.byteOffset, data.length / 2);
49
- return { samples: new Int16Array(samples), sampleRate, channels, bitsPerSample };
49
+ return { Samples: new Int16Array(samples), SampleRate: sampleRate, Channels: channels, BitsPerSample: bitsPerSample };
50
50
  }
51
51
 
52
52
 
@@ -11,15 +11,19 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
20
 
21
+ interface SetAFSKOptions {
22
+ Bits: number[]
23
+ SampleRate: number
24
+ }
21
25
 
22
- export const setAFSK = (bits: number[], sampleRate: number): Int16Array => {
26
+ export const SetAFSK = ({ Bits, SampleRate }: SetAFSKOptions): Int16Array => {
23
27
  const baud = 520.83;
24
28
  const markFreq = 2083.3;
25
29
  const spaceFreq = 1562.5;
@@ -28,20 +32,20 @@ export const setAFSK = (bits: number[], sampleRate: number): Int16Array => {
28
32
  const result = [];
29
33
  let phase = 0;
30
34
  let frac = 0;
31
- for (let b = 0; b < bits.length; b++) {
32
- const bit = bits[b];
35
+ for (let b = 0; b < Bits.length; b++) {
36
+ const bit = Bits[b];
33
37
  const freq = bit ? markFreq : spaceFreq;
34
- const samplesPerBit = sampleRate / baud + frac;
38
+ const samplesPerBit = SampleRate / baud + frac;
35
39
  const n = Math.round(samplesPerBit);
36
40
  frac = samplesPerBit - n;
37
- const inc = twoPi * freq / sampleRate;
41
+ const inc = twoPi * freq / SampleRate;
38
42
  for (let i = 0; i < n; i++) {
39
43
  result.push(Math.round(Math.sin(phase) * amplitude * 32767));
40
44
  phase += inc;
41
45
  if (phase > twoPi) phase -= twoPi;
42
46
  }
43
47
  }
44
- const fadeSamples = Math.floor(sampleRate * 0.002);
48
+ const fadeSamples = Math.floor(SampleRate * 0.002);
45
49
  for (let i = 0; i < fadeSamples; i++) {
46
50
  const gain = i / fadeSamples;
47
51
  result[i] = Math.round(result[i] * gain);
@@ -11,15 +11,14 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
20
 
21
-
22
- export const setAsciiToBits = (str: string): number[] => {
21
+ export const SetAsciiToBits = (str: string): number[] => {
23
22
  const bits = [];
24
23
  for (let i = 0; i < str.length; i++) {
25
24
  const c = str.charCodeAt(i) & 0xFF;
@@ -11,23 +11,28 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
20
 
21
- export const setAttentionTone = (ms: number, sampleRate: number): Int16Array => {
22
- const len = Math.floor(ms * sampleRate);
21
+ interface SetAttentionToneOptions {
22
+ MS: number
23
+ SampleRate: number
24
+ }
25
+
26
+ export const SetAttentionTone = ({ MS, SampleRate }: SetAttentionToneOptions): Int16Array => {
27
+ const len = Math.floor(MS * SampleRate);
23
28
  const out = new Int16Array(len);
24
29
  const f1 = 853;
25
30
  const f2 = 960;
26
31
  const twoPi = Math.PI * 2;
27
32
  const amp = 0.1;
28
- const fadeLen = Math.floor(sampleRate * 0.00);
33
+ const fadeLen = Math.floor(SampleRate * 0.00);
29
34
  for (let i = 0; i < len; i++) {
30
- const t = i / sampleRate;
35
+ const t = i / SampleRate;
31
36
  const s = Math.sin(twoPi * f1 * t) + Math.sin(twoPi * f2 * t);
32
37
  let gain = 1;
33
38
  if (i < fadeLen) gain = i / fadeLen;
@@ -11,21 +11,27 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
- import { getPCMToFloat } from "./eas.getPCMToFloat";
21
- import { getFloatPCM16 } from "./eas.getFloatPCM16";
22
20
 
23
- export const setNoise = (int16: Int16Array, noiseLevel: number = 0.02): Int16Array => {
24
- const x = getPCMToFloat(int16);
25
- for (let i = 0; i < x.length; i++) x[i] += (Math.random() * 2 - 1) * noiseLevel;
21
+ import { GetPCMToFloat } from "@AudioComponents/GetPCMToFloat"
22
+ import { GetFloatPCM16 } from "@AudioComponents/GetFloatPCM16"
23
+
24
+ interface SetNoiseOptions {
25
+ Int16: Int16Array
26
+ NoiseLevel?: number
27
+ }
28
+
29
+ export const SetNoise = ({ Int16, NoiseLevel }: SetNoiseOptions): Int16Array => {
30
+ const x = GetPCMToFloat(Int16);
31
+ for (let i = 0; i < x.length; i++) x[i] += (Math.random() * 2 - 1) * (NoiseLevel ?? 0.02);
26
32
  let peak = 0;
27
33
  for (let i = 0; i < x.length; i++) peak = Math.max(peak, Math.abs(x[i]));
28
34
  if (peak > 1) for (let i = 0; i < x.length; i++) x[i] *= 0.98 / peak;
29
- return getFloatPCM16(x);
35
+ return GetFloatPCM16(x);
30
36
  }
31
37
 
@@ -11,20 +11,26 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
- import { getPCMToFloat } from "./eas.getPCMToFloat";
21
- import { getFloatPCM16 } from "./eas.getFloatPCM16";
22
20
 
23
- export const setRadioEffect = (int16: Int16Array, sampleRate: number): Int16Array => {
21
+ import { GetPCMToFloat } from "@AudioComponents/GetPCMToFloat"
22
+ import { GetFloatPCM16 } from "@AudioComponents/GetFloatPCM16"
23
+
24
+ interface SetRadioEffectOptions {
25
+ Int16: Int16Array
26
+ SampleRate: number
27
+ }
28
+
29
+ export const SetRadioEffect = ({ Int16, SampleRate }: SetRadioEffectOptions): Int16Array => {
24
30
  const hpCut = 3555;
25
31
  const lpCut = 1600;
26
- const x = getPCMToFloat(int16);
27
- const dt = 1 / sampleRate;
32
+ const x = GetPCMToFloat(Int16);
33
+ const dt = 1 / SampleRate;
28
34
  const rcHP = 1 / (2 * Math.PI * hpCut);
29
35
  const aHP = rcHP / (rcHP + dt);
30
36
  let yHP = 0, xPrev = 0;
@@ -44,6 +50,6 @@ export const setRadioEffect = (int16: Int16Array, sampleRate: number): Int16Arra
44
50
  const compGain = 2.0;
45
51
  const norm = Math.tanh(compGain);
46
52
  for (let i = 0; i < x.length; i++) x[i] = Math.tanh(x[i] * compGain) / norm;
47
- return getFloatPCM16(x);
53
+ return GetFloatPCM16(x);
48
54
  }
49
55
 
@@ -11,35 +11,42 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
 
19
19
  */
20
20
 
21
+ import { SetAFSK } from "@AudioComponents/SetAFSK"
22
+ import { SetAsciiToBits } from "@AudioComponents/SetAsciiToBits"
23
+ import { GetMergedPCM16 } from "@AudioComponents/GetMergedPCM16"
21
24
 
22
- import { setAFSK } from "./eas.setAFSK";
23
- import { setAsciiToBits } from "./eas.setAsciiToBits";
24
- import { getMergedPCM16 } from "./eas.getMergedPCM16";
25
+ interface SetSameHeaderOptions {
26
+ VTEC: string
27
+ Repeats: number
28
+ SampleRate?: number
29
+ PreMarkSec?: number
30
+ GapSec?: number
31
+ }
25
32
 
26
- export const setSameHeader = (vtec: string, repeats: number, sampleRate: number = 8000, options: {preMarkSec?: number, gapSec?: number} = {}): Int16Array => {
27
- const preMarkSec = options.preMarkSec ?? 0.3;
28
- const gapSec = options.gapSec ?? 0.1;
33
+ export const SetSameHeader = ({ VTEC, Repeats, SampleRate, PreMarkSec, GapSec }: SetSameHeaderOptions): Int16Array => {
34
+ const preMarkSec = PreMarkSec ?? 0.3;
35
+ const gapSec = GapSec ?? 0.1;
29
36
  const bursts = [];
30
- const gap = new Int16Array(Math.floor(gapSec * sampleRate));
31
- for (let i = 0; i < repeats; i++) {
32
- const bodyBits = setAsciiToBits(vtec);
33
- const body = setAFSK(bodyBits, sampleRate);
34
- const extendedBodyDuration = Math.round(preMarkSec * sampleRate);
37
+ const gap = new Int16Array(Math.floor(gapSec * SampleRate));
38
+ for (let i = 0; i < Repeats; i++) {
39
+ const bodyBits = SetAsciiToBits(VTEC);
40
+ const body = SetAFSK({ Bits: bodyBits, SampleRate: SampleRate});
41
+ const extendedBodyDuration = Math.round(preMarkSec * SampleRate);
35
42
  const extendedBody = new Int16Array(extendedBodyDuration + gap.length);
36
43
  for (let j = 0; j < extendedBodyDuration; j++) {
37
44
  extendedBody[j] = Math.round(body[j % body.length] * 0.2);
38
45
  }
39
46
  extendedBody.set(gap, extendedBodyDuration);
40
47
  bursts.push(extendedBody);
41
- if (i !== repeats - 1) bursts.push(gap);
48
+ if (i !== Repeats - 1) bursts.push(gap);
42
49
  }
43
- return getMergedPCM16(bursts);
50
+ return GetMergedPCM16(bursts);
44
51
  }
45
52
 
@@ -11,24 +11,29 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap"
21
- import { TypeSettings } from "../../@types/types.settings";
20
+ import { Bootstrap } from "@Bootstrap"
21
+ import { SetWarning } from "@Utilities/SetWarning"
22
22
 
23
- interface SetWarningOptions {
24
- title?: string
25
- message: string
23
+ interface CreateQueryOptions {
24
+ Query: string
25
+ Parameters?: unknown[]
26
26
  }
27
27
 
28
- export const setWarning = (options: SetWarningOptions): void => {
29
- const settings = bootstrap.settings as TypeSettings;
30
- bootstrap.listener.emit(`log`, `${options.title ?? `[${bootstrap.ansi_colors.YELLOW}@atmosx/product-parser${bootstrap.ansi_colors.RESET}]`} ${options.message}`)
31
- if (settings.EnableJournal) {
32
- console.log(`${options.title ?? `[${bootstrap.ansi_colors.YELLOW}@atmosx/product-parser${bootstrap.ansi_colors.RESET}]`} ${options.message}`)
28
+ export const CreateQuery = function({ Query, Parameters }: CreateQueryOptions): any {
29
+ try {
30
+ const parameters = Array.isArray(Parameters) ? Parameters : [];
31
+ const statement = Bootstrap.Database.prepare(Query);
32
+ return /^\s*select/i.test(Query)
33
+ ? statement.all(...parameters)
34
+ : statement.run(...parameters);
35
+ } catch (error) {
36
+ SetWarning({Message: `Database Query Error: ${error instanceof Error ? error.stack ?? error.message : String(error)}`})
37
+ throw error;
33
38
  }
34
- }
39
+ };
@@ -11,25 +11,29 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeSettings } from "../../@types/types.settings"
21
- import { bootstrap } from '../../bootstrap'
22
- import { setWarning } from '../@utilities/utilities.setWarning';
23
- import { createEvent } from '../../@building/building.create';
20
+ import { TypeSettings } from "Types/Settings"
21
+ import { Bootstrap } from "@Bootstrap"
22
+ import { SetWarning } from "@Utilities/SetWarning"
23
+ import { CreateEvent } from "@Building/CreateEvent"
24
+ import { CreateQuery } from "@Database/CreateQuery"
24
25
 
25
- export const getCachedEvents = async (): Promise<void> => {
26
+ export const GetCachedEvents = async (): Promise<void> => {
26
27
  try {
27
- const settings = bootstrap.settings as TypeSettings;
28
+ const settings = Bootstrap.Settings as TypeSettings;
28
29
  const tick = performance.now();
29
30
  if (settings.NOAAWeatherWireServiceSettings.CacheSettings.Enabled) {
30
31
  const max = settings.NOAAWeatherWireServiceSettings.CacheSettings.MaxRetentionHistory ?? 500;
31
- const get = await bootstrap.database.prepare(`SELECT * FROM stanzas ORDER BY rowid DESC LIMIT ?`).all(max) as { rowid: number; stanza: string }[];
32
- setWarning({ message: `Fetched ${get.length} cached events from the database in ${Math.floor(performance.now() - tick)} ms` })
32
+ const get = await CreateQuery({
33
+ Query: `SELECT * FROM stanzas ORDER BY rowid DESC LIMIT ?`,
34
+ Parameters: [max]
35
+ }) as { rowid: number; stanza: string }[];
36
+ SetWarning({ Message: `Fetched ${get.length} cached stanzas from the database in ${Math.floor(performance.now() - tick)} ms` })
33
37
  let events = get.map((row) => JSON.parse(row.stanza))
34
38
  .filter(stanza => {
35
39
  if (!stanza) { return }
@@ -39,10 +43,11 @@ export const getCachedEvents = async (): Promise<void> => {
39
43
  return !isSkippable
40
44
  });
41
45
  events = events.sort((a, b) => b.issued - a.issued)
42
- await Promise.all(events.map(event => createEvent(event)))
43
- setWarning({ message: `Processed ${events.length} cached events in ${Math.floor(performance.now() - tick)} ms` })
46
+ await Promise.all(events.map(event => CreateEvent(event)))
47
+ SetWarning({ Message: `Processed ${events.length} cached stanzas in ${Math.floor(performance.now() - tick)} ms` })
44
48
  }
45
- } catch (error) {
46
- setWarning({ message: `An error occurred while fetching cached events: ${error.message} -> ${error.stack}` })
49
+ } catch (error: unknown) {
50
+ const message = error instanceof Error ? error.message : String(error);
51
+ SetWarning({ Message: `An error occurred while fetching cached stanzas: ${message}` })
47
52
  }
48
53
  }