@odoo/owl 2.8.1 → 3.0.0-alpha.10

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 (73) hide show
  1. package/dist/compile_templates.mjs +92 -189
  2. package/dist/compiler.js +2378 -0
  3. package/dist/owl-devtools.zip +0 -0
  4. package/dist/owl.cjs.js +1371 -1261
  5. package/dist/owl.cjs.runtime.js +4094 -0
  6. package/dist/owl.es.js +1358 -1252
  7. package/dist/owl.es.runtime.js +4050 -0
  8. package/dist/owl.iife.js +1371 -1261
  9. package/dist/owl.iife.min.js +1 -1
  10. package/dist/owl.iife.runtime.js +4098 -0
  11. package/dist/owl.iife.runtime.min.js +1 -0
  12. package/dist/types/compiler/code_generator.d.ts +3 -5
  13. package/dist/types/compiler/index.d.ts +4 -4
  14. package/dist/types/compiler/inline_expressions.d.ts +1 -1
  15. package/dist/types/compiler/parser.d.ts +21 -28
  16. package/dist/types/owl.d.ts +299 -205
  17. package/dist/types/runtime/app.d.ts +29 -31
  18. package/dist/types/runtime/blockdom/block_compiler.d.ts +3 -3
  19. package/dist/types/runtime/blockdom/config.d.ts +1 -1
  20. package/dist/types/runtime/blockdom/event_catcher.d.ts +2 -2
  21. package/dist/types/runtime/blockdom/events.d.ts +1 -1
  22. package/dist/types/runtime/blockdom/index.d.ts +1 -1
  23. package/dist/types/runtime/cancellableContext.d.ts +15 -0
  24. package/dist/types/runtime/cancellablePromise.d.ts +15 -0
  25. package/dist/types/runtime/component.d.ts +5 -13
  26. package/dist/types/runtime/component_node.d.ts +15 -35
  27. package/dist/types/runtime/event_handling.d.ts +1 -1
  28. package/dist/types/runtime/executionContext.d.ts +0 -0
  29. package/dist/types/runtime/hooks.d.ts +7 -33
  30. package/dist/types/runtime/index.d.ts +15 -5
  31. package/dist/types/runtime/lifecycle_hooks.d.ts +1 -3
  32. package/dist/types/runtime/listOperation.d.ts +1 -0
  33. package/dist/types/runtime/plugins.d.ts +23 -0
  34. package/dist/types/runtime/portal.d.ts +4 -6
  35. package/dist/types/runtime/props.d.ts +65 -0
  36. package/dist/types/runtime/reactivity/computations.d.ts +31 -0
  37. package/dist/types/runtime/reactivity/computed.d.ts +7 -0
  38. package/dist/types/runtime/reactivity/derived.d.ts +7 -0
  39. package/dist/types/runtime/reactivity/effect.d.ts +2 -0
  40. package/dist/types/runtime/reactivity/proxy.d.ts +46 -0
  41. package/dist/types/runtime/reactivity/reactivity.d.ts +46 -0
  42. package/dist/types/runtime/reactivity/signal.d.ts +17 -0
  43. package/dist/types/runtime/reactivity/signals.d.ts +30 -0
  44. package/dist/types/runtime/registry.d.ts +19 -0
  45. package/dist/types/runtime/relationalModel/discussModel.d.ts +19 -0
  46. package/dist/types/runtime/relationalModel/discussModelTypes.d.ts +22 -0
  47. package/dist/types/runtime/relationalModel/field.d.ts +20 -0
  48. package/dist/types/runtime/relationalModel/model.d.ts +59 -0
  49. package/dist/types/runtime/relationalModel/modelData.d.ts +18 -0
  50. package/dist/types/runtime/relationalModel/modelRegistry.d.ts +3 -0
  51. package/dist/types/runtime/relationalModel/modelUtils.d.ts +4 -0
  52. package/dist/types/runtime/relationalModel/store.d.ts +16 -0
  53. package/dist/types/runtime/relationalModel/types.d.ts +83 -0
  54. package/dist/types/runtime/relationalModel/util.d.ts +1 -0
  55. package/dist/types/runtime/relationalModel/web/WebDataPoint.d.ts +25 -0
  56. package/dist/types/runtime/relationalModel/web/WebRecord.d.ts +131 -0
  57. package/dist/types/runtime/relationalModel/web/WebStaticList.d.ts +63 -0
  58. package/dist/types/runtime/relationalModel/web/webModel.d.ts +5 -0
  59. package/dist/types/runtime/relationalModel/web/webModelTypes.d.ts +139 -0
  60. package/dist/types/runtime/rendering/error_handling.d.ts +13 -0
  61. package/dist/types/runtime/rendering/fibers.d.ts +37 -0
  62. package/dist/types/runtime/rendering/scheduler.d.ts +21 -0
  63. package/dist/types/runtime/rendering/template_helpers.d.ts +50 -0
  64. package/dist/types/runtime/resource.d.ts +12 -0
  65. package/dist/types/runtime/signals.d.ts +19 -0
  66. package/dist/types/runtime/status.d.ts +2 -3
  67. package/dist/types/runtime/task.d.ts +12 -0
  68. package/dist/types/runtime/template_set.d.ts +3 -4
  69. package/dist/types/runtime/utils.d.ts +1 -2
  70. package/dist/types/runtime/validation.d.ts +6 -6
  71. package/dist/types/utils/registry.d.ts +15 -0
  72. package/dist/types/version.d.ts +1 -1
  73. package/package.json +9 -9
