@odoo/owl 3.0.0-alpha.2 → 3.0.0-alpha.20

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 (72) hide show
  1. package/dist/compile_templates.mjs +2430 -2532
  2. package/dist/compiler.js +2371 -0
  3. package/dist/owl.cjs.js +6571 -6615
  4. package/dist/owl.cjs.runtime.js +4070 -0
  5. package/dist/owl.es.js +6559 -6599
  6. package/dist/owl.es.runtime.js +4026 -0
  7. package/dist/owl.iife.js +6572 -6616
  8. package/dist/owl.iife.min.js +1 -1
  9. package/dist/owl.iife.runtime.js +4074 -0
  10. package/dist/owl.iife.runtime.min.js +1 -0
  11. package/dist/types/common/owl_error.d.ts +3 -3
  12. package/dist/types/common/types.d.ts +0 -28
  13. package/dist/types/common/utils.d.ts +8 -8
  14. package/dist/types/compiler/code_generator.d.ts +134 -152
  15. package/dist/types/compiler/index.d.ts +13 -13
  16. package/dist/types/compiler/inline_expressions.d.ts +58 -59
  17. package/dist/types/compiler/parser.d.ts +175 -178
  18. package/dist/types/compiler/standalone/index.d.ts +2 -2
  19. package/dist/types/compiler/standalone/setup_jsdom.d.ts +1 -1
  20. package/dist/types/index.d.ts +1 -1
  21. package/dist/types/owl.d.ts +703 -665
  22. package/dist/types/runtime/app.d.ts +55 -62
  23. package/dist/types/runtime/blockdom/attributes.d.ts +6 -6
  24. package/dist/types/runtime/blockdom/block_compiler.d.ts +21 -21
  25. package/dist/types/runtime/blockdom/config.d.ts +8 -8
  26. package/dist/types/runtime/blockdom/event_catcher.d.ts +7 -7
  27. package/dist/types/runtime/blockdom/events.d.ts +8 -8
  28. package/dist/types/runtime/blockdom/html.d.ts +17 -17
  29. package/dist/types/runtime/blockdom/index.d.ts +25 -26
  30. package/dist/types/runtime/blockdom/list.d.ts +18 -18
  31. package/dist/types/runtime/blockdom/multi.d.ts +17 -17
  32. package/dist/types/runtime/blockdom/text.d.ts +26 -26
  33. package/dist/types/runtime/blockdom/toggler.d.ts +17 -17
  34. package/dist/types/runtime/component.d.ts +17 -28
  35. package/dist/types/runtime/component_node.d.ts +57 -83
  36. package/dist/types/runtime/context.d.ts +36 -0
  37. package/dist/types/runtime/event_handling.d.ts +1 -1
  38. package/dist/types/runtime/hooks.d.ts +32 -57
  39. package/dist/types/runtime/index.d.ts +46 -35
  40. package/dist/types/runtime/lifecycle_hooks.d.ts +10 -12
  41. package/dist/types/runtime/model.d.ts +48 -0
  42. package/dist/types/runtime/plugin_hooks.d.ts +6 -0
  43. package/dist/types/runtime/plugin_manager.d.ts +34 -0
  44. package/dist/types/runtime/plugins.d.ts +36 -39
  45. package/dist/types/runtime/portal.d.ts +12 -15
  46. package/dist/types/runtime/props.d.ts +21 -0
  47. package/dist/types/runtime/reactivity/async_computed.d.ts +1 -0
  48. package/dist/types/runtime/reactivity/computations.d.ts +33 -0
  49. package/dist/types/runtime/reactivity/computed.d.ts +6 -0
  50. package/dist/types/runtime/reactivity/derived.d.ts +7 -0
  51. package/dist/types/runtime/reactivity/effect.d.ts +1 -0
  52. package/dist/types/runtime/reactivity/proxy.d.ts +47 -0
  53. package/dist/types/runtime/reactivity/reactivity.d.ts +46 -0
  54. package/dist/types/runtime/reactivity/signal.d.ts +31 -0
  55. package/dist/types/runtime/reactivity/signals.d.ts +30 -0
  56. package/dist/types/runtime/reactivity/state.d.ts +48 -0
  57. package/dist/types/runtime/reactivity.d.ts +12 -1
  58. package/dist/types/runtime/registry.d.ts +24 -15
  59. package/dist/types/runtime/rendering/error_handling.d.ts +13 -0
  60. package/dist/types/runtime/rendering/fibers.d.ts +37 -0
  61. package/dist/types/runtime/rendering/scheduler.d.ts +21 -0
  62. package/dist/types/runtime/rendering/template_helpers.d.ts +51 -0
  63. package/dist/types/runtime/resource.d.ts +18 -0
  64. package/dist/types/runtime/signals.d.ts +6 -4
  65. package/dist/types/runtime/status.d.ts +11 -10
  66. package/dist/types/runtime/suspense.d.ts +5 -0
  67. package/dist/types/runtime/template_set.d.ts +36 -40
  68. package/dist/types/runtime/types.d.ts +67 -0
  69. package/dist/types/runtime/utils.d.ts +24 -25
  70. package/dist/types/runtime/validation.d.ts +19 -36
  71. package/dist/types/version.d.ts +1 -1
  72. package/package.json +22 -19
@@ -1,687 +1,725 @@
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;
14
- }
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;
14
+ }
15
15
  declare function toggler(key: string, child: VNode): VNode<VToggler>;
16
16
 
17
- declare 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
- */
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
+ */
33
33
  declare function createBlock(str: string): BlockType;
34
34
 
35
- 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;
49
- }
35
+ 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;
49
+ }
50
50
  declare function list(children: VNode[]): VNode<VList>;
51
51
 
52
- 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;
66
- }
52
+ 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;
66
+ }
67
67
  declare function multi(children: (VNode | undefined)[]): VNode<VMulti>;
68
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;
89
- }
90
- declare function text(str: string | String): VNode<VText>;
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;
89
+ }
90
+ declare function text(str: string | String): VNode<VText>;
91
91
  declare function comment(str: string): VNode<VComment>;
92
92
 
93
- 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;
106
- }
93
+ 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;
106
+ }
107
107
  declare function html(str: string): VNode<VHtml>;
