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