@metoceanapi/wxtiles-common 0.0.7 → 0.0.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utils/wxtools.ts +22 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metoceanapi/wxtiles-common",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Common resources shared by wxtiles mapbox and leaflet packages.",
5
5
  "exports": {
6
6
  "./*": "./*.ts",
package/utils/wxtools.ts CHANGED
@@ -183,9 +183,19 @@ export interface WxColorStylesStrict {
183
183
  [name: string]: WxColorStyleStrict | undefined;
184
184
  }
185
185
 
186
- let _units: WxUnits;
187
- let _colorSchemes: WxColorSchemes;
188
- let _colorStylesUnrolled: WxColorStylesStrict;
186
+
187
+ /*const context = {
188
+ [_units: WxUnits]: __units_default_preset,
189
+ [_colorSchemes: WxColorSchemes]: null,
190
+ [_colorStylesUnrolled: WxColorStylesStrict]: null,
191
+ }
192
+ */
193
+ const context = {
194
+ _units: __units_default_preset,
195
+ _colorSchemes: __colorSchemes_default_preset,
196
+ _colorStylesUnrolled: __colorStyles_default_preset,
197
+ wxlogging: false,
198
+ }
189
199
 
190
200
  /** Options for the wxtiles library */
191
201
  export interface WxTilesLibOptions {
@@ -209,14 +219,14 @@ export function WxTilesLibSetup({
209
219
  colorSchemes = {},
210
220
  }: WxTilesLibOptions = {}): void {
211
221
  WXLOG("WxTile lib setup: start");
212
- _units = Object.assign({}, __units_default_preset, units);
213
- _colorSchemes = Object.assign(
222
+ context._units = Object.assign({}, __units_default_preset, units);
223
+ context._colorSchemes = Object.assign(
214
224
  {},
215
225
  colorSchemes,
216
226
  __colorSchemes_default_preset,
217
227
  );
218
228
  const toUnroll = Object.assign({}, colorStyles, __colorStyles_default_preset);
219
- _colorStylesUnrolled = unrollStylesParent(toUnroll);
229
+ context._colorStylesUnrolled = unrollStylesParent(toUnroll);
220
230
  WXLOG("WxTile lib setup: styles unrolled");
221
231
 
222
232
  // Make sure fonts are loaded & ready!
@@ -236,14 +246,14 @@ export function WxTilesLibSetup({
236
246
  * Get all {@link WxColorStylesStrict} used by the library
237
247
  * */
238
248
  export function WxGetColorStyles(): WxColorStylesStrict {
239
- return _colorStylesUnrolled;
249
+ return context._colorStylesUnrolled;
240
250
  }
241
251
 
242
252
  /**
243
253
  * Get all {@link WxColorSchemes} used by the library
244
254
  * */
245
255
  export function WxGetColorSchemes(): WxColorSchemes {
246
- return _colorSchemes;
256
+ return context._colorSchemes;
247
257
  }
248
258
 
249
259
  /** A function type with extra properties. */
@@ -279,7 +289,7 @@ export function makeConverter(
279
289
  return c; // trivial
280
290
  }
281
291
 
282
- const localUnitsCopy = Object.assign({}, _units, customUnits);
292
+ const localUnitsCopy = Object.assign({}, context._units, customUnits);
283
293
  const fromUnit = localUnitsCopy[from];
284
294
  const toUnit = localUnitsCopy[to];
285
295
  if (!fromUnit || !toUnit) {
@@ -1039,7 +1049,6 @@ export function getClosestTimeString(
1039
1049
  );
1040
1050
  }
1041
1051
 
1042
- let wxlogging = false;
1043
1052
  /**
1044
1053
  * Logging helper
1045
1054
  * */
@@ -1058,9 +1067,9 @@ export let WXLOG = (...args: any[]) => {};
1058
1067
  * */
1059
1068
  // biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
1060
1069
  export function WxTilesLogging(on?: boolean | ((...args: any[]) => void)) {
1061
- wxlogging = !!on;
1062
- console.log("WXLOGing", wxlogging);
1063
- WXLOG = typeof on === "function" ? on : wxlogging ? console.log : () => {};
1070
+ context.wxlogging = !!on;
1071
+ console.log("WXLOGing", context.wxlogging);
1072
+ WXLOG = typeof on === "function" ? on : context.wxlogging ? console.log : () => {};
1064
1073
  }
1065
1074
 
1066
1075
  /**