@plumeria/utils 19.1.0 → 19.1.2
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 +5 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/parser.js +0 -2
- package/dist/references.js +4 -4
- package/dist/transform.d.ts +17 -0
- package/dist/transform.js +2286 -0
- package/package.json +1 -1
package/dist/dynamicKey.d.ts
CHANGED
|
@@ -35,4 +35,4 @@ export type DynamicStyleResult = {
|
|
|
35
35
|
prop: string;
|
|
36
36
|
}>>;
|
|
37
37
|
};
|
|
38
|
-
export declare const resolveDynamicStyle: (func: StyleFunction, runtimeParams: string[], staticTable: StaticTable, tables: DynamicStyleTables, providedParams?: ReadonlySet<string>) => DynamicStyleResult
|
|
38
|
+
export declare const resolveDynamicStyle: (func: StyleFunction, runtimeParams: string[], staticTable: StaticTable, tables: DynamicStyleTables, providedParams?: ReadonlySet<string>) => DynamicStyleResult;
|
package/dist/dynamicKey.js
CHANGED
|
@@ -155,7 +155,7 @@ const resolveDynamicStyle = (func, runtimeParams, staticTable, tables, providedP
|
|
|
155
155
|
const varParams = Array.from(new Set([...runtimeParams, ...withDefault.map(([param]) => param)]));
|
|
156
156
|
if (varParams.length > 0) {
|
|
157
157
|
varParams.forEach((param) => (tempStaticTable[param] = param));
|
|
158
|
-
const hash = (0, zss_engine_2.genBase36Hash)(resolveBody()
|
|
158
|
+
const hash = (0, zss_engine_2.genBase36Hash)(resolveBody(), 1, 8);
|
|
159
159
|
varParams.forEach((param) => {
|
|
160
160
|
const cssVar = `--${hash}-${param}`;
|
|
161
161
|
tempStaticTable[param] = `var(${cssVar})`;
|
|
@@ -163,13 +163,10 @@ const resolveDynamicStyle = (func, runtimeParams, staticTable, tables, providedP
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
const style = resolveBody();
|
|
166
|
-
if (!style)
|
|
167
|
-
return null;
|
|
168
166
|
const varGroups = new Map();
|
|
169
167
|
varParams.forEach((param) => {
|
|
170
168
|
const cssVar = cssVars[param];
|
|
171
|
-
|
|
172
|
-
varGroups.set(param, (0, exports.splitVarByUnit)(style, cssVar));
|
|
169
|
+
varGroups.set(param, (0, exports.splitVarByUnit)(style, cssVar));
|
|
173
170
|
});
|
|
174
171
|
withDefault.forEach(([param, expr]) => {
|
|
175
172
|
const resolved = (0, parser_1.objectExpressionToObject)({
|
|
@@ -191,7 +188,9 @@ const resolveDynamicStyle = (func, runtimeParams, staticTable, tables, providedP
|
|
|
191
188
|
const literal = resolved.value;
|
|
192
189
|
if (typeof literal !== 'string' && typeof literal !== 'number')
|
|
193
190
|
return;
|
|
194
|
-
|
|
191
|
+
varGroups
|
|
192
|
+
.get(param)
|
|
193
|
+
.forEach(({ cssVar }) => (0, exports.applyVarFallback)(style, cssVar, literal));
|
|
195
194
|
});
|
|
196
195
|
return { style, varGroups };
|
|
197
196
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -18,3 +18,5 @@ export { profiling, mark, measure, tally, timed, timedAsync } from './profiler';
|
|
|
18
18
|
export { DEFAULT_STYLE_PROP } from './constants';
|
|
19
19
|
export type { PropertyPolicy, PropertyPolicyOptions } from './propertyPolicy';
|
|
20
20
|
export { resolvePropertyPolicy, assertPropertyPolicy } from './propertyPolicy';
|
|
21
|
+
export type { TransformEnv, TransformOutput } from './transform';
|
|
22
|
+
export { transformSource } from './transform';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertPropertyPolicy = exports.resolvePropertyPolicy = exports.DEFAULT_STYLE_PROP = exports.timedAsync = exports.timed = exports.tally = exports.measure = exports.mark = exports.profiling = exports.collectReferenceIdentifiers = exports.getLeadingCommentLength = exports.optimizer = exports.resolveImportPath = exports.themeHashOf = exports.getStateWeights = exports.getPseudoElement = exports.getSpecificity = exports.resolveDynamicStyle = exports.applyVarFallback = exports.splitVarByUnit = exports.isUnitlessProp = exports.styleFunctionsOf = exports.getStyleRecords = exports.resolveThemeSelector = exports.resolveComponentKey = exports.resolveExport = exports.getFileDependencies = exports.resolveFileError = exports.scanAll = exports.deepMerge = exports.extractOndemandStyles = exports.unwrapExpression = exports.getRootIdentifier = exports.t = exports.traverse = exports.collectLocalConsts = exports.objectExpressionToObject = void 0;
|
|
3
|
+
exports.transformSource = exports.assertPropertyPolicy = exports.resolvePropertyPolicy = exports.DEFAULT_STYLE_PROP = exports.timedAsync = exports.timed = exports.tally = exports.measure = exports.mark = exports.profiling = exports.collectReferenceIdentifiers = exports.getLeadingCommentLength = exports.optimizer = exports.resolveImportPath = exports.themeHashOf = exports.getStateWeights = exports.getPseudoElement = exports.getSpecificity = exports.resolveDynamicStyle = exports.applyVarFallback = exports.splitVarByUnit = exports.isUnitlessProp = exports.styleFunctionsOf = exports.getStyleRecords = exports.resolveThemeSelector = exports.resolveComponentKey = exports.resolveExport = exports.getFileDependencies = exports.resolveFileError = exports.scanAll = exports.deepMerge = exports.extractOndemandStyles = exports.unwrapExpression = exports.getRootIdentifier = exports.t = exports.traverse = exports.collectLocalConsts = exports.objectExpressionToObject = void 0;
|
|
4
4
|
var parser_1 = require("./parser");
|
|
5
5
|
Object.defineProperty(exports, "objectExpressionToObject", { enumerable: true, get: function () { return parser_1.objectExpressionToObject; } });
|
|
6
6
|
Object.defineProperty(exports, "collectLocalConsts", { enumerable: true, get: function () { return parser_1.collectLocalConsts; } });
|
|
@@ -51,3 +51,5 @@ Object.defineProperty(exports, "DEFAULT_STYLE_PROP", { enumerable: true, get: fu
|
|
|
51
51
|
var propertyPolicy_1 = require("./propertyPolicy");
|
|
52
52
|
Object.defineProperty(exports, "resolvePropertyPolicy", { enumerable: true, get: function () { return propertyPolicy_1.resolvePropertyPolicy; } });
|
|
53
53
|
Object.defineProperty(exports, "assertPropertyPolicy", { enumerable: true, get: function () { return propertyPolicy_1.assertPropertyPolicy; } });
|
|
54
|
+
var transform_1 = require("./transform");
|
|
55
|
+
Object.defineProperty(exports, "transformSource", { enumerable: true, get: function () { return transform_1.transformSource; } });
|
package/dist/parser.js
CHANGED
|
@@ -1738,8 +1738,6 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
1738
1738
|
});
|
|
1739
1739
|
}
|
|
1740
1740
|
const resolved = (0, dynamicKey_1.resolveDynamicStyle)(func, runtime, dynamicStaticTable, dynamicStyleTables, new Set());
|
|
1741
|
-
if (!resolved)
|
|
1742
|
-
return null;
|
|
1743
1741
|
const hasVars = runtime.some((param) => (resolved.varGroups.get(param) ?? []).length > 0);
|
|
1744
1742
|
return { style: resolved.style, hasVars };
|
|
1745
1743
|
};
|
package/dist/references.js
CHANGED
|
@@ -118,15 +118,15 @@ const collectHoistedNames = (n, out) => {
|
|
|
118
118
|
n.forEach((c) => collectHoistedNames(c, out));
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
|
+
if (n.type === 'FunctionDeclaration') {
|
|
122
|
+
collectPatternNames(n.identifier, out);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
121
125
|
if (FUNCTION_TYPES.has(n.type))
|
|
122
126
|
return;
|
|
123
127
|
if (n.type === 'VariableDeclaration' && n.kind === 'var') {
|
|
124
128
|
n.declarations?.forEach((d) => collectPatternNames(d.id, out));
|
|
125
129
|
}
|
|
126
|
-
else if (n.type === 'FunctionDeclaration') {
|
|
127
|
-
collectPatternNames(n.identifier, out);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
130
|
for (const key in n) {
|
|
131
131
|
if (key === 'span')
|
|
132
132
|
continue;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PropertyPolicy } from './propertyPolicy';
|
|
2
|
+
export type TransformEnv = {
|
|
3
|
+
source: string;
|
|
4
|
+
moduleId: string;
|
|
5
|
+
filePath: string;
|
|
6
|
+
root: string;
|
|
7
|
+
styleProp: string;
|
|
8
|
+
propertyPolicy: PropertyPolicy | undefined;
|
|
9
|
+
isDev: boolean;
|
|
10
|
+
collectOndemandSheets: boolean;
|
|
11
|
+
addDependency: (depPath: string) => void;
|
|
12
|
+
};
|
|
13
|
+
export type TransformOutput = {
|
|
14
|
+
code: string;
|
|
15
|
+
sheets: string[];
|
|
16
|
+
};
|
|
17
|
+
export declare const transformSource: (env: TransformEnv) => Promise<TransformOutput>;
|