@walkthru-earth/objex 1.3.1 → 1.4.0

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 (184) hide show
  1. package/LICENSE +5 -0
  2. package/README.md +20 -12
  3. package/dist/components/browser/FileTreeSidebar.svelte +32 -17
  4. package/dist/components/layout/AboutSheet.svelte +5 -2
  5. package/dist/components/layout/ConnectionDialog.svelte +1 -1
  6. package/dist/components/layout/SettingsSheet.svelte +237 -0
  7. package/dist/components/layout/SettingsSheet.svelte.d.ts +6 -0
  8. package/dist/components/layout/Sidebar.svelte +73 -6
  9. package/dist/components/layout/Sidebar.svelte.d.ts +4 -1
  10. package/dist/components/layout/StatusBar.svelte +1 -1
  11. package/dist/components/layout/TabBar.svelte +2 -2
  12. package/dist/components/ui/context-menu/context-menu-radio-group.svelte.d.ts +1 -1
  13. package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-group.svelte.d.ts +1 -1
  14. package/dist/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte.d.ts +1 -1
  15. package/dist/components/ui/input/input.svelte.d.ts +1 -1
  16. package/dist/components/ui/resizable/index.d.ts +1 -1
  17. package/dist/components/ui/resizable/index.js +2 -2
  18. package/dist/components/ui/slider/index.d.ts +3 -0
  19. package/dist/components/ui/slider/index.js +5 -0
  20. package/dist/components/ui/slider/range-slider.svelte +94 -0
  21. package/dist/components/ui/slider/range-slider.svelte.d.ts +21 -0
  22. package/dist/components/ui/slider/slider.svelte +83 -0
  23. package/dist/components/ui/slider/slider.svelte.d.ts +7 -0
  24. package/dist/components/viewers/ArchiveViewer.svelte +2 -2
  25. package/dist/components/viewers/CodeViewer.svelte +31 -22
  26. package/dist/components/viewers/CogControls.svelte +338 -184
  27. package/dist/components/viewers/CogControls.svelte.d.ts +33 -10
  28. package/dist/components/viewers/CogViewer.svelte +263 -112
  29. package/dist/components/viewers/CopcViewer.svelte +1 -1
  30. package/dist/components/viewers/FlatGeobufViewer.svelte +1 -1
  31. package/dist/components/viewers/GeoParquetMapViewer.svelte +6 -6
  32. package/dist/components/viewers/GeoParquetMapViewer.svelte.d.ts +1 -1
  33. package/dist/components/viewers/ImageViewer.svelte +2 -2
  34. package/dist/components/viewers/MarkdownViewer.svelte +12 -9
  35. package/dist/components/viewers/MediaViewer.svelte +2 -2
  36. package/dist/components/viewers/ModelViewer.svelte +1 -1
  37. package/dist/components/viewers/MultiCogViewer.svelte +467 -102
  38. package/dist/components/viewers/MultiCogViewer.svelte.d.ts +1 -1
  39. package/dist/components/viewers/NotebookViewer.svelte +6 -3
  40. package/dist/components/viewers/PdfViewer.svelte +2 -2
  41. package/dist/components/viewers/PmtilesViewer.svelte +3 -6
  42. package/dist/components/viewers/RawViewer.svelte +6 -3
  43. package/dist/components/viewers/StacMapViewer.svelte +1 -1
  44. package/dist/components/viewers/StacMosaicViewer.svelte +1760 -408
  45. package/dist/components/viewers/StacMosaicViewer.svelte.d.ts +1 -1
  46. package/dist/components/viewers/StacTabViewer.svelte +24 -13
  47. package/dist/components/viewers/StacTabViewer.svelte.d.ts +1 -1
  48. package/dist/components/viewers/TableGrid.svelte +4 -4
  49. package/dist/components/viewers/TableStatusBar.svelte +1 -1
  50. package/dist/components/viewers/TableToolbar.svelte +1 -1
  51. package/dist/components/viewers/TableViewer.svelte +25 -17
  52. package/dist/components/viewers/TableViewer.svelte.d.ts +1 -0
  53. package/dist/components/viewers/ViewerRouter.svelte +16 -8
  54. package/dist/components/viewers/ZarrMapViewer.svelte +11 -9
  55. package/dist/components/viewers/ZarrViewer.svelte +4 -4
  56. package/dist/components/viewers/cog/ChannelPicker.svelte +83 -0
  57. package/dist/components/viewers/cog/ChannelPicker.svelte.d.ts +13 -0
  58. package/dist/components/viewers/cog/PixelInspectorPanel.svelte +87 -0
  59. package/dist/components/viewers/cog/PixelInspectorPanel.svelte.d.ts +17 -0
  60. package/dist/components/viewers/cog/buildRgbLayer.d.ts +78 -0
  61. package/dist/components/viewers/cog/buildRgbLayer.js +176 -0
  62. package/dist/components/viewers/map/AttributeTable.svelte +1 -1
  63. package/dist/components/viewers/map/MapContainer.svelte +37 -11
  64. package/dist/components/viewers/pmtiles/PmtilesArchiveView.svelte +1 -1
  65. package/dist/components/viewers/pmtiles/PmtilesTileInspector.svelte +1 -1
  66. package/dist/components/viewers/stac/StacDatetimeBar.svelte +175 -0
  67. package/dist/components/viewers/stac/StacDatetimeBar.svelte.d.ts +10 -0
  68. package/dist/components/viewers/stac/StacFilterPanel.svelte +243 -0
  69. package/dist/components/viewers/stac/StacFilterPanel.svelte.d.ts +14 -0
  70. package/dist/components/viewers/stac/StacItemInspector.svelte +223 -0
  71. package/dist/components/viewers/stac/StacItemInspector.svelte.d.ts +10 -0
  72. package/dist/components/viewers/stac/StacItemStrip.svelte +228 -0
  73. package/dist/components/viewers/stac/StacItemStrip.svelte.d.ts +12 -0
  74. package/dist/file-icons/index.d.ts +1 -1
  75. package/dist/file-icons/index.js +1 -1
  76. package/dist/i18n/ar.js +110 -2
  77. package/dist/i18n/en.js +110 -2
  78. package/dist/index.d.ts +2 -28
  79. package/dist/index.js +7 -23
  80. package/dist/query/engine.d.ts +10 -0
  81. package/dist/query/source.js +1 -1
  82. package/dist/query/stac-source-factory.d.ts +65 -0
  83. package/dist/query/stac-source-factory.js +77 -0
  84. package/dist/query/stac-source-parquet.d.ts +135 -0
  85. package/dist/query/stac-source-parquet.js +465 -0
  86. package/dist/query/wasm.d.ts +8 -0
  87. package/dist/query/wasm.js +304 -2
  88. package/dist/storage/presign.js +1 -1
  89. package/dist/storage/providers.js +5 -5
  90. package/dist/stores/config.svelte.d.ts +15 -0
  91. package/dist/stores/config.svelte.js +46 -0
  92. package/dist/stores/connections.svelte.d.ts +2 -2
  93. package/dist/stores/connections.svelte.js +1 -2
  94. package/dist/stores/files.svelte.d.ts +1 -1
  95. package/dist/stores/files.svelte.js +1 -1
  96. package/dist/stores/query-history.svelte.js +1 -1
  97. package/dist/stores/settings.svelte.d.ts +16 -1
  98. package/dist/stores/settings.svelte.js +104 -48
  99. package/dist/stores/tabs.svelte.d.ts +3 -0
  100. package/dist/stores/tabs.svelte.js +17 -0
  101. package/dist/utils/cog-histogram.d.ts +121 -0
  102. package/dist/utils/cog-histogram.js +424 -0
  103. package/dist/utils/cog.d.ts +177 -20
  104. package/dist/utils/cog.js +361 -76
  105. package/dist/utils/colormap-sprite.d.ts +0 -9
  106. package/dist/utils/colormap-sprite.js +0 -21
  107. package/dist/utils/deck.d.ts +16 -12
  108. package/dist/utils/deck.js +10 -4
  109. package/dist/utils/pmtiles-tile.js +2 -2
  110. package/dist/utils/{url.d.ts → signed-url.d.ts} +15 -1
  111. package/dist/utils/{url.js → signed-url.js} +32 -10
  112. package/dist/utils/url-state.d.ts +36 -0
  113. package/dist/utils/url-state.js +72 -2
  114. package/dist/utils/zarr-tab.d.ts +1 -2
  115. package/dist/utils/zarr-tab.js +1 -2
  116. package/dist/utils/zarr.d.ts +0 -17
  117. package/dist/utils/zarr.js +1 -45
  118. package/package.json +55 -84
  119. package/dist/components/browser/Breadcrumb.svelte +0 -50
  120. package/dist/components/browser/Breadcrumb.svelte.d.ts +0 -7
  121. package/dist/components/browser/CreateFolderDialog.svelte +0 -98
  122. package/dist/components/browser/CreateFolderDialog.svelte.d.ts +0 -6
  123. package/dist/components/browser/DeleteConfirmDialog.svelte +0 -90
  124. package/dist/components/browser/DeleteConfirmDialog.svelte.d.ts +0 -8
  125. package/dist/components/browser/DropZone.svelte +0 -83
  126. package/dist/components/browser/DropZone.svelte.d.ts +0 -7
  127. package/dist/components/browser/FileBrowser.svelte +0 -252
  128. package/dist/components/browser/FileBrowser.svelte.d.ts +0 -3
  129. package/dist/components/browser/FileRow.svelte +0 -117
  130. package/dist/components/browser/FileRow.svelte.d.ts +0 -9
  131. package/dist/components/browser/RenameDialog.svelte +0 -101
  132. package/dist/components/browser/RenameDialog.svelte.d.ts +0 -8
  133. package/dist/components/browser/SearchBar.svelte +0 -40
  134. package/dist/components/browser/SearchBar.svelte.d.ts +0 -6
  135. package/dist/components/browser/UploadButton.svelte +0 -65
  136. package/dist/components/browser/UploadButton.svelte.d.ts +0 -3
  137. package/dist/query/stac-geoparquet.d.ts +0 -31
  138. package/dist/query/stac-geoparquet.js +0 -136
  139. package/dist/utils/clipboard.d.ts +0 -13
  140. package/dist/utils/clipboard.js +0 -38
  141. package/dist/utils/cloud-url.d.ts +0 -27
  142. package/dist/utils/cloud-url.js +0 -61
  143. package/dist/utils/cog-pure.d.ts +0 -25
  144. package/dist/utils/cog-pure.js +0 -35
  145. package/dist/utils/column-types.d.ts +0 -5
  146. package/dist/utils/column-types.js +0 -137
  147. package/dist/utils/connection-identity.d.ts +0 -51
  148. package/dist/utils/connection-identity.js +0 -97
  149. package/dist/utils/error.d.ts +0 -8
  150. package/dist/utils/error.js +0 -12
  151. package/dist/utils/evidence-context.d.ts +0 -22
  152. package/dist/utils/evidence-context.js +0 -56
  153. package/dist/utils/export.d.ts +0 -22
  154. package/dist/utils/export.js +0 -76
  155. package/dist/utils/file-sort.d.ts +0 -20
  156. package/dist/utils/file-sort.js +0 -41
  157. package/dist/utils/format.d.ts +0 -24
  158. package/dist/utils/format.js +0 -78
  159. package/dist/utils/geoarrow.d.ts +0 -32
  160. package/dist/utils/geoarrow.js +0 -672
  161. package/dist/utils/geometry-type.d.ts +0 -52
  162. package/dist/utils/geometry-type.js +0 -76
  163. package/dist/utils/hex.d.ts +0 -10
  164. package/dist/utils/hex.js +0 -27
  165. package/dist/utils/host-detection.d.ts +0 -23
  166. package/dist/utils/host-detection.js +0 -95
  167. package/dist/utils/local-storage.d.ts +0 -16
  168. package/dist/utils/local-storage.js +0 -37
  169. package/dist/utils/markdown-sql.d.ts +0 -30
  170. package/dist/utils/markdown-sql.js +0 -72
  171. package/dist/utils/notebook.d.ts +0 -59
  172. package/dist/utils/notebook.js +0 -211
  173. package/dist/utils/parquet-metadata.d.ts +0 -64
  174. package/dist/utils/parquet-metadata.js +0 -262
  175. package/dist/utils/stac-geoparquet.d.ts +0 -90
  176. package/dist/utils/stac-geoparquet.js +0 -223
  177. package/dist/utils/stac-hydrate.d.ts +0 -38
  178. package/dist/utils/stac-hydrate.js +0 -243
  179. package/dist/utils/stac.d.ts +0 -136
  180. package/dist/utils/stac.js +0 -176
  181. package/dist/utils/storage-url.d.ts +0 -90
  182. package/dist/utils/storage-url.js +0 -568
  183. package/dist/utils/wkb.d.ts +0 -43
  184. package/dist/utils/wkb.js +0 -359
