@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.
Files changed (73) hide show
  1. package/dist/compile_templates.mjs +92 -189
  2. package/dist/compiler.js +2378 -0
  3. package/dist/owl-devtools.zip +0 -0
  4. package/dist/owl.cjs.js +1371 -1261
  5. package/dist/owl.cjs.runtime.js +4094 -0
  6. package/dist/owl.es.js +1358 -1252
  7. package/dist/owl.es.runtime.js +4050 -0
  8. package/dist/owl.iife.js +1371 -1261
  9. package/dist/owl.iife.min.js +1 -1
  10. package/dist/owl.iife.runtime.js +4098 -0
  11. package/dist/owl.iife.runtime.min.js +1 -0
  12. package/dist/types/compiler/code_generator.d.ts +3 -5
  13. package/dist/types/compiler/index.d.ts +4 -4
  14. package/dist/types/compiler/inline_expressions.d.ts +1 -1
  15. package/dist/types/compiler/parser.d.ts +21 -28
  16. package/dist/types/owl.d.ts +299 -205
  17. package/dist/types/runtime/app.d.ts +29 -31
  18. package/dist/types/runtime/blockdom/block_compiler.d.ts +3 -3
  19. package/dist/types/runtime/blockdom/config.d.ts +1 -1
  20. package/dist/types/runtime/blockdom/event_catcher.d.ts +2 -2
  21. package/dist/types/runtime/blockdom/events.d.ts +1 -1
  22. package/dist/types/runtime/blockdom/index.d.ts +1 -1
  23. package/dist/types/runtime/cancellableContext.d.ts +15 -0
  24. package/dist/types/runtime/cancellablePromise.d.ts +15 -0
  25. package/dist/types/runtime/component.d.ts +5 -13
  26. package/dist/types/runtime/component_node.d.ts +15 -35
  27. package/dist/types/runtime/event_handling.d.ts +1 -1
  28. package/dist/types/runtime/executionContext.d.ts +0 -0
  29. package/dist/types/runtime/hooks.d.ts +7 -33
  30. package/dist/types/runtime/index.d.ts +15 -5
  31. package/dist/types/runtime/lifecycle_hooks.d.ts +1 -3
  32. package/dist/types/runtime/listOperation.d.ts +1 -0
  33. package/dist/types/runtime/plugins.d.ts +23 -0
  34. package/dist/types/runtime/portal.d.ts +4 -6
  35. package/dist/types/runtime/props.d.ts +65 -0
  36. package/dist/types/runtime/reactivity/computations.d.ts +31 -0
  37. package/dist/types/runtime/reactivity/computed.d.ts +7 -0
  38. package/dist/types/runtime/reactivity/derived.d.ts +7 -0
  39. package/dist/types/runtime/reactivity/effect.d.ts +2 -0
  40. package/dist/types/runtime/reactivity/proxy.d.ts +46 -0
  41. package/dist/types/runtime/reactivity/reactivity.d.ts +46 -0
  42. package/dist/types/runtime/reactivity/signal.d.ts +17 -0
  43. package/dist/types/runtime/reactivity/signals.d.ts +30 -0
  44. package/dist/types/runtime/registry.d.ts +19 -0
  45. package/dist/types/runtime/relationalModel/discussModel.d.ts +19 -0
  46. package/dist/types/runtime/relationalModel/discussModelTypes.d.ts +22 -0
  47. package/dist/types/runtime/relationalModel/field.d.ts +20 -0
  48. package/dist/types/runtime/relationalModel/model.d.ts +59 -0
  49. package/dist/types/runtime/relationalModel/modelData.d.ts +18 -0
  50. package/dist/types/runtime/relationalModel/modelRegistry.d.ts +3 -0
  51. package/dist/types/runtime/relationalModel/modelUtils.d.ts +4 -0
  52. package/dist/types/runtime/relationalModel/store.d.ts +16 -0
  53. package/dist/types/runtime/relationalModel/types.d.ts +83 -0
  54. package/dist/types/runtime/relationalModel/util.d.ts +1 -0
  55. package/dist/types/runtime/relationalModel/web/WebDataPoint.d.ts +25 -0
  56. package/dist/types/runtime/relationalModel/web/WebRecord.d.ts +131 -0
  57. package/dist/types/runtime/relationalModel/web/WebStaticList.d.ts +63 -0
  58. package/dist/types/runtime/relationalModel/web/webModel.d.ts +5 -0
  59. package/dist/types/runtime/relationalModel/web/webModelTypes.d.ts +139 -0
  60. package/dist/types/runtime/rendering/error_handling.d.ts +13 -0
  61. package/dist/types/runtime/rendering/fibers.d.ts +37 -0
  62. package/dist/types/runtime/rendering/scheduler.d.ts +21 -0
  63. package/dist/types/runtime/rendering/template_helpers.d.ts +50 -0
  64. package/dist/types/runtime/resource.d.ts +12 -0
  65. package/dist/types/runtime/signals.d.ts +19 -0
  66. package/dist/types/runtime/status.d.ts +2 -3
  67. package/dist/types/runtime/task.d.ts +12 -0
  68. package/dist/types/runtime/template_set.d.ts +3 -4
  69. package/dist/types/runtime/utils.d.ts +1 -2
  70. package/dist/types/runtime/validation.d.ts +6 -6
  71. package/dist/types/utils/registry.d.ts +15 -0
  72. package/dist/types/version.d.ts +1 -1
  73. package/package.json +9 -9
