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

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 (72) hide show
  1. package/dist/compile_templates.mjs +2430 -2532
  2. package/dist/compiler.js +2371 -0
  3. package/dist/owl.cjs.js +6571 -6615
  4. package/dist/owl.cjs.runtime.js +4070 -0
  5. package/dist/owl.es.js +6559 -6599
  6. package/dist/owl.es.runtime.js +4026 -0
  7. package/dist/owl.iife.js +6572 -6616
  8. package/dist/owl.iife.min.js +1 -1
  9. package/dist/owl.iife.runtime.js +4074 -0
  10. package/dist/owl.iife.runtime.min.js +1 -0
  11. package/dist/types/common/owl_error.d.ts +3 -3
  12. package/dist/types/common/types.d.ts +0 -28
  13. package/dist/types/common/utils.d.ts +8 -8
  14. package/dist/types/compiler/code_generator.d.ts +134 -152
  15. package/dist/types/compiler/index.d.ts +13 -13
  16. package/dist/types/compiler/inline_expressions.d.ts +58 -59
  17. package/dist/types/compiler/parser.d.ts +175 -178
  18. package/dist/types/compiler/standalone/index.d.ts +2 -2
  19. package/dist/types/compiler/standalone/setup_jsdom.d.ts +1 -1
  20. package/dist/types/index.d.ts +1 -1
  21. package/dist/types/owl.d.ts +703 -665
  22. package/dist/types/runtime/app.d.ts +55 -62
  23. package/dist/types/runtime/blockdom/attributes.d.ts +6 -6
  24. package/dist/types/runtime/blockdom/block_compiler.d.ts +21 -21
  25. package/dist/types/runtime/blockdom/config.d.ts +8 -8
  26. package/dist/types/runtime/blockdom/event_catcher.d.ts +7 -7
  27. package/dist/types/runtime/blockdom/events.d.ts +8 -8
  28. package/dist/types/runtime/blockdom/html.d.ts +17 -17
  29. package/dist/types/runtime/blockdom/index.d.ts +25 -26
  30. package/dist/types/runtime/blockdom/list.d.ts +18 -18
  31. package/dist/types/runtime/blockdom/multi.d.ts +17 -17
  32. package/dist/types/runtime/blockdom/text.d.ts +26 -26
  33. package/dist/types/runtime/blockdom/toggler.d.ts +17 -17
  34. package/dist/types/runtime/component.d.ts +17 -28
  35. package/dist/types/runtime/component_node.d.ts +57 -83
  36. package/dist/types/runtime/context.d.ts +36 -0
  37. package/dist/types/runtime/event_handling.d.ts +1 -1
  38. package/dist/types/runtime/hooks.d.ts +32 -57
  39. package/dist/types/runtime/index.d.ts +46 -35
  40. package/dist/types/runtime/lifecycle_hooks.d.ts +10 -12
  41. package/dist/types/runtime/model.d.ts +48 -0
  42. package/dist/types/runtime/plugin_hooks.d.ts +6 -0
  43. package/dist/types/runtime/plugin_manager.d.ts +34 -0
  44. package/dist/types/runtime/plugins.d.ts +36 -39
  45. package/dist/types/runtime/portal.d.ts +12 -15
  46. package/dist/types/runtime/props.d.ts +21 -0
  47. package/dist/types/runtime/reactivity/async_computed.d.ts +1 -0
  48. package/dist/types/runtime/reactivity/computations.d.ts +33 -0
  49. package/dist/types/runtime/reactivity/computed.d.ts +6 -0
  50. package/dist/types/runtime/reactivity/derived.d.ts +7 -0
  51. package/dist/types/runtime/reactivity/effect.d.ts +1 -0
  52. package/dist/types/runtime/reactivity/proxy.d.ts +47 -0
  53. package/dist/types/runtime/reactivity/reactivity.d.ts +46 -0
  54. package/dist/types/runtime/reactivity/signal.d.ts +31 -0
  55. package/dist/types/runtime/reactivity/signals.d.ts +30 -0
  56. package/dist/types/runtime/reactivity/state.d.ts +48 -0
  57. package/dist/types/runtime/reactivity.d.ts +12 -1
  58. package/dist/types/runtime/registry.d.ts +24 -15
  59. package/dist/types/runtime/rendering/error_handling.d.ts +13 -0
  60. package/dist/types/runtime/rendering/fibers.d.ts +37 -0
  61. package/dist/types/runtime/rendering/scheduler.d.ts +21 -0
  62. package/dist/types/runtime/rendering/template_helpers.d.ts +51 -0
  63. package/dist/types/runtime/resource.d.ts +18 -0
  64. package/dist/types/runtime/signals.d.ts +6 -4
  65. package/dist/types/runtime/status.d.ts +11 -10
  66. package/dist/types/runtime/suspense.d.ts +5 -0
  67. package/dist/types/runtime/template_set.d.ts +36 -40
  68. package/dist/types/runtime/types.d.ts +67 -0
  69. package/dist/types/runtime/utils.d.ts +24 -25
  70. package/dist/types/runtime/validation.d.ts +19 -36
  71. package/dist/types/version.d.ts +1 -1
  72. package/package.json +22 -19
