@odoo/owl 3.0.0-alpha.13 → 3.0.0-alpha.15

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 (54) hide show
  1. package/dist/compile_templates.mjs +2443 -2435
  2. package/dist/owl.cjs.js +6476 -6381
  3. package/dist/owl.es.js +6475 -6379
  4. package/dist/owl.iife.js +6476 -6381
  5. package/dist/owl.iife.min.js +1 -1
  6. package/dist/types/common/owl_error.d.ts +3 -3
  7. package/dist/types/common/utils.d.ts +8 -8
  8. package/dist/types/compiler/code_generator.d.ts +150 -150
  9. package/dist/types/compiler/index.d.ts +13 -13
  10. package/dist/types/compiler/inline_expressions.d.ts +59 -59
  11. package/dist/types/compiler/parser.d.ts +171 -171
  12. package/dist/types/compiler/standalone/index.d.ts +2 -2
  13. package/dist/types/compiler/standalone/setup_jsdom.d.ts +1 -1
  14. package/dist/types/index.d.ts +1 -1
  15. package/dist/types/owl.d.ts +682 -672
  16. package/dist/types/runtime/app.d.ts +58 -57
  17. package/dist/types/runtime/blockdom/attributes.d.ts +6 -6
  18. package/dist/types/runtime/blockdom/block_compiler.d.ts +21 -21
  19. package/dist/types/runtime/blockdom/config.d.ts +8 -8
  20. package/dist/types/runtime/blockdom/event_catcher.d.ts +7 -7
  21. package/dist/types/runtime/blockdom/events.d.ts +8 -8
  22. package/dist/types/runtime/blockdom/html.d.ts +17 -17
  23. package/dist/types/runtime/blockdom/index.d.ts +26 -26
  24. package/dist/types/runtime/blockdom/list.d.ts +18 -18
  25. package/dist/types/runtime/blockdom/multi.d.ts +17 -17
  26. package/dist/types/runtime/blockdom/text.d.ts +26 -26
  27. package/dist/types/runtime/blockdom/toggler.d.ts +17 -17
  28. package/dist/types/runtime/component.d.ts +17 -18
  29. package/dist/types/runtime/component_node.d.ts +61 -61
  30. package/dist/types/runtime/event_handling.d.ts +1 -1
  31. package/dist/types/runtime/hooks.d.ts +34 -33
  32. package/dist/types/runtime/index.d.ts +43 -43
  33. package/dist/types/runtime/lifecycle_hooks.d.ts +10 -10
  34. package/dist/types/runtime/plugins.d.ts +36 -29
  35. package/dist/types/runtime/portal.d.ts +12 -12
  36. package/dist/types/runtime/props.d.ts +21 -17
  37. package/dist/types/runtime/reactivity/computations.d.ts +31 -31
  38. package/dist/types/runtime/reactivity/computed.d.ts +7 -7
  39. package/dist/types/runtime/reactivity/effect.d.ts +2 -2
  40. package/dist/types/runtime/reactivity/proxy.d.ts +48 -48
  41. package/dist/types/runtime/reactivity/signal.d.ts +18 -18
  42. package/dist/types/runtime/registry.d.ts +24 -20
  43. package/dist/types/runtime/rendering/error_handling.d.ts +13 -13
  44. package/dist/types/runtime/rendering/fibers.d.ts +37 -37
  45. package/dist/types/runtime/rendering/scheduler.d.ts +21 -21
  46. package/dist/types/runtime/rendering/template_helpers.d.ts +50 -50
  47. package/dist/types/runtime/resource.d.ts +17 -15
  48. package/dist/types/runtime/status.d.ts +9 -9
  49. package/dist/types/runtime/template_set.d.ts +39 -39
  50. package/dist/types/runtime/types.d.ts +62 -31
  51. package/dist/types/runtime/utils.d.ts +24 -24
  52. package/dist/types/runtime/validation.d.ts +19 -2
  53. package/dist/types/version.d.ts +1 -1
  54. package/package.json +13 -11
