@loaders.gl/wkt 4.2.0-alpha.5 → 4.2.0-beta.1

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 (43) hide show
  1. package/dist/dist.dev.js +25 -9
  2. package/dist/dist.min.js +2 -2
  3. package/dist/hex-wkb-loader.d.ts +23 -2
  4. package/dist/hex-wkb-loader.d.ts.map +1 -1
  5. package/dist/hex-wkb-loader.js +2 -0
  6. package/dist/index.cjs +26 -10
  7. package/dist/index.cjs.map +2 -2
  8. package/dist/lib/parse-wkb.js +6 -6
  9. package/dist/lib/utils/binary-reader.js +4 -0
  10. package/dist/lib/utils/binary-writer.js +4 -2
  11. package/dist/lib/utils/version.js +1 -1
  12. package/dist/twkb-loader.d.ts +41 -4
  13. package/dist/twkb-loader.d.ts.map +1 -1
  14. package/dist/twkb-loader.js +2 -0
  15. package/dist/twkb-writer.d.ts +16 -2
  16. package/dist/twkb-writer.d.ts.map +1 -1
  17. package/dist/wkb-loader.d.ts +41 -3
  18. package/dist/wkb-loader.d.ts.map +1 -1
  19. package/dist/wkb-loader.js +2 -0
  20. package/dist/wkb-writer.d.ts +16 -2
  21. package/dist/wkb-writer.d.ts.map +1 -1
  22. package/dist/wkt-crs-loader.d.ts +20 -3
  23. package/dist/wkt-crs-loader.d.ts.map +1 -1
  24. package/dist/wkt-crs-loader.js +2 -0
  25. package/dist/wkt-crs-writer.d.ts +17 -3
  26. package/dist/wkt-crs-writer.d.ts.map +1 -1
  27. package/dist/wkt-loader.d.ts +50 -4
  28. package/dist/wkt-loader.d.ts.map +1 -1
  29. package/dist/wkt-loader.js +3 -1
  30. package/dist/wkt-worker.js +7 -3
  31. package/dist/wkt-writer.d.ts +18 -2
  32. package/dist/wkt-writer.d.ts.map +1 -1
  33. package/package.json +5 -4
  34. package/src/hex-wkb-loader.ts +4 -2
  35. package/src/lib/parse-wkb.ts +6 -6
  36. package/src/twkb-loader.ts +7 -4
  37. package/src/twkb-writer.ts +2 -2
  38. package/src/wkb-loader.ts +6 -4
  39. package/src/wkb-writer.ts +2 -2
  40. package/src/wkt-crs-loader.ts +4 -2
  41. package/src/wkt-crs-writer.ts +2 -2
  42. package/src/wkt-loader.ts +13 -7
  43. package/src/wkt-writer.ts +2 -2
@@ -16,7 +16,10 @@ export type WKBLoaderOptions = LoaderOptions & {
16
16
  /**
17
17
  * Worker loader for WKB (Well-Known Binary)
18
18
  */
19
- export const TWKBWorkerLoader: Loader<Geometry, never, WKBLoaderOptions> = {
19
+ export const TWKBWorkerLoader = {
20
+ dataType: null as unknown as Geometry,
21
+ batchType: null as never,
22
+
20
23
  name: 'TWKB (Tiny Well-Known Binary)',
21
24
  id: 'twkb',
22
25
  module: 'wkt',
@@ -32,13 +35,13 @@ export const TWKBWorkerLoader: Loader<Geometry, never, WKBLoaderOptions> = {
32
35
  shape: 'binary-geometry' // 'geojson-geometry'
33
36
  }
34
37
  }
35
- };
38
+ } as const satisfies Loader<Geometry, never, WKBLoaderOptions>;
36
39
 
37
40
  /**
38
41
  * Loader for WKB (Well-Known Binary)
39
42
  */