@@ -0,0 +1,33 @@
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 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,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 @@
1
+ export declare function effect<T>(fn: () => T): () => void;
@@ -0,0 +1,47 @@
1
+ import { Atom } from "./computations";
2
+ type Target = object;
3
+ type Reactive<T extends Target> = T;
4
+ /**
5
+ * Mark an object or array so that it is ignored by the reactivity system
6
+ *
7
+ * @param value the value to mark
8
+ * @returns the object itself
9
+ */
10
+ export declare function markRaw<T extends Target>(value: T): T;
11
+ /**
12
+ * Given a proxy objet, return the raw (non proxy) underlying object
13
+ *
14
+ * @param value a proxy value
15
+ * @returns the underlying value
16
+ */
17
+ export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
18
+ export declare function proxifyTarget<T extends Target>(target: T, atom: Atom | null): T;
19
+ /**
20
+ * Creates a reactive proxy for an object. Reading data on the proxy object
21
+ * subscribes to changes to the data. Writing data on the object will cause the
22
+ * notify callback to be called if there are suscriptions to that data. Nested
23
+ * objects and arrays are automatically made reactive as well.
24
+ *
25
+ * Whenever you are notified of a change, all subscriptions are cleared, and if
26
+ * you would like to be notified of any further changes, you should go read
27
+ * the underlying data again. We assume that if you don't go read it again after
28
+ * being notified, it means that you are no longer interested in that data.
29
+ *
30
+ * Subscriptions:
31
+ * + Reading a property on an object will subscribe you to changes in the value
32
+ * of that property.
33
+ * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
34
+ * subscribe you to the creation/deletion of keys. Checking the presence of a
35
+ * key on the object with 'in' has the same effect.
36
+ * - getOwnPropertyDescriptor does not currently subscribe you to the property.
37
+ * This is a choice that was made because changing a key's value will trigger
38
+ * this trap and we do not want to subscribe by writes. This also means that
39
+ * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
40
+ *
41
+ * @param target the object for which to create a proxy proxy
42
+ * @param callback the function to call when an observed property of the
43
+ * proxy has changed
44
+ * @returns a proxy that tracks changes to it
45
+ */
46
+ export declare function proxy<T extends Target>(target: T): T;
47
+ export {};
@@ -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 {};
@@ -0,0 +1,31 @@
1
+ import { ReactiveValue } from "./computations";
2
+ export interface Signal<T> extends ReactiveValue<T> {
3
+ /**
4
+ * Update the value of the signal with a new value. If the new value is different
5
+ * from the previous values, all computations that depends on this signal will
6
+ * be invalidated, and effects will rerun.
7
+ */
8
+ set(nextValue: T): void;
9
+ }
10
+ interface SignalOptions<T> {
11
+ type?: T;
12
+ }
13
+ declare function invalidateSignal(signal: Signal<any>): void;
14
+ declare function signalArray<T>(initialValue: T[], options?: SignalOptions<T>): Signal<T[]>;
15
+ declare function signalObject<T extends Record<PropertyKey, any>>(initialValue: T, options?: SignalOptions<T>): Signal<T>;
16
+ interface MapSignalOptions<K, V> {
17
+ name?: string;
18
+ keyType?: K;
19
+ valueType?: V;
20
+ }
21
+ declare function signalMap<K, V>(initialValue: Map<K, V>, options?: MapSignalOptions<K, V>): Signal<Map<K, V>>;
22
+ declare function signalSet<T>(initialValue: Set<T>, options?: SignalOptions<T>): Signal<Set<T>>;
23
+ export declare function signal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
24
+ export declare namespace signal {
25
+ var invalidate: typeof invalidateSignal;
26
+ var Array: typeof signalArray;
27
+ var Map: typeof signalMap;
28
+ var Object: typeof signalObject;
29
+ var Set: typeof signalSet;
30
+ }
31
+ export {};
@@ -0,0 +1,30 @@
1
+ import { Atom, Computation, Derived, Opts } from "../../common/types";
2
+ type SignalFunction<T> = () => T;
3
+ export interface Signal<T> extends SignalFunction<T> {
4
+ /**
5
+ * Update the value of the signal with a new value. If the new value is different
6
+ * from the previous values, all computations that depends on this signal will
7
+ * be invalidated, and effects will rerun.
8
+ */
9
+ set(value: T): void;
10
+ /**
11
+ * Call the updater function (if given) to update the signal value.
12
+ * If the updater value is not given, then all computations that depends on
13
+ * this signal will be invalidated and effects will rerun.
14
+ */
15
+ update(updater?: (value: T) => T): void;
16
+ }
17
+ export declare function signal<T>(value: T, opts?: Opts): Signal<T>;
18
+ export declare function effect<T>(fn: () => T, opts?: Opts): () => void;
19
+ export declare function derived<T>(fn: () => T, opts?: Opts): () => T;
20
+ export declare function onReadAtom(atom: Atom): void;
21
+ export declare function onWriteAtom(atom: Atom): void;
22
+ export declare function withoutReactivity<T extends (...args: any[]) => any>(fn: T): ReturnType<T>;
23
+ export declare function getCurrentComputation(): Computation<any> | undefined;
24
+ export declare function setComputation(computation: Computation | undefined): void;
25
+ export declare function runWithComputation<T>(computation: Computation, fn: () => T): T;
26
+ export declare function setSignalHooks(hooks: {
27
+ onDerived: (derived: Derived<any, any>) => void;
28
+ }): void;
29
+ export declare function resetSignalHooks(): void;
30
+ export {};
@@ -0,0 +1,48 @@
1
+ import { Atom } from "./computations";
2
+ type Target = object;
3
+ type Reactive<T extends Target> = T;
4
+ /**
5
+ * Mark an object or array so that it is ignored by the reactivity system
6
+ *
7
+ * @param value the value to mark
8
+ * @returns the object itself
9
+ */
10
+ export declare function markRaw<T extends Target>(value: T): T;
11
+ /**
12
+ * Given a proxy objet, return the raw (non proxy) underlying object
13
+ *
14
+ * @param value a proxy value
15
+ * @returns the underlying value
16
+ */
17
+ export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
18
+ export declare const targets: WeakMap<object, object>;
19
+ export declare function proxifyTarget<T extends Target>(target: T, atom: Atom | null): T;
20
+ /**
21
+ * Creates a reactive proxy for an object. Reading data on the proxy object
22
+ * subscribes to changes to the data. Writing data on the object will cause the
23
+ * notify callback to be called if there are suscriptions to that data. Nested
24
+ * objects and arrays are automatically made reactive as well.
25
+ *
26
+ * Whenever you are notified of a change, all subscriptions are cleared, and if
27
+ * you would like to be notified of any further changes, you should go read
28
+ * the underlying data again. We assume that if you don't go read it again after
29
+ * being notified, it means that you are no longer interested in that data.
30
+ *
31
+ * Subscriptions:
32
+ * + Reading a property on an object will subscribe you to changes in the value
33
+ * of that property.
34
+ * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
35
+ * subscribe you to the creation/deletion of keys. Checking the presence of a
36
+ * key on the object with 'in' has the same effect.
37
+ * - getOwnPropertyDescriptor does not currently subscribe you to the property.
38
+ * This is a choice that was made because changing a key's value will trigger
39
+ * this trap and we do not want to subscribe by writes. This also means that
40
+ * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
41
+ *
42
+ * @param target the object for which to create a proxy proxy
43
+ * @param callback the function to call when an observed property of the
44
+ * proxy has changed
45
+ * @returns a proxy that tracks changes to it
46
+ */
47
+ export declare function state<T extends Target>(target: T): T;
48
+ export {};
@@ -1,3 +1,4 @@
1
+ import type { Callback } from "./utils";
1
2
  declare type Target = object;
