lib0 1.0.0-rc.2 → 1.0.0-rc.21

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.
Files changed (141) hide show
  1. package/README.md +0 -1315
  2. package/{types → dist}/buffer.d.ts +2 -10
  3. package/{types → dist}/delta/delta.d.ts +582 -144
  4. package/dist/delta/position.d.ts +65 -0
  5. package/dist/delta/rdt/delta.d.ts +57 -0
  6. package/dist/delta/rdt/dom.d.ts +102 -0
  7. package/dist/delta/rdt.d.ts +180 -0
  8. package/dist/delta/transformer/attr.d.ts +64 -0
  9. package/dist/delta/transformer/attribution-to-format.d.ts +52 -0
  10. package/dist/delta/transformer/children.d.ts +69 -0
  11. package/dist/delta/transformer/conform.d.ts +83 -0
  12. package/dist/delta/transformer/core.d.ts +189 -0
  13. package/dist/delta/transformer/full-attributions.d.ts +37 -0
  14. package/dist/delta/transformer/id.d.ts +2 -0
  15. package/dist/delta/transformer/inline.d.ts +89 -0
  16. package/dist/delta/transformer/pipe.d.ts +182 -0
  17. package/dist/delta/transformer/project.d.ts +223 -0
  18. package/dist/delta/transformer/rename-attrs.d.ts +75 -0
  19. package/dist/delta/transformer/rename.d.ts +41 -0
  20. package/dist/delta/transformer/value.d.ts +92 -0
  21. package/dist/delta/transformer.d.ts +14 -0
  22. package/dist/diff/patience.d.ts +25 -0
  23. package/{types → dist}/environment.d.ts +10 -0
  24. package/dist/hash/fnv1a.d.ts +11 -0
  25. package/{types → dist}/schema.d.ts +49 -38
  26. package/{types → dist}/ts.d.ts +4 -0
  27. package/dist/webcrypto.d.ts +3 -0
  28. package/package.json +148 -82
  29. package/src/bin/0serve.js +11 -3
  30. package/src/broadcastchannel.js +6 -1
  31. package/src/buffer.js +35 -25
  32. package/src/decoding.js +1 -1
  33. package/src/delta/delta.js +2531 -564
  34. package/src/delta/position.js +165 -0
  35. package/src/delta/rdt/delta.js +105 -0
  36. package/src/delta/rdt/dom.js +307 -0
  37. package/src/delta/rdt.js +255 -0
  38. package/src/delta/transformer/attr.js +126 -0
  39. package/src/delta/transformer/attribution-to-format.js +335 -0
  40. package/src/delta/transformer/children.js +219 -0
  41. package/src/delta/transformer/conform.js +401 -0
  42. package/src/delta/transformer/core.js +323 -0
  43. package/src/delta/transformer/full-attributions.js +282 -0
  44. package/src/delta/transformer/id.js +13 -0
  45. package/src/delta/transformer/inline.js +818 -0
  46. package/src/delta/transformer/pipe.js +272 -0
  47. package/src/delta/transformer/project.js +526 -0
  48. package/src/delta/transformer/rename-attrs.js +152 -0
  49. package/src/delta/transformer/rename.js +84 -0
  50. package/src/delta/transformer/value.js +214 -0
  51. package/src/delta/transformer.js +38 -0
  52. package/src/diff/patience.js +22 -11
  53. package/src/dom.js +2 -2
  54. package/src/encoding.js +1 -1
  55. package/src/environment.js +15 -0
  56. package/src/hash/fnv1a.js +82 -0
  57. package/src/number.js +1 -3
  58. package/src/performance.node.js +3 -3
  59. package/src/schema.js +231 -177
  60. package/src/string.js +3 -5
  61. package/src/testing.js +1 -1
  62. package/src/trait/equality.js +1 -1
  63. package/src/trait/fingerprint.js +1 -1
  64. package/src/ts.js +11 -0
  65. package/src/bin/gendocs.js +0 -117
  66. package/src/component.js +0 -414
  67. package/src/delta/binding.js +0 -372
  68. package/src/tree.js +0 -546
  69. package/types/bin/gendocs.d.ts +0 -3
  70. package/types/component.d.ts +0 -86
  71. package/types/delta/binding.d.ts +0 -106
  72. package/types/diff/patience.d.ts +0 -16
  73. package/types/tree.d.ts +0 -96
  74. package/types/webcrypto.d.ts +0 -3
  75. /package/{types → dist}/array.d.ts +0 -0
  76. /package/{types → dist}/bin/0ecdsa-generate-keypair.d.ts +0 -0
  77. /package/{types → dist}/bin/0serve.d.ts +0 -0
  78. /package/{types → dist}/bin/gentesthtml.d.ts +0 -0
  79. /package/{types → dist}/binary.d.ts +0 -0
  80. /package/{types → dist}/broadcastchannel.d.ts +0 -0
  81. /package/{types → dist}/cache.d.ts +0 -0
  82. /package/{types → dist}/conditions.d.ts +0 -0
  83. /package/{types → dist}/crypto/aes-gcm.d.ts +0 -0
  84. /package/{types → dist}/crypto/common.d.ts +0 -0
  85. /package/{types → dist}/crypto/ecdsa.d.ts +0 -0
  86. /package/{types → dist}/crypto/jwt.d.ts +0 -0
  87. /package/{types → dist}/crypto/rsa-oaep.d.ts +0 -0
  88. /package/{types → dist}/decoding.d.ts +0 -0
  89. /package/{types → dist}/diff.d.ts +0 -0
  90. /package/{types → dist}/dom.d.ts +0 -0
  91. /package/{types → dist}/encoding.d.ts +0 -0
  92. /package/{types → dist}/error.d.ts +0 -0
  93. /package/{types → dist}/eventloop.d.ts +0 -0
  94. /package/{types → dist}/function.d.ts +0 -0
  95. /package/{types → dist}/hash/rabin-gf2-polynomial.d.ts +0 -0
  96. /package/{types → dist}/hash/rabin-uncached.d.ts +0 -0
  97. /package/{types → dist}/hash/rabin.d.ts +0 -0
  98. /package/{types → dist}/hash/sha256.d.ts +0 -0
  99. /package/{types → dist}/hash/sha256.node.d.ts +0 -0
  100. /package/{types → dist}/indexeddb.d.ts +0 -0
  101. /package/{types → dist}/indexeddbV2.d.ts +0 -0
  102. /package/{types → dist}/iterator.d.ts +0 -0
  103. /package/{types → dist}/json.d.ts +0 -0
  104. /package/{types → dist}/list.d.ts +0 -0
  105. /package/{types → dist}/logging.common.d.ts +0 -0
  106. /package/{types → dist}/logging.d.ts +0 -0
  107. /package/{types → dist}/logging.node.d.ts +0 -0
  108. /package/{types → dist}/map.d.ts +0 -0
  109. /package/{types → dist}/math.d.ts +0 -0
  110. /package/{types → dist}/metric.d.ts +0 -0
  111. /package/{types → dist}/mutex.d.ts +0 -0
  112. /package/{types → dist}/number.d.ts +0 -0
  113. /package/{types → dist}/object.d.ts +0 -0
  114. /package/{types → dist}/observable.d.ts +0 -0
  115. /package/{types → dist}/pair.d.ts +0 -0
  116. /package/{types → dist}/performance.d.ts +0 -0
  117. /package/{types → dist}/performance.node.d.ts +0 -0
  118. /package/{types → dist}/pledge.d.ts +0 -0
  119. /package/{types → dist}/prng/Mt19937.d.ts +0 -0
  120. /package/{types → dist}/prng/Xoroshiro128plus.d.ts +0 -0
  121. /package/{types → dist}/prng/Xorshift32.d.ts +0 -0
  122. /package/{types → dist}/prng.d.ts +0 -0
  123. /package/{types → dist}/promise.d.ts +0 -0
  124. /package/{types → dist}/queue.d.ts +0 -0
  125. /package/{types → dist}/random.d.ts +0 -0
  126. /package/{types → dist}/set.d.ts +0 -0
  127. /package/{types → dist}/sort.d.ts +0 -0
  128. /package/{types → dist}/statistics.d.ts +0 -0
  129. /package/{types → dist}/storage.d.ts +0 -0
  130. /package/{types → dist}/string.d.ts +0 -0
  131. /package/{types → dist}/symbol.d.ts +0 -0
  132. /package/{types → dist}/testing.d.ts +0 -0
  133. /package/{types → dist}/time.d.ts +0 -0
  134. /package/{types → dist}/trait/equality.d.ts +0 -0
  135. /package/{types → dist}/trait/fingerprint.d.ts +0 -0
  136. /package/{types → dist}/trait/traits.d.ts +0 -0
  137. /package/{types → dist}/url.d.ts +0 -0
  138. /package/{types → dist}/webcrypto.deno.d.ts +0 -0
  139. /package/{types → dist}/webcrypto.node.d.ts +0 -0
  140. /package/{types → dist}/webcrypto.react-native.d.ts +0 -0
  141. /package/{types → dist}/websocket.d.ts +0 -0
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Makes the projected (side-B) delta conform to `$schema`, **recursively**: drops attributes, attribute
3
+ * values, child nodes, and text the schema does not recognize, and descends into kept delta-valued
4
+ * attributes and kept child nodes with a nested `conform` (a fresh instance per kept child/attr, kept in
5
+ * step with the content — modelled on `children` + `inline`). A child is kept iff its node-name matches
6
+ * one of the schema's child `$Delta`s; a non-delta child iff it validates against `$children`; text iff
7
+ * the schema allows text. Everything else is dropped, so the output is guaranteed to satisfy `$schema`.
8
+ *
9
+ * Content that needs no per-position handling (text, scalars, and nodes matched by a `$deltaAny`/`$any`
10
+ * schema) is coalesced into pass-through runs, so a `$deltaAny` schema is a true zero-overhead identity
11
+ * and an incremental edit costs O(change), not O(document).
12
+ *
13
+ * `applyA` (A → B) does the full recursive filtering. `applyB` (B → A) is a lightweight reverse: it
14
+ * validates each B-side op against `$schema` — throwing on any op that would break conformance — and
15
+ * otherwise passes the change through to A verbatim (a conformant B-edit is already valid on A). Full
16
+ * drop-aware B→A position remapping is deferred (see {@link ConformTransformer#applyB}).
17
+ * Marks are best-effort — marks on kept children/attrs ride through the position map; marks anchored to
18
+ * dropped content are dropped.
19
+ *
20
+ * @template {delta.DeltaConf} SchemaConf
21
+ * @template {delta.DeltaConf} [IN=any]
22
+ * @extends {Template<IN, SchemaConf>}
23
+ */
24
+ export class Conform<SchemaConf extends delta.DeltaConf, IN extends delta.DeltaConf = any> extends Template<IN, SchemaConf> {
25
+ /**
26
+ * @param {import('../../schema.js').Schema<delta.Delta<IN>>} $d input delta schema
27
+ * @param {import('../../schema.js').Schema<delta.Delta<SchemaConf>>} $schema the schema the output must match
28
+ */
29
+ constructor($d: import("../../schema.js").Schema<delta.Delta<IN>>, $schema: import("../../schema.js").Schema<delta.Delta<SchemaConf>>);
30
+ $schema: s.Schema<delta.Delta<SchemaConf>>;
31
+ config: Config;
32
+ }
33
+ /**
34
+ * Stateful, recursive transformer produced by {@link Conform}. See {@link Conform} for semantics.
35
+ *
36
+ * The A→B layout lives in {@link ConformTransformer#cmap} (the *child* map), a delta reused as a
37
+ * coalesced positional map (like `children`'s `childTs`): a `retain(n)` run = pass-through positions, an
38
+ * `insert([t])` = a child routed through nested conform `t`, a `delete(n)` run = dropped positions
39
+ * (width 0 on B). It is rebuilt only on a structural change, carrying the nested transformers by
40
+ * reference so their state survives; a change with only retains/modifies is routed in place.
41
+ *
42
+ * @extends {Transformer<any,any>}
43
+ */
44
+ export class ConformTransformer extends Transformer<any, any> {
45
+ /**
46
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $in
47
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $out
48
+ * @param {Config} config the schema-derived read-only config (computed once, see {@link configOf})
49
+ */
50
+ constructor($in: import("../../schema.js").Schema<delta.Delta<any>>, $out: import("../../schema.js").Schema<delta.Delta<any>>, config: Config);
51
+ config: Config;
52
+ /** @type {delta.DeltaBuilderAny} the coalesced child layout map */
53
+ cmap: delta.DeltaBuilderAny;
54
+ /** @type {Map<string|number, ConformTransformer>} nested conforms for delta-valued attributes */
55
+ transformAttrs: Map<string | number, ConformTransformer>;
56
+ }
57
+ export function conform<IN extends delta.DeltaConf, SchemaConf extends delta.DeltaConf>($d: import("../../schema.js").Schema<delta.Delta<IN>>, $schema: import("../../schema.js").Schema<delta.Delta<SchemaConf>>): Conform<SchemaConf, IN>;
58
+ /**
59
+ * The expanded matcher for a children / attr-value schema.
60
+ */
61
+ export type Allowed = {
62
+ byName: Map<string, delta.$Delta<any>>;
63
+ wild: delta.$Delta<any> | null;
64
+ passAny: boolean;
65
+ $scalar: import("../../schema.js").Schema<any>;
66
+ };
67
+ /**
68
+ * The read-only, schema-derived configuration of a conform transformer. Computed once per schema (see
69
+ * {@link configOf}) and shared by every transformer instance built from that schema — many instances are
70
+ * created for the children of one schema, so this avoids re-expanding the schema each time.
71
+ */
72
+ export type Config = {
73
+ passthrough: boolean;
74
+ hasText: boolean;
75
+ childAllowed: Allowed;
76
+ attrsLoose: boolean;
77
+ attrAllowed: Map<string | number, Allowed>;
78
+ };
79
+ import * as delta from '../delta.js';
80
+ import { Template } from './core.js';
81
+ import * as s from '../../schema.js';
82
+ import { Transformer } from './core.js';
83
+ //# sourceMappingURL=conform.d.ts.map
@@ -0,0 +1,189 @@
1
+ export function $tresult<A extends import("../delta.js").DeltaConf, B extends import("../delta.js").DeltaConf>($a: s.Schema<import("../delta.js").Delta<A>>, $b: s.Schema<import("../delta.js").Delta<B>>): s.Schema<TransformResult<A, B>>;
2
+ export function createTransformResult<DeltaA extends import("../delta.js").DeltaBuilderAny = delta.DeltaBuilderAny, DeltaB extends import("../delta.js").DeltaBuilderAny = delta.DeltaBuilderAny>(a: DeltaA | null, b: DeltaB | null): TransformResult<any, any>;
3
+ /**
4
+ * A stateful, schema-bound mapper between changes of side A and side B, materialized from a
5
+ * {@link Template} via `init()`.
6
+ *
7
+ * ## Deltas are manipulated in place
8
+ *
9
+ * `apply`/`applyA`/`applyB` **mutate their input deltas directly** — they rebase nodes and splice op
10
+ * lists in place, and some transformers `apply(other, { move: true })` the input into an accumulator —
11
+ * rather than editing only through the copy-on-write `apply`/`rebase` surface. This is a deliberate
12
+ * exception to the general rule (a delta is normally edited only via `apply`/`rebase`, which re-clone
13
+ * frozen content on first touch); it keeps the transform allocation-free, but it means a transformer is
14
+ * an *owning* consumer of the delta it is given. **Callers must pass a privately-owned, fully-mutable
15
+ * delta** — never a shared or `done` (frozen) one. A caller holding a shared read delta must
16
+ * {@link import('../delta.js').cloneDeep deep-clone} it first (this is exactly what a
17
+ * {@link import('../rdt.js').Binding} does before routing a change through its transformer).
18
+ *
19
+ * @template {import('../delta.js').DeltaConf} A
20
+ * @template {import('../delta.js').DeltaConf} B
21
+ */
22
+ export class Transformer<A extends import("../delta.js").DeltaConf, B extends import("../delta.js").DeltaConf> {
23
+ /**
24
+ * @param {s.Schema<import('../delta.js').Delta<A>>} $in input delta schema
25
+ * @param {s.Schema<import('../delta.js').Delta<B>>} $out output delta schema (computed by the factory)
26
+ */
27
+ constructor($in: s.Schema<import("../delta.js").Delta<A>>, $out: s.Schema<import("../delta.js").Delta<B>>);
28
+ /**
29
+ * @type {s.Schema<import('../delta.js').Delta<A>>}
30
+ */
31
+ $in: s.Schema<import("../delta.js").Delta<A>>;
32
+ /**
33
+ * @type {s.Schema<import('../delta.js').Delta<B>>}
34
+ */
35
+ $out: s.Schema<import("../delta.js").Delta<B>>;
36
+ /**
37
+ * @param {TransformResult<A, B>} tin
38
+ * @return {TransformResult<A,B>}
39
+ */
40
+ apply(tin: TransformResult<A, B>): TransformResult<A, B>;
41
+ /**
42
+ * @param {import('../delta.js').DeltaBuilder<A>} t
43
+ * @return {TransformResult<A,B>}
44
+ */
45
+ applyA(t: import("../delta.js").DeltaBuilder<A>): TransformResult<A, B>;
46
+ /**
47
+ * @param {import('../delta.js').DeltaBuilder<B>} t
48
+ * @return {TransformResult<A,B>}
49
+ */
50
+ applyB(t: import("../delta.js").DeltaBuilder<B>): TransformResult<A, B>;
51
+ $type: s.Schema<Transformer<any, any>>;
52
+ }
53
+ /**
54
+ * Recognize a {@link Transformer} by its `$type` tag. Every value is either a `Transformer` or a
55
+ * {@link Template}, never both, so the two roles can each own a single prototype `$type`.
56
+ *
57
+ * @type {s.Schema<Transformer<any,any>>}
58
+ */
59
+ export const $transformer: s.Schema<Transformer<any, any>>;
60
+ export function transformerWith<A extends import("../delta.js").DeltaConf, B extends import("../delta.js").DeltaConf>(_a: s.Schema<import("../delta.js").Delta<A>> | A, _b: s.Schema<import("../delta.js").Delta<B>> | A): s.Schema<Transformer<A, B>>;
61
+ /**
62
+ * A function from an input delta schema to a {@link Template} — the schema-deferred form of a
63
+ * transformer factory. Used for `pipe` stages, recursive composition, and `bind`.
64
+ *
65
+ * @template {import('../delta.js').DeltaConf} In
66
+ * @template {import('../delta.js').DeltaConf} Out
67
+ * @typedef {($in: s.Schema<import('../delta.js').Delta<In>>) => Template<In, Out>} TemplateFactory
68
+ */
69
+ /**
70
+ * Force a factory's computed output conf to display fully-resolved (flatten `Omit<…> & {…}` / bare
71
+ * alias artifacts) while staying a valid `DeltaConf` for use as a `Transformer`/`Delta` type
72
+ * argument — conf-aware and depth-limited (nested `Delta<…>` stay intact). Implemented as an
73
+ * overwrite-with-nothing, reusing {@link import('../delta.js').DeltaConfOverwrite}'s
74
+ * prettify+coerce recipe. Apply to every factory's `OUT` typedef whose result is not already
75
+ * produced by `DeltaConfOverwrite`.
76
+ *
77
+ * @template {import('../delta.js').DeltaConf} Conf
78
+ * @typedef {import('../delta.js').DeltaConfOverwrite<Conf, {}>} ResolveOut
79
+ */
80
+ /**
81
+ * The reusable, schema-bound form of a transformer: built by a factory (`attr($d, …)`), it holds the
82
+ * input/output delta schemas (`$in`/`$out`) and materializes a fresh stateful {@link Transformer} via
83
+ * the parameterless `init()`. Concrete templates `extend Template`.
84
+ *
85
+ * Templates are {@link fingerprintTrait.Fingerprintable}: this is what lets them be embedded as values
86
+ * (holes) in a `delta.create(...)` projection spec without collapsing the spec's type.
87
+ *
88
+ * @template {import('../delta.js').DeltaConf} [IN=any]
89
+ * @template {import('../delta.js').DeltaConf} [OUT=any]
90
+ */
91
+ export class Template<IN extends import("../delta.js").DeltaConf = any, OUT extends import("../delta.js").DeltaConf = any> {
92
+ /**
93
+ * @param {s.Schema<import('../delta.js').Delta<IN>>} $in input delta schema
94
+ * @param {s.Schema<import('../delta.js').Delta<OUT>>} $out output delta schema (computed by the factory)
95
+ */
96
+ constructor($in: s.Schema<import("../delta.js").Delta<IN>>, $out: s.Schema<import("../delta.js").Delta<OUT>>);
97
+ /**
98
+ * @type {s.Schema<import('../delta.js').Delta<IN>>}
99
+ */
100
+ $in: s.Schema<import("../delta.js").Delta<IN>>;
101
+ /**
102
+ * @type {s.Schema<import('../delta.js').Delta<OUT>>}
103
+ */
104
+ $out: s.Schema<import("../delta.js").Delta<OUT>>;
105
+ /**
106
+ * Stable, mangle-safe identifier folded into this template's fingerprint. Subclasses with
107
+ * configuration override it so that e.g. `attr('a')` and `attr('b')` fingerprint differently
108
+ * (do NOT use `constructor.name` — class names do not survive mangling).
109
+ *
110
+ * @return {string}
111
+ */
112
+ get name(): string;
113
+ /**
114
+ * Instantiate a fresh stateful {@link Transformer} bound to this template's schema.
115
+ *
116
+ * @return {Transformer<IN, OUT>}
117
+ */
118
+ init(): Transformer<IN, OUT>;
119
+ $type: s.Schema<Template>;
120
+ /**
121
+ * @return {string}
122
+ */
123
+ [fingerprintTrait.FingerprintTraitSymbol](): string;
124
+ }
125
+ export function transform<IN extends import("../delta.js").DeltaConf, T extends Template<IN, any>>($d: s.Schema<import("../delta.js").Delta<IN>>, fn: ($d: s.Schema<import("../delta.js").Delta<IN>>) => T): T;
126
+ export function withAttrs($in: s.Schema<import("../delta.js").DeltaAny>, newAttrsShape: {
127
+ [k: string | number]: s.Schema<any>;
128
+ }): s.Schema<import("../delta.js").DeltaAny>;
129
+ export function withName($in: s.Schema<import("../delta.js").DeltaAny>, name: string): s.Schema<import("../delta.js").DeltaAny>;
130
+ export function attrsShapeOf($in: s.Schema<import("../delta.js").DeltaAny>): {
131
+ [k: string | number]: s.Schema<any>;
132
+ } | null;
133
+ /**
134
+ * Recognize a {@link Template} by its `$type` tag. Used to detect transformer "holes" embedded in a
135
+ * `project` spec.
136
+ *
137
+ * @type {s.Schema<Template>}
138
+ */
139
+ export const $template: s.Schema<Template>;
140
+ export type TransformResultAny = TransformResult<any, any>;
141
+ /**
142
+ * A function from an input delta schema to a {@link Template} — the schema-deferred form of a
143
+ * transformer factory. Used for `pipe` stages, recursive composition, and `bind`.
144
+ */
145
+ export type TemplateFactory<In extends import("../delta.js").DeltaConf, Out extends import("../delta.js").DeltaConf> = ($in: s.Schema<import("../delta.js").Delta<In>>) => Template<In, Out>;
146
+ /**
147
+ * Force a factory's computed output conf to display fully-resolved (flatten `Omit<…> & {…}` / bare
148
+ * alias artifacts) while staying a valid `DeltaConf` for use as a `Transformer`/`Delta` type
149
+ * argument — conf-aware and depth-limited (nested `Delta<…>` stay intact). Implemented as an
150
+ * overwrite-with-nothing, reusing {@link import ('../delta.js').DeltaConfOverwrite}'s
151
+ * prettify+coerce recipe. Apply to every factory's `OUT` typedef whose result is not already
152
+ * produced by `DeltaConfOverwrite`.
153
+ */
154
+ export type ResolveOut<Conf extends import("../delta.js").DeltaConf> = import("../delta.js").DeltaConfOverwrite<Conf, {}>;
155
+ import * as s from '../../schema.js';
156
+ /**
157
+ * @template {import('../delta.js').DeltaConf} [A={}]
158
+ * @template {import('../delta.js').DeltaConf} [B={}]
159
+ */
160
+ declare class TransformResult<A extends import("../delta.js").DeltaConf = {}, B extends import("../delta.js").DeltaConf = {}> {
161
+ /**
162
+ * @param {import('../delta.js').DeltaBuilder<A>?} a
163
+ * @param {import('../delta.js').DeltaBuilder<B>?} b
164
+ */
165
+ constructor(a: import("../delta.js").DeltaBuilder<A> | null, b: import("../delta.js").DeltaBuilder<B> | null);
166
+ /**
167
+ * @type {import('../delta.js').DeltaBuilder<A>?}
168
+ */
169
+ a: import("../delta.js").DeltaBuilder<A> | null;
170
+ /**
171
+ * @type {import('../delta.js').DeltaBuilder<B>?}
172
+ */
173
+ b: import("../delta.js").DeltaBuilder<B> | null;
174
+ isEmpty(): boolean;
175
+ clear(): void;
176
+ /**
177
+ * @param {import('../delta.js').DeltaBuilder<A>?} a
178
+ */
179
+ applyA(a: import("../delta.js").DeltaBuilder<A> | null): this;
180
+ /**
181
+ * @param {import('../delta.js').DeltaBuilder<B>?} b
182
+ */
183
+ applyB(b: import("../delta.js").DeltaBuilder<B> | null): this;
184
+ reverse(): TransformResult<B, A>;
185
+ }
186
+ import * as delta from '../delta.js';
187
+ import * as fingerprintTrait from '../../trait/fingerprint.js';
188
+ export {};
189
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Stateful transformer holding the accumulated attribution overlay.
3
+ *
4
+ * @extends {Transformer<any,any>}
5
+ */
6
+ export class FullAttributionsTransformer extends Transformer<any, any> {
7
+ /**
8
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $in
9
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $out
10
+ */
11
+ constructor($in: import("../../schema.js").Schema<delta.Delta<any>>, $out: import("../../schema.js").Schema<delta.Delta<any>>);
12
+ /**
13
+ * Content-free overlay: the full accumulated attribution at every document position (instruction
14
+ * form). Mutated in place each change by `rebase` + `apply`.
15
+ *
16
+ * @type {delta.DeltaBuilderAny}
17
+ */
18
+ overlay: delta.DeltaBuilderAny;
19
+ }
20
+ /**
21
+ * Template for {@link FullAttributionsTransformer}. The transform touches only the `attribution`
22
+ * dimension (metadata, not part of the delta schema), so the output schema equals the input schema.
23
+ *
24
+ * @template {delta.DeltaConf} [IN=any]
25
+ * @extends {Template<IN, IN>}
26
+ */
27
+ export class FullAttributions<IN extends delta.DeltaConf = any> extends Template<IN, IN> {
28
+ /**
29
+ * @param {import('../../schema.js').Schema<delta.Delta<IN>>} $d
30
+ */
31
+ constructor($d: import("../../schema.js").Schema<delta.Delta<IN>>);
32
+ }
33
+ export function fullAttributions<IN extends delta.DeltaConf>($d: import("../../schema.js").Schema<delta.Delta<IN>>): FullAttributions<IN>;
34
+ import { Transformer } from './core.js';
35
+ import * as delta from '../delta.js';
36
+ import { Template } from './core.js';
37
+ //# sourceMappingURL=full-attributions.d.ts.map
@@ -0,0 +1,2 @@
1
+ export function id<IN extends import("../delta.js").DeltaConf>($d: import("../../schema.js").Schema<import("../delta.js").Delta<IN>>): import("./rename-attrs.js").RenameAttrs<{}, IN>;
2
+ //# sourceMappingURL=id.d.ts.map
@@ -0,0 +1,89 @@
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 {import('../../schema.js').Schema<delta.Delta<any>>} $in
17
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $out
18
+ * @param {Array<string|null>} names the node names to inline (`null` selects anonymous nodes)
19
+ */
20
+ constructor($in: import("../../schema.js").Schema<delta.Delta<any>>, $out: import("../../schema.js").Schema<delta.Delta<any>>, names: Array<string | null>);
21
+ /**
22
+ * @type {Array<string|null>}
23
+ */
24
+ names: Array<string | null>;
25
+ /**
26
+ * The segment layout of the structured side, maintained incrementally (see {@link applySegsChange}).
27
+ *
28
+ * @type {Array<Seg>}
29
+ */
30
+ segs: Array<Seg>;
31
+ /**
32
+ * Whether the structured side has ever contained a direct inline-node child. Monotonic: once a
33
+ * change introduces an inline node it stays set (even if that node is later deleted), which only
34
+ * costs a missed fast-path, never correctness.
35
+ *
36
+ * @type {boolean}
37
+ */
38
+ hasInline: boolean;
39
+ }
40
+ /**
41
+ * Template for {@link InlineTransformer}. Typed loosely: the inlined output shape depends on the
42
+ * runtime `names` and document content, so the OUT side is `any`.
43
+ *
44
+ * @template {delta.DeltaConf} [IN=any]
45
+ * @extends {Template<IN, any>}
46
+ */
47
+ export class Inline<IN extends delta.DeltaConf = any> extends Template<IN, any> {
48
+ /**
49
+ * @param {import('../../schema.js').Schema<delta.Delta<IN>>} $d
50
+ * @param {Array<string|null>} names the node names to inline (`null` selects anonymous nodes)
51
+ */
52
+ constructor($d: import("../../schema.js").Schema<delta.Delta<IN>>, names: Array<string | null>);
53
+ names: (string | null)[];
54
+ }
55
+ export function inline<IN extends delta.DeltaConf>($d: import("../../schema.js").Schema<delta.Delta<IN>>, names: Array<string | null>): Inline<IN>;
56
+ export function inlineNullNodes<IN extends delta.DeltaConf>($d: import("../../schema.js").Schema<delta.Delta<IN>>): Inline<IN>;
57
+ /**
58
+ * The (unexported) delta {@link import ('../delta.js').createMark Mark} type, referenced here for the
59
+ * local mark-bucketing annotations.
60
+ */
61
+ export type Mark = ReturnType<typeof delta.createMark>;
62
+ import { Transformer } from './core.js';
63
+ /**
64
+ * The (unexported) delta {@link import('../delta.js').createMark Mark} type, referenced here for the
65
+ * local mark-bucketing annotations.
66
+ *
67
+ * @typedef {ReturnType<typeof delta.createMark>} Mark
68
+ */
69
+ /**
70
+ * One entry of the segment layout maintained by {@link InlineTransformer}. A segment is either a
71
+ * coalesced run of pass-through positions (root text + opaque non-inlined nodes - same length in both
72
+ * coordinate spaces) or a single inline node (1 structured position that expands to `inlineLen`
73
+ * inlined positions).
74
+ */
75
+ declare class Seg {
76
+ /**
77
+ * @param {boolean} isInline whether this seg is an inline node (its children are spliced into the parent)
78
+ * @param {number} structLen
79
+ * @param {number} inlineLen
80
+ */
81
+ constructor(isInline: boolean, structLen: number, inlineLen: number);
82
+ isInline: boolean;
83
+ structLen: number;
84
+ inlineLen: number;
85
+ }
86
+ import * as delta from '../delta.js';
87
+ import { Template } from './core.js';
88
+ export {};
89
+ //# sourceMappingURL=inline.d.ts.map
@@ -0,0 +1,182 @@
1
+ /**
2
+ * The composite template produced by {@link pipe}: holds the threaded stage templates; `init()`
3
+ * materializes each into a {@link PipeTransformer}.
4
+ *
5
+ * @template {DeltaConf} [IN=any]
6
+ * @template {DeltaConf} [OUT=any]
7
+ * @extends {Template<IN, OUT>}
8
+ */
9
+ export class Pipe<IN extends DeltaConf = any, OUT extends DeltaConf = any> extends Template<IN, OUT> {
10
+ /**
11
+ * @param {DSchema<IN>} $in
12
+ * @param {DSchema<OUT>} $out
13
+ * @param {Template<any,any>[]} stages the threaded stage templates (A→B order)
14
+ */
15
+ constructor($in: DSchema<IN>, $out: DSchema<OUT>, stages: Template<any, any>[]);
16
+ stages: Template<any, any>[];
17
+ }
18
+ /**
19
+ * @extends {Transformer<any,any>}
20
+ */
21
+ export class PipeTransformer extends Transformer<any, any> {
22
+ /**
23
+ * @param {DSchema<any>} $in
24
+ * @param {DSchema<any>} $out
25
+ * @param {Transformer<any,any>[]} ts the per-stage transformers (materialized, A→B order)
26
+ */
27
+ constructor($in: DSchema<any>, $out: DSchema<any>, ts: Transformer<any, any>[]);
28
+ /**
29
+ * @type {Transformer<any,any>[]}
30
+ */
31
+ ts: Transformer<any, any>[];
32
+ }
33
+ /**
34
+ * Chain transformers, threading the input schema left→right so each stage is typed against the
35
+ * previous stage's output. `pipe($d, $d1 => …, $d2 => …)` infers the end-to-end output type
36
+ * automatically; each stage is a `($schema) => Template` factory. Returns a reusable {@link Pipe}
37
+ * template — call `.init()` for the transformer.
38
+ *
39
+ * Order is directional: an `applyA` change flows through the stages **left→right** (the leftmost maps
40
+ * the A-side first), an `applyB` change flows **right→left**. So list stages in A→B order — e.g.
41
+ * `pipe($d, $d1 => children($d1, …), $d2 => rename($d2, 'ul'))` maps an A-side change with `children`
42
+ * then `rename`. Reversing the order silently produces wrong results (there is no init-time check).
43
+ *
44
+ * The overloads cover up to a fixed arity; longer typed pipes nest
45
+ * (`pipe($d, …, $dk => pipe($dk, …more))`).
46
+ *
47
+ * @template {DeltaConf} In
48
+ * @template {DeltaConf} O1
49
+ * @overload
50
+ * @param {DSchema<In>} $in
51
+ * @param {(d: DSchema<In>) => Template<In, O1>} f1
52
+ * @returns {Pipe<In, O1>}
53
+ */
54
+ export function pipe<In extends DeltaConf, O1 extends DeltaConf>($in: DSchema<In>, f1: (d: DSchema<In>) => Template<In, O1>): Pipe<In, O1>;
55
+ /**
56
+ * @template {DeltaConf} In
57
+ * @template {DeltaConf} O1
58
+ * @template {DeltaConf} O2
59
+ * @overload
60
+ * @param {DSchema<In>} $in
61
+ * @param {(d: DSchema<In>) => Template<In, O1>} f1
62
+ * @param {(d: DSchema<O1>) => Template<O1, O2>} f2
63
+ * @returns {Pipe<In, O2>}
64
+ */
65
+ export function pipe<In extends DeltaConf, O1 extends DeltaConf, O2 extends DeltaConf>($in: DSchema<In>, f1: (d: DSchema<In>) => Template<In, O1>, f2: (d: DSchema<O1>) => Template<O1, O2>): Pipe<In, O2>;
66
+ /**
67
+ * @template {DeltaConf} In
68
+ * @template {DeltaConf} O1
69
+ * @template {DeltaConf} O2
70
+ * @template {DeltaConf} O3
71
+ * @overload
72
+ * @param {DSchema<In>} $in
73
+ * @param {(d: DSchema<In>) => Template<In, O1>} f1
74
+ * @param {(d: DSchema<O1>) => Template<O1, O2>} f2
75
+ * @param {(d: DSchema<O2>) => Template<O2, O3>} f3
76
+ * @returns {Pipe<In, O3>}
77
+ */
78
+ export function pipe<In extends DeltaConf, O1 extends DeltaConf, O2 extends DeltaConf, O3 extends DeltaConf>($in: DSchema<In>, f1: (d: DSchema<In>) => Template<In, O1>, f2: (d: DSchema<O1>) => Template<O1, O2>, f3: (d: DSchema<O2>) => Template<O2, O3>): Pipe<In, O3>;
79
+ /**
80
+ * @template {DeltaConf} In
81
+ * @template {DeltaConf} O1
82
+ * @template {DeltaConf} O2
83
+ * @template {DeltaConf} O3
84
+ * @template {DeltaConf} O4
85
+ * @overload
86
+ * @param {DSchema<In>} $in
87
+ * @param {(d: DSchema<In>) => Template<In, O1>} f1
88
+ * @param {(d: DSchema<O1>) => Template<O1, O2>} f2
89
+ * @param {(d: DSchema<O2>) => Template<O2, O3>} f3
90
+ * @param {(d: DSchema<O3>) => Template<O3, O4>} f4
91
+ * @returns {Pipe<In, O4>}
92
+ */
93
+ export function pipe<In extends DeltaConf, O1 extends DeltaConf, O2 extends DeltaConf, O3 extends DeltaConf, O4 extends DeltaConf>($in: DSchema<In>, f1: (d: DSchema<In>) => Template<In, O1>, f2: (d: DSchema<O1>) => Template<O1, O2>, f3: (d: DSchema<O2>) => Template<O2, O3>, f4: (d: DSchema<O3>) => Template<O3, O4>): Pipe<In, O4>;
94
+ /**
95
+ * @template {DeltaConf} In
96
+ * @template {DeltaConf} O1
97
+ * @template {DeltaConf} O2
98
+ * @template {DeltaConf} O3
99
+ * @template {DeltaConf} O4
100
+ * @template {DeltaConf} O5
101
+ * @overload
102
+ * @param {DSchema<In>} $in
103
+ * @param {(d: DSchema<In>) => Template<In, O1>} f1
104
+ * @param {(d: DSchema<O1>) => Template<O1, O2>} f2
105
+ * @param {(d: DSchema<O2>) => Template<O2, O3>} f3
106
+ * @param {(d: DSchema<O3>) => Template<O3, O4>} f4
107
+ * @param {(d: DSchema<O4>) => Template<O4, O5>} f5
108
+ * @returns {Pipe<In, O5>}
109
+ */
110
+ export function pipe<In extends DeltaConf, O1 extends DeltaConf, O2 extends DeltaConf, O3 extends DeltaConf, O4 extends DeltaConf, O5 extends DeltaConf>($in: DSchema<In>, f1: (d: DSchema<In>) => Template<In, O1>, f2: (d: DSchema<O1>) => Template<O1, O2>, f3: (d: DSchema<O2>) => Template<O2, O3>, f4: (d: DSchema<O3>) => Template<O3, O4>, f5: (d: DSchema<O4>) => Template<O4, O5>): Pipe<In, O5>;
111
+ /**
112
+ * @template {DeltaConf} In
113
+ * @template {DeltaConf} O1
114
+ * @template {DeltaConf} O2
115
+ * @template {DeltaConf} O3
116
+ * @template {DeltaConf} O4
117
+ * @template {DeltaConf} O5
118
+ * @template {DeltaConf} O6
119
+ * @overload
120
+ * @param {DSchema<In>} $in
121
+ * @param {(d: DSchema<In>) => Template<In, O1>} f1
122
+ * @param {(d: DSchema<O1>) => Template<O1, O2>} f2
123
+ * @param {(d: DSchema<O2>) => Template<O2, O3>} f3
124
+ * @param {(d: DSchema<O3>) => Template<O3, O4>} f4
125
+ * @param {(d: DSchema<O4>) => Template<O4, O5>} f5
126
+ * @param {(d: DSchema<O5>) => Template<O5, O6>} f6
127
+ * @returns {Pipe<In, O6>}
128
+ */
129
+ export function pipe<In extends DeltaConf, O1 extends DeltaConf, O2 extends DeltaConf, O3 extends DeltaConf, O4 extends DeltaConf, O5 extends DeltaConf, O6 extends DeltaConf>($in: DSchema<In>, f1: (d: DSchema<In>) => Template<In, O1>, f2: (d: DSchema<O1>) => Template<O1, O2>, f3: (d: DSchema<O2>) => Template<O2, O3>, f4: (d: DSchema<O3>) => Template<O3, O4>, f5: (d: DSchema<O4>) => Template<O4, O5>, f6: (d: DSchema<O5>) => Template<O5, O6>): Pipe<In, O6>;
130
+ /**
131
+ * @template {DeltaConf} In
132
+ * @template {DeltaConf} O1
133
+ * @template {DeltaConf} O2
134
+ * @template {DeltaConf} O3
135
+ * @template {DeltaConf} O4
136
+ * @template {DeltaConf} O5
137
+ * @template {DeltaConf} O6
138
+ * @template {DeltaConf} O7
139
+ * @overload
140
+ * @param {DSchema<In>} $in
141
+ * @param {(d: DSchema<In>) => Template<In, O1>} f1
142
+ * @param {(d: DSchema<O1>) => Template<O1, O2>} f2
143
+ * @param {(d: DSchema<O2>) => Template<O2, O3>} f3
144
+ * @param {(d: DSchema<O3>) => Template<O3, O4>} f4
145
+ * @param {(d: DSchema<O4>) => Template<O4, O5>} f5
146
+ * @param {(d: DSchema<O5>) => Template<O5, O6>} f6
147
+ * @param {(d: DSchema<O6>) => Template<O6, O7>} f7
148
+ * @returns {Pipe<In, O7>}
149
+ */
150
+ export function pipe<In extends DeltaConf, O1 extends DeltaConf, O2 extends DeltaConf, O3 extends DeltaConf, O4 extends DeltaConf, O5 extends DeltaConf, O6 extends DeltaConf, O7 extends DeltaConf>($in: DSchema<In>, f1: (d: DSchema<In>) => Template<In, O1>, f2: (d: DSchema<O1>) => Template<O1, O2>, f3: (d: DSchema<O2>) => Template<O2, O3>, f4: (d: DSchema<O3>) => Template<O3, O4>, f5: (d: DSchema<O4>) => Template<O4, O5>, f6: (d: DSchema<O5>) => Template<O5, O6>, f7: (d: DSchema<O6>) => Template<O6, O7>): Pipe<In, O7>;
151
+ /**
152
+ * @template {DeltaConf} In
153
+ * @template {DeltaConf} O1
154
+ * @template {DeltaConf} O2
155
+ * @template {DeltaConf} O3
156
+ * @template {DeltaConf} O4
157
+ * @template {DeltaConf} O5
158
+ * @template {DeltaConf} O6
159
+ * @template {DeltaConf} O7
160
+ * @template {DeltaConf} O8
161
+ * @overload
162
+ * @param {DSchema<In>} $in
163
+ * @param {(d: DSchema<In>) => Template<In, O1>} f1
164
+ * @param {(d: DSchema<O1>) => Template<O1, O2>} f2
165
+ * @param {(d: DSchema<O2>) => Template<O2, O3>} f3
166
+ * @param {(d: DSchema<O3>) => Template<O3, O4>} f4
167
+ * @param {(d: DSchema<O4>) => Template<O4, O5>} f5
168
+ * @param {(d: DSchema<O5>) => Template<O5, O6>} f6
169
+ * @param {(d: DSchema<O6>) => Template<O6, O7>} f7
170
+ * @param {(d: DSchema<O7>) => Template<O7, O8>} f8
171
+ * @returns {Pipe<In, O8>}
172
+ */
173
+ export function pipe<In extends DeltaConf, O1 extends DeltaConf, O2 extends DeltaConf, O3 extends DeltaConf, O4 extends DeltaConf, O5 extends DeltaConf, O6 extends DeltaConf, O7 extends DeltaConf, O8 extends DeltaConf>($in: DSchema<In>, f1: (d: DSchema<In>) => Template<In, O1>, f2: (d: DSchema<O1>) => Template<O1, O2>, f3: (d: DSchema<O2>) => Template<O2, O3>, f4: (d: DSchema<O3>) => Template<O3, O4>, f5: (d: DSchema<O4>) => Template<O4, O5>, f6: (d: DSchema<O5>) => Template<O5, O6>, f7: (d: DSchema<O6>) => Template<O6, O7>, f8: (d: DSchema<O7>) => Template<O7, O8>): Pipe<In, O8>;
174
+ export type DeltaConf = import("../delta.js").DeltaConf;
175
+ /**
176
+ * A delta schema for a given conf — `Schema<Delta<C>>`. Local alias to keep the overload signatures
177
+ * readable; defined via inline `import()` so no value import is needed.
178
+ */
179
+ export type DSchema<C extends DeltaConf> = import("../../schema.js").Schema<import("../delta.js").Delta<C>>;
180
+ import { Template } from './core.js';
181
+ import { Transformer } from './core.js';
182
+ //# sourceMappingURL=pipe.d.ts.map