@odoo/owl 3.0.0-alpha.31 → 3.0.0-alpha.33
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/owl.cjs.js +162 -135
- package/dist/owl.es.js +162 -135
- package/dist/owl.iife.js +162 -135
- package/dist/owl.iife.min.js +8 -8
- package/dist/types/owl.d.ts +98 -109
- package/package.json +4 -4
package/dist/types/owl.d.ts
CHANGED
|
@@ -142,6 +142,51 @@ export interface ComputationAtom<T = any> extends Atom<T> {
|
|
|
142
142
|
state: ComputationState;
|
|
143
143
|
}
|
|
144
144
|
export declare function untrack<T>(fn: (...args: any[]) => T): T;
|
|
145
|
+
export interface ResourceOptions<T> {
|
|
146
|
+
name?: string;
|
|
147
|
+
validation?: T;
|
|
148
|
+
}
|
|
149
|
+
export interface ResourceAddOptions {
|
|
150
|
+
sequence?: number;
|
|
151
|
+
}
|
|
152
|
+
export declare class Resource<T> {
|
|
153
|
+
private _items;
|
|
154
|
+
private _name?;
|
|
155
|
+
private _validation?;
|
|
156
|
+
constructor(options?: ResourceOptions<T>);
|
|
157
|
+
items: ReactiveValue<T[], T[]>;
|
|
158
|
+
add(item: T, options?: ResourceAddOptions): Resource<T>;
|
|
159
|
+
delete(item: T): Resource<T>;
|
|
160
|
+
has(item: T): boolean;
|
|
161
|
+
use(item: T, options?: ResourceAddOptions): Resource<T>;
|
|
162
|
+
}
|
|
163
|
+
export interface PluginConstructor {
|
|
164
|
+
new (...args: any[]): Plugin$1;
|
|
165
|
+
id: string;
|
|
166
|
+
}
|
|
167
|
+
declare class Plugin$1 {
|
|
168
|
+
private static _shadowId;
|
|
169
|
+
static get id(): string;
|
|
170
|
+
static set id(shadowId: string);
|
|
171
|
+
__owl__: PluginManager;
|
|
172
|
+
constructor(manager: PluginManager);
|
|
173
|
+
setup(): void;
|
|
174
|
+
}
|
|
175
|
+
export interface PluginManagerOptions {
|
|
176
|
+
parent?: PluginManager | null;
|
|
177
|
+
config?: Record<string, any>;
|
|
178
|
+
}
|
|
179
|
+
declare class PluginManager extends Scope {
|
|
180
|
+
config: Record<string, any>;
|
|
181
|
+
plugins: Record<string, Plugin$1>;
|
|
182
|
+
ready: Promise<void>;
|
|
183
|
+
constructor(app: any, options?: PluginManagerOptions);
|
|
184
|
+
destroy(): void;
|
|
185
|
+
getPluginById<T extends Plugin$1>(id: string): T | null;
|
|
186
|
+
getPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
|
|
187
|
+
startPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
|
|
188
|
+
startPlugins(pluginConstructors: PluginConstructor[]): void;
|
|
189
|
+
}
|
|
145
190
|
/**
|
|
146
191
|
* Returns the active scope. Throws if no scope is active — use this inside
|
|
147
192
|
* hooks and setup functions where the caller is expected to be in a scope.
|
|
@@ -149,6 +194,7 @@ export declare function untrack<T>(fn: (...args: any[]) => T): T;
|
|
|
149
194
|
export declare function useScope(): Scope;
|
|
150
195
|
export declare abstract class Scope {
|
|
151
196
|
app: any;
|
|
197
|
+
pluginManager: PluginManager;
|
|
152
198
|
status: StatusValue;
|
|
153
199
|
computations: ComputationAtom[];
|
|
154
200
|
willStart: Array<() => any>;
|
|
@@ -226,31 +272,24 @@ export declare function markRaw<T extends Target>(value: T): T;
|
|
|
226
272
|
*/
|
|
227
273
|
export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
|
|
228
274
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
275
|
+
* Wraps an object so it behaves like a signal, but with the familiar
|
|
276
|
+
* property-access API: instead of `count()` / `count.set(n)`, you write
|
|
277
|
+
* `state.count` and `state.count = n`. Reading and writing the proxy
|
|
278
|
+
* transparently looks and feels like reading and writing the original object.
|
|
233
279
|
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
280
|
+
* Reactivity is nested: reading a property that holds another object/array
|
|
281
|
+
* returns a proxy for that value too, recursively. Arrays, Maps, Sets, and
|
|
282
|
+
* WeakMaps are also wrapped, so `state.items.push(x)` or `state.map.set(k, v)`
|
|
283
|
+
* notify subscribers the same way property writes do.
|
|
238
284
|
*
|
|
239
|
-
* Subscriptions
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
* key on the object with 'in' has the same effect.
|
|
245
|
-
* - getOwnPropertyDescriptor does not currently subscribe you to the property.
|
|
246
|
-
* This is a choice that was made because changing a key's value will trigger
|
|
247
|
-
* this trap and we do not want to subscribe by writes. This also means that
|
|
248
|
-
* Object.hasOwnProperty doesn't subscribe as it goes through this trap.
|
|
285
|
+
* Subscriptions are only created when a read happens *while a computation is
|
|
286
|
+
* active* — i.e. inside a component's render, or inside an `effect`,
|
|
287
|
+
* `computed`, or `asyncComputed`. Reading the proxy from a plain function
|
|
288
|
+
* with no surrounding computation just returns the value without subscribing
|
|
289
|
+
* anything.
|
|
249
290
|
*
|
|
250
|
-
* @param target the object
|
|
251
|
-
* @
|
|
252
|
-
* proxy has changed
|
|
253
|
-
* @returns a proxy that tracks changes to it
|
|
291
|
+
* @param target the object to make reactive
|
|
292
|
+
* @returns a proxy that tracks reads/writes against `target`
|
|
254
293
|
*/
|
|
255
294
|
export declare function proxy<T extends Target>(target: T): T;
|
|
256
295
|
export interface Signal<T> extends ReactiveValue<T> {
|
|
@@ -338,24 +377,6 @@ export type ResolveObjectType<T extends {}> = ResolveShapedObject<T extends stri
|
|
|
338
377
|
export type UnionToIntersection<U> = (U extends any ? (_: U) => any : never) extends (_: infer I) => void ? I : never;
|
|
339
378
|
declare function constructorType<T extends Constructor>(constructor: T): T;
|
|
340
379
|
export type LiteralTypes = number | string | boolean | null | undefined;
|
|
341
|
-
export interface ResourceOptions<T> {
|
|
342
|
-
name?: string;
|
|
343
|
-
validation?: T;
|
|
344
|
-
}
|
|
345
|
-
export interface ResourceAddOptions {
|
|
346
|
-
sequence?: number;
|
|
347
|
-
}
|
|
348
|
-
export declare class Resource<T> {
|
|
349
|
-
private _items;
|
|
350
|
-
private _name?;
|
|
351
|
-
private _validation?;
|
|
352
|
-
constructor(options?: ResourceOptions<T>);
|
|
353
|
-
items: ReactiveValue<T[], T[]>;
|
|
354
|
-
add(item: T, options?: ResourceAddOptions): Resource<T>;
|
|
355
|
-
delete(item: T): Resource<T>;
|
|
356
|
-
has(item: T): boolean;
|
|
357
|
-
use(item: T, options?: ResourceAddOptions): Resource<T>;
|
|
358
|
-
}
|
|
359
380
|
export interface RegistryOptions<T> {
|
|
360
381
|
name?: string;
|
|
361
382
|
validation?: T;
|
|
@@ -388,33 +409,43 @@ export declare class Registry<T> {
|
|
|
388
409
|
id: string;
|
|
389
410
|
} & T>(item: U, options?: RegistryAddOptions): Registry<T>;
|
|
390
411
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
412
|
+
/**
|
|
413
|
+
* Creates a reactive effect bound to the surrounding component or plugin.
|
|
414
|
+
* Equivalent to `onWillDestroy(effect(fn))`: the effect runs once immediately,
|
|
415
|
+
* re-runs whenever any reactive value (signal, computed, proxy property) read
|
|
416
|
+
* during its execution changes, and is disposed when the owning scope is
|
|
417
|
+
* destroyed. If the callback returns a function, that function is called as
|
|
418
|
+
* cleanup before each re-run and on disposal.
|
|
419
|
+
*/
|
|
420
|
+
export declare function useEffect(fn: Parameters<typeof effect>[0]): void;
|
|
421
|
+
/**
|
|
422
|
+
* Adds an event listener to a target and automatically removes it when the
|
|
423
|
+
* surrounding component or plugin is destroyed.
|
|
424
|
+
*
|
|
425
|
+
* `target` can be either an `EventTarget` (the listener is attached
|
|
426
|
+
* immediately) or a `Signal<EventTarget | null>` such as a `t-ref` (the
|
|
427
|
+
* listener is attached through a `useEffect` and re-attaches when the signal's
|
|
428
|
+
* value changes; nothing is attached while the signal is null).
|
|
429
|
+
*
|
|
430
|
+
* Example — close a menu when the user clicks anywhere on `window`:
|
|
431
|
+
* useListener(window, "click", () => this.close());
|
|
432
|
+
*/
|
|
433
|
+
export declare function useListener(target: EventTarget | Signal<EventTarget | null>, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
|
|
434
|
+
export declare function onWillStart(fn: (scope: Scope) => Promise<void> | void | any): void;
|
|
435
|
+
export declare function onWillDestroy(fn: (scope: Scope) => void | any): void;
|
|
436
|
+
export type PluginInstance<T extends PluginConstructor> = Omit<InstanceType<T>, "setup">;
|
|
437
|
+
export declare function plugin<T extends PluginConstructor>(pluginType: T): PluginInstance<T>;
|
|
438
|
+
export declare function config<T = any>(key: string): T;
|
|
439
|
+
export declare function config<T>(key: string, type: T): T;
|
|
440
|
+
export declare function config<T>(key: string, type: T, defaultValue: T): T;
|
|
441
|
+
export declare class EventBus extends EventTarget {
|
|
442
|
+
trigger(name: string, payload?: any): void;
|
|
406
443
|
}
|
|
407
|
-
declare class
|
|
408
|
-
config: Record<string, any>;
|
|
409
|
-
plugins: Record<string, Plugin$1>;
|
|
410
|
-
ready: Promise<void>;
|
|
411
|
-
constructor(app: any, options?: PluginManagerOptions);
|
|
412
|
-
destroy(): void;
|
|
413
|
-
getPluginById<T extends Plugin$1>(id: string): T | null;
|
|
414
|
-
getPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
|
|
415
|
-
startPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
|
|
416
|
-
startPlugins(pluginConstructors: PluginConstructor[]): void;
|
|
444
|
+
declare class Markup extends String {
|
|
417
445
|
}
|
|
446
|
+
export declare function htmlEscape(str: any): Markup;
|
|
447
|
+
export declare function markup(strings: TemplateStringsArray, ...placeholders: unknown[]): Markup;
|
|
448
|
+
export declare function markup(value: string): Markup;
|
|
418
449
|
declare class Fiber {
|
|
419
450
|
node: ComponentNode;
|
|
420
451
|
bdom: BDom | null;
|
|
@@ -473,7 +504,6 @@ declare class ComponentNode extends Scope implements VNode<ComponentNode> {
|
|
|
473
504
|
willPatch: LifecycleHook[];
|
|
474
505
|
patched: LifecycleHook[];
|
|
475
506
|
signalComputation: ComputationAtom;
|
|
476
|
-
pluginManager: PluginManager;
|
|
477
507
|
constructor(C: ComponentConstructor, props: Record<string, any>, app: App, parent: ComponentNode | null, parentKey: string | null);
|
|
478
508
|
decorate(f: Function, hookName: string): Function;
|
|
479
509
|
initiateRender(fiber: Fiber | MountFiber): Promise<void>;
|
|
@@ -586,15 +616,7 @@ export declare namespace xml {
|
|
|
586
616
|
var nextId: number;
|
|
587
617
|
}
|
|
588
618
|
declare function validateTarget(target: HTMLElement | ShadowRoot): void;
|
|
589
|
-
export declare class EventBus extends EventTarget {
|
|
590
|
-
trigger(name: string, payload?: any): void;
|
|
591
|
-
}
|
|
592
619
|
export declare function whenReady(fn?: any): Promise<void>;
|
|
593
|
-
declare class Markup extends String {
|
|
594
|
-
}
|
|
595
|
-
export declare function htmlEscape(str: any): Markup;
|
|
596
|
-
export declare function markup(strings: TemplateStringsArray, ...placeholders: unknown[]): Markup;
|
|
597
|
-
export declare function markup(value: string): Markup;
|
|
598
620
|
export type ComponentInstance<C extends ComponentConstructor> = C extends new (...args: any) => infer T ? T : never;
|
|
599
621
|
export interface RootConfig<P> {
|
|
600
622
|
props?: P;
|
|
@@ -659,47 +681,17 @@ export declare class Suspense extends Component {
|
|
|
659
681
|
private subRootMounted;
|
|
660
682
|
setup(): void;
|
|
661
683
|
}
|
|
662
|
-
export declare function prop(key: string):
|
|
684
|
+
export declare function prop<T = any>(key: string): T;
|
|
663
685
|
export declare function prop<T>(key: string, type: T): T;
|
|
664
686
|
export declare function prop<T>(key: string, type: T, defaultValue: T): T;
|
|
665
687
|
export type STATUS_DESCR = "new" | "started" | "mounted" | "cancelled" | "destroyed";
|
|
666
688
|
declare function status$1(entity: Component | Plugin$1): STATUS_DESCR;
|
|
667
|
-
|
|
668
|
-
* This hook will run a callback when a component is mounted and patched, and
|
|
669
|
-
* will run a cleanup function before patching and before unmounting the
|
|
670
|
-
* the component.
|
|
671
|
-
*
|
|
672
|
-
* @template T
|
|
673
|
-
* @param {Effect<T>} effect the effect to run on component mount and/or patch
|
|
674
|
-
* @param {()=>[...T]} [computeDependencies=()=>[NaN]] a callback to compute
|
|
675
|
-
* dependencies that will decide if the effect needs to be cleaned up and
|
|
676
|
-
* run again. If the dependencies did not change, the effect will not run
|
|
677
|
-
* again. The default value returns an array containing only NaN because
|
|
678
|
-
* NaN !== NaN, which will cause the effect to rerun on every patch.
|
|
679
|
-
*/
|
|
680
|
-
export declare function useEffect(fn: Parameters<typeof effect>[0]): void;
|
|
681
|
-
/**
|
|
682
|
-
* When a component needs to listen to DOM Events on element(s) that are not
|
|
683
|
-
* part of his hierarchy, we can use the `useListener` hook.
|
|
684
|
-
* It will immediately add the listener, and remove it whenever the plugin or
|
|
685
|
-
* component is destroyed.
|
|
686
|
-
*
|
|
687
|
-
* Example:
|
|
688
|
-
* a menu needs to listen to the click on window to be closed automatically
|
|
689
|
-
*
|
|
690
|
-
* Usage:
|
|
691
|
-
* in the constructor of the OWL component that needs to be notified,
|
|
692
|
-
* `useListener(window, 'click', () => this._doSomething());`
|
|
693
|
-
* */
|
|
694
|
-
export declare function useListener(target: EventTarget | Signal<EventTarget | null>, eventName: string, handler: EventListener, eventParams?: AddEventListenerOptions): void;
|
|
695
|
-
export declare function useApp(): App;
|
|
696
|
-
export declare function onWillStart(fn: (scope: Scope) => Promise<void> | void | any): void;
|
|
689
|
+
export declare const useApp: () => App;
|
|
697
690
|
export declare function onWillUpdateProps(fn: (nextProps: any, scope: ComponentNode) => Promise<void> | void | any): void;
|
|
698
691
|
export declare function onMounted(fn: (scope: ComponentNode) => void | any): void;
|
|
699
692
|
export declare function onWillPatch(fn: (scope: ComponentNode) => any | void): void;
|
|
700
693
|
export declare function onPatched(fn: (scope: ComponentNode) => void | any): void;
|
|
701
694
|
export declare function onWillUnmount(fn: (scope: ComponentNode) => void | any): void;
|
|
702
|
-
export declare function onWillDestroy(fn: (scope: Scope) => void | any): void;
|
|
703
695
|
export type OnErrorCallback = (error: any) => void | any;
|
|
704
696
|
export declare function onError(callback: OnErrorCallback): void;
|
|
705
697
|
declare function componentType(): typeof Component;
|
|
@@ -752,9 +744,6 @@ export declare const types: {
|
|
|
752
744
|
string: () => string;
|
|
753
745
|
tuple: <const T extends any[]>(types: T) => T;
|
|
754
746
|
};
|
|
755
|
-
export type PluginInstance<T extends PluginConstructor> = Omit<InstanceType<T>, "setup">;
|
|
756
|
-
export declare function plugin<T extends PluginConstructor>(pluginType: T): PluginInstance<T>;
|
|
757
|
-
export declare function config<T = any>(name: string, type?: T): T;
|
|
758
747
|
export declare function providePlugins(pluginConstructors: PluginConstructor[] | Resource<PluginConstructor>, config?: Record<string, any>): void;
|
|
759
748
|
export declare const blockDom: {
|
|
760
749
|
config: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odoo/owl",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.33",
|
|
4
4
|
"description": "Odoo Web Library (OWL)",
|
|
5
5
|
"main": "dist/owl.cjs.js",
|
|
6
6
|
"module": "dist/owl.es.js",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://github.com/odoo/owl#readme",
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@odoo/owl-compiler": "3.0.0-alpha.
|
|
47
|
-
"@odoo/owl-core": "3.0.0-alpha.
|
|
48
|
-
"@odoo/owl-runtime": "3.0.0-alpha.
|
|
46
|
+
"@odoo/owl-compiler": "3.0.0-alpha.33",
|
|
47
|
+
"@odoo/owl-core": "3.0.0-alpha.33",
|
|
48
|
+
"@odoo/owl-runtime": "3.0.0-alpha.33",
|
|
49
49
|
"jsdom": "^25.0.1"
|
|
50
50
|
}
|
|
51
51
|
}
|