UNPKG

lib0

Version:

isomorphic utility functions

64 lines • 2.48 kB
/** * Projects a single node attribute into a `lib0:value` node's `value` attribute (and back). * * @template {string} AttrName * @template {delta.DeltaConf} [IN=any] * @extends {Template<IN, ApplyAttr<AttrName, IN>>} */ export class Attr<AttrName extends string, IN extends delta.DeltaConf = any> extends Template<IN, { name: "lib0:value"; attrs: { value: delta._SanifyDelta<IN extends { attrs: { [K in AttrName]: infer V; }; } ? V : never>; }; }> { /** * @param {import('../../schema.js').Schema<delta.Delta<IN>>} $d * @param {AttrName} attrName */ constructor($d: import("../../schema.js").Schema<delta.Delta<IN>>, attrName: AttrName); attrName: AttrName; } /** * @template {delta.DeltaConf} A * @template {delta.DeltaConf} B * @extends {Transformer<A,B>} */ export class AttrTransformer<A extends delta.DeltaConf, B extends delta.DeltaConf> extends Transformer<A, B> { /** * @param {import('../../schema.js').Schema<delta.Delta<any>>} $in * @param {import('../../schema.js').Schema<delta.Delta<any>>} $out * @param {string} attrName */ constructor($in: import("../../schema.js").Schema<delta.Delta<any>>, $out: import("../../schema.js").Schema<delta.Delta<any>>, attrName: string); attrName: keyof import("../../ts.js").TypeIsAny<A, { [K: string]: any; [K: number]: any; }, A extends { attrs: infer Attrs; } ? Attrs extends undefined ? {} : Attrs : {}> & (string | number); /** * @param {delta.DeltaBuilder<A>} d * @return {import('./core.js').TransformResultAny} */ applyA(d: delta.DeltaBuilder<A>): import("./core.js").TransformResultAny; /** * @param {delta.DeltaBuilder<B>} d * @return {import('./core.js').TransformResultAny} */ applyB(d: delta.DeltaBuilder<B>): import("./core.js").TransformResultAny; } export function attr<AttrName extends string, IN extends delta.DeltaConf>($d: import("../../schema.js").Schema<delta.Delta<IN>>, attrName: AttrName): Attr<AttrName, IN>; export type ApplyAttr<AttrName extends string, IN extends delta.DeltaConf> = import("./core.js").ResolveOut<{ name: "lib0:value"; attrs: { value: IN extends { attrs: { [K in AttrName]: infer V; }; } ? V : never; }; }>; import * as delta from '../delta.js'; import { Template } from './core.js'; import { Transformer } from './core.js'; //# sourceMappingURL=attr.d.ts.map