@plumeria/utils 6.2.0 → 6.2.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/index.d.ts +1 -1
- package/dist/parser.d.ts +3 -4
- package/dist/parser.js +402 -295
- package/dist/types.d.ts +6 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { CSSObject, FileStyles, StaticTable,
|
|
1
|
+
export type { CSSObject, FileStyles, StaticTable, KeyframesHashTable, KeyframesObjectTable, ViewTransitionHashTable, ViewTransitionObjectTable, CreateThemeObjectTable, CreateHashTable, CreateObjectTable, VariantsHashTable, VariantsObjectTable, CreateThemeHashTable, CreateStaticHashTable, CreateStaticObjectTable, } from './types';
|
|
2
2
|
export { objectExpressionToObject, collectLocalConsts, traverse, t, extractOndemandStyles, deepMerge, scanAll, } from './parser';
|
|
3
3
|
export { getStyleRecords } from './create';
|
|
4
4
|
export type { StyleRecord } from './create';
|
package/dist/parser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSSObject,
|
|
1
|
+
import type { CSSObject, Tables, StaticTable, KeyframesHashTable, ViewTransitionHashTable, CreateThemeObjectTable, CreateHashTable, VariantsHashTable, CreateThemeHashTable, CreateStaticHashTable, CreateStaticObjectTable } from './types';
|
|
2
2
|
import { Module, CallExpression, Identifier, KeyValueProperty, StringLiteral, NumericLiteral, BooleanLiteral, ObjectExpression, MemberExpression, TemplateLiteral, BinaryExpression, UnaryExpression, VariableDeclaration, VariableDeclarator, ExportDeclaration, ConditionalExpression } from '@swc/core';
|
|
3
3
|
export declare const t: {
|
|
4
4
|
isObjectExpression: (node: any) => node is ObjectExpression;
|
|
@@ -26,9 +26,8 @@ export declare function traverse(node: Module, visitor: {
|
|
|
26
26
|
stop: () => void;
|
|
27
27
|
}) => void;
|
|
28
28
|
}): void;
|
|
29
|
-
export declare
|
|
30
|
-
export declare function objectExpressionToObject(node: ObjectExpression, staticTable: StaticTable, keyframesHashTable: KeyframesHashTable, viewTransitionHashTable: ViewTransitionHashTable, themeTable: ThemeTable, createHashTable: CreateHashTable, variantsHashTable: VariantsHashTable, resolveVariable?: (name: string) => any): CSSObject;
|
|
29
|
+
export declare function objectExpressionToObject(node: ObjectExpression, staticTable: StaticTable, keyframesHashTable: KeyframesHashTable, viewTransitionHashTable: ViewTransitionHashTable, createThemeHashTable: CreateThemeHashTable, createThemeObjectTable: CreateThemeObjectTable, createHashTable: CreateHashTable, createStaticHashTable: CreateStaticHashTable, createStaticObjectTable: CreateStaticObjectTable, variantsHashTable: VariantsHashTable, resolveVariable?: (name: string) => any): CSSObject;
|
|
31
30
|
export declare function collectLocalConsts(ast: Module): Record<string, any>;
|
|
32
31
|
export declare function scanAll(): Tables;
|
|
33
|
-
export declare function extractOndemandStyles(obj: any, extractedSheets: string[], t
|
|
32
|
+
export declare function extractOndemandStyles(obj: any, extractedSheets: string[], t: Tables): void;
|
|
34
33
|
export declare function deepMerge(target: Record<string, any>, source: Record<string, any>): Record<string, any>;
|
package/dist/parser.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.t = void 0;
|
|
7
7
|
exports.traverse = traverse;
|
|
8
8
|
exports.objectExpressionToObject = objectExpressionToObject;
|
|
9
9
|
exports.collectLocalConsts = collectLocalConsts;
|
|
@@ -17,6 +17,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
17
17
|
const zss_engine_1 = require("zss-engine");
|
|
18
18
|
const viewTransition_1 = require("./viewTransition");
|
|
19
19
|
const create_1 = require("./create");
|
|
20
|
+
const resolver_1 = require("./resolver");
|
|
20
21
|
exports.t = {
|
|
21
22
|
isObjectExpression: (node) => node?.type === 'ObjectExpression',
|
|
22
23
|
isObjectProperty: (node) => node?.type === 'KeyValueProperty',
|
|
@@ -76,26 +77,12 @@ const GLOB_OPTIONS = {
|
|
|
76
77
|
exclude: ['**/node_modules/**', '**/dist/**', '**/build/**', '**/.next/**'],
|
|
77
78
|
cwd: PROJECT_ROOT,
|
|
78
79
|
};
|
|
79
|
-
|
|
80
|
-
staticTable: {},
|
|
81
|
-
themeTable: {},
|
|
82
|
-
keyframesHashTable: {},
|
|
83
|
-
keyframesObjectTable: {},
|
|
84
|
-
viewTransitionHashTable: {},
|
|
85
|
-
viewTransitionObjectTable: {},
|
|
86
|
-
createThemeObjectTable: {},
|
|
87
|
-
createHashTable: {},
|
|
88
|
-
createObjectTable: {},
|
|
89
|
-
createAtomicMapTable: {},
|
|
90
|
-
variantsHashTable: {},
|
|
91
|
-
variantsObjectTable: {},
|
|
92
|
-
};
|
|
93
|
-
function objectExpressionToObject(node, staticTable, keyframesHashTable, viewTransitionHashTable, themeTable, createHashTable, variantsHashTable, resolveVariable) {
|
|
80
|
+
function objectExpressionToObject(node, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createHashTable, createStaticHashTable, createStaticObjectTable, variantsHashTable, resolveVariable) {
|
|
94
81
|
const obj = {};
|
|
95
82
|
node.properties.forEach((prop) => {
|
|
96
83
|
if (!exports.t.isObjectProperty(prop))
|
|
97
84
|
return;
|
|
98
|
-
const key = getPropertyKey(prop.key, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
85
|
+
const key = getPropertyKey(prop.key, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
|
|
99
86
|
if (!key)
|
|
100
87
|
return;
|
|
101
88
|
const val = prop.value;
|
|
@@ -125,11 +112,16 @@ function objectExpressionToObject(node, staticTable, keyframesHashTable, viewTra
|
|
|
125
112
|
obj[key] = 'cr-' + resolvedCreate;
|
|
126
113
|
return;
|
|
127
114
|
}
|
|
128
|
-
const resolvedTheme =
|
|
115
|
+
const resolvedTheme = resolveCreateThemeTableMemberExpressionByNode(val, createThemeHashTable, createThemeObjectTable);
|
|
129
116
|
if (resolvedTheme !== undefined) {
|
|
130
117
|
obj[key] = resolvedTheme;
|
|
131
118
|
return;
|
|
132
119
|
}
|
|
120
|
+
const resolvedStatic = resolveCreateStaticTableMemberExpression(val, createStaticHashTable, createStaticObjectTable);
|
|
121
|
+
if (resolvedStatic !== undefined) {
|
|
122
|
+
obj[key] = resolvedStatic;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
133
125
|
const resolvedVariants = resolveVariantsTableMemberExpression(val, variantsHashTable);
|
|
134
126
|
if (resolvedVariants !== undefined) {
|
|
135
127
|
obj[key] = 'vr-' + resolvedVariants;
|
|
@@ -145,7 +137,7 @@ function objectExpressionToObject(node, staticTable, keyframesHashTable, viewTra
|
|
|
145
137
|
obj[key] = evaluateUnaryExpression(val);
|
|
146
138
|
}
|
|
147
139
|
else if (exports.t.isObjectExpression(val)) {
|
|
148
|
-
obj[key] = objectExpressionToObject(val, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
140
|
+
obj[key] = objectExpressionToObject(val, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createHashTable, createStaticHashTable, createStaticObjectTable, variantsHashTable, resolveVariable);
|
|
149
141
|
}
|
|
150
142
|
else if (exports.t.isMemberExpression(val)) {
|
|
151
143
|
const resolved = resolveStaticTableMemberExpression(val, staticTable);
|
|
@@ -197,7 +189,7 @@ function collectLocalConsts(ast) {
|
|
|
197
189
|
result = init.value;
|
|
198
190
|
}
|
|
199
191
|
else if (exports.t.isObjectExpression(init)) {
|
|
200
|
-
result = objectExpressionToObject(init, localConsts,
|
|
192
|
+
result = objectExpressionToObject(init, localConsts, {}, {}, {}, {}, {}, {}, {}, {}, resolveValue);
|
|
201
193
|
}
|
|
202
194
|
visiting.delete(name);
|
|
203
195
|
if (result !== undefined) {
|
|
@@ -210,7 +202,7 @@ function collectLocalConsts(ast) {
|
|
|
210
202
|
}
|
|
211
203
|
return localConsts;
|
|
212
204
|
}
|
|
213
|
-
function getPropertyKey(node, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
205
|
+
function getPropertyKey(node, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable) {
|
|
214
206
|
if (exports.t.isIdentifier(node)) {
|
|
215
207
|
return node.value;
|
|
216
208
|
}
|
|
@@ -232,44 +224,47 @@ function getPropertyKey(node, staticTable, keyframesHashTable, viewTransitionHas
|
|
|
232
224
|
const result = resolveStaticTableMemberExpression(expr, staticTable);
|
|
233
225
|
if (typeof result === 'string')
|
|
234
226
|
return result;
|
|
227
|
+
const staticResult = resolveCreateStaticTableMemberExpression(expr, createStaticHashTable, createStaticObjectTable);
|
|
228
|
+
if (typeof staticResult === 'string')
|
|
229
|
+
return staticResult;
|
|
235
230
|
}
|
|
236
231
|
if (exports.t.isTemplateLiteral(expr)) {
|
|
237
|
-
return evaluateTemplateLiteral(expr, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
232
|
+
return evaluateTemplateLiteral(expr, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
|
|
238
233
|
}
|
|
239
234
|
if (exports.t.isBinaryExpression(expr)) {
|
|
240
|
-
return evaluateBinaryExpression(expr, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
235
|
+
return evaluateBinaryExpression(expr, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
|
|
241
236
|
}
|
|
242
237
|
return '';
|
|
243
238
|
}
|
|
244
239
|
if (exports.t.isTemplateLiteral(node)) {
|
|
245
|
-
return evaluateTemplateLiteral(node, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
240
|
+
return evaluateTemplateLiteral(node, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
|
|
246
241
|
}
|
|
247
242
|
if (exports.t.isBinaryExpression(node)) {
|
|
248
|
-
return evaluateBinaryExpression(node, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
243
|
+
return evaluateBinaryExpression(node, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
|
|
249
244
|
}
|
|
250
245
|
return '';
|
|
251
246
|
}
|
|
252
|
-
function evaluateTemplateLiteral(node, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
247
|
+
function evaluateTemplateLiteral(node, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable) {
|
|
253
248
|
let result = '';
|
|
254
249
|
for (let i = 0; i < node.quasis.length; i++) {
|
|
255
250
|
result += node.quasis[i].cooked || node.quasis[i].raw;
|
|
256
251
|
if (i < node.expressions.length) {
|
|
257
252
|
const expr = node.expressions[i];
|
|
258
|
-
const evaluatedExpr = evaluateExpression(expr, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
253
|
+
const evaluatedExpr = evaluateExpression(expr, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
|
|
259
254
|
result += String(evaluatedExpr);
|
|
260
255
|
}
|
|
261
256
|
}
|
|
262
257
|
return result;
|
|
263
258
|
}
|
|
264
|
-
function evaluateBinaryExpression(node, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
265
|
-
const left = evaluateExpression(node.left, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
266
|
-
const right = evaluateExpression(node.right, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
259
|
+
function evaluateBinaryExpression(node, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable) {
|
|
260
|
+
const left = evaluateExpression(node.left, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
|
|
261
|
+
const right = evaluateExpression(node.right, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
|
|
267
262
|
if (node.operator === '+') {
|
|
268
263
|
return String(left) + String(right);
|
|
269
264
|
}
|
|
270
265
|
throw new Error(`Unsupported binary operator: ${node.operator}`);
|
|
271
266
|
}
|
|
272
|
-
function evaluateExpression(node, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
267
|
+
function evaluateExpression(node, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable) {
|
|
273
268
|
if (exports.t.isStringLiteral(node)) {
|
|
274
269
|
return node.value;
|
|
275
270
|
}
|
|
@@ -299,17 +294,21 @@ function evaluateExpression(node, staticTable, keyframesHashTable, viewTransitio
|
|
|
299
294
|
if (resolved !== undefined) {
|
|
300
295
|
return resolved;
|
|
301
296
|
}
|
|
302
|
-
const resolvedTheme =
|
|
297
|
+
const resolvedTheme = resolveCreateThemeTableMemberExpressionByNode(node, createThemeHashTable, createThemeObjectTable);
|
|
303
298
|
if (resolvedTheme !== undefined) {
|
|
304
299
|
return resolvedTheme;
|
|
305
300
|
}
|
|
301
|
+
const resolvedStatic = resolveCreateStaticTableMemberExpression(node, createStaticHashTable, createStaticObjectTable);
|
|
302
|
+
if (resolvedStatic !== undefined) {
|
|
303
|
+
return resolvedStatic;
|
|
304
|
+
}
|
|
306
305
|
return `[unresolved member expression]`;
|
|
307
306
|
}
|
|
308
307
|
if (exports.t.isBinaryExpression(node)) {
|
|
309
|
-
return evaluateBinaryExpression(node, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
308
|
+
return evaluateBinaryExpression(node, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
|
|
310
309
|
}
|
|
311
310
|
if (exports.t.isTemplateLiteral(node)) {
|
|
312
|
-
return evaluateTemplateLiteral(node, staticTable, keyframesHashTable, viewTransitionHashTable,
|
|
311
|
+
return evaluateTemplateLiteral(node, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
|
|
313
312
|
}
|
|
314
313
|
if (exports.t.isUnaryExpression(node)) {
|
|
315
314
|
return evaluateUnaryExpression(node);
|
|
@@ -383,20 +382,49 @@ function resolveStaticTableMemberExpression(node, staticTable) {
|
|
|
383
382
|
}
|
|
384
383
|
return undefined;
|
|
385
384
|
}
|
|
386
|
-
function
|
|
385
|
+
function resolveCreateThemeTableMemberExpressionByNode(node, createThemeHashTable, createThemeObjectTable) {
|
|
387
386
|
if (exports.t.isMemberExpression(node) && exports.t.isIdentifier(node.object)) {
|
|
388
387
|
const varName = node.object.value;
|
|
389
|
-
|
|
390
|
-
if (
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
388
|
+
const hash = createThemeHashTable[varName];
|
|
389
|
+
if (hash) {
|
|
390
|
+
const themeObj = createThemeObjectTable[hash];
|
|
391
|
+
if (themeObj) {
|
|
392
|
+
let key;
|
|
393
|
+
if (exports.t.isIdentifier(node.property)) {
|
|
394
|
+
key = node.property.value;
|
|
395
|
+
}
|
|
396
|
+
else if (node.property.type === 'Computed' &&
|
|
397
|
+
exports.t.isStringLiteral(node.property.expression)) {
|
|
398
|
+
key = node.property.expression.value;
|
|
399
|
+
}
|
|
400
|
+
if (key && themeObj[key] !== undefined) {
|
|
401
|
+
const cssVarName = (0, zss_engine_1.camelToKebabCase)(key);
|
|
402
|
+
return `var(--${cssVarName})`;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
396
405
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
406
|
+
}
|
|
407
|
+
return undefined;
|
|
408
|
+
}
|
|
409
|
+
function resolveCreateStaticTableMemberExpression(node, createStaticHashTable, createStaticObjectTable) {
|
|
410
|
+
if (exports.t.isMemberExpression(node) && exports.t.isIdentifier(node.object)) {
|
|
411
|
+
const varName = node.object.value;
|
|
412
|
+
const hash = createStaticHashTable[varName];
|
|
413
|
+
if (hash) {
|
|
414
|
+
const staticObj = createStaticObjectTable[hash];
|
|
415
|
+
if (staticObj) {
|
|
416
|
+
let key;
|
|
417
|
+
if (exports.t.isIdentifier(node.property)) {
|
|
418
|
+
key = node.property.value;
|
|
419
|
+
}
|
|
420
|
+
else if (node.property.type === 'Computed' &&
|
|
421
|
+
exports.t.isStringLiteral(node.property.expression)) {
|
|
422
|
+
key = node.property.expression.value;
|
|
423
|
+
}
|
|
424
|
+
if (key && staticObj[key] !== undefined) {
|
|
425
|
+
return staticObj[key];
|
|
426
|
+
}
|
|
427
|
+
}
|
|
400
428
|
}
|
|
401
429
|
}
|
|
402
430
|
return undefined;
|
|
@@ -409,7 +437,6 @@ function scanAll() {
|
|
|
409
437
|
}
|
|
410
438
|
const localTables = {
|
|
411
439
|
staticTable: {},
|
|
412
|
-
themeTable: {},
|
|
413
440
|
keyframesHashTable: {},
|
|
414
441
|
keyframesObjectTable: {},
|
|
415
442
|
viewTransitionHashTable: {},
|
|
@@ -420,276 +447,357 @@ function scanAll() {
|
|
|
420
447
|
createAtomicMapTable: {},
|
|
421
448
|
variantsHashTable: {},
|
|
422
449
|
variantsObjectTable: {},
|
|
450
|
+
createThemeHashTable: {},
|
|
451
|
+
createStaticHashTable: {},
|
|
452
|
+
createStaticObjectTable: {},
|
|
423
453
|
extractedSheet: '',
|
|
424
454
|
};
|
|
425
455
|
const files = fs_1.default.globSync(PATTERN_PATH, GLOB_OPTIONS);
|
|
456
|
+
files.sort((a, b) => {
|
|
457
|
+
const aPriority = a.includes('/lib/') || a.includes('/utils/') || a.includes('/common/')
|
|
458
|
+
? 0
|
|
459
|
+
: 1;
|
|
460
|
+
const bPriority = b.includes('/lib/') || b.includes('/utils/') || b.includes('/common/')
|
|
461
|
+
? 0
|
|
462
|
+
: 1;
|
|
463
|
+
if (aPriority !== bPriority)
|
|
464
|
+
return aPriority - bPriority;
|
|
465
|
+
return a.localeCompare(b);
|
|
466
|
+
});
|
|
426
467
|
const totalExtractedSheets = [];
|
|
427
|
-
for (
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
468
|
+
for (let passNumber = 1; passNumber <= 2; passNumber++) {
|
|
469
|
+
const isFirstPass = passNumber === 1;
|
|
470
|
+
for (const filePath of files) {
|
|
471
|
+
try {
|
|
472
|
+
const stats = fs_1.default.statSync(filePath);
|
|
473
|
+
const cached = fileCache[filePath];
|
|
474
|
+
if (cached && cached.mtimeMs === stats.mtimeMs) {
|
|
475
|
+
if (cached.hasCssUsage) {
|
|
476
|
+
for (const key of Object.keys(cached.staticTable)) {
|
|
477
|
+
localTables.staticTable[`${filePath}-${key}`] =
|
|
478
|
+
cached.staticTable[key];
|
|
479
|
+
}
|
|
480
|
+
for (const key of Object.keys(cached.keyframesHashTable)) {
|
|
481
|
+
localTables.keyframesHashTable[`${filePath}-${key}`] =
|
|
482
|
+
cached.keyframesHashTable[key];
|
|
483
|
+
}
|
|
484
|
+
for (const key of Object.keys(cached.keyframesObjectTable)) {
|
|
485
|
+
localTables.keyframesObjectTable[key] =
|
|
486
|
+
cached.keyframesObjectTable[key];
|
|
487
|
+
}
|
|
488
|
+
for (const key of Object.keys(cached.viewTransitionHashTable)) {
|
|
489
|
+
localTables.viewTransitionHashTable[`${filePath}-${key}`] =
|
|
490
|
+
cached.viewTransitionHashTable[key];
|
|
491
|
+
}
|
|
492
|
+
for (const key of Object.keys(cached.viewTransitionObjectTable)) {
|
|
493
|
+
localTables.viewTransitionObjectTable[key] =
|
|
494
|
+
cached.viewTransitionObjectTable[key];
|
|
495
|
+
}
|
|
496
|
+
for (const key of Object.keys(cached.createThemeHashTable)) {
|
|
497
|
+
localTables.createThemeHashTable[`${filePath}-${key}`] =
|
|
498
|
+
cached.createThemeHashTable[key];
|
|
499
|
+
}
|
|
500
|
+
for (const key of Object.keys(cached.createThemeObjectTable)) {
|
|
501
|
+
localTables.createThemeObjectTable[key] =
|
|
502
|
+
cached.createThemeObjectTable[key];
|
|
503
|
+
}
|
|
504
|
+
for (const key of Object.keys(cached.createStaticHashTable)) {
|
|
505
|
+
localTables.createStaticHashTable[`${filePath}-${key}`] =
|
|
506
|
+
cached.createStaticHashTable[key];
|
|
507
|
+
}
|
|
508
|
+
for (const key of Object.keys(cached.createStaticObjectTable)) {
|
|
509
|
+
localTables.createStaticObjectTable[key] =
|
|
510
|
+
cached.createStaticObjectTable[key];
|
|
511
|
+
}
|
|
512
|
+
for (const key of Object.keys(cached.createHashTable)) {
|
|
513
|
+
localTables.createHashTable[`${filePath}-${key}`] =
|
|
514
|
+
cached.createHashTable[key];
|
|
515
|
+
}
|
|
516
|
+
for (const key of Object.keys(cached.createObjectTable)) {
|
|
517
|
+
localTables.createObjectTable[key] =
|
|
518
|
+
cached.createObjectTable[key];
|
|
519
|
+
}
|
|
520
|
+
for (const key of Object.keys(cached.createAtomicMapTable)) {
|
|
521
|
+
localTables.createAtomicMapTable[key] =
|
|
522
|
+
cached.createAtomicMapTable[key];
|
|
523
|
+
}
|
|
524
|
+
for (const key of Object.keys(cached.variantsHashTable)) {
|
|
525
|
+
localTables.variantsHashTable[`${filePath}-${key}`] =
|
|
526
|
+
cached.variantsHashTable[key];
|
|
527
|
+
}
|
|
528
|
+
for (const key of Object.keys(cached.variantsObjectTable)) {
|
|
529
|
+
localTables.variantsObjectTable[key] =
|
|
530
|
+
cached.variantsObjectTable[key];
|
|
531
|
+
}
|
|
532
|
+
if (cached.extractedSheet) {
|
|
533
|
+
totalExtractedSheets.push(cached.extractedSheet);
|
|
534
|
+
}
|
|
482
535
|
}
|
|
536
|
+
continue;
|
|
483
537
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
if (
|
|
531
|
-
node.
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
538
|
+
const source = fs_1.default.readFileSync(filePath, 'utf8');
|
|
539
|
+
if (!source.includes('@plumeria/core')) {
|
|
540
|
+
fileCache[filePath] = {
|
|
541
|
+
mtimeMs: stats.mtimeMs,
|
|
542
|
+
staticTable: {},
|
|
543
|
+
keyframesHashTable: {},
|
|
544
|
+
keyframesObjectTable: {},
|
|
545
|
+
viewTransitionHashTable: {},
|
|
546
|
+
viewTransitionObjectTable: {},
|
|
547
|
+
createThemeHashTable: {},
|
|
548
|
+
createThemeObjectTable: {},
|
|
549
|
+
createHashTable: {},
|
|
550
|
+
createObjectTable: {},
|
|
551
|
+
createAtomicMapTable: {},
|
|
552
|
+
variantsHashTable: {},
|
|
553
|
+
variantsObjectTable: {},
|
|
554
|
+
createStaticHashTable: {},
|
|
555
|
+
createStaticObjectTable: {},
|
|
556
|
+
hasCssUsage: false,
|
|
557
|
+
extractedSheet: '',
|
|
558
|
+
};
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
const ast = (0, core_1.parseSync)(source, {
|
|
562
|
+
syntax: 'typescript',
|
|
563
|
+
tsx: true,
|
|
564
|
+
target: 'es2022',
|
|
565
|
+
});
|
|
566
|
+
const localStaticTable = {};
|
|
567
|
+
const localKeyframesHashTable = {};
|
|
568
|
+
const localKeyframesObjectTable = {};
|
|
569
|
+
const localViewTransitionHashTable = {};
|
|
570
|
+
const localViewTransitionObjectTable = {};
|
|
571
|
+
const localCreateThemeObjectTable = {};
|
|
572
|
+
const localCreateHashTable = {};
|
|
573
|
+
const localCreateObjectTable = {};
|
|
574
|
+
const localCreateAtomicMapTable = {};
|
|
575
|
+
const localVariantsHashTable = {};
|
|
576
|
+
const localVariantsObjectTable = {};
|
|
577
|
+
const localCreateThemeHashTable = {};
|
|
578
|
+
const localCreateStaticHashTable = {};
|
|
579
|
+
const localCreateStaticObjectTable = {};
|
|
580
|
+
const plumeriaAliases = {};
|
|
581
|
+
const fileExtractedSheets = [];
|
|
582
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
583
|
+
for (const node of ast.body) {
|
|
584
|
+
if (node.type === 'ImportDeclaration') {
|
|
585
|
+
const sourceValue = node.source.value;
|
|
586
|
+
if (sourceValue === '@plumeria/core') {
|
|
587
|
+
node.specifiers.forEach((specifier) => {
|
|
588
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
589
|
+
if (specifier.local) {
|
|
590
|
+
plumeriaAliases[specifier.local.value] = 'NAMESPACE';
|
|
591
|
+
}
|
|
535
592
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
plumeriaAliases[localName] = importedName;
|
|
543
|
-
}
|
|
544
|
-
else if (specifier.type === 'ImportDefaultSpecifier') {
|
|
545
|
-
if (specifier.local) {
|
|
546
|
-
plumeriaAliases[specifier.local.value] = 'NAMESPACE';
|
|
593
|
+
else if (specifier.type === 'ImportSpecifier') {
|
|
594
|
+
const importedName = specifier.imported
|
|
595
|
+
? specifier.imported.value
|
|
596
|
+
: specifier.local.value;
|
|
597
|
+
const localName = specifier.local.value;
|
|
598
|
+
plumeriaAliases[localName] = importedName;
|
|
547
599
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
let declarations = [];
|
|
555
|
-
if (exports.t.isVariableDeclaration(node)) {
|
|
556
|
-
declarations = node.declarations;
|
|
557
|
-
}
|
|
558
|
-
else if (exports.t.isExportDeclaration(node) &&
|
|
559
|
-
exports.t.isVariableDeclaration(node.declaration)) {
|
|
560
|
-
declarations = node.declaration.declarations;
|
|
561
|
-
}
|
|
562
|
-
for (const decl of declarations) {
|
|
563
|
-
if (exports.t.isVariableDeclarator(decl) &&
|
|
564
|
-
exports.t.isIdentifier(decl.id) &&
|
|
565
|
-
decl.init &&
|
|
566
|
-
exports.t.isCallExpression(decl.init) &&
|
|
567
|
-
exports.t.isCallExpression(decl.init)) {
|
|
568
|
-
const callee = decl.init.callee;
|
|
569
|
-
let method;
|
|
570
|
-
if (exports.t.isMemberExpression(callee) &&
|
|
571
|
-
exports.t.isIdentifier(callee.object) &&
|
|
572
|
-
exports.t.isIdentifier(callee.property)) {
|
|
573
|
-
const objectName = callee.object.value;
|
|
574
|
-
const propertyName = callee.property.value;
|
|
575
|
-
const alias = plumeriaAliases[objectName];
|
|
576
|
-
if (alias === 'NAMESPACE' || objectName === 'css') {
|
|
577
|
-
method = propertyName;
|
|
578
|
-
}
|
|
600
|
+
else if (specifier.type === 'ImportDefaultSpecifier') {
|
|
601
|
+
if (specifier.local) {
|
|
602
|
+
plumeriaAliases[specifier.local.value] = 'NAMESPACE';
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
});
|
|
579
606
|
}
|
|
580
|
-
else
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
607
|
+
else {
|
|
608
|
+
const actualPath = (0, resolver_1.resolveImportPath)(sourceValue, filePath);
|
|
609
|
+
if (actualPath) {
|
|
610
|
+
node.specifiers.forEach((specifier) => {
|
|
611
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
612
|
+
const importedName = specifier.imported
|
|
613
|
+
? specifier.imported.value
|
|
614
|
+
: specifier.local.value;
|
|
615
|
+
const localName = specifier.local.value;
|
|
616
|
+
const uniqueKey = `${actualPath}-${importedName}`;
|
|
617
|
+
if (localTables.createStaticHashTable[uniqueKey]) {
|
|
618
|
+
const hash = localTables.createStaticHashTable[uniqueKey];
|
|
619
|
+
localCreateStaticHashTable[localName] = hash;
|
|
620
|
+
if (localTables.createStaticObjectTable[hash]) {
|
|
621
|
+
localCreateStaticObjectTable[hash] =
|
|
622
|
+
localTables.createStaticObjectTable[hash];
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
if (localTables.createThemeHashTable[uniqueKey]) {
|
|
626
|
+
const hash = localTables.createThemeHashTable[uniqueKey];
|
|
627
|
+
localCreateThemeHashTable[localName] = hash;
|
|
628
|
+
if (localTables.createThemeObjectTable[hash]) {
|
|
629
|
+
localCreateThemeObjectTable[hash] =
|
|
630
|
+
localTables.createThemeObjectTable[hash];
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
});
|
|
585
635
|
}
|
|
586
636
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
for (const node of ast.body) {
|
|
640
|
+
let declarations = [];
|
|
641
|
+
if (exports.t.isVariableDeclaration(node)) {
|
|
642
|
+
declarations = node.declarations;
|
|
643
|
+
}
|
|
644
|
+
else if (exports.t.isExportDeclaration(node) &&
|
|
645
|
+
exports.t.isVariableDeclaration(node.declaration)) {
|
|
646
|
+
declarations = node.declaration.declarations;
|
|
647
|
+
}
|
|
648
|
+
for (const decl of declarations) {
|
|
649
|
+
if (exports.t.isVariableDeclarator(decl) &&
|
|
650
|
+
exports.t.isIdentifier(decl.id) &&
|
|
651
|
+
decl.init &&
|
|
652
|
+
exports.t.isCallExpression(decl.init) &&
|
|
653
|
+
exports.t.isCallExpression(decl.init)) {
|
|
654
|
+
const callee = decl.init.callee;
|
|
655
|
+
let method;
|
|
656
|
+
if (exports.t.isMemberExpression(callee) &&
|
|
657
|
+
exports.t.isIdentifier(callee.object) &&
|
|
658
|
+
exports.t.isIdentifier(callee.property)) {
|
|
659
|
+
const objectName = callee.object.value;
|
|
660
|
+
const propertyName = callee.property.value;
|
|
661
|
+
const alias = plumeriaAliases[objectName];
|
|
662
|
+
if (alias === 'NAMESPACE' || objectName === 'css') {
|
|
663
|
+
method = propertyName;
|
|
596
664
|
}
|
|
597
|
-
return undefined;
|
|
598
|
-
};
|
|
599
|
-
const obj = objectExpressionToObject(init.arguments[0].expression, localStaticTable, localKeyframesHashTable, localViewTransitionHashTable, localThemeTable, localCreateHashTable, localVariantsHashTable, resolveVariable);
|
|
600
|
-
const uniqueKey = `${filePath}-${name}`;
|
|
601
|
-
if (method === 'createStatic') {
|
|
602
|
-
localStaticTable[name] = obj;
|
|
603
|
-
localTables.staticTable[uniqueKey] = obj;
|
|
604
665
|
}
|
|
605
|
-
else if (
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
localTables.keyframesObjectTable[hash] = obj;
|
|
611
|
-
localKeyframesObjectTable[hash] = obj;
|
|
612
|
-
if (!isProduction) {
|
|
613
|
-
extractOndemandStyles({ kf: `kf-${hash}` }, fileExtractedSheets, localTables);
|
|
666
|
+
else if (exports.t.isIdentifier(callee)) {
|
|
667
|
+
const calleeName = callee.value;
|
|
668
|
+
const originalName = plumeriaAliases[calleeName];
|
|
669
|
+
if (originalName) {
|
|
670
|
+
method = originalName;
|
|
614
671
|
}
|
|
615
672
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
673
|
+
if (method &&
|
|
674
|
+
decl.init.arguments.length > 0 &&
|
|
675
|
+
exports.t.isObjectExpression(decl.init.arguments[0].expression)) {
|
|
676
|
+
const name = decl.id.value;
|
|
677
|
+
const init = decl.init;
|
|
678
|
+
const resolveVariable = (name) => {
|
|
679
|
+
const hash = localCreateHashTable[name];
|
|
680
|
+
if (hash && localCreateObjectTable[hash]) {
|
|
681
|
+
return localCreateObjectTable[hash];
|
|
682
|
+
}
|
|
683
|
+
return undefined;
|
|
684
|
+
};
|
|
685
|
+
const obj = objectExpressionToObject(init.arguments[0].expression, localStaticTable, localKeyframesHashTable, localViewTransitionHashTable, localCreateThemeHashTable, localCreateThemeObjectTable, localCreateHashTable, localCreateStaticHashTable, localCreateStaticObjectTable, localVariantsHashTable, resolveVariable);
|
|
686
|
+
const uniqueKey = `${filePath}-${name}`;
|
|
687
|
+
const isPassOneMethod = method === 'createStatic' || method === 'createTheme';
|
|
688
|
+
if (isFirstPass && !isPassOneMethod)
|
|
689
|
+
continue;
|
|
690
|
+
if (method === 'createStatic') {
|
|
691
|
+
localStaticTable[name] = obj;
|
|
692
|
+
localTables.staticTable[uniqueKey] = obj;
|
|
693
|
+
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
694
|
+
localCreateStaticHashTable[name] = hash;
|
|
695
|
+
localTables.createStaticHashTable[uniqueKey] = hash;
|
|
696
|
+
localTables.createStaticObjectTable[hash] = obj;
|
|
697
|
+
localCreateStaticObjectTable[hash] = obj;
|
|
698
|
+
const hashMap = {
|
|
699
|
+
__static: {},
|
|
700
|
+
};
|
|
701
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
702
|
+
if (typeof value === 'string') {
|
|
703
|
+
hashMap.__static[key] = value;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
localTables.createAtomicMapTable[hash] = hashMap;
|
|
626
707
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}
|
|
635
|
-
else if (method === 'create') {
|
|
636
|
-
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
637
|
-
localCreateHashTable[name] = hash;
|
|
638
|
-
localTables.createHashTable[uniqueKey] = hash;
|
|
639
|
-
localTables.createObjectTable[hash] = obj;
|
|
640
|
-
localCreateObjectTable[hash] = obj;
|
|
641
|
-
const hashMap = {};
|
|
642
|
-
Object.entries(obj).forEach(([key, style]) => {
|
|
643
|
-
const records = (0, create_1.getStyleRecords)(key, style, 2);
|
|
644
|
-
const atomMap = {};
|
|
645
|
-
records.forEach((r) => (atomMap[r.key] = r.hash));
|
|
646
|
-
hashMap[key] = atomMap;
|
|
708
|
+
else if (method === 'keyframes') {
|
|
709
|
+
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
710
|
+
localKeyframesHashTable[name] = hash;
|
|
711
|
+
localTables.keyframesHashTable[uniqueKey] = hash;
|
|
712
|
+
localTables.keyframesObjectTable[hash] = obj;
|
|
713
|
+
localTables.keyframesObjectTable[hash] = obj;
|
|
714
|
+
localKeyframesObjectTable[hash] = obj;
|
|
647
715
|
if (!isProduction) {
|
|
648
|
-
extractOndemandStyles(
|
|
649
|
-
records.forEach((r) => {
|
|
650
|
-
if (!fileExtractedSheets.includes(r.sheet)) {
|
|
651
|
-
fileExtractedSheets.push(r.sheet);
|
|
652
|
-
}
|
|
653
|
-
});
|
|
716
|
+
extractOndemandStyles({ kf: `kf-${hash}` }, fileExtractedSheets, localTables);
|
|
654
717
|
}
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
718
|
+
}
|
|
719
|
+
else if (method === 'viewTransition') {
|
|
720
|
+
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
721
|
+
localViewTransitionHashTable[name] = hash;
|
|
722
|
+
localTables.viewTransitionHashTable[uniqueKey] = hash;
|
|
723
|
+
localTables.viewTransitionObjectTable[hash] = obj;
|
|
724
|
+
localTables.viewTransitionObjectTable[hash] = obj;
|
|
725
|
+
localViewTransitionObjectTable[hash] = obj;
|
|
726
|
+
if (!isProduction) {
|
|
727
|
+
extractOndemandStyles(obj, fileExtractedSheets, localTables);
|
|
728
|
+
extractOndemandStyles({ vt: `vt-${hash}` }, fileExtractedSheets, localTables);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
else if (method === 'createTheme') {
|
|
732
|
+
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
733
|
+
localTables.createThemeObjectTable[hash] = obj;
|
|
734
|
+
localCreateThemeObjectTable[hash] = obj;
|
|
735
|
+
localCreateThemeHashTable[name] = hash;
|
|
736
|
+
localTables.createThemeHashTable[uniqueKey] = hash;
|
|
737
|
+
}
|
|
738
|
+
else if (method === 'create') {
|
|
739
|
+
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
740
|
+
localCreateHashTable[name] = hash;
|
|
741
|
+
localTables.createHashTable[uniqueKey] = hash;
|
|
742
|
+
localTables.createObjectTable[hash] = obj;
|
|
743
|
+
localCreateObjectTable[hash] = obj;
|
|
744
|
+
const hashMap = {};
|
|
745
|
+
Object.entries(obj).forEach(([key, style]) => {
|
|
746
|
+
const records = (0, create_1.getStyleRecords)(key, style, 2);
|
|
747
|
+
const atomMap = {};
|
|
748
|
+
records.forEach((r) => (atomMap[r.key] = r.hash));
|
|
749
|
+
hashMap[key] = atomMap;
|
|
750
|
+
if (!isProduction) {
|
|
751
|
+
extractOndemandStyles(style, fileExtractedSheets, localTables);
|
|
752
|
+
records.forEach((r) => {
|
|
753
|
+
if (!fileExtractedSheets.includes(r.sheet)) {
|
|
754
|
+
fileExtractedSheets.push(r.sheet);
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
localCreateAtomicMapTable[hash] = hashMap;
|
|
760
|
+
localTables.createAtomicMapTable[hash] = hashMap;
|
|
761
|
+
}
|
|
762
|
+
else if (method === 'variants') {
|
|
763
|
+
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
764
|
+
localVariantsHashTable[name] = hash;
|
|
765
|
+
localTables.variantsHashTable[uniqueKey] = hash;
|
|
766
|
+
localTables.variantsObjectTable[hash] = obj;
|
|
767
|
+
localVariantsObjectTable[hash] = obj;
|
|
768
|
+
}
|
|
665
769
|
}
|
|
666
770
|
}
|
|
667
771
|
}
|
|
668
772
|
}
|
|
773
|
+
if (!isFirstPass) {
|
|
774
|
+
fileCache[filePath] = {
|
|
775
|
+
mtimeMs: stats.mtimeMs,
|
|
776
|
+
staticTable: localStaticTable,
|
|
777
|
+
keyframesHashTable: localKeyframesHashTable,
|
|
778
|
+
keyframesObjectTable: localKeyframesObjectTable,
|
|
779
|
+
viewTransitionHashTable: localViewTransitionHashTable,
|
|
780
|
+
viewTransitionObjectTable: localViewTransitionObjectTable,
|
|
781
|
+
createThemeHashTable: localCreateThemeHashTable,
|
|
782
|
+
createThemeObjectTable: localCreateThemeObjectTable,
|
|
783
|
+
createHashTable: localCreateHashTable,
|
|
784
|
+
createObjectTable: localCreateObjectTable,
|
|
785
|
+
createAtomicMapTable: localCreateAtomicMapTable,
|
|
786
|
+
variantsHashTable: localVariantsHashTable,
|
|
787
|
+
variantsObjectTable: localVariantsObjectTable,
|
|
788
|
+
createStaticHashTable: localCreateStaticHashTable,
|
|
789
|
+
createStaticObjectTable: localCreateStaticObjectTable,
|
|
790
|
+
hasCssUsage: true,
|
|
791
|
+
extractedSheet: fileExtractedSheets.join(''),
|
|
792
|
+
};
|
|
793
|
+
if (fileExtractedSheets.length > 0) {
|
|
794
|
+
totalExtractedSheets.push(fileExtractedSheets.join(''));
|
|
795
|
+
}
|
|
796
|
+
}
|
|
669
797
|
}
|
|
670
|
-
|
|
671
|
-
mtimeMs: stats.mtimeMs,
|
|
672
|
-
staticTable: localStaticTable,
|
|
673
|
-
keyframesHashTable: localKeyframesHashTable,
|
|
674
|
-
keyframesObjectTable: localKeyframesObjectTable,
|
|
675
|
-
viewTransitionHashTable: localViewTransitionHashTable,
|
|
676
|
-
viewTransitionObjectTable: localViewTransitionObjectTable,
|
|
677
|
-
themeTable: localThemeTable,
|
|
678
|
-
createThemeObjectTable: localCreateThemeObjectTable,
|
|
679
|
-
createHashTable: localCreateHashTable,
|
|
680
|
-
createObjectTable: localCreateObjectTable,
|
|
681
|
-
createAtomicMapTable: localCreateAtomicMapTable,
|
|
682
|
-
variantsHashTable: localVariantsHashTable,
|
|
683
|
-
variantsObjectTable: localVariantsObjectTable,
|
|
684
|
-
hasCssUsage: true,
|
|
685
|
-
extractedSheet: fileExtractedSheets.join(''),
|
|
686
|
-
};
|
|
687
|
-
if (fileExtractedSheets.length > 0) {
|
|
688
|
-
totalExtractedSheets.push(fileExtractedSheets.join(''));
|
|
798
|
+
catch (e) {
|
|
689
799
|
}
|
|
690
800
|
}
|
|
691
|
-
catch (e) {
|
|
692
|
-
}
|
|
693
801
|
}
|
|
694
802
|
localTables.extractedSheet = totalExtractedSheets.join('');
|
|
695
803
|
if (process.env.NODE_ENV === 'production') {
|
|
@@ -697,7 +805,7 @@ function scanAll() {
|
|
|
697
805
|
}
|
|
698
806
|
return localTables;
|
|
699
807
|
}
|
|
700
|
-
function extractOndemandStyles(obj, extractedSheets, t
|
|
808
|
+
function extractOndemandStyles(obj, extractedSheets, t) {
|
|
701
809
|
if (!obj || typeof obj !== 'object')
|
|
702
810
|
return;
|
|
703
811
|
const visited = new Set();
|
|
@@ -767,9 +875,8 @@ function extractOndemandStyles(obj, extractedSheets, t = exports.tables) {
|
|
|
767
875
|
}
|
|
768
876
|
}
|
|
769
877
|
if (needsTheme) {
|
|
770
|
-
for (const themeVarName in t.
|
|
771
|
-
const
|
|
772
|
-
const hash = (0, zss_engine_1.genBase36Hash)(themeObj, 1, 8);
|
|
878
|
+
for (const themeVarName in t.createThemeHashTable) {
|
|
879
|
+
const hash = t.createThemeHashTable[themeVarName];
|
|
773
880
|
const definition = t.createThemeObjectTable[hash];
|
|
774
881
|
if (definition && typeof definition === 'object') {
|
|
775
882
|
const styles = (0, createTheme_1.createTheme)(definition);
|
package/dist/types.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export type CSSObject = {
|
|
|
5
5
|
[key: string]: CSSValue;
|
|
6
6
|
};
|
|
7
7
|
export type StaticTable = Record<string, CSSValue>;
|
|
8
|
-
export type ThemeTable = Record<string, CSSObject>;
|
|
9
8
|
export type KeyframesHashTable = Record<string, string>;
|
|
10
9
|
export type KeyframesObjectTable = Record<string, CSSObject>;
|
|
11
10
|
export type ViewTransitionHashTable = Record<string, string>;
|
|
@@ -16,17 +15,22 @@ export type CreateObjectTable = Record<string, CSSObject>;
|
|
|
16
15
|
export type VariantsHashTable = Record<string, string>;
|
|
17
16
|
export type VariantsObjectTable = Record<string, CSSObject>;
|
|
18
17
|
export type CreateAtomicMapTable = Record<string, Record<string, Record<string, string>>>;
|
|
18
|
+
export type CreateStaticHashTable = Record<string, string>;
|
|
19
|
+
export type CreateStaticObjectTable = Record<string, CSSObject>;
|
|
20
|
+
export type CreateThemeHashTable = Record<string, string>;
|
|
19
21
|
export interface Tables {
|
|
20
22
|
staticTable: StaticTable;
|
|
21
|
-
themeTable: ThemeTable;
|
|
22
23
|
keyframesHashTable: KeyframesHashTable;
|
|
23
24
|
keyframesObjectTable: KeyframesObjectTable;
|
|
24
25
|
viewTransitionHashTable: ViewTransitionHashTable;
|
|
25
26
|
viewTransitionObjectTable: ViewTransitionObjectTable;
|
|
27
|
+
createThemeHashTable: CreateThemeHashTable;
|
|
26
28
|
createThemeObjectTable: CreateThemeObjectTable;
|
|
27
29
|
createHashTable: CreateHashTable;
|
|
28
30
|
createObjectTable: CreateObjectTable;
|
|
29
31
|
createAtomicMapTable: CreateAtomicMapTable;
|
|
32
|
+
createStaticHashTable: CreateStaticHashTable;
|
|
33
|
+
createStaticObjectTable: CreateStaticObjectTable;
|
|
30
34
|
variantsHashTable: VariantsHashTable;
|
|
31
35
|
variantsObjectTable: VariantsObjectTable;
|
|
32
36
|
extractedSheet?: string;
|