@metoceanapi/wxtiles-common 0.0.11 → 0.0.13

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.
@@ -1,4 +1,4 @@
1
- name: Lint
1
+ name: Biome Lint
2
2
 
3
3
  on:
4
4
  pull_request:
@@ -0,0 +1,17 @@
1
+ name: "Validate Pull Request Title"
2
+
3
+ on:
4
+ pull_request_target:
5
+ types: [opened, edited, synchronize]
6
+
7
+ permissions:
8
+ pull-requests: read
9
+
10
+ jobs:
11
+ main:
12
+ name: Validate PR title
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: amannn/action-semantic-pull-request@v5
16
+ env:
17
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package/biome.json CHANGED
@@ -6,7 +6,13 @@
6
6
  "linter": {
7
7
  "enabled": true,
8
8
  "rules": {
9
- "recommended": true
9
+ "recommended": true,
10
+ "suspicious": {
11
+ "noExplicitAny": "off"
12
+ },
13
+ "style": {
14
+ "noParameterAssign": "off"
15
+ }
10
16
  }
11
17
  },
12
18
  "files": {
@@ -14,11 +20,18 @@
14
20
  },
15
21
  "javascript": {
16
22
  "formatter": {
17
- "trailingCommas": "es5",
23
+ "trailingCommas": "all",
18
24
  "quoteStyle": "single",
19
25
  "jsxQuoteStyle": "single",
20
26
  "arrowParentheses": "always",
21
- "lineWidth": 160
27
+ "lineWidth": 160,
28
+ "indentStyle": "space",
29
+ "indentWidth": 2
30
+ }
31
+ },
32
+ "json": {
33
+ "formatter": {
34
+ "indentStyle": "space"
22
35
  }
23
36
  }
24
37
  }
@@ -1,7 +1,7 @@
1
- import type { WxAPI } from "../wxapi";
2
- import { ControlBusy } from "./WxAPIControl/WxAPIControl-busy";
3
- import { ControlDataset } from "./WxAPIControl/WxAPIControl-datasets";
4
- import { ControlFilter } from "./WxAPIControl/WxAPIControl-filter";
1
+ import type { WxAPI } from '../wxapi';
2
+ import { ControlBusy } from './WxAPIControl/WxAPIControl-busy';
3
+ import { ControlDataset } from './WxAPIControl/WxAPIControl-datasets';
4
+ import { ControlFilter } from './WxAPIControl/WxAPIControl-filter';
5
5
 
