@atmosx/event-product-parser 3.0.6 → 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/.github/docs/docs-functions.md +2 -2
- package/.github/docs/docs-general-configurations.md +2 -12
- package/.github/docs/docs-integrations.md +4 -3
- package/.github/docs/docs-listeners.md +1 -1
- package/.github/docs/docs-source-configuration.md +1 -1
- package/.github/docs/docs-technical.md +1 -1
- package/{.github/README.md → README.md} +15 -9
- package/dist/cjs/index.cjs +24073 -7018
- package/dist/esm/index.mjs +24035 -6983
- package/package.json +56 -47
- package/pnpm-workspace.yaml +4 -0
- package/src/bootstrap.ts +64 -48
- package/src/{@building → building}/CreateEvent.ts +22 -24
- package/src/{@building → building}/GetCleanedEvent.ts +2 -2
- package/src/{@building → building}/GetEventAttachments.ts +14 -12
- package/src/building/GetEventDirection.ts +28 -0
- package/src/{@building → building}/GetEventEnhancedName.ts +5 -8
- package/src/{@building → building}/GetEventGeometry.ts +19 -13
- package/src/{@building → building}/GetEventHeader.ts +13 -13
- package/src/{@building → building}/GetEventNodes.ts +21 -19
- package/src/{@building → building}/GetEventOffice.ts +13 -13
- package/src/building/GetEventProperties.ts +105 -0
- package/src/{@building → building}/GetEventSignature.ts +9 -9
- package/src/{@building → building}/GetEventTags.ts +3 -3
- package/src/building/GetEventTheme.ts +26 -0
- package/src/building/GetEventTracking.ts +64 -0
- package/src/components/audio/GenerateAudioMessage.ts +149 -0
- package/src/{@modules/@eas → components/audio/components}/GetCleanDescription.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetFloatPCM16.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetMergedPCM16.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetPCM16.ts +13 -8
- package/src/{@modules/@eas → components/audio/components}/GetPCMToFloat.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetSampledPCM16.ts +14 -8
- package/src/{@modules/@eas → components/audio/components}/GetTTS.ts +17 -10
- package/src/{@modules/@eas → components/audio/components}/GetWavPCM16.ts +7 -7
- package/src/{@modules/@eas → components/audio/components}/SetAFSK.ts +13 -8
- package/src/{@modules/@eas → components/audio/components}/SetAsciiToBits.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/SetAttentionTone.ts +11 -6
- package/src/{@modules/@eas → components/audio/components}/SetNoise.ts +12 -7
- package/src/{@modules/@eas → components/audio/components}/SetRadioEffect.ts +12 -7
- package/src/{@modules/@eas → components/audio/components}/SetSameHeader.ts +22 -14
- package/src/{@modules/@utilities/SetWarning.ts → components/database/CreateQuery.ts} +18 -13
- package/src/{@modules/@database → components/database}/GetCachedEvents.ts +18 -15
- package/src/components/database/ImportBoundaries.ts +168 -0
- package/src/{@modules/@database → components/database}/ImportBroadcastify.ts +14 -24
- package/src/components/database/ImportCities.ts +87 -0
- package/src/{@modules/@database → components/database}/ImportShapefiles.ts +23 -26
- package/src/{@modules/@database → components/database}/ImportStanza.ts +15 -19
- 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 → components/stanza}/GetAwipsType.ts +16 -17
- package/src/{@modules/@stanza → components/stanza}/ValidateStanza.ts +27 -15
- package/src/{@modules/@utilities → components/utilities}/CreateHttp.ts +26 -26
- package/src/{@modules/@utilities → components/utilities}/GetFormattedTime.ts +2 -2
- package/src/{@modules/@utilities → components/utilities}/GetLatestIssuance.ts +2 -2
- package/src/{@modules/@utilities → components/utilities}/GetMatched.ts +10 -5
- package/src/{@modules/@utilities → components/utilities}/GetShapeNearestPoint.ts +24 -19
- package/src/components/utilities/GetUnionPolygon.ts +36 -0
- package/src/components/utilities/QueueManager.ts +70 -0
- package/src/{@modules/@utilities → components/utilities}/SetCronSchedule.ts +29 -25
- package/src/{@modules/@utilities → components/utilities}/SetDebug.ts +12 -12
- package/src/components/utilities/SetEventEmit.ts +42 -0
- package/src/{@modules/@utilities → components/utilities}/SetSettings.ts +7 -7
- package/src/{@modules/@utilities → 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 → components/xmpp}/DeployXMPP.ts +20 -20
- package/src/{@core/CreateListener.ts → components/xmpp/ErrorXMPP.ts} +8 -5
- package/src/{@modules/@xmpp → components/xmpp}/OfflineXMPP.ts +13 -13
- package/src/{@modules/@xmpp → components/xmpp}/OnlineXMPP.ts +18 -18
- package/src/components/xmpp/ReconnectXMPP.ts +64 -0
- package/src/{@modules/@xmpp → components/xmpp}/StanzaXMPP.ts +25 -25
- package/src/{@core → core}/ClearEvents.ts +9 -9
- package/src/{@core → core}/GetEvents.ts +4 -4
- package/src/{@core → core}/GetNodes.ts +4 -4
- package/src/{@core → core}/GetRandomEvent.ts +4 -4
- package/src/{@core → core}/GetVersion.ts +4 -4
- package/src/{@core → core}/ManualEvent.ts +23 -24
- package/src/{@core → core}/QueryStanza.ts +12 -11
- package/src/core/SetNode.ts +87 -0
- package/src/{@core → core}/StartService.ts +21 -20
- package/src/{@core → core}/StopService.ts +10 -10
- package/src/{@enums → enums}/AWIPS.ts +2 -2
- package/src/{@enums → enums}/Actions.ts +2 -2
- package/src/{@enums → enums}/Cancellation.ts +2 -2
- package/src/{@enums → enums}/Causes.ts +2 -2
- package/src/{@enums → enums}/Correlations.ts +2 -2
- package/src/{@enums → enums}/Enhanced.ts +2 -2
- package/src/{@enums → enums}/Events.ts +2 -2
- package/src/{@enums → enums}/Expressions.ts +3 -3
- package/src/{@enums → enums}/GlobalFilter.ts +2 -2
- package/src/{@enums → enums}/Hail.ts +2 -2
- package/src/{@enums → enums}/ICAO.ts +2 -2
- package/src/{@enums → enums}/Matches.ts +8 -3
- package/src/{@enums → enums}/Products.ts +2 -2
- package/src/{@enums → enums}/Records.ts +2 -2
- package/src/{@enums → enums}/Severity.ts +2 -2
- package/src/{@enums → enums}/Shapefiles.ts +2 -2
- package/src/{@enums → enums}/States.ts +68 -4
- package/src/{@enums → enums}/Status.ts +2 -2
- package/src/{@enums → enums}/Strings.ts +2 -2
- package/src/{@enums → enums}/Tags.ts +9 -4
- package/src/{@enums → enums}/Testing.ts +2 -2
- package/src/enums/Themes.ts +70 -0
- package/src/events/ParseAPI.ts +129 -0
- package/src/{@events → events}/ParseText.ts +24 -22
- package/src/{@events → events}/ParseUGC.ts +27 -26
- package/src/{@events → events}/ParseVTEC.ts +38 -37
- package/src/index.ts +57 -37
- package/src/manager/MakeEvents.ts +110 -0
- package/src/manager/RemoveEvent.ts +74 -0
- package/src/{@manager → manager}/SetHash.ts +18 -13
- package/src/{@manager → manager}/UpdateEvents.ts +12 -12
- package/src/{@manager → manager}/UpdateNode.ts +14 -14
- package/src/{@building → manager}/ValidateEvents.ts +47 -57
- package/src/{@parsers/@hvtec → parsers/hvtec}/HVExtract.ts +11 -11
- package/src/{@parsers/@text → parsers/text}/GetDescriptionFromProduct.ts +20 -21
- package/src/{@parsers/@text → parsers/text}/GetEmbededText.ts +7 -6
- package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
- package/src/{@parsers/@text → parsers/text}/GetStringText.ts +9 -9
- package/src/{@parsers/@text → parsers/text}/GetTextFromProduct.ts +12 -12
- package/src/parsers/ugc/GetCache.ts +24 -0
- package/src/{@parsers/@ugc → parsers/ugc}/GetExpiry.ts +2 -2
- package/src/{@parsers/@ugc/GetUGCHeader.ts → parsers/ugc/GetHeader.ts} +4 -4
- package/src/{@parsers/@ugc → parsers/ugc}/GetLocations.ts +10 -10
- package/src/parsers/ugc/GetZonePolygon.ts +73 -0
- package/src/{@parsers/@ugc → parsers/ugc}/GetZones.ts +3 -3
- package/src/{@parsers/@ugc → parsers/ugc}/SetCache.ts +13 -8
- package/src/{@parsers/@ugc → parsers/ugc}/UGCExtract.ts +14 -14
- package/src/{@parsers/@pvtec → parsers/vtec}/GetExpiry.ts +2 -2
- package/src/parsers/vtec/VTECExtract.ts +49 -0
- package/src/{@types → static}/Attributes.ts +2 -3
- package/src/{@types → static}/Event.ts +8 -7
- package/src/{@types → static}/Properties.ts +7 -3
- package/src/{@types → static}/Stanza.ts +2 -2
- package/src/tasks/CreateTasks.ts +123 -0
- package/src/tasks/TaskGenerateJSON.ts +34 -0
- package/src/tasks/TaskGenerateText.ts +34 -0
- package/src/tasks/TaskSendNTFY.ts +97 -0
- package/src/tasks/TaskSendWebhook.ts +107 -0
- package/src/{@types → types}/Actions.ts +3 -3
- package/src/{@types → types}/HVTEC.ts +6 -6
- package/src/{@types → types}/Hash.ts +5 -5
- package/src/types/Nodes.ts +29 -0
- package/src/{@types → types}/Settings.ts +16 -8
- package/src/{@types → types}/StanzaCompiled.ts +15 -15
- package/src/{@types → types}/UGC.ts +5 -5
- package/src/{@modules/@utilities/GetSettings.ts → types/VTEC.ts} +12 -7
- package/tools/build.js +47 -0
- package/tsconfig.json +28 -1
- package/src/@building/GetEventProperties.ts +0 -96
- package/src/@building/GetEventTracking.ts +0 -68
- package/src/@core/SetNode.ts +0 -81
- package/src/@events/ParseAPI.ts +0 -117
- package/src/@manager/CreateActions.ts +0 -213
- package/src/@manager/MakeEvent.ts +0 -99
- package/src/@manager/RemoveEvent.ts +0 -70
- package/src/@modules/@database/InitializeDatabase.ts +0 -59
- package/src/@modules/@eas/GenerateEASMessage.ts +0 -144
- package/src/@modules/@utilities/SetEventEmit.ts +0 -41
- package/src/@modules/@utilities/SetListener.ts +0 -30
- package/src/@modules/@utilities/SetTimeoutAction.ts +0 -64
- package/src/@modules/@xmpp/ErrorXMPP.ts +0 -27
- package/src/@modules/@xmpp/ReconnectXMPP.ts +0 -64
- package/src/@parsers/@pvtec/VTECExtract.ts +0 -49
- package/src/@parsers/@text/GetPolygonFromProduct.ts +0 -53
- package/src/@parsers/@text/GetXML.ts +0 -61
- package/src/@parsers/@ugc/GetCache.ts +0 -24
- package/src/@parsers/@ugc/GetZonePolygon.ts +0 -111
- package/src/@types/VTEC.ts +0 -30
- package/tsup.config.ts +0 -16
|
@@ -1,64 +0,0 @@
|
|
|
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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { bootstrap } from "../../bootstrap"
|
|
21
|
-
|
|
22
|
-
interface SetTimeoutActionOptions {
|
|
23
|
-
identifier: string
|
|
24
|
-
addTime?: boolean
|
|
25
|
-
max?: number
|
|
26
|
-
interval?: number
|
|
27
|
-
expire?: boolean
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
type SetTimeoutActionResponse = {
|
|
31
|
-
limited: boolean
|
|
32
|
-
remaining?: number
|
|
33
|
-
response?: string
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const SetTimeoutAction = (options: SetTimeoutActionOptions): SetTimeoutActionResponse => {
|
|
37
|
-
let target = bootstrap?.ratelimits?.[options?.identifier];
|
|
38
|
-
if (!target) {
|
|
39
|
-
bootstrap.ratelimits[options?.identifier] = [];
|
|
40
|
-
target = bootstrap.ratelimits[options?.identifier];
|
|
41
|
-
}
|
|
42
|
-
if (options?.expire) {
|
|
43
|
-
delete bootstrap.ratelimits[options?.identifier];
|
|
44
|
-
return { limited: false };
|
|
45
|
-
}
|
|
46
|
-
if (target?.length > 0) {
|
|
47
|
-
bootstrap.ratelimits[options?.identifier] = target.filter((ts: number) => Date.now() - ts < options?.interval * 1000);
|
|
48
|
-
target = bootstrap.ratelimits[options?.identifier];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const oldestTimestamp = target?.[0];
|
|
52
|
-
const getWait = oldestTimestamp ? Math.ceil((options?.interval * 1000) - (Date.now() - oldestTimestamp)) : 0;
|
|
53
|
-
const max = options?.max ?? 1;
|
|
54
|
-
|
|
55
|
-
if (target?.length >= max && getWait > 0) {
|
|
56
|
-
return {
|
|
57
|
-
limited: true,
|
|
58
|
-
remaining: getWait,
|
|
59
|
-
response: `You are being rate limited, please wait ${(getWait / 1e3).toFixed(1)} second(s) before performing this action again.`
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
bootstrap.ratelimits[options?.identifier].push(Date.now());
|
|
63
|
-
return { limited: false };
|
|
64
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { bootstrap } from "../../bootstrap";
|
|
21
|
-
|
|
22
|
-
export const ErrorXMPP = () => {
|
|
23
|
-
bootstrap.session_xmpp.on(`error`, async (error: Error) => {
|
|
24
|
-
bootstrap.cache.isConnected = false;
|
|
25
|
-
bootstrap.cache.sigHault = true;
|
|
26
|
-
})
|
|
27
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { TypeSettings } from "../../@types/Settings";
|
|
21
|
-
import { bootstrap } from "../../bootstrap"
|
|
22
|
-
import { SetEventEmit } from "../@utilities/SetEventEmit";
|
|
23
|
-
import { SetWarning } from "../@utilities/SetWarning";
|
|
24
|
-
|
|
25
|
-
export const ReconnectXMPP = async (interval: number): Promise<void> => {
|
|
26
|
-
const settings = bootstrap.settings as TypeSettings;
|
|
27
|
-
const lastStanza = Date.now() - bootstrap.cache.lastStanza
|
|
28
|
-
if (interval < 15) {
|
|
29
|
-
SetWarning({ message: `Reconnection interval of ${interval} seconds is too low, setting to 15 seconds` })
|
|
30
|
-
interval = 15;
|
|
31
|
-
bootstrap.settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.ReconnectionInterval = 15;
|
|
32
|
-
}
|
|
33
|
-
const reconnectThreshold = interval * 1e3
|
|
34
|
-
if ((!bootstrap.cache.isConnected && !bootstrap.cache.sigHault) || !bootstrap.session_xmpp) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (lastStanza > reconnectThreshold) {
|
|
38
|
-
if (!bootstrap.cache.isReconnecting) {
|
|
39
|
-
bootstrap.cache.isReconnecting = true;
|
|
40
|
-
bootstrap.cache.isConnected = false;
|
|
41
|
-
bootstrap.cache.tReconnects += 1;
|
|
42
|
-
try {
|
|
43
|
-
SetEventEmit({
|
|
44
|
-
event: `onServiceStatus`,
|
|
45
|
-
metadata: {
|
|
46
|
-
message: `Attempting to reconnect to XMPP Service (Reconnect Attempt ${bootstrap.cache.tReconnects})`,
|
|
47
|
-
data: {
|
|
48
|
-
last_stanza: lastStanza,
|
|
49
|
-
nickname: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Nickname
|
|
50
|
-
},
|
|
51
|
-
type: `reconnect`,
|
|
52
|
-
error: true
|
|
53
|
-
}, message: `Attempting to reconnect to XMPP Service (Reconnect Attempt ${bootstrap.cache.tReconnects})`,
|
|
54
|
-
})
|
|
55
|
-
await bootstrap.session_xmpp.stop().catch(() => {});
|
|
56
|
-
await bootstrap.session_xmpp.start().catch(() => {});
|
|
57
|
-
} catch (error) {
|
|
58
|
-
SetWarning({ message: `XMPP Reconnect Failed - ${(error as Error).message}` })
|
|
59
|
-
} finally {
|
|
60
|
-
bootstrap.cache.isReconnecting = false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { TypePVTEC } from "../../@types/VTEC";
|
|
21
|
-
import { EnumExpressions } from "../../@enums/Expressions";
|
|
22
|
-
import { EnumProducts } from "../../@enums/Products";
|
|
23
|
-
import { EnumEvents } from "../../@enums/Events";
|
|
24
|
-
import { EnumActions } from "../../@enums/Actions";
|
|
25
|
-
import { EnumStatus } from "../../@enums/Status";
|
|
26
|
-
import { GetExpiry } from "./GetExpiry";
|
|
27
|
-
|
|
28
|
-
export const VTECExtract = (message: string): TypePVTEC[] | null => {
|
|
29
|
-
if (!message) return null;
|
|
30
|
-
const getVTECs = message.match(EnumExpressions.pvtec) ?? [];
|
|
31
|
-
const vtecs: TypePVTEC[] = [];
|
|
32
|
-
for (const vtec of getVTECs) {
|
|
33
|
-
const sub = vtec.split(`.`);
|
|
34
|
-
if (sub?.length < 7) continue;
|
|
35
|
-
const dates = sub[6]?.split(`-`);
|
|
36
|
-
vtecs.push({
|
|
37
|
-
vtec: vtec,
|
|
38
|
-
product: EnumProducts[sub[0]],
|
|
39
|
-
tracking: `${sub[2]}.${sub[3]}.${sub[4]}.${sub[5]}`,
|
|
40
|
-
event: `${EnumEvents[sub[3]]} ${EnumActions[sub[4]]}`,
|
|
41
|
-
status: EnumStatus[sub[1]],
|
|
42
|
-
organization: message.match(EnumExpressions.wmo)?.[0] ?? null,
|
|
43
|
-
expires: GetExpiry(dates),
|
|
44
|
-
is_watch: (sub[4] == `A` || sub[4] == `Y`) && (sub[3] == `TO` || sub[3] == `SV`),
|
|
45
|
-
prediction_center: sub[2] == `KWNS` ? true : false
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
return vtecs.length > 0 ? vtecs : null;
|
|
49
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export const getPolygonFromProduct = (message: string): number[][] => {
|
|
21
|
-
const coordinates: number[][] = [];
|
|
22
|
-
const match = message.match(
|
|
23
|
-
/LAT\.\.\.LON\s+([\s\S]*?)(?=\n[A-Z]{2,}(?:\.\.\.|:)|\$\$|&&|$)/i
|
|
24
|
-
);
|
|
25
|
-
if (!match) return coordinates;
|
|
26
|
-
const text = match[1];
|
|
27
|
-
const values = text.match(/\d{4,8}/g);
|
|
28
|
-
if (!values) return coordinates;
|
|
29
|
-
|
|
30
|
-
if (values.every(v => v.length === 8)) {
|
|
31
|
-
for (const value of values) {
|
|
32
|
-
const lat = parseInt(value.slice(0, 4), 10) / 100;
|
|
33
|
-
const lon = -parseInt(value.slice(4, 8), 10) / 100;
|
|
34
|
-
if (Number.isFinite(lat) && Number.isFinite(lon)) {
|
|
35
|
-
coordinates.push([lon, lat]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
else {
|
|
41
|
-
for (let i = 0; i + 1 < values.length; i += 2) {
|
|
42
|
-
const lat = parseInt(values[i], 10) / 100;
|
|
43
|
-
const lon = -parseInt(values[i + 1], 10) / 100;
|
|
44
|
-
if (Number.isFinite(lat) && Number.isFinite(lon)) {
|
|
45
|
-
coordinates.push([lon, lat]);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (coordinates.length > 2) {
|
|
50
|
-
coordinates.push([...coordinates[0]]);
|
|
51
|
-
}
|
|
52
|
-
return coordinates;
|
|
53
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
interface GetXMLOptions {
|
|
21
|
-
message: string
|
|
22
|
-
targets: string[]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const GetXML = (options: GetXMLOptions): Record<string, string> => {
|
|
26
|
-
const extracted: Record<string, any> = {};
|
|
27
|
-
const findValueByKey = (obj: any, searchKey: string) => {
|
|
28
|
-
const results = [];
|
|
29
|
-
if (obj === null || typeof obj !== 'object') {
|
|
30
|
-
return results;
|
|
31
|
-
}
|
|
32
|
-
const searchKeyLower = searchKey.toLowerCase();
|
|
33
|
-
for (const key in obj) {
|
|
34
|
-
if (obj.hasOwnProperty(key) && key.toLowerCase() === searchKeyLower) {
|
|
35
|
-
results.push(obj[key]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (Array.isArray(obj)) {
|
|
39
|
-
for (const item of obj) {
|
|
40
|
-
if (item.valueName && item.valueName.toLowerCase() === searchKeyLower && item.value !== undefined) {
|
|
41
|
-
results.push(item.value);
|
|
42
|
-
}
|
|
43
|
-
const nestedResults = findValueByKey(item, searchKey);
|
|
44
|
-
results.push(...nestedResults);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
for (const key in obj) {
|
|
48
|
-
if (obj.hasOwnProperty(key)) {
|
|
49
|
-
const nestedResults = findValueByKey(obj[key], searchKey);
|
|
50
|
-
results.push(...nestedResults);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return results;
|
|
54
|
-
};
|
|
55
|
-
for (const key of options.targets) {
|
|
56
|
-
const values = findValueByKey(options.message, key);
|
|
57
|
-
const uniqueValues = [...new Set(values)];
|
|
58
|
-
extracted[key] = uniqueValues.length === 0 ? null : (uniqueValues.length === 1 ? uniqueValues[0] : uniqueValues);
|
|
59
|
-
}
|
|
60
|
-
return extracted;
|
|
61
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { bootstrap } from "../../bootstrap";
|
|
21
|
-
|
|
22
|
-
export const getCache = (key: string) => {
|
|
23
|
-
return bootstrap.cache.ugc.get(key);
|
|
24
|
-
};
|
|
@@ -1,111 +0,0 @@
|
|
|
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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { bootstrap } from "../../bootstrap"
|
|
21
|
-
import { union } from "polygon-clipping";
|
|
22
|
-
|
|
23
|
-
interface CoordinatesOptions {
|
|
24
|
-
zones: string[]
|
|
25
|
-
isUnion: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface CoordinatesResponse {
|
|
29
|
-
type: `Polygon` | `MultiPolygon`
|
|
30
|
-
coordinates: any[]
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const getZonePolygon = (options: CoordinatesOptions): CoordinatesResponse | null => {
|
|
34
|
-
const list = [...new Set(options.zones.map(z => z.trim()))].filter(z => z === 'XX000' ? false : true);
|
|
35
|
-
if (list.length === 0) return null;
|
|
36
|
-
|
|
37
|
-
const placeholders = list.map(() => "?").join(",");
|
|
38
|
-
const rows = bootstrap.database
|
|
39
|
-
.prepare(`SELECT geometry FROM shapefiles WHERE id IN (${placeholders})`)
|
|
40
|
-
.all(...list);
|
|
41
|
-
const polygons: any[] = [];
|
|
42
|
-
for (const row of rows) {
|
|
43
|
-
if (!row?.geometry) continue;
|
|
44
|
-
const geom = JSON.parse(row.geometry);
|
|
45
|
-
if (geom?.type === "Polygon") {
|
|
46
|
-
polygons.push(geom.coordinates);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (polygons.length === 0) return null;
|
|
51
|
-
|
|
52
|
-
if (options.isUnion) {
|
|
53
|
-
const unionFn = union as (...polys: any[]) => any;
|
|
54
|
-
const mergedCoords = unionFn(...polygons);
|
|
55
|
-
if (!mergedCoords || mergedCoords.length === 0) return null;
|
|
56
|
-
let maxArea = -1;
|
|
57
|
-
let bestPoly: any[] = [];
|
|
58
|
-
for (const poly of mergedCoords) {
|
|
59
|
-
const outerRing = poly[0];
|
|
60
|
-
let area = 0;
|
|
61
|
-
for (let i = 0; i < outerRing.length - 1; i++) {
|
|
62
|
-
const [x1, y1] = outerRing[i];
|
|
63
|
-
const [x2, y2] = outerRing[i + 1];
|
|
64
|
-
area += x1 * y2 - x2 * y1;
|
|
65
|
-
}
|
|
66
|
-
area = Math.abs(area / 2);
|
|
67
|
-
if (area > maxArea) {
|
|
68
|
-
maxArea = area;
|
|
69
|
-
bestPoly = poly;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!bestPoly || bestPoly.length === 0) return null;
|
|
73
|
-
const outerRing = bestPoly[0];
|
|
74
|
-
const skip = Math.max(1, parseInt(String(bootstrap.settings.GlobalSettings.ShapefileSkipPoints), 10) ?? 1);
|
|
75
|
-
let skipped = outerRing.filter((_: any, idx: number) => idx % skip === 0);
|
|
76
|
-
if (skipped.length < 4) {
|
|
77
|
-
skipped = outerRing.slice();
|
|
78
|
-
}
|
|
79
|
-
const first = skipped[0];
|
|
80
|
-
const last = skipped[skipped.length - 1];
|
|
81
|
-
if (!first || !last || first[0] !== last[0] || first[1] !== last[1]) {
|
|
82
|
-
skipped.push([first[0], first[1]]);
|
|
83
|
-
}
|
|
84
|
-
return {type: "Polygon", coordinates: [skipped]};
|
|
85
|
-
} else {
|
|
86
|
-
const multi: any[] = [];
|
|
87
|
-
for (const polyCoords of polygons) {
|
|
88
|
-
if (Array.isArray(polyCoords) && Array.isArray(polyCoords[0])) {
|
|
89
|
-
multi.push(polyCoords);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (multi.length === 0) return null;
|
|
93
|
-
const skip = Math.max(1, parseInt(String(bootstrap.settings.GlobalSettings.ShapefileSkipPoints), 10) ?? 1);
|
|
94
|
-
if (skip > 1) {
|
|
95
|
-
for (let p = 0; p < multi.length; p++) {
|
|
96
|
-
for (let r = 0; r < multi[p].length; r++) {
|
|
97
|
-
const ring = multi[p][r];
|
|
98
|
-
let reduced = ring.filter((_: any, i: number) => i % skip === 0);
|
|
99
|
-
if (reduced.length < 4) reduced = ring.slice();
|
|
100
|
-
const first = reduced[0];
|
|
101
|
-
const last = reduced[reduced.length - 1];
|
|
102
|
-
if ( first && last && (first[0] !== last[0] || first[1] !== last[1])) {
|
|
103
|
-
reduced.push([first[0], first[1]]);
|
|
104
|
-
}
|
|
105
|
-
multi[p][r] = reduced;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return {type: "MultiPolygon", coordinates: multi};
|
|
110
|
-
}
|
|
111
|
-
}
|
package/src/@types/VTEC.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export type TypePVTEC = {
|
|
21
|
-
vtec: string
|
|
22
|
-
product: string
|
|
23
|
-
tracking: string
|
|
24
|
-
event: string
|
|
25
|
-
status: string
|
|
26
|
-
organization: string
|
|
27
|
-
expires: string
|
|
28
|
-
is_watch: boolean
|
|
29
|
-
prediction_center: boolean
|
|
30
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: ['src/index.ts'],
|
|
5
|
-
outDir: 'dist',
|
|
6
|
-
format: ['esm', 'cjs'],
|
|
7
|
-
dts: false,
|
|
8
|
-
noExternal: ["@xmpp/client", "@xmpp/sasl", "@xmpp/sasl-plain"],
|
|
9
|
-
clean: true,
|
|
10
|
-
outExtension({ format }) {
|
|
11
|
-
return { js: format === 'esm' ? '.mjs' : '.cjs' }
|
|
12
|
-
},
|
|
13
|
-
esbuildOptions(options, context) {
|
|
14
|
-
options.outdir = `dist/${context.format}`
|
|
15
|
-
},
|
|
16
|
-
})
|