@walkthru-earth/objex-utils 0.1.0 → 1.1.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.
package/dist/index.js CHANGED
@@ -1,4 +1,20 @@
1
1
  import { Field, Float64, FixedSizeList, Schema, Struct, makeData, RecordBatch, Table, List, Utf8 } from 'apache-arrow';
2
+ import YAML from 'yaml';
3
+
4
+ // ../../src/lib/constants.ts
5
+ var STORAGE_KEYS = {
6
+ SETTINGS: "obstore-explore-settings",
7
+ CONNECTIONS: "obstore-explore-connections",
8
+ QUERY_HISTORY: "obstore-explore-query-history"
9
+ };
10
+ var WGS84_CODES = /* @__PURE__ */ new Set([4326, 4979]);
11
+ var DEFAULT_TARGET_CRS = "EPSG:4326";
12
+ var DUCKDB_INIT_TIMEOUT_MS = 3e4;
13
+ var MAX_QUERY_HISTORY_ENTRIES = 200;
14
+ var SQL_PREVIEW_LENGTH = 120;
15
+ var VIEWER_DIR_EXTENSIONS = /* @__PURE__ */ new Set(["zarr", "zr3"]);
16
+ var LAYER_HUE_MULTIPLIER = 137;
17
+ var COPY_FEEDBACK_MS = 2e3;
2
18
 
3
19
  // ../../src/lib/file-icons/index.ts
4
20
  var DEFAULT_INFO = {
@@ -998,6 +1014,11 @@ var EXTENSIONS = {
998
1014
  }
999
1015
  };
1000
1016
  function getFileTypeInfo(extension, isDir = false) {
1017
+ if (isDir && extension) {
1018
+ const ext2 = extension.startsWith(".") ? extension.toLowerCase() : `.${extension.toLowerCase()}`;
1019
+ const found = EXTENSIONS[ext2];
1020
+ if (found) return found;
1021
+ }
1001
1022
  if (isDir) return FOLDER_INFO;
1002
1023
  const ext = extension.startsWith(".") ? extension.toLowerCase() : `.${extension.toLowerCase()}`;
1003
1024
  return EXTENSIONS[ext] ?? DEFAULT_INFO;
@@ -1037,6 +1058,304 @@ var QueryCancelledError = class extends Error {
1037
1058
  }
1038
1059
  };
1039
1060
 
