npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@whenessel/seql-js

v1.6.1

Published

Semantic Element Query Language JS Implementation

Readme

seql-js

Semantic Element Query Language (SEQL) - Stable DOM element identification for web analytics, session replay, and automation.

seql-js provides a robust way to identify DOM elements using semantic features rather than brittle CSS paths or XPath. It's designed to survive DOM restructuring, CSS changes, and framework updates.

Features

  • Semantic-first: Uses ARIA roles, labels, semantic HTML tags, and stable attributes.
  • Resilient: Designed to be stable across UI updates and DOM changes.
  • State-independent (v1.0.3): Filters out state attributes (aria-selected, data-state, disabled) to ensure elements are found regardless of their current state.
  • Dual Format:
    • EID (JSON): Structured descriptor for internal operations and high precision.
    • SEQL Selector (String): Canonical string format for easy transport (analytics) and storage.
  • Deterministic: Guaranteed same output for the same DOM state.
  • Zero Dependencies: Tree-shakeable and lightweight.
  • TypeScript Native: Written in TypeScript with full type definitions.

Requirements

  • Node.js: v18 or higher.
  • Package Manager: Yarn (recommended) or npm.

Installation

yarn add seql-js
# or
npm install seql-js

Quick Start

1. SEQL Selector Format (Recommended for Analytics)

SEQL Selectors are compact, URL-safe strings perfect for sending to analytics platforms.

import { generateSEQL, resolveSEQL } from 'seql-js';

// 1. Generate SEQL Selector from a DOM element
const button = document.querySelector('.submit-button');
const selector = generateSEQL(button);
// Result: "v1: form :: div.actions > button[type="submit",text="Order Now"]"

// 2. Send to your analytics provider
gtag('event', 'click', { element_selector: selector });

// 3. Later: Resolve SEQL Selector back to the original element
const elements = resolveSEQL(selector, document);
// Returns an array: [<button>...]

2. EID Structured Format (Internal Operations)

EID is a rich JSON object containing full semantic metadata and resolution constraints.

import { generateEID, resolve } from 'seql-js';

// 1. Generate EID (JSON)
const button = document.querySelector('.submit-button');
const eid = generateEID(button);

// 2. Resolve EID
const result = resolve(eid, document);

if (result.status === 'success') {
  console.log('Found element:', result.elements[0]);
  console.log('Confidence score:', result.confidence);
}

Concepts

EID vs SEQL Selector

  • EID (Element Identity Descriptor): A detailed JSON structure describing the Anchor, Path, Target, and Constraints.
  • SEQL Selector: A canonical string representation of an EID, similar to CSS Selector or XPath.
Generation: Element → generateEID() → EID (JSON)
Stringify:  EID → stringifySEQL() → SEQL Selector (string)
Parse:      SEQL Selector → parseSEQL() → EID (JSON)
Resolution: EID → resolve() → ResolveResult

Core Architecture

  1. Anchor: A semantic root (e.g., <form>, <main>, or ARIA landmarks).
  2. Path: Semantic traversal from the anchor to the target.
  3. Target: The specific element being identified.
  4. Constraints: Disambiguation rules (uniqueness, visibility, text proximity).

API Reference

SEQL Selector Functions

generateSEQL(element, generatorOptions?, stringifyOptions?)

Convenience function: generateEID + stringifySEQL. Returns a string or null.

resolveSEQL(selector, root, options?)

Convenience function: parseSEQL + resolve. Returns Element[].

parseSEQL(selector)

Parses a SEQL Selector into an ElementIdentity object.

stringifySEQL(eid, options?)

Converts an ElementIdentity object into a canonical SEQL Selector.

Core Functions

generateEID(element, options?)

Generates an ElementIdentity (EID) from a DOM element.

  • maxPathDepth: Default 10.
  • enableSvgFingerprint: Default true.
  • confidenceThreshold: Default 0.1.

resolve(eid, root, options?)

Resolves an EID back to DOM element(s). Returns a ResolveResult object.

  • status: 'success' | 'ambiguous' | 'error' | 'degraded-fallback'.
  • elements: Element[] of matches.
  • confidence: Match confidence score (0-1).

Utilities & Advanced

generateEIDBatch(elements, options?)

Optimized generation for multiple elements at once.

createEIDCache(options?) / getGlobalCache()

Manage the LRU cache to improve performance for frequent generations/resolutions.

Project Structure

  • src/generator/: Logic for converting DOM elements into EID JSON.
  • src/resolver/: Logic for resolving EID JSON back to DOM elements.
  • src/types/: Core type definitions for EIDs, Semantics, and Constraints.
  • src/utils/: Shared utilities, constants, and scoring algorithms.
  • extensions/chrome/: Chrome DevTools extension for visual SEQL inspection.

Developer Tools

Chrome DevTools Extension

The SEQL Inspector extension provides visual tooling for working with SEQL selectors directly in Chrome DevTools.

Features:

  • Generate SEQL selectors for all elements or pick individual elements
  • Full iframe support with automatic detection and context switching
  • Live search and resolution testing
  • Interactive element highlighting and inspection
  • Tree view with grouping and filtering

Installation:

yarn extension:prepare
# Then load extensions/chrome/ as unpacked extension in Chrome

See Chrome Extension README for detailed documentation.

Scripts

  • yarn build: Build the library (outputs to dist/).
  • yarn test: Run all tests using Vitest.
  • yarn test:watch: Run tests in watch mode.
  • yarn test:coverage: Run tests with coverage report.
  • yarn types:check: Run TypeScript type checking.
  • yarn extension:prepare: Build library and prepare Chrome extension.
  • npx vitest <path>: Run a specific test file.

Documentation

Migrating from v0.x

If you are upgrading from v0.x, note these breaking changes:

  • generateDsl()generateEID()
  • resolveDsl()resolve()
  • DslIdentityElementIdentity
  • DslCacheEIDCache
  • validateDsl()validateEID()

See the full Migration Guide for details.

License

MIT