@gluonjs/core


@gluonjs/core / src/styles / getStyleSheetDigest

Function: getStyleSheetDigest()

getStyleSheetDigest(sheet): string

Returns the stable content digest used by Gluon's SSR style transport.

Parameters

sheet

CSSStyleSheet

Returns

string

Example

Read the stable transport digest of a constructed stylesheet after an identity-preserving update:

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();