mancha 0.24.0 → 0.24.2

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 (78) hide show
  1. package/README.md +26 -7
  2. package/dist/browser.d.ts +451 -2
  3. package/dist/browser.js +32 -1
  4. package/dist/cli.js +3 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/css_gen_utils.d.ts +8 -915
  7. package/dist/css_gen_utils.js +382 -641
  8. package/dist/css_gen_utils.js.map +1 -1
  9. package/dist/mancha.js +25 -36
  10. package/dist/plugins.js +11 -1
  11. package/dist/plugins.js.map +1 -1
  12. package/dist/store.d.ts +8 -1
  13. package/dist/store.js +10 -3
  14. package/dist/store.js.map +1 -1
  15. package/dist/trusted_attributes.d.ts +0 -3
  16. package/dist/trusted_attributes.js +1 -3
  17. package/dist/trusted_attributes.js.map +1 -1
  18. package/docs/01_syntax.md +2 -0
  19. package/docs/03_reactivity.md +20 -3
  20. package/docs/05_css.md +270 -275
  21. package/docs/06_ssr.md +3 -2
  22. package/docs/07_typescript.md +5 -5
  23. package/docs/10_security.md +204 -0
  24. package/package.json +20 -7
  25. package/.biomeignore +0 -3
  26. package/.github/workflows/ci.yml +0 -109
  27. package/.vscode/extensions.json +0 -3
  28. package/.vscode/launch.json +0 -34
  29. package/biome.json +0 -46
  30. package/dist/browser.js.map +0 -1
  31. package/dist/expressions/ast.test.d.ts +0 -1
  32. package/dist/expressions/ast.test.js +0 -147
  33. package/dist/expressions/ast.test.js.map +0 -1
  34. package/dist/expressions/ast_factory.test.d.ts +0 -1
  35. package/dist/expressions/ast_factory.test.js +0 -94
  36. package/dist/expressions/ast_factory.test.js.map +0 -1
  37. package/dist/expressions/constants.test.d.ts +0 -1
  38. package/dist/expressions/constants.test.js +0 -84
  39. package/dist/expressions/constants.test.js.map +0 -1
  40. package/dist/expressions/eval.test.d.ts +0 -1
  41. package/dist/expressions/eval.test.js +0 -215
  42. package/dist/expressions/eval.test.js.map +0 -1
  43. package/dist/expressions/expressions.test.d.ts +0 -6
  44. package/dist/expressions/expressions.test.js +0 -7
  45. package/dist/expressions/expressions.test.js.map +0 -1
  46. package/dist/expressions/parser.test.d.ts +0 -1
  47. package/dist/expressions/parser.test.js +0 -174
  48. package/dist/expressions/parser.test.js.map +0 -1
  49. package/dist/expressions/tokenizer.test.d.ts +0 -1
  50. package/dist/expressions/tokenizer.test.js +0 -124
  51. package/dist/expressions/tokenizer.test.js.map +0 -1
  52. package/dist/interfaces-C8heJ6BZ.d.ts +0 -452
  53. package/dist/mancha.js.map +0 -1
  54. package/dist/renderer-B4AORGUN.js +0 -43
  55. package/dist/safe_browser.d.ts +0 -16
  56. package/dist/safe_browser.js +0 -1
  57. package/dist/safe_browser.js.map +0 -1
  58. package/dist/test_types/api.d.ts +0 -11
  59. package/dist/test_types/api.js +0 -3
  60. package/dist/test_types/api.js.map +0 -1
  61. package/dist/test_types/nested/child.d.ts +0 -12
  62. package/dist/test_types/nested/child.js +0 -2
  63. package/dist/test_types/nested/child.js.map +0 -1
  64. package/dist/test_types/product.d.ts +0 -11
  65. package/dist/test_types/product.js +0 -3
  66. package/dist/test_types/product.js.map +0 -1
  67. package/dist/test_types/user.d.ts +0 -10
  68. package/dist/test_types/user.js +0 -3
  69. package/dist/test_types/user.js.map +0 -1
  70. package/dist/test_utils.d.ts +0 -20
  71. package/dist/test_utils.js +0 -94
  72. package/dist/test_utils.js.map +0 -1
  73. package/global.d.ts +0 -4
  74. package/gulpfile.ts +0 -47
  75. package/scripts/generate-css-docs.ts +0 -622
  76. package/tsconfig.json +0 -37
  77. package/tsdown.config.ts +0 -32
  78. package/tsec_exemptions.json +0 -9
