@plumeria/utils 11.1.2 → 11.2.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/createTheme.d.ts +1 -1
- package/dist/createTheme.js +4 -2
- package/dist/parser.js +12 -6
- package/package.json +1 -1
package/dist/createTheme.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CreateTheme } from './types';
|
|
2
|
-
declare const createTheme: <const T extends CreateTheme>(rule: T) => Record<string, Record<string, string | number | Record<string, string | number>>>;
|
|
2
|
+
declare const createTheme: <const T extends CreateTheme>(rule: T, hash?: string) => Record<string, Record<string, string | number | Record<string, string | number>>>;
|
|
3
3
|
export { createTheme };
|
package/dist/createTheme.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTheme = void 0;
|
|
4
4
|
const zss_engine_1 = require("zss-engine");
|
|
5
|
-
const createTheme = (rule) => {
|
|
5
|
+
const createTheme = (rule, hash) => {
|
|
6
6
|
const styles = {};
|
|
7
7
|
for (const key in rule) {
|
|
8
|
-
const varKey =
|
|
8
|
+
const varKey = hash
|
|
9
|
+
? `--${hash}-${(0, zss_engine_1.camelToKebabCase)(key)}`
|
|
10
|
+
: `--${(0, zss_engine_1.camelToKebabCase)(key)}`;
|
|
9
11
|
const themeMap = rule[key];
|
|
10
12
|
for (const themeKey in themeMap) {
|
|
11
13
|
const value = themeMap[themeKey];
|
package/dist/parser.js
CHANGED
|
@@ -502,7 +502,7 @@ function resolveCreateThemeTableMemberExpressionByNode(node, createThemeHashTabl
|
|
|
502
502
|
}
|
|
503
503
|
if (key && themeObj[key] !== undefined) {
|
|
504
504
|
const cssVarName = (0, zss_engine_1.camelToKebabCase)(key);
|
|
505
|
-
return `var(--${cssVarName})`;
|
|
505
|
+
return `var(--${hash}-${cssVarName})`;
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
}
|
|
@@ -714,6 +714,10 @@ function scanAll() {
|
|
|
714
714
|
if (localTables.createThemeHashTable[uniqueKey]) {
|
|
715
715
|
const hash = localTables.createThemeHashTable[uniqueKey];
|
|
716
716
|
localCreateThemeHashTable[localName] = hash;
|
|
717
|
+
if (localTables.createThemeObjectTable[hash]) {
|
|
718
|
+
localCreateThemeObjectTable[hash] =
|
|
719
|
+
localTables.createThemeObjectTable[hash];
|
|
720
|
+
}
|
|
717
721
|
}
|
|
718
722
|
if (localTables.keyframesHashTable[uniqueKey]) {
|
|
719
723
|
const hash = localTables.keyframesHashTable[uniqueKey];
|
|
@@ -835,7 +839,7 @@ function scanAll() {
|
|
|
835
839
|
const hashMap = {};
|
|
836
840
|
for (const [key] of Object.entries(obj)) {
|
|
837
841
|
const cssVarName = (0, zss_engine_1.camelToKebabCase)(key);
|
|
838
|
-
hashMap[key] = `var(--${cssVarName})`;
|
|
842
|
+
hashMap[key] = `var(--${hash}-${cssVarName})`;
|
|
839
843
|
}
|
|
840
844
|
localTables.createAtomicMapTable[hash] = hashMap;
|
|
841
845
|
}
|
|
@@ -992,26 +996,28 @@ function extractOndemandStyles(obj, extractedSheets, t) {
|
|
|
992
996
|
}
|
|
993
997
|
}
|
|
994
998
|
if (usedVariables.size > 0) {
|
|
995
|
-
|
|
999
|
+
Object.keys(t.createThemeHashTable)
|
|
1000
|
+
.sort()
|
|
1001
|
+
.forEach((themeVarName) => {
|
|
996
1002
|
const hash = t.createThemeHashTable[themeVarName];
|
|
997
1003
|
const definition = t.createThemeObjectTable[hash];
|
|
998
1004
|
if (definition && typeof definition === 'object') {
|
|
999
1005
|
const filteredDefinition = {};
|
|
1000
1006
|
let hasUsed = false;
|
|
1001
1007
|
Object.keys(definition).forEach((key) => {
|
|
1002
|
-
const varName = `--${(0, zss_engine_1.camelToKebabCase)(key)}`;
|
|
1008
|
+
const varName = `--${hash}-${(0, zss_engine_1.camelToKebabCase)(key)}`;
|
|
1003
1009
|
if (usedVariables.has(varName)) {
|
|
1004
1010
|
filteredDefinition[key] = definition[key];
|
|
1005
1011
|
hasUsed = true;
|
|
1006
1012
|
}
|
|
1007
1013
|
});
|
|
1008
1014
|
if (hasUsed) {
|
|
1009
|
-
const styles = (0, createTheme_1.createTheme)(filteredDefinition);
|
|
1015
|
+
const styles = (0, createTheme_1.createTheme)(filteredDefinition, hash);
|
|
1010
1016
|
const { styleSheet } = (0, zss_engine_1.transpile)(styles, undefined, '--global');
|
|
1011
1017
|
addSheet(styleSheet);
|
|
1012
1018
|
}
|
|
1013
1019
|
}
|
|
1014
|
-
}
|
|
1020
|
+
});
|
|
1015
1021
|
}
|
|
1016
1022
|
}
|
|
1017
1023
|
function deepMerge(target, source) {
|