lib0 1.0.0-rc.13 → 1.0.0-rc.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The identity {@link import('./core.js').Template Template}: it maps every change verbatim in both
3
+ * directions, so both sides stay bit-for-bit equal. A stateless singleton (an attr-rename with no
4
+ * renames).
5
+ *
6
+ * @type {import('./core.js').Template}
7
+ */
8
+ export const id: import("./core.js").Template;
9
+ //# sourceMappingURL=id.d.ts.map
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Stateful transformer that inlines child nodes whose name is in the configured `names` set. Side A
3
+ * is the structured representation (inline nodes present, e.g. `<p>some<>text</></p>`), side B is the
4
+ * inlined representation (inline nodes flattened, e.g. `<p>sometext</p>`).
5
+ *
6
+ * The state the user calls "offsets and inline node length" is the segment layout {@link Seg} stored
7
+ * in `segs`: a coalesced run-length view of the structured side where each inline node is one
8
+ * structured position expanding to `inlineLen` inlined positions, and every other position (root text
9
+ * and opaque non-inlined nodes) is a pass-through run. It is kept current incrementally - every mapped
10
+ * change is folded into `segs` by {@link applySegsChange} rather than re-derived from scratch.
11
+ *
12
+ * @extends {Transformer<any,any>}
13
+ */
14
+ export class InlineTransformer extends Transformer<any, any> {
15
+ /**
16
+ * @param {Array<string|null>} names the node names to inline (`null` selects anonymous nodes)
17
+ */
18
+ constructor(names: Array<string | null>);
19
+ /**
20
+ * @type {Array<string|null>}
21
+ */
22
+ names: Array<string | null>;
23
+ /**
24
+ * The segment layout of the structured side, maintained incrementally (see {@link applySegsChange}).
25
+ *
26
+ * @type {Array<Seg>}
27
+ */
28
+ segs: Array<Seg>;
29
+ /**
30
+ * Whether the structured side has ever contained a direct inline-node child. Monotonic: once a
31
+ * change introduces an inline node it stays set (even if that node is later deleted), which only
32
+ * costs a missed fast-path, never correctness.
33
+ *
34
+ * @type {boolean}
35
+ */
36
+ hasInline: boolean;
37
+ }
38
+ /**
39
+ * Template for {@link InlineTransformer}.
40
+ *
41
+ * @implements Template
42
+ */
43
+ export class Inline implements Template {
44
+ /**
45
+ * @param {Array<string|null>} names the node names to inline (`null` selects anonymous nodes)
46
+ */
47
+ constructor(names: Array<string | null>);
48
+ names: (string | null)[];
49
+ get stateless(): boolean;
50
+ /**
51
+ * Typed loosely: the inlined output shape is not computed at compile time (it depends on the
52
+ * runtime `names`), so the B side is `any`.
53
+ *
54
+ * @template {delta.DeltaConf} IN
55
+ * @param {import('../../schema.js').Schema<delta.Delta<IN>>} _$d
56
+ * @return {Transformer<IN, any>}
57
+ */
58
+ init<IN extends delta.DeltaConf>(_$d: import("../../schema.js").Schema<delta.Delta<IN>>): Transformer<IN, any>;
59
+ }
60
+ export function inline(names: Array<string | null>): Inline;
61
+ /**
62
+ * Convenience {@link Inline} template that inlines anonymous ("null") child nodes
63
+ * (`<p>some<>text</></p>` <-> `<p>sometext</p>`) - i.e. `inline([null])`.
64
+ */
65
+ export const inlineNullNodes: Inline;
66
+ export type Template = import("./core.js").Template;
67
+ import { Transformer } from './core.js';
68
+ /**
69
+ * @typedef {import('./core.js').Template} Template
70
+ */
71
+ /**
72
+ * One entry of the segment layout maintained by {@link InlineTransformer}. A segment is either a
73
+ * coalesced run of pass-through positions (root text + opaque non-inlined nodes - same length in both
74
+ * coordinate spaces) or a single inline node (1 structured position that expands to `inlineLen`
75
+ * inlined positions).
76
+ */
77
+ declare class Seg {
78
+ /**
79
+ * @param {boolean} isInline whether this seg is an inline node (its children are spliced into the parent)
80
+ * @param {number} structLen
81
+ * @param {number} inlineLen
82
+ */
83
+ constructor(isInline: boolean, structLen: number, inlineLen: number);
84
+ isInline: boolean;
85
+ structLen: number;
86
+ inlineLen: number;
87
+ }
88
+ import * as delta from '../delta.js';
89
+ export {};
90
+ //# sourceMappingURL=inline.d.ts.map
@@ -0,0 +1,271 @@
1
+ /**
2
+ * @typedef {import('./core.js').Template} Template
3
+ */
4
+ /**
5
+ * Marker for absent props in a NormalizedDeltaConf.
6
+ *
7
+ * @typedef {{ 'lib0:notset': true }} NotSet
8
+ */
9
+ /**
10
+ * DeltaConf in normalized form: all props defined, absent props are set to NotSet.
11
+ *
12
+ * ApplyPipe iterates over this form (see ApplyPipeNorm).
13
+ *
14
+ * @template Name
15
+ * @template Attrs
16
+ * @template Children
17
+ * @template Text
18
+ * @template RecursiveChildren
19
+ * @template RecursiveAttrs
20
+ * @typedef {{ name: Name, attrs: Attrs, children: Children, text: Text, recursiveChildren: RecursiveChildren, recursiveAttrs: RecursiveAttrs }} NormalizedDeltaConf
21
+ */
22
+ /**
23
+ * @template {delta.DeltaConf} C
24
+ * @typedef {NormalizedDeltaConf<
25
+ * C extends { name: infer Name extends string } ? Name : NotSet,
26
+ * C extends { attrs: infer Attrs extends {[K:string|number]:any} } ? Attrs : NotSet,
27
+ * C extends { children: infer Children } ? Children : NotSet,
28
+ * C extends { text: infer Text extends boolean } ? Text : NotSet,
29
+ * C extends { recursiveChildren: infer RecursiveChildren extends boolean } ? RecursiveChildren : NotSet,
30
+ * C extends { recursiveAttrs: infer RecursiveAttrs extends boolean } ? RecursiveAttrs : NotSet
31
+ * >} NormalizeDeltaConf
32
+ */
33
+ /**
34
+ * Strip NotSet props from a NormalizedDeltaConf, producing a regular DeltaConf again.
35
+ *
36
+ * @template NC
37
+ * @typedef {{ [K in keyof NC as NC[K] extends NotSet ? never : K]: NC[K] } & {}} DenormalizeDeltaConf
38
+ */
39
+ /**
40
+ * Intersect a prop of a Filter conf with the corresponding pipe conf prop. The prop is only kept
41
+ * if it is defined on both sides (mirrors ApplyExpectType).
42
+ *
43
+ * @template FilterProp
44
+ * @template PipeProp
45
+ * @typedef {FilterProp extends NotSet ? NotSet : PipeProp extends NotSet ? NotSet : FilterProp & PipeProp} FilterConfProp
46
+ */
47
+ /**
48
+ * Apply each Template to a NormalizedDeltaConf - must mirror the semantics of ApplyAttrRename /
49
+ * ApplyExpectType.
50
+ *
51
+ * This shape is tuned to stay below typescript's instantiation-depth limit (TS2589) for long
52
+ * pipes (~85 templates via pipe().init(), measured). What we learned:
53
+ *
54
+ * - The per-step destructure of NC is the load-bearing part: typescript resolves types lazily,
55
+ * and member inference out of the literal that was passed as a type argument in the previous
56
+ * step is what forces resolution of the accumulated conf. Without it (e.g. carrying the conf
57
+ * props as individual type params), the attrs accumulate as a deferred PropsRename chain and
58
+ * the limit hits at ~45 templates. Local annotations do NOT force resolution: `X & {}`,
59
+ * `X extends infer N ? ...`, and an inline `{ attrs: X } extends { attrs: infer A } ? ...`
60
+ * roundtrip were all measured to have no effect.
61
+ * - The recursion must carry a plain object literal. Wrapping the accumulator in a helper alias
62
+ * (even a trivial one like NormalizedDeltaConf) defers per step and rebuilds the chain.
63
+ * - The outer check must be on TS alone. Coupling NC into the check type (e.g.
64
+ * `[TS, NC] extends [[...], {...}]`) makes the conditional generic-deferred whenever the conf
65
+ * is generic, which sends constraint comparisons (e.g. Pipe<TS> vs Pipe<any>) into infinite
66
+ * recursion.
67
+ * - Each dispatch branch costs instantiation depth. A conf-passthrough template (one whose output
68
+ * conf equals its input conf, e.g. transformer/inline, whose init() is typed loosely as
69
+ * `Transformer<IN, any>`) needs NO branch: it falls through to the trailing `NC` and composes
70
+ * correctly. Adding a branch for it (even `FirstT extends X ? NC : ...`) deepens every step and
71
+ * lowers the ~85 ceiling.
72
+ *
73
+ * @template {Array<Template>} TS
74
+ * @template NC
75
+ * @typedef {TS extends [infer FirstT extends Template, ...infer RestT extends Template[]]
76
+ * ? (NC extends { name: infer Name, attrs: infer Attrs extends {[K:string|number]:any}, children: infer Children, text: infer Text, recursiveChildren: infer RecursiveChildren, recursiveAttrs: infer RecursiveAttrs }
77
+ * ? ApplyPipeNorm<RestT,
78
+ * FirstT extends AttrRename<infer Renames> ? { name: Name, attrs: import('../../ts.js').PropsRename<Attrs extends NotSet ? {} : Attrs, Renames>, children: Children, text: Text, recursiveChildren: RecursiveChildren, recursiveAttrs: RecursiveAttrs } :
79
+ * FirstT extends Filter<infer DConf extends delta.DeltaConf> ? (NormalizeDeltaConf<DConf> extends { name: infer FilterName, attrs: infer FilterAttrs, children: infer FilterChildren, text: infer FilterText, recursiveChildren: infer FilterRecursiveChildren, recursiveAttrs: infer FilterRecursiveAttrs } ? {
80
+ * name: FilterConfProp<FilterName, Name>,
81
+ * attrs: FilterAttrs extends NotSet ? NotSet : Attrs extends NotSet ? NotSet : import('../../ts.js').PropsPickShared<FilterAttrs, Attrs>,
82
+ * children: FilterConfProp<FilterChildren, Children>,
83
+ * text: FilterConfProp<FilterText, Text>,
84
+ * recursiveChildren: FilterConfProp<FilterRecursiveChildren, RecursiveChildren>,
85
+ * recursiveAttrs: FilterConfProp<FilterRecursiveAttrs, RecursiveAttrs>
86
+ * } : never) :
87
+ * NC>
88
+ * : NC)
89
+ * : NC} ApplyPipeNorm
90
+ */
91
+ /**
92
+ * @template {Array<Template>} TS
93
+ * @template {delta.DeltaConf} IN
94
+ * @typedef {DenormalizeDeltaConf<ApplyPipeNorm<TS, NormalizeDeltaConf<IN>>>} ApplyPipe
95
+ */
96
+ /**
97
+ * Flattens nested Pipe instances into a single flat Template array.
98
+ * Since pipe() always produces flat Pipes, Inner is already flat and
99
+ * only one level of unwrapping is needed per Pipe element.
100
+ * Tail-recursive with an accumulator so the instantiation depth stays constant.
101
+ *
102
+ * @template {Array<Template>} TS
103
+ * @template {Array<Template>} [Acc=[]]
104
+ * @typedef {TS extends [infer F extends Template, ...infer R extends Template[]]
105
+ * ? FlattenTemplates<R, F extends Pipe<infer Inner extends Template[]> ? [...Acc, ...Inner] : [...Acc, F]>
106
+ * : Acc} FlattenTemplates
107
+ */
108
+ /**
109
+ * Chain multiple Templates together.
110
+ *
111
+ * @template {Template[]} TS
112
+ * @implements Template
113
+ */
114
+ export class Pipe<TS extends Template[]> implements Template {
115
+ /**
116
+ * @param {TS} templates
117
+ */
118
+ constructor(templates: TS);
119
+ /**
120
+ * @type {TS}
121
+ */
122
+ templates: TS;
123
+ stateless: boolean;
124
+ /**
125
+ * @type {PipeTransformer<any,any,this>?}
126
+ */
127
+ statelessTransformer: PipeTransformer<any, any, this> | null;
128
+ /**
129
+ * @template {delta.DeltaConf} IN
130
+ * @param {import('../../schema.js').Schema<delta.Delta<IN>>} _$d
131
+ * @return {Transformer<IN, ApplyPipe<TS, IN>>}
132
+ */
133
+ init<IN extends delta.DeltaConf>(_$d: import("../../schema.js").Schema<delta.Delta<IN>>): Transformer<IN, ApplyPipe<TS, IN>>;
134
+ }
135
+ /**
136
+ * @template {delta.DeltaConf} A
137
+ * @template {delta.DeltaConf} B
138
+ * @template {Pipe<any>} PipeTemplate
139
+ * @extends {Transformer<A,B>}
140
+ */
141
+ export class PipeTransformer<A extends delta.DeltaConf, B extends delta.DeltaConf, PipeTemplate extends Pipe<any>> extends Transformer<A, B> {
142
+ /**
143
+ * @param {PipeTemplate} tpipe
144
+ */
145
+ constructor(tpipe: PipeTemplate);
146
+ tpipe: PipeTemplate;
147
+ /**
148
+ * @type {Transformer<any,any>[]}
149
+ */
150
+ ts: Transformer<any, any>[];
151
+ /**
152
+ * @param {import('./core.js').TransformResultAny} tin
153
+ * @return {import('./core.js').TransformResultAny}
154
+ */
155
+ apply(tin: import("./core.js").TransformResultAny): import("./core.js").TransformResultAny;
156
+ }
157
+ export function pipe<Ts extends Array<Template>>(...ts: Ts): Pipe<FlattenTemplates<Ts>>;
158
+ export type Template = import("./core.js").Template;
159
+ /**
160
+ * Marker for absent props in a NormalizedDeltaConf.
161
+ */
162
+ export type NotSet = {
163
+ "lib0:notset": true;
164
+ };
165
+ /**
166
+ * DeltaConf in normalized form: all props defined, absent props are set to NotSet.
167
+ *
168
+ * ApplyPipe iterates over this form (see ApplyPipeNorm).
169
+ */
170
+ export type NormalizedDeltaConf<Name, Attrs, Children, Text, RecursiveChildren, RecursiveAttrs> = {
171
+ name: Name;
172
+ attrs: Attrs;
173
+ children: Children;
174
+ text: Text;
175
+ recursiveChildren: RecursiveChildren;
176
+ recursiveAttrs: RecursiveAttrs;
177
+ };
178
+ export type NormalizeDeltaConf<C extends delta.DeltaConf> = NormalizedDeltaConf<C extends {
179
+ name: infer Name extends string;
180
+ } ? Name : NotSet, C extends {
181
+ attrs: infer Attrs extends {
182
+ [K: string | number]: any;
183
+ };
184
+ } ? Attrs : NotSet, C extends {
185
+ children: infer Children;
186
+ } ? Children : NotSet, C extends {
187
+ text: infer Text extends boolean;
188
+ } ? Text : NotSet, C extends {
189
+ recursiveChildren: infer RecursiveChildren extends boolean;
190
+ } ? RecursiveChildren : NotSet, C extends {
191
+ recursiveAttrs: infer RecursiveAttrs extends boolean;
192
+ } ? RecursiveAttrs : NotSet>;
193
+ /**
194
+ * Strip NotSet props from a NormalizedDeltaConf, producing a regular DeltaConf again.
195
+ */
196
+ export type DenormalizeDeltaConf<NC> = { [K in keyof NC as NC[K] extends NotSet ? never : K]: NC[K]; } & {};
197
+ /**
198
+ * Intersect a prop of a Filter conf with the corresponding pipe conf prop. The prop is only kept
199
+ * if it is defined on both sides (mirrors ApplyExpectType).
200
+ */
201
+ export type FilterConfProp<FilterProp, PipeProp> = FilterProp extends NotSet ? NotSet : PipeProp extends NotSet ? NotSet : FilterProp & PipeProp;
202
+ /**
203
+ * Apply each Template to a NormalizedDeltaConf - must mirror the semantics of ApplyAttrRename /
204
+ * ApplyExpectType.
205
+ *
206
+ * This shape is tuned to stay below typescript's instantiation-depth limit (TS2589) for long
207
+ * pipes (~85 templates via pipe().init(), measured). What we learned:
208
+ *
209
+ * - The per-step destructure of NC is the load-bearing part: typescript resolves types lazily,
210
+ * and member inference out of the literal that was passed as a type argument in the previous
211
+ * step is what forces resolution of the accumulated conf. Without it (e.g. carrying the conf
212
+ * props as individual type params), the attrs accumulate as a deferred PropsRename chain and
213
+ * the limit hits at ~45 templates. Local annotations do NOT force resolution: `X & {}`,
214
+ * `X extends infer N ? ...`, and an inline `{ attrs: X } extends { attrs: infer A } ? ...`
215
+ * roundtrip were all measured to have no effect.
216
+ * - The recursion must carry a plain object literal. Wrapping the accumulator in a helper alias
217
+ * (even a trivial one like NormalizedDeltaConf) defers per step and rebuilds the chain.
218
+ * - The outer check must be on TS alone. Coupling NC into the check type (e.g.
219
+ * `[TS, NC] extends [[...], {...}]`) makes the conditional generic-deferred whenever the conf
220
+ * is generic, which sends constraint comparisons (e.g. Pipe<TS> vs Pipe<any>) into infinite
221
+ * recursion.
222
+ * - Each dispatch branch costs instantiation depth. A conf-passthrough template (one whose output
223
+ * conf equals its input conf, e.g. transformer/inline, whose init() is typed loosely as
224
+ * `Transformer<IN, any>`) needs NO branch: it falls through to the trailing `NC` and composes
225
+ * correctly. Adding a branch for it (even `FirstT extends X ? NC : ...`) deepens every step and
226
+ * lowers the ~85 ceiling.
227
+ */
228
+ export type ApplyPipeNorm<TS extends Array<Template>, NC> = TS extends [infer FirstT extends Template, ...infer RestT extends Template[]] ? (NC extends {
229
+ name: infer Name;
230
+ attrs: infer Attrs extends {
231
+ [K: string | number]: any;
232
+ };
233
+ children: infer Children;
234
+ text: infer Text;
235
+ recursiveChildren: infer RecursiveChildren;
236
+ recursiveAttrs: infer RecursiveAttrs;
237
+ } ? ApplyPipeNorm<RestT, FirstT extends AttrRename<infer Renames> ? {
238
+ name: Name;
239
+ attrs: import("../../ts.js").PropsRename<Attrs extends NotSet ? {} : Attrs, Renames>;
240
+ children: Children;
241
+ text: Text;
242
+ recursiveChildren: RecursiveChildren;
243
+ recursiveAttrs: RecursiveAttrs;
244
+ } : FirstT extends Filter<infer DConf extends delta.DeltaConf> ? (NormalizeDeltaConf<DConf> extends {
245
+ name: infer FilterName;
246
+ attrs: infer FilterAttrs;
247
+ children: infer FilterChildren;
248
+ text: infer FilterText;
249
+ recursiveChildren: infer FilterRecursiveChildren;
250
+ recursiveAttrs: infer FilterRecursiveAttrs;
251
+ } ? {
252
+ name: FilterConfProp<FilterName, Name>;
253
+ attrs: FilterAttrs extends NotSet ? NotSet : Attrs extends NotSet ? NotSet : import("../../ts.js").PropsPickShared<FilterAttrs, Attrs>;
254
+ children: FilterConfProp<FilterChildren, Children>;
255
+ text: FilterConfProp<FilterText, Text>;
256
+ recursiveChildren: FilterConfProp<FilterRecursiveChildren, RecursiveChildren>;
257
+ recursiveAttrs: FilterConfProp<FilterRecursiveAttrs, RecursiveAttrs>;
258
+ } : never) : NC> : NC) : NC;
259
+ export type ApplyPipe<TS extends Array<Template>, IN extends delta.DeltaConf> = DenormalizeDeltaConf<ApplyPipeNorm<TS, NormalizeDeltaConf<IN>>>;
260
+ /**
261
+ * Flattens nested Pipe instances into a single flat Template array.
262
+ * Since pipe() always produces flat Pipes, Inner is already flat and
263
+ * only one level of unwrapping is needed per Pipe element.
264
+ * Tail-recursive with an accumulator so the instantiation depth stays constant.
265
+ */
266
+ export type FlattenTemplates<TS extends Array<Template>, Acc extends Array<Template> = []> = TS extends [infer F extends Template, ...infer R extends Template[]] ? FlattenTemplates<R, F extends Pipe<infer Inner extends Template[]> ? [...Acc, ...Inner] : [...Acc, F]> : Acc;
267
+ import * as delta from '../delta.js';
268
+ import { Transformer } from './core.js';
269
+ import { AttrRename } from './rename.js';
270
+ import { Filter } from './filter.js';
271
+ //# sourceMappingURL=pipe.d.ts.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Projects an input delta onto a fixed node shape, optionally filling attributes/children from nested
3
+ * transformers (those whose value is a {@link Transformer} instance) and constants otherwise.
4
+ *
5
+ * @template {delta.DeltaConf} A
6
+ * @template {delta.DeltaConf} B
7
+ * @extends {Transformer<A,B>}
8
+ */
9
+ export class ProjectionTransformer<A extends delta.DeltaConf, B extends delta.DeltaConf> extends Transformer<A, B> {
10
+ /**
11
+ * @param {string} name
12
+ * @param {{ [K in string|number]: any }} attrs
13
+ * @param {Array<Array<any> | string>} children
14
+ */
15
+ constructor(name: string, attrs: { [K in string | number]: any; }, children: Array<Array<any> | string>);
16
+ /**
17
+ * @type {delta.DeltaBuilderAny|null}
18
+ */
19
+ initOut: delta.DeltaBuilderAny | null;
20
+ ts: {
21
+ key: number | string;
22
+ t: Transformer<any, any>;
23
+ }[];
24
+ /**
25
+ * @param {import('./core.js').TransformResultAny} tin
26
+ * @return {import('./core.js').TransformResultAny}
27
+ */
28
+ apply(tin: import("./core.js").TransformResultAny): import("./core.js").TransformResultAny;
29
+ }
30
+ export function projection(name: string, attrs: { [K in string | number]: any; }, children: Array<Array<any> | string>): ProjectionTransformer<delta.DeltaConf, delta.DeltaConf>;
31
+ import * as delta from '../delta.js';
32
+ import { Transformer } from './core.js';
33
+ //# sourceMappingURL=projection.d.ts.map
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Projects a single node attribute into a `lib0:value` node's `value` attribute (and back).
3
+ *
4
+ * @template {string} AttrName
5
+ * @implements Template
6
+ */
7
+ export class QueryAttr<AttrName extends string> implements Template {
8
+ /**
9
+ * @param {AttrName} attrName
10
+ */
11
+ constructor(attrName: AttrName);
12
+ attrName: AttrName;
13
+ get stateless(): boolean;
14
+ /**
15
+ * @template {delta.DeltaConf} IN
16
+ * @param {import('../../schema.js').Schema<delta.Delta<IN>>} _$d
17
+ * @return {Transformer<IN, ApplyQueryAttr<AttrName, IN>>}
18
+ */
19
+ init<IN extends delta.DeltaConf>(_$d: import("../../schema.js").Schema<delta.Delta<IN>>): Transformer<IN, ApplyQueryAttr<AttrName, IN>>;
20
+ }
21
+ /**
22
+ * @template {delta.DeltaConf} A
23
+ * @template {delta.DeltaConf} B
24
+ * @extends {Transformer<A,B>}
25
+ */
26
+ export class QueryAttrTransformer<A extends delta.DeltaConf, B extends delta.DeltaConf> extends Transformer<A, B> {
27
+ /**
28
+ * @param {string} attrName
29
+ */
30
+ constructor(attrName: string);
31
+ attrName: keyof import("../../ts.js").TypeIsAny<A, {
32
+ [K: string]: any;
33
+ [K: number]: any;
34
+ }, A extends {
35
+ attrs: infer Attrs;
36
+ } ? Attrs extends undefined ? {} : Attrs : {}> & (string | number);
37
+ /**
38
+ * @param {delta.DeltaBuilder<A>} d
39
+ * @return {import('./core.js').TransformResultAny}
40
+ */
41
+ applyA(d: delta.DeltaBuilder<A>): import("./core.js").TransformResultAny;
42
+ /**
43
+ * @param {delta.DeltaBuilder<B>} d
44
+ * @return {import('./core.js').TransformResultAny}
45
+ */
46
+ applyB(d: delta.DeltaBuilder<B>): import("./core.js").TransformResultAny;
47
+ }
48
+ export function query<AttrName extends string>(attrName: AttrName): QueryAttr<AttrName>;
49
+ export type Template = import("./core.js").Template;
50
+ export type ApplyQueryAttr<AttrName extends string, IN extends delta.DeltaConf> = {
51
+ name: "lib0:value";
52
+ attrs: {
53
+ value: IN extends {
54
+ attrs: { [K in AttrName]: infer V; };
55
+ } ? V : never;
56
+ };
57
+ };
58
+ import * as delta from '../delta.js';
59
+ import { Transformer } from './core.js';
60
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Renames node attributes (`a` -> `b`) in both directions.
3
+ *
4
+ * @template {{[K:string|number]:string|number}} Renames
5
+ * @implements Template
6
+ * @extends Transformer<any,any>
7
+ */
8
+ export class AttrRename<Renames extends {
9
+ [K: string | number]: string | number;
10
+ }> extends Transformer<any, any> implements Template {
11
+ /**
12
+ * @param {Renames} renames
13
+ */
14
+ constructor(renames: Renames);
15
+ arenames: Renames;
16
+ /**
17
+ * @type {{[K:string|number]:string|number}}
18
+ */
19
+ brenames: {
20
+ [K: string | number]: string | number;
21
+ };
22
+ get stateless(): boolean;
23
+ /**
24
+ * @template {delta.DeltaConf} IN
25
+ * @param {import('../../schema.js').Schema<delta.Delta<IN>>} _$d
26
+ * @return {Transformer<IN,ApplyAttrRename<Renames,IN>>}
27
+ */
28
+ init<IN extends delta.DeltaConf>(_$d: import("../../schema.js").Schema<delta.Delta<IN>>): Transformer<IN, ApplyAttrRename<Renames, IN>>;
29
+ /**
30
+ * @param {delta.DeltaAny} deltaA
31
+ * @return {import('./core.js').TransformResultAny}
32
+ */
33
+ applyA(deltaA: delta.DeltaAny): import("./core.js").TransformResultAny;
34
+ /**
35
+ * @param {delta.DeltaAny} deltaB
36
+ * @return {import('./core.js').TransformResultAny}
37
+ */
38
+ applyB(deltaB: delta.DeltaAny): import("./core.js").TransformResultAny;
39
+ }
40
+ export function rename<Renames extends {
41
+ [K: string | number]: string | number;
42
+ }>(renames: Renames): AttrRename<Renames>;
43
+ export type Template = import("./core.js").Template;
44
+ export type ApplyAttrRename<Renames extends {
45
+ [K: string | number]: string | number;
46
+ }, IN extends delta.DeltaConf> = delta.DeltaConfOverwrite<IN, {
47
+ attrs: import("../../ts.js").PropsRename<delta.DeltaConfGetAttrs<IN>, Renames>;
48
+ }>;
49
+ import { Transformer } from './core.js';
50
+ import * as delta from '../delta.js';
51
+ //# sourceMappingURL=rename.d.ts.map