@@ -0,0 +1,139 @@
1
+ export interface WebModelConfig {
2
+ isMonoRecord: boolean;
3
+ context: Record<string, any>;
4
+ fieldsToAggregate: string[];
5
+ activeFields?: {
6
+ [key: string]: ActiveFieldInfo;
7
+ };
8
+ fields: {
9
+ [key: string]: FieldInfo;
10
+ };
11
+ isRoot: boolean;
12
+ resModel: string;
13
+ groupBy: string[];
14
+ resId?: number | false;
15
+ resIds?: number[];
16
+ mode?: "edit" | "readonly";
17
+ domain: any[];
18
+ orderBy: OrderBy[];
19
+ groups?: Record<string, any>;
20
+ offset: number;
21
+ limit: number;
22
+ countLimit: number;
23
+ currentGroups?: {
24
+ params: string;
25
+ groups: any[];
26
+ };
27
+ loadId?: string;
28
+ openGroupsByDefault?: boolean;
29
+ [key: string]: any;
30
+ }
31
+ export interface FieldInfo {
32
+ change_default?: boolean;
33
+ groupable?: boolean;
34
+ name?: string;
35
+ readonly?: boolean;
36
+ required?: boolean;
37
+ searchable?: boolean;
38
+ sortable?: boolean;
39
+ store?: boolean;
40
+ string?: string;
41
+ type?: string;
42
+ help?: string;
43
+ translate?: boolean;
44
+ trim?: boolean;
45
+ context?: {};
46
+ domain?: any[];
47
+ relation?: string;
48
+ related?: string;
49
+ selection?: Array<[string, string]>;
50
+ groups?: string;
51
+ relation_field?: string;
52
+ aggregator?: string;
53
+ digits?: [number, number];
54
+ size?: number;
55
+ currency_field?: string;
56
+ sanitize?: boolean;
57
+ sanitize_tags?: boolean;
58
+ definition_record?: string;
59
+ definition_record_field?: string;
60
+ }
61
+ export interface ActiveFieldInfo {
62
+ context: {};
63
+ invisible: string | boolean;
64
+ readonly: string | boolean;
65
+ required: string | boolean;
66
+ onChange: boolean;
67
+ forceSave: boolean;
68
+ isHandle: boolean;
69
+ related?: {
70
+ activeFields: {
71
+ [key: string]: ActiveFieldInfo;
72
+ };
73
+ fields: {
74
+ [key: string]: FieldInfo;
75
+ };
76
+ };
77
+ }
78
+ export interface WebModelConfigContext {
79
+ default_is_company: boolean;
80
+ lang: string;
81
+ tz: string;
82
+ uid: number;
83
+ allowed_company_ids: number[];
84
+ }
85
+ export interface RelationalModelParams {
86
+ config: {
87
+ activeFields: {
88
+ [key: string]: ActiveFieldInfo;
89
+ };
90
+ [key: string]: any;
91
+ };
92
+ limit?: number;
93
+ groupsLimit?: number;
94
+ countLimit?: number;
95
+ defaultOrderBy?: OrderBy[];
96
+ maxGroupByDepth?: number;
97
+ groupByInfo?: Record<string, any>;
98
+ multiEdit?: boolean;
99
+ activeIdsLimit?: number;
100
+ state?: {
101
+ specialDataCaches?: Record<string, any>;
102
+ };
103
+ useSendBeaconToSaveUrgently?: boolean;
104
+ hooks?: Partial<RelationalModelHooks>;
105
+ [key: string]: any;
106
+ }
107
+ export interface OrderBy {
108
+ name: string;
109
+ asc?: boolean;
110
+ }
111
+ export interface SearchParams {
112
+ context?: Record<string, any>;
113
+ resId?: number | false;
114
+ resIds?: number[];
115
+ domain?: any[];
116
+ groupBy?: string[];
117
+ orderBy?: OrderBy[];
118
+ limit?: number;
119
+ offset?: number;
120
+ countLimit?: number;
121
+ }
122
+ export interface Services {
123
+ action: any;
124
+ dialog: any;
125
+ notification: any;
126
+ orm: any;
127
+ }
128
+ export interface OnChangeParams {
129
+ changes?: Record<string, any>;
130
+ fieldNames?: string[];
131
+ evalContext?: Record<string, any>;
132
+ onError?: (error: any) => void;
133
+ cache?: any;
134
+ }
135
+ export interface RelationalModelHooks {
136
+ onWillLoadRoot: (config: WebModelConfig) => Promise<void>;
137
+ onRootLoaded: (root: any) => Promise<void>;
138
+ onWillDisplayOnchangeWarning: (warning: any) => Promise<void>;
139
+ }
@@ -0,0 +1,13 @@
1
+ import type { ComponentNode } from "../component_node";
2
+ import type { Fiber } from "./fibers";
3
+ export declare const fibersInError: WeakMap<Fiber, any>;
4
+ export declare const nodeErrorHandlers: WeakMap<ComponentNode, ((error: any, finalize: Function) => void)[]>;
5
+ type ErrorParams = {
6
+ error: any;
7
+ } & ({
8
+ node: ComponentNode;
9
+ } | {
10
+ fiber: Fiber;
11
+ });
12
+ export declare function handleError(params: ErrorParams): void;
13
+ export {};
@@ -0,0 +1,37 @@
1
+ import { BDom } from "../blockdom";
2
+ import type { ComponentNode } from "../component_node";
3
+ export declare function makeChildFiber(node: ComponentNode, parent: Fiber): Fiber;
4
+ export declare function makeRootFiber(node: ComponentNode): Fiber;
5
+ export declare class Fiber {
6
+ node: ComponentNode;
7
+ bdom: BDom | null;
8
+ root: RootFiber | null;
9
+ parent: Fiber | null;
10
+ children: Fiber[];
11
+ appliedToDom: boolean;
12
+ deep: boolean;
13
+ childrenMap: ComponentNode["children"];
14
+ constructor(node: ComponentNode, parent: Fiber | null);
15
+ render(): void;
16
+ _render(): void;
17
+ }
18
+ export declare class RootFiber extends Fiber {
19
+ counter: number;
20
+ willPatch: Fiber[];
21
+ patched: Fiber[];
22
+ mounted: Fiber[];
23
+ locked: boolean;
24
+ complete(): void;
25
+ setCounter(newValue: number): void;
26
+ }
27
+ type Position = "first-child" | "last-child";
28
+ export interface MountOptions {
29
+ position?: Position;
30
+ }
31
+ export declare class MountFiber extends RootFiber {
32
+ target: HTMLElement;
33
+ position: Position;
34
+ constructor(node: ComponentNode, target: HTMLElement, options?: MountOptions);
35
+ complete(): void;
36
+ }
37
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { ComponentNode } from "../component_node";
2
+ import { Fiber, RootFiber } from "./fibers";
3
+ export declare class Scheduler {
4
+ static requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
5
+ tasks: Set<RootFiber>;
6
+ requestAnimationFrame: Window["requestAnimationFrame"];
7
+ frame: number;
8
+ delayedRenders: Fiber[];
9
+ cancelledNodes: Set<ComponentNode>;
10
+ processing: boolean;
11
+ constructor();
12
+ addFiber(fiber: Fiber): void;
13
+ scheduleDestroy(node: ComponentNode): void;
14
+ /**
15
+ * Process all current tasks. This only applies to the fibers that are ready.
16
+ * Other tasks are left unchanged.
17
+ */
18
+ flush(): void;
19
+ processTasks(): void;
20
+ processFiber(fiber: RootFiber): void;
21
+ }
@@ -0,0 +1,50 @@
1
+ import { BDom, toggler, createCatcher } from "../blockdom";
2
+ import { markRaw } from "../reactivity/proxy";
3
+ import { OwlError } from "../../common/owl_error";
4
+ /**
5
+ * This file contains utility functions that will be injected in each template,
6
+ * to perform various useful tasks in the compiled code.
7
+ */
8
+ declare function withDefault(value: any, defaultValue: any): any;
9
+ 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
+ declare function withKey(elem: any, k: string): any;
12
+ 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
+ declare function toNumber(val: string): number | string;
17
+ declare function shallowEqual(l1: any[], l2: any[]): boolean;
18
+ declare class LazyValue {
19
+ fn: any;
20
+ ctx: any;
21
+ component: any;
22
+ node: any;
23
+ key: any;
24
+ constructor(fn: any, ctx: any, component: any, node: any, key: any);
25
+ evaluate(): any;
26
+ toString(): any;
27
+ }
28
+ export declare function safeOutput(value: any, defaultValue?: any): ReturnType<typeof toggler>;
29
+ declare function createRef(ref: any): (el: HTMLElement | null, previousEl: HTMLElement | null) => void;
30
+ declare function modelExpr(value: any): any;
31
+ export declare const helpers: {
32
+ withDefault: typeof withDefault;
33
+ zero: symbol;
34
+ isBoundary: symbol;
35
+ callSlot: typeof callSlot;
36
+ capture: typeof capture;
37
+ withKey: typeof withKey;
38
+ prepareList: typeof prepareList;
39
+ setContextValue: typeof setContextValue;
40
+ shallowEqual: typeof shallowEqual;
41
+ toNumber: typeof toNumber;
42
+ LazyValue: typeof LazyValue;
43
+ safeOutput: typeof safeOutput;
44
+ createCatcher: typeof createCatcher;
45
+ markRaw: typeof markRaw;
46
+ OwlError: typeof OwlError;
47
+ createRef: typeof createRef;
48
+ modelExpr: typeof modelExpr;
49
+ };
50
+ export {};
@@ -0,0 +1,12 @@
1
+ import { TypeDescription } from "./validation";
2
+ export declare class Resource<T> {
3
+ private _items;
4
+ private _name;
5
+ private _type?;
6
+ constructor(name?: string, type?: TypeDescription);
7
+ items: import("./reactivity/signal").ReactiveValue<T[]>;
8
+ add(item: T, sequence?: number): Resource<T>;
9
+ remove(item: T): Resource<T>;
10
+ has(item: T): boolean;
11
+ }
12
+ export declare function useResource<T>(r: Resource<T>, elements: T[]): void;
@@ -0,0 +1,19 @@
1
+ import { Atom, Computation, Derived, Opts } from "../common/types";
2
+ type SignalFunction<T> = () => T;
3
+ export interface Signal<T> extends SignalFunction<T> {
4
+ set(value: T): void;
5
+ }
6
+ export declare function signal<T>(value: T, opts?: Opts): Signal<T>;
7
+ export declare function effect<T>(fn: () => T, opts?: Opts): () => void;
8
+ export declare function derived<T>(fn: () => T, opts?: Opts): () => T;
9
+ export declare function onReadAtom(atom: Atom): void;
10
+ export declare function onWriteAtom(atom: Atom): void;
11
+ export declare function withoutReactivity<T extends (...args: any[]) => any>(fn: T): ReturnType<T>;
12
+ export declare function getCurrentComputation(): Computation<any> | undefined;
13
+ export declare function setComputation(computation: Computation | undefined): void;
14
+ export declare function runWithComputation<T>(computation: Computation, fn: () => T): T;
15
+ export declare function setSignalHooks(hooks: {
16
+ onDerived: (derived: Derived<any, any>) => void;
17
+ }): void;
18
+ export declare function resetSignalHooks(): void;
19
+ export {};
@@ -1,10 +1,9 @@
1
- import type { Component } from "./component";
2
1
  export declare const enum STATUS {
3
2
  NEW = 0,
4
3
  MOUNTED = 1,
5
4
  CANCELLED = 2,
6
5
  DESTROYED = 3
7
6
  }
