@aguacerowx/javascript-sdk 0.0.25 → 0.0.26

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/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@aguacerowx/javascript-sdk",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
+ "type": "module",
4
5
  "private": false,
5
6
  "publishConfig": {
6
7
  "access": "public"
@@ -36,6 +37,30 @@
36
37
  "require": "./src/satellite_support.js",
37
38
  "react-native": "./src/satellite_support.js",
38
39
  "default": "./src/satellite_support.js"
40
+ },
41
+ "./nws/NwsWatchesWarningsOverlay.js": {
42
+ "import": "./src/nws/NwsWatchesWarningsOverlay.js",
43
+ "require": "./src/nws/NwsWatchesWarningsOverlay.js",
44
+ "react-native": "./src/nws/NwsWatchesWarningsOverlay.js",
45
+ "default": "./src/nws/NwsWatchesWarningsOverlay.js"
46
+ },
47
+ "./nws/nwsSdkConstants.js": {
48
+ "import": "./src/nws/nwsSdkConstants.js",
49
+ "require": "./src/nws/nwsSdkConstants.js",
50
+ "react-native": "./src/nws/nwsSdkConstants.js",
51
+ "default": "./src/nws/nwsSdkConstants.js"
52
+ },
53
+ "./nws/nwsAlertsSupport.js": {
54
+ "import": "./src/nws/nwsAlertsSupport.js",
55
+ "require": "./src/nws/nwsAlertsSupport.js",
56
+ "react-native": "./src/nws/nwsAlertsSupport.js",
57
+ "default": "./src/nws/nwsAlertsSupport.js"
58
+ },
59
+ "./nws/nwsAlertsFetchSpec.js": {
60
+ "import": "./src/nws/nwsAlertsFetchSpec.js",
61
+ "require": "./src/nws/nwsAlertsFetchSpec.js",
62
+ "react-native": "./src/nws/nwsAlertsFetchSpec.js",
63
+ "default": "./src/nws/nwsAlertsFetchSpec.js"
39
64
  }
40
65
  },
41
66
  "files": [
@@ -43,10 +68,14 @@
43
68
  "src"
44
69
  ],
45
70
  "scripts": {
46
- "build": "babel src -d dist"
71
+ "build": "babel src -d dist",
72
+ "gen:nws-key": "esbuild ../../../aguacero-frontend/src/components/WarningsMenu/nwsWarningCustomizationKey.ts --bundle --format=esm --platform=neutral --outfile=src/nws/nwsWarningCustomizationKey.gen.js"
47
73
  },
48
74
  "author": "Your Name",
49
75
  "license": "MIT",
76
+ "devDependencies": {
77
+ "esbuild": "^0.21.5"
78
+ },
50
79
  "dependencies": {
51
80
  "proj4": "^2.11.0",
52
81
  "fzstd": "^0.1.1"
@@ -8,7 +8,7 @@ import { DICTIONARIES, MODEL_CONFIGS } from './dictionaries.js';
8
8
  import { DEFAULT_COLORMAPS } from './default-colormaps.js';
9
9
  import proj4 from 'proj4';
10
10
  import { processCompressedGrid } from './gridDecodePipeline.js';
11
- import { getBundleId } from './getBundleId';
11
+ import { getBundleId } from './getBundleId.js';
12
12
  import {
13
13
  SATELLITE_FRAMES_URL,
14
14
  buildSatelliteTimelineForSelection,
@@ -115,8 +115,10 @@ export class AguaceroCore extends EventEmitter {
115
115
  super();
116
116
  this.isReactNative = typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
117
117
  this.apiKey = options.apiKey;
118
- /** Passed as CloudFront `userId` for satellite KTX2 URLs (production uses the authenticated account id). */
119
- this.userId = options.userId ?? 'sdk-user';
118
+ /** Base origin for grid HTTP requests (no trailing slash). Node/SSR: sets Origin + Referer so CloudFront can derive a source; browsers usually omit. */
119
+ const siteOriginRaw =
120
+ typeof options.gridRequestSiteOrigin === 'string' ? options.gridRequestSiteOrigin.trim() : '';
121
+ this.gridRequestSiteOrigin = siteOriginRaw ? siteOriginRaw.replace(/\/+$/, '') : null;
120
122
  this.bundleId = getBundleId();
121
123
  this.baseGridUrl = 'https://d3dc62msmxkrd7.cloudfront.net';
122
124
  /** @type {Worker | null} */
@@ -1231,12 +1233,16 @@ export class AguaceroCore extends EventEmitter {
1231
1233
  }
1232
1234
  try {
1233
1235
  const baseUrl = `${this.baseGridUrl}${resourcePath}`;
1234
- const urlWithApiKeyParam = `${baseUrl}?apiKey=${this.apiKey}`;
1236
+ const urlWithApiKeyParam = `${baseUrl}?apiKey=${encodeURIComponent(this.apiKey)}`;
1235
1237
  const headers = { 'x-api-key': this.apiKey };
1236
1238
  if (this.bundleId && this.isReactNative) {
1237
1239
  headers['x-app-identifier'] = this.bundleId;
1238
1240
  }
1239
-
1241
+ if (this.gridRequestSiteOrigin) {
1242
+ headers['Origin'] = this.gridRequestSiteOrigin;
1243
+ headers['Referer'] = `${this.gridRequestSiteOrigin}/`;
1244
+ }
1245
+
1240
1246
  const response = await fetch(urlWithApiKeyParam, {
1241
1247
  headers: headers,
1242
1248
  signal: abortController.signal
@@ -1302,7 +1308,10 @@ export class AguaceroCore extends EventEmitter {
1302
1308
  ? `mrms-${mrmsTimestamp}-${variable}-${effectiveSmoothing}`
1303
1309
  : `${model}-${date}-${run}-${forecastHour}-${variable}-${effectiveSmoothing}`;
1304
1310
 
1305
- const gridDataPromise = this.dataCache.get(dataUrlIdentifier);
1311
+ let gridDataPromise = this.dataCache.get(dataUrlIdentifier);
1312
+ if (!gridDataPromise) {
1313
+ gridDataPromise = await this._loadGridData(this.state);
1314
+ }
1306
1315
  if (!gridDataPromise) return null;
1307
1316
 
1308
1317
  try {
package/src/index.js CHANGED
@@ -40,4 +40,10 @@ export {
40
40
  /** NEXRAD tilt + listing helpers (also importable via subpaths; root re-export fixes Vite/esbuild subpath resolution). */
41
41
  export * from './nexradTilts.js';
42
42
  export * from './nexradTiltCoalesce.js';
43
- export * from './nexrad_support.js';
43
+ export * from './nexrad_support.js';
44
+
45
+ /** NWS watches/warnings (NWWS HTTP + SSE, Mapbox-style paint helpers) — shared by mapsgl and React Native. */
46
+ export { NwsWatchesWarningsOverlay, NWS_DEFAULT_LINE_BEFORE_LAYER_ID } from './nws/NwsWatchesWarningsOverlay.js';
47
+ export * from './nws/nwsSdkConstants.js';
48
+ export * from './nws/nwsAlertsSupport.js';
49
+ export * from './nws/nwsAlertsFetchSpec.js';