@sheetwrite/corefunction
Create a typed bridge while preserving row and identity inference.
- Package
@sheetwrite/core- Source
packages/core/src/row-bridge.ts#L859
Declaration
function createRowBridge< Row extends Record<string, CellScalartype CellScalar = string | number | boolean | null;type CellScalar = string | number | boolean | null;type CellScalar =
| string
| number
| boolean
| null;A scalar that can be displayed directly.API reference →>, Id extends RowBridgeIdtype RowBridgeId = string | number;type RowBridgeId = string | number;type RowBridgeId =
string | number;A stable host identity for one data-space row.API reference → = RowBridgeIdtype RowBridgeId = string | number;type RowBridgeId = string | number;type RowBridgeId =
string | number;A stable host identity for one data-space row.API reference →,>(options: RowBridgeOptionsinterface RowBridgeOptions<
Row extends Record<string, CellScalar>,
Id extends RowBridgeId = RowBridgeId,
> {
readonly columns: readonly RowBridgeColumn<Row>[];
readonly defaultRows: readonly Row[];
readonly getRowId: (row: Row, index: number) => Id;
readonly sheet?: SheetId;
readonly createRowId?: (context: RowBridgeInsertContext) => Id;
}interface RowBridgeOptions<
Row extends Record<string, CellScalar>,
Id extends RowBridgeId = RowBridgeId,
> {
readonly columns: readonly RowBridgeColumn<Row>[];
readonly defaultRows: readonly Row[];
readonly getRowId: (row: Row, index: number) => Id;
readonly sheet?: SheetId;
readonly createRowId?: (context: RowBridgeInsertContext) => Id;
}interface RowBridgeOptions<
Row extends Record<
string,
CellScalar
>,
Id extends RowBridgeId =
RowBridgeId,
> {
readonly columns: readonly RowBridgeColumn<Row>[];
readonly defaultRows: readonly Row[];
readonly getRowId: (
row: Row,
index: number,
) => Id;
readonly sheet?: SheetId;
readonly createRowId?: (
context: RowBridgeInsertContext,
) => Id;
}Options for the framework-neutral, opt-in row bridge.API reference →<Row, Id>): RowBridgeclass RowBridge {
constructor<
Id extends RowBridgeId = RowBridgeId,
Row extends Record<string, CellScalar> = Record<
string,
CellScalar
>,
>(options: RowBridgeOptions<Row, Id>);
columnKeys: (sheet?: SheetId) => readonly string[];
project: (
event: ChangeEvent,
requestedOperations?: readonly DocumentOp[],
transactionId?: string,
) => RowBridgeProjection<Id>;
reconcile: (
// … 4 more lines — see the API reference
}class RowBridge {
constructor<
Id extends RowBridgeId = RowBridgeId,
Row extends Record<string, CellScalar> = Record<
string,
CellScalar
>,
>(options: RowBridgeOptions<Row, Id>);
columnKeys: (sheet?: SheetId) => readonly string[];
project: (
event: ChangeEvent,
requestedOperations?: readonly DocumentOp[],
transactionId?: string,
) => RowBridgeProjection<Id>;
reconcile: (
// … 4 more lines — see the API reference
}class RowBridge {
constructor<
Id extends RowBridgeId =
RowBridgeId,
Row extends Record<
string,
CellScalar
> = Record<
string,
CellScalar
>,
>(
options: RowBridgeOptions<
Row,
Id
>,
);
columnKeys: (
sheet?: SheetId,
// … 13 more lines — see the API reference
}Projects canonical document transactions into host-owned row changes. The bridge only owns compact data-space identity arrays. It never writes to defaultRows, never renders, and never creates a second document store.API reference →<Id>