@loaders.gl/ogc 5.0.0-beta.1 → 5.0.0-beta.10

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 (249) hide show
  1. package/README.md +7 -5
  2. package/dist/{wms/gml-loader.cjs → gml-loader.cjs} +2803 -3808
  3. package/dist/gml-loader.cjs.map +6 -0
  4. package/dist/gml-loader.d.ts +2 -0
  5. package/dist/gml-loader.d.ts.map +1 -0
  6. package/dist/gml-loader.js +2 -0
  7. package/dist/gml-loader.js.map +1 -0
  8. package/dist/index.cjs +346 -4378
  9. package/dist/index.cjs.map +3 -3
  10. package/dist/stac/index.cjs +22 -1044
  11. package/dist/stac/index.cjs.map +3 -3
  12. package/dist/stac/index.d.ts +2 -2
  13. package/dist/stac/index.d.ts.map +1 -1
  14. package/dist/stac/index.js +1 -1
  15. package/dist/stac/index.js.map +1 -1
  16. package/dist/stac/{stac-source-loader-types.d.ts → stac-loader-types.d.ts} +6 -6
  17. package/dist/stac/stac-loader-types.d.ts.map +1 -0
  18. package/dist/stac/{stac-source-loader-types.js → stac-loader-types.js} +8 -8
  19. package/dist/stac/stac-loader-types.js.map +1 -0
  20. package/dist/stac/{stac-source.d.ts → stac-loader.d.ts} +8 -8
  21. package/dist/stac/stac-loader.d.ts.map +1 -0
  22. package/dist/stac/{stac-source.js → stac-loader.js} +7 -7
  23. package/dist/stac/stac-loader.js.map +1 -0
  24. package/dist/{stac/stac-source.cjs → stac-loader.cjs} +288 -791
  25. package/dist/stac-loader.cjs.map +6 -0
  26. package/dist/stac-loader.d.ts +2 -0
  27. package/dist/stac-loader.d.ts.map +1 -0
  28. package/dist/stac-loader.js +2 -0
  29. package/dist/stac-loader.js.map +1 -0
  30. package/dist/wms/bundled.cjs +2639 -3558
  31. package/dist/wms/bundled.cjs.map +3 -3
  32. package/dist/wms/bundled.d.ts +3 -3
  33. package/dist/wms/bundled.d.ts.map +1 -1
  34. package/dist/wms/bundled.js.map +1 -1
  35. package/dist/wms/csw-capabilities-loader-with-parser.d.ts +5 -4
  36. package/dist/wms/csw-capabilities-loader-with-parser.d.ts.map +1 -1
  37. package/dist/wms/csw-capabilities-loader-with-parser.js.map +1 -1
  38. package/dist/wms/csw-capabilities-loader.d.ts +6 -4
  39. package/dist/wms/csw-capabilities-loader.d.ts.map +1 -1
  40. package/dist/wms/csw-capabilities-loader.js +1 -1
  41. package/dist/wms/csw-capabilities-loader.js.map +1 -1
  42. package/dist/wms/csw-domain-loader-with-parser.d.ts +5 -4
  43. package/dist/wms/csw-domain-loader-with-parser.d.ts.map +1 -1
  44. package/dist/wms/csw-domain-loader-with-parser.js.map +1 -1
  45. package/dist/wms/csw-domain-loader.d.ts +6 -4
  46. package/dist/wms/csw-domain-loader.d.ts.map +1 -1
  47. package/dist/wms/csw-domain-loader.js +1 -1
  48. package/dist/wms/csw-domain-loader.js.map +1 -1
  49. package/dist/wms/{csw-source-loader.d.ts → csw-loader.d.ts} +15 -13
  50. package/dist/wms/csw-loader.d.ts.map +1 -0
  51. package/dist/wms/{csw-source-loader.js → csw-loader.js} +5 -5
  52. package/dist/wms/csw-loader.js.map +1 -0
  53. package/dist/wms/csw-records-loader-with-parser.d.ts +5 -4
  54. package/dist/wms/csw-records-loader-with-parser.d.ts.map +1 -1
  55. package/dist/wms/csw-records-loader-with-parser.js.map +1 -1
  56. package/dist/wms/csw-records-loader.d.ts +6 -4
  57. package/dist/wms/csw-records-loader.d.ts.map +1 -1
  58. package/dist/wms/csw-records-loader.js +1 -1
  59. package/dist/wms/csw-records-loader.js.map +1 -1
  60. package/dist/wms/gml-loader-types.d.ts +17 -11
  61. package/dist/wms/gml-loader-types.d.ts.map +1 -1
  62. package/dist/wms/gml-loader-types.js +5 -3
  63. package/dist/wms/gml-loader-types.js.map +1 -1
  64. package/dist/wms/gml-loader.d.ts +11 -9
  65. package/dist/wms/gml-loader.d.ts.map +1 -1
  66. package/dist/wms/gml-loader.js +21 -15
  67. package/dist/wms/gml-loader.js.map +1 -1
  68. package/dist/wms/index.cjs +3241 -4266
  69. package/dist/wms/index.cjs.map +3 -3
  70. package/dist/wms/index.d.ts +21 -21
  71. package/dist/wms/index.d.ts.map +1 -1
  72. package/dist/wms/index.js +10 -12
  73. package/dist/wms/index.js.map +1 -1
  74. package/dist/wms/lib/deprecated/image-source-compatibility.d.ts +1 -1
  75. package/dist/wms/lib/deprecated/image-source-compatibility.js +1 -1
  76. package/dist/wms/lib/parsers/csw/parse-csw-capabilities.d.ts +1 -1
  77. package/dist/wms/lib/parsers/csw/parse-csw-capabilities.d.ts.map +1 -1
  78. package/dist/wms/lib/parsers/csw/parse-csw-domain.d.ts +1 -1
  79. package/dist/wms/lib/parsers/csw/parse-csw-domain.d.ts.map +1 -1
  80. package/dist/wms/lib/parsers/csw/parse-csw-records.d.ts +1 -1
  81. package/dist/wms/lib/parsers/csw/parse-csw-records.d.ts.map +1 -1
  82. package/dist/wms/lib/parsers/csw/parse-csw-records.js +2 -5
  83. package/dist/wms/lib/parsers/csw/parse-csw-records.js.map +1 -1
  84. package/dist/wms/lib/parsers/csw/parse-exception-report.js +2 -2
  85. package/dist/wms/lib/parsers/csw/parse-exception-report.js.map +1 -1
  86. package/dist/wms/lib/parsers/wms/parse-wms-error.d.ts.map +1 -1
  87. package/dist/wms/lib/parsers/wms/parse-wms-error.js +3 -1
  88. package/dist/wms/lib/parsers/wms/parse-wms-error.js.map +1 -1
  89. package/dist/wms/lib/parsers/wms/parse-wms-layer-description.d.ts +1 -1
  90. package/dist/wms/lib/parsers/wms/parse-wms-layer-description.d.ts.map +1 -1
  91. package/dist/wms/lib/parsers/wmts/parse-wmts-capabilities.js +1 -1
  92. package/dist/wms/lib/parsers/wmts/parse-wmts-capabilities.js.map +1 -1
  93. package/dist/wms/lib/parsers/xml/parse-xml-text.d.ts +1 -1
  94. package/dist/wms/lib/parsers/xml/parse-xml-text.d.ts.map +1 -1
  95. package/dist/wms/lib/parsers/xml/parse-xml-text.js +2 -1
  96. package/dist/wms/lib/parsers/xml/parse-xml-text.js.map +1 -1
  97. package/dist/wms/managed-vector-source.js +2 -2
  98. package/dist/wms/managed-vector-source.js.map +1 -1
  99. package/dist/wms/{ogc-api-coverages-source-loader.d.ts → ogc-api-coverages-loader.d.ts} +7 -7
  100. package/dist/wms/ogc-api-coverages-loader.d.ts.map +1 -0
  101. package/dist/wms/{ogc-api-coverages-source-loader.js → ogc-api-coverages-loader.js} +4 -4
  102. package/dist/wms/ogc-api-coverages-loader.js.map +1 -0
  103. package/dist/wms/{ogc-api-edr-source-loader.d.ts → ogc-api-edr-loader.d.ts} +7 -7
  104. package/dist/wms/ogc-api-edr-loader.d.ts.map +1 -0
  105. package/dist/wms/{ogc-api-edr-source-loader.js → ogc-api-edr-loader.js} +4 -4
  106. package/dist/wms/ogc-api-edr-loader.js.map +1 -0
  107. package/dist/wms/{ogc-api-source-loader.d.ts → ogc-api-loaders.d.ts} +11 -11
  108. package/dist/wms/ogc-api-loaders.d.ts.map +1 -0
  109. package/dist/wms/{ogc-api-source-loader.js → ogc-api-loaders.js} +8 -8
  110. package/dist/wms/ogc-api-loaders.js.map +1 -0
  111. package/dist/wms/service-runtime.js +18 -18
  112. package/dist/wms/service-runtime.js.map +1 -1
  113. package/dist/wms/unbundled.cjs +319 -3334
  114. package/dist/wms/unbundled.cjs.map +3 -3
  115. package/dist/wms/unbundled.d.ts +3 -3
  116. package/dist/wms/unbundled.d.ts.map +1 -1
  117. package/dist/wms/{wcs-source-loader.d.ts → wcs-coverage-loader.d.ts} +6 -6
  118. package/dist/wms/wcs-coverage-loader.d.ts.map +1 -0
  119. package/dist/wms/{wcs-source-loader.js → wcs-coverage-loader.js} +5 -5
  120. package/dist/wms/wcs-coverage-loader.js.map +1 -0
  121. package/dist/wms/wfs-capabilities-loader-with-parser.d.ts +4 -3
  122. package/dist/wms/wfs-capabilities-loader-with-parser.d.ts.map +1 -1
  123. package/dist/wms/wfs-capabilities-loader-with-parser.js.map +1 -1
  124. package/dist/wms/wfs-capabilities-loader.d.ts +5 -3
  125. package/dist/wms/wfs-capabilities-loader.d.ts.map +1 -1
  126. package/dist/wms/wfs-capabilities-loader.js +1 -1
  127. package/dist/wms/wfs-capabilities-loader.js.map +1 -1
  128. package/dist/wms/{wfs-source-loader.d.ts → wfs-loader.d.ts} +10 -39
  129. package/dist/wms/wfs-loader.d.ts.map +1 -0
  130. package/dist/wms/{wfs-source-loader.js → wfs-loader.js} +7 -38
  131. package/dist/wms/wfs-loader.js.map +1 -0
  132. package/dist/wms/wip/wcs-capabilities-loader.js +1 -1
  133. package/dist/wms/wip/wcs-capabilities-loader.js.map +1 -1
  134. package/dist/wms/wip/wmts-capabilities-loader-with-parser.d.ts +2 -2
  135. package/dist/wms/wip/wmts-capabilities-loader-with-parser.d.ts.map +1 -1
  136. package/dist/wms/wip/wmts-capabilities-loader-with-parser.js.map +1 -1
  137. package/dist/wms/wip/wmts-capabilities-loader.d.ts +2 -2
  138. package/dist/wms/wip/wmts-capabilities-loader.d.ts.map +1 -1
  139. package/dist/wms/wip/wmts-capabilities-loader.js +1 -1
  140. package/dist/wms/wip/wmts-capabilities-loader.js.map +1 -1
  141. package/dist/wms/wms-capabilities-loader-with-parser.d.ts +2 -1
  142. package/dist/wms/wms-capabilities-loader-with-parser.d.ts.map +1 -1
  143. package/dist/wms/wms-capabilities-loader.d.ts +3 -1
  144. package/dist/wms/wms-capabilities-loader.d.ts.map +1 -1
  145. package/dist/wms/wms-capabilities-loader.js +1 -1
  146. package/dist/wms/wms-capabilities-loader.js.map +1 -1
  147. package/dist/wms/wms-error-loader-with-parser.d.ts +5 -4
  148. package/dist/wms/wms-error-loader-with-parser.d.ts.map +1 -1
  149. package/dist/wms/wms-error-loader-with-parser.js.map +1 -1
  150. package/dist/wms/wms-error-loader.d.ts +6 -4
  151. package/dist/wms/wms-error-loader.d.ts.map +1 -1
  152. package/dist/wms/wms-error-loader.js +1 -1
  153. package/dist/wms/wms-error-loader.js.map +1 -1
  154. package/dist/wms/{wms-source-loader.d.ts → wms-loader.d.ts} +8 -10
  155. package/dist/wms/wms-loader.d.ts.map +1 -0
  156. package/dist/wms/{wms-source-loader.js → wms-loader.js} +8 -8
  157. package/dist/wms/wms-loader.js.map +1 -0
  158. package/dist/wms/wmts-capabilities-loader.d.ts +1 -1
  159. package/dist/wms/wmts-capabilities-loader.d.ts.map +1 -1
  160. package/dist/wms/wmts-capabilities-loader.js +1 -1
  161. package/dist/wms/wmts-capabilities-loader.js.map +1 -1
  162. package/dist/wms/{wmts-source-loader.d.ts → wmts-loader.d.ts} +9 -9
  163. package/dist/wms/wmts-loader.d.ts.map +1 -0
  164. package/dist/wms/{wmts-source-loader.js → wmts-loader.js} +5 -5
  165. package/dist/wms/wmts-loader.js.map +1 -0
  166. package/dist/{wms/wmts-capabilities-loader-with-parser.cjs → wmts-capabilities-loader-with-parser.cjs} +227 -179
  167. package/dist/wmts-capabilities-loader-with-parser.cjs.map +6 -0
  168. package/dist/wmts-capabilities-loader-with-parser.d.ts +2 -0
  169. package/dist/wmts-capabilities-loader-with-parser.d.ts.map +1 -0
  170. package/dist/wmts-capabilities-loader-with-parser.js +3 -0
  171. package/dist/wmts-capabilities-loader-with-parser.js.map +1 -0
  172. package/package.json +29 -21
  173. package/src/gml-loader.ts +1 -0
  174. package/src/stac/index.ts +2 -2
  175. package/src/stac/{stac-source-loader-types.ts → stac-loader-types.ts} +9 -9
  176. package/src/stac/{stac-source.ts → stac-loader.ts} +10 -10
  177. package/src/stac-loader.ts +1 -0
  178. package/src/wms/bundled.ts +6 -3
  179. package/src/wms/csw-capabilities-loader-with-parser.ts +6 -5
  180. package/src/wms/csw-capabilities-loader.ts +3 -3
  181. package/src/wms/csw-domain-loader-with-parser.ts +5 -5
  182. package/src/wms/csw-domain-loader.ts +3 -3
  183. package/src/wms/{csw-source-loader.ts → csw-loader.ts} +11 -11
  184. package/src/wms/csw-records-loader-with-parser.ts +5 -5
  185. package/src/wms/csw-records-loader.ts +3 -3
  186. package/src/wms/gml-loader-types.ts +10 -8
  187. package/src/wms/gml-loader.ts +33 -19
  188. package/src/wms/index.ts +35 -31
  189. package/src/wms/lib/deprecated/image-source-compatibility.ts +1 -1
  190. package/src/wms/lib/parsers/csw/parse-csw-capabilities.ts +1 -1
  191. package/src/wms/lib/parsers/csw/parse-csw-domain.ts +1 -1
  192. package/src/wms/lib/parsers/csw/parse-csw-records.ts +3 -6
  193. package/src/wms/lib/parsers/csw/parse-exception-report.ts +2 -2
  194. package/src/wms/lib/parsers/wms/parse-wms-error.ts +3 -1
  195. package/src/wms/lib/parsers/wms/parse-wms-layer-description.ts +1 -1
  196. package/src/wms/lib/parsers/wmts/parse-wmts-capabilities.ts +1 -1
  197. package/src/wms/lib/parsers/xml/parse-xml-text.ts +3 -2
  198. package/src/wms/managed-vector-source.ts +2 -2
  199. package/src/wms/{ogc-api-coverages-source-loader.ts → ogc-api-coverages-loader.ts} +11 -8
  200. package/src/wms/{ogc-api-edr-source-loader.ts → ogc-api-edr-loader.ts} +7 -7
  201. package/src/wms/{ogc-api-source-loader.ts → ogc-api-loaders.ts} +13 -13
  202. package/src/wms/service-runtime.ts +18 -18
  203. package/src/wms/unbundled.ts +3 -3
  204. package/src/wms/{wcs-source-loader.ts → wcs-coverage-loader.ts} +7 -7
  205. package/src/wms/wfs-capabilities-loader-with-parser.ts +5 -4
  206. package/src/wms/wfs-capabilities-loader.ts +2 -2
  207. package/src/wms/{wfs-source-loader.ts → wfs-loader.ts} +15 -45
  208. package/src/wms/wip/wms-feature-info-loader-with-parser.ts +1 -1
  209. package/src/wms/wip/wms-feature-info-loader.ts +1 -1
  210. package/src/wms/wip/wms-layer-description-loader-with-parser.ts +1 -1
  211. package/src/wms/wip/wms-layer-description-loader.ts +1 -1
  212. package/src/wms/wip/wmts-capabilities-loader-with-parser.ts +5 -5
  213. package/src/wms/wip/wmts-capabilities-loader.ts +3 -3
  214. package/src/wms/wms-capabilities-loader-with-parser.ts +1 -1
  215. package/src/wms/wms-capabilities-loader.ts +1 -1
  216. package/src/wms/wms-error-loader-with-parser.ts +8 -7
  217. package/src/wms/wms-error-loader.ts +2 -2
  218. package/src/wms/{wms-source-loader.ts → wms-loader.ts} +15 -28
  219. package/src/wms/wmts-capabilities-loader.ts +3 -3
  220. package/src/wms/{wmts-source-loader.ts → wmts-loader.ts} +11 -11
  221. package/src/wmts-capabilities-loader-with-parser.ts +2 -0
  222. package/dist/stac/stac-source-loader-types.d.ts.map +0 -1
  223. package/dist/stac/stac-source-loader-types.js.map +0 -1
  224. package/dist/stac/stac-source.cjs.map +0 -6
  225. package/dist/stac/stac-source.d.ts.map +0 -1
  226. package/dist/stac/stac-source.js.map +0 -1
  227. package/dist/wms/csw-source-loader.d.ts.map +0 -1
  228. package/dist/wms/csw-source-loader.js.map +0 -1
  229. package/dist/wms/gml-loader.cjs.map +0 -6
  230. package/dist/wms/lib/deprecated/create-image-source.d.ts +0 -27
  231. package/dist/wms/lib/deprecated/create-image-source.d.ts.map +0 -1
  232. package/dist/wms/lib/deprecated/create-image-source.js +0 -44
  233. package/dist/wms/lib/deprecated/create-image-source.js.map +0 -1
  234. package/dist/wms/ogc-api-coverages-source-loader.d.ts.map +0 -1
  235. package/dist/wms/ogc-api-coverages-source-loader.js.map +0 -1
  236. package/dist/wms/ogc-api-edr-source-loader.d.ts.map +0 -1
  237. package/dist/wms/ogc-api-edr-source-loader.js.map +0 -1
  238. package/dist/wms/ogc-api-source-loader.d.ts.map +0 -1
  239. package/dist/wms/ogc-api-source-loader.js.map +0 -1
  240. package/dist/wms/wcs-source-loader.d.ts.map +0 -1
  241. package/dist/wms/wcs-source-loader.js.map +0 -1
  242. package/dist/wms/wfs-source-loader.d.ts.map +0 -1
  243. package/dist/wms/wfs-source-loader.js.map +0 -1
  244. package/dist/wms/wms-source-loader.d.ts.map +0 -1
  245. package/dist/wms/wms-source-loader.js.map +0 -1
  246. package/dist/wms/wmts-capabilities-loader-with-parser.cjs.map +0 -6
  247. package/dist/wms/wmts-source-loader.d.ts.map +0 -1
  248. package/dist/wms/wmts-source-loader.js.map +0 -1
  249. package/src/wms/lib/deprecated/create-image-source.ts +0 -75