108
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
- declare type BDom = VNode<any>;
123
- declare function mount$1(vnode: VNode, fixture: HTMLElement, afterNode?: Node | null): void;
124
- declare function patch(vnode1: VNode, vnode2: VNode, withBeforeRemove?: boolean): void;
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;
124
+ declare function patch(vnode1: VNode, vnode2: VNode, withBeforeRemove?: boolean): void;
125
125
  declare function remove(vnode: VNode, withBeforeRemove?: boolean): void;
126
126
 
127
- declare type BaseType = {
128
- new (...args: any[]): any;
129
- } | true | "*";
130
- interface TypeInfo {
131
- type?: TypeDescription;
132
- optional?: boolean;
133
- validate?: Function;
134
- shape?: Schema;
135
- element?: TypeDescription;
136
- values?: TypeDescription;
137
- }
138
- declare type ValueType = {
139
- value: any;
140
- };
141
- declare type TypeDescription = BaseType | TypeInfo | ValueType | TypeDescription[];
142
- declare type SimplifiedSchema = string[];
143
- declare type NormalizedSchema = {
144
- [key: string]: TypeDescription;
145
- };
146
- declare type Schema = SimplifiedSchema | NormalizedSchema;
147
- /**
148
- * Main validate function
149
- */
150
- declare function validate(obj: {
151
- [key: string]: any;
152
- }, spec: Schema): void;
153
- declare function validateType(key: string, value: any, descr: TypeDescription): string | null;
154
-
155
- declare type Fn<T> = () => T;
156
- declare class Registry<T> {
157
- _map: {
158
- [key: string]: [number, T];
159
- };
160
- _name: string;
161
- _schema?: Schema;
162
- items: Fn<T[]>;
163
- entries: Fn<[string, T][]>;
164
- constructor(name?: string, schema?: Schema);
165
- set(key: string, value: T, sequence?: number): void;
166
- get(key: string, defaultValue?: T): T;
167
- }
168
-
169
- declare type customDirectives = Record<string, (node: Element, value: string, modifier: string[]) => void>;
170
- declare enum ComputationState {
171
- EXECUTED = 0,
172
- STALE = 1,
173
- PENDING = 2
174
- }
175
- declare type Computation<T = any> = {
176
- compute?: () => T;
177
- state: ComputationState;
178
- sources: Set<Atom | Derived<any, any>>;
179
- isEager?: boolean;
180
- isDerived?: boolean;
181
- value: T;
182
- childrenEffect?: Computation[];
183
- } & Opts;
184
- declare type Opts = {
185
- name?: string;
186
- };
187
- declare type Atom<T = any> = {
188
- value: T;
189
- observers: Set<Computation>;
190
- } & Opts;
191
- interface Derived<Prev, Next = Prev> extends Atom<Next>, Computation<Next> {
192
- }
193
-
194
- declare class Fiber {
195
- node: ComponentNode;
196
- bdom: BDom | null;
197
- root: RootFiber | null;
198
- parent: Fiber | null;
199
- children: Fiber[];
200
- appliedToDom: boolean;
201
- deep: boolean;
202
- childrenMap: ComponentNode["children"];
203
- constructor(node: ComponentNode, parent: Fiber | null);
204
- render(): void;
205
- _render(): void;
206
- }
207
- declare class RootFiber extends Fiber {
208
- counter: number;
209
- willPatch: Fiber[];
210
- patched: Fiber[];
211
- mounted: Fiber[];
212
- locked: boolean;
213
- complete(): void;
214
- setCounter(newValue: number): void;
215
- }
216
- declare type Position = "first-child" | "last-child";
217
- interface MountOptions {
218
- position?: Position;
219
- }
220
- declare class MountFiber extends RootFiber {
221
- target: HTMLElement;
222
- position: Position;
223
- constructor(node: ComponentNode, target: HTMLElement, options?: MountOptions);
224
- complete(): void;
225
- }
226
-
227
- interface PluginCtor {
228
- new (deps: any): Plugin<any>;
229
- id: string;
230
- dependencies: string[];
231
- }
232
- interface PluginMetaData {
233
- isDestroyed: boolean;
234
- }
235
- declare class Plugin<Deps = {
236
- [name: string]: Plugin;
237
- }> {
238
- static id: string;
239
- static dependencies: string[];
240
- readonly plugins: Deps;
241
- static resources: {};
242
- resources: {
243
- [name: string]: any;
244
- };
245
- __meta__: PluginMetaData;
246
- setup(): void;
247
- destroy(): void;
248
- get isDestroyed(): boolean;
249
- }
250
- declare class PluginManager {
251
- _parent: PluginManager | null;
252
- _children: PluginManager[];
253
- plugins: {
254
- [id: string]: Plugin;
255
- };
256
- resources: {
257
- [id: string]: any;
258
- };
259
- constructor(parent: PluginManager | null, Plugins: PluginCtor[] | (() => PluginCtor[]));
260
- destroy(): void;
261
- getPlugin(name: string): Plugin | null;
262
- getResource(name: string): any[];
263
- }
264
- declare function usePlugins(Plugins: PluginCtor[]): void;
265
-
266
- declare const enum STATUS {
267
- NEW = 0,
268
- MOUNTED = 1,
269
- CANCELLED = 2,
270
- DESTROYED = 3
271
- }
272
- declare type STATUS_DESCR = "new" | "mounted" | "cancelled" | "destroyed";
273
- declare function status(component: Component): STATUS_DESCR;
274
-
275
- declare function useComponent(): Component;
276
- /**
277
- * Creates a reactive object that will be observed by the current component.
278
- * Reading data from the returned object (eg during rendering) will cause the
279
- * component to subscribe to that data and be rerendered when it changes.
280
- *
281
- * @param state the state to observe
282
- * @returns a reactive object that will cause the component to re-render on
283
- * relevant changes
284
- * @see reactive
285
- */
286
- declare function useState<T extends object>(state: T): T;
287
- declare type LifecycleHook = Function;
288
- declare class ComponentNode<P extends Props = any, Plugins = any, E = any> implements VNode<ComponentNode<P, E>> {
289
- el?: HTMLElement | Text | undefined;
290
- app: App;
291
- fiber: Fiber | null;
292
- component: Component<P, Plugins, E>;
293
- bdom: BDom | null;
294
- status: STATUS;
295
- forceNextRender: boolean;
296
- parentKey: string | null;
297
- props: P;
298
- nextProps: P | null;
299
- renderFn: Function;
300
- parent: ComponentNode | null;
301
- childEnv: Env;
302
- children: {
303
- [key: string]: ComponentNode;
304
- };
305
- refs: any;
306
- willStart: LifecycleHook[];
307
- willUpdateProps: LifecycleHook[];
308
- willUnmount: LifecycleHook[];
309
- mounted: LifecycleHook[];
310
- willPatch: LifecycleHook[];
311
- patched: LifecycleHook[];
312
- willDestroy: LifecycleHook[];
313
- signalComputation: Computation;
314
- pluginManager: PluginManager;
315
- constructor(C: ComponentConstructor<P, Plugins, E>, props: P, app: App, parent: ComponentNode | null, parentKey: string | null);
316
- mountComponent(target: any, options?: MountOptions): void;
317
- initiateRender(fiber: Fiber | MountFiber): Promise<void>;
318
- render(deep: boolean): Promise<void>;
319
- cancel(): void;
320
- _cancel(): void;
321
- destroy(): void;
322
- _destroy(): void;
323
- updateAndRender(props: P, parentFiber: Fiber): Promise<void>;
324
- /**
325
- * Finds a child that has dom that is not yet updated, and update it. This
326
- * method is meant to be used only in the context of repatching the dom after
327
- * a mounted hook failed and was handled.
328
- */
329
- updateDom(): void;
330
- /**
331
- * Sets a ref to a given HTMLElement.
332
- *
333
- * @param name the name of the ref to set
334
- * @param el the HTMLElement to set the ref to. The ref is not set if the el
335
- * is null, but useRef will not return elements that are not in the DOM
336
- */
337
- setRef(name: string, el: HTMLElement | null): void;
338
- firstNode(): Node | undefined;
339
- mount(parent: HTMLElement, anchor: ChildNode): void;
340
- moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
341
- moveBeforeVNode(other: ComponentNode<P, E> | null, afterNode: Node | null): void;
342
- patch(): void;
343
- _patch(): void;
344
- beforeRemove(): void;
345
- remove(): void;
346
- get name(): string;
347
- }
348
-
349
- declare type Props = {
350
- [key: string]: any;
351
- };
352
- interface StaticComponentProperties {
353
- template: string;
354
- defaultProps?: any;
355
- props?: Schema;
356
- components?: {
357
- [componentName: string]: ComponentConstructor;
358
- };
359
- }
360
- declare type ComponentConstructor<P extends Props = any, Plugins = any, E = any> = (new (props: P, env: E, plugins: Plugins, node: ComponentNode) => Component<P, Plugins, E>) & StaticComponentProperties;
361
- declare class Component<Props = any, Plugins = PluginManager["plugins"], Env = any> {
362
- static template: string;
363
- static props?: Schema;
364
- static defaultProps?: any;
365
- props: Props;
366
- env: Env;
367
- plugins: Plugins;
368
- __owl__: ComponentNode;
369
- constructor(props: Props, env: Env, plugins: Plugins, node: ComponentNode);
370
- setup(): void;
371
- render(deep?: boolean): void;
372
- }
373
-
374
- declare type ErrorParams = {
375
- error: any;
376
- } & ({
377
- node: ComponentNode;
378
- } | {
379
- fiber: Fiber;
380
- });
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
+ declare const enum STATUS {
170
+ NEW = 0,
171
+ MOUNTED = 1,// is ready, and in DOM. It has a valid el
172
+ CANCELLED = 2,
173
+ DESTROYED = 3
174
+ }
175
+ type STATUS_DESCR = "new" | "started" | "mounted" | "cancelled" | "destroyed";
176
+ declare function status(entity: Component | Plugin): STATUS_DESCR;
177
+
178
+ interface PluginConstructor {
179
+ new (...args: any[]): Plugin;
180
+ id: string;
181
+ }
182
+ declare class Plugin {
183
+ private static _shadowId;
184
+ static get id(): string;
185
+ static set id(shadowId: string);
186
+ __owl__: PluginManager;
187
+ constructor(manager: PluginManager);
188
+ setup(): void;
189
+ }
190
+ interface PluginManagerOptions {
191
+ parent?: PluginManager | null;
192
+ config?: Record<string, any>;
193
+ }
194
+ declare class PluginManager {
195
+ app: App;
196
+ config: Record<string, any>;
197
+ onDestroyCb: Function[];
198
+ plugins: Record<string, Plugin>;
199
+ status: STATUS;
200
+ constructor(app: App, options?: PluginManagerOptions);
201
+ destroy(): void;
202
+ getPluginById<T extends Plugin>(id: string): T | null;
203
+ getPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
204
+ startPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
205
+ startPlugins(pluginConstructors: PluginConstructor[]): void;
206
+ }
207
+
208
+ interface ReactiveValue<TRead, TWrite = TRead> {
209
+ (): TRead;
210
+ /**
211
+ * Update the value of the reactive with a new value. If the new value is different
212
+ * from the previous values, all computations that depends on this reactive will
213
+ * be invalidated, and effects will rerun.
214
+ */
215
+ set(nextValue: TWrite): void;
216
+ }
217
+ declare enum ComputationState {
218
+ EXECUTED = 0,
219
+ STALE = 1,
220
+ PENDING = 2
221
+ }
222
+ interface Atom<T = any> {
223
+ observers: Set<ComputationAtom>;
224
+ value: T;
225
+ }
226
+ interface ComputationAtom<T = any> extends Atom<T> {
227
+ compute: () => T;
228
+ isDerived: boolean;
229
+ sources: Set<Atom>;
230
+ state: ComputationState;
231
+ }
232
+ declare function untrack<T>(fn: (...args: any[]) => T): T;
233
+
234
+ declare class Fiber {
235
+ node: ComponentNode;
236
+ bdom: BDom | null;
237
+ root: RootFiber | null;
238
+ parent: Fiber | null;
239
+ children: Fiber[];
240
+ appliedToDom: boolean;
241
+ deep: boolean;
242
+ childrenMap: ComponentNode["children"];
243
+ constructor(node: ComponentNode, parent: Fiber | null);
244
+ render(): void;
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
+ renderFn: Function;
279
+ parent: ComponentNode | null;
280
+ children: {
281
+ [key: string]: ComponentNode;
282
+ };
283
+ willStart: LifecycleHook[];
284
+ willUpdateProps: LifecycleHook[];
285
+ willUnmount: LifecycleHook[];
286
+ mounted: LifecycleHook[];
287
+ willPatch: LifecycleHook[];
288
+ patched: LifecycleHook[];
289
+ willDestroy: LifecycleHook[];
290
+ signalComputation: ComputationAtom;
291
+ pluginManager: PluginManager;
292
+ constructor(C: ComponentConstructor, props: Record<string, any>, app: App, parent: ComponentNode | null, parentKey: string | null);
293
+ mountComponent(target: any, options?: MountOptions): void;
294
+ initiateRender(fiber: Fiber | MountFiber): Promise<void>;
295
+ render(deep: boolean): Promise<void>;
296
+ cancel(): void;
297
+ _cancel(): void;
298
+ destroy(): void;
299
+ _destroy(): void;
300
+ updateAndRender(props: Record<string, any>, parentFiber: Fiber): Promise<void>;
301
+ /**
302
+ * Finds a child that has dom that is not yet updated, and update it. This
303
+ * method is meant to be used only in the context of repatching the dom after
304
+ * a mounted hook failed and was handled.
305
+ */
306
+ updateDom(): void;
307
+ firstNode(): Node | undefined;
308
+ mount(parent: HTMLElement, anchor: ChildNode): void;
309
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
310
+ moveBeforeVNode(other: ComponentNode | null, afterNode: Node | null): void;
311
+ patch(): void;
312
+ _patch(): void;
313
+ beforeRemove(): void;
314
+ remove(): void;
315
+ }
316
+
317
+ interface StaticComponentProperties {
318
+ template: string;
319
+ components?: {
320
+ [componentName: string]: ComponentConstructor;
321
+ };
322
+ }
323
+ interface ComponentConstructor extends StaticComponentProperties {
324
+ new (node: ComponentNode): Component;
325
+ }
326
+ declare class Component {
327
+ static template: string;
328
+ __owl__: ComponentNode;
329
+ constructor(node: ComponentNode);
330
+ setup(): void;
331
+ }
332
+
333
+ type Constructor<T = any> = {
334
+ new (...args: any[]): T;
335
+ };
336
+ type GetOptionalEntries<T> = {
337
+ [K in keyof T as K extends `${infer P}?` ? P : never]?: T[K];
338
+ };
339
+ type GetRequiredEntries<T> = {
340
+ [K in keyof T as K extends `${string}?` ? never : K]: T[K];
341
+ };
342
+ type PrettifyShape<T> = T extends Function ? T : {
343
+ [K in keyof T]: T[K];
344
+ };
345
+ type ResolveOptionalEntries<T> = PrettifyShape<GetRequiredEntries<T> & GetOptionalEntries<T>>;
346
+ type KeyedObject<K extends string[]> = {
347
+ [P in K[number]]: any;
348
+ };
349
+ type ResolveShapedObject<T extends {}> = PrettifyShape<ResolveOptionalEntries<T>>;
350
+ type ResolveObjectType<T extends {}> = ResolveShapedObject<T extends string[] ? KeyedObject<T> : T>;
351
+ type UnionToIntersection<U> = (U extends any ? (_: U) => any : never) extends (_: infer I) => void ? I : never;
352
+ declare function arrayType(): any[];
353
+ declare function arrayType<T>(elementType: T): T[];
354
+ declare function constructorType<T extends Constructor>(constructor: T): T;
355
+ declare function customValidator<T>(type: T, validator: (value: T) => boolean, errorMessage?: string): T;
356
+ declare function functionType(): (...parameters: any[]) => any;
357
+ declare function functionType<const P extends any[]>(parameters: P): (...parameters: P) => void;
358
+ declare function functionType<const P extends any[], R>(parameters: P, result: R): (...parameters: P) => R;
359
+ declare function instanceType<T extends Constructor>(constructor: T): InstanceType<T>;
360
+ declare function intersection<T extends any[]>(types: T): UnionToIntersection<T[number]>;
361
+ type LiteralTypes = number | string | boolean | null | undefined;
362
+ declare function literalType<const T extends LiteralTypes>(literal: T): T;
363
+ declare function literalSelection<const T extends LiteralTypes>(literals: T[]): T;
364
+ declare function objectType(): Record<string, any>;
365
+ declare function objectType<const Keys extends string[]>(keys: Keys): ResolveOptionalEntries<KeyedObject<Keys>>;
366
+ declare function objectType<Shape extends {}>(shape: Shape): ResolveOptionalEntries<Shape>;
367
+ declare function promiseType(): Promise<void>;
368
+ declare function promiseType<T>(type: T): Promise<T>;
369
+ declare function recordType(): Record<PropertyKey, any>;
370
+ declare function recordType<V>(valueType: V): Record<PropertyKey, V>;
371
+ declare function tuple<const T extends any[]>(types: T): T;
372
+ declare function union<T extends any[]>(types: T): T[number];
373
+ declare function reactiveValueType(): ReactiveValue<any>;
374
+ declare function reactiveValueType<T>(type: T): ReactiveValue<T>;
375
+ declare function ref(): HTMLElement | null;
376
+ declare function ref<T extends Constructor<HTMLElement>>(type: T): InstanceType<T> | null;
377
+ declare const types: {
378
+ and: typeof intersection;
379
+ any: any;
380
+ array: typeof arrayType;
381
+ boolean: boolean;
382
+ constructor: typeof constructorType;
383
+ customValidator: typeof customValidator;
384
+ function: typeof functionType;
385
+ instanceOf: typeof instanceType;
386
+ literal: typeof literalType;
387
+ number: number;
388
+ object: typeof objectType;
389
+ or: typeof union;
390
+ promise: typeof promiseType;
391
+ record: typeof recordType;
392
+ ref: typeof ref;
393
+ selection: typeof literalSelection;
394
+ signal: typeof reactiveValueType;
395
+ string: string;
396
+ tuple: typeof tuple;
397
+ };
398
+
399
+ declare const isProps: unique symbol;
400
+ type WithDefaults<T, D> = T & Required<D>;
401
+ type Props<T extends {}> = T & {
402
+ [isProps]: true;
403
+ };
404
+ type GetPropsDefaults<T extends object> = PrettifyShape<GetOptionalEntries<T>>;
405
+ type GetPropsWithOptionals<T> = T extends Props<infer P> ? (P extends WithDefaults<infer R, any> ? R : P) : never;
406
+ type GetProps<T> = {
407
+ [K in keyof T]: T[K] extends {
408
+ [isProps]: true;
409
+ } ? (x: GetPropsWithOptionals<T[K]>) => void : never;
410
+ }[keyof T] extends (x: infer I) => void ? {
411
+ [K in keyof I]: I[K];
412
+ } : never;
413
+ declare function props(): Props<Record<string, any>>;
414
+ declare function props<const Keys extends string[]>(keys: Keys): Props<ResolveObjectType<Keys>>;
415
+ declare function props<const Keys extends string[], Defaults>(keys: Keys, defaults: Defaults & GetPropsDefaults<KeyedObject<Keys>>): Props<WithDefaults<ResolveObjectType<Keys>, Defaults>>;
416
+ declare function props<Shape extends {}>(shape: Shape): Props<ResolveObjectType<Shape>>;
417
+ declare function props<Shape extends {}, Defaults>(shape: Shape, defaults: Defaults & GetPropsDefaults<Shape>): Props<WithDefaults<ResolveObjectType<Shape>, Defaults>>;
418
+
419
+ type Target = object;
420
+ type Reactive<T extends Target> = T;
421
+ /**
422
+ * Mark an object or array so that it is ignored by the reactivity system
423
+ *
424
+ * @param value the value to mark
425
+ * @returns the object itself
426
+ */
427
+ declare function markRaw<T extends Target>(value: T): T;
428
+ /**
429
+ * Given a proxy objet, return the raw (non proxy) underlying object
430
+ *
431
+ * @param value a proxy value
432
+ * @returns the underlying value
433
+ */
434
+ declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
435
+ /**
436
+ * Creates a reactive proxy for an object. Reading data on the proxy object
437
+ * subscribes to changes to the data. Writing data on the object will cause the
438
+ * notify callback to be called if there are suscriptions to that data. Nested
439
+ * objects and arrays are automatically made reactive as well.
440
+ *
441
+ * Whenever you are notified of a change, all subscriptions are cleared, and if
442
+ * you would like to be notified of any further changes, you should go read
443
+ * the underlying data again. We assume that if you don't go read it again after
444
+ * being notified, it means that you are no longer interested in that data.
445
+ *
446
+ * Subscriptions:
447
+ * + Reading a property on an object will subscribe you to changes in the value
448
+ * of that property.
449
+ * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
450
+ * subscribe you to the creation/deletion of keys. Checking the presence of a
451
+ * key on the object with 'in' has the same effect.
452
+ * - getOwnPropertyDescriptor does not currently subscribe you to the property.
453
+ * This is a choice that was made because changing a key's value will trigger
454
+ * this trap and we do not want to subscribe by writes. This also means that
455
+ * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
456
+ *
457
+ * @param target the object for which to create a proxy proxy
458
+ * @param callback the function to call when an observed property of the
459
+ * proxy has changed
460
+ * @returns a proxy that tracks changes to it
461
+ */
462
+ declare function proxy<T extends Target>(target: T): T;
463
+
464
+ type ErrorParams = {
465
+ error: any;
466
+ } & ({
467
+ node: ComponentNode;
468
+ } | {
469
+ fiber: Fiber;
470
+ });
381
471
  declare function handleError(params: ErrorParams): void;