8
- declare type STATUS_DESCR = "new" | "mounted" | "cancelled" | "destroyed";
9
- export declare function status(component: Component): STATUS_DESCR;
7
+ type STATUS_DESCR = "new" | "started" | "mounted" | "cancelled" | "destroyed";
8
+ export declare function status(): () => STATUS_DESCR;
10
9
  export {};
@@ -0,0 +1,12 @@
1
+ import { TaskContext } from "./cancellableContext";
2
+ export declare class Task<T = any> {
3
+ _onCancelled?: Function | undefined;
4
+ _promise: Promise<T>;
5
+ _ctx?: TaskContext;
6
+ constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason: any) => void) => void, _onCancelled?: Function | undefined);
7
+ then(onFulfilled: (value: any) => any, onRejected: (error: any) => any): Promise<any>;
8
+ catch(onRejected: (error: any) => any): Promise<any>;
9
+ finally(onFinally: () => any): Promise<T>;
10
+ cancel(): void;
11
+ get [Symbol.toStringTag](): string;
12
+ }
@@ -1,13 +1,12 @@
1
- import { compile, Template, TemplateFunction } from "../compiler";
1
+ import { compile, CustomDirectives, Template, TemplateFunction } from "../compiler";
2
2
  import { Portal } from "./portal";
