@litsx/babel-preset-litsx 0.4.0 → 0.5.0
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/internal/transform-litsx-components.cjs +35 -24
- package/dist/internal/transform-litsx-components.cjs.map +1 -1
- package/dist/internal/transform-litsx-properties.cjs +1 -1
- package/dist/internal/transform-litsx-properties.cjs.map +1 -1
- package/dist/internal/transform-litsx-renderer-props.cjs.map +1 -1
- package/dist/pipeline.cjs +1 -1
- package/dist/pipeline.cjs.map +1 -1
- package/package.json +2 -2
- package/src/internal/transform-litsx-properties.js +1 -1
- package/src/internal/transform-litsx-static-hoists.js +35 -24
- package/src/pipeline.js +1 -1
|
@@ -25,10 +25,17 @@ function isLightDomHoist(statement) {
|
|
|
25
25
|
if (!t$9.isIdentifier(statement.expression.callee, { name: "__litsx_static_lightDom" })) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
const args = statement.expression.arguments;
|
|
30
|
+
if (args.length === 0) {
|
|
31
|
+
return true;
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
|
|
34
|
+
if (args.length === 1 && t$9.isBooleanLiteral(args[0], { value: true })) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
throw new Error("static lightDom = true only accepts the literal value true.");
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
function createStaticHoistGetter(name, symbolId, expression) {
|
|
@@ -106,11 +113,11 @@ function getStaticPropsExpression(statement) {
|
|
|
106
113
|
|
|
107
114
|
const [argument] = statement.expression.arguments;
|
|
108
115
|
if (isHoistedProperties && (t$9.isFunctionExpression(argument) || t$9.isArrowFunctionExpression(argument))) {
|
|
109
|
-
throw new Error("
|
|
116
|
+
throw new Error("static properties = ... only accepts an object literal with static Lit property options.");
|
|
110
117
|
}
|
|
111
118
|
|
|
112
119
|
if (!t$9.isObjectExpression(argument)) {
|
|
113
|
-
throw new Error("
|
|
120
|
+
throw new Error("static properties = ... only accepts an object literal with static Lit property options.");
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
return isHoistedProperties ? {
|
|
@@ -155,7 +162,7 @@ function normalizeStaticPropOverrideValue(value) {
|
|
|
155
162
|
}
|
|
156
163
|
|
|
157
164
|
throw new Error(
|
|
158
|
-
"
|
|
165
|
+
"static properties = ... values must be Lit property option objects or constructor references."
|
|
159
166
|
);
|
|
160
167
|
}
|
|
161
168
|
|
|
@@ -166,12 +173,12 @@ function mergeStaticPropertyObject(targetNode, overrideObject) {
|
|
|
166
173
|
|
|
167
174
|
overrideObject.properties.forEach((property) => {
|
|
168
175
|
if (!t$9.isObjectProperty(property) && !t$9.isObjectMethod(property)) {
|
|
169
|
-
throw new Error("
|
|
176
|
+
throw new Error("static properties = ... only accepts plain object members.");
|
|
170
177
|
}
|
|
171
178
|
|
|
172
179
|
const keyName = getStaticPropertyName(property.key);
|
|
173
180
|
if (!keyName) {
|
|
174
|
-
throw new Error("
|
|
181
|
+
throw new Error("static properties = ... property option names must be static identifiers or strings.");
|
|
175
182
|
}
|
|
176
183
|
|
|
177
184
|
const existing = targetNode.value.properties.find(
|
|
@@ -203,12 +210,12 @@ function mergeStaticPropsIntoProperties(propertiesStatic, staticProps) {
|
|
|
203
210
|
staticProps.forEach((optionsObject) => {
|
|
204
211
|
optionsObject.properties.forEach((property) => {
|
|
205
212
|
if (!t$9.isObjectProperty(property)) {
|
|
206
|
-
throw new Error("
|
|
213
|
+
throw new Error("static properties = ... only accepts plain object properties.");
|
|
207
214
|
}
|
|
208
215
|
|
|
209
216
|
const keyName = getStaticPropertyName(property.key);
|
|
210
217
|
if (!keyName) {
|
|
211
|
-
throw new Error("
|
|
218
|
+
throw new Error("static properties = ... property names must be static identifiers or strings.");
|
|
212
219
|
}
|
|
213
220
|
|
|
214
221
|
const existing = propertyMap.get(keyName);
|
|
@@ -311,7 +318,7 @@ function getStaticStylesExpression(statement, functionPath) {
|
|
|
311
318
|
const [argument] = statement.expression.arguments;
|
|
312
319
|
|
|
313
320
|
if (isHoistedStyles && (t$9.isFunctionExpression(argument) || t$9.isArrowFunctionExpression(argument))) {
|
|
314
|
-
throw new Error("
|
|
321
|
+
throw new Error("static styles = ... only accepts static values. Move dynamic values to useStyle(...) or CSS custom properties.");
|
|
315
322
|
}
|
|
316
323
|
|
|
317
324
|
const template = normalizeStylesTemplate(
|
|
@@ -319,7 +326,7 @@ function getStaticStylesExpression(statement, functionPath) {
|
|
|
319
326
|
functionPath
|
|
320
327
|
);
|
|
321
328
|
if (!template) {
|
|
322
|
-
throw new Error("
|
|
329
|
+
throw new Error("static styles = ... only accepts static values. Move dynamic values to useStyle(...) or CSS custom properties.");
|
|
323
330
|
}
|
|
324
331
|
|
|
325
332
|
const expression = t$9.taggedTemplateExpression(t$9.identifier("css"), template);
|
|
@@ -344,7 +351,7 @@ function getStaticHoistExpression(statement, functionPath) {
|
|
|
344
351
|
}
|
|
345
352
|
|
|
346
353
|
if (statement.expression.arguments.length !== 1) {
|
|
347
|
-
throw new Error(
|
|
354
|
+
throw new Error(`static ${name} = ... expects exactly one argument.`);
|
|
348
355
|
}
|
|
349
356
|
|
|
350
357
|
const [argument] = statement.expression.arguments;
|
|
@@ -356,15 +363,15 @@ function getStaticHoistExpression(statement, functionPath) {
|
|
|
356
363
|
};
|
|
357
364
|
}
|
|
358
365
|
|
|
359
|
-
throw new Error("
|
|
366
|
+
throw new Error("static expose = ... only accepts an object literal.");
|
|
360
367
|
}
|
|
361
368
|
|
|
362
369
|
if (t$9.isFunctionExpression(argument) || t$9.isArrowFunctionExpression(argument)) {
|
|
363
|
-
throw new Error(
|
|
370
|
+
throw new Error(`static ${name} = ... only accepts a direct static value.`);
|
|
364
371
|
}
|
|
365
372
|
|
|
366
373
|
if (!isStaticStylesExpression(argument, functionPath)) {
|
|
367
|
-
throw new Error(
|
|
374
|
+
throw new Error(`static ${name} = ... only accepts a direct static value.`);
|
|
368
375
|
}
|
|
369
376
|
|
|
370
377
|
return {
|
|
@@ -388,7 +395,7 @@ function normalizeExposeHoistExpression(expression) {
|
|
|
388
395
|
};
|
|
389
396
|
}
|
|
390
397
|
|
|
391
|
-
throw new Error("
|
|
398
|
+
throw new Error("static expose = ... only accepts an object literal.");
|
|
392
399
|
}
|
|
393
400
|
|
|
394
401
|
function createExposeClassMethod(property) {
|
|
@@ -399,12 +406,12 @@ function createExposeClassMethod(property) {
|
|
|
399
406
|
|
|
400
407
|
function normalizeExposePropertyToClassMethod(property) {
|
|
401
408
|
if (t$9.isSpreadElement(property)) {
|
|
402
|
-
throw new Error("
|
|
409
|
+
throw new Error("static expose = ... does not accept spread elements.");
|
|
403
410
|
}
|
|
404
411
|
|
|
405
412
|
if (t$9.isObjectMethod(property)) {
|
|
406
413
|
if (property.kind !== "method") {
|
|
407
|
-
throw new Error("
|
|
414
|
+
throw new Error("static expose = ... only accepts plain methods.");
|
|
408
415
|
}
|
|
409
416
|
|
|
410
417
|
return t$9.classMethod(
|
|
@@ -417,12 +424,12 @@ function normalizeExposePropertyToClassMethod(property) {
|
|
|
417
424
|
}
|
|
418
425
|
|
|
419
426
|
if (!t$9.isObjectProperty(property)) {
|
|
420
|
-
throw new Error("
|
|
427
|
+
throw new Error("static expose = ... only accepts plain methods.");
|
|
421
428
|
}
|
|
422
429
|
|
|
423
430
|
const value = property.value;
|
|
424
431
|
if (!t$9.isFunctionExpression(value) && !t$9.isArrowFunctionExpression(value)) {
|
|
425
|
-
throw new Error("
|
|
432
|
+
throw new Error("static expose = ... values must be functions.");
|
|
426
433
|
}
|
|
427
434
|
|
|
428
435
|
const body = t$9.isBlockStatement(value.body)
|
|
@@ -460,7 +467,7 @@ function assertStaticHoistsStayTopLevel(functionPath) {
|
|
|
460
467
|
|
|
461
468
|
const macroName = callPath.node.callee.name.slice("__litsx_static_".length);
|
|
462
469
|
throw callPath.buildCodeFrameError(
|
|
463
|
-
|
|
470
|
+
`static ${macroName} = ... must appear as a top-level statement in the component body.`
|
|
464
471
|
);
|
|
465
472
|
},
|
|
466
473
|
});
|
|
@@ -671,8 +678,12 @@ function processStaticHoists({
|
|
|
671
678
|
}
|
|
672
679
|
}
|
|
673
680
|
|
|
674
|
-
if (lightDomRequested
|
|
675
|
-
|
|
681
|
+
if (lightDomRequested) {
|
|
682
|
+
for (let index = staticHoists.length - 1; index >= 0; index -= 1) {
|
|
683
|
+
if (staticHoists[index]?.name === "shadowRootOptions") {
|
|
684
|
+
staticHoists.splice(index, 1);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
676
687
|
}
|
|
677
688
|
|
|
678
689
|
if (staticProps.length > 0) {
|