zss-engine 0.2.82 → 0.2.84
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 +2 -1
- package/dist/cjs/utils/build.js +1 -1
- package/dist/cjs/utils/inject-client-css.js +40 -39
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/build.js +1 -1
- package/dist/esm/utils/inject-client-css.js +39 -38
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/inject-client-css.d.ts +1 -1
- package/package.json +1 -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.isHashInStyleSheets = exports.injectClientGlobalCSS = exports.injectClientCSS = exports.applyCssValue = exports.camelToKebabCase = exports.build = 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.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; } });
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "camelToKebabCase", { enumerable: true, get: func
|
|
|
21
21
|
Object.defineProperty(exports, "applyCssValue", { enumerable: true, get: function () { return helper_js_2.applyCssValue; } });
|
|
22
22
|
var inject_client_css_js_1 = require("./utils/inject-client-css.js");
|
|
23
23
|
Object.defineProperty(exports, "injectClientCSS", { enumerable: true, get: function () { return inject_client_css_js_1.injectClientCSS; } });
|
|
24
|
+
Object.defineProperty(exports, "injectClientQuery", { enumerable: true, get: function () { return inject_client_css_js_1.injectClientQuery; } });
|
|
24
25
|
var inject_client_global_css_js_1 = require("./utils/inject-client-global-css.js");
|
|
25
26
|
Object.defineProperty(exports, "injectClientGlobalCSS", { enumerable: true, get: function () { return inject_client_global_css_js_1.injectClientGlobalCSS; } });
|
|
26
27
|
var is_hash_in_style_sheets_js_1 = require("./utils/is-hash-in-style-sheets.js");
|
package/dist/cjs/utils/build.js
CHANGED
|
@@ -7,7 +7,7 @@ const build = async (styleSheet, filePath, global) => {
|
|
|
7
7
|
if (!helper_js_1.isServer)
|
|
8
8
|
return;
|
|
9
9
|
const fs = await import('fs');
|
|
10
|
-
const message = global === '--global' ?
|
|
10
|
+
const message = global === '--global' ? `defines💫:\n\n` : `props💫:\n\n`;
|
|
11
11
|
try {
|
|
12
12
|
if (fs.existsSync(filePath)) {
|
|
13
13
|
const cssData = fs.readFileSync(filePath, 'utf-8');
|
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createStyleElement = createStyleElement;
|
|
4
3
|
exports.injectClientCSS = injectClientCSS;
|
|
4
|
+
exports.injectClientQuery = injectClientQuery;
|
|
5
5
|
const index_js_1 = require("../index.js");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
|
17
32
|
}
|
|
18
33
|
function injectClientCSS(hash, sheet) {
|
|
19
34
|
if (index_js_1.isServer)
|
|
20
35
|
return;
|
|
21
|
-
|
|
22
|
-
styleCleanUp();
|
|
23
|
-
});
|
|
24
|
-
hashCache[hash] = hash;
|
|
25
|
-
const styleElement = createStyleElement(hash);
|
|
26
|
-
if (styleElement == null)
|
|
36
|
+
if (styleCache[hash])
|
|
27
37
|
return;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
requestAnimationFrame(() => {
|
|
32
|
-
for (const hash in hashCache) {
|
|
33
|
-
const classElements = document.querySelectorAll(`[class*="${hash}"]`);
|
|
34
|
-
if (classElements.length === 0) {
|
|
35
|
-
removeStyleElement(hashCache[hash]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
38
|
+
styleCache[hash] = sheet;
|
|
39
|
+
const clientElement = createClientStyleElement();
|
|
40
|
+
clientElement.textContent = sheet + (clientElement.textContent || '');
|
|
39
41
|
}
|
|
40
|
-
function
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
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;
|
|
50
51
|
}
|
|
51
52
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -5,6 +5,6 @@ export { transpileAtomic } from './utils/transpile-atomic.js';
|
|
|
5
5
|
export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
|
|
6
6
|
export { build } from './utils/build.js';
|
|
7
7
|
export { camelToKebabCase, applyCssValue } from './utils/helper.js';
|
|
8
|
-
export { injectClientCSS } from './utils/inject-client-css.js';
|
|
8
|
+
export { injectClientCSS, injectClientQuery } from './utils/inject-client-css.js';
|
|
9
9
|
export { injectClientGlobalCSS } from './utils/inject-client-global-css.js';
|
|
10
10
|
export { isHashInStyleSheets } from './utils/is-hash-in-style-sheets.js';
|
package/dist/esm/utils/build.js
CHANGED
|
@@ -4,7 +4,7 @@ export const build = async (styleSheet, filePath, global) => {
|
|
|
4
4
|
if (!isServer)
|
|
5
5
|
return;
|
|
6
6
|
const fs = await import('fs');
|
|
7
|
-
const message = global === '--global' ?
|
|
7
|
+
const message = global === '--global' ? `defines💫:\n\n` : `props💫:\n\n`;
|
|
8
8
|
try {
|
|
9
9
|
if (fs.existsSync(filePath)) {
|
|
10
10
|
const cssData = fs.readFileSync(filePath, 'utf-8');
|
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
import { isServer } from '../index.js';
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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;
|
|
13
28
|
}
|
|
14
29
|
export function injectClientCSS(hash, sheet) {
|
|
15
30
|
if (isServer)
|
|
16
31
|
return;
|
|
17
|
-
|
|
18
|
-
styleCleanUp();
|
|
19
|
-
});
|
|
20
|
-
hashCache[hash] = hash;
|
|
21
|
-
const styleElement = createStyleElement(hash);
|
|
22
|
-
if (styleElement == null)
|
|
32
|
+
if (styleCache[hash])
|
|
23
33
|
return;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
requestAnimationFrame(() => {
|
|
28
|
-
for (const hash in hashCache) {
|
|
29
|
-
const classElements = document.querySelectorAll(`[class*="${hash}"]`);
|
|
30
|
-
if (classElements.length === 0) {
|
|
31
|
-
removeStyleElement(hashCache[hash]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
34
|
+
styleCache[hash] = sheet;
|
|
35
|
+
const clientElement = createClientStyleElement();
|
|
36
|
+
clientElement.textContent = sheet + (clientElement.textContent || '');
|
|
35
37
|
}
|
|
36
|
-
function
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
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;
|
|
46
47
|
}
|
|
47
48
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export { transpileAtomic } from './utils/transpile-atomic.js';
|
|
|
9
9
|
export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
|
|
10
10
|
export { build } from './utils/build.js';
|
|
11
11
|
export { camelToKebabCase, applyCssValue } from './utils/helper.js';
|
|
12
|
-
export { injectClientCSS } from './utils/inject-client-css.js';
|
|
12
|
+
export { injectClientCSS, injectClientQuery } from './utils/inject-client-css.js';
|
|
13
13
|
export { injectClientGlobalCSS } from './utils/inject-client-global-css.js';
|
|
14
14
|
export { isHashInStyleSheets } from './utils/is-hash-in-style-sheets.js';
|