@loaders.gl/core 4.0.0-beta.2 → 4.0.0-beta.3

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 (401) hide show
  1. package/dist/core-addons/write-file-browser.d.ts.map +1 -0
  2. package/dist/core-addons/write-file-browser.js.map +1 -0
  3. package/dist/{dist.min.js → dist.dev.js} +1674 -1930
  4. package/dist/index.cjs +1576 -0
  5. package/dist/{src/index.d.ts → index.d.ts} +2 -5
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +28 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/iterators/batch-iterators/timed-batch-iterator.d.ts.map +1 -0
  10. package/dist/iterators/batch-iterators/timed-batch-iterator.js.map +1 -0
  11. package/dist/iterators/make-iterator/make-array-buffer-iterator.d.ts.map +1 -0
  12. package/dist/iterators/make-iterator/make-array-buffer-iterator.js.map +1 -0
  13. package/dist/iterators/make-iterator/make-blob-iterator.d.ts.map +1 -0
  14. package/dist/iterators/make-iterator/make-blob-iterator.js.map +1 -0
  15. package/dist/iterators/make-iterator/make-iterator.d.ts.map +1 -0
  16. package/dist/{esm/iterators → iterators}/make-iterator/make-iterator.js +5 -5
  17. package/dist/iterators/make-iterator/make-iterator.js.map +1 -0
  18. package/dist/iterators/make-iterator/make-stream-iterator.d.ts.map +1 -0
  19. package/dist/iterators/make-iterator/make-stream-iterator.js.map +1 -0
  20. package/dist/iterators/make-iterator/make-string-iterator.d.ts.map +1 -0
  21. package/dist/iterators/make-iterator/make-string-iterator.js.map +1 -0
  22. package/dist/{src/iterators/make-stream/make-dom-stream.d.ts → iterators/make-stream/make-stream.d.ts} +1 -1
  23. package/dist/iterators/make-stream/make-stream.d.ts.map +1 -0
  24. package/dist/{esm/iterators/make-stream/make-dom-stream.js → iterators/make-stream/make-stream.js} +4 -1
  25. package/dist/iterators/make-stream/make-stream.js.map +1 -0
  26. package/dist/javascript-utils/is-type.d.ts.map +1 -0
  27. package/dist/javascript-utils/is-type.js.map +1 -0
  28. package/dist/lib/api/encode-table.d.ts.map +1 -0
  29. package/dist/{esm/lib → lib}/api/encode-table.js +1 -1
  30. package/dist/lib/api/encode-table.js.map +1 -0
  31. package/dist/lib/api/encode.d.ts.map +1 -0
  32. package/dist/{esm/lib → lib}/api/encode.js +8 -8
  33. package/dist/lib/api/encode.js.map +1 -0
  34. package/dist/lib/api/load-in-batches.d.ts.map +1 -0
  35. package/dist/{esm/lib → lib}/api/load-in-batches.js +3 -3
  36. package/dist/lib/api/load-in-batches.js.map +1 -0
  37. package/dist/lib/api/load.d.ts.map +1 -0
  38. package/dist/{esm/lib → lib}/api/load.js +4 -4
  39. package/dist/{es5/lib → lib}/api/load.js.map +1 -1
  40. package/dist/lib/api/loader-options.d.ts.map +1 -0
  41. package/dist/lib/api/loader-options.js +3 -0
  42. package/dist/lib/api/loader-options.js.map +1 -0
  43. package/dist/lib/api/parse-in-batches.d.ts.map +1 -0
  44. package/dist/{esm/lib → lib}/api/parse-in-batches.js +7 -7
  45. package/dist/lib/api/parse-in-batches.js.map +1 -0
  46. package/dist/lib/api/parse-sync.d.ts.map +1 -0
  47. package/dist/{esm/lib → lib}/api/parse-sync.js +7 -7
  48. package/dist/lib/api/parse-sync.js.map +1 -0
  49. package/dist/lib/api/parse.d.ts.map +1 -0
  50. package/dist/{esm/lib → lib}/api/parse.js +8 -8
  51. package/dist/lib/api/parse.js.map +1 -0
  52. package/dist/lib/api/register-loaders.d.ts.map +1 -0
  53. package/dist/{esm/lib → lib}/api/register-loaders.js +2 -2
  54. package/dist/lib/api/register-loaders.js.map +1 -0
  55. package/dist/lib/api/select-loader.d.ts.map +1 -0
  56. package/dist/{esm/lib → lib}/api/select-loader.js +16 -16
  57. package/dist/lib/api/select-loader.js.map +1 -0
  58. package/dist/lib/common.d.ts.map +1 -0
  59. package/dist/lib/common.js.map +1 -0
  60. package/dist/lib/fetch/fetch-error-message.d.ts.map +1 -0
  61. package/dist/{esm/lib → lib}/fetch/fetch-error-message.js +2 -2
  62. package/dist/lib/fetch/fetch-error-message.js.map +1 -0
  63. package/dist/lib/fetch/fetch-file.d.ts.map +1 -0
  64. package/dist/{esm/lib → lib}/fetch/fetch-file.js +7 -4
  65. package/dist/lib/fetch/fetch-file.js.map +1 -0
  66. package/dist/{src/lib → lib}/fetch/read-array-buffer.d.ts +1 -1
  67. package/dist/lib/fetch/read-array-buffer.d.ts.map +1 -0
  68. package/dist/{esm/lib → lib}/fetch/read-array-buffer.js +0 -4
  69. package/dist/lib/fetch/read-array-buffer.js.map +1 -0
  70. package/dist/{src/lib → lib}/filesystems/browser-filesystem.d.ts +2 -15
  71. package/dist/lib/filesystems/browser-filesystem.d.ts.map +1 -0
  72. package/dist/{esm/lib → lib}/filesystems/browser-filesystem.js +7 -20
  73. package/dist/lib/filesystems/browser-filesystem.js.map +1 -0
  74. package/dist/lib/filesystems/read-array-buffer.d.ts.map +1 -0
  75. package/dist/lib/filesystems/read-array-buffer.js.map +1 -0
  76. package/dist/{src/lib → lib}/init.d.ts.map +1 -1
  77. package/dist/lib/init.js +11 -0
  78. package/dist/lib/init.js.map +1 -0
  79. package/dist/lib/loader-utils/check-errors.d.ts.map +1 -0
  80. package/dist/{esm/lib → lib}/loader-utils/check-errors.js +4 -4
  81. package/dist/lib/loader-utils/check-errors.js.map +1 -0
  82. package/dist/lib/loader-utils/get-data.d.ts.map +1 -0
  83. package/dist/{esm/lib → lib}/loader-utils/get-data.js +3 -3
  84. package/dist/lib/loader-utils/get-data.js.map +1 -0
  85. package/dist/lib/loader-utils/get-fetch-function.d.ts.map +1 -0
  86. package/dist/{esm/lib → lib}/loader-utils/get-fetch-function.js +3 -3
  87. package/dist/lib/loader-utils/get-fetch-function.js.map +1 -0
  88. package/dist/lib/loader-utils/loader-context.d.ts.map +1 -0
  89. package/dist/{esm/lib → lib}/loader-utils/loader-context.js +2 -2
  90. package/dist/lib/loader-utils/loader-context.js.map +1 -0
  91. package/dist/lib/loader-utils/loggers.d.ts.map +1 -0
  92. package/dist/{esm/lib → lib}/loader-utils/loggers.js +1 -2
  93. package/dist/lib/loader-utils/loggers.js.map +1 -0
  94. package/dist/lib/loader-utils/normalize-loader.d.ts.map +1 -0
  95. package/dist/lib/loader-utils/normalize-loader.js.map +1 -0
  96. package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -0
  97. package/dist/{esm/lib → lib}/loader-utils/option-defaults.js +1 -1
  98. package/dist/lib/loader-utils/option-defaults.js.map +1 -0
  99. package/dist/lib/loader-utils/option-utils.d.ts.map +1 -0
  100. package/dist/{esm/lib → lib}/loader-utils/option-utils.js +8 -8
  101. package/dist/lib/loader-utils/option-utils.js.map +1 -0
  102. package/dist/lib/progress/fetch-progress.d.ts.map +1 -0
  103. package/dist/lib/progress/fetch-progress.js.map +1 -0
  104. package/dist/lib/utils/log.d.ts.map +1 -0
  105. package/dist/lib/utils/log.js.map +1 -0
  106. package/dist/lib/utils/mime-type-utils.d.ts.map +1 -0
  107. package/dist/lib/utils/mime-type-utils.js.map +1 -0
  108. package/dist/lib/utils/resource-utils.d.ts.map +1 -0
  109. package/dist/{esm/lib → lib}/utils/resource-utils.js +3 -3
  110. package/dist/lib/utils/resource-utils.js.map +1 -0
  111. package/dist/lib/utils/response-utils.d.ts.map +1 -0
  112. package/dist/{esm/lib → lib}/utils/response-utils.js +9 -9
  113. package/dist/lib/utils/response-utils.js.map +1 -0
  114. package/dist/lib/utils/url-utils.d.ts.map +1 -0
  115. package/dist/lib/utils/url-utils.js.map +1 -0
  116. package/dist/null-loader.d.ts.map +1 -0
  117. package/dist/{esm/null-loader.js → null-loader.js} +1 -1
  118. package/dist/null-loader.js.map +1 -0
  119. package/dist/null-worker-node.js +21 -27
  120. package/dist/null-worker.js +14 -3
  121. package/dist/workers/null-worker.d.ts.map +1 -0
  122. package/dist/{esm/workers → workers}/null-worker.js +1 -1
  123. package/dist/workers/null-worker.js.map +1 -0
  124. package/package.json +17 -15
  125. package/src/index.ts +7 -5
  126. package/src/iterators/make-stream/{make-dom-stream.ts → make-stream.ts} +4 -0
  127. package/src/lib/api/encode.ts +3 -3
  128. package/src/lib/fetch/fetch-file.ts +7 -3
  129. package/src/lib/fetch/read-array-buffer.ts +2 -6
  130. package/src/lib/filesystems/browser-filesystem.ts +19 -18
  131. package/dist/es5/bundle.js +0 -6
  132. package/dist/es5/bundle.js.map +0 -1
  133. package/dist/es5/core-addons/write-file-browser.js +0 -2
  134. package/dist/es5/core-addons/write-file-browser.js.map +0 -1
  135. package/dist/es5/index.js +0 -382
  136. package/dist/es5/index.js.map +0 -1
  137. package/dist/es5/iterators/batch-iterators/timed-batch-iterator.js +0 -94
  138. package/dist/es5/iterators/batch-iterators/timed-batch-iterator.js.map +0 -1
  139. package/dist/es5/iterators/make-iterator/make-array-buffer-iterator.js +0 -42
  140. package/dist/es5/iterators/make-iterator/make-array-buffer-iterator.js.map +0 -1
  141. package/dist/es5/iterators/make-iterator/make-blob-iterator.js +0 -47
  142. package/dist/es5/iterators/make-iterator/make-blob-iterator.js.map +0 -1
  143. package/dist/es5/iterators/make-iterator/make-iterator.js +0 -31
  144. package/dist/es5/iterators/make-iterator/make-iterator.js.map +0 -1
  145. package/dist/es5/iterators/make-iterator/make-stream-iterator.js +0 -133
  146. package/dist/es5/iterators/make-iterator/make-stream-iterator.js.map +0 -1
  147. package/dist/es5/iterators/make-iterator/make-string-iterator.js +0 -38
  148. package/dist/es5/iterators/make-iterator/make-string-iterator.js.map +0 -1
  149. package/dist/es5/iterators/make-stream/make-dom-stream.js +0 -67
  150. package/dist/es5/iterators/make-stream/make-dom-stream.js.map +0 -1
  151. package/dist/es5/iterators/make-stream/make-node-stream.js +0 -168
  152. package/dist/es5/iterators/make-stream/make-node-stream.js.map +0 -1
  153. package/dist/es5/javascript-utils/is-type.js +0 -79
  154. package/dist/es5/javascript-utils/is-type.js.map +0 -1
  155. package/dist/es5/lib/api/encode-table.js +0 -161
  156. package/dist/es5/lib/api/encode-table.js.map +0 -1
  157. package/dist/es5/lib/api/encode.js +0 -254
  158. package/dist/es5/lib/api/encode.js.map +0 -1
  159. package/dist/es5/lib/api/load-in-batches.js +0 -92
  160. package/dist/es5/lib/api/load-in-batches.js.map +0 -1
  161. package/dist/es5/lib/api/load.js +0 -76
  162. package/dist/es5/lib/api/loader-options.js +0 -19
  163. package/dist/es5/lib/api/loader-options.js.map +0 -1
  164. package/dist/es5/lib/api/parse-in-batches.js +0 -276
  165. package/dist/es5/lib/api/parse-in-batches.js.map +0 -1
  166. package/dist/es5/lib/api/parse-sync.js +0 -49
  167. package/dist/es5/lib/api/parse-sync.js.map +0 -1
  168. package/dist/es5/lib/api/parse.js +0 -142
  169. package/dist/es5/lib/api/parse.js.map +0 -1
  170. package/dist/es5/lib/api/register-loaders.js +0 -50
  171. package/dist/es5/lib/api/register-loaders.js.map +0 -1
  172. package/dist/es5/lib/api/save.js +0 -42
  173. package/dist/es5/lib/api/save.js.map +0 -1
  174. package/dist/es5/lib/api/select-loader.js +0 -304
  175. package/dist/es5/lib/api/select-loader.js.map +0 -1
  176. package/dist/es5/lib/common.js +0 -2
  177. package/dist/es5/lib/common.js.map +0 -1
  178. package/dist/es5/lib/fetch/fetch-error-message.js +0 -56
  179. package/dist/es5/lib/fetch/fetch-error-message.js.map +0 -1
  180. package/dist/es5/lib/fetch/fetch-file.js +0 -65
  181. package/dist/es5/lib/fetch/fetch-file.js.map +0 -1
  182. package/dist/es5/lib/fetch/fetch-file.node.js +0 -86
  183. package/dist/es5/lib/fetch/fetch-file.node.js.map +0 -1
  184. package/dist/es5/lib/fetch/read-array-buffer.js +0 -76
  185. package/dist/es5/lib/fetch/read-array-buffer.js.map +0 -1
  186. package/dist/es5/lib/fetch/read-file.js +0 -20
  187. package/dist/es5/lib/fetch/read-file.js.map +0 -1
  188. package/dist/es5/lib/fetch/write-file.js +0 -48
  189. package/dist/es5/lib/fetch/write-file.js.map +0 -1
  190. package/dist/es5/lib/filesystems/browser-filesystem.js +0 -249
  191. package/dist/es5/lib/filesystems/browser-filesystem.js.map +0 -1
  192. package/dist/es5/lib/filesystems/read-array-buffer.js +0 -41
  193. package/dist/es5/lib/filesystems/read-array-buffer.js.map +0 -1
  194. package/dist/es5/lib/init.js +0 -18
  195. package/dist/es5/lib/init.js.map +0 -1
  196. package/dist/es5/lib/loader-utils/check-errors.js +0 -57
  197. package/dist/es5/lib/loader-utils/check-errors.js.map +0 -1
  198. package/dist/es5/lib/loader-utils/get-data.js +0 -237
  199. package/dist/es5/lib/loader-utils/get-data.js.map +0 -1
  200. package/dist/es5/lib/loader-utils/get-fetch-function.js +0 -26
  201. package/dist/es5/lib/loader-utils/get-fetch-function.js.map +0 -1
  202. package/dist/es5/lib/loader-utils/loader-context.js +0 -49
  203. package/dist/es5/lib/loader-utils/loader-context.js.map +0 -1
  204. package/dist/es5/lib/loader-utils/loggers.js +0 -90
  205. package/dist/es5/lib/loader-utils/loggers.js.map +0 -1
  206. package/dist/es5/lib/loader-utils/normalize-loader.js +0 -44
  207. package/dist/es5/lib/loader-utils/normalize-loader.js.map +0 -1
  208. package/dist/es5/lib/loader-utils/option-defaults.js +0 -48
  209. package/dist/es5/lib/loader-utils/option-defaults.js.map +0 -1
  210. package/dist/es5/lib/loader-utils/option-utils.js +0 -131
  211. package/dist/es5/lib/loader-utils/option-utils.js.map +0 -1
  212. package/dist/es5/lib/progress/fetch-progress.js +0 -134
  213. package/dist/es5/lib/progress/fetch-progress.js.map +0 -1
  214. package/dist/es5/lib/utils/log.js +0 -12
  215. package/dist/es5/lib/utils/log.js.map +0 -1
  216. package/dist/es5/lib/utils/mime-type-utils.js +0 -24
  217. package/dist/es5/lib/utils/mime-type-utils.js.map +0 -1
  218. package/dist/es5/lib/utils/resource-utils.js +0 -62
  219. package/dist/es5/lib/utils/resource-utils.js.map +0 -1
  220. package/dist/es5/lib/utils/response-utils.js +0 -197
  221. package/dist/es5/lib/utils/response-utils.js.map +0 -1
  222. package/dist/es5/lib/utils/url-utils.js +0 -16
  223. package/dist/es5/lib/utils/url-utils.js.map +0 -1
  224. package/dist/es5/null-loader.js +0 -131
  225. package/dist/es5/null-loader.js.map +0 -1
  226. package/dist/es5/workers/null-worker.js +0 -6
  227. package/dist/es5/workers/null-worker.js.map +0 -1
  228. package/dist/esm/bundle.js +0 -4
  229. package/dist/esm/bundle.js.map +0 -1
  230. package/dist/esm/core-addons/README.md +0 -1
  231. package/dist/esm/core-addons/write-file-browser.js.map +0 -1
  232. package/dist/esm/index.js +0 -31
  233. package/dist/esm/index.js.map +0 -1
  234. package/dist/esm/iterators/batch-iterators/timed-batch-iterator.js.map +0 -1
  235. package/dist/esm/iterators/make-iterator/make-array-buffer-iterator.js.map +0 -1
  236. package/dist/esm/iterators/make-iterator/make-blob-iterator.js.map +0 -1
  237. package/dist/esm/iterators/make-iterator/make-iterator.js.map +0 -1
  238. package/dist/esm/iterators/make-iterator/make-stream-iterator.js.map +0 -1
  239. package/dist/esm/iterators/make-iterator/make-string-iterator.js.map +0 -1
  240. package/dist/esm/iterators/make-stream/make-dom-stream.js.map +0 -1
  241. package/dist/esm/iterators/make-stream/make-node-stream.js +0 -57
  242. package/dist/esm/iterators/make-stream/make-node-stream.js.map +0 -1
  243. package/dist/esm/javascript-utils/is-type.js.map +0 -1
  244. package/dist/esm/lib/api/encode-table.js.map +0 -1
  245. package/dist/esm/lib/api/encode.js.map +0 -1
  246. package/dist/esm/lib/api/load-in-batches.js.map +0 -1
  247. package/dist/esm/lib/api/load.js.map +0 -1
  248. package/dist/esm/lib/api/loader-options.js +0 -3
  249. package/dist/esm/lib/api/loader-options.js.map +0 -1
  250. package/dist/esm/lib/api/parse-in-batches.js.map +0 -1
  251. package/dist/esm/lib/api/parse-sync.js.map +0 -1
  252. package/dist/esm/lib/api/parse.js.map +0 -1
  253. package/dist/esm/lib/api/register-loaders.js.map +0 -1
  254. package/dist/esm/lib/api/save.js +0 -11
  255. package/dist/esm/lib/api/save.js.map +0 -1
  256. package/dist/esm/lib/api/select-loader.js.map +0 -1
  257. package/dist/esm/lib/common.js.map +0 -1
  258. package/dist/esm/lib/fetch/fetch-error-message.js.map +0 -1
  259. package/dist/esm/lib/fetch/fetch-file.js.map +0 -1
  260. package/dist/esm/lib/fetch/fetch-file.node.js +0 -54
  261. package/dist/esm/lib/fetch/fetch-file.node.js.map +0 -1
  262. package/dist/esm/lib/fetch/read-array-buffer.js.map +0 -1
  263. package/dist/esm/lib/fetch/read-file.js +0 -15
  264. package/dist/esm/lib/fetch/read-file.js.map +0 -1
  265. package/dist/esm/lib/fetch/write-file.js +0 -21
  266. package/dist/esm/lib/fetch/write-file.js.map +0 -1
  267. package/dist/esm/lib/filesystems/browser-filesystem.js.map +0 -1
  268. package/dist/esm/lib/filesystems/read-array-buffer.js.map +0 -1
  269. package/dist/esm/lib/init.js +0 -11
  270. package/dist/esm/lib/init.js.map +0 -1
  271. package/dist/esm/lib/loader-utils/check-errors.js.map +0 -1
  272. package/dist/esm/lib/loader-utils/get-data.js.map +0 -1
  273. package/dist/esm/lib/loader-utils/get-fetch-function.js.map +0 -1
  274. package/dist/esm/lib/loader-utils/loader-context.js.map +0 -1
  275. package/dist/esm/lib/loader-utils/loggers.js.map +0 -1
  276. package/dist/esm/lib/loader-utils/normalize-loader.js.map +0 -1
  277. package/dist/esm/lib/loader-utils/option-defaults.js.map +0 -1
  278. package/dist/esm/lib/loader-utils/option-utils.js.map +0 -1
  279. package/dist/esm/lib/progress/fetch-progress.js.map +0 -1
  280. package/dist/esm/lib/utils/log.js.map +0 -1
  281. package/dist/esm/lib/utils/mime-type-utils.js.map +0 -1
  282. package/dist/esm/lib/utils/resource-utils.js.map +0 -1
  283. package/dist/esm/lib/utils/response-utils.js.map +0 -1
  284. package/dist/esm/lib/utils/url-utils.js.map +0 -1
  285. package/dist/esm/null-loader.js.map +0 -1
  286. package/dist/esm/workers/null-worker.js.map +0 -1
  287. package/dist/src/bundle.d.ts +0 -2
  288. package/dist/src/bundle.d.ts.map +0 -1
  289. package/dist/src/core-addons/write-file-browser.d.ts.map +0 -1
  290. package/dist/src/index.d.ts.map +0 -1
  291. package/dist/src/iterators/batch-iterators/timed-batch-iterator.d.ts.map +0 -1
  292. package/dist/src/iterators/make-iterator/make-array-buffer-iterator.d.ts.map +0 -1
  293. package/dist/src/iterators/make-iterator/make-blob-iterator.d.ts.map +0 -1
  294. package/dist/src/iterators/make-iterator/make-iterator.d.ts.map +0 -1
  295. package/dist/src/iterators/make-iterator/make-stream-iterator.d.ts.map +0 -1
  296. package/dist/src/iterators/make-iterator/make-string-iterator.d.ts.map +0 -1
  297. package/dist/src/iterators/make-stream/make-dom-stream.d.ts.map +0 -1
  298. package/dist/src/iterators/make-stream/make-node-stream.d.ts +0 -11
  299. package/dist/src/iterators/make-stream/make-node-stream.d.ts.map +0 -1
  300. package/dist/src/javascript-utils/is-type.d.ts.map +0 -1
  301. package/dist/src/lib/api/encode-table.d.ts.map +0 -1
  302. package/dist/src/lib/api/encode.d.ts.map +0 -1
  303. package/dist/src/lib/api/load-in-batches.d.ts.map +0 -1
  304. package/dist/src/lib/api/load.d.ts.map +0 -1
  305. package/dist/src/lib/api/loader-options.d.ts.map +0 -1
  306. package/dist/src/lib/api/parse-in-batches.d.ts.map +0 -1
  307. package/dist/src/lib/api/parse-sync.d.ts.map +0 -1
  308. package/dist/src/lib/api/parse.d.ts.map +0 -1
  309. package/dist/src/lib/api/register-loaders.d.ts.map +0 -1
  310. package/dist/src/lib/api/save.d.ts +0 -4
  311. package/dist/src/lib/api/save.d.ts.map +0 -1
  312. package/dist/src/lib/api/select-loader.d.ts.map +0 -1
  313. package/dist/src/lib/common.d.ts.map +0 -1
  314. package/dist/src/lib/fetch/fetch-error-message.d.ts.map +0 -1
  315. package/dist/src/lib/fetch/fetch-file.d.ts.map +0 -1
  316. package/dist/src/lib/fetch/fetch-file.node.d.ts +0 -8
  317. package/dist/src/lib/fetch/fetch-file.node.d.ts.map +0 -1
  318. package/dist/src/lib/fetch/read-array-buffer.d.ts.map +0 -1
  319. package/dist/src/lib/fetch/read-file.d.ts +0 -5
  320. package/dist/src/lib/fetch/read-file.d.ts.map +0 -1
  321. package/dist/src/lib/fetch/write-file.d.ts +0 -3
  322. package/dist/src/lib/fetch/write-file.d.ts.map +0 -1
  323. package/dist/src/lib/filesystems/browser-filesystem.d.ts.map +0 -1
  324. package/dist/src/lib/filesystems/read-array-buffer.d.ts.map +0 -1
  325. package/dist/src/lib/loader-utils/check-errors.d.ts.map +0 -1
  326. package/dist/src/lib/loader-utils/get-data.d.ts.map +0 -1
  327. package/dist/src/lib/loader-utils/get-fetch-function.d.ts.map +0 -1
  328. package/dist/src/lib/loader-utils/loader-context.d.ts.map +0 -1
  329. package/dist/src/lib/loader-utils/loggers.d.ts.map +0 -1
  330. package/dist/src/lib/loader-utils/normalize-loader.d.ts.map +0 -1
  331. package/dist/src/lib/loader-utils/option-defaults.d.ts.map +0 -1
  332. package/dist/src/lib/loader-utils/option-utils.d.ts.map +0 -1
  333. package/dist/src/lib/progress/fetch-progress.d.ts.map +0 -1
  334. package/dist/src/lib/utils/log.d.ts.map +0 -1
  335. package/dist/src/lib/utils/mime-type-utils.d.ts.map +0 -1
  336. package/dist/src/lib/utils/resource-utils.d.ts.map +0 -1
  337. package/dist/src/lib/utils/response-utils.d.ts.map +0 -1
  338. package/dist/src/lib/utils/url-utils.d.ts.map +0 -1
  339. package/dist/src/null-loader.d.ts.map +0 -1
  340. package/dist/src/workers/null-worker.d.ts.map +0 -1
  341. package/dist/tsconfig.tsbuildinfo +0 -1
  342. package/src/bundle.ts +0 -4
  343. package/src/iterators/make-stream/make-node-stream.ts +0 -74
  344. package/src/lib/api/save.ts +0 -13
  345. package/src/lib/fetch/fetch-file.node.ts +0 -61
  346. package/src/lib/fetch/read-file.ts +0 -31
  347. package/src/lib/fetch/write-file.ts +0 -27
  348. /package/dist/{es5/core-addons → core-addons}/README.md +0 -0
  349. /package/dist/{src/core-addons → core-addons}/write-file-browser.d.ts +0 -0
  350. /package/dist/{esm/core-addons → core-addons}/write-file-browser.js +0 -0
  351. /package/dist/{src/iterators → iterators}/batch-iterators/timed-batch-iterator.d.ts +0 -0
  352. /package/dist/{esm/iterators → iterators}/batch-iterators/timed-batch-iterator.js +0 -0
  353. /package/dist/{src/iterators → iterators}/make-iterator/make-array-buffer-iterator.d.ts +0 -0
  354. /package/dist/{esm/iterators → iterators}/make-iterator/make-array-buffer-iterator.js +0 -0
  355. /package/dist/{src/iterators → iterators}/make-iterator/make-blob-iterator.d.ts +0 -0
  356. /package/dist/{esm/iterators → iterators}/make-iterator/make-blob-iterator.js +0 -0
  357. /package/dist/{src/iterators → iterators}/make-iterator/make-iterator.d.ts +0 -0
  358. /package/dist/{src/iterators → iterators}/make-iterator/make-stream-iterator.d.ts +0 -0
  359. /package/dist/{esm/iterators → iterators}/make-iterator/make-stream-iterator.js +0 -0
  360. /package/dist/{src/iterators → iterators}/make-iterator/make-string-iterator.d.ts +0 -0
  361. /package/dist/{esm/iterators → iterators}/make-iterator/make-string-iterator.js +0 -0
  362. /package/dist/{src/javascript-utils → javascript-utils}/is-type.d.ts +0 -0
  363. /package/dist/{esm/javascript-utils → javascript-utils}/is-type.js +0 -0
  364. /package/dist/{src/lib → lib}/api/encode-table.d.ts +0 -0
  365. /package/dist/{src/lib → lib}/api/encode.d.ts +0 -0
  366. /package/dist/{src/lib → lib}/api/load-in-batches.d.ts +0 -0
  367. /package/dist/{src/lib → lib}/api/load.d.ts +0 -0
  368. /package/dist/{src/lib → lib}/api/loader-options.d.ts +0 -0
  369. /package/dist/{src/lib → lib}/api/parse-in-batches.d.ts +0 -0
  370. /package/dist/{src/lib → lib}/api/parse-sync.d.ts +0 -0
  371. /package/dist/{src/lib → lib}/api/parse.d.ts +0 -0
  372. /package/dist/{src/lib → lib}/api/register-loaders.d.ts +0 -0
  373. /package/dist/{src/lib → lib}/api/select-loader.d.ts +0 -0
  374. /package/dist/{src/lib → lib}/common.d.ts +0 -0
  375. /package/dist/{esm/lib → lib}/common.js +0 -0
  376. /package/dist/{src/lib → lib}/fetch/fetch-error-message.d.ts +0 -0
  377. /package/dist/{src/lib → lib}/fetch/fetch-file.d.ts +0 -0
  378. /package/dist/{src/lib → lib}/filesystems/read-array-buffer.d.ts +0 -0
  379. /package/dist/{esm/lib → lib}/filesystems/read-array-buffer.js +0 -0
  380. /package/dist/{src/lib → lib}/init.d.ts +0 -0
  381. /package/dist/{src/lib → lib}/loader-utils/check-errors.d.ts +0 -0
  382. /package/dist/{src/lib → lib}/loader-utils/get-data.d.ts +0 -0
  383. /package/dist/{src/lib → lib}/loader-utils/get-fetch-function.d.ts +0 -0
  384. /package/dist/{src/lib → lib}/loader-utils/loader-context.d.ts +0 -0
  385. /package/dist/{src/lib → lib}/loader-utils/loggers.d.ts +0 -0
  386. /package/dist/{src/lib → lib}/loader-utils/normalize-loader.d.ts +0 -0
  387. /package/dist/{esm/lib → lib}/loader-utils/normalize-loader.js +0 -0
  388. /package/dist/{src/lib → lib}/loader-utils/option-defaults.d.ts +0 -0
  389. /package/dist/{src/lib → lib}/loader-utils/option-utils.d.ts +0 -0
  390. /package/dist/{src/lib → lib}/progress/fetch-progress.d.ts +0 -0
  391. /package/dist/{esm/lib → lib}/progress/fetch-progress.js +0 -0
  392. /package/dist/{src/lib → lib}/utils/log.d.ts +0 -0
  393. /package/dist/{esm/lib → lib}/utils/log.js +0 -0
  394. /package/dist/{src/lib → lib}/utils/mime-type-utils.d.ts +0 -0
  395. /package/dist/{esm/lib → lib}/utils/mime-type-utils.js +0 -0
  396. /package/dist/{src/lib → lib}/utils/resource-utils.d.ts +0 -0
  397. /package/dist/{src/lib → lib}/utils/response-utils.d.ts +0 -0
  398. /package/dist/{src/lib → lib}/utils/url-utils.d.ts +0 -0
  399. /package/dist/{esm/lib → lib}/utils/url-utils.js +0 -0
  400. /package/dist/{src/null-loader.d.ts → null-loader.d.ts} +0 -0
  401. /package/dist/{src/workers → workers}/null-worker.d.ts +0 -0
