@plumeria/utils 19.15.0 → 21.0.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/compile.js +112 -13
- package/dist/dynamicKey.d.ts +2 -1
- package/dist/dynamicKey.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/parser.d.ts +3 -2
- package/dist/parser.js +133 -54
- package/dist/positionTry.d.ts +4 -0
- package/dist/positionTry.js +7 -0
- package/dist/propertyPolicy.js +10 -1
- package/dist/transform.js +190 -26
- package/dist/types.d.ts +3 -0
- package/dist/viewTransition.js +4 -4
- package/package.json +2 -2
package/dist/compile.js
CHANGED
|
@@ -44,6 +44,7 @@ const index_1 = require("./index");
|
|
|
44
44
|
const index_2 = require("./index");
|
|
45
45
|
const dynamicKey_1 = require("./dynamicKey");
|
|
46
46
|
const varType_1 = require("./varType");
|
|
47
|
+
const references_1 = require("./references");
|
|
47
48
|
const unwrapExport = (node) => {
|
|
48
49
|
if (node?.type === 'ExportDeclaration')
|
|
49
50
|
return node.declaration;
|
|
@@ -128,6 +129,7 @@ const dynamicTablesOf = (ctx) => ({
|
|
|
128
129
|
keyframesHashTable: ctx.mergedKeyframesTable,
|
|
129
130
|
viewTransitionHashTable: ctx.mergedViewTransitionTable,
|
|
130
131
|
varTypeHashTable: ctx.mergedVarTypeTable,
|
|
132
|
+
positionTryHashTable: ctx.mergedPositionTryTable,
|
|
131
133
|
createThemeHashTable: ctx.mergedCreateThemeHashTable,
|
|
132
134
|
createThemeObjectTable: ctx.scannedTables.createThemeObjectTable,
|
|
133
135
|
createHashTable: ctx.mergedCreateTable,
|
|
@@ -263,6 +265,8 @@ const applyWrites = (tables, writes) => {
|
|
|
263
265
|
const sheetCache = new Map();
|
|
264
266
|
let sheetCacheContext = '';
|
|
265
267
|
let sheetGlobals = '';
|
|
268
|
+
const VIEW_TRANSITION_ELEMENTS = ['ViewTransition', 'unstable_ViewTransition'];
|
|
269
|
+
const VIEW_TRANSITION_PROPS = ['default', 'enter', 'exit', 'update', 'share'];
|
|
266
270
|
function compileCSS(options) {
|
|
267
271
|
const { include, exclude, cwd = process.cwd(), styleProp = index_1.DEFAULT_STYLE_PROP, } = options;
|
|
268
272
|
const propertyPolicy = (0, index_1.resolvePropertyPolicy)(options);
|
|
@@ -348,6 +352,7 @@ function compileCSS(options) {
|
|
|
348
352
|
const keyframesImportMap = {};
|
|
349
353
|
const viewTransitionImportMap = {};
|
|
350
354
|
const varTypeImportMap = {};
|
|
355
|
+
const positionTryImportMap = {};
|
|
351
356
|
const createImportMap = {};
|
|
352
357
|
const createFunctionImportMap = {};
|
|
353
358
|
const createThemeImportMap = {};
|
|
@@ -356,9 +361,30 @@ function compileCSS(options) {
|
|
|
356
361
|
const localImports = {};
|
|
357
362
|
const localStyleAliases = {};
|
|
358
363
|
const registeredStyleCalls = new Set();
|
|
364
|
+
const viewTransitionElements = new Set();
|
|
365
|
+
const reactNamespaces = new Set();
|
|
359
366
|
(0, index_1.traverse)(ast, {
|
|
360
367
|
ImportDeclaration({ node }) {
|
|
361
368
|
const sourcePath = node.source.value;
|
|
369
|
+
if (sourcePath === 'react') {
|
|
370
|
+
if (node.typeOnly)
|
|
371
|
+
return;
|
|
372
|
+
node.specifiers.forEach((specifier) => {
|
|
373
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
374
|
+
const importedName = specifier.imported
|
|
375
|
+
? specifier.imported.value
|
|
376
|
+
: specifier.local.value;
|
|
377
|
+
if (!specifier.isTypeOnly &&
|
|
378
|
+
VIEW_TRANSITION_ELEMENTS.includes(importedName)) {
|
|
379
|
+
viewTransitionElements.add(specifier.local.value);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
reactNamespaces.add(specifier.local.value);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
362
388
|
if (sourcePath === '@plumeria/core') {
|
|
363
389
|
node.specifiers.forEach((specifier) => {
|
|
364
390
|
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
@@ -412,6 +438,9 @@ function compileCSS(options) {
|
|
|
412
438
|
if (scannedTables.varTypeHashTable?.[uniqueKey])
|
|
413
439
|
varTypeImportMap[localName] =
|
|
414
440
|
scannedTables.varTypeHashTable[uniqueKey];
|
|
441
|
+
if (scannedTables.positionTryHashTable?.[uniqueKey])
|
|
442
|
+
positionTryImportMap[localName] =
|
|
443
|
+
scannedTables.positionTryHashTable[uniqueKey];
|
|
415
444
|
if (scannedTables.createHashTable[uniqueKey])
|
|
416
445
|
createImportMap[localName] =
|
|
417
446
|
scannedTables.createHashTable[uniqueKey];
|
|
@@ -461,6 +490,16 @@ function compileCSS(options) {
|
|
|
461
490
|
for (const key of Object.keys(varTypeImportMap)) {
|
|
462
491
|
mergedVarTypeTable[key] = varTypeImportMap[key];
|
|
463
492
|
}
|
|
493
|
+
const positionTryHashTable = scannedTables.positionTryHashTable ?? {};
|
|
494
|
+
const mergedPositionTryTable = Object.create(positionTryHashTable);
|
|
495
|
+
for (const key of (0, index_1.fileTableKeys)(resourcePath, 'positionTryHashTable') ??
|
|
496
|
+
[]) {
|
|
497
|
+
mergedPositionTryTable[key.slice(resourcePath.length + 1)] =
|
|
498
|
+
positionTryHashTable[key];
|
|
499
|
+
}
|
|
500
|
+
for (const key of Object.keys(positionTryImportMap)) {
|
|
501
|
+
mergedPositionTryTable[key] = positionTryImportMap[key];
|
|
502
|
+
}
|
|
464
503
|
const mergedCreateThemeHashTable = Object.create(scannedTables.createThemeHashTable);
|
|
465
504
|
for (const key of (0, index_1.fileTableKeys)(resourcePath, 'createThemeHashTable') ??
|
|
466
505
|
[]) {
|
|
@@ -493,6 +532,7 @@ function compileCSS(options) {
|
|
|
493
532
|
mergedKeyframesTable,
|
|
494
533
|
mergedViewTransitionTable,
|
|
495
534
|
mergedVarTypeTable,
|
|
535
|
+
mergedPositionTryTable,
|
|
496
536
|
mergedCreateThemeHashTable,
|
|
497
537
|
mergedCreateStaticHashTable,
|
|
498
538
|
mergedCreateTable,
|
|
@@ -589,6 +629,54 @@ function compileCSS(options) {
|
|
|
589
629
|
}
|
|
590
630
|
const ownerComponentOf = (at) => components.find((c) => at.span.start >= c.node.span.start &&
|
|
591
631
|
at.span.start <= c.node.span.end)?.name;
|
|
632
|
+
const isViewTransition = (name) => name.type === 'Identifier'
|
|
633
|
+
? viewTransitionElements.has(name.value)
|
|
634
|
+
: name.type === 'JSXMemberExpression' &&
|
|
635
|
+
name.object.type === 'Identifier' &&
|
|
636
|
+
reactNamespaces.has(name.object.value) &&
|
|
637
|
+
VIEW_TRANSITION_ELEMENTS.includes(name.property.value);
|
|
638
|
+
let viewTransitionReferences;
|
|
639
|
+
const processViewTransitionClass = (expr) => {
|
|
640
|
+
switch (expr.type) {
|
|
641
|
+
case 'ParenthesisExpression':
|
|
642
|
+
case 'TsAsExpression':
|
|
643
|
+
case 'TsSatisfiesExpression':
|
|
644
|
+
case 'TsNonNullExpression':
|
|
645
|
+
return processViewTransitionClass(expr.expression);
|
|
646
|
+
case 'ConditionalExpression':
|
|
647
|
+
processViewTransitionClass(expr.consequent);
|
|
648
|
+
return processViewTransitionClass(expr.alternate);
|
|
649
|
+
case 'TemplateLiteral':
|
|
650
|
+
return expr.expressions.forEach(processViewTransitionClass);
|
|
651
|
+
case 'BinaryExpression':
|
|
652
|
+
if (['&&', '||', '??'].includes(expr.operator)) {
|
|
653
|
+
processViewTransitionClass(expr.left);
|
|
654
|
+
processViewTransitionClass(expr.right);
|
|
655
|
+
}
|
|
656
|
+
return;
|
|
657
|
+
case 'ObjectExpression':
|
|
658
|
+
expr.properties.forEach((property) => {
|
|
659
|
+
if (property.type === 'KeyValueProperty') {
|
|
660
|
+
processViewTransitionClass(property.value);
|
|
661
|
+
}
|
|
662
|
+
else if (property.type === 'Identifier') {
|
|
663
|
+
processViewTransitionClass(property);
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
return;
|
|
667
|
+
case 'Identifier': {
|
|
668
|
+
viewTransitionReferences ??=
|
|
669
|
+
(0, references_1.collectReferenceIdentifiers)(ast).references;
|
|
670
|
+
if (!viewTransitionReferences.has(expr.span.start))
|
|
671
|
+
return;
|
|
672
|
+
const hash = mergedViewTransitionTable[expr.value];
|
|
673
|
+
if (typeof hash === 'string' && hash) {
|
|
674
|
+
(0, index_1.extractOndemandStyles)({ viewTransitionClass: `vt-${hash}` }, (0, index_1.appendSheet)(extractedSheets), scannedTables);
|
|
675
|
+
}
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
};
|
|
592
680
|
const processStyle = (style) => {
|
|
593
681
|
(0, index_1.extractOndemandStyles)(style, (0, index_1.appendSheet)(extractedSheets), scannedTables);
|
|
594
682
|
const records = (0, index_1.getStyleRecords)(style);
|
|
@@ -617,7 +705,7 @@ function compileCSS(options) {
|
|
|
617
705
|
return merged;
|
|
618
706
|
}
|
|
619
707
|
if (index_1.t.isObjectExpression(expr)) {
|
|
620
|
-
return (0, index_1.objectExpressionToObject)(expr, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable);
|
|
708
|
+
return (0, index_1.objectExpressionToObject)(expr, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable, ctx.mergedPositionTryTable);
|
|
621
709
|
}
|
|
622
710
|
else if (index_1.t.isMemberExpression(expr) &&
|
|
623
711
|
index_1.t.isIdentifier(expr.object) &&
|
|
@@ -731,7 +819,7 @@ function compileCSS(options) {
|
|
|
731
819
|
properties: argExpr.properties.filter((prop) => prop.type === 'Identifier' ||
|
|
732
820
|
(prop.type === 'KeyValueProperty' &&
|
|
733
821
|
isStaticArgValue(prop.value))),
|
|
734
|
-
}, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable);
|
|
822
|
+
}, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable, ctx.mergedPositionTryTable);
|
|
735
823
|
if (func.named) {
|
|
736
824
|
const argExpr = callArgs[0]?.expression;
|
|
737
825
|
if (callArgs.length > 1 ||
|
|
@@ -1019,14 +1107,14 @@ function compileCSS(options) {
|
|
|
1019
1107
|
else if (propName === 'keyframes' &&
|
|
1020
1108
|
args.length > 0 &&
|
|
1021
1109
|
index_1.t.isObjectExpression(args[0].expression)) {
|
|
1022
|
-
const obj = (0, index_1.objectExpressionToObject)(args[0].expression, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable);
|
|
1110
|
+
const obj = (0, index_1.objectExpressionToObject)(args[0].expression, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable, ctx.mergedPositionTryTable);
|
|
1023
1111
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
1024
1112
|
writes.keyframesObjectTable[hash] = obj;
|
|
1025
1113
|
}
|
|
1026
|
-
else if (propName === '
|
|
1114
|
+
else if (propName === 'viewTransitionClass' &&
|
|
1027
1115
|
args.length > 0 &&
|
|
1028
1116
|
index_1.t.isObjectExpression(args[0].expression)) {
|
|
1029
|
-
const obj = (0, index_1.objectExpressionToObject)(args[0].expression, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable);
|
|
1117
|
+
const obj = (0, index_1.objectExpressionToObject)(args[0].expression, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable, ctx.mergedPositionTryTable);
|
|
1030
1118
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
1031
1119
|
writes.viewTransitionObjectTable[hash] = obj;
|
|
1032
1120
|
}
|
|
@@ -1041,9 +1129,9 @@ function compileCSS(options) {
|
|
|
1041
1129
|
}
|
|
1042
1130
|
if (selector.startsWith('@') && !(0, zss_engine_1.isAtRule)(selector)) {
|
|
1043
1131
|
throw new Error(`[plumeria] Unsupported at-rule: "${selector}". createTheme only supports ` +
|
|
1044
|
-
`nesting at-rules such as @media, @container,
|
|
1132
|
+
`nesting at-rules such as @media, @container, and @supports. (${path.basename(resourcePath)})`);
|
|
1045
1133
|
}
|
|
1046
|
-
const obj = (0, index_1.objectExpressionToObject)(args[1].expression, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable);
|
|
1134
|
+
const obj = (0, index_1.objectExpressionToObject)(args[1].expression, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable, ctx.mergedPositionTryTable);
|
|
1047
1135
|
const hash = (0, index_1.themeHashOf)(selector, obj);
|
|
1048
1136
|
writes.createThemeObjectTable[hash] = obj;
|
|
1049
1137
|
if (ctx.scannedTables.createThemeSelectorTable) {
|
|
@@ -1053,7 +1141,7 @@ function compileCSS(options) {
|
|
|
1053
1141
|
else if (propName === 'createStatic' &&
|
|
1054
1142
|
args.length > 0 &&
|
|
1055
1143
|
index_1.t.isObjectExpression(args[0].expression)) {
|
|
1056
|
-
const obj = (0, index_1.objectExpressionToObject)(args[0].expression, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable);
|
|
1144
|
+
const obj = (0, index_1.objectExpressionToObject)(args[0].expression, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable, ctx.mergedPositionTryTable);
|
|
1057
1145
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
1058
1146
|
writes.createStaticObjectTable[hash] = obj;
|
|
1059
1147
|
}
|
|
@@ -1104,7 +1192,7 @@ function compileCSS(options) {
|
|
|
1104
1192
|
? ctx.scannedTables.createAtomicMapTable[ctx.mergedCreateThemeHashTable[name]]
|
|
1105
1193
|
: undefined);
|
|
1106
1194
|
if (pName === 'create') {
|
|
1107
|
-
const obj = (0, index_1.objectExpressionToObject)(arg, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, resolveVariable, ctx.mergedVarTypeTable);
|
|
1195
|
+
const obj = (0, index_1.objectExpressionToObject)(arg, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, resolveVariable, ctx.mergedVarTypeTable, ctx.mergedPositionTryTable);
|
|
1108
1196
|
if (obj) {
|
|
1109
1197
|
const styleFunctions = (0, index_1.styleFunctionsOf)(arg);
|
|
1110
1198
|
ctx.localCreateStyles[node.id.value] = {
|
|
@@ -1123,9 +1211,9 @@ function compileCSS(options) {
|
|
|
1123
1211
|
}
|
|
1124
1212
|
if (selector.startsWith('@') && !(0, zss_engine_1.isAtRule)(selector)) {
|
|
1125
1213
|
throw new Error(`[plumeria] Unsupported at-rule: "${selector}". createTheme only supports ` +
|
|
1126
|
-
`nesting at-rules such as @media, @container,
|
|
1214
|
+
`nesting at-rules such as @media, @container, and @supports. (${path.basename(resourcePath)})`);
|
|
1127
1215
|
}
|
|
1128
|
-
const obj = (0, index_1.objectExpressionToObject)(arg, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable);
|
|
1216
|
+
const obj = (0, index_1.objectExpressionToObject)(arg, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable, ctx.mergedPositionTryTable);
|
|
1129
1217
|
const hash = (0, index_1.themeHashOf)(selector, obj);
|
|
1130
1218
|
const uKey = `${resourcePath}-${node.id.value}`;
|
|
1131
1219
|
writes.createThemeHashTable[uKey] = hash;
|
|
@@ -1146,11 +1234,11 @@ function compileCSS(options) {
|
|
|
1146
1234
|
};
|
|
1147
1235
|
}
|
|
1148
1236
|
else if (pName === 'varType') {
|
|
1149
|
-
const obj = (0, index_1.objectExpressionToObject)(arg, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable);
|
|
1237
|
+
const obj = (0, index_1.objectExpressionToObject)(arg, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable, ctx.mergedPositionTryTable);
|
|
1150
1238
|
ctx.mergedVarTypeTable[node.id.value] = (0, varType_1.checkedVarTypeHash)(node.id.value, obj);
|
|
1151
1239
|
}
|
|
1152
1240
|
else if (pName === 'createStatic') {
|
|
1153
|
-
const obj = (0, index_1.objectExpressionToObject)(arg, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable);
|
|
1241
|
+
const obj = (0, index_1.objectExpressionToObject)(arg, ctx.mergedStaticTable, ctx.mergedKeyframesTable, ctx.mergedViewTransitionTable, ctx.mergedCreateThemeHashTable, ctx.scannedTables.createThemeObjectTable, ctx.mergedCreateTable, ctx.mergedCreateStaticHashTable, ctx.scannedTables.createStaticObjectTable, undefined, ctx.mergedVarTypeTable, ctx.mergedPositionTryTable);
|
|
1154
1242
|
if (obj) {
|
|
1155
1243
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
1156
1244
|
const uKey = `${resourcePath}-${node.id.value}`;
|
|
@@ -1190,6 +1278,17 @@ function compileCSS(options) {
|
|
|
1190
1278
|
processCall(path.node);
|
|
1191
1279
|
},
|
|
1192
1280
|
JSXOpeningElement({ node }) {
|
|
1281
|
+
if (isViewTransition(node.name)) {
|
|
1282
|
+
node.attributes.forEach((attr) => {
|
|
1283
|
+
if (attr.type === 'JSXAttribute' &&
|
|
1284
|
+
attr.name.type === 'Identifier' &&
|
|
1285
|
+
VIEW_TRANSITION_PROPS.includes(attr.name.value) &&
|
|
1286
|
+
attr.value?.type === 'JSXExpressionContainer' &&
|
|
1287
|
+
attr.value.expression.type !== 'JSXEmptyExpression') {
|
|
1288
|
+
processViewTransitionClass(attr.value.expression);
|
|
1289
|
+
}
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1193
1292
|
if (node.name.type === 'Identifier') {
|
|
1194
1293
|
const tagName = node.name.value;
|
|
1195
1294
|
if (tagName[0] !== tagName[0].toUpperCase())
|
package/dist/dynamicKey.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Expression, ObjectExpression } from '@swc/core';
|
|
2
|
-
import type { CSSObject, StaticTable, KeyframesHashTable, ViewTransitionHashTable, VarTypeHashTable, CreateHashTable, CreateThemeHashTable, CreateThemeObjectTable, CreateStaticHashTable, CreateStaticObjectTable } from './types';
|
|
2
|
+
import type { CSSObject, StaticTable, KeyframesHashTable, ViewTransitionHashTable, VarTypeHashTable, PositionTryHashTable, CreateHashTable, CreateThemeHashTable, CreateThemeObjectTable, CreateStaticHashTable, CreateStaticObjectTable } from './types';
|
|
3
3
|
export type NamedParam = {
|
|
4
4
|
key: string;
|
|
5
5
|
local: string;
|
|
@@ -30,6 +30,7 @@ export type DynamicStyleTables = {
|
|
|
30
30
|
keyframesHashTable: KeyframesHashTable;
|
|
31
31
|
viewTransitionHashTable: ViewTransitionHashTable;
|
|
32
32
|
varTypeHashTable?: VarTypeHashTable;
|
|
33
|
+
positionTryHashTable?: PositionTryHashTable;
|
|
33
34
|
createThemeHashTable: CreateThemeHashTable;
|
|
34
35
|
createThemeObjectTable: CreateThemeObjectTable;
|
|
35
36
|
createHashTable: CreateHashTable;
|
package/dist/dynamicKey.js
CHANGED
|
@@ -381,7 +381,7 @@ const resolveDynamicStyle = (func, runtimeParams, staticTable, tables, providedP
|
|
|
381
381
|
value: expr,
|
|
382
382
|
},
|
|
383
383
|
],
|
|
384
|
-
}, table, tables.keyframesHashTable, tables.viewTransitionHashTable, tables.createThemeHashTable, tables.createThemeObjectTable, tables.createHashTable, tables.createStaticHashTable, tables.createStaticObjectTable, undefined, tables.varTypeHashTable).value;
|
|
384
|
+
}, table, tables.keyframesHashTable, tables.viewTransitionHashTable, tables.createThemeHashTable, tables.createThemeObjectTable, tables.createHashTable, tables.createStaticHashTable, tables.createStaticObjectTable, undefined, tables.varTypeHashTable, tables.positionTryHashTable).value;
|
|
385
385
|
const withDefault = Object.entries(func.defaults ?? {}).filter(([param]) => providedParams
|
|
386
386
|
? !providedParams.has(param)
|
|
387
387
|
: tempStaticTable[param] === undefined);
|
|
@@ -424,7 +424,7 @@ const resolveDynamicStyle = (func, runtimeParams, staticTable, tables, providedP
|
|
|
424
424
|
return undefined;
|
|
425
425
|
}
|
|
426
426
|
});
|
|
427
|
-
const resolveBody = () => (0, parser_1.objectExpressionToObject)(body, tempStaticTable, tables.keyframesHashTable, tables.viewTransitionHashTable, tables.createThemeHashTable, tables.createThemeObjectTable, tables.createHashTable, tables.createStaticHashTable, tables.createStaticObjectTable, undefined, tables.varTypeHashTable);
|
|
427
|
+
const resolveBody = () => (0, parser_1.objectExpressionToObject)(body, tempStaticTable, tables.keyframesHashTable, tables.viewTransitionHashTable, tables.createThemeHashTable, tables.createThemeObjectTable, tables.createHashTable, tables.createStaticHashTable, tables.createStaticObjectTable, undefined, tables.varTypeHashTable, tables.positionTryHashTable);
|
|
428
428
|
const varNames = [...varParams, ...derived.map(({ name }) => name)];
|
|
429
429
|
if (varNames.length > 0) {
|
|
430
430
|
varNames.forEach((name) => (tempStaticTable[name] = name));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { CSSObject, StaticTable, KeyframesHashTable, ViewTransitionHashTable, VarTypeHashTable, CreateHashTable, CreateFunctionTable, CreateThemeHashTable, CreateStaticHashTable, } from './types';
|
|
1
|
+
export type { CSSObject, StaticTable, KeyframesHashTable, ViewTransitionHashTable, VarTypeHashTable, PositionTryHashTable, CreateHashTable, CreateFunctionTable, CreateThemeHashTable, CreateStaticHashTable, } from './types';
|
|
2
2
|
export { objectExpressionToObject, collectLocalConsts, traverse, t, getRootIdentifier, resolveOriginError, unwrapExpression, extractOndemandStyles, appendSheet, deepMerge, scanAll, scanOverlay, fileTableKeys, resolveFileError, getFileDependencies, resolveExport, resolveComponentKey, resolveThemeSelector, } from './parser';
|
|
3
3
|
export { resolveExportValue } from './constValue';
|
|
4
4
|
export type { StyleRecord } from './create';
|
package/dist/parser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSSObject, Tables, StaticTable, KeyframesHashTable, ViewTransitionHashTable, VarTypeHashTable, CreateHashTable, CreateThemeHashTable, CreateThemeObjectTable, CreateStaticHashTable, CreateStaticObjectTable, SheetSink } from './types';
|
|
1
|
+
import type { CSSObject, Tables, StaticTable, KeyframesHashTable, ViewTransitionHashTable, VarTypeHashTable, PositionTryHashTable, CreateHashTable, CreateThemeHashTable, CreateThemeObjectTable, CreateStaticHashTable, CreateStaticObjectTable, SheetSink } from './types';
|
|
2
2
|
import type { Module, Expression, CallExpression, Identifier, KeyValueProperty, StringLiteral, NumericLiteral, BooleanLiteral, ObjectExpression, MemberExpression, TemplateLiteral, BinaryExpression, UnaryExpression, ParenthesisExpression, VariableDeclaration, VariableDeclarator, ExportDeclaration, ConditionalExpression, JSXExpression, ArrowFunctionExpression, FunctionExpression } from '@swc/core';
|
|
3
3
|
export declare function unwrapExpression(node: any): any;
|
|
4
4
|
export declare const getRootIdentifier: (node: Expression) => string | null;
|
|
@@ -43,7 +43,7 @@ export declare function traverse(node: Module | JSXExpression, visitor: {
|
|
|
43
43
|
stop: () => void;
|
|
44
44
|
}) => void;
|
|
45
45
|
}): void;
|
|
46
|
-
export declare function objectExpressionToObject(node: ObjectExpression, staticTable: StaticTable, keyframesHashTable: KeyframesHashTable, viewTransitionHashTable: ViewTransitionHashTable, createThemeHashTable: CreateThemeHashTable, createThemeObjectTable: CreateThemeObjectTable, createHashTable: CreateHashTable, createStaticHashTable: CreateStaticHashTable, createStaticObjectTable: CreateStaticObjectTable, resolveVariable?: (name: string) => any, varTypeHashTable?: VarTypeHashTable): CSSObject;
|
|
46
|
+
export declare function objectExpressionToObject(node: ObjectExpression, staticTable: StaticTable, keyframesHashTable: KeyframesHashTable, viewTransitionHashTable: ViewTransitionHashTable, createThemeHashTable: CreateThemeHashTable, createThemeObjectTable: CreateThemeObjectTable, createHashTable: CreateHashTable, createStaticHashTable: CreateStaticHashTable, createStaticObjectTable: CreateStaticObjectTable, resolveVariable?: (name: string) => any, varTypeHashTable?: VarTypeHashTable, positionTryHashTable?: PositionTryHashTable): CSSObject;
|
|
47
47
|
export declare function collectLocalConstNodes(ast: Module): Map<string, any>;
|
|
48
48
|
export declare function collectLocalConsts(ast: Module): Record<string, any>;
|
|
49
49
|
export declare function readsParams(node: any, params: Set<string>): boolean;
|
|
@@ -58,6 +58,7 @@ export declare function fileTableKeys(filePath: string, tableName: string): Read
|
|
|
58
58
|
export declare function scanOverlay(scanCwd?: string, styleProp?: string): Tables;
|
|
59
59
|
export declare function scanAll(scanCwd?: string, styleProp?: string): Tables;
|
|
60
60
|
export declare function getFileDependencies(filePath: string): string[];
|
|
61
|
+
export declare function exportNames(filePath: string, withDefault?: boolean, visited?: Set<string>): string[];
|
|
61
62
|
export declare function resolveExport(filePath: string, exportName: string, visited?: Set<string>): {
|
|
62
63
|
filePath: string;
|
|
63
64
|
localName: string;
|