zss-engine 0.2.102 → 1.1.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/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.overrideLonghand = exports.processAtomicProps = exports.splitAtomicAndNested = exports.transformNestedSelectors = exports.transpileAtomic = exports.transpile = exports.genBase36Hash = exports.isTestingDevelopment = exports.isDevelopment = exports.isServer = void 0;
3
+ exports.applyCssValue = exports.camelToKebabCase = exports.build = exports.overrideLonghand = 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; } });
@@ -11,8 +11,6 @@ var transpile_js_1 = require("./utils/transpile.js");
11
11
  Object.defineProperty(exports, "transpile", { enumerable: true, get: function () { return transpile_js_1.transpile; } });
12
12
  var transpile_atomic_js_1 = require("./utils/transpile-atomic.js");
13
13
  Object.defineProperty(exports, "transpileAtomic", { enumerable: true, get: function () { return transpile_atomic_js_1.transpileAtomic; } });
14
- var transform_nested_selectors_js_1 = require("./utils/transform-nested-selectors.js");
15
- Object.defineProperty(exports, "transformNestedSelectors", { enumerable: true, get: function () { return transform_nested_selectors_js_1.transformNestedSelectors; } });
16
14
  var processor_atomic_js_1 = require("./utils/processor-atomic.js");
17
15
  Object.defineProperty(exports, "splitAtomicAndNested", { enumerable: true, get: function () { return processor_atomic_js_1.splitAtomicAndNested; } });
18
16
  Object.defineProperty(exports, "processAtomicProps", { enumerable: true, get: function () { return processor_atomic_js_1.processAtomicProps; } });
