@loaders.gl/core 5.0.0-beta.6 → 5.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/dist/arrow-geometry/geojson-table.cjs +26 -15
  2. package/dist/arrow-geometry/geojson-table.cjs.map +2 -2
  3. package/dist/arrow-geometry/geojson-table.d.ts +8 -1
  4. package/dist/arrow-geometry/geojson-table.d.ts.map +1 -1
  5. package/dist/arrow-geometry/geojson-table.js +18 -9
  6. package/dist/arrow-geometry/geojson-table.js.map +1 -1
  7. package/dist/cluster-source.cjs +78 -8
  8. package/dist/cluster-source.cjs.map +3 -3
  9. package/dist/dist.dev.js +354 -319
  10. package/dist/dist.min.js +3 -3
  11. package/dist/federated-table-scan-source.cjs +187 -179
  12. package/dist/federated-table-scan-source.cjs.map +2 -2
  13. package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +4 -8
  14. package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs.map +2 -2
  15. package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.d.ts.map +1 -1
  16. package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +4 -8
  17. package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js.map +1 -1
  18. package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs +3 -2
  19. package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs.map +2 -2
  20. package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.d.ts.map +1 -1
  21. package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js +3 -2
  22. package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js.map +1 -1
  23. package/dist/geoarrow/metadata/geoarrow-metadata.cjs +44 -2
  24. package/dist/geoarrow/metadata/geoarrow-metadata.cjs.map +4 -4
  25. package/dist/geoarrow/metadata/geoarrow-metadata.d.ts.map +1 -1
  26. package/dist/geoarrow/metadata/geoarrow-metadata.js +3 -4
  27. package/dist/geoarrow/metadata/geoarrow-metadata.js.map +1 -1
  28. package/dist/index.cjs +351 -281
  29. package/dist/index.cjs.map +3 -3
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +1 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/lib/api/create-data-source.d.ts +14 -9
  35. package/dist/lib/api/create-data-source.d.ts.map +1 -1
  36. package/dist/lib/api/create-data-source.js +55 -45
  37. package/dist/lib/api/create-data-source.js.map +1 -1
  38. package/dist/lib/api/encode.d.ts +1 -1
  39. package/dist/lib/api/encode.d.ts.map +1 -1
  40. package/dist/lib/api/encode.js +11 -2
  41. package/dist/lib/api/encode.js.map +1 -1
  42. package/dist/lib/api/load-in-batches.d.ts +3 -2
  43. package/dist/lib/api/load-in-batches.d.ts.map +1 -1
  44. package/dist/lib/api/load-in-batches.js.map +1 -1
  45. package/dist/lib/api/load-loader.d.ts +3 -3
  46. package/dist/lib/api/load-loader.d.ts.map +1 -1
  47. package/dist/lib/api/load-loader.js +14 -18
  48. package/dist/lib/api/load-loader.js.map +1 -1
  49. package/dist/lib/api/load.d.ts +7 -3
  50. package/dist/lib/api/load.d.ts.map +1 -1
  51. package/dist/lib/api/load.js +11 -64
  52. package/dist/lib/api/load.js.map +1 -1
  53. package/dist/lib/api/parse-file.d.ts +5 -3
  54. package/dist/lib/api/parse-file.d.ts.map +1 -1
  55. package/dist/lib/api/parse-file.js +12 -7
  56. package/dist/lib/api/parse-file.js.map +1 -1
  57. package/dist/lib/api/parse-in-batches.d.ts +5 -3
  58. package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
  59. package/dist/lib/api/parse-in-batches.js +14 -3
  60. package/dist/lib/api/parse-in-batches.js.map +1 -1
  61. package/dist/lib/api/parse-sync.d.ts +5 -3
  62. package/dist/lib/api/parse-sync.d.ts.map +1 -1
  63. package/dist/lib/api/parse-sync.js +8 -6
  64. package/dist/lib/api/parse-sync.js.map +1 -1
  65. package/dist/lib/api/parse.d.ts +5 -3
  66. package/dist/lib/api/parse.d.ts.map +1 -1
  67. package/dist/lib/api/parse.js +26 -15
  68. package/dist/lib/api/parse.js.map +1 -1
  69. package/dist/lib/api/select-loader.d.ts +4 -2
  70. package/dist/lib/api/select-loader.d.ts.map +1 -1
  71. package/dist/lib/api/select-loader.js +43 -40
  72. package/dist/lib/api/select-loader.js.map +1 -1
  73. package/dist/lib/api/select-source.d.ts.map +1 -1
  74. package/dist/lib/api/select-source.js +1 -1
  75. package/dist/lib/api/select-source.js.map +1 -1
  76. package/dist/lib/init.js +1 -1
  77. package/dist/lib/loader-utils/loggers.d.ts +2 -37
  78. package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
  79. package/dist/lib/loader-utils/loggers.js +2 -63
  80. package/dist/lib/loader-utils/loggers.js.map +1 -1
  81. package/dist/lib/loader-utils/native-arrow.d.ts +11 -0
  82. package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -0
  83. package/dist/lib/loader-utils/native-arrow.js +52 -0
  84. package/dist/lib/loader-utils/native-arrow.js.map +1 -0
  85. package/dist/lib/loader-utils/option-defaults.js +2 -2
  86. package/dist/lib/loader-utils/option-defaults.js.map +1 -1
  87. package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
  88. package/dist/lib/loader-utils/option-utils.js +21 -10
  89. package/dist/lib/loader-utils/option-utils.js.map +1 -1
  90. package/dist/loader-utils/index.cjs +143 -42
  91. package/dist/loader-utils/index.cjs.map +3 -3
  92. package/dist/loader-utils/index.d.ts +2 -2
  93. package/dist/loader-utils/index.d.ts.map +1 -1
  94. package/dist/loader-utils/index.js +1 -1
  95. package/dist/loader-utils/index.js.map +1 -1
  96. package/dist/loader-utils/json-loader.js +1 -1
  97. package/dist/loader-utils/lib/log-utils/log.d.ts +24 -1
  98. package/dist/loader-utils/lib/log-utils/log.d.ts.map +1 -1
  99. package/dist/loader-utils/lib/log-utils/log.js +32 -1
  100. package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
  101. package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts +5 -0
  102. package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts.map +1 -1
  103. package/dist/loader-utils/lib/scan-utils/logical-table-query.js +13 -5
  104. package/dist/loader-utils/lib/scan-utils/logical-table-query.js.map +1 -1
  105. package/dist/loader-utils/lib/scan-utils/table-query.d.ts +5 -1
  106. package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
  107. package/dist/loader-utils/lib/scan-utils/table-query.js +6 -0
  108. package/dist/loader-utils/lib/scan-utils/table-query.js.map +1 -1
  109. package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +6 -1
  110. package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
  111. package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +27 -20
  112. package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
  113. package/dist/loader-utils/lib/sources/data-source.js +3 -3
  114. package/dist/loader-utils/lib/sources/data-source.js.map +1 -1
  115. package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
  116. package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js +15 -1
  117. package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
  118. package/dist/loader-utils/loader-types.d.ts +102 -27
  119. package/dist/loader-utils/loader-types.d.ts.map +1 -1
  120. package/dist/loader-utils/loader-types.js.map +1 -1
  121. package/dist/loader-utils/source-types.d.ts +5 -5
  122. package/dist/loader-utils/source-types.d.ts.map +1 -1
  123. package/dist/loader-utils/source-types.js +5 -1
  124. package/dist/loader-utils/source-types.js.map +1 -1
  125. package/dist/null-loader.js +1 -1
  126. package/dist/null-worker-node.js +1 -1
  127. package/dist/null-worker.js +1 -1
  128. package/dist/polyfills/index.cjs +3 -2
  129. package/dist/polyfills/index.d.ts.map +1 -1
  130. package/dist/polyfills/index.js +2 -2
  131. package/dist/polyfills/index.js.map +1 -1
  132. package/dist/scan/arrow-execution/expressions.cjs +110 -0
  133. package/dist/scan/arrow-execution/expressions.cjs.map +7 -0
  134. package/dist/scan/arrow-execution/expressions.d.ts +9 -0
  135. package/dist/scan/arrow-execution/expressions.d.ts.map +1 -0
  136. package/dist/scan/arrow-execution/expressions.js +60 -0
  137. package/dist/scan/arrow-execution/expressions.js.map +1 -0
  138. package/dist/scan/arrow-execution/filter-arrow-table.cjs +15 -3
  139. package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +2 -2
  140. package/dist/scan/arrow-execution/filter-arrow-table.d.ts +2 -0
  141. package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -1
  142. package/dist/scan/arrow-execution/filter-arrow-table.js +10 -2
  143. package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -1
  144. package/dist/scan/index.cjs +21 -6
  145. package/dist/scan/index.cjs.map +2 -2
  146. package/dist/scan/index.d.ts +2 -1
  147. package/dist/scan/index.d.ts.map +1 -1
  148. package/dist/scan/index.js +1 -1
  149. package/dist/scan/index.js.map +1 -1
  150. package/dist/scan/parse-sql-predicate.cjs +3 -294
  151. package/dist/scan/parse-sql-predicate.cjs.map +3 -3
  152. package/dist/scan/parse-sql-predicate.d.ts +1 -7
  153. package/dist/scan/parse-sql-predicate.d.ts.map +1 -1
  154. package/dist/scan/parse-sql-predicate.js +5 -307
  155. package/dist/scan/parse-sql-predicate.js.map +1 -1
  156. package/dist/scan/query-progressive.cjs +191 -0
  157. package/dist/scan/query-progressive.cjs.map +7 -0
  158. package/dist/scan/query-progressive.d.ts +39 -0
  159. package/dist/scan/query-progressive.d.ts.map +1 -0
  160. package/dist/scan/query-progressive.js +174 -0
  161. package/dist/scan/query-progressive.js.map +1 -0
  162. package/dist/scan/query.cjs +143 -22
  163. package/dist/scan/query.cjs.map +3 -3
  164. package/dist/scan/query.d.ts +27 -9
  165. package/dist/scan/query.d.ts.map +1 -1
  166. package/dist/scan/query.js +180 -18
  167. package/dist/scan/query.js.map +1 -1
  168. package/dist/schema-utils/index.cjs +262 -241
  169. package/dist/schema-utils/index.cjs.map +2 -2
  170. package/dist/schema-utils/index.d.ts +1 -0
  171. package/dist/schema-utils/index.d.ts.map +1 -1
  172. package/dist/schema-utils/index.js +1 -0
  173. package/dist/schema-utils/index.js.map +1 -1
  174. package/dist/schema-utils/lib/schema/deduce-table-schema.js +4 -2
  175. package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
  176. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +28 -0
  177. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +1 -0
  178. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +26 -0
  179. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +1 -0
  180. package/dist/schema-utils/lib/table/tables/row-utils.js +2 -2
  181. package/dist/schema-utils/lib/table/tables/row-utils.js.map +1 -1
  182. package/dist/vector-table-scan-source.cjs +12 -4
  183. package/dist/vector-table-scan-source.cjs.map +1 -1
  184. package/dist/worker-utils/index.cjs +49 -9
  185. package/dist/worker-utils/index.cjs.map +3 -3
  186. package/dist/worker-utils/lib/env-utils/version.js +1 -1
  187. package/dist/worker-utils/lib/library-utils/library-utils.d.ts.map +1 -1
  188. package/dist/worker-utils/lib/library-utils/library-utils.js +2 -1
  189. package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -1
  190. package/dist/worker-utils/lib/process-utils/child-process-proxy.d.ts.map +1 -1
  191. package/dist/worker-utils/lib/process-utils/child-process-proxy.js +8 -7
  192. package/dist/worker-utils/lib/process-utils/child-process-proxy.js.map +1 -1
  193. package/dist/worker-utils/lib/worker-api/get-worker-url.d.ts.map +1 -1
  194. package/dist/worker-utils/lib/worker-api/get-worker-url.js +5 -2
  195. package/dist/worker-utils/lib/worker-api/get-worker-url.js.map +1 -1
  196. package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js +1 -6
  197. package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
  198. package/package.json +8 -7
  199. package/src/arrow-geometry/geojson-table.ts +27 -17
  200. package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +4 -11
  201. package/src/geoarrow/mesharrow/arrow-fixed-size-list-utils.ts +3 -2
  202. package/src/geoarrow/metadata/geoarrow-metadata.ts +3 -4
  203. package/src/index.ts +1 -1
  204. package/src/lib/api/create-data-source.ts +136 -58
  205. package/src/lib/api/encode.ts +14 -3
  206. package/src/lib/api/load-in-batches.ts +15 -7
  207. package/src/lib/api/load-loader.ts +21 -20
  208. package/src/lib/api/load.ts +49 -121
  209. package/src/lib/api/parse-file.ts +42 -23
  210. package/src/lib/api/parse-in-batches.ts +49 -12
  211. package/src/lib/api/parse-sync.ts +37 -19
  212. package/src/lib/api/parse.ts +51 -30
  213. package/src/lib/api/select-loader.ts +56 -53
  214. package/src/lib/api/select-source.ts +7 -1
  215. package/src/lib/loader-utils/loggers.ts +2 -70
  216. package/src/lib/loader-utils/native-arrow.ts +70 -0
  217. package/src/lib/loader-utils/option-defaults.ts +2 -2
  218. package/src/lib/loader-utils/option-utils.ts +21 -10
  219. package/src/loader-utils/index.ts +2 -1
  220. package/src/loader-utils/lib/log-utils/log.ts +39 -1
  221. package/src/loader-utils/lib/scan-utils/logical-table-query.ts +18 -8
  222. package/src/loader-utils/lib/scan-utils/table-query.ts +10 -1
  223. package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +36 -25
  224. package/src/loader-utils/lib/sources/data-source.ts +3 -3
  225. package/src/loader-utils/lib/worker-loader-utils/parse-with-worker.ts +16 -1
  226. package/src/loader-utils/loader-types.ts +168 -43
  227. package/src/loader-utils/source-types.ts +12 -6
  228. package/src/polyfills/index.ts +3 -3
  229. package/src/scan/arrow-execution/expressions.ts +86 -0
  230. package/src/scan/arrow-execution/filter-arrow-table.ts +19 -3
  231. package/src/scan/index.ts +7 -1
  232. package/src/scan/parse-sql-predicate.ts +8 -367
  233. package/src/scan/query-progressive.ts +231 -0
  234. package/src/scan/query.ts +247 -24
  235. package/src/schema-utils/index.ts +5 -0
  236. package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
  237. package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +58 -0
  238. package/src/schema-utils/lib/table/tables/row-utils.ts +2 -2
  239. package/src/worker-utils/lib/library-utils/library-utils.ts +2 -1
  240. package/src/worker-utils/lib/process-utils/child-process-proxy.ts +8 -7
  241. package/src/worker-utils/lib/worker-api/get-worker-url.ts +4 -3
  242. package/src/worker-utils/lib/worker-utils/get-loadable-worker-url.ts +1 -6
  243. package/dist/scan/parse-sql-query.cjs +0 -70
  244. package/dist/scan/parse-sql-query.cjs.map +0 -7
  245. package/dist/scan/parse-sql-query.d.ts +0 -5
  246. package/dist/scan/parse-sql-query.d.ts.map +0 -1
  247. package/dist/scan/parse-sql-query.js +0 -49
  248. package/dist/scan/parse-sql-query.js.map +0 -1
  249. package/dist/scan/parse-sql-select.cjs +0 -215
  250. package/dist/scan/parse-sql-select.cjs.map +0 -7
  251. package/dist/scan/parse-sql-select.d.ts +0 -38
  252. package/dist/scan/parse-sql-select.d.ts.map +0 -1
  253. package/dist/scan/parse-sql-select.js +0 -208
  254. package/dist/scan/parse-sql-select.js.map +0 -1
  255. package/src/scan/parse-sql-query.ts +0 -53
  256. package/src/scan/parse-sql-select.ts +0 -220
