@gluonjs/core


@gluonjs/core / src/styles / StyleSheetSelectionEntry

Interface: StyleSheetSelectionEntry

Extended by

Properties

id

readonly id: string

Stable transport identity. Content changes are detected by the digest.


scope?

readonly optional scope?: string

Optional owner namespace used to isolate hydration carriers.


sheet

readonly sheet: CSSStyleSheet

Example

Associate one constructed sheet with its stable transport ID and optional hydration scope:

ts
import {
  createStyleSheetOwner,
  createStyleSheetSelection,
  css,
  getStyleSheetDigest,
  getStyleTextDigest,
  replaceStyleSheet,
  type StyleSheetOwner,
  type StyleSheetSelection,
  type StyleSheetSelectionEntry,
} from '@gluonjs/core';

const sheet = css`:root { --shop-accent: blue; }`;
const entry = { id: 'shop-theme', scope: 'shop', sheet } satisfies StyleSheetSelectionEntry;
const selection: StyleSheetSelection = createStyleSheetSelection([entry]);
const owner: StyleSheetOwner = createStyleSheetOwner(document);
owner.retain(sheet);
replaceStyleSheet(sheet, ':root { --shop-accent: green; }');
console.log(selection.entries[0]?.id, getStyleSheetDigest(sheet), getStyleTextDigest('shop'));
owner.release(sheet);
owner.dispose();