1061
+ // ../../src/lib/storage/providers.ts
1062
+ var PROVIDERS = {
1063
+ s3: {
1064
+ label: "AWS S3",
1065
+ description: "Amazon S3 or any S3-compatible service",
1066
+ authMethod: "sigv4",
1067
+ needsRegion: true,
1068
+ needsEndpoint: false,
1069
+ defaultRegion: "us-east-1",
1070
+ endpointTemplate: null,
1071
+ regions: [
1072
+ { code: "us-east-1", label: "US East (N. Virginia)" },
1073
+ { code: "us-east-2", label: "US East (Ohio)" },
1074
+ { code: "us-west-1", label: "US West (N. California)" },
1075
+ { code: "us-west-2", label: "US West (Oregon)" },
1076
+ { code: "eu-west-1", label: "EU (Ireland)" },
1077
+ { code: "eu-west-2", label: "EU (London)" },
1078
+ { code: "eu-west-3", label: "EU (Paris)" },
1079
+ { code: "eu-central-1", label: "EU (Frankfurt)" },
1080
+ { code: "eu-central-2", label: "EU (Zurich)" },
1081
+ { code: "eu-north-1", label: "EU (Stockholm)" },
1082
+ { code: "eu-south-1", label: "EU (Milan)" },
1083
+ { code: "eu-south-2", label: "EU (Spain)" },
1084
+ { code: "ap-northeast-1", label: "Asia Pacific (Tokyo)" },
1085
+ { code: "ap-northeast-2", label: "Asia Pacific (Seoul)" },
1086
+ { code: "ap-northeast-3", label: "Asia Pacific (Osaka)" },
1087
+ { code: "ap-southeast-1", label: "Asia Pacific (Singapore)" },
1088
+ { code: "ap-southeast-2", label: "Asia Pacific (Sydney)" },
1089
+ { code: "ap-southeast-3", label: "Asia Pacific (Jakarta)" },
1090
+ { code: "ap-south-1", label: "Asia Pacific (Mumbai)" },
1091
+ { code: "ap-south-2", label: "Asia Pacific (Hyderabad)" },
1092
+ { code: "ap-east-1", label: "Asia Pacific (Hong Kong)" },
1093
+ { code: "sa-east-1", label: "South America (S\xE3o Paulo)" },
1094
+ { code: "ca-central-1", label: "Canada (Central)" },
1095
+ { code: "ca-west-1", label: "Canada (Calgary)" },
1096
+ { code: "me-south-1", label: "Middle East (Bahrain)" },
1097
+ { code: "me-central-1", label: "Middle East (UAE)" },
1098
+ { code: "af-south-1", label: "Africa (Cape Town)" },
1099
+ { code: "il-central-1", label: "Israel (Tel Aviv)" }
1100
+ ],
1101
+ endpointPlaceholder: "Leave empty for AWS, or enter custom S3 endpoint",
1102
+ schemes: ["s3", "s3a", "s3n", "aws"]
1103
+ },
1104
+ gcs: {
1105
+ label: "Google Cloud",
1106
+ description: "Google Cloud Storage",
1107
+ authMethod: "sigv4",
1108
+ needsRegion: false,
1109
+ needsEndpoint: false,
1110
+ defaultRegion: "auto",
1111
+ endpointTemplate: "https://storage.googleapis.com",
1112
+ regions: [],
1113
+ endpointPlaceholder: "https://storage.googleapis.com",
1114
+ schemes: ["gs", "gcs"]
1115
+ },
1116
+ r2: {
1117
+ label: "Cloudflare R2",
1118
+ description: "Cloudflare R2 Storage",
1119
+ authMethod: "sigv4",
1120
+ needsRegion: false,
1121
+ needsEndpoint: true,
1122
+ defaultRegion: "auto",
1123
+ endpointTemplate: null,
1124
+ regions: [],
1125
+ endpointPlaceholder: "https://<account-id>.r2.cloudflarestorage.com",
1126
+ schemes: ["r2"]
1127
+ },
1128
+ azure: {
1129
+ label: "Azure",
1130
+ description: "Azure Blob Storage",
1131
+ authMethod: "sas-token",
1132
+ needsRegion: false,
1133
+ needsEndpoint: true,
1134
+ defaultRegion: "",
1135
+ endpointTemplate: null,
1136
+ regions: [],
1137
+ bucketLabel: "Container",
1138
+ endpointPlaceholder: "https://<account>.blob.core.windows.net",
1139
+ schemes: ["azure", "az", "abfs", "abfss", "wasbs", "adl"]
1140
+ },
1141
+ minio: {
1142
+ label: "MinIO",
1143
+ description: "Self-hosted MinIO or S3-compatible",
1144
+ authMethod: "sigv4",
1145
+ needsRegion: false,
1146
+ needsEndpoint: true,
1147
+ defaultRegion: "us-east-1",
1148
+ endpointTemplate: null,
1149
+ regions: [],
1150
+ endpointPlaceholder: "https://minio.example.com or http://localhost:9000",
1151
+ schemes: []
1152
+ },
1153
+ storj: {
1154
+ label: "Storj",
1155
+ description: "Storj Decentralized Cloud",
1156
+ authMethod: "sigv4",
1157
+ needsRegion: false,
1158
+ needsEndpoint: false,
1159
+ defaultRegion: "us1",
1160
+ endpointTemplate: "https://gateway.storjshare.io",
1161
+ regions: [
1162
+ { code: "us1", label: "US1" },
1163
+ { code: "eu1", label: "EU1" },
1164
+ { code: "ap1", label: "AP1" }
1165
+ ],
1166
+ endpointPlaceholder: "https://gateway.storjshare.io",
1167
+ schemes: ["storj", "sj"]
1168
+ },
1169
+ b2: {
1170
+ label: "Backblaze B2",
1171
+ description: "Backblaze B2 Cloud Storage",
1172
+ authMethod: "sigv4",
1173
+ needsRegion: true,
1174
+ needsEndpoint: false,
1175
+ defaultRegion: "us-west-004",
1176
+ endpointTemplate: "https://s3.{region}.backblazeb2.com",
1177
+ regions: [
1178
+ { code: "us-west-000", label: "US West (Sacramento)" },
1179
+ { code: "us-west-001", label: "US West (Stockton)" },
1180
+ { code: "us-west-002", label: "US West (Phoenix)" },
1181
+ { code: "us-west-004", label: "US West" },
1182
+ { code: "us-east-005", label: "US East (Reston)" },
1183
+ { code: "eu-central-003", label: "EU Central (Amsterdam)" },
1184
+ { code: "ca-central-001", label: "Canada (Toronto)" }
1185
+ ],
1186
+ endpointPlaceholder: "https://s3.us-west-004.backblazeb2.com",
1187
+ schemes: []
1188
+ },
1189
+ digitalocean: {
1190
+ label: "DigitalOcean",
1191
+ description: "DigitalOcean Spaces",
1192
+ authMethod: "sigv4",
1193
+ needsRegion: true,
1194
+ needsEndpoint: false,
1195
+ defaultRegion: "nyc3",
1196
+ endpointTemplate: "https://{region}.digitaloceanspaces.com",
1197
+ regions: [
1198
+ { code: "nyc3", label: "New York 3" },
1199
+ { code: "sfo3", label: "San Francisco 3" },
1200
+ { code: "ams3", label: "Amsterdam 3" },
1201
+ { code: "sgp1", label: "Singapore 1" },
1202
+ { code: "lon1", label: "London 1" },
1203
+ { code: "fra1", label: "Frankfurt 1" },
1204
+ { code: "tor1", label: "Toronto 1" },
1205
+ { code: "blr1", label: "Bangalore 1" },
1206
+ { code: "syd1", label: "Sydney 1" }
1207
+ ],
1208
+ endpointPlaceholder: "https://nyc3.digitaloceanspaces.com",
1209
+ schemes: []
1210
+ },
1211
+ wasabi: {
1212
+ label: "Wasabi",
1213
+ description: "Wasabi Hot Cloud Storage",
1214
+ authMethod: "sigv4",
1215
+ needsRegion: true,
1216
+ needsEndpoint: false,
1217
+ defaultRegion: "us-east-1",
1218
+ endpointTemplate: "https://s3.{region}.wasabisys.com",
1219
+ regions: [
1220
+ { code: "us-east-1", label: "US East 1 (Virginia)" },
1221
+ { code: "us-east-2", label: "US East 2 (Virginia)" },
1222
+ { code: "us-central-1", label: "US Central 1 (Texas)" },
1223
+ { code: "us-west-1", label: "US West 1 (Oregon)" },
1224
+ { code: "eu-central-1", label: "EU Central 1 (Amsterdam)" },
1225
+ { code: "eu-central-2", label: "EU Central 2 (Frankfurt)" },
1226
+ { code: "eu-west-1", label: "EU West 1 (London)" },
1227
+ { code: "eu-west-2", label: "EU West 2 (Paris)" },
1228
+ { code: "ap-northeast-1", label: "AP Northeast 1 (Tokyo)" },
1229
+ { code: "ap-northeast-2", label: "AP Northeast 2 (Osaka)" },
1230
+ { code: "ap-southeast-1", label: "AP Southeast 1 (Singapore)" },
1231
+ { code: "ap-southeast-2", label: "AP Southeast 2 (Sydney)" },
1232
+ { code: "ca-central-1", label: "Canada (Toronto)" }
1233
+ ],
1234
+ endpointPlaceholder: "https://s3.us-east-1.wasabisys.com",
1235
+ schemes: []
1236
+ },
1237
+ contabo: {
1238
+ label: "Contabo",
1239
+ description: "Contabo Object Storage",
1240
+ authMethod: "sigv4",
1241
+ needsRegion: true,
1242
+ needsEndpoint: false,
1243
+ defaultRegion: "eu2",
1244
+ endpointTemplate: "https://{region}.contabostorage.com",
1245
+ regions: [
1246
+ { code: "eu2", label: "European Union" },
1247
+ { code: "usc1", label: "US Central" },
1248
+ { code: "sin1", label: "Singapore" }
1249
+ ],
1250
+ endpointPlaceholder: "https://eu2.contabostorage.com",
1251
+ schemes: []
1252
+ },
1253
+ hetzner: {
1254
+ label: "Hetzner",
1255
+ description: "Hetzner Object Storage",
1256
+ authMethod: "sigv4",
1257
+ needsRegion: true,
1258
+ needsEndpoint: false,
1259
+ defaultRegion: "fsn1",
1260
+ endpointTemplate: "https://{region}.your-objectstorage.com",
1261
+ regions: [
1262
+ { code: "fsn1", label: "Falkenstein, DE" },
1263
+ { code: "nbg1", label: "Nuremberg, DE" },
1264
+ { code: "hel1", label: "Helsinki, FI" }
1265
+ ],
1266
+ endpointPlaceholder: "https://fsn1.your-objectstorage.com",
1267
+ schemes: []
1268
+ },
1269
+ linode: {
1270
+ label: "Linode / Akamai",
1271
+ description: "Akamai / Linode Object Storage",
1272
+ authMethod: "sigv4",
1273
+ needsRegion: true,
1274
+ needsEndpoint: false,
1275
+ defaultRegion: "us-east-1",
1276
+ endpointTemplate: "https://{region}.linodeobjects.com",
1277
+ regions: [
1278
+ { code: "us-east-1", label: "Newark, NJ" },
1279
+ { code: "us-southeast-1", label: "Atlanta, GA" },
1280
+ { code: "us-ord-1", label: "Chicago, IL" },
1281
+ { code: "us-iad-1", label: "Washington, DC" },
1282
+ { code: "us-lax-1", label: "Los Angeles, CA" },
1283
+ { code: "us-sea-1", label: "Seattle, WA" },
1284
+ { code: "us-mia-1", label: "Miami, FL" },
1285
+ { code: "eu-central-1", label: "Frankfurt, DE" },
1286
+ { code: "nl-ams-1", label: "Amsterdam, NL" },
1287
+ { code: "gb-lon-1", label: "London, UK" },
1288
+ { code: "fr-par-1", label: "Paris, FR" },
1289
+ { code: "ap-south-1", label: "Singapore" },
1290
+ { code: "jp-osa-1", label: "Osaka, JP" },
1291
+ { code: "au-mel-1", label: "Melbourne, AU" },
1292
+ { code: "br-gru-1", label: "S\xE3o Paulo, BR" },
1293
+ { code: "in-maa-1", label: "Chennai, IN" },
1294
+ { code: "id-cgk-1", label: "Jakarta, ID" },
1295
+ { code: "it-mil-1", label: "Milan, IT" },
1296
+ { code: "se-sto-1", label: "Stockholm, SE" }
1297
+ ],
1298
+ endpointPlaceholder: "https://us-east-1.linodeobjects.com",
1299
+ schemes: []
1300
+ },
1301
+ ovhcloud: {
1302
+ label: "OVHcloud",
1303
+ description: "OVHcloud Object Storage",
1304
+ authMethod: "sigv4",
1305
+ needsRegion: true,
1306
+ needsEndpoint: false,
1307
+ defaultRegion: "gra",
1308
+ endpointTemplate: "https://s3.{region}.io.cloud.ovh.net",
1309
+ regions: [
1310
+ { code: "gra", label: "Gravelines, FR" },
1311
+ { code: "sbg", label: "Strasbourg, FR" },
1312
+ { code: "bhs", label: "Beauharnois, CA" },
1313
+ { code: "de", label: "Frankfurt, DE" },
1314
+ { code: "uk", label: "London, UK" },
1315
+ { code: "waw", label: "Warsaw, PL" }
1316
+ ],
1317
+ endpointPlaceholder: "https://s3.gra.io.cloud.ovh.net",
1318
+ schemes: []
1319
+ }
1320
+ };
1321
+ var PROVIDER_IDS = [
1322
+ "s3",
1323
+ "gcs",
1324
+ "r2",
1325
+ "azure",
1326
+ "b2",
1327
+ "digitalocean",
1328
+ "wasabi",
1329
+ "storj",
1330
+ "hetzner",
1331
+ "contabo",
1332
+ "linode",
1333
+ "ovhcloud",
1334
+ "minio"
1335
+ ];
1336
+ function getProvider(id) {
1337
+ return PROVIDERS[id] ?? PROVIDERS.s3;
1338
+ }
1339
+ function buildEndpointFromTemplate(id, region) {
1340
+ const def = PROVIDERS[id];
1341
+ if (!def?.endpointTemplate) return "";
1342
+ return def.endpointTemplate.replace("{region}", region);
1343
+ }
1344
+ function buildProviderBaseUrl(provider, endpoint, bucket, region) {
1345
+ if (endpoint) {
1346
+ return `${endpoint.replace(/\/$/, "")}/${bucket}`;
1347
+ }
1348
+ const def = PROVIDERS[provider];
1349
+ if (def?.endpointTemplate) {
1350
+ const resolved = def.endpointTemplate.replace("{region}", region || def.defaultRegion);
1351
+ return `${resolved}/${bucket}`;
1352
+ }
1353
+ return `https://s3.${region || "us-east-1"}.amazonaws.com/${bucket}`;
1354
+ }
1355
+ function isGcsProvider(provider, endpoint) {
1356
+ return provider === "gcs" || !!endpoint && /storage\.googleapis\.com/i.test(endpoint);
1357
+ }
1358
+
1040
1359
  // ../../src/lib/storage/url-adapter.ts
