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,223 @@
1
+ /**
2
+ * One child slot of a {@link ProjectionTransformer}'s fixed output layout: a run of static text, a
3
+ * single static node/embed, or a single hole (filled by a sub-transformer's output).
4
+ *
5
+ * A hole's `carrier` records how its sub-transformer's output is placed: `'value'` lifts a
6
+ * `lib0:value` carrier to a bare scalar embed (1 position, replaced on update); `'node'` embeds a
7
+ * structural node verbatim (a nested `project`'s render, or a non-value carrier) and forwards its
8
+ * incremental change as a `modify`. The kind is fixed once: known at `init` for auto-wrapped nested
9
+ * projects, otherwise sniffed from the first render and cached (`lastScalar` keeps the last lifted
10
+ * scalar so a view deletion of a value slot can be self-healed).
11
+ *
12
+ * @typedef {{ kind: 'text', str: string, format?: any, attribution?: any }
13
+ * | { kind: 'static', el: any, format?: any, attribution?: any }
14
+ * | { kind: 'hole', t: Transformer<any,any>, el: any, carrier?: 'value'|'node', lastScalar?: any, format?: any, attribution?: any }} ChildItem
15
+ */
16
+ /**
17
+ * Stateful transformer produced by {@link ProjectionTemplate}. Side A is the data (the
18
+ * *projectionDelta*); side B is the projected structure - the spec with each hole filled by its
19
+ * sub-transformer's output. `project` resolves the `lib0:value` carrier itself: at an *attribute*
20
+ * position (keyed) and at a *child* position (positional, 1->1) it lifts the carrier to its bare
21
+ * scalar. A child hole that is a nested `project` (or any non-`lib0:value` carrier) is embedded as a
22
+ * node. A `lib0:inline` fragment is left intact for a downstream `inline(['lib0:inline'])`.
23
+ *
24
+ * The output layout is *fixed*: every hole occupies exactly one attribute or one child node, and
25
+ * static content is constant. So `applyA` routes data changes into holes, and `applyB` routes view
26
+ * edits at *node*-hole positions back to holes while **self-healing** edits to static content and to
27
+ * value slots (a bare scalar has no `modify` channel, so a value-slot view edit is not round-tripped
28
+ * to data in v1 - use an attribute hole for an editable binding).
29
+ *
30
+ * @extends {Transformer<any,any>}
31
+ */
32
+ export class ProjectionTransformer extends Transformer<any, any> {
33
+ /**
34
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $in
35
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $out
36
+ * @param {string} name
37
+ * @param {Array<{ key: string|number, value: any, attribution?: any }>} staticAttrs
38
+ * @param {Array<{ key: string|number, t: Transformer<any,any> }>} attrHoles
39
+ * @param {Array<ChildItem>} items child slots in output order
40
+ */
41
+ constructor($in: import("../../schema.js").Schema<delta.Delta<any>>, $out: import("../../schema.js").Schema<delta.Delta<any>>, name: string, staticAttrs: Array<{
42
+ key: string | number;
43
+ value: any;
44
+ attribution?: any;
45
+ }>, attrHoles: Array<{
46
+ key: string | number;
47
+ t: Transformer<any, any>;
48
+ }>, items: Array<ChildItem>);
49
+ name: string;
50
+ staticAttrs: {
51
+ key: string | number;
52
+ value: any;
53
+ attribution?: any;
54
+ }[];
55
+ attrHoles: {
56
+ key: string | number;
57
+ t: Transformer<any, any>;
58
+ }[];
59
+ items: ChildItem[];
60
+ /**
61
+ * @type {Array<{ start: number, len: number, item: ChildItem }>}
62
+ */
63
+ segs: Array<{
64
+ start: number;
65
+ len: number;
66
+ item: ChildItem;
67
+ }>;
68
+ initialized: boolean;
69
+ /**
70
+ * Lift a child hole's sub-transformer output and place it on `out`. Returns the output count (1).
71
+ * For a value carrier the bare scalar is inserted (and cached for self-heal); otherwise the node is
72
+ * embedded verbatim. The hole's `carrier` kind is sniffed once here and cached.
73
+ *
74
+ * @param {delta.DeltaBuilderAny} out
75
+ * @param {ChildItem & { kind: 'hole' }} item
76
+ * @param {delta.DeltaAny?} rb the sub-transformer's B output
77
+ */
78
+ _placeHole(out: delta.DeltaBuilderAny, item: ChildItem & {
79
+ kind: "hole";
80
+ }, rb: delta.DeltaAny | null): void;
81
+ /**
82
+ * Initial render: emit the full structure with every hole filled.
83
+ *
84
+ * @param {delta.DeltaBuilderAny} d
85
+ */
86
+ _render(d: delta.DeltaBuilderAny): {
87
+ a: delta.DeltaBuilder<any, false> | null;
88
+ b: delta.DeltaBuilder<any, false> | null;
89
+ isEmpty(): boolean;
90
+ clear(): void;
91
+ applyA(a: delta.DeltaBuilder<any, false> | null): /*elided*/ any;
92
+ applyB(b: delta.DeltaBuilder<any, false> | null): /*elided*/ any;
93
+ reverse(): /*elided*/ any;
94
+ };
95
+ /**
96
+ * Incremental data change: emit only the hole updates. A value hole is *replaced*
97
+ * (`delete(1).insert([scalar])`, since a scalar embed has no inner structure to modify); a node
98
+ * hole forwards its sub-transformer's incremental change as a `modify`.
99
+ *
100
+ * @param {delta.DeltaBuilderAny} d
101
+ */
102
+ _update(d: delta.DeltaBuilderAny): {
103
+ a: delta.DeltaBuilder<any, false> | null;
104
+ b: delta.DeltaBuilder<any, false> | null;
105
+ isEmpty(): boolean;
106
+ clear(): void;
107
+ applyA(a: delta.DeltaBuilder<any, false> | null): /*elided*/ any;
108
+ applyB(b: delta.DeltaBuilder<any, false> | null): /*elided*/ any;
109
+ reverse(): /*elided*/ any;
110
+ };
111
+ /**
112
+ * Reconstruct the content occupying output positions `[start, start+len)` as insert ops on `out`
113
+ * (used to self-heal a view delete). Static text/nodes are restored from the spec, and a value
114
+ * slot is restored from its last-rendered scalar. Node-hole positions are skipped (their dynamic
115
+ * structure cannot be restored without the current data).
116
+ *
117
+ * @param {delta.DeltaBuilderAny} out
118
+ * @param {number} start
119
+ * @param {number} len
120
+ */
121
+ _restore(out: delta.DeltaBuilderAny, start: number, len: number): void;
122
+ }
123
+ /**
124
+ * Template that projects the *projectionDelta* onto a fixed structure described by `spec` - an
125
+ * ordinary {@link import('../delta.js').create delta} whose attribute values and inserted children
126
+ * may be transformer {@link Template templates} ("holes"). Each hole receives the whole
127
+ * projectionDelta; its output is placed at that position. The spec is a *write-only template*: it is
128
+ * walked once at {@link ProjectionTemplate#init} and never fingerprinted/diffed.
129
+ *
130
+ * Holes resolve themselves: a `lib0:value` carrier (produced by {@link import('./attr.js').attr}) is
131
+ * lifted to a bare scalar; a nested subtree that contains a hole is **auto-wrapped** into a nested
132
+ * `project` at `init`, so deep structure composes through nested templates with the recursion built
133
+ * once (bounded by spec depth). Plain static subtrees are embedded verbatim.
134
+ *
135
+ * @template {delta.DeltaConf} [IN=any]
136
+ * @template {delta.DeltaConf} [SpecConf=any]
137
+ * @extends {Template<IN, ProjectOutput<SpecConf>>}
138
+ */
139
+ export class ProjectionTemplate<IN extends delta.DeltaConf = any, SpecConf extends delta.DeltaConf = any> extends Template<IN, delta.DeltaConfOverwrite<delta.AsDeltaConf<Omit<SpecConf, "children" | "attrs"> & (SpecConf extends {
140
+ attrs: infer A;
141
+ } ? {
142
+ attrs: ResolveAttrs<A>;
143
+ } : {}) & (SpecConf extends {
144
+ children: infer Ch;
145
+ } ? {
146
+ children: ResolveChild<Ch>;
147
+ } : {})>, {}>> {
148
+ /**
149
+ * @param {import('../../schema.js').Schema<delta.Delta<IN>>} $d
150
+ * @param {delta.Delta<SpecConf>} spec
151
+ */
152
+ constructor($d: import("../../schema.js").Schema<delta.Delta<IN>>, spec: delta.Delta<SpecConf>);
153
+ spec: delta.Delta<SpecConf>;
154
+ }
155
+ export function project<IN extends delta.DeltaConf, SpecConf extends delta.DeltaConf>($d: import("../../schema.js").Schema<delta.Delta<IN>>, spec: delta.Delta<SpecConf>): ProjectionTemplate<IN, SpecConf>;
156
+ /**
157
+ * Resolve a hole template's output conf `OUT` to its projected placement type: a `lib0:value` carrier
158
+ * lifts to its bare scalar; any other node is embedded as a `Delta<OUT>`.
159
+ */
160
+ export type ResolveHoleOut<OUT extends delta.DeltaConf> = OUT extends {
161
+ name: "lib0:value";
162
+ attrs: {
163
+ value: infer V;
164
+ };
165
+ } ? V : delta.Delta<OUT>;
166
+ /**
167
+ * Resolve one spec child element to its projected output type, distributing over a children union: a
168
+ * hole ({@link Template}, whose output conf the spec carries) resolves via its `OUT`, a nested spec
169
+ * delta recurses, and anything else (text, a static scalar/node) is kept verbatim.
170
+ */
171
+ export type ResolveChild<C> = C extends Template<any, infer OUT extends delta.DeltaConf> ? ResolveHoleOut<OUT> : C extends delta.Delta<infer NC extends delta.DeltaConf> ? delta.Delta<ProjectOutput<NC>> : C;
172
+ /**
173
+ * Resolve a spec's attrs map: a hole attribute value resolves via its output conf; a static value is kept.
174
+ */
175
+ export type ResolveAttrs<A> = { [K in keyof A]: A[K] extends Template<any, infer OUT extends delta.DeltaConf> ? ResolveHoleOut<OUT> : A[K]; };
176
+ /**
177
+ * The concrete output conf of a `project($d, spec)` whose spec has conf `SpecConf`: static structure
178
+ * is kept, value holes lift to their scalar, nested specs / node holes recurse. Holes are schema-bound
179
+ * {@link Template}s, so their output conf is already concrete in `SpecConf` (no input param needed).
180
+ */
181
+ export type ProjectOutput<SpecConf extends delta.DeltaConf> = import("./core.js").ResolveOut<delta.AsDeltaConf<Omit<SpecConf, "attrs" | "children"> & (SpecConf extends {
182
+ attrs: infer A;
183
+ } ? {
184
+ attrs: ResolveAttrs<A>;
185
+ } : {}) & (SpecConf extends {
186
+ children: infer Ch;
187
+ } ? {
188
+ children: ResolveChild<Ch>;
189
+ } : {})>>;
190
+ /**
191
+ * One child slot of a {@link ProjectionTransformer}'s fixed output layout: a run of static text, a
192
+ * single static node/embed, or a single hole (filled by a sub-transformer's output).
193
+ *
194
+ * A hole's `carrier` records how its sub-transformer's output is placed: `'value'` lifts a
195
+ * `lib0:value` carrier to a bare scalar embed (1 position, replaced on update); `'node'` embeds a
196
+ * structural node verbatim (a nested `project`'s render, or a non-value carrier) and forwards its
197
+ * incremental change as a `modify`. The kind is fixed once: known at `init` for auto-wrapped nested
198
+ * projects, otherwise sniffed from the first render and cached (`lastScalar` keeps the last lifted
199
+ * scalar so a view deletion of a value slot can be self-healed).
200
+ */
201
+ export type ChildItem = {
202
+ kind: "text";
203
+ str: string;
204
+ format?: any;
205
+ attribution?: any;
206
+ } | {
207
+ kind: "static";
208
+ el: any;
209
+ format?: any;
210
+ attribution?: any;
211
+ } | {
212
+ kind: "hole";
213
+ t: Transformer<any, any>;
214
+ el: any;
215
+ carrier?: "value" | "node";
216
+ lastScalar?: any;
217
+ format?: any;
218
+ attribution?: any;
219
+ };
220
+ import { Transformer } from './core.js';
221
+ import * as delta from '../delta.js';
222
+ import { Template } from './core.js';
223
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Renames node attributes (`a` -> `b`) in both directions. Holds no per-application state, so
3
+ * {@link RenameAttrs} builds a single instance and shares it across every `init`.
4
+ *
5
+ * @extends Transformer<any,any>
6
+ */
7
+ export class RenameAttrsTransformer extends Transformer<any, any> {
8
+ /**
9
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $in
10
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $out
11
+ * @param {{[K:string|number]:string|number}} renames
12
+ */
13
+ constructor($in: import("../../schema.js").Schema<delta.Delta<any>>, $out: import("../../schema.js").Schema<delta.Delta<any>>, renames: {
14
+ [K: string | number]: string | number;
15
+ });
16
+ arenames: {
17
+ [K: string]: string | number;
18
+ [K: number]: string | number;
19
+ };
20
+ /**
21
+ * @type {{[K:string|number]:string|number}}
22
+ */
23
+ brenames: {
24
+ [K: string | number]: string | number;
25
+ };
26
+ /**
27
+ * @param {delta.DeltaAny} deltaA
28
+ * @return {import('./core.js').TransformResultAny}
29
+ */
30
+ applyA(deltaA: delta.DeltaAny): import("./core.js").TransformResultAny;
31
+ /**
32
+ * @param {delta.DeltaAny} deltaB
33
+ * @return {import('./core.js').TransformResultAny}
34
+ */
35
+ applyB(deltaB: delta.DeltaAny): import("./core.js").TransformResultAny;
36
+ }
37
+ /**
38
+ * Template that renames node attributes (`a` -> `b`) in both directions.
39
+ *
40
+ * @template {{[K:string|number]:string|number}} Renames
41
+ * @template {delta.DeltaConf} [IN=any]
42
+ * @extends {Template<IN, ApplyRenameAttrs<Renames, IN>>}
43
+ */
44
+ export class RenameAttrs<Renames extends {
45
+ [K: string | number]: string | number;
46
+ }, IN extends delta.DeltaConf = any> extends Template<IN, delta.DeltaConfOverwrite<IN, {
47
+ attrs: import("../../ts.js").PropsRename<import("../../ts.js").TypeIsAny<IN, {
48
+ [K: string]: any;
49
+ [K: number]: any;
50
+ }, IN extends {
51
+ attrs: infer Attrs;
52
+ } ? Attrs extends undefined ? {} : Attrs : {}>, Renames>;
53
+ }>> {
54
+ /**
55
+ * @param {import('../../schema.js').Schema<delta.Delta<IN>>} $d
56
+ * @param {Renames} renames
57
+ */
58
+ constructor($d: import("../../schema.js").Schema<delta.Delta<IN>>, renames: Renames);
59
+ /**
60
+ * @type {Renames}
61
+ */
62
+ renames: Renames;
63
+ }
64
+ export function renameAttrs<IN extends delta.DeltaConf, const Renames extends {
65
+ [K: string | number]: string | number;
66
+ }>($d: import("../../schema.js").Schema<delta.Delta<IN>>, renames: Renames): RenameAttrs<Renames, IN>;
67
+ export type ApplyRenameAttrs<Renames extends {
68
+ [K: string | number]: string | number;
69
+ }, IN extends delta.DeltaConf> = delta.DeltaConfOverwrite<IN, {
70
+ attrs: import("../../ts.js").PropsRename<delta.DeltaConfGetAttrs<IN>, Renames>;
71
+ }>;
72
+ import { Transformer } from './core.js';
73
+ import * as delta from '../delta.js';
74
+ import { Template } from './core.js';
75
+ //# sourceMappingURL=rename-attrs.d.ts.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Relabels a node: side B carries the configured `name`, side A keeps the source node's original
3
+ * name. Otherwise identity. Useful to mark a `children`-mapped collection as `lib0:inline` (so a
4
+ * downstream {@link import('./inline.js').inline}`(['lib0:inline'])` splices it into its parent) or
5
+ * simply to rename the container (e.g. a data collection projected as a `<ul>`).
6
+ *
7
+ * @extends {Transformer<any,any>}
8
+ */
9
+ export class RenameTransformer extends Transformer<any, any> {
10
+ /**
11
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $in
12
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $out
13
+ * @param {string} name
14
+ */
15
+ constructor($in: import("../../schema.js").Schema<delta.Delta<any>>, $out: import("../../schema.js").Schema<delta.Delta<any>>, name: string);
16
+ target: string;
17
+ /** @type {string|undefined} */
18
+ srcName: string | undefined;
19
+ }
20
+ /**
21
+ * Template for {@link RenameTransformer}.
22
+ *
23
+ * @template {string} Name
24
+ * @template {delta.DeltaConf} [IN=any]
25
+ * @extends {Template<IN, delta.DeltaConfOverwrite<IN, { name: Name }>>}
26
+ */
27
+ export class Rename<Name extends string, IN extends delta.DeltaConf = any> extends Template<IN, delta.DeltaConfOverwrite<IN, {
28
+ name: Name;
29
+ }>> {
30
+ /**
31
+ * @param {import('../../schema.js').Schema<delta.Delta<IN>>} $d
32
+ * @param {Name} name
33
+ */
34
+ constructor($d: import("../../schema.js").Schema<delta.Delta<IN>>, name: Name);
35
+ target: Name;
36
+ }
37
+ export function rename<IN extends delta.DeltaConf, Name extends string>($d: import("../../schema.js").Schema<delta.Delta<IN>>, name: Name): Rename<Name, IN>;
38
+ import { Transformer } from './core.js';
39
+ import * as delta from '../delta.js';
40
+ import { Template } from './core.js';
41
+ //# sourceMappingURL=rename.d.ts.map
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Stateful transformer that resolves `lib0:value` carrier *children* of a node: a `lib0:value` node
3
+ * (1 position) becomes an embed of its scalar value (1 position), and back. Count-preserving, so a
4
+ * single sparse positional map (`insert([1])` at carrier positions, coalesced `retain(n)` over
5
+ * gaps) indexes both directions - the same `childTs` technique as {@link import('./children.js')}.
6
+ *
7
+ * A standalone, *composable* one-level resolver (the `lib0:value` counterpart of
8
+ * {@link import('./inline.js').inline}`(['lib0:inline'])`): place it after any transformer that emits
9
+ * `lib0:value` carriers, or compose it with {@link import('./children.js').children} to descend into
10
+ * deeper levels. `project` lifts the carriers in its *own* structure, so `unwrapValue` is only needed
11
+ * for carriers emitted by a non-`project` transformer.
12
+ *
13
+ * Editing a resolved scalar from side B (the view) is not round-tripped in v1: a value *update*
14
+ * driven from side A (a `modify` on the carrier) maps to `delete(1).insert([newValue])`, but a side
15
+ * B `delete`+`insert` of the embed is treated structurally.
16
+ *
17
+ * @extends {Transformer<any,any>}
18
+ */
19
+ export class UnwrapValueTransformer extends Transformer<any, any> {
20
+ /**
21
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $in
22
+ * @param {import('../../schema.js').Schema<delta.Delta<any>>} $out
23
+ */
24
+ constructor($in: import("../../schema.js").Schema<delta.Delta<any>>, $out: import("../../schema.js").Schema<delta.Delta<any>>);
25
+ /**
26
+ * Sparse positional map of carriers: `insert([1])` at each `lib0:value` child, `retain(n)` over
27
+ * gaps (text and pass-through nodes).
28
+ *
29
+ * @type {delta.DeltaBuilderAny}
30
+ */
31
+ map: delta.DeltaBuilderAny;
32
+ /**
33
+ * @param {delta.DeltaBuilderAny} d the change to map
34
+ * @param {boolean} fwd `true` maps side A (carriers present) -> B (resolved), `false` maps back
35
+ * @return {import('./core.js').TransformResultAny}
36
+ */
37
+ transform(d: delta.DeltaBuilderAny, fwd: boolean): import("./core.js").TransformResultAny;
38
+ }
39
+ /**
40
+ * A `lib0:value` carrier child lifts to its scalar `value` type; any other child passes through.
41
+ * Naked-param conditional, so it distributes over a children union.
42
+ *
43
+ * @template C
44
+ * @typedef {C extends delta.Delta<{ name: 'lib0:value', attrs: { value: infer V extends import('../../trait/fingerprint.js').Fingerprintable } }> ? V : C} UnwrapValueChild
45
+ */
46
+ /**
47
+ * `unwrapValue`'s output conf: `IN` with every `lib0:value` carrier child replaced by its lifted
48
+ * scalar (see {@link UnwrapValueChild}); name/attrs/text unchanged.
49
+ *
50
+ * @template {delta.DeltaConf} IN
51
+ * @typedef {import('./core.js').ResolveOut<delta.DeltaConfOverwrite<IN, { children: UnwrapValueChild<delta.DeltaConfGetChildren<IN>> }>>} UnwrapValueOut
52
+ */
53
+ /**
54
+ * Template for {@link UnwrapValueTransformer}.
55
+ *
56
+ * @template {delta.DeltaConf} [IN=any]
57
+ * @extends {Template<IN, UnwrapValueOut<IN>>}
58
+ */
59
+ export class UnwrapValue<IN extends delta.DeltaConf = any> extends Template<IN, delta.DeltaConfOverwrite<delta.DeltaConfOverwrite<IN, {
60
+ children: UnwrapValueChild<IN extends {
61
+ children: infer Children;
62
+ } ? unknown extends Children ? any : Children : never> | UnwrapValueChild<IN extends {
63
+ recursiveChildren: true;
64
+ } ? delta.Delta<IN> : never>;
65
+ }>, {}>> {
66
+ /**
67
+ * @param {import('../../schema.js').Schema<delta.Delta<IN>>} $d
68
+ */
69
+ constructor($d: import("../../schema.js").Schema<delta.Delta<IN>>);
70
+ }
71
+ export function unwrapValue<IN extends delta.DeltaConf>($d: import("../../schema.js").Schema<delta.Delta<IN>>): UnwrapValue<IN>;
72
+ /**
73
+ * A `lib0:value` carrier child lifts to its scalar `value` type; any other child passes through.
74
+ * Naked-param conditional, so it distributes over a children union.
75
+ */
76
+ export type UnwrapValueChild<C> = C extends delta.Delta<{
77
+ name: "lib0:value";
78
+ attrs: {
79
+ value: infer V extends import("../../trait/fingerprint.js").Fingerprintable;
80
+ };
81
+ }> ? V : C;
82
+ /**
83
+ * `unwrapValue`'s output conf: `IN` with every `lib0:value` carrier child replaced by its lifted
84
+ * scalar (see {@link UnwrapValueChild}); name/attrs/text unchanged.
85
+ */
86
+ export type UnwrapValueOut<IN extends delta.DeltaConf> = import("./core.js").ResolveOut<delta.DeltaConfOverwrite<IN, {
87
+ children: UnwrapValueChild<delta.DeltaConfGetChildren<IN>>;
88
+ }>>;
89
+ import { Transformer } from './core.js';
90
+ import * as delta from '../delta.js';
91
+ import { Template } from './core.js';
92
+ //# sourceMappingURL=value.d.ts.map
@@ -0,0 +1,14 @@
1
+ export * from "./transformer/core.js";
2
+ export * from "./transformer/id.js";
3
+ export * from "./transformer/rename.js";
4
+ export * from "./transformer/conform.js";
5
+ export * from "./transformer/pipe.js";
6
+ export * from "./transformer/attr.js";
7
+ export * from "./transformer/inline.js";
8
+ export * from "./transformer/children.js";
9
+ export * from "./transformer/project.js";
10
+ export * from "./transformer/value.js";
11
+ export * from "./transformer/rename-attrs.js";
12
+ export * from "./transformer/attribution-to-format.js";
13
+ export * from "./transformer/full-attributions.js";
14
+ //# sourceMappingURL=transformer.d.ts.map
@@ -0,0 +1,25 @@
1
+ export function diff(as: Array<string>, bs: Array<string>): Array<{
2
+ index: number;
3
+ remove: Array<string>;
4
+ insert: Array<string>;
5
+ }>;
6
+ export function diffSplitBy(a: string, b: string, regexp: RegExp | string): {
7
+ index: number;
8
+ remove: string;
9
+ insert: string;
10
+ }[];
11
+ /**
12
+ * Idea: match all "non-word" characters and keep them separate (spaces, comma, exclamation marks, ..).
13
+ * Anything that can be classivied as a word (emoji, char, number) will be bundled together. All other tokens are kept
14
+ * individually. "hello, world!!!!" => ['hello', ',', ' ', 'world', '!', '!']
15
+ *
16
+ * @experimental
17
+ */
18
+ export const smartSplitRegex: RegExp;
19
+ export function diffAuto(a: string, b: string): {
20
+ insert: string;
21
+ remove: string;
22
+ index: number;
23
+ }[];
24
+ export function splitByRegexp(str: string, regexp: RegExp, includeSeparator: boolean): string[];
25
+ //# sourceMappingURL=patience.d.ts.map
@@ -1,6 +1,16 @@
1
1
  export const isNode: boolean;
2
+ /**
3
+ * True iff this script is running in deno
4
+ * @type {boolean}
5
+ */
6
+ export const isDeno: boolean;
2
7
  export const isBrowser: boolean;
3
8
  export const isMac: boolean;
9
+ /**
10
+ * True iff a DOM is available — either a real browser, or Node with a jsdom shim installed (see
11
+ * `src/test-setup.js`). Gate DOM-dependent tests on this so they run in the browser AND under jsdom.
12
+ */
13
+ export const hasDom: boolean;
4
14
  export function hasParam(name: string): boolean;
5
15
  export function getParam(name: string, defaultVal: string): string;
6
16
  export function getVariable(name: string): string | null;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * FNV-1a offset basis (32bit).
3
+ */
4
+ export const offsetBasis: 2166136261;
5
+ /**
6
+ * FNV-1a prime (32bit).
7
+ */
8
+ export const prime: 16777619;
9
+ export function digest(data: Uint8Array, hash?: number): number;
10
+ export function digestString(str: string, hash?: number): number;
11
+ //# sourceMappingURL=fnv1a.d.ts.map