@plumeria/unplugin 18.5.3 → 18.5.4
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/core.js +22 -12
- package/dist/core.mjs +22 -12
- package/package.json +2 -2
package/dist/core.js
CHANGED
|
@@ -553,16 +553,25 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
553
553
|
};
|
|
554
554
|
const replacements = [];
|
|
555
555
|
const deferredSources = [];
|
|
556
|
-
const
|
|
556
|
+
const deferRange = (start, end) => {
|
|
557
557
|
const token = `__plumeria_preserved_${deferredSources.length}__`;
|
|
558
|
-
deferredSources.push({
|
|
559
|
-
token,
|
|
560
|
-
start: node.span.start - baseByteOffset,
|
|
561
|
-
end: node.span.end - baseByteOffset,
|
|
562
|
-
stripObject,
|
|
563
|
-
});
|
|
558
|
+
deferredSources.push({ token, start, end });
|
|
564
559
|
return token;
|
|
565
560
|
};
|
|
561
|
+
const deferSource = (node) => deferRange(node.span.start - baseByteOffset, node.span.end - baseByteOffset);
|
|
562
|
+
const deferProperty = (property) => {
|
|
563
|
+
const node = property;
|
|
564
|
+
const range = node.spread && node.arguments
|
|
565
|
+
? { start: node.spread.start, end: node.arguments.span.end }
|
|
566
|
+
: node.span
|
|
567
|
+
? { start: node.span.start, end: node.span.end }
|
|
568
|
+
: node.key && node.value
|
|
569
|
+
? { start: node.key.span.start, end: node.value.span.end }
|
|
570
|
+
: null;
|
|
571
|
+
return range
|
|
572
|
+
? deferRange(range.start - baseByteOffset, range.end - baseByteOffset)
|
|
573
|
+
: null;
|
|
574
|
+
};
|
|
566
575
|
const dynamicFnCalls = [];
|
|
567
576
|
const processedDecls = new Set();
|
|
568
577
|
const separatelyExported = new Set();
|
|
@@ -2307,8 +2316,11 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
2307
2316
|
if (styleAttrExisting.value?.type === 'JSXExpressionContainer') {
|
|
2308
2317
|
const innerExpr = styleAttrExisting.value?.expression;
|
|
2309
2318
|
if (innerExpr.type === 'ObjectExpression') {
|
|
2310
|
-
|
|
2311
|
-
|
|
2319
|
+
for (const property of innerExpr.properties) {
|
|
2320
|
+
const token = deferProperty(property);
|
|
2321
|
+
if (token)
|
|
2322
|
+
existingStyleParts.push(token);
|
|
2323
|
+
}
|
|
2312
2324
|
}
|
|
2313
2325
|
else {
|
|
2314
2326
|
existingStyleExpr = `...(${deferSource(innerExpr)})`;
|
|
@@ -2467,9 +2479,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
2467
2479
|
cursor = replacement.end;
|
|
2468
2480
|
}
|
|
2469
2481
|
pieces.push(sourceBuffer.subarray(cursor, deferred.end).toString('utf-8'));
|
|
2470
|
-
|
|
2471
|
-
if (deferred.stripObject)
|
|
2472
|
-
content = content.slice(1, -1).trim();
|
|
2482
|
+
const content = pieces.join('');
|
|
2473
2483
|
for (const replacement of replacements)
|
|
2474
2484
|
replacement.content = replacement.content.replaceAll(deferred.token, content);
|
|
2475
2485
|
}
|
package/dist/core.mjs
CHANGED
|
@@ -517,16 +517,25 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
517
517
|
};
|
|
518
518
|
const replacements = [];
|
|
519
519
|
const deferredSources = [];
|
|
520
|
-
const
|
|
520
|
+
const deferRange = (start, end) => {
|
|
521
521
|
const token = `__plumeria_preserved_${deferredSources.length}__`;
|
|
522
|
-
deferredSources.push({
|
|
523
|
-
token,
|
|
524
|
-
start: node.span.start - baseByteOffset,
|
|
525
|
-
end: node.span.end - baseByteOffset,
|
|
526
|
-
stripObject,
|
|
527
|
-
});
|
|
522
|
+
deferredSources.push({ token, start, end });
|
|
528
523
|
return token;
|
|
529
524
|
};
|
|
525
|
+
const deferSource = (node) => deferRange(node.span.start - baseByteOffset, node.span.end - baseByteOffset);
|
|
526
|
+
const deferProperty = (property) => {
|
|
527
|
+
const node = property;
|
|
528
|
+
const range = node.spread && node.arguments
|
|
529
|
+
? { start: node.spread.start, end: node.arguments.span.end }
|
|
530
|
+
: node.span
|
|
531
|
+
? { start: node.span.start, end: node.span.end }
|
|
532
|
+
: node.key && node.value
|
|
533
|
+
? { start: node.key.span.start, end: node.value.span.end }
|
|
534
|
+
: null;
|
|
535
|
+
return range
|
|
536
|
+
? deferRange(range.start - baseByteOffset, range.end - baseByteOffset)
|
|
537
|
+
: null;
|
|
538
|
+
};
|
|
530
539
|
const dynamicFnCalls = [];
|
|
531
540
|
const processedDecls = new Set();
|
|
532
541
|
const separatelyExported = new Set();
|
|
@@ -2271,8 +2280,11 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
2271
2280
|
if (styleAttrExisting.value?.type === 'JSXExpressionContainer') {
|
|
2272
2281
|
const innerExpr = styleAttrExisting.value?.expression;
|
|
2273
2282
|
if (innerExpr.type === 'ObjectExpression') {
|
|
2274
|
-
|
|
2275
|
-
|
|
2283
|
+
for (const property of innerExpr.properties) {
|
|
2284
|
+
const token = deferProperty(property);
|
|
2285
|
+
if (token)
|
|
2286
|
+
existingStyleParts.push(token);
|
|
2287
|
+
}
|
|
2276
2288
|
}
|
|
2277
2289
|
else {
|
|
2278
2290
|
existingStyleExpr = `...(${deferSource(innerExpr)})`;
|
|
@@ -2431,9 +2443,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
2431
2443
|
cursor = replacement.end;
|
|
2432
2444
|
}
|
|
2433
2445
|
pieces.push(sourceBuffer.subarray(cursor, deferred.end).toString('utf-8'));
|
|
2434
|
-
|
|
2435
|
-
if (deferred.stripObject)
|
|
2436
|
-
content = content.slice(1, -1).trim();
|
|
2446
|
+
const content = pieces.join('');
|
|
2437
2447
|
for (const replacement of replacements)
|
|
2438
2448
|
replacement.content = replacement.content.replaceAll(deferred.token, content);
|
|
2439
2449
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/unplugin",
|
|
3
|
-
"version": "18.5.
|
|
3
|
+
"version": "18.5.4",
|
|
4
4
|
"description": "Universal Plumeria plugin for various build tools",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"@rollup/pluginutils": "^5.4.0",
|
|
96
96
|
"unplugin": "^3.0.0",
|
|
97
|
-
"@plumeria/utils": "^18.5.
|
|
97
|
+
"@plumeria/utils": "^18.5.4"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@swc/core": "1.15.47",
|