package/README.md CHANGED
@@ -40,13 +40,31 @@ Here's a small sample of the things that you can do with `mancha`:
40
40
  - **testing**, individual components can be rendered and tested outside the browser
41
41
  - **progressive enhancement**, from simple templating and basic reactivity to a full-blown app
42
42
 
43
- | Feature | mancha | Svelte | React.js | Vue.js | petite-vue | Alpine.js |
44
- | --------------------- | ------ | ------ | -------- | ------ | ---------- | --------- |
45
- | Simple to learn | ✔️ | ❌ | ❌ | ❌ | ✔️ | ✔️ |
46
- | < 18kb compressed | ✔️ | ✔️ | ❌ | ❌ | ✔️ | ❌ |
47
- | Custom web components | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | ❌ |
48
- | Client-side rendering | ✔️ | ❌ | ❌ | ✔️ | ✔️ | ✔️ |
49
- | Server-side rendering | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | ❌ |
43
+ `mancha` is not the smallest option. It is the one that does all of it in a
44
+ single file: drop it in a script tag to prototype, then keep the same templates
45
+ when you move to a bundler or render them on the server.
46
+
47
+ | Library | Size (brotli) | Script tag | Custom tags | Server rendering | CSS utilities |
48
+ | ---------------------- | ------------: | ---------- | ----------- | ---------------- | ------------- |
49
+ | [petite-vue][pv] 0.4.1 | 6,513 B | ✔️ | ❌ | ❌ | ❌ |
50
+ | [htmx][hx] 2.0.10 | 14,996 B | ✔️ | ❌ | ❌ | ❌ |
51
+ | [Svelte][sv] 5.56.9 | 15,106 B | ❌ | ✔️ | ✔️ | ❌ |
52
+ | [Alpine.js][al] 3.16.1 | 15,400 B | ✔️ | ❌ | ❌ | ❌ |
53
+ | **mancha 0.24.2** | **19,852 B** | ✔️ | ✔️ | ✔️ | ✔️ |
54
+ | [React][re] 19.2.8 | 52,002 B | ❌ | ✔️ | ✔️ | ❌ |
55
+ | [Vue][vu] 3.5.41 | 54,171 B | ✔️ | ✔️ | ✔️ | ❌ |
56
+
57
+ Sizes are the brotli-compressed bytes of the file you download, at the version
58
+ shown. Run `npm run compare:sizes` to re-measure them. Svelte and React ship no
59
+ drop-in build — React 19 dropped its UMD build entirely — so their sizes come
60
+ from bundling a minimal app instead.
61
+
62
+ [al]: https://alpinejs.dev
63
+ [hx]: https://htmx.org
64
+ [pv]: https://github.com/vuejs/petite-vue
65
+ [re]: https://react.dev
66
+ [sv]: https://svelte.dev
67
+ [vu]: https://vuejs.org
50
68
 
51
69
  ## Documentation
52
70
 
@@ -60,6 +78,7 @@ Here's a small sample of the things that you can do with `mancha`:
60
78
  - **[TypeScript](./docs/07_typescript.md)**: Type safety and checking.
61
79
  - **[Testing](./docs/08_testing.md)**: Testing your UI.
62
80
  - **[Performance](./docs/09_performance.md)**: Performance monitoring and optimization.
81
+ - **[Security](./docs/10_security.md)**: What rendering a template grants it, and where the trust boundary is.
63
82
 
64
83
  ## AI Agents
65
84
 
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { a as StoreState, i as IRenderer, n as RenderParams, r as RendererPlugin, t as ParserParams } from "./interfaces-C8heJ6BZ.js";
2
1
  import { SafeStyleSheet } from "safevalues";
3
2
 
4
3
  //#region src/css_custom.d.ts
@@ -8,6 +7,457 @@ declare function scanAndInject(root?: Element | Document | DocumentFragment): vo
8
7
  /** For testing: reset module state. */
9
8
  declare function _resetForTesting(): void;
10
9
  //#endregion