1041
1360
  var UrlAdapter = class {
1042
1361
  supportsWrite = false;
@@ -1082,6 +1401,38 @@ var UrlAdapter = class {
1082
1401
  }
1083
1402
  };
1084
1403
 
1404
+ // ../../src/lib/utils/cloud-url.ts
1405
+ var AWS_REGION_RE = /^(us|eu|ap|sa|ca|me|af|il)-(north|south|east|west|central|northeast|southeast|northwest|southwest)-\d+/;
1406
+ function getNativeScheme(provider) {
1407
+ const def = PROVIDERS[provider];
1408
+ if (def?.schemes.length) return def.schemes[0];
1409
+ return "s3";
1410
+ }
1411
+ function safeDecodeURIComponent(s) {
1412
+ try {
1413
+ return decodeURIComponent(s);
1414
+ } catch {
1415
+ return s;
1416
+ }
1417
+ }
1418
+ function resolveCloudUrl(url) {
1419
+ const s3Match = url.match(/^s3[an]?:\/\/([^/]+)\/?(.*)$/);
1420
+ if (s3Match) {
1421
+ const [, bucket, key] = s3Match;
1422
+ const regionMatch = bucket.match(AWS_REGION_RE);
1423
+ const region = regionMatch ? regionMatch[0] : "us-east-1";
1424
+ const base = buildProviderBaseUrl("s3", "", bucket, region);
1425
+ return key ? `${base}/${key}` : base;
1426
+ }
1427
+ const gcsMatch = url.match(/^gcs?:\/\/([^/]+)\/?(.*)$/);
1428
+ if (gcsMatch) {
1429
+ const [, bucket, key] = gcsMatch;
1430
+ const base = buildProviderBaseUrl("gcs", "", bucket, "");
1431
+ return key ? `${base}/${key}` : base;
1432
+ }
1433
+ return url;
1434
+ }
1435
+
1085
1436
  // ../../src/lib/utils/column-types.ts
