@odoo/owl 1.4.7 → 2.0.0-alpha.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.
Files changed (65) hide show
  1. package/README.md +59 -65
  2. package/dist/owl.cjs.js +4628 -5045
  3. package/dist/owl.cjs.min.js +1 -15
  4. package/dist/owl.es.js +4600 -5035
  5. package/dist/owl.es.min.js +1 -15
  6. package/dist/owl.iife.js +4628 -5045
  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} +5 -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 +54 -0
  27. package/dist/types/component/error_handling.d.ts +13 -0
  28. package/dist/types/component/fibers.d.ts +32 -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 +64 -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
@@ -0,0 +1,54 @@
1
+ import type { App, Env } from "../app/app";
2
+ import { BDom, VNode } from "../blockdom";
3
+ import { Component, ComponentConstructor } from "./component";
4
+ import { Fiber, MountFiber, MountOptions, RootFiber } from "./fibers";
5
+ import { STATUS } from "./status";
6
+ export declare function getCurrent(): ComponentNode;
7
+ export declare function useComponent(): Component;
8
+ export declare function component(name: string | typeof Component, props: any, key: string, ctx: ComponentNode, parent: any): ComponentNode;
9
+ declare type LifecycleHook = Function;
10
+ export declare class ComponentNode<P = any, E = any> implements VNode<ComponentNode<P, E>> {
11
+ el?: HTMLElement | Text | undefined;
12
+ app: App;
13
+ fiber: Fiber | null;
14
+ component: Component<P, E>;
15
+ bdom: BDom | null;
16
+ status: STATUS;
17
+ renderFn: Function;
18
+ parent: ComponentNode | null;
19
+ level: number;
20
+ childEnv: Env;
21
+ children: {
22
+ [key: string]: ComponentNode;
23
+ };
24
+ refs: any;
25
+ willStart: LifecycleHook[];
26
+ willUpdateProps: LifecycleHook[];
27
+ willUnmount: LifecycleHook[];
28
+ mounted: LifecycleHook[];
29
+ willPatch: LifecycleHook[];
30
+ patched: LifecycleHook[];
31
+ willDestroy: LifecycleHook[];
32
+ constructor(C: ComponentConstructor<P, E>, props: P, app: App, parent?: ComponentNode);
33
+ mountComponent(target: any, options?: MountOptions): void;
34
+ initiateRender(fiber: Fiber | MountFiber): Promise<void>;
35
+ render(): Promise<void>;
36
+ _render(fiber: Fiber | RootFiber): void;
37
+ destroy(): void;
38
+ _destroy(): void;
39
+ updateAndRender(props: any, parentFiber: Fiber): Promise<void>;
40
+ /**
41
+ * Finds a child that has dom that is not yet updated, and update it. This
42
+ * method is meant to be used only in the context of repatching the dom after
43
+ * a mounted hook failed and was handled.
44
+ */
45
+ updateDom(): void;
46
+ firstNode(): Node | undefined;
47
+ mount(parent: HTMLElement, anchor: ChildNode): void;
48
+ moveBefore(other: ComponentNode | null, afterNode: Node | null): void;
49
+ patch(): void;
50
+ beforeRemove(): void;
51
+ remove(): void;
52
+ cleanOutdatedChildren(): void;
53
+ }
54
+ 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,32 @@
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
+ constructor(node: ComponentNode, parent: Fiber | null);
13
+ }
14
+ export declare class RootFiber extends Fiber {
15
+ counter: number;
16
+ willPatch: Fiber[];
17
+ patched: Fiber[];
18
+ mounted: Fiber[];
19
+ locked: boolean;
20
+ complete(): void;
21
+ }
22
+ declare type Position = "first-child" | "last-child";
23
+ export interface MountOptions {
24
+ position?: Position;
25
+ }
26
+ export declare class MountFiber extends RootFiber {
27
+ target: HTMLElement;
28
+ position: Position;
29
+ constructor(node: ComponentNode, target: HTMLElement, options?: MountOptions);
30
+ complete(): void;
31
+ }
32
+ 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
- export {};
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 "./fiber";
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
- tasks: Task[];
3
+ static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
4
+ tasks: Set<RootFiber>;
18
5
  isRunning: boolean;
19
6
  requestAnimationFrame: Window["requestAnimationFrame"];
20
- constructor(requestAnimationFrame: Window["requestAnimationFrame"]);
7
+ constructor();
21
8
  start(): void;
22
9
  stop(): void;
