@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.
Files changed (65) hide show
  1. package/README.md +59 -65
  2. package/dist/owl.cjs.js +4700 -5068
  3. package/dist/owl.cjs.min.js +1 -15
  4. package/dist/owl.es.js +4672 -5058
  5. package/dist/owl.es.min.js +1 -15
  6. package/dist/owl.iife.js +4700 -5068
  7. package/dist/owl.iife.min.js +1 -15
  8. package/dist/types/app/app.d.ts +29 -0
  9. package/dist/types/app/template_helpers.d.ts +49 -0
  10. package/dist/types/app/template_set.d.ts +34 -0
  11. package/dist/types/blockdom/attributes.d.ts +8 -0
  12. package/dist/types/blockdom/block_compiler.d.ts +21 -0
  13. package/dist/types/blockdom/config.d.ts +8 -0
  14. package/dist/types/blockdom/events.d.ts +7 -0
  15. package/dist/types/blockdom/html.d.ts +16 -0
  16. package/dist/types/blockdom/index.d.ts +24 -0
  17. package/dist/types/blockdom/list.d.ts +17 -0
  18. package/dist/types/blockdom/multi.d.ts +16 -0
  19. package/dist/types/blockdom/text.d.ts +25 -0
  20. package/dist/types/blockdom/toggler.d.ts +16 -0
  21. package/dist/types/compiler/code_generator.d.ts +144 -0
  22. package/dist/types/compiler/index.d.ts +9 -0
  23. package/dist/types/{qweb/expression_parser.d.ts → compiler/inline_expressions.d.ts} +4 -6
  24. package/dist/types/compiler/parser.d.ts +157 -0
  25. package/dist/types/component/component.d.ts +15 -294
  26. package/dist/types/component/component_node.d.ts +67 -0
  27. package/dist/types/component/error_handling.d.ts +13 -0
  28. package/dist/types/component/fibers.d.ts +33 -0
  29. package/dist/types/component/handler.d.ts +1 -0
  30. package/dist/types/component/lifecycle_hooks.d.ts +12 -0
  31. package/dist/types/component/props_validation.d.ts +14 -1
  32. package/dist/types/component/scheduler.d.ts +5 -21
  33. package/dist/types/component/status.d.ts +9 -0
  34. package/dist/types/hooks.d.ts +26 -35
  35. package/dist/types/index.d.ts +27 -47
  36. package/dist/types/memo.d.ts +6 -0
  37. package/dist/types/portal.d.ts +11 -0
  38. package/dist/types/reactivity.d.ts +59 -0
  39. package/dist/types/utils.d.ts +14 -21
  40. package/package.json +14 -9
  41. package/dist/types/browser.d.ts +0 -12
  42. package/dist/types/component/directive.d.ts +0 -1
  43. package/dist/types/component/fiber.d.ts +0 -75
  44. package/dist/types/component/styles.d.ts +0 -12
  45. package/dist/types/config.d.ts +0 -12
  46. package/dist/types/context.d.ts +0 -36
  47. package/dist/types/core/event_bus.d.ts +0 -42
  48. package/dist/types/core/observer.d.ts +0 -30
  49. package/dist/types/core/owl_event.d.ts +0 -10
  50. package/dist/types/misc/async_root.d.ts +0 -13
  51. package/dist/types/misc/portal.d.ts +0 -70
  52. package/dist/types/qweb/base_directives.d.ts +0 -1
  53. package/dist/types/qweb/compilation_context.d.ts +0 -69
  54. package/dist/types/qweb/extensions.d.ts +0 -28
  55. package/dist/types/qweb/index.d.ts +0 -3
  56. package/dist/types/qweb/qweb.d.ts +0 -141
  57. package/dist/types/router/link.d.ts +0 -11
  58. package/dist/types/router/route_component.d.ts +0 -6
  59. package/dist/types/router/router.d.ts +0 -57
  60. package/dist/types/store.d.ts +0 -63
  61. package/dist/types/tags.d.ts +0 -29
  62. package/dist/types/vdom/html_to_vdom.d.ts +0 -2
  63. package/dist/types/vdom/index.d.ts +0 -2
  64. package/dist/types/vdom/modules.d.ts +0 -5
  65. package/dist/types/vdom/vdom.d.ts +0 -101
