@odoo/owl 3.0.0-alpha.19 → 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.
- package/dist/compile_templates.mjs +150 -177
- package/dist/owl.cjs.js +3423 -3452
- package/dist/owl.es.js +3423 -3452
- package/dist/owl.iife.js +3423 -3452
- package/dist/owl.iife.min.js +1 -1
- package/dist/types/compiler/code_generator.d.ts +6 -22
- package/dist/types/compiler/index.d.ts +1 -1
- package/dist/types/compiler/inline_expressions.d.ts +0 -1
- package/dist/types/compiler/parser.d.ts +10 -6
- package/dist/types/owl.d.ts +53 -68
- package/dist/types/runtime/app.d.ts +1 -3
- package/dist/types/runtime/blockdom/index.d.ts +0 -1
- package/dist/types/runtime/index.d.ts +2 -2
- package/dist/types/runtime/plugin_hooks.d.ts +2 -1
- package/dist/types/runtime/plugin_manager.d.ts +2 -2
- package/dist/types/runtime/reactivity/async_computed.d.ts +1 -0
- package/dist/types/runtime/reactivity/computations.d.ts +1 -1
- package/dist/types/runtime/reactivity/proxy.d.ts +0 -1
- package/dist/types/runtime/reactivity/signal.d.ts +13 -8
- package/dist/types/runtime/rendering/template_helpers.d.ts +10 -9
- package/dist/types/runtime/suspense.d.ts +5 -0
- package/dist/types/runtime/template_set.d.ts +2 -5
- package/dist/types/runtime/types.d.ts +10 -5
- package/dist/types/runtime/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/types/owl.d.ts
CHANGED
|
@@ -166,32 +166,6 @@ declare class Registry<T> {
|
|
|
166
166
|
has(key: string): boolean;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
interface ReactiveValue<TRead, TWrite = TRead> {
|
|
170
|
-
(): TRead;
|
|
171
|
-
/**
|
|
172
|
-
* Update the value of the reactive with a new value. If the new value is different
|
|
173
|
-
* from the previous values, all computations that depends on this reactive will
|
|
174
|
-
* be invalidated, and effects will rerun.
|
|
175
|
-
*/
|
|
176
|
-
set(nextValue: TWrite): void;
|
|
177
|
-
}
|
|
178
|
-
declare enum ComputationState {
|
|
179
|
-
EXECUTED = 0,
|
|
180
|
-
STALE = 1,
|
|
181
|
-
PENDING = 2
|
|
182
|
-
}
|
|
183
|
-
interface Atom<T = any> {
|
|
184
|
-
observers: Set<ComputationAtom>;
|
|
185
|
-
value: T;
|
|
186
|
-
}
|
|
187
|
-
interface ComputationAtom<T = any> extends Atom<T> {
|
|
188
|
-
compute: () => T;
|
|
189
|
-
isDerived: boolean;
|
|
190
|
-
sources: Set<Atom>;
|
|
191
|
-
state: ComputationState;
|
|
192
|
-
}
|
|
193
|
-
declare function untrack<T>(fn: (...args: any[]) => T): T;
|
|
194
|
-
|
|
195
169
|
declare const enum STATUS {
|
|
196
170
|
NEW = 0,
|
|
197
171
|
MOUNTED = 1,// is ready, and in DOM. It has a valid el
|
|
@@ -215,7 +189,6 @@ declare class Plugin {
|
|
|
215
189
|
}
|
|
216
190
|
interface PluginManagerOptions {
|
|
217
191
|
parent?: PluginManager | null;
|
|
218
|
-
plugins?: ReactiveValue<PluginConstructor[]>;
|
|
219
192
|
config?: Record<string, any>;
|
|
220
193
|
}
|
|
221
194
|
declare class PluginManager {
|
|
@@ -232,6 +205,32 @@ declare class PluginManager {
|
|
|
232
205
|
startPlugins(pluginConstructors: PluginConstructor[]): void;
|
|
233
206
|
}
|
|
234
207
|
|
|
208
|
+
interface ReactiveValue<TRead, TWrite = TRead> {
|
|
209
|
+
(): TRead;
|
|
210
|
+
/**
|
|
211
|
+
* Update the value of the reactive with a new value. If the new value is different
|
|
212
|
+
* from the previous values, all computations that depends on this reactive will
|
|
213
|
+
* be invalidated, and effects will rerun.
|
|
214
|
+
*/
|
|
215
|
+
set(nextValue: TWrite): void;
|
|
216
|
+
}
|
|
217
|
+
declare enum ComputationState {
|
|
218
|
+
EXECUTED = 0,
|
|
219
|
+
STALE = 1,
|
|
220
|
+
PENDING = 2
|
|
221
|
+
}
|
|
222
|
+
interface Atom<T = any> {
|
|
223
|
+
observers: Set<ComputationAtom>;
|
|
224
|
+
value: T;
|
|
225
|
+
}
|
|
226
|
+
interface ComputationAtom<T = any> extends Atom<T> {
|
|
227
|
+
compute: () => T;
|
|
228
|
+
isDerived: boolean;
|
|
229
|
+
sources: Set<Atom>;
|
|
230
|
+
state: ComputationState;
|
|
231
|
+
}
|
|
232
|
+
declare function untrack<T>(fn: (...args: any[]) => T): T;
|
|
233
|
+
|
|
235
234
|
declare class Fiber {
|
|
236
235
|
node: ComponentNode;
|
|
237
236
|
bdom: BDom | null;
|
|
@@ -331,8 +330,8 @@ declare class Component {
|
|
|
331
330
|
setup(): void;
|
|
332
331
|
}
|
|
333
332
|
|
|
334
|
-
type Constructor = {
|
|
335
|
-
new (...args: any[]):
|
|
333
|
+
type Constructor<T = any> = {
|
|
334
|
+
new (...args: any[]): T;
|
|
336
335
|
};
|
|
337
336
|
type GetOptionalEntries<T> = {
|
|
338
337
|
[K in keyof T as K extends `${infer P}?` ? P : never]?: T[K];
|
|
@@ -361,6 +360,7 @@ declare function instanceType<T extends Constructor>(constructor: T): InstanceTy
|
|
|
361
360
|
declare function intersection<T extends any[]>(types: T): UnionToIntersection<T[number]>;
|
|
362
361
|
type LiteralTypes = number | string | boolean | null | undefined;
|
|
363
362
|
declare function literalType<const T extends LiteralTypes>(literal: T): T;
|
|
363
|
+
declare function literalSelection<const T extends LiteralTypes>(literals: T[]): T;
|
|
364
364
|
declare function objectType(): Record<string, any>;
|
|
365
365
|
declare function objectType<const Keys extends string[]>(keys: Keys): ResolveOptionalEntries<KeyedObject<Keys>>;
|
|
366
366
|
declare function objectType<Shape extends {}>(shape: Shape): ResolveOptionalEntries<Shape>;
|
|
@@ -372,7 +372,10 @@ declare function tuple<const T extends any[]>(types: T): T;
|
|
|
372
372
|
declare function union<T extends any[]>(types: T): T[number];
|
|
373
373
|
declare function reactiveValueType(): ReactiveValue<any>;
|
|
374
374
|
declare function reactiveValueType<T>(type: T): ReactiveValue<T>;
|
|
375
|
+
declare function ref(): HTMLElement | null;
|
|
376
|
+
declare function ref<T extends Constructor<HTMLElement>>(type: T): InstanceType<T> | null;
|
|
375
377
|
declare const types: {
|
|
378
|
+
and: typeof intersection;
|
|
376
379
|
any: any;
|
|
377
380
|
array: typeof arrayType;
|
|
378
381
|
boolean: boolean;
|
|
@@ -383,13 +386,14 @@ declare const types: {
|
|
|
383
386
|
literal: typeof literalType;
|
|
384
387
|
number: number;
|
|
385
388
|
object: typeof objectType;
|
|
389
|
+
or: typeof union;
|
|
386
390
|
promise: typeof promiseType;
|
|
387
|
-
signal: typeof reactiveValueType;
|
|
388
391
|
record: typeof recordType;
|
|
392
|
+
ref: typeof ref;
|
|
393
|
+
selection: typeof literalSelection;
|
|
394
|
+
signal: typeof reactiveValueType;
|
|
389
395
|
string: string;
|
|
390
396
|
tuple: typeof tuple;
|
|
391
|
-
and: typeof intersection;
|
|
392
|
-
or: typeof union;
|
|
393
397
|
};
|
|
394
398
|
|
|
395
399
|
declare const isProps: unique symbol;
|
|
@@ -486,29 +490,9 @@ declare class Scheduler {
|
|
|
486
490
|
processFiber(fiber: RootFiber): void;
|
|
487
491
|
}
|
|
488
492
|
|
|
489
|
-
interface Config {
|
|
490
|
-
translateFn?: (s: string, translationCtx: string) => string;
|
|
491
|
-
translatableAttributes?: string[];
|
|
492
|
-
dev?: boolean;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
493
|
type CustomDirectives = Record<string, (node: Element, value: string, modifier: string[]) => void>;
|
|
496
494
|
type Template = (context: any, vnode: any, key?: string) => BDom;
|
|
497
495
|
type TemplateFunction = (app: TemplateSet, bdom: any, helpers: any) => Template;
|
|
498
|
-
interface CompileOptions extends Config {
|
|
499
|
-
name?: string;
|
|
500
|
-
customDirectives?: CustomDirectives;
|
|
501
|
-
hasGlobalValues: boolean;
|
|
502
|
-
}
|
|
503
|
-
declare function compile(template: string | Element, options?: CompileOptions): TemplateFunction;
|
|
504
|
-
|
|
505
|
-
declare class Portal extends Component {
|
|
506
|
-
static template: string;
|
|
507
|
-
props: Props<{
|
|
508
|
-
target: string;
|
|
509
|
-
}>;
|
|
510
|
-
setup(): void;
|
|
511
|
-
}
|
|
512
496
|
|
|
513
497
|
interface TemplateSetConfig {
|
|
514
498
|
dev?: boolean;
|
|
@@ -529,7 +513,6 @@ declare class TemplateSet {
|
|
|
529
513
|
getRawTemplate?: (s: string) => Element | Function | string | void;
|
|
530
514
|
translateFn?: (s: string, translationCtx: string) => string;
|
|
531
515
|
translatableAttributes?: string[];
|
|
532
|
-
Portal: typeof Portal;
|
|
533
516
|
customDirectives: CustomDirectives;
|
|
534
517
|
runtimeUtils: object;
|
|
535
518
|
hasGlobalValues: boolean;
|
|
@@ -537,8 +520,7 @@ declare class TemplateSet {
|
|
|
537
520
|
addTemplate(name: string, template: string | Element): void;
|
|
538
521
|
addTemplates(xml: string | Document): void;
|
|
539
522
|
getTemplate(name: string): Template;
|
|
540
|
-
_compileTemplate
|
|
541
|
-
callTemplate(owner: any, subTemplate: string, ctx: any, parent: any, key: any): any;
|
|
523
|
+
private _compileTemplate;
|
|
542
524
|
}
|
|
543
525
|
declare const globalTemplates: {
|
|
544
526
|
[key: string]: string | Element | TemplateFunction;
|
|
@@ -548,7 +530,7 @@ declare namespace xml {
|
|
|
548
530
|
var nextId: number;
|
|
549
531
|
}
|
|
550
532
|
|
|
551
|
-
type Callback = () => void;
|
|
533
|
+
type Callback = (...args: any[]) => void;
|
|
552
534
|
/**
|
|
553
535
|
* Creates a batched version of a callback so that all calls to it in the same
|
|
554
536
|
* microtick will only call the original callback once.
|
|
@@ -606,10 +588,8 @@ declare class App extends TemplateSet {
|
|
|
606
588
|
pluginManager: PluginManager;
|
|
607
589
|
constructor(config?: AppConfig);
|
|
608
590
|
createRoot<T extends ComponentConstructor>(Root: T, config?: RootConfig<GetProps<ComponentInstance<T>>>): Root<T>;
|
|
609
|
-
|
|
610
|
-
mountNode(node: ComponentNode, target: HTMLElement | ShadowRoot, resolve: (c: any) => void, reject: (e: any) => void, options?: MountOptions): void;
|
|
591
|
+
private mountNode;
|
|
611
592
|
destroy(): void;
|
|
612
|
-
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;
|
|
613
593
|
handleError(...args: Parameters<typeof handleError>): void;
|
|
614
594
|
}
|
|
615
595
|
declare function mount<T extends ComponentConstructor>(C: T, target: MountTarget, config?: AppConfig & RootConfig<GetProps<ComponentInstance<T>>> & MountOptions): Promise<ComponentInstance<T>>;
|
|
@@ -625,19 +605,24 @@ interface Signal<T> extends ReactiveValue<T> {
|
|
|
625
605
|
interface SignalOptions<T> {
|
|
626
606
|
type?: T;
|
|
627
607
|
}
|
|
628
|
-
declare function signal
|
|
629
|
-
declare
|
|
630
|
-
|
|
631
|
-
var Array: <T>(initialValue: T[], options?: SignalOptions<T>) => Signal<T[]>;
|
|
632
|
-
var Object: <T extends object>(initialValue: T, options?: SignalOptions<T>) => Signal<T>;
|
|
633
|
-
var Map: <K, V>(initialValue: Map<K, V>, options?: MapSignalOptions<K, V>) => Signal<Map<K, V>>;
|
|
634
|
-
var Set: <T>(initialValue: Set<T>, options?: SignalOptions<T>) => Signal<Set<T>>;
|
|
635
|
-
}
|
|
608
|
+
declare function invalidateSignal(signal: Signal<any>): void;
|
|
609
|
+
declare function signalArray<T>(initialValue: T[], options?: SignalOptions<T>): Signal<T[]>;
|
|
610
|
+
declare function signalObject<T extends Record<PropertyKey, any>>(initialValue: T, options?: SignalOptions<T>): Signal<T>;
|
|
636
611
|
interface MapSignalOptions<K, V> {
|
|
637
612
|
name?: string;
|
|
638
613
|
keyType?: K;
|
|
639
614
|
valueType?: V;
|
|
640
615
|
}
|
|
616
|
+
declare function signalMap<K, V>(initialValue: Map<K, V>, options?: MapSignalOptions<K, V>): Signal<Map<K, V>>;
|
|
617
|
+
declare function signalSet<T>(initialValue: Set<T>, options?: SignalOptions<T>): Signal<Set<T>>;
|
|
618
|
+
declare function signal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
|
|
619
|
+
declare namespace signal {
|
|
620
|
+
var invalidate: typeof invalidateSignal;
|
|
621
|
+
var Array: typeof signalArray;
|
|
622
|
+
var Map: typeof signalMap;
|
|
623
|
+
var Object: typeof signalObject;
|
|
624
|
+
var Set: typeof signalSet;
|
|
625
|
+
}
|
|
641
626
|
|
|
642
627
|
interface ComputedOptions<TWrite> {
|
|
643
628
|
set?(value: TWrite): void;
|
|
@@ -702,7 +687,7 @@ declare class OwlError extends Error {
|
|
|
702
687
|
type PluginInstance<T extends PluginConstructor> = Omit<InstanceType<T>, "setup">;
|
|
703
688
|
declare function plugin<T extends PluginConstructor>(pluginType: T): PluginInstance<T>;
|
|
704
689
|
declare function config<T = any>(name: string, type?: T): T;
|
|
705
|
-
declare function providePlugins
|
|
690
|
+
declare function providePlugins(pluginConstructors: PluginConstructor[] | Resource<PluginConstructor>, config?: Record<string, any>): void;
|
|
706
691
|
|
|
707
692
|
interface CapturedContext {
|
|
708
693
|
run<T = void>(callback: () => T): T;
|
|
@@ -47,10 +47,8 @@ export declare class App extends TemplateSet {
|
|
|
47
47
|
pluginManager: PluginManager;
|
|
48
48
|
constructor(config?: AppConfig);
|
|
49
49
|
createRoot<T extends ComponentConstructor>(Root: T, config?: RootConfig<GetProps<ComponentInstance<T>>>): Root<T>;
|
|
50
|
-
|
|
51
|
-
mountNode(node: ComponentNode, target: HTMLElement | ShadowRoot, resolve: (c: any) => void, reject: (e: any) => void, options?: MountOptions): void;
|
|
50
|
+
private mountNode;
|
|
52
51
|
destroy(): void;
|
|
53
|
-
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;
|
|
54
52
|
handleError(...args: Parameters<typeof handleError>): void;
|
|
55
53
|
}
|
|
56
54
|
export declare function mount<T extends ComponentConstructor>(C: T, target: MountTarget, config?: AppConfig & RootConfig<GetProps<ComponentInstance<T>>> & MountOptions): Promise<ComponentInstance<T>>;
|
|
@@ -23,4 +23,3 @@ export type BDom = VNode<any>;
|
|
|
23
23
|
export declare function mount(vnode: VNode, fixture: HTMLElement, afterNode?: Node | null): void;
|
|
24
24
|
export declare function patch(vnode1: VNode, vnode2: VNode, withBeforeRemove?: boolean): void;
|
|
25
25
|
export declare function remove(vnode: VNode, withBeforeRemove?: boolean): void;
|
|
26
|
-
export declare function withKey(vnode: VNode, key: any): VNode<any>;
|
|
@@ -25,8 +25,8 @@ export { props } from "./props";
|
|
|
25
25
|
export type { GetProps } from "./props";
|
|
26
26
|
export { status } from "./status";
|
|
27
27
|
export { proxy, markRaw, toRaw } from "./reactivity/proxy";
|
|
28
|
-
export { untrack, ReactiveValue } from "./reactivity/computations";
|
|
29
|
-
export { signal, Signal } from "./reactivity/signal";
|
|
28
|
+
export { untrack, type ReactiveValue } from "./reactivity/computations";
|
|
29
|
+
export { signal, type Signal } from "./reactivity/signal";
|
|
30
30
|
export { computed } from "./reactivity/computed";
|
|
31
31
|
export { effect } from "./reactivity/effect";
|
|
32
32
|
export { useEffect, useListener, useApp } from "./hooks";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PluginConstructor } from "./plugin_manager";
|
|
2
|
+
import { Resource } from "./resource";
|
|
2
3
|
export type PluginInstance<T extends PluginConstructor> = Omit<InstanceType<T>, "setup">;
|
|
3
4
|
export declare function plugin<T extends PluginConstructor>(pluginType: T): PluginInstance<T>;
|
|
4
5
|
export declare function config<T = any>(name: string, type?: T): T;
|
|
5
|
-
export declare function providePlugins
|
|
6
|
+
export declare function providePlugins(pluginConstructors: PluginConstructor[] | Resource<PluginConstructor>, config?: Record<string, any>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { App } from "./app";
|
|
2
|
-
import {
|
|
2
|
+
import { Resource } from "./resource";
|
|
3
3
|
import { STATUS } from "./status";
|
|
4
4
|
export interface PluginConstructor {
|
|
5
5
|
new (...args: any[]): Plugin;
|
|
@@ -15,7 +15,6 @@ export declare class Plugin {
|
|
|
15
15
|
}
|
|
16
16
|
interface PluginManagerOptions {
|
|
17
17
|
parent?: PluginManager | null;
|
|
18
|
-
plugins?: ReactiveValue<PluginConstructor[]>;
|
|
19
18
|
config?: Record<string, any>;
|
|
20
19
|
}
|
|
21
20
|
export declare class PluginManager {
|
|
@@ -31,4 +30,5 @@ export declare class PluginManager {
|
|
|
31
30
|
startPlugin<T extends PluginConstructor>(pluginConstructor: T): InstanceType<T> | null;
|
|
32
31
|
startPlugins(pluginConstructors: PluginConstructor[]): void;
|
|
33
32
|
}
|
|
33
|
+
export declare function startPlugins(manager: PluginManager, plugins: PluginConstructor[] | Resource<PluginConstructor>): void;
|
|
34
34
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function asyncComputed<T>(fn: () => Promise<T>): () => Promise<T>;
|
|
@@ -23,7 +23,7 @@ export interface ComputationAtom<T = any> extends Atom<T> {
|
|
|
23
23
|
state: ComputationState;
|
|
24
24
|
}
|
|
25
25
|
export declare const atomSymbol: unique symbol;
|
|
26
|
-
export declare function createComputation(
|
|
26
|
+
export declare function createComputation(compute: () => any, isDerived: boolean, state?: ComputationState): ComputationAtom;
|
|
27
27
|
export declare function onReadAtom(atom: Atom): void;
|
|
28
28
|
export declare function onWriteAtom(atom: Atom): void;
|
|
29
29
|
export declare function getCurrentComputation(): ComputationAtom<any> | undefined;
|
|
@@ -15,7 +15,6 @@ export declare function markRaw<T extends Target>(value: T): T;
|
|
|
15
15
|
* @returns the underlying value
|
|
16
16
|
*/
|
|
17
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
18
|
export declare function proxifyTarget<T extends Target>(target: T, atom: Atom | null): T;
|
|
20
19
|
/**
|
|
21
20
|
* Creates a reactive proxy for an object. Reading data on the proxy object
|
|
@@ -10,17 +10,22 @@ export interface Signal<T> extends ReactiveValue<T> {
|
|
|
10
10
|
interface SignalOptions<T> {
|
|
11
11
|
type?: T;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var Array: <T>(initialValue: T[], options?: SignalOptions<T>) => Signal<T[]>;
|
|
17
|
-
var Object: <T extends object>(initialValue: T, options?: SignalOptions<T>) => Signal<T>;
|
|
18
|
-
var Map: <K, V>(initialValue: Map<K, V>, options?: MapSignalOptions<K, V>) => Signal<Map<K, V>>;
|
|
19
|
-
var Set: <T>(initialValue: Set<T>, options?: SignalOptions<T>) => Signal<Set<T>>;
|
|
20
|
-
}
|
|
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>;
|
|
21
16
|
interface MapSignalOptions<K, V> {
|
|
22
17
|
name?: string;
|
|
23
18
|
keyType?: K;
|
|
24
19
|
valueType?: V;
|
|
25
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
|
+
}
|
|
26
31
|
export {};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { BDom, toggler, createCatcher } from "../blockdom";
|
|
2
|
-
import { markRaw } from "../reactivity/proxy";
|
|
3
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";
|
|
4
7
|
/**
|
|
5
8
|
* This file contains utility functions that will be injected in each template,
|
|
6
9
|
* to perform various useful tasks in the compiled code.
|
|
7
10
|
*/
|
|
8
11
|
declare function withDefault(value: any, defaultValue: any): any;
|
|
9
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;
|
|
10
|
-
declare function capture(ctx: any): any;
|
|
11
13
|
declare function withKey(elem: any, k: string): any;
|
|
12
14
|
declare function prepareList(collection: unknown): [unknown[], unknown[], number, undefined[]];
|
|
13
|
-
declare function setContextValue(ctx: {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
}, key: string, value: any): void;
|
|
16
15
|
declare function toNumber(val: string): number | string;
|
|
17
16
|
declare function shallowEqual(l1: any[], l2: any[]): boolean;
|
|
18
17
|
declare class LazyValue {
|
|
@@ -28,15 +27,14 @@ declare class LazyValue {
|
|
|
28
27
|
export declare function safeOutput(value: any, defaultValue?: any): ReturnType<typeof toggler>;
|
|
29
28
|
declare function createRef(ref: any): (el: HTMLElement | null, previousEl: HTMLElement | null) => void;
|
|
30
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;
|
|
31
32
|
export declare const helpers: {
|
|
32
33
|
withDefault: typeof withDefault;
|
|
33
34
|
zero: symbol;
|
|
34
|
-
isBoundary: symbol;
|
|
35
35
|
callSlot: typeof callSlot;
|
|
36
|
-
capture: typeof capture;
|
|
37
36
|
withKey: typeof withKey;
|
|
38
37
|
prepareList: typeof prepareList;
|
|
39
|
-
setContextValue: typeof setContextValue;
|
|
40
38
|
shallowEqual: typeof shallowEqual;
|
|
41
39
|
toNumber: typeof toNumber;
|
|
42
40
|
LazyValue: typeof LazyValue;
|
|
@@ -46,5 +44,8 @@ export declare const helpers: {
|
|
|
46
44
|
OwlError: typeof OwlError;
|
|
47
45
|
createRef: typeof createRef;
|
|
48
46
|
modelExpr: typeof modelExpr;
|
|
47
|
+
createComponent: typeof createComponent;
|
|
48
|
+
Portal: typeof Portal;
|
|
49
|
+
callTemplate: typeof callTemplate;
|
|
49
50
|
};
|
|
50
51
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Portal } from "./portal";
|
|
1
|
+
import { CustomDirectives, Template, TemplateFunction } from "../compiler";
|
|
3
2
|
export interface TemplateSetConfig {
|
|
4
3
|
dev?: boolean;
|
|
5
4
|
translatableAttributes?: string[];
|
|
@@ -19,7 +18,6 @@ export declare class TemplateSet {
|
|
|
19
18
|
getRawTemplate?: (s: string) => Element | Function | string | void;
|
|
20
19
|
translateFn?: (s: string, translationCtx: string) => string;
|
|
21
20
|
translatableAttributes?: string[];
|
|
22
|
-
Portal: typeof Portal;
|
|
23
21
|
customDirectives: CustomDirectives;
|
|
24
22
|
runtimeUtils: object;
|
|
25
23
|
hasGlobalValues: boolean;
|
|
@@ -27,8 +25,7 @@ export declare class TemplateSet {
|
|
|
27
25
|
addTemplate(name: string, template: string | Element): void;
|
|
28
26
|
addTemplates(xml: string | Document): void;
|
|
29
27
|
getTemplate(name: string): Template;
|
|
30
|
-
_compileTemplate
|
|
31
|
-
callTemplate(owner: any, subTemplate: string, ctx: any, parent: any, key: any): any;
|
|
28
|
+
private _compileTemplate;
|
|
32
29
|
}
|
|
33
30
|
export declare const globalTemplates: {
|
|
34
31
|
[key: string]: string | Element | TemplateFunction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactiveValue } from "./reactivity/computations";
|
|
2
|
-
type Constructor = {
|
|
3
|
-
new (...args: any[]):
|
|
2
|
+
type Constructor<T = any> = {
|
|
3
|
+
new (...args: any[]): T;
|
|
4
4
|
};
|
|
5
5
|
export type GetOptionalEntries<T> = {
|
|
6
6
|
[K in keyof T as K extends `${infer P}?` ? P : never]?: T[K];
|
|
@@ -29,6 +29,7 @@ declare function instanceType<T extends Constructor>(constructor: T): InstanceTy
|
|
|
29
29
|
declare function intersection<T extends any[]>(types: T): UnionToIntersection<T[number]>;
|
|
30
30
|
type LiteralTypes = number | string | boolean | null | undefined;
|
|
31
31
|
declare function literalType<const T extends LiteralTypes>(literal: T): T;
|
|
32
|
+
declare function literalSelection<const T extends LiteralTypes>(literals: T[]): T;
|
|
32
33
|
declare function objectType(): Record<string, any>;
|
|
33
34
|
declare function objectType<const Keys extends string[]>(keys: Keys): ResolveOptionalEntries<KeyedObject<Keys>>;
|
|
34
35
|
declare function objectType<Shape extends {}>(shape: Shape): ResolveOptionalEntries<Shape>;
|
|
@@ -40,7 +41,10 @@ declare function tuple<const T extends any[]>(types: T): T;
|
|
|
40
41
|
declare function union<T extends any[]>(types: T): T[number];
|
|
41
42
|
declare function reactiveValueType(): ReactiveValue<any>;
|
|
42
43
|
declare function reactiveValueType<T>(type: T): ReactiveValue<T>;
|
|
44
|
+
declare function ref(): HTMLElement | null;
|
|
45
|
+
declare function ref<T extends Constructor<HTMLElement>>(type: T): InstanceType<T> | null;
|
|
43
46
|
export declare const types: {
|
|
47
|
+
and: typeof intersection;
|
|
44
48
|
any: any;
|
|
45
49
|
array: typeof arrayType;
|
|
46
50
|
boolean: boolean;
|
|
@@ -51,12 +55,13 @@ export declare const types: {
|
|
|
51
55
|
literal: typeof literalType;
|
|
52
56
|
number: number;
|
|
53
57
|
object: typeof objectType;
|
|
58
|
+
or: typeof union;
|
|
54
59
|
promise: typeof promiseType;
|
|
55
|
-
signal: typeof reactiveValueType;
|
|
56
60
|
record: typeof recordType;
|
|
61
|
+
ref: typeof ref;
|
|
62
|
+
selection: typeof literalSelection;
|
|
63
|
+
signal: typeof reactiveValueType;
|
|
57
64
|
string: string;
|
|
58
65
|
tuple: typeof tuple;
|
|
59
|
-
and: typeof intersection;
|
|
60
|
-
or: typeof union;
|
|
61
66
|
};
|
|
62
67
|
export {};
|