@lwc/template-compiler 8.18.0 → 8.18.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/README.md +1 -0
- package/dist/codegen/codegen.d.ts +2 -1
- package/dist/config.d.ts +4 -0
- package/dist/index.cjs.js +63 -1
- package/dist/index.js +63 -1
- package/dist/shared/ast.d.ts +3 -1
- package/dist/shared/types.d.ts +5 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -60,6 +60,7 @@ const { code, warnings } = compile(`<template><h1>Hello World!</h1></template>`,
|
|
|
60
60
|
- `preserveHtmlComments` (boolean, optional, `false` by default) - set to `true` to disable the default behavior of stripping HTML comments.
|
|
61
61
|
- `enableStaticContentOptimization` (boolean, optional, `true` by default) - set to `false` to disable static content optimizations.
|
|
62
62
|
- `enableLwcSpread` (boolean, optional, `true` by default) - Deprecated. Ignored by template-compiler. `lwc:spread` is always enabled.
|
|
63
|
+
- `enableLwcOn` (boolean, optional, `false` by default) - set to `true` to enable `lwc:on` directive in the template.
|
|
63
64
|
- `customRendererConfig` (CustomRendererConfig, optional) - specifies a configuration to use to match elements. Matched elements will get a custom renderer hook in the generated template.
|
|
64
65
|
- `instrumentation` (InstrumentationObject, optional) - instrumentation object to gather metrics and non-error logs for internal use. See the `@lwc/errors` package for details on the interface.
|
|
65
66
|
- `disableSyntheticShadowSupport` (type: `boolean`, default: `false`) - Set to true if synthetic shadow DOM support is not needed, which can result in smaller/faster output.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as t from '../shared/estree';
|
|
2
2
|
import { LWCDirectiveRenderMode } from '../shared/types';
|
|
3
3
|
import type State from '../state';
|
|
4
|
-
import type { ChildNode, Expression, ComplexExpression, Literal, Root, EventListener, RefDirective, Text, StaticElement, Attribute, KeyDirective } from '../shared/types';
|
|
4
|
+
import type { ChildNode, Expression, ComplexExpression, Literal, Root, EventListener, RefDirective, Text, StaticElement, Attribute, KeyDirective, OnDirective } from '../shared/types';
|
|
5
5
|
import type { APIVersion } from '@lwc/shared';
|
|
6
6
|
export default class CodeGen {
|
|
7
7
|
/** The AST root. */
|
|
@@ -93,6 +93,7 @@ export default class CodeGen {
|
|
|
93
93
|
getMemoizationId(): import("estree").Identifier;
|
|
94
94
|
genBooleanAttributeExpr(bindExpr: t.Expression): import("estree").ConditionalExpression;
|
|
95
95
|
genEventListeners(listeners: EventListener[]): import("estree").Property;
|
|
96
|
+
genDynamicEventListeners(onDirective: OnDirective): import("estree").Property[];
|
|
96
97
|
genRef(ref: RefDirective): import("estree").Property;
|
|
97
98
|
genKeyExpression(ref: KeyDirective | undefined, slotParentName: string | undefined): import("estree").SimpleLiteral | import("estree").CallExpression;
|
|
98
99
|
/**
|
package/dist/config.d.ts
CHANGED
|
@@ -56,6 +56,10 @@ export interface Config {
|
|
|
56
56
|
* @deprecated Spread operator is now always enabled.
|
|
57
57
|
*/
|
|
58
58
|
enableLwcSpread?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* When true, enables `lwc:on` directive.
|
|
61
|
+
*/
|
|
62
|
+
enableLwcOn?: boolean;
|
|
59
63
|
/**
|
|
60
64
|
* Config to use to collect metrics and logs
|
|
61
65
|
*/
|
package/dist/index.cjs.js
CHANGED
|
@@ -207,6 +207,7 @@ const AVAILABLE_OPTION_NAMES = new Set([
|
|
|
207
207
|
'apiVersion',
|
|
208
208
|
'customRendererConfig',
|
|
209
209
|
'enableLwcSpread',
|
|
210
|
+
'enableLwcOn',
|
|
210
211
|
'enableStaticContentOptimization',
|
|
211
212
|
// TODO [#3370]: remove experimental template expression flag
|
|
212
213
|
'experimentalComplexExpressions',
|
|
@@ -269,6 +270,7 @@ function normalizeConfig(config) {
|
|
|
269
270
|
enableDynamicComponents: false,
|
|
270
271
|
enableStaticContentOptimization: true,
|
|
271
272
|
enableLwcSpread: true,
|
|
273
|
+
enableLwcOn: false,
|
|
272
274
|
disableSyntheticShadowSupport: false,
|
|
273
275
|
...config,
|
|
274
276
|
apiVersion, // overrides the config apiVersion
|
|
@@ -9110,6 +9112,14 @@ function spreadDirective(value, location) {
|
|
|
9110
9112
|
location,
|
|
9111
9113
|
};
|
|
9112
9114
|
}
|
|
9115
|
+
function OnDirective(value, location) {
|
|
9116
|
+
return {
|
|
9117
|
+
type: 'Directive',
|
|
9118
|
+
name: 'On',
|
|
9119
|
+
value,
|
|
9120
|
+
location,
|
|
9121
|
+
};
|
|
9122
|
+
}
|
|
9113
9123
|
function slotBindDirective(value, location) {
|
|
9114
9124
|
return {
|
|
9115
9125
|
type: 'Directive',
|
|
@@ -9273,6 +9283,9 @@ function isDomDirective(directive) {
|
|
|
9273
9283
|
function isSpreadDirective(directive) {
|
|
9274
9284
|
return directive.name === 'Spread';
|
|
9275
9285
|
}
|
|
9286
|
+
function isOnDirective(directive) {
|
|
9287
|
+
return directive.name === 'On';
|
|
9288
|
+
}
|
|
9276
9289
|
function isInnerHTMLDirective(directive) {
|
|
9277
9290
|
return directive.name === 'InnerHTML';
|
|
9278
9291
|
}
|
|
@@ -9339,6 +9352,7 @@ exports.ElementDirectiveName = void 0;
|
|
|
9339
9352
|
ElementDirectiveName["SlotBind"] = "lwc:slot-bind";
|
|
9340
9353
|
ElementDirectiveName["SlotData"] = "lwc:slot-data";
|
|
9341
9354
|
ElementDirectiveName["Spread"] = "lwc:spread";
|
|
9355
|
+
ElementDirectiveName["On"] = "lwc:on";
|
|
9342
9356
|
ElementDirectiveName["Key"] = "key";
|
|
9343
9357
|
})(exports.ElementDirectiveName || (exports.ElementDirectiveName = {}));
|
|
9344
9358
|
exports.RootDirectiveName = void 0;
|
|
@@ -11970,6 +11984,7 @@ const LWC_DIRECTIVE_PROCESSORS = [
|
|
|
11970
11984
|
applyLwcInnerHtmlDirective,
|
|
11971
11985
|
applyRefDirective,
|
|
11972
11986
|
applyLwcSpreadDirective,
|
|
11987
|
+
applyLwcOnDirective,
|
|
11973
11988
|
applyLwcSlotBindDirective,
|
|
11974
11989
|
];
|
|
11975
11990
|
function applyLwcDirectives(ctx, parsedAttr, element) {
|
|
@@ -12032,6 +12047,28 @@ function applyLwcSpreadDirective(ctx, parsedAttr, element) {
|
|
|
12032
12047
|
}
|
|
12033
12048
|
element.directives.push(spreadDirective(lwcSpreadAttr, lwcSpread.location));
|
|
12034
12049
|
}
|
|
12050
|
+
function applyLwcOnDirective(ctx, parsedAttr, element) {
|
|
12051
|
+
const { name: tag } = element;
|
|
12052
|
+
const lwcOn = parsedAttr.pick(exports.ElementDirectiveName.On);
|
|
12053
|
+
if (!lwcOn) {
|
|
12054
|
+
return;
|
|
12055
|
+
}
|
|
12056
|
+
if (!ctx.config.enableLwcOn) {
|
|
12057
|
+
ctx.throwOnNode(errors.ParserDiagnostics.INVALID_LWC_ON_OPTS, element);
|
|
12058
|
+
}
|
|
12059
|
+
const { value: lwcOnValue } = lwcOn;
|
|
12060
|
+
if (!isExpression$1(lwcOnValue)) {
|
|
12061
|
+
ctx.throwOnNode(errors.ParserDiagnostics.INVALID_LWC_ON_LITERAL_PROP, element, [`<${tag}>`]);
|
|
12062
|
+
}
|
|
12063
|
+
// At this point element.listeners stores declarative event listeners (e.g., `onfoo`)
|
|
12064
|
+
// `lwc:on` directive cannot be used together with declarative event listeners.
|
|
12065
|
+
if (element.listeners.length) {
|
|
12066
|
+
ctx.throwOnNode(errors.ParserDiagnostics.INVALID_LWC_ON_WITH_DECLARATIVE_LISTENERS, element, [
|
|
12067
|
+
`<${tag}>`,
|
|
12068
|
+
]);
|
|
12069
|
+
}
|
|
12070
|
+
element.directives.push(OnDirective(lwcOnValue, lwcOn.location));
|
|
12071
|
+
}
|
|
12035
12072
|
function applyLwcExternalDirective(ctx, parsedAttr, element) {
|
|
12036
12073
|
const lwcExternalAttribute = parsedAttr.pick(exports.ElementDirectiveName.External);
|
|
12037
12074
|
if (!lwcExternalAttribute) {
|
|
@@ -12492,6 +12529,12 @@ function validateTemplate(ctx, parsedAttr, template, parse5ElmLocation) {
|
|
|
12492
12529
|
if (parsedAttr.get(exports.ElementDirectiveName.Is)) {
|
|
12493
12530
|
ctx.throwAtLocation(errors.ParserDiagnostics.LWC_IS_INVALID_ELEMENT, location, ['<template>']);
|
|
12494
12531
|
}
|
|
12532
|
+
if (parsedAttr.get(exports.ElementDirectiveName.On)) {
|
|
12533
|
+
if (!ctx.config.enableLwcOn) {
|
|
12534
|
+
ctx.throwAtLocation(errors.ParserDiagnostics.INVALID_LWC_ON_OPTS, location, ['<template>']);
|
|
12535
|
+
}
|
|
12536
|
+
ctx.throwAtLocation(errors.ParserDiagnostics.INVALID_LWC_ON_ELEMENT, location, ['<template>']);
|
|
12537
|
+
}
|
|
12495
12538
|
// At this point in the parsing all supported attributes from a non root template element
|
|
12496
12539
|
// should have been removed from ParsedAttribute and all other attributes will be ignored.
|
|
12497
12540
|
const invalidTemplateAttributes = parsedAttr.getAttributes();
|
|
@@ -13655,6 +13698,19 @@ class CodeGen {
|
|
|
13655
13698
|
return property$1(identifier('on'), memoize(objectToAST(listenerObj, (k) => listenerObj[k].handler)));
|
|
13656
13699
|
}
|
|
13657
13700
|
}
|
|
13701
|
+
genDynamicEventListeners(onDirective) {
|
|
13702
|
+
// Example Input : lwc:on={someObj}
|
|
13703
|
+
// $cmp.someObj
|
|
13704
|
+
const rawValue = this.bindExpression(onDirective.value);
|
|
13705
|
+
// {__proto__: null, ...$cmp.someObj}
|
|
13706
|
+
const clonedValue = objectExpression([
|
|
13707
|
+
property$1(identifier('__proto__'), literal$1(null)),
|
|
13708
|
+
spreadElement(rawValue),
|
|
13709
|
+
]);
|
|
13710
|
+
const dynamicOnRawProperty = property$1(identifier('dynamicOnRaw'), rawValue);
|
|
13711
|
+
const dynamicOnProperty = property$1(identifier('dynamicOn'), clonedValue);
|
|
13712
|
+
return [dynamicOnRawProperty, dynamicOnProperty];
|
|
13713
|
+
}
|
|
13658
13714
|
genRef(ref) {
|
|
13659
13715
|
this.hasRefs = true;
|
|
13660
13716
|
return property$1(identifier('ref'), ref.value);
|
|
@@ -14484,6 +14540,7 @@ function transform(codeGen) {
|
|
|
14484
14540
|
const dom = element.directives.find(isDomDirective);
|
|
14485
14541
|
const ref = element.directives.find(isRefDirective);
|
|
14486
14542
|
const spread = element.directives.find(isSpreadDirective);
|
|
14543
|
+
const onDirective = element.directives.find(isOnDirective);
|
|
14487
14544
|
const addSanitizationHook = isCustomRendererHookRequired(element, codeGen.state);
|
|
14488
14545
|
const slotBindDirective = element.directives.find(isSlotBindDirective);
|
|
14489
14546
|
// Attributes
|
|
@@ -14585,6 +14642,11 @@ function transform(codeGen) {
|
|
|
14585
14642
|
if (listeners.length) {
|
|
14586
14643
|
data.push(codeGen.genEventListeners(listeners));
|
|
14587
14644
|
}
|
|
14645
|
+
// dynamic event listeners: lwc:on directive
|
|
14646
|
+
// codeGen.genDynamicEventListeners returns an array containing 2 properties: 'dynamicOn' & 'dynamicOnRaw'
|
|
14647
|
+
if (onDirective) {
|
|
14648
|
+
data.push(...codeGen.genDynamicEventListeners(onDirective));
|
|
14649
|
+
}
|
|
14588
14650
|
// SVG handling
|
|
14589
14651
|
if (element.namespace === shared.SVG_NAMESPACE) {
|
|
14590
14652
|
data.push(property$1(identifier('svg'), literal$1(true)));
|
|
@@ -14703,5 +14765,5 @@ exports.generateScopeTokens = generateScopeTokens;
|
|
|
14703
14765
|
exports.kebabcaseToCamelcase = kebabcaseToCamelcase;
|
|
14704
14766
|
exports.parse = parse;
|
|
14705
14767
|
exports.toPropertyName = toPropertyName;
|
|
14706
|
-
/** version: 8.18.
|
|
14768
|
+
/** version: 8.18.2 */
|
|
14707
14769
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.js
CHANGED
|
@@ -183,6 +183,7 @@ const AVAILABLE_OPTION_NAMES = new Set([
|
|
|
183
183
|
'apiVersion',
|
|
184
184
|
'customRendererConfig',
|
|
185
185
|
'enableLwcSpread',
|
|
186
|
+
'enableLwcOn',
|
|
186
187
|
'enableStaticContentOptimization',
|
|
187
188
|
// TODO [#3370]: remove experimental template expression flag
|
|
188
189
|
'experimentalComplexExpressions',
|
|
@@ -245,6 +246,7 @@ function normalizeConfig(config) {
|
|
|
245
246
|
enableDynamicComponents: false,
|
|
246
247
|
enableStaticContentOptimization: true,
|
|
247
248
|
enableLwcSpread: true,
|
|
249
|
+
enableLwcOn: false,
|
|
248
250
|
disableSyntheticShadowSupport: false,
|
|
249
251
|
...config,
|
|
250
252
|
apiVersion, // overrides the config apiVersion
|
|
@@ -9086,6 +9088,14 @@ function spreadDirective(value, location) {
|
|
|
9086
9088
|
location,
|
|
9087
9089
|
};
|
|
9088
9090
|
}
|
|
9091
|
+
function OnDirective(value, location) {
|
|
9092
|
+
return {
|
|
9093
|
+
type: 'Directive',
|
|
9094
|
+
name: 'On',
|
|
9095
|
+
value,
|
|
9096
|
+
location,
|
|
9097
|
+
};
|
|
9098
|
+
}
|
|
9089
9099
|
function slotBindDirective(value, location) {
|
|
9090
9100
|
return {
|
|
9091
9101
|
type: 'Directive',
|
|
@@ -9249,6 +9259,9 @@ function isDomDirective(directive) {
|
|
|
9249
9259
|
function isSpreadDirective(directive) {
|
|
9250
9260
|
return directive.name === 'Spread';
|
|
9251
9261
|
}
|
|
9262
|
+
function isOnDirective(directive) {
|
|
9263
|
+
return directive.name === 'On';
|
|
9264
|
+
}
|
|
9252
9265
|
function isInnerHTMLDirective(directive) {
|
|
9253
9266
|
return directive.name === 'InnerHTML';
|
|
9254
9267
|
}
|
|
@@ -9315,6 +9328,7 @@ var ElementDirectiveName;
|
|
|
9315
9328
|
ElementDirectiveName["SlotBind"] = "lwc:slot-bind";
|
|
9316
9329
|
ElementDirectiveName["SlotData"] = "lwc:slot-data";
|
|
9317
9330
|
ElementDirectiveName["Spread"] = "lwc:spread";
|
|
9331
|
+
ElementDirectiveName["On"] = "lwc:on";
|
|
9318
9332
|
ElementDirectiveName["Key"] = "key";
|
|
9319
9333
|
})(ElementDirectiveName || (ElementDirectiveName = {}));
|
|
9320
9334
|
var RootDirectiveName;
|
|
@@ -11946,6 +11960,7 @@ const LWC_DIRECTIVE_PROCESSORS = [
|
|
|
11946
11960
|
applyLwcInnerHtmlDirective,
|
|
11947
11961
|
applyRefDirective,
|
|
11948
11962
|
applyLwcSpreadDirective,
|
|
11963
|
+
applyLwcOnDirective,
|
|
11949
11964
|
applyLwcSlotBindDirective,
|
|
11950
11965
|
];
|
|
11951
11966
|
function applyLwcDirectives(ctx, parsedAttr, element) {
|
|
@@ -12008,6 +12023,28 @@ function applyLwcSpreadDirective(ctx, parsedAttr, element) {
|
|
|
12008
12023
|
}
|
|
12009
12024
|
element.directives.push(spreadDirective(lwcSpreadAttr, lwcSpread.location));
|
|
12010
12025
|
}
|
|
12026
|
+
function applyLwcOnDirective(ctx, parsedAttr, element) {
|
|
12027
|
+
const { name: tag } = element;
|
|
12028
|
+
const lwcOn = parsedAttr.pick(ElementDirectiveName.On);
|
|
12029
|
+
if (!lwcOn) {
|
|
12030
|
+
return;
|
|
12031
|
+
}
|
|
12032
|
+
if (!ctx.config.enableLwcOn) {
|
|
12033
|
+
ctx.throwOnNode(ParserDiagnostics.INVALID_LWC_ON_OPTS, element);
|
|
12034
|
+
}
|
|
12035
|
+
const { value: lwcOnValue } = lwcOn;
|
|
12036
|
+
if (!isExpression$1(lwcOnValue)) {
|
|
12037
|
+
ctx.throwOnNode(ParserDiagnostics.INVALID_LWC_ON_LITERAL_PROP, element, [`<${tag}>`]);
|
|
12038
|
+
}
|
|
12039
|
+
// At this point element.listeners stores declarative event listeners (e.g., `onfoo`)
|
|
12040
|
+
// `lwc:on` directive cannot be used together with declarative event listeners.
|
|
12041
|
+
if (element.listeners.length) {
|
|
12042
|
+
ctx.throwOnNode(ParserDiagnostics.INVALID_LWC_ON_WITH_DECLARATIVE_LISTENERS, element, [
|
|
12043
|
+
`<${tag}>`,
|
|
12044
|
+
]);
|
|
12045
|
+
}
|
|
12046
|
+
element.directives.push(OnDirective(lwcOnValue, lwcOn.location));
|
|
12047
|
+
}
|
|
12011
12048
|
function applyLwcExternalDirective(ctx, parsedAttr, element) {
|
|
12012
12049
|
const lwcExternalAttribute = parsedAttr.pick(ElementDirectiveName.External);
|
|
12013
12050
|
if (!lwcExternalAttribute) {
|
|
@@ -12468,6 +12505,12 @@ function validateTemplate(ctx, parsedAttr, template, parse5ElmLocation) {
|
|
|
12468
12505
|
if (parsedAttr.get(ElementDirectiveName.Is)) {
|
|
12469
12506
|
ctx.throwAtLocation(ParserDiagnostics.LWC_IS_INVALID_ELEMENT, location, ['<template>']);
|
|
12470
12507
|
}
|
|
12508
|
+
if (parsedAttr.get(ElementDirectiveName.On)) {
|
|
12509
|
+
if (!ctx.config.enableLwcOn) {
|
|
12510
|
+
ctx.throwAtLocation(ParserDiagnostics.INVALID_LWC_ON_OPTS, location, ['<template>']);
|
|
12511
|
+
}
|
|
12512
|
+
ctx.throwAtLocation(ParserDiagnostics.INVALID_LWC_ON_ELEMENT, location, ['<template>']);
|
|
12513
|
+
}
|
|
12471
12514
|
// At this point in the parsing all supported attributes from a non root template element
|
|
12472
12515
|
// should have been removed from ParsedAttribute and all other attributes will be ignored.
|
|
12473
12516
|
const invalidTemplateAttributes = parsedAttr.getAttributes();
|
|
@@ -13631,6 +13674,19 @@ class CodeGen {
|
|
|
13631
13674
|
return property$1(identifier('on'), memoize(objectToAST(listenerObj, (k) => listenerObj[k].handler)));
|
|
13632
13675
|
}
|
|
13633
13676
|
}
|
|
13677
|
+
genDynamicEventListeners(onDirective) {
|
|
13678
|
+
// Example Input : lwc:on={someObj}
|
|
13679
|
+
// $cmp.someObj
|
|
13680
|
+
const rawValue = this.bindExpression(onDirective.value);
|
|
13681
|
+
// {__proto__: null, ...$cmp.someObj}
|
|
13682
|
+
const clonedValue = objectExpression([
|
|
13683
|
+
property$1(identifier('__proto__'), literal$1(null)),
|
|
13684
|
+
spreadElement(rawValue),
|
|
13685
|
+
]);
|
|
13686
|
+
const dynamicOnRawProperty = property$1(identifier('dynamicOnRaw'), rawValue);
|
|
13687
|
+
const dynamicOnProperty = property$1(identifier('dynamicOn'), clonedValue);
|
|
13688
|
+
return [dynamicOnRawProperty, dynamicOnProperty];
|
|
13689
|
+
}
|
|
13634
13690
|
genRef(ref) {
|
|
13635
13691
|
this.hasRefs = true;
|
|
13636
13692
|
return property$1(identifier('ref'), ref.value);
|
|
@@ -14460,6 +14516,7 @@ function transform(codeGen) {
|
|
|
14460
14516
|
const dom = element.directives.find(isDomDirective);
|
|
14461
14517
|
const ref = element.directives.find(isRefDirective);
|
|
14462
14518
|
const spread = element.directives.find(isSpreadDirective);
|
|
14519
|
+
const onDirective = element.directives.find(isOnDirective);
|
|
14463
14520
|
const addSanitizationHook = isCustomRendererHookRequired(element, codeGen.state);
|
|
14464
14521
|
const slotBindDirective = element.directives.find(isSlotBindDirective);
|
|
14465
14522
|
// Attributes
|
|
@@ -14561,6 +14618,11 @@ function transform(codeGen) {
|
|
|
14561
14618
|
if (listeners.length) {
|
|
14562
14619
|
data.push(codeGen.genEventListeners(listeners));
|
|
14563
14620
|
}
|
|
14621
|
+
// dynamic event listeners: lwc:on directive
|
|
14622
|
+
// codeGen.genDynamicEventListeners returns an array containing 2 properties: 'dynamicOn' & 'dynamicOnRaw'
|
|
14623
|
+
if (onDirective) {
|
|
14624
|
+
data.push(...codeGen.genDynamicEventListeners(onDirective));
|
|
14625
|
+
}
|
|
14564
14626
|
// SVG handling
|
|
14565
14627
|
if (element.namespace === SVG_NAMESPACE) {
|
|
14566
14628
|
data.push(property$1(identifier('svg'), literal$1(true)));
|
|
@@ -14674,5 +14736,5 @@ function compile(source, filename, config) {
|
|
|
14674
14736
|
}
|
|
14675
14737
|
|
|
14676
14738
|
export { ElementDirectiveName, LWCDirectiveDomMode, LWCDirectiveRenderMode, LwcTagName, RootDirectiveName, TemplateDirectiveName, compile, compile as default, generateScopeTokens, kebabcaseToCamelcase, parse, toPropertyName };
|
|
14677
|
-
/** version: 8.18.
|
|
14739
|
+
/** version: 8.18.2 */
|
|
14678
14740
|
//# sourceMappingURL=index.js.map
|
package/dist/shared/ast.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Token as parse5TokenInfo } from 'parse5';
|
|
2
|
-
import type { Literal, SourceLocation, Element, ExternalComponent, Component, Expression, ComplexExpression, Comment, Text, ForEach, ForBlock, Slot, Identifier, Root, EventListener, KeyDirective, DynamicDirective, DomDirective, PreserveCommentsDirective, RenderModeDirective, Attribute, Property, ParentNode, BaseNode, ForOf, LWCDirectiveRenderMode, If, IfBlock, ElseBlock, ElseifBlock, ElementSourceLocation, InnerHTMLDirective, BaseElement, LWCDirectiveDomMode, RefDirective, SpreadDirective, ElementDirective, RootDirective, SlotBindDirective, ScopedSlotFragment, SlotDataDirective, IsDirective, LwcComponent, LwcTagName, BaseLwcElement } from './types';
|
|
2
|
+
import type { Literal, SourceLocation, Element, ExternalComponent, Component, Expression, ComplexExpression, Comment, Text, ForEach, ForBlock, Slot, Identifier, Root, EventListener, KeyDirective, DynamicDirective, DomDirective, PreserveCommentsDirective, RenderModeDirective, Attribute, Property, ParentNode, BaseNode, ForOf, LWCDirectiveRenderMode, If, IfBlock, ElseBlock, ElseifBlock, ElementSourceLocation, InnerHTMLDirective, BaseElement, LWCDirectiveDomMode, RefDirective, SpreadDirective, OnDirective, ElementDirective, RootDirective, SlotBindDirective, ScopedSlotFragment, SlotDataDirective, IsDirective, LwcComponent, LwcTagName, BaseLwcElement } from './types';
|
|
3
3
|
export declare function root(parse5ElmLocation: parse5TokenInfo.ElementLocation): Root;
|
|
4
4
|
export declare function element(tagName: string, namespaceURI: string, parse5ElmLocation: parse5TokenInfo.ElementLocation): Element;
|
|
5
5
|
export declare function externalComponent(tagName: string, parse5ElmLocation: parse5TokenInfo.ElementLocation): ExternalComponent;
|
|
@@ -23,6 +23,7 @@ export declare function keyDirective(value: Expression, location: SourceLocation
|
|
|
23
23
|
export declare function dynamicDirective(value: Expression, location: SourceLocation): DynamicDirective;
|
|
24
24
|
export declare function lwcIsDirective(value: Expression, location: SourceLocation): IsDirective;
|
|
25
25
|
export declare function spreadDirective(value: Expression, location: SourceLocation): SpreadDirective;
|
|
26
|
+
export declare function OnDirective(value: Expression, location: SourceLocation): OnDirective;
|
|
26
27
|
export declare function slotBindDirective(value: Expression, location: SourceLocation): SlotBindDirective;
|
|
27
28
|
export declare function slotDataDirective(value: Identifier, location: SourceLocation): SlotDataDirective;
|
|
28
29
|
export declare function domDirective(lwcDomAttr: LWCDirectiveDomMode, location: SourceLocation): DomDirective;
|
|
@@ -60,6 +61,7 @@ export declare function isDynamicDirective(directive: ElementDirective): directi
|
|
|
60
61
|
export declare function isLwcIsDirective(directive: ElementDirective): directive is IsDirective;
|
|
61
62
|
export declare function isDomDirective(directive: ElementDirective): directive is DomDirective;
|
|
62
63
|
export declare function isSpreadDirective(directive: ElementDirective): directive is SpreadDirective;
|
|
64
|
+
export declare function isOnDirective(directive: ElementDirective): directive is OnDirective;
|
|
63
65
|
export declare function isInnerHTMLDirective(directive: ElementDirective): directive is InnerHTMLDirective;
|
|
64
66
|
export declare function isRefDirective(directive: ElementDirective): directive is RefDirective;
|
|
65
67
|
export declare function isKeyDirective(directive: ElementDirective): directive is KeyDirective;
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -84,6 +84,9 @@ export interface DomDirective extends Directive<'Dom'> {
|
|
|
84
84
|
export interface SpreadDirective extends Directive<'Spread'> {
|
|
85
85
|
value: Expression;
|
|
86
86
|
}
|
|
87
|
+
export interface OnDirective extends Directive<'On'> {
|
|
88
|
+
value: Expression;
|
|
89
|
+
}
|
|
87
90
|
export interface InnerHTMLDirective extends Directive<'InnerHTML'> {
|
|
88
91
|
value: Expression | Literal<string>;
|
|
89
92
|
}
|
|
@@ -102,7 +105,7 @@ export interface SlotBindDirective extends Directive<'SlotBind'> {
|
|
|
102
105
|
export interface SlotDataDirective extends Directive<'SlotData'> {
|
|
103
106
|
value: Identifier;
|
|
104
107
|
}
|
|
105
|
-
export type ElementDirective = KeyDirective | DynamicDirective | IsDirective | DomDirective | InnerHTMLDirective | RefDirective | SlotBindDirective | SlotDataDirective | SpreadDirective;
|
|
108
|
+
export type ElementDirective = KeyDirective | DynamicDirective | IsDirective | DomDirective | InnerHTMLDirective | RefDirective | SlotBindDirective | SlotDataDirective | SpreadDirective | OnDirective;
|
|
106
109
|
export type RootDirective = RenderModeDirective | PreserveCommentsDirective;
|
|
107
110
|
export interface Text extends BaseNode {
|
|
108
111
|
type: 'Text';
|
|
@@ -234,6 +237,7 @@ export declare enum ElementDirectiveName {
|
|
|
234
237
|
SlotBind = "lwc:slot-bind",
|
|
235
238
|
SlotData = "lwc:slot-data",
|
|
236
239
|
Spread = "lwc:spread",
|
|
240
|
+
On = "lwc:on",
|
|
237
241
|
Key = "key"
|
|
238
242
|
}
|
|
239
243
|
export declare enum RootDirectiveName {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
|
|
5
5
|
],
|
|
6
6
|
"name": "@lwc/template-compiler",
|
|
7
|
-
"version": "8.18.
|
|
7
|
+
"version": "8.18.2",
|
|
8
8
|
"description": "Template compiler package",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"lwc"
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lwc/errors": "8.18.
|
|
50
|
-
"@lwc/shared": "8.18.
|
|
49
|
+
"@lwc/errors": "8.18.2",
|
|
50
|
+
"@lwc/shared": "8.18.2",
|
|
51
51
|
"acorn": "~8.14.1",
|
|
52
52
|
"astring": "~1.9.0",
|
|
53
53
|
"he": "~1.2.0"
|