23
- addFiber(fiber: Fiber): Promise<void>;
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 {};
@@ -1,40 +1,11 @@
1
- import { Component, Env } from "./component/component";
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
- interface Ref<C extends Component = Component> {
29
- el: HTMLElement | null;
30
- comp: C | null;
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(nextEnv: any): void;
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: any, eventParams?: any): void;
53
+ export declare function useExternalListener(target: HTMLElement | typeof window, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
63
54
  export {};
@@ -1,49 +1,29 @@
1
- /**
2
- * This file is the main file packaged by rollup (see rollup.config.js). From
3
- * this file, we export all public owl elements.
4
- *
5
- * Note that dynamic values, such as a date or a commit hash are added by rollup
6
- */
7
- import { EventBus } from "./core/event_bus";
8
- import { Observer } from "./core/observer";
9
- import { QWeb } from "./qweb/index";
10
- import { config } from "./config";
11
- import * as _store from "./store";
12
- import * as _utils from "./utils";
13
- import * as _tags from "./tags";
14
- import { AsyncRoot } from "./misc/async_root";
15
- import { Portal } from "./misc/portal";
16
- import * as _hooks from "./hooks";
17
- import * as _context from "./context";
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 } from "./component/component_node";
22
+ export { status } from "./component/status";
23
+ export { Memo } from "./memo";
24
+ export { xml } from "./app/template_set";
25
+ export { useState, 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__: {};
@@ -0,0 +1,6 @@
1
+ import { Component } from "./component/component";
2
+ import type { ComponentNode } from "./component/component_node";
3
+ export declare class Memo extends Component {
4
+ static template: string;
5
+ constructor(props: any, env: any, node: ComponentNode);
6
+ }
@@ -0,0 +1,11 @@
1
+ import { Component } from "./component/component";
2
+ export declare class Portal extends Component {
3
+ static template: string;
4
+ static props: {
5
+ target: {
6
+ type: StringConstructor;
7
+ };
8
+ slots: boolean;
9
+ };
10
+ setup(): void;
11
+ }
@@ -0,0 +1,64 @@
1
+ import { Callback } from "./utils";
2
+ declare const TARGET: unique symbol;
3
+ declare const SKIP: unique symbol;
4
+ declare type Target = object;
5
+ export declare type Reactive<T extends Target = Target> = T & {
6
+ [TARGET]: any;
7
+ };
8
+ declare type NonReactive<T extends Target = Target> = T & {
9
+ [SKIP]: any;
10
+ };
11
+ /**
12
+ * Mark an object or array so that it is ignored by the reactivity system
13
+ *
14
+ * @param value the value to mark
15
+ * @returns the object itself
16
+ */
17
+ export declare function markRaw<T extends Target>(value: T): NonReactive<T>;
18
+ /**
19
+ * Given a reactive objet, return the raw (non reactive) underlying object
20
+ *
21
+ * @param value a reactive value
22
+ * @returns the underlying value
23
+ */
24
+ export declare function toRaw<T extends object>(value: Reactive<T>): T;
25
+ /**
26
+ * Creates a reactive proxy for an object. Reading data on the reactive object
27
+ * subscribes to changes to the data. Writing data on the object will cause the
28
+ * notify callback to be called if there are suscriptions to that data. Nested
29
+ * objects and arrays are automatically made reactive as well.
30
+ *
31
+ * Whenever you are notified of a change, all subscriptions are cleared, and if
32
+ * you would like to be notified of any further changes, you should go read
33
+ * the underlying data again. We assume that if you don't go read it again after
34
+ * being notified, it means that you are no longer interested in that data.
35
+ *
36
+ * Subscriptions:
37
+ * + Reading a property on an object will subscribe you to changes in the value
38
+ * of that property.
39
+ * + Accessing an object keys (eg with Object.keys or with `for..in`) will
40
+ * subscribe you to the creation/deletion of keys. Checking the presence of a
41
+ * key on the object with 'in' has the same effect.
42
+ * - getOwnPropertyDescriptor does not currently subscribe you to the property.
43
+ * This is a choice that was made because changing a key's value will trigger
44
+ * this trap and we do not want to subscribe by writes. This also means that
45
+ * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
46
+ *
47
+ * @param target the object for which to create a reactive proxy
48
+ * @param callback the function to call when an observed property of the
49
+ * reactive has changed
50
+ * @returns a proxy that tracks changes to it
51
+ */
52
+ export declare function reactive<T extends Target>(target: T, callback?: Callback): Reactive<T> | NonReactive<T>;
53
+ /**
54
+ * Creates a reactive object that will be observed by the current component.
55
+ * Reading data from the returned object (eg during rendering) will cause the
56
+ * component to subscribe to that data and be rerendered when it changes.
57
+ *
58
+ * @param state the state to observe
59
+ * @returns a reactive object that will cause the component to re-render on
60
+ * relevant changes
61
+ * @see reactive
62
+ */
63
+ export declare function useState<T extends object>(state: T): Reactive<T> | NonReactive<T>;
64
+ export {};
@@ -1,25 +1,18 @@
1
+ export declare type Callback = () => void;
1
2
  /**
2
- * Owl Utils
3
+ * Creates a batched version of a callback so that all calls to it in the same
4
+ * microtick will only call the original callback once.
3
5
  *
4
- * We have here a small collection of utility functions:
5
- *
6
- * - whenReady
7
- * - loadJS
8
- * - loadFile
9
- * - escape
10
- * - debounce
6
+ * @param callback the callback to batch
7
+ * @returns a batched version of the original callback
11
8
  */
12
- export declare function whenReady(fn?: any): Promise<unknown>;
13
- export declare function loadJS(url: string): Promise<void>;
9
+ export declare function batched(callback: Callback): Callback;
10
+ export declare function validateTarget(target: HTMLElement): void;
11
+ export declare class EventBus extends EventTarget {
12
+ trigger(name: string, payload?: any): void;
13
+ }
14
+ export declare function whenReady(fn?: any): Promise<void>;
14
15
  export declare function loadFile(url: string): Promise<string>;
15
- export declare function escape(str: string | number | undefined): string;
16
- /**
17
- * Returns a function, that, as long as it continues to be invoked, will not
18
- * be triggered. The function will be called after it stops being called for
19
- * N milliseconds. If `immediate` is passed, trigger the function on the
20
- * leading edge, instead of the trailing.
21
- *
22
- * Inspired by https://davidwalsh.name/javascript-debounce-function
23
- */
24
- export declare function debounce(func: Function, wait: number, immediate?: boolean): Function;
25
- export declare function shallowEqual(p1: any, p2: any): boolean;
16
+ export declare class Markup extends String {
17
+ }
18
+ export declare function markup(value: any): Markup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/owl",
3
- "version": "1.4.7",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "Odoo Web Library (OWL)",
5
5
  "main": "dist/owl.cjs.js",
6
6
  "browser": "dist/owl.iife.js",
@@ -13,14 +13,15 @@
13
13
  "node": ">=12.18.3"
14
14
  },