package/dist/index.cjs CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  concatenateArrayBuffersAsync: () => concatenateArrayBuffersAsync,
34
34
  coreApi: () => coreApi,
35
35
  createDataSource: () => createDataSource,
36
+ createDataSourceSync: () => createDataSourceSync,
36
37
  document: () => document_,
37
38
  encode: () => encode,
38
39
  encodeInBatches: () => encodeInBatches,
@@ -115,15 +116,45 @@ var import_log = require("probe.gl/log");
115
116
  var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
116
117
  var version = VERSION[0] >= "0" && VERSION[0] <= "9" ? `v${VERSION}` : "";
117
118
  function createLog() {
118
- const log2 = new import_log.Log({ id: "loaders.gl" });
119
+ const log3 = new import_log.Log({ id: "loaders.gl" });
119
120
  globalThis.loaders ||= {};
120
- globalThis.loaders.log = log2;
121
+ globalThis.loaders.log = log3;
121
122
  globalThis.loaders.version = version;
122
123
  globalThis.probe ||= {};
123
- globalThis.probe.loaders = log2;
124
- return log2;
124
+ globalThis.probe.loaders = log3;
125
+ return log3;
125
126
  }
126
127
  var log = createLog();
128
+ var NullLog = class {
129
+ /** Discards debug messages. */
130
+ log() {
131
+ return ignoreMessage;
132
+ }
133
+ /** Discards informational messages. */
134
+ info() {
135
+ return ignoreMessage;
136
+ }
137
+ /** Discards messages marked to be emitted once. */
138
+ once() {
139
+ return ignoreMessage;
140
+ }
141
+ /** Discards warnings. */
142
+ warn() {
143
+ return ignoreMessage;
144
+ }
145
+ /** Discards errors. */
146
+ error() {
147
+ return ignoreMessage;
148
+ }
149
+ };
150
+ function ignoreMessage() {
151
+ }
152
+ var nullLog = new NullLog();
153
+ function getLoaderLog(options) {
154
+ var _a;
155
+ const logger = ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a.log) !== void 0 ? options.core.log : options == null ? void 0 : options.log;
156
+ return logger === null ? nullLog : logger || log;
157
+ }
127
158
 
128
159
  // src/loader-utils/lib/javascript-utils/is-type.ts
129
160
  var isBoolean = (value) => typeof value === "boolean";
@@ -183,10 +214,10 @@ var NPM_TAG = "beta";
183
214
 
184
215
  // src/worker-utils/lib/env-utils/version.ts
185
216
  function getVersion() {
186
- const version2 = typeof __VERSION__ === "undefined" ? NPM_TAG : __VERSION__;
217
+ const version3 = typeof __VERSION__ === "undefined" ? NPM_TAG : __VERSION__;
187
218
  globalThis._loadersgl_ = globalThis._loadersgl_ || {};
188
- globalThis._loadersgl_.version ||= version2;
189
- return version2;
219
+ globalThis._loadersgl_.version ||= version3;
220
+ return version3;
190
221
  }
