@sable-ai/core
v0.1.6
Published
Shared types and utilities for Sable AI SDK packages
Readme
Utilities in src/utils/
Browser.ts— Safe browser checks and globals.- Exports:
isBrowser,safeWindow,safeDocument.
- Exports:
Http.ts— Lightweight HTTP client wrapper.- Exports:
HttpClient.
- Exports:
ElementSelector.ts— Find single or multiple elements, wait for elements.- Exports:
findElement,findElements,waitForElement.
- Exports:
ElementPositioning.ts— Helpers for positioning and observation.- Exports:
getElementPosition,isElementInViewport,applyPositionWithDelay,createPositionObserver,removePositionObserver,cleanupAllPositionObservers.
- Exports:
HighlightElement.ts— Visual pulsing highlight with auto-restore.- Exports:
highlightElement.
- Exports:
ScrollToElement.ts— Scroll an element into view with optional highlight.- Exports:
scrollToElement.
- Exports:
AudioAnalyzer.ts— Audio volume analysis utilities.- Exports:
AudioVolumeAnalyzer.
- Exports:
@sable-ai/core
Core utilities for DOM interaction and client automation.
This package is ESM-first and exposes utilities like highlightElement and scrollToElement for visual guidance and in-page navigation.
Installation
This package is part of the monorepo and is consumed by sibling packages. If you want to use it externally, install via your package manager after publishing.
Build
From packages/core/:
npm run buildThis generates:
dist/esm/— ES modules (used by the visual test page)dist/cjs/— CommonJS buildsdist/types/— TypeScript declarations
Visual testing (no React app required)
A minimal HTML page is provided to visually test the helpers.
- Build the package (if you haven't already):
npm run build- Serve
packages/core/as the web root (so that/test/and/dist/esm/are accessible):
npx serve- Open the test page in your browser:
- http://localhost:3000/test/
If you serve from the monorepo root instead, use:
- http://localhost:3000/packages/core/test/
The page at packages/core/test/index.html loads the built ESM files directly:
../dist/esm/utils/highlightElement.js../dist/esm/utils/scrollToElement.js
Buttons on the page let you:
- Highlight: run
highlightElement()with default yellow pulsing outline and auto-restore. - Flash (1s): run
highlightElement()with an orange style for 1 second. - Scroll + Highlight: run
scrollToElement()which scrolls and callshighlightElement().
API
highlightElement(element, options?, timeMs?) => Promise
- Temporarily applies a prominent yellow pulsing outline to
element, then restores original inline styles. - Options (all optional):
color(default:rgb(204, 184, 0))width(default:2.5px)duration— CSS transition duration, e.g."0.5s"(default0.5s)
timeMs— how long to keep the highlight before restoring (default1000).
- Temporarily applies a prominent yellow pulsing outline to
scrollToElement(element, options?) => Promise
- Scrolls
elementinto view and optionally highlights it. - Options (all optional):
behavior(default:"smooth")block(default:"center")inline(default:"nearest")highlight(default:true)highlightOptions— forwarded tohighlightElement()highlightDurationMs— duration passed tohighlightElement()(default1000)
- Scrolls
Notes
- This package is ESM-first. When importing in the browser, relative imports include the
.jsextension (e.g.,./Browser.js). The visual test page imports fromdist/esm/for this reason. - If your browser blocks
file://ESM imports, usenpx serve(or any static server) as shown above. - Downstream packages should import from the top-level entry:
@sable-ai/core.
Development
- Type-check/build:
npm run build - Linting/tests are configured in the monorepo; run them at the root if applicable.
