@plumeria/core 0.24.1 → 0.24.3

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.js CHANGED
@@ -10,31 +10,33 @@ function create(object) {
10
10
  (0, zss_engine.splitAtomicAndNested)(styleObj, flat, nonFlat);
11
11
  const overrideLonghand = (style) => {
12
12
  const props$1 = Object.keys(style);
13
- if (props$1.some((p) => p.startsWith("@"))) {
14
- const finalStyle$1 = { ...style };
15
- for (const key$1 of props$1) if (key$1.startsWith("@")) finalStyle$1[key$1] = overrideLonghand(style[key$1]);
16
- return finalStyle$1;
13
+ const propsToRemove = new Set();
14
+ const plainProps = [];
15
+ for (let i = 0; i < props$1.length; i++) if (!props$1[i].startsWith("@")) plainProps.push({
16
+ key: props$1[i],
17
+ index: i
18
+ });
19
+ const shorthandsInStyle = {};
20
+ for (const { key: key$1, index } of plainProps) {
21
+ const kebab = (0, zss_engine.camelToKebabCase)(key$1);
22
+ if (zss_engine.SHORTHAND_PROPERTIES[kebab]) shorthandsInStyle[kebab] = index;
17
23
  }
18
- const finalStyle = {};
19
- for (let i = 0; i < props$1.length; i++) {
20
- const prop = props$1[i];
21
- const kebab = (0, zss_engine.camelToKebabCase)(prop);
22
- const isShorthand = !!zss_engine.SHORTHAND_PROPERTIES[kebab];
23
- if (isShorthand) finalStyle[prop] = style[prop];
24
- else {
25
- let isOverridden = false;
26
- const shorthands = zss_engine.LONG_TO_SHORT[kebab] || [];
27
- for (let j = i + 1; j < props$1.length; j++) {
28
- const futureProp = props$1[j];
29
- const futureKebab = (0, zss_engine.camelToKebabCase)(futureProp);
30
- if (shorthands.includes(futureKebab)) {
31
- isOverridden = true;
32
- break;
33
- }
24
+ for (const { key: key$1, index } of plainProps) {
25
+ const kebab = (0, zss_engine.camelToKebabCase)(key$1);
26
+ if (!zss_engine.SHORTHAND_PROPERTIES[kebab]) {
27
+ const longhands = zss_engine.LONG_TO_SHORT[kebab] || [];
28
+ for (const shorthand of longhands) if (shorthandsInStyle[shorthand] > index) {
29
+ propsToRemove.add(key$1);
30
+ break;
34
31
  }
35
- if (!isOverridden) finalStyle[prop] = style[prop];
36
32
  }
37
33
  }
34
+ const finalStyle = {};
35
+ for (const prop of props$1) {
36
+ if (propsToRemove.has(prop)) continue;
37
+ if (prop.startsWith("@")) finalStyle[prop] = overrideLonghand(style[prop]);
38
+ else finalStyle[prop] = style[prop];
39
+ }
38
40
  return finalStyle;
39
41
  };
40
42
  const finalFlat = overrideLonghand(flat);
@@ -72,14 +74,10 @@ function create(object) {
72
74
  });
73
75
  });
74
76
  if (Object.keys(nonFlat).length > 0) {
75
- const finalNonFlat = {};
76
- Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
77
- finalNonFlat[atRule] = overrideLonghand(nestedObj);
78
- });
79
- const nonFlatObj = { [key]: finalNonFlat };
77
+ const nonFlatObj = { [key]: nonFlat };
80
78
  const nonFlatHash = (0, zss_engine.genBase36Hash)(nonFlatObj, 1, 7);
81
79
  const { styleSheet } = (0, zss_engine.transpile)(nonFlatObj, nonFlatHash);
82
- Object.entries(finalNonFlat).forEach(([atRule, nestedObj]) => {
80
+ Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
83
81
  Object.keys(nestedObj).forEach((prop) => {
84
82
  records.push({
85
83
  key: atRule + prop,
package/dist/index.mjs CHANGED
@@ -10,31 +10,33 @@ function create(object) {
10
10
  splitAtomicAndNested(styleObj, flat, nonFlat);
11
11
  const overrideLonghand = (style) => {
12
12
  const props$1 = Object.keys(style);
13
- if (props$1.some((p) => p.startsWith("@"))) {
14
- const finalStyle$1 = { ...style };
15
- for (const key$1 of props$1) if (key$1.startsWith("@")) finalStyle$1[key$1] = overrideLonghand(style[key$1]);
16
- return finalStyle$1;
13
+ const propsToRemove = new Set();
14
+ const plainProps = [];
15
+ for (let i = 0; i < props$1.length; i++) if (!props$1[i].startsWith("@")) plainProps.push({
16
+ key: props$1[i],
17
+ index: i
18
+ });
19
+ const shorthandsInStyle = {};
20
+ for (const { key: key$1, index } of plainProps) {
21
+ const kebab = camelToKebabCase(key$1);
22
+ if (SHORTHAND_PROPERTIES[kebab]) shorthandsInStyle[kebab] = index;
17
23
  }
18
- const finalStyle = {};
19
- for (let i = 0; i < props$1.length; i++) {
20
- const prop = props$1[i];
21
- const kebab = camelToKebabCase(prop);
22
- const isShorthand = !!SHORTHAND_PROPERTIES[kebab];
23
- if (isShorthand) finalStyle[prop] = style[prop];
24
- else {
25
- let isOverridden = false;
26
- const shorthands = LONG_TO_SHORT[kebab] || [];
27
- for (let j = i + 1; j < props$1.length; j++) {
28
- const futureProp = props$1[j];
29
- const futureKebab = camelToKebabCase(futureProp);
30
- if (shorthands.includes(futureKebab)) {
31
- isOverridden = true;
32
- break;
33
- }
24
+ for (const { key: key$1, index } of plainProps) {
25
+ const kebab = camelToKebabCase(key$1);
26
+ if (!SHORTHAND_PROPERTIES[kebab]) {
27
+ const longhands = LONG_TO_SHORT[kebab] || [];
28
+ for (const shorthand of longhands) if (shorthandsInStyle[shorthand] > index) {
29
+ propsToRemove.add(key$1);
30
+ break;
34
31
  }
35
- if (!isOverridden) finalStyle[prop] = style[prop];
36
32
  }
37
33
  }
34
+ const finalStyle = {};
35
+ for (const prop of props$1) {
36
+ if (propsToRemove.has(prop)) continue;
37
+ if (prop.startsWith("@")) finalStyle[prop] = overrideLonghand(style[prop]);
38
+ else finalStyle[prop] = style[prop];
39
+ }
38
40
  return finalStyle;
39
41
  };
40
42
  const finalFlat = overrideLonghand(flat);
@@ -72,14 +74,10 @@ function create(object) {
72
74
  });
73
75
  });
74
76
  if (Object.keys(nonFlat).length > 0) {
75
- const finalNonFlat = {};
76
- Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
77
- finalNonFlat[atRule] = overrideLonghand(nestedObj);
78
- });
79
- const nonFlatObj = { [key]: finalNonFlat };
77
+ const nonFlatObj = { [key]: nonFlat };
80
78
  const nonFlatHash = genBase36Hash(nonFlatObj, 1, 7);
81
79
  const { styleSheet } = transpile(nonFlatObj, nonFlatHash);
82
- Object.entries(finalNonFlat).forEach(([atRule, nestedObj]) => {
80
+ Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
83
81
  Object.keys(nestedObj).forEach((prop) => {
84
82
  records.push({
85
83
  key: atRule + prop,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/core",
3
- "version": "0.24.1",
3
+ "version": "0.24.3",
4
4
  "description": "The atomic on-demand CSS-in-JS.",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",