@odoo/owl 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (90) hide show
  1. package/README.md +100 -110
  2. package/dist/compile_templates.mjs +2434 -2532
  3. package/dist/compiler.js +2371 -0
  4. package/dist/owl-devtools.zip +0 -0
  5. package/dist/owl.cjs.js +6709 -6616
  6. package/dist/owl.cjs.runtime.js +4480 -0
  7. package/dist/owl.es.js +6697 -6600
  8. package/dist/owl.es.runtime.js +4436 -0
  9. package/dist/owl.iife.js +6710 -6617
  10. package/dist/owl.iife.min.js +1 -1
  11. package/dist/owl.iife.runtime.js +4484 -0
  12. package/dist/owl.iife.runtime.min.js +1 -0
  13. package/dist/types/common/owl_error.d.ts +3 -3
  14. package/dist/types/common/types.d.ts +1 -29
  15. package/dist/types/common/utils.d.ts +8 -8
  16. package/dist/types/compiler/code_generator.d.ts +133 -152
  17. package/dist/types/compiler/index.d.ts +13 -13
  18. package/dist/types/compiler/inline_expressions.d.ts +41 -59
  19. package/dist/types/compiler/parser.d.ts +170 -178
  20. package/dist/types/compiler/standalone/index.d.ts +2 -2
  21. package/dist/types/compiler/standalone/setup_jsdom.d.ts +1 -1
  22. package/dist/types/index.d.ts +1 -1
  23. package/dist/types/owl.d.ts +709 -665
  24. package/dist/types/runtime/app.d.ts +55 -62
  25. package/dist/types/runtime/blockdom/attributes.d.ts +8 -6
  26. package/dist/types/runtime/blockdom/block_compiler.d.ts +21 -21
  27. package/dist/types/runtime/blockdom/config.d.ts +8 -8
  28. package/dist/types/runtime/blockdom/event_catcher.d.ts +7 -7
  29. package/dist/types/runtime/blockdom/events.d.ts +8 -8
  30. package/dist/types/runtime/blockdom/html.d.ts +17 -17
  31. package/dist/types/runtime/blockdom/index.d.ts +25 -26
  32. package/dist/types/runtime/blockdom/list.d.ts +18 -18
  33. package/dist/types/runtime/blockdom/multi.d.ts +17 -17
  34. package/dist/types/runtime/blockdom/text.d.ts +26 -26
  35. package/dist/types/runtime/blockdom/toggler.d.ts +17 -17
  36. package/dist/types/runtime/component.d.ts +17 -28
  37. package/dist/types/runtime/component_node.d.ts +59 -83
  38. package/dist/types/runtime/context.d.ts +36 -0
  39. package/dist/types/runtime/error_handling.d.ts +13 -13
  40. package/dist/types/runtime/event_handling.d.ts +1 -1
  41. package/dist/types/runtime/fibers.d.ts +37 -37
  42. package/dist/types/runtime/hooks.d.ts +32 -57
  43. package/dist/types/runtime/index.d.ts +46 -35
  44. package/dist/types/runtime/lifecycle_hooks.d.ts +10 -12
  45. package/dist/types/runtime/plugin_hooks.d.ts +6 -0
  46. package/dist/types/runtime/plugin_manager.d.ts +36 -0
  47. package/dist/types/runtime/props.d.ts +21 -0
  48. package/dist/types/runtime/reactivity/computations.d.ts +34 -0
  49. package/dist/types/runtime/reactivity/computed.d.ts +6 -0
  50. package/dist/types/runtime/reactivity/effect.d.ts +1 -0
  51. package/dist/types/runtime/reactivity/proxy.d.ts +47 -0
  52. package/dist/types/runtime/reactivity/signal.d.ts +31 -0
  53. package/dist/types/runtime/reactivity.d.ts +57 -46
  54. package/dist/types/runtime/registry.d.ts +24 -15
  55. package/dist/types/runtime/rendering/error_handling.d.ts +13 -0
  56. package/dist/types/runtime/rendering/fibers.d.ts +37 -0
  57. package/dist/types/runtime/rendering/scheduler.d.ts +21 -0
  58. package/dist/types/runtime/rendering/template_helpers.d.ts +51 -0
  59. package/dist/types/runtime/resource.d.ts +18 -0
  60. package/dist/types/runtime/scheduler.d.ts +21 -21
  61. package/dist/types/runtime/status.d.ts +11 -10
  62. package/dist/types/runtime/template_set.d.ts +36 -40
  63. package/dist/types/runtime/types.d.ts +70 -0
  64. package/dist/types/runtime/utils.d.ts +24 -25
  65. package/dist/types/runtime/validation.d.ts +19 -36
  66. package/dist/types/version.d.ts +1 -1
  67. package/package.json +45 -19
  68. package/dist/types/runtime/cancellableContext.d.ts +0 -15
  69. package/dist/types/runtime/cancellablePromise.d.ts +0 -15
  70. package/dist/types/runtime/executionContext.d.ts +0 -0
  71. package/dist/types/runtime/listOperation.d.ts +0 -1
  72. package/dist/types/runtime/plugins.d.ts +0 -39
  73. package/dist/types/runtime/relationalModel/discussModel.d.ts +0 -19
  74. package/dist/types/runtime/relationalModel/discussModelTypes.d.ts +0 -22
  75. package/dist/types/runtime/relationalModel/field.d.ts +0 -20
  76. package/dist/types/runtime/relationalModel/model.d.ts +0 -59
  77. package/dist/types/runtime/relationalModel/modelData.d.ts +0 -18
  78. package/dist/types/runtime/relationalModel/modelRegistry.d.ts +0 -3
  79. package/dist/types/runtime/relationalModel/modelUtils.d.ts +0 -4
  80. package/dist/types/runtime/relationalModel/store.d.ts +0 -16
  81. package/dist/types/runtime/relationalModel/types.d.ts +0 -83
  82. package/dist/types/runtime/relationalModel/util.d.ts +0 -1
  83. package/dist/types/runtime/relationalModel/web/WebDataPoint.d.ts +0 -25
  84. package/dist/types/runtime/relationalModel/web/WebRecord.d.ts +0 -131
  85. package/dist/types/runtime/relationalModel/web/WebStaticList.d.ts +0 -63
  86. package/dist/types/runtime/relationalModel/web/webModel.d.ts +0 -5
  87. package/dist/types/runtime/relationalModel/web/webModelTypes.d.ts +0 -139
  88. package/dist/types/runtime/signals.d.ts +0 -17
  89. package/dist/types/runtime/task.d.ts +0 -12
  90. package/dist/types/utils/registry.d.ts +0 -15
