@walkthru-earth/objex 1.1.0 → 1.2.1

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 (89) hide show
  1. package/README.md +3 -1
  2. package/dist/components/browser/FileBrowser.svelte +25 -14
  3. package/dist/components/browser/FileTreeSidebar.svelte +43 -7
  4. package/dist/components/layout/ConnectionDialog.svelte +100 -1
  5. package/dist/components/layout/Sidebar.svelte +70 -25
  6. package/dist/components/viewers/ArchiveViewer.svelte +4 -4
  7. package/dist/components/viewers/CodeViewer.svelte +44 -5
  8. package/dist/components/viewers/CogControls.svelte +208 -0
  9. package/dist/components/viewers/CogControls.svelte.d.ts +12 -0
  10. package/dist/components/viewers/CogViewer.svelte +373 -1162
  11. package/dist/components/viewers/CogViewer.svelte.d.ts +1 -1
  12. package/dist/components/viewers/CopcViewer.svelte +20 -2
  13. package/dist/components/viewers/DatabaseViewer.svelte +345 -37
  14. package/dist/components/viewers/FlatGeobufViewer.svelte +15 -9
  15. package/dist/components/viewers/MarkdownViewer.svelte +1 -1
  16. package/dist/components/viewers/PmtilesViewer.svelte +2 -2
  17. package/dist/components/viewers/StacMapViewer.svelte +25 -9
  18. package/dist/components/viewers/TableViewer.svelte +162 -51
  19. package/dist/components/viewers/ZarrMapViewer.svelte +33 -4
  20. package/dist/components/viewers/ZarrViewer.svelte +3 -6
  21. package/dist/components/viewers/pmtiles/PmtilesMapView.svelte +0 -1
  22. package/dist/constants.d.ts +6 -2
  23. package/dist/constants.js +6 -2
  24. package/dist/file-icons/index.d.ts +1 -1
  25. package/dist/file-icons/index.js +12 -2
  26. package/dist/i18n/ar.js +25 -0
  27. package/dist/i18n/en.js +25 -0
  28. package/dist/i18n/index.svelte.d.ts +0 -1
  29. package/dist/i18n/index.svelte.js +0 -3
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.js +1 -0
  32. package/dist/query/engine.d.ts +20 -4
  33. package/dist/query/index.d.ts +2 -1
  34. package/dist/query/index.js +1 -0
  35. package/dist/query/source.d.ts +42 -0
  36. package/dist/query/source.js +54 -0
  37. package/dist/query/wasm.d.ts +7 -5
  38. package/dist/query/wasm.js +267 -107
  39. package/dist/storage/adapter.d.ts +9 -0
  40. package/dist/storage/adapter.js +13 -1
  41. package/dist/storage/browser-azure.d.ts +1 -1
  42. package/dist/storage/browser-azure.js +4 -0
  43. package/dist/storage/browser-cloud.d.ts +1 -1
  44. package/dist/storage/browser-cloud.js +7 -0
  45. package/dist/storage/presign.d.ts +13 -0
  46. package/dist/storage/presign.js +55 -0
  47. package/dist/storage/providers.d.ts +53 -0
  48. package/dist/storage/providers.js +171 -0
  49. package/dist/stores/browser.svelte.d.ts +2 -0
  50. package/dist/stores/browser.svelte.js +17 -1
  51. package/dist/stores/files.svelte.d.ts +1 -2
  52. package/dist/stores/files.svelte.js +1 -2
  53. package/dist/stores/tabs.svelte.d.ts +9 -2
  54. package/dist/stores/tabs.svelte.js +11 -2
  55. package/dist/types.d.ts +11 -0
  56. package/dist/utils/cog.d.ts +244 -0
  57. package/dist/utils/cog.js +1039 -0
  58. package/dist/utils/deck.d.ts +0 -18
  59. package/dist/utils/deck.js +0 -36
  60. package/dist/utils/geometry-type.d.ts +52 -0
  61. package/dist/utils/geometry-type.js +76 -0
  62. package/dist/utils/markdown-sql.d.ts +1 -1
  63. package/dist/utils/markdown-sql.js +3 -4
  64. package/dist/utils/pmtiles-tile.d.ts +0 -2
  65. package/dist/utils/pmtiles-tile.js +0 -8
  66. package/dist/utils/url-state.d.ts +6 -0
  67. package/dist/utils/url-state.js +34 -26
  68. package/dist/utils/url.d.ts +26 -9
  69. package/dist/utils/url.js +52 -25
  70. package/dist/utils/wkb.js +22 -8
  71. package/dist/utils/zarr-tab.d.ts +22 -0
  72. package/dist/utils/zarr-tab.js +30 -0
  73. package/dist/utils/zarr.d.ts +0 -2
  74. package/dist/utils/zarr.js +73 -44
  75. package/package.json +47 -43
  76. package/dist/components/ui/tabs/index.d.ts +0 -5
  77. package/dist/components/ui/tabs/index.js +0 -7
  78. package/dist/components/ui/tabs/tabs-content.svelte +0 -17
  79. package/dist/components/ui/tabs/tabs-content.svelte.d.ts +0 -4
  80. package/dist/components/ui/tabs/tabs-list.svelte +0 -16
  81. package/dist/components/ui/tabs/tabs-list.svelte.d.ts +0 -4
  82. package/dist/components/ui/tabs/tabs-trigger.svelte +0 -20
  83. package/dist/components/ui/tabs/tabs-trigger.svelte.d.ts +0 -4
  84. package/dist/components/ui/tabs/tabs.svelte +0 -19
  85. package/dist/components/ui/tabs/tabs.svelte.d.ts +0 -4
  86. package/dist/components/viewers/MapViewer.svelte +0 -234
  87. package/dist/components/viewers/MapViewer.svelte.d.ts +0 -7
  88. package/dist/components/viewers/StyleEditorOverlay.svelte +0 -27
  89. package/dist/components/viewers/StyleEditorOverlay.svelte.d.ts +0 -7
