zss-engine 0.2.94 → 0.2.95

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/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isHashInStyleSheets = exports.injectClientGlobalCSS = exports.injectClientQuery = exports.injectClientCSS = exports.applyCssValue = exports.camelToKebabCase = exports.build = exports.LONG_TO_SHORT = exports.SHORTHAND_PROPERTIES = exports.processAtomicProps = exports.splitAtomicAndNested = exports.transpileAtomic = exports.transpile = exports.genBase36Hash = exports.isTestingDevelopment = exports.isDevelopment = exports.isServer = void 0;
3
+ exports.isHashInStyleSheets = exports.injectClientGlobalCSS = exports.injectClientQuery = exports.injectClientCSS = exports.applyCssValue = exports.camelToKebabCase = exports.build = exports.overrideLonghand = exports.LONG_TO_SHORT = exports.SHORTHAND_PROPERTIES = exports.processAtomicProps = exports.splitAtomicAndNested = exports.transpileAtomic = exports.transpile = exports.genBase36Hash = exports.isTestingDevelopment = exports.isDevelopment = exports.isServer = void 0;
4
4
  var helper_js_1 = require("./utils/helper.js");
5
5
  Object.defineProperty(exports, "isServer", { enumerable: true, get: function () { return helper_js_1.isServer; } });