191
222
  var VERSION2 = getVersion();
192
223
 
@@ -250,11 +281,11 @@ function getWorkerURL(worker, options = {}) {
250
281
  }
251
282
  function getDefaultWorkerURL(worker, warn = false) {
252
283
  const workerFile = isBrowser2 ? worker.workerFile || `${worker.id}-worker.js` : worker.workerNode || `${worker.id}-worker-node.js`;
253
- let version2 = worker.version;
254
- if (version2 === "latest") {
255
- version2 = NPM_TAG;
284
+ let version3 = worker.version;
285
+ if (version3 === "latest") {
286
+ version3 = NPM_TAG;
256
287
  }
257
- const versionTag = version2 ? `@${version2}` : "";
288
+ const versionTag = version3 ? `@${version3}` : "";
258
289
  const url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
259
290
  if (warn) {
260
291
  warnIfUsingNpmTagFallback(worker, url);
@@ -270,9 +301,9 @@ function warnIfUsingNpmTagFallback(worker, url) {
270
301
  return;
271
302
  }
272
303
  warnedWorkerVersionFallbacks.add(workerId);
273
- console.warn(
304
+ log.warn(
274
305
  `loaders.gl: ${worker.name} loader worker version is "latest" because __VERSION__ was not injected. Fetching ${url} from CDN.`
275
- );
306
+ )();
276
307
  }
277
308
 
278
309
  // src/worker-utils/lib/worker-api/task-runtime.ts
@@ -732,7 +763,14 @@ function getWorkerOptions(options = {}, loader) {
732
763
  ...portableOptions,
733
764
  signal: void 0,
734
765
  onProgress: void 0,
735
- ...portableOptions.core ? { core: { ...portableOptions.core, authentications: void 0 } } : {}
766
+ log: isDisabledLog(portableOptions.log) ? null : void 0,
767
+ ...portableOptions.core ? {
768
+ core: {
769
+ ...portableOptions.core,
770
+ authentications: void 0,
771
+ log: isDisabledLog(portableOptions.core.log) ? null : void 0
772
+ }
773
+ } : {}
736
774
  };
737
775
  const serializedOptions = JSON.parse(
738
776
  JSON.stringify(optionsToSerialize, (_key, value) => {
@@ -788,6 +826,9 @@ function shouldParseCSVWithWorker(options) {
788
826
  function isLoaderWithWorkerResultDeserializer(loader) {
789
827
  return typeof loader.deserializeWorkerResult === "function";
790
828
  }
829
+ function isDisabledLog(logger) {
830
+ return logger === null || logger instanceof NullLog;
831
+ }
791
832
 
792
833
  // src/loader-utils/lib/worker-loader-utils/encode-with-worker.ts
793
834
  function canEncodeWithWorker(writer, options) {
@@ -1706,7 +1747,9 @@ var NodeFileFacade = class {
1706
1747
 
1707
1748
  // src/loader-utils/source-types.ts
1708
1749
  function isSourceLoader(loader) {
1709
- return Boolean(loader && typeof loader === "object" && "createDataSource" in loader);
1750
+ return Boolean(
1751
+ loader && typeof loader === "object" && "createDataSourceSync" in loader && "fromUrl" in loader && "testURL" in loader
1752
+ );
1710
1753
  }
1711
1754
 
1712
1755
  // dist/lib/fetch/fetch-error.js
@@ -1933,71 +1976,47 @@ async function readBlob(blob) {
1933
1976
  }
1934
1977
 
1935
1978
  // dist/lib/loader-utils/loggers.js
1936
- var import_log3 = require("probe.gl/log");
1937
- var probeLog = new import_log3.Log({ id: "loaders.gl" });
1938
- var NullLog = class {
1939
- /** Drops a log message. */
1979
+ var import_log6 = require("probe.gl/log");
1980
+
1981
+ // dist/loader-utils/lib/log-utils/log.js
1982
+ var import_log5 = require("probe.gl/log");
1983
+ var VERSION4 = true ? "5.0.0-beta.8" : "latest";
1984
+ var version2 = VERSION4[0] >= "0" && VERSION4[0] <= "9" ? `v${VERSION4}` : "";
1985
+ function createLog2() {
1986
+ const log3 = new import_log5.Log({ id: "loaders.gl" });
1987
+ globalThis.loaders ||= {};
1988
+ globalThis.loaders.log = log3;
1989
+ globalThis.loaders.version = version2;
1990
+ globalThis.probe ||= {};
1991
+ globalThis.probe.loaders = log3;
1992
+ return log3;
1993
+ }
1994
+ var log2 = createLog2();
1995
+ var NullLog2 = class {
1996
+ /** Discards debug messages. */
1940
1997
  log() {
1941
- return () => {
1942
- };
1998
+ return ignoreMessage2;
1943
1999
  }
1944
- /** Drops an info message. */
2000
+ /** Discards informational messages. */
1945
2001
  info() {
1946
- return () => {
1947
- };
2002
+ return ignoreMessage2;
1948
2003
  }
1949
- /** Logs one message once; no-op for the null logger. */
2004
+ /** Discards messages marked to be emitted once. */
1950
2005
  once() {
1951
- return () => {
1952
- };
2006
+ return ignoreMessage2;
1953
2007
  }
1954
- /** Drops a warning message. */
2008
+ /** Discards warnings. */
1955
2009
  warn() {
1956
- return () => {
1957
- };
2010
+ return ignoreMessage2;
1958
2011
  }
1959
- /** Drops an error message. */
2012
+ /** Discards errors. */
1960
2013
  error() {
1961
- return () => {
1962
- };
1963
- }
1964
- };
1965
- var ConsoleLog = class {
1966
- /** Console-like object used for message output. */
1967
- console;
1968
- /** Messages already emitted through `once`. */
1969
- onceMessages = /* @__PURE__ */ new Set();
1970
- /** Creates a console-backed logger. */
1971
- constructor() {
1972
- this.console = console;
1973
- }
1974
- /** Logs a message to the console. */
1975
- log(...args) {
1976
- return this.console.log.bind(this.console, ...args);
1977
- }
1978
- /** Logs an informational message to the console. */
1979
- info(...args) {
1980
- return this.console.info.bind(this.console, ...args);
1981
- }
1982
- /** Logs one message once to the console. */
1983
- once(...args) {
1984
- const message = String(args[0]);
1985
- if (this.onceMessages.has(message)) {
1986
- return () => {
1987
- };
1988
- }
1989
- this.onceMessages.add(message);
1990
- return this.console.info.bind(this.console, ...args);
1991
- }
1992
- /** Logs a warning message to the console. */
1993
- warn(...args) {
1994
- return this.console.warn.bind(this.console, ...args);
1995
- }
1996
- /** Logs an error message to the console. */
1997
- error(...args) {
1998
- return this.console.error.bind(this.console, ...args);
2014
+ return ignoreMessage2;
1999
2015
  }
2000
2016
  };
2017
+ function ignoreMessage2() {
2018
+ }
2019
+ var nullLog2 = new NullLog2();
2001
2020
 
2002
2021
  // dist/lib/loader-utils/option-defaults.js
2003
2022
  var DEFAULT_LOADER_OPTIONS = {
@@ -2011,8 +2030,7 @@ var DEFAULT_LOADER_OPTIONS = {
2011
2030
  ignoreRegisteredLoaders: void 0,
2012
2031
  nothrow: false,
2013
2032
  shape: void 0,
2014
- log: new ConsoleLog(),
2015
- // A probe.gl compatible (`log.log()()` syntax) that just logs to console
2033
+ log: log2,
2016
2034
  useLocalLibraries: false,
2017
2035
  subloaders: void 0,
2018
2036
  CDN: "https://unpkg.com/@loaders.gl",
@@ -2083,6 +2101,48 @@ var REMOVED_LOADER_OPTIONS = {
2083
2101
  signal: "core.fetch.signal"
2084
2102
  };
2085
2103
 
2104
+ // dist/lib/loader-utils/native-arrow.js
2105
+ function getShapeOptionKey(loader) {
2106
+ const keys = Object.keys(loader.options || {}).filter((key) => {
2107
+ var _a;
2108
+ const value = (_a = loader.options) == null ? void 0 : _a[key];
2109
+ return key !== "core" && value && typeof value === "object" && "shape" in value;
2110
+ });
2111
+ return keys.includes(loader.id) ? loader.id : keys.length === 1 ? keys[0] : void 0;
2112
+ }
2113
+ function getNativeArrowOptions(loader, options, inBatches = false) {
2114
+ var _a, _b;
2115
+ const key = getShapeOptionKey(loader);
2116
+ const scopedOptions = key && options[key];
2117
+ if (!scopedOptions || typeof scopedOptions !== "object" || !("shape" in scopedOptions) || scopedOptions.shape !== "arrow") {
2118
+ return null;
2119
+ }
2120
+ if (inBatches && ((_a = options.core) == null ? void 0 : _a.metadata)) {
2121
+ throw new Error('shape: "arrow" does not support core.metadata; use "arrow-table" for batch metadata');
2122
+ }
2123
+ return {
2124
+ ...options,
2125
+ core: { ...options.core, ...((_b = options.core) == null ? void 0 : _b.shape) === "arrow" ? { shape: "arrow-table" } : {} },
2126
+ [key]: { ...scopedOptions, shape: "arrow-table" }
2127
+ };
2128
+ }
2129
+ function unwrapArrowTable(result) {
2130
+ const table = result;
2131
+ if ((table == null ? void 0 : table.shape) !== "arrow-table" || !table.data || !Array.isArray(table.data.batches)) {
2132
+ throw new Error('shape: "arrow" requires a loader that supports "arrow-table" output');
2133
+ }
2134
+ return table.data;
2135
+ }
2136
+ async function* unwrapArrowBatches(batches) {
2137
+ for await (const batch of batches) {
2138
+ const batchType = batch == null ? void 0 : batch.batchType;
2139
+ if (batchType === "metadata" || batchType === "partial-result" || batchType === "final-result") {
2140
+ continue;
2141
+ }
2142
+ yield* unwrapArrowTable(batch).batches;
2143
+ }
2144
+ }
2145
+
2086
2146
  // dist/lib/loader-utils/option-utils.js
2087
2147
  var CORE_LOADER_OPTION_KEYS = [
2088
2148
  "baseUrl",
@@ -2200,13 +2260,13 @@ function validateOptionsObject(options, id, defaultOptions, deprecatedOptions, l
2200
2260
  const isWorkerUrlOption = key === "workerUrl" && id;
2201
2261
  if (!(key in defaultOptions) && !isBaseUriOption && !isWorkerUrlOption) {
2202
2262
  if (key in deprecatedOptions) {
2203
- if (probeLog.level > 0) {
2204
- probeLog.warn(`${loaderName} loader option '${prefix}${key}' no longer supported, use '${deprecatedOptions[key]}'`)();
2263
+ if (log2.level > 0) {
2264
+ log2.warn(`${loaderName} loader option '${prefix}${key}' no longer supported, use '${deprecatedOptions[key]}'`)();
2205
2265
  }
2206
2266
  } else if (!isSubOptions) {
2207
- if (probeLog.level > 0) {
2267
+ if (log2.level > 0) {
2208
2268
  const suggestion = findSimilarOption(key, loaders);
2209
- probeLog.warn(`${loaderName} loader option '${prefix}${key}' not recognized. ${suggestion}`)();
2269
+ log2.warn(`${loaderName} loader option '${prefix}${key}' not recognized. ${suggestion}`)();
2210
2270
  }
2211
2271
  }
2212
2272
  }
@@ -2237,13 +2297,20 @@ function normalizeOptionsInternal(loader, options, url) {
2237
2297
  mergedOptions.core = { ...loaderDefaultOptions.core };
2238
2298
  }
2239
2299
  moveDeprecatedTopLevelOptionsToCore(mergedOptions);
2240
- if (((_a = mergedOptions.core) == null ? void 0 : _a.log) === null) {
2241
- mergedOptions.core = { ...mergedOptions.core, log: new NullLog() };
2300
+ const shapeKey = loader.defaultShape && getShapeOptionKey(loader);
2301
+ if (shapeKey) {
2302
+ mergedOptions[shapeKey] = {
2303
+ ...loaderDefaultOptions[shapeKey],
2304
+ shape: loader.defaultShape
2305
+ };
2242
2306
  }
2243
2307
  mergeNestedFields(mergedOptions, normalizeLoaderOptions(getGlobalLoaderOptions()));
2244
2308
  const userOptions = normalizeLoaderOptions(options);
2245
2309
  mergeNestedFields(mergedOptions, userOptions);
2246
2310
  applyCoreShapeDefault(mergedOptions, userOptions, loader);
2311
+ if (((_a = mergedOptions.core) == null ? void 0 : _a.log) === null) {
2312
+ mergedOptions.core = { ...mergedOptions.core, log: getLoaderLog(mergedOptions) };
2313
+ }
2247
2314
  addUrlOptions(mergedOptions, url);
2248
2315
  addDeprecatedTopLevelOptions(mergedOptions);
2249
2316
  return mergedOptions;
@@ -2254,20 +2321,24 @@ function applyCoreShapeDefault(mergedOptions, userOptions, loader) {
2254
2321
  if (coreShape === void 0) {
2255
2322
  return;
2256
2323
  }
2257
- const loaderScopedDefaults = (_b = loader.options) == null ? void 0 : _b[loader.id];
2324
+ const shapeOptionKey = getShapeOptionKey(loader);
2325
+ if (!shapeOptionKey) {
2326
+ return;
2327
+ }
2328
+ const loaderScopedDefaults = (_b = loader.options) == null ? void 0 : _b[shapeOptionKey];
2258
2329
  if (!isPureObject(loaderScopedDefaults) || !("shape" in loaderScopedDefaults)) {
2259
2330
  return;
2260
2331
  }
2261
- const globalLoaderScopedOptions = getGlobalLoaderOptions()[loader.id];
2332
+ const globalLoaderScopedOptions = getGlobalLoaderOptions()[shapeOptionKey];
2262
2333
  if (isPureObject(globalLoaderScopedOptions) && "shape" in globalLoaderScopedOptions) {
2263
2334
  return;
2264
2335
  }
2265
- const userLoaderScopedOptions = userOptions[loader.id];
2336
+ const userLoaderScopedOptions = userOptions[shapeOptionKey];
2266
2337
  if (isPureObject(userLoaderScopedOptions) && "shape" in userLoaderScopedOptions) {
2267
2338
  return;
2268
2339
  }
2269
- const loaderScopedOptions = mergedOptions[loader.id];
2270
- mergedOptions[loader.id] = {
2340
+ const loaderScopedOptions = mergedOptions[shapeOptionKey];
2341
+ mergedOptions[shapeOptionKey] = {
2271
2342
  ...isPureObject(loaderScopedOptions) ? loaderScopedOptions : {},
2272
2343
  shape: coreShape
2273
2344
  };
@@ -2400,30 +2471,29 @@ function _unregisterLoaders() {
2400
2471
 
2401
2472
  // dist/lib/api/select-loader.js
2402
2473
  var EXT_PATTERN = /\.([^.]+)$/;
2403
- async function selectLoader(data, loaders = [], options, context) {
2474
+ async function selectLoader(data, loaders = [], options, context, operation = "parse") {
2404
2475
  if (!validHTTPResponse(data)) {
2405
2476
  return null;
2406
2477
  }
2407
2478
  const normalizedOptions = normalizeLoaderOptions(options || {});
2408
2479
  normalizedOptions.core ||= {};
2409
- if (data instanceof Response && mayContainText(data)) {
2410
- const text = await data.clone().text();
2411
- const textLoader = selectLoaderSync(text, loaders, { ...normalizedOptions, core: { ...normalizedOptions.core, nothrow: true } }, context);
2412
- if (textLoader) {
2413
- return textLoader;
2414
- }
2415
- }
2416
- let loader = selectLoaderSync(data, loaders, { ...normalizedOptions, core: { ...normalizedOptions.core, nothrow: true } }, context);
2417
- if (loader) {
2418
- return loader;
2480
+ if (loaders && !Array.isArray(loaders)) {
2481
+ return normalizeLoader(loaders);
2419
2482
  }
2420
- if (isBlob(data)) {
2421
- data = await data.slice(0, 10).arrayBuffer();
2422
- loader = selectLoaderSync(data, loaders, normalizedOptions, context);
2483
+ const text = data instanceof Response && mayContainText(data) ? await data.clone().text() : null;
2484
+ let initialBytes;
2485
+ async function matchCandidates(candidates) {
2486
+ normalizeLoaders(candidates);
2487
+ const loader2 = text !== null && selectLoaderInternal(text, candidates, normalizedOptions, context, operation) || selectLoaderInternal(data, candidates, normalizedOptions, context, operation);
2488
+ if (!loader2 && isBlob(data) && candidates.length) {
2489
+ initialBytes ??= await data.slice(0, 10).arrayBuffer();
2490
+ return selectLoaderInternal(initialBytes, candidates, normalizedOptions, context, operation);
2491
+ }
2492
+ return loader2;
2423
2493
  }
2424
- if (!loader && data instanceof Response && mayContainText(data)) {
2425
- const text = await data.clone().text();
2426
- loader = selectLoaderSync(text, loaders, normalizedOptions, context);
2494
+ let loader = await matchCandidates(loaders || []);
2495
+ if (!loader && !normalizedOptions.core.ignoreRegisteredLoaders) {
2496
+ loader = await matchCandidates(getRegisteredLoaders());
2427
2497
  }
2428
2498
  if (!loader && !normalizedOptions.core.nothrow) {
2429
2499
  throw new Error(getNoValidLoaderMessage(data));
@@ -2434,7 +2504,7 @@ function mayContainText(response) {
2434
2504
  const mimeType = getResourceMIMEType(response);
2435
2505
  return Boolean(mimeType && (mimeType.startsWith("text/") || mimeType === "application/json" || mimeType.endsWith("+json")));
2436
2506
  }
2437
- function selectLoaderSync(data, loaders = [], options, context) {
2507
+ function selectLoaderSync(data, loaders = [], options, context, operation = "parse") {
2438
2508
  if (!validHTTPResponse(data)) {
2439
2509
  return null;
2440
2510
  }
@@ -2443,21 +2513,18 @@ function selectLoaderSync(data, loaders = [], options, context) {
2443
2513
  if (loaders && !Array.isArray(loaders)) {
2444
2514
  return normalizeLoader(loaders);
2445
2515
  }
2446
- let candidateLoaders = [];
2447
- if (loaders) {
2448
- candidateLoaders = candidateLoaders.concat(loaders);
2449
- }
2450
- if (!normalizedOptions.core.ignoreRegisteredLoaders) {
2451
- candidateLoaders.push(...getRegisteredLoaders());
2516
+ const candidates = loaders || [];
2517
+ normalizeLoaders(candidates);
2518
+ let loader = selectLoaderInternal(data, candidates, normalizedOptions, context, operation);
2519
+ if (!loader && !normalizedOptions.core.ignoreRegisteredLoaders) {
2520
+ loader = selectLoaderInternal(data, getRegisteredLoaders(), normalizedOptions, context, operation);
2452
2521
  }
2453
- normalizeLoaders(candidateLoaders);
2454
- const loader = selectLoaderInternal(data, candidateLoaders, normalizedOptions, context);
2455
2522
  if (!loader && !normalizedOptions.core.nothrow) {
2456
2523
  throw new Error(getNoValidLoaderMessage(data));
2457
2524
  }
2458
2525
  return loader;
2459
2526
  }
2460
- function selectLoaderInternal(data, loaders, options, context) {
2527
+ function selectLoaderInternal(data, loaders, options, context, operation = "parse") {
2461
2528
  var _a, _b, _c, _d, _e;
2462
2529
  const url = getResourceUrl(data);
2463
2530
  const type = getResourceMIMEType(data);
@@ -2473,20 +2540,27 @@ function selectLoaderInternal(data, loaders, options, context) {
2473
2540
  loader = findLoaderByMIMEType(loaders, (_b = options == null ? void 0 : options.core) == null ? void 0 : _b.mimeType);
2474
2541
  reason = `match forced by supplied MIME type ${(_c = options == null ? void 0 : options.core) == null ? void 0 : _c.mimeType}`;
2475
2542
  }
2476
- loader = loader || findSourceLoaderByTestURL(loaders, testUrl);
2477
- reason = reason || (loader ? `matched source url ${testUrl}` : "");
2478
- loader = loader || findLoaderByUrl(loaders, testUrl);
2543
+ if (!loader && operation === "source") {
2544
+ loader = findSourceLoaderByTestURL(loaders, testUrl);
2545
+ reason = loader ? `matched source url ${testUrl}` : "";
2546
+ }
2547
+ const fallbackLoaders = operation === "source" && testUrl ? loaders.filter((candidate) => !isSourceLoader(candidate)) : loaders;
2548
+ loader = loader || findLoaderByUrl(fallbackLoaders, testUrl);
2479
2549
  reason = reason || (loader ? `matched url ${testUrl}` : "");
2480
- loader = loader || findLoaderByMIMEType(loaders, type);
2550
+ if (!loader && operation === "parse") {
2551
+ loader = findSourceLoaderByTestURL(loaders, testUrl);
2552
+ reason = loader ? `matched source url ${testUrl}` : "";
2553
+ }
2554
+ loader = loader || findLoaderByMIMEType(fallbackLoaders, type);
2481
2555
  reason = reason || (loader ? `matched MIME type ${type}` : "");
2482
- loader = loader || findLoaderByInitialBytes(loaders, data);
2556
+ loader = loader || findLoaderByInitialBytes(fallbackLoaders, data);
2483
2557
  reason = reason || (loader ? `matched initial data ${getFirstCharacters(data)}` : "");
2484
2558
  if (!loader && isBlob(data)) {
2485
2559
  loader = findSourceLoaderByTestData(loaders, data);
2486
2560
  reason = reason || (loader ? "matched source testData" : "");
2487
2561
  }
2488
2562
  if ((_d = options == null ? void 0 : options.core) == null ? void 0 : _d.fallbackMimeType) {
2489
- loader = loader || findLoaderByMIMEType(loaders, (_e = options == null ? void 0 : options.core) == null ? void 0 : _e.fallbackMimeType);
2563
+ loader = loader || findLoaderByMIMEType(fallbackLoaders, (_e = options == null ? void 0 : options.core) == null ? void 0 : _e.fallbackMimeType);
2490
2564
  reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
2491
2565
  }
2492
2566
  if (reason) {
@@ -2916,14 +2990,7 @@ var loaderImplementationPromises = /* @__PURE__ */ new Map();
2916
2990
  var loaderImplementations = /* @__PURE__ */ new Map();
2917
2991
  async function getLoaderImplementation(loader, options, url) {
2918
2992
  var _a;
2919
- if (isSourceLoader(loader)) {
2920
- const source = loader.preload ? await loader.preload(url || "", options) : loader;
2921
- if (!isSourceLoader(source)) {
2922
- throw new Error(`${loader.id} source loader preload() did not return a runtime source loader`);
2923
- }
2924
- return source;
2925
- }
2926
- if (isLoaderWithParser(loader)) {
2993
+ if (isLoaderWithParser(loader) || !loader.preload && loader.createDataSourceSync) {
2927
2994
  return loader;
2928
2995
  }
2929
2996
  const implementationCacheKey = getLoaderImplementationCacheKey(loader, options);
@@ -2957,7 +3024,7 @@ async function getLoaderImplementation(loader, options, url) {
2957
3024
  }
2958
3025
  return await loaderImplementationPromise;
2959
3026
  }
2960
- function getLoaderImplementationSync(loader) {
3027
+ function getLoaderImplementationSync(loader, options) {
2961
3028
  var _a;
2962
3029
  if (loader.subloaders && !preparedLoaders.has(loader)) {
2963
3030
  const prepared = preparedDefaults.get(loader);
@@ -2966,23 +3033,23 @@ function getLoaderImplementationSync(loader) {
2966
3033
  if (!isLoaderWithParser(loader))
2967
3034
  return null;
2968
3035
  }
2969
- if (isLoaderWithParser(loader)) {
3036
+ if (isLoaderWithParser(loader) || !loader.preload && loader.createDataSourceSync) {
2970
3037
  return loader;
2971
3038
  }
2972
- const implementationCacheKey = getLoaderImplementationCacheKey(loader);
3039
+ const implementationCacheKey = getLoaderImplementationCacheKey(loader, options);
2973
3040
  return ((_a = loaderImplementations.get(loader)) == null ? void 0 : _a.get(implementationCacheKey)) || null;
2974
3041
  }
2975
3042
  function isLoaderWithParser(loader) {
2976
3043
  const candidate = loader;
2977
- return Boolean(candidate.parse || candidate.parseSync || candidate.parseInBatches || candidate.parseText || candidate.parseTextSync || candidate.parseFile || candidate.parseFileInBatches);
3044
+ return Boolean(candidate.parse || candidate.parseBlob || candidate.parseUrl || candidate.parseSync || candidate.parseInBatches || candidate.parseText || candidate.parseTextSync || candidate.parseFile || candidate.parseFileInBatches);
2978
3045
  }
2979
3046
  async function resolveLoaderImplementation(loader, options, url) {
2980
3047
  if (loader.preload) {
2981
3048
  const preloadedLoader = await loader.preload(url || "", options);
2982
- if (isLoaderWithParser(preloadedLoader)) {
3049
+ if (preloadedLoader && (isLoaderWithParser(preloadedLoader) || preloadedLoader.createDataSourceSync)) {
2983
3050
  return preloadedLoader;
2984
3051
  }
2985
- throw new Error(`${loader.id} loader preload() did not return a parser-bearing loader`);
3052
+ throw new Error(`${loader.id} loader preload() did not return a parser-bearing loader or a source factory`);
2986
3053
  }
2987
3054
  const implementationSpecifier = getLoaderImplementationSpecifier(loader, options);
2988
3055
  return await importLoaderImplementation(implementationSpecifier, loader.id);
@@ -3078,7 +3145,7 @@ async function bindSubloaders(loader, options, url) {
3078
3145
  prepared.worker = false;
3079
3146
  for (const method of [
3080
3147
  "parseBlob",
3081
- "createDataSource",
3148
+ "createDataSourceSync",
3082
3149
  "parse",
3083
3150
  "parseSync",
3084
3151
  "parseText",
@@ -3126,28 +3193,29 @@ async function parseFile(file, loaders, options, context) {
3126
3193
  if (!loader) {
3127
3194
  return null;
3128
3195
  }
3129
- if (isSourceLoader(loader)) {
3130
- throw new Error(`${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parseFile().`);
3131
- }
3132
3196
  const normalizedOptions = normalizeOptions(options, loader, candidateLoaders, url);
3133
3197
  const authenticationLoader = !loader.getAuthentications && ((_c = (_b = normalizedOptions.core) == null ? void 0 : _b.credentials) == null ? void 0 : _c.length) ? await getLoaderImplementation(loader, normalizedOptions, url || (context == null ? void 0 : context.url)) : loader;
3134
3198
  const strictOptions = await resolveLoaderAuthenticationOptions(authenticationLoader, url, normalizedOptions);
3199
+ const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
3135
3200
  context = getLoaderContext(
3136
3201
  // @ts-expect-error candidateLoaders may be a single forced loader
3137
3202
  { url, _parse: parse, loaders: candidateLoaders },
3138
- strictOptions,
3203
+ nativeArrowOptions || strictOptions,
3139
3204
  context || null
3140
3205
  );
3141
- return await parseFileWithLoader(loader, file, strictOptions, context);
3206
+ const result = await parseFileWithLoader(loader, file, nativeArrowOptions || strictOptions, context);
3207
+ return nativeArrowOptions ? unwrapArrowTable(result) : result;
3142
3208
  }
3143
3209
  async function parseFileWithLoader(loader, file, options, context) {
3144
- var _a;
3210
+ var _a, _b;
3145
3211
  (_a = options.signal || context.signal) == null ? void 0 : _a.throwIfAborted();
3146
3212
  validateWorkerVersion(loader);
3147
3213
  options = mergeOptions(loader.options, options);
3148
3214
  const loaderWithParser = await getLoaderImplementation(loader, options, context.url);
3149
3215
  if (loaderWithParser.parseFile) {
3150
- return await loaderWithParser.parseFile(file, options, context);
3216
+ const output = (_b = loaderWithParser.prepareParseOutput) == null ? void 0 : _b.call(loaderWithParser, options);
3217
+ const result = await loaderWithParser.parseFile(file, (output == null ? void 0 : output.options) ?? options, context);
3218
+ return output ? output.convert(result) : result;
3151
3219
  }
3152
3220
  const parseFunction = loaderWithParser.parse;
3153
3221
  if (parseFunction) {
@@ -3158,6 +3226,9 @@ async function parseFileWithLoader(loader, file, options, context) {
3158
3226
  const data = await file.read(0n, length);
3159
3227
  return await parse(data, loaderWithParser, options, context);
3160
3228
  }
3229
+ if (loaderWithParser.createDataSourceSync) {
3230
+ throw new Error(`${loader.id} has no file parser. Use createDataSource() to open a source.`);
3231
+ }
3161
3232
  throw new Error(`${loader.id} loader - no file parser found`);
3162
3233
  }
3163
3234
 
@@ -3175,17 +3246,16 @@ function parseSync(data, loaders, options, context) {
3175
3246
  if (!loader) {
3176
3247
  return null;
3177
3248
  }
3178
- if (isSourceLoader(loader)) {
3179
- throw new Error(`${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parseSync().`);
3180
- }
3181
3249
  const strictOptions = normalizeOptions(options, loader, candidateLoaders);
3182
3250
  const url = getResourceUrl(data);
3183
3251
  const parse2 = () => {
3184
3252
  throw new Error("parseSync called parse (which is async");
3185
3253
  };
3186
- context = getLoaderContext({ url, _parseSync: parse2, _parse: parse2, loaders }, strictOptions, context || null);
3254
+ const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
3255
+ context = getLoaderContext({ url, _parseSync: parse2, _parse: parse2, loaders }, nativeArrowOptions || strictOptions, context || null);
3187
3256
  const loaderWithParser = getLoaderImplementationSync(loader);
3188
- return parseWithLoaderSync(loaderWithParser || loader, data, strictOptions, context);
3257
+ const result = parseWithLoaderSync(loaderWithParser || loader, data, nativeArrowOptions || strictOptions, context);
3258
+ return nativeArrowOptions ? unwrapArrowTable(result) : result;
3189
3259
  }
3190
3260
  function parseWithLoaderSync(loader, data, options, context) {
3191
3261
  data = getArrayBufferOrStringFromDataSync(data, loader, options);
@@ -3198,6 +3268,9 @@ function parseWithLoaderSync(loader, data, options, context) {
3198
3268
  if (loader.preload) {
3199
3269
  throw new Error(`${loader.name} loader: 'parseSync' requires a parser-bearing loader. Import the loader implementation directly, or call preload(loader) before parseSync(). ${context.url || ""}`);
3200
3270
  }
3271
+ if (loader.createDataSourceSync) {
3272
+ throw new Error(`${loader.id} has no synchronous parser. Use createDataSource() to open a source.`);
3273
+ }
3201
3274
  throw new Error(`${loader.name} loader: 'parseSync' not supported by this loader, use 'parse' instead. ${context.url || ""}`);
3202
3275
  }
3203
3276
 
@@ -3222,14 +3295,18 @@ async function parseInBatches(data, loaders, options, context) {
3222
3295
  const normalizedOptions = normalizeOptions(options, loader, loaderArray, url);
3223
3296
  const authenticationLoader = !loader.getAuthentications && ((_d = (_c = normalizedOptions.core) == null ? void 0 : _c.credentials) == null ? void 0 : _d.length) ? await getLoaderImplementation(loader, normalizedOptions, url || (context == null ? void 0 : context.url)) : loader;
3224
3297
  const strictOptions = await resolveLoaderAuthenticationOptions(authenticationLoader, url || "", normalizedOptions);
3225
- context = getLoaderContext({ url, _parseInBatches: parseInBatches, _parse: parse, loaders: loaderArray }, strictOptions, context || null);
3298
+ const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, true);
3299
+ context = getLoaderContext({ url, _parseInBatches: parseInBatches, _parse: parse, loaders: loaderArray }, nativeArrowOptions || strictOptions, context || null);
3226
3300
  const loaderWithParser = await getLoaderImplementation(loader, strictOptions, context.url);
3227
- return await parseWithLoaderInBatches(loader, loaderWithParser, data, strictOptions, context);
3301
+ const batches = await parseWithLoaderInBatches(loader, loaderWithParser, data, nativeArrowOptions || strictOptions, context);
3302
+ return nativeArrowOptions ? unwrapArrowBatches(batches) : batches;
3228
3303
  }
3229
3304
  async function parseWithLoaderInBatches(originalLoader, loader, data, options, context) {
3230
- var _a;
3231
- const outputIterator = await parseToOutputIterator(loader, data, options, context);
3232
- if (!((_a = options == null ? void 0 : options.core) == null ? void 0 : _a.metadata)) {
3305
+ var _a, _b;
3306
+ const output = loader.parseInBatches ? (_a = loader.prepareParseBatchOutput) == null ? void 0 : _a.call(loader, options) : null;
3307
+ const decoded = await parseToOutputIterator(loader, data, (output == null ? void 0 : output.options) ?? options, context);
3308
+ const outputIterator = output ? convertOutputBatches(decoded, output.convert) : decoded;
3309
+ if (!((_b = options == null ? void 0 : options.core) == null ? void 0 : _b.metadata)) {
3233
3310
  return outputIterator;
3234
3311
  }
3235
3312
  const metadataBatch = {
@@ -3249,6 +3326,11 @@ async function parseWithLoaderInBatches(originalLoader, loader, data, options, c
3249
3326
  }
3250
3327
  return makeMetadataBatchIterator(outputIterator);
3251
3328
  }
3329
+ async function* convertOutputBatches(batches, convert) {
3330
+ for await (const batch of batches) {
3331
+ yield convert(batch);
3332
+ }
3333
+ }
3252
3334
  async function parseToOutputIterator(loader, data, options, context) {
3253
3335
  var _a;
3254
3336
  const inputIterator = await getAsyncIterableFromData(data, options);
@@ -3326,39 +3408,6 @@ async function applyInputTransforms(inputIterator, transforms = []) {
3326
3408
  return iteratorChain;
3327
3409
  }
3328
3410
 
3329
- // dist/lib/api/load-in-batches.js
3330
- function loadInBatches(files, loaders, options, context) {
3331
- let loadersArray;
3332
- if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
3333
- context = void 0;
3334
- options = loaders;
3335
- loadersArray = void 0;
3336
- } else {
3337
- loadersArray = loaders;
3338
- }
3339
- if (!Array.isArray(files)) {
3340
- return loadOneFileInBatches(files, loadersArray, options || {});
3341
- }
3342
- const promises = files.map((file) => loadOneFileInBatches(file, loadersArray, options || {}));
3343
- return promises;
3344
- }
3345
- async function loadOneFileInBatches(file, loaders, options) {
3346
- var _a, _b;
3347
- if (typeof file === "string") {
3348
- const url = file;
3349
- const loader = await selectLoader(url, loaders, {
3350
- ...options,
3351
- core: { ...options.core, nothrow: true }
3352
- });
3353
- const authenticationLoader = loader && !loader.getAuthentications && ((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length) ? await getLoaderImplementation(loader, options, url) : loader;
3354
- options = await resolveLoaderAuthenticationOptions(authenticationLoader, url, options);
3355
- const fetch2 = getFetchFunction(options);
3356
- const response = await fetch2(applySearchParamsToUrl(url, options));
3357
- return Array.isArray(loaders) ? await parseInBatches(response, loaders, options) : await parseInBatches(response, loaders, options);
3358
- }
3359
- return Array.isArray(loaders) ? await parseInBatches(file, loaders, options) : await parseInBatches(file, loaders, options);
3360
- }
3361
-
3362
3411
  // dist/lib/api/load.js
3363
3412
  async function load(url, loaders, options, context) {
3364
3413
  var _a;
@@ -3373,59 +3422,23 @@ async function load(url, loaders, options, context) {
3373
3422
  resolvedOptions = options;
3374
3423
  }
3375
3424
  resolvedOptions ||= getGlobalLoaderOptions();
3376
- if (!Array.isArray(resolvedLoaders) && isSourceLoader(resolvedLoaders)) {
3377
- const sourceLoader = await resolveSourceLoader(resolvedLoaders, url, resolvedOptions);
3378
- resolvedOptions = await resolveLoaderAuthenticationOptions(resolvedLoaders.getAuthentications ? resolvedLoaders : sourceLoader, typeof url === "string" ? url : "", resolvedOptions || {});
3379
- const runtimeCoreApi = {
3380
- fetchFile,
3381
- parse,
3382
- parseFile,
3383
- parseSync,
3384
- parseInBatches,
3385
- load,
3386
- loadInBatches
3387
- };
3388
- return sourceLoader.createDataSource(url, resolvedOptions || {}, runtimeCoreApi);
3389
- }
3390
- if (Array.isArray(resolvedLoaders) && resolvedLoaders.length === 1 && isSourceLoader(resolvedLoaders[0])) {
3391
- const sourceLoader = await resolveSourceLoader(resolvedLoaders[0], url, resolvedOptions);
3392
- resolvedOptions = await resolveLoaderAuthenticationOptions(resolvedLoaders[0].getAuthentications ? resolvedLoaders[0] : sourceLoader, typeof url === "string" ? url : "", resolvedOptions || {});
3393
- const runtimeCoreApi = {
3394
- fetchFile,
3395
- parse,
3396
- parseFile,
3397
- parseSync,
3398
- parseInBatches,
3399
- load,
3400
- loadInBatches
3401
- };
3402
- return sourceLoader.createDataSource(url, resolvedOptions || {}, runtimeCoreApi);
3403
- }
3404
3425
  if (typeof url === "string" || isBlob(url)) {
3405
3426
  const selectedLoader = await selectLoader(url, resolvedLoaders, {
3406
3427
  ...resolvedOptions,
3407
3428
  core: { ...resolvedOptions == null ? void 0 : resolvedOptions.core, nothrow: true }
3408
3429
  });
3409
- if (selectedLoader && isSourceLoader(selectedLoader)) {
3410
- const sourceLoader = await resolveSourceLoader(selectedLoader, url, resolvedOptions);
3411
- resolvedOptions = await resolveLoaderAuthenticationOptions(selectedLoader.getAuthentications ? selectedLoader : sourceLoader, typeof url === "string" ? url : "", resolvedOptions || {});
3412
- return sourceLoader.createDataSource(url, resolvedOptions || {}, {
3413
- fetchFile,
3414
- parse,
3415
- parseFile,
3416
- parseSync,
3417
- parseInBatches,
3418
- load,
3419
- loadInBatches
3420
- });
3421
- }
3422
3430
  if (selectedLoader && typeof url === "string") {
3423
3431
  const loaderImplementation = await getLoaderImplementation(selectedLoader, resolvedOptions, url);
3432
+ if (loaderImplementation.createDataSourceSync && !isLoaderWithParser(loaderImplementation)) {
3433
+ throw new Error(`${selectedLoader.id} creates sources. Use createDataSource() instead of load().`);
3434
+ }
3424
3435
  resolvedOptions = await resolveLoaderAuthenticationOptions(selectedLoader.getAuthentications ? selectedLoader : loaderImplementation, url, resolvedOptions || {});
3425
- const parseUrl = loaderImplementation.parseUrl;
3436
+ const { parseUrl } = loaderImplementation;
3426
3437
  if (parseUrl) {
3427
3438
  const requestUrl = applySearchParamsToUrl(url, resolvedOptions);
3428
- return await parseUrl(requestUrl, resolvedOptions, context);
3439
+ const nativeOptions = getNativeArrowOptions(selectedLoader, normalizeOptions(resolvedOptions, selectedLoader, [selectedLoader], url));
3440
+ const result = await parseUrl(requestUrl, nativeOptions || resolvedOptions, context);
3441
+ return nativeOptions ? unwrapArrowTable(result) : result;
3429
3442
  }
3430
3443
  }
3431
3444
  }
@@ -3453,15 +3466,38 @@ async function load(url, loaders, options, context) {
3453
3466
  }
3454
3467
  return Array.isArray(resolvedLoaders) ? await parse(data, resolvedLoaders, resolvedOptions, context) : await parse(data, resolvedLoaders, resolvedOptions, context);
3455
3468
  }
3456
- async function resolveSourceLoader(loader, url, options) {
3457
- if (!loader.preload) {
3458
- return loader;
3469
+
3470
+ // dist/lib/api/load-in-batches.js
3471
+ function loadInBatches(files, loaders, options, context) {
3472
+ let loadersArray;
3473
+ if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
3474
+ context = void 0;
3475
+ options = loaders;
3476
+ loadersArray = void 0;
3477
+ } else {
3478
+ loadersArray = loaders;
3459
3479
  }
3460
- const sourceLoader = await loader.preload(typeof url === "string" ? url : "", options);
3461
- if (!isSourceLoader(sourceLoader)) {
3462
- throw new Error(`${loader.id} source loader preload() did not return a runtime source loader`);
3480
+ if (!Array.isArray(files)) {
3481
+ return loadOneFileInBatches(files, loadersArray, options || {});
3463
3482
  }
3464
- return sourceLoader;
3483
+ const promises = files.map((file) => loadOneFileInBatches(file, loadersArray, options || {}));
3484
+ return promises;
3485
+ }
3486
+ async function loadOneFileInBatches(file, loaders, options) {
3487
+ var _a, _b;
3488
+ if (typeof file === "string") {
3489
+ const url = file;
3490
+ const loader = await selectLoader(url, loaders, {
3491
+ ...options,
3492
+ core: { ...options.core, nothrow: true }
3493
+ });
3494
+ const authenticationLoader = loader && !loader.getAuthentications && ((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length) ? await getLoaderImplementation(loader, options, url) : loader;
3495
+ options = await resolveLoaderAuthenticationOptions(authenticationLoader, url, options);
3496
+ const fetch2 = getFetchFunction(options);
3497
+ const response = await fetch2(applySearchParamsToUrl(url, options));
3498
+ return Array.isArray(loaders) ? await parseInBatches(response, loaders, options) : await parseInBatches(response, loaders, options);
3499
+ }
3500
+ return Array.isArray(loaders) ? await parseInBatches(file, loaders, options) : await parseInBatches(file, loaders, options);
3465
3501
  }
3466
3502
 
3467
3503
  // dist/lib/api/core-api.js
@@ -3540,22 +3576,21 @@ async function parse(data, loaders, options, context) {
3540
3576
  if (!loader) {
3541
3577
  return null;
3542
3578
  }
3543
- if (isSourceLoader(loader)) {
3544
- throw new Error(`${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parse().`);
3545
- }
3546
3579
  const normalizedOptions = normalizeOptions(options, loader, candidateLoaders, url);
3547
3580
  const authenticationLoader = !loader.getAuthentications && ((_d = (_c = normalizedOptions.core) == null ? void 0 : _c.credentials) == null ? void 0 : _d.length) ? await getLoaderImplementation(loader, normalizedOptions, url || (context == null ? void 0 : context.url)) : loader;
3548
3581
  const strictOptions = await resolveLoaderAuthenticationOptions(authenticationLoader, url || "", normalizedOptions);
3582
+ const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
3549
3583
  context = getLoaderContext(
3550
3584
  // @ts-expect-error
3551
3585
  { url, _parse: parse, loaders: candidateLoaders },
3552
- strictOptions,
3586
+ nativeArrowOptions || strictOptions,
3553
3587
  context || null
3554
3588
  );
3555
- return await parseWithLoader(loader, data, strictOptions, context);
3589
+ const result = await parseWithLoader(loader, data, nativeArrowOptions || strictOptions, context);
3590
+ return nativeArrowOptions ? unwrapArrowTable(result) : result;
3556
3591
  }
3557
3592
  async function parseWithLoader(loader, data, options, context) {
3558
- var _a;
3593
+ var _a, _b;
3559
3594
  (_a = options.signal || context.signal) == null ? void 0 : _a.throwIfAborted();
3560
3595
  validateWorkerVersion(loader);
3561
3596
  options = mergeOptions(loader.options, options);
@@ -3565,15 +3600,22 @@ async function parseWithLoader(loader, data, options, context) {
3565
3600
  context.response = { headers, ok, redirected, status, statusText, type, url };
3566
3601
  }
3567
3602
  const loaderWithParser = await getLoaderImplementation(loader, options, context.url);
3568
- if (shouldParseWithWorker(loaderWithParser, data, options, context, loader)) {
3569
- data = await getArrayBufferFromData(data, options);
3570
- return await parseWithWorker(loaderWithParser, data, options, context, parse);
3571
- }
3572
- if (isBlob(data) && loaderWithParser.parseBlob) {
3573
- return await loaderWithParser.parseBlob(data, options, context);
3603
+ if (loaderWithParser.createDataSourceSync && !isLoaderWithParser(loaderWithParser)) {
3604
+ throw new Error(`${loader.id} creates sources. Use createDataSource() to open a source.`);
3605
+ }
3606
+ const output = (_b = loaderWithParser.prepareParseOutput) == null ? void 0 : _b.call(loaderWithParser, options);
3607
+ const parseOptions = (output == null ? void 0 : output.options) ?? options;
3608
+ let result;
3609
+ if (shouldParseWithWorker(loaderWithParser, data, parseOptions, context, loader)) {
3610
+ data = await getArrayBufferFromData(data, parseOptions);
3611
+ result = await parseWithWorker(loaderWithParser, data, parseOptions, context, parse);
3612
+ } else if (isBlob(data) && loaderWithParser.parseBlob) {
3613
+ result = await loaderWithParser.parseBlob(data, parseOptions, context);
3614
+ } else {
3615
+ data = await getArrayBufferOrStringFromData(data, loader, parseOptions);
3616
+ result = await parseWithLoaderImplementation(loaderWithParser, data, parseOptions, context);
3574
3617
  }
3575
- data = await getArrayBufferOrStringFromData(data, loader, options);
3576
- return await parseWithLoaderImplementation(loaderWithParser, data, options, context);
3618
+ return output ? output.convert(result) : result;
3577
3619
  }
3578
3620
  async function parseWithLoaderImplementation(loader, data, options, context) {
3579
3621
  if (loader.parseText && typeof data === "string") {
@@ -3588,6 +3630,9 @@ async function parseWithLoaderImplementation(loader, data, options, context) {
3588
3630
  if (loader.parseSync) {
3589
3631
  throw new Error(`${loader.name} loader: 'parse' not available on parser-bearing sync loader. Add an async 'parse' function to this loader, or call preload(loader) before parseSync(). ${context.url || ""}`);
3590
3632
  }
3633
+ if (loader.createDataSourceSync) {
3634
+ throw new Error(`${loader.id} creates sources. Use createDataSource() to open a source.`);
3635
+ }
3591
3636
  throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
3592
3637
  }
3593
3638
 
@@ -3686,8 +3731,15 @@ function encodeTextSync(data, writer, options) {
3686
3731
  }
3687
3732
  function encodeInBatches(data, writer, options) {
3688
3733
  if (writer.encodeInBatches) {
3689
- const dataIterator = getIterator2(data);
3690
- return writer.encodeInBatches(dataIterator, options);
3734
+ let dataIterator;
3735
+ if (data && typeof data === "object") {
3736
+ if ("numRows" in data && "schema" in data) {
3737
+ dataIterator = [data];
3738
+ } else if (Symbol.iterator in data || Symbol.asyncIterator in data) {
3739
+ dataIterator = data;
3740
+ }
3741
+ }
3742
+ return writer.encodeInBatches(dataIterator ?? getIterator2(data), options);
3691
3743
  }
3692
3744
  throw new Error(`Writer ${writer.name} could not encode in batches`);
3693
3745
  }
@@ -3721,44 +3773,62 @@ function getTemporaryFilename(filename2) {
3721
3773
  }
3722
3774
 
3723
3775
  // dist/lib/api/create-data-source.js
3724
- function createDataSource(data, sources, options = {}) {
3725
- var _a, _b, _c, _d, _e;
3726
- const resolvedOptions = options || {};
3727
- const type = ((_a = resolvedOptions == null ? void 0 : resolvedOptions.core) == null ? void 0 : _a.type) || resolvedOptions.type || "auto";
3728
- const source = sources.length === 1 ? sources[0] : type === "auto" ? selectLoaderSync(data, sources, {
3729
- // `createDataSource` supports non-fetch inputs such as in-memory tables.
3730
- // Selection remains best-effort for those cases.
3731
- ...resolvedOptions,
3732
- core: { ...resolvedOptions == null ? void 0 : resolvedOptions.core, type: "auto" }
3733
- }) : getSourceOfType(type, sources);
3734
- if (!source) {
3735
- throw new Error("Not a valid source type");
3736
- }
3737
- const contributions = ((_c = (_b = resolvedOptions.core) == null ? void 0 : _b.credentials) == null ? void 0 : _c.length) ? (_d = source.getAuthentications) == null ? void 0 : _d.call(source, typeof data === "string" ? data : "", resolvedOptions) : void 0;
3776
+ async function createDataSource(data, loaders, options = {}) {
3777
+ var _a, _b, _c;
3778
+ (_a = options.signal) == null ? void 0 : _a.throwIfAborted();
3779
+ const candidates = getCandidates(loaders, options);
3780
+ const loader = candidates.length === 1 ? candidates[0] : await selectLoader(data, candidates, getSelectionOptions(options), void 0, "source");
3781
+ if (!loader) {
3782
+ throw new Error("No explicit source loader matches the input");
3783
+ }
3784
+ const url = typeof data === "string" ? data : "";
3785
+ const implementation = await preload(loader, options, url);
3786
+ (_b = options.signal) == null ? void 0 : _b.throwIfAborted();
3787
+ const authenticatedOptions = await resolveLoaderAuthenticationOptions(loader.getAuthentications ? loader : implementation, url, options);
3788
+ (_c = options.signal) == null ? void 0 : _c.throwIfAborted();
3789
+ return constructSource(implementation, data, authenticatedOptions);
3790
+ }
3791
+ function createDataSourceSync(data, loaders, options = {}) {
3792
+ var _a, _b, _c, _d;
3793
+ const candidates = getCandidates(loaders, options);
3794
+ const loader = candidates.length === 1 ? candidates[0] : selectLoaderSync(data, candidates, getSelectionOptions(options), void 0, "source");
3795
+ if (!loader) {
3796
+ throw new Error("No explicit source loader matches the input");
3797
+ }
3798
+ const implementation = getLoaderImplementationSync(loader, options);
3799
+ if (!implementation) {
3800
+ throw new Error(`${loader.id} has no synchronous source factory available. Call preload() first.`);
3801
+ }
3802
+ const authenticationLoader = loader.getAuthentications ? loader : implementation;
3803
+ const contributions = ((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length) ? (_c = authenticationLoader.getAuthentications) == null ? void 0 : _c.call(authenticationLoader, typeof data === "string" ? data : "", options) : void 0;
3738
3804
  if (contributions && "then" in contributions) {
3739
3805
  void contributions.catch(() => {
3740
3806
  });
3741
- throw new Error("Use load() with an asynchronous getAuthentications() hook.");
3807
+ throw new Error("Use createDataSource() with an asynchronous getAuthentications() hook.");
3742
3808
  }
3743
3809
  const authenticatedOptions = resolveAuthenticationOptions((contributions == null ? void 0 : contributions.length) ? {
3744
- ...resolvedOptions,
3810
+ ...options,
3745
3811
  core: {
3746
- ...resolvedOptions.core,
3747
- authentications: [
3748
- ...((_e = resolvedOptions.core) == null ? void 0 : _e.authentications) || [],
3749
- ...contributions || []
3750
- ]
3812
+ ...options.core,
3813
+ authentications: [...((_d = options.core) == null ? void 0 : _d.authentications) || [], ...contributions]
3751
3814
  }
3752
- } : resolvedOptions);
3753
- return source.createDataSource(data, authenticatedOptions, coreApi);
3815
+ } : options);
3816
+ return constructSource(implementation, data, authenticatedOptions);
3754
3817
  }
3755
- function getSourceOfType(type, sources) {
3756
- for (const service of sources) {
3757
- if (service.type === type) {
3758
- return service;
3759
- }
3818
+ function getCandidates(loaders, options) {
3819
+ var _a;
3820
+ const candidates = Array.isArray(loaders) ? [...loaders] : [loaders];
3821
+ const type = ((_a = options.core) == null ? void 0 : _a.type) || options.type;
3822
+ return candidates.length > 1 && type && type !== "auto" ? candidates.filter((loader) => isSourceLoader(loader) && loader.type === type) : candidates;
3823
+ }
3824
+ function getSelectionOptions(options) {
3825
+ return { ...options, core: { ...options.core, ignoreRegisteredLoaders: true, nothrow: true } };
3826
+ }
3827
+ function constructSource(loader, data, options) {
3828
+ if (loader.createDataSourceSync) {
3829
+ return loader.createDataSourceSync(data, options, coreApi);
3760
3830
  }
3761
- return null;
3831
+ throw new Error(`${loader.id} has no synchronous source factory. Use createDataSource() to preload the loader.`);
3762
3832
  }
3763
3833
 
3764
3834
  // dist/lib/api/select-source.js
@@ -3766,16 +3836,16 @@ function selectSource(url, sources, options) {
3766
3836
  const type = (options == null ? void 0 : options.type) || "auto";
3767
3837
  let selectedSource = null;
3768
3838
  if (type === "auto") {
3769
- selectedSource = selectLoaderSync(url, sources, { core: { nothrow: true } });
3839
+ selectedSource = selectLoaderSync(url, sources, { core: { nothrow: true } }, void 0, "source");
3770
3840
  } else {
3771
- selectedSource = getSourceOfType2(type, sources);
3841
+ selectedSource = getSourceOfType(type, sources);
3772
3842
  }
3773
3843
  if (!selectedSource && !(options == null ? void 0 : options.nothrow)) {
3774
3844
  throw new Error("Not a valid image source type");
3775
3845
  }
3776
3846
  return selectedSource;
3777
3847
  }
3778
- function getSourceOfType2(type, sources) {
3848
+ function getSourceOfType(type, sources) {
3779
3849
  for (const service of sources) {
3780
3850
  if (service.type === type) {
3781
3851
  return service;
@@ -3824,14 +3894,14 @@ function makeStream(source, options) {
3824
3894
  }
3825
3895
 
3826
3896
  // dist/null-loader.js
3827
- var VERSION4 = true ? "5.0.0-beta.6" : "latest";
3897
+ var VERSION5 = true ? "5.0.0-beta.8" : "latest";
3828
3898
  var NullWorkerLoader = {
3829
3899
  dataType: null,
3830
3900
  batchType: null,
3831
3901
  name: "Null loader",
3832
3902
  id: "null",
3833
3903
  module: "core",
3834
- version: VERSION4,
3904
+ version: VERSION5,
3835
3905
  worker: true,
3836
3906
  mimeTypes: ["application/x.empty"],
3837
3907
  extensions: ["null"],
@@ -3846,7 +3916,7 @@ var NullLoader = {
3846
3916
  name: "Null loader",
3847
3917
  id: "null",
3848
3918
  module: "core",
3849
- version: VERSION4,
3919
+ version: VERSION5,
3850
3920
  mimeTypes: ["application/x.empty"],
3851
3921
  extensions: ["null"],
3852
3922
  parse: async (arrayBuffer, options, context) => parseSync2(arrayBuffer, options || {}, context),