@odoo/owl 3.0.0-alpha.25 → 3.0.0-alpha.28

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 (59) hide show
  1. package/dist/owl.cjs.js +6648 -6618
  2. package/dist/owl.es.js +6628 -6577
  3. package/dist/owl.iife.js +6818 -6790
  4. package/dist/owl.iife.min.js +27 -1
  5. package/dist/types/owl.d.ts +679 -624
  6. package/package.json +9 -95
  7. package/LICENSE +0 -856
  8. package/README.md +0 -139
  9. package/dist/compile_templates.mjs +0 -2458
  10. package/dist/owl-devtools.zip +0 -0
  11. package/dist/types/common/owl_error.d.ts +0 -3
  12. package/dist/types/common/utils.d.ts +0 -8
  13. package/dist/types/compiler/code_generator.d.ts +0 -133
  14. package/dist/types/compiler/index.d.ts +0 -13
  15. package/dist/types/compiler/inline_expressions.d.ts +0 -41
  16. package/dist/types/compiler/parser.d.ts +0 -170
  17. package/dist/types/compiler/standalone/index.d.ts +0 -2
  18. package/dist/types/compiler/standalone/setup_jsdom.d.ts +0 -1
  19. package/dist/types/index.d.ts +0 -1
  20. package/dist/types/runtime/app.d.ts +0 -54
  21. package/dist/types/runtime/blockdom/attributes.d.ts +0 -8
  22. package/dist/types/runtime/blockdom/block_compiler.d.ts +0 -21
  23. package/dist/types/runtime/blockdom/config.d.ts +0 -8
  24. package/dist/types/runtime/blockdom/event_catcher.d.ts +0 -7
  25. package/dist/types/runtime/blockdom/events.d.ts +0 -8
  26. package/dist/types/runtime/blockdom/html.d.ts +0 -17
  27. package/dist/types/runtime/blockdom/index.d.ts +0 -25
  28. package/dist/types/runtime/blockdom/list.d.ts +0 -18
  29. package/dist/types/runtime/blockdom/multi.d.ts +0 -17
  30. package/dist/types/runtime/blockdom/text.d.ts +0 -26
  31. package/dist/types/runtime/blockdom/toggler.d.ts +0 -17
  32. package/dist/types/runtime/component.d.ts +0 -17
  33. package/dist/types/runtime/component_node.d.ts +0 -59
  34. package/dist/types/runtime/context.d.ts +0 -36
  35. package/dist/types/runtime/event_handling.d.ts +0 -1
  36. package/dist/types/runtime/hooks.d.ts +0 -32
  37. package/dist/types/runtime/index.d.ts +0 -46
  38. package/dist/types/runtime/lifecycle_hooks.d.ts +0 -10
  39. package/dist/types/runtime/plugin_hooks.d.ts +0 -6
  40. package/dist/types/runtime/plugin_manager.d.ts +0 -36
  41. package/dist/types/runtime/props.d.ts +0 -21
  42. package/dist/types/runtime/reactivity/computations.d.ts +0 -34
  43. package/dist/types/runtime/reactivity/computed.d.ts +0 -6
  44. package/dist/types/runtime/reactivity/effect.d.ts +0 -1
  45. package/dist/types/runtime/reactivity/proxy.d.ts +0 -47
  46. package/dist/types/runtime/reactivity/signal.d.ts +0 -31
  47. package/dist/types/runtime/registry.d.ts +0 -24
  48. package/dist/types/runtime/rendering/error_handling.d.ts +0 -13
  49. package/dist/types/runtime/rendering/fibers.d.ts +0 -36
  50. package/dist/types/runtime/rendering/scheduler.d.ts +0 -20
  51. package/dist/types/runtime/rendering/template_helpers.d.ts +0 -51
  52. package/dist/types/runtime/resource.d.ts +0 -18
  53. package/dist/types/runtime/status.d.ts +0 -11
  54. package/dist/types/runtime/template_set.d.ts +0 -36
  55. package/dist/types/runtime/types.d.ts +0 -77
  56. package/dist/types/runtime/utils.d.ts +0 -24
  57. package/dist/types/runtime/validation.d.ts +0 -19
  58. package/dist/types/version.d.ts +0 -1
  59. package/tools/compile_owl_templates.mjs +0 -31
@@ -1,448 +1,227 @@
1
1
  declare class VToggler {
2
- key: string;
3
- child: VNode;
4
- parentEl?: HTMLElement | undefined;
5
- constructor(key: string, child: VNode);
6
- mount(parent: HTMLElement, afterNode: Node | null): void;
7
- moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
8
- moveBeforeVNode(other: VToggler | null, afterNode: Node | null): void;
9
- patch(other: VToggler, withBeforeRemove: boolean): void;
10
- beforeRemove(): void;
11
- remove(): void;
12
- firstNode(): Node | undefined;
13
- toString(): string;
2
+ key: string;
3
+ child: VNode;
4
+ parentEl?: HTMLElement | undefined;
5
+ constructor(key: string, child: VNode);
6
+ mount(parent: HTMLElement, afterNode: Node | null): void;
7
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
8
+ moveBeforeVNode(other: VToggler | null, afterNode: Node | null): void;
9
+ patch(other: VToggler, withBeforeRemove: boolean): void;
10
+ beforeRemove(): void;
11
+ remove(): void;
12
+ firstNode(): Node | undefined;
13
+ toString(): string;
14
14
  }
15
15
  declare function toggler(key: string, child: VNode): VNode<VToggler>;
16
-
17
- type BlockType = (data?: any[], children?: VNode[]) => VNode;
18
- /**
19
- * Compiling blocks is a multi-step process:
20
- *
21
- * 1. build an IntermediateTree from the HTML element. This intermediate tree
22
- * is a binary tree structure that encode dynamic info sub nodes, and the
23
- * path required to reach them
24
- * 2. process the tree to build a block context, which is an object that aggregate
25
- * all dynamic info in a list, and also, all ref indexes.
26
- * 3. process the context to build appropriate builder/setter functions
27
- * 4. make a dynamic block class, which will efficiently collect references and
28
- * create/update dynamic locations/children
29
- *
30
- * @param str
31
- * @returns a new block type, that can build concrete blocks
32
- */
16
+ export type BlockType = (data?: any[], children?: VNode[]) => VNode;
33
17
  declare function createBlock(str: string): BlockType;
34
-
35
18
  declare class VList {
36
- children: VNode[];
37
- anchor: Node | undefined;
38
- parentEl?: HTMLElement | undefined;
39
- isOnlyChild?: boolean | undefined;
40
- constructor(children: VNode[]);
41
- mount(parent: HTMLElement, afterNode: Node | null): void;
42
- moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
43
- moveBeforeVNode(other: VList | null, afterNode: Node | null): void;
44
- patch(other: VList, withBeforeRemove: boolean): void;
45
- beforeRemove(): void;
46
- remove(): void;
47
- firstNode(): Node | undefined;
48
- toString(): string;
19
+ children: VNode[];
20
+ anchor: Node | undefined;
21
+ parentEl?: HTMLElement | undefined;
22
+ isOnlyChild?: boolean | undefined;
23
+ constructor(children: VNode[]);
24
+ mount(parent: HTMLElement, afterNode: Node | null): void;
25
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
26
+ moveBeforeVNode(other: VList | null, afterNode: Node | null): void;
27
+ patch(other: VList, withBeforeRemove: boolean): void;
28
+ beforeRemove(): void;
29
+ remove(): void;
30
+ firstNode(): Node | undefined;
31
+ toString(): string;
49
32
  }
50
33
  declare function list(children: VNode[]): VNode<VList>;
51
-
52
34
  declare class VMulti {
53
- children: (VNode | undefined)[];
54
- anchors?: Node[] | undefined;
55
- parentEl?: HTMLElement | undefined;
56
- isOnlyChild?: boolean | undefined;
57
- constructor(children: (VNode | undefined)[]);
58
- mount(parent: HTMLElement, afterNode: Node | null): void;
59
- moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
60
- moveBeforeVNode(other: VMulti | null, afterNode: Node | null): void;
61
- patch(other: VMulti, withBeforeRemove: boolean): void;
62
- beforeRemove(): void;
63
- remove(): void;
64
- firstNode(): Node | undefined;
65
- toString(): string;
35
+ children: (VNode | undefined)[];
36
+ anchors?: Node[] | undefined;
37
+ parentEl?: HTMLElement | undefined;
38
+ isOnlyChild?: boolean | undefined;
39
+ constructor(children: (VNode | undefined)[]);
40
+ mount(parent: HTMLElement, afterNode: Node | null): void;
41
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
42
+ moveBeforeVNode(other: VMulti | null, afterNode: Node | null): void;
43
+ patch(other: VMulti, withBeforeRemove: boolean): void;
44
+ beforeRemove(): void;
45
+ remove(): void;
46
+ firstNode(): Node | undefined;
47
+ toString(): string;
66
48
  }
