@odoo/owl 3.0.0-alpha.26 → 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 +6651 -6652
  2. package/dist/owl.es.js +6631 -6611
  3. package/dist/owl.iife.js +6818 -6821
  4. package/dist/owl.iife.min.js +27 -1
  5. package/dist/types/owl.d.ts +678 -621
  6. package/package.json +9 -95
  7. package/LICENSE +0 -856
  8. package/README.md +0 -139
  9. package/dist/compile_templates.mjs +0 -2474
  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 -134
  14. package/dist/types/compiler/index.d.ts +0 -13
  15. package/dist/types/compiler/inline_expressions.d.ts +0 -35
  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 -53
  21. package/dist/types/runtime/blockdom/attributes.d.ts +0 -8
  22. package/dist/types/runtime/blockdom/block_compiler.d.ts +0 -20
  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 -26
  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 -57
  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 -25
  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,447 +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
- type MountTarget = HTMLElement | ShadowRoot;
110
- interface VNode<T = any> {
111
- mount(parent: MountTarget, afterNode: Node | null): void;
112
- moveBeforeDOMNode(node: Node | null, parent?: MountTarget): void;
113
- moveBeforeVNode(other: T | null, afterNode: Node | null): void;
114
- patch(other: T, withBeforeRemove: boolean): void;
115
- beforeRemove(): void;
116
- remove(): void;
117
- firstNode(): Node | undefined;
118
- el?: undefined | HTMLElement | Text;
119
- parentEl?: undefined | HTMLElement;
120
- isOnlyChild?: boolean | undefined;
121
- key?: any;
122
- }
123
- type BDom = VNode<any>;
124
- declare function mount$1(vnode: VNode, fixture: MountTarget, 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;
125
96
  declare function patch(vnode1: VNode, vnode2: VNode, withBeforeRemove?: boolean): void;
126
97
  declare function remove(vnode: VNode, withBeforeRemove?: boolean): void;
127
-
128
- interface ResourceOptions<T> {
129
- name?: string;
130
- validation?: T;
131
- }
132
- declare class Resource<T> {
133
- private _items;
134
- private _name?;
135
- private _validation?;
136
- constructor(options?: ResourceOptions<T>);
137
- items: ReactiveValue<T[], T[]>;
138
- add(item: T, options?: {
139
- sequence?: number;
140
- }): Resource<T>;
141
- delete(item: T): Resource<T>;
142
- has(item: T): boolean;
143
- }
144
- declare function useResource<T>(r: Resource<T>, elements: T[]): void;
145
-
146
- interface RegistryOptions<T> {
147
- name?: string;
148
- validation?: T;
149
- }
150
- declare class Registry<T> {
151
- private _map;
152
- private _name;
153
- private _validation?;
154
- constructor(options?: RegistryOptions<T>);
155
- entries: ReactiveValue<[string, T][], [string, T][]>;
156
- items: ReactiveValue<T[], T[]>;
157
- addById<U extends {
158
- id: string;
159
- } & T>(item: U, options?: {
160
- sequence?: number;
161
- }): Registry<T>;
162
- add(key: string, value: T, options?: {
163
- sequence?: number;
164
- }): Registry<T>;
165
- get(key: string, defaultValue?: T): T;
166
- delete(key: string): void;
167
- has(key: string): boolean;
168
- }
169
-
170
- interface ReactiveValue<TRead, TWrite = TRead> {
171
- (): TRead;
172
- /**
173
- * Update the value of the reactive with a new value. If the new value is different
174
- * from the previous values, all computations that depends on this reactive will
175
- * be invalidated, and effects will rerun.
176
- */
177
- 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;
178
125
  }
179
126
  declare enum ComputationState {
180
- EXECUTED = 0,
181
- STALE = 1,
182
- PENDING = 2
183
- }
184
- interface Atom<T = any> {
185
- observers: Set<ComputationAtom>;
186
- value: T;
127
+ EXECUTED = 0,
128
+ STALE = 1,
129
+ PENDING = 2
187
130
  }
188
- interface ComputationAtom<T = any> extends Atom<T> {
189
- compute: () => T;
190
- isDerived: boolean;
191
- sources: Set<Atom>;
192
- state: ComputationState;
131
+ export interface Atom<T = any> {
132
+ observers: Set<ComputationAtom>;
133
+ value: T;
193
134
  }
194
- declare function untrack<T>(fn: (...args: any[]) => T): T;
195
-
196
- declare const enum STATUS {
197
- NEW = 0,
198
- MOUNTED = 1,// is ready, and in DOM. It has a valid el
199
- CANCELLED = 2,
200
- DESTROYED = 3
201
- }
202
- type STATUS_DESCR = "new" | "started" | "mounted" | "cancelled" | "destroyed";
203
- declare function status(entity: Component | Plugin): STATUS_DESCR;
204
-
205
- interface PluginConstructor {
206
- new (...args: any[]): Plugin;
207
- id: string;
208
- }
209
- declare class Plugin {
210
- private static _shadowId;
211
- static get id(): string;
212
- static set id(shadowId: string);
213
- __owl__: PluginManager;
214
- constructor(manager: PluginManager);
215
- setup(): void;
216
- }
217
- interface PluginManagerOptions {
218
- parent?: PluginManager | null;
219
- config?: Record<string, any>;
220
- }
221
- declare class PluginManager {
222
- app: App;
223
- config: Record<string, any>;
224
- onDestroyCb: Function[];
225
- computations: ComputationAtom[];
226
- plugins: Record<string, Plugin>;
227
- status: STATUS;
228
- constructor(app: App, options?: PluginManagerOptions);
229
- destroy(): void;
230
- getPluginById<T extends Plugin>(id: string): T | null;
231
- getPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
232
- startPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
233
- 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;
234
140
  }
235
-
236
- declare class Fiber {
237
- node: ComponentNode;
238
- bdom: BDom | null;
239
- root: RootFiber | null;
240
- parent: Fiber | null;
241
- children: Fiber[];
242
- appliedToDom: boolean;
243
- deep: boolean;
244
- childrenMap: ComponentNode["children"];
245
- constructor(node: ComponentNode, parent: Fiber | null);
246
- render(): void;
247
- }
248
- declare class RootFiber extends Fiber {
249
- counter: number;
250
- willPatch: Fiber[];
251
- patched: Fiber[];
252
- mounted: Fiber[];
253
- locked: boolean;
254
- complete(): void;
255
- setCounter(newValue: number): void;
256
- }
257
- type Position = "first-child" | "last-child";
258
- interface MountOptions {
259
- position?: Position;
260
- }
261
- declare class MountFiber extends RootFiber {
262
- target: MountTarget;
263
- position: Position;
264
- constructor(node: ComponentNode, target: MountTarget, options?: MountOptions);
265
- complete(): void;
266
- }
267
-
268
- type LifecycleHook = Function;
269
- declare class ComponentNode implements VNode<ComponentNode> {
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
- initiateRender(fiber: Fiber | MountFiber): Promise<void>;
296
- render(deep: boolean): Promise<void>;
297
- cancel(): void;
298
- _cancel(): void;
299
- destroy(): void;
300
- _destroy(): void;
301
- updateAndRender(props: Record<string, any>, parentFiber: Fiber): Promise<void>;
302
- /**
303
- * Finds a child that has dom that is not yet updated, and update it. This
304
- * method is meant to be used only in the context of repatching the dom after
305
- * a mounted hook failed and was handled.
306
- */
307
- updateDom(): void;
308
- firstNode(): Node | undefined;
309
- mount(parent: HTMLElement, anchor: ChildNode): void;
310
- moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
311
- moveBeforeVNode(other: ComponentNode | null, afterNode: Node | null): void;
312
- patch(): void;
313
- _patch(): void;
314
- beforeRemove(): void;
315
- remove(): void;
316
- }
317
-
318
- interface StaticComponentProperties {
319
- template: string;
320
- components?: {
321
- [componentName: string]: ComponentConstructor;
322
- };
323
- }
324
- interface ComponentConstructor extends StaticComponentProperties {
325
- new (node: ComponentNode): Component;
326
- }
327
- declare class Component {
328
- static template: string;
329
- __owl__: ComponentNode;
330
- constructor(node: ComponentNode);
331
- 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;
332
202
  }
333
-
334
- type Constructor<T = any> = {
335
- new (...args: any[]): T;
336
- };
337
- type GetOptionalEntries<T> = {
338
- [K in keyof T as K extends `${infer P}?` ? P : never]?: T[K];
339
- };
340
- type GetRequiredEntries<T> = {
341
- [K in keyof T as K extends `${string}?` ? never : K]: T[K];
342
- };
343
- type PrettifyShape<T> = T extends Function ? T : {
344
- [K in keyof T]: T[K];
345
- };
346
- type ResolveOptionalEntries<T> = PrettifyShape<GetRequiredEntries<T> & GetOptionalEntries<T>>;
347
- type KeyedObject<K extends string[]> = {
348
- [P in K[number]]: any;
349
- };
350
- type ResolveShapedObject<T extends {}> = PrettifyShape<ResolveOptionalEntries<T>>;
351
- type ResolveObjectType<T extends {}> = ResolveShapedObject<T extends string[] ? KeyedObject<T> : T>;
352
- type UnionToIntersection<U> = (U extends any ? (_: U) => any : never) extends (_: infer I) => void ? I : never;
353
- declare function anyType(): any;
354
- declare function booleanType(): boolean;
355
- declare function numberType(): number;
356
- declare function stringType(): string;
357
- declare function arrayType(): any[];
358
- declare function arrayType<T>(elementType: T): T[];
359
- declare function constructorType<T extends Constructor>(constructor: T): T;
360
- declare function customValidator<T>(type: T, validator: (value: T) => boolean, errorMessage?: string): T;
361
- declare function functionType(): (...parameters: any[]) => any;
362
- declare function functionType<const P extends any[]>(parameters: P): (...parameters: P) => void;
363
- declare function functionType<const P extends any[], R>(parameters: P, result: R): (...parameters: P) => R;
364
- declare function instanceType<T extends Constructor>(constructor: T): InstanceType<T>;
365
- declare function intersection<T extends any[]>(types: T): UnionToIntersection<T[number]>;
366
- type LiteralTypes = number | string | boolean | null | undefined;
367
- declare function literalType<const T extends LiteralTypes>(literal: T): T;
368
- declare function literalSelection<const T extends LiteralTypes>(literals: T[]): T;
369
- declare function objectType(): Record<string, any>;
370
- declare function objectType<const Keys extends string[]>(keys: Keys): ResolveOptionalEntries<KeyedObject<Keys>>;
371
- declare function objectType<Shape extends {}>(shape: Shape): ResolveOptionalEntries<Shape>;
372
- declare function strictObjectType<const Keys extends string[]>(keys: Keys): ResolveOptionalEntries<KeyedObject<Keys>>;
373
- declare function strictObjectType<Shape extends {}>(shape: Shape): ResolveOptionalEntries<Shape>;
374
- declare function promiseType(): Promise<void>;
375
- declare function promiseType<T>(type: T): Promise<T>;
376
- declare function recordType(): Record<PropertyKey, any>;
377
- declare function recordType<V>(valueType: V): Record<PropertyKey, V>;
378
- declare function tuple<const T extends any[]>(types: T): T;
379
- declare function union<T extends any[]>(types: T): T[number];
380
- declare function reactiveValueType(): ReactiveValue<any>;
381
- declare function reactiveValueType<T>(type: T): ReactiveValue<T>;
382
- declare function componentType(): typeof Component;
383
- declare function ref(): HTMLElement | null;
384
- declare function ref<T extends Constructor<HTMLElement>>(type: T): InstanceType<T> | null;
385
- declare const types: {
386
- and: typeof intersection;
387
- any: typeof anyType;
388
- array: typeof arrayType;
389
- boolean: typeof booleanType;
390
- component: typeof componentType;
391
- constructor: typeof constructorType;
392
- customValidator: typeof customValidator;
393
- function: typeof functionType;
394
- instanceOf: typeof instanceType;
395
- literal: typeof literalType;
396
- number: typeof numberType;
397
- object: typeof objectType;
398
- or: typeof union;
399
- promise: typeof promiseType;
400
- record: typeof recordType;
401
- ref: typeof ref;
402
- selection: typeof literalSelection;
403
- signal: typeof reactiveValueType;
404
- strictObject: typeof strictObjectType;
405
- string: typeof stringType;
406
- tuple: typeof tuple;
407
- };
408
-
409
- declare const isProps: unique symbol;
410
- type WithDefaults<T, D> = T & Required<D>;
411
- type Props<T extends {}> = T & {
412
- [isProps]: true;
413
- };
414
- type GetPropsDefaults<T extends object> = PrettifyShape<GetOptionalEntries<T>>;
415
- type GetPropsWithOptionals<T> = T extends Props<infer P> ? (P extends WithDefaults<infer R, any> ? R : P) : never;
416
- type GetProps<T> = {
417
- [K in keyof T]: T[K] extends {
418
- [isProps]: true;
419
- } ? (x: GetPropsWithOptionals<T[K]>) => void : never;
420
- }[keyof T] extends (x: infer I) => void ? {
421
- [K in keyof I]: I[K];
422
- } : never;
423
- declare function props(): Props<Record<string, any>>;
424
- declare function props<const Keys extends string[]>(keys: Keys): Props<ResolveObjectType<Keys>>;
425
- declare function props<const Keys extends string[], Defaults>(keys: Keys, defaults: Defaults & GetPropsDefaults<KeyedObject<Keys>>): Props<WithDefaults<ResolveObjectType<Keys>, Defaults>>;
426
- declare function props<Shape extends {}>(shape: Shape): Props<ResolveObjectType<Shape>>;
427
- declare function props<Shape extends {}, Defaults>(shape: Shape, defaults: Defaults & GetPropsDefaults<Shape>): Props<WithDefaults<ResolveObjectType<Shape>, Defaults>>;
428
-
429
- type Target = object;
430
- 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;
431
211
  /**
432
212
  * Mark an object or array so that it is ignored by the reactivity system
433
213
  *
434
214
  * @param value the value to mark
435
215
  * @returns the object itself
436
216
  */
437
- declare function markRaw<T extends Target>(value: T): T;
217
+ export declare function markRaw<T extends Target>(value: T): T;
438
218
  /**
439
219
  * Given a proxy objet, return the raw (non proxy) underlying object
440
220
  *
441
221
  * @param value a proxy value
442
222
  * @returns the underlying value
443
223
  */
444
- 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;
445
225
  /**
446
226
  * Creates a reactive proxy for an object. Reading data on the proxy object
447
227
  * subscribes to changes to the data. Writing data on the object will cause the
@@ -469,167 +249,420 @@ declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T
469
249
  * proxy has changed
470
250
  * @returns a proxy that tracks changes to it
471
251
  */
472
- declare function proxy<T extends Target>(target: T): T;
473
-
474
- declare class Scheduler {
475
- static requestAnimationFrame: (callback: FrameRequestCallback) => number;
476
- tasks: Set<RootFiber>;
477
- requestAnimationFrame: Window["requestAnimationFrame"];
478
- frame: number;
479
- delayedRenders: Fiber[];
480
- cancelledNodes: Set<ComponentNode>;
481
- processing: boolean;
482
- constructor();
483
- addFiber(fiber: Fiber): void;
484
- scheduleDestroy(node: ComponentNode): void;
485
- /**
486
- * Process all current tasks. This only applies to the fibers that are ready.
487
- * Other tasks are left unchanged.
488
- */
489
- flush(): void;
490
- 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;
491
263
  }
492
-
493
- type CustomDirectives = Record<string, (node: Element, value: string, modifier: string[]) => void>;
494
- type Template = (context: any, vnode: any, key?: string) => BDom;
495
- type TemplateFunction = (app: TemplateSet, bdom: any, helpers: any) => Template;
496
-
497
- interface TemplateSetConfig {
498
- dev?: boolean;
499
- translatableAttributes?: string[];
500
- translateFn?: (s: string, translationCtx: string) => string;
501
- templates?: string | Document | Record<string, string>;
502
- getTemplate?: (s: string) => Element | Function | string | void;
503
- customDirectives?: CustomDirectives;
504
- globalValues?: object;
505
- }
506
- declare class TemplateSet {
507
- static registerTemplate(name: string, fn: TemplateFunction): void;
508
- dev: boolean;
509
- rawTemplates: typeof globalTemplates;
510
- templates: {
511
- [name: string]: Template;
512
- };
513
- getRawTemplate?: (s: string) => Element | Function | string | void;
514
- translateFn?: (s: string, translationCtx: string) => string;
515
- translatableAttributes?: string[];
516
- customDirectives: CustomDirectives;
517
- runtimeUtils: object;
518
- hasGlobalValues: boolean;
519
- constructor(config?: TemplateSetConfig);
520
- addTemplate(name: string, template: string | Element): void;
521
- addTemplates(xml: string | Document): void;
522
- getTemplate(name: string): Template;
523
- private _compileTemplate;
524
- }
525
- declare const globalTemplates: {
526
- [key: string]: string | Element | TemplateFunction;
527
- };
528
- declare function xml(...args: Parameters<typeof String.raw>): string;
529
- declare namespace xml {
530
- 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;
531
304
  }
532
-
533
- type Callback = (...args: any[]) => void;
534
305
  /**
535
- * Creates a batched version of a callback so that all calls to it in the same
536
- * microtick will only call the original callback once.
537
- *
538
- * @param callback the callback to batch
539
- * @returns a batched version of the original callback
306
+ * @experimental The exact API is subject to change in future versions.
540
307
  */
541
- declare function batched(callback: Callback): Callback;
542
- declare function validateTarget(target: HTMLElement | ShadowRoot): void;
543
- declare class EventBus extends EventTarget {
544
- 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;
545
414
  }
546
- declare function whenReady(fn?: any): Promise<void>;
547
- 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;
548
426
  }
549
- declare function htmlEscape(str: any): Markup;
550
- declare function markup(strings: TemplateStringsArray, ...placeholders: unknown[]): Markup;
551
- declare function markup(value: string): Markup;
552
-
553
- type ComponentInstance<C extends ComponentConstructor> = C extends new (...args: any) => infer T ? T : never;
554
- interface RootConfig<P> {
555
- props?: P;
556
- }
557
- interface AppConfig extends TemplateSetConfig {
558
- name?: string;
559
- plugins?: PluginConstructor[] | Resource<PluginConstructor>;
560
- config?: Record<string, any>;
561
- test?: boolean;
562
- }
563
- declare global {
564
- interface Window {
565
- __OWL_DEVTOOLS__: {
566
- apps: Set<App>;
567
- Fiber: typeof Fiber;
568
- RootFiber: typeof RootFiber;
569
- toRaw: typeof toRaw;
570
- proxy: typeof proxy;
571
- };
572
- }
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;
573
440
  }
574
-
575
- interface Root<T extends ComponentConstructor> {
576
- node: ComponentNode;
577
- promise: Promise<ComponentInstance<T>>;
578
- mount(target: MountTarget, options?: MountOptions): Promise<ComponentInstance<T>>;
579
- destroy(): void;
580
- }
581
- declare class App extends TemplateSet {
582
- static validateTarget: typeof validateTarget;
583
- static apps: Set<App>;
584
- static version: string;
585
- name: string;
586
- scheduler: Scheduler;
587
- roots: Set<Root<any>>;
588
- pluginManager: PluginManager;
589
- constructor(config?: AppConfig);
590
- createRoot<T extends ComponentConstructor>(Root: T, config?: RootConfig<GetProps<ComponentInstance<T>>>): Root<T>;
591
- destroy(): void;
592
- _handleError(error: any): void;
593
- }
594
- declare function mount<T extends ComponentConstructor>(C: T, target: MountTarget, config?: AppConfig & RootConfig<GetProps<ComponentInstance<T>>> & MountOptions): Promise<ComponentInstance<T>>;
595
-
596
- interface Signal<T> extends ReactiveValue<T> {
597
- /**
598
- * Update the value of the signal with a new value. If the new value is different
599
- * from the previous values, all computations that depends on this signal will
600
- * be invalidated, and effects will rerun.
601
- */
602
- set(nextValue: T): void;
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;
603
511
  }
604
- interface SignalOptions<T> {
605
- type?: T;
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;
606
587
  }
607
- declare function invalidateSignal(signal: Signal<any>): void;
608
- declare function signalArray<T>(initialValue: T[], options?: SignalOptions<T>): Signal<T[]>;
609
- declare function signalObject<T extends Record<PropertyKey, any>>(initialValue: T, options?: SignalOptions<T>): Signal<T>;
610
- interface MapSignalOptions<K, V> {
611
- name?: string;
612
- keyType?: K;
613
- valueType?: V;
614
- }
615
- declare function signalMap<K, V>(initialValue: Map<K, V>, options?: MapSignalOptions<K, V>): Signal<Map<K, V>>;
616
- declare function signalSet<T>(initialValue: Set<T>, options?: SignalOptions<T>): Signal<Set<T>>;
617
- declare function signal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
618
- declare namespace signal {
619
- var invalidate: typeof invalidateSignal;
620
- var Array: typeof signalArray;
621
- var Map: typeof signalMap;
622
- var Object: typeof signalObject;
623
- var Set: typeof signalSet;
588
+ declare function validateTarget(target: HTMLElement | ShadowRoot): void;
589
+ export declare class EventBus extends EventTarget {
590
+ trigger(name: string, payload?: any): void;
624
591
  }
625
-
626
- interface ComputedOptions<TWrite> {
627
- set?(value: TWrite): void;
592
+ export declare function whenReady(fn?: any): Promise<void>;
593
+ declare class Markup extends String {
628
594
  }
629
- declare function computed<TRead, TWrite = TRead>(getter: () => TRead, options?: ComputedOptions<TWrite>): ReactiveValue<TRead, TWrite>;
630
-
631
- declare function effect<T>(fn: () => T): () => void;
632
-
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;
633
666
  /**
634
667
  * This hook will run a callback when a component is mounted and patched, and
635
668
  * will run a cleanup function before patching and before unmounting the
@@ -643,7 +676,7 @@ declare function effect<T>(fn: () => T): () => void;
643
676
  * again. The default value returns an array containing only NaN because
644
677
  * NaN !== NaN, which will cause the effect to rerun on every patch.
645
678
  */
646
- declare function useEffect(fn: Parameters<typeof effect>[0]): void;
679
+ export declare function useEffect(fn: Parameters<typeof effect>[0]): void;
647
680
  /**
648
681
  * When a component needs to listen to DOM Events on element(s) that are not
649
682
  * part of his hierarchy, we can use the `useListener` hook.
@@ -657,68 +690,92 @@ declare function useEffect(fn: Parameters<typeof effect>[0]): void;
657
690
  * in the constructor of the OWL component that needs to be notified,
658
691
  * `useListener(window, 'click', () => this._doSomething());`
659
692
  * */
660
- declare function useListener(target: EventTarget | Signal<EventTarget | null>, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
661
- declare function useApp(): App;
662
-
663
- declare function onWillStart(fn: () => Promise<void> | void | any): void;
664
- declare function onWillUpdateProps(fn: (nextProps: any) => Promise<void> | void | any): void;
665
- declare function onMounted(fn: () => void | any): void;
666
- declare function onWillPatch(fn: () => any | void): void;
667
- declare function onPatched(fn: () => void | any): void;
668
- declare function onWillUnmount(fn: () => void | any): void;
669
- declare function onWillDestroy(fn: () => void | any): void;
670
- type OnErrorCallback = (error: any) => void | any;
671
- declare function onError(callback: OnErrorCallback): void;
672
-
673
- interface ValidationIssue {
674
- message: string;
675
- path?: PropertyKey[];
676
- received?: any;
677
- [K: string]: any;
678
- }
679
- declare function assertType(value: any, validation: any, errorMessage?: string): void;
680
- declare function validateType(value: any, validation: any): ValidationIssue[];
681
-
682
- declare class OwlError extends Error {
683
- cause?: any;
684
- }
685
-
686
- type PluginInstance<T extends PluginConstructor> = Omit<InstanceType<T>, "setup">;
687
- declare function plugin<T extends PluginConstructor>(pluginType: T): PluginInstance<T>;
688
- declare function config<T = any>(name: string, type?: T): T;
689
- declare function providePlugins(pluginConstructors: PluginConstructor[] | Resource<PluginConstructor>, config?: Record<string, any>): void;
690
-
691
- interface CapturedContext {
692
- run<T = void>(callback: () => T): T;
693
- protectAsync<P extends any[], R>(callback: (...args: P) => Promise<R>): (...args: P) => Promise<R>;
694
- runWithAsyncProtection<T>(callback: () => Promise<T>): Promise<T>;
695
- }
696
- /**
697
- * Captures the current context and gives methods to run
698
- * functions within the captured context.
699
- */
700
- declare function useContext(): CapturedContext;
701
-
702
- declare const blockDom: {
703
- config: {
704
- shouldNormalizeDom: boolean;
705
- mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null) => boolean;
706
- };
707
- mount: typeof mount$1;
708
- patch: typeof patch;
709
- remove: typeof remove;
710
- list: typeof list;
711
- multi: typeof multi;
712
- text: typeof text;
713
- toggler: typeof toggler;
714
- createBlock: typeof createBlock;
715
- html: typeof html;
716
- 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;
717
772
  };
773
+ export declare const __info__: Record<string, string>;
718
774
 
719
- declare const __info__: {
720
- version: string;
775
+ export {
776
+ Plugin$1 as Plugin,
777
+ mount$1 as mount,
778
+ status$1 as status,
721
779
  };
722
780
 
723
- 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 };
724
- export type { CapturedContext, ComponentConstructor, GetProps, PluginConstructor, PluginInstance, ReactiveValue, Signal };
781
+ export {};