Open Local Files

Open browser files once and share the session with sections, well tracks, metadata panels and crossplots.

Open a browser File or Blob once, then share the source and returned path with your views. Parsing and local tile work run in a module worker.

Open and Release a File

import { LocalDataSource } from '@bs/outkrop-readers/browser'

export async function inspectLocalFile(file: File, signal?: AbortSignal) {
  const source = new LocalDataSource()
  try {
    const info = await source.open(file, { signal })
    console.log(info.name, info.kind, info.details)
    if (info.kind === 'seismic') {
      const metadata = await source.seismicInfo(info.path, signal)
      console.log(metadata)
    }
    await source.close(info.path)
    return info
  } finally {
    source.dispose()
  }
}

This inspection example closes before returning: its metadata remains a snapshot, but its path is no longer usable. For a displayed file, keep the source open as in Your First React Section.

Input / result Meaning
File Name comes from the file
Plain Blob Supply { name: 'line.sgy' } for a format hint
FileInfo Ready metadata: path, name, size, type, kind, version, details
Path Session identifier, not a URL or filesystem path

Let paths be generated. Close a supplied path before reuse; reopen files after reload. Your app owns the picker, loading state and error UI.

Choose a Capability

Kind Use
Seismic seismicInfo, tiles/windows, header APIs, SectionView
Well wellInfo, scalar wellCurves, CurveLayer
Table Frame metadata, previews, points

seismicDetails(path, signal) adds header summaries through further reads. Inspect warnings and units. Narrow details by their format before reading format-specific fields. Local array-channel tiles, tie windows and DLIS parsing are unavailable.

Crossplot Columns

import type { LocalDataSource } from '@bs/outkrop-readers/browser'

export async function loadCrossplot(
  source: LocalDataSource,
  path: string,
  frameId: string,
  x: string,
  y: string,
  signal?: AbortSignal,
) {
  const { table, total } = await source.points(path, frameId, [x, y], 100_000, signal)
  return { table, caption: `${table.rows} of ${total} rows` }
}

Pass the returned table to CrossplotView, selecting the same column names. max must be a positive safe integer; results are capped at 2,000,000 rows. Rows are evenly spaced, not random. Show table.rows versus total; keep category code labels available.

Set Memory Budgets

import { LocalDataSource } from '@bs/outkrop-readers/browser'

const MiB = 1024 * 1024
export const source = new LocalDataSource({
  maxTextBytes: 64 * MiB,
  columnBudgetBytes: 128 * MiB,
  tileCacheBytes: 32 * MiB,
})
Default Scope
maxTextBytes: 64 MiB Each LAS/table file
columnBudgetBytes: 128 MiB Retained numeric columns across this source’s files
tileCacheBytes: 32 MiB Seismic cache; zero disables it

Other limits must be positive safe integers. These exclude text, temporary buffers, metadata and GPU allocations. Ranged seismic has no whole-text cap; an overview still reads averaged samples.

Cancellation and Ownership

flowchart TD
  accTitle: A local reader session lifetime
  accDescr: The application creates a source, opens files with cancellation, keeps the source alive while views use it, closes individual files and disposes the source after the views leave.
  Create["Create source"] --> Open["Open file with AbortSignal"]
  Open --> Use["Use metadata and views"]
  Use --> Close["Unmount file views and close path"]
  Close --> More{"Open another file?"}
  More -->|Yes| Open
  More -->|No| Dispose["Dispose source"]
Action Effect
Abort a request Cancel superseded work; suppress cancellation errors in your UI
Detach views, then close(path) Cancel file calls and release its state
dispose() Reject pending calls, release every file and terminate worker

Keep the source stable while used. Sharing files shares its budgets. A later call can restart a disposed source, but old paths must be reopened.