@plumeria/compiler 8.0.3 → 9.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.
Files changed (2) hide show
  1. package/dist/index.js +5 -70
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -32,14 +32,11 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
36
  exports.compileCSS = compileCSS;
40
37
  const core_1 = require("@swc/core");
41
38
  const zss_engine_1 = require("zss-engine");
42
- const fs_1 = __importDefault(require("fs"));
39
+ const fs = __importStar(require("fs"));
43
40
  const rs = __importStar(require("@rust-gear/glob"));
44
41
  const utils_1 = require("@plumeria/utils");
45
42
  const utils_2 = require("@plumeria/utils");
@@ -52,7 +49,7 @@ function compileCSS(options) {
52
49
  });
53
50
  const scannedTables = (0, utils_1.scanAll)();
54
51
  const processFile = (filePath) => {
55
- const source = fs_1.default.readFileSync(filePath, 'utf-8');
52
+ const source = fs.readFileSync(filePath, 'utf-8');
56
53
  const extractedSheets = [];
57
54
  const ast = (0, core_1.parseSync)(source, {
58
55
  syntax: 'typescript',
@@ -191,7 +188,7 @@ function compileCSS(options) {
191
188
  const objectName = callee.object.value;
192
189
  const propertyName = callee.property.value;
193
190
  const alias = plumeriaAliases[objectName];
194
- if (alias === 'NAMESPACE' || objectName === 'css')
191
+ if (alias === 'NAMESPACE')
195
192
  propName = propertyName;
196
193
  }
197
194
  else if (utils_1.t.isIdentifier(callee)) {
@@ -199,15 +196,6 @@ function compileCSS(options) {
199
196
  if (originalName)
200
197
  propName = originalName;
201
198
  }
202
- let localVariantName;
203
- if (!propName && utils_1.t.isIdentifier(callee)) {
204
- const varName = callee.value;
205
- if (localCreateStyles[varName] &&
206
- localCreateStyles[varName].type === 'variant') {
207
- localVariantName = varName;
208
- propName = 'props';
209
- }
210
- }
211
199
  if (propName) {
212
200
  const args = node.arguments;
213
201
  const extractStylesFromExpression = (expression) => {
@@ -274,9 +262,8 @@ function compileCSS(options) {
274
262
  const records = (0, utils_1.getStyleRecords)(style);
275
263
  records.forEach((r) => extractedSheets.push(r.sheet));
276
264
  };
277
- if (propName === 'props') {
265
+ if (propName === 'use') {
278
266
  const conditionals = [];
279
- let groupIdCounter = 0;
280
267
  let baseStyle = {};
281
268
  const resolveStyleObject = (expression) => {
282
269
  const styles = extractStylesFromExpression(expression);
@@ -286,57 +273,6 @@ function compileCSS(options) {
286
273
  };
287
274
  for (const arg of args) {
288
275
  const expr = arg.expression;
289
- let handledAsObjectArg = false;
290
- if (localVariantName && utils_1.t.isObjectExpression(expr)) {
291
- const variantObj = localCreateStyles[localVariantName].obj;
292
- if (variantObj) {
293
- const props = expr.properties;
294
- if (variantObj.base && typeof variantObj.base === 'object') {
295
- baseStyle = (0, utils_1.deepMerge)(baseStyle, variantObj.base);
296
- }
297
- const variantsMap = (variantObj.variants ||
298
- variantObj);
299
- for (const prop of props) {
300
- let groupName;
301
- let valueExpression;
302
- if (prop.type === 'KeyValueProperty' &&
303
- prop.key.type === 'Identifier') {
304
- groupName = prop.key.value;
305
- valueExpression = prop.value;
306
- }
307
- else if (prop.type === 'Identifier') {
308
- groupName = prop.value;
309
- valueExpression = prop;
310
- }
311
- if (groupName && valueExpression && variantsMap[groupName]) {
312
- const groupVariants = variantsMap[groupName];
313
- if (!groupVariants || typeof groupVariants !== 'object')
314
- continue;
315
- const currentGroupId = ++groupIdCounter;
316
- if (valueExpression.type === 'StringLiteral') {
317
- if (groupVariants[valueExpression.value]) {
318
- baseStyle = (0, utils_1.deepMerge)(baseStyle, groupVariants[valueExpression.value]);
319
- }
320
- continue;
321
- }
322
- Object.entries(groupVariants).forEach(([optionName, style]) => {
323
- conditionals.push({
324
- test: valueExpression,
325
- truthy: style,
326
- falsy: {},
327
- groupId: currentGroupId,
328
- groupName: groupName,
329
- valueName: optionName,
330
- varName: localVariantName,
331
- });
332
- });
333
- }
334
- }
335
- handledAsObjectArg = true;
336
- }
337
- }
338
- if (handledAsObjectArg)
339
- continue;
340
276
  const getSource = (node) => sourceBuffer
341
277
  .subarray(node.span.start - baseByteOffset, node.span.end - baseByteOffset)
342
278
  .toString('utf-8');
@@ -441,8 +377,7 @@ function compileCSS(options) {
441
377
  if (utils_1.t.isMemberExpression(callee) &&
442
378
  utils_1.t.isIdentifier(callee.object) &&
443
379
  utils_1.t.isIdentifier(callee.property)) {
444
- if (callee.object.value === 'css' ||
445
- plumeriaAliases[callee.object.value] === 'NAMESPACE')
380
+ if (plumeriaAliases[callee.object.value] === 'NAMESPACE')
446
381
  pName = callee.property.value;
447
382
  }
448
383
  else if (utils_1.t.isIdentifier(callee) && plumeriaAliases[callee.value]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/compiler",
3
- "version": "8.0.3",
3
+ "version": "9.0.0",
4
4
  "description": "Plumeria swc based compiler for statically extracting css",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  "dist/"
22
22
  ],
23
23
  "dependencies": {
24
- "@plumeria/utils": "^8.0.3"
24
+ "@plumeria/utils": "^9.0.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@rust-gear/glob": "0.2.8",