@odoo/owl 2.0.0-beta-21 → 2.0.0-beta-22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/owl.cjs.js +68 -59
- package/dist/owl.es.js +68 -59
- package/dist/owl.iife.js +68 -59
- package/dist/owl.iife.min.js +1 -1
- package/dist/types/compiler/code_generator.d.ts +23 -19
- package/dist/types/runtime/template_helpers.d.ts +2 -1
- package/package.json +1 -1
package/dist/owl.iife.js
CHANGED
|
@@ -2906,14 +2906,15 @@
|
|
|
2906
2906
|
return true;
|
|
2907
2907
|
}
|
|
2908
2908
|
class LazyValue {
|
|
2909
|
-
constructor(fn, ctx, component, node) {
|
|
2909
|
+
constructor(fn, ctx, component, node, key) {
|
|
2910
2910
|
this.fn = fn;
|
|
2911
2911
|
this.ctx = capture(ctx);
|
|
2912
2912
|
this.component = component;
|
|
2913
2913
|
this.node = node;
|
|
2914
|
+
this.key = key;
|
|
2914
2915
|
}
|
|
2915
2916
|
evaluate() {
|
|
2916
|
-
return this.fn.call(this.component, this.ctx, this.node);
|
|
2917
|
+
return this.fn.call(this.component, this.ctx, this.node, this.key);
|
|
2917
2918
|
}
|
|
2918
2919
|
toString() {
|
|
2919
2920
|
return this.evaluate().toString();
|
|
@@ -3599,6 +3600,13 @@
|
|
|
3599
3600
|
result.push(`}`);
|
|
3600
3601
|
return result.join("\n ");
|
|
3601
3602
|
}
|
|
3603
|
+
currentKey(ctx) {
|
|
3604
|
+
let key = this.loopLevel ? `key${this.loopLevel}` : "key";
|
|
3605
|
+
if (ctx.tKeyExpr) {
|
|
3606
|
+
key = `${ctx.tKeyExpr} + ${key}`;
|
|
3607
|
+
}
|
|
3608
|
+
return key;
|
|
3609
|
+
}
|
|
3602
3610
|
}
|
|
3603
3611
|
const TRANSLATABLE_ATTRS = ["label", "title", "placeholder", "alt"];
|
|
3604
3612
|
const translationRE = /^(\s*)([\s\S]+?)(\s*)$/;
|
|
@@ -3728,18 +3736,14 @@
|
|
|
3728
3736
|
}
|
|
3729
3737
|
insertBlock(expression, block, ctx) {
|
|
3730
3738
|
let blockExpr = block.generateExpr(expression);
|
|
3731
|
-
const tKeyExpr = ctx.tKeyExpr;
|
|
3732
3739
|
if (block.parentVar) {
|
|
3733
|
-
let
|
|
3734
|
-
if (tKeyExpr) {
|
|
3735
|
-
keyArg = `${tKeyExpr} + ${keyArg}`;
|
|
3736
|
-
}
|
|
3740
|
+
let key = this.target.currentKey(ctx);
|
|
3737
3741
|
this.helpers.add("withKey");
|
|
3738
|
-
this.addLine(`${block.parentVar}[${ctx.index}] = withKey(${blockExpr}, ${
|
|
3742
|
+
this.addLine(`${block.parentVar}[${ctx.index}] = withKey(${blockExpr}, ${key});`);
|
|
3739
3743
|
return;
|
|
3740
3744
|
}
|
|
3741
|
-
if (tKeyExpr) {
|
|
3742
|
-
blockExpr = `toggler(${tKeyExpr}, ${blockExpr})`;
|
|
3745
|
+
if (ctx.tKeyExpr) {
|
|
3746
|
+
blockExpr = `toggler(${ctx.tKeyExpr}, ${blockExpr})`;
|
|
3743
3747
|
}
|
|
3744
3748
|
if (block.isRoot && !ctx.preventRoot) {
|
|
3745
3749
|
if (this.target.on) {
|
|
@@ -3784,74 +3788,62 @@
|
|
|
3784
3788
|
})
|
|
3785
3789
|
.join("");
|
|
3786
3790
|
}
|
|
3791
|
+
/**
|
|
3792
|
+
* @returns the newly created block name, if any
|
|
3793
|
+
*/
|
|
3787
3794
|
compileAST(ast, ctx) {
|
|
3788
3795
|
switch (ast.type) {
|
|
3789
3796
|
case 1 /* Comment */:
|
|
3790
|
-
this.compileComment(ast, ctx);
|
|
3791
|
-
break;
|
|
3797
|
+
return this.compileComment(ast, ctx);
|
|
3792
3798
|
case 0 /* Text */:
|
|
3793
|
-
this.compileText(ast, ctx);
|
|
3794
|
-
break;
|
|
3799
|
+
return this.compileText(ast, ctx);
|
|
3795
3800
|
case 2 /* DomNode */:
|
|
3796
|
-
this.compileTDomNode(ast, ctx);
|
|
3797
|
-
break;
|
|
3801
|
+
return this.compileTDomNode(ast, ctx);
|
|
3798
3802
|
case 4 /* TEsc */:
|
|
3799
|
-
this.compileTEsc(ast, ctx);
|
|
3800
|
-
break;
|
|
3803
|
+
return this.compileTEsc(ast, ctx);
|
|
3801
3804
|
case 8 /* TOut */:
|
|
3802
|
-
this.compileTOut(ast, ctx);
|
|
3803
|
-
break;
|
|
3805
|
+
return this.compileTOut(ast, ctx);
|
|
3804
3806
|
case 5 /* TIf */:
|
|
3805
|
-
this.compileTIf(ast, ctx);
|
|
3806
|
-
break;
|
|
3807
|
+
return this.compileTIf(ast, ctx);
|
|
3807
3808
|
case 9 /* TForEach */:
|
|
3808
|
-
this.compileTForeach(ast, ctx);
|
|
3809
|
-
break;
|
|
3809
|
+
return this.compileTForeach(ast, ctx);
|
|
3810
3810
|
case 10 /* TKey */:
|
|
3811
|
-
this.compileTKey(ast, ctx);
|
|
3812
|
-
break;
|
|
3811
|
+
return this.compileTKey(ast, ctx);
|
|
3813
3812
|
case 3 /* Multi */:
|
|
3814
|
-
this.compileMulti(ast, ctx);
|
|
3815
|
-
break;
|
|
3813
|
+
return this.compileMulti(ast, ctx);
|
|
3816
3814
|
case 7 /* TCall */:
|
|
3817
|
-
this.compileTCall(ast, ctx);
|
|
3818
|
-
break;
|
|
3815
|
+
return this.compileTCall(ast, ctx);
|
|
3819
3816
|
case 15 /* TCallBlock */:
|
|
3820
|
-
this.compileTCallBlock(ast, ctx);
|
|
3821
|
-
break;
|
|
3817
|
+
return this.compileTCallBlock(ast, ctx);
|
|
3822
3818
|
case 6 /* TSet */:
|
|
3823
|
-
this.compileTSet(ast, ctx);
|
|
3824
|
-
break;
|
|
3819
|
+
return this.compileTSet(ast, ctx);
|
|
3825
3820
|
case 11 /* TComponent */:
|
|
3826
|
-
this.compileComponent(ast, ctx);
|
|
3827
|
-
break;
|
|
3821
|
+
return this.compileComponent(ast, ctx);
|
|
3828
3822
|
case 12 /* TDebug */:
|
|
3829
|
-
this.compileDebug(ast, ctx);
|
|
3830
|
-
break;
|
|
3823
|
+
return this.compileDebug(ast, ctx);
|
|
3831
3824
|
case 13 /* TLog */:
|
|
3832
|
-
this.compileLog(ast, ctx);
|
|
3833
|
-
break;
|
|
3825
|
+
return this.compileLog(ast, ctx);
|
|
3834
3826
|
case 14 /* TSlot */:
|
|
3835
|
-
this.compileTSlot(ast, ctx);
|
|
3836
|
-
break;
|
|
3827
|
+
return this.compileTSlot(ast, ctx);
|
|
3837
3828
|
case 16 /* TTranslation */:
|
|
3838
|
-
this.compileTTranslation(ast, ctx);
|
|
3839
|
-
break;
|
|
3829
|
+
return this.compileTTranslation(ast, ctx);
|
|
3840
3830
|
case 17 /* TPortal */:
|
|
3841
|
-
this.compileTPortal(ast, ctx);
|
|
3831
|
+
return this.compileTPortal(ast, ctx);
|
|
3842
3832
|
}
|
|
3843
3833
|
}
|
|
3844
3834
|
compileDebug(ast, ctx) {
|
|
3845
3835
|
this.addLine(`debugger;`);
|
|
3846
3836
|
if (ast.content) {
|
|
3847
|
-
this.compileAST(ast.content, ctx);
|
|
3837
|
+
return this.compileAST(ast.content, ctx);
|
|
3848
3838
|
}
|
|
3839
|
+
return null;
|
|
3849
3840
|
}
|
|
3850
3841
|
compileLog(ast, ctx) {
|
|
3851
3842
|
this.addLine(`console.log(${compileExpr(ast.expr)});`);
|
|
3852
3843
|
if (ast.content) {
|
|
3853
|
-
this.compileAST(ast.content, ctx);
|
|
3844
|
+
return this.compileAST(ast.content, ctx);
|
|
3854
3845
|
}
|
|
3846
|
+
return null;
|
|
3855
3847
|
}
|
|
3856
3848
|
compileComment(ast, ctx) {
|
|
3857
3849
|
let { block, forceNewBlock } = ctx;
|
|
@@ -3867,6 +3859,7 @@
|
|
|
3867
3859
|
const text = xmlDoc.createComment(ast.value);
|
|
3868
3860
|
block.insert(text);
|
|
3869
3861
|
}
|
|
3862
|
+
return block.varName;
|
|
3870
3863
|
}
|
|
3871
3864
|
compileText(ast, ctx) {
|
|
3872
3865
|
let { block, forceNewBlock } = ctx;
|
|
@@ -3886,6 +3879,7 @@
|
|
|
3886
3879
|
const createFn = ast.type === 0 /* Text */ ? xmlDoc.createTextNode : xmlDoc.createComment;
|
|
3887
3880
|
block.insert(createFn.call(xmlDoc, value));
|
|
3888
3881
|
}
|
|
3882
|
+
return block.varName;
|
|
3889
3883
|
}
|
|
3890
3884
|
generateHandlerCode(rawEvent, handler) {
|
|
3891
3885
|
const modifiers = rawEvent
|
|
@@ -4078,6 +4072,7 @@
|
|
|
4078
4072
|
this.addLine(`let ${block.children.map((c) => c.varName)};`, codeIdx);
|
|
4079
4073
|
}
|
|
4080
4074
|
}
|
|
4075
|
+
return block.varName;
|
|
4081
4076
|
}
|
|
4082
4077
|
compileTEsc(ast, ctx) {
|
|
4083
4078
|
let { block, forceNewBlock } = ctx;
|
|
@@ -4102,6 +4097,7 @@
|
|
|
4102
4097
|
const text = xmlDoc.createElement(`block-text-${idx}`);
|
|
4103
4098
|
block.insert(text);
|
|
4104
4099
|
}
|
|
4100
|
+
return block.varName;
|
|
4105
4101
|
}
|
|
4106
4102
|
compileTOut(ast, ctx) {
|
|
4107
4103
|
let { block } = ctx;
|
|
@@ -4127,6 +4123,7 @@
|
|
|
4127
4123
|
blockStr = `safeOutput(${compileExpr(ast.expr)})`;
|
|
4128
4124
|
}
|
|
4129
4125
|
this.insertBlock(blockStr, block, ctx);
|
|
4126
|
+
return block.varName;
|
|
4130
4127
|
}
|
|
4131
4128
|
compileTIfBranch(content, block, ctx) {
|
|
4132
4129
|
this.target.indentLevel++;
|
|
@@ -4181,6 +4178,7 @@
|
|
|
4181
4178
|
const args = block.children.map((c) => c.varName).join(", ");
|
|
4182
4179
|
this.insertBlock(`multi([${args}])`, block, ctx);
|
|
4183
4180
|
}
|
|
4181
|
+
return block.varName;
|
|
4184
4182
|
}
|
|
4185
4183
|
compileTForeach(ast, ctx) {
|
|
4186
4184
|
let { block } = ctx;
|
|
@@ -4253,6 +4251,7 @@
|
|
|
4253
4251
|
this.addLine(`ctx = ctx.__proto__;`);
|
|
4254
4252
|
}
|
|
4255
4253
|
this.insertBlock("l", block, ctx);
|
|
4254
|
+
return block.varName;
|
|
4256
4255
|
}
|
|
4257
4256
|
compileTKey(ast, ctx) {
|
|
4258
4257
|
const tKeyExpr = generateId("tKey_");
|
|
@@ -4262,7 +4261,7 @@
|
|
|
4262
4261
|
block: ctx.block,
|
|
4263
4262
|
index: ctx.index,
|
|
4264
4263
|
});
|
|
4265
|
-
this.compileAST(ast.content, ctx);
|
|
4264
|
+
return this.compileAST(ast.content, ctx);
|
|
4266
4265
|
}
|
|
4267
4266
|
compileMulti(ast, ctx) {
|
|
4268
4267
|
let { block, forceNewBlock } = ctx;
|
|
@@ -4270,11 +4269,13 @@
|
|
|
4270
4269
|
let codeIdx = this.target.code.length;
|
|
4271
4270
|
if (isNewBlock) {
|
|
4272
4271
|
const n = ast.content.filter((c) => c.type !== 6 /* TSet */).length;
|
|
4272
|
+
let result = null;
|
|
4273
4273
|
if (n <= 1) {
|
|
4274
4274
|
for (let child of ast.content) {
|
|
4275
|
-
this.compileAST(child, ctx);
|
|
4275
|
+
const blockName = this.compileAST(child, ctx);
|
|
4276
|
+
result = result || blockName;
|
|
4276
4277
|
}
|
|
4277
|
-
return;
|
|
4278
|
+
return result;
|
|
4278
4279
|
}
|
|
4279
4280
|
block = this.createBlock(block, "multi", ctx);
|
|
4280
4281
|
}
|
|
@@ -4314,6 +4315,7 @@
|
|
|
4314
4315
|
const args = block.children.map((c) => c.varName).join(", ");
|
|
4315
4316
|
this.insertBlock(`multi([${args}])`, block, ctx);
|
|
4316
4317
|
}
|
|
4318
|
+
return block.varName;
|
|
4317
4319
|
}
|
|
4318
4320
|
compileTCall(ast, ctx) {
|
|
4319
4321
|
let { block, forceNewBlock } = ctx;
|
|
@@ -4326,12 +4328,11 @@
|
|
|
4326
4328
|
this.addLine(`${ctxVar} = Object.create(${ctxVar});`);
|
|
4327
4329
|
this.addLine(`${ctxVar}[isBoundary] = 1;`);
|
|
4328
4330
|
this.helpers.add("isBoundary");
|
|
4329
|
-
const nextId = BlockDescription.nextBlockId;
|
|
4330
4331
|
const subCtx = createContext(ctx, { preventRoot: true, ctxVar });
|
|
4331
|
-
this.
|
|
4332
|
-
if (
|
|
4332
|
+
const bl = this.compileMulti({ type: 3 /* Multi */, content: ast.body }, subCtx);
|
|
4333
|
+
if (bl) {
|
|
4333
4334
|
this.helpers.add("zero");
|
|
4334
|
-
this.addLine(`${ctxVar}[zero] =
|
|
4335
|
+
this.addLine(`${ctxVar}[zero] = ${bl};`);
|
|
4335
4336
|
}
|
|
4336
4337
|
}
|
|
4337
4338
|
const isDynamic = INTERP_REGEXP.test(ast.name);
|
|
@@ -4366,6 +4367,7 @@
|
|
|
4366
4367
|
if (ast.body && !ctx.isLast) {
|
|
4367
4368
|
this.addLine(`${ctxVar} = ${ctxVar}.__proto__;`);
|
|
4368
4369
|
}
|
|
4370
|
+
return block.varName;
|
|
4369
4371
|
}
|
|
4370
4372
|
compileTCallBlock(ast, ctx) {
|
|
4371
4373
|
let { block, forceNewBlock } = ctx;
|
|
@@ -4376,6 +4378,7 @@
|
|
|
4376
4378
|
}
|
|
4377
4379
|
block = this.createBlock(block, "multi", ctx);
|
|
4378
4380
|
this.insertBlock(compileExpr(ast.name), block, { ...ctx, forceNewBlock: !block });
|
|
4381
|
+
return block.varName;
|
|
4379
4382
|
}
|
|
4380
4383
|
compileTSet(ast, ctx) {
|
|
4381
4384
|
this.target.shouldProtectScope = true;
|
|
@@ -4385,7 +4388,8 @@
|
|
|
4385
4388
|
this.helpers.add("LazyValue");
|
|
4386
4389
|
const bodyAst = { type: 3 /* Multi */, content: ast.body };
|
|
4387
4390
|
const name = this.compileInNewTarget("value", bodyAst, ctx);
|
|
4388
|
-
let
|
|
4391
|
+
let key = this.target.currentKey(ctx);
|
|
4392
|
+
let value = `new LazyValue(${name}, ctx, this, node, ${key})`;
|
|
4389
4393
|
value = ast.value ? (value ? `withDefault(${expr}, ${value})` : expr) : value;
|
|
4390
4394
|
this.addLine(`ctx[\`${ast.name}\`] = ${value};`);
|
|
4391
4395
|
}
|
|
@@ -4405,6 +4409,7 @@
|
|
|
4405
4409
|
this.helpers.add("setContextValue");
|
|
4406
4410
|
this.addLine(`setContextValue(${ctx.ctxVar || "ctx"}, "${ast.name}", ${value});`);
|
|
4407
4411
|
}
|
|
4412
|
+
return null;
|
|
4408
4413
|
}
|
|
4409
4414
|
generateComponentKey() {
|
|
4410
4415
|
const parts = [generateId("__")];
|
|
@@ -4535,6 +4540,7 @@
|
|
|
4535
4540
|
}
|
|
4536
4541
|
block = this.createBlock(block, "multi", ctx);
|
|
4537
4542
|
this.insertBlock(blockExpr, block, ctx);
|
|
4543
|
+
return block.varName;
|
|
4538
4544
|
}
|
|
4539
4545
|
wrapWithEventCatcher(expr, on) {
|
|
4540
4546
|
this.helpers.add("createCatcher");
|
|
@@ -4601,11 +4607,13 @@
|
|
|
4601
4607
|
}
|
|
4602
4608
|
block = this.createBlock(block, "multi", ctx);
|
|
4603
4609
|
this.insertBlock(blockString, block, { ...ctx, forceNewBlock: false });
|
|
4610
|
+
return block.varName;
|
|
4604
4611
|
}
|
|
4605
4612
|
compileTTranslation(ast, ctx) {
|
|
4606
4613
|
if (ast.content) {
|
|
4607
|
-
this.compileAST(ast.content, Object.assign({}, ctx, { translate: false }));
|
|
4614
|
+
return this.compileAST(ast.content, Object.assign({}, ctx, { translate: false }));
|
|
4608
4615
|
}
|
|
4616
|
+
return null;
|
|
4609
4617
|
}
|
|
4610
4618
|
compileTPortal(ast, ctx) {
|
|
4611
4619
|
if (!this.staticDefs.find((d) => d.id === "Portal")) {
|
|
@@ -4632,6 +4640,7 @@
|
|
|
4632
4640
|
}
|
|
4633
4641
|
block = this.createBlock(block, "multi", ctx);
|
|
4634
4642
|
this.insertBlock(blockString, block, { ...ctx, forceNewBlock: false });
|
|
4643
|
+
return block.varName;
|
|
4635
4644
|
}
|
|
4636
4645
|
}
|
|
4637
4646
|
|
|
@@ -5801,9 +5810,9 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
|
|
|
5801
5810
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5802
5811
|
|
|
5803
5812
|
|
|
5804
|
-
__info__.version = '2.0.0-beta-
|
|
5805
|
-
__info__.date = '2022-09-
|
|
5806
|
-
__info__.hash = '
|
|
5813
|
+
__info__.version = '2.0.0-beta-22';
|
|
5814
|
+
__info__.date = '2022-09-29T07:17:18.044Z';
|
|
5815
|
+
__info__.hash = '64bad25';
|
|
5807
5816
|
__info__.url = 'https://github.com/odoo/owl';
|
|
5808
5817
|
|
|
5809
5818
|
|