@@ -1,52 +0,0 @@
1
- /**
2
- * Helpers for parsing DuckDB v1.5 parameterized GEOMETRY type strings.
3
- *
4
- * DuckDB v1.5 made GEOMETRY a core type with an optional CRS parameter:
5
- * GEOMETRY — no CRS attached
6
- * GEOMETRY('EPSG:4326') — EPSG form
7
- * GEOMETRY('OGC:CRS84') — OGC form (canonical for GeoParquet 1.1+)
8
- * GEOMETRY('EPSG:27700') — projected CRS
9
- *
10
- * Type strings may come from `DESCRIBE`, from the Arrow schema, or from a
11
- * legacy code path that still reports `BLOB`. Use these helpers everywhere
12
- * instead of ad-hoc regex so behaviour stays consistent.
13
- */
14
- export interface GeometryTypeInfo {
15
- /** True if the type is some form of GEOMETRY (with or without CRS). */
16
- isGeometry: boolean;
17
- /** True if the type carries a CRS parameter, e.g. GEOMETRY('EPSG:4326'). */
18
- hasCrs: boolean;
19
- /** The CRS string if present, otherwise null. Raw value, including WGS84. */
20
- rawCrs: string | null;
21
- /**
22
- * The CRS string if present and NOT a WGS84 variant (EPSG:4326, EPSG:4979,
23
- * OGC:CRS84). Returns null for WGS84 so callers can skip ST_Transform.
24
- */
25
- nonWgs84Crs: string | null;
26
- }
27
- /**
28
- * Parse a DuckDB type string and report whether it is a GEOMETRY type, and
29
- * whether a CRS parameter is attached.
30
- */
31
- export declare function parseGeometryTypeCrs(typeStr: string | null | undefined): GeometryTypeInfo;
32
- /** True for EPSG:4326, EPSG:4979, OGC:CRS84 and equivalent strings. */
33
- export declare function isWgs84Crs(crs: string | null | undefined): boolean;
34
- /**
35
- * Build a `ST_Transform(...)` SQL expression choosing the 2-arg form when the
36
- * input already carries its CRS in the GEOMETRY type (DuckDB v1.5), and the
37
- * 3-arg form otherwise.
38
- *
39
- * `geometry_always_xy` is set globally at DB init, so no per-call `always_xy`
40
- * argument is needed.
41
- */
42
- export declare function buildTransformExpr(innerExpr: string, sourceType: string, sourceCrs: string, targetCrs: string): string;
43
- /**
44
- * Wrap a bare WKB expression with `ST_SetCRS(ST_GeomFromWKB(...))` so that the
45
- * resulting GEOMETRY value carries a CRS through the rest of the pipeline.
46
- * Used in the legacy GeoParquet fallback where we read the geometry column as
47
- * BLOB but still know the source CRS from hyparquet metadata or the GeoParquet
48
- * footer.
49
- *
50
- * If `sourceCrs` is null/empty, returns a plain `ST_GeomFromWKB(...)`.
51
- */
52
- export declare function wrapWkbWithCrs(wkbExpr: string, sourceCrs: string | null | undefined): string;
@@ -1,76 +0,0 @@
1
- /**
2
- * Helpers for parsing DuckDB v1.5 parameterized GEOMETRY type strings.
3
- *
4
- * DuckDB v1.5 made GEOMETRY a core type with an optional CRS parameter:
5
- * GEOMETRY — no CRS attached
6
- * GEOMETRY('EPSG:4326') — EPSG form
7
- * GEOMETRY('OGC:CRS84') — OGC form (canonical for GeoParquet 1.1+)
8
- * GEOMETRY('EPSG:27700') — projected CRS
9
- *
10
- * Type strings may come from `DESCRIBE`, from the Arrow schema, or from a
11
- * legacy code path that still reports `BLOB`. Use these helpers everywhere
12
- * instead of ad-hoc regex so behaviour stays consistent.
13
- */
14
- import { WGS84_CODES } from '../constants.js';
15
- const GEOMETRY_PREFIX = /^GEOMETRY(\s*\(\s*'?([^')]+)'?\s*\))?/i;
16
- /**
17
- * Parse a DuckDB type string and report whether it is a GEOMETRY type, and
18
- * whether a CRS parameter is attached.
19
- */
20
- export function parseGeometryTypeCrs(typeStr) {
21
- if (!typeStr)
22
- return { isGeometry: false, hasCrs: false, rawCrs: null, nonWgs84Crs: null };
23
- const match = typeStr.match(GEOMETRY_PREFIX);
24
- if (!match)
25
- return { isGeometry: false, hasCrs: false, rawCrs: null, nonWgs84Crs: null };
26
- const rawCrs = match[2]?.trim() ?? null;
27
- if (!rawCrs)
28
- return { isGeometry: true, hasCrs: false, rawCrs: null, nonWgs84Crs: null };
29
- return {
30
- isGeometry: true,
31
- hasCrs: true,
32
- rawCrs,
33
- nonWgs84Crs: isWgs84Crs(rawCrs) ? null : rawCrs
34
- };
35
- }
36
- /** True for EPSG:4326, EPSG:4979, OGC:CRS84 and equivalent strings. */
37
- export function isWgs84Crs(crs) {
38
- if (!crs)
39
- return true;
40
- const trimmed = crs.trim();
41
- if (trimmed === 'OGC:CRS84' || trimmed === 'OGC:CRS83')
42
- return true;
43
- const epsgMatch = trimmed.match(/^EPSG:(\d+)$/i);
44
- if (epsgMatch && WGS84_CODES.has(Number(epsgMatch[1])))
45
- return true;
46
- return false;
47
- }
48
- /**
49
- * Build a `ST_Transform(...)` SQL expression choosing the 2-arg form when the
50
- * input already carries its CRS in the GEOMETRY type (DuckDB v1.5), and the
51
- * 3-arg form otherwise.
52
- *
53
- * `geometry_always_xy` is set globally at DB init, so no per-call `always_xy`
54
- * argument is needed.
55
- */
56
- export function buildTransformExpr(innerExpr, sourceType, sourceCrs, targetCrs) {
57
- const info = parseGeometryTypeCrs(sourceType);
58
- if (info.hasCrs) {
59
- return `ST_Transform(${innerExpr}, '${targetCrs}')`;
60
- }
61
- return `ST_Transform(${innerExpr}, '${sourceCrs}', '${targetCrs}')`;
62
- }
63
- /**
64
- * Wrap a bare WKB expression with `ST_SetCRS(ST_GeomFromWKB(...))` so that the
65
- * resulting GEOMETRY value carries a CRS through the rest of the pipeline.
66
- * Used in the legacy GeoParquet fallback where we read the geometry column as
67
- * BLOB but still know the source CRS from hyparquet metadata or the GeoParquet
68
- * footer.
69
- *
70
- * If `sourceCrs` is null/empty, returns a plain `ST_GeomFromWKB(...)`.
71
- */
72
- export function wrapWkbWithCrs(wkbExpr, sourceCrs) {
73
- if (!sourceCrs)
74
- return `ST_GeomFromWKB(${wkbExpr})`;
75
- return `ST_SetCRS(ST_GeomFromWKB(${wkbExpr}), '${sourceCrs}')`;
76
- }
@@ -1,10 +0,0 @@
1
- export interface HexRow {
2
- offset: string;
3
- hex: string[];
4
- ascii: string;
5
- }
6
- /**
7
- * Generates a hex dump from binary data.
8
- * Returns rows of offset | hex bytes | ASCII representation.
9
- */
10
- export declare function generateHexDump(data: Uint8Array, bytesPerRow?: number): HexRow[];
package/dist/utils/hex.js DELETED
@@ -1,27 +0,0 @@
1
- /**
2
- * Generates a hex dump from binary data.
3
- * Returns rows of offset | hex bytes | ASCII representation.
4
- */
5
- export function generateHexDump(data, bytesPerRow = 16) {
6
- const rows = [];
7
- for (let i = 0; i < data.length; i += bytesPerRow) {
8
- const slice = data.slice(i, i + bytesPerRow);
9
- const offset = i.toString(16).padStart(8, '0');
10
- const hex = [];
11
- for (let j = 0; j < bytesPerRow; j++) {
12
- if (j < slice.length) {
13
- hex.push(slice[j].toString(16).padStart(2, '0'));
14
- }
15
- else {
16
- hex.push(' ');
17
- }
18
- }
19
- let ascii = '';
20
- for (let j = 0; j < slice.length; j++) {
21
- const byte = slice[j];
22
- ascii += byte >= 0x20 && byte <= 0x7e ? String.fromCharCode(byte) : '.';
23
- }
24
- rows.push({ offset, hex, ascii });
25
- }
26
- return rows;
27
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Auto-detect hosting bucket from URL search params and window.location.
3
- *
4
- * Detection priority:
5
- * 1. `?url=<storage-url>` query parameter (highest priority)
6
- * 2. `window.location.hostname` pattern matching (fallback)
7
- *
8
- * Also extracts `rootPrefix` when the app is hosted inside a subfolder.
9
- */
10
- import type { StorageProvider } from './storage-url.js';
11
- export interface DetectedHost {
12
- provider: StorageProvider;
13
- bucket: string;
14
- region: string;
15
- endpoint: string;
16
- rootPrefix: string;
17
- bucketUrl: string;
18
- }
19
- /**
20
- * Detect hosting bucket from current URL.
21
- * Returns null when no hosting bucket can be determined.
22
- */
23
- export declare function detectHostBucket(): DetectedHost | null;
@@ -1,95 +0,0 @@
1
- /**
2
- * Auto-detect hosting bucket from URL search params and window.location.
3
- *
4
- * Detection priority:
5
- * 1. `?url=<storage-url>` query parameter (highest priority)
6
- * 2. `window.location.hostname` pattern matching (fallback)
7
- *
8
- * Also extracts `rootPrefix` when the app is hosted inside a subfolder.
9
- */
10
- import { buildProviderBaseUrl } from '../storage/providers.js';
11
- import { isKnownBucketHost, parseStorageUrl } from './storage-url.js';
12
- /**
13
- * Extract root prefix from pathname.
14
- * When hosted at `/subfolder/index.html` or `/subfolder/`, returns `subfolder/`.
15
- */
16
- function extractRootPrefix(pathname) {
17
- // Strip trailing filename (index.html, etc.)
18
- let clean = pathname.replace(/\/[^/]*\.[^/]*$/, '/');
19
- // Remove leading slash
20
- clean = clean.replace(/^\//, '');
21
- // Empty or just '/' means no prefix
22
- if (!clean || clean === '/')
23
- return '';
24
- // Ensure trailing slash
25
- if (!clean.endsWith('/'))
26
- clean += '/';
27
- return clean;
28
- }
29
- /**
30
- * Build a normalized API endpoint URL for a detected provider.
31
- */
32
- function buildBucketUrl(provider, endpoint, bucket, region) {
33
- return buildProviderBaseUrl((provider === 'unknown' ? 's3' : provider), endpoint, bucket, region || '');
34
- }
35
- /**
36
- * Translate a `ParsedStorageUrl` into a `DetectedHost`. Returns null when the
37
- * parser did not recognize a bucket or when the host is not a known provider
38
- * pattern (prevents arbitrary custom endpoints from being auto-connected).
39
- */
40
- function parsedToHost(parsed, host, rootPrefix) {
41
- if (!parsed.bucket || !isKnownBucketHost(host))
42
- return null;
43
- const provider = parsed.provider === 'unknown' ? 's3' : parsed.provider;
44
- return {
45
- provider,
46
- bucket: parsed.bucket,
47
- region: parsed.region,
48
- endpoint: parsed.endpoint,
49
- rootPrefix,
50
- bucketUrl: buildBucketUrl(parsed.provider, parsed.endpoint, parsed.bucket, parsed.region)
51
- };
52
- }
53
- /**
54
- * Detect hosting bucket from current URL.
55
- * Returns null when no hosting bucket can be determined.
56
- */
57
- export function detectHostBucket() {
58
- if (typeof window === 'undefined')
59
- return null;
60
- const url = new URL(window.location.href);
61
- // Priority 1: ?url= query parameter
62
- const urlParam = url.searchParams.get('url');
63
- if (urlParam) {
64
- try {
65
- const paramUrl = new URL(urlParam);
66
- const parsed = parseStorageUrl(urlParam);
67
- const host = parsedToHost(parsed, paramUrl.hostname, '');
68
- if (host)
69
- return host;
70
- }
71
- catch {
72
- // Not a parseable URL, fall through to location-based detection.
73
- }
74
- }
75
- // Priority 2: window.location pattern matching via the unified parser.
76
- // `parseStorageUrl` extracts bucket + any remaining prefix from the
77
- // current URL. The prefix is used as the in-bucket sub-folder the app
78
- // should root into when auto-connecting.
79
- const parsed = parseStorageUrl(window.location.href);
80
- if (!parsed.bucket || !isKnownBucketHost(url.hostname))
81
- return null;
82
- // `rootPrefix` is the in-bucket sub-folder, possibly trailing with an
83
- // `index.html` style filename, which `extractRootPrefix` strips.
84
- const prefixPath = parsed.prefix ? `/${parsed.prefix}` : '';
85
- const rootPrefix = extractRootPrefix(prefixPath || '/');
86
- const provider = parsed.provider === 'unknown' ? 's3' : parsed.provider;
87
- return {
88
- provider,
89
- bucket: parsed.bucket,
90
- region: parsed.region,
91
- endpoint: parsed.endpoint,
92
- rootPrefix,
93
- bucketUrl: buildBucketUrl(parsed.provider, parsed.endpoint, parsed.bucket, parsed.region)
94
- };
95
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Generic localStorage helpers with SSR safety.
3
- *
4
- * Used by connection, settings, and query-history stores to avoid
5
- * repeating the same load/persist/try-catch/SSR-guard pattern.
6
- */
7
- /**
8
- * Load a JSON value from localStorage.
9
- * Returns `defaultValue` on SSR, missing key, or parse error.
10
- */
11
- export declare function loadFromStorage<T>(key: string, defaultValue: T): T;
12
- /**
13
- * Persist a JSON-serializable value to localStorage.
14
- * Silently no-ops on SSR or storage errors (quota, private browsing).
15
- */
16
- export declare function persistToStorage(key: string, value: unknown): void;
@@ -1,37 +0,0 @@
1
- /**
2
- * Generic localStorage helpers with SSR safety.
3
- *
4
- * Used by connection, settings, and query-history stores to avoid
5
- * repeating the same load/persist/try-catch/SSR-guard pattern.
6
- */
7
- /**
8
- * Load a JSON value from localStorage.
9
- * Returns `defaultValue` on SSR, missing key, or parse error.
10
- */
11
- export function loadFromStorage(key, defaultValue) {
12
- if (typeof window === 'undefined')
13
- return defaultValue;
14
- try {
15
- const raw = localStorage.getItem(key);
16
- if (raw)
17
- return JSON.parse(raw);
18
- }
19
- catch {
20
- // ignore parse errors
21
- }
22
- return defaultValue;
23
- }
24
- /**
25
- * Persist a JSON-serializable value to localStorage.
26
- * Silently no-ops on SSR or storage errors (quota, private browsing).
27
- */
28
- export function persistToStorage(key, value) {
29
- if (typeof window === 'undefined')
30
- return;
31
- try {
32
- localStorage.setItem(key, JSON.stringify(value));
33
- }
34
- catch {
35
- // ignore storage errors
36
- }
37
- }
@@ -1,30 +0,0 @@
1
- export interface SqlBlock {
2
- name: string;
3
- sql: string;
4
- startLine: number;
5
- endLine: number;
6
- }
7
- export interface ParsedMarkdownDocument {
8
- frontmatter: Record<string, any>;
9
- content: string;
10
- sqlBlocks: SqlBlock[];
11
- }
12
- /**
13
- * Parse a markdown document with YAML frontmatter and SQL code blocks.
14
- *
15
- * Evidence-compatible syntax:
16
- * ```sql query_name
17
- * SELECT * FROM table
18
- * ```
19
- */
20
- export declare function parseMarkdownDocument(markdown: string): Promise<ParsedMarkdownDocument>;
21
- /**
22
- * Interpolate template variables in markdown text.
23
- * Supports {queryName.rows[0].columnName} syntax.
24
- */
25
- export declare function interpolateTemplates(text: string, queryResults: Map<string, Record<string, any>[]>): string;
26
- /**
27
- * Replace SQL blocks in markdown content with placeholder markers
28
- * that can be replaced with rendered components.
29
- */
30
- export declare function markSqlBlocks(content: string): string;
@@ -1,72 +0,0 @@
1
- /**
2
- * Parse a markdown document with YAML frontmatter and SQL code blocks.
3
- *
4
- * Evidence-compatible syntax:
5
- * ```sql query_name
6
- * SELECT * FROM table
7
- * ```
8
- */
9
- export async function parseMarkdownDocument(markdown) {
10
- let frontmatter = {};
11
- let content = markdown;
12
- const fmMatch = markdown.match(/^---\n([\s\S]*?)\n---\n/);
13
- if (fmMatch) {
14
- try {
15
- const { default: YAML } = await import('yaml');
16
- frontmatter = YAML.parse(fmMatch[1]) || {};
17
- }
18
- catch {
19
- // Invalid YAML or yaml peer dep not installed, ignore frontmatter
20
- }
21
- content = markdown.slice(fmMatch[0].length);
22
- }
23
- // Extract SQL blocks
24
- const sqlBlocks = [];
25
- const lines = content.split('\n');
26
- let i = 0;
27
- while (i < lines.length) {
28
- const line = lines[i];
29
- const match = line.match(/^```sql\s+(\w[\w-]*)\s*$/);
30
- if (match) {
31
- const name = match[1];
32
- const startLine = i;
33
- const sqlLines = [];
34
- i++;
35
- while (i < lines.length && lines[i] !== '```') {
36
- sqlLines.push(lines[i]);
37
- i++;
38
- }
39
- sqlBlocks.push({
40
- name,
41
- sql: sqlLines.join('\n'),
42
- startLine,
43
- endLine: i
44
- });
45
- }
46
- i++;
47
- }
48
- return { frontmatter, content, sqlBlocks };
49
- }
50
- /**
51
- * Interpolate template variables in markdown text.
52
- * Supports {queryName.rows[0].columnName} syntax.
53
- */
54
- export function interpolateTemplates(text, queryResults) {
55
- return text.replace(/\{(\w+)\.rows\[(\d+)\]\.(\w+)\}/g, (match, queryName, rowIdx, colName) => {
56
- const rows = queryResults.get(queryName);
57
- if (!rows)
58
- return match;
59
- const row = rows[parseInt(rowIdx, 10)];
60
- if (!row)
61
- return match;
62
- const value = row[colName];
63
- return value !== undefined ? String(value) : match;
64
- });
65
- }
66
- /**
67
- * Replace SQL blocks in markdown content with placeholder markers
68
- * that can be replaced with rendered components.
69
- */
70
- export function markSqlBlocks(content) {
71
- return content.replace(/```sql\s+(\w[\w-]*)\s*\n([\s\S]*?)```/g, (_, name) => `<div data-sql-block="${name}"></div>`);
72
- }
@@ -1,59 +0,0 @@
1
- /**
2
- * Lightweight browser-native Jupyter notebook renderer.
3
- * Replaces `notebookjs` which depends on jsdom/Buffer (Node.js only).
4
- * Handles nbformat 2, 3, 4, and 5.
5
- */
6
- export interface NotebookConfig {
7
- markdown: (md: string) => string;
8
- ansi: (text: string) => string;
9
- highlighter: (code: string, lang: string) => string;
10
- }
11
- interface RawNotebook {
12
- nbformat: number;
13
- nbformat_minor?: number;
14
- metadata?: Record<string, any>;
15
- cells?: RawCell[];
16
- worksheets?: {
17
- cells: RawCell[];
18
- }[];
19
- }
20
- interface RawCell {
21
- cell_type: string;
22
- source?: string | string[];
23
- input?: string | string[];
24
- outputs?: RawOutput[];
25
- prompt_number?: number;
26
- execution_count?: number | null;
27
- level?: number;
28
- language?: string;
29
- }
30
- interface RawOutput {
31
- output_type: string;
32
- data?: Record<string, string | string[]>;
33
- text?: string | string[];
34
- stream?: string;
35
- name?: string;
36
- png?: string;
37
- jpeg?: string;
38
- svg?: string;
39
- html?: string;
40
- latex?: string;
41
- traceback?: string[];
42
- ename?: string;
43
- evalue?: string;
44
- [key: string]: any;
45
- }
46
- export interface NotebookMeta {
47
- kernelName: string;
48
- language: string;
49
- cellCount: number;
50
- }
51
- /**
52
- * Parse and render a Jupyter notebook JSON to a DOM element.
53
- * Returns the rendered element and metadata.
54
- */
55
- export declare function renderNotebook(raw: RawNotebook, config: NotebookConfig): {
56
- element: HTMLElement;
57
- meta: NotebookMeta;
58
- };
59
- export {};