@odoo/owl 2.8.1 → 3.0.0-alpha.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.
- package/dist/owl-devtools.zip +0 -0
- package/dist/owl.cjs.js +580 -184
- package/dist/owl.es.js +573 -185
- package/dist/owl.iife.js +580 -184
- package/dist/owl.iife.min.js +1 -1
- package/dist/types/common/types.d.ts +28 -0
- package/dist/types/owl.d.ts +161 -77
- package/dist/types/runtime/app.d.ts +3 -0
- 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 -3
- package/dist/types/runtime/component_node.d.ts +7 -5
- package/dist/types/runtime/executionContext.d.ts +0 -0
- package/dist/types/runtime/index.d.ts +3 -0
- package/dist/types/runtime/listOperation.d.ts +1 -0
- package/dist/types/runtime/plugins.d.ts +39 -0
- package/dist/types/runtime/reactivity.d.ts +1 -12
- package/dist/types/runtime/registry.d.ts +15 -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/signals.d.ts +17 -0
- package/dist/types/runtime/task.d.ts +12 -0
- package/dist/types/utils/registry.d.ts +15 -0
- package/package.json +1 -1
package/dist/types/owl.d.ts
CHANGED
|
@@ -152,6 +152,45 @@ declare function validate(obj: {
|
|
|
152
152
|
}, spec: Schema): void;
|
|
153
153
|
declare function validateType(key: string, value: any, descr: TypeDescription): string | null;
|
|
154
154
|
|
|
155
|
+
declare type Fn<T> = () => T;
|
|
156
|
+
declare class Registry<T> {
|
|
157
|
+
_map: {
|
|
158
|
+
[key: string]: [number, T];
|
|
159
|
+
};
|
|
160
|
+
_name: string;
|
|
161
|
+
_schema?: Schema;
|
|
162
|
+
items: Fn<T[]>;
|
|
163
|
+
entries: Fn<[string, T][]>;
|
|
164
|
+
constructor(name?: string, schema?: Schema);
|
|
165
|
+
set(key: string, value: T, sequence?: number): void;
|
|
166
|
+
get(key: string, defaultValue?: T): T;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
declare type customDirectives = Record<string, (node: Element, value: string, modifier: string[]) => void>;
|
|
170
|
+
declare enum ComputationState {
|
|
171
|
+
EXECUTED = 0,
|
|
172
|
+
STALE = 1,
|
|
173
|
+
PENDING = 2
|
|
174
|
+
}
|
|
175
|
+
declare type Computation<T = any> = {
|
|
176
|
+
compute?: () => T;
|
|
177
|
+
state: ComputationState;
|
|
178
|
+
sources: Set<Atom | Derived<any, any>>;
|
|
179
|
+
isEager?: boolean;
|
|
180
|
+
isDerived?: boolean;
|
|
181
|
+
value: T;
|
|
182
|
+
childrenEffect?: Computation[];
|
|
183
|
+
} & Opts;
|
|
184
|
+
declare type Opts = {
|
|
185
|
+
name?: string;
|
|
186
|
+
};
|
|
187
|
+
declare type Atom<T = any> = {
|
|
188
|
+
value: T;
|
|
189
|
+
observers: Set<Computation>;
|
|
190
|
+
} & Opts;
|
|
191
|
+
interface Derived<Prev, Next = Prev> extends Atom<Next>, Computation<Next> {
|
|
192
|
+
}
|
|
193
|
+
|
|
155
194
|
declare class Fiber {
|
|
156
195
|
node: ComponentNode;
|
|
157
196
|
bdom: BDom | null;
|
|
@@ -185,75 +224,44 @@ declare class MountFiber extends RootFiber {
|
|
|
185
224
|
complete(): void;
|
|
186
225
|
}
|
|
187
226
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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;
|
|
227
|
+
interface PluginCtor {
|
|
228
|
+
new (deps: any): Plugin<any>;
|
|
229
|
+
id: string;
|
|
230
|
+
dependencies: string[];
|
|
200
231
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
declare class Markup extends String {
|
|
232
|
+
interface PluginMetaData {
|
|
233
|
+
isDestroyed: boolean;
|
|
204
234
|
}
|
|
205
|
-
declare
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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;
|
|
235
|
+
declare class Plugin<Deps = {
|
|
236
|
+
[name: string]: Plugin;
|
|
237
|
+
}> {
|
|
238
|
+
static id: string;
|
|
239
|
+
static dependencies: string[];
|
|
240
|
+
readonly plugins: Deps;
|
|
241
|
+
static resources: {};
|
|
242
|
+
resources: {
|
|
243
|
+
[name: string]: any;
|
|
244
|
+
};
|
|
245
|
+
__meta__: PluginMetaData;
|
|
246
|
+
setup(): void;
|
|
247
|
+
destroy(): void;
|
|
248
|
+
get isDestroyed(): boolean;
|
|
249
|
+
}
|
|
250
|
+
declare class PluginManager {
|
|
251
|
+
_parent: PluginManager | null;
|
|
252
|
+
_children: PluginManager[];
|
|
253
|
+
plugins: {
|
|
254
|
+
[id: string]: Plugin;
|
|
255
|
+
};
|
|
256
|
+
resources: {
|
|
257
|
+
[id: string]: any;
|
|
258
|
+
};
|
|
259
|
+
constructor(parent: PluginManager | null, Plugins: PluginCtor[] | (() => PluginCtor[]));
|
|
260
|
+
destroy(): void;
|
|
261
|
+
getPlugin(name: string): Plugin | null;
|
|
262
|
+
getResource(name: string): any[];
|
|
263
|
+
}
|
|
264
|
+
declare function usePlugins(Plugins: PluginCtor[]): void;
|
|
257
265
|
|
|
258
266
|
declare const enum STATUS {
|
|
259
267
|
NEW = 0,
|
|
@@ -277,11 +285,11 @@ declare function useComponent(): Component;
|
|
|
277
285
|
*/
|
|
278
286
|
declare function useState<T extends object>(state: T): T;
|
|
279
287
|
declare type LifecycleHook = Function;
|
|
280
|
-
declare class ComponentNode<P extends Props = any, E = any> implements VNode<ComponentNode<P, E>> {
|
|
288
|
+
declare class ComponentNode<P extends Props = any, Plugins = any, E = any> implements VNode<ComponentNode<P, E>> {
|
|
281
289
|
el?: HTMLElement | Text | undefined;
|
|
282
290
|
app: App;
|
|
283
291
|
fiber: Fiber | null;
|
|
284
|
-
component: Component<P, E>;
|
|
292
|
+
component: Component<P, Plugins, E>;
|
|
285
293
|
bdom: BDom | null;
|
|
286
294
|
status: STATUS;
|
|
287
295
|
forceNextRender: boolean;
|
|
@@ -302,7 +310,9 @@ declare class ComponentNode<P extends Props = any, E = any> implements VNode<Com
|
|
|
302
310
|
willPatch: LifecycleHook[];
|
|
303
311
|
patched: LifecycleHook[];
|
|
304
312
|
willDestroy: LifecycleHook[];
|
|
305
|
-
|
|
313
|
+
signalComputation: Computation;
|
|
314
|
+
pluginManager: PluginManager;
|
|
315
|
+
constructor(C: ComponentConstructor<P, Plugins, E>, props: P, app: App, parent: ComponentNode | null, parentKey: string | null);
|
|
306
316
|
mountComponent(target: any, options?: MountOptions): void;
|
|
307
317
|
initiateRender(fiber: Fiber | MountFiber): Promise<void>;
|
|
308
318
|
render(deep: boolean): Promise<void>;
|
|
@@ -334,7 +344,6 @@ declare class ComponentNode<P extends Props = any, E = any> implements VNode<Com
|
|
|
334
344
|
beforeRemove(): void;
|
|
335
345
|
remove(): void;
|
|
336
346
|
get name(): string;
|
|
337
|
-
get subscriptions(): ReturnType<typeof getSubscriptions>;
|
|
338
347
|
}
|
|
339
348
|
|
|
340
349
|
declare type Props = {
|
|
@@ -348,15 +357,16 @@ interface StaticComponentProperties {
|
|
|
348
357
|
[componentName: string]: ComponentConstructor;
|
|
349
358
|
};
|
|
350
359
|
}
|
|
351
|
-
declare type ComponentConstructor<P extends Props = any, E = any> = (new (props: P, env: E, node: ComponentNode) => Component<P, E>) & StaticComponentProperties;
|
|
352
|
-
declare class Component<Props = any, Env = any> {
|
|
360
|
+
declare type ComponentConstructor<P extends Props = any, Plugins = any, E = any> = (new (props: P, env: E, plugins: Plugins, node: ComponentNode) => Component<P, Plugins, E>) & StaticComponentProperties;
|
|
361
|
+
declare class Component<Props = any, Plugins = PluginManager["plugins"], Env = any> {
|
|
353
362
|
static template: string;
|
|
354
363
|
static props?: Schema;
|
|
355
364
|
static defaultProps?: any;
|
|
356
365
|
props: Props;
|
|
357
366
|
env: Env;
|
|
367
|
+
plugins: Plugins;
|
|
358
368
|
__owl__: ComponentNode;
|
|
359
|
-
constructor(props: Props, env: Env, node: ComponentNode);
|
|
369
|
+
constructor(props: Props, env: Env, plugins: Plugins, node: ComponentNode);
|
|
360
370
|
setup(): void;
|
|
361
371
|
render(deep?: boolean): void;
|
|
362
372
|
}
|
|
@@ -390,8 +400,6 @@ declare class Scheduler {
|
|
|
390
400
|
processFiber(fiber: RootFiber): void;
|
|
391
401
|
}
|
|
392
402
|
|
|
393
|
-
declare type customDirectives = Record<string, (node: Element, value: string, modifier: string[]) => void>;
|
|
394
|
-
|
|
395
403
|
interface Config {
|
|
396
404
|
translateFn?: (s: string, translationCtx: string) => string;
|
|
397
405
|
translatableAttributes?: string[];
|
|
@@ -456,12 +464,79 @@ declare namespace xml {
|
|
|
456
464
|
var nextId: number;
|
|
457
465
|
}
|
|
458
466
|
|
|
467
|
+
declare type Callback = () => void;
|
|
468
|
+
/**
|
|
469
|
+
* Creates a batched version of a callback so that all calls to it in the same
|
|
470
|
+
* microtick will only call the original callback once.
|
|
471
|
+
*
|
|
472
|
+
* @param callback the callback to batch
|
|
473
|
+
* @returns a batched version of the original callback
|
|
474
|
+
*/
|
|
475
|
+
declare function batched(callback: Callback): Callback;
|
|
476
|
+
declare function validateTarget(target: HTMLElement | ShadowRoot): void;
|
|
477
|
+
declare class EventBus extends EventTarget {
|
|
478
|
+
trigger(name: string, payload?: any): void;
|
|
479
|
+
}
|
|
480
|
+
declare function whenReady(fn?: any): Promise<void>;
|
|
481
|
+
declare function loadFile(url: string): Promise<string>;
|
|
482
|
+
declare class Markup extends String {
|
|
483
|
+
}
|
|
484
|
+
declare function htmlEscape(str: any): Markup;
|
|
485
|
+
declare function markup(strings: TemplateStringsArray, ...placeholders: unknown[]): Markup;
|
|
486
|
+
declare function markup(value: string): Markup;
|
|
487
|
+
|
|
488
|
+
declare type Target = object;
|
|
489
|
+
declare type Reactive<T extends Target> = T;
|
|
490
|
+
/**
|
|
491
|
+
* Mark an object or array so that it is ignored by the reactivity system
|
|
492
|
+
*
|
|
493
|
+
* @param value the value to mark
|
|
494
|
+
* @returns the object itself
|
|
495
|
+
*/
|
|
496
|
+
declare function markRaw<T extends Target>(value: T): T;
|
|
497
|
+
/**
|
|
498
|
+
* Given a reactive objet, return the raw (non reactive) underlying object
|
|
499
|
+
*
|
|
500
|
+
* @param value a reactive value
|
|
501
|
+
* @returns the underlying value
|
|
502
|
+
*/
|
|
503
|
+
declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
|
|
504
|
+
/**
|
|
505
|
+
* Creates a reactive proxy for an object. Reading data on the reactive object
|
|
506
|
+
* subscribes to changes to the data. Writing data on the object will cause the
|
|
507
|
+
* notify callback to be called if there are suscriptions to that data. Nested
|
|
508
|
+
* objects and arrays are automatically made reactive as well.
|
|
509
|
+
*
|
|
510
|
+
* Whenever you are notified of a change, all subscriptions are cleared, and if
|
|
511
|
+
* you would like to be notified of any further changes, you should go read
|
|
512
|
+
* the underlying data again. We assume that if you don't go read it again after
|
|
513
|
+
* being notified, it means that you are no longer interested in that data.
|
|
514
|
+
*
|
|
515
|
+
* Subscriptions:
|
|
516
|
+
* + Reading a property on an object will subscribe you to changes in the value
|
|
517
|
+
* of that property.
|
|
518
|
+
* + Accessing an object's keys (eg with Object.keys or with `for..in`) will
|
|
519
|
+
* subscribe you to the creation/deletion of keys. Checking the presence of a
|
|
520
|
+
* key on the object with 'in' has the same effect.
|
|
521
|
+
* - getOwnPropertyDescriptor does not currently subscribe you to the property.
|
|
522
|
+
* This is a choice that was made because changing a key's value will trigger
|
|
523
|
+
* this trap and we do not want to subscribe by writes. This also means that
|
|
524
|
+
* Object.hasOwnProperty doesn't subscribe as it goes through this trap.
|
|
525
|
+
*
|
|
526
|
+
* @param target the object for which to create a reactive proxy
|
|
527
|
+
* @param callback the function to call when an observed property of the
|
|
528
|
+
* reactive has changed
|
|
529
|
+
* @returns a proxy that tracks changes to it
|
|
530
|
+
*/
|
|
531
|
+
declare function reactive<T extends Target>(target: T): T;
|
|
532
|
+
|
|
459
533
|
interface Env {
|
|
460
534
|
[key: string]: any;
|
|
461
535
|
}
|
|
462
536
|
interface RootConfig<P, E> {
|
|
463
537
|
props?: P;
|
|
464
538
|
env?: E;
|
|
539
|
+
Plugins?: PluginCtor[];
|
|
465
540
|
}
|
|
466
541
|
interface AppConfig<P, E> extends TemplateSetConfig, RootConfig<P, E> {
|
|
467
542
|
name?: string;
|
|
@@ -496,6 +571,7 @@ declare class App<T extends abstract new (...args: any) => any = any, P extends
|
|
|
496
571
|
subRoots: Set<ComponentNode>;
|
|
497
572
|
root: ComponentNode<P, E> | null;
|
|
498
573
|
warnIfNoStaticProps: boolean;
|
|
574
|
+
pluginManager: PluginManager;
|
|
499
575
|
constructor(Root: ComponentConstructor<P, E>, config?: AppConfig<P, E>);
|
|
500
576
|
mount(target: HTMLElement | ShadowRoot, options?: MountOptions): Promise<Component<P, E> & InstanceType<T>>;
|
|
501
577
|
createRoot<Props extends object, SubEnv = any>(Root: ComponentConstructor<Props, E>, config?: RootConfig<Props, SubEnv>): Root<Props, SubEnv>;
|
|
@@ -507,6 +583,14 @@ declare class App<T extends abstract new (...args: any) => any = any, P extends
|
|
|
507
583
|
}
|
|
508
584
|
declare function mount<T extends abstract new (...args: any) => any = any, P extends object = any, E = any>(C: T & ComponentConstructor<P, E>, target: HTMLElement, config?: AppConfig<P, E> & MountOptions): Promise<Component<P, E> & InstanceType<T>>;
|
|
509
585
|
|
|
586
|
+
declare function signal<T>(value: T, opts?: Opts): {
|
|
587
|
+
readonly get: () => T;
|
|
588
|
+
readonly set: (newValue: T | ((prevValue: T) => T)) => void;
|
|
589
|
+
};
|
|
590
|
+
declare function effect<T>(fn: () => T, opts?: Opts): () => void;
|
|
591
|
+
declare function derived<T>(fn: () => T, opts?: Opts): () => T;
|
|
592
|
+
declare function withoutReactivity<T extends (...args: any[]) => any>(fn: T): ReturnType<T>;
|
|
593
|
+
|
|
510
594
|
/**
|
|
511
595
|
* The purpose of this hook is to allow components to get a reference to a sub
|
|
512
596
|
* html node or component.
|
|
@@ -600,4 +684,4 @@ declare const __info__: {
|
|
|
600
684
|
version: string;
|
|
601
685
|
};
|
|
602
686
|
|
|
603
|
-
export { App, Component, ComponentConstructor, EventBus, OwlError, __info__, batched, blockDom, htmlEscape, 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, validateType, whenReady, xml };
|
|
687
|
+
export { App, Component, ComponentConstructor, EventBus, OwlError, Plugin, PluginManager, Registry, __info__, batched, blockDom, derived, effect, htmlEscape, loadFile, markRaw, markup, mount, onError, onMounted, onPatched, onRendered, onWillDestroy, onWillPatch, onWillRender, onWillStart, onWillUnmount, onWillUpdateProps, reactive, signal, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, usePlugins, useRef, useState, useSubEnv, validate, validateType, whenReady, withoutReactivity, xml };
|
|
@@ -6,12 +6,14 @@ import { Scheduler } from "./scheduler";
|
|
|
6
6
|
import { TemplateSet, TemplateSetConfig } from "./template_set";
|
|
7
7
|
import { validateTarget } from "./utils";
|
|
8
8
|
import { toRaw, reactive } from "./reactivity";
|
|
9
|
+
import { PluginCtor, PluginManager } from "./plugins";
|
|
9
10
|
export interface Env {
|
|
10
11
|
[key: string]: any;
|
|
11
12
|
}
|
|
12
13
|
export interface RootConfig<P, E> {
|
|
13
14
|
props?: P;
|
|
14
15
|
env?: E;
|
|
16
|
+
Plugins?: PluginCtor[];
|
|
15
17
|
}
|
|
16
18
|
export interface AppConfig<P, E> extends TemplateSetConfig, RootConfig<P, E> {
|
|
17
19
|
name?: string;
|
|
@@ -46,6 +48,7 @@ export declare class App<T extends abstract new (...args: any) => any = any, P e
|
|
|
46
48
|
subRoots: Set<ComponentNode>;
|
|
47
49
|
root: ComponentNode<P, E> | null;
|
|
48
50
|
warnIfNoStaticProps: boolean;
|
|
51
|
+
pluginManager: PluginManager;
|
|
49
52
|
constructor(Root: ComponentConstructor<P, E>, config?: AppConfig<P, E>);
|
|
50
53
|
mount(target: HTMLElement | ShadowRoot, options?: MountOptions): Promise<Component<P, E> & InstanceType<T>>;
|
|
51
54
|
createRoot<Props extends object, SubEnv = any>(Root: ComponentConstructor<Props, E>, config?: RootConfig<Props, SubEnv>): Root<Props, SubEnv>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type TaskContext = {
|
|
2
|
+
isCancelled: boolean;
|
|
3
|
+
cancel: () => void;
|
|
4
|
+
meta: Record<string, any>;
|
|
5
|
+
};
|
|
6
|
+
export declare const taskContextStack: TaskContext[];
|
|
7
|
+
export declare function getTaskContext(): TaskContext;
|
|
8
|
+
export declare function makeTaskContext(): TaskContext;
|
|
9
|
+
export declare function useTaskContext(ctx?: TaskContext): {
|
|
10
|
+
ctx: TaskContext;
|
|
11
|
+
cleanup: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function pushTaskContext(context: TaskContext): void;
|
|
14
|
+
export declare function popTaskContext(): void;
|
|
15
|
+
export declare function taskEffect(fn: Function): TaskContext;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type PromiseExecContext = {
|
|
2
|
+
cancelled: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare type CancellablePromise<T = any> = Promise<T> & {
|
|
5
|
+
execContext?: PromiseExecContext;
|
|
6
|
+
};
|
|
7
|
+
export declare const setCancellableContext: (ctx: PromiseExecContext | undefined) => PromiseExecContext | undefined;
|
|
8
|
+
export declare const resetCancellableContext: (ctx: PromiseExecContext | undefined) => void;
|
|
9
|
+
export declare const _exec: (execContext: PromiseExecContext | undefined, cb: Function, args: any[]) => any;
|
|
10
|
+
export declare function patchPromise(): void;
|
|
11
|
+
export declare function restorePromise(): void;
|
|
12
|
+
export declare function getCancellableTask(cb: Function): {
|
|
13
|
+
cancel: () => boolean;
|
|
14
|
+
readonly isCancel: boolean;
|
|
15
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Schema } from "./validation";
|
|
2
2
|
import type { ComponentNode } from "./component_node";
|
|
3
|
+
import type { PluginManager } from "./plugins";
|
|
3
4
|
export declare type Props = {
|
|
4
5
|
[key: string]: any;
|
|
5
6
|
};
|
|
@@ -11,15 +12,16 @@ interface StaticComponentProperties {
|
|
|
11
12
|
[componentName: string]: ComponentConstructor;
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
|
-
export declare type ComponentConstructor<P extends Props = any, E = any> = (new (props: P, env: E, node: ComponentNode) => Component<P, E>) & StaticComponentProperties;
|
|
15
|
-
export declare class Component<Props = any, Env = any> {
|
|
15
|
+
export declare type ComponentConstructor<P extends Props = any, Plugins = any, E = any> = (new (props: P, env: E, plugins: Plugins, node: ComponentNode) => Component<P, Plugins, E>) & StaticComponentProperties;
|
|
16
|
+
export declare class Component<Props = any, Plugins = PluginManager["plugins"], Env = any> {
|
|
16
17
|
static template: string;
|
|
17
18
|
static props?: Schema;
|
|
18
19
|
static defaultProps?: any;
|
|
19
20
|
props: Props;
|
|
20
21
|
env: Env;
|
|
22
|
+
plugins: Plugins;
|
|
21
23
|
__owl__: ComponentNode;
|
|
22
|
-
constructor(props: Props, env: Env, node: ComponentNode);
|
|
24
|
+
constructor(props: Props, env: Env, plugins: Plugins, node: ComponentNode);
|
|
23
25
|
setup(): void;
|
|
24
26
|
render(deep?: boolean): void;
|
|
25
27
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Computation } from "../common/types";
|
|
1
2
|
import type { App, Env } from "./app";
|
|
2
3
|
import { BDom, VNode } from "./blockdom";
|
|
3
4
|
import { Component, ComponentConstructor, Props } from "./component";
|
|
4
5
|
import { Fiber, MountFiber, MountOptions } from "./fibers";
|
|
5
|
-
import {
|
|
6
|
+
import { PluginManager } from "./plugins";
|
|
6
7
|
import { STATUS } from "./status";
|
|
7
8
|
export declare function saveCurrent(): () => void;
|
|
8
9
|
export declare function getCurrent(): ComponentNode;
|
|
@@ -19,11 +20,11 @@ export declare function useComponent(): Component;
|
|
|
19
20
|
*/
|
|
20
21
|
export declare function useState<T extends object>(state: T): T;
|
|
21
22
|
declare type LifecycleHook = Function;
|
|
22
|
-
export declare class ComponentNode<P extends Props = any, E = any> implements VNode<ComponentNode<P, E>> {
|
|
23
|
+
export declare class ComponentNode<P extends Props = any, Plugins = any, E = any> implements VNode<ComponentNode<P, E>> {
|
|
23
24
|
el?: HTMLElement | Text | undefined;
|
|
24
25
|
app: App;
|
|
25
26
|
fiber: Fiber | null;
|
|
26
|
-
component: Component<P, E>;
|
|
27
|
+
component: Component<P, Plugins, E>;
|
|
27
28
|
bdom: BDom | null;
|
|
28
29
|
status: STATUS;
|
|
29
30
|
forceNextRender: boolean;
|
|
@@ -44,7 +45,9 @@ export declare class ComponentNode<P extends Props = any, E = any> implements VN
|
|
|
44
45
|
willPatch: LifecycleHook[];
|
|
45
46
|
patched: LifecycleHook[];
|
|
46
47
|
willDestroy: LifecycleHook[];
|
|
47
|
-
|
|
48
|
+
signalComputation: Computation;
|
|
49
|
+
pluginManager: PluginManager;
|
|
50
|
+
constructor(C: ComponentConstructor<P, Plugins, E>, props: P, app: App, parent: ComponentNode | null, parentKey: string | null);
|
|
48
51
|
mountComponent(target: any, options?: MountOptions): void;
|
|
49
52
|
initiateRender(fiber: Fiber | MountFiber): Promise<void>;
|
|
50
53
|
render(deep: boolean): Promise<void>;
|
|
@@ -76,6 +79,5 @@ export declare class ComponentNode<P extends Props = any, E = any> implements VN
|
|
|
76
79
|
beforeRemove(): void;
|
|
77
80
|
remove(): void;
|
|
78
81
|
get name(): string;
|
|
79
|
-
get subscriptions(): ReturnType<typeof getSubscriptions>;
|
|
80
82
|
}
|
|
81
83
|
export {};
|
|
File without changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createBlock, html, list, mount as blockMount, multi, patch, remove, text, toggler, comment } from "./blockdom";
|
|
2
|
+
export { Registry } from "./registry";
|
|
2
3
|
export declare const blockDom: {
|
|
3
4
|
config: {
|
|
4
5
|
shouldNormalizeDom: boolean;
|
|
@@ -22,6 +23,7 @@ export type { ComponentConstructor } from "./component";
|
|
|
22
23
|
export { useComponent, useState } from "./component_node";
|
|
23
24
|
export { status } from "./status";
|
|
24
25
|
export { reactive, markRaw, toRaw } from "./reactivity";
|
|
26
|
+
export { effect, withoutReactivity, derived, signal } from "./signals";
|
|
25
27
|
export { useEffect, useEnv, useExternalListener, useRef, useChildSubEnv, useSubEnv } from "./hooks";
|
|
26
28
|
export { batched, EventBus, htmlEscape, whenReady, loadFile, markup } from "./utils";
|
|
27
29
|
export { onWillStart, onMounted, onWillUnmount, onWillUpdateProps, onWillPatch, onPatched, onWillRender, onRendered, onWillDestroy, onError, } from "./lifecycle_hooks";
|
|
@@ -30,3 +32,4 @@ export { OwlError } from "../common/owl_error";
|
|
|
30
32
|
export declare const __info__: {
|
|
31
33
|
version: string;
|
|
32
34
|
};
|
|
35
|
+
export { Plugin, PluginManager, usePlugins } from "./plugins";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function reactiveMap<A, B>(arr: A[], fn: (a: A, index: number) => B): any;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface PluginCtor {
|
|
2
|
+
new (deps: any): Plugin<any>;
|
|
3
|
+
id: string;
|
|
4
|
+
dependencies: string[];
|
|
5
|
+
}
|
|
6
|
+
interface PluginMetaData {
|
|
7
|
+
isDestroyed: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class Plugin<Deps = {
|
|
10
|
+
[name: string]: Plugin;
|
|
11
|
+
}> {
|
|
12
|
+
static id: string;
|
|
13
|
+
static dependencies: string[];
|
|
14
|
+
readonly plugins: Deps;
|
|
15
|
+
static resources: {};
|
|
16
|
+
resources: {
|
|
17
|
+
[name: string]: any;
|
|
18
|
+
};
|
|
19
|
+
__meta__: PluginMetaData;
|
|
20
|
+
setup(): void;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
get isDestroyed(): boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare class PluginManager {
|
|
25
|
+
_parent: PluginManager | null;
|
|
26
|
+
_children: PluginManager[];
|
|
27
|
+
plugins: {
|
|
28
|
+
[id: string]: Plugin;
|
|
29
|
+
};
|
|
30
|
+
resources: {
|
|
31
|
+
[id: string]: any;
|
|
32
|
+
};
|
|
33
|
+
constructor(parent: PluginManager | null, Plugins: PluginCtor[] | (() => PluginCtor[]));
|
|
34
|
+
destroy(): void;
|
|
35
|
+
getPlugin(name: string): Plugin | null;
|
|
36
|
+
getResource(name: string): any[];
|
|
37
|
+
}
|
|
38
|
+
export declare function usePlugins(Plugins: PluginCtor[]): void;
|
|
39
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Callback } from "./utils";
|
|
2
1
|
declare type Target = object;
|
|
3
2
|
declare type Reactive<T extends Target> = T;
|
|
4
3
|
/**
|
|
@@ -15,16 +14,6 @@ export declare function markRaw<T extends Target>(value: T): T;
|
|
|
15
14
|
* @returns the underlying value
|
|
16
15
|
*/
|
|
17
16
|
export declare function toRaw<T extends Target, U extends Reactive<T>>(value: U | T): T;
|
|
18
|
-
/**
|
|
19
|
-
* Clears all subscriptions of the Reactives associated with a given callback.
|
|
20
|
-
*
|
|
21
|
-
* @param callback the callback for which the reactives need to be cleared
|
|
22
|
-
*/
|
|
23
|
-
export declare function clearReactivesForCallback(callback: Callback): void;
|
|
24
|
-
export declare function getSubscriptions(callback: Callback): {
|
|
25
|
-
target: object;
|
|
26
|
-
keys: (string | number | symbol)[];
|
|
27
|
-
}[];
|
|
28
17
|
export declare const targets: WeakMap<object, object>;
|
|
29
18
|
/**
|
|
30
19
|
* Creates a reactive proxy for an object. Reading data on the reactive object
|
|
@@ -53,5 +42,5 @@ export declare const targets: WeakMap<object, object>;
|
|
|
53
42
|
* reactive has changed
|
|
54
43
|
* @returns a proxy that tracks changes to it
|
|
55
44
|
*/
|
|
56
|
-
export declare function reactive<T extends Target>(target: T
|
|
45
|
+
export declare function reactive<T extends Target>(target: T): T;
|
|
57
46
|
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Schema } from "./validation";
|
|
2
|
+
declare type Fn<T> = () => T;
|
|
3
|
+
export declare class Registry<T> {
|
|
4
|
+
_map: {
|
|
5
|
+
[key: string]: [number, T];
|
|
6
|
+
};
|
|
7
|
+
_name: string;
|
|
8
|
+
_schema?: Schema;
|
|
9
|
+
items: Fn<T[]>;
|
|
10
|
+
entries: Fn<[string, T][]>;
|
|
11
|
+
constructor(name?: string, schema?: Schema);
|
|
12
|
+
set(key: string, value: T, sequence?: number): void;
|
|
13
|
+
get(key: string, defaultValue?: T): T;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AttrParams, DateParams, DatetimeParams, HtmlParams, ManyParams, RelationParams } from "./discussModelTypes";
|
|
2
|
+
import { Model } from "./model";
|
|
3
|
+
import { FieldDefinition } from "./types";
|
|
4
|
+
export declare class DiscussRecord {
|
|
5
|
+
static Model: typeof Model;
|
|
6
|
+
static fields: Record<string, FieldDefinition>;
|
|
7
|
+
static register(): void;
|
|
8
|
+
static insert(data: Partial<any>): any;
|
|
9
|
+
record: Model;
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
12
|
+
export declare const fields: {
|
|
13
|
+
One: (modelName: string, params?: RelationParams) => import("./types").FieldDefinitionMany2One;
|
|
14
|
+
Many: (modelName: string, params?: ManyParams) => FieldDefinition;
|
|
15
|
+
Attr: (defaultValue: string, params?: AttrParams) => import("./types").FieldDefinitionAny;
|
|
16
|
+
Html: (defaultValue: string, params?: HtmlParams) => import("./types").FieldDefinitionAny;
|
|
17
|
+
Date: (params?: DateParams) => import("./types").FieldDefinitionAny;
|
|
18
|
+
Datetime: (params?: DatetimeParams) => import("./types").FieldDefinitionAny;
|
|
19
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DiscussRecord } from "./discussModel";
|
|
2
|
+
export declare type FieldCommonParams = {
|
|
3
|
+
compute?: (record: DiscussRecord) => any;
|
|
4
|
+
eager?: boolean;
|
|
5
|
+
onUpdate?: (record: DiscussRecord) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare type RelationParams = FieldCommonParams & {
|
|
8
|
+
inverse?: string;
|
|
9
|
+
onAdd?: (record: DiscussRecord) => void;
|
|
10
|
+
onDelete?: (record: DiscussRecord) => void;
|
|
11
|
+
};
|
|
12
|
+
export declare type ManyParams = RelationParams & {
|
|
13
|
+
sort?: (a: DiscussRecord, b: DiscussRecord) => number;
|
|
14
|
+
};
|
|
15
|
+
export declare type AttrParams = FieldCommonParams & {
|
|
16
|
+
sort?: (a: DiscussRecord, b: DiscussRecord) => number;
|
|
17
|
+
type?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare type HtmlParams = FieldCommonParams;
|
|
20
|
+
export declare type DateParams = FieldCommonParams;
|
|
21
|
+
export declare type DatetimeParams = FieldCommonParams;
|
|
22
|
+
export declare type DManyFn<T extends DiscussRecord> = () => T[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FieldDefinition, FieldDefinitionAny, FieldDefinitionChar, FieldDefinitionDate, FieldDefinitionDatetime, FieldDefinitionHtml, FieldDefinitionMany2One, FieldDefinitionMany2OneReference, FieldDefinitionNumber, FieldDefinitionOne2Many, FieldDefinitionProperties, FieldDefinitionReference, FieldDefinitionSelection, FieldDefinitionText, FieldTypes, ModelId } from "./types";
|
|
2
|
+
export declare const fieldAny: () => FieldDefinitionAny;
|
|
3
|
+
export declare const fieldNumber: () => FieldDefinitionNumber;
|
|
4
|
+
export declare const fieldChar: () => FieldDefinitionChar;
|
|
5
|
+
export declare const fieldText: () => FieldDefinitionText;
|
|
6
|
+
export declare const fieldHtml: () => FieldDefinitionHtml;
|
|
7
|
+
export declare const fieldDate: () => FieldDefinitionDate;
|
|
8
|
+
export declare const fieldDatetime: () => FieldDefinitionDatetime;
|
|
9
|
+
export declare const fieldSelection: (selection: any) => FieldDefinitionSelection;
|
|
10
|
+
export declare const fieldReference: () => FieldDefinitionReference;
|
|
11
|
+
export declare const fieldProperties: () => FieldDefinitionProperties;
|
|
12
|
+
export declare const fieldOne2Many: (modelId: ModelId, { relatedField }?: {
|
|
13
|
+
relatedField?: string | undefined;
|
|
14
|
+
}) => FieldDefinitionOne2Many;
|
|
15
|
+
export declare const fieldMany2One: (modelId: ModelId) => FieldDefinitionMany2One;
|
|
16
|
+
export declare const fieldMany2Many: (modelId: ModelId, opts?: {
|
|
17
|
+
relationTableName?: string;
|
|
18
|
+
}) => FieldDefinition;
|
|
19
|
+
export declare const fieldMany2OneReference: () => FieldDefinitionMany2OneReference;
|
|
20
|
+
export declare const field: (type: FieldTypes, opts?: any) => FieldDefinition;
|