vite-plugin-shopify-theme-islands
Version:
Vite plugin for island architecture in Shopify themes
24 lines (23 loc) • 1.04 kB
TypeScript
/**
* Island architecture runtime for Shopify themes.
*
* Walks the DOM for custom elements that match island files, then loads them
* lazily based on client directives:
*
* client:visible — load when the element scrolls into view
* client:media — load when a CSS media query matches
* client:idle — load when the browser has idle time
* client:defer — load after a fixed delay (ms value on the attribute)
* client:interaction — load on mouseenter / touchstart / focusin (or custom events)
*
* Directives can be combined; all conditions must be met before loading.
* A MutationObserver re-runs the same logic for elements added dynamically.
*/
import { type RevivePayload } from "./contract.js";
export interface ReviveRuntime {
disconnect: () => void;
scan: (root?: HTMLElement | null) => void;
observe: (root?: HTMLElement | null) => void;
unobserve: (root?: HTMLElement | null) => void;
}
export declare function revive(payload: RevivePayload): ReviveRuntime;