@plumeria/unplugin 18.3.3 → 18.3.5
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 +11 -9
- package/dist/core.mjs +12 -10
- package/package.json +2 -2
package/dist/core.js
CHANGED
|
@@ -618,16 +618,17 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
618
618
|
if (utils_1.t.isIdentifier(node.id)) {
|
|
619
619
|
idSpans.add(node.id.span.start);
|
|
620
620
|
}
|
|
621
|
-
let selector = '';
|
|
622
621
|
const selectorExpr = init.arguments[0].expression;
|
|
623
|
-
|
|
624
|
-
|
|
622
|
+
const selector = (0, utils_1.resolveThemeSelector)(selectorExpr, mergedStaticTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
|
|
623
|
+
if (!selector) {
|
|
624
|
+
throwCompilationError(`Plumeria: createTheme needs a selector it can read at build time. ` +
|
|
625
|
+
`Pass a string literal such as ".dark", or a name this file declares as one.`, selectorExpr);
|
|
625
626
|
}
|
|
626
627
|
if (selector.startsWith('@') && !(0, zss_engine_1.isAtRule)(selector)) {
|
|
627
628
|
throwCompilationError(`Plumeria: Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
|
|
628
629
|
}
|
|
629
630
|
const obj = (0, utils_1.objectExpressionToObject)(init.arguments[1].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
|
|
630
|
-
const hash = (0,
|
|
631
|
+
const hash = (0, utils_1.themeHashOf)(selector, obj);
|
|
631
632
|
if (utils_1.t.isIdentifier(node.id)) {
|
|
632
633
|
const uniqueKey = `${resourcePath}-${node.id.value}`;
|
|
633
634
|
scannedTables.createThemeHashTable[uniqueKey] = hash;
|
|
@@ -639,7 +640,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
639
640
|
const themeHashMap = {};
|
|
640
641
|
for (const [key, value] of Object.entries(obj)) {
|
|
641
642
|
const cssVarName = (0, zss_engine_1.camelToKebabCase)(key);
|
|
642
|
-
const atomicHash = (0, zss_engine_1.genBase36Hash)({ [key]: value }, 1, 8);
|
|
643
|
+
const atomicHash = (0, zss_engine_1.genBase36Hash)({ _theme: hash, [key]: value }, 1, 8);
|
|
643
644
|
themeHashMap[key] = `var(--${atomicHash}-${cssVarName})`;
|
|
644
645
|
}
|
|
645
646
|
localCreateStyles[node.id.value] = {
|
|
@@ -800,16 +801,17 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
800
801
|
else if (propName === 'createTheme' &&
|
|
801
802
|
args.length >= 2 &&
|
|
802
803
|
utils_1.t.isObjectExpression(args[1].expression)) {
|
|
803
|
-
let selector = '';
|
|
804
804
|
const selectorExpr = args[0].expression;
|
|
805
|
-
|
|
806
|
-
|
|
805
|
+
const selector = (0, utils_1.resolveThemeSelector)(selectorExpr, mergedStaticTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
|
|
806
|
+
if (!selector) {
|
|
807
|
+
throwCompilationError(`Plumeria: createTheme needs a selector it can read at build time. ` +
|
|
808
|
+
`Pass a string literal such as ".dark", or a name this file declares as one.`, selectorExpr);
|
|
807
809
|
}
|
|
808
810
|
if (selector.startsWith('@') && !(0, zss_engine_1.isAtRule)(selector)) {
|
|
809
811
|
throwCompilationError(`Plumeria: Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
|
|
810
812
|
}
|
|
811
813
|
const obj = (0, utils_1.objectExpressionToObject)(args[1].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
|
|
812
|
-
const hash = (0,
|
|
814
|
+
const hash = (0, utils_1.themeHashOf)(selector, obj);
|
|
813
815
|
scannedTables.createThemeObjectTable[hash] = obj;
|
|
814
816
|
if (scannedTables.createThemeSelectorTable) {
|
|
815
817
|
scannedTables.createThemeSelectorTable[hash] = selector;
|
package/dist/core.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createFilter } from '@rollup/pluginutils';
|
|
|
2
2
|
import { parseSync } from '@swc/core';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { applyCssValue, genBase36Hash, exceptionCamelCase, camelToKebabCase, isAtRule, } from 'zss-engine';
|
|
5
|
-
import { traverse, collectReferenceIdentifiers, getStyleRecords, getStateWeights, collectLocalConsts, objectExpressionToObject, t, getRootIdentifier, extractOndemandStyles, deepMerge, scanAll, resolveImportPath, getLeadingCommentLength, optimizer, getFileDependencies, resolveExport, resolveComponentKey, DEFAULT_STYLE_PROP, } from '@plumeria/utils';
|
|
5
|
+
import { traverse, collectReferenceIdentifiers, getStyleRecords, getStateWeights, collectLocalConsts, objectExpressionToObject, t, getRootIdentifier, extractOndemandStyles, deepMerge, scanAll, resolveImportPath, getLeadingCommentLength, optimizer, themeHashOf, getFileDependencies, resolveExport, resolveComponentKey, resolveThemeSelector, DEFAULT_STYLE_PROP, } from '@plumeria/utils';
|
|
6
6
|
export const TARGET_EXTENSIONS = ['ts', 'tsx', 'js', 'jsx'];
|
|
7
7
|
export const EXTENSION_PATTERN = /\.(ts|tsx|js|jsx)$/;
|
|
8
8
|
const isStaticArgValue = (node) => node.type === 'StringLiteral' ||
|
|
@@ -582,16 +582,17 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
582
582
|
if (t.isIdentifier(node.id)) {
|
|
583
583
|
idSpans.add(node.id.span.start);
|
|
584
584
|
}
|
|
585
|
-
let selector = '';
|
|
586
585
|
const selectorExpr = init.arguments[0].expression;
|
|
587
|
-
|
|
588
|
-
|
|
586
|
+
const selector = resolveThemeSelector(selectorExpr, mergedStaticTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
|
|
587
|
+
if (!selector) {
|
|
588
|
+
throwCompilationError(`Plumeria: createTheme needs a selector it can read at build time. ` +
|
|
589
|
+
`Pass a string literal such as ".dark", or a name this file declares as one.`, selectorExpr);
|
|
589
590
|
}
|
|
590
591
|
if (selector.startsWith('@') && !isAtRule(selector)) {
|
|
591
592
|
throwCompilationError(`Plumeria: Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
|
|
592
593
|
}
|
|
593
594
|
const obj = objectExpressionToObject(init.arguments[1].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
|
|
594
|
-
const hash =
|
|
595
|
+
const hash = themeHashOf(selector, obj);
|
|
595
596
|
if (t.isIdentifier(node.id)) {
|
|
596
597
|
const uniqueKey = `${resourcePath}-${node.id.value}`;
|
|
597
598
|
scannedTables.createThemeHashTable[uniqueKey] = hash;
|
|
@@ -603,7 +604,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
603
604
|
const themeHashMap = {};
|
|
604
605
|
for (const [key, value] of Object.entries(obj)) {
|
|
605
606
|
const cssVarName = camelToKebabCase(key);
|
|
606
|
-
const atomicHash = genBase36Hash({ [key]: value }, 1, 8);
|
|
607
|
+
const atomicHash = genBase36Hash({ _theme: hash, [key]: value }, 1, 8);
|
|
607
608
|
themeHashMap[key] = `var(--${atomicHash}-${cssVarName})`;
|
|
608
609
|
}
|
|
609
610
|
localCreateStyles[node.id.value] = {
|
|
@@ -764,16 +765,17 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
764
765
|
else if (propName === 'createTheme' &&
|
|
765
766
|
args.length >= 2 &&
|
|
766
767
|
t.isObjectExpression(args[1].expression)) {
|
|
767
|
-
let selector = '';
|
|
768
768
|
const selectorExpr = args[0].expression;
|
|
769
|
-
|
|
770
|
-
|
|
769
|
+
const selector = resolveThemeSelector(selectorExpr, mergedStaticTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
|
|
770
|
+
if (!selector) {
|
|
771
|
+
throwCompilationError(`Plumeria: createTheme needs a selector it can read at build time. ` +
|
|
772
|
+
`Pass a string literal such as ".dark", or a name this file declares as one.`, selectorExpr);
|
|
771
773
|
}
|
|
772
774
|
if (selector.startsWith('@') && !isAtRule(selector)) {
|
|
773
775
|
throwCompilationError(`Plumeria: Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
|
|
774
776
|
}
|
|
775
777
|
const obj = objectExpressionToObject(args[1].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
|
|
776
|
-
const hash =
|
|
778
|
+
const hash = themeHashOf(selector, obj);
|
|
777
779
|
scannedTables.createThemeObjectTable[hash] = obj;
|
|
778
780
|
if (scannedTables.createThemeSelectorTable) {
|
|
779
781
|
scannedTables.createThemeSelectorTable[hash] = selector;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/unplugin",
|
|
3
|
-
"version": "18.3.
|
|
3
|
+
"version": "18.3.5",
|
|
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.3.
|
|
97
|
+
"@plumeria/utils": "^18.3.5"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@swc/core": "1.15.47",
|