@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
package/dist/types/owl.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare class VToggler {
|
|
|
14
14
|
}
|
|
15
15
|
declare function toggler(key: string, child: VNode): VNode<VToggler>;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
type BlockType = (data?: any[], children?: VNode[]) => VNode;
|
|
18
18
|
/**
|
|
19
19
|
* Compiling blocks is a multi-step process:
|
|
20
20
|
*
|
|
@@ -119,12 +119,54 @@ interface VNode<T = any> {
|
|
|
119
119
|
isOnlyChild?: boolean | undefined;
|
|
120
120
|
key?: any;
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
type BDom = VNode<any>;
|
|
123
123
|
declare function mount$1(vnode: VNode, fixture: HTMLElement, afterNode?: Node | null): void;
|
|
124
124
|
declare function patch(vnode1: VNode, vnode2: VNode, withBeforeRemove?: boolean): void;
|
|
125
125
|
declare function remove(vnode: VNode, withBeforeRemove?: boolean): void;
|
|
126
126
|
|
|
127
|
-
declare
|
|
127
|
+
declare enum ComputationState {
|
|
128
|
+
EXECUTED = 0,
|
|
129
|
+
STALE = 1,
|
|
130
|
+
PENDING = 2
|
|
131
|
+
}
|
|
132
|
+
type Computation<T = any> = {
|
|
133
|
+
compute?: () => T;
|
|
134
|
+
state: ComputationState;
|
|
135
|
+
sources: Set<Atom | Derived<any, any>>;
|
|
136
|
+
isEager?: boolean;
|
|
137
|
+
isDerived?: boolean;
|
|
138
|
+
value: T;
|
|
139
|
+
childrenEffect?: Computation[];
|
|
140
|
+
} & Opts;
|
|
141
|
+
type Opts = {
|
|
142
|
+
name?: string;
|
|
143
|
+
};
|
|
144
|
+
type Atom<T = any> = {
|
|
145
|
+
value: T;
|
|
146
|
+
observers: Set<Computation>;
|
|
147
|
+
} & Opts;
|
|
148
|
+
interface Derived<Prev, Next = Prev> extends Atom<Next>, Computation<Next> {
|
|
149
|
+
}
|
|
150
|
+
declare function untrack<T extends (...args: any[]) => any>(fn: T): ReturnType<T>;
|
|
151
|
+
|
|
152
|
+
type ReactiveValue<T> = () => T;
|
|
153
|
+
interface Signal<T> extends ReactiveValue<T> {
|
|
154
|
+
/**
|
|
155
|
+
* Update the value of the signal with a new value. If the new value is different
|
|
156
|
+
* from the previous values, all computations that depends on this signal will
|
|
157
|
+
* be invalidated, and effects will rerun.
|
|
158
|
+
*/
|
|
159
|
+
set(value: T): void;
|
|
160
|
+
/**
|
|
161
|
+
* Call the updater function (if given) to update the signal value.
|
|
162
|
+
* If the updater value is not given, then all computations that depends on
|
|
163
|
+
* this signal will be invalidated and effects will rerun.
|
|
164
|
+
*/
|
|
165
|
+
update(updater?: (value: T) => T): void;
|
|
166
|
+
}
|
|
167
|
+
declare function signal<T>(value: T, opts?: Opts): Signal<T>;
|
|
168
|
+
|
|
169
|
+
type BaseType = {
|
|
128
170
|
new (...args: any[]): any;
|
|
129
171
|
} | true | "*";
|
|
130
172
|
interface TypeInfo {
|
|
@@ -135,15 +177,15 @@ interface TypeInfo {
|
|
|
135
177
|
element?: TypeDescription;
|
|
136
178
|
values?: TypeDescription;
|
|
137
179
|
}
|
|
138
|
-
|
|
180
|
+
type ValueType = {
|
|
139
181
|
value: any;
|
|
140
182
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
183
|
+
type TypeDescription = BaseType | TypeInfo | ValueType | TypeDescription[];
|
|
184
|
+
type SimplifiedSchema = string[];
|
|
185
|
+
type NormalizedSchema = {
|
|
144
186
|
[key: string]: TypeDescription;
|
|
145
187
|
};
|
|
146
|
-
|
|
188
|
+
type Schema = SimplifiedSchema | NormalizedSchema;
|
|
147
189
|
/**
|
|
148
190
|
* Main validate function
|
|
149
191
|
*/
|
|
@@ -152,6 +194,67 @@ declare function validate(obj: {
|
|
|
152
194
|
}, spec: Schema): void;
|
|
153
195
|
declare function validateType(key: string, value: any, descr: TypeDescription): string | null;
|
|
154
196
|
|
|
197
|
+
declare class Resource<T> {
|
|
198
|
+
private _items;
|
|
199
|
+
private _name;
|
|
200
|
+
private _type?;
|
|
201
|
+
constructor(name?: string, type?: TypeDescription);
|
|
202
|
+
items: ReactiveValue<T[]>;
|
|
203
|
+
add(item: T, sequence?: number): Resource<T>;
|
|
204
|
+
remove(item: T): Resource<T>;
|
|
205
|
+
has(item: T): boolean;
|
|
206
|
+
}
|
|
207
|
+
declare function useResource<T>(r: Resource<T>, elements: T[]): void;
|
|
208
|
+
|
|
209
|
+
declare class Registry<T> {
|
|
210
|
+
_map: Signal<{
|
|
211
|
+
[key: string]: [number, T];
|
|
212
|
+
}>;
|
|
213
|
+
_name: string;
|
|
214
|
+
_type?: TypeDescription;
|
|
215
|
+
constructor(name?: string, type?: TypeDescription);
|
|
216
|
+
entries: ReactiveValue<[string, T][]>;
|
|
217
|
+
items: ReactiveValue<T[]>;
|
|
218
|
+
addById<U extends {
|
|
219
|
+
id: string;
|
|
220
|
+
} & T>(item: U, sequence?: number): Registry<T>;
|
|
221
|
+
add(key: string, value: T, sequence?: number): Registry<T>;
|
|
222
|
+
get(key: string, defaultValue?: T): T;
|
|
223
|
+
remove(key: string): void;
|
|
224
|
+
has(key: string): boolean;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare const enum STATUS {
|
|
228
|
+
NEW = 0,
|
|
229
|
+
MOUNTED = 1,
|
|
230
|
+
CANCELLED = 2,
|
|
231
|
+
DESTROYED = 3
|
|
232
|
+
}
|
|
233
|
+
type STATUS_DESCR = "new" | "started" | "mounted" | "cancelled" | "destroyed";
|
|
234
|
+
declare function status(): () => STATUS_DESCR;
|
|
235
|
+
|
|
236
|
+
interface PluginConstructor {
|
|
237
|
+
new (): Plugin;
|
|
238
|
+
id: string;
|
|
239
|
+
}
|
|
240
|
+
declare class Plugin {
|
|
241
|
+
static id: string;
|
|
242
|
+
setup(): void;
|
|
243
|
+
}
|
|
244
|
+
declare class PluginManager {
|
|
245
|
+
private children;
|
|
246
|
+
private parent;
|
|
247
|
+
private plugins;
|
|
248
|
+
private onDestroyCb;
|
|
249
|
+
status: STATUS;
|
|
250
|
+
constructor(parent: PluginManager | null);
|
|
251
|
+
destroy(): void;
|
|
252
|
+
getPluginById<T extends Plugin>(id: string): T | null;
|
|
253
|
+
getPlugin<T extends PluginConstructor>(pluginType: T): InstanceType<T> | null;
|
|
254
|
+
startPlugins(pluginTypes: PluginConstructor[]): Plugin[];
|
|
255
|
+
}
|
|
256
|
+
declare function plugin<T extends PluginConstructor>(pluginType: T): InstanceType<T>;
|
|
257
|
+
|
|
155
258
|
declare class Fiber {
|
|
156
259
|
node: ComponentNode;
|
|
157
260
|
bdom: BDom | null;
|
|
@@ -174,7 +277,7 @@ declare class RootFiber extends Fiber {
|
|
|
174
277
|
complete(): void;
|
|
175
278
|
setCounter(newValue: number): void;
|
|
176
279
|
}
|
|
177
|
-
|
|
280
|
+
type Position = "first-child" | "last-child";
|
|
178
281
|
interface MountOptions {
|
|
179
282
|
position?: Position;
|
|
180
283
|
}
|
|
@@ -185,116 +288,24 @@ declare class MountFiber extends RootFiber {
|
|
|
185
288
|
complete(): void;
|
|
186
289
|
}
|
|
187
290
|
|
|
188
|
-
declare type Callback = () => void;
|
|
189
|
-
/**
|
|
190
|
-
* Creates a batched version of a callback so that all calls to it in the same
|
|
191
|
-
* microtick will only call the original callback once.
|
|
192
|
-
*
|
|
193
|
-
* @param callback the callback to batch
|
|
194
|
-
* @returns a batched version of the original callback
|
|
195
|
-
*/
|
|
196
|
-
declare function batched(callback: Callback): Callback;
|
|
197
|
-
declare function validateTarget(target: HTMLElement | ShadowRoot): void;
|
|
198
|
-
declare class EventBus extends EventTarget {
|
|
199
|
-
trigger(name: string, payload?: any): void;
|
|
200
|
-
}
|
|
201
|
-
declare function whenReady(fn?: any): Promise<void>;
|
|
202
|
-
declare function loadFile(url: string): Promise<string>;
|
|
203
|
-
declare class Markup extends String {
|
|
204
|
-
}
|
|
205
|
-
declare function htmlEscape(str: any): Markup;
|
|
206
|
-
declare function markup(strings: TemplateStringsArray, ...placeholders: unknown[]): Markup;
|
|
207
|
-
declare function markup(value: string): Markup;
|
|
208
|
-
|
|
209
|
-
declare type Target = object;
|
|
210
|
-
declare type Reactive<T extends Target> = T;
|
|
211
|
-
/**
|
|
212
|
-
* Mark an object or array so that it is ignored by the reactivity system
|
|
213
|
-
*
|
|
214
|
-
* @param value the value to mark
|
|
215
|
-
* @returns the object itself
|
|
216
|
-
*/
|
|
217
|
-
declare function markRaw<T extends Target>(value: T): T;
|
|
218
|
-
/**
|
|
219
|
-
* Given a reactive objet, return the raw (non reactive) underlying object
|
|
220
|
-
*
|
|
221
|
-
* @param value a reactive value
|
|
222
|
-
* @returns the underlying value
|
|
223
|
-
*/
|
|
224
|
-
declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
|
|
225
|
-
declare function getSubscriptions(callback: Callback): {
|
|
226
|
-
target: object;
|
|
227
|
-
keys: (string | number | symbol)[];
|
|
228
|
-
}[];
|
|
229
|
-
/**
|
|
230
|
-
* Creates a reactive proxy for an object. Reading data on the reactive object
|
|
231
|
-
* subscribes to changes to the data. Writing data on the object will cause the
|
|
232
|
-
* notify callback to be called if there are suscriptions to that data. Nested
|
|
233
|
-
* objects and arrays are automatically made reactive as well.
|
|
234
|
-
*
|
|
235
|
-
* Whenever you are notified of a change, all subscriptions are cleared, and if
|
|
236
|
-
* you would like to be notified of any further changes, you should go read
|
|
237
|
-
* the underlying data again. We assume that if you don't go read it again after
|
|
238
|
-
* being notified, it means that you are no longer interested in that data.
|
|
239
|
-
*
|
|
240
|
-
* Subscriptions:
|
|
241
|
-
* + Reading a property on an object will subscribe you to changes in the value
|
|
242
|
-
* of that property.
|
|
243
|
-
* + Accessing an object's keys (eg with Object.keys or with `for..in`) will
|
|
244
|
-
* subscribe you to the creation/deletion of keys. Checking the presence of a
|
|
245
|
-
* key on the object with 'in' has the same effect.
|
|
246
|
-
* - getOwnPropertyDescriptor does not currently subscribe you to the property.
|
|
247
|
-
* This is a choice that was made because changing a key's value will trigger
|
|
248
|
-
* this trap and we do not want to subscribe by writes. This also means that
|
|
249
|
-
* Object.hasOwnProperty doesn't subscribe as it goes through this trap.
|
|
250
|
-
*
|
|
251
|
-
* @param target the object for which to create a reactive proxy
|
|
252
|
-
* @param callback the function to call when an observed property of the
|
|
253
|
-
* reactive has changed
|
|
254
|
-
* @returns a proxy that tracks changes to it
|
|
255
|
-
*/
|
|
256
|
-
declare function reactive<T extends Target>(target: T, callback?: Callback): T;
|
|
257
|
-
|
|
258
|
-
declare const enum STATUS {
|
|
259
|
-
NEW = 0,
|
|
260
|
-
MOUNTED = 1,
|
|
261
|
-
CANCELLED = 2,
|
|
262
|
-
DESTROYED = 3
|
|
263
|
-
}
|
|
264
|
-
declare type STATUS_DESCR = "new" | "mounted" | "cancelled" | "destroyed";
|
|
265
|
-
declare function status(component: Component): STATUS_DESCR;
|
|
266
|
-
|
|
267
291
|
declare function useComponent(): Component;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
* Reading data from the returned object (eg during rendering) will cause the
|
|
271
|
-
* component to subscribe to that data and be rerendered when it changes.
|
|
272
|
-
*
|
|
273
|
-
* @param state the state to observe
|
|
274
|
-
* @returns a reactive object that will cause the component to re-render on
|
|
275
|
-
* relevant changes
|
|
276
|
-
* @see reactive
|
|
277
|
-
*/
|
|
278
|
-
declare function useState<T extends object>(state: T): T;
|
|
279
|
-
declare type LifecycleHook = Function;
|
|
280
|
-
declare class ComponentNode<P extends Props = any, E = any> implements VNode<ComponentNode<P, E>> {
|
|
292
|
+
type LifecycleHook = Function;
|
|
293
|
+
declare class ComponentNode implements VNode<ComponentNode> {
|
|
281
294
|
el?: HTMLElement | Text | undefined;
|
|
282
295
|
app: App;
|
|
283
296
|
fiber: Fiber | null;
|
|
284
|
-
component: Component
|
|
297
|
+
component: Component;
|
|
285
298
|
bdom: BDom | null;
|
|
286
299
|
status: STATUS;
|
|
287
300
|
forceNextRender: boolean;
|
|
288
301
|
parentKey: string | null;
|
|
289
|
-
|
|
290
|
-
|
|
302
|
+
name: string;
|
|
303
|
+
props: Record<string, any>;
|
|
291
304
|
renderFn: Function;
|
|
292
305
|
parent: ComponentNode | null;
|
|
293
|
-
childEnv: Env;
|
|
294
306
|
children: {
|
|
295
307
|
[key: string]: ComponentNode;
|
|
296
308
|
};
|
|
297
|
-
refs: any;
|
|
298
309
|
willStart: LifecycleHook[];
|
|
299
310
|
willUpdateProps: LifecycleHook[];
|
|
300
311
|
willUnmount: LifecycleHook[];
|
|
@@ -302,7 +313,9 @@ declare class ComponentNode<P extends Props = any, E = any> implements VNode<Com
|
|
|
302
313
|
willPatch: LifecycleHook[];
|
|
303
314
|
patched: LifecycleHook[];
|
|
304
315
|
willDestroy: LifecycleHook[];
|
|
305
|
-
|
|
316
|
+
signalComputation: Computation;
|
|
317
|
+
pluginManager: PluginManager;
|
|
318
|
+
constructor(C: ComponentConstructor, props: Record<string, any>, app: App, parent: ComponentNode | null, parentKey: string | null);
|
|
306
319
|
mountComponent(target: any, options?: MountOptions): void;
|
|
307
320
|
initiateRender(fiber: Fiber | MountFiber): Promise<void>;
|
|
308
321
|
render(deep: boolean): Promise<void>;
|
|
@@ -310,58 +323,41 @@ declare class ComponentNode<P extends Props = any, E = any> implements VNode<Com
|
|
|
310
323
|
_cancel(): void;
|
|
311
324
|
destroy(): void;
|
|
312
325
|
_destroy(): void;
|
|
313
|
-
updateAndRender(props:
|
|
326
|
+
updateAndRender(props: Record<string, any>, parentFiber: Fiber): Promise<void>;
|
|
314
327
|
/**
|
|
315
328
|
* Finds a child that has dom that is not yet updated, and update it. This
|
|
316
329
|
* method is meant to be used only in the context of repatching the dom after
|
|
317
330
|
* a mounted hook failed and was handled.
|
|
318
331
|
*/
|
|
319
332
|
updateDom(): void;
|
|
320
|
-
/**
|
|
321
|
-
* Sets a ref to a given HTMLElement.
|
|
322
|
-
*
|
|
323
|
-
* @param name the name of the ref to set
|
|
324
|
-
* @param el the HTMLElement to set the ref to. The ref is not set if the el
|
|
325
|
-
* is null, but useRef will not return elements that are not in the DOM
|
|
326
|
-
*/
|
|
327
|
-
setRef(name: string, el: HTMLElement | null): void;
|
|
328
333
|
firstNode(): Node | undefined;
|
|
329
334
|
mount(parent: HTMLElement, anchor: ChildNode): void;
|
|
330
335
|
moveBeforeDOMNode(node: Node | null, parent?: HTMLElement): void;
|
|
331
|
-
moveBeforeVNode(other: ComponentNode
|
|
336
|
+
moveBeforeVNode(other: ComponentNode | null, afterNode: Node | null): void;
|
|
332
337
|
patch(): void;
|
|
333
338
|
_patch(): void;
|
|
334
339
|
beforeRemove(): void;
|
|
335
340
|
remove(): void;
|
|
336
|
-
get name(): string;
|
|
337
|
-
get subscriptions(): ReturnType<typeof getSubscriptions>;
|
|
338
341
|
}
|
|
339
342
|
|
|
340
|
-
declare type Props = {
|
|
341
|
-
[key: string]: any;
|
|
342
|
-
};
|
|
343
343
|
interface StaticComponentProperties {
|
|
344
344
|
template: string;
|
|
345
|
-
defaultProps?: any;
|
|
346
|
-
props?: Schema;
|
|
347
345
|
components?: {
|
|
348
346
|
[componentName: string]: ComponentConstructor;
|
|
349
347
|
};
|
|
350
348
|
}
|
|
351
|
-
|
|
352
|
-
|
|
349
|
+
interface ComponentConstructor extends StaticComponentProperties {
|
|
350
|
+
new (node: ComponentNode): Component;
|
|
351
|
+
}
|
|
352
|
+
declare class Component {
|
|
353
353
|
static template: string;
|
|
354
|
-
static props?: Schema;
|
|
355
|
-
static defaultProps?: any;
|
|
356
|
-
props: Props;
|
|
357
|
-
env: Env;
|
|
358
354
|
__owl__: ComponentNode;
|
|
359
|
-
constructor(
|
|
355
|
+
constructor(node: ComponentNode);
|
|
360
356
|
setup(): void;
|
|
361
357
|
render(deep?: boolean): void;
|
|
362
358
|
}
|
|
363
359
|
|
|
364
|
-
|
|
360
|
+
type ErrorParams = {
|
|
365
361
|
error: any;
|
|
366
362
|
} & ({
|
|
367
363
|
node: ComponentNode;
|
|
@@ -370,6 +366,51 @@ declare type ErrorParams = {
|
|
|
370
366
|
});
|
|
371
367
|
declare function handleError(params: ErrorParams): void;
|
|
372
368
|
|
|
369
|
+
type Target = object;
|
|
370
|
+
type Reactive<T extends Target> = T;
|
|
371
|
+
/**
|
|
372
|
+
* Mark an object or array so that it is ignored by the reactivity system
|
|
373
|
+
*
|
|
374
|
+
* @param value the value to mark
|
|
375
|
+
* @returns the object itself
|
|
376
|
+
*/
|
|
377
|
+
declare function markRaw<T extends Target>(value: T): T;
|
|
378
|
+
/**
|
|
379
|
+
* Given a proxy objet, return the raw (non proxy) underlying object
|
|
380
|
+
*
|
|
381
|
+
* @param value a proxy value
|
|
382
|
+
* @returns the underlying value
|
|
383
|
+
*/
|
|
384
|
+
declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
|
|
385
|
+
/**
|
|
386
|
+
* Creates a reactive proxy for an object. Reading data on the proxy object
|
|
387
|
+
* subscribes to changes to the data. Writing data on the object will cause the
|
|
388
|
+
* notify callback to be called if there are suscriptions to that data. Nested
|
|
389
|
+
* objects and arrays are automatically made reactive as well.
|
|
390
|
+
*
|
|
391
|
+
* Whenever you are notified of a change, all subscriptions are cleared, and if
|
|
392
|
+
* you would like to be notified of any further changes, you should go read
|
|
393
|
+
* the underlying data again. We assume that if you don't go read it again after
|
|
394
|
+
* being notified, it means that you are no longer interested in that data.
|
|
395
|
+
*
|
|
396
|
+
* Subscriptions:
|
|
397
|
+
* + Reading a property on an object will subscribe you to changes in the value
|
|
398
|
+
* of that property.
|
|
399
|
+
* + Accessing an object's keys (eg with Object.keys or with `for..in`) will
|
|
400
|
+
* subscribe you to the creation/deletion of keys. Checking the presence of a
|
|
401
|
+
* key on the object with 'in' has the same effect.
|
|
402
|
+
* - getOwnPropertyDescriptor does not currently subscribe you to the property.
|
|
403
|
+
* This is a choice that was made because changing a key's value will trigger
|
|
404
|
+
* this trap and we do not want to subscribe by writes. This also means that
|
|
405
|
+
* Object.hasOwnProperty doesn't subscribe as it goes through this trap.
|
|
406
|
+
*
|
|
407
|
+
* @param target the object for which to create a proxy proxy
|
|
408
|
+
* @param callback the function to call when an observed property of the
|
|
409
|
+
* proxy has changed
|
|
410
|
+
* @returns a proxy that tracks changes to it
|
|
411
|
+
*/
|
|
412
|
+
declare function proxy<T extends Target>(target: T): T;
|
|
413
|
+
|
|
373
414
|
declare class Scheduler {
|
|
374
415
|
static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
|
|
375
416
|
tasks: Set<RootFiber>;
|
|
@@ -390,31 +431,92 @@ declare class Scheduler {
|
|
|
390
431
|
processFiber(fiber: RootFiber): void;
|
|
391
432
|
}
|
|
392
433
|
|
|
393
|
-
declare type customDirectives = Record<string, (node: Element, value: string, modifier: string[]) => void>;
|
|
394
|
-
|
|
395
434
|
interface Config {
|
|
396
435
|
translateFn?: (s: string, translationCtx: string) => string;
|
|
397
436
|
translatableAttributes?: string[];
|
|
398
437
|
dev?: boolean;
|
|
399
438
|
}
|
|
400
439
|
|
|
401
|
-
|
|
402
|
-
|
|
440
|
+
type CustomDirectives = Record<string, (node: Element, value: string, modifier: string[]) => void>;
|
|
441
|
+
type Template = (context: any, vnode: any, key?: string) => BDom;
|
|
442
|
+
type TemplateFunction = (app: TemplateSet, bdom: any, helpers: any) => Template;
|
|
403
443
|
interface CompileOptions extends Config {
|
|
404
444
|
name?: string;
|
|
405
|
-
customDirectives?:
|
|
445
|
+
customDirectives?: CustomDirectives;
|
|
406
446
|
hasGlobalValues: boolean;
|
|
407
447
|
}
|
|
408
448
|
declare function compile(template: string | Element, options?: CompileOptions): TemplateFunction;
|
|
409
449
|
|
|
450
|
+
type ConstructorTypedPropsValidation<T = any> = new (...args: any) => T;
|
|
451
|
+
type UnionTypedPropsValidation = ReadonlyArray<TypedPropsValidation>;
|
|
452
|
+
type OptionalSchemaTypedPropsValidation<O extends boolean> = {
|
|
453
|
+
optional: O;
|
|
454
|
+
};
|
|
455
|
+
type DefaultValuedSchemaTypedPropsValidation<T> = {
|
|
456
|
+
defaultValue: T;
|
|
457
|
+
};
|
|
458
|
+
type ValidableSchemaTypedPropsValidation = {
|
|
459
|
+
validate(value: any): boolean;
|
|
460
|
+
};
|
|
461
|
+
type TypeSchemaTypedPropsValidation<T> = {
|
|
462
|
+
type: new (...args: any) => T;
|
|
463
|
+
};
|
|
464
|
+
type MapSchemaTypedPropsValidation = {
|
|
465
|
+
type: ObjectConstructor;
|
|
466
|
+
shape: PropsValidation;
|
|
467
|
+
};
|
|
468
|
+
type RecordSchemaTypedPropsValidation = {
|
|
469
|
+
type: ObjectConstructor;
|
|
470
|
+
values: TypedPropsValidation;
|
|
471
|
+
};
|
|
472
|
+
type ArraySchemaTypedPropsValidation = {
|
|
473
|
+
type: ArrayConstructor;
|
|
474
|
+
element: TypedPropsValidation;
|
|
475
|
+
};
|
|
476
|
+
type SchemaTypedPropsValidation<T, O extends boolean> = {
|
|
477
|
+
type?: new (...args: any) => T;
|
|
478
|
+
optional?: O;
|
|
479
|
+
defaultValue?: T;
|
|
480
|
+
validate?(value: T): boolean;
|
|
481
|
+
shape?: PropsValidation;
|
|
482
|
+
values?: TypedPropsValidation;
|
|
483
|
+
element?: TypedPropsValidation;
|
|
484
|
+
};
|
|
485
|
+
type ValueTypedPropsValidation<T = any> = {
|
|
486
|
+
value: T;
|
|
487
|
+
};
|
|
488
|
+
type TypedPropsValidation = true | ConstructorTypedPropsValidation | UnionTypedPropsValidation | SchemaTypedPropsValidation<any, boolean> | ValueTypedPropsValidation;
|
|
489
|
+
type RecordPropsValidation = Record<string, TypedPropsValidation>;
|
|
490
|
+
type KeysPropsValidation = readonly string[];
|
|
491
|
+
type PropsValidation = RecordPropsValidation | KeysPropsValidation;
|
|
492
|
+
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;
|
|
493
|
+
type ConvertPropsValidation<V extends PropsValidation> = V extends KeysPropsValidation ? {
|
|
494
|
+
[K in V[number] as K extends `${infer N}?` ? N : never]?: any;
|
|
495
|
+
} & {
|
|
496
|
+
[K in V[number] as K extends `${string}?` ? never : K]: any;
|
|
497
|
+
} : V extends RecordPropsValidation ? {
|
|
498
|
+
[K in keyof V as V[K] extends OptionalSchemaTypedPropsValidation<true> ? K : never]?: ConvertTypedPropsValidation<V[K]>;
|
|
499
|
+
} & {
|
|
500
|
+
[K in keyof V as V[K] extends OptionalSchemaTypedPropsValidation<true> ? never : K]: ConvertTypedPropsValidation<V[K]>;
|
|
501
|
+
} : never;
|
|
502
|
+
declare const isProps: unique symbol;
|
|
503
|
+
type IsPropsObj = {
|
|
504
|
+
[isProps]: true;
|
|
505
|
+
};
|
|
506
|
+
type Props<T, V extends PropsValidation> = IsPropsObj & (unknown extends T ? ConvertPropsValidation<V> : T);
|
|
507
|
+
type GetProps<T extends Component> = {
|
|
508
|
+
[K in keyof T]: T[K] extends IsPropsObj ? (x: Omit<T[K], typeof isProps>) => void : never;
|
|
509
|
+
}[keyof T] extends (x: infer I) => void ? {
|
|
510
|
+
[K in keyof I]: I[K];
|
|
511
|
+
} : never;
|
|
512
|
+
declare function props<T = unknown, V extends PropsValidation = PropsValidation>(validation?: V): Props<T, V>;
|
|
513
|
+
|
|
410
514
|
declare class Portal extends Component {
|
|
411
515
|
static template: string;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
readonly slots: true;
|
|
417
|
-
};
|
|
516
|
+
props: Props<unknown, {
|
|
517
|
+
target: StringConstructor;
|
|
518
|
+
slots: true;
|
|
519
|
+
}>;
|
|
418
520
|
setup(): void;
|
|
419
521
|
}
|
|
420
522
|
|
|
@@ -424,7 +526,7 @@ interface TemplateSetConfig {
|
|
|
424
526
|
translateFn?: (s: string, translationCtx: string) => string;
|
|
425
527
|
templates?: string | Document | Record<string, string>;
|
|
426
528
|
getTemplate?: (s: string) => Element | Function | string | void;
|
|
427
|
-
customDirectives?:
|
|
529
|
+
customDirectives?: CustomDirectives;
|
|
428
530
|
globalValues?: object;
|
|
429
531
|
}
|
|
430
532
|
declare class TemplateSet {
|
|
@@ -438,7 +540,7 @@ declare class TemplateSet {
|
|
|
438
540
|
translateFn?: (s: string, translationCtx: string) => string;
|
|
439
541
|
translatableAttributes?: string[];
|
|
440
542
|
Portal: typeof Portal;
|
|
441
|
-
customDirectives:
|
|
543
|
+
customDirectives: CustomDirectives;
|
|
442
544
|
runtimeUtils: object;
|
|
443
545
|
hasGlobalValues: boolean;
|
|
444
546
|
constructor(config?: TemplateSetConfig);
|
|
@@ -456,17 +558,36 @@ declare namespace xml {
|
|
|
456
558
|
var nextId: number;
|
|
457
559
|
}
|
|
458
560
|
|
|
459
|
-
|
|
460
|
-
|
|
561
|
+
type Callback = () => void;
|
|
562
|
+
/**
|
|
563
|
+
* Creates a batched version of a callback so that all calls to it in the same
|
|
564
|
+
* microtick will only call the original callback once.
|
|
565
|
+
*
|
|
566
|
+
* @param callback the callback to batch
|
|
567
|
+
* @returns a batched version of the original callback
|
|
568
|
+
*/
|
|
569
|
+
declare function batched(callback: Callback): Callback;
|
|
570
|
+
declare function validateTarget(target: HTMLElement | ShadowRoot): void;
|
|
571
|
+
declare class EventBus extends EventTarget {
|
|
572
|
+
trigger(name: string, payload?: any): void;
|
|
573
|
+
}
|
|
574
|
+
declare function whenReady(fn?: any): Promise<void>;
|
|
575
|
+
declare class Markup extends String {
|
|
461
576
|
}
|
|
462
|
-
|
|
577
|
+
declare function htmlEscape(str: any): Markup;
|
|
578
|
+
declare function markup(strings: TemplateStringsArray, ...placeholders: unknown[]): Markup;
|
|
579
|
+
declare function markup(value: string): Markup;
|
|
580
|
+
|
|
581
|
+
type ComponentInstance<C extends ComponentConstructor> = C extends new (...args: any) => infer T ? T : never;
|
|
582
|
+
interface RootConfig<P> {
|
|
583
|
+
pluginManager?: PluginManager;
|
|
463
584
|
props?: P;
|
|
464
|
-
env?: E;
|
|
465
585
|
}
|
|
466
|
-
interface AppConfig
|
|
586
|
+
interface AppConfig extends TemplateSetConfig {
|
|
467
587
|
name?: string;
|
|
588
|
+
plugins?: (typeof Plugin)[];
|
|
589
|
+
pluginManager?: PluginManager;
|
|
468
590
|
test?: boolean;
|
|
469
|
-
warnIfNoStaticProps?: boolean;
|
|
470
591
|
}
|
|
471
592
|
declare global {
|
|
472
593
|
interface Window {
|
|
@@ -475,65 +596,39 @@ declare global {
|
|
|
475
596
|
Fiber: typeof Fiber;
|
|
476
597
|
RootFiber: typeof RootFiber;
|
|
477
598
|
toRaw: typeof toRaw;
|
|
478
|
-
|
|
599
|
+
proxy: typeof proxy;
|
|
479
600
|
};
|
|
480
601
|
}
|
|
481
602
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
603
|
+
type MountTarget = HTMLElement | ShadowRoot;
|
|
604
|
+
interface Root<T extends ComponentConstructor> {
|
|
605
|
+
node: ComponentNode;
|
|
606
|
+
promise: Promise<ComponentInstance<T>>;
|
|
607
|
+
mount(target: MountTarget, options?: MountOptions): Promise<ComponentInstance<T>>;
|
|
485
608
|
destroy(): void;
|
|
486
609
|
}
|
|
487
|
-
declare class App
|
|
610
|
+
declare class App extends TemplateSet {
|
|
488
611
|
static validateTarget: typeof validateTarget;
|
|
489
|
-
static apps: Set<App
|
|
612
|
+
static apps: Set<App>;
|
|
490
613
|
static version: string;
|
|
491
614
|
name: string;
|
|
492
|
-
Root: ComponentConstructor<P, E>;
|
|
493
|
-
props: P;
|
|
494
|
-
env: E;
|
|
495
615
|
scheduler: Scheduler;
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
makeNode(Component: ComponentConstructor, props: any): ComponentNode;
|
|
503
|
-
mountNode(node: ComponentNode, target: HTMLElement | ShadowRoot, options?: MountOptions): any;
|
|
616
|
+
roots: Set<Root<any>>;
|
|
617
|
+
pluginManager: PluginManager;
|
|
618
|
+
constructor(config?: AppConfig);
|
|
619
|
+
createRoot<T extends ComponentConstructor>(Root: T, config?: RootConfig<GetProps<ComponentInstance<T>>>): Root<T>;
|
|
620
|
+
makeNode<T extends ComponentConstructor>(Component: T, props: GetProps<ComponentInstance<T>>): ComponentNode;
|
|
621
|
+
mountNode(node: ComponentNode, target: HTMLElement | ShadowRoot, resolve: (c: any) => void, reject: (e: any) => void, options?: MountOptions): void;
|
|
504
622
|
destroy(): void;
|
|
505
|
-
createComponent<P extends
|
|
623
|
+
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;
|
|
506
624
|
handleError(...args: Parameters<typeof handleError>): void;
|
|
507
625
|
}
|
|
508
|
-
declare function mount<T extends
|
|
626
|
+
declare function mount<T extends ComponentConstructor>(C: T, target: MountTarget, config?: AppConfig & RootConfig<GetProps<ComponentInstance<T>>> & MountOptions): Promise<ComponentInstance<T>>;
|
|
627
|
+
|
|
628
|
+
declare function computed<T>(fn: () => T, opts?: Opts): ReactiveValue<T>;
|
|
629
|
+
|
|
630
|
+
declare function effect<T>(fn: () => T, opts?: Opts): () => void;
|
|
509
631
|
|
|
510
|
-
/**
|
|
511
|
-
* The purpose of this hook is to allow components to get a reference to a sub
|
|
512
|
-
* html node or component.
|
|
513
|
-
*/
|
|
514
|
-
declare function useRef<T extends HTMLElement = HTMLElement>(name: string): {
|
|
515
|
-
el: T | null;
|
|
516
|
-
};
|
|
517
|
-
/**
|
|
518
|
-
* This hook is useful as a building block for some customized hooks, that may
|
|
519
|
-
* need a reference to the env of the component calling them.
|
|
520
|
-
*/
|
|
521
|
-
declare function useEnv<E extends Env>(): E;
|
|
522
|
-
/**
|
|
523
|
-
* This hook is a simple way to let components use a sub environment. Note that
|
|
524
|
-
* like for all hooks, it is important that this is only called in the
|
|
525
|
-
* constructor method.
|
|
526
|
-
*/
|
|
527
|
-
declare function useSubEnv(envExtension: Env): void;
|
|
528
|
-
declare function useChildSubEnv(envExtension: Env): void;
|
|
529
|
-
declare type EffectDeps<T extends unknown[]> = T | (T extends [...infer H, never] ? EffectDeps<H> : never);
|
|
530
|
-
/**
|
|
531
|
-
* @template T
|
|
532
|
-
* @param {...T} dependencies the dependencies computed by computeDependencies
|
|
533
|
-
* @returns {void|(()=>void)} a cleanup function that reverses the side
|
|
534
|
-
* effects of the effect callback.
|
|
535
|
-
*/
|
|
536
|
-
declare type Effect<T extends unknown[]> = (...dependencies: EffectDeps<T>) => void | (() => void);
|
|
537
632
|
/**
|
|
538
633
|
* This hook will run a callback when a component is mounted and patched, and
|
|
539
634
|
* will run a cleanup function before patching and before unmounting the
|
|
@@ -547,10 +642,10 @@ declare type Effect<T extends unknown[]> = (...dependencies: EffectDeps<T>) => v
|
|
|
547
642
|
* again. The default value returns an array containing only NaN because
|
|
548
643
|
* NaN !== NaN, which will cause the effect to rerun on every patch.
|
|
549
644
|
*/
|
|
550
|
-
declare function useEffect
|
|
645
|
+
declare function useEffect(fn: Parameters<typeof effect>[0]): void;
|
|
551
646
|
/**
|
|
552
647
|
* When a component needs to listen to DOM Events on element(s) that are not
|
|
553
|
-
* part of his hierarchy, we can use the `
|
|
648
|
+
* part of his hierarchy, we can use the `useListener` hook.
|
|
554
649
|
* It will correctly add and remove the event listener, whenever the
|
|
555
650
|
* component is mounted and unmounted.
|
|
556
651
|
*
|
|
@@ -559,9 +654,10 @@ declare function useEffect<T extends unknown[]>(effect: Effect<T>, computeDepend
|
|
|
559
654
|
*
|
|
560
655
|
* Usage:
|
|
561
656
|
* in the constructor of the OWL component that needs to be notified,
|
|
562
|
-
* `
|
|
657
|
+
* `useListener(window, 'click', this._doSomething);`
|
|
563
658
|
* */
|
|
564
|
-
declare function
|
|
659
|
+
declare function useListener(target: EventTarget, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
|
|
660
|
+
declare function usePlugins(Plugins: PluginConstructor[]): Plugin[];
|
|
565
661
|
|
|
566
662
|
declare function onWillStart(fn: () => Promise<void> | void | any): void;
|
|
567
663
|
declare function onWillUpdateProps(fn: (nextProps: any) => Promise<void> | void | any): void;
|
|
@@ -570,9 +666,7 @@ declare function onWillPatch(fn: () => any | void): void;
|
|
|
570
666
|
declare function onPatched(fn: () => void | any): void;
|
|
571
667
|
declare function onWillUnmount(fn: () => void | any): void;
|
|
572
668
|
declare function onWillDestroy(fn: () => void | any): void;
|
|
573
|
-
|
|
574
|
-
declare function onRendered(fn: () => void | any): void;
|
|
575
|
-
declare type OnErrorCallback = (error: any) => void | any;
|
|
669
|
+
type OnErrorCallback = (error: any) => void | any;
|
|
576
670
|
declare function onError(callback: OnErrorCallback): void;
|
|
577
671
|
|
|
578
672
|
declare class OwlError extends Error {
|
|
@@ -600,4 +694,4 @@ declare const __info__: {
|
|
|
600
694
|
version: string;
|
|
601
695
|
};
|
|
602
696
|
|
|
603
|
-
export { App, Component, ComponentConstructor, EventBus, OwlError, __info__, batched, blockDom,
|
|
697
|
+
export { App, Component, ComponentConstructor, EventBus, GetProps, OwlError, Plugin, PluginConstructor, PluginManager, PropsValidation, ReactiveValue, Registry, Resource, Signal, __info__, batched, blockDom, computed, effect, htmlEscape, markRaw, markup, mount, onError, onMounted, onPatched, onWillDestroy, onWillPatch, onWillStart, onWillUnmount, onWillUpdateProps, plugin, props, proxy, signal, status, toRaw, untrack, useComponent, useEffect, useListener, usePlugins, useResource, validate, validateType, whenReady, xml };
|