40
- export const TWKBLoader: LoaderWithParser<BinaryGeometry | Geometry, never, WKBLoaderOptions> = {
43
+ export const TWKBLoader = {
41
44
  ...TWKBWorkerLoader,
42
45
  parse: async (arrayBuffer: ArrayBuffer) => parseTWKBGeometry(arrayBuffer),
43
46
  parseSync: parseTWKBGeometry
44
- };
47
+ } as const satisfies LoaderWithParser<BinaryGeometry | Geometry, never, WKBLoaderOptions>;
@@ -17,7 +17,7 @@ export type TWKBWriterOptions = WriterOptions & {
17
17
  /**
18
18
  * WKB exporter
19
19
  */
20
- export const TWKBWriter: WriterWithEncoder<Geometry, never, TWKBWriterOptions> = {
20
+ export const TWKBWriter = {
21
21
  name: 'TWKB (Tiny Well Known Binary)',
22
22
  id: 'twkb',
23
23
  module: 'wkt',
@@ -33,4 +33,4 @@ export const TWKBWriter: WriterWithEncoder<Geometry, never, TWKBWriterOptions> =
33
33
  hasM: false
34
34
  }
35
35
  }
36
- };
36
+ } as const satisfies WriterWithEncoder<Geometry, never, TWKBWriterOptions>;
package/src/wkb-loader.ts CHANGED
@@ -18,7 +18,9 @@ export type WKBLoaderOptions = LoaderOptions & {
18
18
  /**
19
19
  * Worker loader for WKB (Well-Known Binary)
20
20
  */
21
- export const WKBWorkerLoader: Loader<Geometry | BinaryGeometry, never, WKBLoaderOptions> = {
21
+ export const WKBWorkerLoader = {
22
+ dataType: null as unknown as Geometry | BinaryGeometry,
23
+ batchType: null as never,
22
24
  name: 'WKB',
23
25
  id: 'wkb',
24
26
  module: 'wkt',
@@ -34,13 +36,13 @@ export const WKBWorkerLoader: Loader<Geometry | BinaryGeometry, never, WKBLoader
34
36
  shape: 'binary-geometry' // 'geojson-geometry'
35
37
  }
36
38
  }
37
- };
39
+ } as const satisfies Loader<Geometry | BinaryGeometry, never, WKBLoaderOptions>;
38
40
 
39
41
  /**
40
42
  * Loader for WKB (Well-Known Binary)
41
43
  */
