@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.
- package/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +1 -1
- package/.github/SUPPORTED_EVENTS.md +370 -0
- package/.github/docs/docs-functions.md +30 -0
- package/.github/docs/docs-general-configurations.md +199 -0
- package/.github/docs/docs-integrations.md +38 -0
- package/.github/docs/docs-listeners.md +28 -0
- package/.github/docs/docs-source-configuration.md +218 -0
- package/.github/docs/docs-technical.md +50 -0
- package/.github/logo.png +0 -0
- package/.github/samples/SAMPLE_EAS_GENERATION.wav +0 -0
- package/.github/samples/SAMPLE_GEOJSON.json +204 -0
- package/.github/samples/SAMPLE_TEXT_PRODUCT.txt +119 -0
- package/README.md +157 -337
- package/dist/cjs/index.cjs +24125 -15815
- package/dist/esm/index.mjs +24144 -15839
- package/package.json +56 -53
- package/pnpm-workspace.yaml +4 -0
- package/src/bootstrap.ts +83 -43
- package/src/building/CreateEvent.ts +54 -0
- package/src/{@building/building.clean.ts → building/GetCleanedEvent.ts} +4 -4
- package/src/building/GetEventAttachments.ts +88 -0
- package/src/building/GetEventDirection.ts +28 -0
- package/src/{@building/building.enhance.ts → building/GetEventEnhancedName.ts} +13 -17
- package/src/{@building/building.geometry.ts → building/GetEventGeometry.ts} +19 -13
- package/src/{@building/building.headers.ts → building/GetEventHeader.ts} +13 -13
- package/src/{@building/building.polygon.ts → building/GetEventNodes.ts} +26 -22
- package/src/{@building/building.office.ts → building/GetEventOffice.ts} +14 -14
- package/src/building/GetEventProperties.ts +105 -0
- package/src/{@building/building.signature.ts → building/GetEventSignature.ts} +16 -17
- package/src/{@core/core.createListener.ts → building/GetEventTags.ts} +11 -6
- package/src/building/GetEventTheme.ts +26 -0
- package/src/building/GetEventTracking.ts +64 -0
- package/src/components/audio/GenerateAudioMessage.ts +149 -0
- package/src/components/audio/components/GetCleanDescription.ts +91 -0
- package/src/{@modules/@eas/eas.getFloatPCM16.ts → components/audio/components/GetFloatPCM16.ts} +3 -3
- package/src/{@modules/@eas/eas.getMergedPCM16.ts → components/audio/components/GetMergedPCM16.ts} +3 -3
- package/src/{@modules/@eas/eas.getPCM16.ts → components/audio/components/GetPCM16.ts} +13 -8
- package/src/{@modules/@eas/eas.getPCMToFloat.ts → components/audio/components/GetPCMToFloat.ts} +3 -3
- package/src/{@modules/@eas/eas.getSampledPCM16.ts → components/audio/components/GetSampledPCM16.ts} +14 -8
- package/src/components/audio/components/GetTTS.ts +61 -0
- package/src/{@modules/@eas/eas.getWavPCM16.ts → components/audio/components/GetWavPCM16.ts} +8 -8
- package/src/{@modules/@eas/eas.setAFSK.ts → components/audio/components/SetAFSK.ts} +12 -8
- package/src/{@modules/@eas/eas.setAsciiToBits.ts → components/audio/components/SetAsciiToBits.ts} +3 -4
- package/src/{@modules/@eas/eas.setAttentionTone.ts → components/audio/components/SetAttentionTone.ts} +11 -6
- package/src/{@modules/@eas/eas.setNoise.ts → components/audio/components/SetNoise.ts} +14 -8
- package/src/{@modules/@eas/eas.setRadioEffect.ts → components/audio/components/SetRadioEffect.ts} +14 -8
- package/src/{@modules/@eas/eas.setSameHeader.ts → components/audio/components/SetSameHeader.ts} +22 -15
- package/src/{@modules/@utilities/utilities.setWarning.ts → components/database/CreateQuery.ts} +18 -13
- package/src/{@modules/@database/database.cache.ts → components/database/GetCachedEvents.ts} +19 -14
- package/src/components/database/ImportBoundaries.ts +168 -0
- package/src/components/database/ImportBroadcastify.ts +60 -0
- package/src/components/database/ImportCities.ts +87 -0
- package/src/{@modules/@database/database.shapefiles.ts → components/database/ImportShapefiles.ts} +31 -37
- package/src/components/database/ImportStanza.ts +43 -0
- package/src/components/database/InitializeDatabase.ts +71 -0
- package/src/components/images/GenerateGraphic.ts +234 -0
- package/src/components/images/components/CreateRectangle.ts +22 -0
- package/src/components/images/components/CreateText.ts +22 -0
- package/src/components/images/modules/CreateSVG.ts +37 -0
- package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
- package/src/components/images/modules/GetGeographicalCities.ts +58 -0
- package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
- package/src/components/images/modules/GetGeometryBounds.ts +82 -0
- package/src/components/images/modules/GetParsedBoundary.ts +58 -0
- package/src/components/images/modules/GetSVGPath.ts +53 -0
- package/src/components/images/modules/NormalizePolygon.ts +57 -0
- package/src/{@modules/@stanza/stanza.getAwipsType.ts → components/stanza/GetAwipsType.ts} +19 -18
- package/src/components/stanza/ValidateStanza.ts +62 -0
- package/src/components/utilities/CreateHttp.ts +83 -0
- package/src/{@modules/@utilities/utilities.getFormattedTime.ts → components/utilities/GetFormattedTime.ts} +3 -3
- package/src/components/utilities/GetLatestIssuance.ts +32 -0
- package/src/components/utilities/GetMatched.ts +38 -0
- package/src/{@modules/@utilities/utilities.getShapeNearestPoint.ts → components/utilities/GetShapeNearestPoint.ts} +24 -19
- package/src/components/utilities/GetUnionPolygon.ts +36 -0
- package/src/components/utilities/QueueManager.ts +70 -0
- package/src/components/utilities/SetCronSchedule.ts +98 -0
- package/src/{@core/core.clearEvents.ts → components/utilities/SetDebug.ts} +17 -12
- package/src/components/utilities/SetEventEmit.ts +42 -0
- package/src/{@modules/@utilities/utilities.setSettings.ts → components/utilities/SetSettings.ts} +7 -7
- package/src/{@modules/@utilities/utilities.setSleep.ts → components/utilities/SetSleep.ts} +5 -5
- package/src/components/utilities/SetTimeoutAction.ts +64 -0
- package/src/components/utilities/SetWarning.ts +47 -0
- package/src/{@modules/@xmpp/xmpp.xDeploy.ts → components/xmpp/DeployXMPP.ts} +26 -27
- package/src/components/xmpp/ErrorXMPP.ts +27 -0
- package/src/{@modules/@xmpp/xmpp.xError.ts → components/xmpp/OfflineXMPP.ts} +17 -9
- package/src/{@modules/@xmpp/xmpp.xOnline.ts → components/xmpp/OnlineXMPP.ts} +21 -20
- package/src/components/xmpp/ReconnectXMPP.ts +64 -0
- package/src/components/xmpp/StanzaXMPP.ts +63 -0
- package/src/{@building/building.tags.ts → core/ClearEvents.ts} +12 -5
- package/src/{@core/core.getVersion.ts → core/GetEvents.ts} +5 -6
- package/src/core/GetNodes.ts +24 -0
- package/src/{@core/core.getNodes.ts → core/GetRandomEvent.ts} +5 -6
- package/src/core/GetVersion.ts +24 -0
- package/src/core/ManualEvent.ts +55 -0
- package/src/core/QueryStanza.ts +40 -0
- package/src/core/SetNode.ts +87 -0
- package/src/core/StartService.ts +62 -0
- package/src/core/StopService.ts +32 -0
- package/src/enums/AWIPS.ts +366 -0
- package/src/{@dictionaries/dictionaries.eventActions.ts → enums/Actions.ts} +3 -3
- package/src/{@dictionaries/dictionaries.eventCancelMessages.ts → enums/Cancellation.ts} +4 -3
- package/src/{@dictionaries/dictionaries.eventCauses.ts → enums/Causes.ts} +3 -3
- package/src/{@dictionaries/dictionaries.statusCorrelationText.ts → enums/Correlations.ts} +3 -3
- package/src/enums/Enhanced.ts +70 -0
- package/src/{@dictionaries/dictionaries.eventTypes.ts → enums/Events.ts} +3 -3
- package/src/{@dictionaries/dictionaries.regExp.ts → enums/Expressions.ts} +5 -4
- package/src/{@core/core.getEvents.ts → enums/GlobalFilter.ts} +7 -8
- package/src/{@dictionaries/dictionaries.hailStrings.ts → enums/Hail.ts} +9 -4
- package/src/{@dictionaries/dictionaries.officeICAOs.ts → enums/ICAO.ts} +5 -3
- package/src/enums/Matches.ts +60 -0
- package/src/{@dictionaries/dictionaries.eventProducts.ts → enums/Products.ts} +3 -3
- package/src/{@dictionaries/dictionaries.eventRecords.ts → enums/Records.ts} +3 -3
- package/src/{@dictionaries/dictionaries.eventSeverity.ts → enums/Severity.ts} +3 -3
- package/src/{@dictionaries/dictionaries.shapefileLinks.ts → enums/Shapefiles.ts} +3 -3
- package/src/enums/States.ts +136 -0
- package/src/{@dictionaries/dictionaries.eventStatus.ts → enums/Status.ts} +3 -3
- package/src/enums/Strings.ts +22 -0
- package/src/enums/Tags.ts +172 -0
- package/src/{@dictionaries/dictionaries.testSignatures.ts → enums/Testing.ts} +5 -4
- package/src/enums/Themes.ts +70 -0
- package/src/events/ParseAPI.ts +129 -0
- package/src/{@events/events.text.ts → events/ParseText.ts} +32 -23
- package/src/{@events/events.ugc.ts → events/ParseUGC.ts} +36 -26
- package/src/events/ParseVTEC.ts +88 -0
- package/src/index.ts +60 -38
- package/src/manager/MakeEvents.ts +110 -0
- package/src/manager/RemoveEvent.ts +74 -0
- package/src/{@manager/manager.setHash.ts → manager/SetHash.ts} +19 -15
- package/src/manager/UpdateEvents.ts +35 -0
- package/src/manager/UpdateNode.ts +62 -0
- package/src/manager/ValidateEvents.ts +144 -0
- package/src/{@parsers/@hvtec/hvtec.extract.ts → parsers/hvtec/HVExtract.ts} +13 -13
- package/src/parsers/text/GetDescriptionFromProduct.ts +59 -0
- package/src/parsers/text/GetEmbededText.ts +57 -0
- package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
- package/src/parsers/text/GetStringText.ts +58 -0
- package/src/{@parsers/@text/text.getTextFromProduct.ts → parsers/text/GetTextFromProduct.ts} +12 -12
- package/src/parsers/ugc/GetCache.ts +24 -0
- package/src/{@parsers/@ugc/ugc.expiry.ts → parsers/ugc/GetExpiry.ts} +3 -3
- package/src/{@parsers/@ugc/ugc.header.ts → parsers/ugc/GetHeader.ts} +6 -6
- package/src/parsers/ugc/GetLocations.ts +57 -0
- package/src/parsers/ugc/GetZonePolygon.ts +73 -0
- package/src/{@parsers/@ugc/ugc.zones.ts → parsers/ugc/GetZones.ts} +3 -3
- package/src/{@modules/@utilities/utilities.setListener.ts → parsers/ugc/SetCache.ts} +13 -10
- package/src/{@parsers/@ugc/ugc.extract.ts → parsers/ugc/UGCExtract.ts} +15 -15
- package/src/{@parsers/@pvtec/pvtec.expires.ts → parsers/vtec/GetExpiry.ts} +3 -3
- package/src/parsers/vtec/VTECExtract.ts +49 -0
- package/src/{@types/types.attributes.ts → static/Attributes.ts} +2 -3
- package/src/{@types/type.event.ts → static/Event.ts} +11 -8
- package/src/{@types/type.properties.ts → static/Properties.ts} +17 -10
- package/src/{@types/types.stanza.ts → static/Stanza.ts} +2 -2
- package/src/tasks/CreateTasks.ts +123 -0
- package/src/{@core/core.stop.ts → tasks/TaskGenerateJSON.ts} +14 -12
- package/src/tasks/TaskGenerateText.ts +34 -0
- package/src/tasks/TaskSendNTFY.ts +97 -0
- package/src/tasks/TaskSendWebhook.ts +107 -0
- package/src/types/Actions.ts +37 -0
- package/src/{@types/types.hvtec.ts → types/HVTEC.ts} +6 -6
- package/src/{@types/types.hash.ts → types/Hash.ts} +5 -5
- package/src/types/Nodes.ts +29 -0
- package/src/{@types/types.settings.ts → types/Settings.ts} +42 -10
- package/src/{@types/types.compiled.ts → types/StanzaCompiled.ts} +15 -14
- package/src/{@types/types.ugc.ts → types/UGC.ts} +5 -5
- package/src/{@modules/@utilities/utilities.getSettings.ts → types/VTEC.ts} +12 -7
- package/tools/build.js +47 -0
- package/tsconfig.json +28 -1
- package/dist/index.d.mts +0 -239
- package/dist/index.d.ts +0 -239
- package/src/@building/building.create.ts +0 -42
- package/src/@building/building.properties.ts +0 -89
- package/src/@building/building.tracking.ts +0 -68
- package/src/@building/building.validate.ts +0 -147
- package/src/@core/core.getRandomEvent.ts +0 -25
- package/src/@core/core.setNode.ts +0 -81
- package/src/@core/core.start.ts +0 -61
- package/src/@dictionaries/dictionaries.betterEventNames.ts +0 -99
- package/src/@dictionaries/dictionaries.eventAwipAbreviations.ts +0 -364
- package/src/@dictionaries/dictionaries.eventTags.ts +0 -93
- package/src/@dictionaries/dictionaries.eventsMatchText.ts +0 -36
- package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +0 -68
- package/src/@events/events.api.ts +0 -113
- package/src/@events/events.vtec.ts +0 -87
- package/src/@manager/manager.mkEvent.ts +0 -96
- package/src/@manager/manager.rmEvent.ts +0 -49
- package/src/@manager/manager.updateEvents.ts +0 -35
- package/src/@manager/manager.updateNodes.ts +0 -55
- package/src/@manager/manager.updateWebhooks.ts +0 -50
- package/src/@modules/@database/database.init.ts +0 -45
- package/src/@modules/@database/database.stanza.ts +0 -48
- package/src/@modules/@eas/eas.setEasTone.ts +0 -137
- package/src/@modules/@stanza/stanza.validate.ts +0 -50
- package/src/@modules/@utilities/utilities.createHttp.ts +0 -85
- package/src/@modules/@utilities/utilities.createWebhook.ts +0 -115
- package/src/@modules/@utilities/utilities.setCronSchedule.ts +0 -65
- package/src/@modules/@utilities/utilities.setEventEmit.ts +0 -41
- package/src/@modules/@utilities/utilities.setTimeoutAction.ts +0 -59
- package/src/@modules/@xmpp/xmpp.xOffline.ts +0 -38
- package/src/@modules/@xmpp/xmpp.xReconnect.ts +0 -64
- package/src/@modules/@xmpp/xmpp.xStanza.ts +0 -63
- package/src/@parsers/@pvtec/pvtec.extract.ts +0 -49
- package/src/@parsers/@text/text.getDescriptionFromProduct.ts +0 -53
- package/src/@parsers/@text/text.getPolygonFromProduct.ts +0 -32
- package/src/@parsers/@text/text.getXML.ts +0 -61
- package/src/@parsers/@ugc/ugc.coordinates.ts +0 -110
- package/src/@parsers/@ugc/ugc.locations.ts +0 -29
- package/src/@types/types.pvtec.ts +0 -30
- package/src/@types/types.webhook.ts +0 -27
- package/test.js +0 -91
- package/tsup.config.ts +0 -16
- /package/{CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md} +0 -0
- /package/{LICENSE → .github/LICENSE} +0 -0
- /package/{SECURITY.md → .github/SECURITY.md} +0 -0
package/src/{@modules/@eas/eas.getFloatPCM16.ts → components/audio/components/GetFloatPCM16.ts}
RENAMED
|
@@ -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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
export const
|
|
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]));
|
package/src/{@modules/@eas/eas.getMergedPCM16.ts → components/audio/components/GetMergedPCM16.ts}
RENAMED
|
@@ -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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
export const
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
|
|
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 =
|
|
26
|
-
const subchunk2Size =
|
|
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(
|
|
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 <
|
|
47
|
-
buffer.writeInt16LE(
|
|
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
|
}
|
package/src/{@modules/@eas/eas.getPCMToFloat.ts → components/audio/components/GetPCMToFloat.ts}
RENAMED
|
@@ -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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
export const
|
|
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;
|
package/src/{@modules/@eas/eas.getSampledPCM16.ts → components/audio/components/GetSampledPCM16.ts}
RENAMED
|
@@ -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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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,
|
|
35
|
+
const i1 = Math.min(i0 + 1, Int16.length - 1);
|
|
30
36
|
const frac = pos - i0;
|
|
31
|
-
const v =
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
interface getWavPCM16Response {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
Samples: Int16Array
|
|
23
|
+
SampleRate: number
|
|
24
|
+
Channels: number
|
|
25
|
+
BitsPerSample: number
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export const
|
|
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 {
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
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
|
|
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 <
|
|
32
|
-
const bit =
|
|
35
|
+
for (let b = 0; b < Bits.length; b++) {
|
|
36
|
+
const bit = Bits[b];
|
|
33
37
|
const freq = bit ? markFreq : spaceFreq;
|
|
34
|
-
const samplesPerBit =
|
|
38
|
+
const samplesPerBit = SampleRate / baud + frac;
|
|
35
39
|
const n = Math.round(samplesPerBit);
|
|
36
40
|
frac = samplesPerBit - n;
|
|
37
|
-
const inc = twoPi * freq /
|
|
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(
|
|
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);
|
package/src/{@modules/@eas/eas.setAsciiToBits.ts → components/audio/components/SetAsciiToBits.ts}
RENAMED
|
@@ -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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
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(
|
|
33
|
+
const fadeLen = Math.floor(SampleRate * 0.00);
|
|
29
34
|
for (let i = 0; i < len; i++) {
|
|
30
|
-
const t = i /
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
35
|
+
return GetFloatPCM16(x);
|
|
30
36
|
}
|
|
31
37
|
|
package/src/{@modules/@eas/eas.setRadioEffect.ts → components/audio/components/SetRadioEffect.ts}
RENAMED
|
@@ -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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
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
|
-
|
|
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 =
|
|
27
|
-
const dt = 1 /
|
|
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
|
|
53
|
+
return GetFloatPCM16(x);
|
|
48
54
|
}
|
|
49
55
|
|
package/src/{@modules/@eas/eas.setSameHeader.ts → components/audio/components/SetSameHeader.ts}
RENAMED
|
@@ -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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
interface SetSameHeaderOptions {
|
|
26
|
+
VTEC: string
|
|
27
|
+
Repeats: number
|
|
28
|
+
SampleRate?: number
|
|
29
|
+
PreMarkSec?: number
|
|
30
|
+
GapSec?: number
|
|
31
|
+
}
|
|
25
32
|
|
|
26
|
-
export const
|
|
27
|
-
const preMarkSec =
|
|
28
|
-
const gapSec =
|
|
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 *
|
|
31
|
-
for (let i = 0; i <
|
|
32
|
-
const bodyBits =
|
|
33
|
-
const body =
|
|
34
|
-
const extendedBodyDuration = Math.round(preMarkSec *
|
|
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 !==
|
|
48
|
+
if (i !== Repeats - 1) bursts.push(gap);
|
|
42
49
|
}
|
|
43
|
-
return
|
|
50
|
+
return GetMergedPCM16(bursts);
|
|
44
51
|
}
|
|
45
52
|
|
package/src/{@modules/@utilities/utilities.setWarning.ts → components/database/CreateQuery.ts}
RENAMED
|
@@ -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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
20
|
+
import { Bootstrap } from "@Bootstrap"
|
|
21
|
+
import { SetWarning } from "@Utilities/SetWarning"
|
|
22
22
|
|
|
23
|
-
interface
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
interface CreateQueryOptions {
|
|
24
|
+
Query: string
|
|
25
|
+
Parameters?: unknown[]
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeSettings } from "
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
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
|
|
26
|
+
export const GetCachedEvents = async (): Promise<void> => {
|
|
26
27
|
try {
|
|
27
|
-
const settings =
|
|
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
|
|
32
|
-
|
|
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 =>
|
|
43
|
-
|
|
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
|
-
|
|
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
|
}
|