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