@plumeria/utils 18.5.0 → 18.5.1
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/dynamicKey.d.ts +1 -1
- package/dist/dynamicKey.js +4 -2
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +15 -13
- package/dist/resolver.d.ts +1 -1
- package/dist/resolver.js +2 -2
- package/package.json +1 -1
package/dist/dynamicKey.d.ts
CHANGED
|
@@ -36,4 +36,4 @@ export type DynamicStyleResult = {
|
|
|
36
36
|
prop: string;
|
|
37
37
|
}>>;
|
|
38
38
|
};
|
|
39
|
-
export declare const resolveDynamicStyle: (func: StyleFunction, runtimeParams: string[], staticTable: StaticTable, tables: DynamicStyleTables) => DynamicStyleResult | null;
|
|
39
|
+
export declare const resolveDynamicStyle: (func: StyleFunction, runtimeParams: string[], staticTable: StaticTable, tables: DynamicStyleTables, providedParams?: ReadonlySet<string>) => DynamicStyleResult | null;
|
package/dist/dynamicKey.js
CHANGED
|
@@ -143,12 +143,14 @@ const applyVarFallback = (style, cssVar, literal) => {
|
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
exports.applyVarFallback = applyVarFallback;
|
|
146
|
-
const resolveDynamicStyle = (func, runtimeParams, staticTable, tables) => {
|
|
146
|
+
const resolveDynamicStyle = (func, runtimeParams, staticTable, tables, providedParams) => {
|
|
147
147
|
if (func.unsupportedParams)
|
|
148
148
|
throw new Error('[plumeria] Dynamic styles require named parameters or object destructuring; array and rest parameters are not supported.');
|
|
149
149
|
const tempStaticTable = { ...staticTable };
|
|
150
150
|
const resolveBody = () => (0, parser_1.objectExpressionToObject)(func.body, tempStaticTable, tables.keyframesHashTable, tables.viewTransitionHashTable, tables.createThemeHashTable, tables.createThemeObjectTable, tables.createHashTable, tables.createStaticHashTable, tables.createStaticObjectTable, tables.variantsHashTable);
|
|
151
|
-
const withDefault = Object.entries(func.defaults ?? {}).filter(([param]) =>
|
|
151
|
+
const withDefault = Object.entries(func.defaults ?? {}).filter(([param]) => providedParams
|
|
152
|
+
? !providedParams.has(param)
|
|
153
|
+
: tempStaticTable[param] === undefined);
|
|
152
154
|
const cssVars = {};
|
|
153
155
|
const varParams = Array.from(new Set([...runtimeParams, ...withDefault.map(([param]) => param)]));
|
|
154
156
|
if (varParams.length > 0) {
|
package/dist/parser.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export declare function resolveFileError(actualPath: string, importedName: strin
|
|
|
42
42
|
filePath: string;
|
|
43
43
|
message: string;
|
|
44
44
|
} | undefined;
|
|
45
|
-
export declare function scanAll(): Tables;
|
|
45
|
+
export declare function scanAll(scanCwd?: string): Tables;
|
|
46
46
|
export declare function getFileDependencies(filePath: string): string[];
|
|
47
47
|
export declare function resolveExport(filePath: string, exportName: string, visited?: Set<string>): {
|
|
48
48
|
filePath: string;
|
package/dist/parser.js
CHANGED
|
@@ -95,9 +95,6 @@ const getRootIdentifier = (node) => {
|
|
|
95
95
|
return (0, exports.getRootIdentifier)(callee);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
if (node.type === 'ParenthesisExpression') {
|
|
99
|
-
return (0, exports.getRootIdentifier)(node.expression);
|
|
100
|
-
}
|
|
101
98
|
return null;
|
|
102
99
|
};
|
|
103
100
|
exports.getRootIdentifier = getRootIdentifier;
|
|
@@ -1024,6 +1021,7 @@ const globalAgregatedTables = {
|
|
|
1024
1021
|
};
|
|
1025
1022
|
let hasComputedOnce = false;
|
|
1026
1023
|
let resolutionConfigStamp;
|
|
1024
|
+
let scannedCwd;
|
|
1027
1025
|
const objectTableOwners = new Map();
|
|
1028
1026
|
const fileObjectContributions = new Map();
|
|
1029
1027
|
function snapshotTables() {
|
|
@@ -1152,12 +1150,16 @@ function stripFileContributions(filePath, cached) {
|
|
|
1152
1150
|
}
|
|
1153
1151
|
}
|
|
1154
1152
|
}
|
|
1155
|
-
function scanAll() {
|
|
1156
|
-
|
|
1153
|
+
function scanAll(scanCwd = process.cwd()) {
|
|
1154
|
+
const cwd = path.resolve(scanCwd);
|
|
1155
|
+
if (hasComputedOnce &&
|
|
1156
|
+
process.env.NODE_ENV === 'production' &&
|
|
1157
|
+
scannedCwd === cwd) {
|
|
1157
1158
|
return snapshotTables();
|
|
1158
1159
|
}
|
|
1159
1160
|
const localTables = globalAgregatedTables;
|
|
1160
|
-
|
|
1161
|
+
scannedCwd = cwd;
|
|
1162
|
+
const configPath = path.join(cwd, 'tsconfig.json');
|
|
1161
1163
|
let configStamp = configPath;
|
|
1162
1164
|
try {
|
|
1163
1165
|
configStamp += `:${fs.statSync(configPath).mtimeMs}`;
|
|
@@ -1166,10 +1168,9 @@ function scanAll() {
|
|
|
1166
1168
|
}
|
|
1167
1169
|
const resolutionChanged = resolutionConfigStamp !== undefined &&
|
|
1168
1170
|
resolutionConfigStamp !== configStamp;
|
|
1169
|
-
if (
|
|
1170
|
-
(0, resolver_1.resetImportResolutionCache)();
|
|
1171
|
+
if (resolutionConfigStamp !== configStamp)
|
|
1172
|
+
(0, resolver_1.resetImportResolutionCache)(cwd);
|
|
1171
1173
|
resolutionConfigStamp = configStamp;
|
|
1172
|
-
const cwd = process.cwd();
|
|
1173
1174
|
const segments = cwd.split(path.sep);
|
|
1174
1175
|
const dependencyDirectory = segments.indexOf('node_modules');
|
|
1175
1176
|
const root = dependencyDirectory < 0
|
|
@@ -1771,7 +1772,7 @@ function scanAll() {
|
|
|
1771
1772
|
runtime.push(param);
|
|
1772
1773
|
});
|
|
1773
1774
|
}
|
|
1774
|
-
const resolved = (0, dynamicKey_1.resolveDynamicStyle)(func, runtime, dynamicStaticTable, dynamicStyleTables);
|
|
1775
|
+
const resolved = (0, dynamicKey_1.resolveDynamicStyle)(func, runtime, dynamicStaticTable, dynamicStyleTables, new Set());
|
|
1775
1776
|
if (!resolved)
|
|
1776
1777
|
return null;
|
|
1777
1778
|
const hasVars = runtime.some((param) => (resolved.varGroups.get(param) ?? []).length > 0);
|
|
@@ -1786,6 +1787,8 @@ function scanAll() {
|
|
|
1786
1787
|
let hasVars = false;
|
|
1787
1788
|
for (const el of expr.elements) {
|
|
1788
1789
|
if (el && el.expression) {
|
|
1790
|
+
if (el.spread)
|
|
1791
|
+
return null;
|
|
1789
1792
|
const res = resolveCallStylePropInScan(el.expression);
|
|
1790
1793
|
if (!res)
|
|
1791
1794
|
continue;
|
|
@@ -1829,9 +1832,6 @@ function scanAll() {
|
|
|
1829
1832
|
}
|
|
1830
1833
|
}
|
|
1831
1834
|
}
|
|
1832
|
-
if (expr.type === 'ParenthesisExpression') {
|
|
1833
|
-
return resolveCallStylePropInScan(expr.expression);
|
|
1834
|
-
}
|
|
1835
1835
|
if (expr.type === 'MemberExpression' &&
|
|
1836
1836
|
expr.object.type === 'Identifier') {
|
|
1837
1837
|
const varName = expr.object.value;
|
|
@@ -1965,6 +1965,8 @@ function scanAll() {
|
|
|
1965
1965
|
if (!alternatives) {
|
|
1966
1966
|
if (!containsStyleReference(node))
|
|
1967
1967
|
return;
|
|
1968
|
+
if (node.elements.some((element) => element?.spread))
|
|
1969
|
+
throw new Error('[plumeria] Spread elements in a style array are not supported. List each style explicitly.');
|
|
1968
1970
|
throw new Error('[plumeria] A style prop array contains an unsupported style expression. Use defined styles, null, false, undefined, or conditional branches of defined styles.');
|
|
1969
1971
|
}
|
|
1970
1972
|
if (!containsStyleReference(node))
|
package/dist/resolver.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function resetImportResolutionCache(): void;
|
|
1
|
+
export declare function resetImportResolutionCache(cwd?: string): void;
|
|
2
2
|
export declare function resolveImportPath(importPath: string, importerPath: string): string | null;
|
package/dist/resolver.js
CHANGED
|
@@ -38,8 +38,8 @@ exports.resolveImportPath = resolveImportPath;
|
|
|
38
38
|
const fs = __importStar(require("fs"));
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
40
|
let cachedTsConfig = undefined;
|
|
41
|
-
function resetImportResolutionCache() {
|
|
42
|
-
const configPath = path.join(
|
|
41
|
+
function resetImportResolutionCache(cwd = process.cwd()) {
|
|
42
|
+
const configPath = path.join(cwd, 'tsconfig.json');
|
|
43
43
|
try {
|
|
44
44
|
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
45
45
|
cachedTsConfig = {
|