3
- import type { customDirectives } from "../common/types";
4
3
  export interface TemplateSetConfig {
5
4
  dev?: boolean;
6
5
  translatableAttributes?: string[];
7
6
  translateFn?: (s: string, translationCtx: string) => string;
8
7
  templates?: string | Document | Record<string, string>;
9
8
  getTemplate?: (s: string) => Element | Function | string | void;
10
- customDirectives?: customDirectives;
9
+ customDirectives?: CustomDirectives;
11
10
  globalValues?: object;
12
11
  }
13
12
  export declare class TemplateSet {
@@ -21,7 +20,7 @@ export declare class TemplateSet {
21
20
  translateFn?: (s: string, translationCtx: string) => string;
22
21
  translatableAttributes?: string[];
23
22
  Portal: typeof Portal;
24
- customDirectives: customDirectives;
23
+ customDirectives: CustomDirectives;
25
24
  runtimeUtils: object;
26
25
  hasGlobalValues: boolean;
27
26
  constructor(config?: TemplateSetConfig);
@@ -1,4 +1,4 @@
1
- export declare type Callback = () => void;
1
+ export type Callback = () => void;
2
2
  /**
3
3
  * Creates a batched version of a callback so that all calls to it in the same
4
4
  * microtick will only call the original callback once.
@@ -17,7 +17,6 @@ export declare class EventBus extends EventTarget {
17
17
  trigger(name: string, payload?: any): void;
18
18
  }
19
19
  export declare function whenReady(fn?: any): Promise<void>;
20
- export declare function loadFile(url: string): Promise<string>;
21
20
  export declare class Markup extends String {
22
21
  }
23
22
  export declare function htmlEscape(str: any): Markup;
@@ -1,4 +1,4 @@
1
- declare type BaseType = {
1
+ type BaseType = {
2
2
  new (...args: any[]): any;
3
3
  } | true | "*";
4
4
  interface TypeInfo {
@@ -9,15 +9,15 @@ interface TypeInfo {
9
9
  element?: TypeDescription;
10
10
  values?: TypeDescription;
11
11
  }
12
- declare type ValueType = {
12
+ type ValueType = {
13
13
  value: any;
14
14
  };
15
- declare type TypeDescription = BaseType | TypeInfo | ValueType | TypeDescription[];
16
- declare type SimplifiedSchema = string[];
17
- declare type NormalizedSchema = {
15
+ export type TypeDescription = BaseType | TypeInfo | ValueType | TypeDescription[];
16
+ type SimplifiedSchema = string[];
17
+ type NormalizedSchema = {
18
18
  [key: string]: TypeDescription;
19
19
  };
20
- export declare type Schema = SimplifiedSchema | NormalizedSchema;
20
+ export type Schema = SimplifiedSchema | NormalizedSchema;
21
21
  export declare function isOptional(t: TypeDescription): Boolean;
22
22
  /**
23
23
  * Main validate function
@@ -0,0 +1,15 @@
1
+ import { Schema } from "../runtime/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 {};
@@ -1 +1 @@
1
- export declare const version = "2.8.1";
1
+ export declare const version = "3.0.0-alpha";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/owl",
3
- "version": "2.8.1",
3
+ "version": "3.0.0-alpha.10",
4
4
  "description": "Odoo Web Library (OWL)",
5
5
  "main": "dist/owl.cjs.js",
6
6
  "module": "dist/owl.es.js",
@@ -48,9 +48,7 @@
48
48
  },
49
49
  "homepage": "https://github.com/odoo/owl#readme",
50
50
  "devDependencies": {
51
- "@types/jest": "^27.0.1",
52
- "@types/jsdom": "^21.1.7",
53
- "@types/node": "^14.11.8",
51
+ "@types/jest": "^29.5.2",
54
52
  "@typescript-eslint/eslint-plugin": "5.48.1",
55
53
  "@typescript-eslint/parser": "5.48.1",
56
54
  "chalk": "^3.0.0",
@@ -58,9 +56,9 @@
58
56
  "eslint": "8.31.0",
59
57
  "git-rev-sync": "^3.0.2",
60
58
  "github-api": "^3.3.0",
61
- "jest": "^27.1.0",
59
+ "jest": "^29.7.0",
62
60
  "jest-diff": "^27.3.1",
63
- "jest-environment-jsdom": "^27.1.0",
61
+ "jest-environment-jsdom": "^30.2.0",
64
62
  "npm-run-all": "^4.1.5",
65
63
  "prettier": "2.4.1",
66
64
  "rollup": "^2.56.3",
@@ -69,11 +67,13 @@
69
67
  "rollup-plugin-dts": "^4.2.2",
70
68
  "rollup-plugin-execute": "^1.1.1",
71
69
  "rollup-plugin-string": "^3.0.0",
72
- "rollup-plugin-terser": "^7.0.2",
70
+ "@rollup/plugin-terser": "^0.3.0",
73
71
  "rollup-plugin-typescript2": "^0.31.1",
74
72
  "source-map-support": "^0.5.10",
75
- "ts-jest": "^27.0.5",
76
- "typescript": "4.5.2"
73
+ "ts-jest": "^29.4.6",
74
+ "@types/node": "^18.16.18",
75
+ "typescript": "^4.9.5",
76
+ "@types/jsdom": "^21.1.7"
77
77
  },
78
78
  "jest": {
79
79
  "testEnvironment": "jsdom",