6
6
  export interface ControlElement {
7
7
  attachToDom(container: HTMLDivElement): void;
@@ -9,11 +9,7 @@ export interface ControlElement {
9
9
  setValue(value: string): void;
10
10
  }
11
11
 
12
- export type onChangeControl = (
13
- dataset: string,
14
- variable: string,
15
- resetStyleAndFlyTo?: boolean
16
- ) => Promise<void>;
12
+ export type onChangeControl = (dataset: string, variable: string, resetStyleAndFlyTo?: boolean) => Promise<void>;
17
13
 
18
14
  // // Leaflet
19
15
  // const apiControl = new WxAPIControl();
@@ -47,16 +43,16 @@ export class WxAPIControl {
47
43
  variable?: string,
48
44
  opts: {
49
45
  filter?: string;
50
- } = {}
46
+ } = {},
51
47
  ) {
52
- const div = document.createElement("div");
53
- div.className = "mapboxgl-ctrl leaflet-control";
54
- div.style.borderStyle = "solid";
55
- div.style.borderColor = "#000";
56
- div.style.backgroundColor = "#aaaaaaaa";
57
- div.style.padding = "5px";
58
- div.style.display = "flex";
59
- div.style.flexDirection = "column";
48
+ const div = document.createElement('div');
49
+ div.className = 'mapboxgl-ctrl leaflet-control';
50
+ div.style.borderStyle = 'solid';
51
+ div.style.borderColor = '#000';
52
+ div.style.backgroundColor = '#aaaaaaaa';
53
+ div.style.padding = '5px';
54
+ div.style.display = 'flex';
55
+ div.style.flexDirection = 'column';
60
56
  this._div = div;
61
57
 
62
58
  // Add filter input field
@@ -132,7 +132,7 @@ export class WxStyleEditorControl {
132
132
  this.parent.onmousemove =
133
133
  this.parent.ondblclick =
134
134
  this.parent.onclick =
135
- (e) => e.stopPropagation?.(); // in case of Leaflet
135
+ (e: MouseEvent | PointerEvent) => e.stopPropagation?.(); // in case of Leaflet
136
136
 
137
137
  const { base } = WxGetColorStyles();
138
138
  this.styleBase = base;
@@ -454,6 +454,7 @@ export class WxStyleEditorControl {
454
454
  protected _getStyleFromDiv(): WxColorStyleWeak {
455
455
  const objFromValue = (field: string) => {
456
456
  try {
457
+ // @ts-ignore
457
458
  return this[field].value ? JSON.parse(this[field].value) : undefined;
458
459
  } catch (e) {
459
460
  console.log(field, " : parsing error: ", e);
@@ -604,7 +605,9 @@ export class WxStyleEditorControl {
604
605
  protected _onDivChange(): void {
605
606
  const style = this._getStyleFromDiv();
606
607
  for (const key of Object.keys(style)) {
608
+ // @ts-ignore
607
609
  if (style[key] === undefined || style[key] === "" || style[key].length === 0) {
610
+ // @ts-ignore
608
611
  delete style[key];
609
612
  }
610
613
  }
@@ -656,6 +659,7 @@ function createEl<K extends keyof HTMLElementTagNameMap>(
656
659
  * treated as distinct and sorted alphabetically in a case-insensitive manner.
657
660
  */
658
661
  // biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
662
+ // @ts-ignore
659
663
  function JSONsort(o: any) {
660
664
  if (Array.isArray(o)) {
661
665
  return o.map(JSONsort);
@@ -669,6 +673,7 @@ function JSONsort(o: any) {
669
673
  return aa === bb ? 0 : aa > bb ? 1 : -1;
670
674
  });
671
675
  return keys.reduce((a, k) => {
676
+ // @ts-ignore
672
677
  a[k] = JSONsort(o[k]);
673
678
  return a;
674
679
  }, {});
@@ -94,7 +94,7 @@ declare interface WxTileSource {
94
94
  *
95
95
  * @returns {Promise<void>} A promise that resolves when the coarse level is set.
96
96
  */
97
- setCoarseLevel(number): Promise<void>;
97
+ setCoarseLevel(level: number): Promise<void>;
98
98
 
99
99
  /**
100
100
  * Registers a listener for a specific event type on the tile source.
package/fonts/barbs.woff CHANGED
Binary file
@@ -1,12 +1,10 @@
1
- import { WXLOG, fetchJson } from "../utils/wxtools";
1
+ import { WXLOG } from "../utils/wxtools";
2
2
  import type {
3
3
  WxAllBoundariesMeta,
4
- WxAllDatasetsShortMetas,
5
4
  WxDatasetMeta,
6
5
  WxVariableMeta,
7
6
  WxDate,
8
7
  WxLayerVarsNames,
9
- WxLayerOptions,
10
8
  WxDataSetManagerOptions,
11
9
  } from "../types";
12
10
  import type { WxAPI } from "../wxapi";
@@ -1,6 +1,6 @@
1
1
  import type { WxAllDatasetsShortMetas } from "../types";
2
2
  import type { WxAPI } from "../wxapi";
3
- import { WXLOG, fetchJson } from "../utils/wxtools";
3
+ import { fetchJson } from "../utils/wxtools";
4
4
 
5
5
  /**
6
6
  * Base class for managing all datasets metadata.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metoceanapi/wxtiles-common",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Common resources shared by wxtiles mapbox and leaflet packages.",
5
5
  "exports": {
6
6
  "./*": "./*.ts",
package/tsconfig.json CHANGED
@@ -1,19 +1,31 @@
1
1
  {
2
- "compilerOptions": {
3
- "outDir": "dist/es",
4
- "allowSyntheticDefaultImports": true,
5
- "moduleResolution": "node",
6
- "declaration": true,
7
- "noImplicitThis": true,
8
- "emitDeclarationOnly": true,
9
- "noImplicitReturns": true,
10
- "strictNullChecks": true,
11
- "strictFunctionTypes": true,
12
- "strictPropertyInitialization": true,
13
- "lib": ["ES2020", "DOM"],
14
- "target": "ES2020",
15
- "sourceMap": true,
16
- "resolveJsonModule": true
17
- },
18
- "exclude": ["node_modules"]
2
+ "compilerOptions": {
3
+ // Output configuration
4
+ "outDir": "dist/es",
5
+ "declaration": true,
6
+ "emitDeclarationOnly": true,
7
+ "sourceMap": true,
8
+
9
+ // Module resolution
10
+ "moduleResolution": "node",
11
+ "allowSyntheticDefaultImports": true,
12
+ "esModuleInterop": true,
13
+ "resolveJsonModule": true,
14
+
15
+ // Target and library
16
+ "target": "ES2020",
17
+ "lib": ["ES2020", "DOM"],
18
+
19
+ // Strict type checking (all enabled by "strict")
20
+ "strict": true,
21
+
22
+ // Additional checks
23
+ "noImplicitOverride": true,
24
+ "noImplicitReturns": true,
25
+ "noUnusedLocals": true,
26
+ "noUnusedParameters": true,
27
+ "noFallthroughCasesInSwitch": true,
28
+ "noUncheckedSideEffectImports": true
29
+ },
30
+ "exclude": ["node_modules", "dist"]
19
31
  }
package/types.ts CHANGED
@@ -326,7 +326,7 @@ export interface WxLngLat {
326
326
  * Used in {@link WxLayerBaseImplementation} cache of the renderes tiles
327
327
  * */
328
328
  export class WxRasterDataCache extends Map<string, WxRasterData> {
329
- clear(): void {
329
+ override clear(): void {
330
330
  WXLOG("TilesCache.clear()");
331
331
 
332
332
  for (const v of this.values()) {
package/utils/qtree.ts CHANGED
@@ -90,7 +90,8 @@ export class QTree {
90
90
  const _seamask = await fetchJson<string>(input, requestInit);
91
91
  this._qtree = qtreeFromString(_seamask, { pos: 0 });
92
92
  } catch (e) {
93
- throw new Error(`Failed to load QTree: ${e.message}`);
93
+ const message = e instanceof Error ? e.message : String(e);
94
+ throw new Error(`Failed to load QTree: ${message}`);
94
95
  }
95
96
 
96
97
  this._qtreedepth = getTreeDepth(this._qtree);
@@ -49,21 +49,21 @@ function ft_printIm(raw: ArrayLike<number>, n: number, comment: string) {
49
49
  }
50
50
 
51
51
  function ft_Uint16ArrayRandom() {
52
- const seed = 1;
52
+ // const seed = 1;
53
53
  // const rnd = () => Math.floor(Math.abs(Math.sin(seed++)) * 32000 + 32000);
54
54
  const rnd = () => Math.floor(Math.random() * 32000);
55
55
  return new Uint16Array(258 * 258).map(rnd);
56
56
  }
57
57
 
58
58
  function ft_Uint16ArrayAscent() {
59
- return new Uint16Array(258 * 258).map((v, i) => (i % 258) + ~~(i / 258));
59
+ return new Uint16Array(258 * 258).map((_v, i) => (i % 258) + ~~(i / 258));
60
60
  }
61
61
 
62
- function ft_Uint16ArrayDescent() {
63
- return new Uint16Array(258 * 258).map(
64
- (v, i) => 514 - ((i % 258) + ~~(i / 258)),
65
- );
66
- }
62
+ // function ft_Uint16ArrayDescent() {
63
+ // return new Uint16Array(258 * 258).map(
64
+ // (_v, i) => 514 - ((i % 258) + ~~(i / 258)),
65
+ // );
66
+ // }
67
67
 
68
68
  function ft_Uint32ArrayCompare(a: ArrayLike<number>, b: ArrayLike<number>) {
69
69
  if (a.length !== b.length) return false;
@@ -102,9 +102,9 @@ function ft_buildDataIntegralAscent(): DataIntegral {
102
102
  return new DataIntegral(ft_Uint16ArrayAscent(), 0, 1, 1);
103
103
  }
104
104
 
105
- function ft_buildDataIntegralDescend(): DataIntegral {
106
- return new DataIntegral(ft_Uint16ArrayDescent(), 0, 1, 1);
107
- }
105
+ // function ft_buildDataIntegralDescend(): DataIntegral {
106
+ // return new DataIntegral(ft_Uint16ArrayDescent(), 0, 1, 1);
107
+ // }
108
108
 
109
109
  function ft_buildDataIntegralRandom(): DataIntegral {
110
110
  return new DataIntegral(ft_Uint16ArrayRandom(), 0, 1, 1);
package/utils/wxtools.ts CHANGED
@@ -1053,6 +1053,7 @@ export function getClosestTimeString(
1053
1053
  * Logging helper
1054
1054
  * */
1055
1055
  // biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
1056
+ // @ts-ignore
1056
1057
  export let WXLOG = (...args: any[]) => {};
1057
1058
 
1058
1059
  /**
package/wxapi.ts CHANGED
@@ -1,5 +1,6 @@
1
+ // @ts-ignore
1
2
  import "@metoceanapi/wxtiles-common/wxtiles.css";
2
-
3
+ import { WxAllDatasetsManager } from "./managers/WxAllDatasetsManager";
3
4
  import { QTree } from "./utils/qtree";
4
5
  import {
5
6
  WXLOG,
@@ -10,9 +11,7 @@ import {
10
11
  loadImageData,
11
12
  uriXYZ,
12
13
  } from "./utils/wxtools";
13
- import type { WxAPIOptions, WxDatasetMeta, WxDataSetManagerOptions } from "./types";
14
- import { BaseDatasetManager } from "./managers/BaseDatasetManager";
15
- import { WxAllDatasetsManager } from "./managers/WxAllDatasetsManager";
14
+ import type { WxAPIOptions, WxDataSetManagerOptions, WxDatasetMeta } from "./types";
16
15
 
17
16
  /**
18
17
  * WxAPI is an initialisation object for the library. See {@link WxAPIOptions} for options.
@@ -1,3 +1,5 @@
1
+ import type { BaseDatasetManager } from "../managers/BaseDatasetManager";
2
+ import type { WxDatasetMeta, WxDate, WxEventType, WxLayerVarsNames, WxRasterData, WxRasterDataCache, WxRequestInit, WxVariableMeta } from "../types";
1
3
  import {
2
4
  WXLOG,
3
5
  type WxColorStyleStrict,
@@ -6,8 +8,6 @@ import {
6
8
  type XYZ,
7
9
  } from "../utils/wxtools";
8
10
  import type { WxLayer } from "./wxlayer";
9
- import type { WxRequestInit, WxDatasetMeta, WxVariableMeta, WxDate, WxLayerVarsNames, WxLngLat, WxRasterDataCache, WxTileInfo, WxLayerBaseAPI, WxRasterData, WxLayerOptions, WxEventType } from "../types";
10
- import type { BaseDatasetManager } from "../managers/BaseDatasetManager";
11
11
 
12
12
  // biome-ignore lint/suspicious/noExplicitAny: necessary for mixins
13
13
  type GenericConstraintConstructor<T> = new (...args: any[]) => T;
@@ -288,8 +288,8 @@ export function WxLayerBaseImplementationMixin<WxDatasetManagerT extends BaseDat
288
288
  * A dummy function to be replaced by ancestor classes.
289
289
  */
290
290
  async _reloadVisible(
291
- requestInit?: WxRequestInit,
292
- redraw?: boolean,
291
+ _requestInit?: WxRequestInit,
292
+ _redraw?: boolean,
293
293
  ): Promise<void> {}
294
294
 
295
295
  /**
@@ -336,12 +336,14 @@ export function WxLayerBaseImplementationMixin<WxDatasetManagerT extends BaseDat
336
336
  // it's ok if the tile is not found. Just return empty tile, or...
337
337
 
338
338
  // ...or, rethrow 'AbortError' to the framework to handle
339
+ // @ts-ignore
339
340
  if (e.name === "AbortError") {
340
341
  throw e;
341
342
  }
342
343
 
343
344
  // ...or, if the loadTile->loadImage->throw 'reason' is 'instance-not-found', try to update wxdatasetManager, then update the layer
344
345
  // if we aren't in the middle of updating wxdatasetManager (others may initiate update as well)
346
+ // @ts-ignore
345
347
  if (e.reason === "instance-not-found" && !this._needUpdateDSManager) {
346
348
  this._needUpdateDSManager = true;
347
349
  WXLOG(
@@ -150,8 +150,8 @@ function interpolatorSquare(
150
150
  d: number,
151
151
  dxt: number,
152
152
  dyt: number,
153
- dmin: number,
154
- dmul: number,
153
+ _dmin: number,
154
+ _dmul: number,
155
155
  ): number {
156
156
  // 0 1
157
157
  // a --- b default version a --- b flipped version
@@ -221,7 +221,7 @@ function _printIsolineTextWithStroke(
221
221
  val: string,
222
222
  ctx: CanvasRenderingContext2D,
223
223
  // biome-ignore lint/suspicious/noExplicitAny: Suppressing for specific use case
224
- z: any,
224
+ _z: any,
225
225
  ): void {
226
226
  ctx.strokeText(val, 0, 0);
227
227
  } // _printIsolineTextWithStroke
@@ -293,8 +293,12 @@ function _printVectorsStatic<WxDatasetManagerT extends BaseDatasetManager>(
293
293
  ? style.vectorFactor * 0.5
294
294
  : 0.2; /*0.2 to fit font*/
295
295
  const vecCode =
296
- Math.min(~~(CLUT.DataToKnots(vecLen) * sm), 25 /* to fit .ttf */) +
297
- 65; /* A */
296
+ Math.min(
297
+ style.vectorType === "barbs"
298
+ ? Math.round(CLUT.DataToKnots(vecLen) * sm) // nearest 5 kn
299
+ : ~~(CLUT.DataToKnots(vecLen) * sm),
300
+ 25 /* to fit .ttf */,
301
+ ) + 65; /* A */
298
302
  const vecChar = String.fromCharCode(vecCode);
299
303
  switch (style.vectorColor) {
300
304
  case "inverted":