@@ -23,10 +21,3 @@ Object.defineProperty(exports, "build", { enumerable: true, get: function () { r
23
21
  var helper_js_2 = require("./utils/helper.js");
24
22
  Object.defineProperty(exports, "camelToKebabCase", { enumerable: true, get: function () { return helper_js_2.camelToKebabCase; } });
25
23
  Object.defineProperty(exports, "applyCssValue", { enumerable: true, get: function () { return helper_js_2.applyCssValue; } });
26
- var inject_client_css_js_1 = require("./utils/inject-client-css.js");
27
- Object.defineProperty(exports, "injectClientCSS", { enumerable: true, get: function () { return inject_client_css_js_1.injectClientCSS; } });
28
- Object.defineProperty(exports, "injectClientQuery", { enumerable: true, get: function () { return inject_client_css_js_1.injectClientQuery; } });
29
- var inject_client_global_css_js_1 = require("./utils/inject-client-global-css.js");
30
- Object.defineProperty(exports, "injectClientGlobalCSS", { enumerable: true, get: function () { return inject_client_global_css_js_1.injectClientGlobalCSS; } });
31
- var is_hash_in_style_sheets_js_1 = require("./utils/is-hash-in-style-sheets.js");
32
- Object.defineProperty(exports, "isHashInStyleSheets", { enumerable: true, get: function () { return is_hash_in_style_sheets_js_1.isHashInStyleSheets; } });
package/dist/esm/index.js CHANGED
@@ -2,11 +2,7 @@ export { isServer, isDevelopment, isTestingDevelopment } from './utils/helper.js
2
2
  export { genBase36Hash } from './utils/hash.js';
3
3
  export { transpile } from './utils/transpile.js';
4
4
  export { transpileAtomic } from './utils/transpile-atomic.js';
5
- export { transformNestedSelectors } from './utils/transform-nested-selectors.js';
6
5
  export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
7
6
  export { overrideLonghand } from './utils/override-longhand.js';
8
7
  export { build } from './utils/build.js';
9
8
  export { camelToKebabCase, applyCssValue } from './utils/helper.js';
10
- export { injectClientCSS, injectClientQuery } from './utils/inject-client-css.js';
11
- export { injectClientGlobalCSS } from './utils/inject-client-global-css.js';
12
- export { isHashInStyleSheets } from './utils/is-hash-in-style-sheets.js';
@@ -1,17 +1,13 @@
1
1
  export type { CSSProperties } from './types/common/css-properties';
2
2
  export type { CreateStyleType, ReturnType, CreateStyle } from './types/main/create';
3
3
  export type { CSSHTML, CreateKeyframes } from './types/main/global';
4
- export type { CreateValues, CreateTokens, ReturnVariableType, RxVariableSet, ReturnRx } from './types/main/variableTypes';
4
+ export type { CreateTheme, CreateValues, ReturnVariableType, XVariableSet, ReturnX } from './types/main/variableTypes';
5
5
  export type { ViewTransitionOptions } from './types/main/viewTransitionOptions';
6
6
  export { isServer, isDevelopment, isTestingDevelopment } from './utils/helper.js';
7
7
  export { genBase36Hash } from './utils/hash.js';
8
8
  export { transpile } from './utils/transpile.js';
9
9
  export { transpileAtomic } from './utils/transpile-atomic.js';
10
- export { transformNestedSelectors } from './utils/transform-nested-selectors.js';
11
10
  export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
12
11
  export { overrideLonghand } from './utils/override-longhand.js';
13
12
  export { build } from './utils/build.js';
14
13
  export { camelToKebabCase, applyCssValue } from './utils/helper.js';
15
- export { injectClientCSS, injectClientQuery } from './utils/inject-client-css.js';
16
- export { injectClientGlobalCSS } from './utils/inject-client-global-css.js';
17
- export { isHashInStyleSheets } from './utils/is-hash-in-style-sheets.js';
@@ -4,14 +4,14 @@ export type CSSVariableProperty = {
4
4
  [key: CSSVariableKey]: string | number;
5
5
  };
6
6
  export type CreateValues = Record<string, string | number>;
7
- export type CreateTokens = Record<string, Record<string, string | number>>;
7
+ export type CreateTheme = Record<string, Record<string, string | number>>;
8
8
  export type ReturnVariableType<T> = {
9
9
  [K in keyof T]: CSSVariableValue;
10
10
  };
11
- export type RxVariableSet = {
11
+ export type XVariableSet = {
12
12
  [key: CSSVariableKey]: string;
13
13
  };
14
- export type ReturnRx = {
14
+ export type ReturnX = {
15
15
  className: string;
16
16
  style: {
17
17
  [k: string]: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zss-engine",
3
- "version": "0.2.102",
3
+ "version": "1.1.0",
4
4
  "description": "Zero-runtime StyleSheet Engine",
5
5
  "funding": "https://github.com/sponsors/refirst11",
6
6
  "author": "Refirst 11",
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.injectClientCSS = injectClientCSS;
4
- exports.injectClientQuery = injectClientQuery;
5
- const index_js_1 = require("../index.js");
6
- const styleCache = {};
7
- let clientStyleElement = null;
8
- let queryStyleElement = null;
9
- function createClientStyleElement() {
10
- if (!clientStyleElement) {
11
- clientStyleElement = document.querySelector('style[data-scope="client"]');
12
- if (!clientStyleElement) {
13
- clientStyleElement = document.createElement('style');
14
- clientStyleElement.setAttribute('data-scope', 'client');
15
- clientStyleElement.setAttribute('type', 'text/css');
16
- document.head.prepend(clientStyleElement);
17
- }
18
- }
19
- return clientStyleElement;
20
- }
21
- function createQueryStyleElement() {
22
- if (!queryStyleElement) {
23
- queryStyleElement = document.querySelector('style[data-scope="query"]');
24
- if (!queryStyleElement) {
25
- queryStyleElement = document.createElement('style');
26
- queryStyleElement.setAttribute('data-scope', 'query');
27
- queryStyleElement.setAttribute('type', 'text/css');
28
- document.head.appendChild(queryStyleElement);
29
- }
30
- }
31
- return queryStyleElement;
32
- }
33
- function injectClientCSS(hash, sheet) {
34
- if (index_js_1.isServer)
35
- return;
36
- if (styleCache[hash])
37
- return;
38
- styleCache[hash] = sheet;
39
- const clientElement = createClientStyleElement();
40
- clientElement.textContent = sheet + (clientElement.textContent || '');
41
- }
42
- function injectClientQuery(hash, sheet) {
43
- if (index_js_1.isServer)
44
- return;
45
- if (styleCache[hash])
46
- return;
47
- styleCache[hash] = sheet;
48
- if (sheet.includes('@media') || sheet.includes('@container')) {
49
- const queryElement = createQueryStyleElement();
50
- queryElement.textContent = (queryElement.textContent || '') + sheet;
51
- }
52
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.injectClientGlobalCSS = injectClientGlobalCSS;
4
- const index_js_1 = require("../index.js");
5
- function injectClientGlobalCSS(sheet) {
6
- if (index_js_1.isServer)
7
- return;
8
- const existingStyleElement = document.querySelector(`[data-scope="global"]`);
9
- if (existingStyleElement instanceof HTMLStyleElement) {
10
- existingStyleElement.textContent += sheet;
11
- return;
12
- }
13
- const styleElement = document.createElement('style');
14
- styleElement.setAttribute('data-scope', 'global');
15
- styleElement.setAttribute('type', 'text/css');
16
- styleElement.textContent = sheet;
17
- document.head.appendChild(styleElement);
18
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isHashInStyleSheets = isHashInStyleSheets;
4
- function isHashInStyleSheets(hash) {
5
- const sheets = Array.from(document.styleSheets);
6
- function checkRule(rule) {
7
- if (rule instanceof CSSStyleRule && rule.selectorText) {
8
- return hasHashInSelector(rule.selectorText, hash);
9
- }
10
- if (rule instanceof CSSMediaRule) {
11
- return Array.from(rule.cssRules).some(checkRule);
12
- }
13
- if (rule instanceof CSSContainerRule) {
14
- return Array.from(rule.cssRules).some(checkRule);
15
- }
16
- if (rule instanceof CSSSupportsRule) {
17
- return Array.from(rule.cssRules).some(checkRule);
18
- }
19
- if ('cssRules' in rule && rule.cssRules) {
20
- return Array.from(rule.cssRules).some(checkRule);
21
- }
22
- return false;
23
- }
24
- function hasHashInSelector(selectorText, hash) {
25
- const selectors = selectorText.split(',').map(s => s.trim());
26
- return selectors.some(selector => {
27
- const classPattern = new RegExp(`\\.${escapeRegExp(hash)}(?![\\w-])`);
28
- return classPattern.test(selector);
29
- });
30
- }
31
- function escapeRegExp(string) {
32
- return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
33
- }
34
- return sheets.some(sheet => {
35
- try {
36
- return Array.from(sheet.cssRules).some(checkRule);
37
- }
38
- catch (_err) {
39
- return false;
40
- }
41
- });
42
- }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformNestedSelectors = transformNestedSelectors;
4
- function transformNestedSelectors(nonFlat) {
5
- const modNonFlat = {};
6
- Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
7
- if (atRule.startsWith(':') || atRule.startsWith('&')) {
8
- modNonFlat[`:not(#\\#)${atRule}`] = nestedObj;
9
- }
10
- else {
11
- modNonFlat[atRule] = nestedObj;
12
- }
13
- });
14
- return modNonFlat;
15
- }
@@ -1,48 +0,0 @@
1
- import { isServer } from '../index.js';
2
- const styleCache = {};
3
- let clientStyleElement = null;
4
- let queryStyleElement = null;
5
- function createClientStyleElement() {
6
- if (!clientStyleElement) {
7
- clientStyleElement = document.querySelector('style[data-scope="client"]');
8
- if (!clientStyleElement) {
9
- clientStyleElement = document.createElement('style');
10
- clientStyleElement.setAttribute('data-scope', 'client');
11
- clientStyleElement.setAttribute('type', 'text/css');
12
- document.head.prepend(clientStyleElement);
13
- }
14
- }
15
- return clientStyleElement;
16
- }
17
- function createQueryStyleElement() {
18
- if (!queryStyleElement) {
19
- queryStyleElement = document.querySelector('style[data-scope="query"]');
20
- if (!queryStyleElement) {
21
- queryStyleElement = document.createElement('style');
22
- queryStyleElement.setAttribute('data-scope', 'query');
23
- queryStyleElement.setAttribute('type', 'text/css');
24
- document.head.appendChild(queryStyleElement);
25
- }
26
- }
27
- return queryStyleElement;
28
- }
29
- export function injectClientCSS(hash, sheet) {
30
- if (isServer)
31
- return;
32
- if (styleCache[hash])
33
- return;
34
- styleCache[hash] = sheet;
35
- const clientElement = createClientStyleElement();
36
- clientElement.textContent = sheet + (clientElement.textContent || '');
37
- }
38
- export function injectClientQuery(hash, sheet) {
39
- if (isServer)
40
- return;
41
- if (styleCache[hash])
42
- return;
43
- styleCache[hash] = sheet;
44
- if (sheet.includes('@media') || sheet.includes('@container')) {
45
- const queryElement = createQueryStyleElement();
46
- queryElement.textContent = (queryElement.textContent || '') + sheet;
47
- }
48
- }
@@ -1,15 +0,0 @@
1
- import { isServer } from '../index.js';
2
- export function injectClientGlobalCSS(sheet) {
3
- if (isServer)
4
- return;
5
- const existingStyleElement = document.querySelector(`[data-scope="global"]`);
6
- if (existingStyleElement instanceof HTMLStyleElement) {
7
- existingStyleElement.textContent += sheet;
8
- return;
9
- }
10
- const styleElement = document.createElement('style');
11
- styleElement.setAttribute('data-scope', 'global');
12
- styleElement.setAttribute('type', 'text/css');
13
- styleElement.textContent = sheet;
14
- document.head.appendChild(styleElement);
15
- }
@@ -1,39 +0,0 @@
1
- export function isHashInStyleSheets(hash) {
2
- const sheets = Array.from(document.styleSheets);
3
- function checkRule(rule) {
4
- if (rule instanceof CSSStyleRule && rule.selectorText) {
5
- return hasHashInSelector(rule.selectorText, hash);
6
- }
7
- if (rule instanceof CSSMediaRule) {
8
- return Array.from(rule.cssRules).some(checkRule);
9
- }
10
- if (rule instanceof CSSContainerRule) {
11
- return Array.from(rule.cssRules).some(checkRule);
12
- }
13
- if (rule instanceof CSSSupportsRule) {
14
- return Array.from(rule.cssRules).some(checkRule);
15
- }
16
- if ('cssRules' in rule && rule.cssRules) {
17
- return Array.from(rule.cssRules).some(checkRule);
18
- }
19
- return false;
20
- }
21
- function hasHashInSelector(selectorText, hash) {
22
- const selectors = selectorText.split(',').map(s => s.trim());
23
- return selectors.some(selector => {
24
- const classPattern = new RegExp(`\\.${escapeRegExp(hash)}(?![\\w-])`);
25
- return classPattern.test(selector);
26
- });
27
- }
28
- function escapeRegExp(string) {
29
- return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
30
- }
31
- return sheets.some(sheet => {
32
- try {
33
- return Array.from(sheet.cssRules).some(checkRule);
34
- }
35
- catch (_err) {
36
- return false;
37
- }
38
- });
39
- }
@@ -1,12 +0,0 @@
1
- export function transformNestedSelectors(nonFlat) {
2
- const modNonFlat = {};
3
- Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
4
- if (atRule.startsWith(':') || atRule.startsWith('&')) {
5
- modNonFlat[`:not(#\\#)${atRule}`] = nestedObj;
6
- }
7
- else {
8
- modNonFlat[atRule] = nestedObj;
9
- }
10
- });
11
- return modNonFlat;
12
- }
@@ -1,2 +0,0 @@
1
- export declare function injectClientCSS(hash: string, sheet: string): void;
2
- export declare function injectClientQuery(hash: string, sheet: string): void;
@@ -1 +0,0 @@
1
- export declare function injectClientGlobalCSS(sheet: string): void;
@@ -1 +0,0 @@
1
- export declare function isHashInStyleSheets(hash: string): boolean;
@@ -1,2 +0,0 @@
1
- import { CreateStyle } from '../types/main/create.js';
2
- export declare function transformNestedSelectors(nonFlat: CreateStyle): CreateStyle;