15
15
  "scripts": {
16
- "build:bundle": "rollup -c",
16
+ "build:bundle": "rollup -c --failAfterWarnings",
17
17
  "build": "npm run build:bundle",
18
18
  "test": "jest",
19
+ "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand --watch --testTimeout=5000000",
19
20
  "test:watch": "jest --watch",
20
- "tools:serve": "python3 tools/server.py || python tools/server.py",
21
- "tools": "npm run build && npm run tools:serve",
22
- "pretools:watch": "npm run build",
23
- "tools:watch": "npm-run-all --parallel tools:serve \"build:* -- --watch\"",
21
+ "playground:serve": "python3 tools/server.py || python tools/server.py",
22
+ "playground": "npm run build && npm run playground:serve",
23
+ "preplayground:watch": "npm run build",
24
+ "playground:watch": "npm-run-all --parallel playground:serve \"build:* -- --watch\"",
24
25
  "prettier": "prettier {src/*.ts,src/**/*.ts,tests/*.ts,tests/**/*.ts,doc/*.md,doc/**/*.md} --write",
25
26
  "check-formatting": "prettier {src/*.ts,src/**/*.ts,tests/*.ts,tests/**/*.ts,doc/*.md,doc/**/*.md} --check",
26
27
  "publish": "npm run build && npm publish",
@@ -45,17 +46,18 @@
45
46
  "git-rev-sync": "^1.12.0",
46
47
  "github-api": "^3.3.0",
47
48
  "jest": "^27.1.0",
49
+ "jest-diff": "^27.3.1",
48
50
  "jest-environment-jsdom": "^27.1.0",
49
51
  "live-server": "^1.2.1",
50
52
  "npm-run-all": "^4.1.5",
51
- "prettier": "^2.0.4",
53
+ "prettier": "2.4.1",
52
54
  "rollup": "^2.56.3",
53
55
  "rollup-plugin-terser": "^7.0.2",
54
- "rollup-plugin-typescript2": "^0.30.0",
56
+ "rollup-plugin-typescript2": "^0.31.1",
55
57
  "sass": "^1.16.1",
56
58
  "source-map-support": "^0.5.10",
57
59
  "ts-jest": "^27.0.5",
58
- "typescript": "^3.7.2",
60
+ "typescript": "4.5.2",
59
61
  "uglify-es": "^3.3.9"
60
62
  },
61
63
  "jest": {
@@ -64,6 +66,9 @@
64
66
  "<rootDir>/src",
65
67
  "<rootDir>/tests"
66
68
  ],
69
+ "setupFiles": [
70
+ "./tests/mocks/mockEventTarget.js"
71
+ ],
67
72
  "transform": {
68
73
  "^.+\\.ts?$": "ts-jest"
69
74
  },