10
+ //#region src/store.d.ts
11
+ /**
12
+ * Internal store properties that are always present. These are managed by the framework
13
+ * and should not be set directly by users.
14
+ */
15
+ type InternalStoreState = {
16
+ /** Reference to the parent store in a hierarchy. */
17
+ $parent?: SignalStore;
18
+ /** Reference to the root renderer instance. */
19
+ $rootRenderer?: SignalStore;
20
+ /** Reference to the root DOM node. */
21
+ $rootNode?: Node;
22
+ } & {
23
+ [key: `$$${string}`]: string | null;
24
+ };
25
+ /**
26
+ * Base type for user-defined store state. Uses `any` intentionally to allow flexible
27
+ * user-defined state types without requiring explicit index signatures.
28
+ */
29
+ type StoreState = Record<string, any>;
30
+ /** Type for expression evaluation function. */
31
+ type EvalFunction = (thisArg: SignalStoreProxy, args: Record<string, unknown>) => unknown;
32
+ /** Type for observer entries that include the store context for proper binding. */
33
+ type ObserverEntry = {
34
+ observer: Observer<unknown>;
35
+ store: SignalStore;
36
+ computedKey?: string;
37
+ };
38
+ /**
39
+ * Internal proxy type used within the store implementation. Uses `any` for dynamic property access.
40
+ */
41
+ type SignalStoreProxy = SignalStore & InternalStoreState & {
42
+ [key: string]: any;
43
+ };
44
+ /**
45
+ * The reactive context type exposed to effects and computed functions.
46
+ * Includes the store's typed state T, internal state, and an index signature for dynamic access.
47
+ */
48
+ type ReactiveContext<T extends StoreState = StoreState> = SignalStore<T> & InternalStoreState & T & Record<string, unknown>;
49
+ type Observer<T> = (this: SignalStoreProxy) => T;
50
+ type KeyValueHandler = (this: SignalStoreProxy, key: string, value: unknown) => void;
51
+ /** Symbol used to identify computed value markers. */
52
+
53
+ /** Function type for computed value definitions. Receives reactive context as `$` parameter. */
54
+ type ComputedFn<T extends StoreState, R> = (this: ReactiveContext<T>, $: ReactiveContext<T>) => R;
55
+ declare class SignalStore<T extends StoreState = StoreState> {
56
+ protected readonly evalkeys: string[];
57
+ protected readonly expressionCache: Map<string, EvalFunction>;
58
+ protected readonly observers: Map<string, Set<ObserverEntry>>;
59
+ protected readonly keyHandlers: Map<RegExp, Set<KeyValueHandler>>;
60
+ readonly _store: Map<string, unknown>;
61
+ _lock: Promise<void>;
62
+ /** Keys with a scheduled observer run. */
63
+ private readonly _pending;
64
+ /** Keys whose observers are running right now. */
65
+ private readonly _executing;
66
+ /** Keys written while their own observers were running, to notify afterwards. */
67
+ private readonly _dirty;
68
+ /**
69
+ * Stores created from this one, disposed along with it. A subrenderer is only reachable
70
+ * through the store that created it and the node it renders, so without this nothing ever
71
+ * disposes a nested `:for` row or a `:render` subrenderer.
72
+ */
73
+ protected readonly _children: Set<SignalStore<StoreState>>;
74
+ /** Per-key deep-mutation subscribers, kept stable so they can be unsubscribed later. */
75
+ private readonly _mutationCallbacks;
76
+ /** Set by dispose(). Observers registered by a disposed store must no longer run. */
77
+ protected _disposed: boolean;
78
+ /**
79
+ * Tracks nested computed evaluation depth. When > 0, we're inside a computed
80
+ * function and writes to reactive properties should trigger a warning.
81
+ */
82
+ private _computedDepth;
83
+ constructor(data?: T);
84
+ private wrapObject;
85
+ watch<T>(key: string, observer: Observer<T>): void;
86
+ addKeyHandler(pattern: RegExp, handler: KeyValueHandler): void;
87
+ /**
88
+ * Tags all observer entries matching the given observer function with a computed key.
89
+ * Called after effect runs to mark which observers belong to which computed.
90
+ */
91
+ private tagObserversForComputed;
92
+ /**
93
+ * Synchronously marks all computeds that depend on this key as dirty.
94
+ * Uses the computedKey field on observer entries for O(1) key lookup.
95
+ * Cascades through computed chains (if A depends on B, and B is marked dirty,
96
+ * then A is also marked dirty).
97
+ */
98
+ private markDependentComputedsDirty;
99
+ /**
100
+ * Invokes `entries` and returns their pending tails. Stays synchronous from end to end:
101
+ * the caller relies on nothing being able to interleave until it returns.
102
+ */
103
+ private runObservers;
104
+ notify(key: string, debounceMillis?: number): Promise<void>;
105
+ get<T>(key: string, observer?: Observer<T>): unknown;
106
+ private setupComputed;
107
+ /**
108
+ * Returns this store's deep-mutation subscriber for `key`. The same key always yields the
109
+ * same function, so subscriptions can be matched and removed. Created on demand, so a key
110
+ * that never holds an object never retains a closure.
111
+ */
112
+ private mutationCallback;
113
+ /**
114
+ * Sets a value in the store.
115
+ * @param key - The key to set.
116
+ * @param value - The value to set (can be a computed marker).
117
+ * @param local - If true, sets directly on this store bypassing ancestor lookup.
118
+ * Use for creating local scope variables that shadow ancestors.
119
+ */
120
+ set(key: string, value: unknown, local?: boolean): Promise<void>;
121
+ del(key: string): Promise<void>;
122
+ /**
123
+ * Releases this store and every store created from it, recording them in `disposed` for the
124
+ * single ancestor pass that follows. Observers registered on ancestors are deliberately left
125
+ * to the caller: every store here shares this store's ancestors, so removing them once for
126
+ * the whole subtree replaces a scan of every ancestor once per descendant.
127
+ */
128
+ private disposeSubtree;
129
+ /**
130
+ * Disposes this store by clearing all observers.
131
+ * Call this when the store is no longer needed to prevent memory leaks.
132
+ * Also removes any observers this store registered on ancestor stores, disposes the stores
133
+ * created from this one, and stops listening to deep mutations of the values it holds.
134
+ */
135
+ dispose(): void;
136
+ keys(): string[];
137
+ /**
138
+ * Checks if a key exists in THIS store only (not ancestors).
139
+ * Use `get(key) !== null` to check if a key exists anywhere in the chain.
140
+ */
141
+ has(key: string): boolean;
142
+ /**
143
+ * Returns observer statistics for performance reporting.
144
+ */
145
+ getObserverStats(): {
146
+ totalKeys: number;
147
+ totalObservers: number;
148
+ byKey: Record<string, number>;
149
+ };
150
+ effect<R>(observer: (this: ReactiveContext<T>) => R, _meta?: EffectMeta): R;
151
+ /**
152
+ * Creates a computed property that automatically updates when its dependencies change.
153
+ * The function is evaluated in a reactive effect, and the result is stored. When any
154
+ * reactive property accessed within the function changes, it re-evaluates and updates.
155
+ *
156
+ * **Important:** This method returns a marker object at runtime, but is typed as
157
+ * returning `R` to enable ergonomic property assignment without type casts. The return
158
+ * value must be assigned to a store property (via `set()` or `$.prop =`) - do not use
159
+ * it directly as a value.
160
+ *
161
+ * @example
162
+ * // Using function() to access reactive `this`:
163
+ * store.set('double', store.$computed(function() { return this.count * 2 }));
164
+ *
165
+ * // Using arrow function with $ parameter (for templates):
166
+ * store.set('double', store.$computed(($) => $.count * 2));
167
+ *
168
+ * // Direct property assignment (ergonomic typing):
169
+ * store.$.doubled = store.$computed(($) => $.count * 2);
170
+ */
171
+ $computed<R>(fn: ComputedFn<T, R>): R;
172
+ private proxify;
173
+ get $(): SignalStore<T> & InternalStoreState & T;
174
+ /**
175
+ * Creates an evaluation function for the provided expression.
176
+ * @param expr The expression to be evaluated.
177
+ * @returns The evaluation function.
178
+ */
179
+ private makeEvalFunction;
180
+ /**
181
+ * Retrieves or creates a cached expression function for the provided expression.
182
+ * @param expr - The expression to retrieve or create a cached function for.
183
+ * @returns The cached expression function.
184
+ */
185
+ private cachedExpressionFunction;
186
+ eval(expr: string, args?: Record<string, unknown>): unknown;
187
+ /**
188
+ * Executes an async function and returns a reactive state object that tracks the result.
189
+ *
190
+ * @param fn - The async function to execute.
191
+ * @param options - Optional arguments to pass to the function.
192
+ * @returns A reactive state object with $pending, $result, and $error properties.
193
+ *
194
+ * @example
195
+ * // In :data attribute - executes on mount
196
+ * :data="{ users: $resolve(api.listUsers) }"
197
+ *
198
+ * // With options
199
+ * :data="{ user: $resolve(api.getUser, { path: { id: userId } }) }"
200
+ *
201
+ * // In :on:click - executes on click
202
+ * :on:click="result = $resolve(api.deleteUser, { path: { id } })"
203
+ */
204
+ $resolve<T, O = unknown>(fn: (options?: O) => Promise<T>, options?: O): {
205
+ $pending: boolean;
206
+ $result: T | null;
207
+ $error: Error | null;
208
+ };
209
+ }
210
+ //#endregion
211
+ //#region src/renderer.d.ts
212
+ /**
213
+ * Represents an abstract class for rendering and manipulating HTML content.
214
+ * Extends the `ReactiveProxyStore` class.
215
+ *
216
+ * @template T - The type of the store state. Defaults to `StoreState`.
217
+ */
218
+ declare abstract class IRenderer<T extends StoreState = StoreState> extends SignalStore<T> {
219
+ abstract readonly impl: string;
220
+ private _debugLevel;
221
+ protected readonly dirpath: string;
222
+ /** Performance data collected during rendering. Reset on each mount(). */
223
+ private _perfData;
224
+ /** Debug level ordering for comparison. */
225
+ private static readonly DEBUG_LEVELS;
226
+ readonly _skipNodes: Set<Node>;
227
+ readonly _customElements: Map<string, Node>;
228
+ /**
229
+ * Queue for retrying failed element.value assignments.
230
+ *
231
+ * Some DOM elements (notably <select>) silently fail when setting .value if
232
+ * the required child elements don't exist yet. For example, setting
233
+ * select.value = "banana" does nothing if no <option value="banana"> exists.
234
+ *
235
+ * This happens when :bind on a parent element runs before :for on child
236
+ * elements creates those children (due to BFS traversal order).
237
+ *
238
+ * The fix: after setting .value, check if it actually worked. If not, queue
239
+ * a retry callback. These callbacks are executed at the end of renderNode()
240
+ * after all child elements have been created.
241
+ */
242
+ readonly _pendingValueRetries: Array<() => void>;
243
+ abstract parseHTML(content: string, params?: ParserParams): Document | DocumentFragment;
244
+ abstract serializeHTML(root: DocumentFragment | Node): string;
245
+ abstract createElement(tag: string, owner?: Document | null): Element;
246
+ abstract createComment(content: string, owner?: Document | null): Node;
247
+ abstract textContent(node: Node, tag: string): void;
248
+ /** Hides an element without touching its application-owned styles. */
249
+ cloakElement(elem: Element): void;
250
+ /** Reveals a cloaked element by removing only Mancha's private marker. */
251
+ uncloakElement(elem: Element): void;
252
+ /**
253
+ * Sets the debug level for the current instance.
254
+ *
255
+ * @param flag - Boolean for backwards compat (true -> 'lifecycle') or a DebugLevel.
256
+ * @returns The current instance of the class.
257
+ */
258
+ debug(flag: boolean | DebugLevel): this;
259
+ /**
260
+ * Returns whether debugging is enabled (any level except 'off').
261
+ */
262
+ get debugging(): boolean;
263
+ /**
264
+ * Checks if the current debug level is at least the specified level.
265
+ */
266
+ private shouldLog;
267
+ /**
268
+ * Clears accumulated performance data. Called automatically at the start of `mount()`.
269
+ *
270
+ * Use this to reset performance tracking before measuring a specific user flow.
271
+ * After clearing, only effects and lifecycle events from subsequent operations
272
+ * will be included in the next `getPerformanceReport()` call.
273
+ *
274
+ * @example
275
+ * ```js
276
+ * // Setup phase
277
+ * $.debug('lifecycle');
278
+ * await $.mount(document.body);
279
+ *
280
+ * // Clear to start fresh measurement
281
+ * $.clearPerformanceReport();
282
+ *
283
+ * // Perform user flow to measure
284
+ * $.items = generateLargeList();
285
+ *
286
+ * // Get report for just this flow
287
+ * const report = $.getPerformanceReport();
288
+ * ```
289
+ */
290
+ clearPerformanceReport(): void;
291
+ /**
292
+ * Generates a DOM path for an element (e.g., "html>body>div>ul>li:nth-child(2)").
293
+ */
294
+ private getNodePath;
295
+ /**
296
+ * Builds an effect identifier from metadata.
297
+ */
298
+ buildObserverId(meta?: EffectMeta): string;
299
+ /**
300
+ * Records an effect execution for performance tracking.
301
+ */
302
+ recordObserverExecution(meta: EffectMeta | undefined, duration: number): void;
303
+ /**
304
+ * Returns a structured performance report.
305
+ */
306
+ getPerformanceReport(): PerformanceReport;
307
+ /**
308
+ * Override effect() to add performance tracking.
309
+ * Wraps the observer so re-executions via notify() are also tracked.
310
+ */
311
+ effect<T>(observer: () => T, meta?: EffectMeta): T;
312
+ /**
313
+ * Fetches the remote file at the specified path and returns its content as a string.
314
+ * @param fpath - The path of the remote file to fetch.
315
+ * @param params - Optional parameters for the fetch operation.
316
+ * @returns A promise that resolves to the content of the remote file as a string.
317
+ */
318
+ fetchRemote(fpath: string, params?: RenderParams): Promise<string>;
319
+ /**
320
+ * Fetches a local path and returns its content as a string.
321
+ *
322
+ * @param fpath - The file path of the resource.
323
+ * @param params - Optional render parameters.
324
+ * @returns A promise that resolves to the fetched resource as a string.
325
+ */
326
+ fetchLocal(fpath: string, params?: RenderParams): Promise<string>;
327
+ /**
328
+ * Preprocesses a string content with optional rendering and parsing parameters.
329
+ *
330
+ * @param content - The string content to preprocess.
331
+ * @param params - Optional rendering and parsing parameters.
332
+ * @returns A promise that resolves to a DocumentFragment representing the preprocessed content.
333
+ */
334
+ preprocessString(content: string, params?: RenderParams & ParserParams): Promise<Document | DocumentFragment>;
335
+ /**
336
+ * Preprocesses a remote file by fetching its content and applying preprocessing steps.
337
+ * @param fpath - The path to the remote file.
338
+ * @param params - Optional parameters for rendering and parsing.
339
+ * @returns A Promise that resolves to a DocumentFragment representing the preprocessed content.
340
+ */
341
+ preprocessRemote(fpath: string, params?: RenderParams & ParserParams): Promise<Document | DocumentFragment>;
342
+ /**
343
+ * Preprocesses a local file by fetching its content and applying preprocessing steps.
344
+ * @param fpath - The path to the local file.
345
+ * @param params - Optional parameters for rendering and parsing.
346
+ * @returns A promise that resolves to the preprocessed document fragment.
347
+ */
348
+ preprocessLocal(fpath: string, params?: RenderParams & ParserParams): Promise<Document | DocumentFragment>;
349
+ /**
350
+ * Creates a subrenderer from the current renderer instance.
351
+ * @returns A new instance of the renderer with the same state as the original.
352
+ */
353
+ subrenderer(): IRenderer;
354
+ /**
355
+ * Logs the provided arguments if verbose debugging is enabled.
356
+ * @param args - The arguments to be logged.
357
+ */
358
+ log(...args: unknown[]): void;
359
+ /**
360
+ * Preprocesses a node by applying all the registered preprocessing plugins.
361
+ *
362
+ * @template T - The type of the input node.
363
+ * @param {T} root - The root node to preprocess.
364
+ * @param {RenderParams} [params] - Optional parameters for preprocessing.
365
+ * @returns {Promise<T>} - A promise that resolves to the preprocessed node.
366
+ */
367
+ preprocessNode<T extends Document | DocumentFragment | Node>(root: T, params?: RenderParams): Promise<T>;
368
+ /**
369
+ * Renders the node and applies all the registered rendering plugins.
370
+ *
371
+ * @template T - The type of the root node (Document, DocumentFragment, or Node).
372
+ * @param {T} root - The root node to render.
373
+ * @param {RenderParams} [params] - Optional parameters for rendering.
374
+ * @returns {Promise<T>} - A promise that resolves to the fully rendered root node.
375
+ */
376
+ renderNode<T extends Document | DocumentFragment | Node>(root: T, params?: RenderParams): Promise<T>;
377
+ /**
378
+ * Mounts the Mancha application to a root element in the DOM.
379
+ *
380
+ * @param root - The root element to mount the application to.
381
+ * @param params - Optional parameters for rendering the application.
382
+ * @returns A promise that resolves when the mounting process is complete.
383
+ */
384
+ mount(root: Document | DocumentFragment | Node, params?: RenderParams): Promise<void>;
385
+ }
386
+ //#endregion
387
+ //#region src/interfaces.d.ts
388
+ interface ParserParams {
389
+ /** Whether the file parsed is a root document, or a document fragment. */
390
+ rootDocument?: boolean;
391
+ /** Encoding to use when processing local files. */
392
+ encoding?: "ascii" | "utf8";
393
+ }
394
+ /** The RendererParams interface defines the parameters that can be passed to the renderer. */
395
+ interface RenderParams {
396
+ /** The current directory of the file being rendered. */
397
+ dirpath?: string;
398
+ /** Maximum level of recursion allowed when resolving includes. */
399
+ maxdepth?: number;
400
+ /** Cache policy used when resolving remote paths. */
401
+ cache?: RequestCache | null;
402
+ /** Whether the current node is the root used in Mancha.moun(...). */
403
+ rootNode?: Node;
404
+ }
405
+ type RendererPlugin = (this: IRenderer, node: ChildNode, params?: RenderParams) => void | Promise<void>;
406
+ /** Debug level for controlling performance tracking and logging verbosity. */
407
+ type DebugLevel = "off" | "lifecycle" | "effects" | "verbose";
408
+ /** Metadata for identifying effects in performance tracking. */
409
+ type EffectMeta = {
410
+ /** The directive that created this effect (e.g., 'class', 'bind', 'for'). */
411
+ directive: string;
412
+ /** The DOM element associated with this effect, if any. */
413
+ element?: Element;
414
+ /** The expression being evaluated by this effect. */
415
+ expression?: string;
416
+ /** Direct identifier for effects without a DOM element (e.g., computed property key). */
417
+ id?: string;
418
+ };
419
+ /** Statistics for a tracked effect. */
420
+ type EffectStats = {
421
+ /** Effect identifier (e.g., "bind:my-input:user.name"). */
422
+ id: string;
423
+ /** Number of times this effect has executed. */
424
+ executionCount: number;
425
+ /** Total execution time in milliseconds. */
426
+ totalTime: number;
427
+ /** Average execution time per invocation in milliseconds. */
428
+ avgTime: number;
429
+ };
430
+ /** Structured performance report returned by getPerformanceReport(). */
431
+ type PerformanceReport = {
432
+ /** Timing data for lifecycle methods. */
433
+ lifecycle: {
434
+ mountTime?: number;
435
+ preprocessTime?: number;
436
+ renderTime?: number;
437
+ };
438
+ /** Effect execution statistics. */
439
+ effects: {
440
+ /** Total number of unique effects tracked. */
441
+ total: number;
442
+ /** Aggregate stats grouped by directive type. */
443
+ byDirective: Record<string, {
444
+ count: number;
445
+ totalTime: number;
446
+ }>;
447
+ /** Top 10 slowest effects by total time. */
448
+ slowest: EffectStats[];
449
+ };
450
+ /** Observer registration statistics. */
451
+ observers: {
452
+ /** Number of keys with registered observers. */
453
+ totalKeys: number;
454
+ /** Total number of observer registrations. */
455
+ totalObservers: number;
456
+ /** Observer count per key. */
457
+ byKey: Record<string, number>;
458
+ };
459
+ };
460
+ //#endregion
11
461
  //#region src/css_gen_basic.d.ts
12
462
  declare function rules(): SafeStyleSheet;
13
463
  //#endregion
@@ -15,7 +465,6 @@ declare function rules(): SafeStyleSheet;
15
465
  declare function rules$1(): SafeStyleSheet;
16
466
  //#endregion
17
467
  //#region src/css_gen_utils.d.ts
18
-
19
468
  declare function rules$2(): string;
20
469
  //#endregion
21
470
  //#region src/browser.d.ts