@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.
- package/dist/compile_templates.mjs +92 -189
- package/dist/compiler.js +2378 -0
- package/dist/owl-devtools.zip +0 -0
- package/dist/owl.cjs.js +1371 -1261
- package/dist/owl.cjs.runtime.js +4094 -0
- package/dist/owl.es.js +1358 -1252
- package/dist/owl.es.runtime.js +4050 -0
- package/dist/owl.iife.js +1371 -1261
- package/dist/owl.iife.min.js +1 -1
- package/dist/owl.iife.runtime.js +4098 -0
- package/dist/owl.iife.runtime.min.js +1 -0
- package/dist/types/compiler/code_generator.d.ts +3 -5
- package/dist/types/compiler/index.d.ts +4 -4
- package/dist/types/compiler/inline_expressions.d.ts +1 -1
- package/dist/types/compiler/parser.d.ts +21 -28
- package/dist/types/owl.d.ts +299 -205
- package/dist/types/runtime/app.d.ts +29 -31
- package/dist/types/runtime/blockdom/block_compiler.d.ts +3 -3
- package/dist/types/runtime/blockdom/config.d.ts +1 -1
- package/dist/types/runtime/blockdom/event_catcher.d.ts +2 -2
- package/dist/types/runtime/blockdom/events.d.ts +1 -1
- package/dist/types/runtime/blockdom/index.d.ts +1 -1
- package/dist/types/runtime/cancellableContext.d.ts +15 -0
- package/dist/types/runtime/cancellablePromise.d.ts +15 -0
- package/dist/types/runtime/component.d.ts +5 -13
- package/dist/types/runtime/component_node.d.ts +15 -35
- package/dist/types/runtime/event_handling.d.ts +1 -1
- package/dist/types/runtime/executionContext.d.ts +0 -0
- package/dist/types/runtime/hooks.d.ts +7 -33
- package/dist/types/runtime/index.d.ts +15 -5
- package/dist/types/runtime/lifecycle_hooks.d.ts +1 -3
- package/dist/types/runtime/listOperation.d.ts +1 -0
- package/dist/types/runtime/plugins.d.ts +23 -0
- package/dist/types/runtime/portal.d.ts +4 -6
- package/dist/types/runtime/props.d.ts +65 -0
- package/dist/types/runtime/reactivity/computations.d.ts +31 -0
- package/dist/types/runtime/reactivity/computed.d.ts +7 -0
- package/dist/types/runtime/reactivity/derived.d.ts +7 -0
- package/dist/types/runtime/reactivity/effect.d.ts +2 -0
- package/dist/types/runtime/reactivity/proxy.d.ts +46 -0
- package/dist/types/runtime/reactivity/reactivity.d.ts +46 -0
- package/dist/types/runtime/reactivity/signal.d.ts +17 -0
- package/dist/types/runtime/reactivity/signals.d.ts +30 -0
- package/dist/types/runtime/registry.d.ts +19 -0
- package/dist/types/runtime/relationalModel/discussModel.d.ts +19 -0
- package/dist/types/runtime/relationalModel/discussModelTypes.d.ts +22 -0
- package/dist/types/runtime/relationalModel/field.d.ts +20 -0
- package/dist/types/runtime/relationalModel/model.d.ts +59 -0
- package/dist/types/runtime/relationalModel/modelData.d.ts +18 -0
- package/dist/types/runtime/relationalModel/modelRegistry.d.ts +3 -0
- package/dist/types/runtime/relationalModel/modelUtils.d.ts +4 -0
- package/dist/types/runtime/relationalModel/store.d.ts +16 -0
- package/dist/types/runtime/relationalModel/types.d.ts +83 -0
- package/dist/types/runtime/relationalModel/util.d.ts +1 -0
- package/dist/types/runtime/relationalModel/web/WebDataPoint.d.ts +25 -0
- package/dist/types/runtime/relationalModel/web/WebRecord.d.ts +131 -0
- package/dist/types/runtime/relationalModel/web/WebStaticList.d.ts +63 -0
- package/dist/types/runtime/relationalModel/web/webModel.d.ts +5 -0
- package/dist/types/runtime/relationalModel/web/webModelTypes.d.ts +139 -0
- package/dist/types/runtime/rendering/error_handling.d.ts +13 -0
- package/dist/types/runtime/rendering/fibers.d.ts +37 -0
- package/dist/types/runtime/rendering/scheduler.d.ts +21 -0
- package/dist/types/runtime/rendering/template_helpers.d.ts +50 -0
- package/dist/types/runtime/resource.d.ts +12 -0
- package/dist/types/runtime/signals.d.ts +19 -0
- package/dist/types/runtime/status.d.ts +2 -3
- package/dist/types/runtime/task.d.ts +12 -0
- package/dist/types/runtime/template_set.d.ts +3 -4
- package/dist/types/runtime/utils.d.ts +1 -2
- package/dist/types/runtime/validation.d.ts +6 -6
- package/dist/types/utils/registry.d.ts +15 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +9 -9
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentConstructor } from "./component";
|
|
2
2
|
import { ComponentNode } from "./component_node";
|
|
3
|
-
import { handleError } from "./error_handling";
|
|
4
|
-
import { Fiber,
|
|
5
|
-
import {
|
|
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 {
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
-
|
|
29
|
+
proxy: typeof proxy;
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
40
|
+
export declare class App extends TemplateSet {
|
|
38
41
|
static validateTarget: typeof validateTarget;
|
|
39
|
-
static apps: Set<App
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
20
|
-
export
|
|
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
|
|
7
|
+
mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null) => boolean;
|
|
8
8
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { VNode } from "./index";
|
|
2
|
-
|
|
2
|
+
type EventsSpec = {
|
|
3
3
|
[name: string]: number;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
type Catcher = (child: VNode, handlers: any[]) => VNode;
|
|
6
6
|
export declare function createCatcher(eventsSpec: EventsSpec): Catcher;
|
|
7
7
|
export {};
|
|
@@ -19,7 +19,7 @@ export interface VNode<T = any> {
|
|
|
19
19
|
isOnlyChild?: boolean | undefined;
|
|
20
20
|
key?: any;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
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
|
|
15
|
-
|
|
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(
|
|
14
|
+
constructor(node: ComponentNode);
|
|
23
15
|
setup(): void;
|
|
24
16
|
render(deep?: boolean): void;
|
|
25
17
|
}
|
|
@@ -1,42 +1,30 @@
|
|
|
1
|
-
import type { App
|
|
1
|
+
import type { App } from "./app";
|
|
2
2
|
import { BDom, VNode } from "./blockdom";
|
|
3
|
-
import { Component, ComponentConstructor
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
-
|
|
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
|
|
16
|
+
component: Component;
|
|
27
17
|
bdom: BDom | null;
|
|
28
18
|
status: STATUS;
|
|
29
19
|
forceNextRender: boolean;
|
|
30
20
|
parentKey: string | null;
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
|
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
|
|
1
|
+
export declare const mainEventHandler: (data: any, ev: Event, currentTarget?: EventTarget | null) => boolean;
|
|
File without changes
|
|
@@ -1,31 +1,5 @@
|
|
|
1
|
-
import
|
|
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
|
|
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 `
|
|
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
|
-
* `
|
|
28
|
+
* `useListener(window, 'click', this._doSomething);`
|
|
55
29
|
* */
|
|
56
|
-
export declare function
|
|
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
|
|
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 {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
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
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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,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 {};
|