package/README.md CHANGED
@@ -63,7 +63,7 @@ import { readParquetMetadata } from '@walkthru-earth/objex/utils/parquet-metadat
63
63
  import { getFileTypeInfo } from '@walkthru-earth/objex/file-icons';
64
64
  ```
65
65
 
66
- Requires `svelte ^5` and `@sveltejs/kit ^2` as peer dependencies. Heavy deps (DuckDB, deck.gl, MapLibre, Arrow, hyparquet) are optional peers -- only install what you need.
66
+ Requires `svelte ^5` and `@sveltejs/kit ^2` as peer dependencies. Heavy deps (DuckDB, deck.gl, MapLibre, Arrow, hyparquet, hyparquet-compressors, yaml) are optional peers -- only install what you need.
67
67
 
68
68
  ### `@walkthru-earth/objex-utils` -- Pure TypeScript Utilities
69
69
 
@@ -86,6 +86,8 @@ import {
86
86
  } from '@walkthru-earth/objex-utils';
87
87
  ```
88
88
 
89
+ Full per-module reference docs: [`packages/objex-utils/docs/`](packages/objex-utils/docs/README.md).
90
+
89
91
  ### Exports
90
92
 
91
93
  | Export path | What |
@@ -15,6 +15,7 @@ import {
15
15
  toggleSortField
16
16
  } from '../../utils/file-sort.js';
17
17
  import { detectZarrMarkers } from '../../utils/zarr.js';
18
+ import { openZarrTab } from '../../utils/zarr-tab.js';
18
19
  import Breadcrumb from './Breadcrumb.svelte';
19
20
  import CreateFolderDialog from './CreateFolderDialog.svelte';
20
21
  import DeleteConfirmDialog from './DeleteConfirmDialog.svelte';
@@ -37,19 +38,22 @@ let showWriteActions = $derived(browser.canWrite && !safeLock.locked);
37
38
 
38
39
  const zarrDetection = $derived(detectZarrMarkers(browser.entries.map((e: FileEntry) => e.name)));
39
40
 
40
- function openAsZarr() {
41
- if (!browser.activeConnection) return;
42
- const prefix = browser.currentPrefix.replace(/\/+$/, '');
43
- const name = prefix.split('/').pop() || browser.activeConnection.bucket;
44
- tabs.open({
45
- id: `${browser.activeConnection.id}:${prefix}/`,
46
- name,
47
- path: `${prefix}/`,
48
- source: 'remote',
49
- connectionId: browser.activeConnection.id,
50
- extension: 'zarr'
51
- });
52
- }
41
+ // Auto-open Zarr viewer when markers are detected in the current directory.
42
+ // Uses a Set to prevent re-triggering when navigating back to a previously opened store.
43
+ const autoOpenedPrefixes = new Set<string>();
44
+ $effect(() => {
45
+ if (zarrDetection.detected && browser.activeConnection) {
46
+ const prefix = browser.currentPrefix;
47
+ if (!autoOpenedPrefixes.has(prefix)) {
48
+ autoOpenedPrefixes.add(prefix);
49
+ openZarrTab(prefix, {
50
+ source: 'remote',
51
+ connectionId: browser.activeConnection.id,
52
+ bucketFallback: browser.activeConnection.bucket
53
+ });
54
+ }
55
+ }
56
+ });
53
57
 