@@ -1,150 +1,150 @@
1
- import { AST, ASTComment, ASTComponent, ASTDebug, ASTDomNode, ASTLog, ASTMulti, ASTTCallSlot, ASTTCall, ASTTCallBlock, ASTText, ASTTForEach, ASTTif, ASTTKey, ASTTOut, ASTTPortal, ASTTranslation, ASTTranslationContext, ASTTSet, EventHandlers } from "./parser";
2
- type BlockType = "block" | "text" | "multi" | "list" | "html" | "comment";
3
- export interface Config {
4
- translateFn?: (s: string, translationCtx: string) => string;
5
- translatableAttributes?: string[];
6
- dev?: boolean;
7
- }
8
- export interface CodeGenOptions extends Config {
9
- hasSafeContext?: boolean;
10
- name?: string;
11
- hasGlobalValues: boolean;
12
- }
13
- declare class BlockDescription {
14
- static nextBlockId: number;
15
- varName: string;
16
- blockName: string;
17
- dynamicTagName: string | null;
18
- isRoot: boolean;
19
- hasDynamicChildren: boolean;
20
- children: BlockDescription[];
21
- data: string[];
22
- dom?: Node;
23
- currentDom?: Element;
24
- childNumber: number;
25
- target: CodeTarget;
26
- type: BlockType;
27
- parentVar: string;
28
- id: number;
29
- constructor(target: CodeTarget, type: BlockType);
30
- insertData(str: string, prefix?: string): number;
31
- insert(dom: Node): void;
32
- generateExpr(expr: string): string;
33
- asXmlString(): string;
34
- }
35
- interface Context {
36
- block: BlockDescription | null;
37
- index: number | string;
38
- forceNewBlock: boolean;
39
- isLast?: boolean;
40
- translate: boolean;
41
- translationCtx: string;
42
- tKeyExpr: string | null;
43
- nameSpace?: string;
44
- tModelSelectedExpr?: string;
45
- ctxVar?: string;
46
- inPreTag?: boolean;
47
- }
48
- declare class CodeTarget {
49
- name: string;
50
- indentLevel: number;
51
- loopLevel: number;
52
- code: string[];
53
- hasRoot: boolean;
54
- hasCache: boolean;
55
- shouldProtectScope: boolean;
56
- on: EventHandlers | null;
57
- constructor(name: string, on?: EventHandlers | null);
58
- addLine(line: string, idx?: number): void;
59
- generateCode(): string;
60
- currentKey(ctx: Context): string;
61
- }
62
- export declare class CodeGenerator {
63
- blocks: BlockDescription[];
64
- nextBlockId: number;
65
- hasSafeContext: boolean;
66
- isDebug: boolean;
67
- targets: CodeTarget[];
68
- target: CodeTarget;
69
- templateName?: string;
70
- dev: boolean;
71
- translateFn: (s: string, translationCtx: string) => string;
72
- translatableAttributes: string[];
73
- ast: AST;
74
- staticDefs: {
75
- id: string;
76
- expr: string;
77
- }[];
78
- slotNames: Set<String>;
79
- helpers: Set<string>;
80
- constructor(ast: AST, options: CodeGenOptions);
81
- generateCode(): string;
82
- compileInNewTarget(prefix: string, ast: AST, ctx: Context, on?: EventHandlers | null): string;
83
- addLine(line: string, idx?: number): void;
84
- define(varName: string, expr: string): void;
85
- insertAnchor(block: BlockDescription, index?: number): void;
86
- createBlock(parentBlock: BlockDescription | null, type: BlockType, ctx: Context): BlockDescription;
87
- insertBlock(expression: string, block: BlockDescription, ctx: Context): void;
88
- /**
89
- * Captures variables that are used inside of an expression. This is useful
90
- * because in compiled code, almost all variables are accessed through the ctx
91
- * object. In the case of functions, that lookup in the context can be delayed
92
- * which can cause issues if the value has changed since the function was
93
- * defined.
94
- *
95
- * @param expr the expression to capture
96
- * @param forceCapture whether the expression should capture its scope even if
97
- * it doesn't contain a function. Useful when the expression will be used as
98
- * a function body.
99
- * @returns a new expression that uses the captured values
100
- */
101
- captureExpression(expr: string, forceCapture?: boolean): string;
102
- translate(str: string, translationCtx: string): string;
103
- /**
104
- * @returns the newly created block name, if any
105
- */
106
- compileAST(ast: AST, ctx: Context): string | null;
107
- compileDebug(ast: ASTDebug, ctx: Context): string | null;
108
- compileLog(ast: ASTLog, ctx: Context): string | null;
109
- compileComment(ast: ASTComment, ctx: Context): string;
110
- compileText(ast: ASTText, ctx: Context): string;
111
- generateHandlerCode(rawEvent: string, handler: string): string;
112
- compileTDomNode(ast: ASTDomNode, ctx: Context): string;
113
- compileTOut(ast: ASTTOut, ctx: Context): string;
114
- compileTIfBranch(content: AST, block: BlockDescription, ctx: Context): void;
115
- compileTIf(ast: ASTTif, ctx: Context, nextNode?: ASTDomNode): string;
116
- compileTForeach(ast: ASTTForEach, ctx: Context): string;
117
- compileTKey(ast: ASTTKey, ctx: Context): string | null;
118
- compileMulti(ast: ASTMulti, ctx: Context): string | null;
119
- compileTCall(ast: ASTTCall, ctx: Context): string;
120
- compileTCallBlock(ast: ASTTCallBlock, ctx: Context): string;
121
- compileTSet(ast: ASTTSet, ctx: Context): null;
122
- generateComponentKey(currentKey?: string): string;
123
- /**
124
- * Formats a prop name and value into a string suitable to be inserted in the
125
- * generated code. For example:
126
- *
127
- * Name Value Result
128
- * ---------------------------------------------------------
129
- * "number" "state" "number: ctx['state']"
130
- * "something" "" "something: undefined"
131
- * "some-prop" "state" "'some-prop': ctx['state']"
132
- * "onClick.bind" "onClick" "onClick: bind(ctx, ctx['onClick'])"
133
- */
134
- formatProp(name: string, value: string, attrsTranslationCtx: {
135
- [name: string]: string;
136
- } | null, translationCtx: string): string;
137
- formatPropObject(obj: {
138
- [prop: string]: any;
139
- }, attrsTranslationCtx: {
140
- [name: string]: string;
141
- } | null, translationCtx: string): string[];
142
- getPropString(props: string[], dynProps: string | null): string;
143
- compileComponent(ast: ASTComponent, ctx: Context): string;
144
- wrapWithEventCatcher(expr: string, on: EventHandlers): string;
145
- compileTCallSlot(ast: ASTTCallSlot, ctx: Context): string;
146
- compileTTranslation(ast: ASTTranslation, ctx: Context): string | null;
147
- compileTTranslationContext(ast: ASTTranslationContext, ctx: Context): string | null;
148
- compileTPortal(ast: ASTTPortal, ctx: Context): string;
149
- }
150
- export {};
1
+ import { AST, ASTComment, ASTComponent, ASTDebug, ASTDomNode, ASTLog, ASTMulti, ASTTCallSlot, ASTTCall, ASTTCallBlock, ASTText, ASTTForEach, ASTTif, ASTTKey, ASTTOut, ASTTPortal, ASTTranslation, ASTTranslationContext, ASTTSet, EventHandlers } from "./parser";
2
+ type BlockType = "block" | "text" | "multi" | "list" | "html" | "comment";
3
+ export interface Config {
4
+ translateFn?: (s: string, translationCtx: string) => string;
5
+ translatableAttributes?: string[];
6
+ dev?: boolean;
7
+ }
8
+ export interface CodeGenOptions extends Config {
9
+ hasSafeContext?: boolean;
10
+ name?: string;
11
+ hasGlobalValues: boolean;
12
+ }
13
+ declare class BlockDescription {
14
+ static nextBlockId: number;
15
+ varName: string;
16
+ blockName: string;
17
+ dynamicTagName: string | null;
18
+ isRoot: boolean;
19
+ hasDynamicChildren: boolean;
20
+ children: BlockDescription[];
21
+ data: string[];
22
+ dom?: Node;
23
+ currentDom?: Element;
24
+ childNumber: number;
25
+ target: CodeTarget;
26
+ type: BlockType;
27
+ parentVar: string;
28
+ id: number;
29
+ constructor(target: CodeTarget, type: BlockType);
30
+ insertData(str: string, prefix?: string): number;
31
+ insert(dom: Node): void;
32
+ generateExpr(expr: string): string;
33
+ asXmlString(): string;
34
+ }
35
+ interface Context {
36
+ block: BlockDescription | null;
37
+ index: number | string;
38
+ forceNewBlock: boolean;
39
+ isLast?: boolean;
40
+ translate: boolean;
41
+ translationCtx: string;
42
+ tKeyExpr: string | null;
43
+ nameSpace?: string;
44
+ tModelSelectedExpr?: string;
45
+ ctxVar?: string;
46
+ inPreTag?: boolean;
47
+ }
48
+ declare class CodeTarget {
49
+ name: string;
50
+ indentLevel: number;
51
+ loopLevel: number;
52
+ code: string[];
53
+ hasRoot: boolean;
54
+ hasCache: boolean;
55
+ shouldProtectScope: boolean;
56
+ on: EventHandlers | null;
57
+ constructor(name: string, on?: EventHandlers | null);
58
+ addLine(line: string, idx?: number): void;
59
+ generateCode(): string;
60
+ currentKey(ctx: Context): string;
61
+ }
62
+ export declare class CodeGenerator {
63
+ blocks: BlockDescription[];
64
+ nextBlockId: number;
65
+ hasSafeContext: boolean;
66
+ isDebug: boolean;
67
+ targets: CodeTarget[];
68
+ target: CodeTarget;
69
+ templateName?: string;
70
+ dev: boolean;
71
+ translateFn: (s: string, translationCtx: string) => string;
72
+ translatableAttributes: string[];
73
+ ast: AST;
74
+ staticDefs: {
75
+ id: string;
76
+ expr: string;
77
+ }[];
78
+ slotNames: Set<String>;
79
+ helpers: Set<string>;
80
+ constructor(ast: AST, options: CodeGenOptions);
81
+ generateCode(): string;
82
+ compileInNewTarget(prefix: string, ast: AST, ctx: Context, on?: EventHandlers | null): string;
83
+ addLine(line: string, idx?: number): void;
84
+ define(varName: string, expr: string): void;
85
+ insertAnchor(block: BlockDescription, index?: number): void;
86
+ createBlock(parentBlock: BlockDescription | null, type: BlockType, ctx: Context): BlockDescription;
87
+ insertBlock(expression: string, block: BlockDescription, ctx: Context): void;
88
+ /**
89
+ * Captures variables that are used inside of an expression. This is useful
90
+ * because in compiled code, almost all variables are accessed through the ctx
91
+ * object. In the case of functions, that lookup in the context can be delayed
92
+ * which can cause issues if the value has changed since the function was
93
+ * defined.
94
+ *
95
+ * @param expr the expression to capture
96
+ * @param forceCapture whether the expression should capture its scope even if
97
+ * it doesn't contain a function. Useful when the expression will be used as
98
+ * a function body.
99
+ * @returns a new expression that uses the captured values
100
+ */
101
+ captureExpression(expr: string, forceCapture?: boolean): string;
102
+ translate(str: string, translationCtx: string): string;
103
+ /**
104
+ * @returns the newly created block name, if any
105
+ */
106
+ compileAST(ast: AST, ctx: Context): string | null;
107
+ compileDebug(ast: ASTDebug, ctx: Context): string | null;
108
+ compileLog(ast: ASTLog, ctx: Context): string | null;
109
+ compileComment(ast: ASTComment, ctx: Context): string;
110
+ compileText(ast: ASTText, ctx: Context): string;
111
+ generateHandlerCode(rawEvent: string, handler: string): string;
112
+ compileTDomNode(ast: ASTDomNode, ctx: Context): string;
113
+ compileTOut(ast: ASTTOut, ctx: Context): string;
114
+ compileTIfBranch(content: AST, block: BlockDescription, ctx: Context): void;
115
+ compileTIf(ast: ASTTif, ctx: Context, nextNode?: ASTDomNode): string;
116
+ compileTForeach(ast: ASTTForEach, ctx: Context): string;
117
+ compileTKey(ast: ASTTKey, ctx: Context): string | null;
118
+ compileMulti(ast: ASTMulti, ctx: Context): string | null;
119
+ compileTCall(ast: ASTTCall, ctx: Context): string;
120
+ compileTCallBlock(ast: ASTTCallBlock, ctx: Context): string;
121
+ compileTSet(ast: ASTTSet, ctx: Context): null;
122
+ generateComponentKey(currentKey?: string): string;
123
+ /**
124
+ * Formats a prop name and value into a string suitable to be inserted in the
125
+ * generated code. For example:
126
+ *
127
+ * Name Value Result
128
+ * ---------------------------------------------------------
129
+ * "number" "state" "number: ctx['state']"
130
+ * "something" "" "something: undefined"
131
+ * "some-prop" "state" "'some-prop': ctx['state']"
132
+ * "onClick.bind" "onClick" "onClick: bind(ctx, ctx['onClick'])"
133
+ */
134
+ formatProp(name: string, value: string, attrsTranslationCtx: {
135
+ [name: string]: string;
136
+ } | null, translationCtx: string): string;
137
+ formatPropObject(obj: {
138
+ [prop: string]: any;
139
+ }, attrsTranslationCtx: {
140
+ [name: string]: string;
141
+ } | null, translationCtx: string): string[];
142
+ getPropString(props: string[], dynProps: string | null): string;
143
+ compileComponent(ast: ASTComponent, ctx: Context): string;
144
+ wrapWithEventCatcher(expr: string, on: EventHandlers): string;
145
+ compileTCallSlot(ast: ASTTCallSlot, ctx: Context): string;
146
+ compileTTranslation(ast: ASTTranslation, ctx: Context): string | null;
147
+ compileTTranslationContext(ast: ASTTranslationContext, ctx: Context): string | null;
148
+ compileTPortal(ast: ASTTPortal, ctx: Context): string;
149
+ }
150
+ export {};
@@ -1,13 +1,13 @@
1
- import type { TemplateSet } from "../runtime/template_set";
2
- import type { BDom } from "../runtime/blockdom";
3
- import { Config } from "./code_generator";
4
- export type CustomDirectives = Record<string, (node: Element, value: string, modifier: string[]) => void>;
5
- export type Template = (context: any, vnode: any, key?: string) => BDom;
6
- export type TemplateFunction = (app: TemplateSet, bdom: any, helpers: any) => Template;
7
- interface CompileOptions extends Config {
8
- name?: string;
9
- customDirectives?: CustomDirectives;
10
- hasGlobalValues: boolean;
11
- }
12
- export declare function compile(template: string | Element, options?: CompileOptions): TemplateFunction;
13
- export {};
1
+ import type { TemplateSet } from "../runtime/template_set";
2
+ import type { BDom } from "../runtime/blockdom";
3
+ import { Config } from "./code_generator";
4
+ export type CustomDirectives = Record<string, (node: Element, value: string, modifier: string[]) => void>;
5
+ export type Template = (context: any, vnode: any, key?: string) => BDom;
6
+ export type TemplateFunction = (app: TemplateSet, bdom: any, helpers: any) => Template;
7
+ interface CompileOptions extends Config {
8
+ name?: string;
9
+ customDirectives?: CustomDirectives;
10
+ hasGlobalValues: boolean;
11
+ }
12
+ export declare function compile(template: string | Element, options?: CompileOptions): TemplateFunction;
13
+ export {};
@@ -1,59 +1,59 @@
1
- export interface QWebVar {
2
- id: string;
3
- expr: string;
4
- value?: string;
5
- hasBody?: boolean;
6
- }
7
- type TKind = "LEFT_BRACE" | "RIGHT_BRACE" | "LEFT_BRACKET" | "RIGHT_BRACKET" | "LEFT_PAREN" | "RIGHT_PAREN" | "COMMA" | "VALUE" | "TEMPLATE_STRING" | "SYMBOL" | "OPERATOR" | "COLON";
8
- interface Token {
9
- type: TKind;
10
- value: string;
11
- originalValue?: string;
12
- size?: number;
13
- varName?: string;
14
- replace?: Function;
15
- isLocal?: boolean;
16
- }
17
- /**
18
- * Convert a javascript expression (as a string) into a list of tokens. For
19
- * example: `tokenize("1 + b")` will return:
20
- * ```js
21
- * [
22
- * {type: "VALUE", value: "1"},
23
- * {type: "OPERATOR", value: "+"},
24
- * {type: "SYMBOL", value: "b"}
25
- * ]
26
- * ```
27
- */
28
- export declare function tokenize(expr: string): Token[];
29
- /**
30
- * This is the main function exported by this file. This is the code that will
31
- * process an expression (given as a string) and returns another expression with
32
- * proper lookups in the context.
33
- *
34
- * Usually, this kind of code would be very simple to do if we had an AST (so,
35
- * if we had a javascript parser), since then, we would only need to find the
36
- * variables and replace them. However, a parser is more complicated, and there
37
- * are no standard builtin parser API.
38
- *
39
- * Since this method is applied to simple javasript expressions, and the work to
40
- * be done is actually quite simple, we actually can get away with not using a
41
- * parser, which helps with the code size.
42
- *
43
- * Here is the heuristic used by this method to determine if a token is a
44
- * variable:
45
- * - by default, all symbols are considered a variable
46
- * - unless the previous token is a dot (in that case, this is a property: `a.b`)
47
- * - or if the previous token is a left brace or a comma, and the next token is
48
- * a colon (in that case, this is an object key: `{a: b}`)
49
- *
50
- * Some specific code is also required to support arrow functions. If we detect
51
- * the arrow operator, then we add the current (or some previous tokens) token to
52
- * the list of variables so it does not get replaced by a lookup in the context
53
- */
54
- export declare function compileExprToArray(expr: string): Token[];
55
- export declare function compileExpr(expr: string): string;
56
- export declare const INTERP_REGEXP: RegExp;
57
- export declare function replaceDynamicParts(s: string, replacer: (s: string) => string): string;
58
- export declare function interpolate(s: string): string;
59
- export {};
1
+ export interface QWebVar {
2
+ id: string;
3
+ expr: string;
4
+ value?: string;
5
+ hasBody?: boolean;
6
+ }
7
+ type TKind = "LEFT_BRACE" | "RIGHT_BRACE" | "LEFT_BRACKET" | "RIGHT_BRACKET" | "LEFT_PAREN" | "RIGHT_PAREN" | "COMMA" | "VALUE" | "TEMPLATE_STRING" | "SYMBOL" | "OPERATOR" | "COLON";
8
+ interface Token {
9
+ type: TKind;
10
+ value: string;
11
+ originalValue?: string;
12
+ size?: number;
13
+ varName?: string;
14
+ replace?: Function;
15
+ isLocal?: boolean;
16
+ }
17
+ /**
18
+ * Convert a javascript expression (as a string) into a list of tokens. For
19
+ * example: `tokenize("1 + b")` will return:
20
+ * ```js
21
+ * [
22
+ * {type: "VALUE", value: "1"},
23
+ * {type: "OPERATOR", value: "+"},
24
+ * {type: "SYMBOL", value: "b"}
25
+ * ]
26
+ * ```
27
+ */
28
+ export declare function tokenize(expr: string): Token[];
29
+ /**
30
+ * This is the main function exported by this file. This is the code that will
31
+ * process an expression (given as a string) and returns another expression with
32
+ * proper lookups in the context.
33
+ *
34
+ * Usually, this kind of code would be very simple to do if we had an AST (so,
35
+ * if we had a javascript parser), since then, we would only need to find the
36
+ * variables and replace them. However, a parser is more complicated, and there
37
+ * are no standard builtin parser API.
38
+ *
39
+ * Since this method is applied to simple javasript expressions, and the work to
40
+ * be done is actually quite simple, we actually can get away with not using a
41
+ * parser, which helps with the code size.
42
+ *
43
+ * Here is the heuristic used by this method to determine if a token is a
44
+ * variable:
45
+ * - by default, all symbols are considered a variable
46
+ * - unless the previous token is a dot (in that case, this is a property: `a.b`)
47
+ * - or if the previous token is a left brace or a comma, and the next token is
48
+ * a colon (in that case, this is an object key: `{a: b}`)
49
+ *
50
+ * Some specific code is also required to support arrow functions. If we detect
51
+ * the arrow operator, then we add the current (or some previous tokens) token to
52
+ * the list of variables so it does not get replaced by a lookup in the context
53
+ */
54
+ export declare function compileExprToArray(expr: string): Token[];
55
+ export declare function compileExpr(expr: string): string;
56
+ export declare const INTERP_REGEXP: RegExp;
57
+ export declare function replaceDynamicParts(s: string, replacer: (s: string) => string): string;
58
+ export declare function interpolate(s: string): string;
59
+ export {};