@loaders.gl/core 4.1.0-alpha.1 → 4.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/core-addons/write-file-browser.js.map +1 -1
  2. package/dist/dist.dev.js +46 -38
  3. package/dist/index.cjs +55 -65
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/iterators/batch-iterators/timed-batch-iterator.d.ts.map +1 -1
  7. package/dist/iterators/batch-iterators/timed-batch-iterator.js.map +1 -1
  8. package/dist/iterators/make-iterator/make-array-buffer-iterator.d.ts.map +1 -1
  9. package/dist/iterators/make-iterator/make-array-buffer-iterator.js.map +1 -1
  10. package/dist/iterators/make-iterator/make-blob-iterator.d.ts.map +1 -1
  11. package/dist/iterators/make-iterator/make-blob-iterator.js.map +1 -1
  12. package/dist/iterators/make-iterator/make-iterator.d.ts.map +1 -1
  13. package/dist/iterators/make-iterator/make-iterator.js.map +1 -1
  14. package/dist/iterators/make-iterator/make-stream-iterator.d.ts.map +1 -1
  15. package/dist/iterators/make-iterator/make-stream-iterator.js.map +1 -1
  16. package/dist/iterators/make-iterator/make-string-iterator.d.ts.map +1 -1
  17. package/dist/iterators/make-iterator/make-string-iterator.js.map +1 -1
  18. package/dist/iterators/make-stream/make-stream.d.ts.map +1 -1
  19. package/dist/iterators/make-stream/make-stream.js.map +1 -1
  20. package/dist/javascript-utils/is-type.d.ts.map +1 -1
  21. package/dist/javascript-utils/is-type.js.map +1 -1
  22. package/dist/lib/api/encode-table.d.ts.map +1 -1
  23. package/dist/lib/api/encode-table.js.map +1 -1
  24. package/dist/lib/api/encode.d.ts +6 -2
  25. package/dist/lib/api/encode.d.ts.map +1 -1
  26. package/dist/lib/api/encode.js +35 -34
  27. package/dist/lib/api/encode.js.map +1 -1
  28. package/dist/lib/api/load-in-batches.d.ts.map +1 -1
  29. package/dist/lib/api/load-in-batches.js.map +1 -1
  30. package/dist/lib/api/load.d.ts.map +1 -1
  31. package/dist/lib/api/load.js.map +1 -1
  32. package/dist/lib/api/loader-options.d.ts.map +1 -1
  33. package/dist/lib/api/loader-options.js.map +1 -1
  34. package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
  35. package/dist/lib/api/parse-in-batches.js +1 -0
  36. package/dist/lib/api/parse-in-batches.js.map +1 -1
  37. package/dist/lib/api/parse-sync.d.ts.map +1 -1
  38. package/dist/lib/api/parse-sync.js.map +1 -1
  39. package/dist/lib/api/parse.d.ts.map +1 -1
  40. package/dist/lib/api/parse.js.map +1 -1
  41. package/dist/lib/api/register-loaders.d.ts.map +1 -1
  42. package/dist/lib/api/register-loaders.js.map +1 -1
  43. package/dist/lib/api/select-loader.d.ts.map +1 -1
  44. package/dist/lib/api/select-loader.js.map +1 -1
  45. package/dist/lib/common.d.ts.map +1 -1
  46. package/dist/lib/common.js.map +1 -1
  47. package/dist/lib/fetch/fetch-error-message.d.ts.map +1 -1
  48. package/dist/lib/fetch/fetch-error-message.js.map +1 -1
  49. package/dist/lib/fetch/fetch-file.d.ts.map +1 -1
  50. package/dist/lib/fetch/fetch-file.js.map +1 -1
  51. package/dist/lib/fetch/read-array-buffer.d.ts.map +1 -1
  52. package/dist/lib/fetch/read-array-buffer.js.map +1 -1
  53. package/dist/lib/filesystems/browser-filesystem.d.ts.map +1 -1
  54. package/dist/lib/filesystems/browser-filesystem.js.map +1 -1
  55. package/dist/lib/filesystems/read-array-buffer.d.ts.map +1 -1
  56. package/dist/lib/filesystems/read-array-buffer.js.map +1 -1
  57. package/dist/lib/init.d.ts.map +1 -1
  58. package/dist/lib/init.js +1 -1
  59. package/dist/lib/init.js.map +1 -1
  60. package/dist/lib/loader-utils/check-errors.d.ts.map +1 -1
  61. package/dist/lib/loader-utils/check-errors.js.map +1 -1
  62. package/dist/lib/loader-utils/get-data.d.ts.map +1 -1
  63. package/dist/lib/loader-utils/get-data.js.map +1 -1
  64. package/dist/lib/loader-utils/get-fetch-function.d.ts.map +1 -1
  65. package/dist/lib/loader-utils/get-fetch-function.js.map +1 -1
  66. package/dist/lib/loader-utils/loader-context.d.ts.map +1 -1
  67. package/dist/lib/loader-utils/loader-context.js.map +1 -1
  68. package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
  69. package/dist/lib/loader-utils/loggers.js.map +1 -1
  70. package/dist/lib/loader-utils/normalize-loader.d.ts.map +1 -1
  71. package/dist/lib/loader-utils/normalize-loader.js.map +1 -1
  72. package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -1
  73. package/dist/lib/loader-utils/option-defaults.js.map +1 -1
  74. package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
  75. package/dist/lib/loader-utils/option-utils.js.map +1 -1
  76. package/dist/lib/progress/fetch-progress.d.ts.map +1 -1
  77. package/dist/lib/progress/fetch-progress.js.map +1 -1
  78. package/dist/lib/utils/log.d.ts.map +1 -1
  79. package/dist/lib/utils/log.js.map +1 -1
  80. package/dist/lib/utils/mime-type-utils.d.ts.map +1 -1
  81. package/dist/lib/utils/mime-type-utils.js.map +1 -1
  82. package/dist/lib/utils/resource-utils.d.ts.map +1 -1
  83. package/dist/lib/utils/resource-utils.js.map +1 -1
  84. package/dist/lib/utils/response-utils.d.ts.map +1 -1
  85. package/dist/lib/utils/response-utils.js.map +1 -1
  86. package/dist/lib/utils/url-utils.d.ts.map +1 -1
  87. package/dist/lib/utils/url-utils.js.map +1 -1
  88. package/dist/null-loader.d.ts.map +1 -1
  89. package/dist/null-loader.js +1 -1
  90. package/dist/null-loader.js.map +1 -1
  91. package/dist/null-worker-node.js +1 -1
  92. package/dist/null-worker.js +1 -1
  93. package/dist/workers/null-worker-node.js.map +1 -1
  94. package/dist/workers/null-worker.js.map +1 -1
  95. package/package.json +6 -6
  96. package/src/core-addons/write-file-browser.ts +2 -1
  97. package/src/index.ts +2 -1
  98. package/src/iterators/batch-iterators/timed-batch-iterator.ts +2 -1
  99. package/src/iterators/make-iterator/make-array-buffer-iterator.ts +2 -1
  100. package/src/iterators/make-iterator/make-blob-iterator.ts +2 -1
  101. package/src/iterators/make-iterator/make-iterator.ts +2 -1
  102. package/src/iterators/make-iterator/make-stream-iterator.ts +2 -1
  103. package/src/iterators/make-iterator/make-string-iterator.ts +2 -1
  104. package/src/iterators/make-stream/make-stream.ts +2 -1
  105. package/src/javascript-utils/is-type.ts +2 -1
  106. package/src/lib/api/encode-table.ts +2 -1
  107. package/src/lib/api/encode.ts +64 -55
  108. package/src/lib/api/load-in-batches.ts +2 -1
  109. package/src/lib/api/load.ts +2 -1
  110. package/src/lib/api/loader-options.ts +2 -1
  111. package/src/lib/api/parse-in-batches.ts +3 -1
  112. package/src/lib/api/parse-sync.ts +2 -1
  113. package/src/lib/api/parse.ts +2 -1
  114. package/src/lib/api/register-loaders.ts +2 -1
  115. package/src/lib/api/select-loader.ts +2 -1
  116. package/src/lib/common.ts +2 -1
  117. package/src/lib/fetch/fetch-error-message.ts +2 -1
  118. package/src/lib/fetch/fetch-file.ts +2 -1
  119. package/src/lib/fetch/read-array-buffer.ts +2 -1
  120. package/src/lib/filesystems/browser-filesystem.ts +2 -1
  121. package/src/lib/filesystems/read-array-buffer.ts +2 -1
  122. package/src/lib/init.ts +2 -1
  123. package/src/lib/loader-utils/check-errors.ts +2 -1
  124. package/src/lib/loader-utils/get-data.ts +2 -1
  125. package/src/lib/loader-utils/get-fetch-function.ts +2 -1
  126. package/src/lib/loader-utils/loader-context.ts +2 -1
  127. package/src/lib/loader-utils/loggers.ts +2 -1
  128. package/src/lib/loader-utils/normalize-loader.ts +2 -1
  129. package/src/lib/loader-utils/option-defaults.ts +2 -1
  130. package/src/lib/loader-utils/option-utils.ts +2 -1
  131. package/src/lib/progress/fetch-progress.ts +2 -1
  132. package/src/lib/utils/log.ts +2 -1
  133. package/src/lib/utils/mime-type-utils.ts +2 -1
  134. package/src/lib/utils/resource-utils.ts +2 -1
  135. package/src/lib/utils/response-utils.ts +2 -1
  136. package/src/lib/utils/url-utils.ts +2 -1
  137. package/src/null-loader.ts +2 -1
  138. package/src/workers/null-worker-node.ts +2 -1
  139. package/src/workers/null-worker.ts +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-progress.js","names":["fetchProgress","response","onProgress","onDone","arguments","length","undefined","onError","ok","body","contentLength","headers","get","totalBytes","parseInt","ReadableStream","getReader","progressStream","start","controller","reader","read","Response","loadedBytes","done","value","close","byteLength","percent","Math","round","enqueue","error"],"sources":["../../../src/lib/progress/fetch-progress.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// Forked from github AnthumChris/fetch-progress-indicators under MIT license\n\n/**\n * Intercepts the Response stream and creates a new Response\n */\nexport async function fetchProgress(\n response: Response | Promise<Response>,\n onProgress: any, // TODO better callback types\n onDone = () => {},\n onError = () => {}\n) {\n response = await response;\n if (!response.ok) {\n // ERROR checking needs to be done separately\n return response;\n }\n const body = response.body;\n if (!body) {\n // 'ReadableStream not yet supported in this browser.\n return response;\n }\n const contentLength = response.headers.get('content-length') || 0;\n const totalBytes = contentLength ? parseInt(contentLength) : 0;\n if (!(totalBytes > 0)) {\n return response;\n }\n // Currently override only implemented in browser\n if (typeof ReadableStream === 'undefined' || !body.getReader) {\n return response;\n }\n\n // Create a new stream that invisbly wraps original stream\n const progressStream = new ReadableStream({\n async start(controller) {\n const reader = body.getReader();\n await read(controller, reader, 0, totalBytes, onProgress, onDone, onError);\n }\n });\n\n return new Response(progressStream);\n}\n\n// Forward to original streams controller\n// TODO - this causes a crazy deep \"async stack\"... rewrite as async iterator?\n// eslint-disable-next-line max-params\nasync function read(\n controller: any,\n reader: any,\n loadedBytes: number,\n totalBytes: number,\n onProgress: Function,\n onDone: Function,\n onError: Function\n): Promise<void> {\n try {\n const {done, value} = await reader.read();\n if (done) {\n onDone();\n controller.close();\n return;\n }\n loadedBytes += value.byteLength;\n const percent = Math.round((loadedBytes / totalBytes) * 100);\n onProgress(percent, {loadedBytes, totalBytes});\n controller.enqueue(value);\n await read(controller, reader, loadedBytes, totalBytes, onProgress, onDone, onError);\n } catch (error) {\n controller.error(error);\n onError(error);\n }\n}\n"],"mappings":"AAQA,OAAO,eAAeA,aAAaA,CACjCC,QAAsC,EACtCC,UAAe,EAGf;EAAA,IAFAC,MAAM,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,MAAM,CAAC,CAAC;EAAA,IACjBG,OAAO,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,MAAM,CAAC,CAAC;EAElBH,QAAQ,GAAG,MAAMA,QAAQ;EACzB,IAAI,CAACA,QAAQ,CAACO,EAAE,EAAE;IAEhB,OAAOP,QAAQ;EACjB;EACA,MAAMQ,IAAI,GAAGR,QAAQ,CAACQ,IAAI;EAC1B,IAAI,CAACA,IAAI,EAAE;IAET,OAAOR,QAAQ;EACjB;EACA,MAAMS,aAAa,GAAGT,QAAQ,CAACU,OAAO,CAACC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC;EACjE,MAAMC,UAAU,GAAGH,aAAa,GAAGI,QAAQ,CAACJ,aAAa,CAAC,GAAG,CAAC;EAC9D,IAAI,EAAEG,UAAU,GAAG,CAAC,CAAC,EAAE;IACrB,OAAOZ,QAAQ;EACjB;EAEA,IAAI,OAAOc,cAAc,KAAK,WAAW,IAAI,CAACN,IAAI,CAACO,SAAS,EAAE;IAC5D,OAAOf,QAAQ;EACjB;EAGA,MAAMgB,cAAc,GAAG,IAAIF,cAAc,CAAC;IACxC,MAAMG,KAAKA,CAACC,UAAU,EAAE;MACtB,MAAMC,MAAM,GAAGX,IAAI,CAACO,SAAS,CAAC,CAAC;MAC/B,MAAMK,IAAI,CAACF,UAAU,EAAEC,MAAM,EAAE,CAAC,EAAEP,UAAU,EAAEX,UAAU,EAAEC,MAAM,EAAEI,OAAO,CAAC;IAC5E;EACF,CAAC,CAAC;EAEF,OAAO,IAAIe,QAAQ,CAACL,cAAc,CAAC;AACrC;AAKA,eAAeI,IAAIA,CACjBF,UAAe,EACfC,MAAW,EACXG,WAAmB,EACnBV,UAAkB,EAClBX,UAAoB,EACpBC,MAAgB,EAChBI,OAAiB,EACF;EACf,IAAI;IACF,MAAM;MAACiB,IAAI;MAAEC;IAAK,CAAC,GAAG,MAAML,MAAM,CAACC,IAAI,CAAC,CAAC;IACzC,IAAIG,IAAI,EAAE;MACRrB,MAAM,CAAC,CAAC;MACRgB,UAAU,CAACO,KAAK,CAAC,CAAC;MAClB;IACF;IACAH,WAAW,IAAIE,KAAK,CAACE,UAAU;IAC/B,MAAMC,OAAO,GAAGC,IAAI,CAACC,KAAK,CAAEP,WAAW,GAAGV,UAAU,GAAI,GAAG,CAAC;IAC5DX,UAAU,CAAC0B,OAAO,EAAE;MAACL,WAAW;MAAEV;IAAU,CAAC,CAAC;IAC9CM,UAAU,CAACY,OAAO,CAACN,KAAK,CAAC;IACzB,MAAMJ,IAAI,CAACF,UAAU,EAAEC,MAAM,EAAEG,WAAW,EAAEV,UAAU,EAAEX,UAAU,EAAEC,MAAM,EAAEI,OAAO,CAAC;EACtF,CAAC,CAAC,OAAOyB,KAAK,EAAE;IACdb,UAAU,CAACa,KAAK,CAACA,KAAK,CAAC;IACvBzB,OAAO,CAACyB,KAAK,CAAC;EAChB;AACF"}
