@odoo/owl 1.4.10 → 2.0.0-alpha.3
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 +59 -65
- package/dist/owl.cjs.js +4700 -5068
- package/dist/owl.cjs.min.js +1 -15
- package/dist/owl.es.js +4672 -5058
- package/dist/owl.es.min.js +1 -15
- package/dist/owl.iife.js +4700 -5068
- package/dist/owl.iife.min.js +1 -15
- package/dist/types/app/app.d.ts +29 -0
- package/dist/types/app/template_helpers.d.ts +49 -0
- package/dist/types/app/template_set.d.ts +34 -0
- package/dist/types/blockdom/attributes.d.ts +8 -0
- package/dist/types/blockdom/block_compiler.d.ts +21 -0
- package/dist/types/blockdom/config.d.ts +8 -0
- package/dist/types/blockdom/events.d.ts +7 -0
- package/dist/types/blockdom/html.d.ts +16 -0
- package/dist/types/blockdom/index.d.ts +24 -0
- package/dist/types/blockdom/list.d.ts +17 -0
- package/dist/types/blockdom/multi.d.ts +16 -0
- package/dist/types/blockdom/text.d.ts +25 -0
- package/dist/types/blockdom/toggler.d.ts +16 -0
- package/dist/types/compiler/code_generator.d.ts +144 -0
- package/dist/types/compiler/index.d.ts +9 -0
- package/dist/types/{qweb/expression_parser.d.ts → compiler/inline_expressions.d.ts} +4 -6
- package/dist/types/compiler/parser.d.ts +157 -0
- package/dist/types/component/component.d.ts +15 -294
- package/dist/types/component/component_node.d.ts +67 -0
- package/dist/types/component/error_handling.d.ts +13 -0
- package/dist/types/component/fibers.d.ts +33 -0
- package/dist/types/component/handler.d.ts +1 -0
- package/dist/types/component/lifecycle_hooks.d.ts +12 -0
- package/dist/types/component/props_validation.d.ts +14 -1
- package/dist/types/component/scheduler.d.ts +5 -21
- package/dist/types/component/status.d.ts +9 -0
- package/dist/types/hooks.d.ts +26 -35
- package/dist/types/index.d.ts +27 -47
- package/dist/types/memo.d.ts +6 -0
- package/dist/types/portal.d.ts +11 -0
- package/dist/types/reactivity.d.ts +59 -0
- package/dist/types/utils.d.ts +14 -21
- package/package.json +14 -9
- package/dist/types/browser.d.ts +0 -12
- package/dist/types/component/directive.d.ts +0 -1
- package/dist/types/component/fiber.d.ts +0 -75
- package/dist/types/component/styles.d.ts +0 -12
- package/dist/types/config.d.ts +0 -12
- package/dist/types/context.d.ts +0 -36
- package/dist/types/core/event_bus.d.ts +0 -42
- package/dist/types/core/observer.d.ts +0 -30
- package/dist/types/core/owl_event.d.ts +0 -10
- package/dist/types/misc/async_root.d.ts +0 -13
- package/dist/types/misc/portal.d.ts +0 -70
- package/dist/types/qweb/base_directives.d.ts +0 -1
- package/dist/types/qweb/compilation_context.d.ts +0 -69
- package/dist/types/qweb/extensions.d.ts +0 -28
- package/dist/types/qweb/index.d.ts +0 -3
- package/dist/types/qweb/qweb.d.ts +0 -141
- package/dist/types/router/link.d.ts +0 -11
- package/dist/types/router/route_component.d.ts +0 -6
- package/dist/types/router/router.d.ts +0 -57
- package/dist/types/store.d.ts +0 -63
- package/dist/types/tags.d.ts +0 -29
- package/dist/types/vdom/html_to_vdom.d.ts +0 -2
- package/dist/types/vdom/index.d.ts +0 -2
- package/dist/types/vdom/modules.d.ts +0 -5
- package/dist/types/vdom/vdom.d.ts +0 -101
|
@@ -1,301 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Owl Component System
|
|
11
|
-
*
|
|
12
|
-
* This file introduces a declarative and composable component system. It
|
|
13
|
-
* contains:
|
|
14
|
-
*
|
|
15
|
-
* - the Env interface (generic type for the environment)
|
|
16
|
-
* - the Internal interface (the owl specific metadata attached to a component)
|
|
17
|
-
* - the Component class
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* An Env (environment) is an object that will be (mostly) shared between all
|
|
21
|
-
* components of an Owl application. It is the location which should contain
|
|
22
|
-
* the qweb instance necessary to render all components.
|
|
23
|
-
*
|
|
24
|
-
* Note that it is totally fine to extend the environment with application
|
|
25
|
-
* specific keys/objects/whatever. For example, a key `isMobile` (to declare
|
|
26
|
-
* if we are in "mobile" mode), or a shared bus could be useful.
|
|
27
|
-
*/
|
|
28
|
-
export interface Env {
|
|
29
|
-
qweb: QWeb;
|
|
30
|
-
browser: Browser;
|
|
31
|
-
}
|
|
32
|
-
export declare type MountPosition = "first-child" | "last-child" | "self";
|
|
33
|
-
interface MountOptions {
|
|
34
|
-
position?: MountPosition;
|
|
35
|
-
}
|
|
36
|
-
export declare const enum STATUS {
|
|
37
|
-
CREATED = 0,
|
|
38
|
-
WILLSTARTED = 1,
|
|
39
|
-
RENDERED = 2,
|
|
40
|
-
MOUNTED = 3,
|
|
41
|
-
UNMOUNTED = 4,
|
|
42
|
-
DESTROYED = 5
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* This is mostly an internal detail of implementation. The Meta interface is
|
|
46
|
-
* useful to typecheck and describe the internal keys used by Owl to manage the
|
|
47
|
-
* component tree.
|
|
48
|
-
*/
|
|
49
|
-
interface Internal<T extends Env> {
|
|
50
|
-
readonly id: number;
|
|
51
|
-
depth: number;
|
|
52
|
-
vnode: VNode | null;
|
|
53
|
-
pvnode: VNode | null;
|
|
54
|
-
status: STATUS;
|
|
55
|
-
parent: Component<any, T> | null;
|
|
56
|
-
children: {
|
|
57
|
-
[key: number]: Component<any, T>;
|
|
58
|
-
};
|
|
59
|
-
cmap: {
|
|
60
|
-
[key: number]: number;
|
|
61
|
-
};
|
|
62
|
-
currentFiber: Fiber | null;
|
|
63
|
-
parentLastFiberId: number;
|
|
64
|
-
scope: any;
|
|
65
|
-
boundHandlers: {
|
|
66
|
-
[key: number]: any;
|
|
67
|
-
};
|
|
68
|
-
observer: Observer | null;
|
|
69
|
-
renderFn: CompiledTemplate;
|
|
70
|
-
mountedCB: Function | null;
|
|
71
|
-
willUnmountCB: Function | null;
|
|
72
|
-
willPatchCB: Function | null;
|
|
73
|
-
patchedCB: Function | null;
|
|
74
|
-
willStartCB: Function | null;
|
|
75
|
-
willUpdatePropsCB: Function | null;
|
|
76
|
-
classObj: {
|
|
77
|
-
[key: string]: boolean;
|
|
78
|
-
} | null;
|
|
79
|
-
refs: {
|
|
80
|
-
[key: string]: Component<any, T> | HTMLElement | undefined;
|
|
81
|
-
} | null;
|
|
1
|
+
import type { ComponentNode } from "./component_node";
|
|
2
|
+
declare type Props = {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
};
|
|
5
|
+
interface StaticComponentProperties {
|
|
6
|
+
template: string;
|
|
7
|
+
defaultProps?: any;
|
|
8
|
+
props?: any;
|
|
82
9
|
}
|
|
83
|
-
export declare
|
|
84
|
-
export declare class Component<Props
|
|
85
|
-
|
|
86
|
-
static template?: string | null;
|
|
87
|
-
static _template?: string | null;
|
|
88
|
-
static current: Component | null;
|
|
89
|
-
static components: {};
|
|
10
|
+
export declare type ComponentConstructor<P extends Props = any, E = any> = (new (props: P, env: E, node: ComponentNode) => Component<P, E>) & StaticComponentProperties;
|
|
11
|
+
export declare class Component<Props = any, Env = any> {
|
|
12
|
+
static template: string;
|
|
90
13
|
static props?: any;
|
|
91
14
|
static defaultProps?: any;
|
|
92
|
-
static env: any;
|
|
93
|
-
static scheduler: Scheduler;
|
|
94
|
-
/**
|
|
95
|
-
* The `el` is the root element of the component. Note that it could be null:
|
|
96
|
-
* this is the case if the component is not mounted yet, or is destroyed.
|
|
97
|
-
*/
|
|
98
|
-
get el(): HTMLElement | null;
|
|
99
|
-
env: T;
|
|
100
15
|
props: Props;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* Note that most of the time, only the root component needs to be created by
|
|
105
|
-
* hand. Other components should be created automatically by the framework (with
|
|
106
|
-
* the t-component directive in a template)
|
|
107
|
-
*/
|
|
108
|
-
constructor(parent?: Component<any, T> | null, props?: Props);
|
|
109
|
-
/**
|
|
110
|
-
* setup is run just after the component is constructed. This is the standard
|
|
111
|
-
* location where the component can setup its hooks. It has some advantages
|
|
112
|
-
* over the constructor:
|
|
113
|
-
* - it can be patched (useful in odoo ecosystem)
|
|
114
|
-
* - it does not need to propagate the arguments to the super call
|
|
115
|
-
*
|
|
116
|
-
* Note: this method should not be called manually.
|
|
117
|
-
*/
|
|
16
|
+
env: Env;
|
|
17
|
+
__owl__: ComponentNode;
|
|
18
|
+
constructor(props: Props, env: Env, node: ComponentNode);
|
|
118
19
|
setup(): void;
|
|
119
|
-
|
|
120
|
-
* willStart is an asynchronous hook that can be implemented to perform some
|
|
121
|
-
* action before the initial rendering of a component.
|
|
122
|
-
*
|
|
123
|
-
* It will be called exactly once before the initial rendering. It is useful
|
|
124
|
-
* in some cases, for example, to load external assets (such as a JS library)
|
|
125
|
-
* before the component is rendered.
|
|
126
|
-
*
|
|
127
|
-
* Note that a slow willStart method will slow down the rendering of the user
|
|
128
|
-
* interface. Therefore, some effort should be made to make this method as
|
|
129
|
-
* fast as possible.
|
|
130
|
-
*
|
|
131
|
-
* Note: this method should not be called manually.
|
|
132
|
-
*/
|
|
133
|
-
willStart(): Promise<void>;
|
|
134
|
-
/**
|
|
135
|
-
* mounted is a hook that is called each time a component is attached to the
|
|
136
|
-
* DOM. This is a good place to add some listeners, or to interact with the
|
|
137
|
-
* DOM, if the component needs to perform some measure for example.
|
|
138
|
-
*
|
|
139
|
-
* Note: this method should not be called manually.
|
|
140
|
-
*
|
|
141
|
-
* @see willUnmount
|
|
142
|
-
*/
|
|
143
|
-
mounted(): void;
|
|
144
|
-
/**
|
|
145
|
-
* The willUpdateProps is an asynchronous hook, called just before new props
|
|
146
|
-
* are set. This is useful if the component needs some asynchronous task
|
|
147
|
-
* performed, depending on the props (for example, assuming that the props are
|
|
148
|
-
* some record Id, fetching the record data).
|
|
149
|
-
*
|
|
150
|
-
* This hook is not called during the first render (but willStart is called
|
|
151
|
-
* and performs a similar job).
|
|
152
|
-
*/
|
|
153
|
-
willUpdateProps(nextProps: Props): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* The willPatch hook is called just before the DOM patching process starts.
|
|
156
|
-
* It is not called on the initial render. This is useful to get some
|
|
157
|
-
* information which are in the DOM. For example, the current position of the
|
|
158
|
-
* scrollbar
|
|
159
|
-
*/
|
|
160
|
-
willPatch(): any;
|
|
161
|
-
/**
|
|
162
|
-
* This hook is called whenever a component did actually update its props,
|
|
163
|
-
* state or env.
|
|
164
|
-
*
|
|
165
|
-
* This method is not called on the initial render. It is useful to interact
|
|
166
|
-
* with the DOM (for example, through an external library) whenever the
|
|
167
|
-
* component was updated.
|
|
168
|
-
*
|
|
169
|
-
* Updating the component state in this hook is possible, but not encouraged.
|
|
170
|
-
* One need to be careful, because updates here will cause rerender, which in
|
|
171
|
-
* turn will cause other calls to updated. So, we need to be particularly
|
|
172
|
-
* careful at avoiding endless cycles.
|
|
173
|
-
*/
|
|
174
|
-
patched(): void;
|
|
175
|
-
/**
|
|
176
|
-
* willUnmount is a hook that is called each time just before a component is
|
|
177
|
-
* unmounted from the DOM. This is a good place to remove some listeners, for
|
|
178
|
-
* example.
|
|
179
|
-
*
|
|
180
|
-
* Note: this method should not be called manually.
|
|
181
|
-
*
|
|
182
|
-
* @see mounted
|
|
183
|
-
*/
|
|
184
|
-
willUnmount(): void;
|
|
185
|
-
/**
|
|
186
|
-
* catchError is a method called whenever some error happens in the rendering or
|
|
187
|
-
* lifecycle hooks of a child.
|
|
188
|
-
*
|
|
189
|
-
* It needs to be implemented by a component that is designed to handle the
|
|
190
|
-
* error properly.
|
|
191
|
-
*/
|
|
192
|
-
catchError?(error?: Error): void;
|
|
193
|
-
/**
|
|
194
|
-
* Mount the component to a target element.
|
|
195
|
-
*
|
|
196
|
-
* This should only be done if the component was created manually. Components
|
|
197
|
-
* created declaratively in templates are managed by the Owl system.
|
|
198
|
-
*
|
|
199
|
-
* Note that a component can be mounted an unmounted several times
|
|
200
|
-
*/
|
|
201
|
-
mount(target: HTMLElement | DocumentFragment, options?: MountOptions): Promise<void>;
|
|
202
|
-
/**
|
|
203
|
-
* The unmount method is the opposite of the mount method. It is useful
|
|
204
|
-
* to call willUnmount calls and remove the component from the DOM.
|
|
205
|
-
*/
|
|
206
|
-
unmount(): void;
|
|
207
|
-
/**
|
|
208
|
-
* The render method is the main entry point to render a component (once it
|
|
209
|
-
* is ready. This method is not initially called when the component is
|
|
210
|
-
* rendered the first time).
|
|
211
|
-
*
|
|
212
|
-
* This method will cause all its sub components to potentially rerender
|
|
213
|
-
* themselves. Note that `render` is not called if a component is updated via
|
|
214
|
-
* its props.
|
|
215
|
-
*/
|
|
216
|
-
render(force?: boolean): Promise<void>;
|
|
217
|
-
/**
|
|
218
|
-
* Destroy the component. This operation is quite complex:
|
|
219
|
-
* - it recursively destroy all children
|
|
220
|
-
* - call the willUnmount hooks if necessary
|
|
221
|
-
* - remove the dom node from the dom
|
|
222
|
-
*
|
|
223
|
-
* This should only be called manually if you created the component. Most
|
|
224
|
-
* components will be automatically destroyed.
|
|
225
|
-
*/
|
|
226
|
-
destroy(): void;
|
|
227
|
-
/**
|
|
228
|
-
* This method is called by the component system whenever its props are
|
|
229
|
-
* updated. If it returns true, then the component will be rendered.
|
|
230
|
-
* Otherwise, it will skip the rendering (also, its props will not be updated)
|
|
231
|
-
*/
|
|
232
|
-
shouldUpdate(nextProps: Props): boolean;
|
|
233
|
-
/**
|
|
234
|
-
* Emit a custom event of type 'eventType' with the given 'payload' on the
|
|
235
|
-
* component's el, if it exists. However, note that the event will only bubble
|
|
236
|
-
* up to the parent DOM nodes. Thus, it must be called between mounted() and
|
|
237
|
-
* willUnmount().
|
|
238
|
-
*/
|
|
239
|
-
trigger<T = any>(eventType: string, payload?: T): void;
|
|
240
|
-
/**
|
|
241
|
-
* Private helper to perform a full destroy, from the point of view of an Owl
|
|
242
|
-
* component. It does not remove the el (this is done only once on the top
|
|
243
|
-
* level destroyed component, for performance reasons).
|
|
244
|
-
*
|
|
245
|
-
* The job of this method is mostly to call willUnmount hooks, and to perform
|
|
246
|
-
* all necessary internal cleanup.
|
|
247
|
-
*
|
|
248
|
-
* Note that it does not call the __callWillUnmount method to avoid visiting
|
|
249
|
-
* all children many times.
|
|
250
|
-
*/
|
|
251
|
-
__destroy(parent: Component | null): void;
|
|
252
|
-
__callMounted(): void;
|
|
253
|
-
__callWillUnmount(): void;
|
|
254
|
-
/**
|
|
255
|
-
* Private trigger method, allows to choose the component which triggered
|
|
256
|
-
* the event in the first place
|
|
257
|
-
*/
|
|
258
|
-
__trigger<T>(component: Component, eventType: string, payload?: T): void;
|
|
259
|
-
/**
|
|
260
|
-
* The __updateProps method is called by the t-component directive whenever
|
|
261
|
-
* it updates a component (so, when the parent template is rerendered).
|
|
262
|
-
*/
|
|
263
|
-
__updateProps(nextProps: Props, parentFiber: Fiber, scope: any): Promise<void>;
|
|
264
|
-
/**
|
|
265
|
-
* Main patching method. We call the virtual dom patch method here to convert
|
|
266
|
-
* a virtual dom vnode into some actual dom.
|
|
267
|
-
*/
|
|
268
|
-
__patch(target: HTMLElement | VNode | DocumentFragment, vnode: VNode): void;
|
|
269
|
-
/**
|
|
270
|
-
* The __prepare method is only called by the t-component directive, when a
|
|
271
|
-
* subcomponent is created. It gets its scope, if any, from the
|
|
272
|
-
* parent template.
|
|
273
|
-
*/
|
|
274
|
-
__prepare(parentFiber: Fiber, scope: any, cb: CallableFunction): Fiber;
|
|
275
|
-
/**
|
|
276
|
-
* Apply the stylesheets defined by the component. Note that we need to make
|
|
277
|
-
* sure all inherited stylesheets are applied as well. We then delete the
|
|
278
|
-
* `style` key from the constructor to make sure we do not apply it again.
|
|
279
|
-
*/
|
|
280
|
-
private __applyStyles;
|
|
281
|
-
__getTemplate(qweb: QWeb): string;
|
|
282
|
-
__prepareAndRender(fiber: Fiber, cb: CallableFunction): Promise<void>;
|
|
283
|
-
__render(fiber: Fiber): void;
|
|
284
|
-
/**
|
|
285
|
-
* Apply default props (only top level).
|
|
286
|
-
*
|
|
287
|
-
* Note that this method does modify in place the props
|
|
288
|
-
*/
|
|
289
|
-
__applyDefaultProps(props: Object, defaultProps: Object): void;
|
|
290
|
-
}
|
|
291
|
-
interface MountParameters {
|
|
292
|
-
env?: Env;
|
|
293
|
-
target: HTMLElement | DocumentFragment;
|
|
294
|
-
props?: any;
|
|
295
|
-
position?: MountOptions["position"];
|
|
296
|
-
}
|
|
297
|
-
interface Type<T> extends Function {
|
|
298
|
-
new (...args: any[]): T;
|
|
20
|
+
render(deep?: boolean): void;
|
|
299
21
|
}
|
|
300
|
-
export declare function mount<T extends Type<Component>>(C: T, params: MountParameters): Promise<InstanceType<T>>;
|
|
301
22
|
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { App, Env } from "../app/app";
|
|
2
|
+
import { BDom, VNode } from "../blockdom";
|
|
3
|
+
import { Reactive, NonReactive } from "../reactivity";
|
|
4
|
+
import { Component, ComponentConstructor } from "./component";
|
|
5
|
+
import { Fiber, MountFiber, MountOptions, RootFiber } from "./fibers";
|
|
6
|
+
import { STATUS } from "./status";
|
|
7
|
+
export declare function getCurrent(): ComponentNode;
|
|
8
|
+
export declare function useComponent(): Component;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a reactive object that will be observed by the current component.
|
|
11
|
+
* Reading data from the returned object (eg during rendering) will cause the
|
|
12
|
+
* component to subscribe to that data and be rerendered when it changes.
|
|
13
|
+
*
|
|
14
|
+
* @param state the state to observe
|
|
15
|
+
* @returns a reactive object that will cause the component to re-render on
|
|
16
|
+
* relevant changes
|
|
17
|
+
* @see reactive
|
|
18
|
+
*/
|
|
19
|
+
export declare function useState<T extends object>(state: T): Reactive<T> | NonReactive<T>;
|
|
20
|
+
export declare function component<P extends object>(name: string | ComponentConstructor<P>, props: P, key: string, ctx: ComponentNode, parent: any): ComponentNode<P>;
|
|
21
|
+
declare type LifecycleHook = Function;
|
|
22
|
+
export declare class ComponentNode<P extends object = any, E = any> implements VNode<ComponentNode<P, E>> {
|
|
23
|
+
el?: HTMLElement | Text | undefined;
|
|
24
|
+
app: App;
|
|
25
|
+
fiber: Fiber | null;
|
|
26
|
+
component: Component<P, E>;
|
|
27
|
+
bdom: BDom | null;
|
|
28
|
+
status: STATUS;
|
|
29
|
+
renderFn: Function;
|
|
30
|
+
parent: ComponentNode | null;
|
|
31
|
+
level: number;
|
|
32
|
+
childEnv: Env;
|
|
33
|
+
children: {
|
|
34
|
+
[key: string]: ComponentNode;
|
|
35
|
+
};
|
|
36
|
+
refs: any;
|
|
37
|
+
willStart: LifecycleHook[];
|
|
38
|
+
willUpdateProps: LifecycleHook[];
|
|
39
|
+
willUnmount: LifecycleHook[];
|
|
40
|
+
mounted: LifecycleHook[];
|
|
41
|
+
willPatch: LifecycleHook[];
|
|
42
|
+
patched: LifecycleHook[];
|
|
43
|
+
willDestroy: LifecycleHook[];
|
|
44
|
+
constructor(C: ComponentConstructor<P, E>, props: P, app: App, parent?: ComponentNode);
|
|
45
|
+
mountComponent(target: any, options?: MountOptions): void;
|
|
46
|
+
initiateRender(fiber: Fiber | MountFiber): Promise<void>;
|
|
47
|
+
render(deep?: boolean): Promise<void>;
|
|
48
|
+
_render(fiber: Fiber | RootFiber): void;
|
|
49
|
+
destroy(): void;
|
|
50
|
+
_destroy(): void;
|
|
51
|
+
updateAndRender(props: any, parentFiber: Fiber): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Finds a child that has dom that is not yet updated, and update it. This
|
|
54
|
+
* method is meant to be used only in the context of repatching the dom after
|
|
55
|
+
* a mounted hook failed and was handled.
|
|
56
|
+
*/
|
|
57
|
+
updateDom(): void;
|
|
58
|
+
firstNode(): Node | undefined;
|
|
59
|
+
mount(parent: HTMLElement, anchor: ChildNode): void;
|
|
60
|
+
moveBefore(other: ComponentNode | null, afterNode: Node | null): void;
|
|
61
|
+
patch(): void;
|
|
62
|
+
_patch(): void;
|
|
63
|
+
beforeRemove(): void;
|
|
64
|
+
remove(): void;
|
|
65
|
+
cleanOutdatedChildren(): void;
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentNode } from "./component_node";
|
|
2
|
+
import type { Fiber } from "./fibers";
|
|
3
|
+
export declare const fibersInError: WeakMap<Fiber, any>;
|
|
4
|
+
export declare const nodeErrorHandlers: WeakMap<ComponentNode, ((error: any) => void)[]>;
|
|
5
|
+
declare type ErrorParams = {
|
|
6
|
+
error: any;
|
|
7
|
+
} & ({
|
|
8
|
+
node: ComponentNode;
|
|
9
|
+
} | {
|
|
10
|
+
fiber: Fiber;
|
|
11
|
+
});
|
|
12
|
+
export declare function handleError(params: ErrorParams): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BDom } from "../blockdom";
|
|
2
|
+
import type { ComponentNode } from "./component_node";
|
|
3
|
+
export declare function makeChildFiber(node: ComponentNode, parent: Fiber): Fiber;
|
|
4
|
+
export declare function makeRootFiber(node: ComponentNode): Fiber;
|
|
5
|
+
export declare class Fiber {
|
|
6
|
+
node: ComponentNode;
|
|
7
|
+
bdom: BDom | null;
|
|
8
|
+
root: RootFiber | null;
|
|
9
|
+
parent: Fiber | null;
|
|
10
|
+
children: Fiber[];
|
|
11
|
+
appliedToDom: boolean;
|
|
12
|
+
deep: boolean;
|
|
13
|
+
constructor(node: ComponentNode, parent: Fiber | null);
|
|
14
|
+
}
|
|
15
|
+
export declare class RootFiber extends Fiber {
|
|
16
|
+
counter: number;
|
|
17
|
+
willPatch: Fiber[];
|
|
18
|
+
patched: Fiber[];
|
|
19
|
+
mounted: Fiber[];
|
|
20
|
+
locked: boolean;
|
|
21
|
+
complete(): void;
|
|
22
|
+
}
|
|
23
|
+
declare type Position = "first-child" | "last-child";
|
|
24
|
+
export interface MountOptions {
|
|
25
|
+
position?: Position;
|
|
26
|
+
}
|
|
27
|
+
export declare class MountFiber extends RootFiber {
|
|
28
|
+
target: HTMLElement;
|
|
29
|
+
position: Position;
|
|
30
|
+
constructor(node: ComponentNode, target: HTMLElement, options?: MountOptions);
|
|
31
|
+
complete(): void;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null | undefined) => boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function onWillStart(fn: () => Promise<void> | void | any): void;
|
|
2
|
+
export declare function onWillUpdateProps(fn: (nextProps: any) => Promise<void> | void | any): void;
|
|
3
|
+
export declare function onMounted(fn: () => void | any): void;
|
|
4
|
+
export declare function onWillPatch(fn: () => Promise<void> | any | void): void;
|
|
5
|
+
export declare function onPatched(fn: () => void | any): void;
|
|
6
|
+
export declare function onWillUnmount(fn: () => Promise<void> | void | any): void;
|
|
7
|
+
export declare function onWillDestroy(fn: () => Promise<void> | void | any): void;
|
|
8
|
+
export declare function onWillRender(fn: () => void | any): void;
|
|
9
|
+
export declare function onRendered(fn: () => void | any): void;
|
|
10
|
+
declare type OnErrorCallback = (error: any) => void | any;
|
|
11
|
+
export declare function onError(callback: OnErrorCallback): void;
|
|
12
|
+
export {};
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { ComponentConstructor } from "./component";
|
|
2
|
+
/**
|
|
3
|
+
* Apply default props (only top level).
|
|
4
|
+
*
|
|
5
|
+
* Note that this method does modify in place the props
|
|
6
|
+
*/
|
|
7
|
+
export declare function applyDefaultProps<P>(props: P, ComponentClass: ComponentConstructor<P>): void;
|
|
8
|
+
/**
|
|
9
|
+
* Validate the component props (or next props) against the (static) props
|
|
10
|
+
* description. This is potentially an expensive operation: it may needs to
|
|
11
|
+
* visit recursively the props and all the children to check if they are valid.
|
|
12
|
+
* This is why it is only done in 'dev' mode.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateProps<P>(name: string | ComponentConstructor<P>, props: P, parent?: any): void;
|
|
@@ -1,27 +1,13 @@
|
|
|
1
|
-
import { Fiber } from "./
|
|
2
|
-
/**
|
|
3
|
-
* Owl Scheduler Class
|
|
4
|
-
*
|
|
5
|
-
* The scheduler is the part of Owl that will effectively apply a rendering
|
|
6
|
-
* whenever a fiber is ready.
|
|
7
|
-
*
|
|
8
|
-
* Briefly, it can be used to register root fibers. Whenever there is an
|
|
9
|
-
* active root fiber, it will poll continuously each animation frame (so, about
|
|
10
|
-
* once every 16ms) and whenever a root fiber is ready, it will apply it.
|
|
11
|
-
*/
|
|
12
|
-
interface Task {
|
|
13
|
-
fiber: Fiber;
|
|
14
|
-
callback: (err?: Error) => void;
|
|
15
|
-
}
|
|
1
|
+
import { Fiber, RootFiber } from "./fibers";
|
|
16
2
|
export declare class Scheduler {
|
|
17
|
-
|
|
3
|
+
static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
|
|
4
|
+
tasks: Set<RootFiber>;
|
|
18
5
|
isRunning: boolean;
|
|
19
6
|
requestAnimationFrame: Window["requestAnimationFrame"];
|
|
20
|
-
constructor(
|
|
7
|
+
constructor();
|
|
21
8
|
start(): void;
|
|
22
9
|
stop(): void;
|
|
23
|
-
addFiber(fiber: Fiber):
|
|
24
|
-
rejectFiber(fiber: Fiber, reason: string): void;
|
|
10
|
+
addFiber(fiber: Fiber): void;
|
|
25
11
|
/**
|
|
26
12
|
* Process all current tasks. This only applies to the fibers that are ready.
|
|
27
13
|
* Other tasks are left unchanged.
|
|
@@ -29,5 +15,3 @@ export declare class Scheduler {
|
|
|
29
15
|
flush(): void;
|
|
30
16
|
scheduleTasks(): void;
|
|
31
17
|
}
|
|
32
|
-
export declare const scheduler: Scheduler;
|
|
33
|
-
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Component } from "./component";
|
|
2
|
+
export declare const enum STATUS {
|
|
3
|
+
NEW = 0,
|
|
4
|
+
MOUNTED = 1,
|
|
5
|
+
DESTROYED = 2
|
|
6
|
+
}
|
|
7
|
+
declare type STATUS_DESCR = "new" | "mounted" | "destroyed";
|
|
8
|
+
export declare function status(component: Component): STATUS_DESCR;
|
|
9
|
+
export {};
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -1,40 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* Owl Hook System
|
|
4
|
-
*
|
|
5
|
-
* This file introduces the concept of hooks, similar to React or Vue hooks.
|
|
6
|
-
* We have currently an implementation of:
|
|
7
|
-
* - useState (reactive state)
|
|
8
|
-
* - onMounted
|
|
9
|
-
* - onWillUnmount
|
|
10
|
-
* - useRef
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* This is the main way a component can be made reactive. The useState hook
|
|
14
|
-
* will return an observed object (or array). Changes to that value will then
|
|
15
|
-
* trigger a rerendering of the current component.
|
|
16
|
-
*/
|
|
17
|
-
export declare function useState<T>(state: T): T;
|
|
18
|
-
export declare const onMounted: (cb: any) => void;
|
|
19
|
-
export declare const onWillUnmount: (cb: any) => void;
|
|
20
|
-
export declare const onWillPatch: (cb: any) => void;
|
|
21
|
-
export declare const onPatched: (cb: any) => void;
|
|
22
|
-
export declare const onWillStart: (cb: any) => void;
|
|
23
|
-
export declare const onWillUpdateProps: (cb: any) => void;
|
|
1
|
+
import type { Env } from "./app/app";
|
|
24
2
|
/**
|
|
25
3
|
* The purpose of this hook is to allow components to get a reference to a sub
|
|
26
4
|
* html node or component.
|
|
27
5
|
*/
|
|
28
|
-
|
|
29
|
-
el:
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
export declare function useRef<C extends Component = Component>(name: string): Ref<C>;
|
|
33
|
-
/**
|
|
34
|
-
* This hook is useful as a building block for some customized hooks, that may
|
|
35
|
-
* need a reference to the component calling them.
|
|
36
|
-
*/
|
|
37
|
-
export declare function useComponent<P, E extends Env>(): Component<P, E>;
|
|
6
|
+
export declare function useRef<T extends HTMLElement = HTMLElement>(name: string): {
|
|
7
|
+
el: T | null;
|
|
8
|
+
};
|
|
38
9
|
/**
|
|
39
10
|
* This hook is useful as a building block for some customized hooks, that may
|
|
40
11
|
* need a reference to the env of the component calling them.
|
|
@@ -45,7 +16,27 @@ export declare function useEnv<E extends Env>(): E;
|
|
|
45
16
|
* like for all hooks, it is important that this is only called in the
|
|
46
17
|
* constructor method.
|
|
47
18
|
*/
|
|
48
|
-
export declare function useSubEnv(
|
|
19
|
+
export declare function useSubEnv(envExtension: Env): void;
|
|
20
|
+
export declare function useChildSubEnv(envExtension: Env): void;
|
|
21
|
+
/**
|
|
22
|
+
* @param {...any} dependencies the dependencies computed by computeDependencies
|
|
23
|
+
* @returns {void|(()=>void)} a cleanup function that reverses the side
|
|
24
|
+
* effects of the effect callback.
|
|
25
|
+
*/
|
|
26
|
+
declare type Effect = (...dependencies: any[]) => void | (() => void);
|
|
27
|
+
/**
|
|
28
|
+
* This hook will run a callback when a component is mounted and patched, and
|
|
29
|
+
* will run a cleanup function before patching and before unmounting the
|
|
30
|
+
* the component.
|
|
31
|
+
*
|
|
32
|
+
* @param {Effect} effect the effect to run on component mount and/or patch
|
|
33
|
+
* @param {()=>any[]} [computeDependencies=()=>[NaN]] a callback to compute
|
|
34
|
+
* dependencies that will decide if the effect needs to be cleaned up and
|
|
35
|
+
* run again. If the dependencies did not change, the effect will not run
|
|
36
|
+
* again. The default value returns an array containing only NaN because
|
|
37
|
+
* NaN !== NaN, which will cause the effect to rerun on every patch.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useEffect(effect: Effect, computeDependencies?: () => any[]): void;
|
|
49
40
|
/**
|
|
50
41
|
* When a component needs to listen to DOM Events on element(s) that are not
|
|
51
42
|
* part of his hierarchy, we can use the `useExternalListener` hook.
|
|
@@ -59,5 +50,5 @@ export declare function useSubEnv(nextEnv: any): void;
|
|
|
59
50
|
* in the constructor of the OWL component that needs to be notified,
|
|
60
51
|
* `useExternalListener(window, 'click', this._doSomething);`
|
|
61
52
|
* */
|
|
62
|
-
export declare function useExternalListener(target: HTMLElement | typeof window, eventName: string, handler:
|
|
53
|
+
export declare function useExternalListener(target: HTMLElement | typeof window, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
|
|
63
54
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,49 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import { Link } from "./router/link";
|
|
19
|
-
import { RouteComponent } from "./router/route_component";
|
|
20
|
-
import { Router } from "./router/router";
|
|
21
|
-
export { Component, mount } from "./component/component";
|
|
22
|
-
export { QWeb };
|
|
23
|
-
export { config };
|
|
24
|
-
export { browser } from "./browser";
|
|
25
|
-
export declare const Context: typeof _context.Context;
|
|
26
|
-
export declare const useState: typeof _hooks.useState;
|
|
27
|
-
export declare const core: {
|
|
28
|
-
EventBus: typeof EventBus;
|
|
29
|
-
Observer: typeof Observer;
|
|
30
|
-
};
|
|
31
|
-
export declare const router: {
|
|
32
|
-
Router: typeof Router;
|
|
33
|
-
RouteComponent: typeof RouteComponent;
|
|
34
|
-
Link: typeof Link;
|
|
35
|
-
};
|
|
36
|
-
export declare const Store: typeof _store.Store;
|
|
37
|
-
export declare const utils: typeof _utils;
|
|
38
|
-
export declare const tags: typeof _tags;
|
|
39
|
-
export declare const misc: {
|
|
40
|
-
AsyncRoot: typeof AsyncRoot;
|
|
41
|
-
Portal: typeof Portal;
|
|
42
|
-
};
|
|
43
|
-
export declare const hooks: typeof _hooks & {
|
|
44
|
-
useContext: typeof _context.useContext;
|
|
45
|
-
useDispatch: typeof _store.useDispatch;
|
|
46
|
-
useGetters: typeof _store.useGetters;
|
|
47
|
-
useStore: typeof _store.useStore;
|
|
1
|
+
import { createBlock, html, list, mount as blockMount, multi, patch, remove, text, toggler, comment } from "./blockdom";
|
|
2
|
+
export type { Reactive } from "./reactivity";
|
|
3
|
+
export declare const blockDom: {
|
|
4
|
+
config: {
|
|
5
|
+
shouldNormalizeDom: boolean;
|
|
6
|
+
mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null | undefined) => boolean;
|
|
7
|
+
};
|
|
8
|
+
mount: typeof blockMount;
|
|
9
|
+
patch: typeof patch;
|
|
10
|
+
remove: typeof remove;
|
|
11
|
+
list: typeof list;
|
|
12
|
+
multi: typeof multi;
|
|
13
|
+
text: typeof text;
|
|
14
|
+
toggler: typeof toggler;
|
|
15
|
+
createBlock: typeof createBlock;
|
|
16
|
+
html: typeof html;
|
|
17
|
+
comment: typeof comment;
|
|
48
18
|
};
|
|
19
|
+
export { App, mount } from "./app/app";
|
|
20
|
+
export { Component } from "./component/component";
|
|
21
|
+
export { useComponent, useState } from "./component/component_node";
|
|
22
|
+
export { status } from "./component/status";
|
|
23
|
+
export { Memo } from "./memo";
|
|
24
|
+
export { xml } from "./app/template_set";
|
|
25
|
+
export { reactive, markRaw, toRaw } from "./reactivity";
|
|
26
|
+
export { useEffect, useEnv, useExternalListener, useRef, useChildSubEnv, useSubEnv } from "./hooks";
|
|
27
|
+
export { EventBus, whenReady, loadFile, markup } from "./utils";
|
|
28
|
+
export { onWillStart, onMounted, onWillUnmount, onWillUpdateProps, onWillPatch, onPatched, onWillRender, onRendered, onWillDestroy, onError, } from "./component/lifecycle_hooks";
|
|
49
29
|
export declare const __info__: {};
|