42
- export const WKBLoader: LoaderWithParser<BinaryGeometry | Geometry, never, WKBLoaderOptions> = {
44
+ export const WKBLoader = {
43
45
  ...WKBWorkerLoader,
44
46
  parse: async (arrayBuffer: ArrayBuffer) => parseWKB(arrayBuffer),
45
47
  parseSync: parseWKB
46
- };
48
+ } as const satisfies LoaderWithParser<BinaryGeometry | Geometry, never, WKBLoaderOptions>;
package/src/wkb-writer.ts CHANGED
@@ -23,7 +23,7 @@ export type WKBWriterOptions = WriterOptions & {
23
23
  /**
24
24
  * WKB exporter
25
25
  */
26
- export const WKBWriter: WriterWithEncoder<Geometry | Feature, never, WriterOptions> = {
26
+ export const WKBWriter = {
27
27
  name: 'WKB (Well Known Binary)',
28
28
  id: 'wkb',
29
29
  module: 'wkt',
@@ -41,4 +41,4 @@ export const WKBWriter: WriterWithEncoder<Geometry | Feature, never, WriterOptio
41
41
  encodeSync(data: Geometry | Feature, options?: WriterOptions): ArrayBuffer {
42
42
  return encodeWKB(data, options?.wkb);
43
43
  }
44
- };
44
+ } as const satisfies WriterWithEncoder<Geometry | Feature, never, WriterOptions>;
@@ -16,7 +16,9 @@ export type WKTCRSLoaderOptions = LoaderOptions & {
16
16
  * @see OGC Standard: https://www.ogc.org/standards/wkt-crs
17
17
  * @see Wikipedia Page: https://en.wikipedia.org/wiki/Well-known_text_representation_of_coordinate_reference_systems
18
18
  */
19
- export const WKTCRSLoader: LoaderWithParser<WKTCRS, never, WKTCRSLoaderOptions> = {
19
+ export const WKTCRSLoader = {
20
+ dataType: null as unknown as WKTCRS,
21
+ batchType: null as never,
20
22
  name: 'WKT CRS (Well-Known Text Coordinate Reference System)',
21
23
  id: 'wkt-crs',
22
24
  module: 'wkt-crs',
@@ -32,4 +34,4 @@ export const WKTCRSLoader: LoaderWithParser<WKTCRS, never, WKTCRSLoaderOptions>
32
34
  parse: async (arrayBuffer, options) =>
33
35
  parseWKTCRS(new TextDecoder().decode(arrayBuffer), options?.['wkt-crs']),
34
36
  parseTextSync: (string, options) => parseWKTCRS(string, options?.['wkt-crs'])
35
- };
37
+ } as const satisfies LoaderWithParser<WKTCRS, never, WKTCRSLoaderOptions>;
@@ -18,7 +18,7 @@ export type WKTCRSWriterOptions = WriterOptions & {
18
18
  * @see OGC Standard: https://www.ogc.org/standards/wkt-crs
19
19
  * @see Wikipedia Page: https://en.wikipedia.org/wiki/Well-known_text_representation_of_coordinate_reference_systems
20
20
  */
21
- export const WKTCRSWriter: WriterWithEncoder<WKTCRS, never, WKTCRSWriterOptions> = {
21
+ export const WKTCRSWriter = {
22
22
  name: 'WKT CRS (Well-Known Text Coordinate Reference System)',
23
23
  id: 'wkt-crs',
24
24
  module: 'wkt-crs',
@@ -36,4 +36,4 @@ export const WKTCRSWriter: WriterWithEncoder<WKTCRS, never, WKTCRSWriterOptions>
36
36
  encodeSync: (wktcrs, options) =>
37
37
  new TextEncoder().encode(encodeWKTCRS(wktcrs, options?.['wkt-crs'])),
38
38
  encodeTextSync: (wktcrs, options) => encodeWKTCRS(wktcrs, options?.['wkt-crs'])
39
- };
39
+ } as const satisfies WriterWithEncoder<WKTCRS, never, WKTCRSWriterOptions>;
package/src/wkt-loader.ts CHANGED
@@ -9,18 +9,24 @@ import {Geometry} from '@loaders.gl/schema';
9
9
  import {isWKT, WKT_MAGIC_STRINGS} from './lib/parse-wkt';
10
10
 
11
11
  export type WKTLoaderOptions = LoaderOptions & {
12
- /** Options for the WKT parser */
12
+ /** Options for the WKTLoader */
13
13
  wkt?: {
14
+ /** Shape of returned geometry */
14
15
  shape?: 'geojson-geometry'; // 'binary-geometry'
15
16
  /** Whether to add any CRS, if found, as undocumented CRS property on the returned geometry */
16
17
  crs?: boolean;
18
+ /** Override the URL to the worker bundle (by default loads from unpkg.com) */
19
+ workerUrl?: string;
17
20
  };
18
21
  };
19
22
 
20
23
  /**
21
24
  * Well-Known text worker loader
22
25
  */
23
- export const WKTWorkerLoader: Loader<Geometry, never, WKTLoaderOptions> = {
26
+ export const WKTWorkerLoader = {
27
+ dataType: null as unknown as Geometry,
28
+ batchType: null as never,
29
+
24
30
  name: 'WKT (Well-Known Text)',
25
31
  id: 'wkt',
26
32
  module: 'wkt',
@@ -38,13 +44,13 @@ export const WKTWorkerLoader: Loader<Geometry, never, WKTLoaderOptions> = {
38
44
  crs: true
39
45
  }
40
46
  }
41
- };
47
+ } as const satisfies Loader<Geometry, never, WKTLoaderOptions>;
42
48
 
43
49
  /**
44
50
  * Well-Known text loader
45
51
  */
46
- export const WKTLoader: LoaderWithParser<Geometry, never, WKTLoaderOptions> = {
52
+ export const WKTLoader = {
47
53
  ...WKTWorkerLoader,
48
- parse: async (arrayBuffer, options) => parseWKT(new TextDecoder().decode(arrayBuffer), options),
49
- parseTextSync: parseWKT
50
- };
54
+ parse: async (arrayBuffer, options?) => parseWKT(new TextDecoder().decode(arrayBuffer), options),
55
+ parseTextSync: (string: string, options?) => parseWKT(string, options)
56
+ } as const satisfies LoaderWithParser<Geometry, never, WKTLoaderOptions>;
package/src/wkt-writer.ts CHANGED
@@ -14,7 +14,7 @@ export type WKTWriterOptions = WriterOptions & {
14
14
  /**
15
15
  * WKT exporter
16
16
  */
17
- export const WKTWriter: WriterWithEncoder<Geometry, never, WKTWriterOptions> = {
17
+ export const WKTWriter = {
18
18
  name: 'WKT (Well Known Text)',
19
19
  id: 'wkt',
20
20
  module: 'wkt',
@@ -27,7 +27,7 @@ export const WKTWriter: WriterWithEncoder<Geometry, never, WKTWriterOptions> = {
27
27
  options: {
28
28
  wkt: {}
29
29
  }
30
- };
30
+ } as const satisfies WriterWithEncoder<Geometry, never, WKTWriterOptions>;
31
31
 
32
32
  function encodeWKTSync(geometry: Geometry): ArrayBuffer {
33
33
  return new TextEncoder().encode(encodeWKT(geometry)).buffer;