@kepler.gl/processors 3.3.0-alpha.2 → 3.3.0-alpha.21

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 (80) hide show
  1. package/dist/cjs/data-processor.js +674 -0
  2. package/dist/cjs/data-processor.js.map +1 -0
  3. package/dist/cjs/export/dataset-to-geojson.js +138 -0
  4. package/dist/cjs/export/dataset-to-geojson.js.map +1 -0
  5. package/dist/cjs/export/geopackage-writer.js +385 -0
  6. package/dist/cjs/export/geopackage-writer.js.map +1 -0
  7. package/dist/cjs/export/geoparquet-writer.js +351 -0
  8. package/dist/cjs/export/geoparquet-writer.js.map +1 -0
  9. package/dist/cjs/export/kml-writer.js +347 -0
  10. package/dist/cjs/export/kml-writer.js.map +1 -0
  11. package/dist/cjs/export/shapefile-writer.js +708 -0
  12. package/dist/cjs/export/shapefile-writer.js.map +1 -0
  13. package/dist/cjs/export/sql-js.js +95 -0
  14. package/dist/cjs/export/sql-js.js.map +1 -0
  15. package/dist/cjs/export/vector-export.js +187 -0
  16. package/dist/cjs/export/vector-export.js.map +1 -0
  17. package/dist/cjs/file-handler.js +997 -0
  18. package/dist/cjs/file-handler.js.map +1 -0
  19. package/dist/cjs/index.js +114 -0
  20. package/dist/cjs/index.js.map +1 -0
  21. package/dist/cjs/kepler-csv-loader.js +163 -0
  22. package/dist/cjs/kepler-csv-loader.js.map +1 -0
  23. package/dist/cjs/loader-registry.js +542 -0
  24. package/dist/cjs/loader-registry.js.map +1 -0
  25. package/dist/cjs/remote-file.js +675 -0
  26. package/dist/cjs/remote-file.js.map +1 -0
  27. package/dist/cjs/shapefile-files.js +281 -0
  28. package/dist/cjs/shapefile-files.js.map +1 -0
  29. package/dist/cjs/types.js +6 -0
  30. package/dist/cjs/types.js.map +1 -0
  31. package/dist/data-processor.d.ts +30 -16
  32. package/dist/esm/data-processor.js +655 -0
  33. package/dist/esm/data-processor.js.map +1 -0
  34. package/dist/esm/export/dataset-to-geojson.js +132 -0
  35. package/dist/esm/export/dataset-to-geojson.js.map +1 -0
  36. package/dist/esm/export/geopackage-writer.js +381 -0
  37. package/dist/esm/export/geopackage-writer.js.map +1 -0
  38. package/dist/esm/export/geoparquet-writer.js +336 -0
  39. package/dist/esm/export/geoparquet-writer.js.map +1 -0
  40. package/dist/esm/export/kml-writer.js +341 -0
  41. package/dist/esm/export/kml-writer.js.map +1 -0
  42. package/dist/esm/export/shapefile-writer.js +701 -0
  43. package/dist/esm/export/shapefile-writer.js.map +1 -0
  44. package/dist/esm/export/sql-js.js +80 -0
  45. package/dist/esm/export/sql-js.js.map +1 -0
  46. package/dist/esm/export/vector-export.js +176 -0
  47. package/dist/esm/export/vector-export.js.map +1 -0
  48. package/dist/esm/file-handler.js +972 -0
  49. package/dist/esm/file-handler.js.map +1 -0
  50. package/dist/esm/index.js +12 -0
  51. package/dist/esm/index.js.map +1 -0
  52. package/dist/esm/kepler-csv-loader.js +152 -0
  53. package/dist/esm/kepler-csv-loader.js.map +1 -0
  54. package/dist/esm/loader-registry.js +510 -0
  55. package/dist/esm/loader-registry.js.map +1 -0
  56. package/dist/esm/remote-file.js +664 -0
  57. package/dist/esm/remote-file.js.map +1 -0
  58. package/dist/esm/shapefile-files.js +264 -0
  59. package/dist/esm/shapefile-files.js.map +1 -0
  60. package/dist/esm/types.js +3 -0
  61. package/dist/esm/types.js.map +1 -0
  62. package/dist/export/dataset-to-geojson.d.ts +12 -0
  63. package/dist/export/geopackage-writer.d.ts +28 -0
  64. package/dist/export/geoparquet-writer.d.ts +7 -0
  65. package/dist/export/kml-writer.d.ts +13 -0
  66. package/dist/export/shapefile-writer.d.ts +28 -0
  67. package/dist/export/sql-js.d.ts +8 -0
  68. package/dist/export/vector-export.d.ts +22 -0
  69. package/dist/file-handler.d.ts +55 -8
  70. package/dist/index.d.ts +6 -0
  71. package/dist/kepler-csv-loader.d.ts +12 -0
  72. package/dist/loader-registry.d.ts +29 -0
  73. package/dist/remote-file.d.ts +79 -0
  74. package/dist/shapefile-files.d.ts +39 -0
  75. package/dist/types.d.ts +13 -0
  76. package/package.json +44 -26
  77. package/dist/data-processor.js +0 -637
  78. package/dist/file-handler.js +0 -409
  79. package/dist/index.js +0 -39
  80. package/dist/types.js +0 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-file.js","names":["parseUri","DATASET_FORMATS","DatasetType","MIME_TO_REMOTE_FILE_EXTENSION","REMOTE_FILE_EXTENSIONS","REMOTE_FILE_MIME_TYPES","generateHashIdFromString","getPersistedRemoteFormat","processFileData","readFileInBatches","KeplerCSVLoader","getPathFileName","url","parsed","URL","segments","pathname","split","filter","Boolean","last","length","decodeURIComponent","_unused","_parseUri","file","String","getExtensionFromUrl","match","toLowerCase","getMimeTypeForFormat","format","undefined","isRemoteDatasetUrl","_URL","protocol","_unused2","getFileNameForRemoteUrl","mimeType","base","formatExt","urlExt","mimeExt","trim","ext","test","endsWith","concat","replace","fetchRemoteFile","_x","_fetchRemoteFile","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","options","onProgress","etag","lastModified","bypassCache","headers","isCrossOrigin","response","_response$body","_response$body$cancel","status","blob","headerType","fileName","responseEtag","responseLastModified","_args","wrap","_callee$","_context","prev","next","Error","location","origin","fetch","_objectSpread","cache","Object","keys","sent","abrupt","notModified","get","ok","body","cancel","call","statusText","readResponseBlob","type","File","keplerSourceUrl","keplerFormat","keplerEtag","keplerLastModified","size","stop","remoteDatasetFromUrl","label","sourceFormat","data","fields","rows","info","id","row","EXTERNALLY_HOSTED","metadata","source","fetchRemoteFileAsKeplerFile","_x2","_x3","_x4","_fetchRemoteFileAsKeplerFile","_callee2","result","_callee2$","_context2","PAINT_WAIT_MS","waitForNextPaint","requestAnimationFrame","document","hidden","Promise","resolve","settled","frames","finish","clearTimeout","timer","cancelAnimationFrame","forEach","setTimeout","push","_x5","_x6","_readResponseBlob","_callee3","contentLength","total","PROGRESS_INTERVAL_MS","lastEmitAt","lastEmittedPercent","emit","reader","chunks","loaded","_yield$reader$read","done","value","_callee3$","_context3","Number","isFinite","complete","percent","Math","min","rounded","round","now","performance","Date","getReader","read","byteLength","Blob","isTabularProcessorResult","_typeof","Array","isArray","matchesCsvHeader","_x7","_x8","_matchesCsvHeader","_callee4","text","escape","blankLines","matchesRecord","_iteratorAbruptCompletion","_didIteratorError","_iteratorError","_iterator","_step","batch","header","names","_callee4$","_context4","strict","some","delimiter","record","map","name","quoted","needsQuotes","includes","join","RegExp","_asyncIterator","parseInBatches","TextEncoder","encode","csv","shape","_toConsumableArray","t0","fromEntries","every","i","loadExternallyHostedDataset","_x9","_loadExternallyHostedDataset","_callee5","_fetched$size","_metadata$csvHeader","_processed","fetched","batches","content","_iteratorAbruptCompletion2","_didIteratorError2","_iteratorError2","_iterator2","_step2","processed","_callee5$","_context5","phase","fileCache","loaders","loadOptions","t1","csvHeader","extensions","extension","t2","t3","t4","sourceUrl","isExternallyHostedFile"],"sources":["../../src/remote-file.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {parseUri} from '@kepler.gl/common-utils';\nimport {\n DATASET_FORMATS,\n DatasetType,\n MIME_TO_REMOTE_FILE_EXTENSION,\n REMOTE_FILE_EXTENSIONS,\n REMOTE_FILE_MIME_TYPES,\n RemoteFileFormat\n} from '@kepler.gl/constants';\nimport {ProcessorResult} from '@kepler.gl/types';\nimport {generateHashIdFromString} from '@kepler.gl/utils';\n\nimport {\n getPersistedRemoteFormat,\n processFileData,\n ProcessFileDataContent,\n readFileInBatches\n} from './file-handler';\nimport {FileCacheItem} from './types';\nimport {KeplerCSVLoader} from './kepler-csv-loader';\n\nexport type KeplerRemoteFile = File & {\n keplerSourceUrl?: string;\n keplerFormat?: string;\n keplerRefreshIntervalMs?: number;\n keplerEtag?: string;\n keplerLastModified?: string;\n};\n\nexport type RemoteLoadProgress = {\n loaded: number;\n total?: number;\n percent: number;\n /** Set once the bytes are in memory and parsing is about to block the main thread. */\n phase?: 'processing';\n};\n\nexport type FetchRemoteFileOptions = {\n format?: string | null;\n onProgress?: (progress: RemoteLoadProgress) => void;\n etag?: string;\n lastModified?: string;\n /** Bypass the HTTP cache. Used for poll/reload, not the first remote URL load. */\n bypassCache?: boolean;\n};\n\nexport type FetchRemoteFileResult = {\n file: KeplerRemoteFile | null;\n notModified: boolean;\n etag?: string;\n lastModified?: string;\n size?: number;\n};\n\nexport type LoadExternallyHostedDatasetResult = {\n data: NonNullable<ProcessorResult> | null;\n notModified: boolean;\n etag?: string;\n lastModified?: string;\n size?: number;\n};\n\nfunction getPathFileName(url: string): string {\n try {\n const parsed = new URL(url);\n const segments = parsed.pathname.split('/').filter(Boolean);\n const last = segments.length ? decodeURIComponent(segments[segments.length - 1]) : '';\n return last.split('?')[0];\n } catch {\n const {file} = parseUri(url);\n return decodeURIComponent(String(file || '')).split('?')[0];\n }\n}\n\nexport function getExtensionFromUrl(url: string): string {\n const file = getPathFileName(url);\n const match = file.match(/\\.([a-z0-9]+)$/i);\n return match ? match[1].toLowerCase() : '';\n}\n\nexport function getMimeTypeForFormat(format?: string | null): string | undefined {\n if (!format || format === 'auto') {\n return undefined;\n }\n return REMOTE_FILE_MIME_TYPES[format as Exclude<RemoteFileFormat, 'auto'>];\n}\n\nexport function isRemoteDatasetUrl(url: string): boolean {\n try {\n const {protocol} = new URL(url);\n return protocol === 'http:' || protocol === 'https:';\n } catch {\n return false;\n }\n}\n\n/**\n * Build a filename loaders.gl can use to pick a parser.\n * Prefers an explicit format, then the URL path extension, then Content-Type.\n */\nexport function getFileNameForRemoteUrl(\n url: string,\n format?: string | null,\n mimeType?: string | null\n): string {\n const base = getPathFileName(url) || 'dataset';\n\n const formatExt =\n format && format !== 'auto'\n ? REMOTE_FILE_EXTENSIONS[format as Exclude<RemoteFileFormat, 'auto'>]\n : undefined;\n const urlExt = getExtensionFromUrl(url);\n const mimeExt = mimeType\n ? MIME_TO_REMOTE_FILE_EXTENSION[mimeType.split(';')[0].trim().toLowerCase()]\n : undefined;\n const ext = formatExt || urlExt || mimeExt;\n\n if (!ext) {\n return base;\n }\n\n if (/\\.[a-z0-9]+$/i.test(base)) {\n if (formatExt && !base.toLowerCase().endsWith(`.${formatExt}`)) {\n return `${base.replace(/\\.[^.]+$/, '')}.${formatExt}`;\n }\n return base;\n }\n\n return `${base}.${ext}`;\n}\n\n/**\n * Fetch a remote dataset URL. Uses conditional headers for same-origin requests\n * (or outside a browser) so unchanged files can skip a re-parse.\n */\nexport async function fetchRemoteFile(\n url: string,\n options: FetchRemoteFileOptions = {}\n): Promise<FetchRemoteFileResult> {\n const {format, onProgress, etag, lastModified, bypassCache} = options;\n if (!isRemoteDatasetUrl(url)) {\n throw new Error('Remote dataset URL must use http or https');\n }\n const headers: Record<string, string> = {};\n // Conditional headers trigger CORS preflights, which simple file servers may\n // not support even when they allow cross-origin GET requests.\n const isCrossOrigin = typeof location !== 'undefined' && new URL(url).origin !== location.origin;\n if (etag && !isCrossOrigin) {\n headers['If-None-Match'] = etag;\n }\n if (lastModified && !isCrossOrigin) {\n headers['If-Modified-Since'] = lastModified;\n }\n const response = await fetch(url, {\n ...(bypassCache ? {cache: 'no-store' as RequestCache} : {}),\n ...(Object.keys(headers).length ? {headers} : {})\n });\n if (response.status === 304) {\n return {\n file: null,\n notModified: true,\n etag: response.headers.get('etag') || etag || undefined,\n lastModified: response.headers.get('last-modified') || lastModified || undefined\n };\n }\n if (!response.ok) {\n // Don't put the response body in the error: 404 HTML pages would dump into the UI.\n response.body?.cancel?.().catch(() => undefined);\n const status = response.statusText\n ? `${response.status} ${response.statusText}`\n : String(response.status);\n throw new Error(`Failed to fetch ${url} (${status})`);\n }\n\n const blob = await readResponseBlob(response, onProgress);\n const headerType = response.headers.get('content-type') || blob.type || '';\n const mimeType = getMimeTypeForFormat(format) || headerType.split(';')[0].trim();\n const fileName = getFileNameForRemoteUrl(url, format, mimeType);\n const file = new File(\n [blob],\n fileName,\n mimeType ? {type: mimeType} : undefined\n ) as KeplerRemoteFile;\n file.keplerSourceUrl = url;\n if (format && format !== 'auto') {\n file.keplerFormat = format;\n }\n const responseEtag = response.headers.get('etag') || undefined;\n const responseLastModified = response.headers.get('last-modified') || undefined;\n if (responseEtag) {\n file.keplerEtag = responseEtag;\n }\n if (responseLastModified) {\n file.keplerLastModified = responseLastModified;\n }\n return {\n file,\n notModified: false,\n etag: responseEtag,\n lastModified: responseLastModified,\n size: file.size\n };\n}\n\n/**\n * A remote URL to hold until Add Data. Rows stay empty so adding it runs the\n * externally hosted download instead of parsing a file in the modal.\n */\nexport function remoteDatasetFromUrl(url: string, format?: string | null): FileCacheItem {\n if (!isRemoteDatasetUrl(url)) {\n throw new Error('Remote dataset URL must use http or https');\n }\n const label = getFileNameForRemoteUrl(url, format);\n const sourceFormat = getPersistedRemoteFormat(\n format && format !== 'auto' ? format : undefined,\n label\n );\n return {\n data: {fields: [], rows: []},\n info: {\n id: generateHashIdFromString(url),\n label,\n format: DATASET_FORMATS.row,\n type: DatasetType.EXTERNALLY_HOSTED\n },\n metadata: {\n source: url,\n ...(sourceFormat ? {sourceFormat} : {})\n }\n };\n}\n\n/**\n * Fetch a remote dataset URL and wrap it as a File the existing loadFiles pipeline can parse.\n * Sets File.type from an explicit format or the response Content-Type so extensionless\n * URLs (SAS keys) still select the right loader.\n */\nexport async function fetchRemoteFileAsKeplerFile(\n url: string,\n format?: string | null,\n onProgress?: (progress: RemoteLoadProgress) => void\n): Promise<KeplerRemoteFile> {\n const result = await fetchRemoteFile(url, {format, onProgress});\n if (!result.file) {\n throw new Error(`Failed to fetch ${url} (304 Not Modified)`);\n }\n return result.file;\n}\n\n/** Two frames are enough for the processing indicator to paint. */\nconst PAINT_WAIT_MS = 100;\n\nfunction waitForNextPaint(): Promise<void> {\n // Hidden tabs suspend requestAnimationFrame. A download that finishes in the\n // background would otherwise wait until the user comes back, and there is\n // nothing to paint there.\n if (\n typeof requestAnimationFrame !== 'function' ||\n (typeof document !== 'undefined' && document.hidden)\n ) {\n return Promise.resolve();\n }\n return new Promise(resolve => {\n let settled = false;\n const frames: number[] = [];\n const finish = () => {\n if (settled) {\n return;\n }\n settled = true;\n clearTimeout(timer);\n if (typeof cancelAnimationFrame === 'function') {\n frames.forEach(id => cancelAnimationFrame(id));\n }\n resolve();\n };\n // The tab can be hidden after this wait starts. Don't sit on frames that will never run.\n const timer = setTimeout(finish, PAINT_WAIT_MS);\n frames.push(\n requestAnimationFrame(() => {\n if (!settled) {\n frames.push(requestAnimationFrame(finish));\n }\n })\n );\n });\n}\n\nasync function readResponseBlob(\n response: Response,\n onProgress?: (progress: RemoteLoadProgress) => void\n): Promise<Blob> {\n const contentLength = Number(response.headers.get('content-length'));\n const total = Number.isFinite(contentLength) && contentLength > 0 ? contentLength : undefined;\n\n const PROGRESS_INTERVAL_MS = 80;\n let lastEmitAt = 0;\n let lastEmittedPercent = -1;\n const emit = (loaded: number, complete = false) => {\n const percent = complete ? 1 : total ? Math.min(1, loaded / total) : 0;\n const rounded = Math.round(percent * 100);\n const now = typeof performance !== 'undefined' ? performance.now() : Date.now();\n if (\n !complete &&\n loaded !== 0 &&\n rounded === lastEmittedPercent &&\n now - lastEmitAt < PROGRESS_INTERVAL_MS\n ) {\n return;\n }\n lastEmitAt = now;\n lastEmittedPercent = rounded;\n onProgress?.({\n loaded,\n total,\n percent\n });\n };\n\n if (!response.body) {\n const blob = await response.blob();\n emit(blob.size, true);\n return blob;\n }\n\n const reader = response.body.getReader();\n const chunks: Uint8Array[] = [];\n let loaded = 0;\n emit(0);\n\n while (true) {\n const {done, value} = await reader.read();\n if (done) {\n break;\n }\n chunks.push(value);\n loaded += value.byteLength;\n emit(loaded);\n }\n\n emit(loaded, true);\n return new Blob(chunks);\n}\n\nfunction isTabularProcessorResult(data: unknown): data is NonNullable<ProcessorResult> {\n return Boolean(\n data &&\n typeof data === 'object' &&\n Array.isArray((data as ProcessorResult)?.fields) &&\n Array.isArray((data as ProcessorResult)?.rows)\n );\n}\n\nasync function matchesCsvHeader(text: string, fields: string[]): Promise<boolean> {\n const escape = (value: string) => value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const blankLines = '(?:[ \\\\t]*[\\\\r\\\\n])*';\n // Keep exact quote validation: the CSV parser accepts some malformed records.\n const matchesRecord = (header: string[], strict: boolean) =>\n [',', '\\t', ';', '|'].some(delimiter => {\n const record = header\n .map(name => {\n const quoted = escape(`\"${name.replace(/\"/g, '\"\"')}\"`);\n const needsQuotes =\n /[\"\\r\\n]/.test(name) || (strict ? /[,\\t;|]/.test(name) : name.includes(delimiter));\n return needsQuotes ? quoted : `(?:${escape(name)}|${quoted})`;\n })\n .join(escape(delimiter));\n return new RegExp(`^\\\\uFEFF?${blankLines}${record}${blankLines}$`).test(text);\n });\n // Quoted names remain unambiguous even when the loader guesses another delimiter.\n if (fields.some(name => name.trim()) && matchesRecord(fields, true)) return true;\n // A lone bare name containing delimiters has no separator to disambiguate it.\n if (fields.length === 1) return false;\n\n // Reuse the same streaming parser as import, exposing the header as a row.\n const rows: string[][] = [];\n for await (const batch of KeplerCSVLoader.parseInBatches!([new TextEncoder().encode(text)], {\n csv: {\n shape: 'array-row-table',\n // @ts-expect-error loaders.gl accepts false but its type only declares 'auto'.\n header: false\n }\n })) {\n rows.push(...batch.data);\n }\n if (rows.length !== 1) return false;\n const header = rows[0];\n // processRowObject uses Object.keys, which sorts integer-named columns.\n const names = Object.keys(Object.fromEntries(header.map(name => [name, null])));\n return (\n header.length === fields.length &&\n names.length === fields.length &&\n names.every((name, i) => name === fields[i]) &&\n matchesRecord(header, false)\n );\n}\n\n/**\n * Fetch, parse, and process a remote file into Kepler dataset data.\n * Used when reloading an `externally-hosted` dataset from a saved map config\n * and when refreshing a live remote dataset.\n */\nexport async function loadExternallyHostedDataset(metadata: {\n source: string;\n format?: string;\n size?: number;\n etag?: string;\n lastModified?: string;\n bypassCache?: boolean;\n onProgress?: (progress: RemoteLoadProgress) => void;\n /** Established CSV columns, supplied only when refreshing an existing table. */\n csvHeader?: string[];\n}): Promise<LoadExternallyHostedDatasetResult> {\n const {source, format, etag, lastModified, size, bypassCache, onProgress} = metadata;\n const fetched = await fetchRemoteFile(source, {\n format,\n etag,\n lastModified,\n bypassCache,\n onProgress\n });\n if (fetched.notModified || !fetched.file) {\n return {\n data: null,\n notModified: true,\n etag: fetched.etag,\n lastModified: fetched.lastModified,\n size\n };\n }\n\n onProgress?.({\n loaded: fetched.size ?? fetched.file.size,\n ...(typeof fetched.size === 'number' ? {total: fetched.size} : {}),\n percent: 1,\n phase: 'processing'\n });\n // Let the loading indicator paint a processing state before parse blocks the tab.\n await waitForNextPaint();\n\n const batches = await readFileInBatches({\n file: fetched.file,\n fileCache: [],\n loaders: [],\n loadOptions: {}\n });\n\n let content: ProcessFileDataContent | undefined;\n for await (const batch of batches) {\n content = batch as ProcessFileDataContent;\n }\n // CSVLoader emits no data batch for a header-only file. Keep its populated\n // parsing path intact; recognize only a header matching this existing table.\n if (\n metadata.csvHeader?.length &&\n KeplerCSVLoader.extensions.some(extension =>\n fetched.file!.name.toLowerCase().endsWith(`.${extension}`)\n ) &&\n (!content || (Array.isArray(content.data) && !content.data.length)) &&\n (await matchesCsvHeader(await fetched.file.text(), metadata.csvHeader))\n ) {\n return {\n data: {fields: [], rows: []},\n notModified: false,\n etag: fetched.etag,\n lastModified: fetched.lastModified,\n size: fetched.size\n };\n }\n if (!content) {\n throw new Error(`No data loaded from ${source}`);\n }\n\n const processed = await processFileData({\n content: {\n ...content,\n fileName: content.fileName,\n sourceUrl: source\n },\n fileCache: []\n });\n const data = processed[processed.length - 1]?.data;\n if (!isTabularProcessorResult(data)) {\n throw new Error(`Remote file is not a dataset: ${source}`);\n }\n return {\n data,\n notModified: false,\n etag: fetched.etag,\n lastModified: fetched.lastModified,\n size: fetched.size\n };\n}\n\nexport function isExternallyHostedFile(file: File): file is KeplerRemoteFile {\n return Boolean((file as KeplerRemoteFile).keplerSourceUrl);\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;;AAEA,SAAQA,Q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OAAAyH,SAAA,CAAArJ,MAAA,WAErD;YACLoB,IAAI,EAAJA,IAAI;YACJnB,WAAW,EAAE,KAAK;YAClB9B,IAAI,EAAEwK,OAAO,CAACxK,IAAI;YAClBC,YAAY,EAAEuK,OAAO,CAACvK,YAAY;YAClC2C,IAAI,EAAE4H,OAAO,CAAC5H;UAChB,CAAC;QAAA;QAAA;UAAA,OAAAsI,SAAA,CAAArI,IAAA;MAAA;IAAA,GAAAuH,QAAA;EAAA,CACF;EAAA,OAAAD,4BAAA,CAAA3K,KAAA,OAAAC,SAAA;AAAA;AAED,OAAO,SAASsM,sBAAsBA,CAAClO,IAAU,EAA4B;EAC3E,OAAON,OAAO,CAAEM,IAAI,CAAsB2E,eAAe,CAAC;AAC5D","ignoreList":[]}
@@ -0,0 +1,264 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
4
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
7
+ // SPDX-License-Identifier: MIT
8
+ // Copyright contributors to the kepler.gl project
9
+
10
+ import { _BrowserFileSystem, parse } from '@loaders.gl/core';
11
+ import { isLoadableDatasetExtension } from './loader-registry';
12
+ export var SHAPEFILE_SIDECAR_EXTENSIONS = ['dbf', 'shx', 'prj', 'cpg'];
13
+ export var SHAPEFILE_SOURCE_EXTENSIONS = ['shp', 'zip'];
14
+ export function getDroppedFileExtension() {
15
+ var fileName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
16
+ var match = fileName.match(/\.([a-z0-9]+)$/i);
17
+ return match ? match[1].toLowerCase() : '';
18
+ }
19
+ export function isShapefileSidecarFileName(fileName) {
20
+ return SHAPEFILE_SIDECAR_EXTENSIONS.includes(getDroppedFileExtension(fileName));
21
+ }
22
+ export function isZipFileName(fileName) {
23
+ return getDroppedFileExtension(fileName) === 'zip';
24
+ }
25
+ export function isShapefileSourceFileName(fileName) {
26
+ return SHAPEFILE_SOURCE_EXTENSIONS.includes(getDroppedFileExtension(fileName));
27
+ }
28
+
29
+ /**
30
+ * Sidecar files (.dbf, .shx, .prj, .cpg) are not datasets. Skip them when a
31
+ * .shp or shapefile .zip is also present so they can be used as companions.
32
+ */
33
+ export function getFilesToParse(files) {
34
+ var list = Array.from(files);
35
+ var hasShapefileSource = list.some(function (file) {
36
+ return isShapefileSourceFileName(file.name);
37
+ });
38
+ if (!hasShapefileSource) {
39
+ return list;
40
+ }
41
+ return list.filter(function (file) {
42
+ return !isShapefileSidecarFileName(file.name);
43
+ });
44
+ }
45
+ export function createCompanionFetch(files) {
46
+ if (!(files !== null && files !== void 0 && files.length) || typeof File === 'undefined' || files.every(function (file) {
47
+ return !(file instanceof File);
48
+ })) {
49
+ return undefined;
50
+ }
51
+ var fileSystem = new _BrowserFileSystem(files);
52
+ return fileSystem.fetch.bind(fileSystem);
53
+ }
54
+ function fileNameFromArchivePath(path) {
55
+ var parts = path.split(/[/\\]/);
56
+ return parts[parts.length - 1] || path;
57
+ }
58
+
59
+ /**
60
+ * Top-level members of a zip. Nested folders are ignored. Directory entries
61
+ * are skipped.
62
+ */
63
+ function listTopLevelZipFiles(_x) {
64
+ return _listTopLevelZipFiles.apply(this, arguments);
65
+ }
66
+ /**
67
+ * Unpack a zip that contains a shapefile. Only top-level .shp plus sidecars
68
+ * are returned; nested folders are ignored.
69
+ */
70
+ function _listTopLevelZipFiles() {
71
+ _listTopLevelZipFiles = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(zipFile) {
72
+ var _yield$import, ZipLoader, zipData, archive, files, _i, _Object$entries, _Object$entries$_i, path, buffer, name;
73
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
74
+ while (1) switch (_context.prev = _context.next) {
75
+ case 0:
76
+ _context.next = 2;
77
+ return import('@loaders.gl/zip');
78
+ case 2:
79
+ _yield$import = _context.sent;
80
+ ZipLoader = _yield$import.ZipLoader;
81
+ _context.next = 6;
82
+ return zipFile.arrayBuffer();
83
+ case 6:
84
+ zipData = _context.sent;
85
+ _context.next = 9;
86
+ return parse(zipData, ZipLoader, {
87
+ worker: false
88
+ });
89
+ case 9:
90
+ archive = _context.sent;
91
+ files = [];
92
+ _i = 0, _Object$entries = Object.entries(archive || {});
93
+ case 12:
94
+ if (!(_i < _Object$entries.length)) {
95
+ _context.next = 23;
96
+ break;
97
+ }
98
+ _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), path = _Object$entries$_i[0], buffer = _Object$entries$_i[1];
99
+ if (!(!path || path.endsWith('/') || path.includes('/'))) {
100
+ _context.next = 16;
101
+ break;
102
+ }
103
+ return _context.abrupt("continue", 20);
104
+ case 16:
105
+ name = fileNameFromArchivePath(path);
106
+ if (name) {
107
+ _context.next = 19;
108
+ break;
109
+ }
110
+ return _context.abrupt("continue", 20);
111
+ case 19:
112
+ files.push(new File([buffer], name));
113
+ case 20:
114
+ _i++;
115
+ _context.next = 12;
116
+ break;
117
+ case 23:
118
+ return _context.abrupt("return", files);
119
+ case 24:
120
+ case "end":
121
+ return _context.stop();
122
+ }
123
+ }, _callee);
124
+ }));
125
+ return _listTopLevelZipFiles.apply(this, arguments);
126
+ }
127
+ export function unzipShapefileArchive(_x2) {
128
+ return _unzipShapefileArchive.apply(this, arguments);
129
+ }
130
+ function _unzipShapefileArchive() {
131
+ _unzipShapefileArchive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(zipFile) {
132
+ var files;
133
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
134
+ while (1) switch (_context2.prev = _context2.next) {
135
+ case 0:
136
+ _context2.next = 2;
137
+ return listTopLevelZipFiles(zipFile);
138
+ case 2:
139
+ files = _context2.sent.filter(function (file) {
140
+ var ext = getDroppedFileExtension(file.name);
141
+ return ext === 'shp' || SHAPEFILE_SIDECAR_EXTENSIONS.includes(ext);
142
+ });
143
+ if (files.some(function (file) {
144
+ return getDroppedFileExtension(file.name) === 'shp';
145
+ })) {
146
+ _context2.next = 5;
147
+ break;
148
+ }
149
+ throw new Error('Zip archive does not contain a shapefile (.shp)');
150
+ case 5:
151
+ return _context2.abrupt("return", files);
152
+ case 6:
153
+ case "end":
154
+ return _context2.stop();
155
+ }
156
+ }, _callee2);
157
+ }));
158
+ return _unzipShapefileArchive.apply(this, arguments);
159
+ }
160
+ /**
161
+ * Split a zip into datasets. A single shapefile plus sidecars stays one
162
+ * shapefile archive. Any other mix (CSV, GeoJSON, several shapefiles, …)
163
+ * becomes one file per supported member. Sidecars are returned as companions
164
+ * and are not datasets. Nested folders and unsupported files are skipped.
165
+ */
166
+ export function expandZipArchive(_x3) {
167
+ return _expandZipArchive.apply(this, arguments);
168
+ }
169
+ function _expandZipArchive() {
170
+ _expandZipArchive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(zipFile) {
171
+ var extraExtensions,
172
+ extra,
173
+ entries,
174
+ companions,
175
+ datasets,
176
+ _iterator,
177
+ _step,
178
+ file,
179
+ ext,
180
+ shapefiles,
181
+ _args3 = arguments;
182
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
183
+ while (1) switch (_context3.prev = _context3.next) {
184
+ case 0:
185
+ extraExtensions = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : [];
186
+ extra = new Set(extraExtensions.map(function (extension) {
187
+ return extension.replace(/^\./, '').trim().toLowerCase();
188
+ }).filter(function (extension) {
189
+ return extension && extension !== 'zip';
190
+ }));
191
+ _context3.next = 4;
192
+ return listTopLevelZipFiles(zipFile);
193
+ case 4:
194
+ entries = _context3.sent;
195
+ companions = [];
196
+ datasets = [];
197
+ _iterator = _createForOfIteratorHelper(entries);
198
+ _context3.prev = 8;
199
+ _iterator.s();
200
+ case 10:
201
+ if ((_step = _iterator.n()).done) {
202
+ _context3.next = 19;
203
+ break;
204
+ }
205
+ file = _step.value;
206
+ if (!isShapefileSidecarFileName(file.name)) {
207
+ _context3.next = 15;
208
+ break;
209
+ }
210
+ companions.push(file);
211
+ return _context3.abrupt("continue", 17);
212
+ case 15:
213
+ ext = getDroppedFileExtension(file.name);
214
+ if (isLoadableDatasetExtension(ext) || extra.has(ext)) {
215
+ datasets.push(file);
216
+ }
217
+ case 17:
218
+ _context3.next = 10;
219
+ break;
220
+ case 19:
221
+ _context3.next = 24;
222
+ break;
223
+ case 21:
224
+ _context3.prev = 21;
225
+ _context3.t0 = _context3["catch"](8);
226
+ _iterator.e(_context3.t0);
227
+ case 24:
228
+ _context3.prev = 24;
229
+ _iterator.f();
230
+ return _context3.finish(24);
231
+ case 27:
232
+ shapefiles = datasets.filter(function (file) {
233
+ return getDroppedFileExtension(file.name) === 'shp';
234
+ });
235
+ if (!(shapefiles.length === 1 && datasets.length === 1)) {
236
+ _context3.next = 30;
237
+ break;
238
+ }
239
+ return _context3.abrupt("return", {
240
+ kind: 'shapefile',
241
+ shapefile: shapefiles[0],
242
+ companions: companions
243
+ });
244
+ case 30:
245
+ if (datasets.length) {
246
+ _context3.next = 32;
247
+ break;
248
+ }
249
+ throw new Error('Zip archive does not contain a supported dataset');
250
+ case 32:
251
+ return _context3.abrupt("return", {
252
+ kind: 'datasets',
253
+ datasets: datasets,
254
+ companions: companions
255
+ });
256
+ case 33:
257
+ case "end":
258
+ return _context3.stop();
259
+ }
260
+ }, _callee3, null, [[8, 21, 24, 27]]);
261
+ }));
262
+ return _expandZipArchive.apply(this, arguments);
263
+ }
264
+ //# sourceMappingURL=shapefile-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapefile-files.js","names":["_BrowserFileSystem","parse","isLoadableDatasetExtension","SHAPEFILE_SIDECAR_EXTENSIONS","SHAPEFILE_SOURCE_EXTENSIONS","getDroppedFileExtension","fileName","arguments","length","undefined","match","toLowerCase","isShapefileSidecarFileName","includes","isZipFileName","isShapefileSourceFileName","getFilesToParse","files","list","Array","from","hasShapefileSource","some","file","name","filter","createCompanionFetch","File","every","fileSystem","fetch","bind","fileNameFromArchivePath","path","parts","split","listTopLevelZipFiles","_x","_listTopLevelZipFiles","apply","_asyncToGenerator","_regeneratorRuntime","mark","_callee","zipFile","_yield$import","ZipLoader","zipData","archive","_i","_Object$entries","_Object$entries$_i","buffer","wrap","_callee$","_context","prev","next","sent","arrayBuffer","worker","Object","entries","_slicedToArray","endsWith","abrupt","push","stop","unzipShapefileArchive","_x2","_unzipShapefileArchive","_callee2","_callee2$","_context2","ext","Error","expandZipArchive","_x3","_expandZipArchive","_callee3","extraExtensions","extra","companions","datasets","_iterator","_step","shapefiles","_args3","_callee3$","_context3","Set","map","extension","replace","trim","_createForOfIteratorHelper","s","n","done","value","has","t0","e","f","finish","kind","shapefile"],"sources":["../../src/shapefile-files.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {_BrowserFileSystem, parse} from '@loaders.gl/core';\n\nimport {isLoadableDatasetExtension} from './loader-registry';\n\nexport const SHAPEFILE_SIDECAR_EXTENSIONS = ['dbf', 'shx', 'prj', 'cpg'] as const;\nexport const SHAPEFILE_SOURCE_EXTENSIONS = ['shp', 'zip'] as const;\n\ntype NamedFile = {name: string};\n\nexport function getDroppedFileExtension(fileName = ''): string {\n const match = fileName.match(/\\.([a-z0-9]+)$/i);\n return match ? match[1].toLowerCase() : '';\n}\n\nexport function isShapefileSidecarFileName(fileName: string): boolean {\n return (SHAPEFILE_SIDECAR_EXTENSIONS as readonly string[]).includes(\n getDroppedFileExtension(fileName)\n );\n}\n\nexport function isZipFileName(fileName: string): boolean {\n return getDroppedFileExtension(fileName) === 'zip';\n}\n\nexport function isShapefileSourceFileName(fileName: string): boolean {\n return (SHAPEFILE_SOURCE_EXTENSIONS as readonly string[]).includes(\n getDroppedFileExtension(fileName)\n );\n}\n\n/**\n * Sidecar files (.dbf, .shx, .prj, .cpg) are not datasets. Skip them when a\n * .shp or shapefile .zip is also present so they can be used as companions.\n */\nexport function getFilesToParse<T extends NamedFile>(files: T[]): T[] {\n const list = Array.from(files);\n const hasShapefileSource = list.some(file => isShapefileSourceFileName(file.name));\n if (!hasShapefileSource) {\n return list;\n }\n return list.filter(file => !isShapefileSidecarFileName(file.name));\n}\n\nexport function createCompanionFetch(\n files?: File[]\n): ((url: string) => Promise<Response>) | undefined {\n if (\n !files?.length ||\n typeof File === 'undefined' ||\n files.every(file => !(file instanceof File))\n ) {\n return undefined;\n }\n const fileSystem = new _BrowserFileSystem(files);\n return fileSystem.fetch.bind(fileSystem);\n}\n\nfunction fileNameFromArchivePath(path: string): string {\n const parts = path.split(/[/\\\\]/);\n return parts[parts.length - 1] || path;\n}\n\n/**\n * Top-level members of a zip. Nested folders are ignored. Directory entries\n * are skipped.\n */\nasync function listTopLevelZipFiles(zipFile: File): Promise<File[]> {\n const {ZipLoader} = await import('@loaders.gl/zip');\n const zipData = await zipFile.arrayBuffer();\n const archive = (await parse(zipData, ZipLoader, {worker: false})) as Record<string, ArrayBuffer>;\n const files: File[] = [];\n\n for (const [path, buffer] of Object.entries(archive || {})) {\n if (!path || path.endsWith('/') || path.includes('/')) {\n continue;\n }\n const name = fileNameFromArchivePath(path);\n if (!name) {\n continue;\n }\n files.push(new File([buffer], name));\n }\n\n return files;\n}\n\n/**\n * Unpack a zip that contains a shapefile. Only top-level .shp plus sidecars\n * are returned; nested folders are ignored.\n */\nexport async function unzipShapefileArchive(zipFile: File): Promise<File[]> {\n const files = (await listTopLevelZipFiles(zipFile)).filter(file => {\n const ext = getDroppedFileExtension(file.name);\n return ext === 'shp' || (SHAPEFILE_SIDECAR_EXTENSIONS as readonly string[]).includes(ext);\n });\n\n if (!files.some(file => getDroppedFileExtension(file.name) === 'shp')) {\n throw new Error('Zip archive does not contain a shapefile (.shp)');\n }\n\n return files;\n}\n\nexport type ZipArchiveExpansion =\n | {\n /** One shapefile and no other datasets. The load keeps the zip's name. */\n kind: 'shapefile';\n shapefile: File;\n companions: File[];\n }\n | {\n /** One dataset per supported top-level file, named from that file. */\n kind: 'datasets';\n datasets: File[];\n companions: File[];\n };\n\n/**\n * Split a zip into datasets. A single shapefile plus sidecars stays one\n * shapefile archive. Any other mix (CSV, GeoJSON, several shapefiles, …)\n * becomes one file per supported member. Sidecars are returned as companions\n * and are not datasets. Nested folders and unsupported files are skipped.\n */\nexport async function expandZipArchive(\n zipFile: File,\n extraExtensions: string[] = []\n): Promise<ZipArchiveExpansion> {\n const extra = new Set(\n extraExtensions\n .map(extension => extension.replace(/^\\./, '').trim().toLowerCase())\n .filter(extension => extension && extension !== 'zip')\n );\n const entries = await listTopLevelZipFiles(zipFile);\n const companions: File[] = [];\n const datasets: File[] = [];\n\n for (const file of entries) {\n if (isShapefileSidecarFileName(file.name)) {\n companions.push(file);\n continue;\n }\n const ext = getDroppedFileExtension(file.name);\n if (isLoadableDatasetExtension(ext) || extra.has(ext)) {\n datasets.push(file);\n }\n }\n\n const shapefiles = datasets.filter(file => getDroppedFileExtension(file.name) === 'shp');\n if (shapefiles.length === 1 && datasets.length === 1) {\n return {kind: 'shapefile', shapefile: shapefiles[0], companions};\n }\n if (!datasets.length) {\n throw new Error('Zip archive does not contain a supported dataset');\n }\n return {kind: 'datasets', datasets, companions};\n}\n"],"mappings":";;;;;;AAAA;AACA;;AAEA,SAAQA,kBAAkB,EAAEC,KAAK,QAAO,kBAAkB;AAE1D,SAAQC,0BAA0B,QAAO,mBAAmB;AAE5D,OAAO,IAAMC,4BAA4B,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU;AACjF,OAAO,IAAMC,2BAA2B,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU;AAIlE,OAAO,SAASC,uBAAuBA,CAAA,EAAwB;EAAA,IAAvBC,QAAQ,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EACnD,IAAMG,KAAK,GAAGJ,QAAQ,CAACI,KAAK,CAAC,iBAAiB,CAAC;EAC/C,OAAOA,KAAK,GAAGA,KAAK,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAG,EAAE;AAC5C;AAEA,OAAO,SAASC,0BAA0BA,CAACN,QAAgB,EAAW;EACpE,OAAQH,4BAA4B,CAAuBU,QAAQ,CACjER,uBAAuB,CAACC,QAAQ,CAClC,CAAC;AACH;AAEA,OAAO,SAASQ,aAAaA,CAACR,QAAgB,EAAW;EACvD,OAAOD,uBAAuB,CAACC,QAAQ,CAAC,KAAK,KAAK;AACpD;AAEA,OAAO,SAASS,yBAAyBA,CAACT,QAAgB,EAAW;EACnE,OAAQF,2BAA2B,CAAuBS,QAAQ,CAChER,uBAAuB,CAACC,QAAQ,CAClC,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASU,eAAeA,CAAsBC,KAAU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,CAACkB,IAAI,CAACC,IAAI,CAAC,KAAK,KAAK;UAAA,EAAC;UAAA,MACpF8D,UAAU,CAAC9E,MAAM,KAAK,CAAC,IAAI2E,QAAQ,CAAC3E,MAAM,KAAK,CAAC;YAAAiF,SAAA,CAAAhC,IAAA;YAAA;UAAA;UAAA,OAAAgC,SAAA,CAAAxB,MAAA,WAC3C;YAACwC,IAAI,EAAE,WAAW;YAAEC,SAAS,EAAEpB,UAAU,CAAC,CAAC,CAAC;YAAEJ,UAAU,EAAVA;UAAU,CAAC;QAAA;UAAA,IAE7DC,QAAQ,CAAC3E,MAAM;YAAAiF,SAAA,CAAAhC,IAAA;YAAA;UAAA;UAAA,MACZ,IAAIkB,KAAK,CAAC,kDAAkD,CAAC;QAAA;UAAA,OAAAc,SAAA,CAAAxB,MAAA,WAE9D;YAACwC,IAAI,EAAE,UAAU;YAAEtB,QAAQ,EAARA,QAAQ;YAAED,UAAU,EAAVA;UAAU,CAAC;QAAA;QAAA;UAAA,OAAAO,SAAA,CAAAtB,IAAA;MAAA;IAAA,GAAAY,QAAA;EAAA,CAChD;EAAA,OAAAD,iBAAA,CAAAvC,KAAA,OAAAhC,SAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export {};
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nexport type FileCacheItem = {\n data: any;\n /**\n * Cumulative Arrow snapshots replayed after the user confirms Add Data.\n * Kept outside `data` so the final staged dataset remains available for\n * validation and row-count display without being added to the map early.\n */\n progressiveData?: any[];\n info: {\n id?: string;\n label: string;\n format: string;\n type?: string;\n };\n metadata?: {\n source?: string;\n format?: string;\n sourceFormat?: string;\n [key: string]: unknown;\n };\n};\n\nexport type ValidKeplerGlMap = {\n datasets: unknown;\n config: unknown;\n info: Record<string, string>;\n};\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ import { Field, FieldPair } from '@kepler.gl/types';
2
+ import { DataContainerInterface } from '@kepler.gl/utils';
3
+ import type { FeatureCollection } from 'geojson';
4
+ /**
5
+ * Turn dataset rows into a FeatureCollection.
6
+ * Columns listed in `hiddenColumns` are left out of feature properties.
7
+ * A geometry column is still used to build the feature geometry.
8
+ */
9
+ export declare function datasetToFeatureCollection(data: DataContainerInterface, fields: Field[], options?: {
10
+ hiddenColumns?: string[];
11
+ fieldPairs?: FieldPair[];
12
+ }): FeatureCollection;
@@ -0,0 +1,28 @@
1
+ import type { FeatureCollection } from 'geojson';
2
+ import type { SqlJsStatic } from 'sql.js';
3
+ /**
4
+ * Synchronous core of {@link writeGeoPackage}, separated so it can be unit-tested
5
+ * with an already-initialised sql.js factory (the async wrapper resolves the
6
+ * factory through a Vite `?url` import that only works in the browser).
7
+ *
8
+ * Args:
9
+ * SQL: An initialised sql.js factory.
10
+ * geojson: Features to write (assumed WGS84).
11
+ * layerName: Name of the single feature table / layer in the GeoPackage.
12
+ *
13
+ * Returns:
14
+ * The GeoPackage file as bytes.
15
+ */
16
+ export declare function writeGeoPackageSync(SQL: SqlJsStatic, geojson: FeatureCollection, layerName: string): Uint8Array;
17
+ /**
18
+ * Write a GeoJSON FeatureCollection to a GeoPackage (loads sql.js, then defers
19
+ * to {@link writeGeoPackageSync}).
20
+ *
21
+ * Args:
22
+ * geojson: Features to write (assumed WGS84).
23
+ * layerName: Name of the single feature table / layer in the GeoPackage.
24
+ *
25
+ * Returns:
26
+ * The GeoPackage file as bytes.
27
+ */
28
+ export declare function writeGeoPackage(geojson: FeatureCollection, layerName: string): Promise<Uint8Array>;
@@ -0,0 +1,7 @@
1
+ import type { Field } from '@kepler.gl/types';
2
+ import type { DataContainerInterface } from '@kepler.gl/utils';
3
+ import type { FeatureCollection } from 'geojson';
4
+ /**
5
+ * Write a GeoJSON FeatureCollection as GeoParquet 1.1 (WKB geometry, WGS84).
6
+ */
7
+ export declare function writeGeoParquet(geojson: FeatureCollection, fields?: Field[], data?: DataContainerInterface): Promise<Uint8Array>;
@@ -0,0 +1,13 @@
1
+ import type { FeatureCollection } from 'geojson';
2
+ export declare class KmlCoordinateError extends Error {
3
+ constructor(featureIndex: number, featureId?: string | number);
4
+ }
5
+ /**
6
+ * Convert a GeoJSON FeatureCollection to a KML 2.2 document.
7
+ *
8
+ * Feature properties are retained in ExtendedData, except primitive `name` and
9
+ * `description` values that are represented by their native KML elements.
10
+ * Simplestyle properties are also promoted to native KML styles for display in
11
+ * Google Earth and other KML clients.
12
+ */
13
+ export declare function writeKml(geojson: FeatureCollection, documentName: string): string;
@@ -0,0 +1,28 @@
1
+ import type { FeatureCollection } from 'geojson';
2
+ /**
3
+ * Write a GeoJSON FeatureCollection to an ESRI Shapefile dataset (the .shp,
4
+ * .shx, .dbf, .prj, and .cpg parts) entirely in the browser.
5
+ *
6
+ * DuckDB-WASM and Pyodide's bundled GDAL cannot write GDAL vector formats in the
7
+ * browser, so the binary parts are assembled directly. The dataset is WGS84
8
+ * (EPSG:4326). All non-null geometries must share one shape family
9
+ * (point/line/polygon). Null geometries are written as the Shapefile "Null"
10
+ * shape so the record count still lines up with the .dbf.
11
+ */
12
+ export interface ShapefileParts {
13
+ shp: Uint8Array;
14
+ shx: Uint8Array;
15
+ dbf: Uint8Array;
16
+ prj: Uint8Array;
17
+ cpg: Uint8Array;
18
+ }
19
+ /**
20
+ * Assemble the parts of an ESRI Shapefile from a FeatureCollection.
21
+ *
22
+ * Args:
23
+ * geojson: Features to write (assumed WGS84).
24
+ *
25
+ * Returns:
26
+ * The .shp/.shx/.dbf/.prj/.cpg byte buffers (the caller names and zips them).
27
+ */
28
+ export declare function writeShapefile(geojson: FeatureCollection): ShapefileParts;
@@ -0,0 +1,8 @@
1
+ import type { SqlJsStatic } from 'sql.js';
2
+ /**
3
+ * Load sql.js once.
4
+ * Tests import the package, which reads the wasm from disk. The browser build
5
+ * of that package calls Node's fs/path/crypto, so the demo bundle loads the
6
+ * script from a CDN instead of importing it.
7
+ */
8
+ export declare function loadSqlJs(): Promise<SqlJsStatic>;
@@ -0,0 +1,22 @@
1
+ import { Field, FieldPair } from '@kepler.gl/types';
2
+ import { DataContainerInterface } from '@kepler.gl/utils';
3
+ export { datasetToFeatureCollection } from './dataset-to-geojson';
4
+ export type EncodedDatasetExport = {
5
+ data: BlobPart;
6
+ extension: string;
7
+ mimeType: string;
8
+ };
9
+ /** Turn a dataset label into a filesystem-safe export base name. */
10
+ export declare function sanitizeExportName(name: string): string;
11
+ /**
12
+ * Encode a dataset for download. Hidden attribute-table columns are omitted.
13
+ * Geometry columns that are hidden are still used to build the feature geometry.
14
+ */
15
+ export declare function encodeDatasetExport(options: {
16
+ data: DataContainerInterface;
17
+ fields: Field[];
18
+ fieldPairs?: FieldPair[];
19
+ hiddenColumns?: string[];
20
+ dataType: string;
21
+ layerName: string;
22
+ }): Promise<EncodedDatasetExport>;
@@ -1,7 +1,8 @@
1
1
  import { Loader } from '@loaders.gl/loader-utils';