@@ -1,22 +1,23 @@
1
- import { Component, ComponentConstructor, Props } from "./component";
1
+ import { ComponentConstructor } from "./component";
2
2
  import { ComponentNode } from "./component_node";
3
- import { handleError } from "./error_handling";
4
- import { Fiber, RootFiber, MountOptions } from "./fibers";
5
- import { Scheduler } from "./scheduler";
3
+ import { handleError } from "./rendering/error_handling";
4
+ import { Fiber, MountOptions, RootFiber } from "./rendering/fibers";
5
+ import { Plugin, PluginManager } from "./plugins";
6
+ import { proxy, toRaw } from "./reactivity/proxy";
7
+ import { Scheduler } from "./rendering/scheduler";
6
8
  import { TemplateSet, TemplateSetConfig } from "./template_set";
7
9
  import { validateTarget } from "./utils";
8
- import { toRaw, reactive } from "./reactivity";
9
- export interface Env {
10
- [key: string]: any;
11
- }
12
- export interface RootConfig<P, E> {
10
+ import { GetProps } from "./props";
11
+ type ComponentInstance<C extends ComponentConstructor> = C extends new (...args: any) => infer T ? T : never;
12
+ interface RootConfig<P> {
13
+ pluginManager?: PluginManager;
13
14
  props?: P;
14
- env?: E;
15
15
  }
16
- export interface AppConfig<P, E> extends TemplateSetConfig, RootConfig<P, E> {
16
+ export interface AppConfig extends TemplateSetConfig {
17
17
  name?: string;
18
+ plugins?: (typeof Plugin)[];
19
+ pluginManager?: PluginManager;
18
20
  test?: boolean;
19
- warnIfNoStaticProps?: boolean;
20
21
  }
21
22
  declare global {
22
23
  interface Window {
@@ -25,35 +26,32 @@ declare global {
25
26
  Fiber: typeof Fiber;
26
27
  RootFiber: typeof RootFiber;
27
28
  toRaw: typeof toRaw;
28
- reactive: typeof reactive;
29
+ proxy: typeof proxy;
29
30
  };
30
31
  }
31
32
  }
32
- interface Root<P extends Props, E> {
33
- node: ComponentNode<P, E>;
34
- mount(target: HTMLElement | ShadowRoot, options?: MountOptions): Promise<Component<P, E>>;
33
+ type MountTarget = HTMLElement | ShadowRoot;
34
+ interface Root<T extends ComponentConstructor> {
35
+ node: ComponentNode;
36
+ promise: Promise<ComponentInstance<T>>;
37
+ mount(target: MountTarget, options?: MountOptions): Promise<ComponentInstance<T>>;
35
38
  destroy(): void;
36
39
  }
37
- export declare class App<T extends abstract new (...args: any) => any = any, P extends object = any, E = any> extends TemplateSet {
40
+ export declare class App extends TemplateSet {
38
41
  static validateTarget: typeof validateTarget;
39
- static apps: Set<App<any, any, any>>;
42
+ static apps: Set<App>;
40
43
  static version: string;
41
44
  name: string;
42
- Root: ComponentConstructor<P, E>;
43
- props: P;
44
- env: E;
45
45
  scheduler: Scheduler;
46
- subRoots: Set<ComponentNode>;
47
- root: ComponentNode<P, E> | null;
48
- warnIfNoStaticProps: boolean;
49
- constructor(Root: ComponentConstructor<P, E>, config?: AppConfig<P, E>);
50
- mount(target: HTMLElement | ShadowRoot, options?: MountOptions): Promise<Component<P, E> & InstanceType<T>>;
51
- createRoot<Props extends object, SubEnv = any>(Root: ComponentConstructor<Props, E>, config?: RootConfig<Props, SubEnv>): Root<Props, SubEnv>;
52
- makeNode(Component: ComponentConstructor, props: any): ComponentNode;
53
- mountNode(node: ComponentNode, target: HTMLElement | ShadowRoot, options?: MountOptions): any;
46
+ roots: Set<Root<any>>;
47
+ pluginManager: PluginManager;
48
+ constructor(config?: AppConfig);
49
+ createRoot<T extends ComponentConstructor>(Root: T, config?: RootConfig<GetProps<ComponentInstance<T>>>): Root<T>;
50
+ makeNode<T extends ComponentConstructor>(Component: T, props: GetProps<ComponentInstance<T>>): ComponentNode;
51
+ mountNode(node: ComponentNode, target: HTMLElement | ShadowRoot, resolve: (c: any) => void, reject: (e: any) => void, options?: MountOptions): void;
54
52
  destroy(): void;
55
- createComponent<P extends Props>(name: string | null, isStatic: boolean, hasSlotsProp: boolean, hasDynamicPropList: boolean, propList: string[]): (props: P, key: string, ctx: ComponentNode, parent: any, C: any) => any;
53
+ createComponent<P extends Record<string, any>>(name: string | null, isStatic: boolean, hasSlotsProp: boolean, hasDynamicPropList: boolean, propList: string[]): (props: P, key: string, ctx: ComponentNode, parent: any, C: any) => any;
56
54
  handleError(...args: Parameters<typeof handleError>): void;
57
55
  }
58
- export declare function mount<T extends abstract new (...args: any) => any = any, P extends object = any, E = any>(C: T & ComponentConstructor<P, E>, target: HTMLElement, config?: AppConfig<P, E> & MountOptions): Promise<Component<P, E> & InstanceType<T>>;
56
+ export declare function mount<T extends ComponentConstructor>(C: T, target: MountTarget, config?: AppConfig & RootConfig<GetProps<ComponentInstance<T>>> & MountOptions): Promise<ComponentInstance<T>>;
59
57
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { VNode } from "./index";
2
- declare type BlockType = (data?: any[], children?: VNode[]) => VNode;
2
+ type BlockType = (data?: any[], children?: VNode[]) => VNode;
3
3
  /**
4
4
  * Compiling blocks is a multi-step process:
5
5
  *
@@ -16,6 +16,6 @@ declare type BlockType = (data?: any[], children?: VNode[]) => VNode;
16
16
  * @returns a new block type, that can build concrete blocks
17
17
  */
18
18
  export declare function createBlock(str: string): BlockType;
19
- export declare type Setter<T = any> = (this: T, value: any) => void;
20
- export declare type Updater<T = any> = (this: T, value: any, oldVal: any) => void;
19
+ export type Setter<T = any> = (this: T, value: any) => void;
20
+ export type Updater<T = any> = (this: T, value: any, oldVal: any) => void;
21
21
  export {};
@@ -4,5 +4,5 @@ export declare function filterOutModifiersFromData(dataList: any[]): {
4
4
  };
5
5
  export declare const config: {
6
6
  shouldNormalizeDom: boolean;
7
- mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null | undefined) => boolean;
7
+ mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null) => boolean;
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import type { VNode } from "./index";
2
- declare type EventsSpec = {
2
+ type EventsSpec = {
3
3
  [name: string]: number;
4
4
  };
5
- declare type Catcher = (child: VNode, handlers: any[]) => VNode;
5
+ type Catcher = (child: VNode, handlers: any[]) => VNode;
6
6
  export declare function createCatcher(eventsSpec: EventsSpec): Catcher;
7
7
  export {};
@@ -1,4 +1,4 @@
1
- declare type EventHandlerSetter = (this: HTMLElement, data: any) => void;
1
+ type EventHandlerSetter = (this: HTMLElement, data: any) => void;
2
2
  interface EventHandlerCreator {
3
3
  setup: EventHandlerSetter;
4
4
  update: EventHandlerSetter;
@@ -19,7 +19,7 @@ export interface VNode<T = any> {
19
19
  isOnlyChild?: boolean | undefined;
20
20
  key?: any;
21
21
  }
22
- export declare type BDom = VNode<any>;
22
+ export type BDom = VNode<any>;
23
23
  export declare function mount(vnode: VNode, fixture: HTMLElement, afterNode?: Node | null): void;
24
24
  export declare function patch(vnode1: VNode, vnode2: VNode, withBeforeRemove?: boolean): void;
25
25
  export declare function remove(vnode: VNode, withBeforeRemove?: boolean): void;
@@ -0,0 +1,15 @@
1
+ export declare type TaskContext = {
2
+ isCancelled: boolean;
3
+ cancel: () => void;
4
+ meta: Record<string, any>;
5
+ };
6
+ export declare const taskContextStack: TaskContext[];
7
+ export declare function getTaskContext(): TaskContext;
8
+ export declare function makeTaskContext(): TaskContext;
9
+ export declare function useTaskContext(ctx?: TaskContext): {
10
+ ctx: TaskContext;
11
+ cleanup: () => void;
12
+ };
13
+ export declare function pushTaskContext(context: TaskContext): void;
14
+ export declare function popTaskContext(): void;
15
+ export declare function taskEffect(fn: Function): TaskContext;
@@ -0,0 +1,15 @@
1
+ export declare type PromiseExecContext = {
2
+ cancelled: boolean;
3
+ };
4
+ export declare type CancellablePromise<T = any> = Promise<T> & {
5
+ execContext?: PromiseExecContext;
6
+ };
7
+ export declare const setCancellableContext: (ctx: PromiseExecContext | undefined) => PromiseExecContext | undefined;
8
+ export declare const resetCancellableContext: (ctx: PromiseExecContext | undefined) => void;
9
+ export declare const _exec: (execContext: PromiseExecContext | undefined, cb: Function, args: any[]) => any;
10
+ export declare function patchPromise(): void;
11
+ export declare function restorePromise(): void;
12
+ export declare function getCancellableTask(cb: Function): {
13
+ cancel: () => boolean;
14
+ readonly isCancel: boolean;
15
+ };
@@ -1,25 +1,17 @@
1
- import { Schema } from "./validation";
2
1
  import type { ComponentNode } from "./component_node";
3
- export declare type Props = {
4
- [key: string]: any;
5
- };
6
2
  interface StaticComponentProperties {
7
3
  template: string;
8
- defaultProps?: any;
9
- props?: Schema;
10
4
  components?: {
11
5
  [componentName: string]: ComponentConstructor;
12
6
  };
13
7
  }
14
- export declare type ComponentConstructor<P extends Props = any, E = any> = (new (props: P, env: E, node: ComponentNode) => Component<P, E>) & StaticComponentProperties;
15
- export declare class Component<Props = any, Env = any> {
8
+ export interface ComponentConstructor extends StaticComponentProperties {
9
+ new (node: ComponentNode): Component;
10
+ }
11
+ export declare class Component {
16
12
  static template: string;
17
- static props?: Schema;
18
- static defaultProps?: any;
19
- props: Props;
20
- env: Env;
21
13
  __owl__: ComponentNode;
22
- constructor(props: Props, env: Env, node: ComponentNode);
14
+ constructor(node: ComponentNode);
23
15
  setup(): void;
24
16
  render(deep?: boolean): void;
25
17
  }
@@ -1,42 +1,30 @@
1
- import type { App, Env } from "./app";
1
+ import type { App } from "./app";
2
2
  import { BDom, VNode } from "./blockdom";
3
- import { Component, ComponentConstructor, Props } from "./component";
4
- import { Fiber, MountFiber, MountOptions } from "./fibers";
5
- import { getSubscriptions } from "./reactivity";
3
+ import { Component, ComponentConstructor } from "./component";
4
+ import { PluginManager } from "./plugins";
5
+ import { Computation } from "./reactivity/computations";
6
+ import { Fiber, MountFiber, MountOptions } from "./rendering/fibers";
6
7
  import { STATUS } from "./status";
7
8
  export declare function saveCurrent(): () => void;
8
9
  export declare function getCurrent(): ComponentNode;
9
10
  export declare function useComponent(): Component;
10
- /**
11
- * Creates a reactive object that will be observed by the current component.
12
- * Reading data from the returned object (eg during rendering) will cause the
13
- * component to subscribe to that data and be rerendered when it changes.
14
- *
15
- * @param state the state to observe
16
- * @returns a reactive object that will cause the component to re-render on
17
- * relevant changes
18
- * @see reactive
19
- */
20
- export declare function useState<T extends object>(state: T): T;
21
- declare type LifecycleHook = Function;
22
- export declare class ComponentNode<P extends Props = any, E = any> implements VNode<ComponentNode<P, E>> {
11
+ type LifecycleHook = Function;
12
+ export declare class ComponentNode implements VNode<ComponentNode> {
23
13
  el?: HTMLElement | Text | undefined;
24
14
  app: App;
25
15
  fiber: Fiber | null;
26
- component: Component<P, E>;
16
+ component: Component;
27
17
  bdom: BDom | null;
28
18
  status: STATUS;
29
19
  forceNextRender: boolean;
30
20
  parentKey: string | null;
31
- props: P;
32
- nextProps: P | null;
21
+ name: string;
22
+ props: Record<string, any>;
33
23
  renderFn: Function;
34
24
  parent: ComponentNode | null;
35
- childEnv: Env;
36
25
  children: {
37
26
  [key: string]: ComponentNode;
38
27
  };
39
- refs: any;
40
28
  willStart: LifecycleHook[];
41
29
  willUpdateProps: LifecycleHook[];
42
30
  willUnmount: LifecycleHook[];
@@ -44,7 +32,9 @@ export declare class ComponentNode<P extends Props = any, E = any> implements VN
44
32
  willPatch: LifecycleHook[];
45
33
  patched: LifecycleHook[];
46
34
  willDestroy: LifecycleHook[];
47
- constructor(C: ComponentConstructor<P, E>, props: P, app: App, parent: ComponentNode | null, parentKey: string | null);
35
+ signalComputation: Computation;
36
+ pluginManager: PluginManager;
37
+ constructor(C: ComponentConstructor, props: Record<string, any>, app: App, parent: ComponentNode | null, parentKey: string | null);
48
38
  mountComponent(target: any, options?: MountOptions): void;
49
39
  initiateRender(fiber: Fiber | MountFiber): Promise<void>;
50
40
  render(deep: boolean): Promise<void>;
@@ -52,30 +42,20 @@ export declare class ComponentNode<P extends Props = any, E = any> implements VN
52
42
  _cancel(): void;
53
43
  destroy(): void;
54
44
  _destroy(): void;
55
- updateAndRender(props: P, parentFiber: Fiber): Promise<void>;
45
+ updateAndRender(props: Record<string, any>, parentFiber: Fiber): Promise<void>;
56
46
  /**
57
47
  * Finds a child that has dom that is not yet updated, and update it. This
58
48
  * method is meant to be used only in the context of repatching the dom after
59
49
  * a mounted hook failed and was handled.
60
50
  */
61
51
  updateDom(): void;
62
- /**
63
- * Sets a ref to a given HTMLElement.
64
- *
65
- * @param name the name of the ref to set
66
- * @param el the HTMLElement to set the ref to. The ref is not set if the el
67
- * is null, but useRef will not return elements that are not in the DOM
68
- */
69
- setRef(name: string, el: HTMLElement | null): void;
70
52
  firstNode(): Node | undefined;
71
53
  mount(parent: HTMLElement, anchor: ChildNode): void;
72
54
  moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
73
- moveBeforeVNode(other: ComponentNode<P, E> | null, afterNode: Node | null): void;
55
+ moveBeforeVNode(other: ComponentNode | null, afterNode: Node | null): void;
74
56
  patch(): void;
75
57
  _patch(): void;
76
58
  beforeRemove(): void;
77
59
  remove(): void;
78
- get name(): string;
79
- get subscriptions(): ReturnType<typeof getSubscriptions>;
80
60
  }
81
61
  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;
File without changes
@@ -1,31 +1,5 @@
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);
1
+ import { PluginConstructor } from "./plugins";
2
+ import { effect } from "./reactivity/effect";
29
3
  /**
30
4
  * This hook will run a callback when a component is mounted and patched, and
31
5
  * will run a cleanup function before patching and before unmounting the
@@ -39,10 +13,10 @@ declare type Effect<T extends unknown[]> = (...dependencies: EffectDeps<T>) => v
39
13
  * again. The default value returns an array containing only NaN because
40
14
  * NaN !== NaN, which will cause the effect to rerun on every patch.
41
15
  */
42
- export declare function useEffect<T extends unknown[]>(effect: Effect<T>, computeDependencies?: () => [...T]): void;
16
+ export declare function useEffect(fn: Parameters<typeof effect>[0]): void;
43
17
  /**
44
18
  * 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.
19
+ * part of his hierarchy, we can use the `useListener` hook.
46
20
  * It will correctly add and remove the event listener, whenever the
47
21
  * component is mounted and unmounted.
48
22
  *
@@ -51,7 +25,7 @@ export declare function useEffect<T extends unknown[]>(effect: Effect<T>, comput
51
25
  *
52
26
  * Usage:
53
27
  * in the constructor of the OWL component that needs to be notified,
54
- * `useExternalListener(window, 'click', this._doSomething);`
28
+ * `useListener(window, 'click', this._doSomething);`
55
29
  * */
56
- export declare function useExternalListener(target: EventTarget, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
57
- export {};
30
+ export declare function useListener(target: EventTarget, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
31
+ export declare function usePlugins(Plugins: PluginConstructor[]): import("./plugins").Plugin[];
@@ -1,4 +1,6 @@
1
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";
2
4
  export declare const blockDom: {
3
5
  config: {
4
6
  shouldNormalizeDom: boolean;
@@ -19,14 +21,22 @@ export { App, mount } from "./app";
19
21
  export { xml } from "./template_set";
20
22
  export { Component } from "./component";
21
23
  export type { ComponentConstructor } from "./component";
22
- export { useComponent, useState } from "./component_node";
24
+ export { useComponent } from "./component_node";
25
+ export { props } from "./props";
26
+ export type { GetProps, PropsValidation } from "./props";
23
27
  export { status } from "./status";
24
- export { reactive, markRaw, toRaw } from "./reactivity";
25
- export { useEffect, useEnv, useExternalListener, useRef, useChildSubEnv, useSubEnv } from "./hooks";
26
- export { batched, EventBus, htmlEscape, whenReady, loadFile, markup } from "./utils";
27
- export { onWillStart, onMounted, onWillUnmount, onWillUpdateProps, onWillPatch, onPatched, onWillRender, onRendered, onWillDestroy, onError, } from "./lifecycle_hooks";
28
+ export { proxy, markRaw, toRaw } from "./reactivity/proxy";
29
+ export { untrack } from "./reactivity/computations";
30
+ export { signal, ReactiveValue, Signal } from "./reactivity/signal";
31
+ export { computed } from "./reactivity/computed";
32
+ export { effect } from "./reactivity/effect";
33
+ export { useEffect, useListener, usePlugins } from "./hooks";
34
+ export { batched, EventBus, htmlEscape, whenReady, markup } from "./utils";
35
+ export { onWillStart, onMounted, onWillUnmount, onWillUpdateProps, onWillPatch, onPatched, onWillDestroy, onError, } from "./lifecycle_hooks";
28
36
  export { validate, validateType } from "./validation";
29
37
  export { OwlError } from "../common/owl_error";
30
38
  export declare const __info__: {
31
39
  version: string;
32
40
  };
41
+ export { Plugin, PluginManager, plugin } from "./plugins";
42
+ export type { PluginConstructor } from "./plugins";
@@ -5,8 +5,6 @@ export declare function onWillPatch(fn: () => any | void): void;
5
5
  export declare function onPatched(fn: () => void | any): void;
6
6
  export declare function onWillUnmount(fn: () => void | any): void;
7
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;
8
+ type OnErrorCallback = (error: any) => void | any;
11
9
  export declare function onError(callback: OnErrorCallback): void;
12
10
  export {};
@@ -0,0 +1 @@
1
+ export declare function reactiveMap<A, B>(arr: A[], fn: (a: A, index: number) => B): any;
@@ -0,0 +1,23 @@
1
+ import { STATUS } from "./status";
2
+ export declare const _getCurrentPluginManager: () => PluginManager | null;
3
+ export interface PluginConstructor {
4
+ new (): Plugin;
5
+ id: string;
6
+ }
7
+ export declare class Plugin {
8
+ static id: string;
9
+ setup(): void;
10
+ }
11
+ export declare class PluginManager {
12
+ private children;
13
+ private parent;
14
+ private plugins;
15
+ private onDestroyCb;
16
+ status: STATUS;
17
+ constructor(parent: PluginManager | null);
18
+ destroy(): void;
19
+ getPluginById<T extends Plugin>(id: string): T | null;
20
+ getPlugin<T extends PluginConstructor>(pluginType: T): InstanceType<T> | null;
21
+ startPlugins(pluginTypes: PluginConstructor[]): Plugin[];
22
+ }
23
+ export declare function plugin<T extends PluginConstructor>(pluginType: T): InstanceType<T>;
@@ -5,11 +5,9 @@ import { Component } from "./component";
5
5
  export declare function portalTemplate(app: any, bdom: any, helpers: any): (ctx: any, node: any, key?: string) => any;
6
6
  export declare class Portal extends Component {
7
7
  static template: string;
8
- static props: {
9
- readonly target: {
10
- readonly type: StringConstructor;
11
- };
12
- readonly slots: true;
13
- };
8
+ props: import("./props").Props<unknown, {
9
+ target: StringConstructor;
10
+ slots: true;
11
+ }>;
14
12
  setup(): void;
15
13
  }
@@ -0,0 +1,65 @@
1
+ import type { Component } from "./component";
2
+ type ConstructorTypedPropsValidation<T = any> = new (...args: any) => T;
3
+ type UnionTypedPropsValidation = ReadonlyArray<TypedPropsValidation>;
4
+ type OptionalSchemaTypedPropsValidation<O extends boolean> = {
5
+ optional: O;
6
+ };
7
+ type DefaultValuedSchemaTypedPropsValidation<T> = {
8
+ defaultValue: T;
9
+ };
10
+ type ValidableSchemaTypedPropsValidation = {
11
+ validate(value: any): boolean;
12
+ };
13
+ type TypeSchemaTypedPropsValidation<T> = {
14
+ type: new (...args: any) => T;
15
+ };
16
+ type MapSchemaTypedPropsValidation = {
17
+ type: ObjectConstructor;
18
+ shape: PropsValidation;
19
+ };
20
+ type RecordSchemaTypedPropsValidation = {
21
+ type: ObjectConstructor;
22
+ values: TypedPropsValidation;
23
+ };
24
+ type ArraySchemaTypedPropsValidation = {
25
+ type: ArrayConstructor;
26
+ element: TypedPropsValidation;
27
+ };
28
+ type SchemaTypedPropsValidation<T, O extends boolean> = {
29
+ type?: new (...args: any) => T;
30
+ optional?: O;
31
+ defaultValue?: T;
32
+ validate?(value: T): boolean;
33
+ shape?: PropsValidation;
34
+ values?: TypedPropsValidation;
35
+ element?: TypedPropsValidation;
36
+ };
37
+ type ValueTypedPropsValidation<T = any> = {
38
+ value: T;
39
+ };
40
+ type TypedPropsValidation = true | ConstructorTypedPropsValidation | UnionTypedPropsValidation | SchemaTypedPropsValidation<any, boolean> | ValueTypedPropsValidation;
41
+ export type RecordPropsValidation = Record<string, TypedPropsValidation>;
42
+ export type KeysPropsValidation = readonly string[];
43
+ export type PropsValidation = RecordPropsValidation | KeysPropsValidation;
44
+ type ConvertTypedPropsValidation<V extends TypedPropsValidation> = V extends true ? any : V extends ConstructorTypedPropsValidation<infer I> ? I : V extends UnionTypedPropsValidation ? V[number] : V extends MapSchemaTypedPropsValidation ? ConvertPropsValidation<V["shape"]> : V extends RecordSchemaTypedPropsValidation ? Record<string, ConvertTypedPropsValidation<V["values"]>> : V extends ArraySchemaTypedPropsValidation ? ConvertTypedPropsValidation<V["element"]>[] : V extends TypeSchemaTypedPropsValidation<infer I> ? I : V extends ValueTypedPropsValidation<infer T> ? T : V extends DefaultValuedSchemaTypedPropsValidation<infer T> ? T : V extends OptionalSchemaTypedPropsValidation<boolean> ? any : V extends ValidableSchemaTypedPropsValidation ? any : never;
45
+ type ConvertPropsValidation<V extends PropsValidation> = V extends KeysPropsValidation ? {
46
+ [K in V[number] as K extends `${infer N}?` ? N : never]?: any;
47
+ } & {
48
+ [K in V[number] as K extends `${string}?` ? never : K]: any;
49
+ } : V extends RecordPropsValidation ? {
50
+ [K in keyof V as V[K] extends OptionalSchemaTypedPropsValidation<true> ? K : never]?: ConvertTypedPropsValidation<V[K]>;
51
+ } & {
52
+ [K in keyof V as V[K] extends OptionalSchemaTypedPropsValidation<true> ? never : K]: ConvertTypedPropsValidation<V[K]>;
53
+ } : never;
54
+ declare const isProps: unique symbol;
55
+ type IsPropsObj = {
56
+ [isProps]: true;
57
+ };
58
+ export type Props<T, V extends PropsValidation> = IsPropsObj & (unknown extends T ? ConvertPropsValidation<V> : T);
59
+ export type GetProps<T extends Component> = {
60
+ [K in keyof T]: T[K] extends IsPropsObj ? (x: Omit<T[K], typeof isProps>) => void : never;
61
+ }[keyof T] extends (x: infer I) => void ? {
62
+ [K in keyof I]: I[K];
63
+ } : never;
64
+ export declare function props<T = unknown, V extends PropsValidation = PropsValidation>(validation?: V): Props<T, V>;
65
+ export {};
@@ -0,0 +1,31 @@
1
+ export declare enum ComputationState {
2
+ EXECUTED = 0,
3
+ STALE = 1,
4
+ PENDING = 2
5
+ }
6
+ export type Computation<T = any> = {
7
+ compute?: () => T;
8
+ state: ComputationState;
9
+ sources: Set<Atom | Derived<any, any>>;
10
+ isEager?: boolean;
11
+ isDerived?: boolean;
12
+ value: T;
13
+ childrenEffect?: Computation[];
14
+ } & Opts;
15
+ export type Opts = {
16
+ name?: string;
17
+ };
18
+ export type Atom<T = any> = {
19
+ value: T;
20
+ observers: Set<Computation>;
21
+ } & Opts;
22
+ export interface Derived<Prev, Next = Prev> extends Atom<Next>, Computation<Next> {
23
+ }
24
+ export declare function onReadAtom(atom: Atom): void;
25
+ export declare function onWriteAtom(atom: Atom): void;
26
+ export declare function untrack<T extends (...args: any[]) => any>(fn: T): ReturnType<T>;
27
+ export declare function getCurrentComputation(): Computation<any> | undefined;
28
+ export declare function setComputation(computation: Computation | undefined): void;
29
+ export declare function runWithComputation<T>(computation: Computation, fn: () => T): T;
30
+ export declare function updateComputation(computation: Computation): void;
31
+ export declare function removeSources(computation: Computation): void;
@@ -0,0 +1,7 @@
1
+ import { Opts, Derived } from "./computations";
2
+ import { ReactiveValue } from "./signal";
3
+ export declare function computed<T>(fn: () => T, opts?: Opts): ReactiveValue<T>;
4
+ export declare function setSignalHooks(hooks: {
5
+ onDerived: (derived: Derived<any, any>) => void;
6
+ }): void;
7
+ export declare function resetSignalHooks(): void;
@@ -0,0 +1,7 @@
1
+ import { Opts, Derived } from "./computations";
2
+ import { ReactiveValue } from "./signal";
3
+ export declare function derived<T>(fn: () => T, opts?: Opts): ReactiveValue<T>;
4
+ export declare function setSignalHooks(hooks: {
5
+ onDerived: (derived: Derived<any, any>) => void;
6
+ }): void;
7
+ export declare function resetSignalHooks(): void;
@@ -0,0 +1,2 @@
1
+ import { Opts } from "./computations";
2
+ export declare function effect<T>(fn: () => T, opts?: Opts): () => void;
@@ -0,0 +1,46 @@
1
+ type Target = object;
2
+ type Reactive<T extends Target> = T;
3
+ /**
4
+ * Mark an object or array so that it is ignored by the reactivity system
5
+ *
6
+ * @param value the value to mark
7
+ * @returns the object itself
8
+ */
9
+ export declare function markRaw<T extends Target>(value: T): T;
10
+ /**
11
+ * Given a proxy objet, return the raw (non proxy) underlying object
12
+ *
13
+ * @param value a proxy value
14
+ * @returns the underlying value
15
+ */
16
+ export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
17
+ export declare const targets: WeakMap<object, object>;
18
+ /**
19
+ * Creates a reactive proxy for an object. Reading data on the proxy object
20
+ * subscribes to changes to the data. Writing data on the object will cause the
21
+ * notify callback to be called if there are suscriptions to that data. Nested
22
+ * objects and arrays are automatically made reactive as well.
23
+ *
24
+ * Whenever you are notified of a change, all subscriptions are cleared, and if
25
+ * you would like to be notified of any further changes, you should go read
26
+ * the underlying data again. We assume that if you don't go read it again after
27
+ * being notified, it means that you are no longer interested in that data.
28
+ *
29
+ * Subscriptions:
30
+ * + Reading a property on an object will subscribe you to changes in the value
31
+ * of that property.
32
+ * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
33
+ * subscribe you to the creation/deletion of keys. Checking the presence of a
34
+ * key on the object with 'in' has the same effect.
35
+ * - getOwnPropertyDescriptor does not currently subscribe you to the property.
36
+ * This is a choice that was made because changing a key's value will trigger
37
+ * this trap and we do not want to subscribe by writes. This also means that
38
+ * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
39
+ *
40
+ * @param target the object for which to create a proxy proxy
41
+ * @param callback the function to call when an observed property of the
42
+ * proxy has changed
43
+ * @returns a proxy that tracks changes to it
44
+ */
45
+ export declare function proxy<T extends Target>(target: T): T;
46
+ export {};