67
49
  declare function multi(children: (VNode | undefined)[]): VNode<VMulti>;
68
-
69
- declare abstract class VSimpleNode {
70
- text: string | String;
71
- parentEl?: HTMLElement | undefined;
72
- el?: any;
73
- constructor(text: string | String);
74
- mountNode(node: Node, parent: HTMLElement, afterNode: Node | null): void;
75
- moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
76
- moveBeforeVNode(other: VText | null, afterNode: Node | null): void;
77
- beforeRemove(): void;
78
- remove(): void;
79
- firstNode(): Node;
80
- toString(): string | String;
81
- }
82
- declare class VText extends VSimpleNode {
83
- mount(parent: HTMLElement, afterNode: Node | null): void;
84
- patch(other: VText): void;
85
- }
86
- declare class VComment extends VSimpleNode {
87
- mount(parent: HTMLElement, afterNode: Node | null): void;
88
- patch(): void;
50
+ declare class VText {
51
+ text: string | String;
52
+ parentEl?: HTMLElement | undefined;
53
+ el?: any;
54
+ constructor(text: string | String);
55
+ mount(parent: HTMLElement, afterNode: Node | null): void;
56
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
57
+ moveBeforeVNode(other: VText | null, afterNode: Node | null): void;
58
+ beforeRemove(): void;
59
+ remove(): void;
60
+ firstNode(): Node;
61
+ patch(other: VText): void;
62
+ toString(): string | String;
89
63
  }
90
64
  declare function text(str: string | String): VNode<VText>;
91
- declare function comment(str: string): VNode<VComment>;
92
-
93
65
  declare class VHtml {
94
- html: string;
95
- parentEl?: HTMLElement | undefined;
96
- content: ChildNode[];
97
- constructor(html: string);
98
- mount(parent: HTMLElement, afterNode: Node | null): void;
99
- moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
100
- moveBeforeVNode(other: VHtml | null, afterNode: Node | null): void;
101
- patch(other: VHtml): void;
102
- beforeRemove(): void;
103
- remove(): void;
104
- firstNode(): Node;
105
- toString(): string;
66
+ html: string;
67
+ parentEl?: HTMLElement | undefined;
68
+ content: ChildNode[];
69
+ constructor(html: string);
70
+ mount(parent: HTMLElement, afterNode: Node | null): void;
71
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
72
+ moveBeforeVNode(other: VHtml | null, afterNode: Node | null): void;
73
+ patch(other: VHtml): void;
74
+ beforeRemove(): void;
75
+ remove(): void;
76
+ firstNode(): Node;
77
+ toString(): string;
106
78
  }
107
79
  declare function html(str: string): VNode<VHtml>;
108
-
109
- interface VNode<T = any> {
110
- mount(parent: HTMLElement, afterNode: Node | null): void;
111
- moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
112
- moveBeforeVNode(other: T | null, afterNode: Node | null): void;
113
- patch(other: T, withBeforeRemove: boolean): void;
114
- beforeRemove(): void;
115
- remove(): void;
116
- firstNode(): Node | undefined;
117
- el?: undefined | HTMLElement | Text;
118
- parentEl?: undefined | HTMLElement;
119
- isOnlyChild?: boolean | undefined;
120
- key?: any;
121
- }
122
- type BDom = VNode<any>;
123
- declare function mount$1(vnode: VNode, fixture: HTMLElement, afterNode?: Node | null): void;
80
+ export type MountTarget = HTMLElement | ShadowRoot;
81
+ export interface VNode<T = any> {
82
+ mount(parent: MountTarget, afterNode: Node | null): void;
83
+ moveBeforeDOMNode(node: Node | null, parent?: MountTarget): void;
84
+ moveBeforeVNode(other: T | null, afterNode: Node | null): void;
85
+ patch(other: T, withBeforeRemove: boolean): void;
86
+ beforeRemove(): void;
87
+ remove(): void;
88
+ firstNode(): Node | undefined;
89
+ el?: undefined | HTMLElement | Text;
90
+ parentEl?: undefined | HTMLElement;
91
+ isOnlyChild?: boolean | undefined;
92
+ key?: any;
93
+ }
94
+ export type BDom = VNode<any>;
95
+ declare function mount(vnode: VNode, fixture: MountTarget, afterNode?: Node | null): void;
124
96
  declare function patch(vnode1: VNode, vnode2: VNode, withBeforeRemove?: boolean): void;
125
97
  declare function remove(vnode: VNode, withBeforeRemove?: boolean): void;
126
-
127
- interface ResourceOptions<T> {
128
- name?: string;
129
- validation?: T;
130
- }
131
- declare class Resource<T> {
132
- private _items;
133
- private _name?;
134
- private _validation?;
135
- constructor(options?: ResourceOptions<T>);
136
- items: ReactiveValue<T[], T[]>;
137
- add(item: T, options?: {
138
- sequence?: number;
139
- }): Resource<T>;
140
- delete(item: T): Resource<T>;
141
- has(item: T): boolean;
142
- }
143
- declare function useResource<T>(r: Resource<T>, elements: T[]): void;
144
-
145
- interface RegistryOptions<T> {
146
- name?: string;
147
- validation?: T;
148
- }
149
- declare class Registry<T> {
150
- private _map;
151
- private _name;
152
- private _validation?;
153
- constructor(options?: RegistryOptions<T>);
154
- entries: ReactiveValue<[string, T][], [string, T][]>;
155
- items: ReactiveValue<T[], T[]>;
156
- addById<U extends {
157
- id: string;
158
- } & T>(item: U, options?: {
159
- sequence?: number;
160
- }): Registry<T>;
161
- add(key: string, value: T, options?: {
162
- sequence?: number;
163
- }): Registry<T>;
164
- get(key: string, defaultValue?: T): T;
165
- delete(key: string): void;
166
- has(key: string): boolean;
167
- }
168
-
169
- interface ReactiveValue<TRead, TWrite = TRead> {
170
- (): TRead;
171
- /**
172
- * Update the value of the reactive with a new value. If the new value is different
173
- * from the previous values, all computations that depends on this reactive will
174
- * be invalidated, and effects will rerun.
175
- */
176
- set(nextValue: TWrite): void;
98
+ export declare class OwlError extends Error {
99
+ cause?: any;
100
+ }
101
+ declare const STATUS: {
102
+ readonly NEW: 0;
103
+ readonly MOUNTED: 1;
104
+ readonly CANCELLED: 2;
105
+ readonly DESTROYED: 3;
106
+ };
107
+ export type StatusValue = (typeof STATUS)[keyof typeof STATUS];
108
+ export type Callback = (...args: any[]) => void;
109
+ /**
110
+ * Creates a batched version of a callback so that all calls to it in the same
111
+ * microtick will only call the original callback once.
112
+ *
113
+ * @param callback the callback to batch
114
+ * @returns a batched version of the original callback
115
+ */
116
+ export declare function batched(callback: Callback): Callback;
117
+ export interface ReactiveValue<TRead, TWrite = TRead> {
118
+ (): TRead;
119
+ /**
120
+ * Update the value of the reactive with a new value. If the new value is different
121
+ * from the previous values, all computations that depends on this reactive will
122
+ * be invalidated, and effects will rerun.
123
+ */
124
+ set(nextValue: TWrite): void;
177
125
  }
178
126
  declare enum ComputationState {
179
- EXECUTED = 0,
180
- STALE = 1,
181
- PENDING = 2
182
- }
183
- interface Atom<T = any> {
184
- observers: Set<ComputationAtom>;
185
- value: T;
127
+ EXECUTED = 0,
128
+ STALE = 1,
129
+ PENDING = 2
186
130
  }
187
- interface ComputationAtom<T = any> extends Atom<T> {
188
- compute: () => T;
189
- isDerived: boolean;
190
- sources: Set<Atom>;
191
- state: ComputationState;
131
+ export interface Atom<T = any> {
132
+ observers: Set<ComputationAtom>;
133
+ value: T;
192
134
  }
193
- declare function untrack<T>(fn: (...args: any[]) => T): T;
194
-
195
- declare const enum STATUS {
196
- NEW = 0,
197
- MOUNTED = 1,// is ready, and in DOM. It has a valid el
198
- CANCELLED = 2,
199
- DESTROYED = 3
200
- }
201
- type STATUS_DESCR = "new" | "started" | "mounted" | "cancelled" | "destroyed";
202
- declare function status(entity: Component | Plugin): STATUS_DESCR;
203
-
204
- interface PluginConstructor {
205
- new (...args: any[]): Plugin;
206
- id: string;
207
- }
208
- declare class Plugin {
209
- private static _shadowId;
210
- static get id(): string;
211
- static set id(shadowId: string);
212
- __owl__: PluginManager;
213
- constructor(manager: PluginManager);
214
- setup(): void;
215
- }
216
- interface PluginManagerOptions {
217
- parent?: PluginManager | null;
218
- config?: Record<string, any>;
219
- }
220
- declare class PluginManager {
221
- app: App;
222
- config: Record<string, any>;
223
- onDestroyCb: Function[];
224
- computations: ComputationAtom[];
225
- plugins: Record<string, Plugin>;
226
- status: STATUS;
227
- constructor(app: App, options?: PluginManagerOptions);
228
- destroy(): void;
229
- getPluginById<T extends Plugin>(id: string): T | null;
230
- getPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
231
- startPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
232
- startPlugins(pluginConstructors: PluginConstructor[]): void;
135
+ export interface ComputationAtom<T = any> extends Atom<T> {
136
+ compute: () => T;
137
+ isDerived: boolean;
138
+ sources: Set<Atom>;
139
+ state: ComputationState;
233
140
  }
234
-
235
- declare class Fiber {
236
- node: ComponentNode;
237
- bdom: BDom | null;
238
- root: RootFiber | null;
239
- parent: Fiber | null;
240
- children: Fiber[];
241
- appliedToDom: boolean;
242
- deep: boolean;
243
- childrenMap: ComponentNode["children"];
244
- constructor(node: ComponentNode, parent: Fiber | null);
245
- render(): void;
246
- }
247
- declare class RootFiber extends Fiber {
248
- counter: number;
249
- willPatch: Fiber[];
250
- patched: Fiber[];
251
- mounted: Fiber[];
252
- locked: boolean;
253
- complete(): void;
254
- setCounter(newValue: number): void;
255
- }
256
- type Position = "first-child" | "last-child";
257
- interface MountOptions {
258
- position?: Position;
259
- }
260
- declare class MountFiber extends RootFiber {
261
- target: HTMLElement;
262
- position: Position;
263
- constructor(node: ComponentNode, target: HTMLElement, options?: MountOptions);
264
- complete(): void;
265
- }
266
-
267
- type LifecycleHook = Function;
268
- declare class ComponentNode implements VNode<ComponentNode> {
269
- el?: HTMLElement | Text | undefined;
270
- app: App;
271
- fiber: Fiber | null;
272
- component: Component;
273
- bdom: BDom | null;
274
- status: STATUS;
275
- forceNextRender: boolean;
276
- parentKey: string | null;
277
- props: Record<string, any>;
278
- defaultProps: Record<string, any>;
279
- renderFn: Function;
280
- parent: ComponentNode | null;
281
- children: {
282
- [key: string]: ComponentNode;
283
- };
284
- willStart: LifecycleHook[];
285
- willUpdateProps: LifecycleHook[];
286
- willUnmount: LifecycleHook[];
287
- mounted: LifecycleHook[];
288
- willPatch: LifecycleHook[];
289
- patched: LifecycleHook[];
290
- willDestroy: LifecycleHook[];
291
- signalComputation: ComputationAtom;
292
- computations: ComputationAtom[];
293
- pluginManager: PluginManager;
294
- constructor(C: ComponentConstructor, props: Record<string, any>, app: App, parent: ComponentNode | null, parentKey: string | null);
295
- mountComponent(target: any, options?: MountOptions): void;
296
- initiateRender(fiber: Fiber | MountFiber): Promise<void>;
297
- render(deep: boolean): Promise<void>;
298
- cancel(): void;
299
- _cancel(): void;
300
- destroy(): void;
301
- _destroy(): void;
302
- updateAndRender(props: Record<string, any>, parentFiber: Fiber): Promise<void>;
303
- /**
304
- * Finds a child that has dom that is not yet updated, and update it. This
305
- * method is meant to be used only in the context of repatching the dom after
306
- * a mounted hook failed and was handled.
307
- */
308
- updateDom(): void;
309
- firstNode(): Node | undefined;
310
- mount(parent: HTMLElement, anchor: ChildNode): void;
311
- moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
312
- moveBeforeVNode(other: ComponentNode | null, afterNode: Node | null): void;
313
- patch(): void;
314
- _patch(): void;
315
- beforeRemove(): void;
316
- remove(): void;
317
- }
318
-
319
- interface StaticComponentProperties {
320
- template: string;
321
- components?: {
322
- [componentName: string]: ComponentConstructor;
323
- };
324
- }
325
- interface ComponentConstructor extends StaticComponentProperties {
326
- new (node: ComponentNode): Component;
327
- }
328
- declare class Component {
329
- static template: string;
330
- __owl__: ComponentNode;
331
- constructor(node: ComponentNode);
332
- setup(): void;
141
+ export declare function untrack<T>(fn: (...args: any[]) => T): T;
142
+ /**
143
+ * Returns the active scope. Throws if no scope is active — use this inside
144
+ * hooks and setup functions where the caller is expected to be in a scope.
145
+ */
146
+ export declare function useScope(): Scope;
147
+ export declare abstract class Scope {
148
+ app: any;
149
+ status: StatusValue;
150
+ computations: ComputationAtom[];
151
+ willStart: Array<() => any>;
152
+ private _controller;
153
+ private _destroyCbs;
154
+ constructor(app: any);
155
+ /**
156
+ * Pushes this scope on the stack for the duration of `callback`. Any code
157
+ * executed inside `callback` can reach this scope via `useScope()`.
158
+ */
159
+ run<T>(callback: () => T): T;
160
+ /**
161
+ * An AbortSignal tied to this scope's lifetime. If the scope is already
162
+ * dead, returns a pre-aborted signal. Lazily allocates an AbortController
163
+ * on first access.
164
+ */
165
+ get abortSignal(): AbortSignal;
166
+ /**
167
+ * Awaits `p`, throwing an AbortError if the scope is dead before or after
168
+ * the await. Unlike `until(signal, p)`, this does not allocate an
169
+ * AbortController — status checks are sufficient for guarding between
170
+ * awaits.
171
+ */
172
+ until<T>(p: Promise<T>): Promise<T>;
173
+ /**
174
+ * Registers a callback to run when the scope is destroyed. If the scope is
175
+ * already destroyed, the callback is invoked immediately.
176
+ */
177
+ onDestroy(cb: () => void): void;
178
+ /**
179
+ * Marks the scope as cancelled and aborts its signal. Used when an entity is
180
+ * abandoned before it reaches the MOUNTED state. Subclasses may override to
181
+ * extend the behavior (e.g. ComponentNode recurses to children).
182
+ */
183
+ cancel(): void;
184
+ /**
185
+ * Aborts the scope's signal, runs all registered onDestroy callbacks in
186
+ * reverse registration order, disposes any computations attached to this
187
+ * scope, and transitions status to DESTROYED. Callbacks run *before* the
188
+ * status transition so they can still observe the pre-destroyed state
189
+ * (matching the prior onWillDestroy contract). Errors in callbacks are
190
+ * routed to `reportError`.
191
+ */
192
+ finalize(reportError: (e: unknown) => void): void;
193
+ /**
194
+ * Wrapper applied to lifecycle callbacks before they are stored. The base
195
+ * implementation prepends the scope as the first argument, so every
196
+ * lifecycle callback receives the scope it was registered in.
197
+ * ComponentNode overrides to additionally bind `this` to the component and,
198
+ * in dev mode, to rename the bound function so the hook shows up as
199
+ * `ComponentName.hookName` in stack traces.
200
+ */
201
+ decorate(fn: Function, _hookName: string): Function;
333
202
  }
334
-
335
- type Constructor<T = any> = {
336
- new (...args: any[]): T;
337
- };
338
- type GetOptionalEntries<T> = {
339
- [K in keyof T as K extends `${infer P}?` ? P : never]?: T[K];
340
- };
341
- type GetRequiredEntries<T> = {
342
- [K in keyof T as K extends `${string}?` ? never : K]: T[K];
343
- };
344
- type PrettifyShape<T> = T extends Function ? T : {
345
- [K in keyof T]: T[K];
346
- };
347
- type ResolveOptionalEntries<T> = PrettifyShape<GetRequiredEntries<T> & GetOptionalEntries<T>>;
348
- type KeyedObject<K extends string[]> = {
349
- [P in K[number]]: any;
350
- };
351
- type ResolveShapedObject<T extends {}> = PrettifyShape<ResolveOptionalEntries<T>>;
352
- type ResolveObjectType<T extends {}> = ResolveShapedObject<T extends string[] ? KeyedObject<T> : T>;
353
- type UnionToIntersection<U> = (U extends any ? (_: U) => any : never) extends (_: infer I) => void ? I : never;
354
- declare function anyType(): any;
355
- declare function booleanType(): boolean;
356
- declare function numberType(): number;
357
- declare function stringType(): string;
358
- declare function arrayType(): any[];
359
- declare function arrayType<T>(elementType: T): T[];
360
- declare function constructorType<T extends Constructor>(constructor: T): T;
361
- declare function customValidator<T>(type: T, validator: (value: T) => boolean, errorMessage?: string): T;
362
- declare function functionType(): (...parameters: any[]) => any;
363
- declare function functionType<const P extends any[]>(parameters: P): (...parameters: P) => void;
364
- declare function functionType<const P extends any[], R>(parameters: P, result: R): (...parameters: P) => R;
365
- declare function instanceType<T extends Constructor>(constructor: T): InstanceType<T>;
366
- declare function intersection<T extends any[]>(types: T): UnionToIntersection<T[number]>;
367
- type LiteralTypes = number | string | boolean | null | undefined;
368
- declare function literalType<const T extends LiteralTypes>(literal: T): T;
369
- declare function literalSelection<const T extends LiteralTypes>(literals: T[]): T;
370
- declare function objectType(): Record<string, any>;
371
- declare function objectType<const Keys extends string[]>(keys: Keys): ResolveOptionalEntries<KeyedObject<Keys>>;
372
- declare function objectType<Shape extends {}>(shape: Shape): ResolveOptionalEntries<Shape>;
373
- declare function strictObjectType<const Keys extends string[]>(keys: Keys): ResolveOptionalEntries<KeyedObject<Keys>>;
374
- declare function strictObjectType<Shape extends {}>(shape: Shape): ResolveOptionalEntries<Shape>;
375
- declare function promiseType(): Promise<void>;
376
- declare function promiseType<T>(type: T): Promise<T>;
377
- declare function recordType(): Record<PropertyKey, any>;
378
- declare function recordType<V>(valueType: V): Record<PropertyKey, V>;
379
- declare function tuple<const T extends any[]>(types: T): T;
380
- declare function union<T extends any[]>(types: T): T[number];
381
- declare function reactiveValueType(): ReactiveValue<any>;
382
- declare function reactiveValueType<T>(type: T): ReactiveValue<T>;
383
- declare function componentType(): typeof Component;
384
- declare function ref(): HTMLElement | null;
385
- declare function ref<T extends Constructor<HTMLElement>>(type: T): InstanceType<T> | null;
386
- declare const types: {
387
- and: typeof intersection;
388
- any: typeof anyType;
389
- array: typeof arrayType;
390
- boolean: typeof booleanType;
391
- component: typeof componentType;
392
- constructor: typeof constructorType;
393
- customValidator: typeof customValidator;
394
- function: typeof functionType;
395
- instanceOf: typeof instanceType;
396
- literal: typeof literalType;
397
- number: typeof numberType;
398
- object: typeof objectType;
399
- or: typeof union;
400
- promise: typeof promiseType;
401
- record: typeof recordType;
402
- ref: typeof ref;
403
- selection: typeof literalSelection;
404
- signal: typeof reactiveValueType;
405
- strictObject: typeof strictObjectType;
406
- string: typeof stringType;
407
- tuple: typeof tuple;
408
- };
409
-
410
- declare const isProps: unique symbol;
411
- type WithDefaults<T, D> = T & Required<D>;
412
- type Props<T extends {}> = T & {
413
- [isProps]: true;
414
- };
415
- type GetPropsDefaults<T extends object> = PrettifyShape<GetOptionalEntries<T>>;
416
- type GetPropsWithOptionals<T> = T extends Props<infer P> ? (P extends WithDefaults<infer R, any> ? R : P) : never;
417
- type GetProps<T> = {
418
- [K in keyof T]: T[K] extends {
419
- [isProps]: true;
420
- } ? (x: GetPropsWithOptionals<T[K]>) => void : never;
421
- }[keyof T] extends (x: infer I) => void ? {
422
- [K in keyof I]: I[K];
423
- } : never;
424
- declare function props(): Props<Record<string, any>>;
425
- declare function props<const Keys extends string[]>(keys: Keys): Props<ResolveObjectType<Keys>>;
426
- declare function props<const Keys extends string[], Defaults>(keys: Keys, defaults: Defaults & GetPropsDefaults<KeyedObject<Keys>>): Props<WithDefaults<ResolveObjectType<Keys>, Defaults>>;
427
- declare function props<Shape extends {}>(shape: Shape): Props<ResolveObjectType<Shape>>;
428
- declare function props<Shape extends {}, Defaults>(shape: Shape, defaults: Defaults & GetPropsDefaults<Shape>): Props<WithDefaults<ResolveObjectType<Shape>, Defaults>>;
429
-
430
- type Target = object;
431
- type Reactive<T extends Target> = T;
203
+ /**
204
+ * Returns the scope currently active on the stack, or null if none. Prefer
205
+ * `useScope()` in hook-like code that expects to be called inside a scope;
206
+ * reach for `getScope()` only when the absence of a scope is meaningful.
207
+ */
208
+ export declare function getScope(): Scope | null;
209
+ export type Target = object;
210
+ export type Reactive<T extends Target> = T;
432
211
  /**
433
212
  * Mark an object or array so that it is ignored by the reactivity system
434
213
  *
435
214
  * @param value the value to mark
436
215
  * @returns the object itself
437
216
  */
438
- declare function markRaw<T extends Target>(value: T): T;
217
+ export declare function markRaw<T extends Target>(value: T): T;
439
218
  /**
440
219
  * Given a proxy objet, return the raw (non proxy) underlying object
441
220
  *
442
221
  * @param value a proxy value
443
222
  * @returns the underlying value
444
223
  */
445
- declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
224
+ export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
446
225
  /**
447
226
  * Creates a reactive proxy for an object. Reading data on the proxy object
448
227
  * subscribes to changes to the data. Writing data on the object will cause the
@@ -470,168 +249,420 @@ declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T
470
249
  * proxy has changed
471
250
  * @returns a proxy that tracks changes to it
472
251
  */
473
- declare function proxy<T extends Target>(target: T): T;
474
-
475
- declare class Scheduler {
476
- static requestAnimationFrame: (callback: FrameRequestCallback) => number;
477
- tasks: Set<RootFiber>;
478
- requestAnimationFrame: Window["requestAnimationFrame"];
479
- frame: number;
480
- delayedRenders: Fiber[];
481
- cancelledNodes: Set<ComponentNode>;
482
- processing: boolean;
483
- constructor();
484
- addFiber(fiber: Fiber): void;
485
- scheduleDestroy(node: ComponentNode): void;
486
- /**
487
- * Process all current tasks. This only applies to the fibers that are ready.
488
- * Other tasks are left unchanged.
489
- */
490
- flush(): void;
491
- processTasks(): void;
252
+ export declare function proxy<T extends Target>(target: T): T;
253
+ export interface Signal<T> extends ReactiveValue<T> {
254
+ /**
255
+ * Update the value of the signal with a new value. If the new value is different
256
+ * from the previous values, all computations that depends on this signal will
257
+ * be invalidated, and effects will rerun.
258
+ */
259
+ set(nextValue: T): void;
260
+ }
261
+ export interface SignalOptions<T> {
262
+ type?: T;
492
263
  }
493
-
494
- type CustomDirectives = Record<string, (node: Element, value: string, modifier: string[]) => void>;
495
- type Template = (context: any, vnode: any, key?: string) => BDom;
496
- type TemplateFunction = (app: TemplateSet, bdom: any, helpers: any) => Template;
497
-
498
- interface TemplateSetConfig {
499
- dev?: boolean;
500
- translatableAttributes?: string[];
501
- translateFn?: (s: string, translationCtx: string) => string;
502
- templates?: string | Document | Record<string, string>;
503
- getTemplate?: (s: string) => Element | Function | string | void;
504
- customDirectives?: CustomDirectives;
505
- globalValues?: object;
506
- }
507
- declare class TemplateSet {
508
- static registerTemplate(name: string, fn: TemplateFunction): void;
509
- dev: boolean;
510
- rawTemplates: typeof globalTemplates;
511
- templates: {
512
- [name: string]: Template;
513
- };
514
- getRawTemplate?: (s: string) => Element | Function | string | void;
515
- translateFn?: (s: string, translationCtx: string) => string;
516
- translatableAttributes?: string[];
517
- customDirectives: CustomDirectives;
518
- runtimeUtils: object;
519
- hasGlobalValues: boolean;
520
- constructor(config?: TemplateSetConfig);
521
- addTemplate(name: string, template: string | Element): void;
522
- addTemplates(xml: string | Document): void;
523
- getTemplate(name: string): Template;
524
- private _compileTemplate;
525
- }
526
- declare const globalTemplates: {
527
- [key: string]: string | Element | TemplateFunction;
528
- };
529
- declare function xml(...args: Parameters<typeof String.raw>): string;
530
- declare namespace xml {
531
- var nextId: number;
264
+ declare function invalidateSignal(signal: Signal<any>): void;
265
+ declare function signalArray<T>(initialValue: T[]): Signal<T[]>;
266
+ declare function signalArray<T>(initialValue: NoInfer<T>[], options: SignalOptions<T>): Signal<T[]>;
267
+ declare function signalObject<T extends Record<PropertyKey, any>>(initialValue: T): Signal<T>;
268
+ declare function signalObject<T extends Record<PropertyKey, any>>(initialValue: NoInfer<T>, options: SignalOptions<T>): Signal<T>;
269
+ export interface MapSignalOptions<K, V> {
270
+ name?: string;
271
+ keyType?: K;
272
+ valueType?: V;
273
+ }
274
+ declare function signalMap<K, V>(initialValue: Map<K, V>): Signal<Map<K, V>>;
275
+ declare function signalMap<K, V>(initialValue: NoInfer<Map<K, V>>, options: MapSignalOptions<K, V>): Signal<Map<K, V>>;
276
+ declare function signalSet<T>(initialValue: Set<T>): Signal<Set<T>>;
277
+ declare function signalSet<T>(initialValue: Set<NoInfer<T>>, options: SignalOptions<T>): Signal<Set<T>>;
278
+ export declare function signal<T>(value: T): Signal<T>;
279
+ export declare function signal<T>(value: NoInfer<T>, options: SignalOptions<T>): Signal<T>;
280
+ export declare namespace signal {
281
+ var invalidate: typeof invalidateSignal;
282
+ var Array: typeof signalArray;
283
+ var Map: typeof signalMap;
284
+ var Object: typeof signalObject;
285
+ var Set: typeof signalSet;
286
+ }
287
+ export interface ComputedOptions<TWrite> {
288
+ set?(value: TWrite): void;
289
+ }
290
+ export declare function computed<TRead, TWrite = TRead>(getter: () => TRead, options?: ComputedOptions<TWrite>): ReactiveValue<TRead, TWrite>;
291
+ export declare function effect<T>(fn: () => T): () => void;
292
+ export interface AsyncComputedContext {
293
+ readonly abortSignal: AbortSignal;
294
+ }
295
+ export interface AsyncComputedOptions<T> {
296
+ initial?: T;
297
+ }
298
+ export interface AsyncComputed<T> {
299
+ (): T | undefined;
300
+ loading(): boolean;
301
+ error(): Error | null;
302
+ refresh(): void;
303
+ dispose(): void;
532
304
  }
533
-
534
- type Callback = (...args: any[]) => void;
535
305
  /**
536
- * Creates a batched version of a callback so that all calls to it in the same
537
- * microtick will only call the original callback once.
538
- *
539
- * @param callback the callback to batch
540
- * @returns a batched version of the original callback
306
+ * @experimental The exact API is subject to change in future versions.
541
307
  */
542
- declare function batched(callback: Callback): Callback;
543
- declare function validateTarget(target: HTMLElement | ShadowRoot): void;
544
- declare class EventBus extends EventTarget {
545
- trigger(name: string, payload?: any): void;
308
+ export declare function asyncComputed<T>(fetcher: (ctx: AsyncComputedContext) => Promise<T>, options?: AsyncComputedOptions<T>): AsyncComputed<T>;
309
+ export interface ValidationIssue {
310
+ message: string;
311
+ path?: PropertyKey[];
312
+ received?: any;
313
+ [K: string]: any;
314
+ }
315
+ export declare function assertType(value: any, validation: any, errorMessage?: string): void;
316
+ export declare function validateType(value: any, validation: any): ValidationIssue[];
317
+ export type Constructor<T = any> = {
318
+ new (...args: any[]): T;
319
+ };
320
+ export type GetOptionalEntries<T> = {
321
+ [K in keyof T as K extends `${infer P}?` ? P : never]?: T[K];
322
+ };
323
+ export type GetRequiredEntries<T> = {
324
+ [K in keyof T as K extends `${string}?` ? never : K]: T[K];
325
+ };
326
+ export type PrettifyShape<T> = T extends Function ? T : {
327
+ [K in keyof T]: T[K];
328
+ };
329
+ export type ResolveOptionalEntries<T> = PrettifyShape<GetRequiredEntries<T> & GetOptionalEntries<T>>;
330
+ export type KeyedObject<K extends string[]> = {
331
+ [P in K[number]]: any;
332
+ };
333
+ export type ResolveShapedObject<T extends {}> = PrettifyShape<ResolveOptionalEntries<T>>;
334
+ export type ResolveObjectType<T extends {}> = ResolveShapedObject<T extends string[] ? KeyedObject<T> : T>;
335
+ export type UnionToIntersection<U> = (U extends any ? (_: U) => any : never) extends (_: infer I) => void ? I : never;
336
+ declare function constructorType<T extends Constructor>(constructor: T): T;
337
+ export type LiteralTypes = number | string | boolean | null | undefined;
338
+ export interface ResourceOptions<T> {
339
+ name?: string;
340
+ validation?: T;
341
+ }
342
+ export interface ResourceAddOptions {
343
+ sequence?: number;
344
+ }
345
+ export declare class Resource<T> {
346
+ private _items;
347
+ private _name?;
348
+ private _validation?;
349
+ constructor(options?: ResourceOptions<T>);
350
+ items: ReactiveValue<T[], T[]>;
351
+ add(item: T, options?: ResourceAddOptions): Resource<T>;
352
+ delete(item: T): Resource<T>;
353
+ has(item: T): boolean;
354
+ use(item: T, options?: ResourceAddOptions): Resource<T>;
355
+ }
356
+ export interface RegistryOptions<T> {
357
+ name?: string;
358
+ validation?: T;
359
+ }
360
+ export interface RegistryAddOptions extends ResourceAddOptions {
361
+ force?: boolean;
362
+ }
363
+ export declare class Registry<T> {
364
+ private _map;
365
+ private _name;
366
+ private _validation?;
367
+ constructor(options?: RegistryOptions<T>);
368
+ entries: ReactiveValue<[
369
+ string,
370
+ T
371
+ ][], [
372
+ string,
373
+ T
374
+ ][]>;
375
+ items: ReactiveValue<T[], T[]>;
376
+ addById<U extends {
377
+ id: string;
378
+ } & T>(item: U, options?: RegistryAddOptions): Registry<T>;
379
+ add(key: string, value: T, options?: RegistryAddOptions): Registry<T>;
380
+ get(key: string, defaultValue?: T): T;
381
+ delete(key: string): void;
382
+ has(key: string): boolean;
383
+ use(key: string, value: T, options?: RegistryAddOptions): Registry<T>;
384
+ useById<U extends {
385
+ id: string;
386
+ } & T>(item: U, options?: RegistryAddOptions): Registry<T>;
387
+ }
388
+ export interface PluginConstructor {
389
+ new (...args: any[]): Plugin$1;
390
+ id: string;
391
+ }
392
+ declare class Plugin$1 {
393
+ private static _shadowId;
394
+ static get id(): string;
395
+ static set id(shadowId: string);
396
+ __owl__: PluginManager;
397
+ constructor(manager: PluginManager);
398
+ setup(): void;
399
+ }
400
+ export interface PluginManagerOptions {
401
+ parent?: PluginManager | null;
402
+ config?: Record<string, any>;
403
+ }
404
+ declare class PluginManager extends Scope {
405
+ config: Record<string, any>;
406
+ plugins: Record<string, Plugin$1>;
407
+ ready: Promise<void>;
408
+ constructor(app: any, options?: PluginManagerOptions);
409
+ destroy(): void;
410
+ getPluginById<T extends Plugin$1>(id: string): T | null;
411
+ getPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
412
+ startPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
413
+ startPlugins(pluginConstructors: PluginConstructor[]): void;
546
414
  }
547
- declare function whenReady(fn?: any): Promise<void>;
548
- declare class Markup extends String {
415
+ declare class Fiber {
416
+ node: ComponentNode;
417
+ bdom: BDom | null;
418
+ root: RootFiber | null;
419
+ parent: Fiber | null;
420
+ children: Fiber[];
421
+ appliedToDom: boolean;
422
+ deep: boolean;
423
+ childrenMap: ComponentNode["children"];
424
+ constructor(node: ComponentNode, parent: Fiber | null);
425
+ render(): void;
549
426
  }
550
- declare function htmlEscape(str: any): Markup;
551
- declare function markup(strings: TemplateStringsArray, ...placeholders: unknown[]): Markup;
552
- declare function markup(value: string): Markup;
553
-
554
- type ComponentInstance<C extends ComponentConstructor> = C extends new (...args: any) => infer T ? T : never;
555
- interface RootConfig<P> {
556
- props?: P;
557
- }
558
- interface AppConfig extends TemplateSetConfig {
559
- name?: string;
560
- plugins?: PluginConstructor[] | Resource<PluginConstructor>;
561
- config?: Record<string, any>;
562
- test?: boolean;
563
- }
564
- declare global {
565
- interface Window {
566
- __OWL_DEVTOOLS__: {
567
- apps: Set<App>;
568
- Fiber: typeof Fiber;
569
- RootFiber: typeof RootFiber;
570
- toRaw: typeof toRaw;
571
- proxy: typeof proxy;
572
- };
573
- }
574
- }
575
- type MountTarget = HTMLElement | ShadowRoot;
576
- interface Root<T extends ComponentConstructor> {
577
- node: ComponentNode;
578
- promise: Promise<ComponentInstance<T>>;
579
- mount(target: MountTarget, options?: MountOptions): Promise<ComponentInstance<T>>;
580
- destroy(): void;
581
- }
582
- declare class App extends TemplateSet {
583
- static validateTarget: typeof validateTarget;
584
- static apps: Set<App>;
585
- static version: string;
586
- name: string;
587
- scheduler: Scheduler;
588
- roots: Set<Root<any>>;
589
- pluginManager: PluginManager;
590
- constructor(config?: AppConfig);
591
- createRoot<T extends ComponentConstructor>(Root: T, config?: RootConfig<GetProps<ComponentInstance<T>>>): Root<T>;
592
- private mountNode;
593
- destroy(): void;
594
- _handleError(error: any): void;
595
- }
596
- declare function mount<T extends ComponentConstructor>(C: T, target: MountTarget, config?: AppConfig & RootConfig<GetProps<ComponentInstance<T>>> & MountOptions): Promise<ComponentInstance<T>>;
597
-
598
- interface Signal<T> extends ReactiveValue<T> {
599
- /**
600
- * Update the value of the signal with a new value. If the new value is different
601
- * from the previous values, all computations that depends on this signal will
602
- * be invalidated, and effects will rerun.
603
- */
604
- set(nextValue: T): void;
427
+ declare class RootFiber extends Fiber {
428
+ counter: number;
429
+ willPatch: Fiber[];
430
+ patched: Fiber[];
431
+ mounted: Fiber[];
432
+ locked: boolean;
433
+ complete(): void;
434
+ setCounter(newValue: number): void;
435
+ }
436
+ export type Position = "first-child" | "last-child";
437
+ export interface MountOptions {
438
+ position?: Position;
439
+ afterNode?: Node | null;
605
440
  }
606
- interface SignalOptions<T> {
607
- type?: T;
441
+ declare class MountFiber extends RootFiber {
442
+ target: MountTarget | null;
443
+ position: Position;
444
+ afterNode: Node | null;
445
+ prepared: boolean;
446
+ onPrepared: (() => void) | null;
447
+ constructor(node: ComponentNode, target: MountTarget | null, options?: MountOptions);
448
+ complete(): void;
449
+ commit(target: MountTarget, options?: MountOptions): void;
450
+ private _mount;
451
+ }
452
+ export type LifecycleHook = Function;
453
+ declare class ComponentNode extends Scope implements VNode<ComponentNode> {
454
+ fiber: Fiber | null;
455
+ component: Component;
456
+ bdom: BDom | null;
457
+ componentName: string;
458
+ forceNextRender: boolean;
459
+ parentKey: string | null;
460
+ props: Record<string, any>;
461
+ defaultProps: Record<string, any> | null;
462
+ renderFn: Function;
463
+ parent: ComponentNode | null;
464
+ children: {
465
+ [key: string]: ComponentNode;
466
+ };
467
+ willUpdateProps: LifecycleHook[];
468
+ willUnmount: LifecycleHook[];
469
+ mounted: LifecycleHook[];
470
+ willPatch: LifecycleHook[];
471
+ patched: LifecycleHook[];
472
+ signalComputation: ComputationAtom;
473
+ pluginManager: PluginManager;
474
+ constructor(C: ComponentConstructor, props: Record<string, any>, app: App, parent: ComponentNode | null, parentKey: string | null);
475
+ decorate(f: Function, hookName: string): Function;
476
+ initiateRender(fiber: Fiber | MountFiber): Promise<void>;
477
+ render(deep: boolean): Promise<void>;
478
+ cancel(): void;
479
+ _cancel(): void;
480
+ destroy(): void;
481
+ _destroy(): void;
482
+ /**
483
+ * Finds a child that has dom that is not yet updated, and update it. This
484
+ * method is meant to be used only in the context of repatching the dom after
485
+ * a mounted hook failed and was handled.
486
+ */
487
+ updateDom(): void;
488
+ firstNode(): Node | undefined;
489
+ mount(parent: HTMLElement, anchor: ChildNode): void;
490
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
491
+ moveBeforeVNode(other: ComponentNode | null, afterNode: Node | null): void;
492
+ patch(): void;
493
+ _patch(): void;
494
+ beforeRemove(): void;
495
+ remove(): void;
496
+ }
497
+ export interface StaticComponentProperties {
498
+ template: string;
499
+ components?: {
500
+ [componentName: string]: ComponentConstructor;
501
+ };
502
+ }
503
+ export interface ComponentConstructor extends StaticComponentProperties {
504
+ new (node: ComponentNode): Component;
505
+ }
506
+ export declare class Component {
507
+ static template: string;
508
+ __owl__: ComponentNode;
509
+ constructor(node: ComponentNode);
510
+ setup(): void;
608
511
  }
609
- declare function invalidateSignal(signal: Signal<any>): void;
610
- declare function signalArray<T>(initialValue: T[], options?: SignalOptions<T>): Signal<T[]>;
611
- declare function signalObject<T extends Record<PropertyKey, any>>(initialValue: T, options?: SignalOptions<T>): Signal<T>;
612
- interface MapSignalOptions<K, V> {
613
- name?: string;
614
- keyType?: K;
615
- valueType?: V;
616
- }
617
- declare function signalMap<K, V>(initialValue: Map<K, V>, options?: MapSignalOptions<K, V>): Signal<Map<K, V>>;
618
- declare function signalSet<T>(initialValue: Set<T>, options?: SignalOptions<T>): Signal<Set<T>>;
619
- declare function signal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
620
- declare namespace signal {
621
- var invalidate: typeof invalidateSignal;
622
- var Array: typeof signalArray;
623
- var Map: typeof signalMap;
624
- var Object: typeof signalObject;
625
- var Set: typeof signalSet;
512
+ declare const isProps: unique symbol;
513
+ export type WithDefaults<T, D> = T & Required<D>;
514
+ export type Props<T extends {}> = T & {
515
+ [isProps]: true;
516
+ };
517
+ export type GetPropsDefaults<T extends object> = PrettifyShape<GetOptionalEntries<T>>;
518
+ export type GetPropsWithOptionals<T> = T extends Props<infer P> ? (P extends WithDefaults<infer R, any> ? R : P) : never;
519
+ export type GetProps<T> = {
520
+ [K in keyof T]: T[K] extends {
521
+ [isProps]: true;
522
+ } ? (x: GetPropsWithOptionals<T[K]>) => void : never;
523
+ }[keyof T] extends (x: infer I) => void ? {
524
+ [K in keyof I]: I[K];
525
+ } : never;
526
+ export declare function props(): Props<Record<string, any>>;
527
+ export declare function props<const Keys extends string[]>(keys: Keys): Props<ResolveObjectType<Keys>>;
528
+ export declare function props<const Keys extends string[], Defaults>(keys: Keys, defaults: Defaults & GetPropsDefaults<KeyedObject<Keys>>): Props<WithDefaults<ResolveObjectType<Keys>, Defaults>>;
529
+ export declare function props<Shape extends {}>(shape: Shape): Props<ResolveObjectType<Shape>>;
530
+ export declare function props<Shape extends {}, Defaults>(shape: Shape, defaults: Defaults & GetPropsDefaults<Shape>): Props<WithDefaults<ResolveObjectType<Shape>, Defaults>>;
531
+ declare class Scheduler {
532
+ static requestAnimationFrame: (callback: FrameRequestCallback) => number;
533
+ tasks: Set<RootFiber>;
534
+ requestAnimationFrame: Window["requestAnimationFrame"];
535
+ frame: number;
536
+ delayedRenders: Fiber[];
537
+ cancelledNodes: Set<ComponentNode>;
538
+ processing: boolean;
539
+ constructor();
540
+ addFiber(fiber: Fiber): void;
541
+ scheduleDestroy(node: ComponentNode): void;
542
+ /**
543
+ * Process all current tasks. This only applies to the fibers that are ready.
544
+ * Other tasks are left unchanged.
545
+ */
546
+ flush(): void;
547
+ processTasks(): void;
548
+ }
549
+ export type CustomDirectives = Record<string, (node: Element, value: string, modifier: string[]) => void>;
550
+ export type Template = (context: any, vnode: any, key?: string) => any;
551
+ export type TemplateFunction = (app: any, bdom: any, helpers: any) => Template;
552
+ export interface TemplateSetConfig {
553
+ dev?: boolean;
554
+ translatableAttributes?: string[];
555
+ translateFn?: (s: string, translationCtx: string) => string;
556
+ templates?: string | Document | Record<string, string>;
557
+ getTemplate?: (s: string) => Element | Function | string | void;
558
+ customDirectives?: CustomDirectives;
559
+ globalValues?: object;
560
+ }
561
+ export declare class TemplateSet {
562
+ static registerTemplate(name: string, fn: TemplateFunction): void;
563
+ dev: boolean;
564
+ rawTemplates: typeof globalTemplates;
565
+ templates: {
566
+ [name: string]: Template;
567
+ };
568
+ getRawTemplate?: (s: string) => Element | Function | string | void;
569
+ translateFn?: (s: string, translationCtx: string) => string;
570
+ translatableAttributes?: string[];
571
+ customDirectives: CustomDirectives;
572
+ runtimeUtils: object;
573
+ hasGlobalValues: boolean;
574
+ constructor(config?: TemplateSetConfig);
575
+ addTemplate(name: string, template: string | Element): void;
576
+ addTemplates(xml: string | Document): void;
577
+ getTemplate(name: string): Template;
578
+ private _compileTemplate;
579
+ private _parseXML;
580
+ }
581
+ export declare const globalTemplates: {
582
+ [key: string]: string | Element | TemplateFunction;
583
+ };
584
+ export declare function xml(...args: Parameters<typeof String.raw>): string;
585
+ export declare namespace xml {
586
+ var nextId: number;
626
587
  }
627
-
628
- interface ComputedOptions<TWrite> {
629
- set?(value: TWrite): void;
588
+ declare function validateTarget(target: HTMLElement | ShadowRoot): void;
589
+ export declare class EventBus extends EventTarget {
590
+ trigger(name: string, payload?: any): void;
630
591
  }
631
- declare function computed<TRead, TWrite = TRead>(getter: () => TRead, options?: ComputedOptions<TWrite>): ReactiveValue<TRead, TWrite>;
632
-
633
- declare function effect<T>(fn: () => T): () => void;
634
-
592
+ export declare function whenReady(fn?: any): Promise<void>;
593
+ declare class Markup extends String {
594
+ }
595
+ export declare function htmlEscape(str: any): Markup;
596
+ export declare function markup(strings: TemplateStringsArray, ...placeholders: unknown[]): Markup;
597
+ export declare function markup(value: string): Markup;
598
+ export type ComponentInstance<C extends ComponentConstructor> = C extends new (...args: any) => infer T ? T : never;
599
+ export interface RootConfig<P> {
600
+ props?: P;
601
+ }
602
+ export interface AppConfig extends TemplateSetConfig {
603
+ name?: string;
604
+ plugins?: PluginConstructor[] | Resource<PluginConstructor>;
605
+ config?: Record<string, any>;
606
+ test?: boolean;
607
+ }
608
+ export interface Root<T extends ComponentConstructor> {
609
+ node: ComponentNode;
610
+ promise: Promise<ComponentInstance<T>>;
611
+ prepare(): Promise<void>;
612
+ mount(target: MountTarget, options?: MountOptions): Promise<ComponentInstance<T>>;
613
+ destroy(): void;
614
+ }
615
+ export declare class App extends TemplateSet {
616
+ static validateTarget: typeof validateTarget;
617
+ static apps: Set<App>;
618
+ static version: string;
619
+ name: string;
620
+ scheduler: Scheduler;
621
+ roots: Set<Root<any>>;
622
+ pluginManager: PluginManager;
623
+ constructor(config?: AppConfig);
624
+ createRoot<T extends ComponentConstructor>(Root: T, config?: RootConfig<GetProps<ComponentInstance<T>>>): Root<T>;
625
+ destroy(): void;
626
+ _handleError(error: any): void;
627
+ }
628
+ declare function mount$1<T extends ComponentConstructor>(C: T, target: MountTarget, config?: AppConfig & RootConfig<GetProps<ComponentInstance<T>>> & MountOptions): Promise<ComponentInstance<T>>;
629
+ export declare class ErrorBoundary extends Component {
630
+ static template: string;
631
+ props: Props<WithDefaults<{
632
+ error?: ReactiveValue<any, any> | undefined;
633
+ }, {
634
+ error: Signal<any>;
635
+ }>>;
636
+ setup(): void;
637
+ }
638
+ export declare class Portal extends Component {
639
+ static template: string;
640
+ props: Props<{
641
+ slots: {
642
+ default: any;
643
+ };
644
+ target: string | HTMLElement | ReactiveValue<HTMLElement, HTMLElement>;
645
+ }>;
646
+ setup(): void;
647
+ }
648
+ export declare class Suspense extends Component {
649
+ static template: string;
650
+ props: Props<{
651
+ slots: {
652
+ default: any;
653
+ fallback?: any;
654
+ };
655
+ }>;
656
+ private prepared;
657
+ private mounted;
658
+ private subRootMounted;
659
+ setup(): void;
660
+ }
661
+ export declare function prop(key: string): any;
662
+ export declare function prop<T>(key: string, type: T): T;
663
+ export declare function prop<T>(key: string, type: T, defaultValue: T): T;
664
+ export type STATUS_DESCR = "new" | "started" | "mounted" | "cancelled" | "destroyed";
665
+ declare function status$1(entity: Component | Plugin$1): STATUS_DESCR;
635
666
  /**
636
667
  * This hook will run a callback when a component is mounted and patched, and
637
668
  * will run a cleanup function before patching and before unmounting the
@@ -645,7 +676,7 @@ declare function effect<T>(fn: () => T): () => void;
645
676
  * again. The default value returns an array containing only NaN because
646
677
  * NaN !== NaN, which will cause the effect to rerun on every patch.
647
678
  */
648
- declare function useEffect(fn: Parameters<typeof effect>[0]): void;
679
+ export declare function useEffect(fn: Parameters<typeof effect>[0]): void;
649
680
  /**
650
681
  * When a component needs to listen to DOM Events on element(s) that are not
651
682
  * part of his hierarchy, we can use the `useListener` hook.
@@ -659,68 +690,92 @@ declare function useEffect(fn: Parameters<typeof effect>[0]): void;
659
690
  * in the constructor of the OWL component that needs to be notified,
660
691
  * `useListener(window, 'click', () => this._doSomething());`
661
692
  * */
662
- declare function useListener(target: EventTarget | Signal<EventTarget | null>, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
663
- declare function useApp(): App;
664
-
665
- declare function onWillStart(fn: () => Promise<void> | void | any): void;
666
- declare function onWillUpdateProps(fn: (nextProps: any) => Promise<void> | void | any): void;
667
- declare function onMounted(fn: () => void | any): void;
668
- declare function onWillPatch(fn: () => any | void): void;
669
- declare function onPatched(fn: () => void | any): void;
670
- declare function onWillUnmount(fn: () => void | any): void;
671
- declare function onWillDestroy(fn: () => void | any): void;
672
- type OnErrorCallback = (error: any) => void | any;
673
- declare function onError(callback: OnErrorCallback): void;
674
-
675
- interface ValidationIssue {
676
- message: string;
677
- path?: PropertyKey[];
678
- received?: any;
679
- [K: string]: any;
680
- }
681
- declare function assertType(value: any, validation: any, errorMessage?: string): void;
682
- declare function validateType(value: any, validation: any): ValidationIssue[];
683
-
684
- declare class OwlError extends Error {
685
- cause?: any;
686
- }
687
-
688
- type PluginInstance<T extends PluginConstructor> = Omit<InstanceType<T>, "setup">;
689
- declare function plugin<T extends PluginConstructor>(pluginType: T): PluginInstance<T>;
690
- declare function config<T = any>(name: string, type?: T): T;
691
- declare function providePlugins(pluginConstructors: PluginConstructor[] | Resource<PluginConstructor>, config?: Record<string, any>): void;
692
-
693
- interface CapturedContext {
694
- run<T = void>(callback: () => T): T;
695
- protectAsync<P extends any[], R>(callback: (...args: P) => Promise<R>): (...args: P) => Promise<R>;
696
- runWithAsyncProtection<T>(callback: () => Promise<T>): Promise<T>;
697
- }
698
- /**
699
- * Captures the current context and gives methods to run
700
- * functions within the captured context.
701
- */
702
- declare function useContext(): CapturedContext;
703
-
704
- declare const blockDom: {
705
- config: {
706
- shouldNormalizeDom: boolean;
707
- mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null) => boolean;
708
- };
709
- mount: typeof mount$1;
710
- patch: typeof patch;
711
- remove: typeof remove;
712
- list: typeof list;
713
- multi: typeof multi;
714
- text: typeof text;
715
- toggler: typeof toggler;
716
- createBlock: typeof createBlock;
717
- html: typeof html;
718
- comment: typeof comment;
693
+ export declare function useListener(target: EventTarget | Signal<EventTarget | null>, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
694
+ export declare function useApp(): App;
695
+ export declare function onWillStart(fn: (scope: Scope) => Promise<void> | void | any): void;
696
+ export declare function onWillUpdateProps(fn: (nextProps: any, scope: ComponentNode) => Promise<void> | void | any): void;
697
+ export declare function onMounted(fn: (scope: ComponentNode) => void | any): void;
698
+ export declare function onWillPatch(fn: (scope: ComponentNode) => any | void): void;
699
+ export declare function onPatched(fn: (scope: ComponentNode) => void | any): void;
700
+ export declare function onWillUnmount(fn: (scope: ComponentNode) => void | any): void;
701
+ export declare function onWillDestroy(fn: (scope: Scope) => void | any): void;
702
+ export type OnErrorCallback = (error: any) => void | any;
703
+ export declare function onError(callback: OnErrorCallback): void;
704
+ declare function componentType(): typeof Component;
705
+ export declare const types: {
706
+ component: typeof componentType;
707
+ and: <T extends any[]>(types: T) => UnionToIntersection<T[number]>;
708
+ any: () => any;
709
+ array: {
710
+ (): any[];
711
+ <T>(elementType: T): T[];
712
+ };
713
+ boolean: () => boolean;
714
+ constructor: typeof constructorType;
715
+ customValidator: <T>(type: T, validator: (value: T) => boolean, errorMessage?: string) => T;
716
+ function: {
717
+ (): (...parameters: any[]) => any;
718
+ <const P extends any[]>(parameters: P): (...parameters: P) => void;
719
+ <const P extends any[], R>(parameters: P, result: R): (...parameters: P) => R;
720
+ };
721
+ instanceOf: <T extends Constructor>(constructor: T) => InstanceType<T>;
722
+ literal: <const T extends LiteralTypes>(literal: T) => T;
723
+ number: () => number;
724
+ object: {
725
+ (): Record<string, any>;
726
+ <const Keys extends string[]>(keys: Keys): ResolveOptionalEntries<KeyedObject<Keys>>;
727
+ <Shape extends {}>(shape: Shape): ResolveOptionalEntries<Shape>;
728
+ };
729
+ or: <T extends any[]>(types: T) => T[number];
730
+ promise: {
731
+ (): Promise<void>;
732
+ <T>(type: T): Promise<T>;
733
+ };
734
+ record: {
735
+ (): Record<PropertyKey, any>;
736
+ <V>(valueType: V): Record<PropertyKey, V>;
737
+ };
738
+ ref: {
739
+ (): HTMLElement | null;
740
+ <T extends Constructor<HTMLElement>>(type: T): InstanceType<T> | null;
741
+ };
742
+ selection: <const T extends LiteralTypes>(literals: T[]) => T;
743
+ signal: {
744
+ (): ReactiveValue<any>;
745
+ <T>(type: T): ReactiveValue<T>;
746
+ };
747
+ strictObject: {
748
+ <const Keys extends string[]>(keys: Keys): ResolveOptionalEntries<KeyedObject<Keys>>;
749
+ <Shape extends {}>(shape: Shape): ResolveOptionalEntries<Shape>;
750
+ };
751
+ string: () => string;
752
+ tuple: <const T extends any[]>(types: T) => T;
753
+ };
754
+ export type PluginInstance<T extends PluginConstructor> = Omit<InstanceType<T>, "setup">;
755
+ export declare function plugin<T extends PluginConstructor>(pluginType: T): PluginInstance<T>;
756
+ export declare function config<T = any>(name: string, type?: T): T;
757
+ export declare function providePlugins(pluginConstructors: PluginConstructor[] | Resource<PluginConstructor>, config?: Record<string, any>): void;
758
+ export declare const blockDom: {
759
+ config: {
760
+ shouldNormalizeDom: boolean;
761
+ mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null) => boolean;
762
+ };
763
+ mount: typeof mount;
764
+ patch: typeof patch;
765
+ remove: typeof remove;
766
+ list: typeof list;
767
+ multi: typeof multi;
768
+ text: typeof text;
769
+ toggler: typeof toggler;
770
+ createBlock: typeof createBlock;
771
+ html: typeof html;
719
772
  };
773
+ export declare const __info__: Record<string, string>;
720
774
 
721
- declare const __info__: {
722
- version: string;
775
+ export {
776
+ Plugin$1 as Plugin,
777
+ mount$1 as mount,
778
+ status$1 as status,
723
779
  };
724
780
 
725
- export { App, Component, EventBus, OwlError, Plugin, Registry, Resource, __info__, assertType, batched, blockDom, computed, config, effect, htmlEscape, markRaw, markup, mount, onError, onMounted, onPatched, onWillDestroy, onWillPatch, onWillStart, onWillUnmount, onWillUpdateProps, plugin, props, providePlugins, proxy, signal, status, toRaw, types, untrack, useApp, useContext, useEffect, useListener, useResource, validateType, whenReady, xml };
726
- export type { CapturedContext, ComponentConstructor, GetProps, PluginConstructor, PluginInstance, ReactiveValue, Signal };
781
+ export {};