Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Notebook Stdlib Package

Status: Implemented for the current package boundary. packages/notebook/stdlib owns current notebook builtin registry contracts, documented bare global names, the pure user-executed lapis output helper implementations, user dependency descriptor/registry validation contracts, the shared runtime dependency loader helpers, source-level runtime feature detection for standard-library-backed helpers, the host-neutral vault/file helper implementations used by notebook runtime hosts, the raw DOM helper loader for html/svg, the host-neutral DOM, Promises, and Generators helper implementations, and the host-neutral bootstrap used to assemble bundled stdlib bindings for notebook execution.

Purpose

@lapis-notes/notebook-stdlib is the shared contract and helper-implementation package for Lapis notebook builtins and user dependency registry metadata. It gives the product plugin and future dependency-management UI one source of truth for which names are Lapis-owned, which bare globals are documented conveniences, how dependency globals are derived and validated, how configured dependencies resolve into runtime globals, which source references require broad DOM-aware handling versus live browser DOM execution or DuckDB-backed execution, how vault-backed file helpers normalize notebook-relative paths, how DSV attachment loaders preserve table columns, and how bundled stdlib helpers are assembled for notebook execution.

The package is intentionally host-neutral. It does not load htl, DuckDB-Wasm, worker code, Svelte UI, or app APIs at workspace boot. Host-specific runtime wiring still lives in the product plugin, but shared host-neutral helper implementations such as vault-backed file attachment plumbing and dynamic bundled-helper bootstrap can live here so notebook-callable helper behavior stays centralized without making workspace boot expensive.

Current Scope

  • canonical lapis global name
  • pure lapis output helper implementations for typed text, markdown, HTML, DOM, input, table, chart, image, and error outputs
  • current lapis.* builtin member names, including output helpers, duckdb, vault, FileAttachment, md, tex, d3, Plot, DOM, Generators, Promises, view, Inputs, html, and svg
  • documented bare convenience globals: Inputs, html, svg, md, tex, d3, Plot, DOM, Generators, and Promises
  • validation for future user dependency globals, including identifier syntax, reserved builtin names, and duplicate configured names
  • host-neutral user dependency descriptors with pinned package versions, optional explicit globals, resolver metadata, package-name-derived default globals, whole-registry validation, and shared runtime dependency resolution helpers for referenced globals
  • source-level detection for broad DOM helper references, live browser DOM runtime references, DuckDB runtime references, and bundled visualization helper references
  • host-neutral notebook file helpers including notebook-relative path normalization, vault runtime adapters backed by host file readers, and FileAttachment helpers for arrayBuffer, text, json, blob, csv, and tsv
  • host-neutral raw DOM helper loading for htl, exposed for notebook-input so the input runtime can pair bare html and svg helpers with its own Inputs namespace ownership
  • host-neutral DOM helper implementations for canvas, context2d, download, and uid, patterned after the Observable stdlib namespace and exposed under both lapis.DOM and the documented bare DOM global
  • host-neutral Promises and Generators helper implementations patterned after Observable stdlib namespaces and exposed under both lapis.* and documented bare globals
  • host-neutral runtime bootstrap for bundled stdlib helpers, currently including lapis.md, lapis.tex, lapis.d3, lapis.Plot, lapis.DOM, lapis.Generators, lapis.Promises, and their documented bare globals during JavaScript-like execution

Consumers

@lapis-notes/notebook consumes this package for pure lapis output helpers, runtime feature detection, inspector DuckDB detection, notebook dependency-analysis reserved globals, shared runtime dependency loading helpers, the raw html/svg DOM helper loader used under notebook-input, the shared DOM, Promises, and Generators namespaces, the stdlib bootstrap for bundled helpers, and vault-backed lapis.vault/lapis.FileAttachment helper implementations. @lapis-notes/notebook-duckdb also reuses the shared notebook-relative file-path normalization so DuckDB vault-file registration and notebook file helpers obey the same path rules.

Boundary Rules

Host-specific implementations should remain lazy and must not make workspace boot load DOM, DuckDB, visualization, or remote dependency resolver code. DOM control wiring, DuckDB service execution, and remote dependency loading still belong outside this package; host-neutral file helper implementations and bundled-helper bootstrap are allowed here because they depend only on host-provided file readers or package-local dynamic imports.