domma-js 0.55.0 → 0.57.0

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 (116) hide show
  1. package/assets/types/generated/public/assets/flags/africa.d.ts +6 -0
  2. package/assets/types/generated/public/assets/flags/americas.d.ts +6 -0
  3. package/assets/types/generated/public/assets/flags/asia.d.ts +6 -0
  4. package/assets/types/generated/public/assets/flags/europe.d.ts +9 -0
  5. package/assets/types/generated/public/assets/flags/index.d.ts +11 -0
  6. package/assets/types/generated/public/assets/flags/oceania.d.ts +2 -0
  7. package/assets/types/generated/public/assets/icons/buildings.d.ts +6 -0
  8. package/assets/types/generated/public/assets/icons/code.d.ts +2 -0
  9. package/assets/types/generated/public/assets/icons/commerce.d.ts +7 -0
  10. package/assets/types/generated/public/assets/icons/communication.d.ts +7 -0
  11. package/assets/types/generated/public/assets/icons/devices.d.ts +6 -0
  12. package/assets/types/generated/public/assets/icons/emojis.d.ts +6 -0
  13. package/assets/types/generated/public/assets/icons/files.d.ts +7 -0
  14. package/assets/types/generated/public/assets/icons/finance.d.ts +6 -0
  15. package/assets/types/generated/public/assets/icons/forms.d.ts +5 -0
  16. package/assets/types/generated/public/assets/icons/health.d.ts +6 -0
  17. package/assets/types/generated/public/assets/icons/index.d.ts +24 -0
  18. package/assets/types/generated/public/assets/icons/media.d.ts +7 -0
  19. package/assets/types/generated/public/assets/icons/navigation.d.ts +7 -0
  20. package/assets/types/generated/public/assets/icons/seasonal.d.ts +6 -0
  21. package/assets/types/generated/public/assets/icons/social.d.ts +7 -0
  22. package/assets/types/generated/public/assets/icons/sport.d.ts +6 -0
  23. package/assets/types/generated/public/assets/icons/status.d.ts +7 -0
  24. package/assets/types/generated/public/assets/icons/transport.d.ts +7 -0
  25. package/assets/types/generated/public/assets/icons/ui.d.ts +7 -0
  26. package/assets/types/generated/public/assets/icons/weather.d.ts +6 -0
  27. package/assets/types/generated/src/auth.d.ts +424 -0
  28. package/assets/types/generated/src/avatar.d.ts +270 -0
  29. package/assets/types/generated/src/binding-source.d.ts +58 -0
  30. package/assets/types/generated/src/butterfly-drawing.d.ts +2 -0
  31. package/assets/types/generated/src/component-factory.d.ts +150 -0
  32. package/assets/types/generated/src/component.d.ts +162 -0
  33. package/assets/types/generated/src/components/back-to-top.d.ts +150 -0
  34. package/assets/types/generated/src/components/badge.d.ts +208 -0
  35. package/assets/types/generated/src/components/card.d.ts +189 -0
  36. package/assets/types/generated/src/components/command-palette.d.ts +352 -0
  37. package/assets/types/generated/src/components/dropzone.d.ts +342 -0
  38. package/assets/types/generated/src/components/focus-trap.d.ts +238 -0
  39. package/assets/types/generated/src/components/loader.d.ts +133 -0
  40. package/assets/types/generated/src/components/modal.d.ts +341 -0
  41. package/assets/types/generated/src/components/range-slider.d.ts +267 -0
  42. package/assets/types/generated/src/components/shared.d.ts +91 -0
  43. package/assets/types/generated/src/components/split-pane.d.ts +239 -0
  44. package/assets/types/generated/src/components/toast.d.ts +284 -0
  45. package/assets/types/generated/src/components/tooltip.d.ts +200 -0
  46. package/assets/types/generated/src/components/virtual-list.d.ts +340 -0
  47. package/assets/types/generated/src/config.d.ts +193 -0
  48. package/assets/types/generated/src/context-cursor.d.ts +69 -0
  49. package/assets/types/generated/src/context-menu.d.ts +596 -0
  50. package/assets/types/generated/src/dates.d.ts +367 -0
  51. package/assets/types/generated/src/dom.d.ts +1221 -0
  52. package/assets/types/generated/src/effects.d.ts +1281 -0
  53. package/assets/types/generated/src/elements.d.ts +4996 -0
  54. package/assets/types/generated/src/escape.d.ts +5 -0
  55. package/assets/types/generated/src/flags-bundle.d.ts +4 -0
  56. package/assets/types/generated/src/flags.d.ts +338 -0
  57. package/assets/types/generated/src/forms.d.ts +1060 -0
  58. package/assets/types/generated/src/globals.d.ts +45 -0
  59. package/assets/types/generated/src/http.d.ts +131 -0
  60. package/assets/types/generated/src/i18n.d.ts +261 -0
  61. package/assets/types/generated/src/icons.d.ts +213 -0
  62. package/assets/types/generated/src/index.d.ts +249 -0
  63. package/assets/types/generated/src/input-group.d.ts +135 -0
  64. package/assets/types/generated/src/models.d.ts +968 -0
  65. package/assets/types/generated/src/popover.d.ts +412 -0
  66. package/assets/types/generated/src/router.d.ts +344 -0
  67. package/assets/types/generated/src/safe-url.d.ts +10 -0
  68. package/assets/types/generated/src/sanitize.d.ts +97 -0
  69. package/assets/types/generated/src/schema-builder.d.ts +420 -0
  70. package/assets/types/generated/src/skeleton.d.ts +135 -0
  71. package/assets/types/generated/src/smooth-caret.d.ts +61 -0
  72. package/assets/types/generated/src/sortable.d.ts +369 -0
  73. package/assets/types/generated/src/storage.d.ts +93 -0
  74. package/assets/types/generated/src/tables.d.ts +901 -0
  75. package/assets/types/generated/src/theme.d.ts +277 -0
  76. package/assets/types/generated/src/ticker-tape-drawing.d.ts +2 -0
  77. package/assets/types/generated/src/treeview.d.ts +504 -0
  78. package/assets/types/generated/src/utils.d.ts +1667 -0
  79. package/assets/types/generated/src/web-components/base/domma-element.d.ts +134 -0
  80. package/assets/types/generated/src/web-components/index.d.ts +14 -0
  81. package/assets/types/generated/vendor/domma-reactive.d.ts +587 -0
  82. package/assets/types/index.d.ts +104 -216
  83. package/package.json +5 -2
  84. package/public/dist/bundles/domma-complete.css +1084 -14
  85. package/public/dist/bundles/domma-data-focused.css +1084 -14
  86. package/public/dist/bundles/domma-essentials.css +1084 -14
  87. package/public/dist/bundles/domma-full.css +1084 -14
  88. package/public/dist/bundles/domma-minimal.css +8 -8
  89. package/public/dist/domma-flags.esm.js +3 -3
  90. package/public/dist/domma-flags.esm.js.map +1 -1
  91. package/public/dist/domma-flags.min.js +3 -3
  92. package/public/dist/domma-flags.min.js.map +1 -1
  93. package/public/dist/domma-syntax.min.js +3 -3
  94. package/public/dist/domma.css +3 -3
  95. package/public/dist/domma.esm.js +5 -5
  96. package/public/dist/domma.esm.js.map +1 -1
  97. package/public/dist/domma.min.js +5 -5
  98. package/public/dist/domma.min.js.map +1 -1
  99. package/public/dist/elements.css +1073 -3
  100. package/public/dist/grid.css +3 -3
  101. package/public/dist/syntax.css +3 -3
  102. package/public/dist/themes/domma-themes.css +3 -3
  103. package/templates/kickstart/frontend/types/domma.d.ts +2 -1
  104. package/assets/types/config.d.ts +0 -136
  105. package/assets/types/dates.d.ts +0 -209
  106. package/assets/types/dom.d.ts +0 -448
  107. package/assets/types/elements.d.ts +0 -682
  108. package/assets/types/flags.d.ts +0 -130
  109. package/assets/types/http.d.ts +0 -97
  110. package/assets/types/icons.d.ts +0 -147
  111. package/assets/types/models.d.ts +0 -260
  112. package/assets/types/smooth-caret.d.ts +0 -12
  113. package/assets/types/storage.d.ts +0 -93
  114. package/assets/types/tables.d.ts +0 -327
  115. package/assets/types/theme.d.ts +0 -137
  116. package/assets/types/utils.d.ts +0 -675