@@ -1,12 +0,0 @@
1
- export interface Browser {
2
- setTimeout: Window["setTimeout"];
3
- clearTimeout: Window["clearTimeout"];
4
- setInterval: Window["setInterval"];
5
- clearInterval: Window["clearInterval"];
6
- requestAnimationFrame: Window["requestAnimationFrame"];
7
- random: Math["random"];
8
- Date: typeof Date;
9
- fetch: Window["fetch"];
10
- localStorage: Window["localStorage"];
11
- }
12
- export declare const browser: Browser;
@@ -1 +0,0 @@
1
- export {};
@@ -1,75 +0,0 @@
1
- import { VNode } from "../vdom/index";
2
- import { Component, MountPosition } from "./component";
3
- /**
4
- * Owl Fiber Class
5
- *
6
- * Fibers are small abstractions designed to contain all the internal state
7
- * associated with a "rendering work unit", relative to a specific component.
8
- *
9
- * A rendering will cause the creation of a fiber for each impacted components.
10
- *
11
- * Fibers capture all that necessary information, which is critical to owl
12
- * asynchronous rendering pipeline. Fibers can be cancelled, can be in different
13
- * states and in general determine the state of the rendering.
14
- */
15
- export declare class Fiber {
16
- static nextId: number;
17
- id: number;
18
- force: boolean;
19
- isCompleted: boolean;
20
- shouldPatch: boolean;
21
- isRendered: boolean;
22
- counter: number;
23
- target: HTMLElement | DocumentFragment | null;
24
- position: MountPosition | null;
25
- scope: any;
26
- component: Component;
27
- vnode: VNode | null;
28
- root: Fiber;
29
- child: Fiber | null;
30
- sibling: Fiber | null;
31
- lastChild: Fiber | null;
32
- parent: Fiber | null;
33
- error?: Error;
34
- constructor(parent: Fiber | null, component: Component, force: boolean, target: HTMLElement | DocumentFragment | null, position: MountPosition | null);
35
- /**
36
- * When the oldFiber is not completed yet, and both oldFiber and this fiber
37
- * are root fibers, we want to reuse the oldFiber instead of creating a new
38
- * one. Doing so will guarantee that the initiator(s) of those renderings will
39
- * be notified (the promise will resolve) when the last rendering will be done.
40
- *
41
- * This function thus assumes that oldFiber is a root fiber.
42
- */
43
- _reuseFiber(oldFiber: Fiber): void;
44
- /**
45
- * In some cases, a rendering initiated at some component can detect that it
46
- * should be part of a larger rendering initiated somewhere up the component
47
- * tree. In that case, it needs to cancel the previous rendering and
48
- * remap itself as a part of the current parent rendering.
49
- */
50
- _remapFiber(oldFiber: Fiber): void;
51
- /**
52
- * This function has been taken from
53
- * https://medium.com/react-in-depth/the-how-and-why-on-reacts-usage-of-linked-list-in-fiber-67f1014d0eb7
54
- */
55
- _walk(doWork: (f: Fiber) => Fiber | null): void;
56
- /**
57
- * Successfully complete the work of the fiber: call the mount or patch hooks
58
- * and patch the DOM. This function is called once the fiber and its children
59
- * are ready, and the scheduler decides to process it.
60
- */
61
- complete(): void;
62
- /**
63
- * Cancel a fiber and all its children.
64
- */
65
- cancel(): void;
66
- /**
67
- * This is the global error handler for errors occurring in Owl main lifecycle
68
- * methods. Caught errors are triggered on the QWeb instance, and are
69
- * potentially given to some parent component which implements `catchError`.
70
- *
71
- * If there are no such component, we destroy everything. This is better than
72
- * being in a corrupted state.
73
- */
74
- handleError(error: Error): void;
75
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Owl Style System
3
- *
4
- * This files contains the Owl code related to processing (extended) css strings
5
- * and creating/adding <style> tags to the document head.
6
- */
7
- export declare const STYLESHEETS: {
8
- [id: string]: HTMLStyleElement;
9
- };
10
- export declare function processSheet(str: string): string;
11
- export declare function registerSheet(id: string, css: string): void;
12
- export declare function activateSheet(id: any, name: any): void;
@@ -1,12 +0,0 @@
1
- /**
2
- * This file creates and exports the OWL 'config' object, with keys:
3
- * - 'mode': 'prod' or 'dev',
4
- * - 'env': the environment to use in root components.
5
- */
6
- interface Config {
7
- mode: string;
8
- enableTransitions: boolean;
9
- translatableAttributes: string[];
10
- }
11
- export declare const config: Config;
12
- export {};