Own Sheetwrite initialization and Grid lifetime without a framework adapter.
Use @sheetwrite/core when the host owns DOM lifetime directly. Call initSheetwrite() on the client, pass an existing element to createGrid, and retain the returned Grid for events and commands.
Vanilla lifecycle
import {
createGridfunction createGrid(host: HTMLElement, opts: GridOptions): GridfunctioncreateGrid(host:HTMLElement,opts:GridOptions,):GridfunctioncreateGrid(host:HTMLElement,opts:GridOptions,):GridCreates and mounts an imperative Grid in the supplied host element.API reference →,
initSheetwritefunction initSheetwrite(source?: BufferSource | URL | string | Request | WebAssembly.Module): Promise<void>functioninitSheetwrite(source?:BufferSource|URL|string|Request|WebAssembly.Module,):Promise<void>functioninitSheetwrite(source?:|BufferSource|URL|string|Request|WebAssembly.Module,):Promise<void>Load the WASM data engine once. Must be awaited before createGrid.API reference →,
typeChangeEventinterface ChangeEventinterfaceChangeEventinterfaceChangeEventPayload of the change event; flows OUT for API submission/reconcile.API reference →,
typeColumnarDatainterface ColumnarDatainterfaceColumnarDatainterfaceColumnarDataEager column-oriented values used to initialize a sheet.API reference →,
typeWorkbookinterface WorkbookinterfaceWorkbookinterfaceWorkbookLive workbook schema containing ordered sheets and the active sheet ID.API reference →,
host:HTMLElementinterface HTMLElementinterfaceHTMLElementinterfaceHTMLElementThe HTMLElement interface represents any HTML element. MDN Reference,
workbook:Workbookinterface WorkbookinterfaceWorkbookinterfaceWorkbookLive workbook schema containing ordered sheets and the active sheet ID.API reference →,
data:ColumnarDatainterface ColumnarDatainterfaceColumnarDatainterfaceColumnarDataEager column-oriented values used to initialize a sheet.API reference →,
persistChange: (event:ChangeEventinterface ChangeEventinterfaceChangeEventinterfaceChangeEventPayload of the change event; flows OUT for API submission/reconcile.API reference →) =>void,
) {
awaitinitSheetwritefunction initSheetwrite(source?: BufferSource | URL | string | Request | WebAssembly.Module): Promise<void>functioninitSheetwrite(source?:BufferSource|URL|string|Request|WebAssembly.Module,):Promise<void>functioninitSheetwrite(source?:|BufferSource|URL|string|Request|WebAssembly.Module,):Promise<void>Load the WASM data engine once. Must be awaited before createGrid.API reference →();
constgridconst grid: Gridconstgrid:Gridconstgrid:GridThe imperative core grid this controller owns.API reference →=createGridfunction createGrid(host: HTMLElement, opts: GridOptions): GridfunctioncreateGrid(host:HTMLElement,opts:GridOptions,):GridfunctioncreateGrid(host:HTMLElement,opts:GridOptions,):GridCreates and mounts an imperative Grid in the supplied host element.API reference →(hosthost: HTMLElementlet host:HTMLElementlet host:HTMLElement, { workbookGridOptions.workbook: WorkbookinterfaceGridOptions {workbook:Workbook;}interfaceGridOptions {workbook:Workbook;}Live workbook schema adopted by the store and updated by document operations.API reference →, dataGridOptions.data?: ColumnarData | undefinedinterfaceGridOptions {data?:ColumnarData|undefined;}interfaceGridOptions {data?:ColumnarData|undefined;}Eager column-major values loaded into workbook.activeSheet; use instead of datasource.API reference → });
gridconst grid: Gridconstgrid:Gridconstgrid:GridThe imperative core grid this controller owns.API reference →.destroyGrid.destroy(): voidGrid.destroy(): voidGrid.destroy(): voidDetach every event subscription and destroy the grid. Call exactly once.API reference →();
};
}
A datasource-backed grid may use dense storage or allocation-lazy paged storage. Full-sheet operations can throw IncompleteDataError until every required page is loaded. Worker rendering automatically falls back to the main-thread canvas when capabilities or startup fail; observe renderer-fallback if the host needs to report that transition.