@plumeria/core 0.9.2 → 0.9.3
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/css.js +135 -0
- package/dist/css.mjs +58 -0
- package/dist/index.d.ts +295 -0
- package/dist/index.js +116 -0
- package/dist/index.mjs +113 -0
- package/dist/processors/css.d.ts +12 -0
- package/dist/processors/css.js +30 -0
- package/dist/processors/css.mjs +3 -0
- package/package.json +12 -13
- package/dist/cjs/css.js +0 -95
- package/dist/cjs/cx.js +0 -22
- package/dist/cjs/index.js +0 -12
- package/dist/cjs/processors/css.js +0 -64
- package/dist/cjs/rx.js +0 -7
- package/dist/esm/css.js +0 -93
- package/dist/esm/cx.js +0 -20
- package/dist/esm/index.js +0 -3
- package/dist/esm/processors/css.js +0 -59
- package/dist/esm/rx.js +0 -5
- package/types/css.d.ts +0 -279
- package/types/cx.d.ts +0 -2
- package/types/index.d.ts +0 -4
- package/types/processors/css.d.ts +0 -10
- package/types/rx.d.ts +0 -9
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { globalPromise_1, globalPromise_2, initPromise_1, initPromise_2, resolvePromise_1, resolvePromise_2 } from "./css.mjs";
|
|
2
|
+
import { camelToKebabCase, genBase36Hash, injectClientCSS, injectClientGlobalCSS, injectServerCSS, isDevAndTest, isServer, transpiler } from "zss-engine";
|
|
3
|
+
import { color, container, media, pseudo } from "zss-utils";
|
|
4
|
+
|
|
5
|
+
//#region src/css.ts
|
|
6
|
+
function create(object) {
|
|
7
|
+
const base36Hash = genBase36Hash(object, 6);
|
|
8
|
+
const { styleSheet } = transpiler(object, base36Hash);
|
|
9
|
+
const injectCSS = isServer ? injectServerCSS : injectClientCSS;
|
|
10
|
+
if (typeof globalPromise_1 === "undefined") initPromise_1();
|
|
11
|
+
resolvePromise_1(styleSheet);
|
|
12
|
+
Object.keys(object).forEach((key) => {
|
|
13
|
+
Object.defineProperty(object, key, { get: () => {
|
|
14
|
+
const className = key + "_" + base36Hash;
|
|
15
|
+
if (isDevAndTest) injectCSS(base36Hash, styleSheet);
|
|
16
|
+
return className;
|
|
17
|
+
} });
|
|
18
|
+
});
|
|
19
|
+
return Object.freeze(object);
|
|
20
|
+
}
|
|
21
|
+
function global(object) {
|
|
22
|
+
const base36Hash = genBase36Hash(object, 8);
|
|
23
|
+
const { styleSheet } = transpiler(object, void 0, "--global");
|
|
24
|
+
if (typeof globalPromise_2 === "undefined") initPromise_2();
|
|
25
|
+
resolvePromise_2(styleSheet);
|
|
26
|
+
if (isDevAndTest) isServer ? injectServerCSS(base36Hash, styleSheet) : injectClientGlobalCSS(styleSheet);
|
|
27
|
+
}
|
|
28
|
+
const defineVars = (object) => {
|
|
29
|
+
const styles = { ":root": {} };
|
|
30
|
+
const result = {};
|
|
31
|
+
Object.entries(object).forEach(([key, value]) => {
|
|
32
|
+
const kebabKey = camelToKebabCase(key);
|
|
33
|
+
result[key] = `var(--${kebabKey})`;
|
|
34
|
+
styles[":root"][`--${key}`] = value;
|
|
35
|
+
});
|
|
36
|
+
global(styles);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
const defineTheme = (object) => {
|
|
40
|
+
const styles = {};
|
|
41
|
+
const result = {};
|
|
42
|
+
Object.entries(object).forEach(([key, value]) => {
|
|
43
|
+
const kebabKey = camelToKebabCase(key);
|
|
44
|
+
result[key] = `var(--${kebabKey})`;
|
|
45
|
+
Object.entries(value).forEach(([subKey, subValue]) => {
|
|
46
|
+
if (subKey.startsWith("@media")) {
|
|
47
|
+
styles[":root"] ||= {};
|
|
48
|
+
styles[":root"][subKey] ||= {};
|
|
49
|
+
styles[":root"][subKey][`--${key}`] = subValue;
|
|
50
|
+
} else {
|
|
51
|
+
const themeSelector = subKey === "default" ? ":root" : `:root[data-theme="${subKey}"]`;
|
|
52
|
+
styles[themeSelector] ||= {};
|
|
53
|
+
styles[themeSelector][`--${key}`] = subValue;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
global(styles);
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
const keyframes = (object) => {
|
|
61
|
+
const prefix = genBase36Hash(object, 8);
|
|
62
|
+
global({ [`@keyframes ${prefix}`]: object });
|
|
63
|
+
return prefix;
|
|
64
|
+
};
|
|
65
|
+
var css = class {
|
|
66
|
+
static create(object) {
|
|
67
|
+
return create(object);
|
|
68
|
+
}
|
|
69
|
+
static global(object) {
|
|
70
|
+
return global(object);
|
|
71
|
+
}
|
|
72
|
+
static defineVars(object) {
|
|
73
|
+
return defineVars(object);
|
|
74
|
+
}
|
|
75
|
+
static defineTheme(object) {
|
|
76
|
+
return defineTheme(object);
|
|
77
|
+
}
|
|
78
|
+
static keyframes(object) {
|
|
79
|
+
return keyframes(object);
|
|
80
|
+
}
|
|
81
|
+
static media = media;
|
|
82
|
+
static container = container;
|
|
83
|
+
static pseudo = pseudo;
|
|
84
|
+
static color = color;
|
|
85
|
+
};
|
|
86
|
+
var css_default = css;
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/cx.ts
|
|
90
|
+
const cx = (...strings) => {
|
|
91
|
+
let result = "";
|
|
92
|
+
let isFirst = true;
|
|
93
|
+
strings.filter(Boolean).forEach((str) => {
|
|
94
|
+
if (str?.toString().startsWith(":")) result += str.toString();
|
|
95
|
+
else if (typeof str === "string") if (isFirst) {
|
|
96
|
+
result += str;
|
|
97
|
+
isFirst = false;
|
|
98
|
+
} else result += ` ${str}`;
|
|
99
|
+
});
|
|
100
|
+
return result;
|
|
101
|
+
};
|
|
102
|
+
var cx_default = cx;
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/rx.ts
|
|
106
|
+
const rx = (className, varSet) => ({
|
|
107
|
+
className,
|
|
108
|
+
style: Object.fromEntries(Object.entries(varSet).map(([key, value]) => [key, value]))
|
|
109
|
+
});
|
|
110
|
+
var rx_default = rx;
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
export { css_default as css, cx_default as cx, rx_default as rx };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/processors/css.d.ts
|
|
2
|
+
declare let resolvePromise_1: (value: string) => void;
|
|
3
|
+
declare let globalPromise_1: Promise<string>;
|
|
4
|
+
declare function initPromise_1(): void;
|
|
5
|
+
declare function buildCreate(filePath: string): Promise<void>;
|
|
6
|
+
declare let resolvePromise_2: (value: string) => void;
|
|
7
|
+
declare let globalPromise_2: Promise<string>;
|
|
8
|
+
declare function initPromise_2(): void;
|
|
9
|
+
declare function buildGlobal(filePath: string): Promise<void>;
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { buildCreate, buildGlobal, globalPromise_1, globalPromise_2, initPromise_1, initPromise_2, resolvePromise_1, resolvePromise_2 };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const require_css = require('../css.js');
|
|
2
|
+
|
|
3
|
+
exports.buildCreate = require_css.buildCreate;
|
|
4
|
+
exports.buildGlobal = require_css.buildGlobal;
|
|
5
|
+
Object.defineProperty(exports, 'globalPromise_1', {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function () {
|
|
8
|
+
return require_css.globalPromise_1;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, 'globalPromise_2', {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return require_css.globalPromise_2;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
exports.initPromise_1 = require_css.initPromise_1;
|
|
18
|
+
exports.initPromise_2 = require_css.initPromise_2;
|
|
19
|
+
Object.defineProperty(exports, 'resolvePromise_1', {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return require_css.resolvePromise_1;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, 'resolvePromise_2', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return require_css.resolvePromise_2;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { buildCreate, buildGlobal, globalPromise_1, globalPromise_2, initPromise_1, initPromise_2, resolvePromise_1, resolvePromise_2 } from "../css.mjs";
|
|
2
|
+
|
|
3
|
+
export { buildCreate, buildGlobal, globalPromise_1, globalPromise_2, initPromise_1, initPromise_2, resolvePromise_1, resolvePromise_2 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "Zero-runtime CSS in JS library in TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
@@ -21,33 +21,32 @@
|
|
|
21
21
|
"./package.json": "./package.json",
|
|
22
22
|
"./stylesheet.css": "./stylesheet.css",
|
|
23
23
|
".": {
|
|
24
|
-
"types": "./
|
|
25
|
-
"import": "./dist/
|
|
26
|
-
"default": "./dist/
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.mjs",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
27
|
},
|
|
28
28
|
"./processors": {
|
|
29
|
-
"types": "./
|
|
30
|
-
"import": "./dist/
|
|
31
|
-
"default": "./dist/
|
|
29
|
+
"types": "./dist/processors/css.d.ts",
|
|
30
|
+
"import": "./dist/procesmsors/css.mjs",
|
|
31
|
+
"default": "./dist/processors/css.js"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
"main": "dist/
|
|
35
|
-
"module": "dist/
|
|
36
|
-
"types": "
|
|
34
|
+
"main": "dist/index.js",
|
|
35
|
+
"module": "dist/index.mjs",
|
|
36
|
+
"types": "dist/index.d.ts",
|
|
37
37
|
"files": [
|
|
38
38
|
"dist/",
|
|
39
|
-
"types/",
|
|
40
39
|
"stylesheet.css"
|
|
41
40
|
],
|
|
42
41
|
"dependencies": {
|
|
43
|
-
"zss-engine": "0.2.
|
|
42
|
+
"zss-engine": "0.2.35",
|
|
44
43
|
"zss-utils": "0.2.2"
|
|
45
44
|
},
|
|
46
45
|
"publishConfig": {
|
|
47
46
|
"access": "public"
|
|
48
47
|
},
|
|
49
48
|
"scripts": {
|
|
50
|
-
"build": "
|
|
49
|
+
"build": "tsdown",
|
|
51
50
|
"cjs": "tsc --project tsconfig.cjs.json",
|
|
52
51
|
"esm": "tsc --project tsconfig.esm.json"
|
|
53
52
|
}
|
package/dist/cjs/css.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const zss_engine_1 = require("zss-engine");
|
|
4
|
-
const css_js_1 = require("./processors/css.js");
|
|
5
|
-
const zss_utils_1 = require("zss-utils");
|
|
6
|
-
function create(object) {
|
|
7
|
-
const base36Hash = (0, zss_engine_1.genBase36Hash)(object, 6);
|
|
8
|
-
const { styleSheet } = (0, zss_engine_1.transpiler)(object, base36Hash);
|
|
9
|
-
const injectCSS = zss_engine_1.isServer ? zss_engine_1.injectServerCSS : zss_engine_1.injectClientCSS;
|
|
10
|
-
if (typeof css_js_1.globalPromise_1 === 'undefined')
|
|
11
|
-
(0, css_js_1.initPromise_1)();
|
|
12
|
-
(0, css_js_1.resolvePromise_1)(styleSheet);
|
|
13
|
-
Object.keys(object).forEach((key) => {
|
|
14
|
-
Object.defineProperty(object, key, {
|
|
15
|
-
get: () => {
|
|
16
|
-
const className = key + '_' + base36Hash;
|
|
17
|
-
if (zss_engine_1.isDevAndTest)
|
|
18
|
-
injectCSS(base36Hash, styleSheet);
|
|
19
|
-
return className;
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
return Object.freeze(object);
|
|
24
|
-
}
|
|
25
|
-
function global(object) {
|
|
26
|
-
const base36Hash = (0, zss_engine_1.genBase36Hash)(object, 8);
|
|
27
|
-
const { styleSheet } = (0, zss_engine_1.transpiler)(object, undefined, '--global');
|
|
28
|
-
if (typeof css_js_1.globalPromise_2 === 'undefined')
|
|
29
|
-
(0, css_js_1.initPromise_2)();
|
|
30
|
-
(0, css_js_1.resolvePromise_2)(styleSheet);
|
|
31
|
-
if (zss_engine_1.isDevAndTest)
|
|
32
|
-
zss_engine_1.isServer
|
|
33
|
-
? (0, zss_engine_1.injectServerCSS)(base36Hash, styleSheet)
|
|
34
|
-
: (0, zss_engine_1.injectClientGlobalCSS)(styleSheet);
|
|
35
|
-
}
|
|
36
|
-
const defineVars = (object) => {
|
|
37
|
-
const styles = {
|
|
38
|
-
':root': {},
|
|
39
|
-
};
|
|
40
|
-
const result = {};
|
|
41
|
-
Object.entries(object).forEach(([key, value]) => {
|
|
42
|
-
result[key] = `var(--${key})`;
|
|
43
|
-
styles[':root'][`--${key}`] = value;
|
|
44
|
-
});
|
|
45
|
-
global(styles);
|
|
46
|
-
return result;
|
|
47
|
-
};
|
|
48
|
-
const defineTheme = (object) => {
|
|
49
|
-
const styles = {};
|
|
50
|
-
const result = {};
|
|
51
|
-
Object.entries(object).forEach(([key, value]) => {
|
|
52
|
-
result[key] = `var(--${key})`;
|
|
53
|
-
Object.entries(value).forEach(([subKey, subValue]) => {
|
|
54
|
-
if (subKey.startsWith('@media')) {
|
|
55
|
-
styles[':root'] ||= {};
|
|
56
|
-
styles[':root'][subKey] ||= {};
|
|
57
|
-
styles[':root'][subKey][`--${key}`] = subValue;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const themeSelector = subKey === 'default' ? ':root' : `:root[data-theme="${subKey}"]`;
|
|
61
|
-
styles[themeSelector] ||= {};
|
|
62
|
-
styles[themeSelector][`--${key}`] = subValue;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
global(styles);
|
|
67
|
-
return result;
|
|
68
|
-
};
|
|
69
|
-
const keyframes = (object) => {
|
|
70
|
-
const prefix = (0, zss_engine_1.genBase36Hash)(object, 8);
|
|
71
|
-
global({ [`@keyframes ${prefix}`]: object });
|
|
72
|
-
return prefix;
|
|
73
|
-
};
|
|
74
|
-
class css {
|
|
75
|
-
static create(object) {
|
|
76
|
-
return create(object);
|
|
77
|
-
}
|
|
78
|
-
static global(object) {
|
|
79
|
-
return global(object);
|
|
80
|
-
}
|
|
81
|
-
static defineVars(object) {
|
|
82
|
-
return defineVars(object);
|
|
83
|
-
}
|
|
84
|
-
static defineTheme(object) {
|
|
85
|
-
return defineTheme(object);
|
|
86
|
-
}
|
|
87
|
-
static keyframes(object) {
|
|
88
|
-
return keyframes(object);
|
|
89
|
-
}
|
|
90
|
-
static media = zss_utils_1.media;
|
|
91
|
-
static container = zss_utils_1.container;
|
|
92
|
-
static pseudo = zss_utils_1.pseudo;
|
|
93
|
-
static color = zss_utils_1.color;
|
|
94
|
-
}
|
|
95
|
-
exports.default = css;
|
package/dist/cjs/cx.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const cx = (...strings) => {
|
|
4
|
-
let result = '';
|
|
5
|
-
let isFirst = true;
|
|
6
|
-
strings.filter(Boolean).forEach((str) => {
|
|
7
|
-
if (str?.toString().startsWith(':')) {
|
|
8
|
-
result += str.toString();
|
|
9
|
-
}
|
|
10
|
-
else if (typeof str === 'string') {
|
|
11
|
-
if (isFirst) {
|
|
12
|
-
result += str;
|
|
13
|
-
isFirst = false;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
result += ` ${str}`;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
return result;
|
|
21
|
-
};
|
|
22
|
-
exports.default = cx;
|
package/dist/cjs/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.rx = exports.cx = exports.css = void 0;
|
|
7
|
-
var css_1 = require("./css");
|
|
8
|
-
Object.defineProperty(exports, "css", { enumerable: true, get: function () { return __importDefault(css_1).default; } });
|
|
9
|
-
var cx_1 = require("./cx");
|
|
10
|
-
Object.defineProperty(exports, "cx", { enumerable: true, get: function () { return __importDefault(cx_1).default; } });
|
|
11
|
-
var rx_1 = require("./rx");
|
|
12
|
-
Object.defineProperty(exports, "rx", { enumerable: true, get: function () { return __importDefault(rx_1).default; } });
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.globalPromise_2 = exports.resolvePromise_2 = exports.globalPromise_1 = exports.resolvePromise_1 = void 0;
|
|
4
|
-
exports.buildCreate = buildCreate;
|
|
5
|
-
exports.initPromise_1 = initPromise_1;
|
|
6
|
-
exports.buildGlobal = buildGlobal;
|
|
7
|
-
exports.initPromise_2 = initPromise_2;
|
|
8
|
-
const zss_engine_1 = require("zss-engine");
|
|
9
|
-
let resolvePromise_1;
|
|
10
|
-
let globalPromise_1;
|
|
11
|
-
const sheetQueue_1 = [];
|
|
12
|
-
let isProcessing_1 = false;
|
|
13
|
-
function initPromise_1() {
|
|
14
|
-
exports.globalPromise_1 = globalPromise_1 = new Promise((resolve) => {
|
|
15
|
-
exports.resolvePromise_1 = resolvePromise_1 = (value) => {
|
|
16
|
-
sheetQueue_1.push(value);
|
|
17
|
-
resolve(value);
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
async function processQueue_1(filePath) {
|
|
22
|
-
while (sheetQueue_1.length > 0) {
|
|
23
|
-
const styleSheet = sheetQueue_1.shift();
|
|
24
|
-
if (!zss_engine_1.isDevelopment && styleSheet)
|
|
25
|
-
(0, zss_engine_1.build)(styleSheet, filePath);
|
|
26
|
-
}
|
|
27
|
-
isProcessing_1 = false;
|
|
28
|
-
}
|
|
29
|
-
async function buildCreate(filePath) {
|
|
30
|
-
if (typeof globalPromise_1 === 'undefined')
|
|
31
|
-
initPromise_1();
|
|
32
|
-
if (!isProcessing_1 && sheetQueue_1.length > 0) {
|
|
33
|
-
isProcessing_1 = true;
|
|
34
|
-
processQueue_1(filePath);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
let resolvePromise_2;
|
|
38
|
-
let globalPromise_2;
|
|
39
|
-
const sheetQueue_2 = [];
|
|
40
|
-
let isProcessing_2 = false;
|
|
41
|
-
function initPromise_2() {
|
|
42
|
-
exports.globalPromise_2 = globalPromise_2 = new Promise((resolve) => {
|
|
43
|
-
exports.resolvePromise_2 = resolvePromise_2 = (value) => {
|
|
44
|
-
sheetQueue_2.push(value);
|
|
45
|
-
resolve(value);
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
async function processQueue_2(filePath) {
|
|
50
|
-
while (sheetQueue_2.length > 0) {
|
|
51
|
-
const styleSheet = sheetQueue_2.shift();
|
|
52
|
-
if (!zss_engine_1.isDevelopment && styleSheet)
|
|
53
|
-
(0, zss_engine_1.build)(styleSheet, filePath, '--global');
|
|
54
|
-
}
|
|
55
|
-
isProcessing_2 = false;
|
|
56
|
-
}
|
|
57
|
-
async function buildGlobal(filePath) {
|
|
58
|
-
if (typeof globalPromise_2 === 'undefined')
|
|
59
|
-
initPromise_2();
|
|
60
|
-
if (!isProcessing_2 && sheetQueue_2.length > 0) {
|
|
61
|
-
isProcessing_2 = true;
|
|
62
|
-
processQueue_2(filePath);
|
|
63
|
-
}
|
|
64
|
-
}
|
package/dist/cjs/rx.js
DELETED
package/dist/esm/css.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { transpiler, isServer, isDevAndTest, injectServerCSS, injectClientCSS, injectClientGlobalCSS, genBase36Hash, } from 'zss-engine';
|
|
2
|
-
import { initPromise_1, globalPromise_1, resolvePromise_1, initPromise_2, globalPromise_2, resolvePromise_2, } from './processors/css.js';
|
|
3
|
-
import { media, container, pseudo, color } from 'zss-utils';
|
|
4
|
-
function create(object) {
|
|
5
|
-
const base36Hash = genBase36Hash(object, 6);
|
|
6
|
-
const { styleSheet } = transpiler(object, base36Hash);
|
|
7
|
-
const injectCSS = isServer ? injectServerCSS : injectClientCSS;
|
|
8
|
-
if (typeof globalPromise_1 === 'undefined')
|
|
9
|
-
initPromise_1();
|
|
10
|
-
resolvePromise_1(styleSheet);
|
|
11
|
-
Object.keys(object).forEach((key) => {
|
|
12
|
-
Object.defineProperty(object, key, {
|
|
13
|
-
get: () => {
|
|
14
|
-
const className = key + '_' + base36Hash;
|
|
15
|
-
if (isDevAndTest)
|
|
16
|
-
injectCSS(base36Hash, styleSheet);
|
|
17
|
-
return className;
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
return Object.freeze(object);
|
|
22
|
-
}
|
|
23
|
-
function global(object) {
|
|
24
|
-
const base36Hash = genBase36Hash(object, 8);
|
|
25
|
-
const { styleSheet } = transpiler(object, undefined, '--global');
|
|
26
|
-
if (typeof globalPromise_2 === 'undefined')
|
|
27
|
-
initPromise_2();
|
|
28
|
-
resolvePromise_2(styleSheet);
|
|
29
|
-
if (isDevAndTest)
|
|
30
|
-
isServer
|
|
31
|
-
? injectServerCSS(base36Hash, styleSheet)
|
|
32
|
-
: injectClientGlobalCSS(styleSheet);
|
|
33
|
-
}
|
|
34
|
-
const defineVars = (object) => {
|
|
35
|
-
const styles = {
|
|
36
|
-
':root': {},
|
|
37
|
-
};
|
|
38
|
-
const result = {};
|
|
39
|
-
Object.entries(object).forEach(([key, value]) => {
|
|
40
|
-
result[key] = `var(--${key})`;
|
|
41
|
-
styles[':root'][`--${key}`] = value;
|
|
42
|
-
});
|
|
43
|
-
global(styles);
|
|
44
|
-
return result;
|
|
45
|
-
};
|
|
46
|
-
const defineTheme = (object) => {
|
|
47
|
-
const styles = {};
|
|
48
|
-
const result = {};
|
|
49
|
-
Object.entries(object).forEach(([key, value]) => {
|
|
50
|
-
result[key] = `var(--${key})`;
|
|
51
|
-
Object.entries(value).forEach(([subKey, subValue]) => {
|
|
52
|
-
if (subKey.startsWith('@media')) {
|
|
53
|
-
styles[':root'] ||= {};
|
|
54
|
-
styles[':root'][subKey] ||= {};
|
|
55
|
-
styles[':root'][subKey][`--${key}`] = subValue;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
const themeSelector = subKey === 'default' ? ':root' : `:root[data-theme="${subKey}"]`;
|
|
59
|
-
styles[themeSelector] ||= {};
|
|
60
|
-
styles[themeSelector][`--${key}`] = subValue;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
global(styles);
|
|
65
|
-
return result;
|
|
66
|
-
};
|
|
67
|
-
const keyframes = (object) => {
|
|
68
|
-
const prefix = genBase36Hash(object, 8);
|
|
69
|
-
global({ [`@keyframes ${prefix}`]: object });
|
|
70
|
-
return prefix;
|
|
71
|
-
};
|
|
72
|
-
class css {
|
|
73
|
-
static create(object) {
|
|
74
|
-
return create(object);
|
|
75
|
-
}
|
|
76
|
-
static global(object) {
|
|
77
|
-
return global(object);
|
|
78
|
-
}
|
|
79
|
-
static defineVars(object) {
|
|
80
|
-
return defineVars(object);
|
|
81
|
-
}
|
|
82
|
-
static defineTheme(object) {
|
|
83
|
-
return defineTheme(object);
|
|
84
|
-
}
|
|
85
|
-
static keyframes(object) {
|
|
86
|
-
return keyframes(object);
|
|
87
|
-
}
|
|
88
|
-
static media = media;
|
|
89
|
-
static container = container;
|
|
90
|
-
static pseudo = pseudo;
|
|
91
|
-
static color = color;
|
|
92
|
-
}
|
|
93
|
-
export default css;
|
package/dist/esm/cx.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const cx = (...strings) => {
|
|
2
|
-
let result = '';
|
|
3
|
-
let isFirst = true;
|
|
4
|
-
strings.filter(Boolean).forEach((str) => {
|
|
5
|
-
if (str?.toString().startsWith(':')) {
|
|
6
|
-
result += str.toString();
|
|
7
|
-
}
|
|
8
|
-
else if (typeof str === 'string') {
|
|
9
|
-
if (isFirst) {
|
|
10
|
-
result += str;
|
|
11
|
-
isFirst = false;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
result += ` ${str}`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
return result;
|
|
19
|
-
};
|
|
20
|
-
export default cx;
|
package/dist/esm/index.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { build, isDevelopment } from 'zss-engine';
|
|
2
|
-
let resolvePromise_1;
|
|
3
|
-
let globalPromise_1;
|
|
4
|
-
const sheetQueue_1 = [];
|
|
5
|
-
let isProcessing_1 = false;
|
|
6
|
-
function initPromise_1() {
|
|
7
|
-
globalPromise_1 = new Promise((resolve) => {
|
|
8
|
-
resolvePromise_1 = (value) => {
|
|
9
|
-
sheetQueue_1.push(value);
|
|
10
|
-
resolve(value);
|
|
11
|
-
};
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
async function processQueue_1(filePath) {
|
|
15
|
-
while (sheetQueue_1.length > 0) {
|
|
16
|
-
const styleSheet = sheetQueue_1.shift();
|
|
17
|
-
if (!isDevelopment && styleSheet)
|
|
18
|
-
build(styleSheet, filePath);
|
|
19
|
-
}
|
|
20
|
-
isProcessing_1 = false;
|
|
21
|
-
}
|
|
22
|
-
export async function buildCreate(filePath) {
|
|
23
|
-
if (typeof globalPromise_1 === 'undefined')
|
|
24
|
-
initPromise_1();
|
|
25
|
-
if (!isProcessing_1 && sheetQueue_1.length > 0) {
|
|
26
|
-
isProcessing_1 = true;
|
|
27
|
-
processQueue_1(filePath);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export { resolvePromise_1, globalPromise_1, initPromise_1 };
|
|
31
|
-
let resolvePromise_2;
|
|
32
|
-
let globalPromise_2;
|
|
33
|
-
const sheetQueue_2 = [];
|
|
34
|
-
let isProcessing_2 = false;
|
|
35
|
-
function initPromise_2() {
|
|
36
|
-
globalPromise_2 = new Promise((resolve) => {
|
|
37
|
-
resolvePromise_2 = (value) => {
|
|
38
|
-
sheetQueue_2.push(value);
|
|
39
|
-
resolve(value);
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
async function processQueue_2(filePath) {
|
|
44
|
-
while (sheetQueue_2.length > 0) {
|
|
45
|
-
const styleSheet = sheetQueue_2.shift();
|
|
46
|
-
if (!isDevelopment && styleSheet)
|
|
47
|
-
build(styleSheet, filePath, '--global');
|
|
48
|
-
}
|
|
49
|
-
isProcessing_2 = false;
|
|
50
|
-
}
|
|
51
|
-
export async function buildGlobal(filePath) {
|
|
52
|
-
if (typeof globalPromise_2 === 'undefined')
|
|
53
|
-
initPromise_2();
|
|
54
|
-
if (!isProcessing_2 && sheetQueue_2.length > 0) {
|
|
55
|
-
isProcessing_2 = true;
|
|
56
|
-
processQueue_2(filePath);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export { resolvePromise_2, globalPromise_2, initPromise_2 };
|