@odoo/owl 2.0.0-beta.3 → 2.0.1
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 +3 -1
- package/dist/owl.cjs.js +2133 -1802
- package/dist/owl.es.js +2132 -1803
- package/dist/owl.iife.js +2133 -1802
- package/dist/owl.iife.min.js +1 -1
- package/dist/types/compiler/code_generator.d.ts +30 -30
- package/dist/types/compiler/index.d.ts +3 -2
- package/dist/types/compiler/inline_expressions.d.ts +1 -22
- package/dist/types/compiler/parser.d.ts +2 -1
- package/dist/types/index.d.ts +1 -27
- package/dist/types/owl.d.ts +539 -0
- package/dist/types/{app → runtime}/app.d.ts +10 -5
- package/dist/types/{blockdom → runtime/blockdom}/attributes.d.ts +0 -0
- package/dist/types/{blockdom → runtime/blockdom}/block_compiler.d.ts +0 -0
- package/dist/types/{blockdom → runtime/blockdom}/config.d.ts +0 -0
- package/dist/types/{blockdom → runtime/blockdom}/event_catcher.d.ts +0 -0
- package/dist/types/{blockdom → runtime/blockdom}/events.d.ts +0 -0
- package/dist/types/{blockdom → runtime/blockdom}/html.d.ts +2 -1
- package/dist/types/{blockdom → runtime/blockdom}/index.d.ts +2 -1
- package/dist/types/{blockdom → runtime/blockdom}/list.d.ts +2 -1
- package/dist/types/{blockdom → runtime/blockdom}/multi.d.ts +2 -1
- package/dist/types/{blockdom → runtime/blockdom}/text.d.ts +2 -1
- package/dist/types/{blockdom → runtime/blockdom}/toggler.d.ts +2 -1
- package/dist/types/{component → runtime}/component.d.ts +6 -2
- package/dist/types/{component → runtime}/component_node.d.ts +15 -14
- package/dist/types/{component → runtime}/error_handling.d.ts +3 -0
- package/dist/types/{component/handler.d.ts → runtime/event_handling.d.ts} +0 -0
- package/dist/types/{component → runtime}/fibers.d.ts +5 -1
- package/dist/types/{hooks.d.ts → runtime/hooks.d.ts} +1 -1
- package/dist/types/runtime/index.d.ts +31 -0
- package/dist/types/{component → runtime}/lifecycle_hooks.d.ts +0 -0
- package/dist/types/runtime/portal.d.ts +15 -0
- package/dist/types/{reactivity.d.ts → runtime/reactivity.d.ts} +0 -0
- package/dist/types/{component → runtime}/scheduler.d.ts +3 -4
- package/dist/types/{component → runtime}/status.d.ts +0 -0
- package/dist/types/{app → runtime}/template_helpers.d.ts +17 -4
- package/dist/types/runtime/template_set.d.ts +32 -0
- package/dist/types/{utils.d.ts → runtime/utils.d.ts} +0 -7
- package/dist/types/runtime/validation.d.ts +32 -0
- package/package.json +7 -4
- package/CHANGELOG.md +0 -766
- package/dist/owl.cjs.min.js +0 -1
- package/dist/owl.es.min.js +0 -1
- package/dist/types/app/template_set.d.ts +0 -27
- package/dist/types/component/props_validation.d.ts +0 -14
- package/dist/types/portal.d.ts +0 -11
|
@@ -0,0 +1,539 @@
|
|
|
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
|
+
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
|
+
*/
|
|
33
|
+
declare function createBlock(str: string): BlockType;
|
|
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
|
+
}
|
|
50
|
+
declare function list(children: VNode[]): VNode<VList>;
|
|
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
|
+
}
|
|
67
|
+
declare function multi(children: (VNode | undefined)[]): VNode<VMulti>;
|
|
68
|
+
|
|
69
|
+
declare abstract class VSimpleNode {
|
|
70
|
+
text: string | String;
|
|
71
|
+
parentEl?: HTMLElement | undefined;
|
|
72
|
+
el?: any;
|
|
73
|
+
constructor(text: string | String);
|
|
74
|
+
mountNode(node: Node, parent: HTMLElement, afterNode: Node | null): void;
|
|
75
|
+
moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
|
|
76
|
+
moveBeforeVNode(other: VText | null, afterNode: Node | null): void;
|
|
77
|
+
beforeRemove(): void;
|
|
78
|
+
remove(): void;
|
|
79
|
+
firstNode(): Node;
|
|
80
|
+
toString(): string | String;
|
|
81
|
+
}
|
|
82
|
+
declare class VText extends VSimpleNode {
|
|
83
|
+
mount(parent: HTMLElement, afterNode: Node | null): void;
|
|
84
|
+
patch(other: VText): void;
|
|
85
|
+
}
|
|
86
|
+
declare class VComment extends VSimpleNode {
|
|
87
|
+
mount(parent: HTMLElement, afterNode: Node | null): void;
|
|
88
|
+
patch(): void;
|
|
89
|
+
}
|
|
90
|
+
declare function text(str: string | String): VNode<VText>;
|
|
91
|
+
declare function comment(str: string): VNode<VComment>;
|
|
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
|
+
}
|
|
107
|
+
declare function html(str: string): VNode<VHtml>;
|
|
108
|
+
|
|
109
|
+
interface VNode<T = any> {
|
|
110
|
+
mount(parent: HTMLElement, afterNode: Node | null): void;
|
|
111
|
+
moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
|
|
112
|
+
moveBeforeVNode(other: T | null, afterNode: Node | null): void;
|
|
113
|
+
patch(other: T, withBeforeRemove: boolean): void;
|
|
114
|
+
beforeRemove(): void;
|
|
115
|
+
remove(): void;
|
|
116
|
+
firstNode(): Node | undefined;
|
|
117
|
+
el?: undefined | HTMLElement | Text;
|
|
118
|
+
parentEl?: undefined | HTMLElement;
|
|
119
|
+
isOnlyChild?: boolean | undefined;
|
|
120
|
+
key?: any;
|
|
121
|
+
}
|
|
122
|
+
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;
|
|
125
|
+
declare function remove(vnode: VNode, withBeforeRemove?: boolean): void;
|
|
126
|
+
|
|
127
|
+
declare type Callback = () => void;
|
|
128
|
+
declare function validateTarget(target: HTMLElement): void;
|
|
129
|
+
declare class EventBus extends EventTarget {
|
|
130
|
+
trigger(name: string, payload?: any): void;
|
|
131
|
+
}
|
|
132
|
+
declare function whenReady(fn?: any): Promise<void>;
|
|
133
|
+
declare function loadFile(url: string): Promise<string>;
|
|
134
|
+
declare class Markup extends String {
|
|
135
|
+
}
|
|
136
|
+
declare function markup(value: any): Markup;
|
|
137
|
+
|
|
138
|
+
declare const TARGET: unique symbol;
|
|
139
|
+
declare const SKIP: unique symbol;
|
|
140
|
+
declare type Target = object;
|
|
141
|
+
declare type Reactive<T extends Target = Target> = T & {
|
|
142
|
+
[TARGET]: any;
|
|
143
|
+
};
|
|
144
|
+
declare type NonReactive<T extends Target = Target> = T & {
|
|
145
|
+
[SKIP]: any;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Mark an object or array so that it is ignored by the reactivity system
|
|
149
|
+
*
|
|
150
|
+
* @param value the value to mark
|
|
151
|
+
* @returns the object itself
|
|
152
|
+
*/
|
|
153
|
+
declare function markRaw<T extends Target>(value: T): NonReactive<T>;
|
|
154
|
+
/**
|
|
155
|
+
* Given a reactive objet, return the raw (non reactive) underlying object
|
|
156
|
+
*
|
|
157
|
+
* @param value a reactive value
|
|
158
|
+
* @returns the underlying value
|
|
159
|
+
*/
|
|
160
|
+
declare function toRaw<T extends object>(value: Reactive<T>): T;
|
|
161
|
+
declare function getSubscriptions(callback: Callback): {
|
|
162
|
+
target: object;
|
|
163
|
+
keys: PropertyKey[];
|
|
164
|
+
}[];
|
|
165
|
+
/**
|
|
166
|
+
* Creates a reactive proxy for an object. Reading data on the reactive object
|
|
167
|
+
* subscribes to changes to the data. Writing data on the object will cause the
|
|
168
|
+
* notify callback to be called if there are suscriptions to that data. Nested
|
|
169
|
+
* objects and arrays are automatically made reactive as well.
|
|
170
|
+
*
|
|
171
|
+
* Whenever you are notified of a change, all subscriptions are cleared, and if
|
|
172
|
+
* you would like to be notified of any further changes, you should go read
|
|
173
|
+
* the underlying data again. We assume that if you don't go read it again after
|
|
174
|
+
* being notified, it means that you are no longer interested in that data.
|
|
175
|
+
*
|
|
176
|
+
* Subscriptions:
|
|
177
|
+
* + Reading a property on an object will subscribe you to changes in the value
|
|
178
|
+
* of that property.
|
|
179
|
+
* + Accessing an object keys (eg with Object.keys or with `for..in`) will
|
|
180
|
+
* subscribe you to the creation/deletion of keys. Checking the presence of a
|
|
181
|
+
* key on the object with 'in' has the same effect.
|
|
182
|
+
* - getOwnPropertyDescriptor does not currently subscribe you to the property.
|
|
183
|
+
* This is a choice that was made because changing a key's value will trigger
|
|
184
|
+
* this trap and we do not want to subscribe by writes. This also means that
|
|
185
|
+
* Object.hasOwnProperty doesn't subscribe as it goes through this trap.
|
|
186
|
+
*
|
|
187
|
+
* @param target the object for which to create a reactive proxy
|
|
188
|
+
* @param callback the function to call when an observed property of the
|
|
189
|
+
* reactive has changed
|
|
190
|
+
* @returns a proxy that tracks changes to it
|
|
191
|
+
*/
|
|
192
|
+
declare function reactive<T extends Target>(target: T, callback?: Callback): Reactive<T> | NonReactive<T>;
|
|
193
|
+
|
|
194
|
+
declare type BaseType = typeof String | typeof Boolean | typeof Number | typeof Date | typeof Object | typeof Array | true | "*";
|
|
195
|
+
interface TypeInfo {
|
|
196
|
+
type?: TypeDescription;
|
|
197
|
+
optional?: boolean;
|
|
198
|
+
validate?: Function;
|
|
199
|
+
shape?: Schema;
|
|
200
|
+
element?: TypeDescription;
|
|
201
|
+
}
|
|
202
|
+
declare type ValueType = {
|
|
203
|
+
value: any;
|
|
204
|
+
};
|
|
205
|
+
declare type TypeDescription = BaseType | TypeInfo | ValueType | TypeDescription[];
|
|
206
|
+
declare type SimplifiedSchema = string[];
|
|
207
|
+
declare type NormalizedSchema = {
|
|
208
|
+
[key: string]: TypeDescription;
|
|
209
|
+
};
|
|
210
|
+
declare type Schema = SimplifiedSchema | NormalizedSchema;
|
|
211
|
+
/**
|
|
212
|
+
* Main validate function
|
|
213
|
+
*/
|
|
214
|
+
declare function validate(obj: {
|
|
215
|
+
[key: string]: any;
|
|
216
|
+
}, spec: Schema): void;
|
|
217
|
+
|
|
218
|
+
declare class Fiber {
|
|
219
|
+
node: ComponentNode;
|
|
220
|
+
bdom: BDom | null;
|
|
221
|
+
root: RootFiber | null;
|
|
222
|
+
parent: Fiber | null;
|
|
223
|
+
children: Fiber[];
|
|
224
|
+
appliedToDom: boolean;
|
|
225
|
+
deep: boolean;
|
|
226
|
+
childrenMap: ComponentNode["children"];
|
|
227
|
+
constructor(node: ComponentNode, parent: Fiber | null);
|
|
228
|
+
render(): void;
|
|
229
|
+
_render(): void;
|
|
230
|
+
}
|
|
231
|
+
declare class RootFiber extends Fiber {
|
|
232
|
+
counter: number;
|
|
233
|
+
willPatch: Fiber[];
|
|
234
|
+
patched: Fiber[];
|
|
235
|
+
mounted: Fiber[];
|
|
236
|
+
locked: boolean;
|
|
237
|
+
complete(): void;
|
|
238
|
+
setCounter(newValue: number): void;
|
|
239
|
+
}
|
|
240
|
+
declare type Position = "first-child" | "last-child";
|
|
241
|
+
interface MountOptions {
|
|
242
|
+
position?: Position;
|
|
243
|
+
}
|
|
244
|
+
declare class MountFiber extends RootFiber {
|
|
245
|
+
target: HTMLElement;
|
|
246
|
+
position: Position;
|
|
247
|
+
constructor(node: ComponentNode, target: HTMLElement, options?: MountOptions);
|
|
248
|
+
complete(): void;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
declare const enum STATUS {
|
|
252
|
+
NEW = 0,
|
|
253
|
+
MOUNTED = 1,
|
|
254
|
+
DESTROYED = 2
|
|
255
|
+
}
|
|
256
|
+
declare type STATUS_DESCR = "new" | "mounted" | "destroyed";
|
|
257
|
+
declare function status(component: Component): STATUS_DESCR;
|
|
258
|
+
|
|
259
|
+
declare function useComponent(): Component;
|
|
260
|
+
/**
|
|
261
|
+
* Creates a reactive object that will be observed by the current component.
|
|
262
|
+
* Reading data from the returned object (eg during rendering) will cause the
|
|
263
|
+
* component to subscribe to that data and be rerendered when it changes.
|
|
264
|
+
*
|
|
265
|
+
* @param state the state to observe
|
|
266
|
+
* @returns a reactive object that will cause the component to re-render on
|
|
267
|
+
* relevant changes
|
|
268
|
+
* @see reactive
|
|
269
|
+
*/
|
|
270
|
+
declare function useState<T extends object>(state: T): Reactive<T> | NonReactive<T>;
|
|
271
|
+
declare type LifecycleHook = Function;
|
|
272
|
+
declare class ComponentNode<P extends Props = any, E = any> implements VNode<ComponentNode<P, E>> {
|
|
273
|
+
el?: HTMLElement | Text | undefined;
|
|
274
|
+
app: App;
|
|
275
|
+
fiber: Fiber | null;
|
|
276
|
+
component: Component<P, E>;
|
|
277
|
+
bdom: BDom | null;
|
|
278
|
+
status: STATUS;
|
|
279
|
+
forceNextRender: boolean;
|
|
280
|
+
parentKey: string | null;
|
|
281
|
+
props: P;
|
|
282
|
+
renderFn: Function;
|
|
283
|
+
parent: ComponentNode | null;
|
|
284
|
+
childEnv: Env;
|
|
285
|
+
children: {
|
|
286
|
+
[key: string]: ComponentNode;
|
|
287
|
+
};
|
|
288
|
+
refs: any;
|
|
289
|
+
willStart: LifecycleHook[];
|
|
290
|
+
willUpdateProps: LifecycleHook[];
|
|
291
|
+
willUnmount: LifecycleHook[];
|
|
292
|
+
mounted: LifecycleHook[];
|
|
293
|
+
willPatch: LifecycleHook[];
|
|
294
|
+
patched: LifecycleHook[];
|
|
295
|
+
willDestroy: LifecycleHook[];
|
|
296
|
+
constructor(C: ComponentConstructor<P, E>, props: P, app: App, parent: ComponentNode | null, parentKey: string | null);
|
|
297
|
+
mountComponent(target: any, options?: MountOptions): void;
|
|
298
|
+
initiateRender(fiber: Fiber | MountFiber): Promise<void>;
|
|
299
|
+
render(deep: boolean): Promise<void>;
|
|
300
|
+
destroy(): void;
|
|
301
|
+
_destroy(): void;
|
|
302
|
+
updateAndRender(props: P, parentFiber: Fiber): Promise<void>;
|
|
303
|
+
/**
|
|
304
|
+
* Finds a child that has dom that is not yet updated, and update it. This
|
|
305
|
+
* method is meant to be used only in the context of repatching the dom after
|
|
306
|
+
* a mounted hook failed and was handled.
|
|
307
|
+
*/
|
|
308
|
+
updateDom(): void;
|
|
309
|
+
firstNode(): Node | undefined;
|
|
310
|
+
mount(parent: HTMLElement, anchor: ChildNode): void;
|
|
311
|
+
moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
|
|
312
|
+
moveBeforeVNode(other: ComponentNode<P, E> | null, afterNode: Node | null): void;
|
|
313
|
+
patch(): void;
|
|
314
|
+
_patch(): void;
|
|
315
|
+
beforeRemove(): void;
|
|
316
|
+
remove(): void;
|
|
317
|
+
get name(): string;
|
|
318
|
+
get subscriptions(): ReturnType<typeof getSubscriptions>;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
declare type Props = {
|
|
322
|
+
[key: string]: any;
|
|
323
|
+
};
|
|
324
|
+
interface StaticComponentProperties {
|
|
325
|
+
template: string;
|
|
326
|
+
defaultProps?: any;
|
|
327
|
+
props?: Schema;
|
|
328
|
+
components?: {
|
|
329
|
+
[componentName: string]: ComponentConstructor;
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
declare type ComponentConstructor<P extends Props = any, E = any> = (new (props: P, env: E, node: ComponentNode) => Component<P, E>) & StaticComponentProperties;
|
|
333
|
+
declare class Component<Props = any, Env = any> {
|
|
334
|
+
static template: string;
|
|
335
|
+
static props?: any;
|
|
336
|
+
static defaultProps?: any;
|
|
337
|
+
props: Props;
|
|
338
|
+
env: Env;
|
|
339
|
+
__owl__: ComponentNode;
|
|
340
|
+
constructor(props: Props, env: Env, node: ComponentNode);
|
|
341
|
+
setup(): void;
|
|
342
|
+
render(deep?: boolean): void;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
declare class Scheduler {
|
|
346
|
+
static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
|
|
347
|
+
tasks: Set<RootFiber>;
|
|
348
|
+
requestAnimationFrame: Window["requestAnimationFrame"];
|
|
349
|
+
frame: number;
|
|
350
|
+
delayedRenders: Fiber[];
|
|
351
|
+
constructor();
|
|
352
|
+
addFiber(fiber: Fiber): void;
|
|
353
|
+
/**
|
|
354
|
+
* Process all current tasks. This only applies to the fibers that are ready.
|
|
355
|
+
* Other tasks are left unchanged.
|
|
356
|
+
*/
|
|
357
|
+
flush(): void;
|
|
358
|
+
processFiber(fiber: RootFiber): void;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
interface Config {
|
|
362
|
+
translateFn?: (s: string) => string;
|
|
363
|
+
translatableAttributes?: string[];
|
|
364
|
+
dev?: boolean;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
declare type Template = (context: any, vnode: any, key?: string) => BDom;
|
|
368
|
+
declare type TemplateFunction = (app: TemplateSet, bdom: any, helpers: any) => Template;
|
|
369
|
+
interface CompileOptions extends Config {
|
|
370
|
+
name?: string;
|
|
371
|
+
}
|
|
372
|
+
declare function compile(template: string | Element, options?: CompileOptions): TemplateFunction;
|
|
373
|
+
|
|
374
|
+
declare class Portal extends Component {
|
|
375
|
+
static template: string;
|
|
376
|
+
static props: {
|
|
377
|
+
target: {
|
|
378
|
+
type: StringConstructor;
|
|
379
|
+
};
|
|
380
|
+
slots: boolean;
|
|
381
|
+
};
|
|
382
|
+
setup(): void;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
interface TemplateSetConfig {
|
|
386
|
+
dev?: boolean;
|
|
387
|
+
translatableAttributes?: string[];
|
|
388
|
+
translateFn?: (s: string) => string;
|
|
389
|
+
templates?: string | Document;
|
|
390
|
+
}
|
|
391
|
+
declare class TemplateSet {
|
|
392
|
+
static registerTemplate(name: string, fn: TemplateFunction): void;
|
|
393
|
+
dev: boolean;
|
|
394
|
+
rawTemplates: typeof globalTemplates;
|
|
395
|
+
templates: {
|
|
396
|
+
[name: string]: Template;
|
|
397
|
+
};
|
|
398
|
+
translateFn?: (s: string) => string;
|
|
399
|
+
translatableAttributes?: string[];
|
|
400
|
+
Portal: typeof Portal;
|
|
401
|
+
constructor(config?: TemplateSetConfig);
|
|
402
|
+
addTemplate(name: string, template: string | Element): void;
|
|
403
|
+
addTemplates(xml: string | Document): void;
|
|
404
|
+
getTemplate(name: string): Template;
|
|
405
|
+
_compileTemplate(name: string, template: string | Element): ReturnType<typeof compile>;
|
|
406
|
+
callTemplate(owner: any, subTemplate: string, ctx: any, parent: any, key: any): any;
|
|
407
|
+
}
|
|
408
|
+
declare const globalTemplates: {
|
|
409
|
+
[key: string]: string | Element | TemplateFunction;
|
|
410
|
+
};
|
|
411
|
+
declare function xml(...args: Parameters<typeof String.raw>): string;
|
|
412
|
+
declare namespace xml {
|
|
413
|
+
var nextId: number;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
declare class OwlError extends Error {
|
|
417
|
+
cause?: any;
|
|
418
|
+
}
|
|
419
|
+
declare type ErrorParams = {
|
|
420
|
+
error: any;
|
|
421
|
+
} & ({
|
|
422
|
+
node: ComponentNode;
|
|
423
|
+
} | {
|
|
424
|
+
fiber: Fiber;
|
|
425
|
+
});
|
|
426
|
+
declare function handleError(params: ErrorParams): void;
|
|
427
|
+
|
|
428
|
+
interface Env {
|
|
429
|
+
[key: string]: any;
|
|
430
|
+
}
|
|
431
|
+
interface AppConfig<P, E> extends TemplateSetConfig {
|
|
432
|
+
props?: P;
|
|
433
|
+
env?: E;
|
|
434
|
+
test?: boolean;
|
|
435
|
+
warnIfNoStaticProps?: boolean;
|
|
436
|
+
}
|
|
437
|
+
declare class App<T extends abstract new (...args: any) => any = any, P extends object = any, E = any> extends TemplateSet {
|
|
438
|
+
static validateTarget: typeof validateTarget;
|
|
439
|
+
Root: ComponentConstructor<P, E>;
|
|
440
|
+
props: P;
|
|
441
|
+
env: E;
|
|
442
|
+
scheduler: Scheduler;
|
|
443
|
+
root: ComponentNode<P, E> | null;
|
|
444
|
+
warnIfNoStaticProps: boolean;
|
|
445
|
+
constructor(Root: ComponentConstructor<P, E>, config?: AppConfig<P, E>);
|
|
446
|
+
mount(target: HTMLElement, options?: MountOptions): Promise<Component<P, E> & InstanceType<T>>;
|
|
447
|
+
makeNode(Component: ComponentConstructor, props: any): ComponentNode;
|
|
448
|
+
mountNode(node: ComponentNode, target: HTMLElement, options?: MountOptions): any;
|
|
449
|
+
destroy(): void;
|
|
450
|
+
createComponent<P extends Props>(name: string | null, isStatic: boolean, hasSlotsProp: boolean, hasDynamicPropList: boolean, hasNoProp: boolean): (props: P, key: string, ctx: ComponentNode, parent: any, C: any) => any;
|
|
451
|
+
handleError(...args: Parameters<typeof handleError>): void;
|
|
452
|
+
}
|
|
453
|
+
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>>;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* The purpose of this hook is to allow components to get a reference to a sub
|
|
457
|
+
* html node or component.
|
|
458
|
+
*/
|
|
459
|
+
declare function useRef<T extends HTMLElement = HTMLElement>(name: string): {
|
|
460
|
+
el: T | null;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* This hook is useful as a building block for some customized hooks, that may
|
|
464
|
+
* need a reference to the env of the component calling them.
|
|
465
|
+
*/
|
|
466
|
+
declare function useEnv<E extends Env>(): E;
|
|
467
|
+
/**
|
|
468
|
+
* This hook is a simple way to let components use a sub environment. Note that
|
|
469
|
+
* like for all hooks, it is important that this is only called in the
|
|
470
|
+
* constructor method.
|
|
471
|
+
*/
|
|
472
|
+
declare function useSubEnv(envExtension: Env): void;
|
|
473
|
+
declare function useChildSubEnv(envExtension: Env): void;
|
|
474
|
+
/**
|
|
475
|
+
* @param {...any} dependencies the dependencies computed by computeDependencies
|
|
476
|
+
* @returns {void|(()=>void)} a cleanup function that reverses the side
|
|
477
|
+
* effects of the effect callback.
|
|
478
|
+
*/
|
|
479
|
+
declare type Effect = (...dependencies: any[]) => void | (() => void);
|
|
480
|
+
/**
|
|
481
|
+
* This hook will run a callback when a component is mounted and patched, and
|
|
482
|
+
* will run a cleanup function before patching and before unmounting the
|
|
483
|
+
* the component.
|
|
484
|
+
*
|
|
485
|
+
* @param {Effect} effect the effect to run on component mount and/or patch
|
|
486
|
+
* @param {()=>any[]} [computeDependencies=()=>[NaN]] a callback to compute
|
|
487
|
+
* dependencies that will decide if the effect needs to be cleaned up and
|
|
488
|
+
* run again. If the dependencies did not change, the effect will not run
|
|
489
|
+
* again. The default value returns an array containing only NaN because
|
|
490
|
+
* NaN !== NaN, which will cause the effect to rerun on every patch.
|
|
491
|
+
*/
|
|
492
|
+
declare function useEffect(effect: Effect, computeDependencies?: () => any[]): void;
|
|
493
|
+
/**
|
|
494
|
+
* When a component needs to listen to DOM Events on element(s) that are not
|
|
495
|
+
* part of his hierarchy, we can use the `useExternalListener` hook.
|
|
496
|
+
* It will correctly add and remove the event listener, whenever the
|
|
497
|
+
* component is mounted and unmounted.
|
|
498
|
+
*
|
|
499
|
+
* Example:
|
|
500
|
+
* a menu needs to listen to the click on window to be closed automatically
|
|
501
|
+
*
|
|
502
|
+
* Usage:
|
|
503
|
+
* in the constructor of the OWL component that needs to be notified,
|
|
504
|
+
* `useExternalListener(window, 'click', this._doSomething);`
|
|
505
|
+
* */
|
|
506
|
+
declare function useExternalListener(target: HTMLElement | typeof window, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
|
|
507
|
+
|
|
508
|
+
declare function onWillStart(fn: () => Promise<void> | void | any): void;
|
|
509
|
+
declare function onWillUpdateProps(fn: (nextProps: any) => Promise<void> | void | any): void;
|
|
510
|
+
declare function onMounted(fn: () => void | any): void;
|
|
511
|
+
declare function onWillPatch(fn: () => Promise<void> | any | void): void;
|
|
512
|
+
declare function onPatched(fn: () => void | any): void;
|
|
513
|
+
declare function onWillUnmount(fn: () => Promise<void> | void | any): void;
|
|
514
|
+
declare function onWillDestroy(fn: () => Promise<void> | void | any): void;
|
|
515
|
+
declare function onWillRender(fn: () => void | any): void;
|
|
516
|
+
declare function onRendered(fn: () => void | any): void;
|
|
517
|
+
declare type OnErrorCallback = (error: any) => void | any;
|
|
518
|
+
declare function onError(callback: OnErrorCallback): void;
|
|
519
|
+
|
|
520
|
+
declare const blockDom: {
|
|
521
|
+
config: {
|
|
522
|
+
shouldNormalizeDom: boolean;
|
|
523
|
+
mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null | undefined) => boolean;
|
|
524
|
+
};
|
|
525
|
+
mount: typeof mount$1;
|
|
526
|
+
patch: typeof patch;
|
|
527
|
+
remove: typeof remove;
|
|
528
|
+
list: typeof list;
|
|
529
|
+
multi: typeof multi;
|
|
530
|
+
text: typeof text;
|
|
531
|
+
toggler: typeof toggler;
|
|
532
|
+
createBlock: typeof createBlock;
|
|
533
|
+
html: typeof html;
|
|
534
|
+
comment: typeof comment;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
declare const __info__: {};
|
|
538
|
+
|
|
539
|
+
export { App, Component, ComponentConstructor, EventBus, OwlError, Reactive, __info__, blockDom, loadFile, markRaw, markup, mount, onError, onMounted, onPatched, onRendered, onWillDestroy, onWillPatch, onWillRender, onWillStart, onWillUnmount, onWillUpdateProps, reactive, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, useRef, useState, useSubEnv, validate, whenReady, xml };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Component, ComponentConstructor } from "
|
|
2
|
-
import { ComponentNode } from "
|
|
3
|
-
import { MountOptions } from "
|
|
4
|
-
import { Scheduler } from "
|
|
1
|
+
import { Component, ComponentConstructor, Props } from "./component";
|
|
2
|
+
import { ComponentNode } from "./component_node";
|
|
3
|
+
import { MountOptions } from "./fibers";
|
|
4
|
+
import { Scheduler } from "./scheduler";
|
|
5
5
|
import { TemplateSet, TemplateSetConfig } from "./template_set";
|
|
6
|
-
import { validateTarget } from "
|
|
6
|
+
import { validateTarget } from "./utils";
|
|
7
|
+
import { handleError } from "./error_handling";
|
|
7
8
|
export interface Env {
|
|
8
9
|
[key: string]: any;
|
|
9
10
|
}
|
|
@@ -11,6 +12,7 @@ export interface AppConfig<P, E> extends TemplateSetConfig {
|
|
|
11
12
|
props?: P;
|
|
12
13
|
env?: E;
|
|
13
14
|
test?: boolean;
|
|
15
|
+
warnIfNoStaticProps?: boolean;
|
|
14
16
|
}
|
|
15
17
|
export declare const DEV_MSG: () => string;
|
|
16
18
|
export declare class App<T extends abstract new (...args: any) => any = any, P extends object = any, E = any> extends TemplateSet {
|
|
@@ -20,10 +22,13 @@ export declare class App<T extends abstract new (...args: any) => any = any, P e
|
|
|
20
22
|
env: E;
|
|
21
23
|
scheduler: Scheduler;
|
|
22
24
|
root: ComponentNode<P, E> | null;
|
|
25
|
+
warnIfNoStaticProps: boolean;
|
|
23
26
|
constructor(Root: ComponentConstructor<P, E>, config?: AppConfig<P, E>);
|
|
24
27
|
mount(target: HTMLElement, options?: MountOptions): Promise<Component<P, E> & InstanceType<T>>;
|
|
25
28
|
makeNode(Component: ComponentConstructor, props: any): ComponentNode;
|
|
26
29
|
mountNode(node: ComponentNode, target: HTMLElement, options?: MountOptions): any;
|
|
27
30
|
destroy(): void;
|
|
31
|
+
createComponent<P extends Props>(name: string | null, isStatic: boolean, hasSlotsProp: boolean, hasDynamicPropList: boolean, hasNoProp: boolean): (props: P, key: string, ctx: ComponentNode, parent: any, C: any) => any;
|
|
32
|
+
handleError(...args: Parameters<typeof handleError>): void;
|
|
28
33
|
}
|
|
29
34
|
export 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>>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -5,7 +5,8 @@ declare class VHtml {
|
|
|
5
5
|
content: ChildNode[];
|
|
6
6
|
constructor(html: string);
|
|
7
7
|
mount(parent: HTMLElement, afterNode: Node | null): void;
|
|
8
|
-
|
|
8
|
+
moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
|
|
9
|
+
moveBeforeVNode(other: VHtml | null, afterNode: Node | null): void;
|
|
9
10
|
patch(other: VHtml): void;
|
|
10
11
|
beforeRemove(): void;
|
|
11
12
|
remove(): void;
|
|
@@ -8,7 +8,8 @@ export { html } from "./html";
|
|
|
8
8
|
export { createCatcher } from "./event_catcher";
|
|
9
9
|
export interface VNode<T = any> {
|
|
10
10
|
mount(parent: HTMLElement, afterNode: Node | null): void;
|
|
11
|
-
|
|
11
|
+
moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
|
|
12
|
+
moveBeforeVNode(other: T | null, afterNode: Node | null): void;
|
|
12
13
|
patch(other: T, withBeforeRemove: boolean): void;
|
|
13
14
|
beforeRemove(): void;
|
|
14
15
|
remove(): void;
|
|
@@ -6,7 +6,8 @@ declare class VList {
|
|
|
6
6
|
isOnlyChild?: boolean | undefined;
|
|
7
7
|
constructor(children: VNode[]);
|
|
8
8
|
mount(parent: HTMLElement, afterNode: Node | null): void;
|
|
9
|
-
|
|
9
|
+
moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
|
|
10
|
+
moveBeforeVNode(other: VList | null, afterNode: Node | null): void;
|
|
10
11
|
patch(other: VList, withBeforeRemove: boolean): void;
|
|
11
12
|
beforeRemove(): void;
|
|
12
13
|
remove(): void;
|
|
@@ -6,7 +6,8 @@ export declare class VMulti {
|
|
|
6
6
|
isOnlyChild?: boolean | undefined;
|
|
7
7
|
constructor(children: (VNode | undefined)[]);
|
|
8
8
|
mount(parent: HTMLElement, afterNode: Node | null): void;
|
|
9
|
-
|
|
9
|
+
moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
|
|
10
|
+
moveBeforeVNode(other: VMulti | null, afterNode: Node | null): void;
|
|
10
11
|
patch(other: VMulti, withBeforeRemove: boolean): void;
|
|
11
12
|
beforeRemove(): void;
|
|
12
13
|
remove(): void;
|
|
@@ -5,7 +5,8 @@ declare abstract class VSimpleNode {
|
|
|
5
5
|
el?: any;
|
|
6
6
|
constructor(text: string | String);
|
|
7
7
|
mountNode(node: Node, parent: HTMLElement, afterNode: Node | null): void;
|
|
8
|
-
|
|
8
|
+
moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
|
|
9
|
+
moveBeforeVNode(other: VText | null, afterNode: Node | null): void;
|
|
9
10
|
beforeRemove(): void;
|
|
10
11
|
remove(): void;
|
|
11
12
|
firstNode(): Node;
|
|
@@ -5,7 +5,8 @@ declare class VToggler {
|
|
|
5
5
|
parentEl?: HTMLElement | undefined;
|
|
6
6
|
constructor(key: string, child: VNode);
|
|
7
7
|
mount(parent: HTMLElement, afterNode: Node | null): void;
|
|
8
|
-
|
|
8
|
+
moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
|
|
9
|
+
moveBeforeVNode(other: VToggler | null, afterNode: Node | null): void;
|
|
9
10
|
patch(other: VToggler, withBeforeRemove: boolean): void;
|
|
10
11
|
beforeRemove(): void;
|
|
11
12
|
remove(): void;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { Schema } from "./validation";
|
|
1
2
|
import type { ComponentNode } from "./component_node";
|
|
2
|
-
declare type Props = {
|
|
3
|
+
export declare type Props = {
|
|
3
4
|
[key: string]: any;
|
|
4
5
|
};
|
|
5
6
|
interface StaticComponentProperties {
|
|
6
7
|
template: string;
|
|
7
8
|
defaultProps?: any;
|
|
8
|
-
props?:
|
|
9
|
+
props?: Schema;
|
|
10
|
+
components?: {
|
|
11
|
+
[componentName: string]: ComponentConstructor;
|
|
12
|
+
};
|
|
9
13
|
}
|
|
10
14
|
export declare type ComponentConstructor<P extends Props = any, E = any> = (new (props: P, env: E, node: ComponentNode) => Component<P, E>) & StaticComponentProperties;
|
|
11
15
|
export declare class Component<Props = any, Env = any> {
|