1
+ {"version":3,"file":"fetch-progress.js","names":["fetchProgress","response","onProgress","onDone","arguments","length","undefined","onError","ok","body","contentLength","headers","get","totalBytes","parseInt","ReadableStream","getReader","progressStream","start","controller","reader","read","Response","loadedBytes","done","value","close","byteLength","percent","Math","round","enqueue","error"],"sources":["../../../src/lib/progress/fetch-progress.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Forked from github AnthumChris/fetch-progress-indicators under MIT license\n\n/**\n * Intercepts the Response stream and creates a new Response\n */\nexport async function fetchProgress(\n response: Response | Promise<Response>,\n onProgress: any, // TODO better callback types\n onDone = () => {},\n onError = () => {}\n) {\n response = await response;\n if (!response.ok) {\n // ERROR checking needs to be done separately\n return response;\n }\n const body = response.body;\n if (!body) {\n // 'ReadableStream not yet supported in this browser.\n return response;\n }\n const contentLength = response.headers.get('content-length') || 0;\n const totalBytes = contentLength ? parseInt(contentLength) : 0;\n if (!(totalBytes > 0)) {\n return response;\n }\n // Currently override only implemented in browser\n if (typeof ReadableStream === 'undefined' || !body.getReader) {\n return response;\n }\n\n // Create a new stream that invisbly wraps original stream\n const progressStream = new ReadableStream({\n async start(controller) {\n const reader = body.getReader();\n await read(controller, reader, 0, totalBytes, onProgress, onDone, onError);\n }\n });\n\n return new Response(progressStream);\n}\n\n// Forward to original streams controller\n// TODO - this causes a crazy deep \"async stack\"... rewrite as async iterator?\n// eslint-disable-next-line max-params\nasync function read(\n controller: any,\n reader: any,\n loadedBytes: number,\n totalBytes: number,\n onProgress: Function,\n onDone: Function,\n onError: Function\n): Promise<void> {\n try {\n const {done, value} = await reader.read();\n if (done) {\n onDone();\n controller.close();\n return;\n }\n loadedBytes += value.byteLength;\n const percent = Math.round((loadedBytes / totalBytes) * 100);\n onProgress(percent, {loadedBytes, totalBytes});\n controller.enqueue(value);\n await read(controller, reader, loadedBytes, totalBytes, onProgress, onDone, onError);\n } catch (error) {\n controller.error(error);\n onError(error);\n }\n}\n"],"mappings":"AASA,OAAO,eAAeA,aAAaA,CACjCC,QAAsC,EACtCC,UAAe,EAGf;EAAA,IAFAC,MAAM,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,MAAM,CAAC,CAAC;EAAA,IACjBG,OAAO,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,MAAM,CAAC,CAAC;EAElBH,QAAQ,GAAG,MAAMA,QAAQ;EACzB,IAAI,CAACA,QAAQ,CAACO,EAAE,EAAE;IAEhB,OAAOP,QAAQ;EACjB;EACA,MAAMQ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AC0B,OAAO,EAAE;MAACL,WAAW;MAAEV;IAAU,CAAC,CAAC;IAC9CM,UAAU,CAACY,OAAO,CAACN,KAAK,CAAC;IACzB,MAAMJ,IAAI,CAACF,UAAU,EAAEC,MAAM,EAAEG,WAAW,EAAEV,UAAU,EAAEX,UAAU,EAAEC,MAAM,EAAEI,OAAO,CAAC;EACtF,CAAC,CAAC,OAAOyB,KAAK,EAAE;IACdb,UAAU,CAACa,KAAK,CAACA,KAAK,CAAC;IACvBzB,OAAO,CAACyB,KAAK,CAAC;EAChB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/log.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,GAAG,EAAC,MAAM,eAAe,CAAC;AAElC,eAAO,MAAM,GAAG,KAA8B,CAAC"}
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/log.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,GAAG,EAAC,MAAM,eAAe,CAAC;AAElC,eAAO,MAAM,GAAG,KAA8B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"log.js","names":["Log","log","id"],"sources":["../../../src/lib/utils/log.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {Log} from '@probe.gl/log';\n\nexport const log = new Log({id: 'loaders.gl'});\n"],"mappings":"AAGA,SAAQA,GAAG,QAAO,eAAe;AAEjC,OAAO,MAAMC,GAAG,GAAG,IAAID,GAAG,CAAC;EAACE,EAAE,EAAE;AAAY,CAAC,CAAC"}
1
+ {"version":3,"file":"log.js","names":["Log","log","id"],"sources":["../../../src/lib/utils/log.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Log} from '@probe.gl/log';\n\nexport const log = new Log({id: 'loaders.gl'});\n"],"mappings":"AAIA,SAAQA,GAAG,QAAO,eAAe;AAEjC,OAAO,MAAMC,GAAG,GAAG,IAAID,GAAG,CAAC;EAACE,EAAE,EAAE;AAAY,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mime-type-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/mime-type-utils.ts"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAOxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOxD"}
1
+ {"version":3,"file":"mime-type-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/mime-type-utils.ts"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAOxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"mime-type-utils.js","names":["DATA_URL_PATTERN","MIME_TYPE_PATTERN","parseMIMEType","mimeString","matches","exec","parseMIMETypeFromURL","url"],"sources":["../../../src/lib/utils/mime-type-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// TODO - build/integrate proper MIME type parsing\n// https://mimesniff.spec.whatwg.org/\n\nconst DATA_URL_PATTERN = /^data:([-\\w.]+\\/[-\\w.+]+)(;|,)/;\nconst MIME_TYPE_PATTERN = /^([-\\w.]+\\/[-\\w.+]+)/;\n\n/**\n * Remove extra data like `charset` from MIME types\n * @param mimeString\n * @returns A clean MIME type, or an empty string\n *\n * @todo - handle more advanced MIMETYpes, multiple types\n * @todo - extract charset etc\n */\nexport function parseMIMEType(mimeString: string): string {\n // If resource is a data url, extract any embedded mime type\n const matches = MIME_TYPE_PATTERN.exec(mimeString);\n if (matches) {\n return matches[1];\n }\n return mimeString;\n}\n\n/**\n * Extract MIME type from data URL\n *\n * @param mimeString\n * @returns A clean MIME type, or an empty string\n *\n * @todo - handle more advanced MIMETYpes, multiple types\n * @todo - extract charset etc\n */\nexport function parseMIMETypeFromURL(url: string): string {\n // If resource is a data URL, extract any embedded mime type\n const matches = DATA_URL_PATTERN.exec(url);\n if (matches) {\n return matches[1];\n }\n return '';\n}\n"],"mappings":"AAMA,MAAMA,gBAAgB,GAAG,gCAAgC;AACzD,MAAMC,iBAAiB,GAAG,sBAAsB;AAUhD,OAAO,SAASC,aAAaA,CAACC,UAAkB,EAAU;EAExD,MAAMC,OAAO,GAAGH,iBAAiB,CAACI,IAAI,CAACF,UAAU,CAAC;EAClD,IAAIC,OAAO,EAAE;IACX,OAAOA,OAAO,CAAC,CAAC,CAAC;EACnB;EACA,OAAOD,UAAU;AACnB;AAWA,OAAO,SAASG,oBAAoBA,CAACC,GAAW,EAAU;EAExD,MAAMH,OAAO,GAAGJ,gBAAgB,CAACK,IAAI,CAACE,GAAG,CAAC;EAC1C,IAAIH,OAAO,EAAE;IACX,OAAOA,OAAO,CAAC,CAAC,CAAC;EACnB;EACA,OAAO,EAAE;AACX"}
1
+ {"version":3,"file":"mime-type-utils.js","names":["DATA_URL_PATTERN","MIME_TYPE_PATTERN","parseMIMEType","mimeString","matches","exec","parseMIMETypeFromURL","url"],"sources":["../../../src/lib/utils/mime-type-utils.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// TODO - build/integrate proper MIME type parsing\n// https://mimesniff.spec.whatwg.org/\n\nconst DATA_URL_PATTERN = /^data:([-\\w.]+\\/[-\\w.+]+)(;|,)/;\nconst MIME_TYPE_PATTERN = /^([-\\w.]+\\/[-\\w.+]+)/;\n\n/**\n * Remove extra data like `charset` from MIME types\n * @param mimeString\n * @returns A clean MIME type, or an empty string\n *\n * @todo - handle more advanced MIMETYpes, multiple types\n * @todo - extract charset etc\n */\nexport function parseMIMEType(mimeString: string): string {\n // If resource is a data url, extract any embedded mime type\n const matches = MIME_TYPE_PATTERN.exec(mimeString);\n if (matches) {\n return matches[1];\n }\n return mimeString;\n}\n\n/**\n * Extract MIME type from data URL\n *\n * @param mimeString\n * @returns A clean MIME type, or an empty string\n *\n * @todo - handle more advanced MIMETYpes, multiple types\n * @todo - extract charset etc\n */\nexport function parseMIMETypeFromURL(url: string): string {\n // If resource is a data URL, extract any embedded mime type\n const matches = DATA_URL_PATTERN.exec(url);\n if (matches) {\n return matches[1];\n }\n return '';\n}\n"],"mappings":"AAOA,MAAMA,gBAAgB,GAAG,gCAAgC;AACzD,MAAMC,iBAAiB,GAAG,sBAAsB;AAUhD,OAAO,SAASC,aAAaA,CAACC,UAAkB,EAAU;EAExD,MAAMC,OAAO,GAAGH,iBAAiB,CAACI,IAAI,CAACF,UAAU,CAAC;EAClD,IAAIC,OAAO,EAAE;IACX,OAAOA,OAAO,CAAC,CAAC,CAAC;EACnB;EACA,OAAOD,UAAU;AACnB;AAWA,OAAO,SAASG,oBAAoBA,CAACC,GAAW,EAAU;EAExD,MAAMH,OAAO,GAAGJ,gBAAgB,CAACK,IAAI,CAACE,GAAG,CAAC;EAC1C,IAAIH,OAAO,EAAE;IACX,OAAOA,OAAO,CAAC,CAAC,CAAC;EACnB;EACA,OAAO,EAAE;AACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"resource-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/resource-utils.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;AAEhD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAqBxD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAqB7D;AAED;;;;;;IAMI;AACJ,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAoBlE"}
1
+ {"version":3,"file":"resource-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/resource-utils.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;AAEhD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAqBxD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAqB7D;AAED;;;;;;IAMI;AACJ,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAoBlE"}
@@ -1 +1 @@
1
- {"version":3,"file":"resource-utils.js","names":["isResponse","isBlob","parseMIMEType","parseMIMETypeFromURL","stripQueryString","getResourceUrl","resource","response","url","blob","name","getResourceMIMEType","contentTypeHeader","headers","get","noQueryUrl","type","getResourceContentLength","size","length","ArrayBuffer","byteLength","isView"],"sources":["../../../src/lib/utils/resource-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {isResponse, isBlob} from '../../javascript-utils/is-type';\nimport {parseMIMEType, parseMIMETypeFromURL} from './mime-type-utils';\nimport {stripQueryString} from './url-utils';\n\n/**\n * A loadable resource. Includes:\n * `Response`, `Blob` (`File` is a subclass), string URLs and data URLs\n */\nexport type Resource = Response | Blob | string;\n\n/**\n * Returns the URL associated with this resource.\n * The returned value may include a query string and need further processing.\n * If it cannot determine url, the corresponding value will be an empty string\n *\n * @todo string parameters are assumed to be URLs\n */\nexport function getResourceUrl(resource: unknown): string {\n // If resource is a `Response`, it contains the information directly as a field\n if (isResponse(resource)) {\n const response = resource as Response;\n return response.url;\n }\n\n // If the resource is a Blob or a File (subclass of Blob)\n if (isBlob(resource)) {\n const blob = resource as Blob;\n // File objects have a \"name\" property. Blob objects don't have any\n // url (name) information\n return blob.name || '';\n }\n\n if (typeof resource === 'string') {\n return resource;\n }\n\n // Unknown\n return '';\n}\n\n/**\n * Returns the URL associated with this resource.\n * The returned value may include a query string and need further processing.\n * If it cannot determine url, the corresponding value will be an empty string\n *\n * @todo string parameters are assumed to be URLs\n */\nexport function getResourceMIMEType(resource: unknown): string {\n // If resource is a response, it contains the information directly\n if (isResponse(resource)) {\n const response = resource as Response;\n const contentTypeHeader = response.headers.get('content-type') || '';\n const noQueryUrl = stripQueryString(response.url);\n return parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(noQueryUrl);\n }\n\n // If the resource is a Blob or a File (subclass of Blob)\n if (isBlob(resource)) {\n const blob = resource as Blob;\n return blob.type || '';\n }\n\n if (typeof resource === 'string') {\n return parseMIMETypeFromURL(resource);\n }\n\n // Unknown\n return '';\n}\n\n/**\n * Returns (approximate) content length for a resource if it can be determined.\n * Returns -1 if content length cannot be determined.\n * @param resource\n\n * @note string parameters are NOT assumed to be URLs\n */\nexport function getResourceContentLength(resource: unknown): number {\n if (isResponse(resource)) {\n const response = resource as Response;\n return response.headers['content-length'] || -1;\n }\n if (isBlob(resource)) {\n const blob = resource as Blob;\n return blob.size;\n }\n if (typeof resource === 'string') {\n // TODO - handle data URL?\n return resource.length;\n }\n if (resource instanceof ArrayBuffer) {\n return resource.byteLength;\n }\n if (ArrayBuffer.isView(resource)) {\n return resource.byteLength;\n }\n return -1;\n}\n"],"mappings":"SAGQA,UAAU,EAAEC,MAAM;AAAA,SAClBC,aAAa,EAAEC,oBAAoB;AAAA,SACnCC,gBAAgB;AAexB,OAAO,SAASC,cAAcA,CAACC,QAAiB,EAAU;EAExD,IAAIN,UAAU,CAACM,QAAQ,CAAC,EAAE;IACxB,MAAMC,QAAQ,GAAGD,QAAoB;IACrC,OAAOC,QAAQ,CAACC,GAAG;EACrB;EAGA,IAAIP,MAAM,CAACK,QAAQ,CAAC,EAAE;IACpB,MAAMG,IAAI,GAAGH,QAAgB;IAG7B,OAAOG,IAAI,CAACC,IAAI,IAAI,EAAE;EACxB;EAEA,IAAI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C,OAAOA,QAAQ,CAACe,UAAU;EAC5B;EACA,OAAO,CAAC,CAAC;AACX"}
1
+ {"version":3,"file":"resource-utils.js","names":["isResponse","isBlob","parseMIMEType","parseMIMETypeFromURL","stripQueryString","getResourceUrl","resource","response","url","blob","name","getResourceMIMEType","contentTypeHeader","headers","get","noQueryUrl","type","getResourceContentLength","size","length","ArrayBuffer","byteLength","isView"],"sources":["../../../src/lib/utils/resource-utils.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {isResponse, isBlob} from '../../javascript-utils/is-type';\nimport {parseMIMEType, parseMIMETypeFromURL} from './mime-type-utils';\nimport {stripQueryString} from './url-utils';\n\n/**\n * A loadable resource. Includes:\n * `Response`, `Blob` (`File` is a subclass), string URLs and data URLs\n */\nexport type Resource = Response | Blob | string;\n\n/**\n * Returns the URL associated with this resource.\n * The returned value may include a query string and need further processing.\n * If it cannot determine url, the corresponding value will be an empty string\n *\n * @todo string parameters are assumed to be URLs\n */\nexport function getResourceUrl(resource: unknown): string {\n // If resource is a `Response`, it contains the information directly as a field\n if (isResponse(resource)) {\n const response = resource as Response;\n return response.url;\n }\n\n // If the resource is a Blob or a File (subclass of Blob)\n if (isBlob(resource)) {\n const blob = resource as Blob;\n // File objects have a \"name\" property. Blob objects don't have any\n // url (name) information\n return blob.name || '';\n }\n\n if (typeof resource === 'string') {\n return resource;\n }\n\n // Unknown\n return '';\n}\n\n/**\n * Returns the URL associated with this resource.\n * The returned value may include a query string and need further processing.\n * If it cannot determine url, the corresponding value will be an empty string\n *\n * @todo string parameters are assumed to be URLs\n */\nexport function getResourceMIMEType(resource: unknown): string {\n // If resource is a response, it contains the information directly\n if (isResponse(resource)) {\n const response = resource as Response;\n const contentTypeHeader = response.headers.get('content-type') || '';\n const noQueryUrl = stripQueryString(response.url);\n return parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(noQueryUrl);\n }\n\n // If the resource is a Blob or a File (subclass of Blob)\n if (isBlob(resource)) {\n const blob = resource as Blob;\n return blob.type || '';\n }\n\n if (typeof resource === 'string') {\n return parseMIMETypeFromURL(resource);\n }\n\n // Unknown\n return '';\n}\n\n/**\n * Returns (approximate) content length for a resource if it can be determined.\n * Returns -1 if content length cannot be determined.\n * @param resource\n\n * @note string parameters are NOT assumed to be URLs\n */\nexport function getResourceContentLength(resource: unknown): number {\n if (isResponse(resource)) {\n const response = resource as Response;\n return response.headers['content-length'] || -1;\n }\n if (isBlob(resource)) {\n const blob = resource as Blob;\n return blob.size;\n }\n if (typeof resource === 'string') {\n // TODO - handle data URL?\n return resource.length;\n }\n if (resource instanceof ArrayBuffer) {\n return resource.byteLength;\n }\n if (ArrayBuffer.isView(resource)) {\n return resource.byteLength;\n }\n return -1;\n}\n"],"mappings":"SAIQA,UAAU,EAAEC,MAAM;AAAA,SAClBC,aAAa,EAAEC,oBAAoB;AAAA,SACnCC,gBAAgB;AAexB,OAAO,SAASC,cAAcA,CAACC,QAAiB,EAAU;EAExD,IAAIN,UAAU,CAACM,QAAQ,CAAC,EAAE;IACxB,MAAMC,QAAQ,GAAGD,QAAoB;IACrC,OAAOC,QAAQ,CAACC,GAAG;EACrB;EAGA,IAAIP,MAAM,CAACK,QAAQ,CAAC,EAAE;IACpB,MAAMG,IAAI,GAAGH,QAAgB;IAG7B,OAAOG,IAAI,CAACC,IAAI,IAAI,EAAE;EACxB;EAEA,IAAI,OAAOJ,QAAQ,KAAK,QAAQ,EAAE;IAChC,OAAOA,QAAQ;EACjB;EAGA,OAAO,EAAE;AACX;AASA,OAAO,SAASK,mBAAmBA,CAACL,QAAiB,EAAU;EAE7D,IAAIN,UAAU,CAACM,QAAQ,CAAC,EAAE;IACxB,MAAMC,QAAQ,GAAGD,QAAoB;IACrC,MAAMM,iBAAiB,GAAGL,QAAQ,CAACM,OAAO,CAACC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE;IACpE,MAAMC,UAAU,GAAGX,gBAAgB,CAACG,QAAQ,C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CAKrE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAM1D"}
1
+ {"version":3,"file":"response-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/response-utils.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuCvE;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAKrE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAM1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"response-utils.js","names":["isResponse","getResourceContentLength","getResourceUrl","getResourceMIMEType","makeResponse","resource","headers","contentLength","String","url","type","initialDataUrl","getInitialDataUrl","TextEncoder","encode","response","Response","Object","defineProperty","value","checkResponse","ok","message","getResponseError","Error","checkResponseSync","status","statusText","length","slice","contentType","get","text","includes","error","INITIAL_DATA_LENGTH","Blob","blobSlice","Promise","resolve","reader","FileReader","onload","event","_event$target","target","result","readAsDataURL","ArrayBuffer","base64","arrayBufferToBase64","buffer","binary","bytes","Uint8Array","i","byteLength","fromCharCode","btoa"],"sources":["../../../src/lib/utils/response-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {isResponse} from '../../javascript-utils/is-type';\nimport {getResourceContentLength, getResourceUrl, getResourceMIMEType} from './resource-utils';\n\n/**\n * Returns a Response object\n * Adds content-length header when possible\n *\n * @param resource\n */\nexport async function makeResponse(resource: unknown): Promise<Response> {\n if (isResponse(resource)) {\n return resource as Response;\n }\n\n // Add content-length header if possible\n const headers: {[header: string]: string} = {};\n\n const contentLength = getResourceContentLength(resource);\n if (contentLength >= 0) {\n headers['content-length'] = String(contentLength);\n }\n\n // `new Response(File)` does not preserve content-type and URL\n // so we add them here\n const url = getResourceUrl(resource);\n const type = getResourceMIMEType(resource);\n if (type) {\n headers['content-type'] = type;\n }\n\n // Add a custom header with initial bytes if available\n const initialDataUrl = await getInitialDataUrl(resource);\n if (initialDataUrl) {\n headers['x-first-bytes'] = initialDataUrl;\n }\n\n // TODO - is this the best way of handling strings?\n // Maybe package as data URL instead?\n if (typeof resource === 'string') {\n // Convert to ArrayBuffer to avoid Response treating it as a URL\n resource = new TextEncoder().encode(resource);\n }\n\n // Attempt to create a Response from the resource, adding headers and setting url\n const response = new Response(resource as any, {headers});\n // We can't control `Response.url` via constructor, use a property override to record URL.\n Object.defineProperty(response, 'url', {value: url});\n return response;\n}\n\n/**\n * Checks response status (async) and throws a helpful error message if status is not OK.\n * @param response\n */\nexport async function checkResponse(response: Response): Promise<void> {\n if (!response.ok) {\n const message = await getResponseError(response);\n throw new Error(message);\n }\n}\n\n/**\n * Checks response status (sync) and throws a helpful error message if status is not OK.\n * @param response\n */\nexport function checkResponseSync(response: Response): void {\n if (!response.ok) {\n let message = `${response.status} ${response.statusText}`;\n message = message.length > 60 ? `${message.slice(0, 60)}...` : message;\n throw new Error(message);\n }\n}\n\n// HELPERS\n\nasync function getResponseError(response: Response): Promise<string> {\n let message = `Failed to fetch resource ${response.url} (${response.status}): `;\n try {\n const contentType = response.headers.get('Content-Type');\n let text = response.statusText;\n if (contentType?.includes('application/json')) {\n text += ` ${await response.text()}`;\n }\n message += text;\n message = message.length > 60 ? `${message.slice(0, 60)}...` : message;\n } catch (error) {\n // eslint forbids return in a finally statement, so we just catch here\n }\n return message;\n}\n\nasync function getInitialDataUrl(\n resource: string | Blob | ArrayBuffer | unknown\n): Promise<string | null> {\n const INITIAL_DATA_LENGTH = 5;\n if (typeof resource === 'string') {\n return `data:,${resource.slice(0, INITIAL_DATA_LENGTH)}`;\n }\n if (resource instanceof Blob) {\n const blobSlice = resource.slice(0, 5);\n return await new Promise((resolve) => {\n const reader = new FileReader();\n reader.onload = (event) => resolve(event?.target?.result as string);\n reader.readAsDataURL(blobSlice);\n });\n }\n if (resource instanceof ArrayBuffer) {\n const slice = resource.slice(0, INITIAL_DATA_LENGTH);\n const base64 = arrayBufferToBase64(slice);\n return `data:base64,${base64}`;\n }\n return null;\n}\n\n// https://stackoverflow.com/questions/9267899/arraybuffer-to-base64-encoded-string\nfunction arrayBufferToBase64(buffer: ArrayBuffer): string {\n let binary = '';\n const bytes = new Uint8Array(buffer);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n"],"mappings":"SAGQA,UAAU;AAAA,SACVC,wBAAwB,EAAEC,cAAc,EAAEC,mBAAmB;AAQrE,OAAO,eAAeC,YAAYA,CAACC,QAAiB,EAAqB;EACvE,IAAIL,UAAU,CAACK,QAAQ,CAAC,EAAE;IACxB,OAAOA,QAAQ;EACjB;EAGA,MAAMC,OAAmC,GAAG,CAAC,CAAC;EAE9C,MAAMC,aAAa,GAAGN,wBAAwB,CAACI,QAAQ,CAAC;EACxD,IAAIE,aAAa,IAAI,CAAC,EAAE;IACtBD,OAAO,CAAC,gBAAgB,CAAC,GAAGE,MAAM,CAACD,aAAa,CAAC;EACnD;EAIA,MAAME,GAAG,GAAGP,cAAc,CAACG,QAAQ,CAAC;EACpC,MAAMK,IAAI,GAAGP,mBAAmB,CAACE,QAAQ,CAAC;EAC1C,IAAIK,IAAI,EAAE;IACRJ,OAAO,CAAC,cAAc,CAAC,GAAGI,IAAI;EAChC;EAGA,MAAMC,cAAc,GAAG,MAAMC,iBAAiB,CAACP,QAAQ,CAAC;EACxD,IAAIM,cAAc,EAAE;IAClBL,OAAO,CAAC,eAAe,CAAC,GAAGK,cAAc;EAC3C;EAIA,IAAI,OAAON,QAAQ,KAAK,QAAQ,EAAE;IAEhCA,QAAQ,GAAG,IAAIQ,WAAW,CAAC,CAAC,CAACC,MAAM,CAACT,QAAQ,CAAC;EAC/C;EAGA,MAAMU,QAAQ,GAAG,IAAIC,QAA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ACpC,KAAK,IAAII,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,KAAK,CAACG,UAAU,EAAED,CAAC,EAAE,EAAE;IACzCH,MAAM,IAAI5C,MAAM,CAACiD,YAAY,CAACJ,KAAK,CAACE,CAAC,CAAC,CAAC;EACzC;EACA,OAAOG,IAAI,CAACN,MAAM,CAAC;AACrB"}
1
+ {"version":3,"file":"response-utils.js","names":["isResponse","getResourceContentLength","getResourceUrl","getResourceMIMEType","makeResponse","resource","headers","contentLength","String","url","type","initialDataUrl","getInitialDataUrl","TextEncoder","encode","response","Response","Object","defineProperty","value","checkResponse","ok","message","getResponseError","Error","checkResponseSync","status","statusText","length","slice","contentType","get","text","includes","error","INITIAL_DATA_LENGTH","Blob","blobSlice","Promise","resolve","reader","FileReader","onload","event","_event$target","target","result","readAsDataURL","ArrayBuffer","base64","arrayBufferToBase64","buffer","binary","bytes","Uint8Array","i","byteLength","fromCharCode","btoa"],"sources":["../../../src/lib/utils/response-utils.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {isResponse} from '../../javascript-utils/is-type';\nimport {getResourceContentLength, getResourceUrl, getResourceMIMEType} from './resource-utils';\n\n/**\n * Returns a Response object\n * Adds content-length header when possible\n *\n * @param resource\n */\nexport async function makeResponse(resource: unknown): Promise<Response> {\n if (isResponse(resource)) {\n return resource as Response;\n }\n\n // Add content-length header if possible\n const headers: {[header: string]: string} = {};\n\n const contentLength = getResourceContentLength(resource);\n if (contentLength >= 0) {\n headers['content-length'] = String(contentLength);\n }\n\n // `new Response(File)` does not preserve content-type and URL\n // so we add them here\n const url = getResourceUrl(resource);\n const type = getResourceMIMEType(resource);\n if (type) {\n headers['content-type'] = type;\n }\n\n // Add a custom header with initial bytes if available\n const initialDataUrl = await getInitialDataUrl(resource);\n if (initialDataUrl) {\n headers['x-first-bytes'] = initialDataUrl;\n }\n\n // TODO - is this the best way of handling strings?\n // Maybe package as data URL instead?\n if (typeof resource === 'string') {\n // Convert to ArrayBuffer to avoid Response treating it as a URL\n resource = new TextEncoder().encode(resource);\n }\n\n // Attempt to create a Response from the resource, adding headers and setting url\n const response = new Response(resource as any, {headers});\n // We can't control `Response.url` via constructor, use a property override to record URL.\n Object.defineProperty(response, 'url', {value: url});\n return response;\n}\n\n/**\n * Checks response status (async) and throws a helpful error message if status is not OK.\n * @param response\n */\nexport async function checkResponse(response: Response): Promise<void> {\n if (!response.ok) {\n const message = await getResponseError(response);\n throw new Error(message);\n }\n}\n\n/**\n * Checks response status (sync) and throws a helpful error message if status is not OK.\n * @param response\n */\nexport function checkResponseSync(response: Response): void {\n if (!response.ok) {\n let message = `${response.status} ${response.statusText}`;\n message = message.length > 60 ? `${message.slice(0, 60)}...` : message;\n throw new Error(message);\n }\n}\n\n// HELPERS\n\nasync function getResponseError(response: Response): Promise<string> {\n let message = `Failed to fetch resource ${response.url} (${response.status}): `;\n try {\n const contentType = response.headers.get('Content-Type');\n let text = response.statusText;\n if (contentType?.includes('application/json')) {\n text += ` ${await response.text()}`;\n }\n message += text;\n message = message.length > 60 ? `${message.slice(0, 60)}...` : message;\n } catch (error) {\n // eslint forbids return in a finally statement, so we just catch here\n }\n return message;\n}\n\nasync function getInitialDataUrl(\n resource: string | Blob | ArrayBuffer | unknown\n): Promise<string | null> {\n const INITIAL_DATA_LENGTH = 5;\n if (typeof resource === 'string') {\n return `data:,${resource.slice(0, INITIAL_DATA_LENGTH)}`;\n }\n if (resource instanceof Blob) {\n const blobSlice = resource.slice(0, 5);\n return await new Promise((resolve) => {\n const reader = new FileReader();\n reader.onload = (event) => resolve(event?.target?.result as string);\n reader.readAsDataURL(blobSlice);\n });\n }\n if (resource instanceof ArrayBuffer) {\n const slice = resource.slice(0, INITIAL_DATA_LENGTH);\n const base64 = arrayBufferToBase64(slice);\n return `data:base64,${base64}`;\n }\n return null;\n}\n\n// https://stackoverflow.com/questions/9267899/arraybuffer-to-base64-encoded-string\nfunction arrayBufferToBase64(buffer: ArrayBuffer): string {\n let binary = '';\n const bytes = new Uint8Array(buffer);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n"],"mappings":"SAIQA,UAAU;AAAA,SACVC,wBAAwB,EAAEC,cAAc,EAAEC,mBAAmB;AAQrE,OAAO,eAAeC,YAAYA,CAACC,QAAiB,EAAqB;EACvE,IAAIL,UAAU,CAACK,QAAQ,CAAC,EAAE;IACxB,OAAOA,QAAQ;EACjB;EAGA,MAAMC,OAAmC,GAAG,CAAC,CAAC;EAE9C,MAAMC,aAAa,GAAGN,wBAAwB,CAACI,QAAQ,CAAC;EACxD,IAAIE,aAAa,IAAI,CAAC,EAAE;IACtBD,OAAO,CAAC,gBAAgB,CAAC,GAAGE,MAAM,CAACD,aAAa,CAAC;EACnD;EAIA,MAAME,GAAG,GAAGP,cAAc,CAACG,QAAQ,CAAC;EACpC,MAAMK,IAAI,GAAGP,mBAAmB,CAACE,QAAQ,CAAC;EAC1C,IAAIK,IAAI,EAAE;IACRJ,OAAO,CAAC,cAAc,CAAC,GAAGI,IAAI;EAChC;EAGA,MAAMC,cAAc,GAAG,MAAMC,iBAAiB,CAACP,QAAQ,CAAC;EACxD,IAAIM,cAAc,EAAE;IAClBL,OAAO,CAAC,eAAe,CAAC,GAAGK,cAAc;EAC3C;EAIA,IAAI,OAAON,QAAQ,KAAK,QAAQ,EAAE;IAEhCA,QAAQ,GAAG,IAAIQ,WAAW,CAAC,CAAC,CAACC,MAAM,CAACT,QAAQ,CAAC;EAC/C;EAGA,MAAMU,QAAQ,GAAG,IAAIC,QAAQ,CAACX,QAAQ,EAAS;IAACC;EAAO,CAAC,CAAC;EAEzDW,MAAM,CAACC,cAAc,CAACH,QAAQ,EAAE,KAAK,EAAE;IAACI,KAAK,EAAEV;EAAG,CAAC,CAAC;EACpD,OAAOM,QAAQ;AACjB;AAMA,OAAO,eAAeK,aAAaA,CAACL,QAAkB,EAAiB;EACrE,IA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}
@@ -1 +1 @@
1
- {"version":3,"file":"url-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/url-utils.ts"],"names":[],"mappings":"AAKA,wBAAgB,kBAAkB,CAAC,GAAG,KAAA,GAAG,MAAM,CAG9C;AAED,wBAAgB,gBAAgB,CAAC,GAAG,KAAA,GAAG,MAAM,CAE5C"}
1
+ {"version":3,"file":"url-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/url-utils.ts"],"names":[],"mappings":"AAMA,wBAAgB,kBAAkB,CAAC,GAAG,KAAA,GAAG,MAAM,CAG9C;AAED,wBAAgB,gBAAgB,CAAC,GAAG,KAAA,GAAG,MAAM,CAE5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"url-utils.js","names":["QUERY_STRING_PATTERN","extractQueryString","url","matches","match","stripQueryString","replace"],"sources":["../../../src/lib/utils/url-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nconst QUERY_STRING_PATTERN = /\\?.*/;\n\nexport function extractQueryString(url): string {\n const matches = url.match(QUERY_STRING_PATTERN);\n return matches && matches[0];\n}\n\nexport function stripQueryString(url): string {\n return url.replace(QUERY_STRING_PATTERN, '');\n}\n"],"mappings":"AAGA,MAAMA,oBAAoB,GAAG,MAAM;AAEnC,OAAO,SAASC,kBAAkBA,CAACC,GAAG,EAAU;EAC9C,MAAMC,OAAO,GAAGD,GAAG,CAACE,KAAK,CAACJ,oBAAoB,CAAC;EAC/C,OAAOG,OAAO,IAAIA,OAAO,CAAC,CAAC,CAAC;AAC9B;AAEA,OAAO,SAASE,gBAAgBA,CAACH,GAAG,EAAU;EAC5C,OAAOA,GAAG,CAACI,OAAO,CAACN,oBAAoB,EAAE,EAAE,CAAC;AAC9C"}
1
+ {"version":3,"file":"url-utils.js","names":["QUERY_STRING_PATTERN","extractQueryString","url","matches","match","stripQueryString","replace"],"sources":["../../../src/lib/utils/url-utils.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nconst QUERY_STRING_PATTERN = /\\?.*/;\n\nexport function extractQueryString(url): string {\n const matches = url.match(QUERY_STRING_PATTERN);\n return matches && matches[0];\n}\n\nexport function stripQueryString(url): string {\n return url.replace(QUERY_STRING_PATTERN, '');\n}\n"],"mappings":"AAIA,MAAMA,oBAAoB,GAAG,MAAM;AAEnC,OAAO,SAASC,kBAAkBA,CAACC,GAAG,EAAU;EAC9C,MAAMC,OAAO,GAAGD,GAAG,CAACE,KAAK,CAACJ,oBAAoB,CAAC;EAC/C,OAAOG,OAAO,IAAIA,OAAO,CAAC,CAAC,CAAC;AAC9B;AAEA,OAAO,SAASE,gBAAgBA,CAACH,GAAG,EAAU;EAC5C,OAAOA,GAAG,CAACI,OAAO,CAACN,oBAAoB,EAAE,EAAE,CAAC;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"null-loader.d.ts","sourceRoot":"","sources":["../src/null-loader.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAGtF,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC9C,IAAI,CAAC,EAAE,EAAE,CAAC;CACX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,iBAAiB,CAYnE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,iBAAiB,CAmBtE,CAAC"}
1
+ {"version":3,"file":"null-loader.d.ts","sourceRoot":"","sources":["../src/null-loader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAGtF,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC9C,IAAI,CAAC,EAAE,EAAE,CAAC;CACX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,iBAAiB,CAYnE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,iBAAiB,CAmBtE,CAAC"}
@@ -1,4 +1,4 @@
1
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
1
+ const VERSION = typeof "4.1.0-alpha.10" !== 'undefined' ? "4.1.0-alpha.10" : 'latest';
2
2
  export const NullWorkerLoader = {
3
3
  name: 'Null loader',
4
4
  id: 'null',
@@ -1 +1 @@
1
- {"version":3,"file":"null-loader.js","names":["VERSION","__VERSION__","NullWorkerLoader","name","id","module","version","worker","mimeTypes","extensions","tests","options","null","NullLoader","parse","arrayBuffer","context","parseSync","parseInBatches","generator","asyncIterator","batch"],"sources":["../src/null-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nimport type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {LoaderContext} from '@loaders.gl/loader-utils';\n\nexport type NullLoaderOptions = LoaderOptions & {\n null?: {};\n};\n\n/**\n * Loads any data and returns null (or optionally passes through data unparsed)\n */\nexport const NullWorkerLoader: Loader<null, never, NullLoaderOptions> = {\n name: 'Null loader',\n id: 'null',\n module: 'core',\n version: VERSION,\n worker: true,\n mimeTypes: ['application/x.empty'],\n extensions: ['null'],\n tests: [() => false],\n options: {\n null: {}\n }\n};\n\n/**\n * Loads any data and returns null (or optionally passes through data unparsed)\n */\nexport const NullLoader: LoaderWithParser<null, null, NullLoaderOptions> = {\n name: 'Null loader',\n id: 'null',\n module: 'core',\n version: VERSION,\n mimeTypes: ['application/x.empty'],\n extensions: ['null'],\n parse: async (arrayBuffer: ArrayBuffer, options?: NullLoaderOptions, context?: LoaderContext) =>\n parseSync(arrayBuffer, options || {}, context),\n parseSync,\n parseInBatches: async function* generator(asyncIterator, options, context) {\n for await (const batch of asyncIterator) {\n yield parseSync(batch, options, context);\n }\n },\n tests: [() => false],\n options: {\n null: {}\n }\n};\n\n/**\n * Returns arguments passed to the parse API in a format that can be transferred to a\n * web worker. The `context` parameter is stripped using JSON.stringify & parse.\n */\nfunction parseSync(\n arrayBuffer: ArrayBuffer,\n options?: NullLoaderOptions,\n context?: LoaderContext\n): null {\n return null;\n}\n"],"mappings":"AAKA,MAAMA,OAAO,GAAG,OAAOC,WAAW,KAAK,WAAW,GAAGA,WAAW,GAAG,QAAQ;AAY3E,OAAO,MAAMC,gBAAwD,GAAG;EACtEC,IAAI,EAAE,aAAa;EACnBC,EAAE,EAAE,MAAM;EACVC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAEN,OAAO;EAChBO,MAAM,EAAE,IAAI;EACZC,SAAS,EAAE,CAAC,qBAAqB,CAAC;EAClCC,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,KAAK,EAAE,CAAC,MAAM,KAAK,CAAC;EACpBC,OAAO,EAAE;IACPC,IAAI,EAAE,CAAC;EACT;AACF,CAAC;AAKD,OAAO,MAAMC,UAA2D,GAAG;EACzEV,IAAI,EAAE,aAAa;EACnBC,EAAE,EAAE,MAAM;EACVC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAEN,OAAO;EAChBQ,SAAS,EAAE,CAAC,qBAAqB,CAAC;EAClCC,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBK,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEJ,OAA2B,EAAEK,OAAuB,KAC1FC,SAAS,CAACF,WAAW,EAAEJ,OAAO,IAAI,CAAC,CAAC,EAAEK,OAAO,CAAC;EAChDC,SAAS;EACTC,cAAc,EAAE,gBAAgBC,SAASA,CAACC,aAAa,EAAET,OAAO,EAAEK,OAAO,EAAE;IACzE,WAAW,MAAMK,KAAK,IAAID,aAAa,EAAE;MACvC,MAAMH,SAAS,CAACI,KAAK,EAAEV,OAAO,EAAEK,OAAO,CAAC;IAC1C;EACF,CAAC;EACDN,KAAK,EAAE,CAAC,MAAM,KAAK,CAAC;EACpBC,OAAO,EAAE;IACPC,IAAI,EAAE,CAAC;EACT;AACF,CAAC;AAMD,SAASK,SAASA,CAChBF,WAAwB,EACxBJ,OAA2B,EAC3BK,OAAuB,EACjB;EACN,OAAO,IAAI;AACb"}
1
+ {"version":3,"file":"null-loader.js","names":["VERSION","NullWorkerLoader","name","id","module","version","worker","mimeTypes","extensions","tests","options","null","NullLoader","parse","arrayBuffer","context","parseSync","parseInBatches","generator","asyncIterator","batch"],"sources":["../src/null-loader.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nimport type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {LoaderContext} from '@loaders.gl/loader-utils';\n\nexport type NullLoaderOptions = LoaderOptions & {\n null?: {};\n};\n\n/**\n * Loads any data and returns null (or optionally passes through data unparsed)\n */\nexport const NullWorkerLoader: Loader<null, never, NullLoaderOptions> = {\n name: 'Null loader',\n id: 'null',\n module: 'core',\n version: VERSION,\n worker: true,\n mimeTypes: ['application/x.empty'],\n extensions: ['null'],\n tests: [() => false],\n options: {\n null: {}\n }\n};\n\n/**\n * Loads any data and returns null (or optionally passes through data unparsed)\n */\nexport const NullLoader: LoaderWithParser<null, null, NullLoaderOptions> = {\n name: 'Null loader',\n id: 'null',\n module: 'core',\n version: VERSION,\n mimeTypes: ['application/x.empty'],\n extensions: ['null'],\n parse: async (arrayBuffer: ArrayBuffer, options?: NullLoaderOptions, context?: LoaderContext) =>\n parseSync(arrayBuffer, options || {}, context),\n parseSync,\n parseInBatches: async function* generator(asyncIterator, options, context) {\n for await (const batch of asyncIterator) {\n yield parseSync(batch, options, context);\n }\n },\n tests: [() => false],\n options: {\n null: {}\n }\n};\n\n/**\n * Returns arguments passed to the parse API in a format that can be transferred to a\n * web worker. The `context` parameter is stripped using JSON.stringify & parse.\n */\nfunction parseSync(\n arrayBuffer: ArrayBuffer,\n options?: NullLoaderOptions,\n context?: LoaderContext\n): null {\n return null;\n}\n"],"mappings":"AAMA,MAAMA,OAAO,GAAG,uBAAkB,KAAK,WAAW,sBAAiB,QAAQ;AAY3E,OAAO,MAAMC,gBAAwD,GAAG;EACtEC,IAAI,EAAE,aAAa;EACnBC,EAAE,EAAE,MAAM;EACVC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAEL,OAAO;EAChBM,MAAM,EAAE,IAAI;EACZC,SAAS,EAAE,CAAC,qBAAqB,CAAC;EAClCC,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,KAAK,EAAE,CAAC,MAAM,KAAK,CAAC;EACpBC,OAAO,EAAE;IACPC,IAAI,EAAE,CAAC;EACT;AACF,CAAC;AAKD,OAAO,MAAMC,UAA2D,GAAG;EACzEV,IAAI,EAAE,aAAa;EACnBC,EAAE,EAAE,MAAM;EACVC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAEL,OAAO;EAChBO,SAAS,EAAE,CAAC,qBAAqB,CAAC;EAClCC,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBK,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEJ,OAA2B,EAAEK,OAAuB,KAC1FC,SAAS,CAACF,WAAW,EAAEJ,OAAO,IAAI,CAAC,CAAC,EAAEK,OAAO,CAAC;EAChDC,SAAS;EACTC,cAAc,EAAE,gBAAgBC,SAASA,CAACC,aAAa,EAAET,OAAO,EAAEK,OAAO,EAAE;IACzE,WAAW,MAAMK,KAAK,IAAID,aAAa,EAAE;MACvC,MAAMH,SAAS,CAACI,KAAK,EAAEV,OAAO,EAAEK,OAAO,CAAC;IAC1C;EACF,CAAC;EACDN,KAAK,EAAE,CAAC,MAAM,KAAK,CAAC;EACpBC,OAAO,EAAE;IACPC,IAAI,EAAE,CAAC;EACT;AACF,CAAC;AAMD,SAASK,SAASA,CAChBF,WAAwB,EACxBJ,OAA2B,EAC3BK,OAAuB,EACjB;EACN,OAAO,IAAI;AACb"}
@@ -233,7 +233,7 @@ async function parseData({
233
233
  }
234
234
 
235
235
  // src/null-loader.ts
236
- var VERSION = true ? "4.1.0-alpha.1" : "latest";
236
+ var VERSION = true ? "4.1.0-alpha.10" : "latest";
237
237
  var NullLoader = {
238
238
  name: "Null loader",
239
239
  id: "null",
@@ -198,7 +198,7 @@
198
198
  }
199
199
 
200
200
  // src/null-loader.ts
201
- var VERSION = true ? "4.1.0-alpha.1" : "latest";
201
+ var VERSION = true ? "4.1.0-alpha.10" : "latest";
202
202
  var NullLoader = {
203
203
  name: "Null loader",
204
204
  id: "null",
@@ -1 +1 @@
1
- {"version":3,"file":"null-worker-node.js","names":["createLoaderWorker","NullLoader"],"sources":["../../src/workers/null-worker-node.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {NullLoader} from '../null-loader';\n\ncreateLoaderWorker(NullLoader);\n"],"mappings":"AAGA,SAAQA,kBAAkB,QAAO,0BAA0B;AAAC,SACpDC,UAAU;AAElBD,kBAAkB,CAACC,UAAU,CAAC"}
1
+ {"version":3,"file":"null-worker-node.js","names":["createLoaderWorker","NullLoader"],"sources":["../../src/workers/null-worker-node.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {NullLoader} from '../null-loader';\n\ncreateLoaderWorker(NullLoader);\n"],"mappings":"AAIA,SAAQA,kBAAkB,QAAO,0BAA0B;AAAC,SACpDC,UAAU;AAElBD,kBAAkB,CAACC,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"null-worker.js","names":["createLoaderWorker","NullLoader"],"sources":["../../src/workers/null-worker.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {NullLoader} from '../null-loader';\n\ncreateLoaderWorker(NullLoader);\n"],"mappings":"AAGA,SAAQA,kBAAkB,QAAO,0BAA0B;AAAC,SACpDC,UAAU;AAElBD,kBAAkB,CAACC,UAAU,CAAC"}
1
+ {"version":3,"file":"null-worker.js","names":["createLoaderWorker","NullLoader"],"sources":["../../src/workers/null-worker.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {NullLoader} from '../null-loader';\n\ncreateLoaderWorker(NullLoader);\n"],"mappings":"AAIA,SAAQA,kBAAkB,QAAO,0BAA0B;AAAC,SACpDC,UAAU;AAElBD,kBAAkB,CAACC,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/core",
3
- "version": "4.1.0-alpha.1",
3
+ "version": "4.1.0-alpha.10",
4
4
  "description": "The core API for working with loaders.gl loaders and writers",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,9 +29,9 @@
29
29
  "module": "dist/index.js",
30
30
  "exports": {
31
31
  ".": {
32
+ "types": "./dist/index.d.ts",
32
33
  "import": "./dist/index.js",
33
- "require": "./dist/index.cjs",
34
- "types": "./dist/index.d.ts"
34
+ "require": "./dist/index.cjs"
35
35
  }
36
36
  },
37
37
  "sideEffects": false,
@@ -55,9 +55,9 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@babel/runtime": "^7.3.1",
58
- "@loaders.gl/loader-utils": "4.1.0-alpha.1",
59
- "@loaders.gl/worker-utils": "4.1.0-alpha.1",
58
+ "@loaders.gl/loader-utils": "4.1.0-alpha.10",
59
+ "@loaders.gl/worker-utils": "4.1.0-alpha.10",
60
60
  "@probe.gl/log": "^4.0.2"
61
61
  },
62
- "gitHead": "6a4d3da93d45115ad99861474a43c3f4a0b280a7"
62
+ "gitHead": "19f43c2d90d8b50860c3f8e487429779a386287d"
63
63
  }
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  // A browser implementation of the Node.js `fs` module's `fs.writeFile` method.
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  // TYPES
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  /**
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {IteratorOptions} from './make-iterator';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {IteratorOptions} from './make-iterator';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {ReadStream} from 'fs';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {Readable} from 'stream';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {IteratorOptions} from './make-iterator';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  export type MakeStreamOptions = {
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {Readable} from 'stream';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  // Copyright 2022 Foursquare Labs, Inc
4
5
 
@@ -1,8 +1,9 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
- import {WriterOptions, WriterWithEncoder, canEncodeWithWorker} from '@loaders.gl/loader-utils';
5
- import {concatenateArrayBuffers, resolvePath, NodeFile} from '@loaders.gl/loader-utils';
5
+ import type {WriterOptions, WriterWithEncoder} from '@loaders.gl/loader-utils';
6
+ import {canEncodeWithWorker, NodeFile, resolvePath} from '@loaders.gl/loader-utils';
6
7
  import {processOnWorker} from '@loaders.gl/worker-utils';
7
8
  import {isBrowser} from '@loaders.gl/loader-utils';
8
9
  import {fetchFile} from '../fetch/fetch-file';
@@ -19,57 +20,19 @@ export async function encode(
19
20
  const globalOptions = getLoaderOptions() as WriterOptions;
20
21
  // const globalOptions: WriterOptions = {}; // getWriterOptions();
21
22
  options = {...globalOptions, ...options};
22
- if (canEncodeWithWorker(writer, options)) {
23
- return await processOnWorker(writer, data, options);
24
- }
25
-
26
- // TODO Merge default writer options with options argument like it is done in load module.
27
- if (writer.encode) {
28
- return await writer.encode(data, options);
29
- }
30
-
31
- if (writer.encodeSync) {
32
- return writer.encodeSync(data, options);
33
- }
34
-
35
- if (writer.encodeText) {
36
- return new TextEncoder().encode(await writer.encodeText(data, options));
37
- }
38
23
 
39
- if (writer.encodeInBatches) {
40
- // Create an iterator representing the data
41
- // TODO - Assumes this is a table
42
- const batches = encodeInBatches(data, writer, options);
43
-
44
- // Concatenate the output
45
- const chunks: unknown[] = [];
46
- for await (const batch of batches) {
47
- chunks.push(batch);
48
- }
49
- // @ts-ignore
50
- return concatenateArrayBuffers(...chunks);
24
+ // Handle the special case where we are invoking external command-line tools
25
+ if (writer.encodeURLtoURL) {
26
+ return encodeWithCommandLineTool(writer, data, options);
51
27
  }
52
28
 
53
- if (!isBrowser && writer.encodeURLtoURL) {
54
- // TODO - how to generate filenames with correct extensions?
55
- const tmpInputFilename = getTemporaryFilename('input');
56
- const file = new NodeFile(tmpInputFilename, 'w');
57
- await file.write(data as ArrayBuffer);
58
-
59
- const tmpOutputFilename = getTemporaryFilename('output');
60
-
61
- const outputFilename = await encodeURLtoURL(
62
- tmpInputFilename,
63
- tmpOutputFilename,
64
- writer,
65
- options
66
- );
67
-
68
- const response = await fetchFile(outputFilename);
69
- return response.arrayBuffer();
29
+ // Worker support
30
+ if (canEncodeWithWorker(writer, options)) {
31
+ return await processOnWorker(writer, data, options);
70
32
  }
71
33
 
72
- throw new Error('Writer could not encode data');
34
+ // TODO Merge default writer options with options argument like it is done in load module.
35
+ return await writer.encode(data, options);
73
36
  }
74
37
 
75
38
  /**
@@ -83,7 +46,10 @@ export function encodeSync(
83
46
  if (writer.encodeSync) {
84
47
  return writer.encodeSync(data, options);
85
48
  }
86
- throw new Error('Writer could not synchronously encode data');
49
+ if (writer.encodeTextSync) {
50
+ return new TextEncoder().encode(writer.encodeTextSync(data, options));
51
+ }
52
+ throw new Error(`Writer ${writer.name} could not synchronously encode data`);
87
53
  }
88
54
 
89
55
  /**
@@ -97,12 +63,16 @@ export async function encodeText(
97
63
  writer: WriterWithEncoder,
98
64
  options?: WriterOptions
99
65
  ): Promise<string> {
100
- if (writer.text && writer.encodeText) {
66
+ if (writer.encodeText) {
101
67
  return await writer.encodeText(data, options);
102
68
  }
103
69
 
70
+ if (writer.encodeTextSync) {
71
+ return writer.encodeTextSync(data, options);
72
+ }
73
+
104
74
  if (writer.text) {
105
- const arrayBuffer = await encode(data, writer, options);
75
+ const arrayBuffer = await writer.encode(data, options);
106
76
  return new TextDecoder().decode(arrayBuffer);
107
77
  }
108
78
 
@@ -120,7 +90,7 @@ export function encodeTextSync(
120
90
  writer: WriterWithEncoder,
121
91
  options?: WriterOptions
122
92
  ): string {
123
- if (writer.text && writer.encodeTextSync) {
93
+ if (writer.encodeTextSync) {
124
94
  return writer.encodeTextSync(data, options);
125
95
  }
126
96
 
@@ -146,7 +116,24 @@ export function encodeInBatches(
146
116
  return writer.encodeInBatches(dataIterator, options);
147
117
  }
148
118
  // TODO -fall back to atomic encode?
149
- throw new Error('Writer could not encode data in batches');
119
+ throw new Error(`Writer ${writer.name} could not encode in batches`);
120
+ }
121
+
122
+ /**
123
+ * Encode loaded data into a sequence (iterator) of binary ArrayBuffers using the specified Writer.
124
+ */
125
+ export function encodeTextInBatches(
126
+ data: unknown,
127
+ writer: WriterWithEncoder,
128
+ options?: WriterOptions
129
+ ): AsyncIterable<ArrayBuffer> {
130
+ if (writer.encodeTextInBatches) {
131
+ const dataIterator = getIterator(data);
132
+ // @ts-expect-error
133
+ return writer.encodeTextInBatches(dataIterator, options);
134
+ }
135
+ // TODO -fall back to atomic encode?
136
+ throw new Error(`Writer ${writer.name} could not encode text in batches`);
150
137
  }
151
138
 
152
139
  /**
@@ -156,7 +143,7 @@ export function encodeInBatches(
156
143
  export async function encodeURLtoURL(
157
144
  inputUrl: string,
158
145
  outputUrl: string,
159
- writer: WriterWithEncoder,
146
+ writer: Omit<WriterWithEncoder, 'encode'>,
160
147
  options?: WriterOptions
161
148
  ): Promise<string> {
162
149
  inputUrl = resolvePath(inputUrl);
@@ -168,6 +155,28 @@ export async function encodeURLtoURL(
168
155
  return outputFilename;
169
156
  }
170
157
 
158
+ /** Helper function to encode via external tool (typically command line execution in Node.js) */
159
+ async function encodeWithCommandLineTool(
160
+ writer: WriterWithEncoder,
161
+ data: unknown,
162
+ options: WriterOptions
163
+ ): Promise<ArrayBuffer> {
164
+ if (isBrowser) {
165
+ throw new Error(`Writer ${writer.name} not supported in browser`);
166
+ }
167
+ // TODO - how to generate filenames with correct extensions?
168
+ const tmpInputFilename = getTemporaryFilename('input');
169
+ const file = new NodeFile(tmpInputFilename, 'w');
170
+ await file.write(data as ArrayBuffer);
171
+
172
+ const tmpOutputFilename = getTemporaryFilename('output');
173
+
174
+ const outputFilename = await encodeURLtoURL(tmpInputFilename, tmpOutputFilename, writer, options);
175
+
176
+ const response = await fetchFile(outputFilename);
177
+ return response.arrayBuffer();
178
+ }
179
+
171
180
  /**
172
181
  * @todo TODO - this is an unacceptable hack!!!
173
182
  */
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {DataType, Loader, LoaderContext, LoaderOptions} from '@loaders.gl/loader-utils';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  export {setGlobalOptions as setLoaderOptions} from '../loader-utils/option-utils';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import {isTable, makeBatchFromTable, type Batch} from '@loaders.gl/schema';
@@ -111,6 +112,7 @@ async function parseWithLoaderInBatches(
111
112
  }
112
113
 
113
114
  const metadataBatch = {
115
+ shape: 'metadata',
114
116
  batchType: 'metadata',
115
117
  metadata: {
116
118
  _loader: loader,
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {Loader, LoaderContext, LoaderOptions} from '@loaders.gl/loader-utils';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import {Loader} from '@loaders.gl/loader-utils';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import type {LoaderContext, LoaderOptions, Loader} from '@loaders.gl/loader-utils';
package/src/lib/common.ts CHANGED
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  export type {LoaderWithParser} from '@loaders.gl/loader-utils';
@@ -1,4 +1,5 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  export function getErrorMessageFromResponseSync(response: Response): string {