@lwc/style-compiler 2.45.1 → 2.45.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. package/dist/index.cjs.js +910 -0
  2. package/dist/index.cjs.js.map +1 -0
  3. package/dist/index.js +906 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +28 -20
  6. package/dist/commonjs/css-import/transform.js +0 -41
  7. package/dist/commonjs/css-import/transform.js.map +0 -1
  8. package/dist/commonjs/custom-properties/transform.js +0 -23
  9. package/dist/commonjs/custom-properties/transform.js.map +0 -1
  10. package/dist/commonjs/dir-pseudo-class/transform.js +0 -74
  11. package/dist/commonjs/dir-pseudo-class/transform.js.map +0 -1
  12. package/dist/commonjs/index.js +0 -24
  13. package/dist/commonjs/index.js.map +0 -1
  14. package/dist/commonjs/no-id-selectors/validate.js +0 -13
  15. package/dist/commonjs/no-id-selectors/validate.js.map +0 -1
  16. package/dist/commonjs/postcss-lwc-plugin.js +0 -64
  17. package/dist/commonjs/postcss-lwc-plugin.js.map +0 -1
  18. package/dist/commonjs/scope-at-rules/transform.js +0 -53
  19. package/dist/commonjs/scope-at-rules/transform.js.map +0 -1
  20. package/dist/commonjs/selector-scoping/transform.js +0 -123
  21. package/dist/commonjs/selector-scoping/transform.js.map +0 -1
  22. package/dist/commonjs/selector-scoping/validate.js +0 -50
  23. package/dist/commonjs/selector-scoping/validate.js.map +0 -1
  24. package/dist/commonjs/serialize.js +0 -430
  25. package/dist/commonjs/serialize.js.map +0 -1
  26. package/dist/commonjs/transform.js +0 -26
  27. package/dist/commonjs/transform.js.map +0 -1
  28. package/dist/commonjs/utils/dir-pseudoclass.js +0 -14
  29. package/dist/commonjs/utils/dir-pseudoclass.js.map +0 -1
  30. package/dist/commonjs/utils/message.js +0 -31
  31. package/dist/commonjs/utils/message.js.map +0 -1
  32. package/dist/commonjs/utils/rtl.js +0 -15
  33. package/dist/commonjs/utils/rtl.js.map +0 -1
  34. package/dist/commonjs/utils/selector-parser.js +0 -28
  35. package/dist/commonjs/utils/selector-parser.js.map +0 -1
  36. package/dist/commonjs/utils/selectors-scoping.js +0 -12
  37. package/dist/commonjs/utils/selectors-scoping.js.map +0 -1
  38. /package/dist/{types/css-import → css-import}/transform.d.ts +0 -0
  39. /package/dist/{types/custom-properties → custom-properties}/transform.d.ts +0 -0
  40. /package/dist/{types/dir-pseudo-class → dir-pseudo-class}/transform.d.ts +0 -0
  41. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
  42. /package/dist/{types/no-id-selectors → no-id-selectors}/validate.d.ts +0 -0
  43. /package/dist/{types/postcss-lwc-plugin.d.ts → postcss-lwc-plugin.d.ts} +0 -0
  44. /package/dist/{types/scope-at-rules → scope-at-rules}/transform.d.ts +0 -0
  45. /package/dist/{types/selector-scoping → selector-scoping}/transform.d.ts +0 -0
  46. /package/dist/{types/selector-scoping → selector-scoping}/validate.d.ts +0 -0
  47. /package/dist/{types/serialize.d.ts → serialize.d.ts} +0 -0
  48. /package/dist/{types/transform.d.ts → transform.d.ts} +0 -0
  49. /package/dist/{types/utils → utils}/dir-pseudoclass.d.ts +0 -0
  50. /package/dist/{types/utils → utils}/message.d.ts +0 -0
  51. /package/dist/{types/utils → utils}/rtl.d.ts +0 -0
  52. /package/dist/{types/utils → utils}/selector-parser.d.ts +0 -0
  53. /package/dist/{types/utils → utils}/selectors-scoping.d.ts +0 -0
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const DEPRECATED_SELECTORS = new Set(['/deep/', '::shadow', '>>>']);
4
- const UNSUPPORTED_SELECTORS = new Set([':root', ':host-context']);
5
- const TEMPLATE_DIRECTIVES = [/^key$/, /^lwc:*/, /^if:*/, /^for:*/, /^iterator:*/];
6
- function validateSelectors(root) {
7
- root.walk((node) => {
8
- const { value, sourceIndex } = node;
9
- if (value) {
10
- // Ensure the selector doesn't use a deprecated CSS selector.
11
- if (DEPRECATED_SELECTORS.has(value)) {
12
- throw root.error(`Invalid usage of deprecated selector "${value}".`, {
13
- index: sourceIndex,
14
- word: value,
15
- });
16
- }
17
- // Ensure the selector doesn't use an unsupported selector.
18
- if (UNSUPPORTED_SELECTORS.has(value)) {
19
- throw root.error(`Invalid usage of unsupported selector "${value}".`, {
20
- index: sourceIndex,
21
- word: value,
22
- });
23
- }
24
- }
25
- });
26
- }
27
- function validateAttribute(root) {
28
- root.walkAttributes((node) => {
29
- const { attribute: attributeName, sourceIndex } = node;
30
- const isTemplateDirective = TEMPLATE_DIRECTIVES.some((directive) => {
31
- return directive.test(attributeName);
32
- });
33
- if (isTemplateDirective) {
34
- const message = [
35
- `Invalid usage of attribute selector "${attributeName}". `,
36
- `"${attributeName}" is a template directive and therefore not supported in css rules.`,
37
- ];
38
- throw root.error(message.join(''), {
39
- index: sourceIndex,
40
- word: attributeName,
41
- });
42
- }
43
- });
44
- }
45
- function validate(root) {
46
- validateSelectors(root);
47
- validateAttribute(root);
48
- }
49
- exports.default = validate;
50
- //# sourceMappingURL=validate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/selector-scoping/validate.ts"],"names":[],"mappings":";;AAQA,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;AACpE,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;AAClE,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;AAElF,SAAS,iBAAiB,CAAC,IAAU;IACjC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACf,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;QAEpC,IAAI,KAAK,EAAE;YACP,6DAA6D;YAC7D,IAAI,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;gBACjC,MAAM,IAAI,CAAC,KAAK,CAAC,yCAAyC,KAAK,IAAI,EAAE;oBACjE,KAAK,EAAE,WAAW;oBAClB,IAAI,EAAE,KAAK;iBACd,CAAC,CAAC;aACN;YAED,2DAA2D;YAC3D,IAAI,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;gBAClC,MAAM,IAAI,CAAC,KAAK,CAAC,0CAA0C,KAAK,IAAI,EAAE;oBAClE,KAAK,EAAE,WAAW;oBAClB,IAAI,EAAE,KAAK;iBACd,CAAC,CAAC;aACN;SACJ;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAU;IACjC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;QACvD,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;YAC/D,OAAO,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,IAAI,mBAAmB,EAAE;YACrB,MAAM,OAAO,GAAG;gBACZ,wCAAwC,aAAa,KAAK;gBAC1D,IAAI,aAAa,qEAAqE;aACzF,CAAC;YAEF,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;gBAC/B,KAAK,EAAE,WAAW;gBAClB,IAAI,EAAE,aAAa;aACtB,CAAC,CAAC;SACN;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAwB,QAAQ,CAAC,IAAU;IACvC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACxB,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAHD,2BAGC"}
@@ -1,430 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /*
7
- * Copyright (c) 2018, salesforce.com, inc.
8
- * All rights reserved.
9
- * SPDX-License-Identifier: MIT
10
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
11
- */
12
- const postcss_1 = __importDefault(require("postcss"));
13
- const postcss_value_parser_1 = __importDefault(require("postcss-value-parser"));
14
- const string_prototype_matchall_1 = __importDefault(require("string.prototype.matchall"));
15
- const shared_1 = require("@lwc/shared");
16
- const message_1 = require("./utils/message");
17
- const selectors_scoping_1 = require("./utils/selectors-scoping");
18
- const dir_pseudoclass_1 = require("./utils/dir-pseudoclass");
19
- var TokenType;
20
- (function (TokenType) {
21
- TokenType["text"] = "text";
22
- TokenType["expression"] = "expression";
23
- TokenType["identifier"] = "identifier";
24
- TokenType["divider"] = "divider";
25
- })(TokenType || (TokenType = {}));
26
- // "1400 binary expressions are enough to reach Node.js maximum call stack size"
27
- // https://github.com/salesforce/lwc/issues/1726
28
- // The vast majority of stylesheet functions are much less than this, so we can set the limit lower
29
- // to play it safe.
30
- const BINARY_EXPRESSION_LIMIT = 100;
31
- // Javascript identifiers used for the generation of the style module
32
- const HOST_SELECTOR_IDENTIFIER = 'hostSelector';
33
- const SHADOW_SELECTOR_IDENTIFIER = 'shadowSelector';
34
- const SUFFIX_TOKEN_IDENTIFIER = 'suffixToken';
35
- const USE_ACTUAL_HOST_SELECTOR = 'useActualHostSelector';
36
- const USE_NATIVE_DIR_PSEUDOCLASS = 'useNativeDirPseudoclass';
37
- const TOKEN = 'token';
38
- const STYLESHEET_IDENTIFIER = 'stylesheet';
39
- const VAR_RESOLVER_IDENTIFIER = 'varResolver';
40
- function serialize(result, config) {
41
- const { messages } = result;
42
- const collectVarFunctions = Boolean(config.customProperties && config.customProperties.resolverModule);
43
- const useVarResolver = messages.some(message_1.isVarFunctionMessage);
44
- const importedStylesheets = messages.filter(message_1.isImportMessage).map((message) => message.id);
45
- const disableSyntheticShadow = Boolean(config.disableSyntheticShadowSupport);
46
- const scoped = Boolean(config.scoped);
47
- let buffer = '';
48
- if (collectVarFunctions && useVarResolver) {
49
- buffer += `import ${VAR_RESOLVER_IDENTIFIER} from "${config.customProperties
50
- .resolverModule}";\n`;
51
- }
52
- for (let i = 0; i < importedStylesheets.length; i++) {
53
- buffer += `import ${STYLESHEET_IDENTIFIER + i} from "${importedStylesheets[i]}";\n`;
54
- }
55
- if (importedStylesheets.length) {
56
- buffer += '\n';
57
- }
58
- const stylesheetList = importedStylesheets.map((_str, i) => `${STYLESHEET_IDENTIFIER + i}`);
59
- const serializedStyle = serializeCss(result, collectVarFunctions).trim();
60
- if (serializedStyle) {
61
- // inline function
62
- if (disableSyntheticShadow && !scoped) {
63
- // If synthetic shadow DOM support is disabled and this is not a scoped stylesheet, then the
64
- // function signature will always be:
65
- // stylesheet(token = undefined, useActualHostSelector = true, useNativeDirPseudoclass = true)
66
- // This means that we can just have a function that takes no arguments and returns a string,
67
- // reducing the bundle size when minified.
68
- buffer += `function ${STYLESHEET_IDENTIFIER}() {\n`;
69
- buffer += ` var ${TOKEN};\n`; // undefined
70
- buffer += ` var ${USE_ACTUAL_HOST_SELECTOR} = true;\n`;
71
- buffer += ` var ${USE_NATIVE_DIR_PSEUDOCLASS} = true;\n`;
72
- }
73
- else {
74
- buffer += `function ${STYLESHEET_IDENTIFIER}(${TOKEN}, ${USE_ACTUAL_HOST_SELECTOR}, ${USE_NATIVE_DIR_PSEUDOCLASS}) {\n`;
75
- }
76
- // For scoped stylesheets, we use classes, but for synthetic shadow DOM, we use attributes
77
- if (scoped) {
78
- buffer += ` var ${SHADOW_SELECTOR_IDENTIFIER} = ${TOKEN} ? ("." + ${TOKEN}) : "";\n`;
79
- buffer += ` var ${HOST_SELECTOR_IDENTIFIER} = ${TOKEN} ? ("." + ${TOKEN} + "-host") : "";\n`;
80
- }
81
- else {
82
- buffer += ` var ${SHADOW_SELECTOR_IDENTIFIER} = ${TOKEN} ? ("[" + ${TOKEN} + "]") : "";\n`;
83
- buffer += ` var ${HOST_SELECTOR_IDENTIFIER} = ${TOKEN} ? ("[" + ${TOKEN} + "-host]") : "";\n`;
84
- }
85
- // Used for keyframes
86
- buffer += ` var ${SUFFIX_TOKEN_IDENTIFIER} = ${TOKEN} ? ("-" + ${TOKEN}) : "";\n`;
87
- buffer += ` return ${serializedStyle};\n`;
88
- buffer += ` /*${shared_1.LWC_VERSION_COMMENT}*/\n`;
89
- buffer += `}\n`;
90
- if (scoped) {
91
- // Mark the stylesheet as scoped so that we can distinguish it later at runtime
92
- buffer += `${STYLESHEET_IDENTIFIER}.${shared_1.KEY__SCOPED_CSS} = true;\n`;
93
- }
94
- // add import at the end
95
- stylesheetList.push(STYLESHEET_IDENTIFIER);
96
- }
97
- // exports
98
- if (stylesheetList.length) {
99
- buffer += `export default [${stylesheetList.join(', ')}];`;
100
- }
101
- else {
102
- buffer += `export default undefined;`;
103
- }
104
- return buffer;
105
- }
106
- exports.default = serialize;
107
- function reduceTokens(tokens) {
108
- return [{ type: TokenType.text, value: '' }, ...tokens, { type: TokenType.text, value: '' }]
109
- .reduce((acc, token) => {
110
- const prev = acc[acc.length - 1];
111
- if (token.type === TokenType.text && prev && prev.type === TokenType.text) {
112
- // clone the previous token to avoid mutating it in-place
113
- acc[acc.length - 1] = {
114
- type: prev.type,
115
- value: prev.value + token.value,
116
- };
117
- return acc;
118
- }
119
- else {
120
- return [...acc, token];
121
- }
122
- }, [])
123
- .filter((t) => t.value !== '');
124
- }
125
- function normalizeString(str) {
126
- return str.replace(/(\r\n\t|\n|\r\t)/gm, '').trim();
127
- }
128
- function generateExpressionFromTokens(tokens) {
129
- const serializedTokens = reduceTokens(tokens).map(({ type, value }) => {
130
- switch (type) {
131
- // Note that we don't expect to get a TokenType.divider here. It should be converted into an
132
- // expression elsewhere.
133
- case TokenType.text:
134
- return JSON.stringify(value);
135
- // Expressions may be concatenated with " + ", in which case we must remove ambiguity
136
- case TokenType.expression:
137
- return `(${value})`;
138
- default:
139
- return value;
140
- }
141
- });
142
- if (serializedTokens.length === 0) {
143
- return '';
144
- }
145
- else if (serializedTokens.length === 1) {
146
- return serializedTokens[0];
147
- }
148
- else if (serializedTokens.length < BINARY_EXPRESSION_LIMIT) {
149
- return serializedTokens.join(' + ');
150
- }
151
- else {
152
- // #1726 Using Array.prototype.join() instead of a standard "+" operator to concatenate the
153
- // string to avoid running into a maximum call stack error when the stylesheet is parsed
154
- // again by the bundler.
155
- return `[${serializedTokens.join(', ')}].join('')`;
156
- }
157
- }
158
- function areTokensEqual(left, right) {
159
- return left.type === right.type && left.value === right.value;
160
- }
161
- function calculateNumDuplicatedTokens(left, right) {
162
- // Walk backwards until we find a token that is different between left and right
163
- let i = 0;
164
- for (; i < left.length && i < right.length; i++) {
165
- const currentLeft = left[left.length - 1 - i];
166
- const currentRight = right[right.length - 1 - i];
167
- if (!areTokensEqual(currentLeft, currentRight)) {
168
- break;
169
- }
170
- }
171
- return i;
172
- }
173
- // For `:host` selectors, the token lists for native vs synthetic will be identical at the end of
174
- // each list. So as an optimization, we can de-dup these tokens.
175
- // See: https://github.com/salesforce/lwc/issues/3224#issuecomment-1353520052
176
- function deduplicateHostTokens(nativeHostTokens, syntheticHostTokens) {
177
- const numDuplicatedTokens = calculateNumDuplicatedTokens(nativeHostTokens, syntheticHostTokens);
178
- const numUniqueNativeTokens = nativeHostTokens.length - numDuplicatedTokens;
179
- const numUniqueSyntheticTokens = syntheticHostTokens.length - numDuplicatedTokens;
180
- const uniqueNativeTokens = nativeHostTokens.slice(0, numUniqueNativeTokens);
181
- const uniqueSyntheticTokens = syntheticHostTokens.slice(0, numUniqueSyntheticTokens);
182
- const nativeExpression = generateExpressionFromTokens(uniqueNativeTokens);
183
- const syntheticExpression = generateExpressionFromTokens(uniqueSyntheticTokens);
184
- // Generate a conditional ternary to switch between native vs synthetic for the unique tokens
185
- const conditionalToken = {
186
- type: TokenType.expression,
187
- value: `(${USE_ACTUAL_HOST_SELECTOR} ? ${nativeExpression} : ${syntheticExpression})`,
188
- };
189
- return [
190
- conditionalToken,
191
- // The remaining tokens are the same between native and synthetic
192
- ...syntheticHostTokens.slice(numUniqueSyntheticTokens),
193
- ];
194
- }
195
- function serializeCss(result, collectVarFunctions) {
196
- const tokens = [];
197
- let currentRuleTokens = [];
198
- let nativeHostTokens;
199
- // Walk though all nodes in the CSS...
200
- postcss_1.default.stringify(result.root, (part, node, nodePosition) => {
201
- // When consuming the beginning of a rule, first we tokenize the selector
202
- if (node && node.type === 'rule' && nodePosition === 'start') {
203
- currentRuleTokens.push(...tokenizeCss(normalizeString(part)));
204
- // When consuming the end of a rule we normalize it and produce a new one
205
- }
206
- else if (node && node.type === 'rule' && nodePosition === 'end') {
207
- currentRuleTokens.push({ type: TokenType.text, value: part });
208
- // If we are in synthetic shadow or scoped light DOM, we don't want to have native :host selectors
209
- // Note that postcss-lwc-plugin should ensure that _isNativeHost appears before _isSyntheticHost
210
- if (node._isNativeHost) {
211
- // Save native tokens so in the next rule we can apply a conditional ternary
212
- nativeHostTokens = [...currentRuleTokens];
213
- }
214
- else if (node._isSyntheticHost) {
215
- /* istanbul ignore if */
216
- if (!nativeHostTokens) {
217
- throw new Error('Unexpected host rules ordering');
218
- }
219
- const hostTokens = deduplicateHostTokens(nativeHostTokens, currentRuleTokens);
220
- tokens.push(...hostTokens);
221
- nativeHostTokens = undefined;
222
- }
223
- else {
224
- /* istanbul ignore if */
225
- if (nativeHostTokens) {
226
- throw new Error('Unexpected host rules ordering');
227
- }
228
- tokens.push(...currentRuleTokens);
229
- }
230
- // Reset rule
231
- currentRuleTokens = [];
232
- // When inside a declaration, tokenize it and push it to the current token list
233
- }
234
- else if (node && node.type === 'decl') {
235
- if (collectVarFunctions) {
236
- const declTokens = tokenizeCssDeclaration(node);
237
- currentRuleTokens.push(...declTokens);
238
- currentRuleTokens.push({ type: TokenType.text, value: ';' });
239
- }
240
- else {
241
- currentRuleTokens.push(...tokenizeCss(part));
242
- }
243
- }
244
- else if (node && node.type === 'atrule') {
245
- // Certain atrules have declaration associated with for example @font-face. We need to add the rules tokens
246
- // when it's the case.
247
- if (currentRuleTokens.length) {
248
- tokens.push(...currentRuleTokens);
249
- currentRuleTokens = [];
250
- }
251
- tokens.push(...tokenizeCss(normalizeString(part)));
252
- }
253
- else {
254
- // When inside anything else but a comment just push it
255
- if (!node || node.type !== 'comment') {
256
- currentRuleTokens.push({ type: TokenType.text, value: normalizeString(part) });
257
- }
258
- }
259
- });
260
- return generateExpressionFromTokens(tokens);
261
- }
262
- // Given any CSS string, replace the scope tokens from the CSS with code to properly
263
- // replace it in the stylesheet function.
264
- function tokenizeCss(data) {
265
- data = data.replace(/( {2,})/gm, ' '); // remove when there are more than two spaces
266
- const tokens = [];
267
- const attributes = [
268
- selectors_scoping_1.SHADOW_ATTRIBUTE,
269
- selectors_scoping_1.HOST_ATTRIBUTE,
270
- dir_pseudoclass_1.DIR_ATTRIBUTE_NATIVE_LTR,
271
- dir_pseudoclass_1.DIR_ATTRIBUTE_NATIVE_RTL,
272
- dir_pseudoclass_1.DIR_ATTRIBUTE_SYNTHETIC_LTR,
273
- dir_pseudoclass_1.DIR_ATTRIBUTE_SYNTHETIC_RTL,
274
- ];
275
- const regex = new RegExp(`[[-](${attributes.join('|')})]?`, 'g');
276
- let lastIndex = 0;
277
- for (const match of (0, string_prototype_matchall_1.default)(data, regex)) {
278
- const index = match.index;
279
- const [matchString, substring] = match;
280
- if (index > lastIndex) {
281
- tokens.push({ type: TokenType.text, value: data.substring(lastIndex, index) });
282
- }
283
- const identifier = substring === selectors_scoping_1.SHADOW_ATTRIBUTE ? SHADOW_SELECTOR_IDENTIFIER : HOST_SELECTOR_IDENTIFIER;
284
- if (matchString.startsWith('[')) {
285
- if (substring === selectors_scoping_1.SHADOW_ATTRIBUTE || substring === selectors_scoping_1.HOST_ATTRIBUTE) {
286
- // attribute in a selector, e.g. `[__shadowAttribute__]` or `[__hostAttribute__]`
287
- tokens.push({
288
- type: TokenType.identifier,
289
- value: identifier,
290
- });
291
- }
292
- else {
293
- // :dir pseudoclass placeholder, e.g. `[__dirAttributeNativeLtr__]` or `[__dirAttributeSyntheticRtl__]`
294
- const native = substring === dir_pseudoclass_1.DIR_ATTRIBUTE_NATIVE_LTR ||
295
- substring === dir_pseudoclass_1.DIR_ATTRIBUTE_NATIVE_RTL;
296
- const dirValue = substring === dir_pseudoclass_1.DIR_ATTRIBUTE_NATIVE_LTR ||
297
- substring === dir_pseudoclass_1.DIR_ATTRIBUTE_SYNTHETIC_LTR
298
- ? 'ltr'
299
- : 'rtl';
300
- tokens.push({
301
- type: TokenType.expression,
302
- // use the native :dir() pseudoclass for native shadow, the [dir] attribute otherwise
303
- value: native
304
- ? `${USE_NATIVE_DIR_PSEUDOCLASS} ? ':dir(${dirValue})' : ''`
305
- : `${USE_NATIVE_DIR_PSEUDOCLASS} ? '' : '[dir="${dirValue}"]'`,
306
- });
307
- }
308
- }
309
- else {
310
- // suffix for an at-rule, e.g. `@keyframes spin-__shadowAttribute__`
311
- tokens.push({
312
- type: TokenType.identifier,
313
- // Suffix the keyframe (i.e. "-" plus the token)
314
- value: SUFFIX_TOKEN_IDENTIFIER,
315
- });
316
- }
317
- lastIndex = index + matchString.length;
318
- }
319
- if (lastIndex < data.length) {
320
- tokens.push({ type: TokenType.text, value: data.substring(lastIndex, data.length) });
321
- }
322
- return tokens;
323
- }
324
- function isTextOrExpression(token) {
325
- return token.type === TokenType.text || token.type == TokenType.expression;
326
- }
327
- /*
328
- * This method takes a tokenized CSS property value `1px solid var(--foo , bar)`
329
- * and transforms its custom variables in function calls
330
- */
331
- function recursiveValueParse(node, inVarExpression = false) {
332
- const { type, nodes, value } = node;
333
- // If it has not type it means is the root, process its children
334
- if (!type && nodes) {
335
- return nodes.reduce((acc, n) => {
336
- acc.push(...recursiveValueParse(n, inVarExpression));
337
- return acc;
338
- }, []);
339
- }
340
- if (type === 'comment') {
341
- return [];
342
- }
343
- if (type === 'div') {
344
- return [
345
- {
346
- type: inVarExpression ? TokenType.divider : TokenType.text,
347
- value,
348
- },
349
- ];
350
- }
351
- if (type === 'string') {
352
- const { quote } = node;
353
- return [
354
- {
355
- type: TokenType.text,
356
- value: quote ? quote + value + quote : value,
357
- },
358
- ];
359
- }
360
- // If we are inside a var() expression use need to stringify since we are converting it into a function
361
- if (type === 'word') {
362
- const convertIdentifier = value.startsWith('--');
363
- if (convertIdentifier) {
364
- return [{ type: TokenType.identifier, value: `"${value}"` }];
365
- }
366
- // For animation properties, the shadow/host attributes may be in this text
367
- return tokenizeCss(value);
368
- }
369
- // If we inside a var() function we need to prepend and append to generate an expression
370
- if (type === 'function') {
371
- if (value === 'var') {
372
- // `tokens` may include tokens of type `divider`, `expression`, `identifier`,
373
- // and `text`. However, an identifier will only ever be adjacent to a divider,
374
- // whereas text and expression tokens may be adjacent to one another. This is
375
- // important below when inserting concatenetors.
376
- //
377
- // For fuller context, see the following conversation:
378
- // https://github.com/salesforce/lwc/pull/2902#discussion_r904626421
379
- let tokens = recursiveValueParse({ nodes }, true);
380
- tokens = reduceTokens(tokens);
381
- const exprToken = tokens.reduce((buffer, token, index) => {
382
- const isTextToken = token.type === TokenType.text;
383
- const normalizedToken = isTextToken ? JSON.stringify(token.value) : token.value;
384
- const nextToken = tokens[index + 1];
385
- // If we have a token sequence of text + expression or expression + text,
386
- // we need to add the concatenation operator. Examples:
387
- //
388
- // Input: var(--x, 0 0 2px var(--y, #fff))
389
- // Output: varResolver("--x", "0 0 2px " + varResolver("--y", "#fff"))
390
- //
391
- // Input: var(--x, var(--y, #fff) 0 0 2px)
392
- // Output: varResolver("--x", varResolver("--y", "#fff") + " 0 0 2px"))
393
- //
394
- // Since identifier tokens will never be adjacent to text or expression
395
- // tokens (see above comment), a concatenator will never be required if
396
- // `token` or `nextToken` is an identifier.
397
- const shouldAddConcatenator = isTextOrExpression(token) && nextToken && isTextOrExpression(nextToken);
398
- const concatOperator = shouldAddConcatenator ? ' + ' : '';
399
- return buffer + normalizedToken + concatOperator;
400
- }, '');
401
- // Generate the function call for runtime evaluation
402
- return [
403
- {
404
- type: TokenType.expression,
405
- value: `${VAR_RESOLVER_IDENTIFIER}(${exprToken})`,
406
- },
407
- ];
408
- // for any other function just do the equivalent string concatenation (no need for expressions)
409
- }
410
- else {
411
- const tokens = nodes.reduce((acc, n) => {
412
- acc.push(...recursiveValueParse(n, false));
413
- return acc;
414
- }, []);
415
- return [
416
- { type: TokenType.text, value: `${value}(` },
417
- ...reduceTokens(tokens),
418
- { type: TokenType.text, value: ')' },
419
- ];
420
- }
421
- }
422
- // For any other token types we just need to return text
423
- return [{ type: TokenType.text, value }];
424
- }
425
- function tokenizeCssDeclaration(node) {
426
- const valueRoot = (0, postcss_value_parser_1.default)(node.value);
427
- const parsed = recursiveValueParse(valueRoot);
428
- return [{ type: TokenType.text, value: `${node.prop.trim()}: ` }, ...parsed];
429
- }
430
- //# sourceMappingURL=serialize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../src/serialize.ts"],"names":[],"mappings":";;;;;AAAA;;;;;GAKG;AACH,sDAAuD;AACvD,gFAAsD;AACtD,0FAAiD;AACjD,wCAAmE;AAEnE,6CAAwE;AACxE,iEAA6E;AAC7E,6DAKiC;AAEjC,IAAK,SAKJ;AALD,WAAK,SAAS;IACV,0BAAa,CAAA;IACb,sCAAyB,CAAA;IACzB,sCAAyB,CAAA;IACzB,gCAAmB,CAAA;AACvB,CAAC,EALI,SAAS,KAAT,SAAS,QAKb;AAMD,gFAAgF;AAChF,gDAAgD;AAChD,mGAAmG;AACnG,mBAAmB;AACnB,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,qEAAqE;AACrE,MAAM,wBAAwB,GAAG,cAAc,CAAC;AAChD,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AACpD,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAC9C,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AACzD,MAAM,0BAA0B,GAAG,yBAAyB,CAAC;A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AAC,CAAC,CAAC;gBAC3C,OAAO,GAAG,CAAC;YACf,CAAC,EAAE,EAAE,CAAC,CAAC;YACP,OAAO;gBACH,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,EAAE;gBAC5C,GAAG,YAAY,CAAC,MAAM,CAAC;gBACvB,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;aACvC,CAAC;SACL;KACJ;IAED,wDAAwD;IACxD,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAiB;IAC7C,MAAM,SAAS,GAAG,IAAA,8BAAkB,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC;AACjF,CAAC"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.transform = void 0;
7
- /*
8
- * Copyright (c) 2018, salesforce.com, inc.
9
- * All rights reserved.
10
- * SPDX-License-Identifier: MIT
11
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
12
- */
13
- const postcss_1 = __importDefault(require("postcss"));
14
- const serialize_1 = __importDefault(require("./serialize"));
15
- const postcss_lwc_plugin_1 = __importDefault(require("./postcss-lwc-plugin"));
16
- function transform(src, id, config = {}) {
17
- if (src === '') {
18
- return { code: 'export default undefined' };
19
- }
20
- const scoped = !!config.scoped;
21
- const plugins = [(0, postcss_lwc_plugin_1.default)({ scoped })];
22
- const result = (0, postcss_1.default)(plugins).process(src, { from: id }).sync();
23
- return { code: (0, serialize_1.default)(result, config) };
24
- }
25
- exports.transform = transform;
26
- //# sourceMappingURL=transform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/transform.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;GAKG;AACH,sDAA8B;AAE9B,4DAAoC;AACpC,8EAA8C;AAc9C,SAAgB,SAAS,CAAC,GAAW,EAAE,EAAU,EAAE,SAAiB,EAAE;IAClE,IAAI,GAAG,KAAK,EAAE,EAAE;QACZ,OAAO,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAC;KAC/C;IAED,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAC/B,MAAM,OAAO,GAAG,CAAC,IAAA,4BAAU,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAEzC,MAAM,MAAM,GAAG,IAAA,iBAAO,EAAC,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAElE,OAAO,EAAE,IAAI,EAAE,IAAA,mBAAS,EAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;AAC/C,CAAC;AAXD,8BAWC"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DIR_ATTRIBUTE_SYNTHETIC_RTL = exports.DIR_ATTRIBUTE_SYNTHETIC_LTR = exports.DIR_ATTRIBUTE_NATIVE_RTL = exports.DIR_ATTRIBUTE_NATIVE_LTR = void 0;
4
- /*
5
- * Copyright (c) 2018, salesforce.com, inc.
6
- * All rights reserved.
7
- * SPDX-License-Identifier: MIT
8
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
9
- */
10
- exports.DIR_ATTRIBUTE_NATIVE_LTR = `__dirAttributeNativeLtr__`;
11
- exports.DIR_ATTRIBUTE_NATIVE_RTL = `__dirAttributeNativeRtl__`;
12
- exports.DIR_ATTRIBUTE_SYNTHETIC_LTR = `__dirAttributeSyntheticLtr__`;
13
- exports.DIR_ATTRIBUTE_SYNTHETIC_RTL = `__dirAttributeSyntheticRtl__`;
14
- //# sourceMappingURL=dir-pseudoclass.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dir-pseudoclass.js","sourceRoot":"","sources":["../../../src/utils/dir-pseudoclass.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACU,QAAA,wBAAwB,GAAG,2BAA2B,CAAC;AACvD,QAAA,wBAAwB,GAAG,2BAA2B,CAAC;AACvD,QAAA,2BAA2B,GAAG,8BAA8B,CAAC;AAC7D,QAAA,2BAA2B,GAAG,8BAA8B,CAAC"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isVarFunctionMessage = exports.varFunctionMessage = exports.isImportMessage = exports.importMessage = void 0;
4
- const PLUGIN_NAME = '@lwc/style-compiler';
5
- const IMPORT_TYPE = 'import';
6
- const VAR_FUNCTION_TYPE = 'var-function';
7
- function importMessage(id) {
8
- return {
9
- plugin: PLUGIN_NAME,
10
- type: IMPORT_TYPE,
11
- id,
12
- };
13
- }
14
- exports.importMessage = importMessage;
15
- function isImportMessage(message) {
16
- return message.type === IMPORT_TYPE && message.id;
17
- }
18
- exports.isImportMessage = isImportMessage;
19
- function varFunctionMessage(original) {
20
- return {
21
- plugin: PLUGIN_NAME,
22
- type: VAR_FUNCTION_TYPE,
23
- original,
24
- };
25
- }
26
- exports.varFunctionMessage = varFunctionMessage;
27
- function isVarFunctionMessage(message) {
28
- return message.type === VAR_FUNCTION_TYPE && message.original;
29
- }
30
- exports.isVarFunctionMessage = isVarFunctionMessage;
31
- //# sourceMappingURL=message.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/utils/message.ts"],"names":[],"mappings":";;;AAkBA,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAE1C,MAAM,WAAW,GAAG,QAAQ,CAAC;AAC7B,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEzC,SAAgB,aAAa,CAAC,EAAU;IACpC,OAAO;QACH,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE,WAAW;QACjB,EAAE;KACL,CAAC;AACN,CAAC;AAND,sCAMC;AAED,SAAgB,eAAe,CAAC,OAAY;IACxC,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,IAAI,OAAO,CAAC,EAAE,CAAC;AACtD,CAAC;AAFD,0CAEC;AAED,SAAgB,kBAAkB,CAAC,QAAgB;IAC/C,OAAO;QACH,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE,iBAAiB;QACvB,QAAQ;KACX,CAAC;AACN,CAAC;AAND,gDAMC;AAED,SAAgB,oBAAoB,CAAC,OAAY;IAC7C,OAAO,OAAO,CAAC,IAAI,KAAK,iBAAiB,IAAI,OAAO,CAAC,QAAQ,CAAC;AAClE,CAAC;AAFD,oDAEC"}
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDirPseudoClass = void 0;
4
- /*
5
- * Copyright (c) 2018, salesforce.com, inc.
6
- * All rights reserved.
7
- * SPDX-License-Identifier: MIT
8
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
9
- */
10
- const postcss_selector_parser_1 = require("postcss-selector-parser");
11
- function isDirPseudoClass(node) {
12
- return (0, postcss_selector_parser_1.isPseudoClass)(node) && node.value === ':dir';
13
- }
14
- exports.isDirPseudoClass = isDirPseudoClass;
15
- //# sourceMappingURL=rtl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rtl.js","sourceRoot":"","sources":["../../../src/utils/rtl.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,qEAAsE;AAEtE,SAAgB,gBAAgB,CAAC,IAAU;IACvC,OAAO,IAAA,uCAAa,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC;AACxD,CAAC;AAFD,4CAEC"}
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.trimNodeWhitespaces = exports.replaceNodeWith = exports.findNode = void 0;
4
- function findNode(container, predicate) {
5
- return container && container.nodes && container.nodes.find(predicate);
6
- }
7
- exports.findNode = findNode;
8
- function replaceNodeWith(oldNode, ...newNodes) {
9
- if (newNodes.length) {
10
- const { parent } = oldNode;
11
- if (!parent) {
12
- throw new Error(`Impossible to replace root node.`);
13
- }
14
- newNodes.forEach((node) => {
15
- parent.insertBefore(oldNode, node);
16
- });
17
- oldNode.remove();
18
- }
19
- }
20
- exports.replaceNodeWith = replaceNodeWith;
21
- function trimNodeWhitespaces(node) {
22
- if (node && node.spaces) {
23
- node.spaces.before = '';
24
- node.spaces.after = '';
25
- }
26
- }
27
- exports.trimNodeWhitespaces = trimNodeWhitespaces;
28
- //# sourceMappingURL=selector-parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selector-parser.js","sourceRoot":"","sources":["../../../src/utils/selector-parser.ts"],"names":[],"mappings":";;;AAQA,SAAgB,QAAQ,CACpB,SAAoB,EACpB,SAAoC;IAEpC,OAAO,SAAS,IAAI,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC3E,CAAC;AALD,4BAKC;AAED,SAAgB,eAAe,CAAC,OAAa,EAAE,GAAG,QAAgB;IAC9D,IAAI,QAAQ,CAAC,MAAM,EAAE;QACjB,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAE3B,IAAI,CAAC,MAAM,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACvD;QAED,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACtB,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,MAAM,EAAE,CAAC;KACpB;AACL,CAAC;AAdD,0CAcC;AAED,SAAgB,mBAAmB,CAAC,IAAU;IAC1C,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE;QACrB,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;KAC1B;AACL,CAAC;AALD,kDAKC"}