@@ -1,83 +1,59 @@
1
- import { Computation } from "../common/types";
2
- import type { App, Env } from "./app";
3
- import { BDom, VNode } from "./blockdom";
4
- import { Component, ComponentConstructor, Props } from "./component";
5
- import { Fiber, MountFiber, MountOptions } from "./fibers";
6
- import { PluginManager } from "./plugins";
7
- import { STATUS } from "./status";
8
- export declare function saveCurrent(): () => void;
9
- export declare function getCurrent(): ComponentNode;
10
- export declare function useComponent(): Component;
11
- /**
12
- * Creates a reactive object that will be observed by the current component.
13
- * Reading data from the returned object (eg during rendering) will cause the
14
- * component to subscribe to that data and be rerendered when it changes.
15
- *
16
- * @param state the state to observe
17
- * @returns a reactive object that will cause the component to re-render on
18
- * relevant changes
19
- * @see reactive
20
- */
21
- export declare function useState<T extends object>(state: T): T;
22
- declare type LifecycleHook = Function;
23
- export declare class ComponentNode<P extends Props = any, Plugins = any, E = any> implements VNode<ComponentNode<P, E>> {
24
- el?: HTMLElement | Text | undefined;
25
- app: App;
26
- fiber: Fiber | null;
27
- component: Component<P, Plugins, E>;
28
- bdom: BDom | null;
29
- status: STATUS;
30
- forceNextRender: boolean;
31
- parentKey: string | null;
32
- props: P;
33
- nextProps: P | null;
34
- renderFn: Function;
35
- parent: ComponentNode | null;
36
- childEnv: Env;
37
- children: {
38
- [key: string]: ComponentNode;
39
- };
40
- refs: any;
41
- willStart: LifecycleHook[];
42
- willUpdateProps: LifecycleHook[];
43
- willUnmount: LifecycleHook[];
44
- mounted: LifecycleHook[];
45
- willPatch: LifecycleHook[];
46
- patched: LifecycleHook[];
47
- willDestroy: LifecycleHook[];
48
- signalComputation: Computation;
49
- pluginManager: PluginManager;
50
- constructor(C: ComponentConstructor<P, Plugins, E>, props: P, app: App, parent: ComponentNode | null, parentKey: string | null);
51
- mountComponent(target: any, options?: MountOptions): void;
52
- initiateRender(fiber: Fiber | MountFiber): Promise<void>;
53
- render(deep: boolean): Promise<void>;
54
- cancel(): void;
55
- _cancel(): void;
56
- destroy(): void;
57
- _destroy(): void;
58
- updateAndRender(props: P, parentFiber: Fiber): Promise<void>;
59
- /**
60
- * Finds a child that has dom that is not yet updated, and update it. This
61
- * method is meant to be used only in the context of repatching the dom after
62
- * a mounted hook failed and was handled.
63
- */
64
- updateDom(): void;
65
- /**
66
- * Sets a ref to a given HTMLElement.
67
- *
68
- * @param name the name of the ref to set
69
- * @param el the HTMLElement to set the ref to. The ref is not set if the el
70
- * is null, but useRef will not return elements that are not in the DOM
71
- */
72
- setRef(name: string, el: HTMLElement | null): void;
73
- firstNode(): Node | undefined;
74
- mount(parent: HTMLElement, anchor: ChildNode): void;
75
- moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
76
- moveBeforeVNode(other: ComponentNode<P, E> | null, afterNode: Node | null): void;
77
- patch(): void;
78
- _patch(): void;
79
- beforeRemove(): void;
80
- remove(): void;
81
- get name(): string;
82
- }
83
- export {};
1
+ import type { App } from "./app";
2
+ import { BDom, VNode } from "./blockdom";
3
+ import { Component, ComponentConstructor } from "./component";
4
+ import { PluginManager } from "./plugin_manager";
5
+ import { ComputationAtom } from "./reactivity/computations";
6
+ import { Fiber, MountFiber, MountOptions } from "./rendering/fibers";
7
+ import { STATUS } from "./status";
8
+ type LifecycleHook = Function;
9
+ export declare class ComponentNode implements VNode<ComponentNode> {
10
+ el?: HTMLElement | Text | undefined;
11
+ app: App;
12
+ fiber: Fiber | null;
13
+ component: Component;
14
+ bdom: BDom | null;
15
+ status: STATUS;
16
+ forceNextRender: boolean;
17
+ parentKey: string | null;
18
+ props: Record<string, any>;
19
+ defaultProps: Record<string, any>;
20
+ renderFn: Function;
21
+ parent: ComponentNode | null;
22
+ children: {
23
+ [key: string]: ComponentNode;
24
+ };
25
+ willStart: LifecycleHook[];
26
+ willUpdateProps: LifecycleHook[];
27
+ willUnmount: LifecycleHook[];
28
+ mounted: LifecycleHook[];
29
+ willPatch: LifecycleHook[];
30
+ patched: LifecycleHook[];
31
+ willDestroy: LifecycleHook[];
32
+ signalComputation: ComputationAtom;
33
+ computations: ComputationAtom[];
34
+ pluginManager: PluginManager;
35
+ constructor(C: ComponentConstructor, props: Record<string, any>, app: App, parent: ComponentNode | null, parentKey: string | null);
36
+ mountComponent(target: any, options?: MountOptions): void;
37
+ initiateRender(fiber: Fiber | MountFiber): Promise<void>;
38
+ render(deep: boolean): Promise<void>;
39
+ cancel(): void;
40
+ _cancel(): void;
41
+ destroy(): void;
42
+ _destroy(): void;
43
+ updateAndRender(props: Record<string, any>, parentFiber: Fiber): Promise<void>;
44
+ /**
45
+ * Finds a child that has dom that is not yet updated, and update it. This
46
+ * method is meant to be used only in the context of repatching the dom after
47
+ * a mounted hook failed and was handled.
48
+ */
49
+ updateDom(): void;
50
+ firstNode(): Node | undefined;
51
+ mount(parent: HTMLElement, anchor: ChildNode): void;
52
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
53
+ moveBeforeVNode(other: ComponentNode | null, afterNode: Node | null): void;
54
+ patch(): void;
55
+ _patch(): void;
56
+ beforeRemove(): void;
57
+ remove(): void;
58
+ }
59
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { App } from "./app";
2
+ import { type ComponentNode } from "./component_node";
3
+ import { PluginManager } from "./plugin_manager";
4
+ import { STATUS } from "./status";
5
+ interface ComponentContext {
6
+ type: "component";
7
+ app: App;
8
+ componentName: string;
9
+ node: ComponentNode;
10
+ status: STATUS;
11
+ }
12
+ interface PluginContext {
13
+ type: "plugin";
14
+ app: App;
15
+ manager: PluginManager;
16
+ status: STATUS;
17
+ }
18
+ type Contexts = {
19
+ plugin: PluginContext;
20
+ component: ComponentContext;
21
+ };
22
+ type Context = Contexts[keyof Contexts];
23
+ export declare let contextStack: Context[];
24
+ export declare function saveContext(): () => void;
25
+ export declare function getContext<K extends keyof Contexts>(type?: K): K extends string ? Contexts[K] : Context;
26
+ export interface CapturedContext {
27
+ run<T = void>(callback: () => T): T;
28
+ protectAsync<P extends any[], R>(callback: (...args: P) => Promise<R>): (...args: P) => Promise<R>;
29
+ runWithAsyncProtection<T>(callback: () => Promise<T>): Promise<T>;
30
+ }
31
+ /**
32
+ * Captures the current context and gives methods to run
33
+ * functions within the captured context.
34
+ */
35
+ export declare function useContext(): CapturedContext;
36
+ export {};
@@ -1,13 +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 {};
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
+ type ErrorParams = {
6
+ error: any;
7
+ } & ({
8
+ node: ComponentNode;
9
+ } | {
10
+ fiber: Fiber;
11
+ });
12
+ export declare function handleError(params: ErrorParams): void;
13
+ export {};
@@ -1 +1 @@
1
- export declare const mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null | undefined) => boolean;
1
+ export declare const mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null) => boolean;
@@ -1,37 +1,37 @@
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
- childrenMap: ComponentNode["children"];
14
- constructor(node: ComponentNode, parent: Fiber | null);
15
- render(): void;
16
- _render(): void;
17
- }
18
- export declare class RootFiber extends Fiber {
19
- counter: number;
20
- willPatch: Fiber[];
21
- patched: Fiber[];
22
- mounted: Fiber[];
23
- locked: boolean;
24
- complete(): void;
25
- setCounter(newValue: number): void;
26
- }
27
- declare type Position = "first-child" | "last-child";
28
- export interface MountOptions {
29
- position?: Position;
30
- }
31
- export declare class MountFiber extends RootFiber {
32
- target: HTMLElement;
33
- position: Position;
34
- constructor(node: ComponentNode, target: HTMLElement, options?: MountOptions);
35
- complete(): void;
36
- }
37
- export {};
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
+ childrenMap: ComponentNode["children"];
14
+ constructor(node: ComponentNode, parent: Fiber | null);
15
+ render(): void;
16
+ _render(): void;
17
+ }
18
+ export declare class RootFiber extends Fiber {
19
+ counter: number;
20
+ willPatch: Fiber[];
21
+ patched: Fiber[];
22
+ mounted: Fiber[];
23
+ locked: boolean;
24
+ complete(): void;
25
+ setCounter(newValue: number): void;
26
+ }
27
+ type Position = "first-child" | "last-child";
28
+ export interface MountOptions {
29
+ position?: Position;
30
+ }
31
+ export declare class MountFiber extends RootFiber {
32
+ target: HTMLElement;
33
+ position: Position;
34
+ constructor(node: ComponentNode, target: HTMLElement, options?: MountOptions);
35
+ complete(): void;
36
+ }
37
+ export {};
@@ -1,57 +1,32 @@
1
- import type { Env } from "./app";
2
- /**
3
- * The purpose of this hook is to allow components to get a reference to a sub
4
- * html node or component.
5
- */
6
- export declare function useRef<T extends HTMLElement = HTMLElement>(name: string): {
7
- el: T | null;
8
- };
9
- /**
10
- * This hook is useful as a building block for some customized hooks, that may
11
- * need a reference to the env of the component calling them.
12
- */
13
- export declare function useEnv<E extends Env>(): E;
14
- /**
15
- * This hook is a simple way to let components use a sub environment. Note that
16
- * like for all hooks, it is important that this is only called in the
17
- * constructor method.
18
- */
19
- export declare function useSubEnv(envExtension: Env): void;
20
- export declare function useChildSubEnv(envExtension: Env): void;
21
- declare type EffectDeps<T extends unknown[]> = T | (T extends [...infer H, never] ? EffectDeps<H> : never);
22
- /**
23
- * @template T
24
- * @param {...T} dependencies the dependencies computed by computeDependencies
25
- * @returns {void|(()=>void)} a cleanup function that reverses the side
26
- * effects of the effect callback.
27
- */
28
- declare type Effect<T extends unknown[]> = (...dependencies: EffectDeps<T>) => void | (() => void);
29
- /**
30
- * This hook will run a callback when a component is mounted and patched, and
31
- * will run a cleanup function before patching and before unmounting the
32
- * the component.
33
- *
34
- * @template T
35
- * @param {Effect<T>} effect the effect to run on component mount and/or patch
36
- * @param {()=>[...T]} [computeDependencies=()=>[NaN]] a callback to compute
37
- * dependencies that will decide if the effect needs to be cleaned up and
38
- * run again. If the dependencies did not change, the effect will not run
39
- * again. The default value returns an array containing only NaN because
40
- * NaN !== NaN, which will cause the effect to rerun on every patch.
41
- */
42
- export declare function useEffect<T extends unknown[]>(effect: Effect<T>, computeDependencies?: () => [...T]): void;
43
- /**
44
- * When a component needs to listen to DOM Events on element(s) that are not
45
- * part of his hierarchy, we can use the `useExternalListener` hook.
46
- * It will correctly add and remove the event listener, whenever the
47
- * component is mounted and unmounted.
48
- *
49
- * Example:
50
- * a menu needs to listen to the click on window to be closed automatically
51
- *
52
- * Usage:
53
- * in the constructor of the OWL component that needs to be notified,
54
- * `useExternalListener(window, 'click', this._doSomething);`
55
- * */
56
- export declare function useExternalListener(target: EventTarget, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
57
- export {};
1
+ import { App } from "./app";
2
+ import { effect } from "./reactivity/effect";
3
+ import { Signal } from "./reactivity/signal";
4
+ /**
5
+ * This hook will run a callback when a component is mounted and patched, and
6
+ * will run a cleanup function before patching and before unmounting the
7
+ * the component.
8
+ *
9
+ * @template T
10
+ * @param {Effect<T>} effect the effect to run on component mount and/or patch
11
+ * @param {()=>[...T]} [computeDependencies=()=>[NaN]] a callback to compute
12
+ * dependencies that will decide if the effect needs to be cleaned up and
13
+ * run again. If the dependencies did not change, the effect will not run
14
+ * again. The default value returns an array containing only NaN because
15
+ * NaN !== NaN, which will cause the effect to rerun on every patch.
16
+ */
17
+ export declare function useEffect(fn: Parameters<typeof effect>[0]): void;
18
+ /**
19
+ * When a component needs to listen to DOM Events on element(s) that are not
20
+ * part of his hierarchy, we can use the `useListener` hook.
21
+ * It will immediately add the listener, and remove it whenever the plugin or
22
+ * component is destroyed.
23
+ *
24
+ * Example:
25
+ * a menu needs to listen to the click on window to be closed automatically
26
+ *
27
+ * Usage:
28
+ * in the constructor of the OWL component that needs to be notified,
29
+ * `useListener(window, 'click', () => this._doSomething());`
30
+ * */
31
+ export declare function useListener(target: EventTarget | Signal<EventTarget | null>, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
32
+ export declare function useApp(): App;
@@ -1,35 +1,46 @@
1
- import { createBlock, html, list, mount as blockMount, multi, patch, remove, text, toggler, comment } from "./blockdom";
2
- export { Registry } from "./registry";
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;
18
- };
19
- export { App, mount } from "./app";
20
- export { xml } from "./template_set";
21
- export { Component } from "./component";
22
- export type { ComponentConstructor } from "./component";
23
- export { useComponent, useState } from "./component_node";
24
- export { status } from "./status";
25
- export { reactive, markRaw, toRaw } from "./reactivity";
26
- export { effect, withoutReactivity, derived, signal } from "./signals";
27
- export { useEffect, useEnv, useExternalListener, useRef, useChildSubEnv, useSubEnv } from "./hooks";
28
- export { batched, EventBus, htmlEscape, whenReady, loadFile, markup } from "./utils";
29
- export { onWillStart, onMounted, onWillUnmount, onWillUpdateProps, onWillPatch, onPatched, onWillRender, onRendered, onWillDestroy, onError, } from "./lifecycle_hooks";
30
- export { validate, validateType } from "./validation";
31
- export { OwlError } from "../common/owl_error";
32
- export declare const __info__: {
33
- version: string;
34
- };
35
- export { Plugin, PluginManager, usePlugins } from "./plugins";
1
+ import { createBlock, html, list, mount as blockMount, multi, patch, remove, text, toggler, comment } from "./blockdom";
2
+ export { Resource, useResource } from "./resource";
3
+ export { Registry } from "./registry";
4
+ export declare const blockDom: {
5
+ config: {
6
+ shouldNormalizeDom: boolean;
7
+ mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null) => boolean;
8
+ };
9
+ mount: typeof blockMount;
10
+ patch: typeof patch;
11
+ remove: typeof remove;
12
+ list: typeof list;
13
+ multi: typeof multi;
14
+ text: typeof text;
15
+ toggler: typeof toggler;
16
+ createBlock: typeof createBlock;
17
+ html: typeof html;
18
+ comment: typeof comment;
19
+ };
20
+ export { App, mount } from "./app";
21
+ export { xml } from "./template_set";
22
+ export { Component } from "./component";
23
+ export type { ComponentConstructor } from "./component";
24
+ export { props } from "./props";
25
+ export type { GetProps } from "./props";
26
+ export { status } from "./status";
27
+ export { proxy, markRaw, toRaw } from "./reactivity/proxy";
28
+ export { untrack, type ReactiveValue } from "./reactivity/computations";
29
+ export { signal, type Signal } from "./reactivity/signal";
30
+ export { computed } from "./reactivity/computed";
31
+ export { effect } from "./reactivity/effect";
32
+ export { useEffect, useListener, useApp } from "./hooks";
33
+ export { batched, EventBus, htmlEscape, whenReady, markup } from "./utils";
34
+ export { onWillStart, onMounted, onWillUnmount, onWillUpdateProps, onWillPatch, onPatched, onWillDestroy, onError, } from "./lifecycle_hooks";
35
+ export { assertType, validateType } from "./validation";
36
+ export { types } from "./types";
37
+ export { OwlError } from "../common/owl_error";
38
+ export { config, plugin, providePlugins } from "./plugin_hooks";
39
+ export type { PluginInstance } from "./plugin_hooks";
40
+ export { Plugin } from "./plugin_manager";
41
+ export type { PluginConstructor } from "./plugin_manager";
42
+ export { useContext } from "./context";
43
+ export type { CapturedContext } from "./context";
44
+ export declare const __info__: {
45
+ version: string;
46
+ };
@@ -1,12 +1,10 @@
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: () => any | void): void;
5
- export declare function onPatched(fn: () => void | any): void;
6
- export declare function onWillUnmount(fn: () => void | any): void;
7
- export declare function onWillDestroy(fn: () => 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
+ 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: () => any | void): void;
5
+ export declare function onPatched(fn: () => void | any): void;
6
+ export declare function onWillUnmount(fn: () => void | any): void;
7
+ export declare function onWillDestroy(fn: () => void | any): void;
8
+ type OnErrorCallback = (error: any) => void | any;
9
+ export declare function onError(callback: OnErrorCallback): void;
10
+ export {};
@@ -0,0 +1,6 @@
1
+ import { PluginConstructor } from "./plugin_manager";
2
+ import { Resource } from "./resource";
3
+ export type PluginInstance<T extends PluginConstructor> = Omit<InstanceType<T>, "setup">;
4
+ export declare function plugin<T extends PluginConstructor>(pluginType: T): PluginInstance<T>;
5
+ export declare function config<T = any>(name: string, type?: T): T;
6
+ export declare function providePlugins(pluginConstructors: PluginConstructor[] | Resource<PluginConstructor>, config?: Record<string, any>): void;
@@ -0,0 +1,36 @@
1
+ import { App } from "./app";
2
+ import { ComputationAtom } from "./reactivity/computations";
3
+ import { Resource } from "./resource";
4
+ import { STATUS } from "./status";
5
+ export interface PluginConstructor {
6
+ new (...args: any[]): Plugin;
7
+ id: string;
8
+ }
9
+ export declare class Plugin {
10
+ private static _shadowId;
11
+ static get id(): string;
12
+ static set id(shadowId: string);
13
+ __owl__: PluginManager;
14
+ constructor(manager: PluginManager);
15
+ setup(): void;
16
+ }
17
+ interface PluginManagerOptions {
18
+ parent?: PluginManager | null;
19
+ config?: Record<string, any>;
20
+ }
21
+ export declare class PluginManager {
22
+ app: App;
23
+ config: Record<string, any>;
24
+ onDestroyCb: Function[];
25
+ computations: ComputationAtom[];
26
+ plugins: Record<string, Plugin>;
27
+ status: STATUS;
28
+ constructor(app: App, options?: PluginManagerOptions);
29
+ destroy(): void;
30
+ getPluginById<T extends Plugin>(id: string): T | null;
31
+ getPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
32
+ startPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
33
+ startPlugins(pluginConstructors: PluginConstructor[]): void;
34
+ }
35
+ export declare function startPlugins(manager: PluginManager, plugins: PluginConstructor[] | Resource<PluginConstructor>): void;
36
+ export {};
@@ -0,0 +1,21 @@
1
+ import { GetOptionalEntries, KeyedObject, PrettifyShape, ResolveObjectType } from "./types";
2
+ declare const isProps: unique symbol;
3
+ export type WithDefaults<T, D> = T & Required<D>;
4
+ export type Props<T extends {}> = T & {
5
+ [isProps]: true;
6
+ };
7
+ type GetPropsDefaults<T extends object> = PrettifyShape<GetOptionalEntries<T>>;
8
+ type GetPropsWithOptionals<T> = T extends Props<infer P> ? (P extends WithDefaults<infer R, any> ? R : P) : never;
9
+ export type GetProps<T> = {
10
+ [K in keyof T]: T[K] extends {
11
+ [isProps]: true;
12
+ } ? (x: GetPropsWithOptionals<T[K]>) => void : never;
13
+ }[keyof T] extends (x: infer I) => void ? {
14
+ [K in keyof I]: I[K];
15
+ } : never;
16
+ export declare function props(): Props<Record<string, any>>;
17
+ export declare function props<const Keys extends string[]>(keys: Keys): Props<ResolveObjectType<Keys>>;
18
+ export declare function props<const Keys extends string[], Defaults>(keys: Keys, defaults: Defaults & GetPropsDefaults<KeyedObject<Keys>>): Props<WithDefaults<ResolveObjectType<Keys>, Defaults>>;
19
+ export declare function props<Shape extends {}>(shape: Shape): Props<ResolveObjectType<Shape>>;
20
+ export declare function props<Shape extends {}, Defaults>(shape: Shape, defaults: Defaults & GetPropsDefaults<Shape>): Props<WithDefaults<ResolveObjectType<Shape>, Defaults>>;
21
+ export {};
@@ -0,0 +1,34 @@
1
+ export interface ReactiveValue<TRead, TWrite = TRead> {
2
+ (): TRead;
3
+ /**
4
+ * Update the value of the reactive with a new value. If the new value is different
5
+ * from the previous values, all computations that depends on this reactive will
6
+ * be invalidated, and effects will rerun.
7
+ */
8
+ set(nextValue: TWrite): void;
9
+ }
10
+ export declare enum ComputationState {
11
+ EXECUTED = 0,
12
+ STALE = 1,
13
+ PENDING = 2
14
+ }
15
+ export interface Atom<T = any> {
16
+ observers: Set<ComputationAtom>;
17
+ value: T;
18
+ }
19
+ export interface ComputationAtom<T = any> extends Atom<T> {
20
+ compute: () => T;
21
+ isDerived: boolean;
22
+ sources: Set<Atom>;
23
+ state: ComputationState;
24
+ }
25
+ export declare const atomSymbol: unique symbol;
26
+ export declare function createComputation(compute: () => any, isDerived: boolean, state?: ComputationState): ComputationAtom;
27
+ export declare function onReadAtom(atom: Atom): void;
28
+ export declare function onWriteAtom(atom: Atom): void;
29
+ export declare function getCurrentComputation(): ComputationAtom<any> | undefined;
30
+ export declare function setComputation(computation: ComputationAtom | undefined): void;
31
+ export declare function updateComputation(computation: ComputationAtom): void;
32
+ export declare function removeSources(computation: ComputationAtom): void;
33
+ export declare function disposeComputation(computation: ComputationAtom): void;
34
+ export declare function untrack<T>(fn: (...args: any[]) => T): T;
@@ -0,0 +1,6 @@
1
+ import { ReactiveValue } from "./computations";
2
+ interface ComputedOptions<TWrite> {
3
+ set?(value: TWrite): void;
4
+ }
5
+ export declare function computed<TRead, TWrite = TRead>(getter: () => TRead, options?: ComputedOptions<TWrite>): ReactiveValue<TRead, TWrite>;
6
+ export {};
@@ -0,0 +1 @@
1
+ export declare function effect<T>(fn: () => T): () => void;