2
+ import { ParseGeoArrowInput, ParseGeoArrowResult } from '@loaders.gl/arrow';
2
3
  import { isArrowTable } from '@kepler.gl/utils';
3
- import { AddDataToMapPayload, Feature } from '@kepler.gl/types';
4
- import { FeatureCollection } from '@turf/helpers';
4
+ import { AddDataToMapOptions, AddDataToMapPayload, GeoArrowBinaryData, ProcessorResult } from '@kepler.gl/types';
5
+ import type { Feature, FeatureCollection } from 'geojson';
5
6
  import { FileCacheItem, ValidKeplerGlMap } from './types';
6
7
  export type ProcessFileDataContent = {
7
8
  data: unknown;
@@ -14,8 +15,39 @@ export type ProcessFileDataContent = {
14
15
  };
15
16
  /** metadata e.g. for arrow data, metadata could be the schema.fields */
16
17
  metadata?: Map<string, string>;
18
+ /** Remote URL this file was fetched from, if any. */
19
+ sourceUrl?: string;
20
+ /** User-selected or inferred remote file format (csv, geojson, parquet, …). */
21
+ keplerFormat?: string;
22
+ /** Poll interval in ms, copied from a remote URL load. */
23
+ refreshIntervalMs?: number;
24
+ /** HTTP ETag from the remote fetch, used for the next conditional refresh. */
25
+ etag?: string;
26
+ /** HTTP Last-Modified from the remote fetch, used for the next conditional refresh. */
27
+ lastModified?: string;
28
+ /** Original file size in bytes, kept so a remounted uploader can still warn. */
29
+ fileSize?: number;
30
+ /**
31
+ * When true, skip Arrow record-batch compaction. Set on intermediate
32
+ * progressive Arrow loads so each batch does not copy the growing table.
33
+ */
34
+ skipArrowCompact?: boolean;
35
+ /** Build cumulative Arrow snapshots that can be replayed after Add Data confirmation. */
36
+ prepareProgressiveReplay?: boolean;
17
37
  };