@@ -1,16 +1,10 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __esm = (fn, res, err) => function __init() {
7
- if (err) throw err[0];
8
- try {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
- } catch (e) {
11
- throw err = [e], e;
12
- }
13
- };
14
8
  var __export = (target, all) => {
15
9
  for (var name in all)
16
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -23,9 +17,29 @@ var __copyProps = (to, from, except, desc) => {
23
17
  }
24
18
  return to;
25
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
26
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
29
 
30
+ // dist/stac-loader.js
31
+ var stac_loader_exports = {};
32
+ __export(stac_loader_exports, {
33
+ STACLoader: () => STACLoaderWithParser,
34
+ STACLoaderWithParser: () => STACLoaderWithParser,
35
+ STACSource: () => STACSource
36
+ });
37
+ module.exports = __toCommonJS(stac_loader_exports);
38
+
28
39
  // ../core/src/loader-utils/lib/log-utils/log.ts
40
+ var import_log = require("probe.gl/log");
41
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
42
+ var version = VERSION[0] >= "0" && VERSION[0] <= "9" ? `v${VERSION}` : "";
29
43
  function createLog() {
30
44
  const log2 = new import_log.Log({ id: "loaders.gl" });
31
45
  globalThis.loaders ||= {};
@@ -35,26 +49,41 @@ function createLog() {
35
49
  globalThis.probe.loaders = log2;
36
50
  return log2;
37
51
  }
38
- var import_log, VERSION, version, log;
39
- var init_log = __esm({
40
- "../core/src/loader-utils/lib/log-utils/log.ts"() {
41
- "use strict";
42
- import_log = require("probe.gl/log");
43
- VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
44
- version = VERSION[0] >= "0" && VERSION[0] <= "9" ? `v${VERSION}` : "";
45
- log = createLog();
52
+ var log = createLog();
53
+ var NullLog = class {
54
+ /** Discards debug messages. */
55
+ log() {
56
+ return ignoreMessage;
46
57
  }
47
- });
58
+ /** Discards informational messages. */
59
+ info() {
60
+ return ignoreMessage;
61
+ }
62
+ /** Discards messages marked to be emitted once. */
63
+ once() {
64
+ return ignoreMessage;
65
+ }
66
+ /** Discards warnings. */
67
+ warn() {
68
+ return ignoreMessage;
69
+ }
70
+ /** Discards errors. */
71
+ error() {
72
+ return ignoreMessage;
73
+ }
74
+ };
75
+ function ignoreMessage() {
76
+ }
77
+ var nullLog = new NullLog();
78
+ function getLoaderLog(options) {
79
+ var _a;
80
+ const logger = (_a = options == null ? void 0 : options.core) == null ? void 0 : _a.log;
81
+ return logger === null ? nullLog : logger || log;
82
+ }
48
83
 
49
84
  // ../core/src/loader-utils/lib/javascript-utils/is-type.ts
50
- var isObject, isPureObject;
51
- var init_is_type = __esm({
52
- "../core/src/loader-utils/lib/javascript-utils/is-type.ts"() {
53
- "use strict";
54
- isObject = (value) => value !== null && typeof value === "object";
55
- isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
56
- }
57
- });
85
+ var isObject = (value) => value !== null && typeof value === "object";
86
+ var isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
58
87
 
59
88
  // ../core/src/loader-utils/lib/option-utils/merge-options.ts
60
89
  function mergeOptions(baseOptions, newOptions) {
@@ -78,12 +107,6 @@ function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
78
107
  }
79
108
  return options;
80
109
  }
81
- var init_merge_options = __esm({
82
- "../core/src/loader-utils/lib/option-utils/merge-options.ts"() {
83
- "use strict";
84
- init_is_type();
85
- }
86
- });
87
110
 
88
111
  // ../core/src/loader-utils/lib/request-utils/authentication.ts
89
112
  function resolveCredentials(credentials, authentications = []) {
@@ -121,13 +144,10 @@ function isAuthentication(credential) {
121
144
  if (credential.type === "request") return typeof credential.authenticate === "function";
122
145
  return (credential.type === "header" || credential.type === "query-parameter") && typeof credential.name === "string" && (typeof credential.token === "string" || typeof credential.token === "function") && Array.isArray(credential.refreshStatusCodes);
123
146
  }
124
- var init_authentication = __esm({
125
- "../core/src/loader-utils/lib/request-utils/authentication.ts"() {
126
- "use strict";
127
- }
128
- });
129
147
 
130
148
  // ../core/src/loader-utils/lib/request-utils/request-credentials.ts
149
+ var AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
150
+ var refreshPromises = /* @__PURE__ */ new WeakMap();
131
151
  function createAuthenticatedFetch(options) {
132
152
  const suppliedFetch = options.fetch || ((url, requestOptions) => fetch(url, requestOptions));
133
153
  const existingMetadata = suppliedFetch[AUTHENTICATED_FETCH];
@@ -217,7 +237,7 @@ function createAuthenticatedFetch(options) {
217
237
  }
218
238
  function getAuthenticatedFetch(options = {}) {
219
239
  var _a, _b, _c;
220
- const fetchOption = options.fetch ?? ((_a = options.core) == null ? void 0 : _a.fetch);
240
+ const fetchOption = (_a = options.core) == null ? void 0 : _a.fetch;
221
241
  let fetchFunction;
222
242
  if (typeof fetchOption === "function") {
223
243
  fetchFunction = fetchOption;
@@ -353,17 +373,10 @@ function isReplayableRequest(options) {
353
373
  if (!["GET", "HEAD", "OPTIONS", "PUT", "DELETE"].includes(method)) return false;
354
374
  return !(options.body && typeof ReadableStream !== "undefined" && options.body instanceof ReadableStream);
355
375
  }
356
- var AUTHENTICATED_FETCH, refreshPromises;
357
- var init_request_credentials = __esm({
358
- "../core/src/loader-utils/lib/request-utils/request-credentials.ts"() {
359
- "use strict";
360
- init_authentication();
361
- AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
362
- refreshPromises = /* @__PURE__ */ new WeakMap();
363
- }
364
- });
365
376
 
366
377
  // ../core/src/loader-utils/lib/path-utils/file-aliases.ts
378
+ var pathPrefix = "";
379
+ var fileAliases = {};
367
380
  function resolvePath(filename) {
368
381
  for (const alias in fileAliases) {
369
382
  if (filename.startsWith(alias)) {
@@ -376,16 +389,95 @@ function resolvePath(filename) {
376
389
  }
377
390
  return filename;
378
391
  }
379
- var pathPrefix, fileAliases;
380
- var init_file_aliases = __esm({
381
- "../core/src/loader-utils/lib/path-utils/file-aliases.ts"() {
382
- "use strict";
383
- pathPrefix = "";
384
- fileAliases = {};
385
- }
386
- });
387
392
 
388
393
  // ../core/src/loader-utils/lib/sources/data-source.ts
394
+ var UNAVAILABLE_CORE_API = {
395
+ fetchFile: unavailableCoreApiMethod("fetchFile"),
396
+ parse: unavailableCoreApiMethod("parse"),
397
+ parseFile: unavailableCoreApiMethod("parseFile"),
398
+ parseSync: unavailableCoreApiMethod("parseSync"),
399
+ parseInBatches: unavailableCoreApiMethod("parseInBatches"),
400
+ load: unavailableCoreApiMethod("load"),
401
+ loadInBatches: unavailableCoreApiMethod("loadInBatches")
402
+ };
403
+ var DataSource = class _DataSource {
404
+ static defaultOptions = {
405
+ core: {
406
+ type: "auto",
407
+ attributions: [],
408
+ loaders: [],
409
+ onError: void 0
410
+ }
411
+ };
412
+ optionsType;
413
+ options;
414
+ data;
415
+ url;
416
+ /** Stable query-visible name, resolved without fetching source data. */
417
+ name;
418
+ /** Shared parser options derived from the source options, excluding source-only core controls. */
419
+ loadOptions;
420
+ /** A resolved fetch function extracted from the shared core options. */
421
+ fetch;
422
+ /** Shared source-level runtime hooks, when supplied by the source factory. */
423
+ coreApi;
424
+ /** Whether a real CoreAPI instance was injected by the integration layer. */
425
+ hasCoreApi;
426
+ _needsRefresh = true;
427
+ constructor(data, options, defaultOptions, coreApi) {
428
+ this.options = mergeOptions(
429
+ mergeOptions(_DataSource.defaultOptions, defaultOptions || {}),
430
+ options
431
+ );
432
+ this.data = data;
433
+ this.url = typeof data === "string" ? resolvePath(data) : "";
434
+ this.name = getDataSourceName(data, this.options);
435
+ const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
436
+ this.loadOptions = loadOptions;
437
+ const fetch2 = getFetchFunction(loadOptions);
438
+ this.coreApi = coreApi || UNAVAILABLE_CORE_API;
439
+ this.hasCoreApi = Boolean(coreApi);
440
+ this.fetch = fetch2;
441
+ }
442
+ setProps(options) {
443
+ var _a;
444
+ if (((_a = options.core) == null ? void 0 : _a.name) !== void 0 && options.core.name !== this.name)
445
+ throw new Error("Data source names are fixed at creation.");
446
+ const mergedOptions = mergeOptions(this.options, options);
447
+ const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(mergedOptions));
448
+ this.options = mergedOptions;
449
+ this.loadOptions = loadOptions;
450
+ this.fetch = getFetchFunction(loadOptions);
451
+ this.setNeedsRefresh();
452
+ }
453
+ /** Mark this data source as needing a refresh (redraw) */
454
+ setNeedsRefresh() {
455
+ this._needsRefresh = true;
456
+ }
457
+ /**
458
+ * Does this data source need refreshing?
459
+ * @note The specifics of the refresh mechanism depends on type of data source
460
+ */
461
+ getNeedsRefresh(clear = true) {
462
+ const needsRefresh = this._needsRefresh;
463
+ if (clear) {
464
+ this._needsRefresh = false;
465
+ }
466
+ return needsRefresh;
467
+ }
468
+ /** Reports a source-level failure through the configured callback or the shared logger. */
469
+ reportError(error, message) {
470
+ var _a;
471
+ const normalizedError = normalizeError(error, message);
472
+ const callback = (_a = this.options.core) == null ? void 0 : _a.onError;
473
+ if (callback) {
474
+ callback(normalizedError, this);
475
+ } else {
476
+ getLoaderLog(this.options).warn(`${this.constructor.name}: ${normalizedError.message}`)();
477
+ }
478
+ return normalizedError;
479
+ }
480
+ };
389
481
  function getFetchFunction(options) {
390
482
  return getAuthenticatedFetch(options);
391
483
  }
@@ -400,23 +492,13 @@ function getSourceLoaderOptions(options) {
400
492
  if (options == null ? void 0 : options.core) {
401
493
  loadOptions.core = { ...options.core };
402
494
  const parserCore = loadOptions.core;
403
- for (const key of ["type", "attributions", "loaders", "onError", "loadOptions"]) {
495
+ for (const key of ["type", "name", "attributions", "loaders", "onError", "loadOptions"]) {
404
496
  delete parserCore[key];
405
497
  }
406
498
  if (Object.keys(parserCore).length === 0) {
407
499
  delete loadOptions.core;
408
500
  }
409
501
  }
410
- const topLevelBaseUri = typeof loadOptions.baseUri === "string" ? loadOptions.baseUri : void 0;
411
- const topLevelBaseUrl = typeof loadOptions.baseUrl === "string" ? loadOptions.baseUrl : void 0;
412
- if (topLevelBaseUri !== void 0 || topLevelBaseUrl !== void 0) {
413
- loadOptions.core ||= {};
414
- if (loadOptions.core.baseUrl === void 0) {
415
- loadOptions.core.baseUrl = topLevelBaseUrl ?? topLevelBaseUri;
416
- }
417
- delete loadOptions.baseUri;
418
- delete loadOptions.baseUrl;
419
- }
420
502
  return loadOptions;
421
503
  }
422
504
  function normalizeError(error, message) {
@@ -431,647 +513,62 @@ function normalizeError(error, message) {
431
513
  function unavailableCoreApiMethod(methodName) {
432
514
  return () => {
433
515
  throw new Error(
434
- `CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.createDataSource().`
516
+ `CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.createDataSourceSync().`
435
517
  );
436
518
  };
437
519
  }
438
- var UNAVAILABLE_CORE_API, DataSource;
439
- var init_data_source = __esm({
440
- "../core/src/loader-utils/lib/sources/data-source.ts"() {
441
- "use strict";
442
- init_merge_options();
443
- init_file_aliases();
444
- init_log();
445
- init_request_credentials();
446
- init_authentication();
447
- UNAVAILABLE_CORE_API = {
448
- fetchFile: unavailableCoreApiMethod("fetchFile"),
449
- parse: unavailableCoreApiMethod("parse"),
450
- parseFile: unavailableCoreApiMethod("parseFile"),
451
- parseSync: unavailableCoreApiMethod("parseSync"),
452
- parseInBatches: unavailableCoreApiMethod("parseInBatches"),
453
- load: unavailableCoreApiMethod("load"),
454
- loadInBatches: unavailableCoreApiMethod("loadInBatches")
455
- };
456
- DataSource = class _DataSource {
457
- static defaultOptions = {
458
- core: {
459
- type: "auto",
460
- attributions: [],
461
- loaders: [],
462
- onError: void 0
463
- }
464
- };
465
- optionsType;
466
- options;
467
- data;
468
- url;
469
- /** Shared parser options derived from the source options, excluding source-only core controls. */
470
- loadOptions;
471
- /** A resolved fetch function extracted from the shared core options. */
472
- fetch;
473
- /** Shared source-level runtime hooks, when supplied by the source factory. */
474
- coreApi;
475
- /** Whether a real CoreAPI instance was injected by the integration layer. */
476
- hasCoreApi;
477
- _needsRefresh = true;
478
- constructor(data, options, defaultOptions, coreApi) {
479
- this.options = mergeOptions(
480
- mergeOptions(_DataSource.defaultOptions, defaultOptions || {}),
481
- options
482
- );
483
- this.data = data;
484
- this.url = typeof data === "string" ? resolvePath(data) : "";
485
- const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
486
- this.loadOptions = loadOptions;
487
- const fetch2 = getFetchFunction(loadOptions);
488
- this.coreApi = coreApi || UNAVAILABLE_CORE_API;
489
- this.hasCoreApi = Boolean(coreApi);
490
- this.fetch = fetch2;
491
- }
492
- setProps(options) {
493
- const mergedOptions = mergeOptions(this.options, options);
494
- const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(mergedOptions));
495
- this.options = mergedOptions;
496
- this.loadOptions = loadOptions;
497
- this.fetch = getFetchFunction(loadOptions);
498
- this.setNeedsRefresh();
499
- }
500
- /** Mark this data source as needing a refresh (redraw) */
501
- setNeedsRefresh() {
502
- this._needsRefresh = true;
503
- }
504
- /**
505
- * Does this data source need refreshing?
506
- * @note The specifics of the refresh mechanism depends on type of data source
507
- */
508
- getNeedsRefresh(clear = true) {
509
- const needsRefresh = this._needsRefresh;
510
- if (clear) {
511
- this._needsRefresh = false;
512
- }
513
- return needsRefresh;
514
- }
515
- /** Reports a source-level failure through the configured callback or the shared logger. */
516
- reportError(error, message) {
517
- var _a;
518
- const normalizedError = normalizeError(error, message);
519
- const callback = (_a = this.options.core) == null ? void 0 : _a.onError;
520
- if (callback) {
521
- callback(normalizedError, this);
522
- } else {
523
- log.warn(`${this.constructor.name}: ${normalizedError.message}`)();
524
- }
525
- return normalizedError;
526
- }
527
- };
528
- }
529
- });
530
-
531
- // ../core/src/loader-utils/index.ts
532
- var init_loader_utils = __esm({
533
- "../core/src/loader-utils/index.ts"() {
534
- "use strict";
535
- init_data_source();
536
- }
537
- });
538
-
539
- // src/stac/stac-source-loader-types.ts
540
- async function preloadSTACSourceLoader() {
541
- const { STACSourceLoaderWithParser: STACSourceLoaderWithParser3 } = await Promise.resolve().then(() => (init_stac_source(), stac_source_exports));
542
- return STACSourceLoaderWithParser3;
543
- }
544
- var VERSION2, STACSourceLoader;
545
- var init_stac_source_loader_types = __esm({
546
- "src/stac/stac-source-loader-types.ts"() {
547
- "use strict";
548
- VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
549
- STACSourceLoader = {
550
- dataType: null,
551
- batchType: null,
552
- name: "STACSourceLoader",
553
- id: "stac-source",
554
- module: "ogc",
555
- version: VERSION2,
556
- extensions: ["json"],
557
- mimeTypes: ["application/json", "application/geo+json"],
558
- type: "stac",
559
- fromUrl: true,
560
- fromBlob: false,
561
- options: {
562
- stac: {
563
- maxDepth: 32,
564
- maxRequests: 1e3
565
- }
566
- },
567
- defaultOptions: {
568
- stac: {
569
- maxDepth: 32,
570
- maxRequests: 1e3
520
+ function getDataSourceName(data, options) {
521
+ var _a, _b, _c;
522
+ const explicitName = (_a = options.core) == null ? void 0 : _a.name;
523
+ if (explicitName !== void 0) {
524
+ if (typeof explicitName !== "string" || !explicitName.trim())
525
+ throw new Error("Data source name must be a non-empty string.");
526
+ return explicitName;
527
+ }
528
+ if (data && typeof data === "object") {
529
+ const named = data;
530
+ if (typeof named.name === "string" && named.name.trim())
531
+ return data instanceof Blob ? removeFileExtension(named.name) : named.name;
532
+ const metadata = (_b = named.schema) == null ? void 0 : _b.metadata;
533
+ const embeddedName = metadata instanceof Map ? metadata.get("name") : metadata == null ? void 0 : metadata.name;
534
+ if (typeof embeddedName === "string" && embeddedName.trim()) return embeddedName;
535
+ }
536
+ if (typeof data === "string") {
537
+ try {
538
+ const url = new URL(data.replace(/\\/g, "/"), "https://source.invalid/");
539
+ if (!["data:", "blob:"].includes(url.protocol)) {
540
+ let basename = url.pathname.split("/").filter(Boolean).pop();
541
+ if (basename) {
542
+ try {
543
+ basename = decodeURIComponent(basename);
544
+ } catch {
545
+ }
546
+ return removeFileExtension(basename);
571
547
  }
572
- },
573
- testURL: (url) => /(?:^|[/_.-])stac(?:[/_.?#-]|$)|\/(?:catalog|collection)\.json(?:$|[?#])/i.test(url),
574
- preload: preloadSTACSourceLoader,
575
- createDataSource(_data, _options, _coreApi) {
576
- throw new Error(
577
- "STACSourceLoader requires async load() or an explicit @loaders.gl/ogc/stac/stac-source import"
578
- );
579
548
  }
580
- };
581
- }
582
- });
583
-
584
- // src/stac/stac-source.ts
585
- var stac_source_exports = {};
586
- __export(stac_source_exports, {
587
- STACSource: () => STACSource,
588
- STACSourceLoader: () => STACSourceLoaderWithParser,
589
- STACSourceLoaderWithParser: () => STACSourceLoaderWithParser
590
- });
591
- function createSearchRequest(link, baseUrl, query) {
592
- const { signal: _signal, ...body } = query;
593
- return {
594
- url: resolveUrl(link.href, baseUrl),
595
- method: link.method || "POST",
596
- headers: link.headers,
597
- body
598
- };
599
- }
600
- function createNextRequest(link, baseUrl, previousRequest) {
601
- const linkBody = link.body || {};
602
- return {
603
- url: resolveUrl(link.href, baseUrl),
604
- method: link.method || previousRequest.method,
605
- headers: { ...previousRequest.headers, ...link.headers },
606
- body: link.merge ? { ...previousRequest.body, ...linkBody } : link.body
607
- };
608
- }
609
- function getRequestKey(request) {
610
- return `${request.method} ${request.url} ${JSON.stringify(request.body || {})}`;
611
- }
612
- function appendQuery(url, body) {
613
- const parsedUrl = new URL(url);
614
- for (const [key, value] of Object.entries(body)) {
615
- if (value !== void 0) {
616
- parsedUrl.searchParams.set(key, Array.isArray(value) ? value.join(",") : String(value));
617
- }
618
- }
619
- return parsedUrl.href;
620
- }
621
- function resolveUrl(url, baseUrl) {
622
- return new URL(url, baseUrl).href;
623
- }
624
- function findLink(links, relation) {
625
- return links.find((link) => link.rel === relation);
626
- }
627
- function assertResponse(response, url) {
628
- if (!response.ok) {
629
- throw new Error(`STAC request failed (${response.status} ${response.statusText}): ${url}`);
630
- }
631
- }
632
- function validateTraversalLimit(name, value) {
633
- if (!Number.isSafeInteger(value) || value < 1) {
634
- throw new Error(`STAC ${name} must be a positive integer`);
635
- }
636
- }
637
- function throwIfAborted(signal) {
638
- if (signal == null ? void 0 : signal.aborted) {
639
- throw signal.reason || new DOMException("The operation was aborted", "AbortError");
640
- }
641
- }
642
- function waitForPromiseWithSignal(promise, signal) {
643
- if (!signal) {
644
- return promise;
645
- }
646
- throwIfAborted(signal);
647
- return new Promise((resolve, reject) => {
648
- const handleAbort = () => reject(signal.reason || new DOMException("The operation was aborted", "AbortError"));
649
- signal.addEventListener("abort", handleAbort, { once: true });
650
- void promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", handleAbort));
651
- });
652
- }
653
- function validateObject(value, url) {
654
- if (!isRecord(value)) {
655
- throw new Error(`Invalid STAC JSON document: ${url}`);
656
- }
657
- if (value.type === "Catalog" || value.type === "Collection") {
658
- if (typeof value.id !== "string" || !Array.isArray(value.links)) {
659
- throw new Error(`Invalid STAC Catalog or Collection: ${url}`);
660
- }
661
- return value;
662
- }
663
- if (value.type === "Feature") {
664
- if (typeof value.id !== "string" || !isRecord(value.assets) || !Array.isArray(value.links)) {
665
- throw new Error(`Invalid STAC Item: ${url}`);
666
- }
667
- return value;
668
- }
669
- if (value.type === "FeatureCollection") {
670
- return validateItemCollection(value, url);
671
- }
672
- throw new Error(`Unsupported STAC object type at ${url}`);
673
- }
674
- function validateItemCollection(value, url) {
675
- if (!isRecord(value) || value.type !== "FeatureCollection" || !Array.isArray(value.features) || !Array.isArray(value.links)) {
676
- throw new Error(`Invalid STAC ItemCollection: ${url}`);
677
- }
678
- for (const item of value.features) {
679
- if (!isItem(item)) {
680
- throw new Error(`Invalid STAC Item in ItemCollection: ${url}`);
681
- }
682
- }
683
- return value;
684
- }
685
- function validateCollections(value, url) {
686
- if (!isRecord(value) || !Array.isArray(value.collections) || !Array.isArray(value.links)) {
687
- throw new Error(`Invalid STAC Collections response: ${url}`);
688
- }
689
- if (!value.collections.every(isCollection)) {
690
- throw new Error(`Invalid Collection in STAC Collections response: ${url}`);
691
- }
692
- return value;
693
- }
694
- function isCatalog(value) {
695
- return isRecord(value) && value.type === "Catalog" && Array.isArray(value.links);
696
- }
697
- function isCollection(value) {
698
- return isRecord(value) && value.type === "Collection" && Array.isArray(value.links);
699
- }
700
- function isItem(value) {
701
- return isRecord(value) && value.type === "Feature" && typeof value.id === "string" && isRecord(value.assets) && Array.isArray(value.links);
702
- }
703
- function isItemCollection(value) {
704
- return isRecord(value) && value.type === "FeatureCollection" && Array.isArray(value.features) && Array.isArray(value.links);
705
- }
706
- function isRecord(value) {
707
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
708
- }
709
- function matchesItem(item, query) {
710
- if (query.ids && !query.ids.includes(item.id)) {
711
- return false;
712
- }
713
- if (query.collections && (!item.collection || !query.collections.includes(item.collection))) {
714
- return false;
715
- }
716
- if (query.bbox && item.bbox && !intersectsBoundingBox(query.bbox, item.bbox)) {
717
- return false;
718
- }
719
- return !query.datetime || intersectsDatetime(query.datetime, item);
720
- }
721
- function intersectsBoundingBox(left, right) {
722
- const leftMaximumX = left.length === 6 ? left[3] : left[2];
723
- const leftMaximumY = left.length === 6 ? left[4] : left[3];
724
- const rightMaximumX = right.length === 6 ? right[3] : right[2];
725
- const rightMaximumY = right.length === 6 ? right[4] : right[3];
726
- return !(leftMaximumX < right[0] || rightMaximumX < left[0] || leftMaximumY < right[1] || rightMaximumY < left[1]);
727
- }
728
- function intersectsDatetime(datetime, item) {
729
- const queryInterval = parseDatetimeInterval(datetime, true);
730
- const itemDatetime = item.properties.datetime;
731
- const itemInterval = typeof itemDatetime === "string" ? parseDatetimeInterval(itemDatetime, false) : parseItemDatetimeInterval(item);
732
- if (!itemInterval) {
733
- return true;
734
- }
735
- return queryInterval[0] <= itemInterval[1] && itemInterval[0] <= queryInterval[1];
736
- }
737
- function parseDatetimeInterval(datetime, throwOnInvalid) {
738
- const parts = datetime.split("/");
739
- const start = parts[0] === ".." ? Number.NEGATIVE_INFINITY : Date.parse(parts[0]);
740
- const endPart = parts.length > 1 ? parts[1] : parts[0];
741
- const end = endPart === ".." ? Number.POSITIVE_INFINITY : Date.parse(endPart);
742
- if (parts.length > 2 || Number.isNaN(start) || Number.isNaN(end) || start > end) {
743
- if (throwOnInvalid) {
744
- throw new Error(`Invalid STAC datetime: ${datetime}`);
549
+ } catch {
745
550
  }
746
- return [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY];
747
551
  }
748
- return [start, end];
552
+ return ((_c = options.core) == null ? void 0 : _c.type) && options.core.type !== "auto" ? options.core.type : "source";
749
553
  }
750
- function parseItemDatetimeInterval(item) {
751
- const start = item.properties.start_datetime;
752
- const end = item.properties.end_datetime;
753
- if (!start || !end) {
754
- return null;
755
- }
756
- return parseDatetimeInterval(`${start}/${end}`, false);
554
+ function removeFileExtension(name) {
555
+ const extension = name.lastIndexOf(".");
556
+ return extension > 0 ? name.slice(0, extension) : name;
757
557
  }
758
- var DEFAULT_MAX_DEPTH, DEFAULT_MAX_REQUESTS, _preloadSTACSourceLoader, _createMetadataDataSource, STACSourceLoaderBase, STACSourceLoaderWithParser, STACSource;
759
- var init_stac_source = __esm({
760
- "src/stac/stac-source.ts"() {
761
- "use strict";
762
- init_loader_utils();
763
- init_stac_source_loader_types();
764
- DEFAULT_MAX_DEPTH = 32;
765
- DEFAULT_MAX_REQUESTS = 1e3;
766
- ({
767
- preload: _preloadSTACSourceLoader,
768
- createDataSource: _createMetadataDataSource,
769
- ...STACSourceLoaderBase
770
- } = STACSourceLoader);
771
- STACSourceLoaderWithParser = {
772
- ...STACSourceLoaderBase,
773
- createDataSource(data, options, coreApi) {
774
- if (typeof data !== "string") {
775
- throw new Error("STACSource requires a catalog URL");
776
- }
777
- return new STACSource(data, options, coreApi);
778
- }
779
- };
780
- STACSource = class extends DataSource {
781
- /** Features exposed through the protocol-neutral catalog interface. */
782
- capabilities = Object.freeze({
783
- search: true,
784
- pagination: true,
785
- hierarchy: true,
786
- spatialFilter: true,
787
- temporalFilter: true,
788
- textFilter: false,
789
- cql2Filter: false,
790
- collections: true,
791
- assets: true
792
- });
793
- /** Cached root initialization shared by metadata and query methods. */
794
- rootPromise = null;
795
- /** Source document URL retained for resolving relative links and assets. */
796
- documentUrls = /* @__PURE__ */ new WeakMap();
797
- /** Creates a source for a static STAC root or STAC API landing page. */
798
- constructor(url, options, coreApi) {
799
- super(url, options, STACSourceLoaderWithParser.defaultOptions, coreApi);
800
- }
801
- /** Returns the cached root Catalog or Collection. */
802
- async getRoot(options = {}) {
803
- throwIfAborted(options.signal);
804
- if (!this.rootPromise) {
805
- const rootPromise = this.fetchObject(this.url).then((object) => {
806
- if (!isCatalog(object) && !isCollection(object)) {
807
- throw new Error(`STAC root must be a Catalog or Collection: ${this.url}`);
808
- }
809
- return object;
810
- });
811
- this.rootPromise = rootPromise;
812
- void rootPromise.catch(() => {
813
- if (this.rootPromise === rootPromise) {
814
- this.rootPromise = null;
815
- }
816
- });
817
- }
818
- return await waitForPromiseWithSignal(this.rootPromise, options.signal);
819
- }
820
- /** Returns root metadata and whether a STAC API search relation was discovered. */
821
- async getMetadata(options = {}) {
822
- const root = await this.getRoot(options);
823
- const conformsTo = Array.isArray(root.conformsTo) ? root.conformsTo : [];
824
- return {
825
- root,
826
- mode: findLink(root.links, "search") || conformsTo.length > 0 ? "api" : "static",
827
- conformsTo
828
- };
829
- }
830
- /**
831
- * Lists collections from an API Collections endpoint or a static catalog hierarchy.
832
- * Static traversal follows `child` links but never fetches Item links.
833
- */
834
- async getCollections(options = {}) {
835
- const metadata = await this.getMetadata({ signal: options.signal });
836
- if (metadata.mode === "api") {
837
- return await this.getAPICollections(metadata.root, options.signal);
838
- }
839
- return await this.getStaticCollections(metadata.root, options);
840
- }
841
- /**
842
- * Searches a STAC API and follows `next` links until all result pages are consumed.
843
- * Throws for static catalogs; use `traverse()` to opt into client-side crawling.
844
- */
845
- async *search(query = {}) {
846
- const root = await this.getRoot({ signal: query.signal });
847
- const searchLink = findLink(root.links, "search");
848
- if (!searchLink) {
849
- throw new Error("This is a static STAC catalog; use STACSource.traverse() explicitly");
850
- }
851
- let request = createSearchRequest(
852
- searchLink,
853
- this.getDocumentUrl(root),
854
- query
855
- );
856
- const visitedRequests = /* @__PURE__ */ new Set();
857
- while (request) {
858
- throwIfAborted(query.signal);
859
- const requestKey = getRequestKey(request);
860
- if (visitedRequests.has(requestKey)) {
861
- throw new Error(`STAC pagination cycle detected at ${request.url}`);
862
- }
863
- visitedRequests.add(requestKey);
864
- const page = await this.fetchItemCollection(request, query.signal);
865
- for (const item of page.features) {
866
- yield item;
867
- }
868
- const nextLink = findLink(page.links, "next");
869
- request = nextLink ? createNextRequest(nextLink, this.getDocumentUrl(page), request) : null;
870
- }
871
- }
872
- /**
873
- * Explicitly traverses a static STAC link graph with cycle, depth, and request limits.
874
- * Optional standard Item Search constraints are evaluated locally.
875
- */
876
- async *traverse(options = {}) {
877
- var _a, _b;
878
- const root = await this.getRoot({ signal: options.signal });
879
- const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ?? DEFAULT_MAX_DEPTH;
880
- const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ?? DEFAULT_MAX_REQUESTS;
881
- validateTraversalLimit("maxDepth", maxDepth);
882
- validateTraversalLimit("maxRequests", maxRequests);
883
- const rootUrl = this.getDocumentUrl(root);
884
- const queue = [{ url: rootUrl, depth: 0 }];
885
- const visitedUrls = /* @__PURE__ */ new Set();
886
- let requestCount = 0;
887
- while (queue.length > 0) {
888
- throwIfAborted(options.signal);
889
- const entry = queue.shift();
890
- if (visitedUrls.has(entry.url)) {
891
- continue;
892
- }
893
- if (requestCount >= maxRequests) {
894
- throw new Error(`STAC traversal exceeded maxRequests (${maxRequests})`);
895
- }
896
- visitedUrls.add(entry.url);
897
- requestCount++;
898
- const object = entry.url === rootUrl ? root : await this.fetchObject(entry.url, options.signal);
899
- if (isItem(object)) {
900
- if (matchesItem(object, options)) {
901
- yield object;
902
- }
903
- continue;
904
- }
905
- if (isItemCollection(object)) {
906
- for (const item of object.features) {
907
- if (matchesItem(item, options)) {
908
- yield item;
909
- }
910
- }
911
- }
912
- for (const link of object.links) {
913
- if (link.rel !== "child" && link.rel !== "item") {
914
- continue;
915
- }
916
- const depth = link.rel === "child" ? entry.depth + 1 : entry.depth;
917
- if (depth <= maxDepth) {
918
- queue.push({ url: resolveUrl(link.href, this.getDocumentUrl(object)), depth });
919
- }
920
- }
921
- }
922
- }
923
- /** Returns matching Item assets with document-relative URLs resolved to absolute URLs. */
924
- getAssets(item, selection = {}) {
925
- const baseUrl = this.documentUrls.get(item) || this.url;
926
- const requiredRoles = new Set(selection.roles || []);
927
- const requiredMediaTypes = new Set(selection.mediaTypes || []);
928
- return Object.entries(item.assets).filter(([, asset]) => {
929
- var _a;
930
- const matchesRole = requiredRoles.size === 0 || ((_a = asset.roles) == null ? void 0 : _a.some((role) => requiredRoles.has(role)));
931
- const matchesMediaType = requiredMediaTypes.size === 0 || Boolean(asset.type && requiredMediaTypes.has(asset.type));
932
- return matchesRole && matchesMediaType;
933
- }).map(([key, asset]) => ({ ...asset, key, href: resolveUrl(asset.href, baseUrl) }));
934
- }
935
- /** Fetches every page from a STAC API Collections relation. */
936
- async getAPICollections(root, signal) {
937
- const collectionsLink = findLink(root.links, "data") || findLink(root.links, "collections");
938
- if (!collectionsLink) {
939
- return isCollection(root) ? [root] : [];
940
- }
941
- const collections = [];
942
- const visitedUrls = /* @__PURE__ */ new Set();
943
- let url = resolveUrl(collectionsLink.href, this.getDocumentUrl(root));
944
- while (url) {
945
- throwIfAborted(signal);
946
- if (visitedUrls.has(url)) {
947
- throw new Error(`STAC Collections pagination cycle detected at ${url}`);
948
- }
949
- visitedUrls.add(url);
950
- const response = await this.fetch(url, { signal });
951
- assertResponse(response, url);
952
- const page = validateCollections(await response.json(), url);
953
- this.attachDocumentUrl(page, url);
954
- for (const collection of page.collections) {
955
- this.attachDocumentUrl(collection, url);
956
- }
957
- collections.push(...page.collections);
958
- const nextLink = findLink(page.links, "next");
959
- url = nextLink ? resolveUrl(nextLink.href, url) : null;
960
- }
961
- return collections;
962
- }
963
- /** Traverses only static `child` links to collect Collection documents. */
964
- async getStaticCollections(root, options) {
965
- var _a, _b;
966
- const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ?? DEFAULT_MAX_DEPTH;
967
- const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ?? DEFAULT_MAX_REQUESTS;
968
- validateTraversalLimit("maxDepth", maxDepth);
969
- validateTraversalLimit("maxRequests", maxRequests);
970
- const rootUrl = this.getDocumentUrl(root);
971
- const queue = [{ url: rootUrl, depth: 0 }];
972
- const visitedUrls = /* @__PURE__ */ new Set();
973
- const collections = [];
974
- let requestCount = 0;
975
- while (queue.length > 0) {
976
- throwIfAborted(options.signal);
977
- const entry = queue.shift();
978
- if (visitedUrls.has(entry.url)) {
979
- continue;
980
- }
981
- if (requestCount >= maxRequests) {
982
- throw new Error(`STAC collection traversal exceeded maxRequests (${maxRequests})`);
983
- }
984
- visitedUrls.add(entry.url);
985
- requestCount++;
986
- const object = entry.url === rootUrl ? root : await this.fetchObject(entry.url, options.signal);
987
- if (isCollection(object)) {
988
- collections.push(object);
989
- }
990
- if (!isCatalog(object) && !isCollection(object)) {
991
- continue;
992
- }
993
- if (entry.depth < maxDepth) {
994
- for (const link of object.links) {
995
- if (link.rel === "child") {
996
- queue.push({
997
- url: resolveUrl(link.href, this.getDocumentUrl(object)),
998
- depth: entry.depth + 1
999
- });
1000
- }
1001
- }
1002
- }
1003
- }
1004
- return collections;
1005
- }
1006
- /** Fetches and validates one core STAC document. */
1007
- async fetchObject(url, signal) {
1008
- throwIfAborted(signal);
1009
- const response = await this.fetch(url, { signal });
1010
- assertResponse(response, url);
1011
- const object = validateObject(await response.json(), url);
1012
- this.attachDocumentUrl(object, url);
1013
- if (isItemCollection(object)) {
1014
- for (const item of object.features) {
1015
- this.attachDocumentUrl(item, url);
1016
- }
1017
- }
1018
- return object;
1019
- }
1020
- /** Executes one STAC API Item Search page request. */
1021
- async fetchItemCollection(request, signal) {
1022
- const headers = new Headers(request.headers);
1023
- let url = request.url;
1024
- let body;
1025
- if (request.method === "POST") {
1026
- headers.set("content-type", "application/json");
1027
- body = JSON.stringify(request.body || {});
1028
- } else if (request.body && Object.keys(request.body).length > 0) {
1029
- url = appendQuery(url, request.body);
1030
- }
1031
- const response = await this.fetch(url, { method: request.method, headers, body, signal });
1032
- assertResponse(response, url);
1033
- const page = validateItemCollection(await response.json(), url);
1034
- this.attachDocumentUrl(page, url);
1035
- for (const item of page.features) {
1036
- this.attachDocumentUrl(item, url);
1037
- }
1038
- return page;
1039
- }
1040
- /** Associates an object and its nested links with the fetched document URL. */
1041
- attachDocumentUrl(object, url) {
1042
- this.documentUrls.set(object, url);
1043
- }
1044
- /** Returns the URL from which a STAC object was fetched. */
1045
- getDocumentUrl(object) {
1046
- return this.documentUrls.get(object) || this.url;
1047
- }
1048
- };
1049
- }
1050
- });
1051
558
 
1052
- // dist/stac/stac-source.js
1053
- var stac_source_exports2 = {};
1054
- __export(stac_source_exports2, {
1055
- STACSource: () => STACSource2,
1056
- STACSourceLoader: () => STACSourceLoaderWithParser2,
1057
- STACSourceLoaderWithParser: () => STACSourceLoaderWithParser2
1058
- });
1059
- module.exports = __toCommonJS(stac_source_exports2);
1060
- init_loader_utils();
1061
-
1062
- // dist/stac/stac-source-loader-types.js
1063
- var VERSION3 = true ? "5.0.0-beta.1" : "latest";
1064
- async function preloadSTACSourceLoader2() {
1065
- const { STACSourceLoaderWithParser: STACSourceLoaderWithParser3 } = await Promise.resolve().then(() => (init_stac_source(), stac_source_exports));
1066
- return STACSourceLoaderWithParser3;
559
+ // dist/stac/stac-loader-types.js
560
+ var VERSION2 = true ? "5.0.0-beta.10" : "latest";
561
+ async function preloadSTACSourceLoader() {
562
+ const { STACLoaderWithParser: STACLoaderWithParser2 } = await import("@loaders.gl/ogc/stac-loader");
563
+ return STACLoaderWithParser2;
1067
564
  }
1068
- var STACSourceLoader2 = {
565
+ var STACLoader = {
1069
566
  dataType: null,
1070
567
  batchType: null,
1071
- name: "STACSourceLoader",
568
+ name: "STACLoader",
1072
569
  id: "stac-source",
1073
570
  module: "ogc",
1074
- version: VERSION3,
571
+ version: VERSION2,
1075
572
  extensions: ["json"],
1076
573
  mimeTypes: ["application/json", "application/geo+json"],
1077
574
  type: "stac",
@@ -1090,26 +587,26 @@ var STACSourceLoader2 = {
1090
587
  }
1091
588
  },
1092
589
  testURL: (url) => /(?:^|[/_.-])stac(?:[/_.?#-]|$)|\/(?:catalog|collection)\.json(?:$|[?#])/i.test(url),
1093
- preload: preloadSTACSourceLoader2,
1094
- createDataSource(_data, _options, _coreApi) {
1095
- throw new Error("STACSourceLoader requires async load() or an explicit @loaders.gl/ogc/stac/stac-source import");
590
+ preload: preloadSTACSourceLoader,
591
+ createDataSourceSync(_data, _options, _coreApi) {
592
+ throw new Error("STACLoader requires async createDataSource() or an explicit @loaders.gl/ogc/stac-loader import");
1096
593
  }
1097
594
  };
1098
595
 
1099
- // dist/stac/stac-source.js
1100
- var DEFAULT_MAX_DEPTH2 = 32;
1101
- var DEFAULT_MAX_REQUESTS2 = 1e3;
1102
- var { preload: _preloadSTACSourceLoader2, createDataSource: _createMetadataDataSource2, ...STACSourceLoaderBase2 } = STACSourceLoader2;
1103
- var STACSourceLoaderWithParser2 = {
1104
- ...STACSourceLoaderBase2,
1105
- createDataSource(data, options, coreApi) {
596
+ // dist/stac/stac-loader.js
597
+ var DEFAULT_MAX_DEPTH = 32;
598
+ var DEFAULT_MAX_REQUESTS = 1e3;
599
+ var { preload: _preloadSTACSourceLoader, createDataSourceSync: _createMetadataDataSource, ...STACSourceLoaderBase } = STACLoader;
600
+ var STACLoaderWithParser = {
601
+ ...STACSourceLoaderBase,
602
+ createDataSourceSync(data, options, coreApi) {
1106
603
  if (typeof data !== "string") {
1107
604
  throw new Error("STACSource requires a catalog URL");
1108
605
  }
1109
- return new STACSource2(data, options, coreApi);
606
+ return new STACSource(data, options, coreApi);
1110
607
  }
1111
608
  };
1112
- var STACSource2 = class extends DataSource {
609
+ var STACSource = class extends DataSource {
1113
610
  /** Features exposed through the protocol-neutral catalog interface. */
1114
611
  capabilities = Object.freeze({
1115
612
  search: true,
@@ -1128,14 +625,14 @@ var STACSource2 = class extends DataSource {
1128
625
  documentUrls = /* @__PURE__ */ new WeakMap();
1129
626
  /** Creates a source for a static STAC root or STAC API landing page. */
1130
627
  constructor(url, options, coreApi) {
1131
- super(url, options, STACSourceLoaderWithParser2.defaultOptions, coreApi);
628
+ super(url, options, STACLoaderWithParser.defaultOptions, coreApi);
1132
629
  }
1133
630
  /** Returns the cached root Catalog or Collection. */
1134
631
  async getRoot(options = {}) {
1135
- throwIfAborted2(options.signal);
632
+ throwIfAborted(options.signal);
1136
633
  if (!this.rootPromise) {
1137
634
  const rootPromise = this.fetchObject(this.url).then((object) => {
1138
- if (!isCatalog2(object) && !isCollection2(object)) {
635
+ if (!isCatalog(object) && !isCollection(object)) {
1139
636
  throw new Error(`STAC root must be a Catalog or Collection: ${this.url}`);
1140
637
  }
1141
638
  return object;
@@ -1147,7 +644,7 @@ var STACSource2 = class extends DataSource {
1147
644
  }
1148
645
  });
1149
646
  }
1150
- return await waitForPromiseWithSignal2(this.rootPromise, options.signal);
647
+ return await waitForPromiseWithSignal(this.rootPromise, options.signal);
1151
648
  }
1152
649
  /** Returns root metadata and whether a STAC API search relation was discovered. */
1153
650
  async getMetadata(options = {}) {
@@ -1155,7 +652,7 @@ var STACSource2 = class extends DataSource {
1155
652
  const conformsTo = Array.isArray(root.conformsTo) ? root.conformsTo : [];
1156
653
  return {
1157
654
  root,
1158
- mode: findLink2(root.links, "search") || conformsTo.length > 0 ? "api" : "static",
655
+ mode: findLink(root.links, "search") || conformsTo.length > 0 ? "api" : "static",
1159
656
  conformsTo
1160
657
  };
1161
658
  }
@@ -1176,15 +673,15 @@ var STACSource2 = class extends DataSource {
1176
673
  */
1177
674
  async *search(query = {}) {
1178
675
  const root = await this.getRoot({ signal: query.signal });
1179
- const searchLink = findLink2(root.links, "search");
676
+ const searchLink = findLink(root.links, "search");
1180
677
  if (!searchLink) {
1181
678
  throw new Error("This is a static STAC catalog; use STACSource.traverse() explicitly");
1182
679
  }
1183
- let request = createSearchRequest2(searchLink, this.getDocumentUrl(root), query);
680
+ let request = createSearchRequest(searchLink, this.getDocumentUrl(root), query);
1184
681
  const visitedRequests = /* @__PURE__ */ new Set();
1185
682
  while (request) {
1186
- throwIfAborted2(query.signal);
1187
- const requestKey = getRequestKey2(request);
683
+ throwIfAborted(query.signal);
684
+ const requestKey = getRequestKey(request);
1188
685
  if (visitedRequests.has(requestKey)) {
1189
686
  throw new Error(`STAC pagination cycle detected at ${request.url}`);
1190
687
  }
@@ -1193,8 +690,8 @@ var STACSource2 = class extends DataSource {
1193
690
  for (const item of page.features) {
1194
691
  yield item;
1195
692
  }
1196
- const nextLink = findLink2(page.links, "next");
1197
- request = nextLink ? createNextRequest2(nextLink, this.getDocumentUrl(page), request) : null;
693
+ const nextLink = findLink(page.links, "next");
694
+ request = nextLink ? createNextRequest(nextLink, this.getDocumentUrl(page), request) : null;
1198
695
  }
1199
696
  }
1200
697
  /**
@@ -1204,16 +701,16 @@ var STACSource2 = class extends DataSource {
1204
701
  async *traverse(options = {}) {
1205
702
  var _a, _b;
1206
703
  const root = await this.getRoot({ signal: options.signal });
1207
- const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ?? DEFAULT_MAX_DEPTH2;
1208
- const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ?? DEFAULT_MAX_REQUESTS2;
1209
- validateTraversalLimit2("maxDepth", maxDepth);
1210
- validateTraversalLimit2("maxRequests", maxRequests);
704
+ const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ?? DEFAULT_MAX_DEPTH;
705
+ const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ?? DEFAULT_MAX_REQUESTS;
706
+ validateTraversalLimit("maxDepth", maxDepth);
707
+ validateTraversalLimit("maxRequests", maxRequests);
1211
708
  const rootUrl = this.getDocumentUrl(root);
1212
709
  const queue = [{ url: rootUrl, depth: 0 }];
1213
710
  const visitedUrls = /* @__PURE__ */ new Set();
1214
711
  let requestCount = 0;
1215
712
  while (queue.length > 0) {
1216
- throwIfAborted2(options.signal);
713
+ throwIfAborted(options.signal);
1217
714
  const entry = queue.shift();
1218
715
  if (visitedUrls.has(entry.url)) {
1219
716
  continue;
@@ -1224,15 +721,15 @@ var STACSource2 = class extends DataSource {
1224
721
  visitedUrls.add(entry.url);
1225
722
  requestCount++;
1226
723
  const object = entry.url === rootUrl ? root : await this.fetchObject(entry.url, options.signal);
1227
- if (isItem2(object)) {
1228
- if (matchesItem2(object, options)) {
724
+ if (isItem(object)) {
725
+ if (matchesItem(object, options)) {
1229
726
  yield object;
1230
727
  }
1231
728
  continue;
1232
729
  }
1233
- if (isItemCollection2(object)) {
730
+ if (isItemCollection(object)) {
1234
731
  for (const item of object.features) {
1235
- if (matchesItem2(item, options)) {
732
+ if (matchesItem(item, options)) {
1236
733
  yield item;
1237
734
  }
1238
735
  }
@@ -1243,7 +740,7 @@ var STACSource2 = class extends DataSource {
1243
740
  }
1244
741
  const depth = link.rel === "child" ? entry.depth + 1 : entry.depth;
1245
742
  if (depth <= maxDepth) {
1246
- queue.push({ url: resolveUrl2(link.href, this.getDocumentUrl(object)), depth });
743
+ queue.push({ url: resolveUrl(link.href, this.getDocumentUrl(object)), depth });
1247
744
  }
1248
745
  }
1249
746
  }
@@ -1258,50 +755,50 @@ var STACSource2 = class extends DataSource {
1258
755
  const matchesRole = requiredRoles.size === 0 || ((_a = asset.roles) == null ? void 0 : _a.some((role) => requiredRoles.has(role)));
1259
756
  const matchesMediaType = requiredMediaTypes.size === 0 || Boolean(asset.type && requiredMediaTypes.has(asset.type));
1260
757
  return matchesRole && matchesMediaType;
1261
- }).map(([key, asset]) => ({ ...asset, key, href: resolveUrl2(asset.href, baseUrl) }));
758
+ }).map(([key, asset]) => ({ ...asset, key, href: resolveUrl(asset.href, baseUrl) }));
1262
759
  }
1263
760
  /** Fetches every page from a STAC API Collections relation. */
1264
761
  async getAPICollections(root, signal) {
1265
- const collectionsLink = findLink2(root.links, "data") || findLink2(root.links, "collections");
762
+ const collectionsLink = findLink(root.links, "data") || findLink(root.links, "collections");
1266
763
  if (!collectionsLink) {
1267
- return isCollection2(root) ? [root] : [];
764
+ return isCollection(root) ? [root] : [];
1268
765
  }
1269
766
  const collections = [];
1270
767
  const visitedUrls = /* @__PURE__ */ new Set();
1271
- let url = resolveUrl2(collectionsLink.href, this.getDocumentUrl(root));
768
+ let url = resolveUrl(collectionsLink.href, this.getDocumentUrl(root));
1272
769
  while (url) {
1273
- throwIfAborted2(signal);
770
+ throwIfAborted(signal);
1274
771
  if (visitedUrls.has(url)) {
1275
772
  throw new Error(`STAC Collections pagination cycle detected at ${url}`);
1276
773
  }
1277
774
  visitedUrls.add(url);
1278
775
  const response = await this.fetch(url, { signal });
1279
- assertResponse2(response, url);
1280
- const page = validateCollections2(await response.json(), url);
776
+ assertResponse(response, url);
777
+ const page = validateCollections(await response.json(), url);
1281
778
  this.attachDocumentUrl(page, url);
1282
779
  for (const collection of page.collections) {
1283
780
  this.attachDocumentUrl(collection, url);
1284
781
  }
1285
782
  collections.push(...page.collections);
1286
- const nextLink = findLink2(page.links, "next");
1287
- url = nextLink ? resolveUrl2(nextLink.href, url) : null;
783
+ const nextLink = findLink(page.links, "next");
784
+ url = nextLink ? resolveUrl(nextLink.href, url) : null;
1288
785
  }
1289
786
  return collections;
1290
787
  }
1291
788
  /** Traverses only static `child` links to collect Collection documents. */
1292
789
  async getStaticCollections(root, options) {
1293
790
  var _a, _b;
1294
- const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ?? DEFAULT_MAX_DEPTH2;
1295
- const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ?? DEFAULT_MAX_REQUESTS2;
1296
- validateTraversalLimit2("maxDepth", maxDepth);
1297
- validateTraversalLimit2("maxRequests", maxRequests);
791
+ const maxDepth = options.maxDepth ?? ((_a = this.options.stac) == null ? void 0 : _a.maxDepth) ?? DEFAULT_MAX_DEPTH;
792
+ const maxRequests = options.maxRequests ?? ((_b = this.options.stac) == null ? void 0 : _b.maxRequests) ?? DEFAULT_MAX_REQUESTS;
793
+ validateTraversalLimit("maxDepth", maxDepth);
794
+ validateTraversalLimit("maxRequests", maxRequests);
1298
795
  const rootUrl = this.getDocumentUrl(root);
1299
796
  const queue = [{ url: rootUrl, depth: 0 }];
1300
797
  const visitedUrls = /* @__PURE__ */ new Set();
1301
798
  const collections = [];
1302
799
  let requestCount = 0;
1303
800
  while (queue.length > 0) {
1304
- throwIfAborted2(options.signal);
801
+ throwIfAborted(options.signal);
1305
802
  const entry = queue.shift();
1306
803
  if (visitedUrls.has(entry.url)) {
1307
804
  continue;
@@ -1312,17 +809,17 @@ var STACSource2 = class extends DataSource {
1312
809
  visitedUrls.add(entry.url);
1313
810
  requestCount++;
1314
811
  const object = entry.url === rootUrl ? root : await this.fetchObject(entry.url, options.signal);
1315
- if (isCollection2(object)) {
812
+ if (isCollection(object)) {
1316
813
  collections.push(object);
1317
814
  }
1318
- if (!isCatalog2(object) && !isCollection2(object)) {
815
+ if (!isCatalog(object) && !isCollection(object)) {
1319
816
  continue;
1320
817
  }
1321
818
  if (entry.depth < maxDepth) {
1322
819
  for (const link of object.links) {
1323
820
  if (link.rel === "child") {
1324
821
  queue.push({
1325
- url: resolveUrl2(link.href, this.getDocumentUrl(object)),
822
+ url: resolveUrl(link.href, this.getDocumentUrl(object)),
1326
823
  depth: entry.depth + 1
1327
824
  });
1328
825
  }
@@ -1333,12 +830,12 @@ var STACSource2 = class extends DataSource {
1333
830
  }
1334
831
  /** Fetches and validates one core STAC document. */
1335
832
  async fetchObject(url, signal) {
1336
- throwIfAborted2(signal);
833
+ throwIfAborted(signal);
1337
834
  const response = await this.fetch(url, { signal });
1338
- assertResponse2(response, url);
1339
- const object = validateObject2(await response.json(), url);
835
+ assertResponse(response, url);
836
+ const object = validateObject(await response.json(), url);
1340
837
  this.attachDocumentUrl(object, url);
1341
- if (isItemCollection2(object)) {
838
+ if (isItemCollection(object)) {
1342
839
  for (const item of object.features) {
1343
840
  this.attachDocumentUrl(item, url);
1344
841
  }
@@ -1354,11 +851,11 @@ var STACSource2 = class extends DataSource {
1354
851
  headers.set("content-type", "application/json");
1355
852
  body = JSON.stringify(request.body || {});
1356
853
  } else if (request.body && Object.keys(request.body).length > 0) {
1357
- url = appendQuery2(url, request.body);
854
+ url = appendQuery(url, request.body);
1358
855
  }
1359
856
  const response = await this.fetch(url, { method: request.method, headers, body, signal });
1360
- assertResponse2(response, url);
1361
- const page = validateItemCollection2(await response.json(), url);
857
+ assertResponse(response, url);
858
+ const page = validateItemCollection(await response.json(), url);
1362
859
  this.attachDocumentUrl(page, url);
1363
860
  for (const item of page.features) {
1364
861
  this.attachDocumentUrl(item, url);
@@ -1374,28 +871,28 @@ var STACSource2 = class extends DataSource {
1374
871
  return this.documentUrls.get(object) || this.url;
1375
872
  }
1376
873
  };
1377
- function createSearchRequest2(link, baseUrl, query) {
874
+ function createSearchRequest(link, baseUrl, query) {
1378
875
  const { signal: _signal, ...body } = query;
1379
876
  return {
1380
- url: resolveUrl2(link.href, baseUrl),
877
+ url: resolveUrl(link.href, baseUrl),
1381
878
  method: link.method || "POST",
1382
879
  headers: link.headers,
1383
880
  body
1384
881
  };
1385
882
  }
1386
- function createNextRequest2(link, baseUrl, previousRequest) {
883
+ function createNextRequest(link, baseUrl, previousRequest) {
1387
884
  const linkBody = link.body || {};
1388
885
  return {
1389
- url: resolveUrl2(link.href, baseUrl),
886
+ url: resolveUrl(link.href, baseUrl),
1390
887
  method: link.method || previousRequest.method,
1391
888
  headers: { ...previousRequest.headers, ...link.headers },
1392
889
  body: link.merge ? { ...previousRequest.body, ...linkBody } : link.body
1393
890
  };
1394
891
  }
1395
- function getRequestKey2(request) {
892
+ function getRequestKey(request) {
1396
893
  return `${request.method} ${request.url} ${JSON.stringify(request.body || {})}`;
1397
894
  }
1398
- function appendQuery2(url, body) {
895
+ function appendQuery(url, body) {
1399
896
  const parsedUrl = new URL(url);
1400
897
  for (const [key, value] of Object.entries(body)) {
1401
898
  if (value !== void 0) {
@@ -1404,40 +901,40 @@ function appendQuery2(url, body) {
1404
901
  }
1405
902
  return parsedUrl.href;
1406
903
  }
1407
- function resolveUrl2(url, baseUrl) {
904
+ function resolveUrl(url, baseUrl) {
1408
905
  return new URL(url, baseUrl).href;
1409
906
  }
1410
- function findLink2(links, relation) {
907
+ function findLink(links, relation) {
1411
908
  return links.find((link) => link.rel === relation);
1412
909
  }
1413
- function assertResponse2(response, url) {
910
+ function assertResponse(response, url) {
1414
911
  if (!response.ok) {
1415
912
  throw new Error(`STAC request failed (${response.status} ${response.statusText}): ${url}`);
1416
913
  }
1417
914
  }
1418
- function validateTraversalLimit2(name, value) {
915
+ function validateTraversalLimit(name, value) {
1419
916
  if (!Number.isSafeInteger(value) || value < 1) {
1420
917
  throw new Error(`STAC ${name} must be a positive integer`);
1421
918
  }
1422
919
  }
1423
- function throwIfAborted2(signal) {
920
+ function throwIfAborted(signal) {
1424
921
  if (signal == null ? void 0 : signal.aborted) {
1425
922
  throw signal.reason || new DOMException("The operation was aborted", "AbortError");
1426
923
  }
1427
924
  }
1428
- function waitForPromiseWithSignal2(promise, signal) {
925
+ function waitForPromiseWithSignal(promise, signal) {
1429
926
  if (!signal) {
1430
927
  return promise;
1431
928
  }
1432
- throwIfAborted2(signal);
929
+ throwIfAborted(signal);
1433
930
  return new Promise((resolve, reject) => {
1434
931
  const handleAbort = () => reject(signal.reason || new DOMException("The operation was aborted", "AbortError"));
1435
932
  signal.addEventListener("abort", handleAbort, { once: true });
1436
933
  void promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", handleAbort));
1437
934
  });
1438
935
  }
1439
- function validateObject2(value, url) {
1440
- if (!isRecord2(value)) {
936
+ function validateObject(value, url) {
937
+ if (!isRecord(value)) {
1441
938
  throw new Error(`Invalid STAC JSON document: ${url}`);
1442
939
  }
1443
940
  if (value.type === "Catalog" || value.type === "Collection") {
@@ -1447,80 +944,80 @@ function validateObject2(value, url) {
1447
944
  return value;
1448
945
  }
1449
946
  if (value.type === "Feature") {
1450
- if (typeof value.id !== "string" || !isRecord2(value.assets) || !Array.isArray(value.links)) {
947
+ if (typeof value.id !== "string" || !isRecord(value.assets) || !Array.isArray(value.links)) {
1451
948
  throw new Error(`Invalid STAC Item: ${url}`);
1452
949
  }
1453
950
  return value;
1454
951
  }
1455
952
  if (value.type === "FeatureCollection") {
1456
- return validateItemCollection2(value, url);
953
+ return validateItemCollection(value, url);
1457
954
  }
1458
955
  throw new Error(`Unsupported STAC object type at ${url}`);
1459
956
  }
1460
- function validateItemCollection2(value, url) {
1461
- if (!isRecord2(value) || value.type !== "FeatureCollection" || !Array.isArray(value.features) || !Array.isArray(value.links)) {
957
+ function validateItemCollection(value, url) {
958
+ if (!isRecord(value) || value.type !== "FeatureCollection" || !Array.isArray(value.features) || !Array.isArray(value.links)) {
1462
959
  throw new Error(`Invalid STAC ItemCollection: ${url}`);
1463
960
  }
1464
961
  for (const item of value.features) {
1465
- if (!isItem2(item)) {
962
+ if (!isItem(item)) {
1466
963
  throw new Error(`Invalid STAC Item in ItemCollection: ${url}`);
1467
964
  }
1468
965
  }
1469
966
  return value;
1470
967
  }
1471
- function validateCollections2(value, url) {
1472
- if (!isRecord2(value) || !Array.isArray(value.collections) || !Array.isArray(value.links)) {
968
+ function validateCollections(value, url) {
969
+ if (!isRecord(value) || !Array.isArray(value.collections) || !Array.isArray(value.links)) {
1473
970
  throw new Error(`Invalid STAC Collections response: ${url}`);
1474
971
  }
1475
- if (!value.collections.every(isCollection2)) {
972
+ if (!value.collections.every(isCollection)) {
1476
973
  throw new Error(`Invalid Collection in STAC Collections response: ${url}`);
1477
974
  }
1478
975
  return value;
1479
976
  }
1480
- function isCatalog2(value) {
1481
- return isRecord2(value) && value.type === "Catalog" && Array.isArray(value.links);
977
+ function isCatalog(value) {
978
+ return isRecord(value) && value.type === "Catalog" && Array.isArray(value.links);
1482
979
  }
1483
- function isCollection2(value) {
1484
- return isRecord2(value) && value.type === "Collection" && Array.isArray(value.links);
980
+ function isCollection(value) {
981
+ return isRecord(value) && value.type === "Collection" && Array.isArray(value.links);
1485
982
  }
1486
- function isItem2(value) {
1487
- return isRecord2(value) && value.type === "Feature" && typeof value.id === "string" && isRecord2(value.assets) && Array.isArray(value.links);
983
+ function isItem(value) {
984
+ return isRecord(value) && value.type === "Feature" && typeof value.id === "string" && isRecord(value.assets) && Array.isArray(value.links);
1488
985
  }
1489
- function isItemCollection2(value) {
1490
- return isRecord2(value) && value.type === "FeatureCollection" && Array.isArray(value.features) && Array.isArray(value.links);
986
+ function isItemCollection(value) {
987
+ return isRecord(value) && value.type === "FeatureCollection" && Array.isArray(value.features) && Array.isArray(value.links);
1491
988
  }
1492
- function isRecord2(value) {
989
+ function isRecord(value) {
1493
990
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1494
991
  }
1495
- function matchesItem2(item, query) {
992
+ function matchesItem(item, query) {
1496
993
  if (query.ids && !query.ids.includes(item.id)) {
1497
994
  return false;
1498
995
  }
1499
996
  if (query.collections && (!item.collection || !query.collections.includes(item.collection))) {
1500
997
  return false;
1501
998
  }
1502
- if (query.bbox && item.bbox && !intersectsBoundingBox2(query.bbox, item.bbox)) {
999
+ if (query.bbox && item.bbox && !intersectsBoundingBox(query.bbox, item.bbox)) {
1503
1000
  return false;
1504
1001
  }
1505
- return !query.datetime || intersectsDatetime2(query.datetime, item);
1002
+ return !query.datetime || intersectsDatetime(query.datetime, item);
1506
1003
  }
1507
- function intersectsBoundingBox2(left, right) {
1004
+ function intersectsBoundingBox(left, right) {
1508
1005
  const leftMaximumX = left.length === 6 ? left[3] : left[2];
1509
1006
  const leftMaximumY = left.length === 6 ? left[4] : left[3];
1510
1007
  const rightMaximumX = right.length === 6 ? right[3] : right[2];
1511
1008
  const rightMaximumY = right.length === 6 ? right[4] : right[3];
1512
1009
  return !(leftMaximumX < right[0] || rightMaximumX < left[0] || leftMaximumY < right[1] || rightMaximumY < left[1]);
1513
1010
  }
1514
- function intersectsDatetime2(datetime, item) {
1515
- const queryInterval = parseDatetimeInterval2(datetime, true);
1011
+ function intersectsDatetime(datetime, item) {
1012
+ const queryInterval = parseDatetimeInterval(datetime, true);
1516
1013
  const itemDatetime = item.properties.datetime;
1517
- const itemInterval = typeof itemDatetime === "string" ? parseDatetimeInterval2(itemDatetime, false) : parseItemDatetimeInterval2(item);
1014
+ const itemInterval = typeof itemDatetime === "string" ? parseDatetimeInterval(itemDatetime, false) : parseItemDatetimeInterval(item);
1518
1015
  if (!itemInterval) {
1519
1016
  return true;
1520
1017
  }
1521
1018
  return queryInterval[0] <= itemInterval[1] && itemInterval[0] <= queryInterval[1];
1522
1019
  }
1523
- function parseDatetimeInterval2(datetime, throwOnInvalid) {
1020
+ function parseDatetimeInterval(datetime, throwOnInvalid) {
1524
1021
  const parts = datetime.split("/");
1525
1022
  const start = parts[0] === ".." ? Number.NEGATIVE_INFINITY : Date.parse(parts[0]);
1526
1023
  const endPart = parts.length > 1 ? parts[1] : parts[0];
@@ -1533,12 +1030,12 @@ function parseDatetimeInterval2(datetime, throwOnInvalid) {
1533
1030
  }
1534
1031
  return [start, end];
1535
1032
  }
1536
- function parseItemDatetimeInterval2(item) {
1033
+ function parseItemDatetimeInterval(item) {
1537
1034
  const start = item.properties.start_datetime;
1538
1035
  const end = item.properties.end_datetime;
1539
1036
  if (!start || !end) {
1540
1037
  return null;
1541
1038
  }
1542
- return parseDatetimeInterval2(`${start}/${end}`, false);
1039
+ return parseDatetimeInterval(`${start}/${end}`, false);
1543
1040
  }
1544
- //# sourceMappingURL=stac-source.cjs.map
1041
+ //# sourceMappingURL=stac-loader.cjs.map