@@ -0,0 +1,587 @@
1
+ // domma-reactive@1.3.1 declarations, copied by scripts/build-types.mjs - bundled into Domma.
2
+ /*! domma-reactive v1.3.1 | MIT | https://github.com/pinpointzero73/domma-reactive */
3
+ /**
4
+ * Type declarations for domma-reactive.
5
+ *
6
+ * Hand-written, not generated. The sources are JavaScript with JSDoc, and what
7
+ * JSDoc can express - `{Object}`, `{Function}`, `{*}` - is exactly the part a
8
+ * TypeScript consumer gets nothing from. What matters here is the generics:
9
+ * `observable(0)` is an `Observable<number>`, `computed(() => …)` carries its
10
+ * result type, and a read-only computed refuses assignment at compile time
11
+ * rather than warning at runtime.
12
+ *
13
+ * This file describes the public surface of src/index.js and nothing else. The
14
+ * build copies it to dist/ twice - `.d.ts` for `import`, `.d.cts` for
15
+ * `require()` - because under `"type": "module"` a single `.d.ts` would be read
16
+ * as ESM types for the CommonJS entry point too. See rollup.config.js.
17
+ *
18
+ * types/test/ holds the compile-time tests that keep it honest; run them with
19
+ * `npm run test:types`.
20
+ */
21
+
22
+ /// <reference lib="dom" />
23
+
24
+
25
+ // ── Equality ──────────────────────────────────────────────────────────────────
26
+
27
+ /**
28
+ * Deep structural equality: Date, Array and plain objects compared by content,
29
+ * everything else by reference. +0 and -0 are equal, NaN equals itself.
30
+ */
31
+ export function isEqual(a: unknown, b: unknown): boolean;
32
+
33
+ // ── The dependency graph ──────────────────────────────────────────────────────
34
+
35
+ /** A single reactive slot - one data field, or the output of one computed. */
36
+ export class Dep {
37
+ constructor(owner?: Computation<any> | null);
38
+ /** Computations that read this slot during their last evaluation. */
39
+ subs: Set<Computation<any>>;
40
+ /** The Computation this Dep represents the output of, if any. */
41
+ owner: Computation<any> | null;
42
+ /** Record that the currently-evaluating computation read this slot. */
43
+ track(): void;
44
+ /** Queue every dependent computation and schedule a flush. */
45
+ trigger(): void;
46
+ }
47
+
48
+ /** A lazily-populated keyed collection of Deps - one per data field. */
49
+ export class DepMap {
50
+ constructor();
51
+ /** Get, creating if needed, the Dep for a field. */
52
+ for(key: string): Dep;
53
+ /** Signal that a field changed. No-op when nothing has read it. */
54
+ trigger(key: string): void;
55
+ /** Drop every Dep. */
56
+ clear(): void;
57
+ }
58
+
59
+ export interface ComputationOptions<T> {
60
+ /** True for effects. */
61
+ effect?: boolean;
62
+ /** Debug label. */
63
+ label?: string;
64
+ /** Called after the value changes. */
65
+ onNotify?: ((value: T, computation: Computation<T>) => void) | null;
66
+ /** Makes the computation writable: where an assignment to `.value` lands. */
67
+ write?: (next: T) => void;
68
+ }
69
+
70
+ /**
71
+ * A tracked unit of work: a computed value or an effect.
72
+ *
73
+ * A body that throws is reported and yields `undefined` for that evaluation;
74
+ * the type says `T` because that is the only case in which it is not one.
75
+ */
76
+ export class Computation<T = unknown> {
77
+ constructor(fn: () => T, options?: ComputationOptions<T>);
78
+
79
+ fn: () => T;
80
+ label: string;
81
+ readonly isEffect: boolean;
82
+ onNotify: ((value: T, computation: Computation<T>) => void) | null;
83
+ /** Deps this computation read during its last evaluation. */
84
+ deps: Set<Dep>;
85
+ /** The Dep representing this computation's output. */
86
+ dep: Dep;
87
+ dirty: boolean;
88
+ disposed: boolean;
89
+
90
+ /** Pull the current value, recomputing only if dirty, and track the read. */
91
+ get(): T;
92
+ /** The same read as `get()`, spelled as a property. Assigning calls `write()`. */
93
+ get value(): T;
94
+ set value(next: T);
95
+ /** Push a value back through the derivation. Warns on a read-only computed. */
96
+ write(next: T): void;
97
+ /** Imperative alias for assigning `.value`. */
98
+ set(next: T): void;
99
+ /** Force a re-evaluation and report whether the value changed. */
100
+ recompute(): {changed: boolean; value: T};
101
+ /** Mark stale without recomputing. */
102
+ invalidate(): void;
103
+ /** Computations that read this one's output during their last evaluation. */
104
+ dependents(): Set<Computation<any>>;
105
+ /** Fire the change callback. */
106
+ notify(): void;
107
+ /** Unlink from the graph. Safe to call more than once. */
108
+ dispose(): void;
109
+ }
110
+
111
+ /**
112
+ * What `computed(fn)` returns: a Computation with no `write` to receive an
113
+ * assignment, so the assignment is refused here rather than ignored at runtime.
114
+ */
115
+ export type ReadonlyComputed<T> =
116
+ Omit<Computation<T>, 'value' | 'set' | 'write'> & {readonly value: T};
117
+
118
+ /** What `computed({read, write})` returns. */
119
+ export type WritableComputed<T> = Computation<T>;
120
+
121
+ export interface ComputedOptions<T> {
122
+ /** Debug label. */
123
+ label?: string;
124
+ /** Called when the derived value changes. */
125
+ onNotify?: ((value: T, computation: Computation<T>) => void) | null;
126
+ }
127
+
128
+ export interface WritableComputedDefinition<T> extends ComputedOptions<T> {
129
+ read: () => T;
130
+ write: (next: T) => void;
131
+ }
132
+
133
+ /** A writable computed: `computed({read, write})`. */
134
+ export function computed<T>(
135
+ definition: WritableComputedDefinition<T>,
136
+ options?: ComputedOptions<T>
137
+ ): WritableComputed<T>;
138
+ /** A writable computed: `computed(read, {write})`. */
139
+ export function computed<T>(
140
+ read: () => T,
141
+ options: ComputedOptions<T> & {write: (next: T) => void}
142
+ ): WritableComputed<T>;
143
+ /** A lazily-evaluated, read-only derived value. */
144
+ export function computed<T>(read: () => T, options?: ComputedOptions<T>): ReadonlyComputed<T>;
145
+
146
+ /**
147
+ * Run `fn` now, collecting what it reads, and again whenever any of that
148
+ * changes. The body must be synchronous. Stop it with `.dispose()`.
149
+ */
150
+ export function effect(fn: () => unknown, options?: {label?: string}): ReadonlyComputed<unknown>;
151
+
152
+ /** Run `fn` with dependency tracking suspended. */
153
+ export function untracked<T>(fn: () => T): T;
154
+
155
+ export interface TrackingProxyOptions {
156
+ /** Route writes here instead of mutating the target. */
157
+ onSet?: ((key: string, value: unknown) => void) | null;
158
+ }
159
+
160
+ /** Wrap an object so that reading a field tracks the Dep `depFor(key)` returns. */
161
+ export function trackingProxy<T extends object>(
162
+ target: T,
163
+ depFor: (key: string) => Dep,
164
+ options?: TrackingProxyOptions
165
+ ): T;
166
+
167
+ /** Drain every pending recomputation now instead of on the next microtask. */
168
+ export function flushSync(): void;
169
+
170
+ // ── Observables ───────────────────────────────────────────────────────────────
171
+
172
+ /** What `subscribe()` returns: call it, or call its `.dispose()`. */
173
+ export interface Unsubscribe {
174
+ (): void;
175
+ dispose(): void;
176
+ }
177
+
178
+ export interface ObservableOptions<T> {
179
+ /** The change gate. Defaults to `isEqual`. Gates notification, never the write. */
180
+ equals?: (a: T, b: T) => boolean;
181
+ }
182
+
183
+ /** Hold notifications back; the write itself always lands immediately. */
184
+ export type RateLimit =
185
+ | number
186
+ | {timeout: number; method?: 'notifyWhenChangesStop' | 'notifyAtFixedRate'};
187
+
188
+ /**
189
+ * The argument to `.extend()`. The built-ins are typed; any other key is an
190
+ * extender added with `registerExtender`.
191
+ */
192
+ export interface ExtenderSpec {
193
+ rateLimit?: RateLimit;
194
+ /** Knockout's older name for `rateLimit`, with `rateLimit`'s behaviour. */
195
+ throttle?: RateLimit;
196
+ /** Announce every write, including one the change gate would swallow. */
197
+ notify?: 'always';
198
+ [extender: string]: unknown;
199
+ }
200
+
201
+ export interface Observable<T> {
202
+ /** Tracked on read; assigning writes, and notifies if the value changed. */
203
+ value: T;
204
+ /** Read without registering a dependency. */
205
+ peek(): T;
206
+ /** Imperative alias for assigning `.value`. */
207
+ set(next: T): void;
208
+ /** Called synchronously, at the write, with the new value. */
209
+ subscribe(fn: (value: T) => void): Unsubscribe;
210
+ /** Layer behaviour onto this observable. */
211
+ extend(spec: ExtenderSpec): this;
212
+ }
213
+
214
+ /** A value to be tested against each item, or a test function. */
215
+ export type ItemMatch<T> = T | ((item: T, index: number) => boolean);
216
+
217
+ export interface ObservableArray<T> {
218
+ /**
219
+ * The live array, tracked on read. An assigned array is copied rather than
220
+ * adopted; a non-array is coerced to an empty one.
221
+ */
222
+ value: T[];
223
+ /** Tracked. */
224
+ readonly length: number;
225
+ /** The live array, untracked. */
226
+ peek(): T[];
227
+ /** Imperative alias for assigning `.value`. */
228
+ set(next: readonly T[]): void;
229
+
230
+ /** Remove every item equal to `match`, or every item the test accepts. */
231
+ remove(match: ItemMatch<T>): this;
232
+ /** Empty the array in place. */
233
+ removeAll(): this;
234
+ /** Tracked `indexOf`, by identity. */
235
+ indexOf(item: T): number;
236
+ /** Swap the first occurrence of `oldItem` for `newItem`. */
237
+ replace(oldItem: T, newItem: T): this;
238
+ /** Mark matching object items `_destroy: true` without removing them. */
239
+ destroy(match: ItemMatch<T>): this;
240
+ /** Mark every item deleted. */
241
+ destroyAll(): this;
242
+
243
+ /** Called synchronously on every change, with the live array. */
244
+ subscribe(fn: (value: T[]) => void): Unsubscribe;
245
+ /** Layer behaviour onto this array. A rate limit covers the mutators too. */
246
+ extend(spec: ExtenderSpec): this;
247
+
248
+ // The in-place mutators: the native method, run against the live array.
249
+ push(...items: T[]): number;
250
+ pop(): T | undefined;
251
+ shift(): T | undefined;
252
+ unshift(...items: T[]): number;
253
+ splice(start: number, deleteCount?: number, ...items: T[]): T[];
254
+ sort(compareFn?: (a: T, b: T) => number): T[];
255
+ reverse(): T[];
256
+ fill(value: T, start?: number, end?: number): T[];
257
+ copyWithin(target: number, start: number, end?: number): T[];
258
+ }
259
+
260
+ /** Create an observable value. */
261
+ export function observable<T>(initial: T, options?: ObservableOptions<T>): Observable<T>;
262
+ export function observable<T = undefined>(): Observable<T | undefined>;
263
+
264
+ /** Create an observable array. The initial array is copied. */
265
+ export function observableArray<T = unknown>(
266
+ initial?: readonly T[] | null,
267
+ options?: ObservableOptions<T[]>
268
+ ): ObservableArray<T>;
269
+
270
+ // ── Extenders ─────────────────────────────────────────────────────────────────
271
+
272
+ /**
273
+ * What an extender is handed. It can replace the change gate and wrap the
274
+ * announcement, and deliberately cannot touch the stored value.
275
+ */
276
+ export interface ExtenderControl {
277
+ /** The observable being extended. */
278
+ readonly observable: Observable<any> | ObservableArray<any>;
279
+ /** Replace the change gate. */
280
+ setEquals(fn: (a: any, b: any) => boolean): void;
281
+ /** Wrap the announcement: `next` delivers a value to the graph and subscribers. */
282
+ intercept(wrap: (next: (value: any) => void) => (value: any) => void): void;
283
+ }
284
+
285
+ export type Extender<V = any> = (control: ExtenderControl, value: V) => void;
286
+
287
+ /** Register an extender usable as `.extend({[name]: value})`. */
288
+ export function registerExtender<F extends Extender>(name: string, fn: F): F;
289
+ /** Remove an extender. Built-ins are refused. */
290
+ export function unregisterExtender(name: string): boolean;
291
+
292
+ // ── Binding contexts ──────────────────────────────────────────────────────────
293
+
294
+ /** What an expression resolves names against. Frozen. */
295
+ export interface BindingContext<D = any> {
296
+ readonly $data: D;
297
+ readonly $root: any;
298
+ /** The enclosing data, or null at the root. */
299
+ readonly $parent: any;
300
+ /** Every enclosing `$data`, nearest first. */
301
+ readonly $parents: readonly any[];
302
+ readonly $parentContext: BindingContext | null;
303
+ /** Position within a list, or null outside one. */
304
+ readonly $index: number | null;
305
+ /** Size of the enclosing list, or null outside one. */
306
+ readonly $length: number | null;
307
+ /** The enclosing component's view model, or null outside one. */
308
+ readonly $component: any;
309
+ }
310
+
311
+ /** The top-level context for a data object. */
312
+ export function createRootContext<D>(data: D): BindingContext<D>;
313
+
314
+ /** A context one level down: a list item, or the body of a `with`. */
315
+ export function createChildContext<D>(
316
+ parent: unknown,
317
+ data: D,
318
+ index?: number | null,
319
+ length?: number | null
320
+ ): BindingContext<D>;
321
+
322
+ // ── Expressions ───────────────────────────────────────────────────────────────
323
+
324
+ /** A node of a parsed expression. Frozen. */
325
+ export type ExpressionAst =
326
+ | {readonly type: 'Literal'; readonly value: string | number | boolean | null}
327
+ | {readonly type: 'Identifier'; readonly name: string}
328
+ | {
329
+ readonly type: 'Member';
330
+ readonly object: ExpressionAst;
331
+ readonly property: string | ExpressionAst;
332
+ readonly computed: boolean;
333
+ }
334
+ | {readonly type: 'Call'; readonly callee: string; readonly args: readonly ExpressionAst[]}
335
+ | {readonly type: 'MethodCall'; readonly [key: string]: unknown}
336
+ | {readonly type: 'Unary'; readonly [key: string]: unknown}
337
+ | {readonly type: 'Binary'; readonly [key: string]: unknown}
338
+ | {readonly type: 'Logical'; readonly [key: string]: unknown}
339
+ | {
340
+ readonly type: 'Conditional';
341
+ readonly test: ExpressionAst;
342
+ readonly consequent: ExpressionAst;
343
+ readonly alternate: ExpressionAst;
344
+ };
345
+
346
+ export interface ExpressionOptions {
347
+ /** A name for the template, used in warnings. */
348
+ template?: string;
349
+ /** Permit `x.foo()` to parse. The evaluator still refuses to perform it. */
350
+ methodCalls?: boolean;
351
+ }
352
+
353
+ /** A compiled expression: evaluate against a binding context or plain data. */
354
+ export type CompiledExpression = (context: unknown) => unknown;
355
+
356
+ /** Parse, cached by source. Null when the source does not parse. */
357
+ export function parseExpression(source: string, options?: ExpressionOptions): ExpressionAst | null;
358
+ /** Evaluate an AST. Never throws; an error yields `undefined`. */
359
+ export function evaluateAst(ast: ExpressionAst | null, context: unknown): unknown;
360
+ /** Parse and evaluate in one call. `undefined` if the source does not parse. */
361
+ export function evaluateExpression(source: string, context: unknown, options?: ExpressionOptions): unknown;
362
+ /** Source to a reusable evaluator. Null when the source does not parse. */
363
+ export function compileExpression(source: string, options?: ExpressionOptions): CompiledExpression | null;
364
+ /** The root names an expression reads. Empty when it does not parse. */
365
+ export function expressionDependencies(
366
+ source: string | ExpressionAst | null,
367
+ options?: ExpressionOptions
368
+ ): Set<string>;
369
+ /** Register a helper. It takes precedence over a built-in (len, includes, where, ...) of the same name. */
370
+ export function registerHelper<F extends (...args: any[]) => unknown>(name: string, fn: F): F;
371
+ /** Remove a registered helper; a built-in of the same name applies again. */
372
+ export function unregisterHelper(name: string): boolean;
373
+ /** Empty the parse cache, returning how many entries were dropped. */
374
+ export function clearExpressionCache(): number;
375
+
376
+ // ── Rendering ─────────────────────────────────────────────────────────────────
377
+
378
+ export interface RenderOptions {
379
+ /** name → template, for `{{> name}}`. */
380
+ partials?: Record<string, string>;
381
+ /** A label for expression warnings. */
382
+ template?: string;
383
+ }
384
+
385
+ /** A mustache renderer: `(template, data) => html`. */
386
+ export type RenderFn = (template: string, data: any) => string;
387
+
388
+ /** The default mustache renderer. HTML-escapes `{{ }}`; `{{{ }}}` is raw. */
389
+ export function renderTemplate(template: string, data?: object, options?: RenderOptions): string;
390
+
391
+ // ── Bindings ──────────────────────────────────────────────────────────────────
392
+
393
+ /** A comment-anchored region of DOM, owned by a region binding. */
394
+ export interface Region {
395
+ open: Comment;
396
+ close: Comment;
397
+ }
398
+
399
+ /**
400
+ * A compiled binding record. Handlers read these fields; the compiler and the
401
+ * runtime own them.
402
+ */
403
+ export interface Binding {
404
+ id: string;
405
+ /** The registered name of the handler, e.g. 'model'. */
406
+ kind: string;
407
+ /** For an `attributePrefix` handler, the rest of the attribute name. */
408
+ arg?: string | null;
409
+ /** The source of the binding's expression. */
410
+ expr: string;
411
+ /** For a region handler, the annotated source of the region. */
412
+ body?: string;
413
+ /** Set when the handler declares `expression: true`. */
414
+ ast?: ExpressionAst | null;
415
+ evaluate?: CompiledExpression | null;
416
+ /** Root names the expression reads. */
417
+ deps: Set<string>;
418
+ /** Elements for attribute bindings; regions for comment-anchored ones. */
419
+ nodes: Array<Element | Region> | null;
420
+ [key: string]: unknown;
421
+ }
422
+
423
+ export interface BindingUpdateArgs {
424
+ binding: Binding;
425
+ nodes: Array<Element | Region>;
426
+ context: BindingContext;
427
+ render: RenderFn;
428
+ replaceRegion(open: Comment, close: Comment, html: string): void;
429
+ /** Re-index after revealing new markup. */
430
+ reindex(): void;
431
+ controller: BindingController;
432
+ }
433
+
434
+ export interface BindingNodeArgs {
435
+ binding: Binding;
436
+ node: Element | Region;
437
+ controller: BindingController;
438
+ }
439
+
440
+ /** The contract `registerBinding` accepts. Only `update` is required. */
441
+ export interface BindingHandler {
442
+ /** An exact attribute name that asks for this binding, e.g. 'data-model'. */
443
+ attribute?: string;
444
+ /** An attribute prefix; the remainder becomes `binding.arg`. */
445
+ attributePrefix?: string;
446
+ /** Parse the value; sets `binding.ast` and `binding.evaluate`. */
447
+ expression?: boolean;
448
+ /** Contribute the expression's dependencies to `binding.deps`. */
449
+ tracks?: boolean;
450
+ /** Wrap the owning element in comment anchors. */
451
+ region?: boolean;
452
+ /** Fill `binding.body` with the region's annotated source. */
453
+ capturesBody?: boolean;
454
+ /** Run `update()` once immediately after the first paint. */
455
+ primes?: boolean;
456
+ /** Returns whether anything was written. */
457
+ update(args: BindingUpdateArgs): boolean | void;
458
+ /** Once per node, when it is indexed. */
459
+ attach?(args: BindingNodeArgs): void;
460
+ /** On teardown. */
461
+ detach?(args: BindingNodeArgs): void;
462
+ }
463
+
464
+ /** Register a binding kind - the same function every built-in is registered with. */
465
+ export function registerBinding<H extends BindingHandler>(name: string, handler: H): H;
466
+ /** Remove a binding kind. */
467
+ export function unregisterBinding(name: string): boolean;
468
+
469
+ // ── The template compiler ─────────────────────────────────────────────────────
470
+
471
+ export interface BlockLocation {
472
+ start: number;
473
+ end: number;
474
+ kind: string;
475
+ expr: string;
476
+ }
477
+
478
+ export interface AnnotateOptions {
479
+ /** A name for the template, used in warnings. */
480
+ template?: string;
481
+ }
482
+
483
+ export interface AnnotateResult {
484
+ annotated: string;
485
+ bindings: Binding[];
486
+ }
487
+
488
+ export interface CompileOptions {
489
+ /** A name for the template, used in warnings. */
490
+ template?: string;
491
+ /**
492
+ * Own one effect per binding, so the DOM follows the data unaided. Off by
493
+ * default; a standalone consumer almost certainly wants it on.
494
+ */
495
+ reactive?: boolean;
496
+ }
497
+
498
+ /** What `compile()` returns. Call `destroy()` when the markup is done with. */
499
+ export interface BindingController {
500
+ readonly bindings: Binding[];
501
+ /** Dependencies of one binding. */
502
+ deps(id: string): Set<string>;
503
+ /** The binding context in force. */
504
+ context(): BindingContext;
505
+ /** Re-point every binding at a different context, running nothing. */
506
+ setContext(next: unknown): void;
507
+ /** Re-run every binding that currently has nodes. */
508
+ refresh(filter?: ((binding: Binding) => boolean) | null): void;
509
+ /** Re-index from the current roots. */
510
+ index(): void;
511
+ /** Update one binding in place. True if anything was written. */
512
+ update(id: string, fullData?: unknown): boolean;
513
+ /** Update every binding. */
514
+ updateAll(fullData?: unknown): void;
515
+ /** Full re-render. */
516
+ rerenderAll(fullData?: unknown): void;
517
+ /** @deprecated Use `rerenderAll`. */
518
+ rerender(fullData?: unknown): void;
519
+ /** Detach listeners and dispose every effect. Leaves the nodes in place. */
520
+ destroy(): void;
521
+ /** Live effect count. */
522
+ effectCount(): number;
523
+ }
524
+
525
+ /** Locate every block in a template, at any nesting depth. */
526
+ export function scanBlocks(template: string): BlockLocation[];
527
+
528
+ /** Annotate a template with anchors and build its binding list. Needs no DOM. */
529
+ export function annotate(template: string, options?: AnnotateOptions): AnnotateResult;
530
+
531
+ /** Compile a template into a container. Needs a DOM. */
532
+ export function compile(
533
+ template: string,
534
+ data: unknown,
535
+ container: Element,
536
+ renderFn?: RenderFn | null,
537
+ options?: CompileOptions
538
+ ): BindingController;
539
+
540
+ export const TemplateCompiler: {
541
+ readonly annotate: typeof annotate;
542
+ readonly compile: typeof compile;
543
+ readonly scanBlocks: typeof scanBlocks;
544
+ /** Resolve a dotted path against a data object. */
545
+ readonly resolvePath: (data: unknown, path: string) => unknown;
546
+ };
547
+
548
+ // ── applyBindings ─────────────────────────────────────────────────────────────
549
+
550
+ export interface ApplyBindingsOptions {
551
+ /** Renderer for `data-each` item templates. */
552
+ render?: RenderFn;
553
+ /** A name for this subtree, used in warnings. */
554
+ template?: string;
555
+ }
556
+
557
+ /** What `applyBindings()` returns. Call `dispose()` when the markup is done with. */
558
+ export interface BindingsHandle {
559
+ /** How many bindings this call activated. */
560
+ readonly bindings: number;
561
+ /** The binding context in force. */
562
+ context(): BindingContext;
563
+ /** Re-point at different data and re-run every binding. */
564
+ update(next?: unknown): void;
565
+ /** Tear down everything this call created. Safe to call twice. */
566
+ dispose(): void;
567
+ }
568
+
569
+ /** Bring an existing DOM subtree, inclusive of the root, to life. */
570
+ export function applyBindings(data: unknown, rootElement: Element, options?: ApplyBindingsOptions): BindingsHandle;
571
+
572
+ // ── Components ────────────────────────────────────────────────────────────────
573
+
574
+ export interface ComponentDefinition<P = any, VM extends object = any> {
575
+ /** Markup, bound against the view model - or against the params with no `create`. */
576
+ template: string;
577
+ /**
578
+ * A plain factory: no `new`. Handed the frozen params and the host element.
579
+ * A `dispose()` on the view model it returns runs on teardown.
580
+ */
581
+ create?: (params: P, info: {element: Element}) => VM;
582
+ }
583
+
584
+ /** Register a component, used as `data-component="'name'"`. */
585
+ export function registerComponent<D extends ComponentDefinition>(name: string, definition: D): D;
586
+ /** Remove a component. */
587
+ export function unregisterComponent(name: string): boolean;