18
38
  export { isArrowTable };
39
+ type ParseGeoArrowWorker = (data: ParseGeoArrowInput) => Promise<ParseGeoArrowResult>;
40
+ /**
41
+ * Convert native GeoArrow chunks to deck.gl binary features without blocking
42
+ * the main thread. WKB/WKT remain on the synchronous fallback because the
43
+ * loaders.gl triangulation worker only supports native GeoArrow encodings.
44
+ */
45
+ export declare function parseGeoArrowBatchesOnWorkers(data: NonNullable<ProcessorResult>, options?: {
46
+ latestOnly?: boolean;
47
+ parseOnWorker?: ParseGeoArrowWorker;
48
+ /** Merge per-batch worker output when the final Arrow table was compacted to one chunk. */
49
+ targetChunkCount?: number;
50
+ }): Promise<GeoArrowBinaryData | undefined>;
19
51
  /**
20
52
  * check if data is an ArrowData object, which is an array of RecordBatch
21
53
  * @param data - object to check
@@ -25,20 +57,35 @@ export declare function isArrowData(data: any): boolean;
25
57
  export declare function isGeoJson(json: unknown): json is Feature | FeatureCollection;
26
58
  export declare function isFeature(json: unknown): json is Feature;
27
59
  export declare function isFeatureCollection(json: unknown): json is FeatureCollection;
60
+ export declare function isGeoJsonFeatureArray(json: unknown): json is Feature[];
61
+ /**
62
+ * Normalize loaders.gl GIS output (Feature arrays, geojson-table, object-row
63
+ * tables of Features) into a GeoJSON Feature or FeatureCollection Kepler can process.
64
+ */
65
+ export declare function getGeoJsonFromLoaderResult(data: unknown): Feature | FeatureCollection | null;
28
66
  export declare function isRowObject(json: any): boolean;
