zss-engine 0.2.102 → 1.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.
- package/dist/cjs/index.js +1 -8
- package/dist/esm/index.js +0 -3
- package/dist/types/index.d.ts +0 -3
- package/package.json +1 -1
- package/dist/cjs/utils/inject-client-css.js +0 -52
- package/dist/cjs/utils/inject-client-global-css.js +0 -18
- package/dist/cjs/utils/is-hash-in-style-sheets.js +0 -42
- package/dist/esm/utils/inject-client-css.js +0 -48
- package/dist/esm/utils/inject-client-global-css.js +0 -15
- package/dist/esm/utils/is-hash-in-style-sheets.js +0 -39
- package/dist/types/utils/inject-client-css.d.ts +0 -2
- package/dist/types/utils/inject-client-global-css.d.ts +0 -1
- package/dist/types/utils/is-hash-in-style-sheets.d.ts +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
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;
|
|
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; } });
|
|
@@ -23,10 +23,3 @@ Object.defineProperty(exports, "build", { enumerable: true, get: function () { r
|
|
|
23
23
|
var helper_js_2 = require("./utils/helper.js");
|
|
24
24
|
Object.defineProperty(exports, "camelToKebabCase", { enumerable: true, get: function () { return helper_js_2.camelToKebabCase; } });
|
|
25
25
|
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
|
@@ -7,6 +7,3 @@ export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atom
|
|
|
7
7
|
export { overrideLonghand } from './utils/override-longhand.js';
|
|
8
8
|
export { build } from './utils/build.js';
|
|
9
9
|
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';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -12,6 +12,3 @@ export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atom
|
|
|
12
12
|
export { overrideLonghand } from './utils/override-longhand.js';
|
|
13
13
|
export { build } from './utils/build.js';
|
|
14
14
|
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';
|
package/package.json
CHANGED
|
@@ -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,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 +0,0 @@
|
|
|
1
|
-
export declare function injectClientGlobalCSS(sheet: string): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isHashInStyleSheets(hash: string): boolean;
|