zss-engine 1.2.1 → 2.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.
@@ -3,18 +3,20 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.build = void 0;
5
5
  const helper_js_1 = require("./helper.js");
6
- const build = async (styleSheet, filePath, global) => {
6
+ const build = async (styleSheet, filePath) => {
7
7
  if (!helper_js_1.isServer)
8
8
  return;
9
9
  const fs = await import('fs');
10
- const message = global === '--global' ? `defines💫:\n\n` : `props💫:\n\n`;
11
10
  try {
12
11
  if (fs.existsSync(filePath)) {
13
- const cssData = fs.readFileSync(filePath, 'utf-8');
14
- if (!cssData.includes(styleSheet)) {
12
+ const css = fs.readFileSync(filePath, 'utf-8');
13
+ if (!css.includes(styleSheet)) {
15
14
  fs.appendFileSync(filePath, styleSheet, 'utf-8');
16
- if (process.argv.includes('--view'))
17
- console.log(message + styleSheet);
15
+ if (process.argv.includes('--view')) {
16
+ const { styleText } = await import('util');
17
+ const line = styleText('gray', '─'.repeat(60));
18
+ console.log('\n' + styleText(['green', 'bold'], '✓ extract...') + '\n\n' + styleText('cyan', styleSheet) + '\n' + line);
19
+ }
18
20
  }
19
21
  }
20
22
  return;
@@ -50,7 +50,9 @@ function transpile(object, base36Hash, core) {
50
50
  }
51
51
  else if (!property.startsWith('@')) {
52
52
  const kebabPseudoSelector = (0, helper_js_1.camelToKebabCase)(property.replace('&', ''));
53
- const styles = stringConverter(className + kebabPseudoSelector, value, indentLevel);
53
+ const isPseudo = property.startsWith(':') || property.startsWith('&');
54
+ const selector = isPseudo ? className + ':not(#\\#)' + kebabPseudoSelector : className + kebabPseudoSelector;
55
+ const styles = stringConverter(selector, value, indentLevel);
54
56
  Object.assign(classSelector, styles);
55
57
  }
56
58
  else if (property.startsWith('@media') || property.startsWith('@container')) {
@@ -64,6 +66,7 @@ function transpile(object, base36Hash, core) {
64
66
  const isAnd = mediaProp.startsWith('&');
65
67
  if (isColon || isAnd) {
66
68
  const kebabMediaProp = (0, helper_js_1.camelToKebabCase)(mediaProp.replace('&', ''));
69
+ const increaseKebabMediaProp = ':not(#\\#)' + kebabMediaProp;
67
70
  let pseudoClassRule = '';
68
71
  if (typeof mediaValue === 'object' && mediaValue !== null) {
69
72
  for (const pseudoProp in mediaValue) {
@@ -74,7 +77,7 @@ function transpile(object, base36Hash, core) {
74
77
  }
75
78
  }
76
79
  }
77
- nestedRules += `${innerIndent}${className}${kebabMediaProp} {\n${pseudoClassRule}${innerIndent}}\n`;
80
+ nestedRules += `${innerIndent}${className}${increaseKebabMediaProp} {\n${pseudoClassRule}${innerIndent}}\n`;
78
81
  }
79
82
  else {
80
83
  const CSSProp = (0, helper_js_1.camelToKebabCase)(mediaProp);
@@ -1,17 +1,19 @@
1
1
  'use server';
2
2
  import { isServer } from './helper.js';
3
- export const build = async (styleSheet, filePath, global) => {
3
+ export const build = async (styleSheet, filePath) => {
4
4
  if (!isServer)
5
5
  return;
6
6
  const fs = await import('fs');
7
- const message = global === '--global' ? `defines💫:\n\n` : `props💫:\n\n`;
8
7
  try {
9
8
  if (fs.existsSync(filePath)) {
10
- const cssData = fs.readFileSync(filePath, 'utf-8');
11
- if (!cssData.includes(styleSheet)) {
9
+ const css = fs.readFileSync(filePath, 'utf-8');
10
+ if (!css.includes(styleSheet)) {
12
11
  fs.appendFileSync(filePath, styleSheet, 'utf-8');
13
- if (process.argv.includes('--view'))
14
- console.log(message + styleSheet);
12
+ if (process.argv.includes('--view')) {
13
+ const { styleText } = await import('util');
14
+ const line = styleText('gray', '─'.repeat(60));
15
+ console.log('\n' + styleText(['green', 'bold'], '✓ extract...') + '\n\n' + styleText('cyan', styleSheet) + '\n' + line);
16
+ }
15
17
  }
16
18
  }
17
19
  return;
@@ -47,7 +47,9 @@ export function transpile(object, base36Hash, core) {
47
47
  }
48
48
  else if (!property.startsWith('@')) {
49
49
  const kebabPseudoSelector = camelToKebabCase(property.replace('&', ''));
50
- const styles = stringConverter(className + kebabPseudoSelector, value, indentLevel);
50
+ const isPseudo = property.startsWith(':') || property.startsWith('&');
51
+ const selector = isPseudo ? className + ':not(#\\#)' + kebabPseudoSelector : className + kebabPseudoSelector;
52
+ const styles = stringConverter(selector, value, indentLevel);
51
53
  Object.assign(classSelector, styles);
52
54
  }
53
55
  else if (property.startsWith('@media') || property.startsWith('@container')) {
@@ -61,6 +63,7 @@ export function transpile(object, base36Hash, core) {
61
63
  const isAnd = mediaProp.startsWith('&');
62
64
  if (isColon || isAnd) {
63
65
  const kebabMediaProp = camelToKebabCase(mediaProp.replace('&', ''));
66
+ const increaseKebabMediaProp = ':not(#\\#)' + kebabMediaProp;
64
67
  let pseudoClassRule = '';
65
68
  if (typeof mediaValue === 'object' && mediaValue !== null) {
66
69
  for (const pseudoProp in mediaValue) {
@@ -71,7 +74,7 @@ export function transpile(object, base36Hash, core) {
71
74
  }
72
75
  }
73
76
  }
74
- nestedRules += `${innerIndent}${className}${kebabMediaProp} {\n${pseudoClassRule}${innerIndent}}\n`;
77
+ nestedRules += `${innerIndent}${className}${increaseKebabMediaProp} {\n${pseudoClassRule}${innerIndent}}\n`;
75
78
  }
76
79
  else {
77
80
  const CSSProp = camelToKebabCase(mediaProp);
@@ -1 +1 @@
1
- export declare const build: (styleSheet: string, filePath: string, global?: string) => Promise<void>;
1
+ export declare const build: (styleSheet: string, filePath: string) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zss-engine",
3
- "version": "1.2.1",
3
+ "version": "2.0.0",
4
4
  "description": "Zero-runtime StyleSheet Engine",
5
5
  "funding": "https://github.com/sponsors/refirst11",
6
6
  "author": "Refirst 11",