1086
1437
  var NUMBER_TYPES = [
1087
1438
  "TINYINT",
@@ -1198,6 +1549,12 @@ function typeLabel(category) {
1198
1549
  return TYPE_LABELS[category];
1199
1550
  }
1200
1551
 
1552
+ // ../../src/lib/utils/error.ts
1553
+ function handleLoadError(err) {
1554
+ if (err instanceof DOMException && err.name === "AbortError") return null;
1555
+ return err instanceof Error ? err.message : String(err);
1556
+ }
1557
+
1201
1558
  // ../../src/lib/utils/format.ts
1202
1559
  function formatFileSize(bytes) {
1203
1560
  if (bytes < 0) return "0 B";
@@ -1233,6 +1590,81 @@ function getFileExtension(filename) {
1233
1590
  if (lastDot <= 0) return "";
1234
1591
  return filename.slice(lastDot).toLowerCase();
1235
1592
  }
1593
+ function jsonReplacerBigInt(_key, value) {
1594
+ return typeof value === "bigint" ? value.toString() : value;
1595
+ }
1596
+ function formatValue(value) {
1597
+ if (value === null || value === void 0) return "NULL";
1598
+ if (value instanceof Date) return value.toISOString();
1599
+ if (typeof value === "bigint") return value.toString();
1600
+ if (typeof value === "object") return JSON.stringify(value, jsonReplacerBigInt);
1601
+ return String(value);
1602
+ }
1603
+
1604
+ // ../../src/lib/utils/export.ts
1605
+ function formatCellValue(value) {
1606
+ if (value === null || value === void 0) return "";
1607
+ if (value instanceof Date) return value.toISOString();
1608
+ if (typeof value === "bigint") return value.toString();
1609
+ if (typeof value === "object") return JSON.stringify(value, jsonReplacerBigInt);
1610
+ return String(value);
1611
+ }
1612
+ function escapeCsvField(value) {
1613
+ if (value.includes(",") || value.includes('"') || value.includes("\n") || value.includes("\r")) {
1614
+ return `"${value.replace(/"/g, '""')}"`;
1615
+ }
1616
+ return value;
1617
+ }
1618
+ function serializeToCsv(columns, rows) {
1619
+ const header = columns.map(escapeCsvField).join(",");
1620
+ const body = rows.map((row) => columns.map((col) => escapeCsvField(formatCellValue(row[col]))).join(",")).join("\n");
1621
+ return `${header}
1622
+ ${body}`;
1623
+ }
1624
+ function serializeToJson(columns, rows) {
1625
+ const data = rows.map((row) => {
1626
+ const obj = {};
1627
+ for (const col of columns) {
1628
+ const val = row[col];
1629
+ if (val instanceof Date) {
1630
+ obj[col] = val.toISOString();
1631
+ } else {
1632
+ obj[col] = val ?? null;
1633
+ }
1634
+ }
1635
+ return obj;
1636
+ });
1637
+ return JSON.stringify(data, jsonReplacerBigInt, 2);
1638
+ }
1639
+
1640
+ // ../../src/lib/utils/file-sort.ts
1641
+ function sortFileEntries(entries, config) {
1642
+ const sorted = [...entries];
1643
+ const dir = config.direction === "asc" ? 1 : -1;
1644
+ sorted.sort((a, b) => {
1645
+ if (a.is_dir && !b.is_dir) return -1;
1646
+ if (!a.is_dir && b.is_dir) return 1;
1647
+ switch (config.field) {
1648
+ case "name":
1649
+ return dir * a.name.localeCompare(b.name, void 0, { sensitivity: "base" });
1650
+ case "size":
1651
+ return dir * (a.size - b.size);
1652
+ case "modified":
1653
+ return dir * (a.modified - b.modified);
1654
+ case "extension":
1655
+ return dir * a.extension.localeCompare(b.extension, void 0, { sensitivity: "base" });
1656
+ default:
1657
+ return 0;
1658
+ }
1659
+ });
1660
+ return sorted;
1661
+ }
1662
+ function toggleSortField(current, field) {
1663
+ if (current.field === field) {
1664
+ return { field, direction: current.direction === "asc" ? "desc" : "asc" };
1665
+ }
1666
+ return { field, direction: "asc" };
1667
+ }
1236
1668
  function normalizeGeomType(raw) {
1237
1669
  const s = raw.toUpperCase().replace(/\s+/g, "");
1238
1670
  if (s === "POINT") return "point";
@@ -1834,8 +2266,78 @@ function generateHexDump(data, bytesPerRow = 16) {
1834
2266
  return rows;
1835
2267
  }
1836
2268
 
2269
+ // ../../src/lib/utils/local-storage.ts
2270
+ function loadFromStorage(key, defaultValue) {
2271
+ if (typeof window === "undefined") return defaultValue;
2272
+ try {
2273
+ const raw = localStorage.getItem(key);
2274
+ if (raw) return JSON.parse(raw);
2275
+ } catch {
2276
+ }
2277
+ return defaultValue;
2278
+ }
2279
+ function persistToStorage(key, value) {
2280
+ if (typeof window === "undefined") return;
2281
+ try {
2282
+ localStorage.setItem(key, JSON.stringify(value));
2283
+ } catch {
2284
+ }
2285
+ }
2286
+ function parseMarkdownDocument(markdown) {
2287
+ let frontmatter = {};
2288
+ let content = markdown;
2289
+ const fmMatch = markdown.match(/^---\n([\s\S]*?)\n---\n/);
2290
+ if (fmMatch) {
2291
+ try {
2292
+ frontmatter = YAML.parse(fmMatch[1]) || {};
2293
+ } catch {
2294
+ }
2295
+ content = markdown.slice(fmMatch[0].length);
2296
+ }
2297
+ const sqlBlocks = [];
2298
+ const lines = content.split("\n");
2299
+ let i = 0;
2300
+ while (i < lines.length) {
2301
+ const line = lines[i];
2302
+ const match = line.match(/^```sql\s+(\w[\w-]*)\s*$/);
2303
+ if (match) {
2304
+ const name = match[1];
2305
+ const startLine = i;
2306
+ const sqlLines = [];
2307
+ i++;
2308
+ while (i < lines.length && lines[i] !== "```") {
2309
+ sqlLines.push(lines[i]);
2310
+ i++;
2311
+ }
2312
+ sqlBlocks.push({
2313
+ name,
2314
+ sql: sqlLines.join("\n"),
2315
+ startLine,
2316
+ endLine: i
2317
+ });
2318
+ }
2319
+ i++;
2320
+ }
2321
+ return { frontmatter, content, sqlBlocks };
2322
+ }
2323
+ function interpolateTemplates(text, queryResults) {
2324
+ return text.replace(/\{(\w+)\.rows\[(\d+)\]\.(\w+)\}/g, (match, queryName, rowIdx, colName) => {
2325
+ const rows = queryResults.get(queryName);
2326
+ if (!rows) return match;
2327
+ const row = rows[parseInt(rowIdx, 10)];
2328
+ if (!row) return match;
2329
+ const value = row[colName];
2330
+ return value !== void 0 ? String(value) : match;
2331
+ });
2332
+ }
2333
+ function markSqlBlocks(content) {
2334
+ return content.replace(
2335
+ /```sql\s+(\w[\w-]*)\s*\n([\s\S]*?)```/g,
2336
+ (_, name) => `<div data-sql-block="${name}"></div>`
2337
+ );
2338
+ }
2339
+
1837
2340
  // ../../src/lib/utils/parquet-metadata.ts
1838
- var WGS84_CODES = /* @__PURE__ */ new Set([4326, 4979]);
1839
2341
  function mapParquetType(col) {
1840
2342
  const lt = col.logical_type;
1841
2343
  if (lt) {
@@ -1976,24 +2478,18 @@ function extractBounds(geo) {
1976
2478
  }
1977
2479
 
1978
2480
  // ../../src/lib/utils/storage-url.ts
1979
- var SCHEME_MAP = {
1980
- "s3://": { provider: "s3", strip: 5 },
1981
- "s3a://": { provider: "s3", strip: 6 },
1982
- "s3n://": { provider: "s3", strip: 6 },
1983
- "aws://": { provider: "s3", strip: 6 },
1984
- "r2://": { provider: "r2", strip: 5 },
1985
- "gs://": { provider: "gcs", strip: 5 },
1986
- "gcs://": { provider: "gcs", strip: 6 },
1987
- "azure://": { provider: "azure", strip: 8 },
1988
- "az://": { provider: "azure", strip: 5 },
1989
- "abfs://": { provider: "azure", strip: 7 },
1990
- "abfss://": { provider: "azure", strip: 8 },
1991
- "wasbs://": { provider: "azure", strip: 8 },
1992
- "adl://": { provider: "azure", strip: 6 },
1993
- "storj://": { provider: "storj", strip: 8 },
1994
- "sj://": { provider: "storj", strip: 5 },
1995
- "swift://": { provider: "unknown", strip: 8 }
1996
- };
2481
+ function buildSchemeMap() {
2482
+ const map = {};
2483
+ for (const [id, def] of Object.entries(PROVIDERS)) {
2484
+ for (const scheme of def.schemes) {
2485
+ const key = `${scheme}://`;
2486
+ map[key] = { provider: id, strip: key.length };
2487
+ }
2488
+ }
2489
+ map["swift://"] = { provider: "unknown", strip: 8 };
2490
+ return map;
2491
+ }
2492
+ var SCHEME_MAP = buildSchemeMap();
1997
2493
  function defaultResult(defaults) {
1998
2494
  return {
1999
2495
  bucket: "",
@@ -2098,7 +2594,7 @@ function parseStorageUrl(input, defaults = {}) {
2098
2594
  bucket: doVhost[1],
2099
2595
  region: doVhost[2],
2100
2596
  endpoint: `${url.protocol}//${doVhost[2]}.digitaloceanspaces.com`,
2101
- provider: "s3",
2597
+ provider: "digitalocean",
2102
2598
  prefix: pathParts.join("/")
2103
2599
  };
2104
2600
  }
@@ -2108,7 +2604,7 @@ function parseStorageUrl(input, defaults = {}) {
2108
2604
  bucket: pathParts[0],
2109
2605
  region: doPath[1],
2110
2606
  endpoint: `${url.protocol}//${url.host}`,
2111
- provider: "s3",
2607
+ provider: "digitalocean",
2112
2608
  prefix: pathParts.slice(1).join("/")
2113
2609
  };
2114
2610
  }
@@ -2118,7 +2614,7 @@ function parseStorageUrl(input, defaults = {}) {
2118
2614
  bucket: pathParts[0],
2119
2615
  region: wasabiMatch[1],
2120
2616
  endpoint: `${url.protocol}//${url.host}`,
2121
- provider: "s3",
2617
+ provider: "wasabi",
2122
2618
  prefix: pathParts.slice(1).join("/")
2123
2619
  };
2124
2620
  }
@@ -2128,7 +2624,7 @@ function parseStorageUrl(input, defaults = {}) {
2128
2624
  bucket: b2S3[1],
2129
2625
  region: b2S3[2],
2130
2626
  endpoint: `${url.protocol}//s3.${b2S3[2]}.backblazeb2.com`,
2131
- provider: "s3",
2627
+ provider: "b2",
2132
2628
  prefix: pathParts.join("/")
2133
2629
  };
2134
2630
  }
@@ -2138,7 +2634,7 @@ function parseStorageUrl(input, defaults = {}) {
2138
2634
  bucket: pathParts[1],
2139
2635
  region: defaults.region || "us-west-000",
2140
2636
  endpoint: `${url.protocol}//${url.host}`,
2141
- provider: "s3",
2637
+ provider: "b2",
2142
2638
  prefix: pathParts.slice(2).join("/")
2143
2639
  };
2144
2640
  }
@@ -2171,6 +2667,56 @@ function parseStorageUrl(input, defaults = {}) {
2171
2667
  prefix: pathParts.slice(1).join("/")
2172
2668
  };
2173
2669
  }
