@odoo/owl 2.0.0 → 2.0.2

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.
@@ -4,7 +4,8 @@ declare class VToggler {
4
4
  parentEl?: HTMLElement | undefined;
5
5
  constructor(key: string, child: VNode);
6
6
  mount(parent: HTMLElement, afterNode: Node | null): void;
7
- moveBefore(other: VToggler | null, afterNode: Node | null): void;
7
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
8
+ moveBeforeVNode(other: VToggler | null, afterNode: Node | null): void;
8
9
  patch(other: VToggler, withBeforeRemove: boolean): void;
9
10
  beforeRemove(): void;
10
11
  remove(): void;
@@ -38,7 +39,8 @@ declare class VList {
38
39
  isOnlyChild?: boolean | undefined;
39
40
  constructor(children: VNode[]);
40
41
  mount(parent: HTMLElement, afterNode: Node | null): void;
41
- moveBefore(other: VList | null, afterNode: Node | null): void;
42
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
43
+ moveBeforeVNode(other: VList | null, afterNode: Node | null): void;
42
44
  patch(other: VList, withBeforeRemove: boolean): void;
43
45
  beforeRemove(): void;
44
46
  remove(): void;
@@ -54,7 +56,8 @@ declare class VMulti {
54
56
  isOnlyChild?: boolean | undefined;
55
57
  constructor(children: (VNode | undefined)[]);
56
58
  mount(parent: HTMLElement, afterNode: Node | null): void;
57
- moveBefore(other: VMulti | null, afterNode: Node | null): void;
59
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
60
+ moveBeforeVNode(other: VMulti | null, afterNode: Node | null): void;
58
61
  patch(other: VMulti, withBeforeRemove: boolean): void;
59
62
  beforeRemove(): void;
60
63
  remove(): void;
@@ -69,7 +72,8 @@ declare abstract class VSimpleNode {
69
72
  el?: any;
70
73
  constructor(text: string | String);
71
74
  mountNode(node: Node, parent: HTMLElement, afterNode: Node | null): void;
72
- moveBefore(other: VText | null, afterNode: Node | null): void;
75
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
76
+ moveBeforeVNode(other: VText | null, afterNode: Node | null): void;
73
77
  beforeRemove(): void;
74
78
  remove(): void;
75
79
  firstNode(): Node;
@@ -92,7 +96,8 @@ declare class VHtml {
92
96
  content: ChildNode[];
93
97
  constructor(html: string);
94
98
  mount(parent: HTMLElement, afterNode: Node | null): void;
95
- moveBefore(other: VHtml | null, afterNode: Node | null): void;
99
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
100
+ moveBeforeVNode(other: VHtml | null, afterNode: Node | null): void;
96
101
  patch(other: VHtml): void;
97
102
  beforeRemove(): void;
98
103
  remove(): void;
@@ -103,7 +108,8 @@ declare function html(str: string): VNode<VHtml>;
103
108
 
104
109
  interface VNode<T = any> {
105
110
  mount(parent: HTMLElement, afterNode: Node | null): void;
106
- moveBefore(other: T | null, afterNode: Node | null): void;
111
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
112
+ moveBeforeVNode(other: T | null, afterNode: Node | null): void;
107
113
  patch(other: T, withBeforeRemove: boolean): void;
108
114
  beforeRemove(): void;
109
115
  remove(): void;
@@ -118,73 +124,6 @@ declare function mount$1(vnode: VNode, fixture: HTMLElement, afterNode?: Node |
118
124
  declare function patch(vnode1: VNode, vnode2: VNode, withBeforeRemove?: boolean): void;
119
125
  declare function remove(vnode: VNode, withBeforeRemove?: boolean): void;
120
126
 
121
- declare type Callback = () => void;
122
- declare function validateTarget(target: HTMLElement): void;
123
- declare class EventBus extends EventTarget {
124
- trigger(name: string, payload?: any): void;
125
- }
126
- declare function whenReady(fn?: any): Promise<void>;
127
- declare function loadFile(url: string): Promise<string>;
128
- declare class Markup extends String {
129
- }
130
- declare function markup(value: any): Markup;
131
-
132
- declare const TARGET: unique symbol;
133
- declare const SKIP: unique symbol;
134
- declare type Target = object;
135
- declare type Reactive<T extends Target = Target> = T & {
136
- [TARGET]: any;
137
- };
138
- declare type NonReactive<T extends Target = Target> = T & {
139
- [SKIP]: any;
140
- };
141
- /**
142
- * Mark an object or array so that it is ignored by the reactivity system
143
- *
144
- * @param value the value to mark
145
- * @returns the object itself
146
- */
147
- declare function markRaw<T extends Target>(value: T): NonReactive<T>;
148
- /**
149
- * Given a reactive objet, return the raw (non reactive) underlying object
150
- *
151
- * @param value a reactive value
152
- * @returns the underlying value
153
- */
154
- declare function toRaw<T extends object>(value: Reactive<T>): T;
155
- declare function getSubscriptions(callback: Callback): {
156
- target: object;
157
- keys: PropertyKey[];
158
- }[];
159
- /**
160
- * Creates a reactive proxy for an object. Reading data on the reactive object
161
- * subscribes to changes to the data. Writing data on the object will cause the
162
- * notify callback to be called if there are suscriptions to that data. Nested
163
- * objects and arrays are automatically made reactive as well.
164
- *
165
- * Whenever you are notified of a change, all subscriptions are cleared, and if
166
- * you would like to be notified of any further changes, you should go read
167
- * the underlying data again. We assume that if you don't go read it again after
168
- * being notified, it means that you are no longer interested in that data.
169
- *
170
- * Subscriptions:
171
- * + Reading a property on an object will subscribe you to changes in the value
172
- * of that property.
173
- * + Accessing an object keys (eg with Object.keys or with `for..in`) will
174
- * subscribe you to the creation/deletion of keys. Checking the presence of a
175
- * key on the object with 'in' has the same effect.
176
- * - getOwnPropertyDescriptor does not currently subscribe you to the property.
177
- * This is a choice that was made because changing a key's value will trigger
178
- * this trap and we do not want to subscribe by writes. This also means that
179
- * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
180
- *
181
- * @param target the object for which to create a reactive proxy
182
- * @param callback the function to call when an observed property of the
183
- * reactive has changed
184
- * @returns a proxy that tracks changes to it
185
- */
186
- declare function reactive<T extends Target>(target: T, callback?: Callback): Reactive<T> | NonReactive<T>;
187
-
188
127
  declare type BaseType = typeof String | typeof Boolean | typeof Number | typeof Date | typeof Object | typeof Array | true | "*";
189
128
  interface TypeInfo {
190
129
  type?: TypeDescription;
@@ -242,6 +181,66 @@ declare class MountFiber extends RootFiber {
242
181
  complete(): void;
243
182
  }
244
183
 
184
+ declare type Callback = () => void;
185
+ declare function validateTarget(target: HTMLElement): void;
186
+ declare class EventBus extends EventTarget {
187
+ trigger(name: string, payload?: any): void;
188
+ }
189
+ declare function whenReady(fn?: any): Promise<void>;
190
+ declare function loadFile(url: string): Promise<string>;
191
+ declare class Markup extends String {
192
+ }
193
+ declare function markup(value: any): Markup;
194
+
195
+ declare type Target = object;
196
+ declare type Reactive<T extends Target> = T;
197
+ /**
198
+ * Mark an object or array so that it is ignored by the reactivity system
199
+ *
200
+ * @param value the value to mark
201
+ * @returns the object itself
202
+ */
203
+ declare function markRaw<T extends Target>(value: T): T;
204
+ /**
205
+ * Given a reactive objet, return the raw (non reactive) underlying object
206
+ *
207
+ * @param value a reactive value
208
+ * @returns the underlying value
209
+ */
210
+ declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
211
+ declare function getSubscriptions(callback: Callback): {
212
+ target: object;
213
+ keys: PropertyKey[];
214
+ }[];
215
+ /**
216
+ * Creates a reactive proxy for an object. Reading data on the reactive object
217
+ * subscribes to changes to the data. Writing data on the object will cause the
218
+ * notify callback to be called if there are suscriptions to that data. Nested
219
+ * objects and arrays are automatically made reactive as well.
220
+ *
221
+ * Whenever you are notified of a change, all subscriptions are cleared, and if
222
+ * you would like to be notified of any further changes, you should go read
223
+ * the underlying data again. We assume that if you don't go read it again after
224
+ * being notified, it means that you are no longer interested in that data.
225
+ *
226
+ * Subscriptions:
227
+ * + Reading a property on an object will subscribe you to changes in the value
228
+ * of that property.
229
+ * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
230
+ * subscribe you to the creation/deletion of keys. Checking the presence of a
231
+ * key on the object with 'in' has the same effect.
232
+ * - getOwnPropertyDescriptor does not currently subscribe you to the property.
233
+ * This is a choice that was made because changing a key's value will trigger
234
+ * this trap and we do not want to subscribe by writes. This also means that
235
+ * Object.hasOwnProperty doesn't subscribe as it goes through this trap.
236
+ *
237
+ * @param target the object for which to create a reactive proxy
238
+ * @param callback the function to call when an observed property of the
239
+ * reactive has changed
240
+ * @returns a proxy that tracks changes to it
241
+ */
242
+ declare function reactive<T extends Target>(target: T, callback?: Callback): T;
243
+
245
244
  declare const enum STATUS {
246
245
  NEW = 0,
247
246
  MOUNTED = 1,
@@ -261,7 +260,7 @@ declare function useComponent(): Component;
261
260
  * relevant changes
262
261
  * @see reactive
263
262
  */
264
- declare function useState<T extends object>(state: T): Reactive<T> | NonReactive<T>;
263
+ declare function useState<T extends object>(state: T): T;
265
264
  declare type LifecycleHook = Function;
266
265
  declare class ComponentNode<P extends Props = any, E = any> implements VNode<ComponentNode<P, E>> {
267
266
  el?: HTMLElement | Text | undefined;
@@ -302,7 +301,8 @@ declare class ComponentNode<P extends Props = any, E = any> implements VNode<Com
302
301
  updateDom(): void;
303
302
  firstNode(): Node | undefined;
304
303
  mount(parent: HTMLElement, anchor: ChildNode): void;
305
- moveBefore(other: ComponentNode | null, afterNode: Node | null): void;
304
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
305
+ moveBeforeVNode(other: ComponentNode<P, E> | null, afterNode: Node | null): void;
306
306
  patch(): void;
307
307
  _patch(): void;
308
308
  beforeRemove(): void;
@@ -529,4 +529,4 @@ declare const blockDom: {
529
529
 
530
530
  declare const __info__: {};
531
531
 
532
- export { App, Component, ComponentConstructor, EventBus, OwlError, Reactive, __info__, blockDom, loadFile, markRaw, markup, mount, onError, onMounted, onPatched, onRendered, onWillDestroy, onWillPatch, onWillRender, onWillStart, onWillUnmount, onWillUpdateProps, reactive, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, useRef, useState, useSubEnv, validate, whenReady, xml };
532
+ export { App, Component, ComponentConstructor, EventBus, OwlError, __info__, blockDom, loadFile, markRaw, markup, mount, onError, onMounted, onPatched, onRendered, onWillDestroy, onWillPatch, onWillRender, onWillStart, onWillUnmount, onWillUpdateProps, reactive, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, useRef, useState, useSubEnv, validate, whenReady, xml };
@@ -5,7 +5,8 @@ declare class VHtml {
5
5
  content: ChildNode[];
6
6
  constructor(html: string);
7
7
  mount(parent: HTMLElement, afterNode: Node | null): void;
8
- moveBefore(other: VHtml | null, afterNode: Node | null): void;
8
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
9
+ moveBeforeVNode(other: VHtml | null, afterNode: Node | null): void;
9
10
  patch(other: VHtml): void;
10
11
  beforeRemove(): void;
11
12
  remove(): void;
@@ -8,7 +8,8 @@ export { html } from "./html";
8
8
  export { createCatcher } from "./event_catcher";
9
9
  export interface VNode<T = any> {
10
10
  mount(parent: HTMLElement, afterNode: Node | null): void;
11
- moveBefore(other: T | null, afterNode: Node | null): void;
11
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
12
+ moveBeforeVNode(other: T | null, afterNode: Node | null): void;
12
13
  patch(other: T, withBeforeRemove: boolean): void;
13
14
  beforeRemove(): void;
14
15
  remove(): void;
@@ -6,7 +6,8 @@ declare class VList {
6
6
  isOnlyChild?: boolean | undefined;
7
7
  constructor(children: VNode[]);
8
8
  mount(parent: HTMLElement, afterNode: Node | null): void;
9
- moveBefore(other: VList | null, afterNode: Node | null): void;
9
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
10
+ moveBeforeVNode(other: VList | null, afterNode: Node | null): void;
10
11
  patch(other: VList, withBeforeRemove: boolean): void;
11
12
  beforeRemove(): void;
12
13
  remove(): void;
@@ -6,7 +6,8 @@ export declare class VMulti {
6
6
  isOnlyChild?: boolean | undefined;
7
7
  constructor(children: (VNode | undefined)[]);
8
8
  mount(parent: HTMLElement, afterNode: Node | null): void;
9
- moveBefore(other: VMulti | null, afterNode: Node | null): void;
9
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
10
+ moveBeforeVNode(other: VMulti | null, afterNode: Node | null): void;
10
11
  patch(other: VMulti, withBeforeRemove: boolean): void;
11
12
  beforeRemove(): void;
12
13
  remove(): void;
@@ -5,7 +5,8 @@ declare abstract class VSimpleNode {
5
5
  el?: any;
6
6
  constructor(text: string | String);
7
7
  mountNode(node: Node, parent: HTMLElement, afterNode: Node | null): void;
8
- moveBefore(other: VText | null, afterNode: Node | null): void;
8
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement | undefined): void;
9
+ moveBeforeVNode(other: VText | null, afterNode: Node | null): void;
9
10
  beforeRemove(): void;
10
11
  remove(): void;
11
12
  firstNode(): Node;
@@ -5,7 +5,8 @@ declare class VToggler {
5
5
  parentEl?: HTMLElement | undefined;
6
6
  constructor(key: string, child: VNode);
7
7
  mount(parent: HTMLElement, afterNode: Node | null): void;
8
- moveBefore(other: VToggler | null, afterNode: Node | null): void;
8
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
9
+ moveBeforeVNode(other: VToggler | null, afterNode: Node | null): void;
9
10
  patch(other: VToggler, withBeforeRemove: boolean): void;
10
11
  beforeRemove(): void;
11
12
  remove(): void;
@@ -2,7 +2,7 @@ import type { App, Env } from "./app";
2
2
  import { BDom, VNode } from "./blockdom";
3
3
  import { Component, ComponentConstructor, Props } from "./component";
4
4
  import { Fiber, MountFiber, MountOptions } from "./fibers";
5
- import { getSubscriptions, NonReactive, Reactive } from "./reactivity";
5
+ import { getSubscriptions } from "./reactivity";
6
6
  import { STATUS } from "./status";
7
7
  export declare function getCurrent(): ComponentNode;
8
8
  export declare function useComponent(): Component;
@@ -16,7 +16,7 @@ export declare function useComponent(): Component;
16
16
  * relevant changes
17
17
  * @see reactive
18
18
  */
19
- export declare function useState<T extends object>(state: T): Reactive<T> | NonReactive<T>;
19
+ export declare function useState<T extends object>(state: T): T;
20
20
  declare type LifecycleHook = Function;
21
21
  export declare class ComponentNode<P extends Props = any, E = any> implements VNode<ComponentNode<P, E>> {
22
22
  el?: HTMLElement | Text | undefined;
@@ -57,7 +57,8 @@ export declare class ComponentNode<P extends Props = any, E = any> implements VN
57
57
  updateDom(): void;
58
58
  firstNode(): Node | undefined;
59
59
  mount(parent: HTMLElement, anchor: ChildNode): void;
60
- moveBefore(other: ComponentNode | null, afterNode: Node | null): void;
60
+ moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
61
+ moveBeforeVNode(other: ComponentNode<P, E> | null, afterNode: Node | null): void;
61
62
  patch(): void;
62
63
  _patch(): void;
63
64
  beforeRemove(): void;
@@ -1,5 +1,4 @@
1
1
  import { createBlock, html, list, mount as blockMount, multi, patch, remove, text, toggler, comment } from "./blockdom";
2
- export type { Reactive } from "./reactivity";
3
2
  export declare const blockDom: {
4
3
  config: {
5
4
  shouldNormalizeDom: boolean;
@@ -1,27 +1,20 @@
1
1
  import { Callback } from "./utils";
2
- export declare const TARGET: unique symbol;
3
- declare const SKIP: unique symbol;
4
2
  declare type Target = object;
5
- export declare type Reactive<T extends Target = Target> = T & {
6
- [TARGET]: any;
7
- };
8
- export declare type NonReactive<T extends Target = Target> = T & {
9
- [SKIP]: any;
10
- };
3
+ declare type Reactive<T extends Target> = T;
11
4
  /**
12
5
  * Mark an object or array so that it is ignored by the reactivity system
13
6
  *
14
7
  * @param value the value to mark
15
8
  * @returns the object itself
16
9
  */
17
- export declare function markRaw<T extends Target>(value: T): NonReactive<T>;
10
+ export declare function markRaw<T extends Target>(value: T): T;
18
11
  /**
19
12
  * Given a reactive objet, return the raw (non reactive) underlying object
20
13
  *
21
14
  * @param value a reactive value
22
15
  * @returns the underlying value
23
16
  */
24
- export declare function toRaw<T extends object>(value: Reactive<T>): T;
17
+ export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
25
18
  /**
26
19
  * Clears all subscriptions of the Reactives associated with a given callback.
27
20
  *
@@ -32,6 +25,7 @@ export declare function getSubscriptions(callback: Callback): {
32
25
  target: object;
33
26
  keys: PropertyKey[];
34
27
  }[];
28
+ export declare const targets: WeakMap<object, object>;
35
29
  /**
36
30
  * Creates a reactive proxy for an object. Reading data on the reactive object
37
31
  * subscribes to changes to the data. Writing data on the object will cause the
@@ -46,7 +40,7 @@ export declare function getSubscriptions(callback: Callback): {
46
40
  * Subscriptions:
47
41
  * + Reading a property on an object will subscribe you to changes in the value
48
42
  * of that property.
49
- * + Accessing an object keys (eg with Object.keys or with `for..in`) will
43
+ * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
50
44
  * subscribe you to the creation/deletion of keys. Checking the presence of a
51
45
  * key on the object with 'in' has the same effect.
52
46
  * - getOwnPropertyDescriptor does not currently subscribe you to the property.
@@ -59,5 +53,5 @@ export declare function getSubscriptions(callback: Callback): {
59
53
  * reactive has changed
60
54
  * @returns a proxy that tracks changes to it
61
55
  */
62
- export declare function reactive<T extends Target>(target: T, callback?: Callback): Reactive<T> | NonReactive<T>;
56
+ export declare function reactive<T extends Target>(target: T, callback?: Callback): T;
63
57
  export {};
@@ -8,7 +8,7 @@ import { OwlError } from "./error_handling";
8
8
  */
9
9
  declare function withDefault(value: any, defaultValue: any): any;
10
10
  declare function callSlot(ctx: any, parent: any, key: string, name: string, dynamic: boolean, extra: any, defaultContent?: (ctx: any, node: any, key: string) => BDom): BDom;
11
- declare function capture(ctx: any): any;
11
+ declare function capture(ctx: any, component: any): any;
12
12
  declare function withKey(elem: any, k: string): any;
13
13
  declare function prepareList(collection: any): [any[], any[], number, any[]];
14
14
  declare function setContextValue(ctx: {
@@ -27,7 +27,7 @@ declare class LazyValue {
27
27
  toString(): any;
28
28
  }
29
29
  export declare function safeOutput(value: any, defaultValue?: any): ReturnType<typeof toggler>;
30
- declare function bind(ctx: any, fn: Function): Function;
30
+ declare function bind(component: any, fn: Function): Function;
31
31
  declare type RefMap = {
32
32
  [key: string]: HTMLElement | null;
33
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/owl",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Odoo Web Library (OWL)",
5
5
  "main": "dist/owl.cjs.js",
6
6
  "module": "dist/owl.es.js",