29
67
  export declare function isKeplerGlMap(json: unknown): json is ValidKeplerGlMap;
30
68
  export declare function makeProgressIterator(asyncIterator: AsyncIterable<any>, info: {
31
69
  size: number;
32
70
  }): AsyncGenerator;
33
- export declare function readBatch(asyncIterator: AsyncIterable<any>, fileName: string): AsyncGenerator;
34
- export declare function readFileInBatches({ file, loaders, loadOptions }: {
71
+ export declare function getPersistedRemoteFormat(keplerFormat?: string, fileName?: string): string | undefined;
72
+ export declare function readBatch(asyncIterator: AsyncIterable<any>, fileName: string, sourceUrl?: string, keplerFormat?: string, refreshIntervalMs?: number, etag?: string, lastModified?: string, fileSize?: number): AsyncGenerator;
73
+ export declare function readFileInBatches({ file, loaders, loadOptions, companionFiles, fileName }: {
35
74
  file: File;
36
- fileCache: FileCacheItem[];
37
- loaders: Loader[];
38
- loadOptions: any;
75
+ fileCache?: FileCacheItem[];
76
+ loaders?: Loader[];
77
+ loadOptions?: any;
78
+ companionFiles?: File[];
79
+ /** Display/progress name. Kept across zip → shapefile recursion. */
80
+ fileName?: string;
39
81
  }): Promise<AsyncGenerator>;
40
82
  export declare function processFileData({ content, fileCache }: {
41
83
  content: ProcessFileDataContent;
42
84
  fileCache: FileCacheItem[];
43
85
  }): Promise<FileCacheItem[]>;
44
- export declare function filesToDataPayload(fileCache: FileCacheItem[]): AddDataToMapPayload[];
86
+ /**
87
+ * Expand staged files into cumulative payloads for one redraw per Arrow batch.
88
+ * Non-progressive files are present only in the first payload.
89
+ */
90
+ export declare function fileCacheToProgressiveSteps(fileCache: FileCacheItem[]): FileCacheItem[][];
91
+ export declare function filesToDataPayload(fileCache: FileCacheItem[], options?: AddDataToMapOptions): AddDataToMapPayload[];
package/dist/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
1
  export * from './data-processor';
2
2
  export * from './file-handler';
3
+ export * from './remote-file';
3
4
  export * from './types';
5
+ export * from './kepler-csv-loader';
6
+ export * from './loader-registry';
7
+ export * from './shapefile-files';
8
+ export { datasetToFeatureCollection, encodeDatasetExport, sanitizeExportName } from './export/vector-export';
9
+ export type { EncodedDatasetExport } from './export/vector-export';