2670
+ const contaboMatch = host.match(/^([a-z0-9]+)\.contabostorage\.com$/);
2671
+ if (contaboMatch && pathParts.length > 0) {
2672
+ return {
2673
+ bucket: pathParts[0],
2674
+ region: contaboMatch[1],
2675
+ endpoint: `${url.protocol}//${url.host}`,
2676
+ provider: "contabo",
2677
+ prefix: pathParts.slice(1).join("/")
2678
+ };
2679
+ }
2680
+ const hetznerMatch = host.match(/^([a-z0-9]+)\.your-objectstorage\.com$/);
2681
+ if (hetznerMatch && pathParts.length > 0) {
2682
+ return {
2683
+ bucket: pathParts[0],
2684
+ region: hetznerMatch[1],
2685
+ endpoint: `${url.protocol}//${url.host}`,
2686
+ provider: "hetzner",
2687
+ prefix: pathParts.slice(1).join("/")
2688
+ };
2689
+ }
2690
+ const linodeVhost = host.match(/^(.+)\.([a-z0-9-]+)\.linodeobjects\.com$/);
2691
+ if (linodeVhost) {
2692
+ return {
2693
+ bucket: linodeVhost[1],
2694
+ region: linodeVhost[2],
2695
+ endpoint: `${url.protocol}//${linodeVhost[2]}.linodeobjects.com`,
2696
+ provider: "linode",
2697
+ prefix: pathParts.join("/")
2698
+ };
2699
+ }
2700
+ const linodePath = host.match(/^([a-z0-9-]+)\.linodeobjects\.com$/);
2701
+ if (linodePath && pathParts.length > 0) {
2702
+ return {
2703
+ bucket: pathParts[0],
2704
+ region: linodePath[1],
2705
+ endpoint: `${url.protocol}//${url.host}`,
2706
+ provider: "linode",
2707
+ prefix: pathParts.slice(1).join("/")
2708
+ };
2709
+ }
2710
+ const ovhMatch = host.match(/^s3\.([a-z0-9-]+)\.io\.cloud\.ovh\.(?:net|us)$/);
2711
+ if (ovhMatch && pathParts.length > 0) {
2712
+ return {
2713
+ bucket: pathParts[0],
2714
+ region: ovhMatch[1],
2715
+ endpoint: `${url.protocol}//${url.host}`,
2716
+ provider: "ovhcloud",
2717
+ prefix: pathParts.slice(1).join("/")
2718
+ };
2719
+ }
2174
2720
  const isMinioLike = host.includes("minio") || host === "localhost" || host === "127.0.0.1" || host.startsWith("192.168.") || host.startsWith("10.");