@@ -1,33 +1,87 @@
1
- (() => {
2
- var __create = Object.create;
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if (typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if (typeof define === 'function' && define.amd) define([], factory);
5
+ else if (typeof exports === 'object') exports['loader'] = factory();
6
+ else root['loader'] = factory();})(globalThis, function () {
7
+ "use strict";
8
+ var __exports__ = (() => {
3
9
  var __defProp = Object.defineProperty;
4
10
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
11
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
9
- var __esm = (fn, res) => function __init() {
10
- return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
11
- };
12
- var __commonJS = (cb, mod) => function __require() {
13
- return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
- };
15
13
  var __export = (target, all) => {
16
- __markAsModule(target);
17
14
  for (var name in all)
18
15
  __defProp(target, name, { get: all[name], enumerable: true });
19
16
  };
20
- var __reExport = (target, module, desc) => {
21
- if (module && typeof module === "object" || typeof module === "function") {
22
- for (let key of __getOwnPropNames(module))
23
- if (!__hasOwnProp.call(target, key) && key !== "default")
24
- __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
22
  }
26
- return target;
27
- };
28
- var __toModule = (module) => {
29
- return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
23
+ return to;
30
24
  };
25
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+
27
+ // src/index.ts
28
+ var src_exports = {};
29
+ __export(src_exports, {
30
+ JSONLoader: () => JSONLoader,
31
+ NullLoader: () => NullLoader,
32
+ NullWorkerLoader: () => NullWorkerLoader,
33
+ RequestScheduler: () => RequestScheduler,
34
+ _BrowserFileSystem: () => BrowserFileSystem,
35
+ _fetchProgress: () => fetchProgress,
36
+ _unregisterLoaders: () => _unregisterLoaders,
37
+ assert: () => assert,
38
+ concatenateArrayBuffersAsync: () => concatenateArrayBuffersAsync,
39
+ document: () => document_,
40
+ encode: () => encode,
41
+ encodeInBatches: () => encodeInBatches,
42
+ encodeSync: () => encodeSync,
43
+ encodeTable: () => encodeTable,
44
+ encodeTableAsText: () => encodeTableAsText,
45
+ encodeTableInBatches: () => encodeTableInBatches,
46
+ encodeText: () => encodeText,
47
+ encodeTextSync: () => encodeTextSync,
48
+ encodeURLtoURL: () => encodeURLtoURL,
49
+ fetchFile: () => fetchFile,
50
+ forEach: () => forEach,
51
+ getLoaderOptions: () => getGlobalLoaderOptions,
52
+ getPathPrefix: () => getPathPrefix,
53
+ global: () => global_,
54
+ isAsyncIterable: () => isAsyncIterable,
55
+ isBrowser: () => isBrowser,
56
+ isIterable: () => isIterable,
57
+ isIterator: () => isIterator,
58
+ isPromise: () => isPromise,
59
+ isPureObject: () => isPureObject,
60
+ isReadableStream: () => isReadableStream,
61
+ isResponse: () => isResponse,
62
+ isWorker: () => isWorker,
63
+ isWritableStream: () => isWritableStream,
64
+ load: () => load,
65
+ loadInBatches: () => loadInBatches,
66
+ makeIterator: () => makeIterator,
67
+ makeLineIterator: () => makeLineIterator,
68
+ makeNumberedLineIterator: () => makeNumberedLineIterator,
69
+ makeStream: () => makeStream,
70
+ makeTextDecoderIterator: () => makeTextDecoderIterator,
71
+ makeTextEncoderIterator: () => makeTextEncoderIterator,
72
+ parse: () => parse,
73
+ parseInBatches: () => parseInBatches,
74
+ parseSync: () => parseSync,
75
+ readArrayBuffer: () => readArrayBuffer,
76
+ registerLoaders: () => registerLoaders,
77
+ resolvePath: () => resolvePath,
78
+ selectLoader: () => selectLoader,
79
+ selectLoaderSync: () => selectLoaderSync,
80
+ self: () => self_,
81
+ setLoaderOptions: () => setGlobalOptions,
82
+ setPathPrefix: () => setPathPrefix,
83
+ window: () => window_
84
+ });
31
85
 
32
86
  // ../loader-utils/src/lib/env-utils/assert.ts
33
87
  function assert(condition, message) {
@@ -35,38 +89,34 @@
35
89
  throw new Error(message || "loader assertion failed.");
36
90
  }
37
91
  }
38
- var init_assert = __esm({
39
- "../loader-utils/src/lib/env-utils/assert.ts"() {
40
- }
41
- });
42
92
 
43
93
  // ../loader-utils/src/lib/env-utils/globals.ts
44
- var globals, self_, window_, global_, document_, isBrowser, isWorker, matches, nodeVersion;
45
- var init_globals = __esm({
46
- "../loader-utils/src/lib/env-utils/globals.ts"() {
47
- globals = {
48
- self: typeof self !== "undefined" && self,
49
- window: typeof window !== "undefined" && window,
50
- global: typeof global !== "undefined" && global,
51
- document: typeof document !== "undefined" && document
52
- };
53
- self_ = globals.self || globals.window || globals.global || {};
54
- window_ = globals.window || globals.self || globals.global || {};
55
- global_ = globals.global || globals.self || globals.window || {};
56
- document_ = globals.document || {};
57
- isBrowser = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser);
58
- isWorker = typeof importScripts === "function";
59
- matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
60
- nodeVersion = matches && parseFloat(matches[1]) || 0;
61
- }
62
- });
94
+ var globals = {
95
+ self: typeof self !== "undefined" && self,
96
+ window: typeof window !== "undefined" && window,
97
+ global: typeof global !== "undefined" && global,
98
+ document: typeof document !== "undefined" && document
99
+ };
100
+ var self_ = globals.self || globals.window || globals.global || {};
101
+ var window_ = globals.window || globals.self || globals.global || {};
102
+ var global_ = globals.global || globals.self || globals.window || {};
103
+ var document_ = globals.document || {};
104
+ var isBrowser = (
105
+ // @ts-ignore process does not exist on browser
106
+ Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
107
+ );
108
+ var isWorker = typeof importScripts === "function";
109
+ var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
110
+ var nodeVersion = matches && parseFloat(matches[1]) || 0;
63
111
 
64
112
  // ../loader-utils/src/lib/option-utils/merge-loader-options.ts
65
113
  function mergeLoaderOptions(baseOptions, newOptions) {
66
114
  return mergeOptionsRecursively(baseOptions || {}, newOptions);
67
115
  }
68
116
  function mergeOptionsRecursively(baseOptions, newOptions) {
69
- const options = { ...baseOptions };
117
+ const options = {
118
+ ...baseOptions
119
+ };
70
120
  for (const [key, newValue] of Object.entries(newOptions)) {
71
121
  if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
72
122
  options[key] = mergeOptionsRecursively(options[key] || {}, newOptions[key]);
@@ -76,12 +126,9 @@
76
126
  }
77
127
  return options;
78
128
  }
79
- var init_merge_loader_options = __esm({
80
- "../loader-utils/src/lib/option-utils/merge-loader-options.ts"() {
81
- }
82
- });
83
129
 
84
130
  // ../worker-utils/src/lib/env-utils/version.ts
131
+ var NPM_TAG = "beta";
85
132
  function getVersion() {
86
133
  if (!globalThis._loadersgl_?.version) {
87
134
  globalThis._loadersgl_ = globalThis._loadersgl_ || {};
@@ -94,13 +141,7 @@
94
141
  }
95
142
  return globalThis._loadersgl_.version;
96
143
  }
97
- var NPM_TAG, VERSION;
98
- var init_version = __esm({
99
- "../worker-utils/src/lib/env-utils/version.ts"() {
100
- NPM_TAG = "beta";
101
- VERSION = getVersion();
102
- }
103
- });
144
+ var VERSION = getVersion();
104
145
 
105
146
  // ../worker-utils/src/lib/env-utils/assert.ts
106
147
  function assert2(condition, message) {
@@ -108,84 +149,80 @@
108
149
  throw new Error(message || "loaders.gl assertion failed.");
109
150
  }
110
151
  }
111
- var init_assert2 = __esm({
112
- "../worker-utils/src/lib/env-utils/assert.ts"() {
113
- }
114
- });
115
152
 
116
153
  // ../worker-utils/src/lib/env-utils/globals.ts
117
- var globals2, self_2, window_2, global_2, document_2, isBrowser2, isMobile, matches2, nodeVersion2;
118
- var init_globals2 = __esm({
119
- "../worker-utils/src/lib/env-utils/globals.ts"() {
120
- globals2 = {
121
- self: typeof self !== "undefined" && self,
122
- window: typeof window !== "undefined" && window,
123
- global: typeof global !== "undefined" && global,
124
- document: typeof document !== "undefined" && document
125
- };
126
- self_2 = globals2.self || globals2.window || globals2.global || {};
127
- window_2 = globals2.window || globals2.self || globals2.global || {};
128
- global_2 = globals2.global || globals2.self || globals2.window || {};
129
- document_2 = globals2.document || {};
130
- isBrowser2 = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
131
- isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
132
- matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
133
- nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
134
- }
135
- });
154
+ var globals2 = {
155
+ self: typeof self !== "undefined" && self,
156
+ window: typeof window !== "undefined" && window,
157
+ global: typeof global !== "undefined" && global,
158
+ document: typeof document !== "undefined" && document
159
+ };
160
+ var self_2 = globals2.self || globals2.window || globals2.global || {};
161
+ var window_2 = globals2.window || globals2.self || globals2.global || {};
162
+ var global_2 = globals2.global || globals2.self || globals2.window || {};
163
+ var document_2 = globals2.document || {};
164
+ var isBrowser2 = (
165
+ // @ts-ignore process.browser
166
+ typeof process !== "object" || String(process) !== "[object process]" || process.browser
167
+ );
168
+ var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
169
+ var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
170
+ var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
136
171
 
137
172
  // ../worker-utils/src/lib/worker-farm/worker-job.ts
138
- var WorkerJob;
139
- var init_worker_job = __esm({
140
- "../worker-utils/src/lib/worker-farm/worker-job.ts"() {
141
- init_assert2();
142
- WorkerJob = class {
143
- constructor(jobName, workerThread) {
144
- this.isRunning = true;
145
- this._resolve = () => {
146
- };
147
- this._reject = () => {
148
- };
149
- this.name = jobName;
150
- this.workerThread = workerThread;
151
- this.result = new Promise((resolve2, reject) => {
152
- this._resolve = resolve2;
153
- this._reject = reject;
154
- });
155
- }
156
- postMessage(type, payload) {
157
- this.workerThread.postMessage({
158
- source: "loaders.gl",
159
- type,
160
- payload
161
- });
162
- }
163
- done(value) {
164
- assert2(this.isRunning);
165
- this.isRunning = false;
166
- this._resolve(value);
167
- }
168
- error(error) {
169
- assert2(this.isRunning);
170
- this.isRunning = false;
171
- this._reject(error);
172
- }
173
- };
173
+ var WorkerJob = class {
174
+ isRunning = true;
175
+ /** Promise that resolves when Job is done */
176
+ _resolve = () => {
177
+ };
178
+ _reject = () => {
179
+ };
180
+ constructor(jobName, workerThread) {
181
+ this.name = jobName;
182
+ this.workerThread = workerThread;
183
+ this.result = new Promise((resolve2, reject) => {
184
+ this._resolve = resolve2;
185
+ this._reject = reject;
186
+ });
174
187
  }
175
- });
188
+ /**
189
+ * Send a message to the job's worker thread
190
+ * @param data any data structure, ideally consisting mostly of transferrable objects
191
+ */
192
+ postMessage(type, payload) {
193
+ this.workerThread.postMessage({
194
+ source: "loaders.gl",
195
+ // Lets worker ignore unrelated messages
196
+ type,
197
+ payload
198
+ });
199
+ }
200
+ /**
201
+ * Call to resolve the `result` Promise with the supplied value
202
+ */
203
+ done(value) {
204
+ assert2(this.isRunning);
205
+ this.isRunning = false;
206
+ this._resolve(value);
207
+ }
208
+ /**
209
+ * Call to reject the `result` Promise with the supplied error
210
+ */
211
+ error(error) {
212
+ assert2(this.isRunning);
213
+ this.isRunning = false;
214
+ this._reject(error);
215
+ }
216
+ };
176
217
 
177
218
  // ../worker-utils/src/lib/node/worker_threads-browser.ts
178
- var Worker2;
179
- var init_worker_threads_browser = __esm({
180
- "../worker-utils/src/lib/node/worker_threads-browser.ts"() {
181
- Worker2 = class {
182
- terminate() {
183
- }
184
- };
219
+ var Worker2 = class {
220
+ terminate() {
185
221
  }
186
- });
222
+ };
187
223
 
188
224
  // ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
225
+ var workerURLCache = /* @__PURE__ */ new Map();
189
226
  function getLoadableWorkerURL(props) {
190
227
  assert2(props.source && !props.url || !props.source && props.url);
191
228
  let workerURL = workerURLCache.get(props.source || props.url);
@@ -210,7 +247,9 @@
210
247
  return getLoadableWorkerURLFromSource(workerSource);
211
248
  }
212
249
  function getLoadableWorkerURLFromSource(workerSource) {
213
- const blob = new Blob([workerSource], { type: "application/javascript" });
250
+ const blob = new Blob([workerSource], {
251
+ type: "application/javascript"
252
+ });
214
253
  return URL.createObjectURL(blob);
215
254
  }
216
255
  function buildScriptSource(workerUrl) {
@@ -221,17 +260,10 @@
221
260
  throw error;
222
261
  }`;
223
262
  }
224
- var workerURLCache;
225
- var init_get_loadable_worker_url = __esm({
226
- "../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts"() {
227
- init_assert2();
228
- workerURLCache = new Map();
229
- }
230
- });
231
263
 
232
264
  // ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
233
265
  function getTransferList(object, recursive = true, transfers) {
234
- const transfersSet = transfers || new Set();
266
+ const transfersSet = transfers || /* @__PURE__ */ new Set();
235
267
  if (!object) {
236
268
  } else if (isTransferable(object)) {
237
269
  transfersSet.add(object);
@@ -279,283 +311,366 @@
279
311
  });
280
312
  return clone;
281
313
  }
282
- var init_get_transfer_list = __esm({
283
- "../worker-utils/src/lib/worker-utils/get-transfer-list.ts"() {
284
- }
285
- });
286
314
 
287
315
  // ../worker-utils/src/lib/worker-farm/worker-thread.ts
288
- var NOOP, WorkerThread;
289
- var init_worker_thread = __esm({
290
- "../worker-utils/src/lib/worker-farm/worker-thread.ts"() {
291
- init_worker_threads_browser();
292
- init_globals2();
293
- init_assert2();
294
- init_get_loadable_worker_url();
295
- init_get_transfer_list();
296
- NOOP = () => {
297
- };
298
- WorkerThread = class {
299
- constructor(props) {
300
- this.terminated = false;
301
- this._loadableURL = "";
302
- const { name, source, url } = props;
303
- assert2(source || url);
304
- this.name = name;
305
- this.source = source;
306
- this.url = url;
307
- this.onMessage = NOOP;
308
- this.onError = (error) => console.log(error);
309
- this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
310
- }
311
- static isSupported() {
312
- return typeof Worker !== "undefined" && isBrowser2 || typeof Worker2 !== "undefined" && !isBrowser2;
313
- }
314
- destroy() {
315
- this.onMessage = NOOP;
316
- this.onError = NOOP;
317
- this.worker.terminate();
318
- this.terminated = true;
319
- }
320
- get isRunning() {
321
- return Boolean(this.onMessage);
322
- }
323
- postMessage(data, transferList) {
324
- transferList = transferList || getTransferList(data);
325
- this.worker.postMessage(data, transferList);
326
- }
327
- _getErrorFromErrorEvent(event) {
328
- let message = "Failed to load ";
329
- message += `worker ${this.name} from ${this.url}. `;
330
- if (event.message) {
331
- message += `${event.message} in `;
332
- }
333
- if (event.lineno) {
334
- message += `:${event.lineno}:${event.colno}`;
335
- }
336
- return new Error(message);
337
- }
338
- _createBrowserWorker() {
339
- this._loadableURL = getLoadableWorkerURL({ source: this.source, url: this.url });
340
- const worker = new Worker(this._loadableURL, { name: this.name });
341
- worker.onmessage = (event) => {
342
- if (!event.data) {
343
- this.onError(new Error("No data received"));
344
- } else {
345
- this.onMessage(event.data);
346
- }
347
- };
348
- worker.onerror = (error) => {
349
- this.onError(this._getErrorFromErrorEvent(error));
350
- this.terminated = true;
351
- };
352
- worker.onmessageerror = (event) => console.error(event);
353
- return worker;
354
- }
355
- _createNodeWorker() {
356
- let worker;
357
- if (this.url) {
358
- const absolute = this.url.includes(":/") || this.url.startsWith("/");
359
- const url = absolute ? this.url : `./${this.url}`;
360
- worker = new Worker2(url, { eval: false });
361
- } else if (this.source) {
362
- worker = new Worker2(this.source, { eval: true });
363
- } else {
364
- throw new Error("no worker");
365
- }
366
- worker.on("message", (data) => {
367
- this.onMessage(data);
368
- });
369
- worker.on("error", (error) => {
370
- this.onError(error);
371
- });
372
- worker.on("exit", (code) => {
373
- });
374
- return worker;
316
+ var NOOP = () => {
317
+ };
318
+ var WorkerThread = class {
319
+ terminated = false;
320
+ _loadableURL = "";
321
+ /** Checks if workers are supported on this platform */
322
+ static isSupported() {
323
+ return typeof Worker !== "undefined" && isBrowser2 || typeof Worker2 !== "undefined" && !isBrowser2;
324
+ }
325
+ constructor(props) {
326
+ const {
327
+ name,
328
+ source,
329
+ url
330
+ } = props;
331
+ assert2(source || url);
332
+ this.name = name;
333
+ this.source = source;
334
+ this.url = url;
335
+ this.onMessage = NOOP;
336
+ this.onError = (error) => console.log(error);
337
+ this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
338
+ }
339
+ /**
340
+ * Terminate this worker thread
341
+ * @note Can free up significant memory
342
+ */
343
+ destroy() {
344
+ this.onMessage = NOOP;
345
+ this.onError = NOOP;
346
+ this.worker.terminate();
347
+ this.terminated = true;
348
+ }
349
+ get isRunning() {
350
+ return Boolean(this.onMessage);
351
+ }
352
+ /**
353
+ * Send a message to this worker thread
354
+ * @param data any data structure, ideally consisting mostly of transferrable objects
355
+ * @param transferList If not supplied, calculated automatically by traversing data
356
+ */
357
+ postMessage(data, transferList) {
358
+ transferList = transferList || getTransferList(data);
359
+ this.worker.postMessage(data, transferList);
360
+ }
361
+ // PRIVATE
362
+ /**
363
+ * Generate a standard Error from an ErrorEvent
364
+ * @param event
365
+ */
366
+ _getErrorFromErrorEvent(event) {
367
+ let message = "Failed to load ";
368
+ message += `worker ${this.name} from ${this.url}. `;
369
+ if (event.message) {
370
+ message += `${event.message} in `;
371
+ }
372
+ if (event.lineno) {
373
+ message += `:${event.lineno}:${event.colno}`;
374
+ }
375
+ return new Error(message);
376
+ }
377
+ /**
378
+ * Creates a worker thread on the browser
379
+ */
380
+ _createBrowserWorker() {
381
+ this._loadableURL = getLoadableWorkerURL({
382
+ source: this.source,
383
+ url: this.url
384
+ });
385
+ const worker = new Worker(this._loadableURL, {
386
+ name: this.name
387
+ });
388
+ worker.onmessage = (event) => {
389
+ if (!event.data) {
390
+ this.onError(new Error("No data received"));
391
+ } else {
392
+ this.onMessage(event.data);
375
393
  }
376
394
  };
395
+ worker.onerror = (error) => {
396
+ this.onError(this._getErrorFromErrorEvent(error));
397
+ this.terminated = true;
398
+ };
399
+ worker.onmessageerror = (event) => console.error(event);
400
+ return worker;
401
+ }
402
+ /**
403
+ * Creates a worker thread in node.js
404
+ * @todo https://nodejs.org/api/async_hooks.html#async-resource-worker-pool
405
+ */
406
+ _createNodeWorker() {
407
+ let worker;
408
+ if (this.url) {
409
+ const absolute = this.url.includes(":/") || this.url.startsWith("/");
410
+ const url = absolute ? this.url : `./${this.url}`;
411
+ worker = new Worker2(url, {
412
+ eval: false
413
+ });
414
+ } else if (this.source) {
415
+ worker = new Worker2(this.source, {
416
+ eval: true
417
+ });
418
+ } else {
419
+ throw new Error("no worker");
420
+ }
421
+ worker.on("message", (data) => {
422
+ this.onMessage(data);
423
+ });
424
+ worker.on("error", (error) => {
425
+ this.onError(error);
426
+ });
427
+ worker.on("exit", (code) => {
428
+ });
429
+ return worker;
377
430
  }
378
- });
431
+ };
379
432
 
380
433
  // ../worker-utils/src/lib/worker-farm/worker-pool.ts
381
- var WorkerPool;
382
- var init_worker_pool = __esm({
383
- "../worker-utils/src/lib/worker-farm/worker-pool.ts"() {
384
- init_globals2();
385
- init_worker_thread();
386
- init_worker_job();
387
- WorkerPool = class {
388
- constructor(props) {
389
- this.name = "unnamed";
390
- this.maxConcurrency = 1;
391
- this.maxMobileConcurrency = 1;
392
- this.onDebug = () => {
393
- };
394
- this.reuseWorkers = true;
395
- this.props = {};
396
- this.jobQueue = [];
397
- this.idleQueue = [];
398
- this.count = 0;
399
- this.isDestroyed = false;
400
- this.source = props.source;
401
- this.url = props.url;
402
- this.setProps(props);
403
- }
404
- static isSupported() {
405
- return WorkerThread.isSupported();
406
- }
407
- destroy() {
408
- this.idleQueue.forEach((worker) => worker.destroy());
409
- this.isDestroyed = true;
410
- }
411
- setProps(props) {
412
- this.props = { ...this.props, ...props };
413
- if (props.name !== void 0) {
414
- this.name = props.name;
415
- }
416
- if (props.maxConcurrency !== void 0) {
417
- this.maxConcurrency = props.maxConcurrency;
418
- }
419
- if (props.maxMobileConcurrency !== void 0) {
420
- this.maxMobileConcurrency = props.maxMobileConcurrency;
421
- }
422
- if (props.reuseWorkers !== void 0) {
423
- this.reuseWorkers = props.reuseWorkers;
424
- }
425
- if (props.onDebug !== void 0) {
426
- this.onDebug = props.onDebug;
427
- }
428
- }
429
- async startJob(name, onMessage3 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error)) {
430
- const startPromise = new Promise((onStart) => {
431
- this.jobQueue.push({ name, onMessage: onMessage3, onError, onStart });
432
- return this;
433
- });
434
- this._startQueuedJob();
435
- return await startPromise;
436
- }
437
- async _startQueuedJob() {
438
- if (!this.jobQueue.length) {
439
- return;
440
- }
441
- const workerThread = this._getAvailableWorker();
442
- if (!workerThread) {
443
- return;
444
- }
445
- const queuedJob = this.jobQueue.shift();
446
- if (queuedJob) {
447
- this.onDebug({
448
- message: "Starting job",
449
- name: queuedJob.name,
450
- workerThread,
451
- backlog: this.jobQueue.length
452
- });
453
- const job = new WorkerJob(queuedJob.name, workerThread);
454
- workerThread.onMessage = (data) => queuedJob.onMessage(job, data.type, data.payload);
455
- workerThread.onError = (error) => queuedJob.onError(job, error);
456
- queuedJob.onStart(job);
457
- try {
458
- await job.result;
459
- } finally {
460
- this.returnWorkerToQueue(workerThread);
461
- }
462
- }
463
- }
464
- returnWorkerToQueue(worker) {
465
- const shouldDestroyWorker = !isBrowser2 || this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency();
466
- if (shouldDestroyWorker) {
467
- worker.destroy();
468
- this.count--;
469
- } else {
470
- this.idleQueue.push(worker);
471
- }
472
- if (!this.isDestroyed) {
473
- this._startQueuedJob();
474
- }
475
- }
476
- _getAvailableWorker() {
477
- if (this.idleQueue.length > 0) {
478
- return this.idleQueue.shift() || null;
479
- }
480
- if (this.count < this._getMaxConcurrency()) {
481
- this.count++;
482
- const name = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
483
- return new WorkerThread({ name, source: this.source, url: this.url });
484
- }
485
- return null;
486
- }
487
- _getMaxConcurrency() {
488
- return isMobile ? this.maxMobileConcurrency : this.maxConcurrency;
489
- }
434
+ var WorkerPool = class {
435
+ name = "unnamed";
436
+ // | Function;
437
+ maxConcurrency = 1;
438
+ maxMobileConcurrency = 1;
439
+ onDebug = () => {
440
+ };
441
+ reuseWorkers = true;
442
+ props = {};
443
+ jobQueue = [];
444
+ idleQueue = [];
445
+ count = 0;
446
+ isDestroyed = false;
447
+ /** Checks if workers are supported on this platform */
448
+ static isSupported() {
449
+ return WorkerThread.isSupported();
450
+ }
451
+ /**
452
+ * @param processor - worker function
453
+ * @param maxConcurrency - max count of workers
454
+ */
455
+ constructor(props) {
456
+ this.source = props.source;
457
+ this.url = props.url;
458
+ this.setProps(props);
459
+ }
460
+ /**
461
+ * Terminates all workers in the pool
462
+ * @note Can free up significant memory
463
+ */
464
+ destroy() {
465
+ this.idleQueue.forEach((worker) => worker.destroy());
466
+ this.isDestroyed = true;
467
+ }
468
+ setProps(props) {
469
+ this.props = {
470
+ ...this.props,
471
+ ...props
490
472
  };
473
+ if (props.name !== void 0) {
474
+ this.name = props.name;
475
+ }
476
+ if (props.maxConcurrency !== void 0) {
477
+ this.maxConcurrency = props.maxConcurrency;
478
+ }
479
+ if (props.maxMobileConcurrency !== void 0) {
480
+ this.maxMobileConcurrency = props.maxMobileConcurrency;
481
+ }
482
+ if (props.reuseWorkers !== void 0) {
483
+ this.reuseWorkers = props.reuseWorkers;
484
+ }
485
+ if (props.onDebug !== void 0) {
486
+ this.onDebug = props.onDebug;
487
+ }
491
488
  }
492
- });
489
+ async startJob(name, onMessage3 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error)) {
490
+ const startPromise = new Promise((onStart) => {
491
+ this.jobQueue.push({
492
+ name,
493
+ onMessage: onMessage3,
494
+ onError,
495
+ onStart
496
+ });
497
+ return this;
498
+ });
499
+ this._startQueuedJob();
500
+ return await startPromise;
501
+ }
502
+ // PRIVATE
503
+ /**
504
+ * Starts first queued job if worker is available or can be created
505
+ * Called when job is started and whenever a worker returns to the idleQueue
506
+ */
507
+ async _startQueuedJob() {
508
+ if (!this.jobQueue.length) {
509
+ return;
510
+ }
511
+ const workerThread = this._getAvailableWorker();
512
+ if (!workerThread) {
513
+ return;
514
+ }
515
+ const queuedJob = this.jobQueue.shift();
516
+ if (queuedJob) {
517
+ this.onDebug({
518
+ message: "Starting job",
519
+ name: queuedJob.name,
520
+ workerThread,
521
+ backlog: this.jobQueue.length
522
+ });
523
+ const job = new WorkerJob(queuedJob.name, workerThread);
524
+ workerThread.onMessage = (data) => queuedJob.onMessage(job, data.type, data.payload);
525
+ workerThread.onError = (error) => queuedJob.onError(job, error);
526
+ queuedJob.onStart(job);
527
+ try {
528
+ await job.result;
529
+ } catch (error) {
530
+ console.error(`Worker exception: ${error}`);
531
+ } finally {
532
+ this.returnWorkerToQueue(workerThread);
533
+ }
534
+ }
535
+ }
536
+ /**
537
+ * Returns a worker to the idle queue
538
+ * Destroys the worker if
539
+ * - pool is destroyed
540
+ * - if this pool doesn't reuse workers
541
+ * - if maxConcurrency has been lowered
542
+ * @param worker
543
+ */
544
+ returnWorkerToQueue(worker) {
545
+ const shouldDestroyWorker = (
546
+ // Workers on Node.js prevent the process from exiting.
547
+ // Until we figure out how to close them before exit, we always destroy them
548
+ !isBrowser2 || // If the pool is destroyed, there is no reason to keep the worker around
549
+ this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed
550
+ !this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements
551
+ this.count > this._getMaxConcurrency()
552
+ );
553
+ if (shouldDestroyWorker) {
554
+ worker.destroy();
555
+ this.count--;
556
+ } else {
557
+ this.idleQueue.push(worker);
558
+ }
559
+ if (!this.isDestroyed) {
560
+ this._startQueuedJob();
561
+ }
562
+ }
563
+ /**
564
+ * Returns idle worker or creates new worker if maxConcurrency has not been reached
565
+ */
566
+ _getAvailableWorker() {
567
+ if (this.idleQueue.length > 0) {
568
+ return this.idleQueue.shift() || null;
569
+ }
570
+ if (this.count < this._getMaxConcurrency()) {
571
+ this.count++;
572
+ const name = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
573
+ return new WorkerThread({
574
+ name,
575
+ source: this.source,
576
+ url: this.url
577
+ });
578
+ }
579
+ return null;
580
+ }
581
+ _getMaxConcurrency() {
582
+ return isMobile ? this.maxMobileConcurrency : this.maxConcurrency;
583
+ }
584
+ };
493
585
 
494
586
  // ../worker-utils/src/lib/worker-farm/worker-farm.ts
495
- var DEFAULT_PROPS, WorkerFarm;
496
- var init_worker_farm = __esm({
497
- "../worker-utils/src/lib/worker-farm/worker-farm.ts"() {
498
- init_worker_pool();
499
- init_worker_thread();
500
- DEFAULT_PROPS = {
501
- maxConcurrency: 3,
502
- maxMobileConcurrency: 1,
503
- reuseWorkers: true,
504
- onDebug: () => {
505
- }
587
+ var DEFAULT_PROPS = {
588
+ maxConcurrency: 3,
589
+ maxMobileConcurrency: 1,
590
+ reuseWorkers: true,
591
+ onDebug: () => {
592
+ }
593
+ };
594
+ var WorkerFarm = class {
595
+ workerPools = /* @__PURE__ */ new Map();
596
+ // singleton
597
+ /** Checks if workers are supported on this platform */
598
+ static isSupported() {
599
+ return WorkerThread.isSupported();
600
+ }
601
+ /** Get the singleton instance of the global worker farm */
602
+ static getWorkerFarm(props = {}) {
603
+ WorkerFarm._workerFarm = WorkerFarm._workerFarm || new WorkerFarm({});
604
+ WorkerFarm._workerFarm.setProps(props);
605
+ return WorkerFarm._workerFarm;
606
+ }
607
+ /** get global instance with WorkerFarm.getWorkerFarm() */
608
+ constructor(props) {
609
+ this.props = {
610
+ ...DEFAULT_PROPS
506
611
  };
507
- WorkerFarm = class {
508
- constructor(props) {
509
- this.workerPools = new Map();
510
- this.props = { ...DEFAULT_PROPS };
511
- this.setProps(props);
512
- this.workerPools = new Map();
513
- }
514
- static isSupported() {
515
- return WorkerThread.isSupported();
516
- }
517
- static getWorkerFarm(props = {}) {
518
- WorkerFarm._workerFarm = WorkerFarm._workerFarm || new WorkerFarm({});
519
- WorkerFarm._workerFarm.setProps(props);
520
- return WorkerFarm._workerFarm;
521
- }
522
- destroy() {
523
- for (const workerPool of this.workerPools.values()) {
524
- workerPool.destroy();
525
- }
526
- this.workerPools = new Map();
527
- }
528
- setProps(props) {
529
- this.props = { ...this.props, ...props };
530
- for (const workerPool of this.workerPools.values()) {
531
- workerPool.setProps(this._getWorkerPoolProps());
532
- }
533
- }
534
- getWorkerPool(options) {
535
- const { name, source, url } = options;
536
- let workerPool = this.workerPools.get(name);
537
- if (!workerPool) {
538
- workerPool = new WorkerPool({
539
- name,
540
- source,
541
- url
542
- });
543
- workerPool.setProps(this._getWorkerPoolProps());
544
- this.workerPools.set(name, workerPool);
545
- }
546
- return workerPool;
547
- }
548
- _getWorkerPoolProps() {
549
- return {
550
- maxConcurrency: this.props.maxConcurrency,
551
- maxMobileConcurrency: this.props.maxMobileConcurrency,
552
- reuseWorkers: this.props.reuseWorkers,
553
- onDebug: this.props.onDebug
554
- };
555
- }
612
+ this.setProps(props);
613
+ this.workerPools = /* @__PURE__ */ new Map();
614
+ }
615
+ /**
616
+ * Terminate all workers in the farm
617
+ * @note Can free up significant memory
618
+ */
619
+ destroy() {
620
+ for (const workerPool of this.workerPools.values()) {
621
+ workerPool.destroy();
622
+ }
623
+ this.workerPools = /* @__PURE__ */ new Map();
624
+ }
625
+ /**
626
+ * Set props used when initializing worker pools
627
+ * @param props
628
+ */
629
+ setProps(props) {
630
+ this.props = {
631
+ ...this.props,
632
+ ...props
556
633
  };
634
+ for (const workerPool of this.workerPools.values()) {
635
+ workerPool.setProps(this._getWorkerPoolProps());
636
+ }
557
637
  }
558
- });
638
+ /**
639
+ * Returns a worker pool for the specified worker
640
+ * @param options - only used first time for a specific worker name
641
+ * @param options.name - the name of the worker - used to identify worker pool
642
+ * @param options.url -
643
+ * @param options.source -
644
+ * @example
645
+ * const job = WorkerFarm.getWorkerFarm().getWorkerPool({name, url}).startJob(...);
646
+ */
647
+ getWorkerPool(options) {
648
+ const {
649
+ name,
650
+ source,
651
+ url
652
+ } = options;
653
+ let workerPool = this.workerPools.get(name);
654
+ if (!workerPool) {
655
+ workerPool = new WorkerPool({
656
+ name,
657
+ source,
658
+ url
659
+ });
660
+ workerPool.setProps(this._getWorkerPoolProps());
661
+ this.workerPools.set(name, workerPool);
662
+ }
663
+ return workerPool;
664
+ }
665
+ _getWorkerPoolProps() {
666
+ return {
667
+ maxConcurrency: this.props.maxConcurrency,
668
+ maxMobileConcurrency: this.props.maxMobileConcurrency,
669
+ reuseWorkers: this.props.reuseWorkers,
670
+ onDebug: this.props.onDebug
671
+ };
672
+ }
673
+ };
559
674
 
560
675
  // ../worker-utils/src/lib/worker-api/get-worker-url.ts
561
676
  function getWorkerName(worker) {
@@ -583,28 +698,33 @@
583
698
  assert2(url);
584
699
  return url;
585
700
  }
586
- var init_get_worker_url = __esm({
587
- "../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
588
- init_assert2();
589
- init_globals2();
590
- init_version();
591
- }
592
- });
593
701
 
594
702
  // ../worker-utils/src/lib/worker-api/process-on-worker.ts
595
703
  async function processOnWorker(worker, data, options = {}, context = {}) {
596
704
  const name = getWorkerName(worker);
597
705
  const workerFarm = WorkerFarm.getWorkerFarm(options);
598
- const { source } = options;
599
- const workerPoolProps = { name, source };
706
+ const {
707
+ source
708
+ } = options;
709
+ const workerPoolProps = {
710
+ name,
711
+ source
712
+ };
600
713
  if (!source) {
601
714
  workerPoolProps.url = getWorkerURL(worker, options);
602
715
  }
603
716
  const workerPool = workerFarm.getWorkerPool(workerPoolProps);
604
717
  const jobName = options.jobName || worker.name;
605
- const job = await workerPool.startJob(jobName, onMessage.bind(null, context));
718
+ const job = await workerPool.startJob(
719
+ jobName,
720
+ // eslint-disable-next-line
721
+ onMessage.bind(null, context)
722
+ );
606
723
  const transferableOptions = getTransferListForWriter(options);
607
- job.postMessage("process", { input: data, options: transferableOptions });
724
+ job.postMessage("process", {
725
+ input: data,
726
+ options: transferableOptions
727
+ });
608
728
  const result = await job.result;
609
729
  return result.result;
610
730
  }
@@ -617,30 +737,36 @@
617
737
  job.error(new Error(payload.error));
618
738
  break;
619
739
  case "process":
620
- const { id, input, options } = payload;
740
+ const {
741
+ id,
742
+ input,
743
+ options
744
+ } = payload;
621
745
  try {
622
746
  if (!context.process) {
623
- job.postMessage("error", { id, error: "Worker not set up to process on main thread" });
747
+ job.postMessage("error", {
748
+ id,
749
+ error: "Worker not set up to process on main thread"
750
+ });
624
751
  return;
625
752
  }
626
753
  const result = await context.process(input, options);
627
- job.postMessage("done", { id, result });
754
+ job.postMessage("done", {
755
+ id,
756
+ result
757
+ });
628
758
  } catch (error) {
629
759
  const message = error instanceof Error ? error.message : "unknown error";
630
- job.postMessage("error", { id, error: message });
760
+ job.postMessage("error", {
761
+ id,
762
+ error: message
763
+ });
631
764
  }
632
765
  break;
633
766
  default:
634
767
  console.warn(`process-on-worker: unknown message ${type}`);
635
768
  }
636
769
  }
637
- var init_process_on_worker = __esm({
638
- "../worker-utils/src/lib/worker-api/process-on-worker.ts"() {
639
- init_worker_farm();
640
- init_get_worker_url();
641
- init_get_transfer_list();
642
- }
643
- });
644
770
 
645
771
  // ../worker-utils/src/lib/worker-api/validate-worker-version.ts
646
772
  function validateWorkerVersion(worker, coreVersion = VERSION) {
@@ -651,24 +777,6 @@
651
777
  }
652
778
  return true;
653
779
  }
654
- var init_validate_worker_version = __esm({
655
- "../worker-utils/src/lib/worker-api/validate-worker-version.ts"() {
656
- init_assert2();
657
- init_version();
658
- }
659
- });
660
-
661
- // ../worker-utils/src/index.ts
662
- var init_src = __esm({
663
- "../worker-utils/src/index.ts"() {
664
- init_assert2();
665
- init_globals2();
666
- init_worker_farm();
667
- init_process_on_worker();
668
- init_get_worker_url();
669
- init_validate_worker_version();
670
- }
671
- });
672
780
 
673
781
  // ../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts
674
782
  function canParseWithWorker(loader, options) {
@@ -684,11 +792,20 @@
684
792
  const name = loader.id;
685
793
  const url = getWorkerURL(loader, options);
686
794
  const workerFarm = WorkerFarm.getWorkerFarm(options);
687
- const workerPool = workerFarm.getWorkerPool({ name, url });
795
+ const workerPool = workerFarm.getWorkerPool({
796
+ name,
797
+ url
798
+ });
688
799
  options = JSON.parse(JSON.stringify(options));
689
800
  context = JSON.parse(JSON.stringify(context || {}));
690
- const job = await workerPool.startJob("process-on-worker", onMessage2.bind(null, parseOnMainThread));
801
+ const job = await workerPool.startJob(
802
+ "process-on-worker",
803
+ // @ts-expect-error
804
+ onMessage2.bind(null, parseOnMainThread)
805
+ // eslint-disable-line @typescript-eslint/no-misused-promises
806
+ );
691
807
  job.postMessage("process", {
808
+ // @ts-ignore
692
809
  input: data,
693
810
  options,
694
811
  context
@@ -705,25 +822,29 @@
705
822
  job.error(new Error(payload.error));
706
823
  break;
707
824
  case "process":
708
- const { id, input, options } = payload;
825
+ const {
826
+ id,
827
+ input,
828
+ options
829
+ } = payload;
709
830
  try {
710
831
  const result = await parseOnMainThread(input, options);
711
- job.postMessage("done", { id, result });
832
+ job.postMessage("done", {
833
+ id,
834
+ result
835
+ });
712
836
  } catch (error) {
713
837
  const message = error instanceof Error ? error.message : "unknown error";
714
- job.postMessage("error", { id, error: message });
838
+ job.postMessage("error", {
839
+ id,
840
+ error: message
841
+ });
715
842
  }
716
843
  break;
717
844
  default:
718
845
  console.warn(`parse-with-worker unknown message ${type}`);
719
846
  }
720
847
  }
721
- var init_parse_with_worker = __esm({
722
- "../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts"() {
723
- init_src();
724
- init_src();
725
- }
726
- });
727
848
 
728
849
  // ../loader-utils/src/lib/worker-loader-utils/encode-with-worker.ts
729
850
  function canEncodeWithWorker(writer, options) {
@@ -735,12 +856,6 @@
735
856
  }
736
857
  return writer.worker && options?.worker;
737
858
  }
738
- var init_encode_with_worker = __esm({
739
- "../loader-utils/src/lib/worker-loader-utils/encode-with-worker.ts"() {
740
- init_src();
741
- init_globals();
742
- }
743
- });
744
859
 
745
860
  // ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
746
861
  function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
@@ -768,16 +883,14 @@
768
883
  }
769
884
  return result.buffer;
770
885
  }
771
- var init_array_buffer_utils = __esm({
772
- "../loader-utils/src/lib/binary-utils/array-buffer-utils.ts"() {
773
- }
774
- });
775
886
 
776
887
  // ../loader-utils/src/lib/iterators/text-iterators.ts
777
888
  async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
778
889
  const textDecoder = new TextDecoder(void 0, options);
779
890
  for await (const arrayBuffer of arrayBufferIterator) {
780
- yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder.decode(arrayBuffer, { stream: true });
891
+ yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder.decode(arrayBuffer, {
892
+ stream: true
893
+ });
781
894
  }
782
895
  }
783
896
  async function* makeTextEncoderIterator(textIterator) {
@@ -804,19 +917,21 @@
804
917
  async function* makeNumberedLineIterator(lineIterator) {
805
918
  let counter = 1;
806
919
  for await (const line of lineIterator) {
807
- yield { counter, line };
920
+ yield {
921
+ counter,
922
+ line
923
+ };
808
924
  counter++;
809
925
  }
810
926
  }
811
- var init_text_iterators = __esm({
812
- "../loader-utils/src/lib/iterators/text-iterators.ts"() {
813
- }
814
- });
815
927
 
816
928
  // ../loader-utils/src/lib/iterators/async-iteration.ts
817
929
  async function forEach(iterator, visitor) {
818
930
  while (true) {
819
- const { done, value } = await iterator.next();
931
+ const {
932
+ done,
933
+ value
934
+ } = await iterator.next();
820
935
  if (done) {
821
936
  iterator.return();
822
937
  return;
@@ -834,25 +949,16 @@
834
949
  }
835
950
  return concatenateArrayBuffers(...arrayBuffers);
836
951
  }
837
- var init_async_iteration = __esm({
838
- "../loader-utils/src/lib/iterators/async-iteration.ts"() {
839
- init_array_buffer_utils();
840
- }
841
- });
842
952
 
843
953
  // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
844
954
  function _typeof(obj) {
845
955
  "@babel/helpers - typeof";
846
- return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
956
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
847
957
  return typeof obj2;
848
958
  } : function(obj2) {
849
- return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
959
+ return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
850
960
  }, _typeof(obj);
851
961
  }
852
- var init_typeof = __esm({
853
- "../../node_modules/@babel/runtime/helpers/esm/typeof.js"() {
854
- }
855
- });
856
962
 
857
963
  // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
858
964
  function _toPrimitive(input, hint) {
@@ -867,23 +973,12 @@
867
973
  }
868
974
  return (hint === "string" ? String : Number)(input);
869
975
  }
870
- var init_toPrimitive = __esm({
871
- "../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js"() {
872
- init_typeof();
873
- }
874
- });
875
976
 
876
977
  // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
877
978
  function _toPropertyKey(arg) {
878
979
  var key = _toPrimitive(arg, "string");
879
980
  return _typeof(key) === "symbol" ? key : String(key);
880
981
  }
881
- var init_toPropertyKey = __esm({
882
- "../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js"() {
883
- init_typeof();
884
- init_toPrimitive();
885
- }
886
- });
887
982
 
888
983
  // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
889
984
  function _defineProperty(obj, key, value) {
@@ -900,11 +995,6 @@
900
995
  }
901
996
  return obj;
902
997
  }
903
- var init_defineProperty = __esm({
904
- "../../node_modules/@babel/runtime/helpers/esm/defineProperty.js"() {
905
- init_toPropertyKey();
906
- }
907
- });
908
998
 
909
999
  // ../loader-utils/node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
910
1000
  function getHiResTimestamp() {
@@ -919,316 +1009,327 @@
919
1009
  }
920
1010
  return timestamp;
921
1011
  }
922
- var init_hi_res_timestamp = __esm({
923
- "../loader-utils/node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js"() {
924
- }
925
- });
926
1012
 
927
1013
  // ../loader-utils/node_modules/@probe.gl/stats/dist/lib/stat.js
928
- var Stat;
929
- var init_stat = __esm({
930
- "../loader-utils/node_modules/@probe.gl/stats/dist/lib/stat.js"() {
931
- init_defineProperty();
932
- init_hi_res_timestamp();
933
- Stat = class {
934
- constructor(name, type) {
935
- _defineProperty(this, "name", void 0);
936
- _defineProperty(this, "type", void 0);
937
- _defineProperty(this, "sampleSize", 1);
938
- _defineProperty(this, "time", 0);
939
- _defineProperty(this, "count", 0);
940
- _defineProperty(this, "samples", 0);
941
- _defineProperty(this, "lastTiming", 0);
942
- _defineProperty(this, "lastSampleTime", 0);
943
- _defineProperty(this, "lastSampleCount", 0);
944
- _defineProperty(this, "_count", 0);
945
- _defineProperty(this, "_time", 0);
946
- _defineProperty(this, "_samples", 0);
947
- _defineProperty(this, "_startTime", 0);
948
- _defineProperty(this, "_timerPending", false);
949
- this.name = name;
950
- this.type = type;
951
- this.reset();
952
- }
953
- reset() {
954
- this.time = 0;
955
- this.count = 0;
956
- this.samples = 0;
957
- this.lastTiming = 0;
958
- this.lastSampleTime = 0;
959
- this.lastSampleCount = 0;
960
- this._count = 0;
961
- this._time = 0;
962
- this._samples = 0;
963
- this._startTime = 0;
964
- this._timerPending = false;
965
- return this;
966
- }
967
- setSampleSize(samples) {
968
- this.sampleSize = samples;
969
- return this;
970
- }
971
- incrementCount() {
972
- this.addCount(1);
973
- return this;
974
- }
975
- decrementCount() {
976
- this.subtractCount(1);
977
- return this;
978
- }
979
- addCount(value) {
980
- this._count += value;
981
- this._samples++;
982
- this._checkSampling();
983
- return this;
984
- }
985
- subtractCount(value) {
986
- this._count -= value;
987
- this._samples++;
988
- this._checkSampling();
989
- return this;
990
- }
991
- addTime(time) {
992
- this._time += time;
993
- this.lastTiming = time;
994
- this._samples++;
995
- this._checkSampling();
996
- return this;
997
- }
998
- timeStart() {
999
- this._startTime = getHiResTimestamp();
1000
- this._timerPending = true;
1001
- return this;
1002
- }
1003
- timeEnd() {
1004
- if (!this._timerPending) {
1005
- return this;
1006
- }
1007
- this.addTime(getHiResTimestamp() - this._startTime);
1008
- this._timerPending = false;
1009
- this._checkSampling();
1010
- return this;
1011
- }
1012
- getSampleAverageCount() {
1013
- return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
1014
- }
1015
- getSampleAverageTime() {
1016
- return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
1017
- }
1018
- getSampleHz() {
1019
- return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
1020
- }
1021
- getAverageCount() {
1022
- return this.samples > 0 ? this.count / this.samples : 0;
1023
- }
1024
- getAverageTime() {
1025
- return this.samples > 0 ? this.time / this.samples : 0;
1026
- }
1027
- getHz() {
1028
- return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
1029
- }
1030
- _checkSampling() {
1031
- if (this._samples === this.sampleSize) {
1032
- this.lastSampleTime = this._time;
1033
- this.lastSampleCount = this._count;
1034
- this.count += this._count;
1035
- this.time += this._time;
1036
- this.samples += this._samples;
1037
- this._time = 0;
1038
- this._count = 0;
1039
- this._samples = 0;
1040
- }
1041
- }
1042
- };
1014
+ var Stat = class {
1015
+ constructor(name, type) {
1016
+ _defineProperty(this, "name", void 0);
1017
+ _defineProperty(this, "type", void 0);
1018
+ _defineProperty(this, "sampleSize", 1);
1019
+ _defineProperty(this, "time", 0);
1020
+ _defineProperty(this, "count", 0);
1021
+ _defineProperty(this, "samples", 0);
1022
+ _defineProperty(this, "lastTiming", 0);
1023
+ _defineProperty(this, "lastSampleTime", 0);
1024
+ _defineProperty(this, "lastSampleCount", 0);
1025
+ _defineProperty(this, "_count", 0);
1026
+ _defineProperty(this, "_time", 0);
1027
+ _defineProperty(this, "_samples", 0);
1028
+ _defineProperty(this, "_startTime", 0);
1029
+ _defineProperty(this, "_timerPending", false);
1030
+ this.name = name;
1031
+ this.type = type;
1032
+ this.reset();
1033
+ }
1034
+ reset() {
1035
+ this.time = 0;
1036
+ this.count = 0;
1037
+ this.samples = 0;
1038
+ this.lastTiming = 0;
1039
+ this.lastSampleTime = 0;
1040
+ this.lastSampleCount = 0;
1041
+ this._count = 0;
1042
+ this._time = 0;
1043
+ this._samples = 0;
1044
+ this._startTime = 0;
1045
+ this._timerPending = false;
1046
+ return this;
1047
+ }
1048
+ setSampleSize(samples) {
1049
+ this.sampleSize = samples;
1050
+ return this;
1051
+ }
1052
+ incrementCount() {
1053
+ this.addCount(1);
1054
+ return this;
1055
+ }
1056
+ decrementCount() {
1057
+ this.subtractCount(1);
1058
+ return this;
1059
+ }
1060
+ addCount(value) {
1061
+ this._count += value;
1062
+ this._samples++;
1063
+ this._checkSampling();
1064
+ return this;
1065
+ }
1066
+ subtractCount(value) {
1067
+ this._count -= value;
1068
+ this._samples++;
1069
+ this._checkSampling();
1070
+ return this;
1071
+ }
1072
+ addTime(time) {
1073
+ this._time += time;
1074
+ this.lastTiming = time;
1075
+ this._samples++;
1076
+ this._checkSampling();
1077
+ return this;
1078
+ }
1079
+ timeStart() {
1080
+ this._startTime = getHiResTimestamp();
1081
+ this._timerPending = true;
1082
+ return this;
1083
+ }
1084
+ timeEnd() {
1085
+ if (!this._timerPending) {
1086
+ return this;
1087
+ }
1088
+ this.addTime(getHiResTimestamp() - this._startTime);
1089
+ this._timerPending = false;
1090
+ this._checkSampling();
1091
+ return this;
1092
+ }
1093
+ getSampleAverageCount() {
1094
+ return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
1095
+ }
1096
+ getSampleAverageTime() {
1097
+ return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
1098
+ }
1099
+ getSampleHz() {
1100
+ return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
1101
+ }
1102
+ getAverageCount() {
1103
+ return this.samples > 0 ? this.count / this.samples : 0;
1104
+ }
1105
+ getAverageTime() {
1106
+ return this.samples > 0 ? this.time / this.samples : 0;
1107
+ }
1108
+ getHz() {
1109
+ return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
1110
+ }
1111
+ _checkSampling() {
1112
+ if (this._samples === this.sampleSize) {
1113
+ this.lastSampleTime = this._time;
1114
+ this.lastSampleCount = this._count;
1115
+ this.count += this._count;
1116
+ this.time += this._time;
1117
+ this.samples += this._samples;
1118
+ this._time = 0;
1119
+ this._count = 0;
1120
+ this._samples = 0;
1121
+ }
1043
1122
  }
1044
- });
1123
+ };
1045
1124
 
1046
1125
  // ../loader-utils/node_modules/@probe.gl/stats/dist/lib/stats.js
1047
- var Stats;
1048
- var init_stats = __esm({
1049
- "../loader-utils/node_modules/@probe.gl/stats/dist/lib/stats.js"() {
1050
- init_defineProperty();
1051
- init_stat();
1052
- Stats = class {
1053
- constructor(options) {
1054
- _defineProperty(this, "id", void 0);
1055
- _defineProperty(this, "stats", {});
1056
- this.id = options.id;
1057
- this.stats = {};
1058
- this._initializeStats(options.stats);
1059
- Object.seal(this);
1060
- }
1061
- get(name) {
1062
- let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
1063
- return this._getOrCreate({
1064
- name,
1065
- type
1066
- });
1067
- }
1068
- get size() {
1069
- return Object.keys(this.stats).length;
1070
- }
1071
- reset() {
1072
- for (const stat of Object.values(this.stats)) {
1073
- stat.reset();
1074
- }
1075
- return this;
1076
- }
1077
- forEach(fn) {
1078
- for (const stat of Object.values(this.stats)) {
1079
- fn(stat);
1080
- }
1081
- }
1082
- getTable() {
1083
- const table = {};
1084
- this.forEach((stat) => {
1085
- table[stat.name] = {
1086
- time: stat.time || 0,
1087
- count: stat.count || 0,
1088
- average: stat.getAverageTime() || 0,
1089
- hz: stat.getHz() || 0
1090
- };
1091
- });
1092
- return table;
1093
- }
1094
- _initializeStats() {
1095
- let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
1096
- stats.forEach((stat) => this._getOrCreate(stat));
1097
- }
1098
- _getOrCreate(stat) {
1099
- const {
1100
- name,
1101
- type
1102
- } = stat;
1103
- let result = this.stats[name];
1104
- if (!result) {
1105
- if (stat instanceof Stat) {
1106
- result = stat;
1107
- } else {
1108
- result = new Stat(name, type);
1109
- }
1110
- this.stats[name] = result;
1111
- }
1112
- return result;
1113
- }
1114
- };
1126
+ var Stats = class {
1127
+ constructor(options) {
1128
+ _defineProperty(this, "id", void 0);
1129
+ _defineProperty(this, "stats", {});
1130
+ this.id = options.id;
1131
+ this.stats = {};
1132
+ this._initializeStats(options.stats);
1133
+ Object.seal(this);
1134
+ }
1135
+ get(name) {
1136
+ let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
1137
+ return this._getOrCreate({
1138
+ name,
1139
+ type
1140
+ });
1115
1141
  }
1116
- });
1117
-
1118
- // ../loader-utils/node_modules/@probe.gl/stats/dist/index.js
1119
- var init_dist = __esm({
1120
- "../loader-utils/node_modules/@probe.gl/stats/dist/index.js"() {
1121
- init_stats();
1122
- init_stat();
1123
- init_hi_res_timestamp();
1142
+ get size() {
1143
+ return Object.keys(this.stats).length;
1124
1144
  }
1125
- });
1145
+ reset() {
1146
+ for (const stat of Object.values(this.stats)) {
1147
+ stat.reset();
1148
+ }
1149
+ return this;
1150
+ }
1151
+ forEach(fn) {
1152
+ for (const stat of Object.values(this.stats)) {
1153
+ fn(stat);
1154
+ }
1155
+ }
1156
+ getTable() {
1157
+ const table = {};
1158
+ this.forEach((stat) => {
1159
+ table[stat.name] = {
1160
+ time: stat.time || 0,
1161
+ count: stat.count || 0,
1162
+ average: stat.getAverageTime() || 0,
1163
+ hz: stat.getHz() || 0
1164
+ };
1165
+ });
1166
+ return table;
1167
+ }
1168
+ _initializeStats() {
1169
+ let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
1170
+ stats.forEach((stat) => this._getOrCreate(stat));
1171
+ }
1172
+ _getOrCreate(stat) {
1173
+ const {
1174
+ name,
1175
+ type
1176
+ } = stat;
1177
+ let result = this.stats[name];
1178
+ if (!result) {
1179
+ if (stat instanceof Stat) {
1180
+ result = stat;
1181
+ } else {
1182
+ result = new Stat(name, type);
1183
+ }
1184
+ this.stats[name] = result;
1185
+ }
1186
+ return result;
1187
+ }
1188
+ };
1126
1189
 
1127
1190
  // ../loader-utils/src/lib/request-utils/request-scheduler.ts
1128
- var STAT_QUEUED_REQUESTS, STAT_ACTIVE_REQUESTS, STAT_CANCELLED_REQUESTS, STAT_QUEUED_REQUESTS_EVER, STAT_ACTIVE_REQUESTS_EVER, DEFAULT_PROPS2, RequestScheduler;
1129
- var init_request_scheduler = __esm({
1130
- "../loader-utils/src/lib/request-utils/request-scheduler.ts"() {
1131
- init_dist();
1132
- STAT_QUEUED_REQUESTS = "Queued Requests";
1133
- STAT_ACTIVE_REQUESTS = "Active Requests";
1134
- STAT_CANCELLED_REQUESTS = "Cancelled Requests";
1135
- STAT_QUEUED_REQUESTS_EVER = "Queued Requests Ever";
1136
- STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
1137
- DEFAULT_PROPS2 = {
1138
- id: "request-scheduler",
1139
- throttleRequests: true,
1140
- maxRequests: 6
1191
+ var STAT_QUEUED_REQUESTS = "Queued Requests";
1192
+ var STAT_ACTIVE_REQUESTS = "Active Requests";
1193
+ var STAT_CANCELLED_REQUESTS = "Cancelled Requests";
1194
+ var STAT_QUEUED_REQUESTS_EVER = "Queued Requests Ever";
1195
+ var STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
1196
+ var DEFAULT_PROPS2 = {
1197
+ id: "request-scheduler",
1198
+ // Specifies if the request scheduler should throttle incoming requests, mainly for comparative testing
1199
+ throttleRequests: true,
1200
+ // The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit.
1201
+ maxRequests: 6
1202
+ };
1203
+ var RequestScheduler = class {
1204
+ activeRequestCount = 0;
1205
+ /** Tracks the number of active requests and prioritizes/cancels queued requests. */
1206
+ requestQueue = [];
1207
+ requestMap = /* @__PURE__ */ new Map();
1208
+ deferredUpdate = null;
1209
+ constructor(props = {}) {
1210
+ this.props = {
1211
+ ...DEFAULT_PROPS2,
1212
+ ...props
1141
1213
  };
1142
- RequestScheduler = class {
1143
- constructor(props = {}) {
1144
- this.activeRequestCount = 0;
1145
- this.requestQueue = [];
1146
- this.requestMap = new Map();
1147
- this.deferredUpdate = null;
1148
- this.props = { ...DEFAULT_PROPS2, ...props };
1149
- this.stats = new Stats({ id: this.props.id });
1150
- this.stats.get(STAT_QUEUED_REQUESTS);
1151
- this.stats.get(STAT_ACTIVE_REQUESTS);
1152
- this.stats.get(STAT_CANCELLED_REQUESTS);
1153
- this.stats.get(STAT_QUEUED_REQUESTS_EVER);
1154
- this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
1155
- }
1156
- scheduleRequest(handle, getPriority = () => 0) {
1157
- if (!this.props.throttleRequests) {
1158
- return Promise.resolve({ done: () => {
1159
- } });
1160
- }
1161
- if (this.requestMap.has(handle)) {
1162
- return this.requestMap.get(handle);
1214
+ this.stats = new Stats({
1215
+ id: this.props.id
1216
+ });
1217
+ this.stats.get(STAT_QUEUED_REQUESTS);
1218
+ this.stats.get(STAT_ACTIVE_REQUESTS);
1219
+ this.stats.get(STAT_CANCELLED_REQUESTS);
1220
+ this.stats.get(STAT_QUEUED_REQUESTS_EVER);
1221
+ this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
1222
+ }
1223
+ /**
1224
+ * Called by an application that wants to issue a request, without having it deeply queued by the browser
1225
+ *
1226
+ * When the returned promise resolved, it is OK for the application to issue a request.
1227
+ * The promise resolves to an object that contains a `done` method.
1228
+ * When the application's request has completed (or failed), the application must call the `done` function
1229
+ *
1230
+ * @param handle
1231
+ * @param getPriority will be called when request "slots" open up,
1232
+ * allowing the caller to update priority or cancel the request
1233
+ * Highest priority executes first, priority < 0 cancels the request
1234
+ * @returns a promise
1235
+ * - resolves to a object (with a `done` field) when the request can be issued without queueing,
1236
+ * - resolves to `null` if the request has been cancelled (by the callback return < 0).
1237
+ * In this case the application should not issue the request
1238
+ */
1239
+ scheduleRequest(handle, getPriority = () => 0) {
1240
+ if (!this.props.throttleRequests) {
1241
+ return Promise.resolve({
1242
+ done: () => {
1163
1243
  }
1164
- const request = { handle, priority: 0, getPriority };
1165
- const promise = new Promise((resolve2) => {
1166
- request.resolve = resolve2;
1167
- return request;
1168
- });
1169
- this.requestQueue.push(request);
1170
- this.requestMap.set(handle, promise);
1244
+ });
1245
+ }
1246
+ if (this.requestMap.has(handle)) {
1247
+ return this.requestMap.get(handle);
1248
+ }
1249
+ const request = {
1250
+ handle,
1251
+ priority: 0,
1252
+ getPriority
1253
+ };
1254
+ const promise = new Promise((resolve2) => {
1255
+ request.resolve = resolve2;
1256
+ return request;
1257
+ });
1258
+ this.requestQueue.push(request);
1259
+ this.requestMap.set(handle, promise);
1260
+ this._issueNewRequests();
1261
+ return promise;
1262
+ }
1263
+ // PRIVATE
1264
+ _issueRequest(request) {
1265
+ const {
1266
+ handle,
1267
+ resolve: resolve2
1268
+ } = request;
1269
+ let isDone = false;
1270
+ const done = () => {
1271
+ if (!isDone) {
1272
+ isDone = true;
1273
+ this.requestMap.delete(handle);
1274
+ this.activeRequestCount--;
1171
1275
  this._issueNewRequests();
1172
- return promise;
1173
- }
1174
- _issueRequest(request) {
1175
- const { handle, resolve: resolve2 } = request;
1176
- let isDone = false;
1177
- const done = () => {
1178
- if (!isDone) {
1179
- isDone = true;
1180
- this.requestMap.delete(handle);
1181
- this.activeRequestCount--;
1182
- this._issueNewRequests();
1183
- }
1184
- };
1185
- this.activeRequestCount++;
1186
- return resolve2 ? resolve2({ done }) : Promise.resolve({ done });
1187
- }
1188
- _issueNewRequests() {
1189
- if (!this.deferredUpdate) {
1190
- this.deferredUpdate = setTimeout(() => this._issueNewRequestsAsync(), 0);
1191
- }
1192
- }
1193
- _issueNewRequestsAsync() {
1194
- this.deferredUpdate = null;
1195
- const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0);
1196
- if (freeSlots === 0) {
1197
- return;
1198
- }
1199
- this._updateAllRequests();
1200
- for (let i = 0; i < freeSlots; ++i) {
1201
- const request = this.requestQueue.shift();
1202
- if (request) {
1203
- this._issueRequest(request);
1204
- }
1205
- }
1206
1276
  }
1207
- _updateAllRequests() {
1208
- const requestQueue = this.requestQueue;
1209
- for (let i = 0; i < requestQueue.length; ++i) {
1210
- const request = requestQueue[i];
1211
- if (!this._updateRequest(request)) {
1212
- requestQueue.splice(i, 1);
1213
- this.requestMap.delete(request.handle);
1214
- i--;
1215
- }
1216
- }
1217
- requestQueue.sort((a, b) => a.priority - b.priority);
1277
+ };
1278
+ this.activeRequestCount++;
1279
+ return resolve2 ? resolve2({
1280
+ done
1281
+ }) : Promise.resolve({
1282
+ done
1283
+ });
1284
+ }
1285
+ /** We check requests asynchronously, to prevent multiple updates */
1286
+ _issueNewRequests() {
1287
+ if (!this.deferredUpdate) {
1288
+ this.deferredUpdate = setTimeout(() => this._issueNewRequestsAsync(), 0);
1289
+ }
1290
+ }
1291
+ /** Refresh all requests */
1292
+ _issueNewRequestsAsync() {
1293
+ this.deferredUpdate = null;
1294
+ const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0);
1295
+ if (freeSlots === 0) {
1296
+ return;
1297
+ }
1298
+ this._updateAllRequests();
1299
+ for (let i = 0; i < freeSlots; ++i) {
1300
+ const request = this.requestQueue.shift();
1301
+ if (request) {
1302
+ this._issueRequest(request);
1218
1303
  }
1219
- _updateRequest(request) {
1220
- request.priority = request.getPriority(request.handle);
1221
- if (request.priority < 0) {
1222
- request.resolve(null);
1223
- return false;
1224
- }
1225
- return true;
1304
+ }
1305
+ }
1306
+ /** Ensure all requests have updated priorities, and that no longer valid requests are cancelled */
1307
+ _updateAllRequests() {
1308
+ const requestQueue = this.requestQueue;
1309
+ for (let i = 0; i < requestQueue.length; ++i) {
1310
+ const request = requestQueue[i];
1311
+ if (!this._updateRequest(request)) {
1312
+ requestQueue.splice(i, 1);
1313
+ this.requestMap.delete(request.handle);
1314
+ i--;
1226
1315
  }
1227
- };
1316
+ }
1317
+ requestQueue.sort((a, b) => a.priority - b.priority);
1228
1318
  }
1229
- });
1319
+ /** Update a single request by calling the callback */
1320
+ _updateRequest(request) {
1321
+ request.priority = request.getPriority(request.handle);
1322
+ if (request.priority < 0) {
1323
+ request.resolve(null);
1324
+ return false;
1325
+ }
1326
+ return true;
1327
+ }
1328
+ };
1230
1329
 
1231
1330
  // ../loader-utils/src/lib/path-utils/file-aliases.ts
1331
+ var pathPrefix = "";
1332
+ var fileAliases = {};
1232
1333
  function setPathPrefix(prefix) {
1233
1334
  pathPrefix = prefix;
1234
1335
  }
@@ -1247,57 +1348,35 @@
1247
1348
  }
1248
1349
  return filename2;
1249
1350
  }
1250
- var pathPrefix, fileAliases;
1251
- var init_file_aliases = __esm({
1252
- "../loader-utils/src/lib/path-utils/file-aliases.ts"() {
1253
- pathPrefix = "";
1254
- fileAliases = {};
1255
- }
1256
- });
1257
1351
 
1258
1352
  // ../loader-utils/src/json-loader.ts
1353
+ var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1354
+ var JSONLoader = {
1355
+ name: "JSON",
1356
+ id: "json",
1357
+ module: "json",
1358
+ version: VERSION2,
1359
+ extensions: ["json", "geojson"],
1360
+ mimeTypes: ["application/json"],
1361
+ category: "json",
1362
+ text: true,
1363
+ parseTextSync,
1364
+ parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),
1365
+ options: {}
1366
+ };
1259
1367
  function parseTextSync(text) {
1260
1368
  return JSON.parse(text);
1261
1369
  }
1262
- var VERSION2, JSONLoader;
1263
- var init_json_loader = __esm({
1264
- "../loader-utils/src/json-loader.ts"() {
1265
- VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1266
- JSONLoader = {
1267
- name: "JSON",
1268
- id: "json",
1269
- module: "json",
1270
- version: VERSION2,
1271
- extensions: ["json", "geojson"],
1272
- mimeTypes: ["application/json"],
1273
- category: "json",
1274
- text: true,
1275
- parseTextSync,
1276
- parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),
1277
- options: {}
1278
- };
1279
- }
1280
- });
1281
1370
 
1282
1371
  // ../loader-utils/src/lib/node/buffer.browser.ts
1283
1372
  function toArrayBuffer(buffer) {
1284
1373
  return buffer;
1285
- }
1286
- function toBuffer(binaryData) {
1287
- throw new Error("Buffer not supported in browser");
1288
- }
1289
- var init_buffer_browser = __esm({
1290
- "../loader-utils/src/lib/node/buffer.browser.ts"() {
1291
- }
1292
- });
1374
+ }
1293
1375
 
1294
1376
  // ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
1295
1377
  function isBuffer(value) {
1296
1378
  return value && typeof value === "object" && value.isBuffer;
1297
1379
  }
1298
- function toBuffer2(data) {
1299
- return toBuffer ? toBuffer(data) : data;
1300
- }
1301
1380
  function toArrayBuffer2(data) {
1302
1381
  if (isBuffer(data)) {
1303
1382
  return toArrayBuffer(data);
@@ -1321,10 +1400,14 @@
1321
1400
  }
1322
1401
  throw new Error("toArrayBuffer");
1323
1402
  }
1324
- var init_memory_conversion_utils = __esm({
1325
- "../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts"() {
1326
- init_buffer_browser();
1327
- }
1403
+
1404
+ // ../loader-utils/src/lib/path-utils/path.ts
1405
+ var path_exports = {};
1406
+ __export(path_exports, {
1407
+ dirname: () => dirname,
1408
+ filename: () => filename,
1409
+ join: () => join,
1410
+ resolve: () => resolve
1328
1411
  });
1329
1412
 
1330
1413
  // ../loader-utils/src/lib/path-utils/get-cwd.ts
@@ -1335,19 +1418,8 @@
1335
1418
  const pathname = window.location?.pathname;
1336
1419
  return pathname?.slice(0, pathname.lastIndexOf("/") + 1) || "";
1337
1420
  }
1338
- var init_get_cwd = __esm({
1339
- "../loader-utils/src/lib/path-utils/get-cwd.ts"() {
1340
- }
1341
- });
1342
1421
 
1343
1422
  // ../loader-utils/src/lib/path-utils/path.ts
1344
- var path_exports = {};
1345
- __export(path_exports, {
1346
- dirname: () => dirname,
1347
- filename: () => filename,
1348
- join: () => join,
1349
- resolve: () => resolve
1350
- });
1351
1423
  function filename(url) {
1352
1424
  const slashIndex = url ? url.lastIndexOf("/") : -1;
1353
1425
  return slashIndex >= 0 ? url.substr(slashIndex + 1) : "";
@@ -1401,6 +1473,8 @@
1401
1473
  }
1402
1474
  return ".";
1403
1475
  }
1476
+ var SLASH = 47;
1477
+ var DOT = 46;
1404
1478
  function normalizeStringPosix(path, allowAboveRoot) {
1405
1479
  let res = "";
1406
1480
  let lastSlash = -1;
@@ -1469,72 +1543,84 @@
1469
1543
  }
1470
1544
  return res;
1471
1545
  }
1472
- var SLASH, DOT;
1473
- var init_path = __esm({
1474
- "../loader-utils/src/lib/path-utils/path.ts"() {
1475
- init_get_cwd();
1476
- SLASH = 47;
1477
- DOT = 46;
1478
- }
1479
- });
1480
1546
 
1481
- // ../loader-utils/src/lib/node/fs.browser.ts
1482
- var fs_browser_exports = {};
1483
- __export(fs_browser_exports, {
1484
- isSupported: () => isSupported
1485
- });
1486
- var isSupported;
1487
- var init_fs_browser = __esm({
1488
- "../loader-utils/src/lib/node/fs.browser.ts"() {
1489
- isSupported = false;
1547
+ // ../loader-utils/src/lib/files/blob-file.ts
1548
+ var BlobFile = class {
1549
+ constructor(blob) {
1550
+ this.handle = blob instanceof ArrayBuffer ? new Blob([blob]) : blob;
1551
+ this.size = blob instanceof ArrayBuffer ? blob.byteLength : blob.size;
1552
+ this.bigsize = BigInt(this.size);
1553
+ this.url = blob instanceof File ? blob.name : "";
1490
1554
  }
1491
- });
1555
+ async close() {
1556
+ }
1557
+ async stat() {
1558
+ return {
1559
+ size: this.handle.size,
1560
+ bigsize: BigInt(this.handle.size),
1561
+ isDirectory: false
1562
+ };
1563
+ }
1564
+ async read(start, length) {
1565
+ const arrayBuffer = await this.handle.slice(start, start + length).arrayBuffer();
1566
+ return arrayBuffer;
1567
+ }
1568
+ };
1492
1569
 
1493
- // ../loader-utils/src/index.ts
1494
- var init_src2 = __esm({
1495
- "../loader-utils/src/index.ts"() {
1496
- init_assert();
1497
- init_globals();
1498
- init_merge_loader_options();
1499
- init_parse_with_worker();
1500
- init_encode_with_worker();
1501
- init_array_buffer_utils();
1502
- init_text_iterators();
1503
- init_async_iteration();
1504
- init_request_scheduler();
1505
- init_file_aliases();
1506
- init_json_loader();
1507
- init_memory_conversion_utils();
1508
- init_path();
1509
- init_fs_browser();
1570
+ // ../loader-utils/src/lib/files/node-file-facade.ts
1571
+ var NOT_IMPLEMENTED = new Error("Not implemented");
1572
+ var NodeFileFacade = class {
1573
+ size = 0;
1574
+ bigsize = 0n;
1575
+ url = "";
1576
+ constructor(url, flags, mode) {
1577
+ if (globalThis.loaders?.NodeFile) {
1578
+ return new globalThis.loaders.NodeFile(url, flags, mode);
1579
+ }
1580
+ if (isBrowser) {
1581
+ throw new Error("Can't instantiate NodeFile in browser.");
1582
+ }
1583
+ throw new Error("Can't instantiate NodeFile. Make sure to import @loaders.gl/polyfills first.");
1510
1584
  }
1511
- });
1585
+ /** Read data */
1586
+ async read(start, end) {
1587
+ throw NOT_IMPLEMENTED;
1588
+ }
1589
+ /** Write to file. The number of bytes written will be returned */
1590
+ async write(arrayBuffer, offset, length) {
1591
+ throw NOT_IMPLEMENTED;
1592
+ }
1593
+ /** Get information about file */
1594
+ async stat() {
1595
+ throw NOT_IMPLEMENTED;
1596
+ }
1597
+ /** Close the file */
1598
+ async close() {
1599
+ }
1600
+ };
1512
1601
 
1513
1602
  // src/javascript-utils/is-type.ts
1514
- var isBoolean, isFunction, isObject, isPureObject, isPromise, isIterable, isAsyncIterable, isIterator, isResponse, isBlob, isBuffer2, isWritableDOMStream, isReadableDOMStream, isWritableNodeStream, isReadableNodeStream, isReadableStream, isWritableStream;
1515
- var init_is_type = __esm({
1516
- "src/javascript-utils/is-type.ts"() {
1517
- isBoolean = (x) => typeof x === "boolean";
1518
- isFunction = (x) => typeof x === "function";
1519
- isObject = (x) => x !== null && typeof x === "object";
1520
- isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
1521
- isPromise = (x) => isObject(x) && isFunction(x.then);
1522
- isIterable = (x) => Boolean(x) && typeof x[Symbol.iterator] === "function";
1523
- isAsyncIterable = (x) => x && typeof x[Symbol.asyncIterator] === "function";
1524
- isIterator = (x) => x && isFunction(x.next);
1525
- isResponse = (x) => typeof Response !== "undefined" && x instanceof Response || x && x.arrayBuffer && x.text && x.json;
1526
- isBlob = (x) => typeof Blob !== "undefined" && x instanceof Blob;
1527
- isBuffer2 = (x) => x && typeof x === "object" && x.isBuffer;
1528
- isWritableDOMStream = (x) => isObject(x) && isFunction(x.abort) && isFunction(x.getWriter);
1529
- isReadableDOMStream = (x) => typeof ReadableStream !== "undefined" && x instanceof ReadableStream || isObject(x) && isFunction(x.tee) && isFunction(x.cancel) && isFunction(x.getReader);
1530
- isWritableNodeStream = (x) => isObject(x) && isFunction(x.end) && isFunction(x.write) && isBoolean(x.writable);
1531
- isReadableNodeStream = (x) => isObject(x) && isFunction(x.read) && isFunction(x.pipe) && isBoolean(x.readable);
1532
- isReadableStream = (x) => isReadableDOMStream(x) || isReadableNodeStream(x);
1533
- isWritableStream = (x) => isWritableDOMStream(x) || isWritableNodeStream(x);
1534
- }
1535
- });
1603
+ var isBoolean = (x) => typeof x === "boolean";
1604
+ var isFunction = (x) => typeof x === "function";
1605
+ var isObject = (x) => x !== null && typeof x === "object";
1606
+ var isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
1607
+ var isPromise = (x) => isObject(x) && isFunction(x.then);
1608
+ var isIterable = (x) => Boolean(x) && typeof x[Symbol.iterator] === "function";
1609
+ var isAsyncIterable = (x) => x && typeof x[Symbol.asyncIterator] === "function";
1610
+ var isIterator = (x) => x && isFunction(x.next);
1611
+ var isResponse = (x) => typeof Response !== "undefined" && x instanceof Response || x && x.arrayBuffer && x.text && x.json;
1612
+ var isBlob = (x) => typeof Blob !== "undefined" && x instanceof Blob;
1613
+ var isBuffer2 = (x) => x && typeof x === "object" && x.isBuffer;
1614
+ var isWritableDOMStream = (x) => isObject(x) && isFunction(x.abort) && isFunction(x.getWriter);
1615
+ var isReadableDOMStream = (x) => typeof ReadableStream !== "undefined" && x instanceof ReadableStream || isObject(x) && isFunction(x.tee) && isFunction(x.cancel) && isFunction(x.getReader);
1616
+ var isWritableNodeStream = (x) => isObject(x) && isFunction(x.end) && isFunction(x.write) && isBoolean(x.writable);
1617
+ var isReadableNodeStream = (x) => isObject(x) && isFunction(x.read) && isFunction(x.pipe) && isBoolean(x.readable);
1618
+ var isReadableStream = (x) => isReadableDOMStream(x) || isReadableNodeStream(x);
1619
+ var isWritableStream = (x) => isWritableDOMStream(x) || isWritableNodeStream(x);
1536
1620
 
1537
1621
  // src/lib/utils/mime-type-utils.ts
1622
+ var DATA_URL_PATTERN = /^data:([-\w.]+\/[-\w.+]+)(;|,)/;
1623
+ var MIME_TYPE_PATTERN = /^([-\w.]+\/[-\w.+]+)/;
1538
1624
  function parseMIMEType(mimeString) {
1539
1625
  const matches3 = MIME_TYPE_PATTERN.exec(mimeString);
1540
1626
  if (matches3) {
@@ -1549,15 +1635,9 @@
1549
1635
  }
1550
1636
  return "";
1551
1637
  }
1552
- var DATA_URL_PATTERN, MIME_TYPE_PATTERN;
1553
- var init_mime_type_utils = __esm({
1554
- "src/lib/utils/mime-type-utils.ts"() {
1555
- DATA_URL_PATTERN = /^data:([-\w.]+\/[-\w.+]+)(;|,)/;
1556
- MIME_TYPE_PATTERN = /^([-\w.]+\/[-\w.+]+)/;
1557
- }
1558
- });
1559
1638
 
1560
1639
  // src/lib/utils/url-utils.ts
1640
+ var QUERY_STRING_PATTERN = /\?.*/;
1561
1641
  function extractQueryString(url) {
1562
1642
  const matches3 = url.match(QUERY_STRING_PATTERN);
1563
1643
  return matches3 && matches3[0];
@@ -1565,12 +1645,6 @@
1565
1645
  function stripQueryString(url) {
1566
1646
  return url.replace(QUERY_STRING_PATTERN, "");
1567
1647
  }
1568
- var QUERY_STRING_PATTERN;
1569
- var init_url_utils = __esm({
1570
- "src/lib/utils/url-utils.ts"() {
1571
- QUERY_STRING_PATTERN = /\?.*/;
1572
- }
1573
- });
1574
1648
 
1575
1649
  // src/lib/utils/resource-utils.ts
1576
1650
  function getResourceUrl(resource) {
@@ -1623,13 +1697,6 @@
1623
1697
  }
1624
1698
  return -1;
1625
1699
  }
1626
- var init_resource_utils = __esm({
1627
- "src/lib/utils/resource-utils.ts"() {
1628
- init_is_type();
1629
- init_mime_type_utils();
1630
- init_url_utils();
1631
- }
1632
- });
1633
1700
 
1634
1701
  // src/lib/utils/response-utils.ts
1635
1702
  async function makeResponse(resource) {
@@ -1653,8 +1720,12 @@
1653
1720
  if (typeof resource === "string") {
1654
1721
  resource = new TextEncoder().encode(resource);
1655
1722
  }
1656
- const response = new Response(resource, { headers });
1657
- Object.defineProperty(response, "url", { value: url });
1723
+ const response = new Response(resource, {
1724
+ headers
1725
+ });
1726
+ Object.defineProperty(response, "url", {
1727
+ value: url
1728
+ });
1658
1729
  return response;
1659
1730
  }
1660
1731
  async function checkResponse(response) {
@@ -1705,18 +1776,6 @@
1705
1776
  }
1706
1777
  return btoa(binary);
1707
1778
  }
1708
- var init_response_utils = __esm({
1709
- "src/lib/utils/response-utils.ts"() {
1710
- init_is_type();
1711
- init_resource_utils();
1712
- }
1713
- });
1714
-
1715
- // (disabled):src/lib/fetch/fetch-file.node
1716
- var require_fetch_file = __commonJS({
1717
- "(disabled):src/lib/fetch/fetch-file.node"() {
1718
- }
1719
- });
1720
1779
 
1721
1780
  // src/lib/fetch/fetch-file.ts
1722
1781
  function isNodePath(url) {
@@ -1731,27 +1790,18 @@
1731
1790
  async function fetchFile(urlOrData, fetchOptions) {
1732
1791
  if (typeof urlOrData === "string") {
1733
1792
  const url = resolvePath(urlOrData);
1734
- if (isNodePath(url) && node2?.fetchFileNode) {
1735
- return node2.fetchFileNode(url, fetchOptions);
1793
+ if (isNodePath(url)) {
1794
+ if (globalThis.loaders?.fetchNode) {
1795
+ return globalThis.loaders?.fetchNode(url, fetchOptions);
1796
+ }
1736
1797
  }
1737
1798
  return await fetch(url, fetchOptions);
1738
1799
  }
1739
1800
  return await makeResponse(urlOrData);
1740
1801
  }
1741
- var node2;
1742
- var init_fetch_file = __esm({
1743
- "src/lib/fetch/fetch-file.ts"() {
1744
- init_src2();
1745
- init_response_utils();
1746
- node2 = __toModule(require_fetch_file());
1747
- }
1748
- });
1749
1802
 
1750
1803
  // src/lib/fetch/read-array-buffer.ts
1751
1804
  async function readArrayBuffer(file, start, length) {
1752
- if (typeof file === "number") {
1753
- return await fs_browser_exports._readToArrayBuffer(file, start, length);
1754
- }
1755
1805
  if (!(file instanceof Blob)) {
1756
1806
  file = new Blob([file]);
1757
1807
  }
@@ -1766,52 +1816,6 @@
1766
1816
  fileReader.readAsArrayBuffer(blob);
1767
1817
  });
1768
1818
  }
1769
- var init_read_array_buffer = __esm({
1770
- "src/lib/fetch/read-array-buffer.ts"() {
1771
- init_src2();
1772
- }
1773
- });
1774
-
1775
- // src/lib/fetch/read-file.ts
1776
- function readFileSync(url, options = {}) {
1777
- url = resolvePath(url);
1778
- if (!isBrowser) {
1779
- const buffer = fs_browser_exports.readFileSync(url, options);
1780
- return typeof buffer !== "string" ? toArrayBuffer2(buffer) : buffer;
1781
- }
1782
- if (!options.nothrow) {
1783
- assert(false);
1784
- }
1785
- return null;
1786
- }
1787
- var init_read_file = __esm({
1788
- "src/lib/fetch/read-file.ts"() {
1789
- init_src2();
1790
- init_src2();
1791
- }
1792
- });
1793
-
1794
- // src/lib/fetch/write-file.ts
1795
- async function writeFile(filePath, arrayBufferOrString, options) {
1796
- filePath = resolvePath(filePath);
1797
- if (!isBrowser) {
1798
- await fs_browser_exports.writeFile(filePath, toBuffer2(arrayBufferOrString), { flag: "w" });
1799
- }
1800
- assert(false);
1801
- }
1802
- function writeFileSync(filePath, arrayBufferOrString, options) {
1803
- filePath = resolvePath(filePath);
1804
- if (!isBrowser) {
1805
- fs_browser_exports.writeFileSync(filePath, toBuffer2(arrayBufferOrString), { flag: "w" });
1806
- }
1807
- assert(false);
1808
- }
1809
- var init_write_file = __esm({
1810
- "src/lib/fetch/write-file.ts"() {
1811
- init_src2();
1812
- init_src2();
1813
- }
1814
- });
1815
1819
 
1816
1820
  // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
1817
1821
  function isElectron(mockUserAgent) {
@@ -1828,53 +1832,24 @@
1828
1832
  }
1829
1833
  return false;
1830
1834
  }
1831
- var init_is_electron = __esm({
1832
- "../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js"() {
1833
- }
1834
- });
1835
1835
 
1836
1836
  // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
1837
1837
  function isBrowser3() {
1838
1838
  const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
1839
1839
  return !isNode || isElectron();
1840
1840
  }
1841
- var init_is_browser = __esm({
1842
- "../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js"() {
1843
- init_is_electron();
1844
- }
1845
- });
1846
1841
 
1847
1842
  // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
1848
- var self_3, window_3, document_3, process_, console_, navigator_;
1849
- var init_globals3 = __esm({
1850
- "../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js"() {
1851
- self_3 = globalThis.self || globalThis.window || globalThis.global;
1852
- window_3 = globalThis.window || globalThis.self || globalThis.global;
1853
- document_3 = globalThis.document || {};
1854
- process_ = globalThis.process || {};
1855
- console_ = globalThis.console;
1856
- navigator_ = globalThis.navigator || {};
1857
- }
1858
- });
1843
+ var self_3 = globalThis.self || globalThis.window || globalThis.global;
1844
+ var window_3 = globalThis.window || globalThis.self || globalThis.global;
1845
+ var document_3 = globalThis.document || {};
1846
+ var process_ = globalThis.process || {};
1847
+ var console_ = globalThis.console;
1848
+ var navigator_ = globalThis.navigator || {};
1859
1849
 
1860
1850
  // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
1861
- var VERSION3, isBrowser4;
1862
- var init_globals4 = __esm({
1863
- "../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js"() {
1864
- init_is_browser();
1865
- VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
1866
- isBrowser4 = isBrowser3();
1867
- }
1868
- });
1869
-
1870
- // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/index.js
1871
- var init_dist2 = __esm({
1872
- "../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/index.js"() {
1873
- init_globals4();
1874
- init_globals3();
1875
- init_is_browser();
1876
- }
1877
- });
1851
+ var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
1852
+ var isBrowser4 = isBrowser3();
1878
1853
 
1879
1854
  // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
1880
1855
  function getStorage(type) {
@@ -1888,43 +1863,37 @@
1888
1863
  return null;
1889
1864
  }
1890
1865
  }
1891
- var LocalStorage;
1892
- var init_local_storage = __esm({
1893
- "../../node_modules/@probe.gl/log/dist/utils/local-storage.js"() {
1894
- init_defineProperty();
1895
- LocalStorage = class {
1896
- constructor(id, defaultConfig) {
1897
- let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
1898
- _defineProperty(this, "storage", void 0);
1899
- _defineProperty(this, "id", void 0);
1900
- _defineProperty(this, "config", void 0);
1901
- this.storage = getStorage(type);
1902
- this.id = id;
1903
- this.config = defaultConfig;
1904
- this._loadConfiguration();
1905
- }
1906
- getConfiguration() {
1907
- return this.config;
1908
- }
1909
- setConfiguration(configuration) {
1910
- Object.assign(this.config, configuration);
1911
- if (this.storage) {
1912
- const serialized = JSON.stringify(this.config);
1913
- this.storage.setItem(this.id, serialized);
1914
- }
1915
- }
1916
- _loadConfiguration() {
1917
- let configuration = {};
1918
- if (this.storage) {
1919
- const serializedConfiguration = this.storage.getItem(this.id);
1920
- configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
1921
- }
1922
- Object.assign(this.config, configuration);
1923
- return this;
1924
- }
1925
- };
1866
+ var LocalStorage = class {
1867
+ constructor(id, defaultConfig) {
1868
+ let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
1869
+ _defineProperty(this, "storage", void 0);
1870
+ _defineProperty(this, "id", void 0);
1871
+ _defineProperty(this, "config", void 0);
1872
+ this.storage = getStorage(type);
1873
+ this.id = id;
1874
+ this.config = defaultConfig;
1875
+ this._loadConfiguration();
1876
+ }
1877
+ getConfiguration() {
1878
+ return this.config;
1879
+ }
1880
+ setConfiguration(configuration) {
1881
+ Object.assign(this.config, configuration);
1882
+ if (this.storage) {
1883
+ const serialized = JSON.stringify(this.config);
1884
+ this.storage.setItem(this.id, serialized);
1885
+ }
1926
1886
  }
1927
- });
1887
+ _loadConfiguration() {
1888
+ let configuration = {};
1889
+ if (this.storage) {
1890
+ const serializedConfiguration = this.storage.getItem(this.id);
1891
+ configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
1892
+ }
1893
+ Object.assign(this.config, configuration);
1894
+ return this;
1895
+ }
1896
+ };
1928
1897
 
1929
1898
  // ../../node_modules/@probe.gl/log/dist/utils/formatters.js
1930
1899
  function formatTime(ms) {
@@ -1956,12 +1925,28 @@
1956
1925
  const style = ["font-size:1px;", "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), "color:transparent;"].join("");
1957
1926
  return ["".concat(message, " %c+"), style];
1958
1927
  }
1959
- var init_formatters = __esm({
1960
- "../../node_modules/@probe.gl/log/dist/utils/formatters.js"() {
1961
- }
1962
- });
1963
1928
 
1964
1929
  // ../../node_modules/@probe.gl/log/dist/utils/color.js
1930
+ var COLOR;
1931
+ (function(COLOR2) {
1932
+ COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
1933
+ COLOR2[COLOR2["RED"] = 31] = "RED";
1934
+ COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
1935
+ COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
1936
+ COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
1937
+ COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
1938
+ COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
1939
+ COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
1940
+ COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
1941
+ COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
1942
+ COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
1943
+ COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
1944
+ COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
1945
+ COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
1946
+ COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
1947
+ COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
1948
+ })(COLOR || (COLOR = {}));
1949
+ var BACKGROUND_INCREMENT = 10;
1965
1950
  function getColor(color) {
1966
1951
  if (typeof color !== "string") {
1967
1952
  return color;
@@ -1973,40 +1958,15 @@
1973
1958
  if (!isBrowser3 && typeof string === "string") {
1974
1959
  if (color) {
1975
1960
  const colorCode = getColor(color);
1976
- string = "[".concat(colorCode, "m").concat(string, "");
1961
+ string = "\x1B[".concat(colorCode, "m").concat(string, "\x1B[39m");
1977
1962
  }
1978
1963
  if (background) {
1979
1964
  const colorCode = getColor(background);
1980
- string = "[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "");
1965
+ string = "\x1B[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "\x1B[49m");
1981
1966
  }
1982
1967
  }
1983
1968
  return string;
1984
1969
  }
1985
- var COLOR, BACKGROUND_INCREMENT;
1986
- var init_color = __esm({
1987
- "../../node_modules/@probe.gl/log/dist/utils/color.js"() {
1988
- init_dist2();
1989
- (function(COLOR2) {
1990
- COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
1991
- COLOR2[COLOR2["RED"] = 31] = "RED";
1992
- COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
1993
- COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
1994
- COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
1995
- COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
1996
- COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
1997
- COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
1998
- COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
1999
- COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
2000
- COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
2001
- COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
2002
- COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
2003
- COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
2004
- COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
2005
- COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
2006
- })(COLOR || (COLOR = {}));
2007
- BACKGROUND_INCREMENT = 10;
2008
- }
2009
- });
2010
1970
 
2011
1971
  // ../../node_modules/@probe.gl/log/dist/utils/autobind.js
2012
1972
  function autobind(obj) {
@@ -2023,10 +1983,6 @@
2023
1983
  }
2024
1984
  }
2025
1985
  }
2026
- var init_autobind = __esm({
2027
- "../../node_modules/@probe.gl/log/dist/utils/autobind.js"() {
2028
- }
2029
- });
2030
1986
 
2031
1987
  // ../../node_modules/@probe.gl/log/dist/utils/assert.js
2032
1988
  function assert3(condition, message) {
@@ -2034,10 +1990,6 @@
2034
1990
  throw new Error(message || "Assertion failed");
2035
1991
  }
2036
1992
  }
2037
- var init_assert3 = __esm({
2038
- "../../node_modules/@probe.gl/log/dist/utils/assert.js"() {
2039
- }
2040
- });
2041
1993
 
2042
1994
  // ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
2043
1995
  function getHiResTimestamp2() {
@@ -2054,15 +2006,237 @@
2054
2006
  }
2055
2007
  return timestamp;
2056
2008
  }
2057
- var init_hi_res_timestamp2 = __esm({
2058
- "../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js"() {
2059
- init_dist2();
2060
- }
2061
- });
2062
2009
 
2063
2010
  // ../../node_modules/@probe.gl/log/dist/log.js
2011
+ var originalConsole = {
2012
+ debug: isBrowser3() ? console.debug || console.log : console.log,
2013
+ log: console.log,
2014
+ info: console.info,
2015
+ warn: console.warn,
2016
+ error: console.error
2017
+ };
2018
+ var DEFAULT_LOG_CONFIGURATION = {
2019
+ enabled: true,
2020
+ level: 0
2021
+ };
2064
2022
  function noop() {
2065
2023
  }
2024
+ var cache = {};
2025
+ var ONCE = {
2026
+ once: true
2027
+ };
2028
+ var Log = class {
2029
+ constructor() {
2030
+ let {
2031
+ id
2032
+ } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
2033
+ id: ""
2034
+ };
2035
+ _defineProperty(this, "id", void 0);
2036
+ _defineProperty(this, "VERSION", VERSION3);
2037
+ _defineProperty(this, "_startTs", getHiResTimestamp2());
2038
+ _defineProperty(this, "_deltaTs", getHiResTimestamp2());
2039
+ _defineProperty(this, "_storage", void 0);
2040
+ _defineProperty(this, "userData", {});
2041
+ _defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
2042
+ this.id = id;
2043
+ this.userData = {};
2044
+ this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
2045
+ this.timeStamp("".concat(this.id, " started"));
2046
+ autobind(this);
2047
+ Object.seal(this);
2048
+ }
2049
+ set level(newLevel) {
2050
+ this.setLevel(newLevel);
2051
+ }
2052
+ get level() {
2053
+ return this.getLevel();
2054
+ }
2055
+ isEnabled() {
2056
+ return this._storage.config.enabled;
2057
+ }
2058
+ getLevel() {
2059
+ return this._storage.config.level;
2060
+ }
2061
+ getTotal() {
2062
+ return Number((getHiResTimestamp2() - this._startTs).toPrecision(10));
2063
+ }
2064
+ getDelta() {
2065
+ return Number((getHiResTimestamp2() - this._deltaTs).toPrecision(10));
2066
+ }
2067
+ set priority(newPriority) {
2068
+ this.level = newPriority;
2069
+ }
2070
+ get priority() {
2071
+ return this.level;
2072
+ }
2073
+ getPriority() {
2074
+ return this.level;
2075
+ }
2076
+ enable() {
2077
+ let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
2078
+ this._storage.setConfiguration({
2079
+ enabled
2080
+ });
2081
+ return this;
2082
+ }
2083
+ setLevel(level) {
2084
+ this._storage.setConfiguration({
2085
+ level
2086
+ });
2087
+ return this;
2088
+ }
2089
+ get(setting) {
2090
+ return this._storage.config[setting];
2091
+ }
2092
+ set(setting, value) {
2093
+ this._storage.setConfiguration({
2094
+ [setting]: value
2095
+ });
2096
+ }
2097
+ settings() {
2098
+ if (console.table) {
2099
+ console.table(this._storage.config);
2100
+ } else {
2101
+ console.log(this._storage.config);
2102
+ }
2103
+ }
2104
+ assert(condition, message) {
2105
+ assert3(condition, message);
2106
+ }
2107
+ warn(message) {
2108
+ return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
2109
+ }
2110
+ error(message) {
2111
+ return this._getLogFunction(0, message, originalConsole.error, arguments);
2112
+ }
2113
+ deprecated(oldUsage, newUsage) {
2114
+ return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
2115
+ }
2116
+ removed(oldUsage, newUsage) {
2117
+ return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
2118
+ }
2119
+ probe(logLevel, message) {
2120
+ return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
2121
+ time: true,
2122
+ once: true
2123
+ });
2124
+ }
2125
+ log(logLevel, message) {
2126
+ return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
2127
+ }
2128
+ info(logLevel, message) {
2129
+ return this._getLogFunction(logLevel, message, console.info, arguments);
2130
+ }
2131
+ once(logLevel, message) {
2132
+ return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
2133
+ }
2134
+ table(logLevel, table, columns) {
2135
+ if (table) {
2136
+ return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
2137
+ tag: getTableHeader(table)
2138
+ });
2139
+ }
2140
+ return noop;
2141
+ }
2142
+ image(_ref) {
2143
+ let {
2144
+ logLevel,
2145
+ priority,
2146
+ image,
2147
+ message = "",
2148
+ scale = 1
2149
+ } = _ref;
2150
+ if (!this._shouldLog(logLevel || priority)) {
2151
+ return noop;
2152
+ }
2153
+ return isBrowser3() ? logImageInBrowser({
2154
+ image,
2155
+ message,
2156
+ scale
2157
+ }) : logImageInNode({
2158
+ image,
2159
+ message,
2160
+ scale
2161
+ });
2162
+ }
2163
+ time(logLevel, message) {
2164
+ return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
2165
+ }
2166
+ timeEnd(logLevel, message) {
2167
+ return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
2168
+ }
2169
+ timeStamp(logLevel, message) {
2170
+ return this._getLogFunction(logLevel, message, console.timeStamp || noop);
2171
+ }
2172
+ group(logLevel, message) {
2173
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
2174
+ collapsed: false
2175
+ };
2176
+ const options = normalizeArguments({
2177
+ logLevel,
2178
+ message,
2179
+ opts
2180
+ });
2181
+ const {
2182
+ collapsed
2183
+ } = opts;
2184
+ options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
2185
+ return this._getLogFunction(options);
2186
+ }
2187
+ groupCollapsed(logLevel, message) {
2188
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2189
+ return this.group(logLevel, message, Object.assign({}, opts, {
2190
+ collapsed: true
2191
+ }));
2192
+ }
2193
+ groupEnd(logLevel) {
2194
+ return this._getLogFunction(logLevel, "", console.groupEnd || noop);
2195
+ }
2196
+ withGroup(logLevel, message, func) {
2197
+ this.group(logLevel, message)();
2198
+ try {
2199
+ func();
2200
+ } finally {
2201
+ this.groupEnd(logLevel)();
2202
+ }
2203
+ }
2204
+ trace() {
2205
+ if (console.trace) {
2206
+ console.trace();
2207
+ }
2208
+ }
2209
+ _shouldLog(logLevel) {
2210
+ return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
2211
+ }
2212
+ _getLogFunction(logLevel, message, method, args, opts) {
2213
+ if (this._shouldLog(logLevel)) {
2214
+ opts = normalizeArguments({
2215
+ logLevel,
2216
+ message,
2217
+ args,
2218
+ opts
2219
+ });
2220
+ method = method || opts.method;
2221
+ assert3(method);
2222
+ opts.total = this.getTotal();
2223
+ opts.delta = this.getDelta();
2224
+ this._deltaTs = getHiResTimestamp2();
2225
+ const tag = opts.tag || opts.message;
2226
+ if (opts.once && tag) {
2227
+ if (!cache[tag]) {
2228
+ cache[tag] = getHiResTimestamp2();
2229
+ } else {
2230
+ return noop;
2231
+ }
2232
+ }
2233
+ message = decorateMessage(this.id, opts.message, opts);
2234
+ return method.bind(console, message, ...opts.args);
2235
+ }
2236
+ return noop;
2237
+ }
2238
+ };
2239
+ _defineProperty(Log, "VERSION", VERSION3);
2066
2240
  function normalizeLogLevel(logLevel) {
2067
2241
  if (!logLevel) {
2068
2242
  return 0;
@@ -2124,400 +2298,156 @@
2124
2298
  let {
2125
2299
  image,
2126
2300
  message = "",
2127
- scale = 1
2128
- } = _ref2;
2129
- console.warn("removed");
2130
- return noop;
2131
- }
2132
- function logImageInBrowser(_ref3) {
2133
- let {
2134
- image,
2135
- message = "",
2136
- scale = 1
2137
- } = _ref3;
2138
- if (typeof image === "string") {
2139
- const img = new Image();
2140
- img.onload = () => {
2141
- const args = formatImage(img, message, scale);
2142
- console.log(...args);
2143
- };
2144
- img.src = image;
2145
- return noop;
2146
- }
2147
- const element = image.nodeName || "";
2148
- if (element.toLowerCase() === "img") {
2149
- console.log(...formatImage(image, message, scale));
2150
- return noop;
2151
- }
2152
- if (element.toLowerCase() === "canvas") {
2153
- const img = new Image();
2154
- img.onload = () => console.log(...formatImage(img, message, scale));
2155
- img.src = image.toDataURL();
2156
- return noop;
2157
- }
2158
- return noop;
2159
- }
2160
- function getTableHeader(table) {
2161
- for (const key in table) {
2162
- for (const title in table[key]) {
2163
- return title || "untitled";
2164
- }
2165
- }
2166
- return "empty";
2167
- }
2168
- var originalConsole, DEFAULT_LOG_CONFIGURATION, cache, ONCE, Log;
2169
- var init_log = __esm({
2170
- "../../node_modules/@probe.gl/log/dist/log.js"() {
2171
- init_defineProperty();
2172
- init_dist2();
2173
- init_local_storage();
2174
- init_formatters();
2175
- init_color();
2176
- init_autobind();
2177
- init_assert3();
2178
- init_hi_res_timestamp2();
2179
- originalConsole = {
2180
- debug: isBrowser3() ? console.debug || console.log : console.log,
2181
- log: console.log,
2182
- info: console.info,
2183
- warn: console.warn,
2184
- error: console.error
2185
- };
2186
- DEFAULT_LOG_CONFIGURATION = {
2187
- enabled: true,
2188
- level: 0
2189
- };
2190
- cache = {};
2191
- ONCE = {
2192
- once: true
2193
- };
2194
- Log = class {
2195
- constructor() {
2196
- let {
2197
- id
2198
- } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
2199
- id: ""
2200
- };
2201
- _defineProperty(this, "id", void 0);
2202
- _defineProperty(this, "VERSION", VERSION3);
2203
- _defineProperty(this, "_startTs", getHiResTimestamp2());
2204
- _defineProperty(this, "_deltaTs", getHiResTimestamp2());
2205
- _defineProperty(this, "_storage", void 0);
2206
- _defineProperty(this, "userData", {});
2207
- _defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
2208
- this.id = id;
2209
- this.userData = {};
2210
- this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
2211
- this.timeStamp("".concat(this.id, " started"));
2212
- autobind(this);
2213
- Object.seal(this);
2214
- }
2215
- set level(newLevel) {
2216
- this.setLevel(newLevel);
2217
- }
2218
- get level() {
2219
- return this.getLevel();
2220
- }
2221
- isEnabled() {
2222
- return this._storage.config.enabled;
2223
- }
2224
- getLevel() {
2225
- return this._storage.config.level;
2226
- }
2227
- getTotal() {
2228
- return Number((getHiResTimestamp2() - this._startTs).toPrecision(10));
2229
- }
2230
- getDelta() {
2231
- return Number((getHiResTimestamp2() - this._deltaTs).toPrecision(10));
2232
- }
2233
- set priority(newPriority) {
2234
- this.level = newPriority;
2235
- }
2236
- get priority() {
2237
- return this.level;
2238
- }
2239
- getPriority() {
2240
- return this.level;
2241
- }
2242
- enable() {
2243
- let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
2244
- this._storage.setConfiguration({
2245
- enabled
2246
- });
2247
- return this;
2248
- }
2249
- setLevel(level) {
2250
- this._storage.setConfiguration({
2251
- level
2252
- });
2253
- return this;
2254
- }
2255
- get(setting) {
2256
- return this._storage.config[setting];
2257
- }
2258
- set(setting, value) {
2259
- this._storage.setConfiguration({
2260
- [setting]: value
2261
- });
2262
- }
2263
- settings() {
2264
- if (console.table) {
2265
- console.table(this._storage.config);
2266
- } else {
2267
- console.log(this._storage.config);
2268
- }
2269
- }
2270
- assert(condition, message) {
2271
- assert3(condition, message);
2272
- }
2273
- warn(message) {
2274
- return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
2275
- }
2276
- error(message) {
2277
- return this._getLogFunction(0, message, originalConsole.error, arguments);
2278
- }
2279
- deprecated(oldUsage, newUsage) {
2280
- return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
2281
- }
2282
- removed(oldUsage, newUsage) {
2283
- return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
2284
- }
2285
- probe(logLevel, message) {
2286
- return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
2287
- time: true,
2288
- once: true
2289
- });
2290
- }
2291
- log(logLevel, message) {
2292
- return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
2293
- }
2294
- info(logLevel, message) {
2295
- return this._getLogFunction(logLevel, message, console.info, arguments);
2296
- }
2297
- once(logLevel, message) {
2298
- return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
2299
- }
2300
- table(logLevel, table, columns) {
2301
- if (table) {
2302
- return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
2303
- tag: getTableHeader(table)
2304
- });
2305
- }
2306
- return noop;
2307
- }
2308
- image(_ref) {
2309
- let {
2310
- logLevel,
2311
- priority,
2312
- image,
2313
- message = "",
2314
- scale = 1
2315
- } = _ref;
2316
- if (!this._shouldLog(logLevel || priority)) {
2317
- return noop;
2318
- }
2319
- return isBrowser3() ? logImageInBrowser({
2320
- image,
2321
- message,
2322
- scale
2323
- }) : logImageInNode({
2324
- image,
2325
- message,
2326
- scale
2327
- });
2328
- }
2329
- time(logLevel, message) {
2330
- return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
2331
- }
2332
- timeEnd(logLevel, message) {
2333
- return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
2334
- }
2335
- timeStamp(logLevel, message) {
2336
- return this._getLogFunction(logLevel, message, console.timeStamp || noop);
2337
- }
2338
- group(logLevel, message) {
2339
- let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
2340
- collapsed: false
2341
- };
2342
- const options = normalizeArguments({
2343
- logLevel,
2344
- message,
2345
- opts
2346
- });
2347
- const {
2348
- collapsed
2349
- } = opts;
2350
- options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
2351
- return this._getLogFunction(options);
2352
- }
2353
- groupCollapsed(logLevel, message) {
2354
- let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2355
- return this.group(logLevel, message, Object.assign({}, opts, {
2356
- collapsed: true
2357
- }));
2358
- }
2359
- groupEnd(logLevel) {
2360
- return this._getLogFunction(logLevel, "", console.groupEnd || noop);
2361
- }
2362
- withGroup(logLevel, message, func) {
2363
- this.group(logLevel, message)();
2364
- try {
2365
- func();
2366
- } finally {
2367
- this.groupEnd(logLevel)();
2368
- }
2369
- }
2370
- trace() {
2371
- if (console.trace) {
2372
- console.trace();
2373
- }
2374
- }
2375
- _shouldLog(logLevel) {
2376
- return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
2377
- }
2378
- _getLogFunction(logLevel, message, method, args, opts) {
2379
- if (this._shouldLog(logLevel)) {
2380
- opts = normalizeArguments({
2381
- logLevel,
2382
- message,
2383
- args,
2384
- opts
2385
- });
2386
- method = method || opts.method;
2387
- assert3(method);
2388
- opts.total = this.getTotal();
2389
- opts.delta = this.getDelta();
2390
- this._deltaTs = getHiResTimestamp2();
2391
- const tag = opts.tag || opts.message;
2392
- if (opts.once && tag) {
2393
- if (!cache[tag]) {
2394
- cache[tag] = getHiResTimestamp2();
2395
- } else {
2396
- return noop;
2397
- }
2398
- }
2399
- message = decorateMessage(this.id, opts.message, opts);
2400
- return method.bind(console, message, ...opts.args);
2401
- }
2402
- return noop;
2403
- }
2301
+ scale = 1
2302
+ } = _ref2;
2303
+ console.warn("removed");
2304
+ return noop;
2305
+ }
2306
+ function logImageInBrowser(_ref3) {
2307
+ let {
2308
+ image,
2309
+ message = "",
2310
+ scale = 1
2311
+ } = _ref3;
2312
+ if (typeof image === "string") {
2313
+ const img = new Image();
2314
+ img.onload = () => {
2315
+ const args = formatImage(img, message, scale);
2316
+ console.log(...args);
2404
2317
  };
2405
- _defineProperty(Log, "VERSION", VERSION3);
2318
+ img.src = image;
2319
+ return noop;
2406
2320
  }
2407
- });
2321
+ const element = image.nodeName || "";
2322
+ if (element.toLowerCase() === "img") {
2323
+ console.log(...formatImage(image, message, scale));
2324
+ return noop;
2325
+ }
2326
+ if (element.toLowerCase() === "canvas") {
2327
+ const img = new Image();
2328
+ img.onload = () => console.log(...formatImage(img, message, scale));
2329
+ img.src = image.toDataURL();
2330
+ return noop;
2331
+ }
2332
+ return noop;
2333
+ }
2334
+ function getTableHeader(table) {
2335
+ for (const key in table) {
2336
+ for (const title in table[key]) {
2337
+ return title || "untitled";
2338
+ }
2339
+ }
2340
+ return "empty";
2341
+ }
2408
2342
 
2409
2343
  // ../../node_modules/@probe.gl/log/dist/index.js
2410
- var dist_default;
2411
- var init_dist3 = __esm({
2412
- "../../node_modules/@probe.gl/log/dist/index.js"() {
2413
- init_log();
2414
- init_log();
2415
- dist_default = new Log({
2416
- id: "@probe.gl/log"
2417
- });
2418
- }
2344
+ var dist_default = new Log({
2345
+ id: "@probe.gl/log"
2419
2346
  });
2420
2347
 
2421
2348
  // src/lib/loader-utils/loggers.ts
2422
- var probeLog, NullLog, ConsoleLog;
2423
- var init_loggers = __esm({
2424
- "src/lib/loader-utils/loggers.ts"() {
2425
- init_dist3();
2426
- probeLog = new Log({ id: "loaders.gl" });
2427
- NullLog = class {
2428
- log() {
2429
- return () => {
2430
- };
2431
- }
2432
- info() {
2433
- return () => {
2434
- };
2435
- }
2436
- warn() {
2437
- return () => {
2438
- };
2439
- }
2440
- error() {
2441
- return () => {
2442
- };
2443
- }
2349
+ var probeLog = new Log({
2350
+ id: "loaders.gl"
2351
+ });
2352
+ var NullLog = class {
2353
+ log() {
2354
+ return () => {
2444
2355
  };
2445
- ConsoleLog = class {
2446
- constructor() {
2447
- this.console = console;
2448
- }
2449
- log(...args) {
2450
- return this.console.log.bind(this.console, ...args);
2451
- }
2452
- info(...args) {
2453
- return this.console.info.bind(this.console, ...args);
2454
- }
2455
- warn(...args) {
2456
- return this.console.warn.bind(this.console, ...args);
2457
- }
2458
- error(...args) {
2459
- return this.console.error.bind(this.console, ...args);
2460
- }
2356
+ }
2357
+ info() {
2358
+ return () => {
2461
2359
  };
2462
2360
  }
2463
- });
2464
-
2465
- // src/lib/loader-utils/option-defaults.ts
2466
- var DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS;
2467
- var init_option_defaults = __esm({
2468
- "src/lib/loader-utils/option-defaults.ts"() {
2469
- init_src2();
2470
- init_loggers();
2471
- DEFAULT_LOADER_OPTIONS = {
2472
- fetch: null,
2473
- mimeType: void 0,
2474
- nothrow: false,
2475
- log: new ConsoleLog(),
2476
- useLocalLibraries: false,
2477
- CDN: "https://unpkg.com/@loaders.gl",
2478
- worker: true,
2479
- maxConcurrency: 3,
2480
- maxMobileConcurrency: 1,
2481
- reuseWorkers: isBrowser,
2482
- _nodeWorkers: false,
2483
- _workerType: "",
2484
- limit: 0,
2485
- _limitMB: 0,
2486
- batchSize: "auto",
2487
- batchDebounceMs: 0,
2488
- metadata: false,
2489
- transforms: []
2361
+ warn() {
2362
+ return () => {
2490
2363
  };
2491
- REMOVED_LOADER_OPTIONS = {
2492
- throws: "nothrow",
2493
- dataType: "(no longer used)",
2494
- uri: "baseUri",
2495
- method: "fetch.method",
2496
- headers: "fetch.headers",
2497
- body: "fetch.body",
2498
- mode: "fetch.mode",
2499
- credentials: "fetch.credentials",
2500
- cache: "fetch.cache",
2501
- redirect: "fetch.redirect",
2502
- referrer: "fetch.referrer",
2503
- referrerPolicy: "fetch.referrerPolicy",
2504
- integrity: "fetch.integrity",
2505
- keepalive: "fetch.keepalive",
2506
- signal: "fetch.signal"
2364
+ }
2365
+ error() {
2366
+ return () => {
2507
2367
  };
2508
2368
  }
2509
- });
2369
+ };
2370
+ var ConsoleLog = class {
2371
+ constructor() {
2372
+ this.console = console;
2373
+ }
2374
+ log(...args) {
2375
+ return this.console.log.bind(this.console, ...args);
2376
+ }
2377
+ info(...args) {
2378
+ return this.console.info.bind(this.console, ...args);
2379
+ }
2380
+ warn(...args) {
2381
+ return this.console.warn.bind(this.console, ...args);
2382
+ }
2383
+ error(...args) {
2384
+ return this.console.error.bind(this.console, ...args);
2385
+ }
2386
+ };
2387
+
2388
+ // src/lib/loader-utils/option-defaults.ts
2389
+ var DEFAULT_LOADER_OPTIONS = {
2390
+ // baseUri
2391
+ fetch: null,
2392
+ mimeType: void 0,
2393
+ nothrow: false,
2394
+ log: new ConsoleLog(),
2395
+ // A probe.gl compatible (`log.log()()` syntax) that just logs to console
2396
+ useLocalLibraries: false,
2397
+ CDN: "https://unpkg.com/@loaders.gl",
2398
+ worker: true,
2399
+ // By default, use worker if provided by loader.
2400
+ maxConcurrency: 3,
2401
+ // How many worker instances should be created for each loader.
2402
+ maxMobileConcurrency: 1,
2403
+ // How many worker instances should be created for each loader on mobile devices.
2404
+ reuseWorkers: isBrowser,
2405
+ // By default reuse workers in browser (Node.js refuses to terminate if browsers are running)
2406
+ _nodeWorkers: false,
2407
+ // By default do not support node workers
2408
+ _workerType: "",
2409
+ // 'test' to use locally generated workers
2410
+ limit: 0,
2411
+ _limitMB: 0,
2412
+ batchSize: "auto",
2413
+ batchDebounceMs: 0,
2414
+ metadata: false,
2415
+ // TODO - currently only implemented for parseInBatches, adds initial metadata batch,
2416
+ transforms: []
2417
+ };
2418
+ var REMOVED_LOADER_OPTIONS = {
2419
+ throws: "nothrow",
2420
+ dataType: "(no longer used)",
2421
+ uri: "baseUri",
2422
+ // Warn if fetch options are used on top-level
2423
+ method: "fetch.method",
2424
+ headers: "fetch.headers",
2425
+ body: "fetch.body",
2426
+ mode: "fetch.mode",
2427
+ credentials: "fetch.credentials",
2428
+ cache: "fetch.cache",
2429
+ redirect: "fetch.redirect",
2430
+ referrer: "fetch.referrer",
2431
+ referrerPolicy: "fetch.referrerPolicy",
2432
+ integrity: "fetch.integrity",
2433
+ keepalive: "fetch.keepalive",
2434
+ signal: "fetch.signal"
2435
+ };
2510
2436
 
2511
2437
  // src/lib/loader-utils/option-utils.ts
2512
2438
  function getGlobalLoaderState() {
2513
2439
  globalThis.loaders = globalThis.loaders || {};
2514
- const { loaders } = globalThis;
2440
+ const {
2441
+ loaders
2442
+ } = globalThis;
2515
2443
  loaders._state = loaders._state || {};
2516
2444
  return loaders._state;
2517
2445
  }
2518
2446
  function getGlobalLoaderOptions() {
2519
2447
  const state = getGlobalLoaderState();
2520
- state.globalOptions = state.globalOptions || { ...DEFAULT_LOADER_OPTIONS };
2448
+ state.globalOptions = state.globalOptions || {
2449
+ ...DEFAULT_LOADER_OPTIONS
2450
+ };
2521
2451
  return state.globalOptions;
2522
2452
  }
2523
2453
  function setGlobalOptions(options) {
@@ -2576,7 +2506,9 @@
2576
2506
  }
2577
2507
  function normalizeOptionsInternal(loader, options, url) {
2578
2508
  const loaderDefaultOptions = loader.options || {};
2579
- const mergedOptions = { ...loaderDefaultOptions };
2509
+ const mergedOptions = {
2510
+ ...loaderDefaultOptions
2511
+ };
2580
2512
  addUrlOptions(mergedOptions, url);
2581
2513
  if (mergedOptions.log === null) {
2582
2514
  mergedOptions.log = new NullLog();
@@ -2605,21 +2537,6 @@
2605
2537
  options.baseUri = url;
2606
2538
  }
2607
2539
  }
2608
- var init_option_utils = __esm({
2609
- "src/lib/loader-utils/option-utils.ts"() {
2610
- init_is_type();
2611
- init_loggers();
2612
- init_option_defaults();
2613
- }
2614
- });
2615
-
2616
- // src/lib/api/loader-options.ts
2617
- var init_loader_options = __esm({
2618
- "src/lib/api/loader-options.ts"() {
2619
- init_option_utils();
2620
- init_option_utils();
2621
- }
2622
- });
2623
2540
 
2624
2541
  // src/lib/loader-utils/normalize-loader.ts
2625
2542
  function isLoaderObject(loader) {
@@ -2641,7 +2558,10 @@
2641
2558
  loader = loader[0];
2642
2559
  loader = {
2643
2560
  ...loader,
2644
- options: { ...loader.options, ...options }
2561
+ options: {
2562
+ ...loader.options,
2563
+ ...options
2564
+ }
2645
2565
  };
2646
2566
  }
2647
2567
  if (loader?.parseTextSync || loader?.parseText) {
@@ -2652,13 +2572,13 @@
2652
2572
  }
2653
2573
  return loader;
2654
2574
  }
2655
- var init_normalize_loader = __esm({
2656
- "src/lib/loader-utils/normalize-loader.ts"() {
2657
- init_src2();
2658
- }
2659
- });
2660
2575
 
2661
2576
  // src/lib/api/register-loaders.ts
2577
+ var getGlobalLoaderRegistry = () => {
2578
+ const state = getGlobalLoaderState();
2579
+ state.loaderRegistry = state.loaderRegistry || [];
2580
+ return state.loaderRegistry;
2581
+ };
2662
2582
  function registerLoaders(loaders) {
2663
2583
  const loaderRegistry = getGlobalLoaderRegistry();
2664
2584
  loaders = Array.isArray(loaders) ? loaders : [loaders];
@@ -2676,34 +2596,22 @@
2676
2596
  const state = getGlobalLoaderState();
2677
2597
  state.loaderRegistry = [];
2678
2598
  }
2679
- var getGlobalLoaderRegistry;
2680
- var init_register_loaders = __esm({
2681
- "src/lib/api/register-loaders.ts"() {
2682
- init_normalize_loader();
2683
- init_option_utils();
2684
- getGlobalLoaderRegistry = () => {
2685
- const state = getGlobalLoaderState();
2686
- state.loaderRegistry = state.loaderRegistry || [];
2687
- return state.loaderRegistry;
2688
- };
2689
- }
2690
- });
2691
2599
 
2692
2600
  // src/lib/utils/log.ts
2693
- var log;
2694
- var init_log2 = __esm({
2695
- "src/lib/utils/log.ts"() {
2696
- init_dist3();
2697
- log = new Log({ id: "loaders.gl" });
2698
- }
2601
+ var log = new Log({
2602
+ id: "loaders.gl"
2699
2603
  });
2700
2604
 
2701
2605
  // src/lib/api/select-loader.ts
2606
+ var EXT_PATTERN = /\.([^.]+)$/;
2702
2607
  async function selectLoader(data, loaders = [], options, context) {
2703
2608
  if (!validHTTPResponse(data)) {
2704
2609
  return null;
2705
2610
  }
2706
- let loader = selectLoaderSync(data, loaders, { ...options, nothrow: true }, context);
2611
+ let loader = selectLoaderSync(data, loaders, {
2612
+ ...options,
2613
+ nothrow: true
2614
+ }, context);
2707
2615
  if (loader) {
2708
2616
  return loader;
2709
2617
  }
@@ -2882,21 +2790,9 @@
2882
2790
  }
2883
2791
  return magic;
2884
2792
  }
2885
- var EXT_PATTERN;
2886
- var init_select_loader = __esm({
2887
- "src/lib/api/select-loader.ts"() {
2888
- init_src2();
2889
- init_normalize_loader();
2890
- init_log2();
2891
- init_resource_utils();
2892
- init_register_loaders();
2893
- init_is_type();
2894
- init_url_utils();
2895
- EXT_PATTERN = /\.([^.]+)$/;
2896
- }
2897
- });
2898
2793
 
2899
2794
  // src/iterators/make-iterator/make-string-iterator.ts
2795
+ var DEFAULT_CHUNK_SIZE = 256 * 1024;
2900
2796
  function* makeStringIterator(string, options) {
2901
2797
  const chunkSize = options?.chunkSize || DEFAULT_CHUNK_SIZE;
2902
2798
  let offset = 0;
@@ -2908,16 +2804,13 @@
2908
2804
  yield textEncoder.encode(chunk);
2909
2805
  }
2910
2806
  }
2911
- var DEFAULT_CHUNK_SIZE;
2912
- var init_make_string_iterator = __esm({
2913
- "src/iterators/make-iterator/make-string-iterator.ts"() {
2914
- DEFAULT_CHUNK_SIZE = 256 * 1024;
2915
- }
2916
- });
2917
2807
 
2918
2808
  // src/iterators/make-iterator/make-array-buffer-iterator.ts
2809
+ var DEFAULT_CHUNK_SIZE2 = 256 * 1024;
2919
2810
  function* makeArrayBufferIterator(arrayBuffer, options = {}) {
2920
- const { chunkSize = DEFAULT_CHUNK_SIZE2 } = options;
2811
+ const {
2812
+ chunkSize = DEFAULT_CHUNK_SIZE2
2813
+ } = options;
2921
2814
  let byteOffset = 0;
2922
2815
  while (byteOffset < arrayBuffer.byteLength) {
2923
2816
  const chunkByteLength = Math.min(arrayBuffer.byteLength - byteOffset, chunkSize);
@@ -2929,14 +2822,9 @@
2929
2822
  yield chunk;
2930
2823
  }
2931
2824
  }
2932
- var DEFAULT_CHUNK_SIZE2;
2933
- var init_make_array_buffer_iterator = __esm({
2934
- "src/iterators/make-iterator/make-array-buffer-iterator.ts"() {
2935
- DEFAULT_CHUNK_SIZE2 = 256 * 1024;
2936
- }
2937
- });
2938
2825
 
2939
2826
  // src/iterators/make-iterator/make-blob-iterator.ts
2827
+ var DEFAULT_CHUNK_SIZE3 = 1024 * 1024;
2940
2828
  async function* makeBlobIterator(blob, options) {
2941
2829
  const chunkSize = options?.chunkSize || DEFAULT_CHUNK_SIZE3;
2942
2830
  let offset = 0;
@@ -2947,12 +2835,6 @@
2947
2835
  yield chunk;
2948
2836
  }
2949
2837
  }
2950
- var DEFAULT_CHUNK_SIZE3;
2951
- var init_make_blob_iterator = __esm({
2952
- "src/iterators/make-iterator/make-blob-iterator.ts"() {
2953
- DEFAULT_CHUNK_SIZE3 = 1024 * 1024;
2954
- }
2955
- });
2956
2838
 
2957
2839
  // src/iterators/make-iterator/make-stream-iterator.ts
2958
2840
  function makeStreamIterator(stream, options) {
@@ -2967,7 +2849,10 @@
2967
2849
  if (options?._streamReadAhead) {
2968
2850
  nextBatchPromise = reader.read();
2969
2851
  }
2970
- const { done, value } = await currentBatchPromise;
2852
+ const {
2853
+ done,
2854
+ value
2855
+ } = await currentBatchPromise;
2971
2856
  if (done) {
2972
2857
  return;
2973
2858
  }
@@ -2982,11 +2867,6 @@
2982
2867
  yield toArrayBuffer2(chunk);
2983
2868
  }
2984
2869
  }
2985
- var init_make_stream_iterator = __esm({
2986
- "src/iterators/make-iterator/make-stream-iterator.ts"() {
2987
- init_src2();
2988
- }
2989
- });
2990
2870
 
2991
2871
  // src/iterators/make-iterator/make-iterator.ts
2992
2872
  function makeIterator(data, options) {
@@ -3008,17 +2888,9 @@
3008
2888
  }
3009
2889
  throw new Error("makeIterator");
3010
2890
  }
3011
- var init_make_iterator = __esm({
3012
- "src/iterators/make-iterator/make-iterator.ts"() {
3013
- init_make_string_iterator();
3014
- init_make_array_buffer_iterator();
3015
- init_make_blob_iterator();
3016
- init_make_stream_iterator();
3017
- init_is_type();
3018
- }
3019
- });
3020
2891
 
3021
2892
  // src/lib/loader-utils/get-data.ts
2893
+ var ERR_DATA = "Cannot convert supplied data type";
3022
2894
  function getArrayBufferOrStringFromDataSync(data, loader, options) {
3023
2895
  if (loader.text && typeof data === "string") {
3024
2896
  return data;
@@ -3106,16 +2978,6 @@
3106
2978
  }
3107
2979
  throw new Error(ERR_DATA);
3108
2980
  }
3109
- var ERR_DATA;
3110
- var init_get_data = __esm({
3111
- "src/lib/loader-utils/get-data.ts"() {
3112
- init_src2();
3113
- init_is_type();
3114
- init_make_iterator();
3115
- init_response_utils();
3116
- ERR_DATA = "Cannot convert supplied data type";
3117
- }
3118
- });
3119
2981
 
3120
2982
  // src/lib/loader-utils/get-fetch-function.ts
3121
2983
  function getFetchFunction(options, context) {
@@ -3132,13 +2994,6 @@
3132
2994
  }
3133
2995
  return fetchFile;
3134
2996
  }
3135
- var init_get_fetch_function = __esm({
3136
- "src/lib/loader-utils/get-fetch-function.ts"() {
3137
- init_is_type();
3138
- init_fetch_file();
3139
- init_option_utils();
3140
- }
3141
- });
3142
2997
 
3143
2998
  // src/lib/loader-utils/loader-context.ts
3144
2999
  function getLoaderContext(context, options, parentContext) {
@@ -3175,13 +3030,6 @@
3175
3030
  }
3176
3031
  return candidateLoaders && candidateLoaders.length ? candidateLoaders : void 0;
3177
3032
  }
3178
- var init_loader_context = __esm({
3179
- "src/lib/loader-utils/loader-context.ts"() {
3180
- init_get_fetch_function();
3181
- init_url_utils();
3182
- init_src2();
3183
- }
3184
- });
3185
3033
 
3186
3034
  // src/lib/api/parse.ts
3187
3035
  async function parse(data, loaders, options, context) {
@@ -3200,7 +3048,16 @@
3200
3048
  return null;
3201
3049
  }
3202
3050
  options = normalizeOptions(options, loader, candidateLoaders, url);
3203
- context = getLoaderContext({ url, _parse: parse, loaders: candidateLoaders }, options, context || null);
3051
+ context = getLoaderContext(
3052
+ // @ts-expect-error
3053
+ {
3054
+ url,
3055
+ _parse: parse,
3056
+ loaders: candidateLoaders
3057
+ },
3058
+ options,
3059
+ context || null
3060
+ );
3204
3061
  return await parseWithLoader(loader, data, options, context);
3205
3062
  }
3206
3063
  async function parseWithLoader(loader, data, options, context) {
@@ -3208,9 +3065,24 @@
3208
3065
  options = mergeLoaderOptions(loader.options, options);
3209
3066
  if (isResponse(data)) {
3210
3067
  const response = data;
3211
- const { ok, redirected, status, statusText, type, url } = response;
3068
+ const {
3069
+ ok,
3070
+ redirected,
3071
+ status,
3072
+ statusText,
3073
+ type,
3074
+ url
3075
+ } = response;
3212
3076
  const headers = Object.fromEntries(response.headers.entries());
3213
- context.response = { headers, ok, redirected, status, statusText, type, url };
3077
+ context.response = {
3078
+ headers,
3079
+ ok,
3080
+ redirected,
3081
+ status,
3082
+ statusText,
3083
+ type,
3084
+ url
3085
+ };
3214
3086
  }
3215
3087
  data = await getArrayBufferOrStringFromData(data, loader, options);
3216
3088
  const loaderWithParser = loader;
@@ -3229,20 +3101,6 @@
3229
3101
  assert2(!loaderWithParser.parseSync);
3230
3102
  throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
3231
3103
  }
3232
- var init_parse = __esm({
3233
- "src/lib/api/parse.ts"() {
3234
- init_src2();
3235
- init_src();
3236
- init_normalize_loader();
3237
- init_is_type();
3238
- init_option_utils();
3239
- init_src2();
3240
- init_get_data();
3241
- init_loader_context();
3242
- init_resource_utils();
3243
- init_select_loader();
3244
- }
3245
- });
3246
3104
 
3247
3105
  // src/lib/api/parse-sync.ts
3248
3106
  function parseSync(data, loaders, options, context) {
@@ -3263,7 +3121,12 @@
3263
3121
  const parse2 = () => {
3264
3122
  throw new Error("parseSync called parse (which is async");
3265
3123
  };
3266
- context = getLoaderContext({ url, _parseSync: parse2, _parse: parse2, loaders }, options, context || null);
3124
+ context = getLoaderContext({
3125
+ url,
3126
+ _parseSync: parse2,
3127
+ _parse: parse2,
3128
+ loaders
3129
+ }, options, context || null);
3267
3130
  return parseWithLoaderSync(loader, data, options, context);
3268
3131
  }
3269
3132
  function parseWithLoaderSync(loader, data, options, context) {
@@ -3276,16 +3139,6 @@
3276
3139
  }
3277
3140
  throw new Error(`${loader.name} loader: 'parseSync' not supported by this loader, use 'parse' instead. ${context.url || ""}`);
3278
3141
  }
3279
- var init_parse_sync = __esm({
3280
- "src/lib/api/parse-sync.ts"() {
3281
- init_select_loader();
3282
- init_normalize_loader();
3283
- init_option_utils();
3284
- init_get_data();
3285
- init_loader_context();
3286
- init_resource_utils();
3287
- }
3288
- });
3289
3142
 
3290
3143
  // src/lib/api/parse-in-batches.ts
3291
3144
  async function parseInBatches(data, loaders, options, context) {
@@ -3303,7 +3156,12 @@
3303
3156
  return [];
3304
3157
  }
3305
3158
  options = normalizeOptions(options, loader, loaderArray, url);
3306
- context = getLoaderContext({ url, _parseInBatches: parseInBatches, _parse: parse, loaders: loaderArray }, options, context || null);
3159
+ context = getLoaderContext({
3160
+ url,
3161
+ _parseInBatches: parseInBatches,
3162
+ _parse: parse,
3163
+ loaders: loaderArray
3164
+ }, options, context || null);
3307
3165
  return await parseWithLoaderInBatches(loader, data, options, context);
3308
3166
  }
3309
3167
  async function parseWithLoaderInBatches(loader, data, options, context) {
@@ -3317,6 +3175,7 @@
3317
3175
  _loader: loader,
3318
3176
  _context: context
3319
3177
  },
3178
+ // Populate with some default fields to avoid crashing
3320
3179
  data: [],
3321
3180
  bytesUsed: 0
3322
3181
  };
@@ -3334,7 +3193,16 @@
3334
3193
  }
3335
3194
  async function* parseChunkInBatches() {
3336
3195
  const arrayBuffer = await concatenateArrayBuffersAsync(transformedIterator);
3337
- const parsedData = await parse(arrayBuffer, loader, { ...options, mimeType: loader.mimeTypes[0] }, context);
3196
+ const parsedData = await parse(
3197
+ arrayBuffer,
3198
+ loader,
3199
+ // TODO - Hack: supply loaders MIME type to ensure we match it
3200
+ {
3201
+ ...options,
3202
+ mimeType: loader.mimeTypes[0]
3203
+ },
3204
+ context
3205
+ );
3338
3206
  const batch = {
3339
3207
  mimeType: loader.mimeTypes[0],
3340
3208
  shape: Array.isArray(parsedData) ? "row-table" : "unknown",
@@ -3353,18 +3221,6 @@
3353
3221
  }
3354
3222
  return iteratorChain;
3355
3223
  }
3356
- var init_parse_in_batches = __esm({
3357
- "src/lib/api/parse-in-batches.ts"() {
3358
- init_src2();
3359
- init_normalize_loader();
3360
- init_option_utils();
3361
- init_loader_context();
3362
- init_get_data();
3363
- init_resource_utils();
3364
- init_select_loader();
3365
- init_parse();
3366
- }
3367
- });
3368
3224
 
3369
3225
  // src/lib/api/load.ts
3370
3226
  async function load(url, loaders, options, context) {
@@ -3388,14 +3244,6 @@
3388
3244
  }
3389
3245
  return Array.isArray(resolvedLoaders) ? await parse(data, resolvedLoaders, resolvedOptions) : await parse(data, resolvedLoaders, resolvedOptions);
3390
3246
  }
3391
- var init_load = __esm({
3392
- "src/lib/api/load.ts"() {
3393
- init_is_type();
3394
- init_normalize_loader();
3395
- init_get_fetch_function();
3396
- init_parse();
3397
- }
3398
- });
3399
3247
 
3400
3248
  // src/lib/api/load-in-batches.ts
3401
3249
  function loadInBatches(files, loaders, options, context) {
@@ -3422,13 +3270,6 @@
3422
3270
  }
3423
3271
  return Array.isArray(loaders) ? await parseInBatches(file, loaders, options) : await parseInBatches(file, loaders, options);
3424
3272
  }
3425
- var init_load_in_batches = __esm({
3426
- "src/lib/api/load-in-batches.ts"() {
3427
- init_normalize_loader();
3428
- init_get_fetch_function();
3429
- init_parse_in_batches();
3430
- }
3431
- });
3432
3273
 
3433
3274
  // src/lib/api/encode-table.ts
3434
3275
  async function encodeTable(data, writer, options) {
@@ -3467,19 +3308,21 @@
3467
3308
  throw new Error("Writer could not encode data in batches");
3468
3309
  }
3469
3310
  function getIterator(data) {
3470
- const dataIterator = [{ ...data, start: 0, end: data.length }];
3311
+ const dataIterator = [{
3312
+ ...data,
3313
+ start: 0,
3314
+ end: data.length
3315
+ }];
3471
3316
  return dataIterator;
3472
3317
  }
3473
- var init_encode_table = __esm({
3474
- "src/lib/api/encode-table.ts"() {
3475
- init_src2();
3476
- }
3477
- });
3478
3318
 
3479
3319
  // src/lib/api/encode.ts
3480
3320
  async function encode(data, writer, options) {
3481
3321
  const globalOptions = getGlobalLoaderOptions();
3482
- options = { ...globalOptions, ...options };
3322
+ options = {
3323
+ ...globalOptions,
3324
+ ...options
3325
+ };
3483
3326
  if (canEncodeWithWorker(writer, options)) {
3484
3327
  return await processOnWorker(writer, data, options);
3485
3328
  }
@@ -3502,7 +3345,8 @@
3502
3345
  }
3503
3346
  if (!isBrowser && writer.encodeURLtoURL) {
3504
3347
  const tmpInputFilename = getTemporaryFilename("input");
3505
- await writeFile(tmpInputFilename, data);
3348
+ const file = new NodeFileFacade(tmpInputFilename, "w");
3349
+ await file.write(data);
3506
3350
  const tmpOutputFilename = getTemporaryFilename("output");
3507
3351
  const outputFilename = await encodeURLtoURL(tmpInputFilename, tmpOutputFilename, writer, options);
3508
3352
  const response = await fetchFile(outputFilename);
@@ -3553,112 +3397,94 @@
3553
3397
  return outputFilename;
3554
3398
  }
3555
3399
  function getIterator2(data) {
3556
- const dataIterator = [{ ...data, start: 0, end: data.length }];
3400
+ const dataIterator = [{
3401
+ ...data,
3402
+ start: 0,
3403
+ end: data.length
3404
+ }];
3557
3405
  return dataIterator;
3558
3406
  }
3559
3407
  function getTemporaryFilename(filename2) {
3560
3408
  return `/tmp/${filename2}`;
3561
3409
  }
3562
- var init_encode = __esm({
3563
- "src/lib/api/encode.ts"() {
3564
- init_src2();
3565
- init_src();
3566
- init_src2();
3567
- init_src2();
3568
- init_write_file();
3569
- init_fetch_file();
3570
- init_loader_options();
3571
- }
3572
- });
3573
-
3574
- // src/lib/api/save.ts
3575
- async function save(data, url, writer, options) {
3576
- const encodedData = await encode(data, writer, options);
3577
- return await writeFile(url, encodedData);
3578
- }
3579
- function saveSync(data, url, writer, options) {
3580
- const encodedData = encodeSync(data, writer, options);
3581
- return writeFileSync(url, encodedData);
3582
- }
3583
- var init_save = __esm({
3584
- "src/lib/api/save.ts"() {
3585
- init_encode();
3586
- init_write_file();
3587
- }
3588
- });
3589
3410
 
3590
- // src/iterators/make-stream/make-dom-stream.ts
3411
+ // src/iterators/make-stream/make-stream.ts
3591
3412
  function makeStream(source, options) {
3413
+ if (globalThis.loaders.makeNodeStream) {
3414
+ return globalThis.loaders.makeNodeStream(source, options);
3415
+ }
3592
3416
  const iterator = source[Symbol.asyncIterator] ? source[Symbol.asyncIterator]() : source[Symbol.iterator]();
3593
- return new ReadableStream({
3594
- type: "bytes",
3595
- async pull(controller) {
3596
- try {
3597
- const { done, value } = await iterator.next();
3598
- if (done) {
3599
- controller.close();
3600
- } else {
3601
- controller.enqueue(new Uint8Array(value));
3417
+ return new ReadableStream(
3418
+ {
3419
+ // Create a byte stream (enables `Response(stream).arrayBuffer()`)
3420
+ // Only supported on Chrome
3421
+ // See: https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController
3422
+ type: "bytes",
3423
+ async pull(controller) {
3424
+ try {
3425
+ const {
3426
+ done,
3427
+ value
3428
+ } = await iterator.next();
3429
+ if (done) {
3430
+ controller.close();
3431
+ } else {
3432
+ controller.enqueue(new Uint8Array(value));
3433
+ }
3434
+ } catch (error) {
3435
+ controller.error(error);
3602
3436
  }
3603
- } catch (error) {
3604
- controller.error(error);
3437
+ },
3438
+ async cancel() {
3439
+ await iterator?.return?.();
3605
3440
  }
3606
3441
  },
3607
- async cancel() {
3608
- await iterator?.return?.();
3442
+ // options: QueingStrategy<Uint8Array>
3443
+ {
3444
+ // This is bytes, not chunks
3445
+ highWaterMark: 2 ** 24,
3446
+ ...options
3609
3447
  }
3610
- }, {
3611
- highWaterMark: 2 ** 24,
3612
- ...options
3613
- });
3448
+ );
3614
3449
  }
3615
- var init_make_dom_stream = __esm({
3616
- "src/iterators/make-stream/make-dom-stream.ts"() {
3617
- }
3618
- });
3619
3450
 
3620
3451
  // src/null-loader.ts
3452
+ var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3453
+ var NullWorkerLoader = {
3454
+ name: "Null loader",
3455
+ id: "null",
3456
+ module: "core",
3457
+ version: VERSION4,
3458
+ worker: true,
3459
+ mimeTypes: ["application/x.empty"],
3460
+ extensions: ["null"],
3461
+ tests: [() => false],
3462
+ options: {
3463
+ null: {}
3464
+ }
3465
+ };
3466
+ var NullLoader = {
3467
+ name: "Null loader",
3468
+ id: "null",
3469
+ module: "core",
3470
+ version: VERSION4,
3471
+ mimeTypes: ["application/x.empty"],
3472
+ extensions: ["null"],
3473
+ parse: async (arrayBuffer, options, context) => parseSync2(arrayBuffer, options || {}, context),
3474
+ parseSync: parseSync2,
3475
+ parseInBatches: async function* generator(asyncIterator, options, context) {
3476
+ for await (const batch of asyncIterator) {
3477
+ yield parseSync2(batch, options, context);
3478
+ }
3479
+ },
3480
+ tests: [() => false],
3481
+ options: {
3482
+ null: {}
3483
+ }
3484
+ };
3621
3485
  function parseSync2(arrayBuffer, options, context) {
3622
3486
  return null;
3623
3487
  }
3624
- var VERSION4, NullWorkerLoader, NullLoader;
3625
- var init_null_loader = __esm({
3626
- "src/null-loader.ts"() {
3627
- VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3628
- NullWorkerLoader = {
3629
- name: "Null loader",
3630
- id: "null",
3631
- module: "core",
3632
- version: VERSION4,
3633
- worker: true,
3634
- mimeTypes: ["application/x.empty"],
3635
- extensions: ["null"],
3636
- tests: [() => false],
3637
- options: {
3638
- null: {}
3639
- }
3640
- };
3641
- NullLoader = {
3642
- name: "Null loader",
3643
- id: "null",
3644
- module: "core",
3645
- version: VERSION4,
3646
- mimeTypes: ["application/x.empty"],
3647
- extensions: ["null"],
3648
- parse: async (arrayBuffer, options, context) => parseSync2(arrayBuffer, options || {}, context),
3649
- parseSync: parseSync2,
3650
- parseInBatches: async function* generator(asyncIterator, options, context) {
3651
- for await (const batch of asyncIterator) {
3652
- yield parseSync2(batch, options, context);
3653
- }
3654
- },
3655
- tests: [() => false],
3656
- options: {
3657
- null: {}
3658
- }
3659
- };
3660
- }
3661
- });
3662
3488
 
3663
3489
  // src/lib/progress/fetch-progress.ts
3664
3490
  async function fetchProgress(response, onProgress, onDone = () => {
@@ -3690,7 +3516,10 @@
3690
3516
  }
3691
3517
  async function read(controller, reader, loadedBytes, totalBytes, onProgress, onDone, onError) {
3692
3518
  try {
3693
- const { done, value } = await reader.read();
3519
+ const {
3520
+ done,
3521
+ value
3522
+ } = await reader.read();
3694
3523
  if (done) {
3695
3524
  onDone();
3696
3525
  controller.close();
@@ -3698,7 +3527,10 @@
3698
3527
  }
3699
3528
  loadedBytes += value.byteLength;
3700
3529
  const percent = Math.round(loadedBytes / totalBytes * 100);
3701
- onProgress(percent, { loadedBytes, totalBytes });
3530
+ onProgress(percent, {
3531
+ loadedBytes,
3532
+ totalBytes
3533
+ });
3702
3534
  controller.enqueue(value);
3703
3535
  await read(controller, reader, loadedBytes, totalBytes, onProgress, onDone, onError);
3704
3536
  } catch (error) {
@@ -3706,198 +3538,110 @@
3706
3538
  onError(error);
3707
3539
  }
3708
3540
  }
3709
- var init_fetch_progress = __esm({
3710
- "src/lib/progress/fetch-progress.ts"() {
3711
- }
3712
- });
3713
3541
 
3714
3542
  // src/lib/filesystems/browser-filesystem.ts
3715
- var BrowserFileSystem;
3716
- var init_browser_filesystem = __esm({
3717
- "src/lib/filesystems/browser-filesystem.ts"() {
3718
- BrowserFileSystem = class {
3719
- constructor(files, options) {
3720
- this.files = {};
3721
- this.lowerCaseFiles = {};
3722
- this.usedFiles = {};
3723
- this._fetch = options?.fetch || fetch;
3724
- for (let i = 0; i < files.length; ++i) {
3725
- const file = files[i];
3726
- this.files[file.name] = file;
3727
- this.lowerCaseFiles[file.name.toLowerCase()] = file;
3728
- this.usedFiles[file.name] = false;
3729
- }
3730
- this.fetch = this.fetch.bind(this);
3731
- }
3732
- async fetch(path, options) {
3733
- if (path.includes("://")) {
3734
- return this._fetch(path, options);
3735
- }
3736
- const file = this.files[path];
3737
- if (!file) {
3738
- return new Response(path, { status: 400, statusText: "NOT FOUND" });
3739
- }
3740
- const headers = new Headers(options?.headers);
3741
- const range = headers.get("Range");
3742
- const bytes = range && /bytes=($1)-($2)/.exec(range);
3743
- if (bytes) {
3744
- const start = parseInt(bytes[1]);
3745
- const end = parseInt(bytes[2]);
3746
- const data = await file.slice(start, end).arrayBuffer();
3747
- const response2 = new Response(data);
3748
- Object.defineProperty(response2, "url", { value: path });
3749
- return response2;
3750
- }
3751
- const response = new Response(file);
3752
- Object.defineProperty(response, "url", { value: path });
3753
- return response;
3754
- }
3755
- async readdir(dirname2) {
3756
- const files = [];
3757
- for (const path in this.files) {
3758
- files.push(path);
3759
- }
3760
- return files;
3761
- }
3762
- async stat(path, options) {
3763
- const file = this.files[path];
3764
- if (!file) {
3765
- throw new Error(path);
3766
- }
3767
- return { size: file.size };
3768
- }
3769
- async unlink(path) {
3770
- delete this.files[path];
3771
- delete this.lowerCaseFiles[path];
3772
- this.usedFiles[path] = true;
3773
- }
3774
- async open(pathname, flags, mode) {
3775
- return this.files[pathname];
3776
- }
3777
- async read(fd, buffer, offset = 0, length = buffer.byteLength, position = null) {
3778
- const file = fd;
3779
- const startPosition = 0;
3780
- const arrayBuffer = await file.slice(startPosition, startPosition + length).arrayBuffer();
3781
- return { bytesRead: length, buffer: arrayBuffer };
3782
- }
3783
- async close(fd) {
3784
- }
3785
- _getFile(path, used) {
3786
- const file = this.files[path] || this.lowerCaseFiles[path];
3787
- if (file && used) {
3788
- this.usedFiles[path] = true;
3789
- }
3790
- return file;
3791
- }
3792
- };
3543
+ var BrowserFileSystem = class {
3544
+ files = {};
3545
+ lowerCaseFiles = {};
3546
+ usedFiles = {};
3547
+ /**
3548
+ * A FileSystem API wrapper around a list of browser 'File' objects
3549
+ * @param files
3550
+ * @param options
3551
+ */
3552
+ constructor(files, options) {
3553
+ this._fetch = options?.fetch || fetch;
3554
+ for (let i = 0; i < files.length; ++i) {
3555
+ const file = files[i];
3556
+ this.files[file.name] = file;
3557
+ this.lowerCaseFiles[file.name.toLowerCase()] = file;
3558
+ this.usedFiles[file.name] = false;
3559
+ }
3560
+ this.fetch = this.fetch.bind(this);
3561
+ }
3562
+ // implements IFileSystem
3563
+ /**
3564
+ * Implementation of fetch against this file system
3565
+ * Delegates to global fetch for http{s}:// or data://
3566
+ */
3567
+ async fetch(path, options) {
3568
+ if (path.includes("://")) {
3569
+ return this._fetch(path, options);
3570
+ }
3571
+ const file = this.files[path];
3572
+ if (!file) {
3573
+ return new Response(path, {
3574
+ status: 400,
3575
+ statusText: "NOT FOUND"
3576
+ });
3577
+ }
3578
+ const headers = new Headers(options?.headers);
3579
+ const range = headers.get("Range");
3580
+ const bytes = range && /bytes=($1)-($2)/.exec(range);
3581
+ if (bytes) {
3582
+ const start = parseInt(bytes[1]);
3583
+ const end = parseInt(bytes[2]);
3584
+ const data = await file.slice(start, end).arrayBuffer();
3585
+ const response2 = new Response(data);
3586
+ Object.defineProperty(response2, "url", {
3587
+ value: path
3588
+ });
3589
+ return response2;
3590
+ }
3591
+ const response = new Response(file);
3592
+ Object.defineProperty(response, "url", {
3593
+ value: path
3594
+ });
3595
+ return response;
3793
3596
  }
3794
- });
3795
-
3796
- // src/index.ts
3797
- var src_exports = {};
3798
- __export(src_exports, {
3799
- JSONLoader: () => JSONLoader,
3800
- NullLoader: () => NullLoader,
3801
- NullWorkerLoader: () => NullWorkerLoader,
3802
- RequestScheduler: () => RequestScheduler,
3803
- _BrowserFileSystem: () => BrowserFileSystem,
3804
- _fetchProgress: () => fetchProgress,
3805
- _unregisterLoaders: () => _unregisterLoaders,
3806
- assert: () => assert,
3807
- concatenateArrayBuffersAsync: () => concatenateArrayBuffersAsync,
3808
- document: () => document_,
3809
- encode: () => encode,
3810
- encodeInBatches: () => encodeInBatches,
3811
- encodeSync: () => encodeSync,
3812
- encodeTable: () => encodeTable,
3813
- encodeTableAsText: () => encodeTableAsText,
3814
- encodeTableInBatches: () => encodeTableInBatches,
3815
- encodeText: () => encodeText,
3816
- encodeTextSync: () => encodeTextSync,
3817
- encodeURLtoURL: () => encodeURLtoURL,
3818
- fetchFile: () => fetchFile,
3819
- forEach: () => forEach,
3820
- getLoaderOptions: () => getGlobalLoaderOptions,
3821
- getPathPrefix: () => getPathPrefix,
3822
- global: () => global_,
3823
- isAsyncIterable: () => isAsyncIterable,
3824
- isBrowser: () => isBrowser,
3825
- isIterable: () => isIterable,
3826
- isIterator: () => isIterator,
3827
- isPromise: () => isPromise,
3828
- isPureObject: () => isPureObject,
3829
- isReadableStream: () => isReadableStream,
3830
- isResponse: () => isResponse,
3831
- isWorker: () => isWorker,
3832
- isWritableStream: () => isWritableStream,
3833
- load: () => load,
3834
- loadInBatches: () => loadInBatches,
3835
- makeIterator: () => makeIterator,
3836
- makeLineIterator: () => makeLineIterator,
3837
- makeNumberedLineIterator: () => makeNumberedLineIterator,
3838
- makeStream: () => makeStream,
3839
- makeTextDecoderIterator: () => makeTextDecoderIterator,
3840
- makeTextEncoderIterator: () => makeTextEncoderIterator,
3841
- parse: () => parse,
3842
- parseInBatches: () => parseInBatches,
3843
- parseSync: () => parseSync,
3844
- readArrayBuffer: () => readArrayBuffer,
3845
- readFileSync: () => readFileSync,
3846
- registerLoaders: () => registerLoaders,
3847
- resolvePath: () => resolvePath,
3848
- save: () => save,
3849
- saveSync: () => saveSync,
3850
- selectLoader: () => selectLoader,
3851
- selectLoaderSync: () => selectLoaderSync,
3852
- self: () => self_,
3853
- setLoaderOptions: () => setGlobalOptions,
3854
- setPathPrefix: () => setPathPrefix,
3855
- window: () => window_,
3856
- writeFile: () => writeFile,
3857
- writeFileSync: () => writeFileSync
3858
- });
3859
- var init_src3 = __esm({
3860
- "src/index.ts"() {
3861
- init_fetch_file();
3862
- init_read_array_buffer();
3863
- init_read_file();
3864
- init_write_file();
3865
- init_loader_options();
3866
- init_register_loaders();
3867
- init_select_loader();
3868
- init_parse();
3869
- init_parse_sync();
3870
- init_parse_in_batches();
3871
- init_load();
3872
- init_load_in_batches();
3873
- init_encode_table();
3874
- init_encode();
3875
- init_encode();
3876
- init_save();
3877
- init_src2();
3878
- init_src2();
3879
- init_make_iterator();
3880
- init_make_dom_stream();
3881
- init_null_loader();
3882
- init_src2();
3883
- init_fetch_progress();
3884
- init_browser_filesystem();
3885
- init_register_loaders();
3886
- init_src2();
3887
- init_src2();
3888
- init_src2();
3889
- init_src2();
3890
- init_is_type();
3597
+ /**
3598
+ * List filenames in this filesystem
3599
+ * @param dirname
3600
+ * @returns
3601
+ */
3602
+ async readdir(dirname2) {
3603
+ const files = [];
3604
+ for (const path in this.files) {
3605
+ files.push(path);
3606
+ }
3607
+ return files;
3608
+ }
3609
+ /**
3610
+ * Return information (size) about files in this file system
3611
+ */
3612
+ async stat(path, options) {
3613
+ const file = this.files[path];
3614
+ if (!file) {
3615
+ throw new Error(path);
3616
+ }
3617
+ return {
3618
+ size: file.size
3619
+ };
3891
3620
  }
3892
- });
3893
-
3894
- // src/bundle.ts
3895
- var require_bundle = __commonJS({
3896
- "src/bundle.ts"(exports, module) {
3897
- var moduleExports = (init_src3(), src_exports);
3898
- globalThis.loaders = globalThis.loaders || {};
3899
- module.exports = Object.assign(globalThis.loaders, moduleExports);
3621
+ /**
3622
+ * Just removes the file from the list
3623
+ */
3624
+ async unlink(path) {
3625
+ delete this.files[path];
3626
+ delete this.lowerCaseFiles[path];
3627
+ this.usedFiles[path] = true;
3628
+ }
3629
+ // implements IRandomAccessFileSystem
3630
+ // RANDOM ACCESS
3631
+ async openReadableFile(pathname, flags) {
3632
+ return new BlobFile(this.files[pathname]);
3633
+ }
3634
+ // PRIVATE
3635
+ // Supports case independent paths, and file usage tracking
3636
+ _getFile(path, used) {
3637
+ const file = this.files[path] || this.lowerCaseFiles[path];
3638
+ if (file && used) {
3639
+ this.usedFiles[path] = true;
3640
+ }
3641
+ return file;
3900
3642
  }
3901
- });
3902
- require_bundle();
3643
+ };
3644
+ return __toCommonJS(src_exports);
3903
3645
  })();
3646
+ return __exports__;
3647
+ });