@plumeria/webpack-plugin 0.22.3 → 0.23.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/create.js CHANGED
@@ -11,31 +11,44 @@ function compileToSingleCSS(object) {
11
11
  const flat = {};
12
12
  const nonFlat = {};
13
13
  (0, zss_engine_1.splitAtomicAndNested)(styleObj, flat, nonFlat);
14
- const props = Object.keys(flat);
15
- const finalFlat = {};
16
- for (let i = 0; i < props.length; i++) {
17
- const prop = props[i];
18
- const kebab = (0, zss_engine_1.camelToKebabCase)(prop);
19
- const isShorthand = !!zss_engine_1.SHORTHAND_PROPERTIES[kebab];
20
- if (isShorthand) {
21
- finalFlat[prop] = flat[prop];
22
- }
23
- else {
24
- let isOverridden = false;
25
- const shorthands = zss_engine_1.LONG_TO_SHORT[kebab] || [];
26
- for (let j = i + 1; j < props.length; j++) {
27
- const futureProp = props[j];
28
- const futureKebab = (0, zss_engine_1.camelToKebabCase)(futureProp);
29
- if (shorthands.includes(futureKebab)) {
30
- isOverridden = true;
31
- break;
14
+ const overrideLonghand = (style) => {
15
+ const props = Object.keys(style);
16
+ if (props.some((p) => p.startsWith('@'))) {
17
+ const finalStyle = { ...style };
18
+ for (const key of props) {
19
+ if (key.startsWith('@')) {
20
+ finalStyle[key] = overrideLonghand(style[key]);
32
21
  }
33
22
  }
34
- if (!isOverridden) {
35
- finalFlat[prop] = flat[prop];
23
+ return finalStyle;
24
+ }
25
+ const finalStyle = {};
26
+ for (let i = 0; i < props.length; i++) {
27
+ const prop = props[i];
28
+ const kebab = (0, zss_engine_1.camelToKebabCase)(prop);
29
+ const isShorthand = !!zss_engine_1.SHORTHAND_PROPERTIES[kebab];
30
+ if (isShorthand) {
31
+ finalStyle[prop] = style[prop];
32
+ }
33
+ else {
34
+ let isOverridden = false;
35
+ const shorthands = zss_engine_1.LONG_TO_SHORT[kebab] || [];
36
+ for (let j = i + 1; j < props.length; j++) {
37
+ const futureProp = props[j];
38
+ const futureKebab = (0, zss_engine_1.camelToKebabCase)(futureProp);
39
+ if (shorthands.includes(futureKebab)) {
40
+ isOverridden = true;
41
+ break;
42
+ }
43
+ }
44
+ if (!isOverridden) {
45
+ finalStyle[prop] = style[prop];
46
+ }
36
47
  }
37
48
  }
38
- }
49
+ return finalStyle;
50
+ };
51
+ const finalFlat = overrideLonghand(flat);
39
52
  const records = [];
40
53
  Object.entries(finalFlat).forEach(([prop, value]) => {
41
54
  const hashes = new Set();
@@ -60,10 +73,14 @@ function compileToSingleCSS(object) {
60
73
  });
61
74
  });
62
75
  if (Object.keys(nonFlat).length > 0) {
63
- const nonFlatObj = { [key]: nonFlat };
76
+ const finalNonFlat = {};
77
+ Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
78
+ finalNonFlat[atRule] = overrideLonghand(nestedObj);
79
+ });
80
+ const nonFlatObj = { [key]: finalNonFlat };
64
81
  const nonFlatHash = (0, zss_engine_1.genBase36Hash)(nonFlatObj, 1, 7);
65
82
  const { styleSheet } = (0, zss_engine_1.transpile)(nonFlatObj, nonFlatHash);
66
- Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
83
+ Object.entries(finalNonFlat).forEach(([atRule, nestedObj]) => {
67
84
  Object.entries(nestedObj).forEach(([prop]) => {
68
85
  records.push({
69
86
  key: atRule + prop,
@@ -42,7 +42,6 @@ const t = __importStar(require("@babel/types"));
42
42
  const path_1 = __importDefault(require("path"));
43
43
  const fs_1 = __importDefault(require("fs"));
44
44
  const create_1 = require("./create");
45
- const glob_1 = require("@rust-gear/glob");
46
45
  const zss_engine_1 = require("zss-engine");
47
46
  const PROJECT_ROOT = process.cwd().split('node_modules')[0];
48
47
  const PATTERN_PATH = path_1.default.join(PROJECT_ROOT, '**/*.{js,jsx,ts,tsx}');
@@ -289,7 +288,7 @@ function resolveTokensTableMemberExpressionByNode(node, tokensTable) {
289
288
  function scanForKeyframes() {
290
289
  const keyframesHashTableLocal = {};
291
290
  const keyframesObjectTableLocal = {};
292
- const files = (0, glob_1.globSync)(PATTERN_PATH, GLOB_OPTIONS);
291
+ const files = fs_1.default.globSync(PATTERN_PATH, GLOB_OPTIONS);
293
292
  for (const filePath of files) {
294
293
  if (!isCSSDefineFile(filePath, 'keyframes'))
295
294
  continue;
@@ -336,7 +335,7 @@ function scanForKeyframes() {
336
335
  function scanForViewTransition() {
337
336
  const viewTransitionHashTableLocal = {};
338
337
  const viewTransitionObjectTableLocal = {};
339
- const files = (0, glob_1.globSync)(PATTERN_PATH, GLOB_OPTIONS);
338
+ const files = fs_1.default.globSync(PATTERN_PATH, GLOB_OPTIONS);
340
339
  for (const filePath of files) {
341
340
  if (!isCSSDefineFile(filePath, 'viewTransition'))
342
341
  continue;
@@ -384,7 +383,7 @@ function scanForViewTransition() {
384
383
  }
385
384
  function scanForDefineConsts() {
386
385
  const constTableLocal = {};
387
- const files = (0, glob_1.globSync)(PATTERN_PATH, GLOB_OPTIONS);
386
+ const files = fs_1.default.globSync(PATTERN_PATH, GLOB_OPTIONS);
388
387
  for (const filePath of files) {
389
388
  if (!isCSSDefineFile(filePath, 'defineConsts'))
390
389
  continue;
@@ -426,7 +425,7 @@ function scanForDefineConsts() {
426
425
  function scanForDefineTokens() {
427
426
  const tokensTableLocal = {};
428
427
  const defineTokensObjectTableLocal = {};
429
- const files = (0, glob_1.globSync)(PATTERN_PATH, GLOB_OPTIONS);
428
+ const files = fs_1.default.globSync(PATTERN_PATH, GLOB_OPTIONS);
430
429
  for (const filePath of files) {
431
430
  if (!isCSSDefineFile(filePath, 'defineTokens'))
432
431
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/webpack-plugin",
3
- "version": "0.22.3",
3
+ "version": "0.23.0",
4
4
  "description": "Plumeria Webpack plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,6 @@
21
21
  "@babel/types": "^7.28.2"
22
22
  },
23
23
  "devDependencies": {
24
- "@rust-gear/glob": "^0.2.2",
25
24
  "@types/babel__core": "^7.20.5",
26
25
  "webpack": "^5.101.0",
27
26
  "zss-engine": "^0.2.94"