382
472
 
383
- declare class Scheduler {
384
- static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
385
- tasks: Set<RootFiber>;
386
- requestAnimationFrame: Window["requestAnimationFrame"];
387
- frame: number;
388
- delayedRenders: Fiber[];
389
- cancelledNodes: Set<ComponentNode>;
390
- processing: boolean;
391
- constructor();
392
- addFiber(fiber: Fiber): void;
393
- scheduleDestroy(node: ComponentNode): void;
394
- /**
395
- * Process all current tasks. This only applies to the fibers that are ready.
396
- * Other tasks are left unchanged.
397
- */
398
- flush(): void;
399
- processTasks(): void;
400
- processFiber(fiber: RootFiber): void;
401
- }
402
-
403
- interface Config {
404
- translateFn?: (s: string, translationCtx: string) => string;
405
- translatableAttributes?: string[];
406
- dev?: boolean;
407
- }
408
-
409
- declare type Template = (context: any, vnode: any, key?: string) => BDom;
410
- declare type TemplateFunction = (app: TemplateSet, bdom: any, helpers: any) => Template;
411
- interface CompileOptions extends Config {
412
- name?: string;
413
- customDirectives?: customDirectives;
414
- hasGlobalValues: boolean;
415
- }
416
- declare function compile(template: string | Element, options?: CompileOptions): TemplateFunction;
417
-
418
- declare class Portal extends Component {
419
- static template: string;
420
- static props: {
421
- readonly target: {
422
- readonly type: StringConstructor;
423
- };
424
- readonly slots: true;
425
- };
426
- setup(): void;
427
- }
428
-
429
- interface TemplateSetConfig {
430
- dev?: boolean;
431
- translatableAttributes?: string[];
432
- translateFn?: (s: string, translationCtx: string) => string;
433
- templates?: string | Document | Record<string, string>;
434
- getTemplate?: (s: string) => Element | Function | string | void;
435
- customDirectives?: customDirectives;
436
- globalValues?: object;
437
- }
438
- declare class TemplateSet {
439
- static registerTemplate(name: string, fn: TemplateFunction): void;
440
- dev: boolean;
441
- rawTemplates: typeof globalTemplates;
442
- templates: {
443
- [name: string]: Template;
444
- };
445
- getRawTemplate?: (s: string) => Element | Function | string | void;
446
- translateFn?: (s: string, translationCtx: string) => string;
447
- translatableAttributes?: string[];
448
- Portal: typeof Portal;
449
- customDirectives: customDirectives;
450
- runtimeUtils: object;
451
- hasGlobalValues: boolean;
452
- constructor(config?: TemplateSetConfig);
453
- addTemplate(name: string, template: string | Element): void;
454
- addTemplates(xml: string | Document): void;
455
- getTemplate(name: string): Template;
456
- _compileTemplate(name: string, template: string | Element): ReturnType<typeof compile>;
457
- callTemplate(owner: any, subTemplate: string, ctx: any, parent: any, key: any): any;
458
- }
459
- declare const globalTemplates: {
460
- [key: string]: string | Element | TemplateFunction;
461
- };
462
- declare function xml(...args: Parameters<typeof String.raw>): string;
463
- declare namespace xml {
464
- var nextId: number;
465
- }
466
-
467
- declare type Callback = () => void;
468
- /**
469
- * Creates a batched version of a callback so that all calls to it in the same
470
- * microtick will only call the original callback once.
471
- *
472
- * @param callback the callback to batch
473
- * @returns a batched version of the original callback
474
- */
475
- declare function batched(callback: Callback): Callback;
476
- declare function validateTarget(target: HTMLElement | ShadowRoot): void;
477
- declare class EventBus extends EventTarget {
478
- trigger(name: string, payload?: any): void;
479
- }
480
- declare function whenReady(fn?: any): Promise<void>;
481
- declare function loadFile(url: string): Promise<string>;
482
- declare class Markup extends String {
483
- }
484
- declare function htmlEscape(str: any): Markup;
485
- declare function markup(strings: TemplateStringsArray, ...placeholders: unknown[]): Markup;
473
+ declare class Scheduler {
474
+ static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
475
+ tasks: Set<RootFiber>;
476
+ requestAnimationFrame: Window["requestAnimationFrame"];
477
+ frame: number;
478
+ delayedRenders: Fiber[];
479
+ cancelledNodes: Set<ComponentNode>;
480
+ processing: boolean;
481
+ constructor();
482
+ addFiber(fiber: Fiber): void;
483
+ scheduleDestroy(node: ComponentNode): void;
484
+ /**
485
+ * Process all current tasks. This only applies to the fibers that are ready.
486
+ * Other tasks are left unchanged.
487
+ */
488
+ flush(): void;
489
+ processTasks(): void;
490
+ processFiber(fiber: RootFiber): void;
491
+ }
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;
531
+ }
532
+
533
+ type Callback = (...args: any[]) => void;
534
+ /**
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
540
+ */
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;
545
+ }
546
+ declare function whenReady(fn?: any): Promise<void>;
547
+ declare class Markup extends String {
548
+ }
549
+ declare function htmlEscape(str: any): Markup;
550
+ declare function markup(strings: TemplateStringsArray, ...placeholders: unknown[]): Markup;
486
551
  declare function markup(value: string): Markup;