54
58
  const sortedAndFilteredEntries = $derived.by(() => {
55
59
  let result = browser.entries;
@@ -177,7 +181,14 @@ function handleRename(entry: FileEntry) {
177
181
  variant="outline"
178
182
  size="sm"
179
183
  class="h-6 gap-1 px-2 text-[11px]"
180
- onclick={openAsZarr}
184
+ onclick={() => {
185
+ if (!browser.activeConnection) return;
186
+ openZarrTab(browser.currentPrefix, {
187
+ source: 'remote',
188
+ connectionId: browser.activeConnection.id,
189
+ bucketFallback: browser.activeConnection.bucket
190
+ });
191
+ }}
181
192
  >
182
193
  {t('fileBrowser.openAsZarr')}
183
194
  </Button>
@@ -19,6 +19,8 @@ import { tabs } from '../../stores/tabs.svelte.js';
19
19
  import type { Connection, FileEntry } from '../../types.js';
20
20
  import { getNativeScheme } from '../../utils/cloud-url.js';
21
21
  import { syncUrlParam } from '../../utils/url-state.js';
22
+ import { detectZarrMarkers } from '../../utils/zarr.js';
23
+ import { openZarrTab } from '../../utils/zarr-tab.js';
22
24
 
23
25
  let {
24
26
  connection,
@@ -48,6 +50,8 @@ let rootContinuationToken = $state<string | undefined>();
48
50
  let rootHasMore = $state(false);
49
51
  let filterQuery = $state('');
50
52
  let scrollEl = $state<HTMLElement>();
53
+ /** Paths of directories detected as Zarr stores (by marker files in children). */
54
+ let detectedZarrPaths = $state(new Set<string>());
51
55
 
52
56
  const filteredNodes = $derived(
53
57
  filterQuery ? filterTree(rootNodes, filterQuery.toLowerCase()) : rootNodes
@@ -156,6 +160,16 @@ async function toggleFolder(node: TreeNode) {
156
160
  node.expanded = !node.expanded;
157
161
  }
158
162
 
163
+ function openAsZarr(dirPath: string) {
164
+ const path = dirPath.endsWith('/') ? dirPath : `${dirPath}/`;
165
+ openZarrTab(path, {
166
+ source: 'remote',
167
+ connectionId: connection.id,
168
+ bucketFallback: connection.bucket
169
+ });
170
+ syncUrlParam(connection, path);
171
+ }
172
+
159
173
  function openFile(entry: FileEntry) {
160
174
  tabs.open({
161
175
  id: `${connection.id}:${entry.path}`,
@@ -175,12 +189,27 @@ function isViewerDir(entry: FileEntry): boolean {
175
189
  return entry.is_dir && VIEWER_DIR_EXTENSIONS.has(entry.extension);
176
190
  }
177
191
 
178
- function handleNodeClick(node: TreeNode) {
192
+ /** Whether a directory should render with the Zarr icon (either by extension or marker detection). */
193
+ function isZarrDir(entry: FileEntry): boolean {
194
+ return isViewerDir(entry) || detectedZarrPaths.has(entry.path);
195
+ }
196
+
197
+ async function handleNodeClick(node: TreeNode) {
179
198
  if (isViewerDir(node.entry)) {
180
- // .zarr directories open in the viewer (clicking chevron expands)
181
- openFile(node.entry);
199
+ // .zarr / .zr3 directories open in the viewer (clicking chevron expands)
200
+ openAsZarr(node.entry.path);
182
201
  } else if (node.entry.is_dir) {
183
- toggleFolder(node);
202
+ // Load children if needed, then check for zarr markers
203
+ if (node.children.length === 0) {
204
+ await loadChildren(node);
205
+ }
206
+ const zarrCheck = detectZarrMarkers(node.children.map((c) => c.entry.name));
207
+ if (zarrCheck.detected) {
208
+ detectedZarrPaths.add(node.entry.path);
209
+ openAsZarr(node.entry.path);
210
+ }
211
+ // Always expand so user can also browse contents
212
+ node.expanded = !node.expanded;
184
213
  } else {
185
214
  openFile(node.entry);
186
215
  }
@@ -327,7 +356,7 @@ async function expandToPath(path: string) {
327
356
  ? await findNodeAtRoot(accumulatedPath)
328
357
  : await findNodeInParent(parentNode, accumulatedPath);
329
358
 
330
- if (!node || !node.entry.is_dir) break;
359
+ if (!node?.entry.is_dir) break;
331
360
 
332
361
  if (node.children.length === 0) {
333
362
  await loadChildren(node);
@@ -349,6 +378,7 @@ async function loadRoot() {
349
378
  rootLoading = true;
350
379
  rootContinuationToken = undefined;
351
380
  rootHasMore = false;
381
+ detectedZarrPaths = new Set();
352
382
  try {
353
383
  const adapter = getAdapter('remote', connection.id);
354
384
  const prefix = connection.rootPrefix ?? '';
@@ -488,8 +518,8 @@ async function loadMoreRoot() {
488
518
  onclick={() => handleNodeClick(node)}
489
519
  >
490
520
  <FileTypeIcon
491
- extension={entry.extension}
492
- isDir={entry.is_dir && !isViewerDir(entry)}
521
+ extension={isZarrDir(entry) ? 'zarr' : entry.extension}
522
+ isDir={entry.is_dir && !isZarrDir(entry)}
493
523
  isOpen={node.expanded}
494
524
  class="size-3.5 shrink-0"
495
525
  />
@@ -510,6 +540,12 @@ async function loadMoreRoot() {
510
540
  {t('fileTree.open')}
511
541
  </ContextMenu.Item>
512
542
  <ContextMenu.Separator />
543
+ {:else if detectedZarrPaths.has(entry.path)}
544
+ <ContextMenu.Item onclick={() => openAsZarr(entry.path)}>
545
+ <ExternalLinkIcon class="me-2 size-3.5" />
546
+ {t('fileBrowser.openAsZarr')}
547
+ </ContextMenu.Item>
548
+ <ContextMenu.Separator />
513
549
  {/if}
514
550
 
515
551
  <ContextMenu.Item onclick={() => copyToClipboard(buildHttpUrl(entry.path))}>
@@ -1,10 +1,14 @@
1
1
  <script lang="ts">
2
2
  import CheckIcon from '@lucide/svelte/icons/check';
3
+ import ChevronRightIcon from '@lucide/svelte/icons/chevron-right';
3
4
  import CloudIcon from '@lucide/svelte/icons/cloud';
5
+ import ExternalLinkIcon from '@lucide/svelte/icons/external-link';
6
+ import GlobeIcon from '@lucide/svelte/icons/globe';
4
7
  import LinkIcon from '@lucide/svelte/icons/link';
5
8
  import Loader2Icon from '@lucide/svelte/icons/loader-2';
6
9
  import LockIcon from '@lucide/svelte/icons/lock';
7
10
  import PlugZapIcon from '@lucide/svelte/icons/plug-zap';
11
+ import ShieldIcon from '@lucide/svelte/icons/shield';
8
12
  import XIcon from '@lucide/svelte/icons/x';
9
13
  import { Button } from '../ui/button/index.js';
10
14
  import { Input } from '../ui/input/index.js';
@@ -20,10 +24,12 @@ import { Switch } from '../ui/switch/index.js';
20
24
  import { t } from '../../i18n/index.svelte.js';
21
25
  import {
22
26
  buildEndpointFromTemplate,
27
+ CORS_HELP,
23
28
  getProvider,
24
29
  PROVIDER_IDS,
25
30
  PROVIDERS,
26
- type ProviderId
31
+ type ProviderId,
32
+ READ_ONLY_HELP
27
33
  } from '../../storage/providers.js';
28
34
  import { connections } from '../../stores/connections.svelte.js';
29
35
  import type { Connection, ConnectionConfig } from '../../types.js';
@@ -71,6 +77,8 @@ let isAzure = $derived(provider === 'azure');
71
77
  let hasRegions = $derived(providerDef.regions.length > 0);
72
78
  let needsRegion = $derived(providerDef.needsRegion);
73
79
  let bucketLabel = $derived(providerDef.bucketLabel ?? t('connection.bucket'));
80
+ let corsHelp = $derived(CORS_HELP[provider]);
81
+ let readOnlyHelp = $derived(READ_ONLY_HELP[provider]);
74
82
 
75
83
  let isEditMode = $derived(editConnection !== null && editConnection !== undefined);
76
84
  let title = $derived(isEditMode ? t('connection.editTitle') : t('connection.newTitle'));
@@ -433,6 +441,97 @@ async function handleTestConnection() {
433
441
  </form>
434
442
  {/if}
435
443
 
444
+ <!-- CORS Help -->
445
+ {#if corsHelp}
446
+ <details class="group rounded-md border border-border">
447
+ <summary class="flex cursor-pointer list-none items-center gap-2 px-3 py-2 text-sm font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden">
448
+ <ChevronRightIcon class="size-3.5 shrink-0 transition-transform group-open:rotate-90" />
449
+ <GlobeIcon class="size-3.5 shrink-0" />
450
+ {t('connection.corsTitle')}
451
+ </summary>
452
+ <div class="flex flex-col gap-2.5 border-t border-border px-3 py-2.5">
453
+ {#if corsHelp.defaultEnabled}
454
+ <div class="flex items-center gap-1.5 text-xs text-green-700 dark:text-green-400">
455
+ <CheckIcon class="size-3 shrink-0" />
456
+ <span>{t('connection.corsDefault')}</span>
457
+ </div>
458
+ {:else}
459
+ <p class="text-xs text-muted-foreground">{t('connection.corsRequired')}</p>
460
+ {/if}
461
+
462
+ {#if corsHelp.note}
463
+ <p class="text-xs text-muted-foreground">{corsHelp.note}</p>
464
+ {/if}
465
+
466
+ {#if corsHelp.docsUrl}
467
+ <a
468
+ href={corsHelp.docsUrl}
469
+ target="_blank"
470
+ rel="noopener noreferrer"
471
+ class="inline-flex items-center gap-1 text-xs text-primary hover:underline"
472
+ >
473
+ <ExternalLinkIcon class="size-3 shrink-0" />
474
+ {t('connection.corsDocs')}
475
+ </a>
476
+ {/if}
477
+
478
+ {#if corsHelp.cliSteps && corsHelp.cliSteps.length > 0}
479
+ <details class="group/cli">
480
+ <summary class="flex cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden">
481
+ <ChevronRightIcon class="size-3 shrink-0 transition-transform group-open/cli:rotate-90" />
482
+ {t('connection.corsCliTitle')}
483
+ </summary>
484
+ <div class="mt-1.5 flex flex-col gap-1.5">
485
+ {#each corsHelp.cliSteps as step, i}
486
+ <pre class="overflow-x-auto rounded bg-muted px-2.5 py-2 text-[11px] leading-relaxed">{step}</pre>
487
+ {/each}
488
+ </div>
489
+ </details>
490
+ {/if}
491
+ </div>
492
+ </details>
493
+ {/if}
494
+
495
+ <!-- Read-Only Access Help -->
496
+ {#if readOnlyHelp}
497
+ <details class="group rounded-md border border-border">
498
+ <summary class="flex cursor-pointer list-none items-center gap-2 px-3 py-2 text-sm font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden">
499
+ <ChevronRightIcon class="size-3.5 shrink-0 transition-transform group-open:rotate-90" />
500
+ <ShieldIcon class="size-3.5 shrink-0" />
501
+ {t('connection.readOnlyTitle')}
502
+ </summary>
503
+ <div class="flex flex-col gap-2.5 border-t border-border px-3 py-2.5">
504
+ <p class="text-xs text-muted-foreground">{readOnlyHelp.note}</p>
505
+
506
+ {#if readOnlyHelp.docsUrl}
507
+ <a
508
+ href={readOnlyHelp.docsUrl}
509
+ target="_blank"
510
+ rel="noopener noreferrer"
511
+ class="inline-flex items-center gap-1 text-xs text-primary hover:underline"
512
+ >
513
+ <ExternalLinkIcon class="size-3 shrink-0" />
514
+ {t('connection.readOnlyDocs')}
515
+ </a>
516
+ {/if}
517
+
518
+ {#if readOnlyHelp.cliSteps && readOnlyHelp.cliSteps.length > 0}
519
+ <details class="group/ro">
520
+ <summary class="flex cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden">
521
+ <ChevronRightIcon class="size-3 shrink-0 transition-transform group-open/ro:rotate-90" />
522
+ {t('connection.readOnlyCliTitle')}
523
+ </summary>
524
+ <div class="mt-1.5 flex flex-col gap-1.5">
525
+ {#each readOnlyHelp.cliSteps as step, i}
526
+ <pre class="overflow-x-auto rounded bg-muted px-2.5 py-2 text-[11px] leading-relaxed">{step}</pre>
527
+ {/each}
528
+ </div>
529
+ </details>
530
+ {/if}
531
+ </div>
532
+ </details>
533
+ {/if}
534
+
436
535
  <!-- Test Connection Result -->
437
536
  {#if testResult === 'success'}
438
537
  <div class="flex items-center gap-2 rounded-md border border-green-500/30 bg-green-500/10 px-3 py-2 text-sm text-green-700 dark:text-green-400">
@@ -23,7 +23,7 @@ import { t } from '../../i18n/index.svelte.js';
23
23
  import { browser } from '../../stores/browser.svelte.js';
24
24
  import { connections } from '../../stores/connections.svelte.js';
25
25
  import { credentialStore, loadFromNative } from '../../stores/credentials.svelte.js';
26
- import { tabs } from '../../stores/tabs.svelte.js';
26
+ import { eagerUrlTabId, tabs } from '../../stores/tabs.svelte.js';
27
27
  import type { Connection } from '../../types.js';
28
28
  import { type DetectedHost, detectHostBucket } from '../../utils/host-detection.js';
29
29
  import { parseStorageUrl } from '../../utils/storage-url.js';
@@ -57,17 +57,53 @@ $effect(() => {
57
57
  }
58
58
  });
59
59
 
60
+ // Auto-detected ?url= buckets are saved anonymously (zero-click demo flow).
61
+ // If the first LIST returns 401/403, the bucket is actually private — flip
62
+ // the connection to non-anonymous and open the credential dialog so the
63
+ // user can paste keys instead of seeing a silent failure.
64
+ $effect(() => {
65
+ const conn = browser.authRequired;
66
+ if (!conn) return;
67
+ handleAuthRequired(conn);
68
+ });
69
+
70
+ async function handleAuthRequired(conn: Connection) {
71
+ browser.clearAuthRequired();
72
+ await connections.update(conn.id, {
73
+ name: conn.name,
74
+ provider: conn.provider,
75
+ endpoint: conn.endpoint,
76
+ bucket: conn.bucket,
77
+ region: conn.region,
78
+ anonymous: false,
79
+ authMethod: conn.authMethod,
80
+ rootPrefix: conn.rootPrefix
81
+ });
82
+ const updated = connections.getById(conn.id);
83
+ if (!updated) return;
84
+ await ensureCredentials(updated);
85
+ }
86
+
60
87
  async function handleAutoDetection() {
61
- // Direct file URLs (e.g. ?url=https://...file.parquet) are opened eagerly
62
- // in +page.svelte so they work on mobile. Skip if tab already exists.
63
88
  const url = new URL(window.location.href);
64
89
  const rawUrl = url.searchParams.get('url');
65
- if (rawUrl && tabs.items.some((t) => t.id === `url:${rawUrl}`)) {
90
+
91
+ const detected = detectHostBucket();
92
+ if (!detected) {
93
+ // No recognizable host — let the eager URL tab handle it
66
94
  return;
67
95
  }
68
96
 
69
- const detected = detectHostBucket();
70
- if (!detected) return;
97
+ // A recognizable storage provider was detected. Close the eagerly-opened
98
+ // URL tab (if any) so we can re-open it with a proper connectionId that
99
+ // provides S3 credentials and endpoint config for DuckDB httpfs.
100
+ if (rawUrl) {
101
+ const eagerTabId = eagerUrlTabId(rawUrl);
102
+ const eagerTab = tabs.items.find((t) => t.id === eagerTabId);
103
+ if (eagerTab) {
104
+ tabs.close(eagerTabId);
105
+ }
106
+ }
71
107
 
72
108
  const hasUrlParam = url.searchParams.has('url');
73
109
 
@@ -85,27 +121,36 @@ async function handleAutoDetection() {
85
121
  const prefixParam = parsed.prefix;
86
122
 
87
123
  if (prefixParam && !prefixParam.endsWith('/')) {
88
- // It's a file — browse to its parent folder and open it
89
- const parentPrefix = prefixParam.includes('/') ? prefixParam.replace(/\/[^/]*$/, '/') : '';
90
- browser.browse(conn, parentPrefix || undefined);
91
124
  const fileName = prefixParam.split('/').pop() || prefixParam;
92
125
  const ext = fileName.includes('.') ? fileName.split('.').pop()!.toLowerCase() : '';
93
- const tabId = `${conn.id}:${prefixParam}`;
94
- tabs.open({
95
- id: tabId,
96
- name: fileName,
97
- path: prefixParam,
98
- source: 'remote',
99
- connectionId: conn.id,
100
- extension: ext
101
- });
102
- // Fire-and-forget: fetch file size via HEAD request
103
- fetch(url.searchParams.get('url')!, { method: 'HEAD' })
104
- .then((res) => {
105
- const cl = res.headers.get('content-length');
106
- if (cl) tabs.update(tabId, { size: Number(cl) });
107
- })
108
- .catch(() => {});
126
+ if (ext) {
127
+ // It's a file — browse to its parent folder and open it
128
+ const parentPrefix = prefixParam.includes('/')
129
+ ? prefixParam.replace(/\/[^/]*$/, '/')
130
+ : '';
131
+ browser.browse(conn, parentPrefix || undefined);
132
+ const tabId = `${conn.id}:${prefixParam}`;
133
+ tabs.open({
134
+ id: tabId,
135
+ name: fileName,
136
+ path: prefixParam,
137
+ source: 'remote',
138
+ connectionId: conn.id,
139
+ extension: ext
140
+ });
141
+ // Fire-and-forget: fetch file size via HEAD request
142
+ fetch(url.searchParams.get('url')!, { method: 'HEAD' })
143
+ .then((res) => {
144
+ const cl = res.headers.get('content-length');
145
+ if (cl) tabs.update(tabId, { size: Number(cl) });
146
+ })
147
+ .catch(() => {});
148
+ } else {
149
+ // No extension — likely a directory (e.g. Zarr store without .zarr suffix).
150
+ // Browse into it and let FileBrowser's auto-detection handle Zarr/etc.
151
+ const dirPrefix = `${prefixParam}/`;
152
+ browser.browse(conn, dirPrefix);
153
+ }
109
154
  } else if (prefixParam) {
110
155
  // It's a directory prefix
111
156
  browser.browse(conn, prefixParam);
@@ -29,7 +29,7 @@ import {
29
29
  streamZipEntriesFromUrl
30
30
  } from '../../utils/archive';
31
31
  import { formatFileSize } from '../../utils/format';
32
- import { buildHttpsUrl } from '../../utils/url.js';
32
+ import { buildHttpsUrlAsync } from '../../utils/url.js';
33
33
 
34
34
  let { tab }: { tab: Tab } = $props();
35
35
 
@@ -177,7 +177,7 @@ async function loadZip() {
177
177
  const signal = abortController!.signal;
178
178
 
179
179
  if (tab.source === 'remote') {
180
- const url = buildHttpsUrl(tab);
180
+ const url = await buildHttpsUrlAsync(tab);
181
181
  try {
182
182
  scanning = true;
183
183
  for await (const batch of streamZipEntriesFromUrl(url, signal)) {
@@ -208,7 +208,7 @@ async function loadTar() {
208
208
  const signal = abortController!.signal;
209
209
 
210
210
  if (tab.source === 'remote') {
211
- const url = buildHttpsUrl(tab);
211
+ const url = await buildHttpsUrlAsync(tab);
212
212
  try {
213
213
  scanning = true;
214
214
  remoteUrl = url;
@@ -240,7 +240,7 @@ async function loadTarGz() {
240
240
 
241
241
  // For remote URLs: stream-fetch → decompress → parse progressively
242
242
  if (tab.source === 'remote' || tab.source === 'url') {
243
- const url = buildHttpsUrl(tab);
243
+ const url = await buildHttpsUrlAsync(tab);
244
244
  try {
245
245
  scanning = true;
246
246
  const decompressedChunks: Uint8Array[] = [];
@@ -11,8 +11,9 @@ import type { Tab } from '../../types';
11
11
  import { copyToClipboard } from '../../utils/clipboard.js';
12
12
  import { handleLoadError } from '../../utils/error.js';
13
13
  import { extensionToShikiLang, highlightCode } from '../../utils/shiki';
14
- import { buildHttpsUrl } from '../../utils/url.js';
14
+ import { buildHttpsUrl, buildHttpsUrlAsync, canStreamDirectly } from '../../utils/url.js';
15
15
  import { getUrlView, updateUrlView } from '../../utils/url-state.js';
16
+ import { openZarrTab } from '../../utils/zarr-tab.js';
16
17
 
17
18
  let { tab }: { tab: Tab } = $props();
18
19
 
@@ -49,6 +50,8 @@ type JsonKind =
49
50
  | 'stac-collection'
50
51
  | 'stac-item'
51
52
  | 'kepler'
53
+ | 'zarr-v2'
54
+ | 'zarr-v3'
52
55
  | null;
53
56
 
54
57
  /** Detect if a .py file is a marimo notebook (first 512 bytes contain both markers) */
@@ -74,6 +77,8 @@ function detectJsonKind(code: string): JsonKind {
74
77
  if (obj.type === 'Collection' && obj.stac_version) return 'stac-collection';
75
78
  if (obj.type === 'Feature' && obj.stac_version) return 'stac-item';
76
79
  if (obj.info?.app === 'kepler.gl' && obj.config) return 'kepler';
80
+ if (obj.zarr_format === 3) return 'zarr-v3';
81
+ if (obj.zarr_format === 2) return 'zarr-v2';
77
82
  }
78
83
  } catch {
79
84
  // not valid JSON
@@ -91,7 +96,23 @@ const stacBadgeKey = $derived<Record<string, string>>({
91
96
  'stac-collection': 'code.stacCollection',
92
97
  'stac-item': 'code.stacItem'
93
98
  });
94
- const styleUrl = $derived(buildHttpsUrl(tab));
99
+ // Third-party iframes can't route through the storage adapter, so the URL
100
+ // must carry auth. Public/SAS connections resolve synchronously; `signed-s3`
101
+ // must wait for the presign so the iframe never loads a bare `s3://` href.
102
+ let styleUrl = $state('');
103
+ $effect(() => {
104
+ const id = tab.id;
105
+ styleUrl = canStreamDirectly(tab) ? buildHttpsUrl(tab) : '';
106
+ let cancelled = false;
107
+ (async () => {
108
+ const url = await buildHttpsUrlAsync(tab);
109
+ if (cancelled || id !== tab.id) return;
110
+ styleUrl = url;
111
+ })();
112
+ return () => {
113
+ cancelled = true;
114
+ };
115
+ });
95
116
  const stacBrowserSrc = $derived(
96
117
  `https://radiantearth.github.io/stac-browser/#/external/${styleUrl}`
97
118
  );
@@ -353,6 +374,24 @@ async function copyCode() {
353
374
  >
354
375
  {viewMode === 'kepler' ? t('code.code') : t('code.openKepler')}
355
376
  </Button>
377
+ {:else if jsonKind === 'zarr-v3' || jsonKind === 'zarr-v2'}
378
+ <Badge variant="outline" class="hidden border-purple-200 text-purple-600 sm:inline-flex dark:border-purple-800 dark:text-purple-300">
379
+ {jsonKind === 'zarr-v3' ? 'Zarr v3' : 'Zarr v2'}
380
+ </Badge>
381
+ <Button
382
+ variant="outline"
383
+ size="sm"
384
+ class="h-7 gap-1 px-2 text-xs border-purple-300 text-purple-600 hover:bg-purple-50 hover:text-purple-700 dark:border-purple-700 dark:text-purple-400 dark:hover:bg-purple-950"
385
+ onclick={() => {
386
+ const parentPath = tab.path.replace(/[^/]+$/, '');
387
+ openZarrTab(parentPath, {
388
+ source: tab.source as 'remote' | 'url',
389
+ connectionId: tab.connectionId
390
+ });
391
+ }}
392
+ >
393
+ {t('fileBrowser.openAsZarr')}
394
+ </Button>
356
395
  {/if}
357
396
 
358
397
  {#if isMarimo}
@@ -458,7 +497,7 @@ async function copyCode() {
458
497
  </div>
459
498
  </div>
460
499
 
461
- {#if viewMode === 'stac-browser'}
500
+ {#if viewMode === 'stac-browser' && styleUrl}
462
501
  <div class="flex-1 overflow-hidden">
463
502
  <iframe
464
503
  src={stacBrowserSrc}
@@ -467,7 +506,7 @@ async function copyCode() {
467
506
  allow="fullscreen"
468
507
  ></iframe>
469
508
  </div>
470
- {:else if viewMode === 'kepler'}
509
+ {:else if viewMode === 'kepler' && styleUrl}
471
510
  <div class="flex-1 overflow-hidden">
472
511
  <iframe
473
512
  src={keplerSrc}
@@ -476,7 +515,7 @@ async function copyCode() {
476
515
  allow="fullscreen"
477
516
  ></iframe>
478
517
  </div>
479
- {:else if viewMode === 'maputnik'}
518
+ {:else if viewMode === 'maputnik' && styleUrl}
480
519
  <div class="flex-1 overflow-hidden">
481
520
  <iframe
482
521
  src={maputnikSrc}