@atmosx/event-product-parser 3.0.42 → 3.0.46
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/README.md +70 -22
- package/SUPPORTED_EVENTS.md +369 -0
- package/dist/cjs/index.cjs +1990 -1758
- package/dist/esm/index.mjs +1560 -1329
- package/dist/index.d.mts +44 -20
- package/dist/index.d.ts +44 -20
- package/package.json +1 -1
- package/src/@building/building.attachments.ts +42 -0
- package/src/@building/building.create.ts +2 -2
- package/src/@building/building.enhance.ts +8 -4
- package/src/@building/building.geometry.ts +1 -1
- package/src/@building/building.headers.ts +1 -1
- package/src/@building/building.office.ts +4 -4
- package/src/@building/building.properties.ts +15 -13
- package/src/@building/building.signature.ts +11 -11
- package/src/@building/building.tags.ts +2 -2
- package/src/@building/building.tracking.ts +6 -6
- package/src/@building/building.validate.ts +5 -3
- package/src/@core/core.createEvent.ts +82 -0
- package/src/@core/core.query.ts +1 -1
- package/src/@core/core.start.ts +1 -1
- package/src/@dictionaries/{dictionaries.eventActions.ts → dictionaries.actions.ts} +1 -1
- package/src/@dictionaries/{dictionaries.eventAwipAbreviations.ts → dictionaries.awips.ts} +1 -1
- package/src/@dictionaries/{dictionaries.eventCancelMessages.ts → dictionaries.cancellation.ts} +1 -1
- package/src/@dictionaries/{dictionaries.eventCauses.ts → dictionaries.causes.ts} +1 -1
- package/src/@dictionaries/{dictionaries.statusCorrelationText.ts → dictionaries.correlations.ts} +1 -1
- package/src/@dictionaries/{dictionaries.betterEventNames.ts → dictionaries.enhanced.ts} +13 -2
- package/src/@dictionaries/{dictionaries.eventTypes.ts → dictionaries.events.ts} +1 -1
- package/src/@dictionaries/{dictionaries.regExp.ts → dictionaries.expressions.ts} +1 -1
- package/src/@dictionaries/{dictionaries.hailStrings.ts → dictionaries.hail.ts} +4 -1
- package/src/@dictionaries/{dictionaries.officeICAOs.ts → dictionaries.icao.ts} +1 -1
- package/src/@dictionaries/{dictionaries.eventsMatchText.ts → dictionaries.matches.ts} +1 -1
- package/src/@dictionaries/{dictionaries.eventProducts.ts → dictionaries.products.ts} +1 -1
- package/src/@dictionaries/{dictionaries.eventRecords.ts → dictionaries.records.ts} +1 -1
- package/src/@dictionaries/{dictionaries.eventSeverity.ts → dictionaries.severity.ts} +1 -1
- package/src/@dictionaries/{dictionaries.shapefileLinks.ts → dictionaries.shapefiles.ts} +1 -1
- package/src/@dictionaries/{dictionaries.eventStatus.ts → dictionaries.status.ts} +1 -1
- package/src/@dictionaries/{dictionaries.eventTags.ts → dictionaries.tags.ts} +1 -1
- package/src/@dictionaries/{dictionaries.testSignatures.ts → dictionaries.test.ts} +3 -2
- package/src/@events/events.api.ts +19 -14
- package/src/@events/events.text.ts +5 -4
- package/src/@events/events.ugc.ts +5 -4
- package/src/@events/events.vtec.ts +5 -4
- package/src/@manager/manager.mkEvent.ts +4 -4
- package/src/@manager/manager.rmEvent.ts +3 -2
- package/src/@manager/manager.setHash.ts +1 -1
- package/src/@manager/manager.updateListener.ts +124 -0
- package/src/@modules/@database/database.cache.ts +1 -1
- package/src/@modules/@database/database.init.ts +1 -1
- package/src/@modules/@database/database.shapefiles.ts +3 -3
- package/src/@modules/@database/database.stanza.ts +2 -2
- package/src/@modules/@eas/eas.getCleanDescription.ts +91 -0
- package/src/@modules/@eas/eas.getTTS.ts +54 -0
- package/src/@modules/@eas/eas.setEasTone.ts +40 -30
- package/src/@modules/@stanza/stanza.getAwipsType.ts +3 -3
- package/src/@modules/@stanza/stanza.validate.ts +5 -5
- package/src/@modules/@utilities/utilities.getLatestIssuance.ts +32 -0
- package/src/@modules/@utilities/utilities.getSettings.ts +1 -1
- package/src/@modules/@utilities/utilities.setCronSchedule.ts +30 -2
- package/src/@modules/@utilities/utilities.setSettings.ts +1 -1
- package/src/@modules/@utilities/utilities.setWarning.ts +1 -1
- package/src/@modules/@xmpp/xmpp.xDeploy.ts +1 -1
- package/src/@modules/@xmpp/xmpp.xReconnect.ts +1 -1
- package/src/@modules/@xmpp/xmpp.xStanza.ts +1 -1
- package/src/@parsers/@hvtec/hvtec.extract.ts +9 -9
- package/src/@parsers/@pvtec/pvtec.extract.ts +13 -13
- package/src/@parsers/@text/text.getDescriptionFromProduct.ts +2 -2
- package/src/@parsers/@text/text.getEmbed.ts +60 -0
- package/src/@parsers/@ugc/ugc.extract.ts +1 -1
- package/src/@parsers/@ugc/ugc.header.ts +3 -3
- package/src/@types/{types.compiled.ts → type.compiled.ts} +1 -1
- package/src/@types/type.event.ts +6 -4
- package/src/@types/{types.webhook.ts → type.listener.ts} +11 -6
- package/src/@types/type.properties.ts +10 -8
- package/src/@types/{types.settings.ts → type.settings.ts} +7 -5
- package/src/bootstrap.ts +7 -5
- package/src/index.ts +3 -2
- package/test.js +19 -19
- package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +0 -68
- package/src/@manager/manager.createWebhook.ts +0 -117
- package/src/@manager/manager.updateWebhooks.ts +0 -49
- /package/src/@types/{types.attributes.ts → type.attributes.ts} +0 -0
- /package/src/@types/{types.hash.ts → type.hash.ts} +0 -0
- /package/src/@types/{types.hvtec.ts → type.hvtec.ts} +0 -0
- /package/src/@types/{types.pvtec.ts → type.pvtec.ts} +0 -0
- /package/src/@types/{types.stanza.ts → type.stanza.ts} +0 -0
- /package/src/@types/{types.ugc.ts → type.ugc.ts} +0 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -10491,6 +10491,7 @@ var index_exports = {};
|
|
|
10491
10491
|
__export(index_exports, {
|
|
10492
10492
|
Manager: () => Manager,
|
|
10493
10493
|
clearEvents: () => clearEvents,
|
|
10494
|
+
createEvent: () => createEvent2,
|
|
10494
10495
|
default: () => index_default,
|
|
10495
10496
|
getCleanedEvent: () => getCleanedEvent,
|
|
10496
10497
|
getEventGeometry: () => getEventGeometry,
|
|
@@ -10510,7 +10511,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
10510
10511
|
var import_path = __toESM(require("path"));
|
|
10511
10512
|
var import_node_events = require("events");
|
|
10512
10513
|
var bootstrap = {
|
|
10513
|
-
version: `3.0.
|
|
10514
|
+
version: `3.0.46`,
|
|
10514
10515
|
isReady: true,
|
|
10515
10516
|
ratelimits: {},
|
|
10516
10517
|
session_xmpp: null,
|
|
@@ -10566,7 +10567,7 @@ var bootstrap = {
|
|
|
10566
10567
|
CallbackInterval: 15,
|
|
10567
10568
|
EventsEndpoint: `https://api.weather.gov/alerts/active`
|
|
10568
10569
|
},
|
|
10569
|
-
|
|
10570
|
+
ListenerSettings: [],
|
|
10570
10571
|
GlobalSettings: {
|
|
10571
10572
|
EventManagement: true,
|
|
10572
10573
|
BetterEventNames: true,
|
|
@@ -10586,9 +10587,11 @@ var bootstrap = {
|
|
|
10586
10587
|
NodeLocationFiltering: false,
|
|
10587
10588
|
IgnoreTestProducts: true
|
|
10588
10589
|
},
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
|
|
10590
|
+
ArchiveSettings: {
|
|
10591
|
+
TTL: 60,
|
|
10592
|
+
TextDirectory: null,
|
|
10593
|
+
EasDirectory: null,
|
|
10594
|
+
EasToneout: null
|
|
10592
10595
|
}
|
|
10593
10596
|
}
|
|
10594
10597
|
}
|
|
@@ -13602,8 +13605,8 @@ var xError = () => {
|
|
|
13602
13605
|
}));
|
|
13603
13606
|
};
|
|
13604
13607
|
|
|
13605
|
-
// src/@dictionaries/dictionaries.
|
|
13606
|
-
var
|
|
13608
|
+
// src/@dictionaries/dictionaries.expressions.ts
|
|
13609
|
+
var dict_expressions = {
|
|
13607
13610
|
pvtec: new RegExp(`[OTEX].(NEW|CON|EXT|EXA|EXB|UPG|CAN|EXP|COR|ROU).[A-Z]{4}.[A-Z]{2}.[WAYSFON].[0-9]{4}.[0-9]{6}T[0-9]{4}Z-[0-9]{6}T[0-9]{4}Z`, "g"),
|
|
13608
13611
|
hvtec: new RegExp(`[a-zA-Z0-9]{4}.[A-Z0-9].[A-Z]{2}.[0-9]{6}T[0-9]{4}Z.[0-9]{6}T[0-9]{4}Z.[0-9]{6}T[0-9]{4}Z.[A-Z]{2}`, "imu"),
|
|
13609
13612
|
wmo: new RegExp(`[A-Z0-9]{6}\\s[A-Z]{4}\\s\\d{6}`, "imu"),
|
|
@@ -13613,8 +13616,8 @@ var regExp = {
|
|
|
13613
13616
|
dateline: new RegExp(`\\d{3,4}\\s*(AM|PM)?\\s*[A-Z]{2,4}\\s+[A-Z]{3,}\\s+[A-Z]{3,}\\s+\\d{1,2}\\s+\\d{4}`, "gim")
|
|
13614
13617
|
};
|
|
13615
13618
|
|
|
13616
|
-
// src/@dictionaries/dictionaries.
|
|
13617
|
-
var
|
|
13619
|
+
// src/@dictionaries/dictionaries.awips.ts
|
|
13620
|
+
var dict_awips = {
|
|
13618
13621
|
ABV: `rawinsonde-data-above-100-millibars`,
|
|
13619
13622
|
ADA: `alarm-alert-administrative-message`,
|
|
13620
13623
|
ADM: `alert-administrative-message`,
|
|
@@ -13969,7 +13972,7 @@ var getAwipsType = (options) => {
|
|
|
13969
13972
|
prefix: null
|
|
13970
13973
|
};
|
|
13971
13974
|
}
|
|
13972
|
-
for (const [prefix, type] of Object.entries(
|
|
13975
|
+
for (const [prefix, type] of Object.entries(dict_awips)) {
|
|
13973
13976
|
if (attributes.awipsid.startsWith(prefix)) {
|
|
13974
13977
|
return { type, prefix };
|
|
13975
13978
|
}
|
|
@@ -13987,8 +13990,8 @@ var validate = (options) => {
|
|
|
13987
13990
|
if (attributes.awipsid && attributes.awipsid.length > 1) {
|
|
13988
13991
|
const isCapEvent = message.includes(`<?xml`);
|
|
13989
13992
|
const isCapAreaDescription = message.includes(`<areaDesc>`);
|
|
13990
|
-
const isVTEC = message.match(
|
|
13991
|
-
const isUGC = message.match(
|
|
13993
|
+
const isVTEC = message.match(dict_expressions.pvtec) != null;
|
|
13994
|
+
const isUGC = message.match(dict_expressions.ugc1) != null;
|
|
13992
13995
|
const getType = getAwipsType({ attributes });
|
|
13993
13996
|
if (getType.type != null) {
|
|
13994
13997
|
return {
|
|
@@ -14012,7 +14015,7 @@ var validate = (options) => {
|
|
|
14012
14015
|
// src/@parsers/@text/text.getDescriptionFromProduct.ts
|
|
14013
14016
|
var getDescriptionFromProduct = (options) => {
|
|
14014
14017
|
let message = options.message;
|
|
14015
|
-
const dates = Array.from(message.matchAll(
|
|
14018
|
+
const dates = Array.from(message.matchAll(dict_expressions.dateline));
|
|
14016
14019
|
if (dates.length) {
|
|
14017
14020
|
const lastMatch = dates[dates.length - 1][0];
|
|
14018
14021
|
const sIndx = message.lastIndexOf(lastMatch);
|
|
@@ -14078,8 +14081,8 @@ var getTextFromProduct = (options) => {
|
|
|
14078
14081
|
return null;
|
|
14079
14082
|
};
|
|
14080
14083
|
|
|
14081
|
-
// src/@dictionaries/dictionaries.
|
|
14082
|
-
var
|
|
14084
|
+
// src/@dictionaries/dictionaries.icao.ts
|
|
14085
|
+
var dict_icao = {
|
|
14083
14086
|
"KLUB": "Lubbock, TX",
|
|
14084
14087
|
"KLCH": "Lake Charles, LA",
|
|
14085
14088
|
"TSTL": "St. Louis, MO",
|
|
@@ -14324,12 +14327,12 @@ var officeICAOs = {
|
|
|
14324
14327
|
var getEventOffice = (options) => {
|
|
14325
14328
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
14326
14329
|
const office = options.pVtec != null ? (_b = (_a = options.pVtec) == null ? void 0 : _a.tracking) == null ? void 0 : _b.split(`.`)[0] : (_e = (_c = options.attributes) == null ? void 0 : _c.cccc) != null ? _e : options.organization != null ? Array.isArray(options.organization) ? (_d = options.organization) == null ? void 0 : _d[0] : options.organization : null;
|
|
14327
|
-
const name = (_g = (_f =
|
|
14330
|
+
const name = (_g = (_f = dict_icao) == null ? void 0 : _f[office]) != null ? _g : null;
|
|
14328
14331
|
return { office, name };
|
|
14329
14332
|
};
|
|
14330
14333
|
|
|
14331
|
-
// src/@dictionaries/dictionaries.
|
|
14332
|
-
var
|
|
14334
|
+
// src/@dictionaries/dictionaries.tags.ts
|
|
14335
|
+
var dict_tags = {
|
|
14333
14336
|
"FROSTBITE AND HYPOTHERMIA ARE LIKELY": "Frostbite and Hypothermia Likely",
|
|
14334
14337
|
"LICKELY BECOME SLICK AND HAZARDOUS": "Slick and Hazardous Roads",
|
|
14335
14338
|
"SLIPPERY ROAD CONDITIONS": "Slippery Roads",
|
|
@@ -14406,13 +14409,13 @@ var eventTags = {
|
|
|
14406
14409
|
|
|
14407
14410
|
// src/@building/building.tags.ts
|
|
14408
14411
|
var getEventTags = (message) => {
|
|
14409
|
-
return Object.entries(
|
|
14412
|
+
return Object.entries(dict_tags).filter(([key]) => message == null ? void 0 : message.toLowerCase().includes(key.toLowerCase())).map(([, value]) => value);
|
|
14410
14413
|
};
|
|
14411
14414
|
|
|
14412
14415
|
// src/@building/building.properties.ts
|
|
14413
14416
|
var properties = (options) => {
|
|
14414
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J;
|
|
14415
|
-
const organization = (_b = (_a = options.message.match(
|
|
14417
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V;
|
|
14418
|
+
const organization = (_b = (_a = options.message.match(dict_expressions.wmo)) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
14416
14419
|
const polygons = getPolygonFromProduct(options.message);
|
|
14417
14420
|
const properties2 = {
|
|
14418
14421
|
locations: (_e = (_d = (_c = options == null ? void 0 : options.ugc) == null ? void 0 : _c.locations) == null ? void 0 : _d.join(`; `)) != null ? _e : null,
|
|
@@ -14439,25 +14442,27 @@ var properties = (options) => {
|
|
|
14439
14442
|
wind_threat: (_s = getTextFromProduct({ message: options.message, find: [`WIND THREAT...`] })) != null ? _s : null,
|
|
14440
14443
|
hail_threat: (_t = getTextFromProduct({ message: options.message, find: [`HAIL THREAT...`], removal: [] })) != null ? _t : null
|
|
14441
14444
|
},
|
|
14442
|
-
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14445
|
+
discussion_parameters: {
|
|
14446
|
+
discussion_number: (_w = (_v = (_u = getTextFromProduct({ message: options.message, find: [`Mesoscale Discussion `], removal: [`Mesoscale Discussion`, `Number`, `...`] })) == null ? void 0 : _u.toString()) == null ? void 0 : _v.padStart(4, "0")) != null ? _w : null,
|
|
14447
|
+
discussion_concerning: (_x = getTextFromProduct({ message: options.message, find: [`Concerning...`] })) != null ? _x : null,
|
|
14448
|
+
discussion_max_tornado: (_y = getTextFromProduct({ message: options.message, find: [`MOST PROBABLE PEAK TORNADO INTENSITY...`] })) != null ? _y : null,
|
|
14449
|
+
discussion_max_hail: (_z = getTextFromProduct({ message: options.message, find: [`MOST PROBABLE PEAK HAIL SIZE...`] })) != null ? _z : null,
|
|
14450
|
+
discussion_max_wind: (_A = getTextFromProduct({ message: options.message, find: [`MOST PROBABLE PEAK WIND GUST...`] })) != null ? _A : null,
|
|
14451
|
+
discussion_watch_issuance: (_B = getTextFromProduct({ message: options.message, find: [`Probability of Watch Issuance...`], removal: [`percent`] })) != null ? _B : null
|
|
14447
14452
|
},
|
|
14448
14453
|
watch_parameters: {
|
|
14449
|
-
watch_number: (
|
|
14454
|
+
watch_number: ((_C = options == null ? void 0 : options.pVtec) == null ? void 0 : _C.is_watch) && ((_M = (_L = (_G = (_F = (_E = (_D = getTextFromProduct({ message: options.message, find: [`ITIES FOR`, `UPDATE FOR`, `Watch Number `], removal: [`%`, `<`, `:`] })) == null ? void 0 : _D.replace(/(WT|WS|)/g, "")) == null ? void 0 : _E.trim()) == null ? void 0 : _F.toString()) == null ? void 0 : _G.padStart(4, "0")) != null ? _L : (_K = (_J = (_I = (_H = options == null ? void 0 : options.pVtec) == null ? void 0 : _H.tracking) == null ? void 0 : _I.slice(-4)) == null ? void 0 : _J.toString()) == null ? void 0 : _K.padStart(4, "0")) != null ? _M : null),
|
|
14450
14455
|
watch_type: options.message.includes(`TORNADO WATCH`) ? `Tornado` : (options == null ? void 0 : options.message.includes(`SEVERE`)) ? `Severe` : null,
|
|
14451
|
-
additional_tornadoes_probability: (
|
|
14452
|
-
strong_tornadoes_probability: (
|
|
14453
|
-
severe_wind_probability: (
|
|
14454
|
-
severe_hail_probability: (
|
|
14455
|
-
hail_2in_probability: (
|
|
14456
|
-
combined_hail_wind_probability: (
|
|
14457
|
-
max_hail_in: (
|
|
14458
|
-
max_wind_surface: (
|
|
14459
|
-
max_tops_x100feet: (
|
|
14460
|
-
pds_watch: getTextFromProduct({ message: options.message, find: [`PARTICULARLY DANGEROUS SITUATION`], removal: [`%`, `<`, `:`] }) === `YES`
|
|
14456
|
+
additional_tornadoes_probability: (_N = getTextFromProduct({ message: options.message, find: [`PROB OF 2 OR MORE TORNADOES`], removal: [`%`, `<`, `:`] })) != null ? _N : null,
|
|
14457
|
+
strong_tornadoes_probability: (_O = getTextFromProduct({ message: options.message, find: [`PROB OF 1 OR MORE STRONG /EF2-EF5/ TORNADOES`], removal: [`%`, `<`, `:`] })) != null ? _O : null,
|
|
14458
|
+
severe_wind_probability: (_P = getTextFromProduct({ message: options.message, find: [`PROB OF 10 OR MORE SEVERE WIND EVENTS`], removal: [`%`, `<`, `:`] })) != null ? _P : null,
|
|
14459
|
+
severe_hail_probability: (_Q = getTextFromProduct({ message: options.message, find: [`PROB OF 10 OR MORE SEVERE HAIL EVENTS`], removal: [`%`, `<`, `:`] })) != null ? _Q : null,
|
|
14460
|
+
hail_2in_probability: (_R = getTextFromProduct({ message: options.message, find: [`PROB OF 1 OR MORE HAIL EVENTS >= 2 INCHES`], removal: [`%`, `<`, `:`] })) != null ? _R : null,
|
|
14461
|
+
combined_hail_wind_probability: (_S = getTextFromProduct({ message: options.message, find: [`PROB OF 6 OR MORE COMBINED SEVERE HAIL/WIND EVENTS`], removal: [`%`, `<`, `:`] })) != null ? _S : null,
|
|
14462
|
+
max_hail_in: (_T = getTextFromProduct({ message: options.message, find: [`MAX HAIL /INCHES/`], removal: [`%`, `<`, `:`] })) != null ? _T : null,
|
|
14463
|
+
max_wind_surface: (_U = getTextFromProduct({ message: options.message, find: [`MAX WIND GUSTS SURFACE /KNOTS/`], removal: [`%`, `<`, `:`] })) != null ? _U : null,
|
|
14464
|
+
max_tops_x100feet: (_V = getTextFromProduct({ message: options.message, find: [`MAX TOPS /X 100 FEET/`], removal: [`%`, `<`, `:`] })) != null ? _V : null,
|
|
14465
|
+
pds_watch: getTextFromProduct({ message: options.message, find: [`PARTICULARLY DANGEROUS SITUATION`], removal: [`%`, `<`, `:`] }) === `YES` ? true : null
|
|
14461
14466
|
}
|
|
14462
14467
|
};
|
|
14463
14468
|
if (isNaN(Number(properties2.watch_parameters.watch_number))) {
|
|
@@ -14475,8 +14480,8 @@ var getEventHeader = (options) => {
|
|
|
14475
14480
|
return `ZCZC-ATMOSX-${options.getType.prefix}-${ugc2}-${(_b = vtec2 == null ? void 0 : vtec2.status) != null ? _b : `Issued`}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").split(".")[0]}-${(_c = properties2.geocode.office.office) != null ? _c : `KWNS`}`;
|
|
14476
14481
|
};
|
|
14477
14482
|
|
|
14478
|
-
// src/@dictionaries/dictionaries.
|
|
14479
|
-
var
|
|
14483
|
+
// src/@dictionaries/dictionaries.matches.ts
|
|
14484
|
+
var dict_matches = {
|
|
14480
14485
|
"Special Weather Statement": "Special Weather Statement",
|
|
14481
14486
|
"Hurricane Warning": "Hurricane Warning",
|
|
14482
14487
|
"Hurricane Force Wind Warning": "Hurricane Force Wind Warning",
|
|
@@ -14496,7 +14501,7 @@ var eventsMatchText = {
|
|
|
14496
14501
|
|
|
14497
14502
|
// src/@building/building.tracking.ts
|
|
14498
14503
|
var getEventTracking = (options) => {
|
|
14499
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
14504
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
14500
14505
|
const properties2 = options.properties;
|
|
14501
14506
|
const attributes = options.attributes;
|
|
14502
14507
|
const stanza = options.stanza;
|
|
@@ -14513,26 +14518,26 @@ var getEventTracking = (options) => {
|
|
|
14513
14518
|
}
|
|
14514
14519
|
if (options.type === `API`) {
|
|
14515
14520
|
if (options.vtec) {
|
|
14516
|
-
const vtecValue = Array.isArray(options.vtec) ? options.vtec[0] : options.vtec;
|
|
14521
|
+
const vtecValue = Array.isArray(options.vtec) ? options.vtec[0].vtec : (_c = options.vtec) == null ? void 0 : _c.vtec;
|
|
14517
14522
|
const splitPVTEC = vtecValue.split(".");
|
|
14518
14523
|
return `${splitPVTEC[2]}.${splitPVTEC[3]}.${splitPVTEC[4]}.${splitPVTEC[5]}`;
|
|
14519
14524
|
}
|
|
14520
|
-
const wmoMatch = (
|
|
14521
|
-
const station = (
|
|
14525
|
+
const wmoMatch = (_e = (_d = options.organization) == null ? void 0 : _d.wmoidentifier) == null ? void 0 : _e.match(/([A-Z]{4}\d{2})\s+([A-Z]{4})/);
|
|
14526
|
+
const station = (_f = wmoMatch == null ? void 0 : wmoMatch[2]) != null ? _f : "N/A";
|
|
14522
14527
|
if (options.organization.featureId) {
|
|
14523
14528
|
const idMatch = options.organization.featureId.match(/([a-f0-9]+)\.(\d+)\.(\d+)$/);
|
|
14524
|
-
return `${station}.${(
|
|
14529
|
+
return `${station}.${(_h = (_g = idMatch == null ? void 0 : idMatch[0]) == null ? void 0 : _g.replace(/\./g, "")) != null ? _h : "N/A"}`;
|
|
14525
14530
|
}
|
|
14526
|
-
const id2 = (
|
|
14527
|
-
return `${station}.${id2}`;
|
|
14531
|
+
const id2 = (_i = wmoMatch == null ? void 0 : wmoMatch[1]) != null ? _i : "N/A";
|
|
14532
|
+
return `${station}.${(_j = id2 == null ? void 0 : id2.replace(/\./g, "")) != null ? _j : "N/A"}`;
|
|
14528
14533
|
}
|
|
14529
14534
|
};
|
|
14530
14535
|
|
|
14531
14536
|
// src/@building/building.validate.ts
|
|
14532
14537
|
var import_crypto = require("crypto");
|
|
14533
14538
|
|
|
14534
|
-
// src/@dictionaries/dictionaries.
|
|
14535
|
-
var
|
|
14539
|
+
// src/@dictionaries/dictionaries.enhanced.ts
|
|
14540
|
+
var dict_enhanced = {
|
|
14536
14541
|
"Tornado Warning": {
|
|
14537
14542
|
"Tornado Emergency": {
|
|
14538
14543
|
description: "tornado emergency"
|
|
@@ -14550,6 +14555,11 @@ var betterEventNames = {
|
|
|
14550
14555
|
},
|
|
14551
14556
|
"Radar Indicated Tornado Warning": {}
|
|
14552
14557
|
},
|
|
14558
|
+
"Fire Weather Warning": {
|
|
14559
|
+
"PDS Fire Weather Warning": {
|
|
14560
|
+
description: "particularly dangerous situation"
|
|
14561
|
+
}
|
|
14562
|
+
},
|
|
14553
14563
|
"Blizzard Warning": {
|
|
14554
14564
|
"PDS Blizzard Warning": {
|
|
14555
14565
|
description: "particularly dangerous situation"
|
|
@@ -14567,7 +14577,12 @@ var betterEventNames = {
|
|
|
14567
14577
|
},
|
|
14568
14578
|
"Tornado Watch": {
|
|
14569
14579
|
"PDS Tornado Watch": {
|
|
14570
|
-
|
|
14580
|
+
pdswatch: true
|
|
14581
|
+
}
|
|
14582
|
+
},
|
|
14583
|
+
"Severe Thunderstorm Watch": {
|
|
14584
|
+
"PDS Severe Thunderstorm Watch": {
|
|
14585
|
+
pdswatch: true
|
|
14571
14586
|
}
|
|
14572
14587
|
},
|
|
14573
14588
|
"Flash Flood Warning": {
|
|
@@ -14608,16 +14623,17 @@ var betterEventNames = {
|
|
|
14608
14623
|
|
|
14609
14624
|
// src/@building/building.enhance.ts
|
|
14610
14625
|
var getEventEnhancedName = (event) => {
|
|
14611
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
14626
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
14612
14627
|
const configurations = bootstrap.settings;
|
|
14613
14628
|
let name = (_a = event == null ? void 0 : event.properties) == null ? void 0 : _a.event;
|
|
14614
14629
|
if (!((_b = configurations == null ? void 0 : configurations.GlobalSettings) == null ? void 0 : _b.BetterEventNames)) {
|
|
14615
14630
|
return name;
|
|
14616
14631
|
}
|
|
14617
14632
|
const damage = (_d = (_c = event == null ? void 0 : event.properties) == null ? void 0 : _c.parameters) == null ? void 0 : _d.damage_threat;
|
|
14618
|
-
const tornado = (_e = event == null ? void 0 : event.properties) == null ? void 0 : _e.parameters.tornado_threat;
|
|
14619
|
-
const
|
|
14620
|
-
|
|
14633
|
+
const tornado = (_f = (_e = event == null ? void 0 : event.properties) == null ? void 0 : _e.parameters) == null ? void 0 : _f.tornado_threat;
|
|
14634
|
+
const pdswatch = (_h = (_g = event == null ? void 0 : event.properties) == null ? void 0 : _g.watch_parameters) == null ? void 0 : _h.pds_watch;
|
|
14635
|
+
const description = (_j = (_i = event == null ? void 0 : event.properties) == null ? void 0 : _i.description) == null ? void 0 : _j.toLowerCase();
|
|
14636
|
+
for (const [eventKey, eventConfig] of Object.entries(dict_enhanced)) {
|
|
14621
14637
|
if (eventKey !== name) continue;
|
|
14622
14638
|
for (const [paramKey, paramValue] of Object.entries(eventConfig)) {
|
|
14623
14639
|
let matches = true;
|
|
@@ -14630,6 +14646,9 @@ var getEventEnhancedName = (event) => {
|
|
|
14630
14646
|
if (paramValue == null ? void 0 : paramValue.tornado) {
|
|
14631
14647
|
if (paramValue.tornado !== tornado) matches = false;
|
|
14632
14648
|
}
|
|
14649
|
+
if (paramValue == null ? void 0 : paramValue.pdswatch) {
|
|
14650
|
+
if (paramValue.pdswatch !== pdswatch) matches = false;
|
|
14651
|
+
}
|
|
14633
14652
|
if (matches) {
|
|
14634
14653
|
name = paramKey;
|
|
14635
14654
|
break;
|
|
@@ -14639,8 +14658,8 @@ var getEventEnhancedName = (event) => {
|
|
|
14639
14658
|
return name;
|
|
14640
14659
|
};
|
|
14641
14660
|
|
|
14642
|
-
// src/@dictionaries/dictionaries.
|
|
14643
|
-
var
|
|
14661
|
+
// src/@dictionaries/dictionaries.correlations.ts
|
|
14662
|
+
var dict_correlations = [
|
|
14644
14663
|
{ type: "Statement", name: "Statement", isCancel: false, isUpdate: false, isIssued: true, isStatement: true },
|
|
14645
14664
|
{ type: "Update", name: "Updated", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
|
|
14646
14665
|
{ type: "Cancel", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false, isStatement: false },
|
|
@@ -14655,8 +14674,8 @@ var statusCorrelationText = [
|
|
|
14655
14674
|
{ type: "Routine", name: "Routine", isCancel: false, isUpdate: true, isIssued: false, isStatement: false }
|
|
14656
14675
|
];
|
|
14657
14676
|
|
|
14658
|
-
// src/@dictionaries/dictionaries.
|
|
14659
|
-
var
|
|
14677
|
+
// src/@dictionaries/dictionaries.cancellation.ts
|
|
14678
|
+
var dict_cancellation = [
|
|
14660
14679
|
"has been cancelled",
|
|
14661
14680
|
"subsided sufficiently for the advisory to be cancelled",
|
|
14662
14681
|
"has been cancelled",
|
|
@@ -14668,24 +14687,28 @@ var eventCancelMessages = [
|
|
|
14668
14687
|
"has weakened below severe"
|
|
14669
14688
|
];
|
|
14670
14689
|
|
|
14671
|
-
// src/@dictionaries/dictionaries.
|
|
14672
|
-
var
|
|
14690
|
+
// src/@dictionaries/dictionaries.test.ts
|
|
14691
|
+
var dict_testing = [
|
|
14673
14692
|
`This is a test message`,
|
|
14674
14693
|
`Monitoring message only.`,
|
|
14675
|
-
`THIS_MESSAGE_IS_FOR_TEST_PURPOSES_ONLY
|
|
14694
|
+
`THIS_MESSAGE_IS_FOR_TEST_PURPOSES_ONLY`,
|
|
14695
|
+
"TEST MESSAGE"
|
|
14676
14696
|
];
|
|
14677
14697
|
|
|
14678
|
-
// src/@dictionaries/dictionaries.
|
|
14679
|
-
var
|
|
14698
|
+
// src/@dictionaries/dictionaries.products.ts
|
|
14699
|
+
var dict_products = {
|
|
14680
14700
|
"O": "Operational Product",
|
|
14681
14701
|
"T": "Test Product",
|
|
14682
14702
|
"E": "Experimental Product",
|
|
14683
14703
|
"X": "Experimental Product (Non-Operational)"
|
|
14684
14704
|
};
|
|
14685
14705
|
|
|
14686
|
-
// src/@dictionaries/dictionaries.
|
|
14687
|
-
var
|
|
14706
|
+
// src/@dictionaries/dictionaries.hail.ts
|
|
14707
|
+
var dict_hail = {
|
|
14708
|
+
".25": "Pea",
|
|
14709
|
+
".50": "Penny",
|
|
14688
14710
|
".75": "Penny",
|
|
14711
|
+
"Up to .75": "Penny",
|
|
14689
14712
|
".88": "Nickel",
|
|
14690
14713
|
"0.75": "Penny",
|
|
14691
14714
|
"0.88": "Nickel",
|
|
@@ -14701,25 +14724,25 @@ var hailStrings = {
|
|
|
14701
14724
|
|
|
14702
14725
|
// src/@building/building.signature.ts
|
|
14703
14726
|
var getEventSignature = (event) => {
|
|
14704
|
-
var _a, _b, _c, _d, _e, _f;
|
|
14727
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
14705
14728
|
const properties2 = event == null ? void 0 : event.properties;
|
|
14706
14729
|
const vtec2 = (_b = (_a = event == null ? void 0 : event.properties) == null ? void 0 : _a.metadata) == null ? void 0 : _b.vtec;
|
|
14707
|
-
const status =
|
|
14708
|
-
const csig =
|
|
14730
|
+
const status = dict_correlations.find((c) => c.type === (properties2 == null ? void 0 : properties2.status));
|
|
14731
|
+
const csig = dict_cancellation.find((sig) => properties2.description.toLowerCase().includes(sig.toLowerCase()));
|
|
14709
14732
|
properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_issued: true, is_test: false });
|
|
14710
|
-
if (properties2.parameters.estimated_hail_size) {
|
|
14711
|
-
properties2.parameters.estimated_hail_size += ` (${(
|
|
14733
|
+
if ((_c = properties2 == null ? void 0 : properties2.parameters) == null ? void 0 : _c.estimated_hail_size) {
|
|
14734
|
+
properties2.parameters.estimated_hail_size += ` (${(_e = dict_hail[(_d = properties2 == null ? void 0 : properties2.parameters) == null ? void 0 : _d.estimated_hail_size]) != null ? _e : "--"})`;
|
|
14712
14735
|
}
|
|
14713
14736
|
if (status) {
|
|
14714
|
-
properties2.status = (
|
|
14737
|
+
properties2.status = (_f = status.name) != null ? _f : properties2.status;
|
|
14715
14738
|
properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_updated: !!status.isUpdate, is_issued: !!status.isIssued, is_expired: !!status.isCancel, is_statement: !!status.isStatement });
|
|
14716
14739
|
}
|
|
14717
14740
|
if (csig) {
|
|
14718
14741
|
properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_expired: true });
|
|
14719
14742
|
}
|
|
14720
|
-
const getProduct = (
|
|
14721
|
-
const isTestProduct =
|
|
14722
|
-
if (isTestProduct ||
|
|
14743
|
+
const getProduct = (_h = (_g = vtec2 == null ? void 0 : vtec2.vtec) == null ? void 0 : _g.split(`.`)[0]) == null ? void 0 : _h.replace(`/`, ``);
|
|
14744
|
+
const isTestProduct = dict_products[getProduct] == `Test Product`;
|
|
14745
|
+
if (isTestProduct || dict_testing.some((sig) => {
|
|
14723
14746
|
var _a2, _b2, _c2, _d2;
|
|
14724
14747
|
return (_d2 = (_a2 = properties2.description) == null ? void 0 : _a2.toLowerCase().includes(sig.toLowerCase())) != null ? _d2 : (_c2 = (_b2 = properties2 == null ? void 0 : properties2.parameters) == null ? void 0 : _b2.instructions) == null ? void 0 : _c2.toLowerCase().includes(sig.toLowerCase());
|
|
14725
14748
|
})) {
|
|
@@ -14746,1849 +14769,2004 @@ var setHash = (event, entry) => {
|
|
|
14746
14769
|
}
|
|
14747
14770
|
};
|
|
14748
14771
|
|
|
14749
|
-
// src/@modules/@
|
|
14750
|
-
var
|
|
14751
|
-
|
|
14752
|
-
|
|
14753
|
-
|
|
14754
|
-
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14760
|
-
|
|
14761
|
-
|
|
14762
|
-
|
|
14763
|
-
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
status: -1,
|
|
14778
|
-
message: (_a2 = error.message) != null ? _a2 : `Unknown Error`
|
|
14779
|
-
});
|
|
14780
|
-
}
|
|
14781
|
-
if (response2.statusCode < 200 || response2.statusCode >= 300) {
|
|
14782
|
-
return resolve6({
|
|
14783
|
-
error: true,
|
|
14784
|
-
options: requestOptions,
|
|
14785
|
-
status: (_b2 = response2.statusCode) != null ? _b2 : -1,
|
|
14786
|
-
message: `HTTP Status Code ${(_c2 = response2.statusCode) != null ? _c2 : `Unknown Status Code`} (${body})`
|
|
14787
|
-
});
|
|
14788
|
-
}
|
|
14789
|
-
if (body == void 0 || body == null) {
|
|
14790
|
-
return resolve6({
|
|
14791
|
-
error: true,
|
|
14792
|
-
options: requestOptions,
|
|
14793
|
-
status: (_d2 = response2.statusCode) != null ? _d2 : -1,
|
|
14794
|
-
message: `Empty Response Body`
|
|
14795
|
-
});
|
|
14796
|
-
}
|
|
14797
|
-
resolve6({
|
|
14798
|
-
error: false,
|
|
14799
|
-
options: requestOptions,
|
|
14800
|
-
status: (_e2 = response2.statusCode) != null ? _e2 : -1,
|
|
14801
|
-
message: body
|
|
14802
|
-
});
|
|
14803
|
-
});
|
|
14804
|
-
});
|
|
14805
|
-
});
|
|
14772
|
+
// src/@modules/@eas/eas.getWavPCM16.ts
|
|
14773
|
+
var getWavPCM16 = (buffer) => {
|
|
14774
|
+
if (buffer.toString("ascii", 0, 4) !== "RIFF" || buffer.toString("ascii", 8, 12) !== "WAVE") {
|
|
14775
|
+
return null;
|
|
14776
|
+
}
|
|
14777
|
+
let fmt = null;
|
|
14778
|
+
let data = null;
|
|
14779
|
+
let i = 12;
|
|
14780
|
+
while (i + 8 <= buffer.length) {
|
|
14781
|
+
const id2 = buffer.toString("ascii", i, i + 4);
|
|
14782
|
+
const size = buffer.readUInt32LE(i + 4);
|
|
14783
|
+
const start = i + 8;
|
|
14784
|
+
const end = start + size;
|
|
14785
|
+
if (id2 === "fmt ") fmt = buffer.slice(start, end);
|
|
14786
|
+
if (id2 === "data") data = buffer.slice(start, end);
|
|
14787
|
+
i = end + size % 2;
|
|
14788
|
+
}
|
|
14789
|
+
if (!fmt || !data) return null;
|
|
14790
|
+
const audioFormat = fmt.readUInt16LE(0);
|
|
14791
|
+
const channels = fmt.readUInt16LE(2);
|
|
14792
|
+
const sampleRate = fmt.readUInt32LE(4);
|
|
14793
|
+
const bitsPerSample = fmt.readUInt16LE(14);
|
|
14794
|
+
if (audioFormat !== 1 || bitsPerSample !== 16 || channels !== 1) {
|
|
14795
|
+
return null;
|
|
14796
|
+
}
|
|
14797
|
+
const samples = new Int16Array(data.buffer, data.byteOffset, data.length / 2);
|
|
14798
|
+
return { samples: new Int16Array(samples), sampleRate, channels, bitsPerSample };
|
|
14799
|
+
};
|
|
14806
14800
|
|
|
14807
|
-
// src/@
|
|
14808
|
-
var
|
|
14809
|
-
|
|
14810
|
-
|
|
14811
|
-
const
|
|
14812
|
-
const
|
|
14813
|
-
let
|
|
14814
|
-
|
|
14815
|
-
|
|
14816
|
-
|
|
14817
|
-
|
|
14818
|
-
|
|
14819
|
-
|
|
14820
|
-
const th = (_b2 = event.parameters.wind_threat) != null ? _b2 : null;
|
|
14821
|
-
const combined = [val, th].filter(Boolean).join(" ");
|
|
14822
|
-
return combined ? `**Wind Gusts**: ${val} ${th ? `(${th})` : ""}` : null;
|
|
14823
|
-
})(),
|
|
14824
|
-
(() => {
|
|
14825
|
-
var _a2, _b2;
|
|
14826
|
-
const val = (_a2 = event.parameters.estimated_hail_size) != null ? _a2 : null;
|
|
14827
|
-
const th = (_b2 = event.parameters.hail_threat) != null ? _b2 : null;
|
|
14828
|
-
return (val != null ? val : th) ? `**Hail Threat**: ${val} ${th ? `(${th})` : ""}` : null;
|
|
14829
|
-
})(),
|
|
14830
|
-
event.parameters.damage_threat ? `**Damage Threat**: ${event.parameters.damage_threat}` : null,
|
|
14831
|
-
event.parameters.flood_threat ? `**Flood Threat**: ${event.parameters.flood_threat}` : null,
|
|
14832
|
-
event.parameters.tornado_threat ? `**Tornado Threat**: ${event.parameters.tornado_threat}` : null,
|
|
14833
|
-
event.spc_parameters.spc_max_tornado ? `**Max Tornado Threat**: ${event.spc_parameters.spc_max_tornado}` : null,
|
|
14834
|
-
event.spc_parameters.spc_max_hail ? `**Max Hail Threat**: ${event.spc_parameters.spc_max_hail}` : null,
|
|
14835
|
-
event.spc_parameters.spc_max_wind ? `**Max Wind Threat**: ${event.spc_parameters.spc_max_wind}` : null,
|
|
14836
|
-
event.spc_parameters.spc_watch_issuance ? `**Watch Issuance**: ${event.spc_parameters.spc_watch_issuance}%` : null,
|
|
14837
|
-
event.watch_parameters.watch_number ? `**Watch Number**: ${event.watch_parameters.watch_number}` : null,
|
|
14838
|
-
event.watch_parameters.strong_tornadoes_probability ? `**Strong Tornadoes Probability**: ${event.watch_parameters.strong_tornadoes_probability}%` : null,
|
|
14839
|
-
event.watch_parameters.additional_tornadoes_probability ? `**Additional Tornadoes Probability**: ${event.watch_parameters.additional_tornadoes_probability}%` : null,
|
|
14840
|
-
event.watch_parameters.combined_hail_wind_probability ? `**Combined Hail/Wind Probability**: ${event.watch_parameters.combined_hail_wind_probability}%` : null,
|
|
14841
|
-
event.watch_parameters.severe_hail_probability ? `**Severe Hail Probability**: ${event.watch_parameters.severe_hail_probability}%` : null,
|
|
14842
|
-
event.watch_parameters.hail_2in_probability ? `**Hail \u22652in Probability**: ${event.watch_parameters.hail_2in_probability}%` : null,
|
|
14843
|
-
event.watch_parameters.max_hail_in ? `**Max Hail Inches**: ${event.watch_parameters.max_hail_in}` : null,
|
|
14844
|
-
event.watch_parameters.severe_wind_probability ? `**Severe Wind Probability**: ${event.watch_parameters.severe_wind_probability}%` : null,
|
|
14845
|
-
event.watch_parameters.max_wind_surface ? `**Max Surface Wind**: ${event.watch_parameters.max_wind_surface}` : null,
|
|
14846
|
-
event.watch_parameters.max_tops_x100feet ? `**Max Tops (x100 feet)**: ${event.watch_parameters.max_tops_x100feet}` : null,
|
|
14847
|
-
((_a = event.parameters.tags) == null ? void 0 : _a.length) > 0 ? `**Tags**: ${event.parameters.tags.join(", ")}` : null,
|
|
14848
|
-
(() => {
|
|
14849
|
-
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
14850
|
-
const val = (_c2 = (_b2 = (_a2 = event.geocode) == null ? void 0 : _a2.office) == null ? void 0 : _b2.name) != null ? _c2 : `N/A`;
|
|
14851
|
-
const th = (_f2 = (_e2 = (_d2 = event.geocode) == null ? void 0 : _d2.office) == null ? void 0 : _e2.office) != null ? _f2 : null;
|
|
14852
|
-
return (val != null ? val : th) ? `**Sender**: ${val} ${th ? `(${th})` : ""}` : null;
|
|
14853
|
-
})(),
|
|
14854
|
-
((_b = event.metadata) == null ? void 0 : _b.tracking) ? `**Tracking**: ${event.metadata.tracking}` : null,
|
|
14855
|
-
((_c = event.metadata.history) == null ? void 0 : _c.length) > 0 ? `**Logs**: ${event.metadata.history.length}` : null,
|
|
14856
|
-
(() => {
|
|
14857
|
-
var _a2;
|
|
14858
|
-
if (event.status == `Expired`) {
|
|
14859
|
-
return null;
|
|
14860
|
-
}
|
|
14861
|
-
const desc = ((_a2 = event.description) != null ? _a2 : "").split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
|
|
14862
|
-
return desc ? "```\n" + desc + "\n```" : null;
|
|
14863
|
-
})()
|
|
14864
|
-
].filter(Boolean).join("\n");
|
|
14865
|
-
const isLimited = setTimeoutAction({ identifier: options.webhook.webhook, interval: options.webhook.rate, max: options.webhook.rate, addTime: true });
|
|
14866
|
-
if (isLimited.limited) {
|
|
14867
|
-
return;
|
|
14801
|
+
// src/@modules/@eas/eas.getSampledPCM16.ts
|
|
14802
|
+
var getSampledPCM16 = (int16, originalRate, targetRate) => {
|
|
14803
|
+
if (originalRate === targetRate) return int16;
|
|
14804
|
+
const ratio = targetRate / originalRate;
|
|
14805
|
+
const outLen = Math.max(1, Math.round(int16.length * ratio));
|
|
14806
|
+
const out = new Int16Array(outLen);
|
|
14807
|
+
for (let i = 0; i < outLen; i++) {
|
|
14808
|
+
const pos = i / ratio;
|
|
14809
|
+
const i0 = Math.floor(pos);
|
|
14810
|
+
const i1 = Math.min(i0 + 1, int16.length - 1);
|
|
14811
|
+
const frac = pos - i0;
|
|
14812
|
+
const v = int16[i0] * (1 - frac) + int16[i1] * frac;
|
|
14813
|
+
out[i] = Math.round(v);
|
|
14868
14814
|
}
|
|
14869
|
-
|
|
14870
|
-
|
|
14871
|
-
|
|
14872
|
-
|
|
14873
|
-
|
|
14874
|
-
const
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14880
|
-
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
embeds: [embed]
|
|
14886
|
-
}));
|
|
14887
|
-
if (settings.upload) {
|
|
14888
|
-
form.append("file", Buffer.from(JSON.stringify(getCleanedEvent(event), null, 2)), {
|
|
14889
|
-
filename: `${event.event}_${event.status}_${event.metadata.tracking}.json`,
|
|
14890
|
-
contentType: "application/json"
|
|
14891
|
-
});
|
|
14815
|
+
return out;
|
|
14816
|
+
};
|
|
14817
|
+
|
|
14818
|
+
// src/@modules/@eas/eas.getPCMToFloat.ts
|
|
14819
|
+
var getPCMToFloat = (int16) => {
|
|
14820
|
+
const out = new Float32Array(int16.length);
|
|
14821
|
+
for (let i = 0; i < int16.length; i++) out[i] = int16[i] / 32768;
|
|
14822
|
+
return out;
|
|
14823
|
+
};
|
|
14824
|
+
|
|
14825
|
+
// src/@modules/@eas/eas.getFloatPCM16.ts
|
|
14826
|
+
var getFloatPCM16 = (float32) => {
|
|
14827
|
+
const out = new Int16Array(float32.length);
|
|
14828
|
+
for (let i = 0; i < float32.length; i++) {
|
|
14829
|
+
let v = Math.max(-1, Math.min(1, float32[i]));
|
|
14830
|
+
out[i] = Math.round(v * 32767);
|
|
14892
14831
|
}
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
timeout: 2e3,
|
|
14896
|
-
method: `POST`,
|
|
14897
|
-
headers: form.getHeaders(),
|
|
14898
|
-
body: form
|
|
14899
|
-
});
|
|
14900
|
-
});
|
|
14832
|
+
return out;
|
|
14833
|
+
};
|
|
14901
14834
|
|
|
14902
|
-
// src/@
|
|
14903
|
-
var
|
|
14904
|
-
const
|
|
14905
|
-
const
|
|
14906
|
-
const
|
|
14907
|
-
|
|
14908
|
-
|
|
14909
|
-
|
|
14910
|
-
|
|
14911
|
-
|
|
14912
|
-
|
|
14913
|
-
|
|
14914
|
-
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
|
|
14918
|
-
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
|
|
14835
|
+
// src/@modules/@eas/eas.setRadioEffect.ts
|
|
14836
|
+
var setRadioEffect = (int16, sampleRate) => {
|
|
14837
|
+
const hpCut = 3555;
|
|
14838
|
+
const lpCut = 1600;
|
|
14839
|
+
const x = getPCMToFloat(int16);
|
|
14840
|
+
const dt = 1 / sampleRate;
|
|
14841
|
+
const rcHP = 1 / (2 * Math.PI * hpCut);
|
|
14842
|
+
const aHP = rcHP / (rcHP + dt);
|
|
14843
|
+
let yHP = 0, xPrev = 0;
|
|
14844
|
+
for (let i = 0; i < x.length; i++) {
|
|
14845
|
+
const xi = x[i];
|
|
14846
|
+
yHP = aHP * (yHP + xi - xPrev);
|
|
14847
|
+
xPrev = xi;
|
|
14848
|
+
x[i] = yHP;
|
|
14849
|
+
}
|
|
14850
|
+
const rcLP = 1 / (2 * Math.PI * lpCut);
|
|
14851
|
+
const aLP = dt / (rcLP + dt);
|
|
14852
|
+
let yLP = 0;
|
|
14853
|
+
for (let i = 0; i < x.length; i++) {
|
|
14854
|
+
yLP = yLP + aLP * (x[i] - yLP);
|
|
14855
|
+
x[i] = yLP;
|
|
14856
|
+
}
|
|
14857
|
+
const compGain = 2;
|
|
14858
|
+
const norm = Math.tanh(compGain);
|
|
14859
|
+
for (let i = 0; i < x.length; i++) x[i] = Math.tanh(x[i] * compGain) / norm;
|
|
14860
|
+
return getFloatPCM16(x);
|
|
14861
|
+
};
|
|
14862
|
+
|
|
14863
|
+
// src/@modules/@eas/eas.setAFSK.ts
|
|
14864
|
+
var setAFSK = (bits, sampleRate) => {
|
|
14865
|
+
const baud = 520.83;
|
|
14866
|
+
const markFreq = 2083.3;
|
|
14867
|
+
const spaceFreq = 1562.5;
|
|
14868
|
+
const amplitude = 0.6;
|
|
14869
|
+
const twoPi = Math.PI * 2;
|
|
14870
|
+
const result = [];
|
|
14871
|
+
let phase = 0;
|
|
14872
|
+
let frac = 0;
|
|
14873
|
+
for (let b = 0; b < bits.length; b++) {
|
|
14874
|
+
const bit = bits[b];
|
|
14875
|
+
const freq = bit ? markFreq : spaceFreq;
|
|
14876
|
+
const samplesPerBit = sampleRate / baud + frac;
|
|
14877
|
+
const n = Math.round(samplesPerBit);
|
|
14878
|
+
frac = samplesPerBit - n;
|
|
14879
|
+
const inc = twoPi * freq / sampleRate;
|
|
14880
|
+
for (let i = 0; i < n; i++) {
|
|
14881
|
+
result.push(Math.round(Math.sin(phase) * amplitude * 32767));
|
|
14882
|
+
phase += inc;
|
|
14883
|
+
if (phase > twoPi) phase -= twoPi;
|
|
14924
14884
|
}
|
|
14925
14885
|
}
|
|
14926
|
-
|
|
14886
|
+
const fadeSamples = Math.floor(sampleRate * 2e-3);
|
|
14887
|
+
for (let i = 0; i < fadeSamples; i++) {
|
|
14888
|
+
const gain = i / fadeSamples;
|
|
14889
|
+
result[i] = Math.round(result[i] * gain);
|
|
14890
|
+
result[result.length - 1 - i] = Math.round(result[result.length - 1 - i] * gain);
|
|
14891
|
+
}
|
|
14892
|
+
return Int16Array.from(result);
|
|
14893
|
+
};
|
|
14927
14894
|
|
|
14928
|
-
// src/@modules/@
|
|
14929
|
-
var
|
|
14930
|
-
|
|
14931
|
-
|
|
14895
|
+
// src/@modules/@eas/eas.setAsciiToBits.ts
|
|
14896
|
+
var setAsciiToBits = (str) => {
|
|
14897
|
+
const bits = [];
|
|
14898
|
+
for (let i = 0; i < str.length; i++) {
|
|
14899
|
+
const c = str.charCodeAt(i) & 255;
|
|
14900
|
+
bits.push(0);
|
|
14901
|
+
for (let b = 0; b < 8; b++) bits.push(c >> b & 1);
|
|
14902
|
+
bits.push(1, 1);
|
|
14932
14903
|
}
|
|
14933
|
-
|
|
14934
|
-
|
|
14935
|
-
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
14939
|
-
|
|
14940
|
-
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
|
|
14944
|
-
|
|
14945
|
-
|
|
14946
|
-
|
|
14947
|
-
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
|
|
14951
|
-
|
|
14952
|
-
|
|
14953
|
-
|
|
14954
|
-
|
|
14955
|
-
|
|
14956
|
-
|
|
14957
|
-
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
|
|
14961
|
-
|
|
14962
|
-
|
|
14963
|
-
const haversineMiles = (a, b) => {
|
|
14964
|
-
const R = 3958.8;
|
|
14965
|
-
const dLat = toRadians(b[1] - a[1]);
|
|
14966
|
-
const dLon = toRadians(b[0] - a[0]);
|
|
14967
|
-
const lat1 = toRadians(a[1]);
|
|
14968
|
-
const lat2 = toRadians(b[1]);
|
|
14969
|
-
const sinDLat = Math.sin(dLat / 2);
|
|
14970
|
-
const sinDLon = Math.sin(dLon / 2);
|
|
14971
|
-
const c = 2 * Math.asin(Math.sqrt(sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon));
|
|
14972
|
-
return R * c;
|
|
14973
|
-
};
|
|
14974
|
-
let minDistance = Infinity;
|
|
14975
|
-
let closestPoint = null;
|
|
14976
|
-
for (const poly of polys) {
|
|
14977
|
-
const outer = poly[0];
|
|
14978
|
-
const holes = poly.slice(1);
|
|
14979
|
-
if (pointInRing(point, outer)) {
|
|
14980
|
-
let inHole = false;
|
|
14981
|
-
for (const hole of holes) {
|
|
14982
|
-
if (pointInRing(point, hole)) {
|
|
14983
|
-
inHole = true;
|
|
14984
|
-
break;
|
|
14985
|
-
}
|
|
14986
|
-
}
|
|
14987
|
-
if (!inHole) {
|
|
14988
|
-
return { proximity: true, point, distance: 0 };
|
|
14989
|
-
}
|
|
14990
|
-
}
|
|
14991
|
-
for (const ring of poly) {
|
|
14992
|
-
for (let i = 0; i < ring.length - 1; i++) {
|
|
14993
|
-
const start = [ring[i][0], ring[i][1]];
|
|
14994
|
-
const end = [ring[i + 1][0], ring[i + 1][1]];
|
|
14995
|
-
const A = lon - start[0];
|
|
14996
|
-
const B = lat - start[1];
|
|
14997
|
-
const C = end[0] - start[0];
|
|
14998
|
-
const D = end[1] - start[1];
|
|
14999
|
-
const lenSq = C * C + D * D;
|
|
15000
|
-
const t = lenSq === 0 ? 0 : Math.max(0, Math.min(1, (A * C + B * D) / lenSq));
|
|
15001
|
-
const candidate = [start[0] + t * C, start[1] + t * D];
|
|
15002
|
-
const dist = haversineMiles([lon, lat], candidate);
|
|
15003
|
-
if (!isNaN(dist) && dist < minDistance) {
|
|
15004
|
-
minDistance = Number(dist.toFixed(3));
|
|
15005
|
-
closestPoint = candidate;
|
|
15006
|
-
}
|
|
15007
|
-
}
|
|
14904
|
+
return bits;
|
|
14905
|
+
};
|
|
14906
|
+
|
|
14907
|
+
// src/@modules/@eas/eas.getMergedPCM16.ts
|
|
14908
|
+
var getMergedPCM16 = (arrays) => {
|
|
14909
|
+
let total = 0;
|
|
14910
|
+
for (const a of arrays) total += a.length;
|
|
14911
|
+
const out = new Int16Array(total);
|
|
14912
|
+
let o = 0;
|
|
14913
|
+
for (const a of arrays) {
|
|
14914
|
+
out.set(a, o);
|
|
14915
|
+
o += a.length;
|
|
14916
|
+
}
|
|
14917
|
+
return out;
|
|
14918
|
+
};
|
|
14919
|
+
|
|
14920
|
+
// src/@modules/@eas/eas.setSameHeader.ts
|
|
14921
|
+
var setSameHeader = (vtec2, repeats, sampleRate = 8e3, options = {}) => {
|
|
14922
|
+
var _a, _b;
|
|
14923
|
+
const preMarkSec = (_a = options.preMarkSec) != null ? _a : 0.3;
|
|
14924
|
+
const gapSec = (_b = options.gapSec) != null ? _b : 0.1;
|
|
14925
|
+
const bursts = [];
|
|
14926
|
+
const gap = new Int16Array(Math.floor(gapSec * sampleRate));
|
|
14927
|
+
for (let i = 0; i < repeats; i++) {
|
|
14928
|
+
const bodyBits = setAsciiToBits(vtec2);
|
|
14929
|
+
const body = setAFSK(bodyBits, sampleRate);
|
|
14930
|
+
const extendedBodyDuration = Math.round(preMarkSec * sampleRate);
|
|
14931
|
+
const extendedBody = new Int16Array(extendedBodyDuration + gap.length);
|
|
14932
|
+
for (let j2 = 0; j2 < extendedBodyDuration; j2++) {
|
|
14933
|
+
extendedBody[j2] = Math.round(body[j2 % body.length] * 0.2);
|
|
15008
14934
|
}
|
|
14935
|
+
extendedBody.set(gap, extendedBodyDuration);
|
|
14936
|
+
bursts.push(extendedBody);
|
|
14937
|
+
if (i !== repeats - 1) bursts.push(gap);
|
|
15009
14938
|
}
|
|
15010
|
-
|
|
15011
|
-
|
|
14939
|
+
return getMergedPCM16(bursts);
|
|
14940
|
+
};
|
|
14941
|
+
|
|
14942
|
+
// src/@modules/@eas/eas.setAttentionTone.ts
|
|
14943
|
+
var setAttentionTone = (ms, sampleRate) => {
|
|
14944
|
+
const len = Math.floor(ms * sampleRate);
|
|
14945
|
+
const out = new Int16Array(len);
|
|
14946
|
+
const f1 = 853;
|
|
14947
|
+
const f2 = 960;
|
|
14948
|
+
const twoPi = Math.PI * 2;
|
|
14949
|
+
const amp = 0.1;
|
|
14950
|
+
const fadeLen = Math.floor(sampleRate * 0);
|
|
14951
|
+
for (let i = 0; i < len; i++) {
|
|
14952
|
+
const t = i / sampleRate;
|
|
14953
|
+
const s = Math.sin(twoPi * f1 * t) + Math.sin(twoPi * f2 * t);
|
|
14954
|
+
let gain = 1;
|
|
14955
|
+
if (i < fadeLen) gain = i / fadeLen;
|
|
14956
|
+
else if (i > len - fadeLen) gain = (len - i) / fadeLen;
|
|
14957
|
+
const v = Math.max(-1, Math.min(1, s / 2 * amp * gain));
|
|
14958
|
+
out[i] = Math.round(v * 32767);
|
|
15012
14959
|
}
|
|
15013
|
-
|
|
15014
|
-
const distanceKm = Number((distanceMiles * 1.609344).toFixed(3));
|
|
15015
|
-
const distanceMeters = Math.round(distanceKm * 1e3);
|
|
15016
|
-
return { proximity: distanceMiles === 0, point: closestPoint, distance: distanceMiles, distanceKm, distanceMeters };
|
|
14960
|
+
return out;
|
|
15017
14961
|
};
|
|
15018
14962
|
|
|
15019
|
-
// src/@
|
|
15020
|
-
var
|
|
15021
|
-
|
|
15022
|
-
|
|
15023
|
-
|
|
15024
|
-
|
|
15025
|
-
|
|
14963
|
+
// src/@modules/@eas/eas.setNoise.ts
|
|
14964
|
+
var setNoise = (int16, noiseLevel = 0.02) => {
|
|
14965
|
+
const x = getPCMToFloat(int16);
|
|
14966
|
+
for (let i = 0; i < x.length; i++) x[i] += (Math.random() * 2 - 1) * noiseLevel;
|
|
14967
|
+
let peak = 0;
|
|
14968
|
+
for (let i = 0; i < x.length; i++) peak = Math.max(peak, Math.abs(x[i]));
|
|
14969
|
+
if (peak > 1) for (let i = 0; i < x.length; i++) x[i] *= 0.98 / peak;
|
|
14970
|
+
return getFloatPCM16(x);
|
|
14971
|
+
};
|
|
14972
|
+
|
|
14973
|
+
// src/@modules/@eas/eas.getPCM16.ts
|
|
14974
|
+
var getPCM16 = (samples, sampleRate) => {
|
|
14975
|
+
let o = 0;
|
|
14976
|
+
const bytesPerSample = 2;
|
|
14977
|
+
const blockAlign = 1 * bytesPerSample;
|
|
14978
|
+
const byteRate = sampleRate * blockAlign;
|
|
14979
|
+
const subchunk2Size = samples.length * bytesPerSample;
|
|
14980
|
+
const chunkSize = 36 + subchunk2Size;
|
|
14981
|
+
const buffer = Buffer.alloc(44 + subchunk2Size);
|
|
14982
|
+
buffer.write("RIFF", o);
|
|
14983
|
+
o += 4;
|
|
14984
|
+
buffer.writeUInt32LE(chunkSize, o);
|
|
14985
|
+
o += 4;
|
|
14986
|
+
buffer.write("WAVE", o);
|
|
14987
|
+
o += 4;
|
|
14988
|
+
buffer.write("fmt ", o);
|
|
14989
|
+
o += 4;
|
|
14990
|
+
buffer.writeUInt32LE(16, o);
|
|
14991
|
+
o += 4;
|
|
14992
|
+
buffer.writeUInt16LE(1, o);
|
|
14993
|
+
o += 2;
|
|
14994
|
+
buffer.writeUInt16LE(1, o);
|
|
14995
|
+
o += 2;
|
|
14996
|
+
buffer.writeUInt32LE(sampleRate, o);
|
|
14997
|
+
o += 4;
|
|
14998
|
+
buffer.writeUInt32LE(byteRate, o);
|
|
14999
|
+
o += 4;
|
|
15000
|
+
buffer.writeUInt16LE(blockAlign, o);
|
|
15001
|
+
o += 2;
|
|
15002
|
+
buffer.writeUInt16LE(16, o);
|
|
15003
|
+
o += 2;
|
|
15004
|
+
buffer.write("data", o);
|
|
15005
|
+
o += 4;
|
|
15006
|
+
buffer.writeUInt32LE(subchunk2Size, o);
|
|
15007
|
+
o += 4;
|
|
15008
|
+
for (let i = 0; i < samples.length; i++, o += 2) {
|
|
15009
|
+
buffer.writeInt16LE(samples[i].value, o);
|
|
15026
15010
|
}
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
|
|
15036
|
-
|
|
15037
|
-
|
|
15038
|
-
|
|
15039
|
-
|
|
15040
|
-
|
|
15041
|
-
|
|
15042
|
-
|
|
15043
|
-
|
|
15044
|
-
|
|
15011
|
+
return buffer;
|
|
15012
|
+
};
|
|
15013
|
+
|
|
15014
|
+
// src/@modules/@eas/eas.getTTS.ts
|
|
15015
|
+
var import_os = require("os");
|
|
15016
|
+
var import_fs = require("fs");
|
|
15017
|
+
var import_child_process = require("child_process");
|
|
15018
|
+
var getTTS = (text2, outputPath) => __async(null, null, function* () {
|
|
15019
|
+
const vPlatform = (0, import_os.platform)();
|
|
15020
|
+
switch (vPlatform) {
|
|
15021
|
+
case "win32": {
|
|
15022
|
+
try {
|
|
15023
|
+
const txtPath = outputPath + ".txt";
|
|
15024
|
+
(0, import_fs.writeFileSync)(txtPath, text2, "utf8");
|
|
15025
|
+
const command = [
|
|
15026
|
+
"Add-Type -AssemblyName System.Speech;",
|
|
15027
|
+
`$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer;`,
|
|
15028
|
+
`$text = Get-Content -Raw -LiteralPath '${txtPath}';`,
|
|
15029
|
+
`$speak.SetOutputToWaveFile('${outputPath}');`,
|
|
15030
|
+
`$speak.Speak($text);`,
|
|
15031
|
+
`$speak.Dispose();`
|
|
15032
|
+
].join(" ");
|
|
15033
|
+
(0, import_child_process.execSync)(`powershell -Command "${command}"`, { stdio: "inherit" });
|
|
15034
|
+
} catch (error) {
|
|
15035
|
+
console.error("Error occurred while generating TTS:", error);
|
|
15036
|
+
}
|
|
15037
|
+
break;
|
|
15045
15038
|
}
|
|
15039
|
+
case "linux":
|
|
15040
|
+
try {
|
|
15041
|
+
(0, import_child_process.execSync)(`espeak -w "${outputPath}" "${text2.replace(/"/g, '\\"')}"`);
|
|
15042
|
+
} catch (e) {
|
|
15043
|
+
}
|
|
15044
|
+
break;
|
|
15045
|
+
default:
|
|
15046
|
+
break;
|
|
15046
15047
|
}
|
|
15047
|
-
return {
|
|
15048
|
-
nodes: metadata.nodes,
|
|
15049
|
-
filtered: metadata.proximity,
|
|
15050
|
-
updated: Date.now()
|
|
15051
|
-
};
|
|
15052
15048
|
});
|
|
15053
15049
|
|
|
15054
|
-
// src/@
|
|
15055
|
-
var
|
|
15056
|
-
const
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
|
|
15067
|
-
|
|
15068
|
-
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15050
|
+
// src/@modules/@eas/eas.getCleanDescription.ts
|
|
15051
|
+
var getCleanDescription = (message) => {
|
|
15052
|
+
const patches = [
|
|
15053
|
+
{ regex: /\.{3,}/g, replacement: ". " },
|
|
15054
|
+
{ regex: /\bUTC\b/g, replacement: "Coordinated Universal Time" },
|
|
15055
|
+
{ regex: /\bGMT\b/g, replacement: "Greenwich Mean Time" },
|
|
15056
|
+
{ regex: /\bEST\b(?!\w)/g, replacement: "Eastern Standard Time" },
|
|
15057
|
+
{ regex: /\bEDT\b(?!\w)/g, replacement: "Eastern Daylight Time" },
|
|
15058
|
+
{ regex: /\bCST\b(?!\w)/g, replacement: "Central Standard Time" },
|
|
15059
|
+
{ regex: /\bCDT\b(?!\w)/g, replacement: "Central Daylight Time" },
|
|
15060
|
+
{ regex: /\bMST\b(?!\w)/g, replacement: "Mountain Standard Time" },
|
|
15061
|
+
{ regex: /\bMDT\b(?!\w)/g, replacement: "Mountain Daylight Time" },
|
|
15062
|
+
{ regex: /\bPST\b(?!\w)/g, replacement: "Pacific Standard Time" },
|
|
15063
|
+
{ regex: /\bPDT\b(?!\w)/g, replacement: "Pacific Daylight Time" },
|
|
15064
|
+
{ regex: /\bAKST\b(?!\w)/g, replacement: "Alaska Standard Time" },
|
|
15065
|
+
{ regex: /\bAKDT\b(?!\w)/g, replacement: "Alaska Daylight Time" },
|
|
15066
|
+
{ regex: /\bHST\b(?!\w)/g, replacement: "Hawaii Standard Time" },
|
|
15067
|
+
{ regex: /\bHDT\b(?!\w)/g, replacement: "Hawaii Daylight Time" },
|
|
15068
|
+
{ regex: /\bmph\b(?!\w)/g, replacement: "miles per hour" },
|
|
15069
|
+
{ regex: /\bkm\/h\b(?!\w)/g, replacement: "kilometers per hour" },
|
|
15070
|
+
{ regex: /\bkmh\b(?!\w)/g, replacement: "kilometers per hour" },
|
|
15071
|
+
{ regex: /\bkt\b(?!\w)/g, replacement: "knots" },
|
|
15072
|
+
{ regex: /\bNE\b(?!\w)/g, replacement: "northeast" },
|
|
15073
|
+
{ regex: /\bNW\b(?!\w)/g, replacement: "northwest" },
|
|
15074
|
+
{ regex: /\bSE\b(?!\w)/g, replacement: "southeast" },
|
|
15075
|
+
{ regex: /\bSW\b(?!\w)/g, replacement: "southwest" },
|
|
15076
|
+
{ regex: /\bNM\b(?!\w)/g, replacement: "nautical miles" },
|
|
15077
|
+
{ regex: /\bdeg\b(?!\w)/g, replacement: "degrees" },
|
|
15078
|
+
{ regex: /\btstm\b(?!\w)/g, replacement: "thunderstorm" },
|
|
15079
|
+
{ regex: /\bmm\b(?!\w)/g, replacement: "millimeters" },
|
|
15080
|
+
{ regex: /\bcm\b(?!\w)/g, replacement: "centimeters" },
|
|
15081
|
+
{ regex: /\bin.\b(?!\w)/g, replacement: "inches" },
|
|
15082
|
+
{ regex: /\bft\b(?!\w)/g, replacement: "feet" },
|
|
15083
|
+
{ regex: /\bmi\b(?!\w)/g, replacement: "miles" },
|
|
15084
|
+
{ regex: /\bhr\b(?!\w)/g, replacement: "hour" },
|
|
15085
|
+
{ regex: /\bhourly\b(?!\w)/g, replacement: "per hour" },
|
|
15086
|
+
{ regex: /\bkg\b(?!\w)/g, replacement: "kilograms" },
|
|
15087
|
+
{ regex: /\bg\/kg\b(?!\w)/g, replacement: "grams per kilogram" },
|
|
15088
|
+
{ regex: /\bmb\b(?!\w)/g, replacement: "millibars" },
|
|
15089
|
+
{ regex: /\bhPa\b(?!\w)/g, replacement: "hectopascals" },
|
|
15090
|
+
{ regex: /\bPa\b(?!\w)/g, replacement: "pascals" },
|
|
15091
|
+
{ regex: /\bKPa\b(?!\w)/g, replacement: "kilopascals" },
|
|
15092
|
+
{ regex: /\bC\/hr\b(?!\w)/g, replacement: "degrees Celsius per hour" },
|
|
15093
|
+
{ regex: /\bF\/hr\b(?!\w)/g, replacement: "degrees Fahrenheit per hour" },
|
|
15094
|
+
{ regex: /\bC\/min\b(?!\w)/g, replacement: "degrees Celsius per minute" },
|
|
15095
|
+
{ regex: /\bF\/min\b(?!\w)/g, replacement: "degrees Fahrenheit per minute" },
|
|
15096
|
+
{ regex: /\bC\b(?!\w)/g, replacement: "degrees Celsius" },
|
|
15097
|
+
{ regex: /\bF\b(?!\w)/g, replacement: "degrees Fahrenheit" }
|
|
15098
|
+
];
|
|
15099
|
+
const hours = {
|
|
15100
|
+
0: "twelve",
|
|
15101
|
+
1: "one",
|
|
15102
|
+
2: "two",
|
|
15103
|
+
3: "three",
|
|
15104
|
+
4: "four",
|
|
15105
|
+
5: "five",
|
|
15106
|
+
6: "six",
|
|
15107
|
+
7: "seven",
|
|
15108
|
+
8: "eight",
|
|
15109
|
+
9: "nine",
|
|
15110
|
+
10: "ten",
|
|
15111
|
+
11: "eleven",
|
|
15112
|
+
12: "twelve"
|
|
15113
|
+
};
|
|
15114
|
+
const minWord = (m) => m === 0 ? "o'clock" : m < 10 ? `oh ${m}` : `${m}`;
|
|
15115
|
+
const fmt = (h, m, ap) => `${hours[h % 12]} ${minWord(m)} ${ap}`;
|
|
15116
|
+
for (const { regex, replacement } of patches) {
|
|
15117
|
+
message = message.replace(regex, replacement);
|
|
15118
|
+
}
|
|
15119
|
+
return message.replace(/'/g, "''").replace(/\b(\d{1,2}):(\d{2})\s*(AM|PM)\b/gi, (_, h, m, ap) => fmt(+h, +m, ap.toUpperCase())).replace(/\b(\d{1,2})\s+(\d{2})\s+(AM|PM)\b/gi, (_, h, m, ap) => fmt(+h, +m, ap.toUpperCase())).replace(/\b(\d{2})(\d{2})\s+(AM|PM)\b/gi, (_, hh, mm, ap) => fmt(+hh, +mm, ap.toUpperCase())).replace(/\b(\d{1,2})\s+(AM|PM)\b/gi, (_, h, ap) => fmt(+h, 0, ap.toUpperCase())).replace(/\*+/g, " ").replace(/-/g, " ").replace(/\n/g, " ").trim();
|
|
15120
|
+
};
|
|
15121
|
+
|
|
15122
|
+
// src/@modules/@eas/eas.setEasTone.ts
|
|
15123
|
+
var import_path2 = require("path");
|
|
15124
|
+
var import_fs2 = require("fs");
|
|
15125
|
+
var import_child_process2 = require("child_process");
|
|
15126
|
+
var import_os2 = require("os");
|
|
15127
|
+
var setEasTone = (options) => __async(null, null, function* () {
|
|
15128
|
+
var _a;
|
|
15129
|
+
const settings = bootstrap.settings;
|
|
15130
|
+
const directory = settings.GlobalSettings.ArchiveSettings.EasDirectory;
|
|
15131
|
+
const prefix = settings.GlobalSettings.ArchiveSettings.EasToneout;
|
|
15132
|
+
let message = options.message;
|
|
15133
|
+
let header = options.header;
|
|
15134
|
+
let title = (_a = options.title) != null ? _a : `${Math.random().toString(36).substring(2, 15)}-${header.replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
15135
|
+
if (!message || !header) {
|
|
15136
|
+
setWarning({
|
|
15137
|
+
title: `EAS`,
|
|
15138
|
+
message: `Message and header are required to generate an EAS tone.`
|
|
15073
15139
|
});
|
|
15140
|
+
return null;
|
|
15074
15141
|
}
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
|
|
15078
|
-
|
|
15142
|
+
let buffTTS;
|
|
15143
|
+
let buffRadio;
|
|
15144
|
+
let buffFull = [];
|
|
15145
|
+
if (!(0, import_fs2.existsSync)(directory)) {
|
|
15146
|
+
(0, import_fs2.mkdirSync)(directory, { recursive: true });
|
|
15079
15147
|
}
|
|
15080
|
-
if (
|
|
15081
|
-
|
|
15148
|
+
if (!(0, import_fs2.existsSync)((0, import_path2.join)(directory, `/tts`))) {
|
|
15149
|
+
(0, import_fs2.mkdirSync)((0, import_path2.join)(directory, `/tts`), { recursive: true });
|
|
15082
15150
|
}
|
|
15083
|
-
if (
|
|
15084
|
-
|
|
15085
|
-
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15151
|
+
if (!(0, import_fs2.existsSync)((0, import_path2.join)(directory, `/encoded`))) {
|
|
15152
|
+
(0, import_fs2.mkdirSync)((0, import_path2.join)(directory, `/encoded`), { recursive: true });
|
|
15153
|
+
}
|
|
15154
|
+
const tmpTTS = (0, import_path2.join)(directory, `/tts/${title}.wav`);
|
|
15155
|
+
const outTTS = (0, import_path2.join)(directory, `/encoded/${title}.wav`);
|
|
15156
|
+
const vPlatform = (0, import_os2.platform)();
|
|
15157
|
+
if (vPlatform === "darwin") {
|
|
15158
|
+
setWarning({
|
|
15159
|
+
title: `EAS`,
|
|
15160
|
+
message: `EAS tone generation is not supported on macOS.`
|
|
15090
15161
|
});
|
|
15162
|
+
return null;
|
|
15091
15163
|
}
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
const settings = bootstrap.settings;
|
|
15098
|
-
const features = bootstrap.cache.events.features;
|
|
15099
|
-
const getHash = event.properties.metadata.hash;
|
|
15100
|
-
const getTracking = event.properties.metadata.tracking;
|
|
15101
|
-
const isEntry = (_a = bootstrap.cache.hashes) == null ? void 0 : _a.find((hash) => hash.tracking === getTracking);
|
|
15102
|
-
const isHashed = (_c = (_b = isEntry == null ? void 0 : isEntry.hashes) == null ? void 0 : _b.includes(getHash)) != null ? _c : false;
|
|
15103
|
-
const getFeature = features.find((feature) => feature.properties.metadata.tracking === getTracking);
|
|
15104
|
-
if (isHashed || event.properties.status_metadata.is_expired) return;
|
|
15105
|
-
setHash(event, isEntry);
|
|
15106
|
-
const isFilteredLocation = yield updateNode(event).then(() => event.properties.metadata.filtered_proximity);
|
|
15107
|
-
if (!isFilteredLocation && settings.GlobalSettings.EventFiltering.NodeLocationFiltering) {
|
|
15108
|
-
return;
|
|
15109
|
-
}
|
|
15110
|
-
setEventEmit({
|
|
15111
|
-
event: `onEventStatus`,
|
|
15112
|
-
metadata: {
|
|
15113
|
-
type: getFeature ? `Updated` : `New`,
|
|
15114
|
-
event
|
|
15115
|
-
},
|
|
15116
|
-
message: `[${getFeature ? "Updated" : "New"}] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
|
|
15164
|
+
yield new Promise((resolve6, reject) => {
|
|
15165
|
+
const tMsg = getCleanDescription(message);
|
|
15166
|
+
getTTS(tMsg, tmpTTS).then(() => {
|
|
15167
|
+
resolve6();
|
|
15168
|
+
});
|
|
15117
15169
|
});
|
|
15118
|
-
if (
|
|
15119
|
-
|
|
15120
|
-
|
|
15121
|
-
|
|
15122
|
-
|
|
15123
|
-
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
|
|
15127
|
-
|
|
15128
|
-
|
|
15129
|
-
|
|
15130
|
-
const
|
|
15131
|
-
|
|
15132
|
-
|
|
15133
|
-
|
|
15134
|
-
|
|
15135
|
-
|
|
15136
|
-
|
|
15137
|
-
|
|
15138
|
-
|
|
15139
|
-
|
|
15140
|
-
|
|
15141
|
-
});
|
|
15142
|
-
updateWebhooks(bootstrap.cache.events.features[getIndex]);
|
|
15143
|
-
} else {
|
|
15144
|
-
features.push(event);
|
|
15145
|
-
updateWebhooks(event);
|
|
15170
|
+
if (!(0, import_fs2.existsSync)(tmpTTS)) {
|
|
15171
|
+
return null;
|
|
15172
|
+
}
|
|
15173
|
+
buffTTS = (0, import_fs2.readFileSync)(tmpTTS);
|
|
15174
|
+
const vWav = getWavPCM16(buffTTS);
|
|
15175
|
+
const vSamples = getSampledPCM16(vWav.samples, vWav.sampleRate, 8e3);
|
|
15176
|
+
const vRadio = setRadioEffect(vSamples, 8e3);
|
|
15177
|
+
if ((0, import_fs2.existsSync)(prefix)) {
|
|
15178
|
+
let tBuffer = (0, import_fs2.readFileSync)(prefix);
|
|
15179
|
+
let tWav = getWavPCM16(tBuffer);
|
|
15180
|
+
if (tWav == null) {
|
|
15181
|
+
try {
|
|
15182
|
+
const converted = (0, import_path2.join)(directory, `/tts/${title}.converted.wav`);
|
|
15183
|
+
(0, import_child_process2.execSync)(`ffmpeg -y -i "${prefix}" -ar 8000 -ac 1 -sample_fmt s16 "${converted}"`, { stdio: "ignore" });
|
|
15184
|
+
if ((0, import_fs2.existsSync)(converted)) {
|
|
15185
|
+
tBuffer = (0, import_fs2.readFileSync)(converted);
|
|
15186
|
+
tWav = getWavPCM16(tBuffer);
|
|
15187
|
+
try {
|
|
15188
|
+
(0, import_fs2.unlinkSync)(converted);
|
|
15189
|
+
} catch (e) {
|
|
15190
|
+
}
|
|
15191
|
+
}
|
|
15192
|
+
} catch (e) {
|
|
15146
15193
|
}
|
|
15147
15194
|
}
|
|
15195
|
+
if (tWav == null) {
|
|
15196
|
+
setWarning({ title: `EAS`, message: `Intro tone isn't a valid .WAV file or isn't in PCM 16-bit format. Converted attempt failed; please convert it then try again.` });
|
|
15197
|
+
return null;
|
|
15198
|
+
}
|
|
15199
|
+
const tSamples = tWav.sampleRate != 8e3 ? getSampledPCM16(tWav.samples, tWav.sampleRate, 8e3) : tWav.samples;
|
|
15200
|
+
buffRadio = setRadioEffect(tSamples, 8e3);
|
|
15201
|
+
}
|
|
15202
|
+
buffFull = buffRadio != null ? [buffRadio, new Int16Array(Math.floor(0.5 * 8e3))] : [];
|
|
15203
|
+
buffFull.push(
|
|
15204
|
+
setSameHeader(header, 3, 8e3, {
|
|
15205
|
+
preMarkSec: 1.1,
|
|
15206
|
+
gapSec: 0.5
|
|
15207
|
+
}),
|
|
15208
|
+
new Int16Array(Math.floor(0.5 * 8e3)),
|
|
15209
|
+
setAttentionTone(8, 8e3),
|
|
15210
|
+
new Int16Array(Math.floor(0.5 * 8e3)),
|
|
15211
|
+
vRadio
|
|
15212
|
+
);
|
|
15213
|
+
for (let i = 0; i < 3; i++) {
|
|
15214
|
+
buffFull.push(setSameHeader(header, 1, 8e3, { preMarkSec: 0.5, gapSec: 0.1 }));
|
|
15215
|
+
buffFull.push(new Int16Array(Math.floor(0.5 * 8e3)));
|
|
15216
|
+
}
|
|
15217
|
+
const aSamples = getMergedPCM16(buffFull);
|
|
15218
|
+
const aFinal = setNoise(aSamples, 2e-3);
|
|
15219
|
+
const aBuffer = getPCM16(Array.from(aFinal).map((v) => ({ value: v })), 8e3);
|
|
15220
|
+
(0, import_fs2.writeFileSync)(outTTS, aBuffer);
|
|
15221
|
+
try {
|
|
15222
|
+
(0, import_fs2.unlinkSync)(tmpTTS);
|
|
15223
|
+
} catch (e) {
|
|
15148
15224
|
}
|
|
15225
|
+
return outTTS;
|
|
15149
15226
|
});
|
|
15150
15227
|
|
|
15151
|
-
// src/@
|
|
15152
|
-
var
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15157
|
-
|
|
15158
|
-
|
|
15159
|
-
|
|
15160
|
-
|
|
15161
|
-
|
|
15162
|
-
|
|
15163
|
-
|
|
15164
|
-
|
|
15165
|
-
|
|
15166
|
-
|
|
15167
|
-
|
|
15168
|
-
|
|
15169
|
-
|
|
15170
|
-
|
|
15171
|
-
|
|
15172
|
-
|
|
15173
|
-
|
|
15174
|
-
|
|
15175
|
-
event:
|
|
15176
|
-
|
|
15177
|
-
|
|
15178
|
-
|
|
15228
|
+
// src/@parsers/@text/text.getEmbed.ts
|
|
15229
|
+
var getEmebed = (event) => {
|
|
15230
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua;
|
|
15231
|
+
const line = (label, value, condition = true) => condition && value ? `${label} ${value}` : null;
|
|
15232
|
+
const isStatement = event.properties.status_metadata.is_statement;
|
|
15233
|
+
const isExpired = event.properties.status_metadata.is_expired;
|
|
15234
|
+
return [
|
|
15235
|
+
line(`**Locations:**`, (_b = (_a = event == null ? void 0 : event.properties) == null ? void 0 : _a.locations) == null ? void 0 : _b.slice(0, 100)),
|
|
15236
|
+
line(`**Issued:**`, `<t:${Math.floor(new Date(event.properties.issued).getTime() / 1e3)}:R>`, !isExpired),
|
|
15237
|
+
line(`**Expires:**`, `<t:${Math.floor(new Date(event.properties.expires).getTime() / 1e3)}:R>`, !isStatement),
|
|
15238
|
+
line(`**Damage Threat:**`, (_d = (_c = event == null ? void 0 : event.properties) == null ? void 0 : _c.parameters) == null ? void 0 : _d.damage_threat, !isExpired),
|
|
15239
|
+
line(`**Flood Threat:**`, (_f = (_e = event == null ? void 0 : event.properties) == null ? void 0 : _e.parameters) == null ? void 0 : _f.flood_threat, !isExpired),
|
|
15240
|
+
line(`**Tornado Threat:**`, (_h = (_g = event == null ? void 0 : event.properties) == null ? void 0 : _g.parameters) == null ? void 0 : _h.tornado_threat, !isExpired),
|
|
15241
|
+
line(`**Estimated Wind Gusts:**`, `${(_j = (_i = event == null ? void 0 : event.properties) == null ? void 0 : _i.parameters) == null ? void 0 : _j.estimated_wind_gusts} ${((_l = (_k = event == null ? void 0 : event.properties) == null ? void 0 : _k.parameters) == null ? void 0 : _l.wind_threat) ? ` (${(_n = (_m = event == null ? void 0 : event.properties) == null ? void 0 : _m.parameters) == null ? void 0 : _n.wind_threat})` : ""}`, !isExpired && ((_p = (_o = event == null ? void 0 : event.properties) == null ? void 0 : _o.parameters) == null ? void 0 : _p.estimated_wind_gusts) != null),
|
|
15242
|
+
line(`**Estimated Hail Size:**`, `${(_r = (_q = event == null ? void 0 : event.properties) == null ? void 0 : _q.parameters) == null ? void 0 : _r.estimated_hail_size} ${((_t = (_s = event == null ? void 0 : event.properties) == null ? void 0 : _s.parameters) == null ? void 0 : _t.hail_threat) ? ` (${(_v = (_u = event == null ? void 0 : event.properties) == null ? void 0 : _u.parameters) == null ? void 0 : _v.hail_threat})` : ""}`, !isExpired && ((_x = (_w = event == null ? void 0 : event.properties) == null ? void 0 : _w.parameters) == null ? void 0 : _x.estimated_hail_size) != null),
|
|
15243
|
+
line(`**Discussion:**`, (_z = (_y = event == null ? void 0 : event.properties) == null ? void 0 : _y.discussion_parameters) == null ? void 0 : _z.discussion_number, !isExpired),
|
|
15244
|
+
line(`**Concern:**`, (_B = (_A = event == null ? void 0 : event.properties) == null ? void 0 : _A.discussion_parameters) == null ? void 0 : _B.discussion_concerning, !isExpired),
|
|
15245
|
+
line(`**SPC Max Tornado Threat:**`, (_D = (_C = event == null ? void 0 : event.properties) == null ? void 0 : _C.discussion_parameters) == null ? void 0 : _D.discussion_max_tornado, !isExpired),
|
|
15246
|
+
line(`**SPC Max Hail Threat:**`, (_F = (_E = event == null ? void 0 : event.properties) == null ? void 0 : _E.discussion_parameters) == null ? void 0 : _F.discussion_max_hail, !isExpired),
|
|
15247
|
+
line(`**SPC Max Wind Threat:**`, (_H = (_G = event == null ? void 0 : event.properties) == null ? void 0 : _G.discussion_parameters) == null ? void 0 : _H.discussion_max_wind, !isExpired),
|
|
15248
|
+
line(`**SPC Watch Issuance Probability:**`, ((_J = (_I = event == null ? void 0 : event.properties) == null ? void 0 : _I.discussion_parameters) == null ? void 0 : _J.discussion_watch_issuance) ? `${(_L = (_K = event == null ? void 0 : event.properties) == null ? void 0 : _K.discussion_parameters) == null ? void 0 : _L.discussion_watch_issuance}%` : null, !isExpired),
|
|
15249
|
+
line(`**Watch Number:**`, (_N = (_M = event == null ? void 0 : event.properties) == null ? void 0 : _M.watch_parameters) == null ? void 0 : _N.watch_number, !isExpired),
|
|
15250
|
+
line(`**Strong Tornadoes Probability:**`, ((_P = (_O = event == null ? void 0 : event.properties) == null ? void 0 : _O.watch_parameters) == null ? void 0 : _P.strong_tornadoes_probability) ? `${(_R = (_Q = event == null ? void 0 : event.properties) == null ? void 0 : _Q.watch_parameters) == null ? void 0 : _R.strong_tornadoes_probability}%` : null, !isExpired),
|
|
15251
|
+
line(`**Additional Tornadoes Probability:**`, ((_T = (_S = event == null ? void 0 : event.properties) == null ? void 0 : _S.watch_parameters) == null ? void 0 : _T.additional_tornadoes_probability) ? `${(_V = (_U = event == null ? void 0 : event.properties) == null ? void 0 : _U.watch_parameters) == null ? void 0 : _V.additional_tornadoes_probability}%` : null, !isExpired),
|
|
15252
|
+
line(`**Combined Hail/Wind Probability:**`, ((_X = (_W = event == null ? void 0 : event.properties) == null ? void 0 : _W.watch_parameters) == null ? void 0 : _X.combined_hail_wind_probability) ? `${(_Z = (_Y = event == null ? void 0 : event.properties) == null ? void 0 : _Y.watch_parameters) == null ? void 0 : _Z.combined_hail_wind_probability}%` : null, !isExpired),
|
|
15253
|
+
line(`**Severe Hail Probability:**`, ((_$ = (__ = event == null ? void 0 : event.properties) == null ? void 0 : __.watch_parameters) == null ? void 0 : _$.severe_hail_probability) ? `${(_ba = (_aa = event == null ? void 0 : event.properties) == null ? void 0 : _aa.watch_parameters) == null ? void 0 : _ba.severe_hail_probability}%` : null, !isExpired),
|
|
15254
|
+
line(`**Hail >2in Probability:**`, ((_da = (_ca = event == null ? void 0 : event.properties) == null ? void 0 : _ca.watch_parameters) == null ? void 0 : _da.hail_2in_probability) ? `${(_fa = (_ea = event == null ? void 0 : event.properties) == null ? void 0 : _ea.watch_parameters) == null ? void 0 : _fa.hail_2in_probability}%` : null, !isExpired),
|
|
15255
|
+
line(`**Max Hail Inches:**`, (_ha = (_ga = event == null ? void 0 : event.properties) == null ? void 0 : _ga.watch_parameters) == null ? void 0 : _ha.max_hail_in, !isExpired),
|
|
15256
|
+
line(`**Severe Wind Probability:**`, ((_ja = (_ia = event == null ? void 0 : event.properties) == null ? void 0 : _ia.watch_parameters) == null ? void 0 : _ja.severe_wind_probability) ? `${(_la = (_ka = event == null ? void 0 : event.properties) == null ? void 0 : _ka.watch_parameters) == null ? void 0 : _la.severe_wind_probability}%` : null, !isExpired),
|
|
15257
|
+
line(`**Max Surface Wind:**`, (_na = (_ma = event == null ? void 0 : event.properties) == null ? void 0 : _ma.watch_parameters) == null ? void 0 : _na.max_wind_surface, !isExpired),
|
|
15258
|
+
line(`**Max Tops (x100 feet):**`, (_pa = (_oa = event == null ? void 0 : event.properties) == null ? void 0 : _oa.watch_parameters) == null ? void 0 : _pa.max_tops_x100feet, !isExpired),
|
|
15259
|
+
line(`**Tags:**`, ((_sa = (_ra = (_qa = event == null ? void 0 : event.properties) == null ? void 0 : _qa.parameters) == null ? void 0 : _ra.tags) == null ? void 0 : _sa.length) > 0 ? (_ua = (_ta = event == null ? void 0 : event.properties) == null ? void 0 : _ta.parameters) == null ? void 0 : _ua.tags.join(", ") : null, !isExpired),
|
|
15260
|
+
line(`**Sender:**`, ((_xa = (_wa = (_va = event == null ? void 0 : event.properties) == null ? void 0 : _va.geocode) == null ? void 0 : _wa.office) == null ? void 0 : _xa.name) ? `${(_Aa = (_za = (_ya = event == null ? void 0 : event.properties) == null ? void 0 : _ya.geocode) == null ? void 0 : _za.office) == null ? void 0 : _Aa.name} (${(_Da = (_Ca = (_Ba = event == null ? void 0 : event.properties) == null ? void 0 : _Ba.geocode) == null ? void 0 : _Ca.office) == null ? void 0 : _Da.office})` : (_Ga = (_Fa = (_Ea = event == null ? void 0 : event.properties) == null ? void 0 : _Ea.geocode) == null ? void 0 : _Fa.office) == null ? void 0 : _Ga.office),
|
|
15261
|
+
line(`**Tracking:**`, (_Ia = (_Ha = event == null ? void 0 : event.properties) == null ? void 0 : _Ha.metadata) == null ? void 0 : _Ia.tracking),
|
|
15262
|
+
line(`**Logs:**`, ((_La = (_Ka = (_Ja = event == null ? void 0 : event.properties) == null ? void 0 : _Ja.metadata) == null ? void 0 : _Ka.history) == null ? void 0 : _La.length) > 0 ? (_Na = (_Ma = event == null ? void 0 : event.properties) == null ? void 0 : _Ma.metadata) == null ? void 0 : _Na.history.length : null),
|
|
15263
|
+
line(``, ((_Qa = (_Pa = (_Oa = event == null ? void 0 : event.properties) == null ? void 0 : _Oa.metadata) == null ? void 0 : _Pa.attachments) == null ? void 0 : _Qa.length) > 0 ? `**Attachments:** ${(_Sa = (_Ra = event == null ? void 0 : event.properties) == null ? void 0 : _Ra.metadata) == null ? void 0 : _Sa.attachments.map((attachment) => {
|
|
15264
|
+
var _a2, _b2;
|
|
15265
|
+
return `[Attachment #${((_b2 = (_a2 = event == null ? void 0 : event.properties) == null ? void 0 : _a2.metadata) == null ? void 0 : _b2.attachments.indexOf(attachment)) + 1}](${attachment})`;
|
|
15266
|
+
}).join(" | ")}` : null),
|
|
15267
|
+
line(``, ((_Ta = event == null ? void 0 : event.properties) == null ? void 0 : _Ta.description) ? "```\n" + ((_Ua = event == null ? void 0 : event.properties) == null ? void 0 : _Ua.description.split("\n").map((l) => l.trim()).filter(Boolean).join("\n")) + "\n```" : null, !isExpired)
|
|
15268
|
+
].filter(Boolean).join("\n");
|
|
15179
15269
|
};
|
|
15180
15270
|
|
|
15181
|
-
// src/@
|
|
15182
|
-
var
|
|
15183
|
-
|
|
15184
|
-
|
|
15185
|
-
|
|
15186
|
-
|
|
15187
|
-
|
|
15188
|
-
|
|
15189
|
-
|
|
15190
|
-
|
|
15191
|
-
|
|
15192
|
-
|
|
15193
|
-
|
|
15194
|
-
|
|
15195
|
-
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
const zones = properties2.geocode.ugc;
|
|
15203
|
-
const icao = properties2.geocode.office.office;
|
|
15204
|
-
const enhancedEventName = properties2.event = getEventEnhancedName(event);
|
|
15205
|
-
const filteredProperties = JSON.parse(JSON.stringify(properties2));
|
|
15206
|
-
if ((filteredProperties == null ? void 0 : filteredProperties.metadata) && "ms" in filteredProperties.metadata) {
|
|
15207
|
-
delete filteredProperties.metadata.ms;
|
|
15208
|
-
}
|
|
15209
|
-
filteredProperties.metadata = (_a2 = filteredProperties.metadata) != null ? _a2 : {};
|
|
15210
|
-
properties2.metadata.hash = (0, import_crypto.createHash)("sha256").update(JSON.stringify(filteredProperties)).digest("hex");
|
|
15211
|
-
setEventEmit({ event: `onProductType${enhancedEventName.replace(/\s+/g, "")}`, metadata: define2 });
|
|
15212
|
-
if (properties2.status_metadata.is_test) {
|
|
15213
|
-
setEventEmit({ event: `onTestProduct`, metadata: define2 });
|
|
15214
|
-
if (bools == null ? void 0 : bools.IgnoreTestProducts) return false;
|
|
15215
|
-
}
|
|
15216
|
-
if (properties2.status_metadata.is_expired) {
|
|
15217
|
-
setEventEmit({ event: `onExpiredProduct`, metadata: define2 });
|
|
15218
|
-
rmEvent(define2);
|
|
15219
|
-
return false;
|
|
15220
|
-
}
|
|
15221
|
-
if ((_c = (_b = properties2.metadata) == null ? void 0 : _b.vtec) == null ? void 0 : _c.is_watch) {
|
|
15222
|
-
const isSPC = (_e = (_d = properties2.metadata) == null ? void 0 : _d.vtec) == null ? void 0 : _e.prediction_center;
|
|
15223
|
-
setEventEmit({ event: isSPC ? `onStormPredictionWatch` : `onNonStormPredictionWatch`, metadata: define2 });
|
|
15224
|
-
if ((bools == null ? void 0 : bools.SPCWatchesOnly) && !isSPC) {
|
|
15225
|
-
return false;
|
|
15226
|
-
}
|
|
15227
|
-
if (!(bools == null ? void 0 : bools.SPCWatchesOnly) && isSPC) {
|
|
15228
|
-
return false;
|
|
15229
|
-
}
|
|
15271
|
+
// src/@modules/@utilities/utilities.createHttp.ts
|
|
15272
|
+
var import_request = __toESM(require("request"));
|
|
15273
|
+
var createHttp = (options) => __async(null, null, function* () {
|
|
15274
|
+
return new Promise((resolve6, reject) => {
|
|
15275
|
+
var _a, _b, _c, _d, _e;
|
|
15276
|
+
const requestOptions = {
|
|
15277
|
+
url: (_a = options.url) != null ? _a : `https://api.weather.gov/alerts/active`,
|
|
15278
|
+
headers: (_b = options.headers) != null ? _b : {
|
|
15279
|
+
"User-Agent": "AtmosphericX",
|
|
15280
|
+
"Accept": "application/geo+json, text/plain, */*; q=0.9",
|
|
15281
|
+
"Accept-Language": "en-US,en;q=0.9"
|
|
15282
|
+
},
|
|
15283
|
+
method: (_c = options.method) != null ? _c : `GET`,
|
|
15284
|
+
timeout: (_d = options.timeout) != null ? _d : 1e4,
|
|
15285
|
+
proxy: (_e = options.proxy) != null ? _e : null,
|
|
15286
|
+
maxRedirects: 1
|
|
15287
|
+
};
|
|
15288
|
+
if (options.formData) {
|
|
15289
|
+
requestOptions["formData"] = options.formData;
|
|
15290
|
+
} else if (options.body) {
|
|
15291
|
+
requestOptions["body"] = options.body;
|
|
15230
15292
|
}
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
if (
|
|
15234
|
-
|
|
15235
|
-
|
|
15236
|
-
|
|
15237
|
-
|
|
15238
|
-
|
|
15239
|
-
}
|
|
15240
|
-
if (key === "IgnoredEvents" && setting.size > 0 && setting.has(define2.properties.event.toLowerCase())) {
|
|
15241
|
-
setEventEmit({
|
|
15242
|
-
event: `onIgnoredEvent`,
|
|
15243
|
-
metadata: define2
|
|
15293
|
+
(0, import_request.default)(requestOptions, (error, response2, body) => {
|
|
15294
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
15295
|
+
if (error) {
|
|
15296
|
+
return resolve6({
|
|
15297
|
+
error: true,
|
|
15298
|
+
options: requestOptions,
|
|
15299
|
+
status: -1,
|
|
15300
|
+
message: (_a2 = error.message) != null ? _a2 : `Unknown Error`
|
|
15244
15301
|
});
|
|
15245
|
-
return false;
|
|
15246
15302
|
}
|
|
15247
|
-
if (
|
|
15248
|
-
|
|
15249
|
-
|
|
15250
|
-
|
|
15303
|
+
if (response2.statusCode < 200 || response2.statusCode >= 300) {
|
|
15304
|
+
return resolve6({
|
|
15305
|
+
error: true,
|
|
15306
|
+
options: requestOptions,
|
|
15307
|
+
status: (_b2 = response2.statusCode) != null ? _b2 : -1,
|
|
15308
|
+
message: `HTTP Status Code ${(_c2 = response2.statusCode) != null ? _c2 : `Unknown Status Code`} (${body})`
|
|
15251
15309
|
});
|
|
15252
|
-
return false;
|
|
15253
15310
|
}
|
|
15254
|
-
if (
|
|
15255
|
-
|
|
15256
|
-
|
|
15257
|
-
|
|
15311
|
+
if (body == void 0 || body == null) {
|
|
15312
|
+
return resolve6({
|
|
15313
|
+
error: true,
|
|
15314
|
+
options: requestOptions,
|
|
15315
|
+
status: (_d2 = response2.statusCode) != null ? _d2 : -1,
|
|
15316
|
+
message: `Empty Response Body`
|
|
15258
15317
|
});
|
|
15259
|
-
return false;
|
|
15260
15318
|
}
|
|
15261
|
-
|
|
15262
|
-
|
|
15263
|
-
|
|
15264
|
-
|
|
15265
|
-
|
|
15266
|
-
|
|
15319
|
+
resolve6({
|
|
15320
|
+
error: false,
|
|
15321
|
+
options: requestOptions,
|
|
15322
|
+
status: (_e2 = response2.statusCode) != null ? _e2 : -1,
|
|
15323
|
+
message: body
|
|
15324
|
+
});
|
|
15325
|
+
});
|
|
15326
|
+
});
|
|
15327
|
+
});
|
|
15328
|
+
|
|
15329
|
+
// src/@manager/manager.updateListener.ts
|
|
15330
|
+
var import_fs3 = require("fs");
|
|
15331
|
+
var import_form_data = __toESM(require_form_data());
|
|
15332
|
+
var updateListener = (event) => __async(null, null, function* () {
|
|
15333
|
+
var _a, _b, _c, _d;
|
|
15334
|
+
const settings = bootstrap.settings;
|
|
15335
|
+
const listeners2 = settings.ListenerSettings;
|
|
15336
|
+
const properties2 = event.properties;
|
|
15337
|
+
for (const socket of listeners2) {
|
|
15338
|
+
const events = socket.events;
|
|
15339
|
+
const sWebhook = socket == null ? void 0 : socket.webhook;
|
|
15340
|
+
const sUploads = socket == null ? void 0 : socket.uploads;
|
|
15341
|
+
const matched = events.some((pattern) => {
|
|
15342
|
+
if (!pattern) return false;
|
|
15343
|
+
if (pattern === "*" || pattern === properties2.event) return true;
|
|
15344
|
+
if (pattern.includes("*")) {
|
|
15345
|
+
const regex = "^" + pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*") + "$";
|
|
15346
|
+
return new RegExp(regex).test(properties2.event);
|
|
15267
15347
|
}
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
|
|
15271
|
-
|
|
15348
|
+
return false;
|
|
15349
|
+
});
|
|
15350
|
+
if ((events == null ? void 0 : events.length) == 0 || matched) {
|
|
15351
|
+
let eas;
|
|
15352
|
+
let file;
|
|
15353
|
+
if (sUploads == null ? void 0 : sUploads.eas) {
|
|
15354
|
+
eas = yield setEasTone({
|
|
15355
|
+
title: `${properties2.event}_${properties2.status}_${properties2.metadata.tracking}`,
|
|
15356
|
+
message: properties2.description,
|
|
15357
|
+
header: properties2.metadata.header
|
|
15272
15358
|
});
|
|
15273
|
-
return false;
|
|
15274
15359
|
}
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
|
|
15288
|
-
|
|
15289
|
-
|
|
15290
|
-
|
|
15291
|
-
|
|
15292
|
-
|
|
15293
|
-
|
|
15294
|
-
|
|
15295
|
-
|
|
15296
|
-
|
|
15297
|
-
|
|
15298
|
-
|
|
15299
|
-
|
|
15300
|
-
|
|
15301
|
-
|
|
15302
|
-
|
|
15303
|
-
|
|
15304
|
-
|
|
15305
|
-
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
|
|
15318
|
-
|
|
15319
|
-
|
|
15320
|
-
|
|
15321
|
-
|
|
15322
|
-
event,
|
|
15323
|
-
parent: event,
|
|
15324
|
-
status: isStatement ? `Statement` : `Issued`,
|
|
15325
|
-
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
15326
|
-
expires: isStatement ? new Date(issued.getTime() + 120 * 1e3).toISOString() : !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
|
|
15327
|
-
}, props), {
|
|
15328
|
-
metadata: {
|
|
15329
|
-
ms: performance.now() - tick,
|
|
15330
|
-
source: `events.text`,
|
|
15331
|
-
tracking: getEventTracking({ type: `RAW`, stanza, attributes, properties: props }),
|
|
15332
|
-
header,
|
|
15333
|
-
vtec: null,
|
|
15334
|
-
hvtec: null,
|
|
15335
|
-
history: [
|
|
15336
|
-
{
|
|
15337
|
-
description: props.description,
|
|
15338
|
-
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
15339
|
-
status: `Issued`
|
|
15360
|
+
if (sUploads == null ? void 0 : sUploads.file) {
|
|
15361
|
+
const destination = bootstrap.settings.GlobalSettings.ArchiveSettings.TextDirectory;
|
|
15362
|
+
if (destination) {
|
|
15363
|
+
if (!(0, import_fs3.existsSync)(destination)) {
|
|
15364
|
+
(0, import_fs3.mkdirSync)(destination, { recursive: true });
|
|
15365
|
+
}
|
|
15366
|
+
if ((0, import_fs3.existsSync)(`${destination}/${properties2.event}_${properties2.status}_${properties2.metadata.tracking}.txt`)) {
|
|
15367
|
+
(0, import_fs3.appendFileSync)(`${destination}/${properties2.event}_${properties2.status}_${properties2.metadata.tracking}.txt`, properties2.metadata.raw);
|
|
15368
|
+
} else {
|
|
15369
|
+
(0, import_fs3.writeFileSync)(`${destination}/${properties2.event}_${properties2.status}_${properties2.metadata.tracking}.txt`, properties2.metadata.raw);
|
|
15370
|
+
}
|
|
15371
|
+
}
|
|
15372
|
+
file = properties2.metadata.raw;
|
|
15373
|
+
}
|
|
15374
|
+
if (sWebhook == null ? void 0 : sWebhook.enabled) {
|
|
15375
|
+
const isLimited = setTimeoutAction({ identifier: sWebhook.destination, interval: sWebhook.ratelimit, max: sWebhook.ratelimit, addTime: true });
|
|
15376
|
+
if (!isLimited.limited) {
|
|
15377
|
+
let body = getEmebed(event);
|
|
15378
|
+
if (body.length > 1900) {
|
|
15379
|
+
body = body.substring(0, 1900) + "\n\n[Message truncated due to length]";
|
|
15380
|
+
const blocks = ((_a = body.match(/```/g)) != null ? _a : []).length;
|
|
15381
|
+
if (blocks % 2 !== 0) body += "```";
|
|
15382
|
+
}
|
|
15383
|
+
if (properties2.description.length < 25) {
|
|
15384
|
+
continue;
|
|
15385
|
+
}
|
|
15386
|
+
const form = new import_form_data.default();
|
|
15387
|
+
const embed = {
|
|
15388
|
+
title: `${properties2.event} (${properties2.status})`,
|
|
15389
|
+
description: body,
|
|
15390
|
+
color: 16711680,
|
|
15391
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15392
|
+
image: {},
|
|
15393
|
+
footer: { text: (_b = sWebhook.title) != null ? _b : `AtmosphericX` }
|
|
15394
|
+
};
|
|
15395
|
+
form.append("payload_json", JSON.stringify({
|
|
15396
|
+
username: (_c = sWebhook.title) != null ? _c : "AtmosphericX",
|
|
15397
|
+
content: (_d = sWebhook.message) != null ? _d : "",
|
|
15398
|
+
embeds: [embed]
|
|
15399
|
+
}));
|
|
15400
|
+
if (sUploads == null ? void 0 : sUploads.file) {
|
|
15401
|
+
form.append("fUpload", Buffer.from(file), { filename: `${properties2.event}_${properties2.status}_${properties2.metadata.tracking}.txt`, contentType: "application/text" });
|
|
15402
|
+
}
|
|
15403
|
+
if (sUploads == null ? void 0 : sUploads.eas) {
|
|
15404
|
+
if (eas) {
|
|
15405
|
+
const file2 = (0, import_fs3.readFileSync)(eas);
|
|
15406
|
+
form.append("fEas", Buffer.from(file2), { filename: `${properties2.event}_${properties2.status}_${properties2.metadata.tracking}_eas.mp3`, contentType: "audio/mpeg" });
|
|
15340
15407
|
}
|
|
15341
|
-
|
|
15408
|
+
}
|
|
15409
|
+
const a = yield createHttp({
|
|
15410
|
+
url: sWebhook.destination,
|
|
15411
|
+
timeout: 5e3,
|
|
15412
|
+
method: `POST`,
|
|
15413
|
+
headers: form.getHeaders(),
|
|
15414
|
+
body: form
|
|
15415
|
+
});
|
|
15342
15416
|
}
|
|
15343
|
-
}
|
|
15344
|
-
}
|
|
15417
|
+
}
|
|
15418
|
+
}
|
|
15345
15419
|
}
|
|
15346
|
-
validateEvents(processed);
|
|
15347
15420
|
});
|
|
15348
15421
|
|
|
15349
|
-
// src/@
|
|
15350
|
-
var
|
|
15351
|
-
|
|
15352
|
-
|
|
15353
|
-
|
|
15354
|
-
const
|
|
15355
|
-
|
|
15356
|
-
|
|
15357
|
-
|
|
15358
|
-
|
|
15359
|
-
|
|
15360
|
-
|
|
15361
|
-
|
|
15362
|
-
|
|
15363
|
-
|
|
15364
|
-
|
|
15365
|
-
|
|
15366
|
-
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15372
|
-
|
|
15422
|
+
// src/@modules/@utilities/utilities.getShapeNearestPoint.ts
|
|
15423
|
+
var getShapeNearestPoint = (coordinates, point) => {
|
|
15424
|
+
if (!coordinates || !point) {
|
|
15425
|
+
return { proximity: false, point: [0, 0], distance: null };
|
|
15426
|
+
}
|
|
15427
|
+
const normalize = (coords) => {
|
|
15428
|
+
if (!Array.isArray(coords)) return [];
|
|
15429
|
+
if (typeof coords[0] === "number" && typeof coords[1] === "number") return [];
|
|
15430
|
+
if (Array.isArray(coords[0]) && typeof coords[0][0] === "number") {
|
|
15431
|
+
return [[coords]];
|
|
15432
|
+
}
|
|
15433
|
+
if (Array.isArray(coords[0]) && Array.isArray(coords[0][0]) && typeof coords[0][0][0] === "number") {
|
|
15434
|
+
return [coords];
|
|
15435
|
+
}
|
|
15436
|
+
if (Array.isArray(coords[0]) && Array.isArray(coords[0][0]) && Array.isArray(coords[0][0][0]) && typeof coords[0][0][0][0] === "number") {
|
|
15437
|
+
return coords;
|
|
15438
|
+
}
|
|
15439
|
+
return [];
|
|
15440
|
+
};
|
|
15441
|
+
const polys = normalize(coordinates);
|
|
15442
|
+
if (polys.length === 0) return { proximity: false, point: [0, 0], distance: null };
|
|
15443
|
+
const lon = point[0];
|
|
15444
|
+
const lat = point[1];
|
|
15445
|
+
const pointInRing = (pt, ring) => {
|
|
15446
|
+
let x = pt[0], y = pt[1];
|
|
15447
|
+
let inside = false;
|
|
15448
|
+
for (let i = 0, j2 = ring.length - 1; i < ring.length; j2 = i++) {
|
|
15449
|
+
const xi = ring[i][0], yi = ring[i][1];
|
|
15450
|
+
const xj = ring[j2][0], yj = ring[j2][1];
|
|
15451
|
+
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi + 0) + xi;
|
|
15452
|
+
if (intersect) inside = !inside;
|
|
15453
|
+
}
|
|
15454
|
+
return inside;
|
|
15455
|
+
};
|
|
15456
|
+
const toRadians = (deg) => deg * Math.PI / 180;
|
|
15457
|
+
const haversineMiles = (a, b) => {
|
|
15458
|
+
const R = 3958.8;
|
|
15459
|
+
const dLat = toRadians(b[1] - a[1]);
|
|
15460
|
+
const dLon = toRadians(b[0] - a[0]);
|
|
15461
|
+
const lat1 = toRadians(a[1]);
|
|
15462
|
+
const lat2 = toRadians(b[1]);
|
|
15463
|
+
const sinDLat = Math.sin(dLat / 2);
|
|
15464
|
+
const sinDLon = Math.sin(dLon / 2);
|
|
15465
|
+
const c = 2 * Math.asin(Math.sqrt(sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon));
|
|
15466
|
+
return R * c;
|
|
15467
|
+
};
|
|
15468
|
+
let minDistance = Infinity;
|
|
15469
|
+
let closestPoint = null;
|
|
15470
|
+
for (const poly of polys) {
|
|
15471
|
+
const outer = poly[0];
|
|
15472
|
+
const holes = poly.slice(1);
|
|
15473
|
+
if (pointInRing(point, outer)) {
|
|
15474
|
+
let inHole = false;
|
|
15475
|
+
for (const hole of holes) {
|
|
15476
|
+
if (pointInRing(point, hole)) {
|
|
15477
|
+
inHole = true;
|
|
15478
|
+
break;
|
|
15373
15479
|
}
|
|
15374
|
-
} else {
|
|
15375
|
-
zones.push(part);
|
|
15376
15480
|
}
|
|
15377
|
-
|
|
15481
|
+
if (!inHole) {
|
|
15482
|
+
return { proximity: true, point, distance: 0 };
|
|
15483
|
+
}
|
|
15378
15484
|
}
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
|
|
15383
|
-
|
|
15384
|
-
|
|
15485
|
+
for (const ring of poly) {
|
|
15486
|
+
for (let i = 0; i < ring.length - 1; i++) {
|
|
15487
|
+
const start = [ring[i][0], ring[i][1]];
|
|
15488
|
+
const end = [ring[i + 1][0], ring[i + 1][1]];
|
|
15489
|
+
const A = lon - start[0];
|
|
15490
|
+
const B = lat - start[1];
|
|
15491
|
+
const C = end[0] - start[0];
|
|
15492
|
+
const D = end[1] - start[1];
|
|
15493
|
+
const lenSq = C * C + D * D;
|
|
15494
|
+
const t = lenSq === 0 ? 0 : Math.max(0, Math.min(1, (A * C + B * D) / lenSq));
|
|
15495
|
+
const candidate = [start[0] + t * C, start[1] + t * D];
|
|
15496
|
+
const dist = haversineMiles([lon, lat], candidate);
|
|
15497
|
+
if (!isNaN(dist) && dist < minDistance) {
|
|
15498
|
+
minDistance = Number(dist.toFixed(3));
|
|
15499
|
+
closestPoint = candidate;
|
|
15500
|
+
}
|
|
15385
15501
|
}
|
|
15386
|
-
} else {
|
|
15387
|
-
zones.push(`${state}${format}${part}`);
|
|
15388
15502
|
}
|
|
15389
15503
|
}
|
|
15390
|
-
|
|
15391
|
-
};
|
|
15392
|
-
|
|
15393
|
-
// src/@parsers/@ugc/ugc.expiry.ts
|
|
15394
|
-
var getExpiry = (message) => {
|
|
15395
|
-
const match = message.match(/\b(\d{6})-/);
|
|
15396
|
-
if (!match) {
|
|
15397
|
-
return null;
|
|
15504
|
+
if (!isFinite(minDistance) || closestPoint == null) {
|
|
15505
|
+
return { proximity: false, point: [0, 0], distance: null };
|
|
15398
15506
|
}
|
|
15399
|
-
const
|
|
15400
|
-
const
|
|
15401
|
-
const
|
|
15402
|
-
|
|
15403
|
-
const now = /* @__PURE__ */ new Date();
|
|
15404
|
-
const expires = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), day, hour, minute));
|
|
15405
|
-
return expires.toISOString();
|
|
15507
|
+
const distanceMiles = minDistance;
|
|
15508
|
+
const distanceKm = Number((distanceMiles * 1.609344).toFixed(3));
|
|
15509
|
+
const distanceMeters = Math.round(distanceKm * 1e3);
|
|
15510
|
+
return { proximity: distanceMiles === 0, point: closestPoint, distance: distanceMiles, distanceKm, distanceMeters };
|
|
15406
15511
|
};
|
|
15407
15512
|
|
|
15408
|
-
// src/@
|
|
15409
|
-
var
|
|
15410
|
-
|
|
15411
|
-
const
|
|
15412
|
-
const
|
|
15413
|
-
|
|
15513
|
+
// src/@building/building.polygon.ts
|
|
15514
|
+
var getEventNodes = (event) => __async(null, null, function* () {
|
|
15515
|
+
var _a, _b;
|
|
15516
|
+
const metadata = { nodes: [], proximity: false, filtered: false };
|
|
15517
|
+
const geometry = yield getEventGeometry(event);
|
|
15518
|
+
if (!geometry || !geometry.coordinates) {
|
|
15519
|
+
return { nodes: [], filtered: false, updated: Date.now() };
|
|
15520
|
+
}
|
|
15521
|
+
const nodes = bootstrap.cache.nodes.features;
|
|
15522
|
+
for (const node of nodes) {
|
|
15523
|
+
const [longitude, latitude] = node.geometry.coordinates;
|
|
15524
|
+
const getPoint = getShapeNearestPoint(geometry.coordinates, [longitude, latitude]);
|
|
15525
|
+
const miles = (_a = getPoint.distance) != null ? _a : null;
|
|
15526
|
+
const kilometers = Number((miles * 1.609344).toFixed(3));
|
|
15527
|
+
const info = {
|
|
15528
|
+
id: (_b = node.properties) == null ? void 0 : _b.identifier,
|
|
15529
|
+
coordinates: [longitude, latitude],
|
|
15530
|
+
nearest: getPoint.point,
|
|
15531
|
+
miles,
|
|
15532
|
+
kilometers,
|
|
15533
|
+
proximity: getPoint.proximity
|
|
15534
|
+
};
|
|
15535
|
+
metadata.nodes.push(info);
|
|
15536
|
+
if (bootstrap.settings.GlobalSettings.EventFiltering.NodeLocationFiltering && miles < bootstrap.settings.GlobalSettings.NodeMinDistance) {
|
|
15537
|
+
metadata.proximity = true;
|
|
15538
|
+
info.proximity = true;
|
|
15539
|
+
}
|
|
15540
|
+
}
|
|
15541
|
+
return {
|
|
15542
|
+
nodes: metadata.nodes,
|
|
15543
|
+
filtered: metadata.proximity,
|
|
15544
|
+
updated: Date.now()
|
|
15545
|
+
};
|
|
15414
15546
|
});
|
|
15415
15547
|
|
|
15416
|
-
// src/@
|
|
15417
|
-
var
|
|
15418
|
-
const
|
|
15419
|
-
const
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
|
|
15426
|
-
|
|
15427
|
-
|
|
15548
|
+
// src/@manager/manager.updateNodes.ts
|
|
15549
|
+
var updateNode = (selectedEvent) => __async(null, null, function* () {
|
|
15550
|
+
const events = bootstrap.cache.events.features;
|
|
15551
|
+
const ttl = bootstrap.settings.GlobalSettings.NodeTTL * 1e3;
|
|
15552
|
+
let total = 0;
|
|
15553
|
+
function update(evt) {
|
|
15554
|
+
return __async(this, null, function* () {
|
|
15555
|
+
var _a, _b, _c;
|
|
15556
|
+
const lastUpdate = (_c = (_b = (_a = evt == null ? void 0 : evt.properties) == null ? void 0 : _a.metadata) == null ? void 0 : _b.updated) != null ? _c : null;
|
|
15557
|
+
if (lastUpdate != null && Date.now() - lastUpdate < ttl) {
|
|
15558
|
+
return evt;
|
|
15559
|
+
}
|
|
15560
|
+
const node = yield getEventNodes(evt);
|
|
15561
|
+
if (node.nodes.length > 0) {
|
|
15562
|
+
total++;
|
|
15563
|
+
}
|
|
15564
|
+
evt.properties.metadata.nodes = node.nodes;
|
|
15565
|
+
evt.properties.metadata.filtered_proximity = node.filtered;
|
|
15566
|
+
evt.properties.metadata.updated = node.updated;
|
|
15567
|
+
});
|
|
15568
|
+
}
|
|
15569
|
+
if (!selectedEvent) {
|
|
15570
|
+
yield Promise.all(events.map((evt) => __async(null, null, function* () {
|
|
15571
|
+
yield update(evt);
|
|
15572
|
+
})));
|
|
15573
|
+
}
|
|
15574
|
+
if (selectedEvent) {
|
|
15575
|
+
yield update(selectedEvent);
|
|
15576
|
+
}
|
|
15577
|
+
if (total > 0) {
|
|
15578
|
+
setEventEmit({
|
|
15579
|
+
event: `onNodeUpdate`,
|
|
15580
|
+
metadata: {
|
|
15581
|
+
type: `global-update`,
|
|
15582
|
+
updated: total
|
|
15583
|
+
}
|
|
15584
|
+
});
|
|
15585
|
+
}
|
|
15428
15586
|
});
|
|
15429
15587
|
|
|
15430
|
-
// src/@
|
|
15431
|
-
var
|
|
15432
|
-
var _a, _b, _c;
|
|
15433
|
-
|
|
15434
|
-
const
|
|
15435
|
-
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
|
|
15444
|
-
|
|
15445
|
-
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15588
|
+
// src/@manager/manager.mkEvent.ts
|
|
15589
|
+
var mkEvent = (event) => __async(null, null, function* () {
|
|
15590
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
15591
|
+
const settings = bootstrap.settings;
|
|
15592
|
+
const features = bootstrap.cache.events.features;
|
|
15593
|
+
const getHash = event.properties.metadata.hash;
|
|
15594
|
+
const getTracking = event.properties.metadata.tracking;
|
|
15595
|
+
const isEntry = (_a = bootstrap.cache.hashes) == null ? void 0 : _a.find((hash) => hash.tracking === getTracking);
|
|
15596
|
+
const isHashed = (_c = (_b = isEntry == null ? void 0 : isEntry.hashes) == null ? void 0 : _b.includes(getHash)) != null ? _c : false;
|
|
15597
|
+
const getFeature = features.find((feature) => feature.properties.metadata.tracking === getTracking);
|
|
15598
|
+
if (isHashed || event.properties.status_metadata.is_expired) return;
|
|
15599
|
+
setHash(event, isEntry);
|
|
15600
|
+
const isFilteredLocation = yield updateNode(event).then(() => event.properties.metadata.filtered_proximity);
|
|
15601
|
+
if (!isFilteredLocation && settings.GlobalSettings.EventFiltering.NodeLocationFiltering) {
|
|
15602
|
+
return;
|
|
15603
|
+
}
|
|
15604
|
+
setEventEmit({
|
|
15605
|
+
event: `onEventStatus`,
|
|
15606
|
+
metadata: {
|
|
15607
|
+
type: getFeature ? `Updated` : `New`,
|
|
15608
|
+
event
|
|
15609
|
+
},
|
|
15610
|
+
message: `[${getFeature ? "Updated" : "New"}] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
|
|
15611
|
+
});
|
|
15612
|
+
if (settings.GlobalSettings.EventManagement) {
|
|
15613
|
+
if (event.properties.status_metadata.is_issued || event.properties.status_metadata.is_updated) {
|
|
15614
|
+
if (getFeature) {
|
|
15615
|
+
const getIndex = features.indexOf(getFeature);
|
|
15616
|
+
const cHistory = (_f = (_e = (_d = getFeature == null ? void 0 : getFeature.properties) == null ? void 0 : _d.metadata) == null ? void 0 : _e.history) != null ? _f : [];
|
|
15617
|
+
const cLocations = (_i = (_h = (_g = getFeature == null ? void 0 : getFeature.properties) == null ? void 0 : _g.locations) == null ? void 0 : _h.split(";").map((l) => l.trim())) != null ? _i : [];
|
|
15618
|
+
const cUgc = (_l = (_k = (_j = getFeature == null ? void 0 : getFeature.properties) == null ? void 0 : _j.geocode) == null ? void 0 : _k.ugc) != null ? _l : [];
|
|
15619
|
+
const iHistory = (_o = (_n = (_m = event.properties) == null ? void 0 : _m.metadata) == null ? void 0 : _n.history) != null ? _o : [];
|
|
15620
|
+
const iLocations = (_r = (_q = (_p = event.properties) == null ? void 0 : _p.locations) == null ? void 0 : _q.split(";").map((l) => l.trim())) != null ? _r : [];
|
|
15621
|
+
const iUgc = (_u = (_t = (_s = event.properties) == null ? void 0 : _s.geocode) == null ? void 0 : _t.ugc) != null ? _u : [];
|
|
15622
|
+
const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i).filter((v, i, a) => a.findIndex((h) => h.description === v.description && h.issued === v.issued) === i);
|
|
15623
|
+
const mLocations = [...cLocations, ...iLocations].filter((v, i, a) => a.indexOf(v) === i).join("; ");
|
|
15624
|
+
const mUgc = [...cUgc, ...iUgc].filter((v, i, a) => a.indexOf(v) === i);
|
|
15625
|
+
bootstrap.cache.events.features[getIndex] = __spreadProps(__spreadValues({}, event), {
|
|
15626
|
+
properties: __spreadProps(__spreadValues({}, event.properties), {
|
|
15627
|
+
metadata: __spreadProps(__spreadValues({}, (_v = event == null ? void 0 : event.properties) == null ? void 0 : _v.metadata), {
|
|
15628
|
+
history: mHistory
|
|
15629
|
+
}),
|
|
15630
|
+
locations: mLocations,
|
|
15631
|
+
geocode: __spreadProps(__spreadValues({}, (_w = event == null ? void 0 : event.properties) == null ? void 0 : _w.geocode), {
|
|
15632
|
+
ugc: mUgc
|
|
15633
|
+
})
|
|
15634
|
+
})
|
|
15635
|
+
});
|
|
15636
|
+
updateListener(bootstrap.cache.events.features[getIndex]);
|
|
15637
|
+
} else {
|
|
15638
|
+
features.push(event);
|
|
15639
|
+
updateListener(event);
|
|
15450
15640
|
}
|
|
15451
|
-
processed.push({
|
|
15452
|
-
type: `Feature`,
|
|
15453
|
-
geometry: {
|
|
15454
|
-
type: `Point`,
|
|
15455
|
-
coordinates: []
|
|
15456
|
-
},
|
|
15457
|
-
properties: __spreadProps(__spreadValues({
|
|
15458
|
-
event,
|
|
15459
|
-
parent: event,
|
|
15460
|
-
status: isStatement ? `Statement` : `Issued`,
|
|
15461
|
-
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
15462
|
-
expires: isStatement ? new Date(issued.getTime() + 120 * 1e3).toISOString() : !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
|
|
15463
|
-
}, props), {
|
|
15464
|
-
metadata: {
|
|
15465
|
-
ms: performance.now() - tick,
|
|
15466
|
-
source: `events.ugc`,
|
|
15467
|
-
tracking: getEventTracking({ type: `RAW`, stanza, attributes, properties: props }),
|
|
15468
|
-
header,
|
|
15469
|
-
vtec: null,
|
|
15470
|
-
hvtec: null,
|
|
15471
|
-
history: [
|
|
15472
|
-
{
|
|
15473
|
-
description: props.description,
|
|
15474
|
-
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
15475
|
-
status: `Issued`
|
|
15476
|
-
}
|
|
15477
|
-
]
|
|
15478
|
-
}
|
|
15479
|
-
})
|
|
15480
|
-
});
|
|
15481
15641
|
}
|
|
15482
15642
|
}
|
|
15483
|
-
validateEvents(processed);
|
|
15484
15643
|
});
|
|
15485
15644
|
|
|
15486
|
-
// src/@
|
|
15487
|
-
var
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
|
|
15491
|
-
|
|
15492
|
-
|
|
15493
|
-
|
|
15494
|
-
|
|
15495
|
-
|
|
15496
|
-
|
|
15497
|
-
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
|
|
15501
|
-
|
|
15502
|
-
|
|
15503
|
-
|
|
15504
|
-
|
|
15505
|
-
|
|
15506
|
-
|
|
15507
|
-
|
|
15508
|
-
|
|
15509
|
-
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
|
|
15513
|
-
|
|
15514
|
-
|
|
15515
|
-
"LE": "Lake Effect Snow",
|
|
15516
|
-
"LO": "Low Water",
|
|
15517
|
-
"LS": "Lakeshore Flood",
|
|
15518
|
-
"LW": "Lake Wind",
|
|
15519
|
-
"MA": "Special Marine",
|
|
15520
|
-
"EQ": "Earthquake",
|
|
15521
|
-
"MF": "Dense Fog",
|
|
15522
|
-
"MH": "Ashfall",
|
|
15523
|
-
"MS": "Dense Smoke",
|
|
15524
|
-
"RB": "Small Craft for Rough Bar",
|
|
15525
|
-
"RP": "Rip Current Risk",
|
|
15526
|
-
"SC": "Small Craft",
|
|
15527
|
-
"SE": "Hazardous Seas",
|
|
15528
|
-
"SI": "Small Craft for Winds",
|
|
15529
|
-
"SM": "Dense Smoke",
|
|
15530
|
-
"SQ": "Snow Squall",
|
|
15531
|
-
"SR": "Storm",
|
|
15532
|
-
"SS": "Storm Surge",
|
|
15533
|
-
"SU": "High Surf",
|
|
15534
|
-
"SV": "Severe Thunderstorm",
|
|
15535
|
-
"SW": "Small Craft for Hazardous Seas",
|
|
15536
|
-
"TO": "Tornado",
|
|
15537
|
-
"TR": "Tropical Storm",
|
|
15538
|
-
"TS": "Tsunami",
|
|
15539
|
-
"TY": "Typhoon",
|
|
15540
|
-
"SP": "Special Weather",
|
|
15541
|
-
"UP": "Heavy Freezing Spray",
|
|
15542
|
-
"WC": "Wind Chill",
|
|
15543
|
-
"WI": "Wind",
|
|
15544
|
-
"WS": "Winter Storm",
|
|
15545
|
-
"WW": "Winter Weather",
|
|
15546
|
-
"ZF": "Freezing Fog",
|
|
15547
|
-
"ZR": "Freezing Rain",
|
|
15548
|
-
"ZY": "Freezing Spray"
|
|
15645
|
+
// src/@manager/manager.rmEvent.ts
|
|
15646
|
+
var rmEvent = (event) => {
|
|
15647
|
+
const getEvent = bootstrap.cache.events.features.find((f) => {
|
|
15648
|
+
var _a, _b, _c, _d;
|
|
15649
|
+
return ((_b = (_a = f == null ? void 0 : f.properties) == null ? void 0 : _a.metadata) == null ? void 0 : _b.tracking) === ((_d = (_c = event == null ? void 0 : event.properties) == null ? void 0 : _c.metadata) == null ? void 0 : _d.tracking);
|
|
15650
|
+
});
|
|
15651
|
+
const cachedStatus = event.properties.status;
|
|
15652
|
+
event.properties.expires = (/* @__PURE__ */ new Date()).toISOString();
|
|
15653
|
+
event.properties.status = `Expired`;
|
|
15654
|
+
event.properties.status_metadata.is_expired = true;
|
|
15655
|
+
if (getEvent) {
|
|
15656
|
+
setEventEmit({
|
|
15657
|
+
event: `onEventStatus`,
|
|
15658
|
+
metadata: {
|
|
15659
|
+
type: `Removed`,
|
|
15660
|
+
event
|
|
15661
|
+
},
|
|
15662
|
+
message: `[Removed] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
|
|
15663
|
+
});
|
|
15664
|
+
setEventEmit({ event: `onExpiredProduct`, metadata: event });
|
|
15665
|
+
if (cachedStatus != `Statement`) updateListener(event);
|
|
15666
|
+
bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(getEvent), 1);
|
|
15667
|
+
bootstrap.cache.hashes = bootstrap.cache.hashes.filter((hash) => hash.tracking !== event.properties.metadata.tracking);
|
|
15668
|
+
}
|
|
15669
|
+
setEventEmit({
|
|
15670
|
+
event: `onEventCache`,
|
|
15671
|
+
metadata: bootstrap.cache.events,
|
|
15672
|
+
limited: true
|
|
15673
|
+
});
|
|
15549
15674
|
};
|
|
15550
15675
|
|
|
15551
|
-
// src/@
|
|
15552
|
-
var
|
|
15553
|
-
|
|
15554
|
-
|
|
15555
|
-
|
|
15556
|
-
|
|
15557
|
-
|
|
15558
|
-
|
|
15559
|
-
|
|
15676
|
+
// src/@modules/@utilities/utilities.getLatestIssuance.ts
|
|
15677
|
+
var getLatestIssuance = () => {
|
|
15678
|
+
const now = /* @__PURE__ */ new Date();
|
|
15679
|
+
const current = now.getUTCHours() * 100 + now.getUTCMinutes();
|
|
15680
|
+
const issuances = [100, 600, 1300, 1630, 2e3];
|
|
15681
|
+
let latest = issuances[0];
|
|
15682
|
+
for (const issuance of issuances) {
|
|
15683
|
+
if (current >= issuance) {
|
|
15684
|
+
latest = issuance;
|
|
15685
|
+
}
|
|
15686
|
+
}
|
|
15687
|
+
return latest.toString().padStart(4, "0");
|
|
15560
15688
|
};
|
|
15561
15689
|
|
|
15562
|
-
// src/@
|
|
15563
|
-
var
|
|
15564
|
-
|
|
15565
|
-
|
|
15566
|
-
|
|
15567
|
-
|
|
15568
|
-
|
|
15569
|
-
|
|
15570
|
-
|
|
15571
|
-
|
|
15572
|
-
|
|
15573
|
-
|
|
15690
|
+
// src/@building/building.attachments.ts
|
|
15691
|
+
var getEventAttachments = (event) => {
|
|
15692
|
+
var _a, _b, _c, _d;
|
|
15693
|
+
const latestTime = getLatestIssuance();
|
|
15694
|
+
const spcNumber = (_b = (_a = event == null ? void 0 : event.properties) == null ? void 0 : _a.discussion_parameters) == null ? void 0 : _b.discussion_number;
|
|
15695
|
+
const watchNumber = (_d = (_c = event == null ? void 0 : event.properties) == null ? void 0 : _c.watch_parameters) == null ? void 0 : _d.watch_number;
|
|
15696
|
+
const validEvents = [
|
|
15697
|
+
{ target: "Day 1", attachment: `https://www.spc.noaa.gov/products/outlook/day1otlk_${latestTime}.png` },
|
|
15698
|
+
{ target: "Day 2", attachment: `https://www.spc.noaa.gov/products/outlook/day2otlk.png` },
|
|
15699
|
+
{ target: "Day 3", attachment: `https://www.spc.noaa.gov/products/outlook/day3otlk.png` },
|
|
15700
|
+
{ target: "Mesoscale Discussion", attachment: `https://www.spc.noaa.gov/products/md/mcd${spcNumber}.png` },
|
|
15701
|
+
{ target: "Tornado Watch", attachment: `https://www.spc.noaa.gov/products/watch/ww${watchNumber}_radar_big.gif` },
|
|
15702
|
+
{ target: "PDS Tornado Watch", attachment: `https://www.spc.noaa.gov/products/watch/ww${watchNumber}_radar_big.gif` },
|
|
15703
|
+
{ target: "Severe Thunderstorm Watch", attachment: `https://www.spc.noaa.gov/products/watch/ww${watchNumber}_radar_big.gif` },
|
|
15704
|
+
{ target: "PDS Severe Thunderstorm Watch", attachment: `https://www.spc.noaa.gov/products/watch/ww${watchNumber}_radar_big.gif` }
|
|
15705
|
+
];
|
|
15706
|
+
const isValid = validEvents.find((outlook) => outlook.target == event.properties.event);
|
|
15707
|
+
if (isValid) {
|
|
15708
|
+
return (isValid == null ? void 0 : isValid.attachment) ? [isValid.attachment] : [];
|
|
15709
|
+
}
|
|
15710
|
+
return null;
|
|
15574
15711
|
};
|
|
15575
15712
|
|
|
15576
|
-
// src/@
|
|
15577
|
-
var
|
|
15578
|
-
if ((dates == null ? void 0 : dates[1]) == `000000T0000Z`) return "Invalid Date Format";
|
|
15579
|
-
const expires = `${(/* @__PURE__ */ new Date()).getFullYear().toString().substring(0, 2)}${dates[1].substring(0, 2)}-${dates[1].substring(2, 4)}-${dates[1].substring(4, 6)}T${dates[1].substring(7, 9)}:${dates[1].substring(9, 11)}:00`;
|
|
15580
|
-
const local = new Date(new Date(expires).getTime() - 4 * 60 * 6e4);
|
|
15581
|
-
const pad = (n) => n.toString().padStart(2, "0");
|
|
15582
|
-
return `${local.getFullYear()}-${pad(local.getMonth() + 1)}-${pad(local.getDate())}T${pad(local.getHours())}:${pad(local.getMinutes())}:00.000-04:00`;
|
|
15583
|
-
};
|
|
15584
|
-
|
|
15585
|
-
// src/@parsers/@pvtec/pvtec.extract.ts
|
|
15586
|
-
var pvExtract = (message) => {
|
|
15587
|
-
var _a, _b, _c, _d;
|
|
15588
|
-
const getVTECs = (_a = message.match(regExp.pvtec)) != null ? _a : [];
|
|
15589
|
-
const vtecs = [];
|
|
15590
|
-
for (const vtec2 of getVTECs) {
|
|
15591
|
-
const sub = vtec2.split(`.`);
|
|
15592
|
-
if ((sub == null ? void 0 : sub.length) < 7) continue;
|
|
15593
|
-
const dates = (_b = sub[6]) == null ? void 0 : _b.split(`-`);
|
|
15594
|
-
vtecs.push({
|
|
15595
|
-
vtec: vtec2,
|
|
15596
|
-
product: eventProducts[sub[0]],
|
|
15597
|
-
tracking: `${sub[2]}.${sub[3]}.${sub[4]}.${sub[5]}`,
|
|
15598
|
-
event: `${eventTypes[sub[3]]} ${eventActions[sub[4]]}`,
|
|
15599
|
-
status: eventStatus[sub[1]],
|
|
15600
|
-
organization: (_d = (_c = message.match(regExp.wmo)) == null ? void 0 : _c[0]) != null ? _d : null,
|
|
15601
|
-
expires: getExpiry2(dates),
|
|
15602
|
-
is_watch: (sub[4] == `A` || sub[4] == `Y`) && (sub[3] == `TO` || sub[3] == `SV`),
|
|
15603
|
-
prediction_center: sub[2] == `KWNS` ? true : false
|
|
15604
|
-
});
|
|
15605
|
-
}
|
|
15606
|
-
return vtecs.length > 0 ? vtecs : null;
|
|
15607
|
-
};
|
|
15608
|
-
|
|
15609
|
-
// src/@dictionaries/dictionaries.eventCauses.ts
|
|
15610
|
-
var eventCauses = {
|
|
15611
|
-
"SM": "Snow Melt",
|
|
15612
|
-
"RS": "Rain/Snow Melt",
|
|
15613
|
-
"ER": "Excessive Rain",
|
|
15614
|
-
"DM": "Dam/Levee Failure",
|
|
15615
|
-
"IJ": "Ice Jam",
|
|
15616
|
-
"GO": "Glacier Lake Outburst",
|
|
15617
|
-
"IC": "Ice",
|
|
15618
|
-
"FS": "Flash Flood / Storm Surge",
|
|
15619
|
-
"FT": "Tidal Effects",
|
|
15620
|
-
"ET": "Elevated Upstream Flow",
|
|
15621
|
-
"MC": "Other Multiple Causes",
|
|
15622
|
-
"WT": "Wind and/or Tidal Effects",
|
|
15623
|
-
"DR": "Reservoir Release",
|
|
15624
|
-
"UU": "Unknown",
|
|
15625
|
-
"OT": "Other Effects"
|
|
15626
|
-
};
|
|
15627
|
-
|
|
15628
|
-
// src/@dictionaries/dictionaries.eventRecords.ts
|
|
15629
|
-
var eventRecords = {
|
|
15630
|
-
"NO": "No Record Expected",
|
|
15631
|
-
"NR": "Near Record or possible record",
|
|
15632
|
-
"UU": "Unknown history of records",
|
|
15633
|
-
"OO": "Other"
|
|
15634
|
-
};
|
|
15635
|
-
|
|
15636
|
-
// src/@dictionaries/dictionaries.eventSeverity.ts
|
|
15637
|
-
var eventSeverity = {
|
|
15638
|
-
N: "Not Expected",
|
|
15639
|
-
0: "Areal Flood or FF Product",
|
|
15640
|
-
1: "Minor",
|
|
15641
|
-
2: "Moderate",
|
|
15642
|
-
3: "Major",
|
|
15643
|
-
U: "Unknown"
|
|
15644
|
-
};
|
|
15645
|
-
|
|
15646
|
-
// src/@parsers/@hvtec/hvtec.extract.ts
|
|
15647
|
-
var hvExtract = (message) => {
|
|
15713
|
+
// src/@building/building.validate.ts
|
|
15714
|
+
var validateEvents = (events) => __async(null, null, function* () {
|
|
15648
15715
|
var _a;
|
|
15649
|
-
|
|
15650
|
-
const
|
|
15651
|
-
|
|
15652
|
-
|
|
15653
|
-
|
|
15654
|
-
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15716
|
+
if (events.length === 0) return;
|
|
15717
|
+
const configurations = bootstrap.settings;
|
|
15718
|
+
const sets = {};
|
|
15719
|
+
const bools = {};
|
|
15720
|
+
const megered = __spreadValues(__spreadValues({}, configurations.GlobalSettings), configurations.GlobalSettings.EventFiltering);
|
|
15721
|
+
for (const key in megered) {
|
|
15722
|
+
const setting = megered[key];
|
|
15723
|
+
if (Array.isArray(setting)) {
|
|
15724
|
+
sets[key] = new Set(setting.map((item) => item.toLowerCase()));
|
|
15725
|
+
}
|
|
15726
|
+
if (typeof setting === "boolean") {
|
|
15727
|
+
bools[key] = setting;
|
|
15728
|
+
}
|
|
15660
15729
|
}
|
|
15661
|
-
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
|
|
15669
|
-
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
|
|
15676
|
-
if (
|
|
15677
|
-
|
|
15678
|
-
|
|
15679
|
-
|
|
15680
|
-
|
|
15681
|
-
|
|
15682
|
-
|
|
15683
|
-
|
|
15684
|
-
|
|
15685
|
-
|
|
15686
|
-
|
|
15687
|
-
|
|
15688
|
-
|
|
15689
|
-
|
|
15690
|
-
|
|
15691
|
-
|
|
15692
|
-
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
|
|
15696
|
-
|
|
15697
|
-
|
|
15698
|
-
|
|
15699
|
-
|
|
15700
|
-
|
|
15701
|
-
|
|
15702
|
-
|
|
15703
|
-
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
15709
|
-
|
|
15710
|
-
|
|
15711
|
-
|
|
15730
|
+
const filterd = events.filter((event) => {
|
|
15731
|
+
var _a2, _b, _c, _d, _e;
|
|
15732
|
+
const define2 = getEventSignature(event);
|
|
15733
|
+
const properties2 = define2.properties;
|
|
15734
|
+
const zones = properties2.geocode.ugc;
|
|
15735
|
+
const icao = properties2.geocode.office.office;
|
|
15736
|
+
const enhancedEventName = properties2.event = getEventEnhancedName(event);
|
|
15737
|
+
const filteredProperties = JSON.parse(JSON.stringify(properties2));
|
|
15738
|
+
if ((filteredProperties == null ? void 0 : filteredProperties.metadata) && "ms" in filteredProperties.metadata) {
|
|
15739
|
+
delete filteredProperties.metadata.ms;
|
|
15740
|
+
}
|
|
15741
|
+
filteredProperties.metadata = (_a2 = filteredProperties.metadata) != null ? _a2 : {};
|
|
15742
|
+
properties2.metadata.hash = (0, import_crypto.createHash)("sha256").update(JSON.stringify(filteredProperties)).digest("hex");
|
|
15743
|
+
properties2.metadata.attachments = getEventAttachments(event);
|
|
15744
|
+
setEventEmit({ event: `onProductType${enhancedEventName.replace(/\s+/g, "")}`, metadata: define2 });
|
|
15745
|
+
if (properties2.status_metadata.is_test) {
|
|
15746
|
+
setEventEmit({ event: `onTestProduct`, metadata: define2 });
|
|
15747
|
+
if (bools == null ? void 0 : bools.IgnoreTestProducts) return false;
|
|
15748
|
+
}
|
|
15749
|
+
if (properties2.status_metadata.is_expired) {
|
|
15750
|
+
setEventEmit({ event: `onExpiredProduct`, metadata: define2 });
|
|
15751
|
+
rmEvent(define2);
|
|
15752
|
+
return false;
|
|
15753
|
+
}
|
|
15754
|
+
if (((_c = (_b = properties2.metadata) == null ? void 0 : _b.vtec) == null ? void 0 : _c.is_watch) && properties2.metadata.source != `events.api`) {
|
|
15755
|
+
const isSPC = (_e = (_d = properties2.metadata) == null ? void 0 : _d.vtec) == null ? void 0 : _e.prediction_center;
|
|
15756
|
+
setEventEmit({ event: isSPC ? `onStormPredictionWatch` : `onNonStormPredictionWatch`, metadata: define2 });
|
|
15757
|
+
if ((bools == null ? void 0 : bools.SPCWatchesOnly) && !isSPC) {
|
|
15758
|
+
return false;
|
|
15759
|
+
}
|
|
15760
|
+
if (!(bools == null ? void 0 : bools.SPCWatchesOnly) && isSPC) {
|
|
15761
|
+
return false;
|
|
15762
|
+
}
|
|
15763
|
+
}
|
|
15764
|
+
for (const key in sets) {
|
|
15765
|
+
const setting = sets[key];
|
|
15766
|
+
if (key === "ListeningEvents" && setting.size > 0 && !setting.has(define2.properties.event.toLowerCase())) {
|
|
15767
|
+
setEventEmit({
|
|
15768
|
+
event: `onFilteredEvent`,
|
|
15769
|
+
metadata: define2
|
|
15770
|
+
});
|
|
15771
|
+
return false;
|
|
15772
|
+
}
|
|
15773
|
+
if (key === "IgnoredEvents" && setting.size > 0 && setting.has(define2.properties.event.toLowerCase())) {
|
|
15774
|
+
setEventEmit({
|
|
15775
|
+
event: `onIgnoredEvent`,
|
|
15776
|
+
metadata: define2
|
|
15777
|
+
});
|
|
15778
|
+
return false;
|
|
15779
|
+
}
|
|
15780
|
+
if (key === "ListeningICAO" && setting.size > 0 && icao != null && !setting.has(icao.toLowerCase())) {
|
|
15781
|
+
setEventEmit({
|
|
15782
|
+
event: `onFilteredICAO`,
|
|
15783
|
+
metadata: define2
|
|
15784
|
+
});
|
|
15785
|
+
return false;
|
|
15786
|
+
}
|
|
15787
|
+
if (key === "IgnoredICAO" && setting.size > 0 && icao != null && setting.has(icao.toLowerCase())) {
|
|
15788
|
+
setEventEmit({
|
|
15789
|
+
event: `onIgnoredICAO`,
|
|
15790
|
+
metadata: define2
|
|
15791
|
+
});
|
|
15792
|
+
return false;
|
|
15793
|
+
}
|
|
15794
|
+
if (key === "ListeningUGC" && setting.size > 0 && zones.length > 0 && !zones.some((ugc2) => setting.has(ugc2.toLowerCase()))) {
|
|
15795
|
+
setEventEmit({
|
|
15796
|
+
event: `onFilteredUGC`,
|
|
15797
|
+
metadata: define2
|
|
15712
15798
|
});
|
|
15799
|
+
return false;
|
|
15800
|
+
}
|
|
15801
|
+
if (key === "ListeningStates" && setting.size > 0 && zones.length > 0 && !zones.some((ugc2) => setting.has(ugc2.substring(0, 2).toLowerCase()))) {
|
|
15802
|
+
setEventEmit({
|
|
15803
|
+
event: `onFilteredState`,
|
|
15804
|
+
metadata: define2
|
|
15805
|
+
});
|
|
15806
|
+
return false;
|
|
15713
15807
|
}
|
|
15714
15808
|
}
|
|
15809
|
+
return true;
|
|
15810
|
+
});
|
|
15811
|
+
if (!((_a = configurations == null ? void 0 : configurations.GlobalSettings) == null ? void 0 : _a.DisableGeometryParsing)) {
|
|
15812
|
+
for (const event of filterd) {
|
|
15813
|
+
event.geometry = yield getEventGeometry(event);
|
|
15814
|
+
}
|
|
15715
15815
|
}
|
|
15716
|
-
|
|
15816
|
+
if (filterd.length > 0) {
|
|
15817
|
+
for (const event of filterd) {
|
|
15818
|
+
yield mkEvent(event);
|
|
15819
|
+
}
|
|
15820
|
+
}
|
|
15821
|
+
yield updateNode();
|
|
15822
|
+
setEventEmit({
|
|
15823
|
+
event: `onEventCache`,
|
|
15824
|
+
metadata: bootstrap.cache.events,
|
|
15825
|
+
limited: true
|
|
15826
|
+
});
|
|
15717
15827
|
});
|
|
15718
15828
|
|
|
15719
|
-
// src/@events/events.
|
|
15720
|
-
var
|
|
15721
|
-
var _a, _b, _c
|
|
15829
|
+
// src/@events/events.text.ts
|
|
15830
|
+
var text = (stanza) => __async(null, null, function* () {
|
|
15831
|
+
var _a, _b, _c;
|
|
15722
15832
|
let processed = [];
|
|
15723
|
-
const
|
|
15724
|
-
|
|
15833
|
+
const getMessages = (_c = (_b = (_a = stanza == null ? void 0 : stanza.message) == null ? void 0 : _a.split(/(?=\$\$)/g)) == null ? void 0 : _b.map((message) => message.trim())) == null ? void 0 : _c.filter((message) => message && message !== "$$");
|
|
15834
|
+
if (!getMessages || (getMessages == null ? void 0 : getMessages.length) == 0) return;
|
|
15835
|
+
for (const message of getMessages) {
|
|
15725
15836
|
const tick = performance.now();
|
|
15726
|
-
const
|
|
15837
|
+
const attributes = stanza == null ? void 0 : stanza.attributes;
|
|
15838
|
+
const props = properties({ message, attributes });
|
|
15839
|
+
const header = getEventHeader({ properties: props, getType: stanza.getType });
|
|
15840
|
+
const issued = new Date(attributes.issue);
|
|
15841
|
+
const expires = new Date(issued.getTime() + 12 * 60 * 60 * 1e3);
|
|
15842
|
+
let event = Object.keys(dict_matches).find((event2) => message.toLowerCase().includes(event2.toLowerCase()));
|
|
15843
|
+
let isStatement = false;
|
|
15844
|
+
if (!event) {
|
|
15845
|
+
event = stanza.getType.type.split(`-`).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(` `);
|
|
15846
|
+
isStatement = true;
|
|
15847
|
+
}
|
|
15727
15848
|
processed.push({
|
|
15728
15849
|
type: `Feature`,
|
|
15729
15850
|
geometry: {
|
|
15730
15851
|
type: `Point`,
|
|
15731
15852
|
coordinates: []
|
|
15732
15853
|
},
|
|
15733
|
-
properties: {
|
|
15734
|
-
event
|
|
15735
|
-
parent:
|
|
15736
|
-
status:
|
|
15737
|
-
issued: ((
|
|
15738
|
-
expires:
|
|
15739
|
-
|
|
15740
|
-
description: (_r = (_q = feature == null ? void 0 : feature.properties) == null ? void 0 : _q.description) != null ? _r : null,
|
|
15741
|
-
attributes: (_t = (_s = feature == null ? void 0 : feature.properties) == null ? void 0 : _s.attributes) != null ? _t : {},
|
|
15742
|
-
geocode: {
|
|
15743
|
-
office: {
|
|
15744
|
-
office: pVtec ? pVtec.split(`.`)[2] : null,
|
|
15745
|
-
name: (_u = officeICAOs[pVtec ? pVtec.split(`.`)[2] : null]) != null ? _u : null
|
|
15746
|
-
},
|
|
15747
|
-
organization: (_x = (_w = (_v = feature == null ? void 0 : feature.properties) == null ? void 0 : _v.parameters) == null ? void 0 : _w.WMOidentifier) == null ? void 0 : _x[0],
|
|
15748
|
-
ugc: (_A = (_z = (_y = feature == null ? void 0 : feature.properties) == null ? void 0 : _y.geocode) == null ? void 0 : _z.UGC) != null ? _A : [],
|
|
15749
|
-
polygon: ((_B = feature == null ? void 0 : feature.geometry) == null ? void 0 : _B.coordinates.length) > 0 ? Buffer.from(JSON.stringify([(_C = feature == null ? void 0 : feature.geometry) == null ? void 0 : _C.coordinates[0]])).toString("base64") : null,
|
|
15750
|
-
polygon_generated: ((_D = feature == null ? void 0 : feature.geometry) == null ? void 0 : _D.coordinates.length) > 0 ? true : false
|
|
15751
|
-
},
|
|
15752
|
-
parameters: {
|
|
15753
|
-
tags: getEventTags((_E = feature == null ? void 0 : feature.properties) == null ? void 0 : _E.description),
|
|
15754
|
-
instructions: (_G = (_F = feature == null ? void 0 : feature.properties) == null ? void 0 : _F.instruction) != null ? _G : null,
|
|
15755
|
-
source: (_I = getTextFromProduct({ message: (_H = feature == null ? void 0 : feature.properties) == null ? void 0 : _H.description, find: [`SOURCE...`], removal: [`.`] })) != null ? _I : null,
|
|
15756
|
-
hazards: (_K = getTextFromProduct({ message: (_J = feature == null ? void 0 : feature.properties) == null ? void 0 : _J.description, find: [`HAZARD...`], removal: [`.`] })) != null ? _K : null,
|
|
15757
|
-
impacts: (_M = getTextFromProduct({ message: (_L = feature == null ? void 0 : feature.properties) == null ? void 0 : _L.description, find: [`IMPACT...`], removal: [`.`] })) != null ? _M : null,
|
|
15758
|
-
estimated_hail_size: (_Q = (_P = (_O = (_N = feature == null ? void 0 : feature.properties) == null ? void 0 : _N.parameters) == null ? void 0 : _O.maxHailSize) == null ? void 0 : _P[0]) != null ? _Q : null,
|
|
15759
|
-
estimated_wind_gusts: (_U = (_T = (_S = (_R = feature == null ? void 0 : feature.properties) == null ? void 0 : _R.parameters) == null ? void 0 : _S.maxWindGust) == null ? void 0 : _T[0]) != null ? _U : null,
|
|
15760
|
-
damage_threat: (_Y = (_X = (_W = (_V = feature == null ? void 0 : feature.properties) == null ? void 0 : _V.parameters) == null ? void 0 : _W.thunderstormDamageThreat) == null ? void 0 : _X[0]) != null ? _Y : null,
|
|
15761
|
-
tornado_threat: (_aa = (_$ = (__ = (_Z = feature == null ? void 0 : feature.properties) == null ? void 0 : _Z.parameters) == null ? void 0 : __.tornadoDetection) == null ? void 0 : _$[0]) != null ? _aa : null,
|
|
15762
|
-
flood_threat: (_ea = (_da = (_ca = (_ba = feature == null ? void 0 : feature.properties) == null ? void 0 : _ba.parameters) == null ? void 0 : _ca.floodDetection) == null ? void 0 : _da[0]) != null ? _ea : null,
|
|
15763
|
-
wind_threat: (_ia = (_ha = (_ga = (_fa = feature == null ? void 0 : feature.properties) == null ? void 0 : _fa.parameters) == null ? void 0 : _ga.windThreat) == null ? void 0 : _ha[0]) != null ? _ia : null,
|
|
15764
|
-
hail_threat: (_ma = (_la = (_ka = (_ja = feature == null ? void 0 : feature.properties) == null ? void 0 : _ja.parameters) == null ? void 0 : _ka.hailThreat) == null ? void 0 : _la[0]) != null ? _ma : null
|
|
15765
|
-
},
|
|
15766
|
-
spc_parameters: {
|
|
15767
|
-
spc_max_tornado: (_oa = getTextFromProduct({ message: (_na = feature == null ? void 0 : feature.properties) == null ? void 0 : _na.description, find: [`MOST PROBABLE PEAK TORNADO INTENSITY...`] })) != null ? _oa : null,
|
|
15768
|
-
spc_max_hail: (_qa = getTextFromProduct({ message: (_pa = feature == null ? void 0 : feature.properties) == null ? void 0 : _pa.description, find: [`MOST PROBABLE PEAK HAIL SIZE...`] })) != null ? _qa : null,
|
|
15769
|
-
spc_max_wind: (_sa = getTextFromProduct({ message: (_ra = feature == null ? void 0 : feature.properties) == null ? void 0 : _ra.description, find: [`MOST PROBABLE PEAK WIND GUST...`] })) != null ? _sa : null,
|
|
15770
|
-
spc_watch_issuance: (_ua = getTextFromProduct({ message: (_ta = feature == null ? void 0 : feature.properties) == null ? void 0 : _ta.description, find: [`Probability of Watch Issuance...`], removal: [`percent`] })) != null ? _ua : null
|
|
15771
|
-
},
|
|
15772
|
-
watch_parameters: {
|
|
15773
|
-
watch_number: (_ya = (_xa = (_wa = getTextFromProduct({ message: (_va = feature == null ? void 0 : feature.properties) == null ? void 0 : _va.description, find: [`ITIES FOR`, `UPDATE FOR`, `Watch Number `], removal: [`%`, `<`, `:`] })) == null ? void 0 : _wa.replace(/(WT|WS|)/g, "")) == null ? void 0 : _xa.trim()) != null ? _ya : null,
|
|
15774
|
-
watch_type: ((_za = feature == null ? void 0 : feature.properties) == null ? void 0 : _za.description.includes(`TORNADO WATCH`)) ? `Tornado` : ((_Aa = feature == null ? void 0 : feature.properties) == null ? void 0 : _Aa.description.includes(`SEVERE`)) ? `Severe` : null,
|
|
15775
|
-
additional_tornadoes_probability: (_Ca = getTextFromProduct({ message: (_Ba = feature == null ? void 0 : feature.properties) == null ? void 0 : _Ba.description, find: [`PROB OF 2 OR MORE TORNADOES`], removal: [`%`, `<`, `:`] })) != null ? _Ca : null,
|
|
15776
|
-
strong_tornadoes_probability: (_Ea = getTextFromProduct({ message: (_Da = feature == null ? void 0 : feature.properties) == null ? void 0 : _Da.description, find: [`PROB OF 1 OR MORE STRONG /EF2-EF5/ TORNADOES`], removal: [`%`, `<`, `:`] })) != null ? _Ea : null,
|
|
15777
|
-
severe_wind_probability: (_Ga = getTextFromProduct({ message: (_Fa = feature == null ? void 0 : feature.properties) == null ? void 0 : _Fa.description, find: [`PROB OF 10 OR MORE SEVERE WIND EVENTS`], removal: [`%`, `<`, `:`] })) != null ? _Ga : null,
|
|
15778
|
-
severe_hail_probability: (_Ia = getTextFromProduct({ message: (_Ha = feature == null ? void 0 : feature.properties) == null ? void 0 : _Ha.description, find: [`PROB OF 10 OR MORE SEVERE HAIL EVENTS`], removal: [`%`, `<`, `:`] })) != null ? _Ia : null,
|
|
15779
|
-
hail_2in_probability: (_Ka = getTextFromProduct({ message: (_Ja = feature == null ? void 0 : feature.properties) == null ? void 0 : _Ja.description, find: [`PROB OF 1 OR MORE HAIL EVENTS >= 2 INCHES`], removal: [`%`, `<`, `:`] })) != null ? _Ka : null,
|
|
15780
|
-
combined_hail_wind_probability: (_Ma = getTextFromProduct({ message: (_La = feature == null ? void 0 : feature.properties) == null ? void 0 : _La.description, find: [`PROB OF 6 OR MORE COMBINED SEVERE HAIL/WIND EVENTS`], removal: [`%`, `<`, `:`] })) != null ? _Ma : null,
|
|
15781
|
-
max_hail_in: (_Oa = getTextFromProduct({ message: (_Na = feature == null ? void 0 : feature.properties) == null ? void 0 : _Na.description, find: [`MAX HAIL /INCHES/`], removal: [`%`, `<`, `:`] })) != null ? _Oa : null,
|
|
15782
|
-
max_wind_surface: (_Qa = getTextFromProduct({ message: (_Pa = feature == null ? void 0 : feature.properties) == null ? void 0 : _Pa.description, find: [`MAX WIND GUSTS SURFACE /KNOTS/`], removal: [`%`, `<`, `:`] })) != null ? _Qa : null,
|
|
15783
|
-
max_tops_x100feet: (_Sa = getTextFromProduct({ message: (_Ra = feature == null ? void 0 : feature.properties) == null ? void 0 : _Ra.description, find: [`MAX TOPS /X 100 FEET/`], removal: [`%`, `<`, `:`] })) != null ? _Sa : null,
|
|
15784
|
-
pds_watch: getTextFromProduct({ message: (_Ta = feature == null ? void 0 : feature.properties) == null ? void 0 : _Ta.description, find: [`PARTICULARLY DANGEROUS SITUATION`], removal: [`%`, `<`, `:`] }) === `YES`
|
|
15785
|
-
},
|
|
15854
|
+
properties: __spreadProps(__spreadValues({
|
|
15855
|
+
event,
|
|
15856
|
+
parent: event,
|
|
15857
|
+
status: isStatement ? `Statement` : `Issued`,
|
|
15858
|
+
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
15859
|
+
expires: isStatement ? new Date(issued.getTime() + 120 * 1e3).toISOString() : !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
|
|
15860
|
+
}, props), {
|
|
15786
15861
|
metadata: {
|
|
15787
15862
|
ms: performance.now() - tick,
|
|
15788
|
-
source: `events.
|
|
15789
|
-
tracking: getEventTracking({ type: `
|
|
15790
|
-
header
|
|
15791
|
-
vtec:
|
|
15863
|
+
source: `events.text`,
|
|
15864
|
+
tracking: getEventTracking({ type: `RAW`, stanza, attributes, properties: props }),
|
|
15865
|
+
header,
|
|
15866
|
+
vtec: null,
|
|
15792
15867
|
hvtec: null,
|
|
15868
|
+
raw: message,
|
|
15793
15869
|
history: [
|
|
15794
15870
|
{
|
|
15795
|
-
description:
|
|
15796
|
-
issued: ((
|
|
15797
|
-
status:
|
|
15871
|
+
description: props.description,
|
|
15872
|
+
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
15873
|
+
status: `Issued`
|
|
15798
15874
|
}
|
|
15799
15875
|
]
|
|
15800
15876
|
}
|
|
15801
|
-
}
|
|
15877
|
+
})
|
|
15802
15878
|
});
|
|
15803
15879
|
}
|
|
15804
15880
|
validateEvents(processed);
|
|
15805
15881
|
});
|
|
15806
15882
|
|
|
15807
|
-
// src/@
|
|
15808
|
-
var
|
|
15809
|
-
const
|
|
15810
|
-
const
|
|
15811
|
-
const
|
|
15812
|
-
const
|
|
15813
|
-
|
|
15814
|
-
|
|
15815
|
-
if (!isNWWS) return yield api(stanza);
|
|
15816
|
-
if (!StanzaSettings.DisableVTEC && isVtecEvent) return yield vtec(stanza);
|
|
15817
|
-
if (!StanzaSettings.DisableUGC && isUgcEvent) return yield ugc(stanza);
|
|
15818
|
-
if (!StanzaSettings.DisableText && isTextEvent) return yield text(stanza);
|
|
15819
|
-
return "nothing picked";
|
|
15820
|
-
});
|
|
15883
|
+
// src/@parsers/@ugc/ugc.header.ts
|
|
15884
|
+
var getUGCHeader = (message) => {
|
|
15885
|
+
const start = message.search(dict_expressions.ugc1);
|
|
15886
|
+
const sub = message.substring(start);
|
|
15887
|
+
const end = sub.search(dict_expressions.ugc2);
|
|
15888
|
+
const fin = sub.substring(0, end).replace(/\s+/g, "").slice(0, -1);
|
|
15889
|
+
return fin != null ? fin : null;
|
|
15890
|
+
};
|
|
15821
15891
|
|
|
15822
|
-
// src/@
|
|
15823
|
-
var
|
|
15824
|
-
const
|
|
15825
|
-
|
|
15826
|
-
|
|
15827
|
-
|
|
15892
|
+
// src/@parsers/@ugc/ugc.zones.ts
|
|
15893
|
+
var getZones = (header) => {
|
|
15894
|
+
const splits = header.split("-");
|
|
15895
|
+
const zones = [];
|
|
15896
|
+
let state = splits[0].substring(0, 2);
|
|
15897
|
+
const format = splits[0].substring(2, 3);
|
|
15898
|
+
for (const part of splits) {
|
|
15899
|
+
if (/^[A-Z]/.test(part)) {
|
|
15900
|
+
state = part.substring(0, 2);
|
|
15901
|
+
if (part.includes(">")) {
|
|
15902
|
+
const [start, end] = part.split(">");
|
|
15903
|
+
const startNum = parseInt(start.substring(3), 10);
|
|
15904
|
+
const endNum = parseInt(end, 10);
|
|
15905
|
+
for (let j2 = startNum; j2 <= endNum; j2++) {
|
|
15906
|
+
zones.push(`${state}${format}${j2.toString().padStart(3, "0")}`);
|
|
15907
|
+
}
|
|
15908
|
+
} else {
|
|
15909
|
+
zones.push(part);
|
|
15910
|
+
}
|
|
15911
|
+
continue;
|
|
15828
15912
|
}
|
|
15829
|
-
|
|
15830
|
-
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15835
|
-
bootstrap.database.prepare(`DELETE FROM stanzas WHERE id IN (SELECT id FROM stanzas ORDER BY issued ASC LIMIT ?)`).run(toDelete);
|
|
15913
|
+
if (part.includes(">")) {
|
|
15914
|
+
const [start, end] = part.split(">");
|
|
15915
|
+
const startNum = parseInt(start, 10);
|
|
15916
|
+
const endNum = parseInt(end, 10);
|
|
15917
|
+
for (let j2 = startNum; j2 <= endNum; j2++) {
|
|
15918
|
+
zones.push(`${state}${format}${j2.toString().padStart(3, "0")}`);
|
|
15836
15919
|
}
|
|
15920
|
+
} else {
|
|
15921
|
+
zones.push(`${state}${format}${part}`);
|
|
15837
15922
|
}
|
|
15838
|
-
} catch (error) {
|
|
15839
|
-
setWarning({ message: `An error occurred while importing stanza: ${error.message}` });
|
|
15840
15923
|
}
|
|
15924
|
+
return zones.filter((item) => item !== "");
|
|
15925
|
+
};
|
|
15926
|
+
|
|
15927
|
+
// src/@parsers/@ugc/ugc.expiry.ts
|
|
15928
|
+
var getExpiry = (message) => {
|
|
15929
|
+
const match = message.match(/\b(\d{6})-/);
|
|
15930
|
+
if (!match) {
|
|
15931
|
+
return null;
|
|
15932
|
+
}
|
|
15933
|
+
const date = match == null ? void 0 : match[1];
|
|
15934
|
+
const day = parseInt(date == null ? void 0 : date.slice(0, 2), 10);
|
|
15935
|
+
const hour = parseInt(date == null ? void 0 : date.slice(2, 4), 10);
|
|
15936
|
+
const minute = parseInt(date == null ? void 0 : date.slice(4, 6), 10);
|
|
15937
|
+
const now = /* @__PURE__ */ new Date();
|
|
15938
|
+
const expires = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), day, hour, minute));
|
|
15939
|
+
return expires.toISOString();
|
|
15940
|
+
};
|
|
15941
|
+
|
|
15942
|
+
// src/@parsers/@ugc/ugc.locations.ts
|
|
15943
|
+
var getLocations = (zones) => __async(null, null, function* () {
|
|
15944
|
+
const sites = Array.from(new Set(zones));
|
|
15945
|
+
const placeholders = sites.map(() => "?").join(",");
|
|
15946
|
+
const rows = yield bootstrap.database.prepare(`SELECT id, location FROM shapefiles WHERE id IN (${placeholders})`).all(...sites);
|
|
15947
|
+
return rows.map((row) => row.location).sort();
|
|
15841
15948
|
});
|
|
15842
15949
|
|
|
15843
|
-
// src/@
|
|
15844
|
-
var
|
|
15845
|
-
|
|
15846
|
-
|
|
15847
|
-
|
|
15848
|
-
|
|
15849
|
-
|
|
15850
|
-
|
|
15851
|
-
|
|
15852
|
-
|
|
15853
|
-
|
|
15854
|
-
|
|
15855
|
-
|
|
15856
|
-
|
|
15857
|
-
|
|
15858
|
-
|
|
15859
|
-
|
|
15860
|
-
|
|
15861
|
-
|
|
15862
|
-
|
|
15950
|
+
// src/@parsers/@ugc/ugc.extract.ts
|
|
15951
|
+
var ugcExtract = (message) => __async(null, null, function* () {
|
|
15952
|
+
const head = getUGCHeader(message);
|
|
15953
|
+
const ugcs = getZones(head);
|
|
15954
|
+
const expires = getExpiry(message);
|
|
15955
|
+
const areas = yield getLocations(ugcs);
|
|
15956
|
+
if (!head || (ugcs == null ? void 0 : ugcs.length) == 0) return;
|
|
15957
|
+
return {
|
|
15958
|
+
zones: ugcs,
|
|
15959
|
+
locations: areas,
|
|
15960
|
+
expires
|
|
15961
|
+
};
|
|
15962
|
+
});
|
|
15963
|
+
|
|
15964
|
+
// src/@events/events.ugc.ts
|
|
15965
|
+
var ugc = (stanza) => __async(null, null, function* () {
|
|
15966
|
+
var _a, _b, _c;
|
|
15967
|
+
let processed = [];
|
|
15968
|
+
const getMessages = (_c = (_b = (_a = stanza == null ? void 0 : stanza.message) == null ? void 0 : _a.split(/(?=\$\$)/g)) == null ? void 0 : _b.map((message) => message.trim())) == null ? void 0 : _c.filter((message) => message && message !== "$$");
|
|
15969
|
+
if (!getMessages || (getMessages == null ? void 0 : getMessages.length) == 0) return;
|
|
15970
|
+
for (const message of getMessages) {
|
|
15971
|
+
const tick = performance.now();
|
|
15972
|
+
const attributes = stanza == null ? void 0 : stanza.attributes;
|
|
15973
|
+
const ugc2 = yield ugcExtract(message);
|
|
15974
|
+
if (ugc2 != null) {
|
|
15975
|
+
const props = properties({ message, attributes, ugc: ugc2 });
|
|
15976
|
+
const issued = new Date(attributes.issue);
|
|
15977
|
+
const expires = new Date(ugc2.expires);
|
|
15978
|
+
const header = getEventHeader({ properties: props, getType: stanza.getType });
|
|
15979
|
+
let event = Object.keys(dict_matches).find((event2) => message.toLowerCase().includes(event2.toLowerCase()));
|
|
15980
|
+
let isStatement = false;
|
|
15981
|
+
if (!event) {
|
|
15982
|
+
event = stanza.getType.type.split(`-`).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(` `);
|
|
15983
|
+
isStatement = true;
|
|
15863
15984
|
}
|
|
15864
|
-
|
|
15865
|
-
|
|
15866
|
-
|
|
15867
|
-
|
|
15868
|
-
|
|
15869
|
-
|
|
15870
|
-
|
|
15871
|
-
|
|
15872
|
-
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15985
|
+
processed.push({
|
|
15986
|
+
type: `Feature`,
|
|
15987
|
+
geometry: {
|
|
15988
|
+
type: `Point`,
|
|
15989
|
+
coordinates: []
|
|
15990
|
+
},
|
|
15991
|
+
properties: __spreadProps(__spreadValues({
|
|
15992
|
+
event,
|
|
15993
|
+
parent: event,
|
|
15994
|
+
status: isStatement ? `Statement` : `Issued`,
|
|
15995
|
+
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
15996
|
+
expires: isStatement ? new Date(issued.getTime() + 120 * 1e3).toISOString() : !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
|
|
15997
|
+
}, props), {
|
|
15998
|
+
metadata: {
|
|
15999
|
+
ms: performance.now() - tick,
|
|
16000
|
+
source: `events.ugc`,
|
|
16001
|
+
tracking: getEventTracking({ type: `RAW`, stanza, attributes, properties: props }),
|
|
16002
|
+
header,
|
|
16003
|
+
vtec: null,
|
|
16004
|
+
hvtec: null,
|
|
16005
|
+
raw: message,
|
|
16006
|
+
history: [
|
|
16007
|
+
{
|
|
16008
|
+
description: props.description,
|
|
16009
|
+
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
16010
|
+
status: `Issued`
|
|
16011
|
+
}
|
|
16012
|
+
]
|
|
16013
|
+
}
|
|
16014
|
+
})
|
|
15878
16015
|
});
|
|
15879
16016
|
}
|
|
15880
|
-
}));
|
|
15881
|
-
};
|
|
15882
|
-
|
|
15883
|
-
// src/@modules/@xmpp/xmpp.xDeploy.ts
|
|
15884
|
-
var xDeploy = () => __async(null, null, function* () {
|
|
15885
|
-
var _a, _b;
|
|
15886
|
-
let session;
|
|
15887
|
-
const settings = bootstrap.settings;
|
|
15888
|
-
(_b = (_a = settings.NOAAWeatherWireServiceSettings.CredentialSettings).Nickname) != null ? _b : _a.Nickname = settings.NOAAWeatherWireServiceSettings.CredentialSettings.Username;
|
|
15889
|
-
session = bootstrap.session_xmpp = client({
|
|
15890
|
-
service: "xmpp://nwws-oi.weather.gov",
|
|
15891
|
-
domain: "nwws-oi.weather.gov",
|
|
15892
|
-
username: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Username,
|
|
15893
|
-
password: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Password
|
|
15894
|
-
});
|
|
15895
|
-
try {
|
|
15896
|
-
yield xOffline();
|
|
15897
|
-
yield xError();
|
|
15898
|
-
yield xStanza();
|
|
15899
|
-
yield xOnline();
|
|
15900
|
-
yield session.start();
|
|
15901
|
-
} catch (error) {
|
|
15902
|
-
setEventEmit({
|
|
15903
|
-
event: `onServiceStatus`,
|
|
15904
|
-
metadata: {
|
|
15905
|
-
message: `Error occured while starting XMPP Session: ${error}`,
|
|
15906
|
-
data: {},
|
|
15907
|
-
type: `error`,
|
|
15908
|
-
error: true
|
|
15909
|
-
}
|
|
15910
|
-
});
|
|
15911
16017
|
}
|
|
16018
|
+
validateEvents(processed);
|
|
15912
16019
|
});
|
|
15913
16020
|
|
|
15914
|
-
// src/@
|
|
15915
|
-
var
|
|
15916
|
-
|
|
15917
|
-
|
|
15918
|
-
|
|
15919
|
-
|
|
15920
|
-
|
|
15921
|
-
|
|
15922
|
-
|
|
15923
|
-
|
|
15924
|
-
|
|
15925
|
-
|
|
15926
|
-
|
|
15927
|
-
|
|
15928
|
-
|
|
15929
|
-
|
|
15930
|
-
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
|
|
15934
|
-
|
|
15935
|
-
|
|
15936
|
-
|
|
15937
|
-
|
|
15938
|
-
|
|
15939
|
-
|
|
15940
|
-
|
|
15941
|
-
|
|
15942
|
-
|
|
15943
|
-
|
|
15944
|
-
|
|
15945
|
-
|
|
15946
|
-
|
|
15947
|
-
|
|
15948
|
-
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
|
|
15952
|
-
|
|
15953
|
-
|
|
15954
|
-
|
|
15955
|
-
|
|
15956
|
-
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
|
|
15961
|
-
|
|
15962
|
-
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
15977
|
-
|
|
15978
|
-
var _a2, _b2, _c;
|
|
15979
|
-
for (const entry of entries) {
|
|
15980
|
-
const { properties: properties2, geometry } = entry;
|
|
15981
|
-
let final2, location;
|
|
15982
|
-
if (properties2.FIPS) {
|
|
15983
|
-
final2 = `${properties2.STATE}${shapefile.id}${properties2.FIPS.substring(2)}`;
|
|
15984
|
-
location = `${properties2.COUNTYNAME}, ${properties2.STATE}`;
|
|
15985
|
-
} else if (properties2.FULLSTAID) {
|
|
15986
|
-
final2 = `${properties2.ST}${shapefile.id}${properties2.WFO}`;
|
|
15987
|
-
location = `${properties2.CITY}, ${properties2.STATE}`;
|
|
15988
|
-
} else if (properties2.STATE) {
|
|
15989
|
-
final2 = `${properties2.STATE}${shapefile.id}${(_a2 = properties2.ZONE) != null ? _a2 : properties2.SITE_ID}`;
|
|
15990
|
-
location = `${(_b2 = properties2.NAME) != null ? _b2 : `${properties2.RFC_NAME} ${properties2.RFC_CITY}`}, ${properties2.STATE}`;
|
|
15991
|
-
} else {
|
|
15992
|
-
final2 = (_c = properties2.ID) != null ? _c : properties2.WFO;
|
|
15993
|
-
location = properties2.NAME;
|
|
15994
|
-
}
|
|
15995
|
-
insert.run(final2, location, JSON.stringify(geometry));
|
|
15996
|
-
}
|
|
15997
|
-
});
|
|
15998
|
-
import_fs.default.unlinkSync(`${filepath}.shp`);
|
|
15999
|
-
import_fs.default.unlinkSync(`${filepath}.dbf`);
|
|
16000
|
-
setWarning({ message: `Cleaned up temporary files for ${shapefile.name}_${shapefile.id}` });
|
|
16001
|
-
transaction(features);
|
|
16002
|
-
}
|
|
16003
|
-
setWarning({ message: `Shapefiles have finished compiling, you can now continue and close this terminal` });
|
|
16004
|
-
import_fs.default.rm((0, import_path2.resolve)(__dirname, "../../shapefiles"), { recursive: true, force: true }, () => {
|
|
16005
|
-
});
|
|
16006
|
-
}
|
|
16007
|
-
} catch (error) {
|
|
16008
|
-
setWarning({ message: `An error occurred while compiling shapefiles: ${error.message}` });
|
|
16009
|
-
}
|
|
16010
|
-
});
|
|
16011
|
-
|
|
16012
|
-
// src/@modules/@database/database.init.ts
|
|
16013
|
-
var initializeDatabase = () => __async(null, null, function* () {
|
|
16014
|
-
const settings = bootstrap.settings;
|
|
16015
|
-
try {
|
|
16016
|
-
if (!import_fs2.default.existsSync(settings.Database)) {
|
|
16017
|
-
import_fs2.default.writeFileSync(settings.Database, "");
|
|
16018
|
-
setWarning({ message: `Creating new database at ${settings.Database}` });
|
|
16019
|
-
}
|
|
16020
|
-
bootstrap.database = new import_better_sqlite3.default(settings.Database);
|
|
16021
|
-
bootstrap.database.prepare(`CREATE TABLE IF NOT EXISTS stanzas ( id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, issued TEXT, stanza TEXT )`).run();
|
|
16022
|
-
bootstrap.database.prepare(`CREATE TABLE IF NOT EXISTS shapefiles (id TEXT PRIMARY KEY, location TEXT, geometry TEXT)`).run();
|
|
16023
|
-
yield importShapefiles();
|
|
16024
|
-
} catch (error) {
|
|
16025
|
-
setWarning({ message: `An error occurred while initializing the database: ${error.message}` });
|
|
16026
|
-
}
|
|
16027
|
-
});
|
|
16028
|
-
|
|
16029
|
-
// src/@modules/@database/database.cache.ts
|
|
16030
|
-
var getCachedEvents = () => __async(null, null, function* () {
|
|
16031
|
-
var _a;
|
|
16032
|
-
try {
|
|
16033
|
-
const settings = bootstrap.settings;
|
|
16034
|
-
const tick = performance.now();
|
|
16035
|
-
if (settings.NOAAWeatherWireServiceSettings.CacheSettings.Enabled) {
|
|
16036
|
-
const max = (_a = settings.NOAAWeatherWireServiceSettings.CacheSettings.MaxRetentionHistory) != null ? _a : 500;
|
|
16037
|
-
const get = yield bootstrap.database.prepare(`SELECT * FROM stanzas ORDER BY rowid DESC LIMIT ?`).all(max);
|
|
16038
|
-
setWarning({ message: `Fetched ${get.length} cached events from the database in ${Math.floor(performance.now() - tick)} ms` });
|
|
16039
|
-
let events = get.map((row) => JSON.parse(row.stanza)).filter((stanza) => {
|
|
16040
|
-
if (!stanza) {
|
|
16041
|
-
return;
|
|
16042
|
-
}
|
|
16043
|
-
const isSkippable = stanza.isIgnored || stanza.isCapEvent || stanza.isCapEvent && !stanza.isCapAreaDescription;
|
|
16044
|
-
return !isSkippable;
|
|
16045
|
-
});
|
|
16046
|
-
events = events.sort((a, b) => b.issued - a.issued);
|
|
16047
|
-
yield Promise.all(events.map((event) => createEvent(event)));
|
|
16048
|
-
setWarning({ message: `Processed ${events.length} cached events in ${Math.floor(performance.now() - tick)} ms` });
|
|
16049
|
-
}
|
|
16050
|
-
} catch (error) {
|
|
16051
|
-
setWarning({ message: `An error occurred while fetching cached events: ${error.message} -> ${error.stack}` });
|
|
16052
|
-
}
|
|
16053
|
-
});
|
|
16054
|
-
|
|
16055
|
-
// src/@modules/@xmpp/xmpp.xReconnect.ts
|
|
16056
|
-
var xReconnect = (interval) => __async(null, null, function* () {
|
|
16057
|
-
const settings = bootstrap.settings;
|
|
16058
|
-
const lastStanza = Date.now() - bootstrap.cache.lastStanza;
|
|
16059
|
-
if (interval < 15) {
|
|
16060
|
-
setWarning({ message: `Reconnection interval of ${interval} seconds is too low, setting to 15 seconds` });
|
|
16061
|
-
interval = 15;
|
|
16062
|
-
bootstrap.settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.ReconnectionInterval = 15;
|
|
16063
|
-
}
|
|
16064
|
-
const reconnectThreshold = interval * 1e3;
|
|
16065
|
-
if (!bootstrap.cache.isConnected && !bootstrap.cache.sigHault || !bootstrap.session_xmpp) {
|
|
16066
|
-
return;
|
|
16067
|
-
}
|
|
16068
|
-
if (lastStanza > reconnectThreshold) {
|
|
16069
|
-
if (!bootstrap.cache.isReconnecting) {
|
|
16070
|
-
bootstrap.cache.isReconnecting = true;
|
|
16071
|
-
bootstrap.cache.isConnected = false;
|
|
16072
|
-
bootstrap.cache.tReconnects += 1;
|
|
16073
|
-
try {
|
|
16074
|
-
setEventEmit({
|
|
16075
|
-
event: `onServiceStatus`,
|
|
16076
|
-
metadata: {
|
|
16077
|
-
message: `Attempting to reconnect to XMPP Service (Reconnect Attempt ${bootstrap.cache.tReconnects})`,
|
|
16078
|
-
data: {
|
|
16079
|
-
last_stanza: lastStanza,
|
|
16080
|
-
nickname: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Nickname
|
|
16081
|
-
},
|
|
16082
|
-
type: `reconnect`,
|
|
16083
|
-
error: true
|
|
16084
|
-
}
|
|
16085
|
-
});
|
|
16086
|
-
yield bootstrap.session_xmpp.stop().catch(() => {
|
|
16087
|
-
});
|
|
16088
|
-
yield bootstrap.session_xmpp.start().catch(() => {
|
|
16089
|
-
});
|
|
16090
|
-
} catch (error) {
|
|
16091
|
-
setWarning({ message: `XMPP Reconnect Failed - ${error.message}` });
|
|
16092
|
-
} finally {
|
|
16093
|
-
bootstrap.cache.isReconnecting = false;
|
|
16094
|
-
}
|
|
16095
|
-
}
|
|
16096
|
-
}
|
|
16097
|
-
});
|
|
16098
|
-
|
|
16099
|
-
// src/@modules/@utilities/utilities.setCronSchedule.ts
|
|
16100
|
-
var setCronSchedule = () => __async(null, null, function* () {
|
|
16101
|
-
const settings = bootstrap.settings;
|
|
16102
|
-
if (settings.EnableWireService) {
|
|
16103
|
-
if (settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.Enabled) {
|
|
16104
|
-
void xReconnect(settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.ReconnectionInterval);
|
|
16105
|
-
}
|
|
16106
|
-
} else {
|
|
16107
|
-
const response2 = yield createHttp({
|
|
16108
|
-
url: settings.NationalWeatherServiceSettings.EventsEndpoint,
|
|
16109
|
-
headers: {
|
|
16110
|
-
"User-Agent": "@atmosx/event-product-parser"
|
|
16111
|
-
}
|
|
16112
|
-
});
|
|
16113
|
-
if (response2.error) {
|
|
16114
|
-
return setEventEmit({
|
|
16115
|
-
event: `onServiceStatus`,
|
|
16116
|
-
metadata: {
|
|
16117
|
-
type: "fetch-api",
|
|
16118
|
-
message: `Failed to fetch latest events from National Weather Service API - ${response2.message}`,
|
|
16119
|
-
data: {},
|
|
16120
|
-
error: true
|
|
16121
|
-
}
|
|
16122
|
-
});
|
|
16123
|
-
}
|
|
16124
|
-
setEventEmit({
|
|
16125
|
-
event: `onServiceStatus`,
|
|
16126
|
-
metadata: {
|
|
16127
|
-
message: `Fetched latest events from National Weather Service API`,
|
|
16128
|
-
data: {},
|
|
16129
|
-
type: "fetch-api",
|
|
16130
|
-
error: false
|
|
16131
|
-
}
|
|
16132
|
-
});
|
|
16133
|
-
createEvent({ message: response2.message, isNWWS: false });
|
|
16134
|
-
}
|
|
16135
|
-
});
|
|
16136
|
-
|
|
16137
|
-
// src/@manager/manager.updateEvents.ts
|
|
16138
|
-
var updateEvents = (selectedEvent) => __async(null, null, function* () {
|
|
16139
|
-
const events = bootstrap.cache.events.features;
|
|
16140
|
-
function update(evt) {
|
|
16141
|
-
return __async(this, null, function* () {
|
|
16142
|
-
if (new Date(evt.properties.expires) < /* @__PURE__ */ new Date()) {
|
|
16143
|
-
rmEvent(evt);
|
|
16144
|
-
}
|
|
16145
|
-
});
|
|
16146
|
-
}
|
|
16147
|
-
if (!selectedEvent) {
|
|
16148
|
-
yield Promise.all(events.map((evt) => __async(null, null, function* () {
|
|
16149
|
-
yield update(evt);
|
|
16150
|
-
})));
|
|
16151
|
-
}
|
|
16152
|
-
if (selectedEvent) {
|
|
16153
|
-
yield update(selectedEvent);
|
|
16154
|
-
}
|
|
16155
|
-
});
|
|
16156
|
-
|
|
16157
|
-
// src/@core/core.start.ts
|
|
16158
|
-
var import_croner = require("croner");
|
|
16159
|
-
var startService = (configurations) => __async(null, null, function* () {
|
|
16160
|
-
if (!bootstrap.isReady) {
|
|
16161
|
-
return setWarning({
|
|
16162
|
-
message: `You can not create another instance without shutting down the current one first, please make sure to call the stop() method first!`
|
|
16163
|
-
});
|
|
16164
|
-
}
|
|
16165
|
-
const settings = setSettings(configurations);
|
|
16166
|
-
bootstrap.isReady = true;
|
|
16167
|
-
yield initializeDatabase();
|
|
16168
|
-
if (settings.EnableWireService) {
|
|
16169
|
-
(() => __async(null, null, function* () {
|
|
16170
|
-
yield getCachedEvents();
|
|
16171
|
-
yield xDeploy();
|
|
16172
|
-
}))();
|
|
16173
|
-
}
|
|
16174
|
-
yield setCronSchedule();
|
|
16175
|
-
let scheduleInterval = !settings.EnableWireService ? settings.NationalWeatherServiceSettings.CallbackInterval : 1;
|
|
16176
|
-
if (!settings.EnableWireService && scheduleInterval < 15) {
|
|
16177
|
-
setWarning({ message: `Schedule interval of ${scheduleInterval} seconds is too low, setting to 15 seconds` });
|
|
16178
|
-
bootstrap.settings.NationalWeatherServiceSettings.CallbackInterval = 15;
|
|
16179
|
-
scheduleInterval = 15;
|
|
16180
|
-
}
|
|
16181
|
-
bootstrap.cron = new import_croner.Cron(`*/${scheduleInterval} * * * * *`, () => __async(null, null, function* () {
|
|
16182
|
-
yield setCronSchedule();
|
|
16183
|
-
}));
|
|
16184
|
-
bootstrap.cron = new import_croner.Cron(`* * * * * *`, () => __async(null, null, function* () {
|
|
16185
|
-
yield updateNode();
|
|
16186
|
-
yield updateEvents();
|
|
16187
|
-
}));
|
|
16188
|
-
});
|
|
16021
|
+
// src/@dictionaries/dictionaries.events.ts
|
|
16022
|
+
var dict_events = {
|
|
16023
|
+
"AF": "Ashfall",
|
|
16024
|
+
"AS": "Air Stagnation",
|
|
16025
|
+
"BH": "Beach Hazard",
|
|
16026
|
+
"BW": "Brisk Wind",
|
|
16027
|
+
"BZ": "Blizzard",
|
|
16028
|
+
"CF": "Coastal Flood",
|
|
16029
|
+
"DF": "Debris Flow",
|
|
16030
|
+
"DS": "Dust Storm",
|
|
16031
|
+
"EC": "Extreme Cold",
|
|
16032
|
+
"EH": "Excessive Heat",
|
|
16033
|
+
"XH": "Extreme Heat",
|
|
16034
|
+
"EW": "Extreme Wind",
|
|
16035
|
+
"FA": "Areal Flood",
|
|
16036
|
+
"FF": "Flash Flood",
|
|
16037
|
+
"FG": "Dense Fog",
|
|
16038
|
+
"FL": "Flood",
|
|
16039
|
+
"FR": "Frost",
|
|
16040
|
+
"FW": "Fire Weather",
|
|
16041
|
+
"FZ": "Freeze",
|
|
16042
|
+
"GL": "Gale",
|
|
16043
|
+
"HF": "Hurricane Force Wind",
|
|
16044
|
+
"HT": "Heat",
|
|
16045
|
+
"HU": "Hurricane",
|
|
16046
|
+
"HW": "High Wind",
|
|
16047
|
+
"HY": "Hydrologic",
|
|
16048
|
+
"HZ": "Hard Freeze",
|
|
16049
|
+
"IS": "Ice Storm",
|
|
16050
|
+
"LE": "Lake Effect Snow",
|
|
16051
|
+
"LO": "Low Water",
|
|
16052
|
+
"LS": "Lakeshore Flood",
|
|
16053
|
+
"LW": "Lake Wind",
|
|
16054
|
+
"MA": "Special Marine",
|
|
16055
|
+
"EQ": "Earthquake",
|
|
16056
|
+
"MF": "Dense Fog",
|
|
16057
|
+
"MH": "Ashfall",
|
|
16058
|
+
"MS": "Dense Smoke",
|
|
16059
|
+
"RB": "Small Craft for Rough Bar",
|
|
16060
|
+
"RP": "Rip Current Risk",
|
|
16061
|
+
"SC": "Small Craft",
|
|
16062
|
+
"SE": "Hazardous Seas",
|
|
16063
|
+
"SI": "Small Craft for Winds",
|
|
16064
|
+
"SM": "Dense Smoke",
|
|
16065
|
+
"SQ": "Snow Squall",
|
|
16066
|
+
"SR": "Storm",
|
|
16067
|
+
"SS": "Storm Surge",
|
|
16068
|
+
"SU": "High Surf",
|
|
16069
|
+
"SV": "Severe Thunderstorm",
|
|
16070
|
+
"SW": "Small Craft for Hazardous Seas",
|
|
16071
|
+
"TO": "Tornado",
|
|
16072
|
+
"TR": "Tropical Storm",
|
|
16073
|
+
"TS": "Tsunami",
|
|
16074
|
+
"TY": "Typhoon",
|
|
16075
|
+
"SP": "Special Weather",
|
|
16076
|
+
"UP": "Heavy Freezing Spray",
|
|
16077
|
+
"WC": "Wind Chill",
|
|
16078
|
+
"WI": "Wind",
|
|
16079
|
+
"WS": "Winter Storm",
|
|
16080
|
+
"WW": "Winter Weather",
|
|
16081
|
+
"ZF": "Freezing Fog",
|
|
16082
|
+
"ZR": "Freezing Rain",
|
|
16083
|
+
"ZY": "Freezing Spray"
|
|
16084
|
+
};
|
|
16189
16085
|
|
|
16190
|
-
// src/@
|
|
16191
|
-
var
|
|
16192
|
-
|
|
16193
|
-
|
|
16194
|
-
|
|
16195
|
-
|
|
16196
|
-
|
|
16197
|
-
|
|
16198
|
-
|
|
16199
|
-
|
|
16200
|
-
bootstrap.cache.sigHault = true;
|
|
16201
|
-
bootstrap.session_xmpp = null;
|
|
16202
|
-
}
|
|
16203
|
-
}
|
|
16204
|
-
});
|
|
16086
|
+
// src/@dictionaries/dictionaries.actions.ts
|
|
16087
|
+
var dict_actions = {
|
|
16088
|
+
"W": "Warning",
|
|
16089
|
+
"F": "Forecast",
|
|
16090
|
+
"A": "Watch",
|
|
16091
|
+
"O": "Outlook",
|
|
16092
|
+
"Y": "Advisory",
|
|
16093
|
+
"N": "Synopsis",
|
|
16094
|
+
"S": "Statement"
|
|
16095
|
+
};
|
|
16205
16096
|
|
|
16206
|
-
// src/@dictionaries/dictionaries.
|
|
16207
|
-
var
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
16212
|
-
|
|
16213
|
-
|
|
16214
|
-
|
|
16215
|
-
|
|
16216
|
-
|
|
16217
|
-
|
|
16218
|
-
|
|
16219
|
-
{ regex: /\bPDT\b(?!\w)/g, replacement: "Pacific Daylight Time" },
|
|
16220
|
-
{ regex: /\bAKST\b(?!\w)/g, replacement: "Alaska Standard Time" },
|
|
16221
|
-
{ regex: /\bAKDT\b(?!\w)/g, replacement: "Alaska Daylight Time" },
|
|
16222
|
-
{ regex: /\bHST\b(?!\w)/g, replacement: "Hawaii Standard Time" },
|
|
16223
|
-
{ regex: /\bHDT\b(?!\w)/g, replacement: "Hawaii Daylight Time" },
|
|
16224
|
-
{ regex: /\bmph\b(?!\w)/g, replacement: "miles per hour" },
|
|
16225
|
-
{ regex: /\bkm\/h\b(?!\w)/g, replacement: "kilometers per hour" },
|
|
16226
|
-
{ regex: /\bkmh\b(?!\w)/g, replacement: "kilometers per hour" },
|
|
16227
|
-
{ regex: /\bkt\b(?!\w)/g, replacement: "knots" },
|
|
16228
|
-
{ regex: /\bNE\b(?!\w)/g, replacement: "northeast" },
|
|
16229
|
-
{ regex: /\bNW\b(?!\w)/g, replacement: "northwest" },
|
|
16230
|
-
{ regex: /\bSE\b(?!\w)/g, replacement: "southeast" },
|
|
16231
|
-
{ regex: /\bSW\b(?!\w)/g, replacement: "southwest" },
|
|
16232
|
-
{ regex: /\bNM\b(?!\w)/g, replacement: "nautical miles" },
|
|
16233
|
-
{ regex: /\bdeg\b(?!\w)/g, replacement: "degrees" },
|
|
16234
|
-
{ regex: /\btstm\b(?!\w)/g, replacement: "thunderstorm" },
|
|
16235
|
-
{ regex: /\bmm\b(?!\w)/g, replacement: "millimeters" },
|
|
16236
|
-
{ regex: /\bcm\b(?!\w)/g, replacement: "centimeters" },
|
|
16237
|
-
{ regex: /\bin.\b(?!\w)/g, replacement: "inches" },
|
|
16238
|
-
{ regex: /\bft\b(?!\w)/g, replacement: "feet" },
|
|
16239
|
-
{ regex: /\bmi\b(?!\w)/g, replacement: "miles" },
|
|
16240
|
-
{ regex: /\bhr\b(?!\w)/g, replacement: "hour" },
|
|
16241
|
-
{ regex: /\bhourly\b(?!\w)/g, replacement: "per hour" },
|
|
16242
|
-
{ regex: /\bkg\b(?!\w)/g, replacement: "kilograms" },
|
|
16243
|
-
{ regex: /\bg\/kg\b(?!\w)/g, replacement: "grams per kilogram" },
|
|
16244
|
-
{ regex: /\bmb\b(?!\w)/g, replacement: "millibars" },
|
|
16245
|
-
{ regex: /\bhPa\b(?!\w)/g, replacement: "hectopascals" },
|
|
16246
|
-
{ regex: /\bPa\b(?!\w)/g, replacement: "pascals" },
|
|
16247
|
-
{ regex: /\bKPa\b(?!\w)/g, replacement: "kilopascals" },
|
|
16248
|
-
{ regex: /\bC\/hr\b(?!\w)/g, replacement: "degrees Celsius per hour" },
|
|
16249
|
-
{ regex: /\bF\/hr\b(?!\w)/g, replacement: "degrees Fahrenheit per hour" },
|
|
16250
|
-
{ regex: /\bC\/min\b(?!\w)/g, replacement: "degrees Celsius per minute" },
|
|
16251
|
-
{ regex: /\bF\/min\b(?!\w)/g, replacement: "degrees Fahrenheit per minute" },
|
|
16252
|
-
{ regex: /\bC\b(?!\w)/g, replacement: "degrees Celsius" },
|
|
16253
|
-
{ regex: /\bF\b(?!\w)/g, replacement: "degrees Fahrenheit" }
|
|
16254
|
-
];
|
|
16097
|
+
// src/@dictionaries/dictionaries.status.ts
|
|
16098
|
+
var dict_status = {
|
|
16099
|
+
"NEW": "Issued",
|
|
16100
|
+
"CON": "Updated",
|
|
16101
|
+
"EXT": "Extended",
|
|
16102
|
+
"EXA": "Extended",
|
|
16103
|
+
"EXB": "Extended",
|
|
16104
|
+
"UPG": "Upgraded",
|
|
16105
|
+
"COR": "Correction",
|
|
16106
|
+
"ROU": "Routine",
|
|
16107
|
+
"CAN": "Cancelled",
|
|
16108
|
+
"EXP": "Expired"
|
|
16109
|
+
};
|
|
16255
16110
|
|
|
16256
|
-
// src/@
|
|
16257
|
-
var
|
|
16258
|
-
if (
|
|
16259
|
-
|
|
16260
|
-
|
|
16261
|
-
|
|
16262
|
-
|
|
16263
|
-
let i = 12;
|
|
16264
|
-
while (i + 8 <= buffer.length) {
|
|
16265
|
-
const id2 = buffer.toString("ascii", i, i + 4);
|
|
16266
|
-
const size = buffer.readUInt32LE(i + 4);
|
|
16267
|
-
const start = i + 8;
|
|
16268
|
-
const end = start + size;
|
|
16269
|
-
if (id2 === "fmt ") fmt = buffer.slice(start, end);
|
|
16270
|
-
if (id2 === "data") data = buffer.slice(start, end);
|
|
16271
|
-
i = end + size % 2;
|
|
16272
|
-
}
|
|
16273
|
-
if (!fmt || !data) return null;
|
|
16274
|
-
const audioFormat = fmt.readUInt16LE(0);
|
|
16275
|
-
const channels = fmt.readUInt16LE(2);
|
|
16276
|
-
const sampleRate = fmt.readUInt32LE(4);
|
|
16277
|
-
const bitsPerSample = fmt.readUInt16LE(14);
|
|
16278
|
-
if (audioFormat !== 1 || bitsPerSample !== 16 || channels !== 1) {
|
|
16279
|
-
return null;
|
|
16280
|
-
}
|
|
16281
|
-
const samples = new Int16Array(data.buffer, data.byteOffset, data.length / 2);
|
|
16282
|
-
return { samples: new Int16Array(samples), sampleRate, channels, bitsPerSample };
|
|
16111
|
+
// src/@parsers/@pvtec/pvtec.expires.ts
|
|
16112
|
+
var getExpiry2 = (dates) => {
|
|
16113
|
+
if ((dates == null ? void 0 : dates[1]) == `000000T0000Z`) return "Invalid Date Format";
|
|
16114
|
+
const expires = `${(/* @__PURE__ */ new Date()).getFullYear().toString().substring(0, 2)}${dates[1].substring(0, 2)}-${dates[1].substring(2, 4)}-${dates[1].substring(4, 6)}T${dates[1].substring(7, 9)}:${dates[1].substring(9, 11)}:00`;
|
|
16115
|
+
const local = new Date(new Date(expires).getTime() - 4 * 60 * 6e4);
|
|
16116
|
+
const pad = (n) => n.toString().padStart(2, "0");
|
|
16117
|
+
return `${local.getFullYear()}-${pad(local.getMonth() + 1)}-${pad(local.getDate())}T${pad(local.getHours())}:${pad(local.getMinutes())}:00.000-04:00`;
|
|
16283
16118
|
};
|
|
16284
16119
|
|
|
16285
|
-
// src/@
|
|
16286
|
-
var
|
|
16287
|
-
|
|
16288
|
-
|
|
16289
|
-
const
|
|
16290
|
-
const
|
|
16291
|
-
for (
|
|
16292
|
-
const
|
|
16293
|
-
|
|
16294
|
-
const
|
|
16295
|
-
|
|
16296
|
-
|
|
16297
|
-
|
|
16120
|
+
// src/@parsers/@pvtec/pvtec.extract.ts
|
|
16121
|
+
var pvExtract = (message) => {
|
|
16122
|
+
var _a, _b, _c, _d;
|
|
16123
|
+
if (!message) return null;
|
|
16124
|
+
const getVTECs = (_a = message.match(dict_expressions.pvtec)) != null ? _a : [];
|
|
16125
|
+
const vtecs = [];
|
|
16126
|
+
for (const vtec2 of getVTECs) {
|
|
16127
|
+
const sub = vtec2.split(`.`);
|
|
16128
|
+
if ((sub == null ? void 0 : sub.length) < 7) continue;
|
|
16129
|
+
const dates = (_b = sub[6]) == null ? void 0 : _b.split(`-`);
|
|
16130
|
+
vtecs.push({
|
|
16131
|
+
vtec: vtec2,
|
|
16132
|
+
product: dict_products[sub[0]],
|
|
16133
|
+
tracking: `${sub[2]}.${sub[3]}.${sub[4]}.${sub[5]}`,
|
|
16134
|
+
event: `${dict_events[sub[3]]} ${dict_actions[sub[4]]}`,
|
|
16135
|
+
status: dict_status[sub[1]],
|
|
16136
|
+
organization: (_d = (_c = message.match(dict_expressions.wmo)) == null ? void 0 : _c[0]) != null ? _d : null,
|
|
16137
|
+
expires: getExpiry2(dates),
|
|
16138
|
+
is_watch: (sub[4] == `A` || sub[4] == `Y`) && (sub[3] == `TO` || sub[3] == `SV`),
|
|
16139
|
+
prediction_center: sub[2] == `KWNS` ? true : false
|
|
16140
|
+
});
|
|
16298
16141
|
}
|
|
16299
|
-
return
|
|
16142
|
+
return vtecs.length > 0 ? vtecs : null;
|
|
16300
16143
|
};
|
|
16301
16144
|
|
|
16302
|
-
// src/@
|
|
16303
|
-
var
|
|
16304
|
-
|
|
16305
|
-
|
|
16306
|
-
|
|
16145
|
+
// src/@dictionaries/dictionaries.causes.ts
|
|
16146
|
+
var dict_causes = {
|
|
16147
|
+
"SM": "Snow Melt",
|
|
16148
|
+
"RS": "Rain/Snow Melt",
|
|
16149
|
+
"ER": "Excessive Rain",
|
|
16150
|
+
"DM": "Dam/Levee Failure",
|
|
16151
|
+
"IJ": "Ice Jam",
|
|
16152
|
+
"GO": "Glacier Lake Outburst",
|
|
16153
|
+
"IC": "Ice",
|
|
16154
|
+
"FS": "Flash Flood / Storm Surge",
|
|
16155
|
+
"FT": "Tidal Effects",
|
|
16156
|
+
"ET": "Elevated Upstream Flow",
|
|
16157
|
+
"MC": "Other Multiple Causes",
|
|
16158
|
+
"WT": "Wind and/or Tidal Effects",
|
|
16159
|
+
"DR": "Reservoir Release",
|
|
16160
|
+
"UU": "Unknown",
|
|
16161
|
+
"OT": "Other Effects"
|
|
16307
16162
|
};
|
|
16308
16163
|
|
|
16309
|
-
// src/@
|
|
16310
|
-
var
|
|
16311
|
-
|
|
16312
|
-
|
|
16313
|
-
|
|
16314
|
-
|
|
16315
|
-
}
|
|
16316
|
-
return out;
|
|
16164
|
+
// src/@dictionaries/dictionaries.records.ts
|
|
16165
|
+
var dict_records = {
|
|
16166
|
+
"NO": "No Record Expected",
|
|
16167
|
+
"NR": "Near Record or possible record",
|
|
16168
|
+
"UU": "Unknown history of records",
|
|
16169
|
+
"OO": "Other"
|
|
16317
16170
|
};
|
|
16318
16171
|
|
|
16319
|
-
// src/@
|
|
16320
|
-
var
|
|
16321
|
-
|
|
16322
|
-
|
|
16323
|
-
|
|
16324
|
-
|
|
16325
|
-
|
|
16326
|
-
|
|
16327
|
-
|
|
16328
|
-
|
|
16329
|
-
|
|
16330
|
-
|
|
16331
|
-
|
|
16332
|
-
|
|
16333
|
-
|
|
16334
|
-
|
|
16335
|
-
|
|
16336
|
-
|
|
16337
|
-
|
|
16338
|
-
|
|
16339
|
-
|
|
16172
|
+
// src/@dictionaries/dictionaries.severity.ts
|
|
16173
|
+
var dict_severity = {
|
|
16174
|
+
N: "Not Expected",
|
|
16175
|
+
0: "Areal Flood or FF Product",
|
|
16176
|
+
1: "Minor",
|
|
16177
|
+
2: "Moderate",
|
|
16178
|
+
3: "Major",
|
|
16179
|
+
U: "Unknown"
|
|
16180
|
+
};
|
|
16181
|
+
|
|
16182
|
+
// src/@parsers/@hvtec/hvtec.extract.ts
|
|
16183
|
+
var hvExtract = (message) => {
|
|
16184
|
+
var _a;
|
|
16185
|
+
const getHVTECs = (_a = message.match(dict_expressions.hvtec)) != null ? _a : [];
|
|
16186
|
+
const vtecs = [];
|
|
16187
|
+
for (const vtec2 of getHVTECs) {
|
|
16188
|
+
const sub = vtec2.split(`.`);
|
|
16189
|
+
if (sub.length < 7) continue;
|
|
16190
|
+
vtecs.push({
|
|
16191
|
+
hvtec: vtec2,
|
|
16192
|
+
severity: dict_severity[sub[1]],
|
|
16193
|
+
cause: dict_causes[sub[2]],
|
|
16194
|
+
record: dict_records[sub[6]]
|
|
16195
|
+
});
|
|
16340
16196
|
}
|
|
16341
|
-
|
|
16342
|
-
const norm = Math.tanh(compGain);
|
|
16343
|
-
for (let i = 0; i < x.length; i++) x[i] = Math.tanh(x[i] * compGain) / norm;
|
|
16344
|
-
return getFloatPCM16(x);
|
|
16197
|
+
return vtecs.length > 0 ? vtecs : null;
|
|
16345
16198
|
};
|
|
16346
16199
|
|
|
16347
|
-
// src/@
|
|
16348
|
-
var
|
|
16349
|
-
|
|
16350
|
-
|
|
16351
|
-
const
|
|
16352
|
-
|
|
16353
|
-
const
|
|
16354
|
-
|
|
16355
|
-
|
|
16356
|
-
|
|
16357
|
-
|
|
16358
|
-
const
|
|
16359
|
-
|
|
16360
|
-
|
|
16361
|
-
|
|
16362
|
-
|
|
16363
|
-
|
|
16364
|
-
|
|
16365
|
-
|
|
16366
|
-
|
|
16367
|
-
|
|
16200
|
+
// src/@events/events.vtec.ts
|
|
16201
|
+
var vtec = (stanza) => __async(null, null, function* () {
|
|
16202
|
+
var _a, _b, _c, _d, _e;
|
|
16203
|
+
let processed = [];
|
|
16204
|
+
const getMessages = (_c = (_b = (_a = stanza == null ? void 0 : stanza.message) == null ? void 0 : _a.split(/(?=\$\$)/g)) == null ? void 0 : _b.map((message) => message.trim())) == null ? void 0 : _c.filter((message) => message && message !== "$$");
|
|
16205
|
+
if (!getMessages || (getMessages == null ? void 0 : getMessages.length) == 0) return;
|
|
16206
|
+
for (const message of getMessages) {
|
|
16207
|
+
const tick = performance.now();
|
|
16208
|
+
const attributes = stanza == null ? void 0 : stanza.attributes;
|
|
16209
|
+
const pVtec = pvExtract(message);
|
|
16210
|
+
const hVtec = hvExtract(message);
|
|
16211
|
+
const ugc2 = yield ugcExtract(message);
|
|
16212
|
+
if (pVtec != null && ugc2 != null) {
|
|
16213
|
+
for (const pv of pVtec) {
|
|
16214
|
+
const vtec2 = pv;
|
|
16215
|
+
const props = properties({ message, attributes, ugc: ugc2, pVtec: vtec2 });
|
|
16216
|
+
const header = getEventHeader({ properties: props, getType: stanza.getType, vtec: vtec2 });
|
|
16217
|
+
const issued = (_d = new Date(attributes.issue)) != null ? _d : /* @__PURE__ */ new Date();
|
|
16218
|
+
const expires = new Date(vtec2.expires);
|
|
16219
|
+
processed.push({
|
|
16220
|
+
type: `Feature`,
|
|
16221
|
+
geometry: {
|
|
16222
|
+
type: `Point`,
|
|
16223
|
+
coordinates: []
|
|
16224
|
+
},
|
|
16225
|
+
properties: __spreadProps(__spreadValues({
|
|
16226
|
+
event: pv.event,
|
|
16227
|
+
parent: pv.event,
|
|
16228
|
+
status: pv.status,
|
|
16229
|
+
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
16230
|
+
expires: !isNaN(expires.getTime()) ? expires.toISOString() : (_e = ugc2.expires) != null ? _e : new Date(issued.getTime() + 60 * 60 * 1e3).toISOString()
|
|
16231
|
+
}, props), {
|
|
16232
|
+
metadata: {
|
|
16233
|
+
ms: performance.now() - tick,
|
|
16234
|
+
source: `events.vtec`,
|
|
16235
|
+
tracking: getEventTracking({ type: `VTEC`, stanza, attributes, properties: props, vtec: vtec2 }),
|
|
16236
|
+
header,
|
|
16237
|
+
vtec: pv,
|
|
16238
|
+
hvtec: hVtec,
|
|
16239
|
+
raw: message,
|
|
16240
|
+
history: [
|
|
16241
|
+
{
|
|
16242
|
+
description: props.description,
|
|
16243
|
+
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
16244
|
+
status: pv.status
|
|
16245
|
+
}
|
|
16246
|
+
]
|
|
16247
|
+
}
|
|
16248
|
+
})
|
|
16249
|
+
});
|
|
16250
|
+
}
|
|
16368
16251
|
}
|
|
16369
16252
|
}
|
|
16370
|
-
|
|
16371
|
-
|
|
16372
|
-
|
|
16373
|
-
|
|
16374
|
-
|
|
16253
|
+
validateEvents(processed);
|
|
16254
|
+
});
|
|
16255
|
+
|
|
16256
|
+
// src/@events/events.api.ts
|
|
16257
|
+
var api = (stanza) => __async(null, null, function* () {
|
|
16258
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb;
|
|
16259
|
+
let processed = [];
|
|
16260
|
+
const messages = Object.values(JSON.parse(stanza.message).features);
|
|
16261
|
+
for (const feature of messages) {
|
|
16262
|
+
const tick = performance.now();
|
|
16263
|
+
const pVtec = (_d = pvExtract((_c = (_b = (_a = feature == null ? void 0 : feature.properties) == null ? void 0 : _a.parameters) == null ? void 0 : _b.VTEC) == null ? void 0 : _c[0])) != null ? _d : null;
|
|
16264
|
+
processed.push({
|
|
16265
|
+
type: `Feature`,
|
|
16266
|
+
geometry: {
|
|
16267
|
+
type: `Point`,
|
|
16268
|
+
coordinates: []
|
|
16269
|
+
},
|
|
16270
|
+
properties: {
|
|
16271
|
+
event: (_f = (_e = feature == null ? void 0 : feature.properties) == null ? void 0 : _e.event) != null ? _f : null,
|
|
16272
|
+
parent: (_h = (_g = feature == null ? void 0 : feature.properties) == null ? void 0 : _g.event) != null ? _h : null,
|
|
16273
|
+
status: (_j = (_i = feature == null ? void 0 : feature.properties) == null ? void 0 : _i.messageType) != null ? _j : null,
|
|
16274
|
+
issued: ((_k = feature == null ? void 0 : feature.properties) == null ? void 0 : _k.sent) ? new Date((_l = feature == null ? void 0 : feature.properties) == null ? void 0 : _l.sent).toISOString() : null,
|
|
16275
|
+
expires: ((_m = feature == null ? void 0 : feature.properties) == null ? void 0 : _m.expires) ? new Date((_n = feature == null ? void 0 : feature.properties) == null ? void 0 : _n.expires).toISOString() : null,
|
|
16276
|
+
locations: (_p = (_o = feature == null ? void 0 : feature.properties) == null ? void 0 : _o.areaDesc) != null ? _p : null,
|
|
16277
|
+
description: (_r = (_q = feature == null ? void 0 : feature.properties) == null ? void 0 : _q.description) != null ? _r : null,
|
|
16278
|
+
attributes: (_t = (_s = feature == null ? void 0 : feature.properties) == null ? void 0 : _s.attributes) != null ? _t : {},
|
|
16279
|
+
geocode: {
|
|
16280
|
+
office: {
|
|
16281
|
+
office: pVtec ? (_u = pVtec == null ? void 0 : pVtec[0]) == null ? void 0 : _u.tracking.split(`.`)[0] : null,
|
|
16282
|
+
name: (_w = dict_icao[pVtec ? (_v = pVtec == null ? void 0 : pVtec[0]) == null ? void 0 : _v.tracking.split(`.`)[0] : null]) != null ? _w : null
|
|
16283
|
+
},
|
|
16284
|
+
organization: (_z = (_y = (_x = feature == null ? void 0 : feature.properties) == null ? void 0 : _x.parameters) == null ? void 0 : _y.WMOidentifier) == null ? void 0 : _z[0],
|
|
16285
|
+
ugc: (_C = (_B = (_A = feature == null ? void 0 : feature.properties) == null ? void 0 : _A.geocode) == null ? void 0 : _B.UGC) != null ? _C : [],
|
|
16286
|
+
polygon: ((_D = feature == null ? void 0 : feature.geometry) == null ? void 0 : _D.coordinates.length) > 0 ? Buffer.from(JSON.stringify([(_E = feature == null ? void 0 : feature.geometry) == null ? void 0 : _E.coordinates[0]])).toString("base64") : null,
|
|
16287
|
+
polygon_generated: ((_F = feature == null ? void 0 : feature.geometry) == null ? void 0 : _F.coordinates.length) > 0 ? true : false
|
|
16288
|
+
},
|
|
16289
|
+
parameters: {
|
|
16290
|
+
tags: getEventTags((_G = feature == null ? void 0 : feature.properties) == null ? void 0 : _G.description),
|
|
16291
|
+
instructions: (_I = (_H = feature == null ? void 0 : feature.properties) == null ? void 0 : _H.instruction) != null ? _I : null,
|
|
16292
|
+
source: (_K = getTextFromProduct({ message: (_J = feature == null ? void 0 : feature.properties) == null ? void 0 : _J.description, find: [`SOURCE...`], removal: [`.`] })) != null ? _K : null,
|
|
16293
|
+
hazards: (_M = getTextFromProduct({ message: (_L = feature == null ? void 0 : feature.properties) == null ? void 0 : _L.description, find: [`HAZARD...`], removal: [`.`] })) != null ? _M : null,
|
|
16294
|
+
impacts: (_O = getTextFromProduct({ message: (_N = feature == null ? void 0 : feature.properties) == null ? void 0 : _N.description, find: [`IMPACT...`], removal: [`.`] })) != null ? _O : null,
|
|
16295
|
+
estimated_hail_size: (_S = (_R = (_Q = (_P = feature == null ? void 0 : feature.properties) == null ? void 0 : _P.parameters) == null ? void 0 : _Q.maxHailSize) == null ? void 0 : _R[0]) != null ? _S : null,
|
|
16296
|
+
estimated_wind_gusts: (_W = (_V = (_U = (_T = feature == null ? void 0 : feature.properties) == null ? void 0 : _T.parameters) == null ? void 0 : _U.maxWindGust) == null ? void 0 : _V[0]) != null ? _W : null,
|
|
16297
|
+
damage_threat: (__ = (_Z = (_Y = (_X = feature == null ? void 0 : feature.properties) == null ? void 0 : _X.parameters) == null ? void 0 : _Y.thunderstormDamageThreat) == null ? void 0 : _Z[0]) != null ? __ : null,
|
|
16298
|
+
tornado_threat: (_ca = (_ba = (_aa = (_$ = feature == null ? void 0 : feature.properties) == null ? void 0 : _$.parameters) == null ? void 0 : _aa.tornadoDetection) == null ? void 0 : _ba[0]) != null ? _ca : null,
|
|
16299
|
+
flood_threat: (_ga = (_fa = (_ea = (_da = feature == null ? void 0 : feature.properties) == null ? void 0 : _da.parameters) == null ? void 0 : _ea.floodDetection) == null ? void 0 : _fa[0]) != null ? _ga : null,
|
|
16300
|
+
wind_threat: (_ka = (_ja = (_ia = (_ha = feature == null ? void 0 : feature.properties) == null ? void 0 : _ha.parameters) == null ? void 0 : _ia.windThreat) == null ? void 0 : _ja[0]) != null ? _ka : null,
|
|
16301
|
+
hail_threat: (_oa = (_na = (_ma = (_la = feature == null ? void 0 : feature.properties) == null ? void 0 : _la.parameters) == null ? void 0 : _ma.hailThreat) == null ? void 0 : _na[0]) != null ? _oa : null
|
|
16302
|
+
},
|
|
16303
|
+
discussion_parameters: {
|
|
16304
|
+
discussion_number: (_sa = (_ra = (_qa = getTextFromProduct({ message: (_pa = feature == null ? void 0 : feature.properties) == null ? void 0 : _pa.description, find: [`Mesoscale Discussion `], removal: [`Mesoscale Discussion`, `Number`, `...`] })) == null ? void 0 : _qa.toString()) == null ? void 0 : _ra.padStart(4, "0")) != null ? _sa : null,
|
|
16305
|
+
discussion_concerning: (_ua = getTextFromProduct({ message: (_ta = feature == null ? void 0 : feature.properties) == null ? void 0 : _ta.description, find: [`Concerning...`] })) != null ? _ua : null,
|
|
16306
|
+
discussion_max_tornado: (_wa = getTextFromProduct({ message: (_va = feature == null ? void 0 : feature.properties) == null ? void 0 : _va.description, find: [`MOST PROBABLE PEAK TORNADO INTENSITY...`] })) != null ? _wa : null,
|
|
16307
|
+
discussion_max_hail: (_ya = getTextFromProduct({ message: (_xa = feature == null ? void 0 : feature.properties) == null ? void 0 : _xa.description, find: [`MOST PROBABLE PEAK HAIL SIZE...`] })) != null ? _ya : null,
|
|
16308
|
+
discussion_max_wind: (_Aa = getTextFromProduct({ message: (_za = feature == null ? void 0 : feature.properties) == null ? void 0 : _za.description, find: [`MOST PROBABLE PEAK WIND GUST...`] })) != null ? _Aa : null,
|
|
16309
|
+
discussion_watch_issuance: (_Ca = getTextFromProduct({ message: (_Ba = feature == null ? void 0 : feature.properties) == null ? void 0 : _Ba.description, find: [`Probability of Watch Issuance...`], removal: [`percent`] })) != null ? _Ca : null
|
|
16310
|
+
},
|
|
16311
|
+
watch_parameters: {
|
|
16312
|
+
watch_number: ((_Da = pVtec == null ? void 0 : pVtec[0]) == null ? void 0 : _Da.is_watch) && ((_Oa = (_Na = (_Ia = (_Ha = (_Ga = (_Fa = getTextFromProduct({ message: (_Ea = feature == null ? void 0 : feature.properties) == null ? void 0 : _Ea.description, find: [`ITIES FOR`, `UPDATE FOR`, `Watch Number `], removal: [`%`, `<`, `:`] })) == null ? void 0 : _Fa.replace(/(WT|WS|)/g, "")) == null ? void 0 : _Ga.trim()) == null ? void 0 : _Ha.toString()) == null ? void 0 : _Ia.padStart(4, "0")) != null ? _Na : (_Ma = (_La = (_Ka = (_Ja = pVtec == null ? void 0 : pVtec[0]) == null ? void 0 : _Ja.tracking) == null ? void 0 : _Ka.slice(-4)) == null ? void 0 : _La.toString()) == null ? void 0 : _Ma.padStart(4, "0")) != null ? _Oa : null),
|
|
16313
|
+
watch_type: ((_Pa = feature == null ? void 0 : feature.properties) == null ? void 0 : _Pa.description.includes(`TORNADO WATCH`)) ? `Tornado` : ((_Qa = feature == null ? void 0 : feature.properties) == null ? void 0 : _Qa.description.includes(`SEVERE`)) ? `Severe` : null,
|
|
16314
|
+
additional_tornadoes_probability: (_Sa = getTextFromProduct({ message: (_Ra = feature == null ? void 0 : feature.properties) == null ? void 0 : _Ra.description, find: [`PROB OF 2 OR MORE TORNADOES`], removal: [`%`, `<`, `:`] })) != null ? _Sa : null,
|
|
16315
|
+
strong_tornadoes_probability: (_Ua = getTextFromProduct({ message: (_Ta = feature == null ? void 0 : feature.properties) == null ? void 0 : _Ta.description, find: [`PROB OF 1 OR MORE STRONG /EF2-EF5/ TORNADOES`], removal: [`%`, `<`, `:`] })) != null ? _Ua : null,
|
|
16316
|
+
severe_wind_probability: (_Wa = getTextFromProduct({ message: (_Va = feature == null ? void 0 : feature.properties) == null ? void 0 : _Va.description, find: [`PROB OF 10 OR MORE SEVERE WIND EVENTS`], removal: [`%`, `<`, `:`] })) != null ? _Wa : null,
|
|
16317
|
+
severe_hail_probability: (_Ya = getTextFromProduct({ message: (_Xa = feature == null ? void 0 : feature.properties) == null ? void 0 : _Xa.description, find: [`PROB OF 10 OR MORE SEVERE HAIL EVENTS`], removal: [`%`, `<`, `:`] })) != null ? _Ya : null,
|
|
16318
|
+
hail_2in_probability: (__a = getTextFromProduct({ message: (_Za = feature == null ? void 0 : feature.properties) == null ? void 0 : _Za.description, find: [`PROB OF 1 OR MORE HAIL EVENTS >= 2 INCHES`], removal: [`%`, `<`, `:`] })) != null ? __a : null,
|
|
16319
|
+
combined_hail_wind_probability: (_ab = getTextFromProduct({ message: (_$a = feature == null ? void 0 : feature.properties) == null ? void 0 : _$a.description, find: [`PROB OF 6 OR MORE COMBINED SEVERE HAIL/WIND EVENTS`], removal: [`%`, `<`, `:`] })) != null ? _ab : null,
|
|
16320
|
+
max_hail_in: (_cb = getTextFromProduct({ message: (_bb = feature == null ? void 0 : feature.properties) == null ? void 0 : _bb.description, find: [`MAX HAIL /INCHES/`], removal: [`%`, `<`, `:`] })) != null ? _cb : null,
|
|
16321
|
+
max_wind_surface: (_eb = getTextFromProduct({ message: (_db = feature == null ? void 0 : feature.properties) == null ? void 0 : _db.description, find: [`MAX WIND GUSTS SURFACE /KNOTS/`], removal: [`%`, `<`, `:`] })) != null ? _eb : null,
|
|
16322
|
+
max_tops_x100feet: (_gb = getTextFromProduct({ message: (_fb = feature == null ? void 0 : feature.properties) == null ? void 0 : _fb.description, find: [`MAX TOPS /X 100 FEET/`], removal: [`%`, `<`, `:`] })) != null ? _gb : null,
|
|
16323
|
+
pds_watch: getTextFromProduct({ message: (_hb = feature == null ? void 0 : feature.properties) == null ? void 0 : _hb.description, find: [`PARTICULARLY DANGEROUS SITUATION`], removal: [`%`, `<`, `:`] }) === `YES`
|
|
16324
|
+
},
|
|
16325
|
+
metadata: {
|
|
16326
|
+
ms: performance.now() - tick,
|
|
16327
|
+
source: `events.api`,
|
|
16328
|
+
tracking: getEventTracking({ type: `API`, organization: { wmoidentifier: (_kb = (_jb = (_ib = feature == null ? void 0 : feature.properties) == null ? void 0 : _ib.parameters) == null ? void 0 : _jb.WMOidentifier) == null ? void 0 : _kb[0], featureId: feature == null ? void 0 : feature.id }, vtec: pVtec == null ? void 0 : pVtec[0] }),
|
|
16329
|
+
header: `ZCZC-ATMOSX-${(_mb = (_lb = feature == null ? void 0 : feature.properties) == null ? void 0 : _lb.parameters) == null ? void 0 : _mb.WMOidentifier}`,
|
|
16330
|
+
vtec: pVtec == null ? void 0 : pVtec[0],
|
|
16331
|
+
hvtec: null,
|
|
16332
|
+
raw: (_nb = feature == null ? void 0 : feature.properties) == null ? void 0 : _nb.description,
|
|
16333
|
+
history: [
|
|
16334
|
+
{
|
|
16335
|
+
description: (_ob = feature == null ? void 0 : feature.properties) == null ? void 0 : _ob.description,
|
|
16336
|
+
issued: ((_pb = feature == null ? void 0 : feature.properties) == null ? void 0 : _pb.sent) ? new Date((_qb = feature == null ? void 0 : feature.properties) == null ? void 0 : _qb.sent).toISOString() : null,
|
|
16337
|
+
status: (_sb = (_rb = feature == null ? void 0 : feature.properties) == null ? void 0 : _rb.messageType) != null ? _sb : null
|
|
16338
|
+
}
|
|
16339
|
+
]
|
|
16340
|
+
}
|
|
16341
|
+
}
|
|
16342
|
+
});
|
|
16375
16343
|
}
|
|
16376
|
-
|
|
16377
|
-
};
|
|
16344
|
+
validateEvents(processed);
|
|
16345
|
+
});
|
|
16378
16346
|
|
|
16379
|
-
// src/@
|
|
16380
|
-
var
|
|
16381
|
-
const
|
|
16382
|
-
|
|
16383
|
-
|
|
16384
|
-
|
|
16385
|
-
|
|
16386
|
-
|
|
16347
|
+
// src/@building/building.create.ts
|
|
16348
|
+
var createEvent = (stanza) => __async(null, null, function* () {
|
|
16349
|
+
const settings = bootstrap.settings;
|
|
16350
|
+
const StanzaSettings = settings.NOAAWeatherWireServiceSettings.StanzaSettings;
|
|
16351
|
+
const isVtecEvent = stanza.isVTEC && stanza.isUGC;
|
|
16352
|
+
const isUgcEvent = !stanza.isVTEC && stanza.isUGC;
|
|
16353
|
+
const isTextEvent = !stanza.isVTEC && !stanza.isUGC;
|
|
16354
|
+
const isNWWS = stanza.isNWWS;
|
|
16355
|
+
if (!isNWWS) return yield api(stanza);
|
|
16356
|
+
if (!StanzaSettings.DisableVTEC && isVtecEvent) return yield vtec(stanza);
|
|
16357
|
+
if (!StanzaSettings.DisableUGC && isUgcEvent) return yield ugc(stanza);
|
|
16358
|
+
if (!StanzaSettings.DisableText && isTextEvent) return yield text(stanza);
|
|
16359
|
+
return "nothing picked";
|
|
16360
|
+
});
|
|
16361
|
+
|
|
16362
|
+
// src/@modules/@database/database.stanza.ts
|
|
16363
|
+
var importStanza = (stanza) => __async(null, null, function* () {
|
|
16364
|
+
const settings = bootstrap.settings;
|
|
16365
|
+
try {
|
|
16366
|
+
if (!settings.NOAAWeatherWireServiceSettings.CacheSettings.Enabled) {
|
|
16367
|
+
return;
|
|
16368
|
+
}
|
|
16369
|
+
bootstrap.database.prepare(`INSERT OR IGNORE INTO stanzas (type, stanza, issued) VALUES (?, ?, ?)`).run(stanza.getType.type, JSON.stringify(stanza), stanza.attributes.issue);
|
|
16370
|
+
const count = bootstrap.database.prepare(`SELECT COUNT(*) as total FROM stanzas`).get();
|
|
16371
|
+
const max = settings.NOAAWeatherWireServiceSettings.CacheSettings.MaxDatabaseHistory;
|
|
16372
|
+
if (count.total > max) {
|
|
16373
|
+
const toDelete = count.total - max;
|
|
16374
|
+
if (toDelete > 0) {
|
|
16375
|
+
bootstrap.database.prepare(`DELETE FROM stanzas WHERE id IN (SELECT id FROM stanzas ORDER BY issued ASC LIMIT ?)`).run(toDelete);
|
|
16376
|
+
}
|
|
16377
|
+
}
|
|
16378
|
+
} catch (error) {
|
|
16379
|
+
setWarning({ message: `An error occurred while importing stanza: ${error.message}` });
|
|
16387
16380
|
}
|
|
16388
|
-
|
|
16389
|
-
};
|
|
16381
|
+
});
|
|
16390
16382
|
|
|
16391
|
-
// src/@modules/@
|
|
16392
|
-
var
|
|
16393
|
-
|
|
16394
|
-
|
|
16395
|
-
|
|
16396
|
-
|
|
16397
|
-
|
|
16398
|
-
|
|
16399
|
-
|
|
16400
|
-
|
|
16401
|
-
|
|
16383
|
+
// src/@modules/@xmpp/xmpp.xStanza.ts
|
|
16384
|
+
var xStanza = () => {
|
|
16385
|
+
bootstrap.session_xmpp.on(`stanza`, (stanza) => __async(null, null, function* () {
|
|
16386
|
+
var _a, _b, _c, _d;
|
|
16387
|
+
const msgFrom = (_b = (_a = stanza == null ? void 0 : stanza.attrs) == null ? void 0 : _a.from) != null ? _b : ``;
|
|
16388
|
+
const msgType = (_d = (_c = stanza == null ? void 0 : stanza.attrs) == null ? void 0 : _c.type) != null ? _d : ``;
|
|
16389
|
+
setEventEmit({
|
|
16390
|
+
event: `onServiceStatus`,
|
|
16391
|
+
metadata: {
|
|
16392
|
+
message: stanza,
|
|
16393
|
+
from: msgFrom,
|
|
16394
|
+
type: `stanza`
|
|
16395
|
+
}
|
|
16396
|
+
});
|
|
16397
|
+
bootstrap.cache.lastStanza = Date.now();
|
|
16398
|
+
if (stanza.is(`message`)) {
|
|
16399
|
+
const result = validate({ stanza });
|
|
16400
|
+
const isSkippable = result.isIgnored || result.isCapEvent || result.isCapEvent && !result.isCapAreaDescription;
|
|
16401
|
+
if (isSkippable) {
|
|
16402
|
+
return;
|
|
16403
|
+
}
|
|
16404
|
+
yield createEvent(result);
|
|
16405
|
+
yield importStanza(result);
|
|
16406
|
+
}
|
|
16407
|
+
if (stanza.is(`presence`) && msgFrom.startsWith("nwws@conference.nwws-oi.weather.gov/")) {
|
|
16408
|
+
const getOccupant = msgFrom.split(`/`).slice(1).join(`/`);
|
|
16409
|
+
const getAvailability = msgType === `unavailable`;
|
|
16410
|
+
setEventEmit({
|
|
16411
|
+
event: `onServiceStatus`,
|
|
16412
|
+
metadata: {
|
|
16413
|
+
message: `Occupant ${getOccupant} has ${getAvailability ? `left` : `joined`} the room`,
|
|
16414
|
+
data: {},
|
|
16415
|
+
type: `occupant`,
|
|
16416
|
+
error: false
|
|
16417
|
+
}
|
|
16418
|
+
});
|
|
16419
|
+
}
|
|
16420
|
+
}));
|
|
16402
16421
|
};
|
|
16403
16422
|
|
|
16404
|
-
// src/@modules/@
|
|
16405
|
-
var
|
|
16423
|
+
// src/@modules/@xmpp/xmpp.xDeploy.ts
|
|
16424
|
+
var xDeploy = () => __async(null, null, function* () {
|
|
16406
16425
|
var _a, _b;
|
|
16407
|
-
|
|
16408
|
-
const
|
|
16409
|
-
|
|
16410
|
-
|
|
16411
|
-
|
|
16412
|
-
|
|
16413
|
-
|
|
16414
|
-
|
|
16415
|
-
|
|
16416
|
-
|
|
16417
|
-
|
|
16418
|
-
|
|
16419
|
-
|
|
16420
|
-
|
|
16421
|
-
|
|
16426
|
+
let session;
|
|
16427
|
+
const settings = bootstrap.settings;
|
|
16428
|
+
(_b = (_a = settings.NOAAWeatherWireServiceSettings.CredentialSettings).Nickname) != null ? _b : _a.Nickname = settings.NOAAWeatherWireServiceSettings.CredentialSettings.Username;
|
|
16429
|
+
session = bootstrap.session_xmpp = client({
|
|
16430
|
+
service: "xmpp://nwws-oi.weather.gov",
|
|
16431
|
+
domain: "nwws-oi.weather.gov",
|
|
16432
|
+
username: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Username,
|
|
16433
|
+
password: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Password
|
|
16434
|
+
});
|
|
16435
|
+
try {
|
|
16436
|
+
yield xOffline();
|
|
16437
|
+
yield xError();
|
|
16438
|
+
yield xStanza();
|
|
16439
|
+
yield xOnline();
|
|
16440
|
+
yield session.start();
|
|
16441
|
+
} catch (error) {
|
|
16442
|
+
setEventEmit({
|
|
16443
|
+
event: `onServiceStatus`,
|
|
16444
|
+
metadata: {
|
|
16445
|
+
message: `Error occured while starting XMPP Session: ${error}`,
|
|
16446
|
+
data: {},
|
|
16447
|
+
type: `error`,
|
|
16448
|
+
error: true
|
|
16449
|
+
}
|
|
16450
|
+
});
|
|
16422
16451
|
}
|
|
16423
|
-
|
|
16424
|
-
};
|
|
16452
|
+
});
|
|
16425
16453
|
|
|
16426
|
-
// src/@modules/@
|
|
16427
|
-
var
|
|
16428
|
-
|
|
16429
|
-
const out = new Int16Array(len);
|
|
16430
|
-
const f1 = 853;
|
|
16431
|
-
const f2 = 960;
|
|
16432
|
-
const twoPi = Math.PI * 2;
|
|
16433
|
-
const amp = 0.1;
|
|
16434
|
-
const fadeLen = Math.floor(sampleRate * 0);
|
|
16435
|
-
for (let i = 0; i < len; i++) {
|
|
16436
|
-
const t = i / sampleRate;
|
|
16437
|
-
const s = Math.sin(twoPi * f1 * t) + Math.sin(twoPi * f2 * t);
|
|
16438
|
-
let gain = 1;
|
|
16439
|
-
if (i < fadeLen) gain = i / fadeLen;
|
|
16440
|
-
else if (i > len - fadeLen) gain = (len - i) / fadeLen;
|
|
16441
|
-
const v = Math.max(-1, Math.min(1, s / 2 * amp * gain));
|
|
16442
|
-
out[i] = Math.round(v * 32767);
|
|
16443
|
-
}
|
|
16444
|
-
return out;
|
|
16445
|
-
};
|
|
16454
|
+
// src/@modules/@database/database.init.ts
|
|
16455
|
+
var import_fs5 = __toESM(require("fs"));
|
|
16456
|
+
var import_better_sqlite3 = __toESM(require("better-sqlite3"));
|
|
16446
16457
|
|
|
16447
|
-
// src/@modules/@
|
|
16448
|
-
var
|
|
16449
|
-
|
|
16450
|
-
|
|
16451
|
-
|
|
16452
|
-
for (let i = 0; i < x.length; i++) peak = Math.max(peak, Math.abs(x[i]));
|
|
16453
|
-
if (peak > 1) for (let i = 0; i < x.length; i++) x[i] *= 0.98 / peak;
|
|
16454
|
-
return getFloatPCM16(x);
|
|
16455
|
-
};
|
|
16458
|
+
// src/@modules/@database/database.shapefiles.ts
|
|
16459
|
+
var import_fs4 = __toESM(require("fs"));
|
|
16460
|
+
var import_path3 = require("path");
|
|
16461
|
+
var import_jszip = require("jszip");
|
|
16462
|
+
var import_shapefile = require("shapefile");
|
|
16456
16463
|
|
|
16457
|
-
// src/@modules/@
|
|
16458
|
-
var
|
|
16459
|
-
|
|
16460
|
-
|
|
16461
|
-
|
|
16462
|
-
|
|
16463
|
-
|
|
16464
|
-
|
|
16465
|
-
|
|
16466
|
-
|
|
16467
|
-
|
|
16468
|
-
|
|
16469
|
-
|
|
16470
|
-
|
|
16471
|
-
|
|
16472
|
-
|
|
16473
|
-
|
|
16474
|
-
|
|
16475
|
-
|
|
16476
|
-
|
|
16477
|
-
|
|
16478
|
-
|
|
16479
|
-
|
|
16480
|
-
|
|
16481
|
-
|
|
16482
|
-
|
|
16483
|
-
|
|
16484
|
-
|
|
16485
|
-
|
|
16486
|
-
|
|
16487
|
-
|
|
16488
|
-
|
|
16489
|
-
|
|
16490
|
-
|
|
16491
|
-
|
|
16492
|
-
|
|
16493
|
-
|
|
16464
|
+
// src/@modules/@utilities/utilities.setSleep.ts
|
|
16465
|
+
var setSleep = (options) => __async(null, null, function* () {
|
|
16466
|
+
return new Promise((resolve6) => {
|
|
16467
|
+
setTimeout(() => {
|
|
16468
|
+
resolve6();
|
|
16469
|
+
}, options.timeout);
|
|
16470
|
+
});
|
|
16471
|
+
});
|
|
16472
|
+
|
|
16473
|
+
// src/@dictionaries/dictionaries.shapefiles.ts
|
|
16474
|
+
var dict_shapefiles = [
|
|
16475
|
+
{ name: "us_counties", id: "C", link: "https://www.weather.gov/source/gis/Shapefiles/County/c_16ap26.zip" },
|
|
16476
|
+
{ name: "us_states_territories", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/County/s_16ap26.zip" },
|
|
16477
|
+
{ name: "fire_weather_zones", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/fz16ap26.zip" },
|
|
16478
|
+
{ name: "costal_marine_zones", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/mz16ap26.zip" },
|
|
16479
|
+
{ name: "offshore_marine_zones", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/oz16ap26.zip" },
|
|
16480
|
+
{ name: "public_forecast_zones", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/z_16ap26.zip" },
|
|
16481
|
+
{ name: "county_warning_areas", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/w_16ap26.zip" },
|
|
16482
|
+
{ name: "river_forecast_boundaries", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/Misc/rf05mr24.zip" },
|
|
16483
|
+
{ name: "high_seas_marine_zones", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/hz17fe26.zip" }
|
|
16484
|
+
];
|
|
16485
|
+
|
|
16486
|
+
// src/@modules/@database/database.shapefiles.ts
|
|
16487
|
+
var importShapefiles = () => __async(null, null, function* () {
|
|
16488
|
+
var _a, _b;
|
|
16489
|
+
const settings = bootstrap.settings;
|
|
16490
|
+
try {
|
|
16491
|
+
const tShapefiles = bootstrap.database.prepare(`SELECT COUNT(*) AS count FROM shapefiles`).get().count;
|
|
16492
|
+
if (tShapefiles === 0) {
|
|
16493
|
+
yield setSleep({ timeout: 1e3 });
|
|
16494
|
+
setWarning({ message: `Shapefiles are currently building, please DO NOT close your terminal. The shapefiles will not finish and will remain incomplete. If you do mess up, you will need to delete ${settings.Database} and restart the application.` });
|
|
16495
|
+
for (const shapefile of dict_shapefiles) {
|
|
16496
|
+
const response2 = yield fetch(shapefile.link);
|
|
16497
|
+
const arrayBuff = yield response2.arrayBuffer();
|
|
16498
|
+
const content = yield (0, import_jszip.loadAsync)(arrayBuff);
|
|
16499
|
+
const directory = (0, import_path3.resolve)(__dirname, `../../shapefiles`);
|
|
16500
|
+
if (!import_fs4.default.existsSync(directory)) {
|
|
16501
|
+
import_fs4.default.mkdirSync(directory, { recursive: true });
|
|
16502
|
+
}
|
|
16503
|
+
for (const file of Object.keys(content.files)) {
|
|
16504
|
+
if (file.endsWith(".shp") || file.endsWith(".dbf")) {
|
|
16505
|
+
const data = yield content.files[file].async(`nodebuffer`);
|
|
16506
|
+
const output = (0, import_path3.resolve)(directory, `${(_a = shapefile == null ? void 0 : shapefile.name) != null ? _a : ``}_${(_b = shapefile == null ? void 0 : shapefile.id) != null ? _b : ``}${(0, import_path3.extname)(file)}`);
|
|
16507
|
+
import_fs4.default.writeFileSync(output, data);
|
|
16508
|
+
}
|
|
16509
|
+
}
|
|
16510
|
+
const filepath = (0, import_path3.resolve)(__dirname, "../../shapefiles", shapefile.name + "_" + shapefile.id);
|
|
16511
|
+
const { features } = yield (0, import_shapefile.read)(
|
|
16512
|
+
filepath,
|
|
16513
|
+
filepath
|
|
16514
|
+
);
|
|
16515
|
+
setWarning({ message: `Importing ${features.length} features from ${shapefile.name}_${shapefile.id}` });
|
|
16516
|
+
const insert = bootstrap.database.prepare(`INSERT OR REPLACE INTO shapefiles (id, location, geometry) VALUES (?, ?, ?)`);
|
|
16517
|
+
const transaction = bootstrap.database.transaction((entries) => {
|
|
16518
|
+
var _a2, _b2, _c;
|
|
16519
|
+
for (const entry of entries) {
|
|
16520
|
+
const { properties: properties2, geometry } = entry;
|
|
16521
|
+
let final2, location;
|
|
16522
|
+
if (properties2.FIPS) {
|
|
16523
|
+
final2 = `${properties2.STATE}${shapefile.id}${properties2.FIPS.substring(2)}`;
|
|
16524
|
+
location = `${properties2.COUNTYNAME}, ${properties2.STATE}`;
|
|
16525
|
+
} else if (properties2.FULLSTAID) {
|
|
16526
|
+
final2 = `${properties2.ST}${shapefile.id}${properties2.WFO}`;
|
|
16527
|
+
location = `${properties2.CITY}, ${properties2.STATE}`;
|
|
16528
|
+
} else if (properties2.STATE) {
|
|
16529
|
+
final2 = `${properties2.STATE}${shapefile.id}${(_a2 = properties2.ZONE) != null ? _a2 : properties2.SITE_ID}`;
|
|
16530
|
+
location = `${(_b2 = properties2.NAME) != null ? _b2 : `${properties2.RFC_NAME} ${properties2.RFC_CITY}`}, ${properties2.STATE}`;
|
|
16531
|
+
} else {
|
|
16532
|
+
final2 = (_c = properties2.ID) != null ? _c : properties2.WFO;
|
|
16533
|
+
location = properties2.NAME;
|
|
16534
|
+
}
|
|
16535
|
+
insert.run(final2, location, JSON.stringify(geometry));
|
|
16536
|
+
}
|
|
16537
|
+
});
|
|
16538
|
+
import_fs4.default.unlinkSync(`${filepath}.shp`);
|
|
16539
|
+
import_fs4.default.unlinkSync(`${filepath}.dbf`);
|
|
16540
|
+
setWarning({ message: `Cleaned up temporary files for ${shapefile.name}_${shapefile.id}` });
|
|
16541
|
+
transaction(features);
|
|
16542
|
+
}
|
|
16543
|
+
setWarning({ message: `Shapefiles have finished compiling, you can now continue and close this terminal` });
|
|
16544
|
+
import_fs4.default.rm((0, import_path3.resolve)(__dirname, "../../shapefiles"), { recursive: true, force: true }, () => {
|
|
16545
|
+
});
|
|
16546
|
+
}
|
|
16547
|
+
} catch (error) {
|
|
16548
|
+
setWarning({ message: `An error occurred while compiling shapefiles: ${error.message}` });
|
|
16494
16549
|
}
|
|
16495
|
-
|
|
16496
|
-
};
|
|
16550
|
+
});
|
|
16497
16551
|
|
|
16498
|
-
// src/@modules/@
|
|
16499
|
-
var
|
|
16500
|
-
var import_fs3 = require("fs");
|
|
16501
|
-
var import_child_process = require("child_process");
|
|
16502
|
-
var import_os = require("os");
|
|
16503
|
-
var import_say = __toESM(require("say"));
|
|
16504
|
-
var setEasTone = (options) => __async(null, null, function* () {
|
|
16552
|
+
// src/@modules/@database/database.init.ts
|
|
16553
|
+
var initializeDatabase = () => __async(null, null, function* () {
|
|
16505
16554
|
const settings = bootstrap.settings;
|
|
16506
|
-
|
|
16507
|
-
|
|
16508
|
-
|
|
16509
|
-
|
|
16510
|
-
|
|
16511
|
-
|
|
16512
|
-
|
|
16513
|
-
|
|
16514
|
-
|
|
16515
|
-
|
|
16516
|
-
|
|
16517
|
-
if (!(0, import_fs3.existsSync)(directory)) {
|
|
16518
|
-
(0, import_fs3.mkdirSync)(directory, { recursive: true });
|
|
16519
|
-
}
|
|
16520
|
-
if (!(0, import_fs3.existsSync)((0, import_path3.join)(directory, `/temp`))) {
|
|
16521
|
-
(0, import_fs3.mkdirSync)((0, import_path3.join)(directory, `/temp`), { recursive: true });
|
|
16522
|
-
}
|
|
16523
|
-
if (!(0, import_fs3.existsSync)((0, import_path3.join)(directory, `/output`))) {
|
|
16524
|
-
(0, import_fs3.mkdirSync)((0, import_path3.join)(directory, `/output`), { recursive: true });
|
|
16555
|
+
try {
|
|
16556
|
+
if (!import_fs5.default.existsSync(settings.Database)) {
|
|
16557
|
+
import_fs5.default.writeFileSync(settings.Database, "");
|
|
16558
|
+
setWarning({ message: `Creating new database at ${settings.Database}` });
|
|
16559
|
+
}
|
|
16560
|
+
bootstrap.database = new import_better_sqlite3.default(settings.Database);
|
|
16561
|
+
bootstrap.database.prepare(`CREATE TABLE IF NOT EXISTS stanzas ( id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, issued TEXT, stanza TEXT )`).run();
|
|
16562
|
+
bootstrap.database.prepare(`CREATE TABLE IF NOT EXISTS shapefiles (id TEXT PRIMARY KEY, location TEXT, geometry TEXT)`).run();
|
|
16563
|
+
yield importShapefiles();
|
|
16564
|
+
} catch (error) {
|
|
16565
|
+
setWarning({ message: `An error occurred while initializing the database: ${error.message}` });
|
|
16525
16566
|
}
|
|
16526
|
-
|
|
16527
|
-
|
|
16567
|
+
});
|
|
16568
|
+
|
|
16569
|
+
// src/@modules/@database/database.cache.ts
|
|
16570
|
+
var getCachedEvents = () => __async(null, null, function* () {
|
|
16571
|
+
var _a;
|
|
16572
|
+
try {
|
|
16573
|
+
const settings = bootstrap.settings;
|
|
16574
|
+
const tick = performance.now();
|
|
16575
|
+
if (settings.NOAAWeatherWireServiceSettings.CacheSettings.Enabled) {
|
|
16576
|
+
const max = (_a = settings.NOAAWeatherWireServiceSettings.CacheSettings.MaxRetentionHistory) != null ? _a : 500;
|
|
16577
|
+
const get = yield bootstrap.database.prepare(`SELECT * FROM stanzas ORDER BY rowid DESC LIMIT ?`).all(max);
|
|
16578
|
+
setWarning({ message: `Fetched ${get.length} cached events from the database in ${Math.floor(performance.now() - tick)} ms` });
|
|
16579
|
+
let events = get.map((row) => JSON.parse(row.stanza)).filter((stanza) => {
|
|
16580
|
+
if (!stanza) {
|
|
16581
|
+
return;
|
|
16582
|
+
}
|
|
16583
|
+
const isSkippable = stanza.isIgnored || stanza.isCapEvent || stanza.isCapEvent && !stanza.isCapAreaDescription;
|
|
16584
|
+
return !isSkippable;
|
|
16585
|
+
});
|
|
16586
|
+
events = events.sort((a, b) => b.issued - a.issued);
|
|
16587
|
+
yield Promise.all(events.map((event) => createEvent(event)));
|
|
16588
|
+
setWarning({ message: `Processed ${events.length} cached events in ${Math.floor(performance.now() - tick)} ms` });
|
|
16589
|
+
}
|
|
16590
|
+
} catch (error) {
|
|
16591
|
+
setWarning({ message: `An error occurred while fetching cached events: ${error.message} -> ${error.stack}` });
|
|
16528
16592
|
}
|
|
16529
|
-
|
|
16530
|
-
|
|
16531
|
-
|
|
16532
|
-
|
|
16533
|
-
|
|
16534
|
-
|
|
16593
|
+
});
|
|
16594
|
+
|
|
16595
|
+
// src/@modules/@xmpp/xmpp.xReconnect.ts
|
|
16596
|
+
var xReconnect = (interval) => __async(null, null, function* () {
|
|
16597
|
+
const settings = bootstrap.settings;
|
|
16598
|
+
const lastStanza = Date.now() - bootstrap.cache.lastStanza;
|
|
16599
|
+
if (interval < 15) {
|
|
16600
|
+
setWarning({ message: `Reconnection interval of ${interval} seconds is too low, setting to 15 seconds` });
|
|
16601
|
+
interval = 15;
|
|
16602
|
+
bootstrap.settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.ReconnectionInterval = 15;
|
|
16535
16603
|
}
|
|
16536
|
-
|
|
16537
|
-
|
|
16538
|
-
|
|
16604
|
+
const reconnectThreshold = interval * 1e3;
|
|
16605
|
+
if (!bootstrap.cache.isConnected && !bootstrap.cache.sigHault || !bootstrap.session_xmpp) {
|
|
16606
|
+
return;
|
|
16539
16607
|
}
|
|
16540
|
-
|
|
16541
|
-
|
|
16542
|
-
|
|
16543
|
-
|
|
16544
|
-
|
|
16545
|
-
let tWav = getWavPCM16(tBuffer);
|
|
16546
|
-
if (tWav == null) {
|
|
16608
|
+
if (lastStanza > reconnectThreshold) {
|
|
16609
|
+
if (!bootstrap.cache.isReconnecting) {
|
|
16610
|
+
bootstrap.cache.isReconnecting = true;
|
|
16611
|
+
bootstrap.cache.isConnected = false;
|
|
16612
|
+
bootstrap.cache.tReconnects += 1;
|
|
16547
16613
|
try {
|
|
16548
|
-
|
|
16549
|
-
|
|
16550
|
-
|
|
16551
|
-
|
|
16552
|
-
|
|
16614
|
+
setEventEmit({
|
|
16615
|
+
event: `onServiceStatus`,
|
|
16616
|
+
metadata: {
|
|
16617
|
+
message: `Attempting to reconnect to XMPP Service (Reconnect Attempt ${bootstrap.cache.tReconnects})`,
|
|
16618
|
+
data: {
|
|
16619
|
+
last_stanza: lastStanza,
|
|
16620
|
+
nickname: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Nickname
|
|
16621
|
+
},
|
|
16622
|
+
type: `reconnect`,
|
|
16623
|
+
error: true
|
|
16624
|
+
}
|
|
16625
|
+
});
|
|
16626
|
+
yield bootstrap.session_xmpp.stop().catch(() => {
|
|
16627
|
+
});
|
|
16628
|
+
yield bootstrap.session_xmpp.start().catch(() => {
|
|
16629
|
+
});
|
|
16630
|
+
} catch (error) {
|
|
16631
|
+
setWarning({ message: `XMPP Reconnect Failed - ${error.message}` });
|
|
16632
|
+
} finally {
|
|
16633
|
+
bootstrap.cache.isReconnecting = false;
|
|
16634
|
+
}
|
|
16635
|
+
}
|
|
16636
|
+
}
|
|
16637
|
+
});
|
|
16638
|
+
|
|
16639
|
+
// src/@modules/@utilities/utilities.setCronSchedule.ts
|
|
16640
|
+
var import_fs6 = require("fs");
|
|
16641
|
+
var import_path4 = require("path");
|
|
16642
|
+
var setCronSchedule = () => __async(null, null, function* () {
|
|
16643
|
+
const settings = bootstrap.settings;
|
|
16644
|
+
const TTL = settings.GlobalSettings.ArchiveSettings.TTL;
|
|
16645
|
+
const TTLCUT = Date.now() - TTL * 1e3;
|
|
16646
|
+
const walk = (dir) => {
|
|
16647
|
+
if ((0, import_fs6.existsSync)(dir)) {
|
|
16648
|
+
const entries = (0, import_fs6.readdirSync)(dir, { withFileTypes: true });
|
|
16649
|
+
for (const entry of entries) {
|
|
16650
|
+
const fullPath = (0, import_path4.join)(dir, entry.name);
|
|
16651
|
+
if (entry.isDirectory()) {
|
|
16652
|
+
walk(fullPath);
|
|
16653
|
+
continue;
|
|
16654
|
+
}
|
|
16655
|
+
const stats = (0, import_fs6.statSync)(fullPath);
|
|
16656
|
+
if (stats.mtime.getTime() < TTLCUT) {
|
|
16553
16657
|
try {
|
|
16554
|
-
(0,
|
|
16555
|
-
} catch (
|
|
16658
|
+
(0, import_fs6.unlinkSync)(fullPath);
|
|
16659
|
+
} catch (err) {
|
|
16660
|
+
console.error(`Failed to delete ${fullPath}:`, err);
|
|
16556
16661
|
}
|
|
16557
16662
|
}
|
|
16558
|
-
} catch (e) {
|
|
16559
16663
|
}
|
|
16560
16664
|
}
|
|
16561
|
-
|
|
16562
|
-
|
|
16563
|
-
|
|
16665
|
+
};
|
|
16666
|
+
walk(settings.GlobalSettings.ArchiveSettings.TextDirectory);
|
|
16667
|
+
walk(settings.GlobalSettings.ArchiveSettings.EasDirectory);
|
|
16668
|
+
if (settings.EnableWireService) {
|
|
16669
|
+
if (settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.Enabled) {
|
|
16670
|
+
void xReconnect(settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.ReconnectionInterval);
|
|
16564
16671
|
}
|
|
16565
|
-
|
|
16566
|
-
|
|
16672
|
+
} else {
|
|
16673
|
+
const response2 = yield createHttp({
|
|
16674
|
+
url: settings.NationalWeatherServiceSettings.EventsEndpoint,
|
|
16675
|
+
headers: {
|
|
16676
|
+
"User-Agent": "@atmosx/event-product-parser"
|
|
16677
|
+
}
|
|
16678
|
+
});
|
|
16679
|
+
if (response2.error) {
|
|
16680
|
+
return setEventEmit({
|
|
16681
|
+
event: `onServiceStatus`,
|
|
16682
|
+
metadata: {
|
|
16683
|
+
type: "fetch-api",
|
|
16684
|
+
message: `Failed to fetch latest events from National Weather Service API - ${response2.message}`,
|
|
16685
|
+
data: {},
|
|
16686
|
+
error: true
|
|
16687
|
+
}
|
|
16688
|
+
});
|
|
16689
|
+
}
|
|
16690
|
+
setEventEmit({
|
|
16691
|
+
event: `onServiceStatus`,
|
|
16692
|
+
metadata: {
|
|
16693
|
+
message: `Fetched latest events from National Weather Service API`,
|
|
16694
|
+
data: {},
|
|
16695
|
+
type: "fetch-api",
|
|
16696
|
+
error: false
|
|
16697
|
+
}
|
|
16698
|
+
});
|
|
16699
|
+
createEvent({ message: response2.message, isNWWS: false });
|
|
16567
16700
|
}
|
|
16568
|
-
|
|
16569
|
-
|
|
16570
|
-
|
|
16571
|
-
|
|
16572
|
-
|
|
16573
|
-
|
|
16574
|
-
|
|
16575
|
-
|
|
16576
|
-
|
|
16577
|
-
|
|
16578
|
-
|
|
16579
|
-
for (let i = 0; i < 3; i++) {
|
|
16580
|
-
buffFull.push(setSameHeader(header, 1, 8e3, { preMarkSec: 0.5, gapSec: 0.1 }));
|
|
16581
|
-
buffFull.push(new Int16Array(Math.floor(0.5 * 8e3)));
|
|
16701
|
+
});
|
|
16702
|
+
|
|
16703
|
+
// src/@manager/manager.updateEvents.ts
|
|
16704
|
+
var updateEvents = (selectedEvent) => __async(null, null, function* () {
|
|
16705
|
+
const events = bootstrap.cache.events.features;
|
|
16706
|
+
function update(evt) {
|
|
16707
|
+
return __async(this, null, function* () {
|
|
16708
|
+
if (new Date(evt.properties.expires) < /* @__PURE__ */ new Date()) {
|
|
16709
|
+
rmEvent(evt);
|
|
16710
|
+
}
|
|
16711
|
+
});
|
|
16582
16712
|
}
|
|
16583
|
-
|
|
16584
|
-
|
|
16585
|
-
|
|
16586
|
-
|
|
16587
|
-
|
|
16588
|
-
|
|
16589
|
-
|
|
16713
|
+
if (!selectedEvent) {
|
|
16714
|
+
yield Promise.all(events.map((evt) => __async(null, null, function* () {
|
|
16715
|
+
yield update(evt);
|
|
16716
|
+
})));
|
|
16717
|
+
}
|
|
16718
|
+
if (selectedEvent) {
|
|
16719
|
+
yield update(selectedEvent);
|
|
16720
|
+
}
|
|
16721
|
+
});
|
|
16722
|
+
|
|
16723
|
+
// src/@core/core.start.ts
|
|
16724
|
+
var import_croner = require("croner");
|
|
16725
|
+
var startService = (configurations) => __async(null, null, function* () {
|
|
16726
|
+
if (!bootstrap.isReady) {
|
|
16727
|
+
return setWarning({
|
|
16728
|
+
message: `You can not create another instance without shutting down the current one first, please make sure to call the stop() method first!`
|
|
16729
|
+
});
|
|
16730
|
+
}
|
|
16731
|
+
const settings = setSettings(configurations);
|
|
16732
|
+
bootstrap.isReady = true;
|
|
16733
|
+
yield initializeDatabase();
|
|
16734
|
+
if (settings.EnableWireService) {
|
|
16735
|
+
(() => __async(null, null, function* () {
|
|
16736
|
+
yield getCachedEvents();
|
|
16737
|
+
yield xDeploy();
|
|
16738
|
+
}))();
|
|
16739
|
+
}
|
|
16740
|
+
yield setCronSchedule();
|
|
16741
|
+
let scheduleInterval = !settings.EnableWireService ? settings.NationalWeatherServiceSettings.CallbackInterval : 1;
|
|
16742
|
+
if (!settings.EnableWireService && scheduleInterval < 15) {
|
|
16743
|
+
setWarning({ message: `Schedule interval of ${scheduleInterval} seconds is too low, setting to 15 seconds` });
|
|
16744
|
+
bootstrap.settings.NationalWeatherServiceSettings.CallbackInterval = 15;
|
|
16745
|
+
scheduleInterval = 15;
|
|
16746
|
+
}
|
|
16747
|
+
bootstrap.cron = new import_croner.Cron(`*/${scheduleInterval} * * * * *`, () => __async(null, null, function* () {
|
|
16748
|
+
yield setCronSchedule();
|
|
16749
|
+
}));
|
|
16750
|
+
bootstrap.cron = new import_croner.Cron(`* * * * * *`, () => __async(null, null, function* () {
|
|
16751
|
+
yield updateNode();
|
|
16752
|
+
yield updateEvents();
|
|
16753
|
+
}));
|
|
16754
|
+
});
|
|
16755
|
+
|
|
16756
|
+
// src/@core/core.stop.ts
|
|
16757
|
+
var stopService = () => __async(null, null, function* () {
|
|
16758
|
+
if (bootstrap.isReady) {
|
|
16759
|
+
bootstrap.isReady = false;
|
|
16760
|
+
if (bootstrap.session_xmpp) {
|
|
16761
|
+
try {
|
|
16762
|
+
yield bootstrap.session_xmpp.stop();
|
|
16763
|
+
} catch (e) {
|
|
16764
|
+
}
|
|
16765
|
+
bootstrap.cache.isConnected = false;
|
|
16766
|
+
bootstrap.cache.sigHault = true;
|
|
16767
|
+
bootstrap.session_xmpp = null;
|
|
16768
|
+
}
|
|
16590
16769
|
}
|
|
16591
|
-
return outTTS;
|
|
16592
16770
|
});
|
|
16593
16771
|
|
|
16594
16772
|
// src/@core/core.setNode.ts
|
|
@@ -16654,6 +16832,59 @@ var getNodes = () => {
|
|
|
16654
16832
|
return bootstrap.cache.nodes;
|
|
16655
16833
|
};
|
|
16656
16834
|
|
|
16835
|
+
// src/@core/core.createEvent.ts
|
|
16836
|
+
var createEvent2 = (options) => {
|
|
16837
|
+
var _a;
|
|
16838
|
+
const tick = performance.now();
|
|
16839
|
+
validateEvents([{
|
|
16840
|
+
type: `Feature`,
|
|
16841
|
+
geometry: {
|
|
16842
|
+
type: `Point`,
|
|
16843
|
+
coordinates: options.coordinates
|
|
16844
|
+
},
|
|
16845
|
+
properties: {
|
|
16846
|
+
event: options.event,
|
|
16847
|
+
parent: options.event,
|
|
16848
|
+
status: options.status,
|
|
16849
|
+
issued: options.issued.toISOString(),
|
|
16850
|
+
expires: options.expires.toISOString(),
|
|
16851
|
+
locations: options.locations,
|
|
16852
|
+
description: options.description,
|
|
16853
|
+
geocode: {
|
|
16854
|
+
office: {
|
|
16855
|
+
office: `ATMX`,
|
|
16856
|
+
name: `AtmosphericX Manual Event`
|
|
16857
|
+
},
|
|
16858
|
+
organization: `AtmosphericX`,
|
|
16859
|
+
ugc: [],
|
|
16860
|
+
polygon: options.coordinates.length > 0 ? Buffer.from(JSON.stringify([options.coordinates[0]])).toString("base64") : null,
|
|
16861
|
+
polygon_generated: options.coordinates.length > 0 ? true : false
|
|
16862
|
+
},
|
|
16863
|
+
status_metadata: {
|
|
16864
|
+
is_issued: options.status == `Issued`,
|
|
16865
|
+
is_updated: options.status == `Updated`,
|
|
16866
|
+
is_expired: options.status == `Expired`,
|
|
16867
|
+
is_test: options.status == `Test`,
|
|
16868
|
+
is_statement: options.status == `Statement`
|
|
16869
|
+
},
|
|
16870
|
+
metadata: {
|
|
16871
|
+
ms: performance.now() - tick,
|
|
16872
|
+
source: `events.manual`,
|
|
16873
|
+
tracking: `ATMX-M-W-01`,
|
|
16874
|
+
header: `ZCZC-ATMOSX-ATMX-M-W-01`,
|
|
16875
|
+
raw: options.description,
|
|
16876
|
+
history: [
|
|
16877
|
+
{
|
|
16878
|
+
description: options.description,
|
|
16879
|
+
issued: options.issued.toISOString(),
|
|
16880
|
+
status: (_a = options.status) != null ? _a : null
|
|
16881
|
+
}
|
|
16882
|
+
]
|
|
16883
|
+
}
|
|
16884
|
+
}
|
|
16885
|
+
}]);
|
|
16886
|
+
};
|
|
16887
|
+
|
|
16657
16888
|
// src/@core/core.getRandomEvent.ts
|
|
16658
16889
|
var getRandomEvent = () => {
|
|
16659
16890
|
return bootstrap.cache.events.features[Math.floor(Math.random() * bootstrap.cache.events.features.length)];
|
|
@@ -16714,6 +16945,7 @@ var index_default = Manager;
|
|
|
16714
16945
|
0 && (module.exports = {
|
|
16715
16946
|
Manager,
|
|
16716
16947
|
clearEvents,
|
|
16948
|
+
createEvent,
|
|
16717
16949
|
getCleanedEvent,
|
|
16718
16950
|
getEventGeometry,
|
|
16719
16951
|
getEvents,
|