2175
2721
  if (isMinioLike && pathParts.length > 0) {
2176
2722
  return {
@@ -2507,6 +3053,6 @@ function isWKT(value) {
2507
3053
  return WKT_TYPES.some((t) => s.startsWith(t) || s.startsWith(`MULTI${t}`));
2508
3054
  }
2509
3055
 
2510
- export { QueryCancelledError, UrlAdapter, buildDuckDbSource, buildGeoArrowTables, classifyType, describeParseResult, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, formatDate, formatFileSize, generateHexDump, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getViewerKind, isCloudNativeFormat, isQueryable, looksLikeUrl, normalizeGeomType, parseStorageUrl, parseWKB, readParquetMetadata, toBinary, typeBadgeClass, typeColor, typeLabel };
3056
+ export { COPY_FEEDBACK_MS, DEFAULT_TARGET_CRS, DUCKDB_INIT_TIMEOUT_MS, LAYER_HUE_MULTIPLIER, MAX_QUERY_HISTORY_ENTRIES, PROVIDERS, PROVIDER_IDS, QueryCancelledError, SQL_PREVIEW_LENGTH, STORAGE_KEYS, UrlAdapter, VIEWER_DIR_EXTENSIONS, WGS84_CODES, buildDuckDbSource, buildEndpointFromTemplate, buildGeoArrowTables, buildProviderBaseUrl, classifyType, describeParseResult, escapeCsvField, extractBounds, extractEpsgFromGeoMeta, extractGeometryTypes, findGeoColumn, findGeoColumnFromRows, formatDate, formatFileSize, formatValue, generateHexDump, getDuckDbReadFn, getFileExtension, getFileTypeInfo, getMimeType, getNativeScheme, getProvider, getViewerKind, handleLoadError, interpolateTemplates, isCloudNativeFormat, isGcsProvider, isQueryable, jsonReplacerBigInt, loadFromStorage, looksLikeUrl, markSqlBlocks, normalizeGeomType, parseMarkdownDocument, parseStorageUrl, parseWKB, persistToStorage, readParquetMetadata, resolveCloudUrl, safeDecodeURIComponent, serializeToCsv, serializeToJson, sortFileEntries, toBinary, toggleSortField, typeBadgeClass, typeColor, typeLabel };
2511
3057
  //# sourceMappingURL=index.js.map
2512
3058
  //# sourceMappingURL=index.js.map