487
552
 
488
- declare type Target = object;
489
- declare type Reactive<T extends Target> = T;
490
- /**
491
- * Mark an object or array so that it is ignored by the reactivity system
492
- *
493
- * @param value the value to mark
494
- * @returns the object itself
495
- */
496
- declare function markRaw<T extends Target>(value: T): T;
497
- /**
498
- * Given a reactive objet, return the raw (non reactive) underlying object
499
- *
500
- * @param value a reactive value
501
- * @returns the underlying value
502
- */
503
- declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
504
- /**
505
- * Creates a reactive proxy for an object. Reading data on the reactive object
506
- * subscribes to changes to the data. Writing data on the object will cause the
507
- * notify callback to be called if there are suscriptions to that data. Nested
508
- * objects and arrays are automatically made reactive as well.
509
- *
510
- * Whenever you are notified of a change, all subscriptions are cleared, and if
511
- * you would like to be notified of any further changes, you should go read
512
- * the underlying data again. We assume that if you don't go read it again after
513
- * being notified, it means that you are no longer interested in that data.
514
- *
515
- * Subscriptions:
516
- * + Reading a property on an object will subscribe you to changes in the value
517
- * of that property.
518
- * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
519
- * subscribe you to the creation/deletion of keys. Checking the presence of a
520
- * key on the object with 'in' has the same effect.
521
- * - getOwnPropertyDescriptor does not currently subscribe you to the property.
522
- * This is a choice that was made because changing a key's value will trigger
523
- * this trap and we do not want to subscribe by writes. This also means that
524
- * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
525
- *
526
- * @param target the object for which to create a reactive proxy
527
- * @param callback the function to call when an observed property of the
528
- * reactive has changed
529
- * @returns a proxy that tracks changes to it
530
- */
531
- declare function reactive<T extends Target>(target: T): T;
532
-
533
- interface Env {
534
- [key: string]: any;
535
- }
536
- interface RootConfig<P, E> {
537
- props?: P;
538
- env?: E;
539
- Plugins?: PluginCtor[];
540
- }
541
- interface AppConfig<P, E> extends TemplateSetConfig, RootConfig<P, E> {
542
- name?: string;
543
- test?: boolean;
544
- warnIfNoStaticProps?: boolean;
545
- }
546
- declare global {
547
- interface Window {
548
- __OWL_DEVTOOLS__: {
549
- apps: Set<App>;
550
- Fiber: typeof Fiber;
551
- RootFiber: typeof RootFiber;
552
- toRaw: typeof toRaw;
553
- reactive: typeof reactive;
554
- };
555
- }
556
- }
557
- interface Root<P extends Props, E> {
558
- node: ComponentNode<P, E>;
559
- mount(target: HTMLElement | ShadowRoot, options?: MountOptions): Promise<Component<P, E>>;
560
- destroy(): void;
561
- }
562
- declare class App<T extends abstract new (...args: any) => any = any, P extends object = any, E = any> extends TemplateSet {
563
- static validateTarget: typeof validateTarget;
564
- static apps: Set<App<any, any, any>>;
565
- static version: string;
566
- name: string;
567
- Root: ComponentConstructor<P, E>;
568
- props: P;
569
- env: E;
570
- scheduler: Scheduler;
571
- subRoots: Set<ComponentNode>;
572
- root: ComponentNode<P, E> | null;
573
- warnIfNoStaticProps: boolean;
574
- pluginManager: PluginManager;
575
- constructor(Root: ComponentConstructor<P, E>, config?: AppConfig<P, E>);
576
- mount(target: HTMLElement | ShadowRoot, options?: MountOptions): Promise<Component<P, E> & InstanceType<T>>;
577
- createRoot<Props extends object, SubEnv = any>(Root: ComponentConstructor<Props, E>, config?: RootConfig<Props, SubEnv>): Root<Props, SubEnv>;
578
- makeNode(Component: ComponentConstructor, props: any): ComponentNode;
579
- mountNode(node: ComponentNode, target: HTMLElement | ShadowRoot, options?: MountOptions): any;
580
- destroy(): void;
581
- createComponent<P extends Props>(name: string | null, isStatic: boolean, hasSlotsProp: boolean, hasDynamicPropList: boolean, propList: string[]): (props: P, key: string, ctx: ComponentNode, parent: any, C: any) => any;
582
- handleError(...args: Parameters<typeof handleError>): void;
583
- }
584
- declare function mount<T extends abstract new (...args: any) => any = any, P extends object = any, E = any>(C: T & ComponentConstructor<P, E>, target: HTMLElement, config?: AppConfig<P, E> & MountOptions): Promise<Component<P, E> & InstanceType<T>>;
585
-
586
- declare function signal<T>(value: T, opts?: Opts): {
587
- readonly get: () => T;
588
- readonly set: (newValue: T | ((prevValue: T) => T)) => void;
589
- };
590
- declare function effect<T>(fn: () => T, opts?: Opts): () => void;
591
- declare function derived<T>(fn: () => T, opts?: Opts): () => T;
592
- declare function withoutReactivity<T extends (...args: any[]) => any>(fn: T): ReturnType<T>;
593
-
594
- /**
595
- * The purpose of this hook is to allow components to get a reference to a sub
596
- * html node or component.
597
- */
598
- declare function useRef<T extends HTMLElement = HTMLElement>(name: string): {
599
- el: T | null;
600
- };
601
- /**
602
- * This hook is useful as a building block for some customized hooks, that may
603
- * need a reference to the env of the component calling them.
604
- */
605
- declare function useEnv<E extends Env>(): E;
606
- /**
607
- * This hook is a simple way to let components use a sub environment. Note that
608
- * like for all hooks, it is important that this is only called in the
609
- * constructor method.
610
- */
611
- declare function useSubEnv(envExtension: Env): void;
612
- declare function useChildSubEnv(envExtension: Env): void;
613
- declare type EffectDeps<T extends unknown[]> = T | (T extends [...infer H, never] ? EffectDeps<H> : never);
614
- /**
615
- * @template T
616
- * @param {...T} dependencies the dependencies computed by computeDependencies
617
- * @returns {void|(()=>void)} a cleanup function that reverses the side
618
- * effects of the effect callback.
619
- */
620
- declare type Effect<T extends unknown[]> = (...dependencies: EffectDeps<T>) => void | (() => void);
621
- /**
622
- * This hook will run a callback when a component is mounted and patched, and
623
- * will run a cleanup function before patching and before unmounting the
624
- * the component.
625
- *
626
- * @template T
627
- * @param {Effect<T>} effect the effect to run on component mount and/or patch
628
- * @param {()=>[...T]} [computeDependencies=()=>[NaN]] a callback to compute
629
- * dependencies that will decide if the effect needs to be cleaned up and
630
- * run again. If the dependencies did not change, the effect will not run
631
- * again. The default value returns an array containing only NaN because
632
- * NaN !== NaN, which will cause the effect to rerun on every patch.
633
- */
634
- declare function useEffect<T extends unknown[]>(effect: Effect<T>, computeDependencies?: () => [...T]): void;
635
- /**
636
- * When a component needs to listen to DOM Events on element(s) that are not
637
- * part of his hierarchy, we can use the `useExternalListener` hook.
638
- * It will correctly add and remove the event listener, whenever the
639
- * component is mounted and unmounted.
640
- *
641
- * Example:
642
- * a menu needs to listen to the click on window to be closed automatically
643
- *
644
- * Usage:
645
- * in the constructor of the OWL component that needs to be notified,
646
- * `useExternalListener(window, 'click', this._doSomething);`
647
- * */
648
- declare function useExternalListener(target: EventTarget, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
649
-
650
- declare function onWillStart(fn: () => Promise<void> | void | any): void;
651
- declare function onWillUpdateProps(fn: (nextProps: any) => Promise<void> | void | any): void;
652
- declare function onMounted(fn: () => void | any): void;
653
- declare function onWillPatch(fn: () => any | void): void;
654
- declare function onPatched(fn: () => void | any): void;
655
- declare function onWillUnmount(fn: () => void | any): void;
656
- declare function onWillDestroy(fn: () => void | any): void;
657
- declare function onWillRender(fn: () => void | any): void;
658
- declare function onRendered(fn: () => void | any): void;
659
- declare type OnErrorCallback = (error: any) => void | any;
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
+ }
573
+ }
574
+ type MountTarget = HTMLElement | ShadowRoot;
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
+ private mountNode;
592
+ destroy(): void;
593
+ handleError(...args: Parameters<typeof handleError>): void;
594
+ }
595
+ declare function mount<T extends ComponentConstructor>(C: T, target: MountTarget, config?: AppConfig & RootConfig<GetProps<ComponentInstance<T>>> & MountOptions): Promise<ComponentInstance<T>>;
596
+
597
+ interface Signal<T> extends ReactiveValue<T> {
598
+ /**
599
+ * Update the value of the signal with a new value. If the new value is different
600
+ * from the previous values, all computations that depends on this signal will
601
+ * be invalidated, and effects will rerun.
602
+ */
603
+ set(nextValue: T): void;
604
+ }
605
+ interface SignalOptions<T> {
606
+ type?: T;
607
+ }
608
+ declare function invalidateSignal(signal: Signal<any>): void;
609
+ declare function signalArray<T>(initialValue: T[], options?: SignalOptions<T>): Signal<T[]>;
610
+ declare function signalObject<T extends Record<PropertyKey, any>>(initialValue: T, options?: SignalOptions<T>): Signal<T>;
611
+ interface MapSignalOptions<K, V> {
612
+ name?: string;
613
+ keyType?: K;
614
+ valueType?: V;
615
+ }
616
+ declare function signalMap<K, V>(initialValue: Map<K, V>, options?: MapSignalOptions<K, V>): Signal<Map<K, V>>;
617
+ declare function signalSet<T>(initialValue: Set<T>, options?: SignalOptions<T>): Signal<Set<T>>;
618
+ declare function signal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
619
+ declare namespace signal {
620
+ var invalidate: typeof invalidateSignal;
621
+ var Array: typeof signalArray;
622
+ var Map: typeof signalMap;
623
+ var Object: typeof signalObject;
624
+ var Set: typeof signalSet;
625
+ }
626
+
627
+ interface ComputedOptions<TWrite> {
628
+ set?(value: TWrite): void;
629
+ }
630
+ declare function computed<TRead, TWrite = TRead>(getter: () => TRead, options?: ComputedOptions<TWrite>): ReactiveValue<TRead, TWrite>;
631
+
632
+ declare function effect<T>(fn: () => T): () => void;
633
+
634
+ /**
635
+ * This hook will run a callback when a component is mounted and patched, and
636
+ * will run a cleanup function before patching and before unmounting the
637
+ * the component.
638
+ *
639
+ * @template T
640
+ * @param {Effect<T>} effect the effect to run on component mount and/or patch
641
+ * @param {()=>[...T]} [computeDependencies=()=>[NaN]] a callback to compute
642
+ * dependencies that will decide if the effect needs to be cleaned up and
643
+ * run again. If the dependencies did not change, the effect will not run
644
+ * again. The default value returns an array containing only NaN because
645
+ * NaN !== NaN, which will cause the effect to rerun on every patch.
646
+ */
647
+ declare function useEffect(fn: Parameters<typeof effect>[0]): void;
648
+ /**
649
+ * When a component needs to listen to DOM Events on element(s) that are not
650
+ * part of his hierarchy, we can use the `useListener` hook.
651
+ * It will immediately add the listener, and remove it whenever the plugin or
652
+ * component is destroyed.
653
+ *
654
+ * Example:
655
+ * a menu needs to listen to the click on window to be closed automatically
656
+ *
657
+ * Usage:
658
+ * in the constructor of the OWL component that needs to be notified,
659
+ * `useListener(window, 'click', () => this._doSomething());`
660
+ * */
661
+ declare function useListener(target: EventTarget | Signal<EventTarget | null>, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
662
+ declare function useApp(): App;
663
+
664
+ declare function onWillStart(fn: () => Promise<void> | void | any): void;
665
+ declare function onWillUpdateProps(fn: (nextProps: any) => Promise<void> | void | any): void;
666
+ declare function onMounted(fn: () => void | any): void;
667
+ declare function onWillPatch(fn: () => any | void): void;
668
+ declare function onPatched(fn: () => void | any): void;
669
+ declare function onWillUnmount(fn: () => void | any): void;
670
+ declare function onWillDestroy(fn: () => void | any): void;
671
+ type OnErrorCallback = (error: any) => void | any;
660
672
  declare function onError(callback: OnErrorCallback): void;
661
673
 
662
- declare class OwlError extends Error {
663
- cause?: any;
664
- }
665
-
666
- declare const blockDom: {
667
- config: {
668
- shouldNormalizeDom: boolean;
669
- mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null | undefined) => boolean;
670
- };
671
- mount: typeof mount$1;
672
- patch: typeof patch;
673
- remove: typeof remove;
674
- list: typeof list;
675
- multi: typeof multi;
676
- text: typeof text;
677
- toggler: typeof toggler;
678
- createBlock: typeof createBlock;
679
- html: typeof html;
680
- comment: typeof comment;
681
- };
682
-
683
- declare const __info__: {
684
- version: string;
674
+ interface ValidationIssue {
675
+ message: string;
676
+ path?: PropertyKey[];
677
+ received?: any;
678
+ [K: string]: any;
679
+ }
680
+ declare function assertType(value: any, validation: any, errorMessage?: string): void;
681
+ declare function validateType(value: any, validation: any): ValidationIssue[];
682
+
683
+ declare class OwlError extends Error {
684
+ cause?: any;
685
+ }
686
+
687
+ type PluginInstance<T extends PluginConstructor> = Omit<InstanceType<T>, "setup">;
688
+ declare function plugin<T extends PluginConstructor>(pluginType: T): PluginInstance<T>;
689
+ declare function config<T = any>(name: string, type?: T): T;
690
+ declare function providePlugins(pluginConstructors: PluginConstructor[] | Resource<PluginConstructor>, config?: Record<string, any>): void;
691
+
692
+ interface CapturedContext {
693
+ run<T = void>(callback: () => T): T;
694
+ protectAsync<P extends any[], R>(callback: (...args: P) => Promise<R>): (...args: P) => Promise<R>;
695
+ runWithAsyncProtection<T>(callback: () => Promise<T>): Promise<T>;
696
+ }
697
+ /**
698
+ * Captures the current context and gives methods to run
699
+ * functions within the captured context.
700
+ */
701
+ declare function useContext(): CapturedContext;
702
+
703
+ declare const blockDom: {
704
+ config: {
705
+ shouldNormalizeDom: boolean;
706
+ mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null) => boolean;
707
+ };
708
+ mount: typeof mount$1;
709
+ patch: typeof patch;
710
+ remove: typeof remove;
711
+ list: typeof list;
712
+ multi: typeof multi;
713
+ text: typeof text;
714
+ toggler: typeof toggler;
715
+ createBlock: typeof createBlock;
716
+ html: typeof html;
717
+ comment: typeof comment;
718
+ };
719
+
720
+ declare const __info__: {
721
+ version: string;
685
722
  };
686
723
 
687
- export { App, Component, ComponentConstructor, EventBus, OwlError, Plugin, PluginManager, Registry, __info__, batched, blockDom, derived, effect, htmlEscape, loadFile, markRaw, markup, mount, onError, onMounted, onPatched, onRendered, onWillDestroy, onWillPatch, onWillRender, onWillStart, onWillUnmount, onWillUpdateProps, reactive, signal, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, usePlugins, useRef, useState, useSubEnv, validate, validateType, whenReady, withoutReactivity, xml };
724
+ 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 };
725
+ export type { CapturedContext, ComponentConstructor, GetProps, PluginConstructor, PluginInstance, ReactiveValue, Signal };