@odoo/owl 2.0.0-alpha.1 → 2.0.0-beta-4

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.
@@ -1,3 +1,9 @@
1
+ export declare type EventHandlers = {
2
+ [eventName: string]: string;
3
+ };
4
+ export declare type Attrs = {
5
+ [attrs: string]: string;
6
+ };
1
7
  export declare const enum ASTType {
2
8
  Text = 0,
3
9
  Comment = 1,
@@ -27,28 +33,24 @@ export interface ASTComment {
27
33
  value: string;
28
34
  }
29
35
  interface TModelInfo {
30
- hasDynamicChildren?: boolean;
31
36
  baseExpr: string;
32
37
  expr: string;
33
38
  targetAttr: string;
34
- specialInitTargetAttr: string | null;
35
39
  eventType: "change" | "click" | "input";
36
40
  shouldTrim: boolean;
37
41
  shouldNumberize: boolean;
42
+ hasDynamicChildren: boolean;
43
+ specialInitTargetAttr: string | null;
38
44
  }
39
45
  export interface ASTDomNode {
40
46
  type: ASTType.DomNode;
41
47
  tag: string;
42
- dynamicTag: string | null;
43
- attrs: {
44
- [key: string]: string;
45
- };
46
48
  content: AST[];
49
+ attrs: Attrs | null;
47
50
  ref: string | null;
48
- on: {
49
- [key: string]: string;
50
- };
51
- model?: TModelInfo | null;
51
+ on: EventHandlers | null;
52
+ model: TModelInfo | null;
53
+ dynamicTag: string | null;
52
54
  ns: string | null;
53
55
  }
54
56
  export interface ASTMulti {
@@ -86,13 +88,13 @@ export interface ASTTForEach {
86
88
  type: ASTType.TForEach;
87
89
  collection: string;
88
90
  elem: string;
89
- key: string | null;
90
91
  body: AST;
91
92
  memo: string;
92
93
  hasNoFirst: boolean;
93
94
  hasNoLast: boolean;
94
95
  hasNoIndex: boolean;
95
96
  hasNoValue: boolean;
97
+ key: string | null;
96
98
  }
97
99
  export interface ASTTKey {
98
100
  type: ASTType.TKey;
@@ -104,30 +106,30 @@ export interface ASTTCall {
104
106
  name: string;
105
107
  body: AST[] | null;
106
108
  }
109
+ interface SlotDefinition {
110
+ content: AST;
111
+ scope: string | null;
112
+ on: EventHandlers | null;
113
+ attrs: Attrs | null;
114
+ }
107
115
  export interface ASTComponent {
108
116
  type: ASTType.TComponent;
109
117
  name: string;
110
118
  isDynamic: boolean;
111
119
  dynamicProps: string | null;
120
+ on: EventHandlers | null;
112
121
  props: {
113
122
  [name: string]: string;
114
- };
123
+ } | null;
115
124
  slots: {
116
- [name: string]: {
117
- content: AST;
118
- attrs?: {
119
- [key: string]: string;
120
- };
121
- scope?: string;
122
- };
123
- };
125
+ [name: string]: SlotDefinition;
126
+ } | null;
124
127
  }
125
128
  export interface ASTSlot {
126
129
  type: ASTType.TSlot;
127
130
  name: string;
128
- attrs: {
129
- [key: string]: string;
130
- };
131
+ attrs: Attrs | null;
132
+ on: EventHandlers | null;
131
133
  defaultContent: AST | null;
132
134
  }
133
135
  export interface ASTTCallBlock {
@@ -17,6 +17,6 @@ export declare class Component<Props = any, Env = any> {
17
17
  __owl__: ComponentNode;
18
18
  constructor(props: Props, env: Env, node: ComponentNode);
19
19
  setup(): void;
20
- render(): void;
20
+ render(deep?: boolean): void;
21
21
  }
22
22
  export {};
@@ -1,19 +1,32 @@
1
1
  import type { App, Env } from "../app/app";
2
2
  import { BDom, VNode } from "../blockdom";
3
+ import { getSubscriptions, NonReactive, Reactive } from "../reactivity";
3
4
  import { Component, ComponentConstructor } from "./component";
4
- import { Fiber, MountFiber, MountOptions, RootFiber } from "./fibers";
5
+ import { Fiber, MountFiber, MountOptions } from "./fibers";
5
6
  import { STATUS } from "./status";
6
7
  export declare function getCurrent(): ComponentNode;
7
8
  export declare function useComponent(): Component;
8
- export declare function component(name: string | typeof Component, props: any, key: string, ctx: ComponentNode, parent: any): ComponentNode;
9
+ /**
10
+ * Creates a reactive object that will be observed by the current component.
11
+ * Reading data from the returned object (eg during rendering) will cause the
12
+ * component to subscribe to that data and be rerendered when it changes.
13
+ *
14
+ * @param state the state to observe
15
+ * @returns a reactive object that will cause the component to re-render on
16
+ * relevant changes
17
+ * @see reactive
18
+ */
19
+ export declare function useState<T extends object>(state: T): Reactive<T> | NonReactive<T>;
20
+ export declare function component<P extends object>(name: string | ComponentConstructor<P>, props: P, key: string, ctx: ComponentNode, parent: any): ComponentNode<P>;
9
21
  declare type LifecycleHook = Function;
10
- export declare class ComponentNode<P = any, E = any> implements VNode<ComponentNode<P, E>> {
22
+ export declare class ComponentNode<P extends object = any, E = any> implements VNode<ComponentNode<P, E>> {
11
23
  el?: HTMLElement | Text | undefined;
12
24
  app: App;
13
25
  fiber: Fiber | null;
14
26
  component: Component<P, E>;
15
27
  bdom: BDom | null;
16
28
  status: STATUS;
29
+ forceNextRender: boolean;
17
30
  renderFn: Function;
18
31
  parent: ComponentNode | null;
19
32
  level: number;
@@ -32,8 +45,7 @@ export declare class ComponentNode<P = any, E = any> implements VNode<ComponentN
32
45
  constructor(C: ComponentConstructor<P, E>, props: P, app: App, parent?: ComponentNode);
33
46
  mountComponent(target: any, options?: MountOptions): void;
34
47
  initiateRender(fiber: Fiber | MountFiber): Promise<void>;
35
- render(): Promise<void>;
36
- _render(fiber: Fiber | RootFiber): void;
48
+ render(deep?: boolean): Promise<void>;
37
49
  destroy(): void;
38
50
  _destroy(): void;
39
51
  updateAndRender(props: any, parentFiber: Fiber): Promise<void>;
@@ -47,8 +59,11 @@ export declare class ComponentNode<P = any, E = any> implements VNode<ComponentN
47
59
  mount(parent: HTMLElement, anchor: ChildNode): void;
48
60
  moveBefore(other: ComponentNode | null, afterNode: Node | null): void;
49
61
  patch(): void;
62
+ _patch(): void;
50
63
  beforeRemove(): void;
51
64
  remove(): void;
52
65
  cleanOutdatedChildren(): void;
66
+ get name(): string;
67
+ get subscriptions(): ReturnType<typeof getSubscriptions>;
53
68
  }
54
69
  export {};
@@ -9,7 +9,10 @@ export declare class Fiber {
9
9
  parent: Fiber | null;
10
10
  children: Fiber[];
11
11
  appliedToDom: boolean;
12
+ deep: boolean;
12
13
  constructor(node: ComponentNode, parent: Fiber | null);
14
+ render(): void;
15
+ _render(): void;
13
16
  }
14
17
  export declare class RootFiber extends Fiber {
15
18
  counter: number;
@@ -17,7 +20,10 @@ export declare class RootFiber extends Fiber {
17
20
  patched: Fiber[];
18
21
  mounted: Fiber[];
19
22
  locked: boolean;
23
+ delayedRenders: Fiber[];
24
+ reachedChildren: WeakSet<ComponentNode>;
20
25
  complete(): void;
26
+ setCounter(newValue: number): void;
21
27
  }
22
28
  declare type Position = "first-child" | "last-child";
23
29
  export interface MountOptions {
@@ -2,16 +2,15 @@ import { Fiber, RootFiber } from "./fibers";
2
2
  export declare class Scheduler {
3
3
  static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
4
4
  tasks: Set<RootFiber>;
5
- isRunning: boolean;
6
5
  requestAnimationFrame: Window["requestAnimationFrame"];
6
+ frame: number;
7
+ shouldClear: boolean;
7
8
  constructor();
8
- start(): void;
9
- stop(): void;
10
9
  addFiber(fiber: Fiber): void;
11
10
  /**
12
11
  * Process all current tasks. This only applies to the fibers that are ready.
13
12
  * Other tasks are left unchanged.
14
13
  */
15
14
  flush(): void;
16
- scheduleTasks(): void;
15
+ processFiber(fiber: RootFiber): void;
17
16
  }
@@ -18,12 +18,10 @@ export declare const blockDom: {
18
18
  };
19
19
  export { App, mount } from "./app/app";
20
20
  export { Component } from "./component/component";
21
- export { useComponent } from "./component/component_node";
21
+ export { useComponent, useState } from "./component/component_node";
22
22
  export { status } from "./component/status";
23
- export { Memo } from "./memo";
24
- export { xml } from "./app/template_set";
25
- export { useState, reactive, markRaw, toRaw } from "./reactivity";
23
+ export { reactive, markRaw, toRaw } from "./reactivity";
26
24
  export { useEffect, useEnv, useExternalListener, useRef, useChildSubEnv, useSubEnv } from "./hooks";
27
- export { EventBus, whenReady, loadFile, markup } from "./utils";
25
+ export { EventBus, whenReady, loadFile, markup, xml } from "./utils";
28
26
  export { onWillStart, onMounted, onWillUnmount, onWillUpdateProps, onWillPatch, onPatched, onWillRender, onRendered, onWillDestroy, onError, } from "./component/lifecycle_hooks";
29
27
  export declare const __info__: {};
@@ -1,11 +1,11 @@
1
1
  import { Callback } from "./utils";
2
- declare const TARGET: unique symbol;
2
+ export declare const TARGET: unique symbol;
3
3
  declare const SKIP: unique symbol;
4
4
  declare type Target = object;
5
5
  export declare type Reactive<T extends Target = Target> = T & {
6
6
  [TARGET]: any;
7
7
  };
8
- declare type NonReactive<T extends Target = Target> = T & {
8
+ export declare type NonReactive<T extends Target = Target> = T & {
9
9
  [SKIP]: any;
10
10
  };
11
11
  /**
@@ -22,6 +22,16 @@ export declare function markRaw<T extends Target>(value: T): NonReactive<T>;
22
22
  * @returns the underlying value
23
23
  */
24
24
  export declare function toRaw<T extends object>(value: Reactive<T>): T;
25
+ /**
26
+ * Clears all subscriptions of the Reactives associated with a given callback.
27
+ *
28
+ * @param callback the callback for which the reactives need to be cleared
29
+ */
30
+ export declare function clearReactivesForCallback(callback: Callback): void;
31
+ export declare function getSubscriptions(callback: Callback): {
32
+ target: object;
33
+ keys: PropertyKey[];
34
+ }[];
25
35
  /**
26
36
  * Creates a reactive proxy for an object. Reading data on the reactive object
27
37
  * subscribes to changes to the data. Writing data on the object will cause the
@@ -50,15 +60,4 @@ export declare function toRaw<T extends object>(value: Reactive<T>): T;
50
60
  * @returns a proxy that tracks changes to it
51
61
  */
52
62
  export declare function reactive<T extends Target>(target: T, callback?: Callback): Reactive<T> | NonReactive<T>;
53
- /**
54
- * Creates a reactive object that will be observed by the current component.
55
- * Reading data from the returned object (eg during rendering) will cause the
56
- * component to subscribe to that data and be rerendered when it changes.
57
- *
58
- * @param state the state to observe
59
- * @returns a reactive object that will cause the component to re-render on
60
- * relevant changes
61
- * @see reactive
62
- */
63
- export declare function useState<T extends object>(state: T): Reactive<T> | NonReactive<T>;
64
63
  export {};
@@ -16,3 +16,10 @@ export declare function loadFile(url: string): Promise<string>;
16
16
  export declare class Markup extends String {
17
17
  }
18
18
  export declare function markup(value: any): Markup;
19
+ export declare const globalTemplates: {
20
+ [key: string]: string | Element;
21
+ };
22
+ export declare function xml(...args: Parameters<typeof String.raw>): string;
23
+ export declare namespace xml {
24
+ var nextId: number;
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/owl",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-beta-4",
4
4
  "description": "Odoo Web Library (OWL)",
5
5
  "main": "dist/owl.cjs.js",
6
6
  "browser": "dist/owl.iife.js",
@@ -1,6 +0,0 @@
1
- import { Component } from "./component/component";
2
- import type { ComponentNode } from "./component/component_node";
3
- export declare class Memo extends Component {
4
- static template: string;
5
- constructor(props: any, env: any, node: ComponentNode);
6
- }