6
6
  Object.defineProperty(exports, "isDevelopment", { enumerable: true, get: function () { return helper_js_1.isDevelopment; } });
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "processAtomicProps", { enumerable: true, get: fu
17
17
  var shorthand_js_1 = require("./utils/shorthand.js");
18
18
  Object.defineProperty(exports, "SHORTHAND_PROPERTIES", { enumerable: true, get: function () { return shorthand_js_1.SHORTHAND_PROPERTIES; } });
19
19
  Object.defineProperty(exports, "LONG_TO_SHORT", { enumerable: true, get: function () { return shorthand_js_1.LONG_TO_SHORT; } });
20
+ var override_longhand_1 = require("./utils/override-longhand");
21
+ Object.defineProperty(exports, "overrideLonghand", { enumerable: true, get: function () { return override_longhand_1.overrideLonghand; } });
20
22
  var build_js_1 = require("./utils/build.js");
21
23
  Object.defineProperty(exports, "build", { enumerable: true, get: function () { return build_js_1.build; } });
22
24
  var helper_js_2 = require("./utils/helper.js");
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.overrideLonghand = void 0;
4
+ const __1 = require("..");
5
+ const overrideLonghand = (style) => {
6
+ const props = Object.keys(style);
7
+ const propsToRemove = new Set();
8
+ const plainProps = [];
9
+ for (let i = 0; i < props.length; i++) {
10
+ if (!props[i].startsWith('@')) {
11
+ plainProps.push({ key: props[i], index: i });
12
+ }
13
+ }
14
+ const shorthandsInStyle = {};
15
+ for (const { key, index } of plainProps) {
16
+ const kebab = (0, __1.camelToKebabCase)(key);
17
+ if (__1.SHORTHAND_PROPERTIES[kebab]) {
18
+ shorthandsInStyle[kebab] = index;
19
+ }
20
+ }
21
+ for (const { key, index } of plainProps) {
22
+ const kebab = (0, __1.camelToKebabCase)(key);
23
+ if (!__1.SHORTHAND_PROPERTIES[kebab]) {
24
+ const longhands = __1.LONG_TO_SHORT[kebab] || [];
25
+ for (const shorthand of longhands) {
26
+ if (shorthandsInStyle[shorthand] > index) {
27
+ propsToRemove.add(key);
28
+ break;
29
+ }
30
+ }
31
+ }
32
+ }
33
+ const finalStyle = {};
34
+ for (const prop of props) {
35
+ if (propsToRemove.has(prop)) {
36
+ continue;
37
+ }
38
+ if (prop.startsWith('@')) {
39
+ finalStyle[prop] = (0, exports.overrideLonghand)(style[prop]);
40
+ }
41
+ else {
42
+ finalStyle[prop] = style[prop];
43
+ }
44
+ }
45
+ return finalStyle;
46
+ };
47
+ exports.overrideLonghand = overrideLonghand;
package/dist/esm/index.js CHANGED
@@ -4,6 +4,7 @@ export { transpile } from './utils/transpile.js';
4
4
  export { transpileAtomic } from './utils/transpile-atomic.js';
5
5
  export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
6
6
  export { SHORTHAND_PROPERTIES, LONG_TO_SHORT } from './utils/shorthand.js';
7
+ export { overrideLonghand } from './utils/override-longhand';
7
8
  export { build } from './utils/build.js';
8
9
  export { camelToKebabCase, applyCssValue } from './utils/helper.js';
9
10
  export { injectClientCSS, injectClientQuery } from './utils/inject-client-css.js';
@@ -0,0 +1,43 @@
1
+ import { camelToKebabCase, LONG_TO_SHORT, SHORTHAND_PROPERTIES } from '..';
2
+ export const overrideLonghand = (style) => {
3
+ const props = Object.keys(style);
4
+ const propsToRemove = new Set();
5
+ const plainProps = [];
6
+ for (let i = 0; i < props.length; i++) {
7
+ if (!props[i].startsWith('@')) {
8
+ plainProps.push({ key: props[i], index: i });
9
+ }
10
+ }
11
+ const shorthandsInStyle = {};
12
+ for (const { key, index } of plainProps) {
13
+ const kebab = camelToKebabCase(key);
14
+ if (SHORTHAND_PROPERTIES[kebab]) {
15
+ shorthandsInStyle[kebab] = index;
16
+ }
17
+ }
18
+ for (const { key, index } of plainProps) {
19
+ const kebab = camelToKebabCase(key);
20
+ if (!SHORTHAND_PROPERTIES[kebab]) {
21
+ const longhands = LONG_TO_SHORT[kebab] || [];
22
+ for (const shorthand of longhands) {
23
+ if (shorthandsInStyle[shorthand] > index) {
24
+ propsToRemove.add(key);
25
+ break;
26
+ }
27
+ }
28
+ }
29
+ }
30
+ const finalStyle = {};
31
+ for (const prop of props) {
32
+ if (propsToRemove.has(prop)) {
33
+ continue;
34
+ }
35
+ if (prop.startsWith('@')) {
36
+ finalStyle[prop] = overrideLonghand(style[prop]);
37
+ }
38
+ else {
39
+ finalStyle[prop] = style[prop];
40
+ }
41
+ }
42
+ return finalStyle;
43
+ };
@@ -9,6 +9,7 @@ export { transpile } from './utils/transpile.js';
9
9
  export { transpileAtomic } from './utils/transpile-atomic.js';
10
10
  export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
11
11
  export { SHORTHAND_PROPERTIES, LONG_TO_SHORT } from './utils/shorthand.js';
12
+ export { overrideLonghand } from './utils/override-longhand';
12
13
  export { build } from './utils/build.js';
13
14
  export { camelToKebabCase, applyCssValue } from './utils/helper.js';
14
15
  export { injectClientCSS, injectClientQuery } from './utils/inject-client-css.js';
@@ -0,0 +1,2 @@
1
+ import { CreateStyle } from '..';
2
+ export declare const overrideLonghand: (style: CreateStyle) => CreateStyle;
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "zss-engine",
3
- "version": "0.2.94",
3
+ "version": "0.2.95",
4
4
  "description": "Zero-runtime StyleSheet Engine",
5
5
  "funding": "https://github.com/sponsors/refirst11",
6
6
  "author": "Refirst 11",
7
7
  "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/zss-in-js/zss-engine.git",
11
- "directory": "packages/core"
10
+ "url": "git+https://github.com/zss-in-js/zss-engine.git"
12
11
  },
13
12
  "bugs": {
14
13
  "url": "https://github.com/zss-in-js/zss-engine/issues"