@@ -1,141 +0,0 @@
1
- import { EventBus } from "../core/event_bus";
2
- import { h, VNode } from "../vdom/index";
3
- import { CompilationContext } from "./compilation_context";
4
- /**
5
- * Owl QWeb Engine
6
- *
7
- * In this file, you will find a QWeb engine/template compiler. It is the core
8
- * of how Owl component works.
9
- *
10
- * Briefly, Owl QWeb compiles XML templates into functions that output a virtual
11
- * DOM representation.
12
- *
13
- * We have here:
14
- * - a CompilationContext class, which is an internal object that contains all
15
- * compilation specific information, while a template is being compiled.
16
- * - a QWeb class: this is the code of the QWeb compiler.
17
- *
18
- * Note that this file does not contain the implementation of the QWeb
19
- * directives (see qweb_directives.ts and qweb_extensions.ts).
20
- */
21
- export declare type EvalContext = {
22
- [key: string]: any;
23
- };
24
- export declare type CompiledTemplate = (context: EvalContext, extra: any) => VNode;
25
- interface Template {
26
- elem: Element;
27
- fn: CompiledTemplate;
28
- }
29
- interface CompilationInfo {
30
- node: Element;
31
- qweb: QWeb;
32
- ctx: CompilationContext;
33
- fullName: string;
34
- value: string;
35
- }
36
- interface NodeCreationCompilationInfo extends CompilationInfo {
37
- nodeID: number;
38
- addNodeHook: Function;
39
- }
40
- export interface Directive {
41
- name: string;
42
- extraNames?: string[];
43
- priority: number;
44
- atNodeEncounter?(info: CompilationInfo): boolean | void;
45
- atNodeCreation?(info: NodeCreationCompilationInfo): void;
46
- finalize?(info: CompilationInfo): void;
47
- }
48
- interface QWebConfig {
49
- templates?: string;
50
- translateFn?(text: string): string;
51
- }
52
- export declare const TRANSLATABLE_ATTRS: string[];
53
- interface Utils {
54
- toClassObj(expr: any): Object;
55
- shallowEqual(p1: Object, p2: Object): boolean;
56
- [key: string]: any;
57
- }
58
- export declare class QWeb extends EventBus {
59
- templates: {
60
- [name: string]: Template;
61
- };
62
- static utils: Utils;
63
- static components: any;
64
- static DIRECTIVE_NAMES: {
65
- [key: string]: 1;
66
- };
67
- static DIRECTIVES: Directive[];
68
- static TEMPLATES: {
69
- [name: string]: Template;
70
- };
71
- static nextId: number;
72
- h: typeof h;
73
- static dev: boolean;
74
- static enableTransitions: boolean;
75
- static slots: {};
76
- static nextSlotId: number;
77
- subTemplates: {
78
- [key: string]: number;
79
- };
80
- static subTemplates: {
81
- [id: number]: Function;
82
- };
83
- isUpdating: boolean;
84
- translateFn?: QWebConfig["translateFn"];
85
- constructor(config?: QWebConfig);
86
- static addDirective(directive: Directive): void;
87
- static registerComponent(name: string, Component: any): void;
88
- /**
89
- * Register globally a template. All QWeb instances will obtain their
90
- * templates from their own template map, and then, from the global static
91
- * TEMPLATES property.
92
- */
93
- static registerTemplate(name: string, template: string): void;
94
- /**
95
- * Add a template to the internal template map. Note that it is not
96
- * immediately compiled.
97
- */
98
- addTemplate(name: string, xmlString: string, allowDuplicate?: boolean): void;
99
- /**
100
- * Load templates from a xml (as a string or xml document). This will look up
101
- * for the first <templates> tag, and will consider each child of this as a
102
- * template, with the name given by the t-name attribute.
103
- */
104
- addTemplates(xmlstr: string | Document): void;
105
- _addTemplate(name: string, elem: Element): void;
106
- _processTemplate(elem: Element): void;
107
- /**
108
- * Render a template
109
- *
110
- * @param {string} name the template should already have been added
111
- */
112
- render(name: string, context?: EvalContext, extra?: any): VNode;
113
- /**
114
- * Render a template to a html string.
115
- *
116
- * Note that this is more limited than the `render` method: it is not suitable
117
- * to render a full component tree, since this is an asynchronous operation.
118
- * This method can only render templates without components.
119
- */
120
- renderToString(name: string, context?: EvalContext, extra?: any): string;
121
- /**
122
- * Force all widgets connected to this QWeb instance to rerender themselves.
123
- *
124
- * This method is mostly useful for external code that want to modify the
125
- * application in some cases. For example, a router plugin.
126
- */
127
- forceUpdate(): void;
128
- _compile(name: string, options?: {
129
- elem?: Element;
130
- hasParent?: boolean;
131
- defineKey?: boolean;
132
- }): CompiledTemplate;
133
- /**
134
- * Generate code from an xml node
135
- *
136
- */
137
- _compileNode(node: ChildNode, ctx: CompilationContext): void;
138
- _compileGenericNode(node: ChildNode, ctx: CompilationContext, withHandlers?: boolean): number;
139
- _compileChildren(node: ChildNode, ctx: CompilationContext): void;
140
- }
141
- export {};
@@ -1,11 +0,0 @@
1
- import { Component } from "../component/component";
2
- import { Destination, RouterEnv } from "./router";
3
- declare type Props = Destination;
4
- export declare class Link<Env extends RouterEnv> extends Component<Props, Env> {
5
- static template: string;
6
- href: string;
7
- willUpdateProps(nextProps: any): Promise<void>;
8
- get isActive(): boolean;
9
- navigate(ev: any): void;
10
- }
11
- export {};
@@ -1,6 +0,0 @@
1
- import { Component } from "../component/component";
2
- import { EnvWithRouter } from "./router";
3
- export declare class RouteComponent extends Component<{}, EnvWithRouter> {
4
- static template: string;
5
- get routeComponent(): any;
6
- }
@@ -1,57 +0,0 @@
1
- import { Env } from "../component/component";
2
- declare type NavigationGuard = (info: {
3
- env: Env;
4
- to: Route | null;
5
- from: Route | null;
6
- }) => boolean | Destination;
7
- export interface Route {
8
- name: string;
9
- path: string;
10
- extractionRegExp: RegExp;
11
- component?: any;
12
- redirect?: Destination;
13
- params: string[];
14
- beforeRouteEnter?: NavigationGuard;
15
- }
16
- export declare type RouteParams = {
17
- [key: string]: string | number;
18
- };
19
- export interface RouterEnv extends Env {
20
- router: Router;
21
- }
22
- export interface Destination {
23
- path?: string;
24
- to?: string;
25
- params?: RouteParams;
26
- }
27
- interface Options {
28
- mode: Router["mode"];
29
- }
30
- export interface EnvWithRouter extends Env {
31
- router: Router;
32
- }
33
- export declare class Router {
34
- currentRoute: Route | null;
35
- currentParams: RouteParams | null;
36
- mode: "history" | "hash";
37
- routes: {
38
- [id: string]: Route;
39
- };
40
- routeIds: string[];
41
- env: RouterEnv;
42
- constructor(env: Partial<EnvWithRouter>, routes: Partial<Route>[], options?: Options);
43
- start(): Promise<void>;
44
- navigate(to: Destination): Promise<boolean>;
45
- _navigate(path: string, ev?: any): Promise<boolean>;
46
- destToPath(dest: Destination): string;
47
- get currentRouteName(): string | null;
48
- private setUrlFromPath;
49
- private validateDestination;
50
- private routeToPath;
51
- private currentPath;
52
- private match;
53
- private matchAndApplyRules;
54
- private applyRules;
55
- private getRouteParams;
56
- }
57
- export {};
@@ -1,63 +0,0 @@
1
- import { Env } from "./component/component";
2
- import { Context } from "./context";
3
- /**
4
- * Owl Store
5
- *
6
- * We have here:
7
- * - a Store class
8
- * - useStore hook
9
- * - useDispatch hook
10
- * - useGetters hook
11
- *
12
- * The Owl store is our answer to the problem of managing complex state across
13
- * components. The main idea is that the store owns some state, allow external
14
- * code to modify it through actions, and for each state changes,
15
- * connected component will be notified, and updated if necessary.
16
- *
17
- * Note that this code is partly inspired by VueX and React/Redux
18
- */
19
- export interface EnvWithStore extends Env {
20
- store: Store;
21
- }
22
- export declare type Action = ({ state, dispatch, env, getters }: {
23
- state: any;
24
- dispatch: any;
25
- env: any;
26
- getters: any;
27
- }, ...payload: any) => any;
28
- export declare type Getter = ({ state: any, getters }: {
29
- state: any;
30
- getters: any;
31
- }, payload?: any) => any;
32
- interface StoreConfig {
33
- env?: Env;
34
- state?: any;
35
- actions?: {
36
- [name: string]: Action;
37
- };
38
- getters?: {
39
- [name: string]: Getter;
40
- };
41
- }
42
- export declare class Store extends Context {
43
- actions: any;
44
- env: any;
45
- getters: {
46
- [name: string]: (payload?: any) => any;
47
- };
48
- updateFunctions: {
49
- [key: number]: (() => boolean)[];
50
- };
51
- constructor(config: StoreConfig);
52
- dispatch(action: string, ...payload: any): Promise<void> | void;
53
- __notifyComponents(): Promise<void>;
54
- }
55
- interface SelectorOptions {
56
- store?: Store;
57
- isEqual?: (a: any, b: any) => boolean;
58
- onUpdate?: (result: any) => any;
59
- }
60
- export declare function useStore(selector: any, options?: SelectorOptions): any;
61
- export declare function useDispatch(store?: Store): Store["dispatch"];
62
- export declare function useGetters(store?: Store): Store["getters"];
63
- export {};
@@ -1,29 +0,0 @@
1
- /**
2
- * Owl Tags
3
- *
4
- * We have here a (very) small collection of tag functions:
5
- *
6
- * - xml
7
- *
8
- * The plan is to add a few other tags such as css, globalcss.
9
- */
10
- /**
11
- * XML tag helper for defining templates. With this, one can simply define
12
- * an inline template with just the template xml:
13
- * ```js
14
- * class A extends Component {
15
- * static template = xml`<div>some template</div>`;
16
- * }
17
- * ```
18
- */
19
- export declare function xml(strings: any, ...args: any[]): string;
20
- /**
21
- * CSS tag helper for defining inline stylesheets. With this, one can simply define
22
- * an inline stylesheet with just the following code:
23
- * ```js
24
- * class A extends Component {
25
- * static style = css`.component-a { color: red; }`;
26
- * }
27
- * ```
28
- */
29
- export declare function css(strings: any, ...args: any[]): string;
@@ -1,2 +0,0 @@
1
- import { VNode } from "./vdom";
2
- export declare function htmlToVDOM(html: string): VNode[];
@@ -1,2 +0,0 @@
1
- export { h, VNode } from "./vdom";
2
- export declare const patch: (oldVnode: import("./vdom").VNode | Element, vnode: import("./vdom").VNode) => import("./vdom").VNode;
@@ -1,5 +0,0 @@
1
- import { Module } from "./vdom";
2
- export declare const propsModule: Module;
3
- export declare const eventListenersModule: Module;
4
- export declare const attrsModule: Module;
5
- export declare const classModule: Module;
@@ -1,101 +0,0 @@
1
- /**
2
- * Owl VDOM
3
- *
4
- * This file contains an implementation of a virtual DOM, which is a system that
5
- * can generate in-memory representations of a DOM tree, compare them, and
6
- * eventually change a concrete DOM tree to match its representation, in an
7
- * hopefully efficient way.
8
- *
9
- * Note that this code is a fork of Snabbdom, slightly tweaked/optimized for our
10
- * needs (see https://github.com/snabbdom/snabbdom).
11
- *
12
- * The main exported values are:
13
- * - interface VNode
14
- * - h function (a helper function to generate a vnode)
15
- * - patch function (to apply a vnode to an actual DOM node)
16
- */
17
- declare global {
18
- interface Element {
19
- setAttribute(name: string, value: string | number | boolean): void;
20
- setAttributeNS(namespaceURI: string, qualifiedName: string, value: string | number | boolean): void;
21
- }
22
- }
23
- declare type Props = Record<string, any>;
24
- declare type Attrs = Record<string, string | number | boolean>;
25
- declare type On = {
26
- [N in keyof HTMLElementEventMap]?: (ev: HTMLElementEventMap[N]) => void;
27
- } & {
28
- [event: string]: EventListener;
29
- };
30
- export interface Module {
31
- pre: PreHook;
32
- create: CreateHook;
33
- update: UpdateHook;
34
- destroy: DestroyHook;
35
- remove: RemoveHook;
36
- post: PostHook;
37
- }
38
- declare type Key = string | number;
39
- export interface VNode {
40
- sel: string | undefined;
41
- data: VNodeData | undefined;
42
- children: Array<VNode | string> | undefined;
43
- elm: Node | undefined;
44
- text: string | undefined;
45
- key: Key | undefined;
46
- }
47
- export interface VNodeData {
48
- props?: Props;
49
- attrs?: Attrs;
50
- on?: On;
51
- hook?: Hooks;
52
- key?: Key;
53
- ns?: string;
54
- [key: string]: any;
55
- }
56
- export declare function init(modules: Array<Partial<Module>>, domApi?: DOMAPI): (oldVnode: VNode | Element, vnode: VNode) => VNode;
57
- interface DOMAPI {
58
- createElement: (tagName: any) => HTMLElement;
59
- createElementNS: (namespaceURI: string, qualifiedName: string) => Element;
60
- createTextNode: (text: string) => Text;
61
- createComment: (text: string) => Comment;
62
- insertBefore: (parentNode: Node, newNode: Node, referenceNode: Node | null) => void;
63
- removeChild: (node: Node, child: Node) => void;
64
- appendChild: (node: Node, child: Node) => void;
65
- parentNode: (node: Node) => Node;
66
- nextSibling: (node: Node) => Node;
67
- tagName: (elm: Element) => string;
68
- setTextContent: (node: Node, text: string | null) => void;
69
- }
70
- declare type PreHook = () => any;
71
- declare type InitHook = (vNode: VNode) => any;
72
- declare type CreateHook = (emptyVNode: VNode, vNode: VNode) => any;
73
- declare type InsertHook = (vNode: VNode) => any;
74
- declare type PrePatchHook = (oldVNode: VNode, vNode: VNode) => any;
75
- declare type UpdateHook = (oldVNode: VNode, vNode: VNode) => any;
76
- declare type PostPatchHook = (oldVNode: VNode, vNode: VNode) => any;
77
- declare type DestroyHook = (vNode: VNode) => any;
78
- declare type RemoveHook = (vNode: VNode, removeCallback: () => void) => any;
79
- declare type PostHook = () => any;
80
- interface Hooks {
81
- pre?: PreHook;
82
- init?: InitHook;
83
- create?: CreateHook;
84
- insert?: InsertHook;
85
- prepatch?: PrePatchHook;
86
- update?: UpdateHook;
87
- postpatch?: PostPatchHook;
88
- destroy?: DestroyHook;
89
- remove?: RemoveHook;
90
- post?: PostHook;
91
- }
92
- declare type VNodes = Array<VNode>;
93
- declare type VNodeChildElement = VNode | string | number | undefined | null;
94
- declare type ArrayOrElement<T> = T | T[];
95
- declare type VNodeChildren = ArrayOrElement<VNodeChildElement>;
96
- export declare function addNS(data: any, children: VNodes | undefined, sel: string | undefined): void;
97
- export declare function h(sel: string): VNode;
98
- export declare function h(sel: string, data: VNodeData): VNode;
99
- export declare function h(sel: string, children: VNodeChildren): VNode;
100
- export declare function h(sel: string, data: VNodeData, children: VNodeChildren): VNode;
101
- export {};