2
3
  declare type Reactive<T extends Target> = T;
3
4
  /**
@@ -14,6 +15,16 @@ export declare function markRaw<T extends Target>(value: T): T;
14
15
  * @returns the underlying value
15
16
  */
16
17
  export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
18
+ /**
19
+ * Clears all subscriptions of the Reactives associated with a given callback.
20
+ *
21
+ * @param callback the callback for which the reactives need to be cleared
22
+ */
23
+ export declare function clearReactivesForCallback(callback: Callback): void;
24
+ export declare function getSubscriptions(callback: Callback): {
25
+ target: object;
26
+ keys: (string | number | symbol)[];
27
+ }[];
17
28
  export declare const targets: WeakMap<object, object>;
18
29
  /**
19
30
  * Creates a reactive proxy for an object. Reading data on the reactive object
@@ -42,5 +53,5 @@ export declare const targets: WeakMap<object, object>;
42
53
  * reactive has changed
43
54
  * @returns a proxy that tracks changes to it
44
55
  */
45
- export declare function reactive<T extends Target>(target: T): T;
56
+ export declare function reactive<T extends Target>(target: T, callback?: Callback): T;
46
57
  export {};
@@ -1,15 +1,24 @@
1
- import { Schema } from "./validation";
2
- declare type Fn<T> = () => T;
3
- export declare class Registry<T> {
4
- _map: {
5
- [key: string]: [number, T];
6
- };
7
- _name: string;
8
- _schema?: Schema;
9
- items: Fn<T[]>;
10
- entries: Fn<[string, T][]>;
11
- constructor(name?: string, schema?: Schema);
12
- set(key: string, value: T, sequence?: number): void;
13
- get(key: string, defaultValue?: T): T;
14
- }
15
- export {};
1
+ interface RegistryOptions<T> {
2
+ name?: string;
3
+ validation?: T;
4
+ }
5
+ export declare class Registry<T> {
6
+ private _map;
7
+ private _name;
8
+ private _validation?;
9
+ constructor(options?: RegistryOptions<T>);
10
+ entries: import(".").ReactiveValue<[string, T][], [string, T][]>;
11
+ items: import(".").ReactiveValue<T[], T[]>;
12
+ addById<U extends {
13
+ id: string;
14
+ } & T>(item: U, options?: {
15
+ sequence?: number;
16
+ }): Registry<T>;
17
+ add(key: string, value: T, options?: {
18
+ sequence?: number;
19
+ }): Registry<T>;
20
+ get(key: string, defaultValue?: T): T;
21
+ delete(key: string): void;
22
+ has(key: string): boolean;
23
+ }
24
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { ComponentNode } from "../component_node";
2
+ import type { Fiber } from "./fibers";
3
+ export declare const fibersInError: WeakMap<Fiber, any>;
4
+ export declare const nodeErrorHandlers: WeakMap<ComponentNode, ((error: any, finalize: Function) => 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 {};
@@ -0,0 +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
+ 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 {};
@@ -0,0 +1,21 @@
1
+ import type { ComponentNode } from "../component_node";
2
+ import { Fiber, RootFiber } from "./fibers";
3
+ export declare class Scheduler {
4
+ static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
5
+ tasks: Set<RootFiber>;
6
+ requestAnimationFrame: Window["requestAnimationFrame"];
7
+ frame: number;
8
+ delayedRenders: Fiber[];
9
+ cancelledNodes: Set<ComponentNode>;
10
+ processing: boolean;
11
+ constructor();
12
+ addFiber(fiber: Fiber): void;
13
+ scheduleDestroy(node: ComponentNode): void;
14
+ /**
15
+ * Process all current tasks. This only applies to the fibers that are ready.
16
+ * Other tasks are left unchanged.
17
+ */
18
+ flush(): void;
19
+ processTasks(): void;
20
+ processFiber(fiber: RootFiber): void;
21
+ }
@@ -0,0 +1,51 @@
1
+ import { OwlError } from "../../common/owl_error";
2
+ import { App } from "../app";
3
+ import { BDom, createCatcher, toggler } from "../blockdom";
4
+ import { ComponentNode } from "../component_node";
5
+ import { Portal } from "../portal";
6
+ import { markRaw } from "../reactivity/proxy";
7
+ /**
8
+ * This file contains utility functions that will be injected in each template,
9
+ * to perform various useful tasks in the compiled code.
10
+ */
11
+ declare function withDefault(value: any, defaultValue: any): any;
12
+ declare function callSlot(ctx: any, parent: any, key: string, name: string, dynamic: boolean, extra: any, defaultContent?: (ctx: any, node: any, key: string) => BDom): BDom;
13
+ declare function withKey(elem: any, k: string): any;
14
+ declare function prepareList(collection: unknown): [unknown[], unknown[], number, undefined[]];
15
+ declare function toNumber(val: string): number | string;
16
+ declare function shallowEqual(l1: any[], l2: any[]): boolean;
17
+ declare class LazyValue {
18
+ fn: any;
19
+ ctx: any;
20
+ component: any;
21
+ node: any;
22
+ key: any;
23
+ constructor(fn: any, ctx: any, component: any, node: any, key: any);
24
+ evaluate(): any;
25
+ toString(): any;
26
+ }
27
+ export declare function safeOutput(value: any, defaultValue?: any): ReturnType<typeof toggler>;
28
+ declare function createRef(ref: any): (el: HTMLElement | null, previousEl: HTMLElement | null) => void;
29
+ declare function modelExpr(value: any): any;
30
+ declare function createComponent<P extends Record<string, any>>(app: App, name: string | null, isStatic: boolean, hasSlotsProp: boolean, hasDynamicPropList: boolean, propList: string[]): (props: P, key: string, ctx: ComponentNode, parent: any, C: any) => any;
31
+ declare function callTemplate(subTemplate: string, owner: any, app: App, ctx: any, parent: any, key: any): any;
32
+ export declare const helpers: {
33
+ withDefault: typeof withDefault;
34
+ zero: symbol;
35
+ callSlot: typeof callSlot;
36
+ withKey: typeof withKey;
37
+ prepareList: typeof prepareList;
38
+ shallowEqual: typeof shallowEqual;
39
+ toNumber: typeof toNumber;
40
+ LazyValue: typeof LazyValue;
41
+ safeOutput: typeof safeOutput;
42
+ createCatcher: typeof createCatcher;
43
+ markRaw: typeof markRaw;
44
+ OwlError: typeof OwlError;
45
+ createRef: typeof createRef;
46
+ modelExpr: typeof modelExpr;
47
+ createComponent: typeof createComponent;
48
+ Portal: typeof Portal;
49
+ callTemplate: typeof callTemplate;
50
+ };
51
+ export {};
@@ -0,0 +1,18 @@
1
+ interface ResourceOptions<T> {
2
+ name?: string;
3
+ validation?: T;
4
+ }
5
+ export declare class Resource<T> {
6
+ private _items;
7
+ private _name?;
8
+ private _validation?;
9
+ constructor(options?: ResourceOptions<T>);
10
+ items: import(".").ReactiveValue<T[], T[]>;
11
+ add(item: T, options?: {
12
+ sequence?: number;
13
+ }): Resource<T>;
14
+ delete(item: T): Resource<T>;
15
+ has(item: T): boolean;
16
+ }
17
+ export declare function useResource<T>(r: Resource<T>, elements: T[]): void;
18
+ export {};
@@ -1,8 +1,9 @@
1
1
  import { Atom, Computation, Derived, Opts } from "../common/types";
2
- export declare function signal<T>(value: T, opts?: Opts): {
3
- readonly get: () => T;
4
- readonly set: (newValue: T | ((prevValue: T) => T)) => void;
5
- };
2
+ type SignalFunction<T> = () => T;
3
+ export interface Signal<T> extends SignalFunction<T> {
4
+ set(value: T): void;
5
+ }
6
+ export declare function signal<T>(value: T, opts?: Opts): Signal<T>;
6
7
  export declare function effect<T>(fn: () => T, opts?: Opts): () => void;
7
8
  export declare function derived<T>(fn: () => T, opts?: Opts): () => T;
8
9
  export declare function onReadAtom(atom: Atom): void;
@@ -15,3 +16,4 @@ export declare function setSignalHooks(hooks: {
15
16
  onDerived: (derived: Derived<any, any>) => void;
16
17
  }): void;
17
18
  export declare function resetSignalHooks(): void;
19
+ export {};
@@ -1,10 +1,11 @@
1
- import type { Component } from "./component";
2
- export declare const enum STATUS {
3
- NEW = 0,
4
- MOUNTED = 1,
5
- CANCELLED = 2,
6
- DESTROYED = 3
7
- }
8
- declare type STATUS_DESCR = "new" | "mounted" | "cancelled" | "destroyed";
9
- export declare function status(component: Component): STATUS_DESCR;
10
- export {};
1
+ import type { Component } from "./component";
2
+ import { Plugin } from "./plugin_manager";
3
+ export declare const enum STATUS {
4
+ NEW = 0,
5
+ MOUNTED = 1,// is ready, and in DOM. It has a valid el
6
+ CANCELLED = 2,
7
+ DESTROYED = 3
8
+ }
9
+ type STATUS_DESCR = "new" | "started" | "mounted" | "cancelled" | "destroyed";
10
+ export declare function status(entity: Component | Plugin): STATUS_DESCR;
11
+ export {};
@@ -0,0 +1,5 @@
1
+ import { Component } from "./component";
2
+ export declare function suspenseTemplate(app: any, bdom: any, helpers: any): (ctx: any, node: any, key?: string) => any;
3
+ export declare class Suspense extends Component {
4
+ static template: string;
5
+ }
@@ -1,40 +1,36 @@
1
- import { compile, Template, TemplateFunction } from "../compiler";
2
- import { Portal } from "./portal";
3
- import type { customDirectives } from "../common/types";
4
- export interface TemplateSetConfig {
5
- dev?: boolean;
6
- translatableAttributes?: string[];
7
- translateFn?: (s: string, translationCtx: string) => string;
8
- templates?: string | Document | Record<string, string>;
9
- getTemplate?: (s: string) => Element | Function | string | void;
10
- customDirectives?: customDirectives;
11
- globalValues?: object;
12
- }
13
- export declare class TemplateSet {
14
- static registerTemplate(name: string, fn: TemplateFunction): void;
15
- dev: boolean;
16
- rawTemplates: typeof globalTemplates;
17
- templates: {
18
- [name: string]: Template;
19
- };
20
- getRawTemplate?: (s: string) => Element | Function | string | void;
21
- translateFn?: (s: string, translationCtx: string) => string;
22
- translatableAttributes?: string[];
23
- Portal: typeof Portal;
24
- customDirectives: customDirectives;
25
- runtimeUtils: object;
26
- hasGlobalValues: boolean;
27
- constructor(config?: TemplateSetConfig);
28
- addTemplate(name: string, template: string | Element): void;
29
- addTemplates(xml: string | Document): void;
30
- getTemplate(name: string): Template;
31
- _compileTemplate(name: string, template: string | Element): ReturnType<typeof compile>;
32
- callTemplate(owner: any, subTemplate: string, ctx: any, parent: any, key: any): any;
33
- }
34
- export declare const globalTemplates: {
35
- [key: string]: string | Element | TemplateFunction;
36
- };
37
- export declare function xml(...args: Parameters<typeof String.raw>): string;
38
- export declare namespace xml {
39
- var nextId: number;
40
- }
1
+ import { CustomDirectives, Template, TemplateFunction } from "../compiler";
2
+ export interface TemplateSetConfig {
3
+ dev?: boolean;
4
+ translatableAttributes?: string[];
5
+ translateFn?: (s: string, translationCtx: string) => string;
6
+ templates?: string | Document | Record<string, string>;
7
+ getTemplate?: (s: string) => Element | Function | string | void;
8
+ customDirectives?: CustomDirectives;
9
+ globalValues?: object;
10
+ }
11
+ export declare class TemplateSet {
12
+ static registerTemplate(name: string, fn: TemplateFunction): void;
13
+ dev: boolean;
14
+ rawTemplates: typeof globalTemplates;
15
+ templates: {
16
+ [name: string]: Template;
17
+ };
18
+ getRawTemplate?: (s: string) => Element | Function | string | void;
19
+ translateFn?: (s: string, translationCtx: string) => string;
20
+ translatableAttributes?: string[];
21
+ customDirectives: CustomDirectives;
22
+ runtimeUtils: object;
23
+ hasGlobalValues: boolean;
24
+ constructor(config?: TemplateSetConfig);
25
+ addTemplate(name: string, template: string | Element): void;
26
+ addTemplates(xml: string | Document): void;
27
+ getTemplate(name: string): Template;
28
+ private _compileTemplate;
29
+ }
30
+ export declare const globalTemplates: {
31
+ [key: string]: string | Element | TemplateFunction;
32
+ };
33
+ export declare function xml(...args: Parameters<typeof String.raw>): string;
34
+ export declare namespace xml {
35
+ var nextId: number;
36
+ }